[
  {
    "path": ".gitignore",
    "content": "node_modules\npackage-lock.json\n\n/.sass-cache/\n"
  },
  {
    "path": ".project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>webgl-shader-examples</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t</buildSpec>\n\t<natures>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": "Gruntfile.js",
    "content": "module.exports = function(grunt) {\n\n\t/*\n\t * Defines the grunt-replace parameters that will fill the html template file for a shader example\n\t */\n\tfunction replaceParametersForExample(name, htmlFile, jsFile, vertexShader, fragmentShader) {\n\t\tvar parameters = {\n\t\t\tfiles : [ {\n\t\t\t\tsrc : 'html/' + htmlFile,\n\t\t\t\tdest : 'WebContent/' + name + '-example.html'\n\t\t\t} ],\n\t\t\toptions : {\n\t\t\t\tpatterns : [ {\n\t\t\t\t\tmatch : 'name',\n\t\t\t\t\treplacement : name\n\t\t\t\t}, {\n\t\t\t\t\tmatch : 'jsFile',\n\t\t\t\t\treplacement : '/js/' + jsFile\n\t\t\t\t}, {\n\t\t\t\t\tmatch : 'vertexShaderFile',\n\t\t\t\t\treplacement : '/shaders/' + vertexShader\n\t\t\t\t}, {\n\t\t\t\t\tmatch : 'fragmentShaderFile',\n\t\t\t\t\treplacement : '/shaders/' + fragmentShader\n\t\t\t\t}, {\n\t\t\t\t\tmatch : 'vertexShaderContent',\n\t\t\t\t\treplacement : '<%= grunt.file.read(\"WebContent/shaders/' + vertexShader + '\") %>'\n\t\t\t\t}, {\n\t\t\t\t\tmatch : 'fragmentShaderContent',\n\t\t\t\t\treplacement : '<%= grunt.file.read(\"WebContent/shaders/' + fragmentShader + '\") %>'\n\t\t\t\t} ]\n\t\t\t}\n\t\t};\n\n\t\treturn parameters;\n\t}\n\n\t/*\n\t * Defines the grunt-replace parameters that will fill the html template file for a simulation shader example\n\t */\n\tfunction replaceParametersForSimExample(name, htmlFile, jsFile, positionShader, velocityShader, vertexShader, fragmentShader) {\n\t\tvar parameters = {\n\t\t\tfiles : [ {\n\t\t\t\tsrc : 'html/' + htmlFile,\n\t\t\t\tdest : 'WebContent/' + name + '-example.html'\n\t\t\t} ],\n\t\t\toptions : {\n\t\t\t\tpatterns : [ {\n\t\t\t\t\tmatch : 'name',\n\t\t\t\t\treplacement : name\n\t\t\t\t}, {\n\t\t\t\t\tmatch : 'jsFile',\n\t\t\t\t\treplacement : '/js/' + jsFile\n\t\t\t\t}, {\n\t\t\t\t\tmatch : 'positionShaderFile',\n\t\t\t\t\treplacement : '/shaders/' + positionShader\n\t\t\t\t}, {\n\t\t\t\t\tmatch : 'velocityShaderFile',\n\t\t\t\t\treplacement : '/shaders/' + velocityShader\n\t\t\t\t}, {\n\t\t\t\t\tmatch : 'vertexShaderFile',\n\t\t\t\t\treplacement : '/shaders/' + vertexShader\n\t\t\t\t}, {\n\t\t\t\t\tmatch : 'fragmentShaderFile',\n\t\t\t\t\treplacement : '/shaders/' + fragmentShader\n\t\t\t\t}, {\n\t\t\t\t\tmatch : 'positionShaderContent',\n\t\t\t\t\treplacement : '<%= grunt.file.read(\"WebContent/shaders/' + positionShader + '\") %>'\n\t\t\t\t}, {\n\t\t\t\t\tmatch : 'velocityShaderContent',\n\t\t\t\t\treplacement : '<%= grunt.file.read(\"WebContent/shaders/' + velocityShader + '\") %>'\n\t\t\t\t}, {\n\t\t\t\t\tmatch : 'vertexShaderContent',\n\t\t\t\t\treplacement : '<%= grunt.file.read(\"WebContent/shaders/' + vertexShader + '\") %>'\n\t\t\t\t}, {\n\t\t\t\t\tmatch : 'fragmentShaderContent',\n\t\t\t\t\treplacement : '<%= grunt.file.read(\"WebContent/shaders/' + fragmentShader + '\") %>'\n\t\t\t\t} ]\n\t\t\t}\n\t\t};\n\n\t\treturn parameters;\n\t}\n\n\t// Project configuration.\n\tgrunt.initConfig({\n\t\tpkg : grunt.file.readJSON('package.json'),\n\n\t\t// grunt-contrib-clean\n\t\tclean : {\n\t\t\tbuild : {\n\t\t\t\tsrc : [ 'WebContent/*.html', 'WebContent/shaders/*.glsl' ]\n\t\t\t\t//src : [ 'WebContent/*.html', 'WebContent/shaders/frag-mountains.glsl' ]\n\t\t\t}\n\t\t},\n\n\t\t// grunt-contrib-copy\n\t\tcopy : {\n\t\t\tindex : {\n\t\t\t\tsrc : 'html/index.html',\n\t\t\t\tdest : 'WebContent/index.html'\n\t\t\t},\n\t\t\tabout : {\n\t\t\t\tsrc : 'html/about.html',\n\t\t\t\tdest : 'WebContent/about.html'\n\t\t\t}\n\t\t},\n\n\t\t// grunt-exec\n\t\texec : {\n\t\t\tbuild_shaders : {\n\t\t\t\tcwd : 'shaders',\n\t\t\t\tcmd : 'for filename in *.glsl; do glslify \"${filename}\" -o ../WebContent/shaders/\"${filename}\"; done'\n\t\t\t\t//cmd : 'glslify frag-mountains.glsl -o ../WebContent/shaders/frag-mountains.glsl'\n\t\t\t}\n\t\t},\n\n\t\t// grunt-replace\n\t\treplace : {\n\t\t\trandom : replaceParametersForExample('random', 'template-example-2d.html', 'shader-example-2d.js', 'vert-2d.glsl', 'frag-random.glsl'),\n\t\t\tnoise : replaceParametersForExample('noise', 'template-example-2d.html', 'shader-example-2d.js', 'vert-2d.glsl', 'frag-noise.glsl'),\n\t\t\train : replaceParametersForExample('rain', 'template-example-2d.html', 'shader-example-2d.js', 'vert-2d.glsl', 'frag-rain.glsl'),\n\t\t\ttile : replaceParametersForExample('tile', 'template-example-2d.html', 'shader-example-2d.js', 'vert-2d.glsl', 'frag-tile.glsl'),\n\t\t\twave : replaceParametersForExample('wave', 'template-example-3d.html', 'shader-example-3d.js', 'vert-3d.glsl', 'frag-wave.glsl'),\n\t\t\tpencil : replaceParametersForExample('pencil', 'template-example-3d.html', 'shader-example-3d.js', 'vert-3d.glsl', 'frag-pencil.glsl'),\n\t\t\tdots : replaceParametersForExample('dots', 'template-example-3d.html', 'shader-example-3d.js', 'vert-3d.glsl', 'frag-dots.glsl'),\n\t\t\ttoon : replaceParametersForExample('toon', 'template-example-3d.html', 'shader-example-3d.js', 'vert-3d.glsl', 'frag-toon.glsl'),\n\t\t\tstripes : replaceParametersForExample('stripes', 'template-example-3d.html', 'shader-example-3d.js', 'vert-3d.glsl', 'frag-stripes.glsl'),\n\t\t\tedge : replaceParametersForExample('edge', 'template-example-2d.html', 'shader-example-filters.js', 'vert-filters.glsl', 'frag-edge.glsl'),\n\t\t\tblur : replaceParametersForExample('blur', 'template-example-2d.html', 'shader-example-filters.js', 'vert-filters.glsl', 'frag-blur.glsl'),\n\t\t\tpixels : replaceParametersForExample('pixels', 'template-example-2d.html', 'shader-example-filters.js', 'vert-filters.glsl', 'frag-pixelated.glsl'),\n\t\t\tlens : replaceParametersForExample('lens', 'template-example-2d.html', 'shader-example-filters.js', 'vert-filters.glsl', 'frag-lens.glsl'),\n\t\t\tgravity : replaceParametersForSimExample('gravity', 'template-example-sim.html', 'shader-example-gravity.js', 'frag-grav-pos.glsl', 'frag-grav-vel.glsl', 'vert-sim.glsl', 'frag-sim.glsl'),\n\t\t\tgalaxies : replaceParametersForSimExample('galaxies', 'template-example-sim.html', 'shader-example-galaxies.js', 'frag-galaxies-pos.glsl', 'frag-galaxies-vel.glsl', 'vert-sim.glsl', 'frag-sim.glsl'),\n\t\t\tdebug : replaceParametersForSimExample('debug', 'template-example-sim.html', 'shader-example-debug.js', 'frag-debug-pos.glsl', 'frag-debug-vel.glsl', 'vert-debug.glsl', 'frag-debug.glsl'),\n\t\t\trepulsion : replaceParametersForSimExample('repulsion', 'template-example-sim.html', 'shader-example-repulsion.js', 'frag-repulsion-pos.glsl', 'frag-repulsion-vel.glsl', 'vert-repulsion.glsl', 'frag-repulsion.glsl'),\n\t\t\tstippling : replaceParametersForSimExample('stippling', 'template-example-sim.html', 'shader-example-stippling.js', 'frag-stippling-pos.glsl', 'frag-stippling-vel.glsl', 'vert-stippling.glsl', 'frag-stippling.glsl'),\n\t\t\tdla : replaceParametersForSimExample('dla', 'template-example-sim.html', 'shader-example-dla.js', 'frag-dla-pos.glsl', 'frag-dla-vel.glsl', 'vert-dla.glsl', 'frag-dla.glsl'),\n\t\t\tbadtv : replaceParametersForExample('badtv', 'template-example-post.html', 'shader-example-postprocessing.js', 'vert-filters.glsl', 'frag-badtv.glsl'),\n\t\t\tpixelated : replaceParametersForExample('pixelated', 'template-example-post.html', 'shader-example-postprocessing.js', 'vert-filters.glsl', 'frag-pixelated.glsl'),\n\t\t\tcuts : replaceParametersForExample('cuts', 'template-example-post.html', 'shader-example-postprocessing.js', 'vert-filters.glsl', 'frag-cuts.glsl'),\n\t\t\trgb : replaceParametersForExample('rgb', 'template-example-post.html', 'shader-example-postprocessing.js', 'vert-filters.glsl', 'frag-rgb.glsl'),\n\t\t\tflare : replaceParametersForExample('flare', 'template-example-2d.html', 'shader-example-evolve.js', 'vert-filters.glsl', 'frag-flare.glsl'),\n\t\t\tfire : replaceParametersForExample('fire', 'template-example-2d.html', 'shader-example-evolve.js', 'vert-filters.glsl', 'frag-fire.glsl'),\n\t\t\tcursor : replaceParametersForExample('cursor', 'template-example-2d.html', 'shader-example-evolve.js', 'vert-filters.glsl', 'frag-cursor.glsl'),\n\t\t\treaction : replaceParametersForExample('reaction', 'template-example-2d.html', 'shader-example-evolve.js', 'vert-filters.glsl', 'frag-reaction.glsl'),\n\t\t\tsort : replaceParametersForExample('sort', 'template-example-2d.html', 'shader-example-evolveImage.js', 'vert-filters.glsl', 'frag-sort.glsl'),\n\t\t\tdeform : replaceParametersForExample('deform', 'template-example-3d.html', 'shader-example-3d.js', 'vert-deform.glsl', 'frag-normals.glsl'),\n\t\t\tattraction : replaceParametersForExample('attraction', 'template-example-3d.html', 'shader-example-3d.js', 'vert-attraction.glsl', 'frag-normals.glsl'),\n\t\t\tmountains : replaceParametersForExample('mountains', 'template-example-3d.html', 'shader-example-mountains.js', 'vert-mountains.glsl', 'frag-mountains.glsl'),\n\t\t\tsphere : replaceParametersForExample('sphere', 'template-example-3d.html', 'shader-example-sphere.js', 'vert-sphere.glsl', 'frag-sphere.glsl')\n\t\t},\n\n\t\t// grunt-jshint\n\t\tjshint : {\n\t\t\tfiles : [ 'Gruntfile.js', 'package.json', 'WebContent/js/*.js' ]\n\t\t},\n\n\t\t// grunt-contrib-sass\n\t\tsass : {\n\t\t\toptions : {\n\t\t\t\tsourcemap : 'none',\n\t\t\t\tstyle : 'expanded'\n\t\t\t},\n\t\t\tbuild : {\n\t\t\t\tsrc : 'sass/styles.scss',\n\t\t\t\tdest : 'WebContent/css/styles.css'\n\t\t\t}\n\t\t},\n\n\t\t// grunt-autoprefixer\n\t\tautoprefixer : {\n\t\t\tbuild : {\n\t\t\t\tsrc : 'WebContent/css/styles.css',\n\t\t\t\tdest : 'WebContent/css/styles.css'\n\t\t\t}\n\t\t},\n\n\t\t// grunt-contrib-watch\n\t\twatch : {\n\t\t\tfiles : [ 'html/*.html', 'shaders/**/*.glsl', 'WebContent/js/*.js' ],\n\t\t\ttasks : [ 'default' ]\n\t\t}\n\t});\n\n\t// Load the grunt tasks\n\tgrunt.loadNpmTasks('grunt-contrib-clean');\n\tgrunt.loadNpmTasks('grunt-contrib-copy');\n\tgrunt.loadNpmTasks('grunt-exec');\n\tgrunt.loadNpmTasks('grunt-replace');\n\tgrunt.loadNpmTasks('grunt-contrib-jshint');\n\tgrunt.loadNpmTasks('grunt-contrib-sass');\n\tgrunt.loadNpmTasks('grunt-autoprefixer');\n\tgrunt.loadNpmTasks('grunt-contrib-watch');\n\n\t// Default task\n\tgrunt.registerTask('default', [ 'clean', 'copy', 'exec', 'replace', 'jshint', 'sass', 'autoprefixer' ]);\n};\n"
  },
  {
    "path": "LICENSE",
    "content": "                   GNU LESSER GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n\n  This version of the GNU Lesser General Public License incorporates\nthe terms and conditions of version 3 of the GNU General Public\nLicense, supplemented by the additional permissions listed below.\n\n  0. Additional Definitions.\n\n  As used herein, \"this License\" refers to version 3 of the GNU Lesser\nGeneral Public License, and the \"GNU GPL\" refers to version 3 of the GNU\nGeneral Public License.\n\n  \"The Library\" refers to a covered work governed by this License,\nother than an Application or a Combined Work as defined below.\n\n  An \"Application\" is any work that makes use of an interface provided\nby the Library, but which is not otherwise based on the Library.\nDefining a subclass of a class defined by the Library is deemed a mode\nof using an interface provided by the Library.\n\n  A \"Combined Work\" is a work produced by combining or linking an\nApplication with the Library.  The particular version of the Library\nwith which the Combined Work was made is also called the \"Linked\nVersion\".\n\n  The \"Minimal Corresponding Source\" for a Combined Work means the\nCorresponding Source for the Combined Work, excluding any source code\nfor portions of the Combined Work that, considered in isolation, are\nbased on the Application, and not on the Linked Version.\n\n  The \"Corresponding Application Code\" for a Combined Work means the\nobject code and/or source code for the Application, including any data\nand utility programs needed for reproducing the Combined Work from the\nApplication, but excluding the System Libraries of the Combined Work.\n\n  1. Exception to Section 3 of the GNU GPL.\n\n  You may convey a covered work under sections 3 and 4 of this License\nwithout being bound by section 3 of the GNU GPL.\n\n  2. Conveying Modified Versions.\n\n  If you modify a copy of the Library, and, in your modifications, a\nfacility refers to a function or data to be supplied by an Application\nthat uses the facility (other than as an argument passed when the\nfacility is invoked), then you may convey a copy of the modified\nversion:\n\n   a) under this License, provided that you make a good faith effort to\n   ensure that, in the event an Application does not supply the\n   function or data, the facility still operates, and performs\n   whatever part of its purpose remains meaningful, or\n\n   b) under the GNU GPL, with none of the additional permissions of\n   this License applicable to that copy.\n\n  3. Object Code Incorporating Material from Library Header Files.\n\n  The object code form of an Application may incorporate material from\na header file that is part of the Library.  You may convey such object\ncode under terms of your choice, provided that, if the incorporated\nmaterial is not limited to numerical parameters, data structure\nlayouts and accessors, or small macros, inline functions and templates\n(ten or fewer lines in length), you do both of the following:\n\n   a) Give prominent notice with each copy of the object code that the\n   Library is used in it and that the Library and its use are\n   covered by this License.\n\n   b) Accompany the object code with a copy of the GNU GPL and this license\n   document.\n\n  4. Combined Works.\n\n  You may convey a Combined Work under terms of your choice that,\ntaken together, effectively do not restrict modification of the\nportions of the Library contained in the Combined Work and reverse\nengineering for debugging such modifications, if you also do each of\nthe following:\n\n   a) Give prominent notice with each copy of the Combined Work that\n   the Library is used in it and that the Library and its use are\n   covered by this License.\n\n   b) Accompany the Combined Work with a copy of the GNU GPL and this license\n   document.\n\n   c) For a Combined Work that displays copyright notices during\n   execution, include the copyright notice for the Library among\n   these notices, as well as a reference directing the user to the\n   copies of the GNU GPL and this license document.\n\n   d) Do one of the following:\n\n       0) Convey the Minimal Corresponding Source under the terms of this\n       License, and the Corresponding Application Code in a form\n       suitable for, and under terms that permit, the user to\n       recombine or relink the Application with a modified version of\n       the Linked Version to produce a modified Combined Work, in the\n       manner specified by section 6 of the GNU GPL for conveying\n       Corresponding Source.\n\n       1) Use a suitable shared library mechanism for linking with the\n       Library.  A suitable mechanism is one that (a) uses at run time\n       a copy of the Library already present on the user's computer\n       system, and (b) will operate properly with a modified version\n       of the Library that is interface-compatible with the Linked\n       Version.\n\n   e) Provide Installation Information, but only if you would otherwise\n   be required to provide such information under section 6 of the\n   GNU GPL, and only to the extent that such information is\n   necessary to install and execute a modified version of the\n   Combined Work produced by recombining or relinking the\n   Application with a modified version of the Linked Version. (If\n   you use option 4d0, the Installation Information must accompany\n   the Minimal Corresponding Source and Corresponding Application\n   Code. If you use option 4d1, you must provide the Installation\n   Information in the manner specified by section 6 of the GNU GPL\n   for conveying Corresponding Source.)\n\n  5. Combined Libraries.\n\n  You may place library facilities that are a work based on the\nLibrary side by side in a single library together with other library\nfacilities that are not Applications and are not covered by this\nLicense, and convey such a combined library under terms of your\nchoice, if you do both of the following:\n\n   a) Accompany the combined library with a copy of the same work based\n   on the Library, uncombined with any other library facilities,\n   conveyed under the terms of this License.\n\n   b) Give prominent notice with the combined library that part of it\n   is a work based on the Library, and explaining where to find the\n   accompanying uncombined form of the same work.\n\n  6. Revised Versions of the GNU Lesser General Public License.\n\n  The Free Software Foundation may publish revised and/or new versions\nof the GNU Lesser General Public License from time to time. Such new\nversions will be similar in spirit to the present version, but may\ndiffer in detail to address new problems or concerns.\n\n  Each version is given a distinguishing version number. If the\nLibrary as you received it specifies that a certain numbered version\nof the GNU Lesser General Public License \"or any later version\"\napplies to it, you have the option of following the terms and\nconditions either of that published version or of any later version\npublished by the Free Software Foundation. If the Library as you\nreceived it does not specify a version number of the GNU Lesser\nGeneral Public License, you may choose any version of the GNU Lesser\nGeneral Public License ever published by the Free Software Foundation.\n\n  If the Library as you received it specifies that a proxy can decide\nwhether future versions of the GNU Lesser General Public License shall\napply, that proxy's public statement of acceptance of any version is\npermanent authorization for you to choose that version for the\nLibrary.\n"
  },
  {
    "path": "README.md",
    "content": "# WebGL shader examples\n\nSome simple examples of WebGL shaders. They can be seen live at [webgl-shaders.com](https://webgl-shaders.com).\n\n# Build the project\n\nInstall [Node.js](https://nodejs.org) (for Ubuntu):\n\n``` bash\nsudo apt-get install curl\ncurl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -\nsudo apt-get install -y nodejs\n```\n\nInstall [grunt](https://gruntjs.com/), [glslify](https://github.com/glslify/glslify) and [budo](https://github.com/mattdesl/budo) globally:\n\n``` bash\nsudo npm install -g grunt-cli\nsudo npm install -g glslify\nsudo npm install -g budo\n```\n\nDownload the git repository and install the dependencies:\n\n``` bash\ngit clone https://github.com/jagracar/webgl-shader-examples.git\ncd webgl-shader-examples\nnpm install\n```\n\nBuild the project:\n\n``` bash\ngrunt\n```\n\nRun budo:\n\n``` bash\nbudo --dir WebContent/ --live\n```\n\nThen open [http://localhost:9966/](http://localhost:9966/) to test the examples.\n"
  },
  {
    "path": "WebContent/.htaccess",
    "content": "RewriteEngine On\nRewriteCond %{HTTPS} !=on\nRewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n\n"
  },
  {
    "path": "WebContent/about.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, examples, about\">\n<meta name=\"description\" content=\"About the WebGL shader examples project\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>About this project</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item is-active-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<header>\n\t\t\t<h2>About WebGL-shaders.com</h2>\n\t\t</header>\n\n\t\t<p>\n\t\t\tThe main intention of this site is to teach <a href=\"https://jagracar.com\">myself</a> to program WebGL shaders, but I\n\t\t\thope it will also be useful to oder people that are trying to do the same.\n\t\t</p>\n\n\t\t<p>Bellow is a non-complete list of references that have helped me to learn the basics:</p>\n\t\t<ul>\n\t\t\t<li><a href=\"https://thebookofshaders.com/\">The Book of shaders</a>.</li>\n\t\t\t<li><a href=\"https://webglfundamentals.org/\">WebGL fundamentals</a>.</li>\n\t\t\t<li><a href=\"http://pixelshaders.com/\">Pixel shaders</a>.</li>\n\t\t\t<li><a href=\"https://www.clicktorelease.com/blog/\">Clicktorelease blog</a>.</li>\n\t\t\t<li><a href=\"http://madebyevan.com/shaders/\">Shader tricks</a>.</li>\n\t\t\t<li><a href=\"https://www.airtightinteractive.com/2013/02/intro-to-pixel-shaders-in-three-js/\">Intro to pixel\n\t\t\t\t\tshaders in Three.js</a>.</li>\n\t\t\t<li><a href=\"http://www.iquilezles.org/www/index.htm\">List of articles by Íñigo Quílez</a>.</li>\n\t\t\t<li><a href=\"https://www.taylorpetrick.com/blog/post/convolution-part1\">Image convolution tutorial</a>.</li>\n\t\t\t<li><a href=\"https://developer.nvidia.com/gpugems/GPUGems/gpugems_pref01.html\">GPU gems</a>.</li>\n\t\t\t<li><a href=\"http://codeflow.org/tags/howto.html\">Codeflow howtos</a>.</li>\n\t\t\t<li><a href=\"https://processing.org/tutorials/pshader/\">Processing shaders tutorial</a>.</li>\n\t\t\t<li><a href=\"https://openframeworks.cc/ofBook/chapters/shaders.html\">OpenFrameworks shaders tutorial</a>.</li>\n\t\t\t<li><a href=\"https://threejs.org/examples/\">Three.js examples</a>.</li>\n\t\t</ul>\n\n\t\t<p>Some inspiration:</p>\n\t\t<ul>\n\t\t\t<li><a href=\"https://www.shadertoy.com/\">Shadertoy</a>.</li>\n\t\t\t<li><a href=\"http://glslsandbox.com/\">GLSL sandbox</a>.</li>\n\t\t</ul>\n\t</article>\n\t</main>\n\n\t<!-- Footer -->\n\t<footer class=\"footer-container\">\n\t\t<div class=\"footer-content\">\n\t\t\t<p>\n\t\t\t\tHand made in Munich. <span class=\"separator\">///</span> Unless otherwise stated, all the content in this site is\n\t\t\t\tlicensed under a Creative Commons Attribution-ShareAlike <a href=\"https://creativecommons.org/licenses/by-sa/4.0/\">license</a>.\n\t\t\t</p>\n\t\t</div>\n\t</footer>\n</body>\n</html>"
  },
  {
    "path": "WebContent/attraction-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 3D\">\n<meta name=\"description\" content=\"attraction shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>attraction shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-3d.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-attraction.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-normals.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * The main program\n */\nvoid main() {\n\t// Define the attractor position using spherical coordinates\n\tfloat r = 15.0;\n\tfloat theta = 0.87 * u_time;\n\tfloat phi = 0.63 * u_time;\n\tvec3 attractor_position = r * vec3(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));\n\n\t// Calculate the new vertex position to simulate attraction effect\n\tvec3 effect_direction = attractor_position - position;\n\tfloat effect_intensity = min(30.0 * pow(length(effect_direction), -2.0), 1.0);\n\tvec3 new_position = position + effect_intensity * effect_direction;\n\n\t// Calculate the modelview position\n\tvec4 mv_position = modelViewMatrix * vec4(new_position, 1.0);\n\n\t// Save the varyings\n\tv_position = mv_position.xyz;\n\tv_normal = normalize(normalMatrix * normal);\n\n\t// Vertex shader output\n\tgl_Position = projectionMatrix * mv_position;\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n *  Calculates the normal vector at the given position\n *\n *  Uses this fix for some mobiles:\n *  https://stackoverflow.com/questions/20272272/standard-derivatives-from-fragment-shader-dfdx-dfdy-dont-run-correctly-in-a\n */\nvec3 calculateNormal(vec3 position) {\n    vec3 fdx = vec3(dFdx(position.x), dFdx(position.y), dFdx(position.z));\n    vec3 fdy = vec3(dFdy(position.x), dFdy(position.y), dFdy(position.z));\n    vec3 normal = normalize(cross(fdx, fdy));\n\n    if (!gl_FrontFacing) {\n        normal = -normal;\n    }\n\n    return normal;\n}\n\n/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new normal vector\n\tvec3 new_normal = calculateNormal(v_position);\n\n\t// Use the mouse position to define the light direction\n\tfloat min_resolution = min(u_resolution.x, u_resolution.y);\n\tvec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.25);\n\n\t// Set the surface color\n\tvec3 surface_color = vec3(1.0);\n\n\t// Apply the light diffusion factor\n\tsurface_color *= diffuseFactor(new_normal, light_direction);\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(surface_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-3d.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/badtv-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, postprocessin\">\n<meta name=\"description\" content=\"badtv shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>badtv shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/CopyShader.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/EffectComposer.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/RenderPass.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/ShaderPass.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-postprocessing.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-filters.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-badtv.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the varyings\n    v_uv = uv;\n\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * Random number generator with a float seed\n *\n * Credits:\n * http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0\n */\nhighp float random1d(float dt) {\n    highp float c = 43758.5453;\n    highp float sn = mod(dt, 3.14);\n    return fract(sin(sn) * c);\n}\n\n/*\n * Pseudo-noise generator\n *\n * Credits:\n * https://thebookofshaders.com/11/\n */\nhighp float noise1d(float value) {\n\thighp float i = floor(value);\n\thighp float f = fract(value);\n\treturn mix(random1d(i), random1d(i + 1.0), smoothstep(0.0, 1.0, f));\n}\n\n/*\n * Random number generator with a vec2 seed\n *\n * Credits:\n * http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0\n * https://github.com/mattdesl/glsl-random\n */\nhighp float random2d(vec2 co) {\n    highp float a = 12.9898;\n    highp float b = 78.233;\n    highp float c = 43758.5453;\n    highp float dt = dot(co.xy, vec2(a, b));\n    highp float sn = mod(dt, 3.14);\n    return fract(sin(sn) * c);\n}\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the effect relative strength\n\tfloat strength = (0.3 + 0.7 * noise1d(0.3 * u_time)) * u_mouse.x / u_resolution.x;\n\n\t// Calculate the effect jump at the current time interval\n\tfloat jump = 500.0 * floor(0.3 * (u_mouse.x / u_resolution.x) * (u_time + noise1d(u_time)));\n\n\t// Shift the texture coordinates\n\tvec2 uv = v_uv;\n\tuv.y += 0.2 * strength * (noise1d(5.0 * v_uv.y + 2.0 * u_time + jump) - 0.5);\n\tuv.x += 0.1 * strength * (noise1d(100.0 * strength * uv.y + 3.0 * u_time + jump) - 0.5);\n\n\t// Get the texture pixel color\n\tvec3 pixel_color = texture2D(u_texture, uv).rgb;\n\n\t// Add some white noise\n\tpixel_color += vec3(5.0 * strength * (random2d(v_uv + 1.133001 * vec2(u_time, 1.13)) - 0.5));\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(pixel_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-postprocessing.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/blur-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 2D\">\n<meta name=\"description\" content=\"blur shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>blur shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-filters.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-filters.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-blur.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the varyings\n    v_uv = uv;\n\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the pixel color based on the mouse position\n    vec3 pixel_color;\n\n    if (gl_FragCoord.x > u_mouse.x) {\n        // Apply the gaussian kernel\n        float step = 1.0 + 2.0 * u_mouse.y / u_resolution.y;\n        pixel_color += (1.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-2, -2) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-2, -1) / u_resolution).rgb;\n        pixel_color += (6.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-2, 0) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-2, 1) / u_resolution).rgb;\n        pixel_color += (1.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-2, 2) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-1, -2) / u_resolution).rgb;\n        pixel_color += (16.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-1, -1) / u_resolution).rgb;\n        pixel_color += (24.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-1, 0) / u_resolution).rgb;\n        pixel_color += (16.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-1, 1) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-1, 2) / u_resolution).rgb;\n        pixel_color += (6.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(0, -2) / u_resolution).rgb;\n        pixel_color += (24.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(0, -1) / u_resolution).rgb;\n        pixel_color += (36.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(0, 0) / u_resolution).rgb;\n        pixel_color += (24.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(0, 1) / u_resolution).rgb;\n        pixel_color += (6.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(0, 2) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(1, -2) / u_resolution).rgb;\n        pixel_color += (16.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(1, -1) / u_resolution).rgb;\n        pixel_color += (24.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(1, 0) / u_resolution).rgb;\n        pixel_color += (16.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(1, 1) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(1, 2) / u_resolution).rgb;\n        pixel_color += (1.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(2, -2) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(2, -1) / u_resolution).rgb;\n        pixel_color += (6.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(2, 0) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(2, 1) / u_resolution).rgb;\n        pixel_color += (1.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(2, 2) / u_resolution).rgb;\n    } else if (gl_FragCoord.x > u_mouse.x - 1.0) {\n        // Draw a line indicating the transition\n        pixel_color = vec3(0.0);\n    } else {\n        // Use the original image pixel color\n        pixel_color = texture2D(u_texture, v_uv).rgb;\n    }\n\n// Fragment shader output\n    gl_FragColor = vec4(pixel_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-filters.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/css/styles.css",
    "content": "/*\n * Normalize\n *\n * v8.0.0 | MIT License | github.com/necolas/normalize.css\n */\nhtml {\n  line-height: 1.15;\n  -webkit-text-size-adjust: 100%;\n}\n\nbody {\n  margin: 0;\n}\n\nh1 {\n  font-size: 2em;\n  margin: 0.67em 0;\n}\n\nhr {\n  box-sizing: content-box;\n  height: 0;\n  overflow: visible;\n}\n\npre {\n  font-family: monospace, monospace;\n  font-size: 1em;\n}\n\na {\n  background-color: transparent;\n}\n\nabbr[title] {\n  border-bottom: none;\n  text-decoration: underline;\n  text-decoration: underline dotted;\n}\n\nb, strong {\n  font-weight: bolder;\n}\n\ncode, kbd, samp {\n  font-family: monospace, monospace;\n  font-size: 1em;\n}\n\nsmall {\n  font-size: 80%;\n}\n\nsub, sup {\n  font-size: 75%;\n  line-height: 0;\n  position: relative;\n  vertical-align: baseline;\n}\n\nsub {\n  bottom: -0.25em;\n}\n\nsup {\n  top: -0.5em;\n}\n\nimg {\n  border-style: none;\n}\n\nbutton, input, optgroup, select, textarea {\n  font-family: inherit;\n  font-size: 100%;\n  line-height: 1.15;\n  margin: 0;\n}\n\nbutton, input {\n  overflow: visible;\n}\n\nbutton, select {\n  text-transform: none;\n}\n\nbutton, [type=\"button\"], [type=\"reset\"], [type=\"submit\"] {\n  -webkit-appearance: button;\n}\n\nbutton::-moz-focus-inner, [type=\"button\"]::-moz-focus-inner, [type=\"reset\"]::-moz-focus-inner,\n[type=\"submit\"]::-moz-focus-inner {\n  border-style: none;\n  padding: 0;\n}\n\nbutton:-moz-focusring, [type=\"button\"]:-moz-focusring, [type=\"reset\"]:-moz-focusring,\n[type=\"submit\"]:-moz-focusring {\n  outline: 1px dotted ButtonText;\n}\n\nfieldset {\n  padding: 0.35em 0.75em 0.625em;\n}\n\nlegend {\n  box-sizing: border-box;\n  color: inherit;\n  display: table;\n  max-width: 100%;\n  padding: 0;\n  white-space: normal;\n}\n\nprogress {\n  vertical-align: baseline;\n}\n\ntextarea {\n  overflow: auto;\n}\n\n[type=\"checkbox\"], [type=\"radio\"] {\n  box-sizing: border-box;\n  padding: 0;\n}\n\n[type=\"number\"]::-webkit-inner-spin-button, [type=\"number\"]::-webkit-outer-spin-button {\n  height: auto;\n}\n\n[type=\"search\"] {\n  -webkit-appearance: textfield;\n  outline-offset: -2px;\n}\n\n[type=\"search\"]::-webkit-search-decoration {\n  -webkit-appearance: none;\n}\n\n::-webkit-file-upload-button {\n  -webkit-appearance: button;\n  font: inherit;\n}\n\ndetails {\n  display: block;\n}\n\nsummary {\n  display: list-item;\n}\n\ntemplate {\n  display: none;\n}\n\n[hidden] {\n  display: none;\n}\n\n/*\n * Fonts declarations\n */\n@font-face {\n  font-family: \"Font Awesome 4.7\";\n  font-style: normal;\n  font-weight: normal;\n  src: url(\"../fonts/fontAwesome-4.7.0/fontawesome-webfont.eot?v=4.7.0\");\n  src: url(\"../fonts/fontAwesome-4.7.0/fontawesome-webfont.eot?#iefix&v=4.7.0\") format(\"embedded-opentype\"), url(\"../fonts/fontAwesome-4.7.0/fontawesome-webfont.woff2?v=4.7.0\") format(\"woff2\"), url(\"../fonts/fontAwesome-4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0\") format(\"woff\"), url(\"../fonts/fontAwesome-4.7.0/fonts/fontawesome-webfont.ttf?v=4.7.0\") format(\"truetype\"), url(\"../fonts/fontAwesome-4.7.0/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular\") format(\"svg\");\n}\n@font-face {\n  font-family: 'Font Awesome 5 Brands';\n  font-style: normal;\n  font-weight: normal;\n  src: url(\"../fonts/fontAwesome-5.2.0/fa-brands-400.eot\");\n  src: url(\"../fonts/fontAwesome-5.2.0/fa-brands-400.eot?#iefix\") format(\"embedded-opentype\"), url(\"../fonts/fontAwesome-5.2.0/fa-brands-400.woff2\") format(\"woff2\"), url(\"../fonts/fontAwesome-5.2.0/fa-brands-400.woff\") format(\"woff\"), url(\"../fonts/fontAwesome-5.2.0/fa-brands-400.ttf\") format(\"truetype\"), url(\"../fonts/fontAwesome-5.2.0/fa-brands-400.svg#fontawesome\") format(\"svg\");\n}\n@font-face {\n  font-family: 'Font Awesome 5 Regular';\n  font-style: normal;\n  font-weight: 400;\n  src: url(\"../fonts/fontAwesome-5.2.0/fa-regular-400.eot\");\n  src: url(\"../fonts/fontAwesome-5.2.0/fa-regular-400.eot?#iefix\") format(\"embedded-opentype\"), url(\"../fonts/fontAwesome-5.2.0/fa-regular-400.woff2\") format(\"woff2\"), url(\"../fonts/fontAwesome-5.2.0/fa-regular-400.woff\") format(\"woff\"), url(\"../fonts/fontAwesome-5.2.0/fa-regular-400.ttf\") format(\"truetype\"), url(\"../fonts/fontAwesome-5.2.0/fa-regular-400.svg#fontawesome\") format(\"svg\");\n}\n@font-face {\n  font-family: 'Font Awesome 5 Solid';\n  font-style: normal;\n  font-weight: 900;\n  src: url(\"../fonts/fontAwesome-5.2.0/fa-solid-900.eot\");\n  src: url(\"../fonts/fontAwesome-5.2.0/fa-solid-900.eot?#iefix\") format(\"embedded-opentype\"), url(\"../fonts/fontAwesome-5.2.0/fa-solid-900.woff2\") format(\"woff2\"), url(\"../fonts/fontAwesome-5.2.0/fa-solid-900.woff\") format(\"woff\"), url(\"../fonts/fontAwesome-5.2.0/fa-solid-900.ttf\") format(\"truetype\"), url(\"../fonts/fontAwesome-5.2.0/fa-solid-900.svg#fontawesome\") format(\"svg\");\n}\n.fab, .far, .fas {\n  -moz-osx-font-smoothing: grayscale;\n  -webkit-font-smoothing: antialiased;\n  display: inline-block;\n  font-style: normal;\n  font-variant: normal;\n  text-rendering: auto;\n  line-height: 1;\n}\n\n.fab {\n  font-family: 'Font Awesome 5 Brands';\n}\n\n.far {\n  font-family: 'Font Awesome 5 Regular';\n  font-weight: 400;\n}\n\n.fas {\n  font-family: 'Font Awesome 5 Solid';\n  font-weight: 900;\n}\n\n/*\n * Icons\n */\n.menu-icon:before {\n  font-family: \"Font Awesome 5 Solid\";\n  font-weight: 900;\n  content: \"\\f0c9\";\n}\n\n.back-icon:before {\n  font-family: \"Font Awesome 5 Solid\";\n  font-weight: 900;\n  content: \"\\f52b\";\n}\n\n.love-icon:before {\n  font-family: \"Font Awesome 5 Regular\";\n  content: \"\\f004\";\n}\n\n.envelope-icon:before {\n  font-family: \"Font Awesome 5 Regular\";\n  content: \"\\f0e0\";\n}\n\n.phone-icon:before {\n  font-family: \"Font Awesome 5 Solid\";\n  font-weight: 900;\n  content: \"\\f095\";\n}\n\n.noSpam-icon:before {\n  font-family: \"Font Awesome 4.7\";\n  content: \"\\f1fa\";\n}\n\n.handMade-icon:before {\n  font-family: \"Font Awesome 5 Solid\";\n  font-weight: 900;\n  content: \"\\f1b0\";\n}\n\n.up-icon:before {\n  font-family: \"Font Awesome 5 Solid\";\n  font-weight: 900;\n  content: \"\\f106\";\n}\n\n.down-icon:before {\n  font-family: \"Font Awesome 5 Solid\";\n  font-weight: 900;\n  content: \"\\f107\";\n}\n\n.js-icon:before {\n  font-family: \"Font Awesome 5 Brands\";\n  content: \"\\f3b8\";\n}\n\n.code-icon:before {\n  font-family: \"Font Awesome 5 Solid\";\n  font-weight: 900;\n  content: \"\\f121\";\n}\n\n.github-icon:before {\n  font-family: \"Font Awesome 5 Brands\";\n  content: \"\\f09b\";\n}\n\n/*\n * General styling\n */\n*, *:before, *:after {\n  box-sizing: border-box;\n}\n\nbody {\n  font-family: \"HelveticaNeue-Light\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n  font-size: 0.9em;\n  line-height: 1.4;\n  color: #333333;\n}\n\na {\n  text-decoration: none;\n  color: #6666ff;\n}\na:hover, a:focus {\n  text-decoration: underline;\n}\nh1 a, h2 a, h3 a, h4 a, h5 a, h6 a {\n  color: inherit;\n}\nh1 a:hover, h1 a:focus, h2 a:hover, h2 a:focus, h3 a:hover, h3 a:focus, h4 a:hover, h4 a:focus, h5 a:hover, h5 a:focus, h6 a:hover, h6 a:focus {\n  text-decoration: none;\n}\n\nh1, h2, h3, h4, h5, h6 {\n  font-weight: normal;\n  color: #666666;\n}\nh1 small, h2 small, h3 small, h4 small, h5 small, h6 small {\n  font-size: 60%;\n}\n\nh2 {\n  font-size: 2.6em;\n}\n@media (max-width: 816px) {\n  h2 {\n    font-size: 2.2em;\n  }\n}\n\nh3 {\n  font-size: 1.5em;\n}\n\nh4 {\n  font-size: 1.2em;\n}\n\np {\n  max-width: 1152px;\n}\n\nfigure {\n  margin: 0;\n}\n\n/*\n * General layout\n */\nhtml, body {\n  height: 100%;\n}\n\nbody {\n  display: -ms-flexbox;\n  display: flex;\n  -ms-flex-direction: column;\n      flex-direction: column;\n}\n\n.nav-container {\n  position: fixed;\n  top: 0;\n  left: 0;\n  z-index: 5000;\n}\n\n.main-container {\n  -ms-flex: 1 1 auto;\n      flex: 1 1 auto;\n}\n\n.footer-container {\n  -ms-flex: 0 0 auto;\n      flex: 0 0 auto;\n}\n\n.nav-container {\n  display: -ms-flexbox;\n  display: flex;\n  -ms-flex-direction: row;\n      flex-direction: row;\n}\n\n.nav-header {\n  -ms-flex: 0 0 auto;\n      flex: 0 0 auto;\n}\n\n.nav-menu-wrapper {\n  -ms-flex: 1 1 auto;\n      flex: 1 1 auto;\n}\n\n.nav-menu-wrapper {\n  display: -ms-flexbox;\n  display: flex;\n  -ms-flex-direction: row;\n      flex-direction: row;\n  -ms-flex-pack: justify;\n      justify-content: space-between;\n}\n\n@media (max-width: 816px) {\n  .nav-header {\n    -ms-flex: 1 1 auto;\n        flex: 1 1 auto;\n  }\n\n  .nav-menu-wrapper {\n    position: absolute;\n    top: 0.3em;\n    left: 0;\n  }\n\n  .nav-menu-wrapper {\n    display: block;\n  }\n}\n/*\n * Navigation bar components\n */\n.nav-container {\n  width: 100%;\n  padding: 0.3em;\n  border-bottom: 0.0625em solid rgba(102, 102, 102, 0.96);\n  margin: 0;\n  background: linear-gradient(to right, rgba(26, 26, 26, 0.96), rgba(64, 64, 64, 0.96) 30%, rgba(64, 64, 64, 0.96) 70%, rgba(26, 26, 26, 0.96));\n}\n.nav-container a:hover, .nav-container a:focus {\n  text-decoration: none;\n}\n.nav-container ul {\n  padding: 0;\n  margin: 0;\n}\n.nav-container li {\n  display: inline-block;\n  list-style-type: none;\n}\n\n.nav-header {\n  width: 14em;\n  margin: 0;\n  font-size: 1.0em;\n}\n\n.nav-item {\n  display: block;\n  min-width: 4em;\n  padding: 0.3375em 0.6375em;\n  border: 0.0625em solid rgba(255, 255, 255, 0.1);\n  border-radius: 3px;\n  font-size: 1.0em;\n  text-align: center;\n  white-space: nowrap;\n  color: #e6e6e6;\n  background-color: rgba(255, 255, 255, 0.1);\n  transition: color 0.6s, background-color 0.6s;\n}\n.nav-item:hover {\n  color: white;\n  background-color: rgba(255, 255, 255, 0.3);\n}\n\n.is-header-item {\n  padding: 0.4em 0.7em;\n  border: 0;\n  background-color: transparent;\n}\n.is-header-item:hover {\n  background-color: transparent;\n}\n\n.is-menu-item {\n  display: none;\n  min-width: 0;\n}\n\n.is-active-item {\n  background-color: rgba(0, 150, 255, 0.7);\n}\n.is-active-item:hover {\n  background-color: #0096ff;\n}\n\n@media (max-width: 816px) {\n  .nav-menu-wrapper:hover {\n    width: 100%;\n  }\n\n  .is-menu-item {\n    display: inline-block;\n    padding: 0.3375em 0.6375em;\n    border: 0.0625em solid rgba(255, 255, 255, 0.1);\n    margin-left: 0.3em;\n  }\n  .nav-menu-wrapper:hover .is-menu-item {\n    background-color: rgba(255, 255, 255, 0.3);\n  }\n\n  .nav-menu-list {\n    display: none;\n  }\n  .nav-menu-list:first-of-type {\n    margin-top: 0.3em;\n  }\n  .nav-menu-wrapper:hover .nav-menu-list {\n    display: block;\n    background: linear-gradient(to right, rgba(26, 26, 26, 0.96), rgba(64, 64, 64, 0.96) 30%, rgba(64, 64, 64, 0.96) 70%, rgba(26, 26, 26, 0.96));\n  }\n  .nav-menu-list li {\n    display: list-item;\n    border-top: 0.0625em solid rgba(255, 255, 255, 0.1);\n  }\n  .nav-menu-list .nav-item {\n    padding: 0.4em 0.7em;\n    border: 0;\n    border-radius: 0;\n    text-align: left;\n  }\n}\n/*\n * Content components\n */\n.main-container {\n  padding: 2.5em 10% 0 10%;\n}\n\n.content {\n  padding-bottom: 2em;\n}\n\n.example-list {\n  display: -ms-flexbox;\n  display: flex;\n  -ms-flex-flow: row wrap;\n      flex-flow: row wrap;\n  -ms-flex-pack: justify;\n      justify-content: space-between;\n}\n.example-list nav {\n  -ms-flex: 0 0 48%;\n      flex: 0 0 48%;\n}\n.example-list ul {\n  padding: 0;\n  margin: 0;\n}\n.example-list li {\n  list-style-type: none;\n}\n.example-list a {\n  display: block;\n  padding: 0.4em;\n  margin-bottom: 0.3em;\n  border-radius: 3px;\n  text-align: center;\n  white-space: nowrap;\n  color: #333333;\n  background-color: #f2f2f2;\n  transition: background-color 0.6s;\n}\n.example-list a:hover, .example-list a:focus, .example-list a.active-sketch {\n  text-decoration: none;\n  color: white;\n  background-color: #bfbfbf;\n}\n\n@media (max-width: 1440px) {\n  .main-container {\n    padding: 2.5em 5% 0 5%;\n  }\n}\n@media (max-width: 816px) {\n  .example-list {\n    display: block;\n  }\n}\n/*\n * Sketch components\n */\n.sketch-container {\n  position: absolute;\n  right: 0;\n  top: 0;\n}\n.sketch-container canvas {\n  display: block;\n}\n\n.sketch-gui {\n  position: absolute;\n  right: 0;\n  bottom: 20px;\n}\n.sketch-gui select {\n  color: #333333;\n}\n\n.sketch-stats {\n  position: absolute;\n  left: 0;\n  bottom: 0;\n  z-index: 10000;\n  cursor: pointer;\n  opacity: 0.9;\n}\n\n/*\n * Footer components\n */\n.footer-container {\n  padding: 0 10%;\n}\n\n.footer-content {\n  border-top: 1px dotted #cccccc;\n  color: #666666;\n}\n\n.separator {\n  padding: 0 0.5em;\n}\n\n@media (max-width: 1440px) {\n  .footer-container {\n    padding: 0 5%;\n  }\n}\n"
  },
  {
    "path": "WebContent/cursor-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 2D\">\n<meta name=\"description\" content=\"cursor shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>cursor shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-evolve.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-filters.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-cursor.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the varyings\n    v_uv = uv;\n\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the circle\n */\nfloat circle(vec2 pixel, vec2 center, float radius) {\n    return 1.0 - smoothstep(radius - 1.0, radius + 1.0, length(pixel - center));\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the pixel color\n    vec3 pixel_color = texture2D(u_texture, v_uv).rgb;\n\n\t// Draw a circle at the mouse position\n    float circle_radius = 50.0;\n    vec3 circle_color = vec3(0.5, 0.5, 0.8) + vec3(0.3 * cos(u_time), 0.3 * sin(1.3 *u_time), 0.2 * cos(2.7 *u_time));\n    float mix_factor = 0.8 * circle(gl_FragCoord.xy, u_mouse, circle_radius);\n    pixel_color = mix(pixel_color, circle_color, mix_factor);\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(pixel_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-evolve.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/cuts-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, postprocessin\">\n<meta name=\"description\" content=\"cuts shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>cuts shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/CopyShader.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/EffectComposer.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/RenderPass.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/ShaderPass.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-postprocessing.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-filters.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-cuts.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the varyings\n    v_uv = uv;\n\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * Returns a rotation matrix for the given angle\n */\nmat2 rotate(float angle) {\n    return mat2(cos(angle), -sin(angle), sin(angle), cos(angle));\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Change the cuts pixel size as a function of the mouse relative position\n    float cuts_size = 150.0 * (1.1 - u_mouse.x / u_resolution.x);\n\n    // Calculate the cuts offset\n    float angle = 0.4 * u_time;\n    vec2 offset = 30.0 * sin(angle) * vec2(cos(angle), sin(angle));\n\n    // Change the offset direction between cuts\n    vec2 rotated_pos = rotate(angle) * (gl_FragCoord.xy - 0.5 * u_resolution) + 0.5 * u_resolution;\n    offset *= 2.0 * floor(mod(rotated_pos.y / cuts_size, 2.0)) - 1.0;\n\n    // Fragment shader output\n    gl_FragColor = texture2D(u_texture, v_uv + offset / u_resolution);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-postprocessing.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/debug-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 3D, simulation\">\n<meta name=\"description\" content=\"debug shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>debug shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/GPUComputationRenderer.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-debug.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-debug-pos.glsl\" class=\"nav-item\">Position shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-debug-vel.glsl\" class=\"nav-item\">Velocity shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-debug.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-debug.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"positionShader\">\n#define GLSLIFY 1\nvoid main() {\n    vec2 uv = gl_FragCoord.xy / resolution;\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    gl_FragColor = vec4(position + velocity, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"velocityShader\">\n#define GLSLIFY 1\nvoid main() {\n    vec2 uv = gl_FragCoord.xy / resolution;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    gl_FragColor = vec4(velocity, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\nattribute float a_index;\n\nuniform float u_width;\nuniform float u_height;\nuniform sampler2D u_positionTexture;\n\nvoid main() {\n    vec2 uv = vec2((mod(a_index, u_width) + 0.5) / u_width, (floor(a_index / u_width) + 0.5) / u_height);\n    gl_PointSize = 2.0;\n    gl_Position = projectionMatrix * modelViewMatrix * texture2D(u_positionTexture, uv);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\nvoid main() {\n    gl_FragColor = vec4(vec3(1.0), 1);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-debug.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/deform-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 3D\">\n<meta name=\"description\" content=\"deform shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>deform shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-3d.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-deform.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-normals.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new vertex position to simulate a wave effect\n\tfloat effect_intensity = 2.0 * u_mouse.x / u_resolution.x;\n\tvec3 new_position = position + effect_intensity * (0.5 + 0.5 * cos(position.x + 4.0 * u_time)) * normal;\n\n\t// Calculate the modelview position\n\tvec4 mv_position = modelViewMatrix * vec4(new_position, 1.0);\n\n\t// Save the varyings\n\tv_position = mv_position.xyz;\n\tv_normal = normalize(normalMatrix * normal);\n\n\t// Vertex shader output\n\tgl_Position = projectionMatrix * mv_position;\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n *  Calculates the normal vector at the given position\n *\n *  Uses this fix for some mobiles:\n *  https://stackoverflow.com/questions/20272272/standard-derivatives-from-fragment-shader-dfdx-dfdy-dont-run-correctly-in-a\n */\nvec3 calculateNormal(vec3 position) {\n    vec3 fdx = vec3(dFdx(position.x), dFdx(position.y), dFdx(position.z));\n    vec3 fdy = vec3(dFdy(position.x), dFdy(position.y), dFdy(position.z));\n    vec3 normal = normalize(cross(fdx, fdy));\n\n    if (!gl_FrontFacing) {\n        normal = -normal;\n    }\n\n    return normal;\n}\n\n/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new normal vector\n\tvec3 new_normal = calculateNormal(v_position);\n\n\t// Use the mouse position to define the light direction\n\tfloat min_resolution = min(u_resolution.x, u_resolution.y);\n\tvec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.25);\n\n\t// Set the surface color\n\tvec3 surface_color = vec3(1.0);\n\n\t// Apply the light diffusion factor\n\tsurface_color *= diffuseFactor(new_normal, light_direction);\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(surface_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-3d.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/dla-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 3D, simulation\">\n<meta name=\"description\" content=\"dla shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>dla shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/GPUComputationRenderer.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-dla.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-dla-pos.glsl\" class=\"nav-item\">Position shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-dla-vel.glsl\" class=\"nav-item\">Velocity shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-dla.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-dla.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"positionShader\">\n#define GLSLIFY 1\n/*\n * Random number generator with a vec2 seed\n *\n * Credits:\n * http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0\n * https://github.com/mattdesl/glsl-random\n */\nhighp float random2d(vec2 co) {\n    highp float a = 12.9898;\n    highp float b = 78.233;\n    highp float c = 43758.5453;\n    highp float dt = dot(co.xy, vec2(a, b));\n    highp float sn = mod(dt, 3.14);\n    return fract(sin(sn) * c);\n}\n\n// Simulation uniforms\nuniform float u_minDistance;\nuniform float u_maxDistance;\nuniform float u_time;\n\n// Simulation constants\nconst float width = resolution.x;\nconst float height = resolution.y;\nconst float nParticles = width * height;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position\n    vec4 position = texture2D(u_positionTexture, uv);\n\n    // Update the particle position if it has not been aggregated\n    if (position.w > 0.0) {\n        // Move the particle to a new random position\n        float ang = 2.0 * 3.141593 * random2d(123.456 * position.xy + u_time);\n        position.xy += 0.9 * u_minDistance * vec2(cos(ang), sin(ang));\n\n        // Loop over all the particles in the simulation\n        for (float i = 0.0; i < nParticles; i++) {\n            // Get the particle position and velocity\n            vec2 particleUv = vec2(mod(i, width) + 0.5, floor(i / width) + 0.5) / resolution;\n            vec4 particlePosition = texture2D(u_positionTexture, particleUv);\n\n            // Check if it's an aggregated particle\n            if (position.w > 0.0 && particlePosition.w < 0.0) {\n                // Calculate the distance between the two particles\n                float distance = length(particlePosition.xy - position.xy);\n\n                // Set the particle as aggregated if the distance is small\n                // enough and we are not comparing the particle with itself\n                if (distance != 0.0 && distance < u_minDistance) {\n                    position.w = -1.0;\n                    position.xy = particlePosition.xy + u_minDistance * (position.xy - particlePosition.xy) / distance;\n                    break;\n                }\n            }\n        }\n\n        // Make sure that the particle distance to the center is smaller than\n        // the maximum allowed distance\n        float distanceToCenter = length(position.xy);\n\n        if (distanceToCenter > u_maxDistance) {\n            position.xy -= 2.0 * u_maxDistance * position.xy / distanceToCenter;\n        }\n    }\n\n    // Return the updated particle position\n    gl_FragColor = position;\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"velocityShader\">\n#define GLSLIFY 1\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Particle index attribute\nattribute float a_index;\n\n// Simulation uniforms\nuniform float u_width;\nuniform float u_height;\nuniform float u_particleSize;\nuniform sampler2D u_positionTexture;\n\n// Varying with the aggregation information\nvarying float v_aggregation;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle model view position\n    vec2 uv = vec2((mod(a_index, u_width) + 0.5) / u_width, (floor(a_index / u_width) + 0.5) / u_height);\n    vec4 position = texture2D(u_positionTexture, uv);\n    vec4 mvPosition = modelViewMatrix * vec4(position.xyz, 1.0);\n\n    // Pass the aggregation information to the fragment shader\n    v_aggregation = position.w;\n\n    // Vertex shader output\n    gl_PointSize = v_aggregation < 0.0 ? -u_particleSize / mvPosition.z : -0.5 * u_particleSize / mvPosition.z;\n    gl_Position = projectionMatrix * mvPosition;\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Texture with the particle profile\nuniform sampler2D u_texture;\n\n// Varying with the aggregation information\nvarying float v_aggregation;\n\n/*\n * The main program\n */\nvoid main() {\n    // Use a different color for aggregated and non-aggregated particles\n    vec3 particleColor = v_aggregation < 0.0 ? vec3(1.0) : vec3(0.5);\n\n    // Fragment shader output\n    gl_FragColor = vec4(particleColor, texture2D(u_texture, gl_PointCoord).a);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-dla.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/dots-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 3D\">\n<meta name=\"description\" content=\"dots shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>dots shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-3d.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-3d.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-dots.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * The main program\n */\nvoid main() {\n    // Save the varyings\n    v_position = position;\n    v_normal = normalize(normalMatrix * normal);\n\n    // Vertex shader output\n    gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the circle\n */\nfloat circle(vec2 pixel, vec2 center, float radius) {\n    return 1.0 - smoothstep(radius - 1.0, radius + 1.0, length(pixel - center));\n}\n\n/*\n * Returns a rotation matrix for the given angle\n */\nmat2 rotate(float angle) {\n    return mat2(cos(angle), -sin(angle), sin(angle), cos(angle));\n}\n\n/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Use the mouse position to define the light direction\n    float min_resolution = min(u_resolution.x, u_resolution.y);\n    vec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.5);\n\n    // Calculate the light diffusion factor\n    float df = diffuseFactor(v_normal, light_direction);\n\n    // Move the pixel coordinates origin to the center of the screen\n    vec2 pos = gl_FragCoord.xy - 0.5 * u_resolution;\n\n    // Rotate the coordinates 20 degrees\n    pos = rotate(radians(20.0)) * pos;\n\n    // Define the grid\n    float grid_step = 12.0;\n    vec2 grid_pos = mod(pos, grid_step);\n\n    // Calculate the surface color\n    float surface_color = 1.0;\n    surface_color -= circle(grid_pos, vec2(grid_step / 2.0), 0.8 * grid_step * pow(1.0 - df, 2.0));\n    surface_color = clamp(surface_color, 0.05, 1.0);\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(surface_color), 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-3d.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/edge-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 2D\">\n<meta name=\"description\" content=\"edge shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>edge shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-filters.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-filters.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-edge.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the varyings\n    v_uv = uv;\n\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the pixel color based on the mouse position\n    vec3 pixel_color;\n\n    if (gl_FragCoord.x > u_mouse.x) {\n        // Apply the edge detection kernel\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(-1, -1) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(-1, 0) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(-1, 1) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(0, -1) / u_resolution).rgb;\n        pixel_color += 8.0 * texture2D(u_texture, v_uv + vec2(0, 0) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(0, 1) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(1, -1) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(1, 0) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(1, 1) / u_resolution).rgb;\n\n        // Use the most extreme color value\n        float min_value = min(pixel_color.r, min(pixel_color.g, pixel_color.b));\n        float max_value = max(pixel_color.r, max(pixel_color.g, pixel_color.b));\n\n        if (abs(min_value) > abs(max_value)) {\n            pixel_color = vec3(min_value);\n        } else {\n            pixel_color = vec3(max_value);\n        }\n\n        // Rescale the pixel color using the mouse y position\n        float scale = 0.2 + 2.5 * u_mouse.y / u_resolution.y;\n        pixel_color = 0.5 + scale * pixel_color;\n    } else if (gl_FragCoord.x > u_mouse.x - 1.0) {\n        // Draw a line indicating the transition\n        pixel_color = vec3(0.0);\n    } else {\n        // Use the original image pixel color\n        pixel_color = texture2D(u_texture, v_uv).rgb;\n    }\n\n    // Fragment shader output\n    gl_FragColor = vec4(pixel_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-filters.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/fire-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 2D\">\n<meta name=\"description\" content=\"fire shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>fire shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-evolve.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-filters.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-fire.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the varyings\n    v_uv = uv;\n\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * GLSL textureless classic 2D noise \"cnoise\",\n * with an RSL-style periodic variant \"pnoise\".\n * Author:  Stefan Gustavson (stefan.gustavson@liu.se)\n * Version: 2011-08-22\n *\n * Many thanks to Ian McEwan of Ashima Arts for the\n * ideas for permutation and gradient selection.\n *\n * Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n * Distributed under the MIT license. See LICENSE file.\n * https://github.com/stegu/webgl-noise\n */\n\nvec4 mod289(vec4 x) {\n    return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x) {\n    return mod289(((x * 34.0) + 1.0) * x);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n    return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nvec2 fade(vec2 t) {\n    return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n\nfloat cnoise(vec2 P) {\n    vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n    vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n    Pi = mod289(Pi);\n    vec4 ix = Pi.xzxz;\n    vec4 iy = Pi.yyww;\n    vec4 fx = Pf.xzxz;\n    vec4 fy = Pf.yyww;\n\n    vec4 i = permute(permute(ix) + iy);\n\n    vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0;\n    vec4 gy = abs(gx) - 0.5;\n    vec4 tx = floor(gx + 0.5);\n    gx = gx - tx;\n\n    vec2 g00 = vec2(gx.x, gy.x);\n    vec2 g10 = vec2(gx.y, gy.y);\n    vec2 g01 = vec2(gx.z, gy.z);\n    vec2 g11 = vec2(gx.w, gy.w);\n\n    vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n    g00 *= norm.x;\n    g01 *= norm.y;\n    g10 *= norm.z;\n    g11 *= norm.w;\n\n    float n00 = dot(g00, vec2(fx.x, fy.x));\n    float n10 = dot(g10, vec2(fx.y, fy.y));\n    float n01 = dot(g01, vec2(fx.z, fy.z));\n    float n11 = dot(g11, vec2(fx.w, fy.w));\n\n    vec2 fade_xy = fade(Pf.xy);\n    vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n    float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n    return 2.3 * n_xy;\n}\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the pixel color depending of the distance from the floor\n\tvec3 pixel_color = vec3(0.0);\n\tfloat floor = 2.0;\n\n\tif (gl_FragCoord.y <= floor) {\n\t\t// Use some 2D noise to simulate the fire change in position and time\n\t\tpixel_color.rg = vec2(cnoise(vec2(0.01 * gl_FragCoord.x, -0.2 * u_time)));\n\t} else {\n\t\t// Get a smoothed value of the pixels bellow\n\t    vec2 delta =  1.0 / u_resolution;\n\t    pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(2.0 * delta.x, -delta.y)).rgb;\n\t\tpixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(1.0 * delta.x, -delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(0.0 * delta.x, -delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(-1.0 * delta.x, -delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(-2.0 * delta.x, -delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(2.0 * delta.x, -2.0 * delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(1.0 * delta.x, -2.0 * delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(0.0 * delta.x, -2.0 * delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(-1.0 * delta.x, -2.0 * delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(-2.0 * delta.x, -2.0 * delta.y)).rgb;\n\n        // Decrease the intensity with the distance to the floor\n        float fade_factor = 1.0 - smoothstep(0.0, u_resolution.x, (gl_FragCoord.y - floor) / 3.0);\n        pixel_color.r *= fade_factor;\n        pixel_color.g *= 0.99 * fade_factor;\n        pixel_color.b = 0.0;\n\t}\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(pixel_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-evolve.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/flare-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 2D\">\n<meta name=\"description\" content=\"flare shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>flare shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-evolve.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-filters.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-flare.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the varyings\n    v_uv = uv;\n\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * GLSL textureless classic 2D noise \"cnoise\",\n * with an RSL-style periodic variant \"pnoise\".\n * Author:  Stefan Gustavson (stefan.gustavson@liu.se)\n * Version: 2011-08-22\n *\n * Many thanks to Ian McEwan of Ashima Arts for the\n * ideas for permutation and gradient selection.\n *\n * Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n * Distributed under the MIT license. See LICENSE file.\n * https://github.com/stegu/webgl-noise\n */\n\nvec4 mod289(vec4 x) {\n    return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x) {\n    return mod289(((x * 34.0) + 1.0) * x);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n    return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nvec2 fade(vec2 t) {\n    return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n\nfloat cnoise(vec2 P) {\n    vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n    vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n    Pi = mod289(Pi);\n    vec4 ix = Pi.xzxz;\n    vec4 iy = Pi.yyww;\n    vec4 fx = Pf.xzxz;\n    vec4 fy = Pf.yyww;\n\n    vec4 i = permute(permute(ix) + iy);\n\n    vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0;\n    vec4 gy = abs(gx) - 0.5;\n    vec4 tx = floor(gx + 0.5);\n    gx = gx - tx;\n\n    vec2 g00 = vec2(gx.x, gy.x);\n    vec2 g10 = vec2(gx.y, gy.y);\n    vec2 g01 = vec2(gx.z, gy.z);\n    vec2 g11 = vec2(gx.w, gy.w);\n\n    vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n    g00 *= norm.x;\n    g01 *= norm.y;\n    g10 *= norm.z;\n    g11 *= norm.w;\n\n    float n00 = dot(g00, vec2(fx.x, fy.x));\n    float n10 = dot(g10, vec2(fx.y, fy.y));\n    float n01 = dot(g01, vec2(fx.z, fy.z));\n    float n11 = dot(g11, vec2(fx.w, fy.w));\n\n    vec2 fade_xy = fade(Pf.xy);\n    vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n    float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n    return 2.3 * n_xy;\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Set the star radius\n    float star_radius = 90.0;\n\n    // Get the pixel position relative to the screen center\n    vec2 position = gl_FragCoord.xy - 0.5 * u_resolution;\n\n    // Calculate the pixel distance from the center\n    float radial_distance = length(position);\n\n    // Calculate the star color\n    vec3 star_color = vec3(0.0);\n\n    if (radial_distance < star_radius) {\n        // Calculate the pixel polar angle\n        float angle = atan(position.y, position.x) + radians(180.0);\n\n        // Calculate the radial noise position\n        float r = 0.05 * (radial_distance - u_frame);\n\n        // Calculate the noise value\n        float noise_value = cnoise(vec2(r, 1.5 * angle));\n\n        // Smooth the noise discontinuity between 0 and 360 degrees\n        float smooth_step = radians(20.0);\n        float limit_angle = radians(360.0) - smooth_step;\n\n        if (angle > limit_angle) {\n            noise_value = mix(noise_value, cnoise(vec2(r, 0.0)), (angle - limit_angle) / smooth_step);\n        }\n\n        // The final star color is the combination of a radially constant\n        // declining intensity plus the noise\n        float f = pow(radial_distance / star_radius, 2.0);\n        star_color = vec3((1.0 - f) + f * (0.1 + 0.4 * u_mouse.x / u_resolution.x) * (0.5 + 0.5 * noise_value));\n    }\n\n    // Calculate the average color of the pixels that are radially bellow the\n    // current pixel\n    vec3 average_color = vec3(0.0);\n    float counter = 0.0;\n\n    for (float i = -2.0; i <= 2.0; i++) {\n        for (float j = -2.0; j <= 2.0; j++) {\n            // Get the pixel color at the offset position\n            vec2 offset = vec2(i, j);\n            vec3 color = texture2D(u_texture, v_uv + offset / u_resolution).rgb;\n\n            // Add the color to the average if the pixel is above the offset\n            // position and is not a pixel inside the star\n            if (radial_distance > length(position + offset) && radial_distance >= star_radius) {\n                average_color += color;\n                counter++;\n            }\n        }\n    }\n\n    if (counter > 0.0) {\n        average_color /= counter;\n    }\n\n    // Set the distance decrement factor for the average color\n    float decrement_factor = 0.1 * (u_resolution.y - u_mouse.y) / u_resolution.y;\n\n    // Fragment shader output\n    gl_FragColor = vec4(star_color + (1.0 - decrement_factor) * average_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-evolve.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/galaxies-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 3D, simulation\">\n<meta name=\"description\" content=\"galaxies shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>galaxies shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/GPUComputationRenderer.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-galaxies.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-galaxies-pos.glsl\" class=\"nav-item\">Position shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-galaxies-vel.glsl\" class=\"nav-item\">Velocity shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-sim.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-sim.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"positionShader\">\n#define GLSLIFY 1\n// Simulation uniforms\nuniform float u_dt;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Return the updated particle position\n    gl_FragColor = vec4(position + u_dt * velocity, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"velocityShader\">\n#define GLSLIFY 1\n// Simulation uniforms\nuniform float u_dt;\nuniform float u_mass;\nuniform float u_haloSize;\n\n// Simulation constants\nconst float width = resolution.x;\nconst float height = resolution.y;\n\n// Softening factor. This is required to avoid high acceleration values\n// when two particles get too close\nconst float softening = 0.001;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Loop over all the particles and calculate the total gravitational force\n    vec3 totalForce = vec3(0.0);\n\n    for (float i = 0.0; i < nGalaxies; i++) {\n        // Get the position of the attracting particle\n        vec2 particleUv = vec2(mod(i, width) + 0.5, floor(i / width) + 0.5) / resolution;\n        vec3 particlePosition = texture2D(u_positionTexture, particleUv).xyz;\n\n        // Calculate the force direction\n        vec3 forceDirection = particlePosition - position;\n\n        // Calculate the particle distance\n        float distance = length(forceDirection);\n\n        // Move to the next particle if the distance is exactly zero, which\n        // indicates that we are comparing the particle with itself\n        if (distance == 0.0) {\n            continue;\n        }\n\n        // Add the particle gravitational force\n        float massAtPosition = u_mass * min(distance, u_haloSize) / u_haloSize;\n        totalForce += massAtPosition * (forceDirection / distance) / pow(distance + softening, 2.0);\n    }\n\n    // Return the updated particle velocity\n    gl_FragColor = vec4(velocity + u_dt * totalForce, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Particle index attribute\nattribute float a_index;\n\n// Simulation uniforms\nuniform float u_width;\nuniform float u_height;\nuniform float u_particleSize;\nuniform sampler2D u_positionTexture;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle model view position\n    vec2 uv = vec2((mod(a_index, u_width) + 0.5) / u_width, (floor(a_index / u_width) + 0.5) / u_height);\n    vec4 mvPosition = modelViewMatrix * texture2D(u_positionTexture, uv);\n\n    // Vertex shader output\n    gl_PointSize = -u_particleSize / mvPosition.z;\n    gl_Position = projectionMatrix * mvPosition;\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Texture with the particle profile\nuniform sampler2D u_texture;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle alpha value from the texture\n    float alpha = texture2D(u_texture, gl_PointCoord).a;\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(1.0), alpha);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-galaxies.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/gravity-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 3D, simulation\">\n<meta name=\"description\" content=\"gravity shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>gravity shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/GPUComputationRenderer.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-gravity.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-grav-pos.glsl\" class=\"nav-item\">Position shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-grav-vel.glsl\" class=\"nav-item\">Velocity shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-sim.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-sim.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"positionShader\">\n#define GLSLIFY 1\n// Simulation uniforms\nuniform float u_dt;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Return the updated particle position\n    gl_FragColor = vec4(position + u_dt * velocity, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"velocityShader\">\n#define GLSLIFY 1\n// Simulation uniforms\nuniform float u_dt;\n\n// Simulation constants\nconst float width = resolution.x;\nconst float height = resolution.y;\nconst float nParticles = width * height;\n\n// Softening factor. This is required to avoid high acceleration values\n// when two particles get too close\nconst float softening = 0.1;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Loop over all the particles and calculate the total gravitational force\n    vec3 totalForce = vec3(0.0);\n    float forceScalingFactor = 1.0 / (2.0 * pow(nParticles, 1.5));\n\n    for (float i = 0.0; i < nParticles; i++) {\n        // Get the position of the attracting particle\n        vec2 particleUv = vec2(mod(i, width) + 0.5, floor(i / width) + 0.5) / resolution;\n        vec3 particlePosition = texture2D(u_positionTexture, particleUv).xyz;\n\n        // Calculate the force direction\n        vec3 forceDirection = particlePosition - position;\n\n        // Calculate the particle distance\n        float distance = length(forceDirection);\n\n        // Move to the next particle if the distance is exactly zero, which\n        // indicates that we are comparing the particle with itself\n        if (distance == 0.0) {\n            continue;\n        }\n\n        // Add the particle gravitational force\n        totalForce += forceScalingFactor * (forceDirection / distance) / pow(distance + softening, 2.0);\n    }\n\n    // Return the updated particle velocity\n    gl_FragColor = vec4(velocity + u_dt * totalForce, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Particle index attribute\nattribute float a_index;\n\n// Simulation uniforms\nuniform float u_width;\nuniform float u_height;\nuniform float u_particleSize;\nuniform sampler2D u_positionTexture;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle model view position\n    vec2 uv = vec2((mod(a_index, u_width) + 0.5) / u_width, (floor(a_index / u_width) + 0.5) / u_height);\n    vec4 mvPosition = modelViewMatrix * texture2D(u_positionTexture, uv);\n\n    // Vertex shader output\n    gl_PointSize = -u_particleSize / mvPosition.z;\n    gl_Position = projectionMatrix * mvPosition;\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Texture with the particle profile\nuniform sampler2D u_texture;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle alpha value from the texture\n    float alpha = texture2D(u_texture, gl_PointCoord).a;\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(1.0), alpha);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-gravity.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, examples\">\n<meta name=\"description\" content=\"WebGL shader examples\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>WebGL shader examples</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<header>\n\t\t\t<h2>\n\t\t\t\tWebGL shader examples<br /> <small>by <a href=\"https://jagracar.com\">Javier Gracia Carpio</a></small>\n\t\t\t</h2>\n\t\t</header>\n\n\t\t<div class=\"example-list\">\n\t\t\t<nav>\n\t\t\t\t<header>\n\t\t\t\t\t<h3>2D examples:</h3>\n\t\t\t\t</header>\n\n\t\t\t\t<ul>\n\t\t\t\t\t<li><a href=\"/random-example.html\">Random pixels</a></li>\n\t\t\t\t\t<li><a href=\"/noise-example.html\">Classic 2D noise</a></li>\n\t\t\t\t\t<li><a href=\"/rain-example.html\">Rain drops</a></li>\n\t\t\t\t\t<li><a href=\"/tile-example.html\">Geometric tile</a></li>\n\t\t\t\t</ul>\n\t\t\t</nav>\n\n\t\t\t<nav>\n\t\t\t\t<header>\n\t\t\t\t\t<h3>3D examples:</h3>\n\t\t\t\t</header>\n\n\t\t\t\t<ul>\n\t\t\t\t\t<li><a href=\"/wave-example.html\">Cosine wave</a></li>\n\t\t\t\t\t<li><a href=\"/pencil-example.html\">Pencil shading</a></li>\n\t\t\t\t\t<li><a href=\"/dots-example.html\">Dot shading</a></li>\n\t\t\t\t\t<li><a href=\"/toon-example.html\">Toon shading</a></li>\n\t\t\t\t\t<li><a href=\"/stripes-example.html\">Stripes</a></li>\n\t\t\t\t</ul>\n\t\t\t</nav>\n\n\t\t\t<nav>\n\t\t\t\t<header>\n\t\t\t\t\t<h3>Image manipulation examples:</h3>\n\t\t\t\t</header>\n\n\t\t\t\t<ul>\n\t\t\t\t\t<li><a href=\"/edge-example.html\">Edge detection</a></li>\n\t\t\t\t\t<li><a href=\"/blur-example.html\">Gaussian blur</a></li>\n\t\t\t\t\t<li><a href=\"/pixels-example.html\">Pixelated</a></li>\n\t\t\t\t\t<li><a href=\"/lens-example.html\">Lens effect</a></li>\n\t\t\t\t</ul>\n\t\t\t</nav>\n\n\t\t\t<nav>\n\t\t\t\t<header>\n\t\t\t\t\t<h3>Simulation examples:</h3>\n\t\t\t\t</header>\n\n\t\t\t\t<ul>\n\t\t\t\t\t<li><a href=\"/gravity-example.html\">Gravity</a></li>\n\t\t\t\t\t<li><a href=\"/galaxies-example.html\">Interacting galaxies</a></li>\n\t\t\t\t\t<li><a href=\"/repulsion-example.html\">Repulsion</a></li>\n\t\t\t\t\t<li><a href=\"/stippling-example.html\">Stippling</a></li>\n\t\t\t\t\t<li><a href=\"/dla-example.html\">Diffusion-limited aggregation</a></li>\n\t\t\t\t</ul>\n\t\t\t</nav>\n\n\t\t\t<nav>\n\t\t\t\t<header>\n\t\t\t\t\t<h3>Post-processing examples:</h3>\n\t\t\t\t</header>\n\n\t\t\t\t<ul>\n\t\t\t\t\t<li><a href=\"/badtv-example.html\">Bad TV</a></li>\n\t\t\t\t\t<li><a href=\"/pixelated-example.html\">Pixelated</a></li>\n\t\t\t\t\t<li><a href=\"/cuts-example.html\">Cuts</a></li>\n\t\t\t\t\t<li><a href=\"/rgb-example.html\">RGB shift</a></li>\n\t\t\t\t</ul>\n\t\t\t</nav>\n\n\t\t\t<nav>\n\t\t\t\t<header>\n\t\t\t\t\t<h3>Evolution examples:</h3>\n\t\t\t\t</header>\n\n\t\t\t\t<ul>\n\t\t\t\t\t<li><a href=\"/fire-example.html\">Fire</a></li>\n\t\t\t\t\t<li><a href=\"/flare-example.html\">Flaring star</a></li>\n\t\t\t\t\t<li><a href=\"/cursor-example.html\">Cursor draw</a></li>\n\t\t\t\t\t<li><a href=\"/reaction-example.html\">Reaction-diffusion</a></li>\n\t\t\t\t\t<li><a href=\"/sort-example.html\">Pixel sorting</a></li>\n\t\t\t\t</ul>\n\t\t\t</nav>\n\n\t\t\t<nav>\n\t\t\t\t<header>\n\t\t\t\t\t<h3>Vertex manipulation examples:</h3>\n\t\t\t\t</header>\n\n\t\t\t\t<ul>\n\t\t\t\t\t<li><a href=\"/deform-example.html\">Deformation</a></li>\n\t\t\t\t\t<li><a href=\"/attraction-example.html\">Attraction</a></li>\n\t\t\t\t\t<li><a href=\"/mountains-example.html\">Infinite landscape</a></li>\n\t\t\t\t\t<li><a href=\"/sphere-example.html\">Alien sphere</a></li>\n\t\t\t\t</ul>\n\t\t\t</nav>\n\t\t</div>\n\t</article>\n\t</main>\n\n\t<!-- Footer -->\n\t<footer class=\"footer-container\">\n\t\t<div class=\"footer-content\">\n\t\t\t<p>\n\t\t\t\tHand made in Munich. <span class=\"separator\">///</span> Unless otherwise stated, all the content in this site is\n\t\t\t\tlicensed under a Creative Commons Attribution-ShareAlike <a href=\"https://creativecommons.org/licenses/by-sa/4.0/\">license</a>.\n\t\t\t</p>\n\t\t</div>\n\t</footer>\n</body>\n</html>"
  },
  {
    "path": "WebContent/js/libs/CopyShader.js",
    "content": "/**\n * @author alteredq / http://alteredqualia.com/\n *\n * Full-screen textured quad shader\n */\n\nTHREE.CopyShader = {\n\n\tuniforms: {\n\n\t\t\"tDiffuse\": { value: null },\n\t\t\"opacity\":  { value: 1.0 }\n\n\t},\n\n\tvertexShader: [\n\n\t\t\"varying vec2 vUv;\",\n\n\t\t\"void main() {\",\n\n\t\t\t\"vUv = uv;\",\n\t\t\t\"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\",\n\n\t\t\"}\"\n\n\t].join( \"\\n\" ),\n\n\tfragmentShader: [\n\n\t\t\"uniform float opacity;\",\n\n\t\t\"uniform sampler2D tDiffuse;\",\n\n\t\t\"varying vec2 vUv;\",\n\n\t\t\"void main() {\",\n\n\t\t\t\"vec4 texel = texture2D( tDiffuse, vUv );\",\n\t\t\t\"gl_FragColor = opacity * texel;\",\n\n\t\t\"}\"\n\n\t].join( \"\\n\" )\n\n};\n"
  },
  {
    "path": "WebContent/js/libs/EffectComposer.js",
    "content": "/**\n * @author alteredq / http://alteredqualia.com/\n */\n\nTHREE.EffectComposer = function ( renderer, renderTarget ) {\n\n\tthis.renderer = renderer;\n\n\tif ( renderTarget === undefined ) {\n\n\t\tvar parameters = {\n\t\t\tminFilter: THREE.LinearFilter,\n\t\t\tmagFilter: THREE.LinearFilter,\n\t\t\tformat: THREE.RGBAFormat,\n\t\t\tstencilBuffer: false\n\t\t};\n\n\t\tvar size = renderer.getDrawingBufferSize();\n\t\trenderTarget = new THREE.WebGLRenderTarget( size.width, size.height, parameters );\n\t\trenderTarget.texture.name = 'EffectComposer.rt1';\n\n\t}\n\n\tthis.renderTarget1 = renderTarget;\n\tthis.renderTarget2 = renderTarget.clone();\n\tthis.renderTarget2.texture.name = 'EffectComposer.rt2';\n\n\tthis.writeBuffer = this.renderTarget1;\n\tthis.readBuffer = this.renderTarget2;\n\n\tthis.passes = [];\n\n\t// dependencies\n\n\tif ( THREE.CopyShader === undefined ) {\n\n\t\tconsole.error( 'THREE.EffectComposer relies on THREE.CopyShader' );\n\n\t}\n\n\tif ( THREE.ShaderPass === undefined ) {\n\n\t\tconsole.error( 'THREE.EffectComposer relies on THREE.ShaderPass' );\n\n\t}\n\n\tthis.copyPass = new THREE.ShaderPass( THREE.CopyShader );\n\n};\n\nObject.assign( THREE.EffectComposer.prototype, {\n\n\tswapBuffers: function () {\n\n\t\tvar tmp = this.readBuffer;\n\t\tthis.readBuffer = this.writeBuffer;\n\t\tthis.writeBuffer = tmp;\n\n\t},\n\n\taddPass: function ( pass ) {\n\n\t\tthis.passes.push( pass );\n\n\t\tvar size = this.renderer.getDrawingBufferSize();\n\t\tpass.setSize( size.width, size.height );\n\n\t},\n\n\tinsertPass: function ( pass, index ) {\n\n\t\tthis.passes.splice( index, 0, pass );\n\n\t},\n\n\trender: function ( delta ) {\n\n\t\tvar maskActive = false;\n\n\t\tvar pass, i, il = this.passes.length;\n\n\t\tfor ( i = 0; i < il; i ++ ) {\n\n\t\t\tpass = this.passes[ i ];\n\n\t\t\tif ( pass.enabled === false ) continue;\n\n\t\t\tpass.render( this.renderer, this.writeBuffer, this.readBuffer, delta, maskActive );\n\n\t\t\tif ( pass.needsSwap ) {\n\n\t\t\t\tif ( maskActive ) {\n\n\t\t\t\t\tvar context = this.renderer.context;\n\n\t\t\t\t\tcontext.stencilFunc( context.NOTEQUAL, 1, 0xffffffff );\n\n\t\t\t\t\tthis.copyPass.render( this.renderer, this.writeBuffer, this.readBuffer, delta );\n\n\t\t\t\t\tcontext.stencilFunc( context.EQUAL, 1, 0xffffffff );\n\n\t\t\t\t}\n\n\t\t\t\tthis.swapBuffers();\n\n\t\t\t}\n\n\t\t\tif ( THREE.MaskPass !== undefined ) {\n\n\t\t\t\tif ( pass instanceof THREE.MaskPass ) {\n\n\t\t\t\t\tmaskActive = true;\n\n\t\t\t\t} else if ( pass instanceof THREE.ClearMaskPass ) {\n\n\t\t\t\t\tmaskActive = false;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\treset: function ( renderTarget ) {\n\n\t\tif ( renderTarget === undefined ) {\n\n\t\t\tvar size = this.renderer.getDrawingBufferSize();\n\n\t\t\trenderTarget = this.renderTarget1.clone();\n\t\t\trenderTarget.setSize( size.width, size.height );\n\n\t\t}\n\n\t\tthis.renderTarget1.dispose();\n\t\tthis.renderTarget2.dispose();\n\t\tthis.renderTarget1 = renderTarget;\n\t\tthis.renderTarget2 = renderTarget.clone();\n\n\t\tthis.writeBuffer = this.renderTarget1;\n\t\tthis.readBuffer = this.renderTarget2;\n\n\t},\n\n\tsetSize: function ( width, height ) {\n\n\t\tthis.renderTarget1.setSize( width, height );\n\t\tthis.renderTarget2.setSize( width, height );\n\n\t\tfor ( var i = 0; i < this.passes.length; i ++ ) {\n\n\t\t\tthis.passes[ i ].setSize( width, height );\n\n\t\t}\n\n\t}\n\n} );\n\n\nTHREE.Pass = function () {\n\n\t// if set to true, the pass is processed by the composer\n\tthis.enabled = true;\n\n\t// if set to true, the pass indicates to swap read and write buffer after rendering\n\tthis.needsSwap = true;\n\n\t// if set to true, the pass clears its buffer before rendering\n\tthis.clear = false;\n\n\t// if set to true, the result of the pass is rendered to screen\n\tthis.renderToScreen = false;\n\n};\n\nObject.assign( THREE.Pass.prototype, {\n\n\tsetSize: function ( width, height ) {},\n\n\trender: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {\n\n\t\tconsole.error( 'THREE.Pass: .render() must be implemented in derived pass.' );\n\n\t}\n\n} );\n"
  },
  {
    "path": "WebContent/js/libs/GPUComputationRenderer.js",
    "content": "/**\n * @author yomboprime https://github.com/yomboprime\n *\n * GPUComputationRenderer, based on SimulationRenderer by zz85\n *\n * The GPUComputationRenderer uses the concept of variables. These variables are RGBA float textures that hold 4 floats\n * for each compute element (texel)\n *\n * Each variable has a fragment shader that defines the computation made to obtain the variable in question.\n * You can use as many variables you need, and make dependencies so you can use textures of other variables in the shader\n * (the sampler uniforms are added automatically) Most of the variables will need themselves as dependency.\n *\n * The renderer has actually two render targets per variable, to make ping-pong. Textures from the current frame are used\n * as inputs to render the textures of the next frame.\n *\n * The render targets of the variables can be used as input textures for your visualization shaders.\n *\n * Variable names should be valid identifiers and should not collide with THREE GLSL used identifiers.\n * a common approach could be to use 'texture' prefixing the variable name; i.e texturePosition, textureVelocity...\n *\n * The size of the computation (sizeX * sizeY) is defined as 'resolution' automatically in the shader. For example:\n * #DEFINE resolution vec2( 1024.0, 1024.0 )\n *\n * -------------\n *\n * Basic use:\n *\n * // Initialization...\n *\n * // Create computation renderer\n * var gpuCompute = new GPUComputationRenderer( 1024, 1024, renderer );\n *\n * // Create initial state float textures\n * var pos0 = gpuCompute.createTexture();\n * var vel0 = gpuCompute.createTexture();\n * // and fill in here the texture data...\n *\n * // Add texture variables\n * var velVar = gpuCompute.addVariable( \"textureVelocity\", fragmentShaderVel, pos0 );\n * var posVar = gpuCompute.addVariable( \"texturePosition\", fragmentShaderPos, vel0 );\n *\n * // Add variable dependencies\n * gpuCompute.setVariableDependencies( velVar, [ velVar, posVar ] );\n * gpuCompute.setVariableDependencies( posVar, [ velVar, posVar ] );\n *\n * // Add custom uniforms\n * velVar.material.uniforms.time = { value: 0.0 };\n *\n * // Check for completeness\n * var error = gpuCompute.init();\n * if ( error !== null ) {\n *\t\tconsole.error( error );\n  * }\n *\n *\n * // In each frame...\n *\n * // Compute!\n * gpuCompute.compute();\n *\n * // Update texture uniforms in your visualization materials with the gpu renderer output\n * myMaterial.uniforms.myTexture.value = gpuCompute.getCurrentRenderTarget( posVar ).texture;\n *\n * // Do your rendering\n * renderer.render( myScene, myCamera );\n *\n * -------------\n *\n * Also, you can use utility functions to create ShaderMaterial and perform computations (rendering between textures)\n * Note that the shaders can have multiple input textures.\n *\n * var myFilter1 = gpuCompute.createShaderMaterial( myFilterFragmentShader1, { theTexture: { value: null } } );\n * var myFilter2 = gpuCompute.createShaderMaterial( myFilterFragmentShader2, { theTexture: { value: null } } );\n *\n * var inputTexture = gpuCompute.createTexture();\n *\n * // Fill in here inputTexture...\n *\n * myFilter1.uniforms.theTexture.value = inputTexture;\n *\n * var myRenderTarget = gpuCompute.createRenderTarget();\n * myFilter2.uniforms.theTexture.value = myRenderTarget.texture;\n *\n * var outputRenderTarget = gpuCompute.createRenderTarget();\n *\n * // Now use the output texture where you want:\n * myMaterial.uniforms.map.value = outputRenderTarget.texture;\n *\n * // And compute each frame, before rendering to screen:\n * gpuCompute.doRenderTarget( myFilter1, myRenderTarget );\n * gpuCompute.doRenderTarget( myFilter2, outputRenderTarget );\n * \n *\n *\n * @param {int} sizeX Computation problem size is always 2d: sizeX * sizeY elements.\n * @param {int} sizeY Computation problem size is always 2d: sizeX * sizeY elements.\n * @param {WebGLRenderer} renderer The renderer\n  */\n\nfunction GPUComputationRenderer( sizeX, sizeY, renderer ) {\n\n\tthis.variables = [];\n\n\tthis.currentTextureIndex = 0;\n\n\tvar scene = new THREE.Scene();\n\n\tvar camera = new THREE.Camera();\n\tcamera.position.z = 1;\n\n\tvar passThruUniforms = {\n\t\ttexture: { value: null }\n\t};\n\n\tvar passThruShader = createShaderMaterial( getPassThroughFragmentShader(), passThruUniforms );\n\n\tvar mesh = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), passThruShader );\n\tscene.add( mesh );\n\n\n\tthis.addVariable = function( variableName, computeFragmentShader, initialValueTexture ) {\n\n\t\tvar material = this.createShaderMaterial( computeFragmentShader );\n\n\t\tvar variable = {\n\t\t\tname: variableName,\n\t\t\tinitialValueTexture: initialValueTexture,\n\t\t\tmaterial: material,\n\t\t\tdependencies: null,\n\t\t\trenderTargets: [],\n\t\t\twrapS: null,\n\t\t\twrapT: null,\n\t\t\tminFilter: THREE.NearestFilter,\n\t\t\tmagFilter: THREE.NearestFilter\n\t\t};\n\n\t\tthis.variables.push( variable );\n\n\t\treturn variable;\n\t\t\n\t};\n\n\tthis.setVariableDependencies = function( variable, dependencies ) {\n\n\t\tvariable.dependencies = dependencies;\n\n\t};\n\n\tthis.init = function() {\n\n\t\tif ( ! renderer.extensions.get( \"OES_texture_float\" ) ) {\n\n\t\t\treturn \"No OES_texture_float support for float textures.\";\n\n\t\t}\n\n\t\tif ( renderer.capabilities.maxVertexTextures === 0 ) {\n\n\t\t\treturn \"No support for vertex shader textures.\";\n\n\t\t}\n\n\t\tfor ( var i = 0; i < this.variables.length; i++ ) {\n\n\t\t\tvar variable = this.variables[ i ];\n\n\t\t\t// Creates rendertargets and initialize them with input texture\n\t\t\tvariable.renderTargets[ 0 ] = this.createRenderTarget( sizeX, sizeY, variable.wrapS, variable.wrapT, variable.minFilter, variable.magFilter );\n\t\t\tvariable.renderTargets[ 1 ] = this.createRenderTarget( sizeX, sizeY, variable.wrapS, variable.wrapT, variable.minFilter, variable.magFilter );\n\t\t\tthis.renderTexture( variable.initialValueTexture, variable.renderTargets[ 0 ] );\n\t\t\tthis.renderTexture( variable.initialValueTexture, variable.renderTargets[ 1 ] );\n\n\t\t\t// Adds dependencies uniforms to the ShaderMaterial\n\t\t\tvar material = variable.material;\n\t\t\tvar uniforms = material.uniforms;\n\t\t\tif ( variable.dependencies !== null ) {\n\n\t\t\t\tfor ( var d = 0; d < variable.dependencies.length; d++ ) {\n\n\t\t\t\t\tvar depVar = variable.dependencies[ d ];\n\n\t\t\t\t\tif ( depVar.name !== variable.name ) {\n\n\t\t\t\t\t\t// Checks if variable exists\n\t\t\t\t\t\tvar found = false;\n\t\t\t\t\t\tfor ( var j = 0; j < this.variables.length; j++ ) {\n\n\t\t\t\t\t\t\tif ( depVar.name === this.variables[ j ].name ) {\n\t\t\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( ! found ) {\n\t\t\t\t\t\t\treturn \"Variable dependency not found. Variable=\" + variable.name + \", dependency=\" + depVar.name;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tuniforms[ depVar.name ] = { value: null };\n\n\t\t\t\t\tmaterial.fragmentShader = \"\\nuniform sampler2D \" + depVar.name + \";\\n\" + material.fragmentShader;\n\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.currentTextureIndex = 0;\n\n\t\treturn null;\n\n\t};\n\n\tthis.compute = function() {\n\n\t\tvar currentTextureIndex = this.currentTextureIndex;\n\t\tvar nextTextureIndex = this.currentTextureIndex === 0 ? 1 : 0;\n\n\t\tfor ( var i = 0, il = this.variables.length; i < il; i++ ) {\n\n\t\t\tvar variable = this.variables[ i ];\n\n\t\t\t// Sets texture dependencies uniforms\n\t\t\tif ( variable.dependencies !== null ) {\n\n\t\t\t\tvar uniforms = variable.material.uniforms;\n\t\t\t\tfor ( var d = 0, dl = variable.dependencies.length; d < dl; d++ ) {\n\n\t\t\t\t\tvar depVar = variable.dependencies[ d ];\n\n\t\t\t\t\tuniforms[ depVar.name ].value = depVar.renderTargets[ currentTextureIndex ].texture;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// Performs the computation for this variable\n\t\t\tthis.doRenderTarget( variable.material, variable.renderTargets[ nextTextureIndex ] );\n\n\t\t}\n\n\t\tthis.currentTextureIndex = nextTextureIndex;\n\t};\n\n\tthis.getCurrentRenderTarget = function( variable ) {\n\n\t\treturn variable.renderTargets[ this.currentTextureIndex ];\n\n\t};\n\n\tthis.getAlternateRenderTarget = function( variable ) {\n\n\t\treturn variable.renderTargets[ this.currentTextureIndex === 0 ? 1 : 0 ];\n\n\t};\n\n\tfunction addResolutionDefine( materialShader ) {\n\n\t\tmaterialShader.defines.resolution = 'vec2( ' + sizeX.toFixed( 1 ) + ', ' + sizeY.toFixed( 1 ) + \" )\";\n\n\t}\n\tthis.addResolutionDefine = addResolutionDefine;\n\n\n\t// The following functions can be used to compute things manually\n\n\tfunction createShaderMaterial( computeFragmentShader, uniforms ) {\n\n\t\tuniforms = uniforms || {};\n\n\t\tvar material = new THREE.ShaderMaterial( {\n\t\t\tuniforms: uniforms,\n\t\t\tvertexShader: getPassThroughVertexShader(),\n\t\t\tfragmentShader: computeFragmentShader\n\t\t} );\n\n\t\taddResolutionDefine( material );\n\n\t\treturn material;\n\t}\n\tthis.createShaderMaterial = createShaderMaterial;\n\n\tthis.createRenderTarget = function( sizeXTexture, sizeYTexture, wrapS, wrapT, minFilter, magFilter ) {\n\n\t\tsizeXTexture = sizeXTexture || sizeX;\n\t\tsizeYTexture = sizeYTexture || sizeY;\n\n\t\twrapS = wrapS || THREE.ClampToEdgeWrapping;\n\t\twrapT = wrapT || THREE.ClampToEdgeWrapping;\n\n\t\tminFilter = minFilter || THREE.NearestFilter;\n\t\tmagFilter = magFilter || THREE.NearestFilter;\n\n\t\tvar renderTarget = new THREE.WebGLRenderTarget( sizeXTexture, sizeYTexture, {\n\t\t\twrapS: wrapS,\n\t\t\twrapT: wrapT,\n\t\t\tminFilter: minFilter,\n\t\t\tmagFilter: magFilter,\n\t\t\tformat: THREE.RGBAFormat,\n\t\t\ttype: ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) ? THREE.HalfFloatType : THREE.FloatType,\n\t\t\tstencilBuffer: false,\n\t\t\tdepthBuffer: false\n\t\t} );\n\n\t\treturn renderTarget;\n\n\t};\n\n\tthis.createTexture = function() {\n\n\t\tvar a = new Float32Array( sizeX * sizeY * 4 );\n\t\tvar texture = new THREE.DataTexture( a, sizeX, sizeY, THREE.RGBAFormat, THREE.FloatType );\n\t\ttexture.needsUpdate = true;\n\n\t\treturn texture;\n\n\t};\n\n\n\tthis.renderTexture = function( input, output ) {\n\n\t\t// Takes a texture, and render out in rendertarget\n\t\t// input = Texture\n\t\t// output = RenderTarget\n\n\t\tpassThruUniforms.texture.value = input;\n\n\t\tthis.doRenderTarget( passThruShader, output);\n\n\t\tpassThruUniforms.texture.value = null;\n\n\t};\n\n\tthis.doRenderTarget = function( material, output ) {\n\n\t\tmesh.material = material;\n\t\trenderer.render( scene, camera, output );\n\t\tmesh.material = passThruShader;\n\n\t};\n\n\t// Shaders\n\n\tfunction getPassThroughVertexShader() {\n\n\t\treturn\t\"void main()\t{\\n\" +\n\t\t\t\t\"\\n\" +\n\t\t\t\t\"\tgl_Position = vec4( position, 1.0 );\\n\" +\n\t\t\t\t\"\\n\" +\n\t\t\t\t\"}\\n\";\n\n\t}\n\n\tfunction getPassThroughFragmentShader() {\n\n\t\treturn\t\"uniform sampler2D texture;\\n\" +\n\t\t\t\t\"\\n\" +\n\t\t\t\t\"void main() {\\n\" +\n\t\t\t\t\"\\n\" +\n\t\t\t\t\"\tvec2 uv = gl_FragCoord.xy / resolution.xy;\\n\" +\n\t\t\t\t\"\\n\" +\n\t\t\t\t\"\tgl_FragColor = texture2D( texture, uv );\\n\" +\n\t\t\t\t\"\\n\" +\n\t\t\t\t\"}\\n\";\n\n\t}\n\n}\n"
  },
  {
    "path": "WebContent/js/libs/MaskPass.js",
    "content": "/**\n * @author alteredq / http://alteredqualia.com/\n */\n\nTHREE.MaskPass = function ( scene, camera ) {\n\n\tTHREE.Pass.call( this );\n\n\tthis.scene = scene;\n\tthis.camera = camera;\n\n\tthis.clear = true;\n\tthis.needsSwap = false;\n\n\tthis.inverse = false;\n\n};\n\nTHREE.MaskPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {\n\n\tconstructor: THREE.MaskPass,\n\n\trender: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {\n\n\t\tvar context = renderer.context;\n\t\tvar state = renderer.state;\n\n\t\t// don't update color or depth\n\n\t\tstate.buffers.color.setMask( false );\n\t\tstate.buffers.depth.setMask( false );\n\n\t\t// lock buffers\n\n\t\tstate.buffers.color.setLocked( true );\n\t\tstate.buffers.depth.setLocked( true );\n\n\t\t// set up stencil\n\n\t\tvar writeValue, clearValue;\n\n\t\tif ( this.inverse ) {\n\n\t\t\twriteValue = 0;\n\t\t\tclearValue = 1;\n\n\t\t} else {\n\n\t\t\twriteValue = 1;\n\t\t\tclearValue = 0;\n\n\t\t}\n\n\t\tstate.buffers.stencil.setTest( true );\n\t\tstate.buffers.stencil.setOp( context.REPLACE, context.REPLACE, context.REPLACE );\n\t\tstate.buffers.stencil.setFunc( context.ALWAYS, writeValue, 0xffffffff );\n\t\tstate.buffers.stencil.setClear( clearValue );\n\n\t\t// draw into the stencil buffer\n\n\t\trenderer.render( this.scene, this.camera, readBuffer, this.clear );\n\t\trenderer.render( this.scene, this.camera, writeBuffer, this.clear );\n\n\t\t// unlock color and depth buffer for subsequent rendering\n\n\t\tstate.buffers.color.setLocked( false );\n\t\tstate.buffers.depth.setLocked( false );\n\n\t\t// only render where stencil is set to 1\n\n\t\tstate.buffers.stencil.setFunc( context.EQUAL, 1, 0xffffffff );  // draw if == 1\n\t\tstate.buffers.stencil.setOp( context.KEEP, context.KEEP, context.KEEP );\n\n\t}\n\n} );\n\n\nTHREE.ClearMaskPass = function () {\n\n\tTHREE.Pass.call( this );\n\n\tthis.needsSwap = false;\n\n};\n\nTHREE.ClearMaskPass.prototype = Object.create( THREE.Pass.prototype );\n\nObject.assign( THREE.ClearMaskPass.prototype, {\n\n\trender: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {\n\n\t\trenderer.state.buffers.stencil.setTest( false );\n\n\t}\n\n} );\n"
  },
  {
    "path": "WebContent/js/libs/OrbitControls.js",
    "content": "/**\n * @author qiao / https://github.com/qiao\n * @author mrdoob / http://mrdoob.com\n * @author alteredq / http://alteredqualia.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author erich666 / http://erichaines.com\n */\n\n// This set of controls performs orbiting, dollying (zooming), and panning.\n// Unlike TrackballControls, it maintains the \"up\" direction object.up (+Y by default).\n//\n//    Orbit - left mouse / touch: one-finger move\n//    Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish\n//    Pan - right mouse, or left mouse + ctrl/meta/shiftKey, or arrow keys / touch: two-finger move\n\nTHREE.OrbitControls = function ( object, domElement ) {\n\n\tthis.object = object;\n\n\tthis.domElement = ( domElement !== undefined ) ? domElement : document;\n\n\t// Set to false to disable this control\n\tthis.enabled = true;\n\n\t// \"target\" sets the location of focus, where the object orbits around\n\tthis.target = new THREE.Vector3();\n\n\t// How far you can dolly in and out ( PerspectiveCamera only )\n\tthis.minDistance = 0;\n\tthis.maxDistance = Infinity;\n\n\t// How far you can zoom in and out ( OrthographicCamera only )\n\tthis.minZoom = 0;\n\tthis.maxZoom = Infinity;\n\n\t// How far you can orbit vertically, upper and lower limits.\n\t// Range is 0 to Math.PI radians.\n\tthis.minPolarAngle = 0; // radians\n\tthis.maxPolarAngle = Math.PI; // radians\n\n\t// How far you can orbit horizontally, upper and lower limits.\n\t// If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ].\n\tthis.minAzimuthAngle = - Infinity; // radians\n\tthis.maxAzimuthAngle = Infinity; // radians\n\n\t// Set to true to enable damping (inertia)\n\t// If damping is enabled, you must call controls.update() in your animation loop\n\tthis.enableDamping = false;\n\tthis.dampingFactor = 0.25;\n\n\t// This option actually enables dollying in and out; left as \"zoom\" for backwards compatibility.\n\t// Set to false to disable zooming\n\tthis.enableZoom = true;\n\tthis.zoomSpeed = 1.0;\n\n\t// Set to false to disable rotating\n\tthis.enableRotate = true;\n\tthis.rotateSpeed = 1.0;\n\n\t// Set to false to disable panning\n\tthis.enablePan = true;\n\tthis.panSpeed = 1.0;\n\tthis.screenSpacePanning = false; // if true, pan in screen-space\n\tthis.keyPanSpeed = 7.0;\t// pixels moved per arrow key push\n\n\t// Set to true to automatically rotate around the target\n\t// If auto-rotate is enabled, you must call controls.update() in your animation loop\n\tthis.autoRotate = false;\n\tthis.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60\n\n\t// Set to false to disable use of the keys\n\tthis.enableKeys = true;\n\n\t// The four arrow keys\n\tthis.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };\n\n\t// Mouse buttons\n\tthis.mouseButtons = { LEFT: THREE.MOUSE.LEFT, MIDDLE: THREE.MOUSE.MIDDLE, RIGHT: THREE.MOUSE.RIGHT };\n\n\t// for reset\n\tthis.target0 = this.target.clone();\n\tthis.position0 = this.object.position.clone();\n\tthis.zoom0 = this.object.zoom;\n\n\t//\n\t// public methods\n\t//\n\n\tthis.getPolarAngle = function () {\n\n\t\treturn spherical.phi;\n\n\t};\n\n\tthis.getAzimuthalAngle = function () {\n\n\t\treturn spherical.theta;\n\n\t};\n\n\tthis.saveState = function () {\n\n\t\tscope.target0.copy( scope.target );\n\t\tscope.position0.copy( scope.object.position );\n\t\tscope.zoom0 = scope.object.zoom;\n\n\t};\n\n\tthis.reset = function () {\n\n\t\tscope.target.copy( scope.target0 );\n\t\tscope.object.position.copy( scope.position0 );\n\t\tscope.object.zoom = scope.zoom0;\n\n\t\tscope.object.updateProjectionMatrix();\n\t\tscope.dispatchEvent( changeEvent );\n\n\t\tscope.update();\n\n\t\tstate = STATE.NONE;\n\n\t};\n\n\t// this method is exposed, but perhaps it would be better if we can make it private...\n\tthis.update = function () {\n\n\t\tvar offset = new THREE.Vector3();\n\n\t\t// so camera.up is the orbit axis\n\t\tvar quat = new THREE.Quaternion().setFromUnitVectors( object.up, new THREE.Vector3( 0, 1, 0 ) );\n\t\tvar quatInverse = quat.clone().inverse();\n\n\t\tvar lastPosition = new THREE.Vector3();\n\t\tvar lastQuaternion = new THREE.Quaternion();\n\n\t\treturn function update() {\n\n\t\t\tvar position = scope.object.position;\n\n\t\t\toffset.copy( position ).sub( scope.target );\n\n\t\t\t// rotate offset to \"y-axis-is-up\" space\n\t\t\toffset.applyQuaternion( quat );\n\n\t\t\t// angle from z-axis around y-axis\n\t\t\tspherical.setFromVector3( offset );\n\n\t\t\tif ( scope.autoRotate && state === STATE.NONE ) {\n\n\t\t\t\trotateLeft( getAutoRotationAngle() );\n\n\t\t\t}\n\n\t\t\tspherical.theta += sphericalDelta.theta;\n\t\t\tspherical.phi += sphericalDelta.phi;\n\n\t\t\t// restrict theta to be between desired limits\n\t\t\tspherical.theta = Math.max( scope.minAzimuthAngle, Math.min( scope.maxAzimuthAngle, spherical.theta ) );\n\n\t\t\t// restrict phi to be between desired limits\n\t\t\tspherical.phi = Math.max( scope.minPolarAngle, Math.min( scope.maxPolarAngle, spherical.phi ) );\n\n\t\t\tspherical.makeSafe();\n\n\n\t\t\tspherical.radius *= scale;\n\n\t\t\t// restrict radius to be between desired limits\n\t\t\tspherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) );\n\n\t\t\t// move target to panned location\n\t\t\tscope.target.add( panOffset );\n\n\t\t\toffset.setFromSpherical( spherical );\n\n\t\t\t// rotate offset back to \"camera-up-vector-is-up\" space\n\t\t\toffset.applyQuaternion( quatInverse );\n\n\t\t\tposition.copy( scope.target ).add( offset );\n\n\t\t\tscope.object.lookAt( scope.target );\n\n\t\t\tif ( scope.enableDamping === true ) {\n\n\t\t\t\tsphericalDelta.theta *= ( 1 - scope.dampingFactor );\n\t\t\t\tsphericalDelta.phi *= ( 1 - scope.dampingFactor );\n\n\t\t\t\tpanOffset.multiplyScalar( 1 - scope.dampingFactor );\n\n\t\t\t} else {\n\n\t\t\t\tsphericalDelta.set( 0, 0, 0 );\n\n\t\t\t\tpanOffset.set( 0, 0, 0 );\n\n\t\t\t}\n\n\t\t\tscale = 1;\n\n\t\t\t// update condition is:\n\t\t\t// min(camera displacement, camera rotation in radians)^2 > EPS\n\t\t\t// using small-angle approximation cos(x/2) = 1 - x^2 / 8\n\n\t\t\tif ( zoomChanged ||\n\t\t\t\tlastPosition.distanceToSquared( scope.object.position ) > EPS ||\n\t\t\t\t8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) {\n\n\t\t\t\tscope.dispatchEvent( changeEvent );\n\n\t\t\t\tlastPosition.copy( scope.object.position );\n\t\t\t\tlastQuaternion.copy( scope.object.quaternion );\n\t\t\t\tzoomChanged = false;\n\n\t\t\t\treturn true;\n\n\t\t\t}\n\n\t\t\treturn false;\n\n\t\t};\n\n\t}();\n\n\tthis.dispose = function () {\n\n\t\tscope.domElement.removeEventListener( 'contextmenu', onContextMenu, false );\n\t\tscope.domElement.removeEventListener( 'mousedown', onMouseDown, false );\n\t\tscope.domElement.removeEventListener( 'wheel', onMouseWheel, false );\n\n\t\tscope.domElement.removeEventListener( 'touchstart', onTouchStart, false );\n\t\tscope.domElement.removeEventListener( 'touchend', onTouchEnd, false );\n\t\tscope.domElement.removeEventListener( 'touchmove', onTouchMove, false );\n\n\t\tdocument.removeEventListener( 'mousemove', onMouseMove, false );\n\t\tdocument.removeEventListener( 'mouseup', onMouseUp, false );\n\n\t\twindow.removeEventListener( 'keydown', onKeyDown, false );\n\n\t\t//scope.dispatchEvent( { type: 'dispose' } ); // should this be added here?\n\n\t};\n\n\t//\n\t// internals\n\t//\n\n\tvar scope = this;\n\n\tvar changeEvent = { type: 'change' };\n\tvar startEvent = { type: 'start' };\n\tvar endEvent = { type: 'end' };\n\n\tvar STATE = { NONE: - 1, ROTATE: 0, DOLLY: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_DOLLY_PAN: 4 };\n\n\tvar state = STATE.NONE;\n\n\tvar EPS = 0.000001;\n\n\t// current position in spherical coordinates\n\tvar spherical = new THREE.Spherical();\n\tvar sphericalDelta = new THREE.Spherical();\n\n\tvar scale = 1;\n\tvar panOffset = new THREE.Vector3();\n\tvar zoomChanged = false;\n\n\tvar rotateStart = new THREE.Vector2();\n\tvar rotateEnd = new THREE.Vector2();\n\tvar rotateDelta = new THREE.Vector2();\n\n\tvar panStart = new THREE.Vector2();\n\tvar panEnd = new THREE.Vector2();\n\tvar panDelta = new THREE.Vector2();\n\n\tvar dollyStart = new THREE.Vector2();\n\tvar dollyEnd = new THREE.Vector2();\n\tvar dollyDelta = new THREE.Vector2();\n\n\tfunction getAutoRotationAngle() {\n\n\t\treturn 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;\n\n\t}\n\n\tfunction getZoomScale() {\n\n\t\treturn Math.pow( 0.95, scope.zoomSpeed );\n\n\t}\n\n\tfunction rotateLeft( angle ) {\n\n\t\tsphericalDelta.theta -= angle;\n\n\t}\n\n\tfunction rotateUp( angle ) {\n\n\t\tsphericalDelta.phi -= angle;\n\n\t}\n\n\tvar panLeft = function () {\n\n\t\tvar v = new THREE.Vector3();\n\n\t\treturn function panLeft( distance, objectMatrix ) {\n\n\t\t\tv.setFromMatrixColumn( objectMatrix, 0 ); // get X column of objectMatrix\n\t\t\tv.multiplyScalar( - distance );\n\n\t\t\tpanOffset.add( v );\n\n\t\t};\n\n\t}();\n\n\tvar panUp = function () {\n\n\t\tvar v = new THREE.Vector3();\n\n\t\treturn function panUp( distance, objectMatrix ) {\n\n\t\t\tif ( scope.screenSpacePanning === true ) {\n\n\t\t\t\tv.setFromMatrixColumn( objectMatrix, 1 );\n\n\t\t\t} else {\n\n\t\t\t\tv.setFromMatrixColumn( objectMatrix, 0 );\n\t\t\t\tv.crossVectors( scope.object.up, v );\n\n\t\t\t}\n\n\t\t\tv.multiplyScalar( distance );\n\n\t\t\tpanOffset.add( v );\n\n\t\t};\n\n\t}();\n\n\t// deltaX and deltaY are in pixels; right and down are positive\n\tvar pan = function () {\n\n\t\tvar offset = new THREE.Vector3();\n\n\t\treturn function pan( deltaX, deltaY ) {\n\n\t\t\tvar element = scope.domElement === document ? scope.domElement.body : scope.domElement;\n\n\t\t\tif ( scope.object.isPerspectiveCamera ) {\n\n\t\t\t\t// perspective\n\t\t\t\tvar position = scope.object.position;\n\t\t\t\toffset.copy( position ).sub( scope.target );\n\t\t\t\tvar targetDistance = offset.length();\n\n\t\t\t\t// half of the fov is center to top of screen\n\t\t\t\ttargetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 );\n\n\t\t\t\t// we use only clientHeight here so aspect ratio does not distort speed\n\t\t\t\tpanLeft( 2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix );\n\t\t\t\tpanUp( 2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix );\n\n\t\t\t} else if ( scope.object.isOrthographicCamera ) {\n\n\t\t\t\t// orthographic\n\t\t\t\tpanLeft( deltaX * ( scope.object.right - scope.object.left ) / scope.object.zoom / element.clientWidth, scope.object.matrix );\n\t\t\t\tpanUp( deltaY * ( scope.object.top - scope.object.bottom ) / scope.object.zoom / element.clientHeight, scope.object.matrix );\n\n\t\t\t} else {\n\n\t\t\t\t// camera neither orthographic nor perspective\n\t\t\t\tconsole.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' );\n\t\t\t\tscope.enablePan = false;\n\n\t\t\t}\n\n\t\t};\n\n\t}();\n\n\tfunction dollyIn( dollyScale ) {\n\n\t\tif ( scope.object.isPerspectiveCamera ) {\n\n\t\t\tscale /= dollyScale;\n\n\t\t} else if ( scope.object.isOrthographicCamera ) {\n\n\t\t\tscope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom * dollyScale ) );\n\t\t\tscope.object.updateProjectionMatrix();\n\t\t\tzoomChanged = true;\n\n\t\t} else {\n\n\t\t\tconsole.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );\n\t\t\tscope.enableZoom = false;\n\n\t\t}\n\n\t}\n\n\tfunction dollyOut( dollyScale ) {\n\n\t\tif ( scope.object.isPerspectiveCamera ) {\n\n\t\t\tscale *= dollyScale;\n\n\t\t} else if ( scope.object.isOrthographicCamera ) {\n\n\t\t\tscope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / dollyScale ) );\n\t\t\tscope.object.updateProjectionMatrix();\n\t\t\tzoomChanged = true;\n\n\t\t} else {\n\n\t\t\tconsole.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );\n\t\t\tscope.enableZoom = false;\n\n\t\t}\n\n\t}\n\n\t//\n\t// event callbacks - update the object state\n\t//\n\n\tfunction handleMouseDownRotate( event ) {\n\n\t\t//console.log( 'handleMouseDownRotate' );\n\n\t\trotateStart.set( event.clientX, event.clientY );\n\n\t}\n\n\tfunction handleMouseDownDolly( event ) {\n\n\t\t//console.log( 'handleMouseDownDolly' );\n\n\t\tdollyStart.set( event.clientX, event.clientY );\n\n\t}\n\n\tfunction handleMouseDownPan( event ) {\n\n\t\t//console.log( 'handleMouseDownPan' );\n\n\t\tpanStart.set( event.clientX, event.clientY );\n\n\t}\n\n\tfunction handleMouseMoveRotate( event ) {\n\n\t\t//console.log( 'handleMouseMoveRotate' );\n\n\t\trotateEnd.set( event.clientX, event.clientY );\n\n\t\trotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed );\n\n\t\tvar element = scope.domElement === document ? scope.domElement.body : scope.domElement;\n\n\t\trotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height\n\n\t\trotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight );\n\n\t\trotateStart.copy( rotateEnd );\n\n\t\tscope.update();\n\n\t}\n\n\tfunction handleMouseMoveDolly( event ) {\n\n\t\t//console.log( 'handleMouseMoveDolly' );\n\n\t\tdollyEnd.set( event.clientX, event.clientY );\n\n\t\tdollyDelta.subVectors( dollyEnd, dollyStart );\n\n\t\tif ( dollyDelta.y > 0 ) {\n\n\t\t\tdollyIn( getZoomScale() );\n\n\t\t} else if ( dollyDelta.y < 0 ) {\n\n\t\t\tdollyOut( getZoomScale() );\n\n\t\t}\n\n\t\tdollyStart.copy( dollyEnd );\n\n\t\tscope.update();\n\n\t}\n\n\tfunction handleMouseMovePan( event ) {\n\n\t\t//console.log( 'handleMouseMovePan' );\n\n\t\tpanEnd.set( event.clientX, event.clientY );\n\n\t\tpanDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed );\n\n\t\tpan( panDelta.x, panDelta.y );\n\n\t\tpanStart.copy( panEnd );\n\n\t\tscope.update();\n\n\t}\n\n\tfunction handleMouseUp( event ) {\n\n\t\t// console.log( 'handleMouseUp' );\n\n\t}\n\n\tfunction handleMouseWheel( event ) {\n\n\t\t// console.log( 'handleMouseWheel' );\n\n\t\tif ( event.deltaY < 0 ) {\n\n\t\t\tdollyOut( getZoomScale() );\n\n\t\t} else if ( event.deltaY > 0 ) {\n\n\t\t\tdollyIn( getZoomScale() );\n\n\t\t}\n\n\t\tscope.update();\n\n\t}\n\n\tfunction handleKeyDown( event ) {\n\n\t\t//console.log( 'handleKeyDown' );\n\n\t\tswitch ( event.keyCode ) {\n\n\t\t\tcase scope.keys.UP:\n\t\t\t\tpan( 0, scope.keyPanSpeed );\n\t\t\t\tscope.update();\n\t\t\t\tbreak;\n\n\t\t\tcase scope.keys.BOTTOM:\n\t\t\t\tpan( 0, - scope.keyPanSpeed );\n\t\t\t\tscope.update();\n\t\t\t\tbreak;\n\n\t\t\tcase scope.keys.LEFT:\n\t\t\t\tpan( scope.keyPanSpeed, 0 );\n\t\t\t\tscope.update();\n\t\t\t\tbreak;\n\n\t\t\tcase scope.keys.RIGHT:\n\t\t\t\tpan( - scope.keyPanSpeed, 0 );\n\t\t\t\tscope.update();\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\tfunction handleTouchStartRotate( event ) {\n\n\t\t//console.log( 'handleTouchStartRotate' );\n\n\t\trotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );\n\n\t}\n\n\tfunction handleTouchStartDollyPan( event ) {\n\n\t\t//console.log( 'handleTouchStartDollyPan' );\n\n\t\tif ( scope.enableZoom ) {\n\n\t\t\tvar dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;\n\t\t\tvar dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;\n\n\t\t\tvar distance = Math.sqrt( dx * dx + dy * dy );\n\n\t\t\tdollyStart.set( 0, distance );\n\n\t\t}\n\n\t\tif ( scope.enablePan ) {\n\n\t\t\tvar x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX );\n\t\t\tvar y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY );\n\n\t\t\tpanStart.set( x, y );\n\n\t\t}\n\n\t}\n\n\tfunction handleTouchMoveRotate( event ) {\n\n\t\t//console.log( 'handleTouchMoveRotate' );\n\n\t\trotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );\n\n\t\trotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed );\n\n\t\tvar element = scope.domElement === document ? scope.domElement.body : scope.domElement;\n\n\t\trotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height\n\n\t\trotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight );\n\n\t\trotateStart.copy( rotateEnd );\n\n\t\tscope.update();\n\n\t}\n\n\tfunction handleTouchMoveDollyPan( event ) {\n\n\t\t//console.log( 'handleTouchMoveDollyPan' );\n\n\t\tif ( scope.enableZoom ) {\n\n\t\t\tvar dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;\n\t\t\tvar dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;\n\n\t\t\tvar distance = Math.sqrt( dx * dx + dy * dy );\n\n\t\t\tdollyEnd.set( 0, distance );\n\n\t\t\tdollyDelta.set( 0, Math.pow( dollyEnd.y / dollyStart.y, scope.zoomSpeed ) );\n\n\t\t\tdollyIn( dollyDelta.y );\n\n\t\t\tdollyStart.copy( dollyEnd );\n\n\t\t}\n\n\t\tif ( scope.enablePan ) {\n\n\t\t\tvar x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX );\n\t\t\tvar y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY );\n\n\t\t\tpanEnd.set( x, y );\n\n\t\t\tpanDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed );\n\n\t\t\tpan( panDelta.x, panDelta.y );\n\n\t\t\tpanStart.copy( panEnd );\n\n\t\t}\n\n\t\tscope.update();\n\n\t}\n\n\tfunction handleTouchEnd( event ) {\n\n\t\t//console.log( 'handleTouchEnd' );\n\n\t}\n\n\t//\n\t// event handlers - FSM: listen for events and reset state\n\t//\n\n\tfunction onMouseDown( event ) {\n\n\t\tif ( scope.enabled === false ) return;\n\n\t\tevent.preventDefault();\n\n\t\tswitch ( event.button ) {\n\n\t\t\tcase scope.mouseButtons.LEFT:\n\n\t\t\t\tif ( event.ctrlKey || event.metaKey || event.shiftKey ) {\n\n\t\t\t\t\tif ( scope.enablePan === false ) return;\n\n\t\t\t\t\thandleMouseDownPan( event );\n\n\t\t\t\t\tstate = STATE.PAN;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tif ( scope.enableRotate === false ) return;\n\n\t\t\t\t\thandleMouseDownRotate( event );\n\n\t\t\t\t\tstate = STATE.ROTATE;\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase scope.mouseButtons.MIDDLE:\n\n\t\t\t\tif ( scope.enableZoom === false ) return;\n\n\t\t\t\thandleMouseDownDolly( event );\n\n\t\t\t\tstate = STATE.DOLLY;\n\n\t\t\t\tbreak;\n\n\t\t\tcase scope.mouseButtons.RIGHT:\n\n\t\t\t\tif ( scope.enablePan === false ) return;\n\n\t\t\t\thandleMouseDownPan( event );\n\n\t\t\t\tstate = STATE.PAN;\n\n\t\t\t\tbreak;\n\n\t\t}\n\n\t\tif ( state !== STATE.NONE ) {\n\n\t\t\tdocument.addEventListener( 'mousemove', onMouseMove, false );\n\t\t\tdocument.addEventListener( 'mouseup', onMouseUp, false );\n\n\t\t\tscope.dispatchEvent( startEvent );\n\n\t\t}\n\n\t}\n\n\tfunction onMouseMove( event ) {\n\n\t\tif ( scope.enabled === false ) return;\n\n\t\tevent.preventDefault();\n\n\t\tswitch ( state ) {\n\n\t\t\tcase STATE.ROTATE:\n\n\t\t\t\tif ( scope.enableRotate === false ) return;\n\n\t\t\t\thandleMouseMoveRotate( event );\n\n\t\t\t\tbreak;\n\n\t\t\tcase STATE.DOLLY:\n\n\t\t\t\tif ( scope.enableZoom === false ) return;\n\n\t\t\t\thandleMouseMoveDolly( event );\n\n\t\t\t\tbreak;\n\n\t\t\tcase STATE.PAN:\n\n\t\t\t\tif ( scope.enablePan === false ) return;\n\n\t\t\t\thandleMouseMovePan( event );\n\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\tfunction onMouseUp( event ) {\n\n\t\tif ( scope.enabled === false ) return;\n\n\t\thandleMouseUp( event );\n\n\t\tdocument.removeEventListener( 'mousemove', onMouseMove, false );\n\t\tdocument.removeEventListener( 'mouseup', onMouseUp, false );\n\n\t\tscope.dispatchEvent( endEvent );\n\n\t\tstate = STATE.NONE;\n\n\t}\n\n\tfunction onMouseWheel( event ) {\n\n\t\tif ( scope.enabled === false || scope.enableZoom === false || ( state !== STATE.NONE && state !== STATE.ROTATE ) ) return;\n\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\tscope.dispatchEvent( startEvent );\n\n\t\thandleMouseWheel( event );\n\n\t\tscope.dispatchEvent( endEvent );\n\n\t}\n\n\tfunction onKeyDown( event ) {\n\n\t\tif ( scope.enabled === false || scope.enableKeys === false || scope.enablePan === false ) return;\n\n\t\thandleKeyDown( event );\n\n\t}\n\n\tfunction onTouchStart( event ) {\n\n\t\tif ( scope.enabled === false ) return;\n\n\t\tevent.preventDefault();\n\n\t\tswitch ( event.touches.length ) {\n\n\t\t\tcase 1:\t// one-fingered touch: rotate\n\n\t\t\t\tif ( scope.enableRotate === false ) return;\n\n\t\t\t\thandleTouchStartRotate( event );\n\n\t\t\t\tstate = STATE.TOUCH_ROTATE;\n\n\t\t\t\tbreak;\n\n\t\t\tcase 2:\t// two-fingered touch: dolly-pan\n\n\t\t\t\tif ( scope.enableZoom === false && scope.enablePan === false ) return;\n\n\t\t\t\thandleTouchStartDollyPan( event );\n\n\t\t\t\tstate = STATE.TOUCH_DOLLY_PAN;\n\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\n\t\t\t\tstate = STATE.NONE;\n\n\t\t}\n\n\t\tif ( state !== STATE.NONE ) {\n\n\t\t\tscope.dispatchEvent( startEvent );\n\n\t\t}\n\n\t}\n\n\tfunction onTouchMove( event ) {\n\n\t\tif ( scope.enabled === false ) return;\n\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\tswitch ( event.touches.length ) {\n\n\t\t\tcase 1: // one-fingered touch: rotate\n\n\t\t\t\tif ( scope.enableRotate === false ) return;\n\t\t\t\tif ( state !== STATE.TOUCH_ROTATE ) return; // is this needed?\n\n\t\t\t\thandleTouchMoveRotate( event );\n\n\t\t\t\tbreak;\n\n\t\t\tcase 2: // two-fingered touch: dolly-pan\n\n\t\t\t\tif ( scope.enableZoom === false && scope.enablePan === false ) return;\n\t\t\t\tif ( state !== STATE.TOUCH_DOLLY_PAN ) return; // is this needed?\n\n\t\t\t\thandleTouchMoveDollyPan( event );\n\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\n\t\t\t\tstate = STATE.NONE;\n\n\t\t}\n\n\t}\n\n\tfunction onTouchEnd( event ) {\n\n\t\tif ( scope.enabled === false ) return;\n\n\t\thandleTouchEnd( event );\n\n\t\tscope.dispatchEvent( endEvent );\n\n\t\tstate = STATE.NONE;\n\n\t}\n\n\tfunction onContextMenu( event ) {\n\n\t\tif ( scope.enabled === false ) return;\n\n\t\tevent.preventDefault();\n\n\t}\n\n\t//\n\n\tscope.domElement.addEventListener( 'contextmenu', onContextMenu, false );\n\n\tscope.domElement.addEventListener( 'mousedown', onMouseDown, false );\n\tscope.domElement.addEventListener( 'wheel', onMouseWheel, false );\n\n\tscope.domElement.addEventListener( 'touchstart', onTouchStart, false );\n\tscope.domElement.addEventListener( 'touchend', onTouchEnd, false );\n\tscope.domElement.addEventListener( 'touchmove', onTouchMove, false );\n\n\twindow.addEventListener( 'keydown', onKeyDown, false );\n\n\t// force an update at start\n\n\tthis.update();\n\n};\n\nTHREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype );\nTHREE.OrbitControls.prototype.constructor = THREE.OrbitControls;\n\nObject.defineProperties( THREE.OrbitControls.prototype, {\n\n\tcenter: {\n\n\t\tget: function () {\n\n\t\t\tconsole.warn( 'THREE.OrbitControls: .center has been renamed to .target' );\n\t\t\treturn this.target;\n\n\t\t}\n\n\t},\n\n\t// backward compatibility\n\n\tnoZoom: {\n\n\t\tget: function () {\n\n\t\t\tconsole.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' );\n\t\t\treturn ! this.enableZoom;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tconsole.warn( 'THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead.' );\n\t\t\tthis.enableZoom = ! value;\n\n\t\t}\n\n\t},\n\n\tnoRotate: {\n\n\t\tget: function () {\n\n\t\t\tconsole.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' );\n\t\t\treturn ! this.enableRotate;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tconsole.warn( 'THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead.' );\n\t\t\tthis.enableRotate = ! value;\n\n\t\t}\n\n\t},\n\n\tnoPan: {\n\n\t\tget: function () {\n\n\t\t\tconsole.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' );\n\t\t\treturn ! this.enablePan;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tconsole.warn( 'THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead.' );\n\t\t\tthis.enablePan = ! value;\n\n\t\t}\n\n\t},\n\n\tnoKeys: {\n\n\t\tget: function () {\n\n\t\t\tconsole.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' );\n\t\t\treturn ! this.enableKeys;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tconsole.warn( 'THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead.' );\n\t\t\tthis.enableKeys = ! value;\n\n\t\t}\n\n\t},\n\n\tstaticMoving: {\n\n\t\tget: function () {\n\n\t\t\tconsole.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' );\n\t\t\treturn ! this.enableDamping;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tconsole.warn( 'THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead.' );\n\t\t\tthis.enableDamping = ! value;\n\n\t\t}\n\n\t},\n\n\tdynamicDampingFactor: {\n\n\t\tget: function () {\n\n\t\t\tconsole.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' );\n\t\t\treturn this.dampingFactor;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tconsole.warn( 'THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead.' );\n\t\t\tthis.dampingFactor = value;\n\n\t\t}\n\n\t}\n\n} );\n"
  },
  {
    "path": "WebContent/js/libs/RenderPass.js",
    "content": "/**\n * @author alteredq / http://alteredqualia.com/\n */\n\nTHREE.RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) {\n\n\tTHREE.Pass.call( this );\n\n\tthis.scene = scene;\n\tthis.camera = camera;\n\n\tthis.overrideMaterial = overrideMaterial;\n\n\tthis.clearColor = clearColor;\n\tthis.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;\n\n\tthis.clear = true;\n\tthis.clearDepth = false;\n\tthis.needsSwap = false;\n\n};\n\nTHREE.RenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {\n\n\tconstructor: THREE.RenderPass,\n\n\trender: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {\n\n\t\tvar oldAutoClear = renderer.autoClear;\n\t\trenderer.autoClear = false;\n\n\t\tthis.scene.overrideMaterial = this.overrideMaterial;\n\n\t\tvar oldClearColor, oldClearAlpha;\n\n\t\tif ( this.clearColor ) {\n\n\t\t\toldClearColor = renderer.getClearColor().getHex();\n\t\t\toldClearAlpha = renderer.getClearAlpha();\n\n\t\t\trenderer.setClearColor( this.clearColor, this.clearAlpha );\n\n\t\t}\n\n\t\tif ( this.clearDepth ) {\n\n\t\t\trenderer.clearDepth();\n\n\t\t}\n\n\t\trenderer.render( this.scene, this.camera, this.renderToScreen ? null : readBuffer, this.clear );\n\n\t\tif ( this.clearColor ) {\n\n\t\t\trenderer.setClearColor( oldClearColor, oldClearAlpha );\n\n\t\t}\n\n\t\tthis.scene.overrideMaterial = null;\n\t\trenderer.autoClear = oldAutoClear;\n\t}\n\n} );\n"
  },
  {
    "path": "WebContent/js/libs/ShaderPass.js",
    "content": "/**\n * @author alteredq / http://alteredqualia.com/\n */\n\nTHREE.ShaderPass = function ( shader, textureID ) {\n\n\tTHREE.Pass.call( this );\n\n\tthis.textureID = ( textureID !== undefined ) ? textureID : \"tDiffuse\";\n\n\tif ( shader instanceof THREE.ShaderMaterial ) {\n\n\t\tthis.uniforms = shader.uniforms;\n\n\t\tthis.material = shader;\n\n\t} else if ( shader ) {\n\n\t\tthis.uniforms = THREE.UniformsUtils.clone( shader.uniforms );\n\n\t\tthis.material = new THREE.ShaderMaterial( {\n\n\t\t\tdefines: Object.assign( {}, shader.defines ),\n\t\t\tuniforms: this.uniforms,\n\t\t\tvertexShader: shader.vertexShader,\n\t\t\tfragmentShader: shader.fragmentShader\n\n\t\t} );\n\n\t}\n\n\tthis.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );\n\tthis.scene = new THREE.Scene();\n\n\tthis.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null );\n\tthis.quad.frustumCulled = false; // Avoid getting clipped\n\tthis.scene.add( this.quad );\n\n};\n\nTHREE.ShaderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {\n\n\tconstructor: THREE.ShaderPass,\n\n\trender: function( renderer, writeBuffer, readBuffer, delta, maskActive ) {\n\n\t\tif ( this.uniforms[ this.textureID ] ) {\n\n\t\t\tthis.uniforms[ this.textureID ].value = readBuffer.texture;\n\n\t\t}\n\n\t\tthis.quad.material = this.material;\n\n\t\tif ( this.renderToScreen ) {\n\n\t\t\trenderer.render( this.scene, this.camera );\n\n\t\t} else {\n\n\t\t\trenderer.render( this.scene, this.camera, writeBuffer, this.clear );\n\n\t\t}\n\n\t}\n\n} );\n"
  },
  {
    "path": "WebContent/js/libs/TrackballControls.js",
    "content": "/**\n * @author Eberhard Graether / http://egraether.com/\n * @author Mark Lundin \t/ http://mark-lundin.com\n * @author Simone Manini / http://daron1337.github.io\n * @author Luca Antiga \t/ http://lantiga.github.io\n */\n\nTHREE.TrackballControls = function ( object, domElement ) {\n\n\tvar _this = this;\n\tvar STATE = { NONE: - 1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM_PAN: 4 };\n\n\tthis.object = object;\n\tthis.domElement = ( domElement !== undefined ) ? domElement : document;\n\n\t// API\n\n\tthis.enabled = true;\n\n\tthis.screen = { left: 0, top: 0, width: 0, height: 0 };\n\n\tthis.rotateSpeed = 1.0;\n\tthis.zoomSpeed = 1.2;\n\tthis.panSpeed = 0.3;\n\n\tthis.noRotate = false;\n\tthis.noZoom = false;\n\tthis.noPan = false;\n\n\tthis.staticMoving = false;\n\tthis.dynamicDampingFactor = 0.2;\n\n\tthis.minDistance = 0;\n\tthis.maxDistance = Infinity;\n\n\tthis.keys = [ 65 /*A*/, 83 /*S*/, 68 /*D*/ ];\n\n\t// internals\n\n\tthis.target = new THREE.Vector3();\n\n\tvar EPS = 0.000001;\n\n\tvar lastPosition = new THREE.Vector3();\n\n\tvar _state = STATE.NONE,\n\t\t_prevState = STATE.NONE,\n\n\t\t_eye = new THREE.Vector3(),\n\n\t\t_movePrev = new THREE.Vector2(),\n\t\t_moveCurr = new THREE.Vector2(),\n\n\t\t_lastAxis = new THREE.Vector3(),\n\t\t_lastAngle = 0,\n\n\t\t_zoomStart = new THREE.Vector2(),\n\t\t_zoomEnd = new THREE.Vector2(),\n\n\t\t_touchZoomDistanceStart = 0,\n\t\t_touchZoomDistanceEnd = 0,\n\n\t\t_panStart = new THREE.Vector2(),\n\t\t_panEnd = new THREE.Vector2();\n\n\t// for reset\n\n\tthis.target0 = this.target.clone();\n\tthis.position0 = this.object.position.clone();\n\tthis.up0 = this.object.up.clone();\n\n\t// events\n\n\tvar changeEvent = { type: 'change' };\n\tvar startEvent = { type: 'start' };\n\tvar endEvent = { type: 'end' };\n\n\n\t// methods\n\n\tthis.handleResize = function () {\n\n\t\tif ( this.domElement === document ) {\n\n\t\t\tthis.screen.left = 0;\n\t\t\tthis.screen.top = 0;\n\t\t\tthis.screen.width = window.innerWidth;\n\t\t\tthis.screen.height = window.innerHeight;\n\n\t\t} else {\n\n\t\t\tvar box = this.domElement.getBoundingClientRect();\n\t\t\t// adjustments come from similar code in the jquery offset() function\n\t\t\tvar d = this.domElement.ownerDocument.documentElement;\n\t\t\tthis.screen.left = box.left + window.pageXOffset - d.clientLeft;\n\t\t\tthis.screen.top = box.top + window.pageYOffset - d.clientTop;\n\t\t\tthis.screen.width = box.width;\n\t\t\tthis.screen.height = box.height;\n\n\t\t}\n\n\t};\n\n\tvar getMouseOnScreen = ( function () {\n\n\t\tvar vector = new THREE.Vector2();\n\n\t\treturn function getMouseOnScreen( pageX, pageY ) {\n\n\t\t\tvector.set(\n\t\t\t\t( pageX - _this.screen.left ) / _this.screen.width,\n\t\t\t\t( pageY - _this.screen.top ) / _this.screen.height\n\t\t\t);\n\n\t\t\treturn vector;\n\n\t\t};\n\n\t}() );\n\n\tvar getMouseOnCircle = ( function () {\n\n\t\tvar vector = new THREE.Vector2();\n\n\t\treturn function getMouseOnCircle( pageX, pageY ) {\n\n\t\t\tvector.set(\n\t\t\t\t( ( pageX - _this.screen.width * 0.5 - _this.screen.left ) / ( _this.screen.width * 0.5 ) ),\n\t\t\t\t( ( _this.screen.height + 2 * ( _this.screen.top - pageY ) ) / _this.screen.width ) // screen.width intentional\n\t\t\t);\n\n\t\t\treturn vector;\n\n\t\t};\n\n\t}() );\n\n\tthis.rotateCamera = ( function () {\n\n\t\tvar axis = new THREE.Vector3(),\n\t\t\tquaternion = new THREE.Quaternion(),\n\t\t\teyeDirection = new THREE.Vector3(),\n\t\t\tobjectUpDirection = new THREE.Vector3(),\n\t\t\tobjectSidewaysDirection = new THREE.Vector3(),\n\t\t\tmoveDirection = new THREE.Vector3(),\n\t\t\tangle;\n\n\t\treturn function rotateCamera() {\n\n\t\t\tmoveDirection.set( _moveCurr.x - _movePrev.x, _moveCurr.y - _movePrev.y, 0 );\n\t\t\tangle = moveDirection.length();\n\n\t\t\tif ( angle ) {\n\n\t\t\t\t_eye.copy( _this.object.position ).sub( _this.target );\n\n\t\t\t\teyeDirection.copy( _eye ).normalize();\n\t\t\t\tobjectUpDirection.copy( _this.object.up ).normalize();\n\t\t\t\tobjectSidewaysDirection.crossVectors( objectUpDirection, eyeDirection ).normalize();\n\n\t\t\t\tobjectUpDirection.setLength( _moveCurr.y - _movePrev.y );\n\t\t\t\tobjectSidewaysDirection.setLength( _moveCurr.x - _movePrev.x );\n\n\t\t\t\tmoveDirection.copy( objectUpDirection.add( objectSidewaysDirection ) );\n\n\t\t\t\taxis.crossVectors( moveDirection, _eye ).normalize();\n\n\t\t\t\tangle *= _this.rotateSpeed;\n\t\t\t\tquaternion.setFromAxisAngle( axis, angle );\n\n\t\t\t\t_eye.applyQuaternion( quaternion );\n\t\t\t\t_this.object.up.applyQuaternion( quaternion );\n\n\t\t\t\t_lastAxis.copy( axis );\n\t\t\t\t_lastAngle = angle;\n\n\t\t\t} else if ( ! _this.staticMoving && _lastAngle ) {\n\n\t\t\t\t_lastAngle *= Math.sqrt( 1.0 - _this.dynamicDampingFactor );\n\t\t\t\t_eye.copy( _this.object.position ).sub( _this.target );\n\t\t\t\tquaternion.setFromAxisAngle( _lastAxis, _lastAngle );\n\t\t\t\t_eye.applyQuaternion( quaternion );\n\t\t\t\t_this.object.up.applyQuaternion( quaternion );\n\n\t\t\t}\n\n\t\t\t_movePrev.copy( _moveCurr );\n\n\t\t};\n\n\t}() );\n\n\n\tthis.zoomCamera = function () {\n\n\t\tvar factor;\n\n\t\tif ( _state === STATE.TOUCH_ZOOM_PAN ) {\n\n\t\t\tfactor = _touchZoomDistanceStart / _touchZoomDistanceEnd;\n\t\t\t_touchZoomDistanceStart = _touchZoomDistanceEnd;\n\t\t\t_eye.multiplyScalar( factor );\n\n\t\t} else {\n\n\t\t\tfactor = 1.0 + ( _zoomEnd.y - _zoomStart.y ) * _this.zoomSpeed;\n\n\t\t\tif ( factor !== 1.0 && factor > 0.0 ) {\n\n\t\t\t\t_eye.multiplyScalar( factor );\n\n\t\t\t}\n\n\t\t\tif ( _this.staticMoving ) {\n\n\t\t\t\t_zoomStart.copy( _zoomEnd );\n\n\t\t\t} else {\n\n\t\t\t\t_zoomStart.y += ( _zoomEnd.y - _zoomStart.y ) * this.dynamicDampingFactor;\n\n\t\t\t}\n\n\t\t}\n\n\t};\n\n\tthis.panCamera = ( function () {\n\n\t\tvar mouseChange = new THREE.Vector2(),\n\t\t\tobjectUp = new THREE.Vector3(),\n\t\t\tpan = new THREE.Vector3();\n\n\t\treturn function panCamera() {\n\n\t\t\tmouseChange.copy( _panEnd ).sub( _panStart );\n\n\t\t\tif ( mouseChange.lengthSq() ) {\n\n\t\t\t\tmouseChange.multiplyScalar( _eye.length() * _this.panSpeed );\n\n\t\t\t\tpan.copy( _eye ).cross( _this.object.up ).setLength( mouseChange.x );\n\t\t\t\tpan.add( objectUp.copy( _this.object.up ).setLength( mouseChange.y ) );\n\n\t\t\t\t_this.object.position.add( pan );\n\t\t\t\t_this.target.add( pan );\n\n\t\t\t\tif ( _this.staticMoving ) {\n\n\t\t\t\t\t_panStart.copy( _panEnd );\n\n\t\t\t\t} else {\n\n\t\t\t\t\t_panStart.add( mouseChange.subVectors( _panEnd, _panStart ).multiplyScalar( _this.dynamicDampingFactor ) );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t};\n\n\t}() );\n\n\tthis.checkDistances = function () {\n\n\t\tif ( ! _this.noZoom || ! _this.noPan ) {\n\n\t\t\tif ( _eye.lengthSq() > _this.maxDistance * _this.maxDistance ) {\n\n\t\t\t\t_this.object.position.addVectors( _this.target, _eye.setLength( _this.maxDistance ) );\n\t\t\t\t_zoomStart.copy( _zoomEnd );\n\n\t\t\t}\n\n\t\t\tif ( _eye.lengthSq() < _this.minDistance * _this.minDistance ) {\n\n\t\t\t\t_this.object.position.addVectors( _this.target, _eye.setLength( _this.minDistance ) );\n\t\t\t\t_zoomStart.copy( _zoomEnd );\n\n\t\t\t}\n\n\t\t}\n\n\t};\n\n\tthis.update = function () {\n\n\t\t_eye.subVectors( _this.object.position, _this.target );\n\n\t\tif ( ! _this.noRotate ) {\n\n\t\t\t_this.rotateCamera();\n\n\t\t}\n\n\t\tif ( ! _this.noZoom ) {\n\n\t\t\t_this.zoomCamera();\n\n\t\t}\n\n\t\tif ( ! _this.noPan ) {\n\n\t\t\t_this.panCamera();\n\n\t\t}\n\n\t\t_this.object.position.addVectors( _this.target, _eye );\n\n\t\t_this.checkDistances();\n\n\t\t_this.object.lookAt( _this.target );\n\n\t\tif ( lastPosition.distanceToSquared( _this.object.position ) > EPS ) {\n\n\t\t\t_this.dispatchEvent( changeEvent );\n\n\t\t\tlastPosition.copy( _this.object.position );\n\n\t\t}\n\n\t};\n\n\tthis.reset = function () {\n\n\t\t_state = STATE.NONE;\n\t\t_prevState = STATE.NONE;\n\n\t\t_this.target.copy( _this.target0 );\n\t\t_this.object.position.copy( _this.position0 );\n\t\t_this.object.up.copy( _this.up0 );\n\n\t\t_eye.subVectors( _this.object.position, _this.target );\n\n\t\t_this.object.lookAt( _this.target );\n\n\t\t_this.dispatchEvent( changeEvent );\n\n\t\tlastPosition.copy( _this.object.position );\n\n\t};\n\n\t// listeners\n\n\tfunction keydown( event ) {\n\n\t\tif ( _this.enabled === false ) return;\n\n\t\twindow.removeEventListener( 'keydown', keydown );\n\n\t\t_prevState = _state;\n\n\t\tif ( _state !== STATE.NONE ) {\n\n\t\t\treturn;\n\n\t\t} else if ( event.keyCode === _this.keys[ STATE.ROTATE ] && ! _this.noRotate ) {\n\n\t\t\t_state = STATE.ROTATE;\n\n\t\t} else if ( event.keyCode === _this.keys[ STATE.ZOOM ] && ! _this.noZoom ) {\n\n\t\t\t_state = STATE.ZOOM;\n\n\t\t} else if ( event.keyCode === _this.keys[ STATE.PAN ] && ! _this.noPan ) {\n\n\t\t\t_state = STATE.PAN;\n\n\t\t}\n\n\t}\n\n\tfunction keyup( event ) {\n\n\t\tif ( _this.enabled === false ) return;\n\n\t\t_state = _prevState;\n\n\t\twindow.addEventListener( 'keydown', keydown, false );\n\n\t}\n\n\tfunction mousedown( event ) {\n\n\t\tif ( _this.enabled === false ) return;\n\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\tif ( _state === STATE.NONE ) {\n\n\t\t\t_state = event.button;\n\n\t\t}\n\n\t\tif ( _state === STATE.ROTATE && ! _this.noRotate ) {\n\n\t\t\t_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );\n\t\t\t_movePrev.copy( _moveCurr );\n\n\t\t} else if ( _state === STATE.ZOOM && ! _this.noZoom ) {\n\n\t\t\t_zoomStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );\n\t\t\t_zoomEnd.copy( _zoomStart );\n\n\t\t} else if ( _state === STATE.PAN && ! _this.noPan ) {\n\n\t\t\t_panStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );\n\t\t\t_panEnd.copy( _panStart );\n\n\t\t}\n\n\t\tdocument.addEventListener( 'mousemove', mousemove, false );\n\t\tdocument.addEventListener( 'mouseup', mouseup, false );\n\n\t\t_this.dispatchEvent( startEvent );\n\n\t}\n\n\tfunction mousemove( event ) {\n\n\t\tif ( _this.enabled === false ) return;\n\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\tif ( _state === STATE.ROTATE && ! _this.noRotate ) {\n\n\t\t\t_movePrev.copy( _moveCurr );\n\t\t\t_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );\n\n\t\t} else if ( _state === STATE.ZOOM && ! _this.noZoom ) {\n\n\t\t\t_zoomEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );\n\n\t\t} else if ( _state === STATE.PAN && ! _this.noPan ) {\n\n\t\t\t_panEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );\n\n\t\t}\n\n\t}\n\n\tfunction mouseup( event ) {\n\n\t\tif ( _this.enabled === false ) return;\n\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\t_state = STATE.NONE;\n\n\t\tdocument.removeEventListener( 'mousemove', mousemove );\n\t\tdocument.removeEventListener( 'mouseup', mouseup );\n\t\t_this.dispatchEvent( endEvent );\n\n\t}\n\n\tfunction mousewheel( event ) {\n\n\t\tif ( _this.enabled === false ) return;\n\n\t\tif ( _this.noZoom === true ) return;\n\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\tswitch ( event.deltaMode ) {\n\n\t\t\tcase 2:\n\t\t\t\t// Zoom in pages\n\t\t\t\t_zoomStart.y -= event.deltaY * 0.025;\n\t\t\t\tbreak;\n\n\t\t\tcase 1:\n\t\t\t\t// Zoom in lines\n\t\t\t\t_zoomStart.y -= event.deltaY * 0.01;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\t// undefined, 0, assume pixels\n\t\t\t\t_zoomStart.y -= event.deltaY * 0.00025;\n\t\t\t\tbreak;\n\n\t\t}\n\n\t\t_this.dispatchEvent( startEvent );\n\t\t_this.dispatchEvent( endEvent );\n\n\t}\n\n\tfunction touchstart( event ) {\n\n\t\tif ( _this.enabled === false ) return;\n\t\t\n\t\tevent.preventDefault();\n\n\t\tswitch ( event.touches.length ) {\n\n\t\t\tcase 1:\n\t\t\t\t_state = STATE.TOUCH_ROTATE;\n\t\t\t\t_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );\n\t\t\t\t_movePrev.copy( _moveCurr );\n\t\t\t\tbreak;\n\n\t\t\tdefault: // 2 or more\n\t\t\t\t_state = STATE.TOUCH_ZOOM_PAN;\n\t\t\t\tvar dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;\n\t\t\t\tvar dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;\n\t\t\t\t_touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt( dx * dx + dy * dy );\n\n\t\t\t\tvar x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2;\n\t\t\t\tvar y = ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2;\n\t\t\t\t_panStart.copy( getMouseOnScreen( x, y ) );\n\t\t\t\t_panEnd.copy( _panStart );\n\t\t\t\tbreak;\n\n\t\t}\n\n\t\t_this.dispatchEvent( startEvent );\n\n\t}\n\n\tfunction touchmove( event ) {\n\n\t\tif ( _this.enabled === false ) return;\n\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\tswitch ( event.touches.length ) {\n\n\t\t\tcase 1:\n\t\t\t\t_movePrev.copy( _moveCurr );\n\t\t\t\t_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );\n\t\t\t\tbreak;\n\n\t\t\tdefault: // 2 or more\n\t\t\t\tvar dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;\n\t\t\t\tvar dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;\n\t\t\t\t_touchZoomDistanceEnd = Math.sqrt( dx * dx + dy * dy );\n\n\t\t\t\tvar x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2;\n\t\t\t\tvar y = ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2;\n\t\t\t\t_panEnd.copy( getMouseOnScreen( x, y ) );\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\tfunction touchend( event ) {\n\n\t\tif ( _this.enabled === false ) return;\n\n\t\tswitch ( event.touches.length ) {\n\n\t\t\tcase 0:\n\t\t\t\t_state = STATE.NONE;\n\t\t\t\tbreak;\n\n\t\t\tcase 1:\n\t\t\t\t_state = STATE.TOUCH_ROTATE;\n\t\t\t\t_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );\n\t\t\t\t_movePrev.copy( _moveCurr );\n\t\t\t\tbreak;\n\n\t\t}\n\n\t\t_this.dispatchEvent( endEvent );\n\n\t}\n\n\tfunction contextmenu( event ) {\n\n\t\tif ( _this.enabled === false ) return;\n\n\t\tevent.preventDefault();\n\n\t}\n\n\tthis.dispose = function () {\n\n\t\tthis.domElement.removeEventListener( 'contextmenu', contextmenu, false );\n\t\tthis.domElement.removeEventListener( 'mousedown', mousedown, false );\n\t\tthis.domElement.removeEventListener( 'wheel', mousewheel, false );\n\n\t\tthis.domElement.removeEventListener( 'touchstart', touchstart, false );\n\t\tthis.domElement.removeEventListener( 'touchend', touchend, false );\n\t\tthis.domElement.removeEventListener( 'touchmove', touchmove, false );\n\n\t\tdocument.removeEventListener( 'mousemove', mousemove, false );\n\t\tdocument.removeEventListener( 'mouseup', mouseup, false );\n\n\t\twindow.removeEventListener( 'keydown', keydown, false );\n\t\twindow.removeEventListener( 'keyup', keyup, false );\n\n\t};\n\n\tthis.domElement.addEventListener( 'contextmenu', contextmenu, false );\n\tthis.domElement.addEventListener( 'mousedown', mousedown, false );\n\tthis.domElement.addEventListener( 'wheel', mousewheel, false );\n\n\tthis.domElement.addEventListener( 'touchstart', touchstart, false );\n\tthis.domElement.addEventListener( 'touchend', touchend, false );\n\tthis.domElement.addEventListener( 'touchmove', touchmove, false );\n\n\twindow.addEventListener( 'keydown', keydown, false );\n\twindow.addEventListener( 'keyup', keyup, false );\n\n\tthis.handleResize();\n\n\t// force an update at start\n\tthis.update();\n\n};\n\nTHREE.TrackballControls.prototype = Object.create( THREE.EventDispatcher.prototype );\nTHREE.TrackballControls.prototype.constructor = THREE.TrackballControls;\n"
  },
  {
    "path": "WebContent/js/libs/dat.gui.js",
    "content": "/**\n * dat-gui JavaScript Controller Library\n * http://code.google.com/p/dat-gui\n *\n * Copyright 2011 Data Arts Team, Google Creative Lab\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n */\n\n(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\n\ttypeof define === 'function' && define.amd ? define(['exports'], factory) :\n\t(factory((global.dat = {})));\n}(this, (function (exports) { 'use strict';\n\nfunction ___$insertStyle(css) {\n  if (!css) {\n    return;\n  }\n  if (typeof window === 'undefined') {\n    return;\n  }\n\n  var style = document.createElement('style');\n\n  style.setAttribute('type', 'text/css');\n  style.innerHTML = css;\n  document.head.appendChild(style);\n\n  return css;\n}\n\nfunction colorToString (color, forceCSSHex) {\n  var colorFormat = color.__state.conversionName.toString();\n  var r = Math.round(color.r);\n  var g = Math.round(color.g);\n  var b = Math.round(color.b);\n  var a = color.a;\n  var h = Math.round(color.h);\n  var s = color.s.toFixed(1);\n  var v = color.v.toFixed(1);\n  if (forceCSSHex || colorFormat === 'THREE_CHAR_HEX' || colorFormat === 'SIX_CHAR_HEX') {\n    var str = color.hex.toString(16);\n    while (str.length < 6) {\n      str = '0' + str;\n    }\n    return '#' + str;\n  } else if (colorFormat === 'CSS_RGB') {\n    return 'rgb(' + r + ',' + g + ',' + b + ')';\n  } else if (colorFormat === 'CSS_RGBA') {\n    return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';\n  } else if (colorFormat === 'HEX') {\n    return '0x' + color.hex.toString(16);\n  } else if (colorFormat === 'RGB_ARRAY') {\n    return '[' + r + ',' + g + ',' + b + ']';\n  } else if (colorFormat === 'RGBA_ARRAY') {\n    return '[' + r + ',' + g + ',' + b + ',' + a + ']';\n  } else if (colorFormat === 'RGB_OBJ') {\n    return '{r:' + r + ',g:' + g + ',b:' + b + '}';\n  } else if (colorFormat === 'RGBA_OBJ') {\n    return '{r:' + r + ',g:' + g + ',b:' + b + ',a:' + a + '}';\n  } else if (colorFormat === 'HSV_OBJ') {\n    return '{h:' + h + ',s:' + s + ',v:' + v + '}';\n  } else if (colorFormat === 'HSVA_OBJ') {\n    return '{h:' + h + ',s:' + s + ',v:' + v + ',a:' + a + '}';\n  }\n  return 'unknown format';\n}\n\nvar ARR_EACH = Array.prototype.forEach;\nvar ARR_SLICE = Array.prototype.slice;\nvar Common = {\n  BREAK: {},\n  extend: function extend(target) {\n    this.each(ARR_SLICE.call(arguments, 1), function (obj) {\n      var keys = this.isObject(obj) ? Object.keys(obj) : [];\n      keys.forEach(function (key) {\n        if (!this.isUndefined(obj[key])) {\n          target[key] = obj[key];\n        }\n      }.bind(this));\n    }, this);\n    return target;\n  },\n  defaults: function defaults(target) {\n    this.each(ARR_SLICE.call(arguments, 1), function (obj) {\n      var keys = this.isObject(obj) ? Object.keys(obj) : [];\n      keys.forEach(function (key) {\n        if (this.isUndefined(target[key])) {\n          target[key] = obj[key];\n        }\n      }.bind(this));\n    }, this);\n    return target;\n  },\n  compose: function compose() {\n    var toCall = ARR_SLICE.call(arguments);\n    return function () {\n      var args = ARR_SLICE.call(arguments);\n      for (var i = toCall.length - 1; i >= 0; i--) {\n        args = [toCall[i].apply(this, args)];\n      }\n      return args[0];\n    };\n  },\n  each: function each(obj, itr, scope) {\n    if (!obj) {\n      return;\n    }\n    if (ARR_EACH && obj.forEach && obj.forEach === ARR_EACH) {\n      obj.forEach(itr, scope);\n    } else if (obj.length === obj.length + 0) {\n      var key = void 0;\n      var l = void 0;\n      for (key = 0, l = obj.length; key < l; key++) {\n        if (key in obj && itr.call(scope, obj[key], key) === this.BREAK) {\n          return;\n        }\n      }\n    } else {\n      for (var _key in obj) {\n        if (itr.call(scope, obj[_key], _key) === this.BREAK) {\n          return;\n        }\n      }\n    }\n  },\n  defer: function defer(fnc) {\n    setTimeout(fnc, 0);\n  },\n  debounce: function debounce(func, threshold, callImmediately) {\n    var timeout = void 0;\n    return function () {\n      var obj = this;\n      var args = arguments;\n      function delayed() {\n        timeout = null;\n        if (!callImmediately) func.apply(obj, args);\n      }\n      var callNow = callImmediately || !timeout;\n      clearTimeout(timeout);\n      timeout = setTimeout(delayed, threshold);\n      if (callNow) {\n        func.apply(obj, args);\n      }\n    };\n  },\n  toArray: function toArray(obj) {\n    if (obj.toArray) return obj.toArray();\n    return ARR_SLICE.call(obj);\n  },\n  isUndefined: function isUndefined(obj) {\n    return obj === undefined;\n  },\n  isNull: function isNull(obj) {\n    return obj === null;\n  },\n  isNaN: function (_isNaN) {\n    function isNaN(_x) {\n      return _isNaN.apply(this, arguments);\n    }\n    isNaN.toString = function () {\n      return _isNaN.toString();\n    };\n    return isNaN;\n  }(function (obj) {\n    return isNaN(obj);\n  }),\n  isArray: Array.isArray || function (obj) {\n    return obj.constructor === Array;\n  },\n  isObject: function isObject(obj) {\n    return obj === Object(obj);\n  },\n  isNumber: function isNumber(obj) {\n    return obj === obj + 0;\n  },\n  isString: function isString(obj) {\n    return obj === obj + '';\n  },\n  isBoolean: function isBoolean(obj) {\n    return obj === false || obj === true;\n  },\n  isFunction: function isFunction(obj) {\n    return Object.prototype.toString.call(obj) === '[object Function]';\n  }\n};\n\nvar INTERPRETATIONS = [\n{\n  litmus: Common.isString,\n  conversions: {\n    THREE_CHAR_HEX: {\n      read: function read(original) {\n        var test = original.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);\n        if (test === null) {\n          return false;\n        }\n        return {\n          space: 'HEX',\n          hex: parseInt('0x' + test[1].toString() + test[1].toString() + test[2].toString() + test[2].toString() + test[3].toString() + test[3].toString(), 0)\n        };\n      },\n      write: colorToString\n    },\n    SIX_CHAR_HEX: {\n      read: function read(original) {\n        var test = original.match(/^#([A-F0-9]{6})$/i);\n        if (test === null) {\n          return false;\n        }\n        return {\n          space: 'HEX',\n          hex: parseInt('0x' + test[1].toString(), 0)\n        };\n      },\n      write: colorToString\n    },\n    CSS_RGB: {\n      read: function read(original) {\n        var test = original.match(/^rgb\\(\\s*(.+)\\s*,\\s*(.+)\\s*,\\s*(.+)\\s*\\)/);\n        if (test === null) {\n          return false;\n        }\n        return {\n          space: 'RGB',\n          r: parseFloat(test[1]),\n          g: parseFloat(test[2]),\n          b: parseFloat(test[3])\n        };\n      },\n      write: colorToString\n    },\n    CSS_RGBA: {\n      read: function read(original) {\n        var test = original.match(/^rgba\\(\\s*(.+)\\s*,\\s*(.+)\\s*,\\s*(.+)\\s*,\\s*(.+)\\s*\\)/);\n        if (test === null) {\n          return false;\n        }\n        return {\n          space: 'RGB',\n          r: parseFloat(test[1]),\n          g: parseFloat(test[2]),\n          b: parseFloat(test[3]),\n          a: parseFloat(test[4])\n        };\n      },\n      write: colorToString\n    }\n  }\n},\n{\n  litmus: Common.isNumber,\n  conversions: {\n    HEX: {\n      read: function read(original) {\n        return {\n          space: 'HEX',\n          hex: original,\n          conversionName: 'HEX'\n        };\n      },\n      write: function write(color) {\n        return color.hex;\n      }\n    }\n  }\n},\n{\n  litmus: Common.isArray,\n  conversions: {\n    RGB_ARRAY: {\n      read: function read(original) {\n        if (original.length !== 3) {\n          return false;\n        }\n        return {\n          space: 'RGB',\n          r: original[0],\n          g: original[1],\n          b: original[2]\n        };\n      },\n      write: function write(color) {\n        return [color.r, color.g, color.b];\n      }\n    },\n    RGBA_ARRAY: {\n      read: function read(original) {\n        if (original.length !== 4) return false;\n        return {\n          space: 'RGB',\n          r: original[0],\n          g: original[1],\n          b: original[2],\n          a: original[3]\n        };\n      },\n      write: function write(color) {\n        return [color.r, color.g, color.b, color.a];\n      }\n    }\n  }\n},\n{\n  litmus: Common.isObject,\n  conversions: {\n    RGBA_OBJ: {\n      read: function read(original) {\n        if (Common.isNumber(original.r) && Common.isNumber(original.g) && Common.isNumber(original.b) && Common.isNumber(original.a)) {\n          return {\n            space: 'RGB',\n            r: original.r,\n            g: original.g,\n            b: original.b,\n            a: original.a\n          };\n        }\n        return false;\n      },\n      write: function write(color) {\n        return {\n          r: color.r,\n          g: color.g,\n          b: color.b,\n          a: color.a\n        };\n      }\n    },\n    RGB_OBJ: {\n      read: function read(original) {\n        if (Common.isNumber(original.r) && Common.isNumber(original.g) && Common.isNumber(original.b)) {\n          return {\n            space: 'RGB',\n            r: original.r,\n            g: original.g,\n            b: original.b\n          };\n        }\n        return false;\n      },\n      write: function write(color) {\n        return {\n          r: color.r,\n          g: color.g,\n          b: color.b\n        };\n      }\n    },\n    HSVA_OBJ: {\n      read: function read(original) {\n        if (Common.isNumber(original.h) && Common.isNumber(original.s) && Common.isNumber(original.v) && Common.isNumber(original.a)) {\n          return {\n            space: 'HSV',\n            h: original.h,\n            s: original.s,\n            v: original.v,\n            a: original.a\n          };\n        }\n        return false;\n      },\n      write: function write(color) {\n        return {\n          h: color.h,\n          s: color.s,\n          v: color.v,\n          a: color.a\n        };\n      }\n    },\n    HSV_OBJ: {\n      read: function read(original) {\n        if (Common.isNumber(original.h) && Common.isNumber(original.s) && Common.isNumber(original.v)) {\n          return {\n            space: 'HSV',\n            h: original.h,\n            s: original.s,\n            v: original.v\n          };\n        }\n        return false;\n      },\n      write: function write(color) {\n        return {\n          h: color.h,\n          s: color.s,\n          v: color.v\n        };\n      }\n    }\n  }\n}];\nvar result = void 0;\nvar toReturn = void 0;\nvar interpret = function interpret() {\n  toReturn = false;\n  var original = arguments.length > 1 ? Common.toArray(arguments) : arguments[0];\n  Common.each(INTERPRETATIONS, function (family) {\n    if (family.litmus(original)) {\n      Common.each(family.conversions, function (conversion, conversionName) {\n        result = conversion.read(original);\n        if (toReturn === false && result !== false) {\n          toReturn = result;\n          result.conversionName = conversionName;\n          result.conversion = conversion;\n          return Common.BREAK;\n        }\n      });\n      return Common.BREAK;\n    }\n  });\n  return toReturn;\n};\n\nvar tmpComponent = void 0;\nvar ColorMath = {\n  hsv_to_rgb: function hsv_to_rgb(h, s, v) {\n    var hi = Math.floor(h / 60) % 6;\n    var f = h / 60 - Math.floor(h / 60);\n    var p = v * (1.0 - s);\n    var q = v * (1.0 - f * s);\n    var t = v * (1.0 - (1.0 - f) * s);\n    var c = [[v, t, p], [q, v, p], [p, v, t], [p, q, v], [t, p, v], [v, p, q]][hi];\n    return {\n      r: c[0] * 255,\n      g: c[1] * 255,\n      b: c[2] * 255\n    };\n  },\n  rgb_to_hsv: function rgb_to_hsv(r, g, b) {\n    var min = Math.min(r, g, b);\n    var max = Math.max(r, g, b);\n    var delta = max - min;\n    var h = void 0;\n    var s = void 0;\n    if (max !== 0) {\n      s = delta / max;\n    } else {\n      return {\n        h: NaN,\n        s: 0,\n        v: 0\n      };\n    }\n    if (r === max) {\n      h = (g - b) / delta;\n    } else if (g === max) {\n      h = 2 + (b - r) / delta;\n    } else {\n      h = 4 + (r - g) / delta;\n    }\n    h /= 6;\n    if (h < 0) {\n      h += 1;\n    }\n    return {\n      h: h * 360,\n      s: s,\n      v: max / 255\n    };\n  },\n  rgb_to_hex: function rgb_to_hex(r, g, b) {\n    var hex = this.hex_with_component(0, 2, r);\n    hex = this.hex_with_component(hex, 1, g);\n    hex = this.hex_with_component(hex, 0, b);\n    return hex;\n  },\n  component_from_hex: function component_from_hex(hex, componentIndex) {\n    return hex >> componentIndex * 8 & 0xFF;\n  },\n  hex_with_component: function hex_with_component(hex, componentIndex, value) {\n    return value << (tmpComponent = componentIndex * 8) | hex & ~(0xFF << tmpComponent);\n  }\n};\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) {\n  return typeof obj;\n} : function (obj) {\n  return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n};\n\n\n\n\n\n\n\n\n\n\n\nvar classCallCheck = function (instance, Constructor) {\n  if (!(instance instanceof Constructor)) {\n    throw new TypeError(\"Cannot call a class as a function\");\n  }\n};\n\nvar createClass = function () {\n  function defineProperties(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n\n  return function (Constructor, protoProps, staticProps) {\n    if (protoProps) defineProperties(Constructor.prototype, protoProps);\n    if (staticProps) defineProperties(Constructor, staticProps);\n    return Constructor;\n  };\n}();\n\n\n\n\n\n\n\nvar get = function get(object, property, receiver) {\n  if (object === null) object = Function.prototype;\n  var desc = Object.getOwnPropertyDescriptor(object, property);\n\n  if (desc === undefined) {\n    var parent = Object.getPrototypeOf(object);\n\n    if (parent === null) {\n      return undefined;\n    } else {\n      return get(parent, property, receiver);\n    }\n  } else if (\"value\" in desc) {\n    return desc.value;\n  } else {\n    var getter = desc.get;\n\n    if (getter === undefined) {\n      return undefined;\n    }\n\n    return getter.call(receiver);\n  }\n};\n\nvar inherits = function (subClass, superClass) {\n  if (typeof superClass !== \"function\" && superClass !== null) {\n    throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass);\n  }\n\n  subClass.prototype = Object.create(superClass && superClass.prototype, {\n    constructor: {\n      value: subClass,\n      enumerable: false,\n      writable: true,\n      configurable: true\n    }\n  });\n  if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;\n};\n\n\n\n\n\n\n\n\n\n\n\nvar possibleConstructorReturn = function (self, call) {\n  if (!self) {\n    throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n  }\n\n  return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self;\n};\n\nvar Color = function () {\n  function Color() {\n    classCallCheck(this, Color);\n    this.__state = interpret.apply(this, arguments);\n    if (this.__state === false) {\n      throw new Error('Failed to interpret color arguments');\n    }\n    this.__state.a = this.__state.a || 1;\n  }\n  createClass(Color, [{\n    key: 'toString',\n    value: function toString() {\n      return colorToString(this);\n    }\n  }, {\n    key: 'toHexString',\n    value: function toHexString() {\n      return colorToString(this, true);\n    }\n  }, {\n    key: 'toOriginal',\n    value: function toOriginal() {\n      return this.__state.conversion.write(this);\n    }\n  }]);\n  return Color;\n}();\nfunction defineRGBComponent(target, component, componentHexIndex) {\n  Object.defineProperty(target, component, {\n    get: function get$$1() {\n      if (this.__state.space === 'RGB') {\n        return this.__state[component];\n      }\n      Color.recalculateRGB(this, component, componentHexIndex);\n      return this.__state[component];\n    },\n    set: function set$$1(v) {\n      if (this.__state.space !== 'RGB') {\n        Color.recalculateRGB(this, component, componentHexIndex);\n        this.__state.space = 'RGB';\n      }\n      this.__state[component] = v;\n    }\n  });\n}\nfunction defineHSVComponent(target, component) {\n  Object.defineProperty(target, component, {\n    get: function get$$1() {\n      if (this.__state.space === 'HSV') {\n        return this.__state[component];\n      }\n      Color.recalculateHSV(this);\n      return this.__state[component];\n    },\n    set: function set$$1(v) {\n      if (this.__state.space !== 'HSV') {\n        Color.recalculateHSV(this);\n        this.__state.space = 'HSV';\n      }\n      this.__state[component] = v;\n    }\n  });\n}\nColor.recalculateRGB = function (color, component, componentHexIndex) {\n  if (color.__state.space === 'HEX') {\n    color.__state[component] = ColorMath.component_from_hex(color.__state.hex, componentHexIndex);\n  } else if (color.__state.space === 'HSV') {\n    Common.extend(color.__state, ColorMath.hsv_to_rgb(color.__state.h, color.__state.s, color.__state.v));\n  } else {\n    throw new Error('Corrupted color state');\n  }\n};\nColor.recalculateHSV = function (color) {\n  var result = ColorMath.rgb_to_hsv(color.r, color.g, color.b);\n  Common.extend(color.__state, {\n    s: result.s,\n    v: result.v\n  });\n  if (!Common.isNaN(result.h)) {\n    color.__state.h = result.h;\n  } else if (Common.isUndefined(color.__state.h)) {\n    color.__state.h = 0;\n  }\n};\nColor.COMPONENTS = ['r', 'g', 'b', 'h', 's', 'v', 'hex', 'a'];\ndefineRGBComponent(Color.prototype, 'r', 2);\ndefineRGBComponent(Color.prototype, 'g', 1);\ndefineRGBComponent(Color.prototype, 'b', 0);\ndefineHSVComponent(Color.prototype, 'h');\ndefineHSVComponent(Color.prototype, 's');\ndefineHSVComponent(Color.prototype, 'v');\nObject.defineProperty(Color.prototype, 'a', {\n  get: function get$$1() {\n    return this.__state.a;\n  },\n  set: function set$$1(v) {\n    this.__state.a = v;\n  }\n});\nObject.defineProperty(Color.prototype, 'hex', {\n  get: function get$$1() {\n    if (!this.__state.space !== 'HEX') {\n      this.__state.hex = ColorMath.rgb_to_hex(this.r, this.g, this.b);\n    }\n    return this.__state.hex;\n  },\n  set: function set$$1(v) {\n    this.__state.space = 'HEX';\n    this.__state.hex = v;\n  }\n});\n\nvar Controller = function () {\n  function Controller(object, property) {\n    classCallCheck(this, Controller);\n    this.initialValue = object[property];\n    this.domElement = document.createElement('div');\n    this.object = object;\n    this.property = property;\n    this.__onChange = undefined;\n    this.__onFinishChange = undefined;\n  }\n  createClass(Controller, [{\n    key: 'onChange',\n    value: function onChange(fnc) {\n      this.__onChange = fnc;\n      return this;\n    }\n  }, {\n    key: 'onFinishChange',\n    value: function onFinishChange(fnc) {\n      this.__onFinishChange = fnc;\n      return this;\n    }\n  }, {\n    key: 'setValue',\n    value: function setValue(newValue) {\n      this.object[this.property] = newValue;\n      if (this.__onChange) {\n        this.__onChange.call(this, newValue);\n      }\n      this.updateDisplay();\n      return this;\n    }\n  }, {\n    key: 'getValue',\n    value: function getValue() {\n      return this.object[this.property];\n    }\n  }, {\n    key: 'updateDisplay',\n    value: function updateDisplay() {\n      return this;\n    }\n  }, {\n    key: 'isModified',\n    value: function isModified() {\n      return this.initialValue !== this.getValue();\n    }\n  }]);\n  return Controller;\n}();\n\nvar EVENT_MAP = {\n  HTMLEvents: ['change'],\n  MouseEvents: ['click', 'mousemove', 'mousedown', 'mouseup', 'mouseover'],\n  KeyboardEvents: ['keydown']\n};\nvar EVENT_MAP_INV = {};\nCommon.each(EVENT_MAP, function (v, k) {\n  Common.each(v, function (e) {\n    EVENT_MAP_INV[e] = k;\n  });\n});\nvar CSS_VALUE_PIXELS = /(\\d+(\\.\\d+)?)px/;\nfunction cssValueToPixels(val) {\n  if (val === '0' || Common.isUndefined(val)) {\n    return 0;\n  }\n  var match = val.match(CSS_VALUE_PIXELS);\n  if (!Common.isNull(match)) {\n    return parseFloat(match[1]);\n  }\n  return 0;\n}\nvar dom = {\n  makeSelectable: function makeSelectable(elem, selectable) {\n    if (elem === undefined || elem.style === undefined) return;\n    elem.onselectstart = selectable ? function () {\n      return false;\n    } : function () {};\n    elem.style.MozUserSelect = selectable ? 'auto' : 'none';\n    elem.style.KhtmlUserSelect = selectable ? 'auto' : 'none';\n    elem.unselectable = selectable ? 'on' : 'off';\n  },\n  makeFullscreen: function makeFullscreen(elem, hor, vert) {\n    var vertical = vert;\n    var horizontal = hor;\n    if (Common.isUndefined(horizontal)) {\n      horizontal = true;\n    }\n    if (Common.isUndefined(vertical)) {\n      vertical = true;\n    }\n    elem.style.position = 'absolute';\n    if (horizontal) {\n      elem.style.left = 0;\n      elem.style.right = 0;\n    }\n    if (vertical) {\n      elem.style.top = 0;\n      elem.style.bottom = 0;\n    }\n  },\n  fakeEvent: function fakeEvent(elem, eventType, pars, aux) {\n    var params = pars || {};\n    var className = EVENT_MAP_INV[eventType];\n    if (!className) {\n      throw new Error('Event type ' + eventType + ' not supported.');\n    }\n    var evt = document.createEvent(className);\n    switch (className) {\n      case 'MouseEvents':\n        {\n          var clientX = params.x || params.clientX || 0;\n          var clientY = params.y || params.clientY || 0;\n          evt.initMouseEvent(eventType, params.bubbles || false, params.cancelable || true, window, params.clickCount || 1, 0,\n          0,\n          clientX,\n          clientY,\n          false, false, false, false, 0, null);\n          break;\n        }\n      case 'KeyboardEvents':\n        {\n          var init = evt.initKeyboardEvent || evt.initKeyEvent;\n          Common.defaults(params, {\n            cancelable: true,\n            ctrlKey: false,\n            altKey: false,\n            shiftKey: false,\n            metaKey: false,\n            keyCode: undefined,\n            charCode: undefined\n          });\n          init(eventType, params.bubbles || false, params.cancelable, window, params.ctrlKey, params.altKey, params.shiftKey, params.metaKey, params.keyCode, params.charCode);\n          break;\n        }\n      default:\n        {\n          evt.initEvent(eventType, params.bubbles || false, params.cancelable || true);\n          break;\n        }\n    }\n    Common.defaults(evt, aux);\n    elem.dispatchEvent(evt);\n  },\n  bind: function bind(elem, event, func, newBool) {\n    var bool = newBool || false;\n    if (elem.addEventListener) {\n      elem.addEventListener(event, func, bool);\n    } else if (elem.attachEvent) {\n      elem.attachEvent('on' + event, func);\n    }\n    return dom;\n  },\n  unbind: function unbind(elem, event, func, newBool) {\n    var bool = newBool || false;\n    if (elem.removeEventListener) {\n      elem.removeEventListener(event, func, bool);\n    } else if (elem.detachEvent) {\n      elem.detachEvent('on' + event, func);\n    }\n    return dom;\n  },\n  addClass: function addClass(elem, className) {\n    if (elem.className === undefined) {\n      elem.className = className;\n    } else if (elem.className !== className) {\n      var classes = elem.className.split(/ +/);\n      if (classes.indexOf(className) === -1) {\n        classes.push(className);\n        elem.className = classes.join(' ').replace(/^\\s+/, '').replace(/\\s+$/, '');\n      }\n    }\n    return dom;\n  },\n  removeClass: function removeClass(elem, className) {\n    if (className) {\n      if (elem.className === className) {\n        elem.removeAttribute('class');\n      } else {\n        var classes = elem.className.split(/ +/);\n        var index = classes.indexOf(className);\n        if (index !== -1) {\n          classes.splice(index, 1);\n          elem.className = classes.join(' ');\n        }\n      }\n    } else {\n      elem.className = undefined;\n    }\n    return dom;\n  },\n  hasClass: function hasClass(elem, className) {\n    return new RegExp('(?:^|\\\\s+)' + className + '(?:\\\\s+|$)').test(elem.className) || false;\n  },\n  getWidth: function getWidth(elem) {\n    var style = getComputedStyle(elem);\n    return cssValueToPixels(style['border-left-width']) + cssValueToPixels(style['border-right-width']) + cssValueToPixels(style['padding-left']) + cssValueToPixels(style['padding-right']) + cssValueToPixels(style.width);\n  },\n  getHeight: function getHeight(elem) {\n    var style = getComputedStyle(elem);\n    return cssValueToPixels(style['border-top-width']) + cssValueToPixels(style['border-bottom-width']) + cssValueToPixels(style['padding-top']) + cssValueToPixels(style['padding-bottom']) + cssValueToPixels(style.height);\n  },\n  getOffset: function getOffset(el) {\n    var elem = el;\n    var offset = { left: 0, top: 0 };\n    if (elem.offsetParent) {\n      do {\n        offset.left += elem.offsetLeft;\n        offset.top += elem.offsetTop;\n        elem = elem.offsetParent;\n      } while (elem);\n    }\n    return offset;\n  },\n  isActive: function isActive(elem) {\n    return elem === document.activeElement && (elem.type || elem.href);\n  }\n};\n\nvar BooleanController = function (_Controller) {\n  inherits(BooleanController, _Controller);\n  function BooleanController(object, property) {\n    classCallCheck(this, BooleanController);\n    var _this2 = possibleConstructorReturn(this, (BooleanController.__proto__ || Object.getPrototypeOf(BooleanController)).call(this, object, property));\n    var _this = _this2;\n    _this2.__prev = _this2.getValue();\n    _this2.__checkbox = document.createElement('input');\n    _this2.__checkbox.setAttribute('type', 'checkbox');\n    function onChange() {\n      _this.setValue(!_this.__prev);\n    }\n    dom.bind(_this2.__checkbox, 'change', onChange, false);\n    _this2.domElement.appendChild(_this2.__checkbox);\n    _this2.updateDisplay();\n    return _this2;\n  }\n  createClass(BooleanController, [{\n    key: 'setValue',\n    value: function setValue(v) {\n      var toReturn = get(BooleanController.prototype.__proto__ || Object.getPrototypeOf(BooleanController.prototype), 'setValue', this).call(this, v);\n      if (this.__onFinishChange) {\n        this.__onFinishChange.call(this, this.getValue());\n      }\n      this.__prev = this.getValue();\n      return toReturn;\n    }\n  }, {\n    key: 'updateDisplay',\n    value: function updateDisplay() {\n      if (this.getValue() === true) {\n        this.__checkbox.setAttribute('checked', 'checked');\n        this.__checkbox.checked = true;\n        this.__prev = true;\n      } else {\n        this.__checkbox.checked = false;\n        this.__prev = false;\n      }\n      return get(BooleanController.prototype.__proto__ || Object.getPrototypeOf(BooleanController.prototype), 'updateDisplay', this).call(this);\n    }\n  }]);\n  return BooleanController;\n}(Controller);\n\nvar OptionController = function (_Controller) {\n  inherits(OptionController, _Controller);\n  function OptionController(object, property, opts) {\n    classCallCheck(this, OptionController);\n    var _this2 = possibleConstructorReturn(this, (OptionController.__proto__ || Object.getPrototypeOf(OptionController)).call(this, object, property));\n    var options = opts;\n    var _this = _this2;\n    _this2.__select = document.createElement('select');\n    if (Common.isArray(options)) {\n      var map = {};\n      Common.each(options, function (element) {\n        map[element] = element;\n      });\n      options = map;\n    }\n    Common.each(options, function (value, key) {\n      var opt = document.createElement('option');\n      opt.innerHTML = key;\n      opt.setAttribute('value', value);\n      _this.__select.appendChild(opt);\n    });\n    _this2.updateDisplay();\n    dom.bind(_this2.__select, 'change', function () {\n      var desiredValue = this.options[this.selectedIndex].value;\n      _this.setValue(desiredValue);\n    });\n    _this2.domElement.appendChild(_this2.__select);\n    return _this2;\n  }\n  createClass(OptionController, [{\n    key: 'setValue',\n    value: function setValue(v) {\n      var toReturn = get(OptionController.prototype.__proto__ || Object.getPrototypeOf(OptionController.prototype), 'setValue', this).call(this, v);\n      if (this.__onFinishChange) {\n        this.__onFinishChange.call(this, this.getValue());\n      }\n      return toReturn;\n    }\n  }, {\n    key: 'updateDisplay',\n    value: function updateDisplay() {\n      if (dom.isActive(this.__select)) return this;\n      this.__select.value = this.getValue();\n      return get(OptionController.prototype.__proto__ || Object.getPrototypeOf(OptionController.prototype), 'updateDisplay', this).call(this);\n    }\n  }]);\n  return OptionController;\n}(Controller);\n\nvar StringController = function (_Controller) {\n  inherits(StringController, _Controller);\n  function StringController(object, property) {\n    classCallCheck(this, StringController);\n    var _this2 = possibleConstructorReturn(this, (StringController.__proto__ || Object.getPrototypeOf(StringController)).call(this, object, property));\n    var _this = _this2;\n    function onChange() {\n      _this.setValue(_this.__input.value);\n    }\n    function onBlur() {\n      if (_this.__onFinishChange) {\n        _this.__onFinishChange.call(_this, _this.getValue());\n      }\n    }\n    _this2.__input = document.createElement('input');\n    _this2.__input.setAttribute('type', 'text');\n    dom.bind(_this2.__input, 'keyup', onChange);\n    dom.bind(_this2.__input, 'change', onChange);\n    dom.bind(_this2.__input, 'blur', onBlur);\n    dom.bind(_this2.__input, 'keydown', function (e) {\n      if (e.keyCode === 13) {\n        this.blur();\n      }\n    });\n    _this2.updateDisplay();\n    _this2.domElement.appendChild(_this2.__input);\n    return _this2;\n  }\n  createClass(StringController, [{\n    key: 'updateDisplay',\n    value: function updateDisplay() {\n      if (!dom.isActive(this.__input)) {\n        this.__input.value = this.getValue();\n      }\n      return get(StringController.prototype.__proto__ || Object.getPrototypeOf(StringController.prototype), 'updateDisplay', this).call(this);\n    }\n  }]);\n  return StringController;\n}(Controller);\n\nfunction numDecimals(x) {\n  var _x = x.toString();\n  if (_x.indexOf('.') > -1) {\n    return _x.length - _x.indexOf('.') - 1;\n  }\n  return 0;\n}\nvar NumberController = function (_Controller) {\n  inherits(NumberController, _Controller);\n  function NumberController(object, property, params) {\n    classCallCheck(this, NumberController);\n    var _this = possibleConstructorReturn(this, (NumberController.__proto__ || Object.getPrototypeOf(NumberController)).call(this, object, property));\n    var _params = params || {};\n    _this.__min = _params.min;\n    _this.__max = _params.max;\n    _this.__step = _params.step;\n    if (Common.isUndefined(_this.__step)) {\n      if (_this.initialValue === 0) {\n        _this.__impliedStep = 1;\n      } else {\n        _this.__impliedStep = Math.pow(10, Math.floor(Math.log(Math.abs(_this.initialValue)) / Math.LN10)) / 10;\n      }\n    } else {\n      _this.__impliedStep = _this.__step;\n    }\n    _this.__precision = numDecimals(_this.__impliedStep);\n    return _this;\n  }\n  createClass(NumberController, [{\n    key: 'setValue',\n    value: function setValue(v) {\n      var _v = v;\n      if (this.__min !== undefined && _v < this.__min) {\n        _v = this.__min;\n      } else if (this.__max !== undefined && _v > this.__max) {\n        _v = this.__max;\n      }\n      if (this.__step !== undefined && _v % this.__step !== 0) {\n        _v = Math.round(_v / this.__step) * this.__step;\n      }\n      return get(NumberController.prototype.__proto__ || Object.getPrototypeOf(NumberController.prototype), 'setValue', this).call(this, _v);\n    }\n  }, {\n    key: 'min',\n    value: function min(minValue) {\n      this.__min = minValue;\n      return this;\n    }\n  }, {\n    key: 'max',\n    value: function max(maxValue) {\n      this.__max = maxValue;\n      return this;\n    }\n  }, {\n    key: 'step',\n    value: function step(stepValue) {\n      this.__step = stepValue;\n      this.__impliedStep = stepValue;\n      this.__precision = numDecimals(stepValue);\n      return this;\n    }\n  }]);\n  return NumberController;\n}(Controller);\n\nfunction roundToDecimal(value, decimals) {\n  var tenTo = Math.pow(10, decimals);\n  return Math.round(value * tenTo) / tenTo;\n}\nvar NumberControllerBox = function (_NumberController) {\n  inherits(NumberControllerBox, _NumberController);\n  function NumberControllerBox(object, property, params) {\n    classCallCheck(this, NumberControllerBox);\n    var _this2 = possibleConstructorReturn(this, (NumberControllerBox.__proto__ || Object.getPrototypeOf(NumberControllerBox)).call(this, object, property, params));\n    _this2.__truncationSuspended = false;\n    var _this = _this2;\n    var prevY = void 0;\n    function onChange() {\n      var attempted = parseFloat(_this.__input.value);\n      if (!Common.isNaN(attempted)) {\n        _this.setValue(attempted);\n      }\n    }\n    function onFinish() {\n      if (_this.__onFinishChange) {\n        _this.__onFinishChange.call(_this, _this.getValue());\n      }\n    }\n    function onBlur() {\n      onFinish();\n    }\n    function onMouseDrag(e) {\n      var diff = prevY - e.clientY;\n      _this.setValue(_this.getValue() + diff * _this.__impliedStep);\n      prevY = e.clientY;\n    }\n    function onMouseUp() {\n      dom.unbind(window, 'mousemove', onMouseDrag);\n      dom.unbind(window, 'mouseup', onMouseUp);\n      onFinish();\n    }\n    function onMouseDown(e) {\n      dom.bind(window, 'mousemove', onMouseDrag);\n      dom.bind(window, 'mouseup', onMouseUp);\n      prevY = e.clientY;\n    }\n    _this2.__input = document.createElement('input');\n    _this2.__input.setAttribute('type', 'text');\n    dom.bind(_this2.__input, 'change', onChange);\n    dom.bind(_this2.__input, 'blur', onBlur);\n    dom.bind(_this2.__input, 'mousedown', onMouseDown);\n    dom.bind(_this2.__input, 'keydown', function (e) {\n      if (e.keyCode === 13) {\n        _this.__truncationSuspended = true;\n        this.blur();\n        _this.__truncationSuspended = false;\n        onFinish();\n      }\n    });\n    _this2.updateDisplay();\n    _this2.domElement.appendChild(_this2.__input);\n    return _this2;\n  }\n  createClass(NumberControllerBox, [{\n    key: 'updateDisplay',\n    value: function updateDisplay() {\n      this.__input.value = this.__truncationSuspended ? this.getValue() : roundToDecimal(this.getValue(), this.__precision);\n      return get(NumberControllerBox.prototype.__proto__ || Object.getPrototypeOf(NumberControllerBox.prototype), 'updateDisplay', this).call(this);\n    }\n  }]);\n  return NumberControllerBox;\n}(NumberController);\n\nfunction map(v, i1, i2, o1, o2) {\n  return o1 + (o2 - o1) * ((v - i1) / (i2 - i1));\n}\nvar NumberControllerSlider = function (_NumberController) {\n  inherits(NumberControllerSlider, _NumberController);\n  function NumberControllerSlider(object, property, min, max, step) {\n    classCallCheck(this, NumberControllerSlider);\n    var _this2 = possibleConstructorReturn(this, (NumberControllerSlider.__proto__ || Object.getPrototypeOf(NumberControllerSlider)).call(this, object, property, { min: min, max: max, step: step }));\n    var _this = _this2;\n    _this2.__background = document.createElement('div');\n    _this2.__foreground = document.createElement('div');\n    dom.bind(_this2.__background, 'mousedown', onMouseDown);\n    dom.bind(_this2.__background, 'touchstart', onTouchStart);\n    dom.addClass(_this2.__background, 'slider');\n    dom.addClass(_this2.__foreground, 'slider-fg');\n    function onMouseDown(e) {\n      document.activeElement.blur();\n      dom.bind(window, 'mousemove', onMouseDrag);\n      dom.bind(window, 'mouseup', onMouseUp);\n      onMouseDrag(e);\n    }\n    function onMouseDrag(e) {\n      e.preventDefault();\n      var bgRect = _this.__background.getBoundingClientRect();\n      _this.setValue(map(e.clientX, bgRect.left, bgRect.right, _this.__min, _this.__max));\n      return false;\n    }\n    function onMouseUp() {\n      dom.unbind(window, 'mousemove', onMouseDrag);\n      dom.unbind(window, 'mouseup', onMouseUp);\n      if (_this.__onFinishChange) {\n        _this.__onFinishChange.call(_this, _this.getValue());\n      }\n    }\n    function onTouchStart(e) {\n      if (e.touches.length !== 1) {\n        return;\n      }\n      dom.bind(window, 'touchmove', onTouchMove);\n      dom.bind(window, 'touchend', onTouchEnd);\n      onTouchMove(e);\n    }\n    function onTouchMove(e) {\n      var clientX = e.touches[0].clientX;\n      var bgRect = _this.__background.getBoundingClientRect();\n      _this.setValue(map(clientX, bgRect.left, bgRect.right, _this.__min, _this.__max));\n    }\n    function onTouchEnd() {\n      dom.unbind(window, 'touchmove', onTouchMove);\n      dom.unbind(window, 'touchend', onTouchEnd);\n      if (_this.__onFinishChange) {\n        _this.__onFinishChange.call(_this, _this.getValue());\n      }\n    }\n    _this2.updateDisplay();\n    _this2.__background.appendChild(_this2.__foreground);\n    _this2.domElement.appendChild(_this2.__background);\n    return _this2;\n  }\n  createClass(NumberControllerSlider, [{\n    key: 'updateDisplay',\n    value: function updateDisplay() {\n      var pct = (this.getValue() - this.__min) / (this.__max - this.__min);\n      this.__foreground.style.width = pct * 100 + '%';\n      return get(NumberControllerSlider.prototype.__proto__ || Object.getPrototypeOf(NumberControllerSlider.prototype), 'updateDisplay', this).call(this);\n    }\n  }]);\n  return NumberControllerSlider;\n}(NumberController);\n\nvar FunctionController = function (_Controller) {\n  inherits(FunctionController, _Controller);\n  function FunctionController(object, property, text) {\n    classCallCheck(this, FunctionController);\n    var _this2 = possibleConstructorReturn(this, (FunctionController.__proto__ || Object.getPrototypeOf(FunctionController)).call(this, object, property));\n    var _this = _this2;\n    _this2.__button = document.createElement('div');\n    _this2.__button.innerHTML = text === undefined ? 'Fire' : text;\n    dom.bind(_this2.__button, 'click', function (e) {\n      e.preventDefault();\n      _this.fire();\n      return false;\n    });\n    dom.addClass(_this2.__button, 'button');\n    _this2.domElement.appendChild(_this2.__button);\n    return _this2;\n  }\n  createClass(FunctionController, [{\n    key: 'fire',\n    value: function fire() {\n      if (this.__onChange) {\n        this.__onChange.call(this);\n      }\n      this.getValue().call(this.object);\n      if (this.__onFinishChange) {\n        this.__onFinishChange.call(this, this.getValue());\n      }\n    }\n  }]);\n  return FunctionController;\n}(Controller);\n\nvar ColorController = function (_Controller) {\n  inherits(ColorController, _Controller);\n  function ColorController(object, property) {\n    classCallCheck(this, ColorController);\n    var _this2 = possibleConstructorReturn(this, (ColorController.__proto__ || Object.getPrototypeOf(ColorController)).call(this, object, property));\n    _this2.__color = new Color(_this2.getValue());\n    _this2.__temp = new Color(0);\n    var _this = _this2;\n    _this2.domElement = document.createElement('div');\n    dom.makeSelectable(_this2.domElement, false);\n    _this2.__selector = document.createElement('div');\n    _this2.__selector.className = 'selector';\n    _this2.__saturation_field = document.createElement('div');\n    _this2.__saturation_field.className = 'saturation-field';\n    _this2.__field_knob = document.createElement('div');\n    _this2.__field_knob.className = 'field-knob';\n    _this2.__field_knob_border = '2px solid ';\n    _this2.__hue_knob = document.createElement('div');\n    _this2.__hue_knob.className = 'hue-knob';\n    _this2.__hue_field = document.createElement('div');\n    _this2.__hue_field.className = 'hue-field';\n    _this2.__input = document.createElement('input');\n    _this2.__input.type = 'text';\n    _this2.__input_textShadow = '0 1px 1px ';\n    dom.bind(_this2.__input, 'keydown', function (e) {\n      if (e.keyCode === 13) {\n        onBlur.call(this);\n      }\n    });\n    dom.bind(_this2.__input, 'blur', onBlur);\n    dom.bind(_this2.__selector, 'mousedown', function ()        {\n      dom.addClass(this, 'drag').bind(window, 'mouseup', function ()        {\n        dom.removeClass(_this.__selector, 'drag');\n      });\n    });\n    dom.bind(_this2.__selector, 'touchstart', function ()        {\n      dom.addClass(this, 'drag').bind(window, 'touchend', function ()        {\n        dom.removeClass(_this.__selector, 'drag');\n      });\n    });\n    var valueField = document.createElement('div');\n    Common.extend(_this2.__selector.style, {\n      width: '122px',\n      height: '102px',\n      padding: '3px',\n      backgroundColor: '#222',\n      boxShadow: '0px 1px 3px rgba(0,0,0,0.3)'\n    });\n    Common.extend(_this2.__field_knob.style, {\n      position: 'absolute',\n      width: '12px',\n      height: '12px',\n      border: _this2.__field_knob_border + (_this2.__color.v < 0.5 ? '#fff' : '#000'),\n      boxShadow: '0px 1px 3px rgba(0,0,0,0.5)',\n      borderRadius: '12px',\n      zIndex: 1\n    });\n    Common.extend(_this2.__hue_knob.style, {\n      position: 'absolute',\n      width: '15px',\n      height: '2px',\n      borderRight: '4px solid #fff',\n      zIndex: 1\n    });\n    Common.extend(_this2.__saturation_field.style, {\n      width: '100px',\n      height: '100px',\n      border: '1px solid #555',\n      marginRight: '3px',\n      display: 'inline-block',\n      cursor: 'pointer'\n    });\n    Common.extend(valueField.style, {\n      width: '100%',\n      height: '100%',\n      background: 'none'\n    });\n    linearGradient(valueField, 'top', 'rgba(0,0,0,0)', '#000');\n    Common.extend(_this2.__hue_field.style, {\n      width: '15px',\n      height: '100px',\n      border: '1px solid #555',\n      cursor: 'ns-resize',\n      position: 'absolute',\n      top: '3px',\n      right: '3px'\n    });\n    hueGradient(_this2.__hue_field);\n    Common.extend(_this2.__input.style, {\n      outline: 'none',\n      textAlign: 'center',\n      color: '#fff',\n      border: 0,\n      fontWeight: 'bold',\n      textShadow: _this2.__input_textShadow + 'rgba(0,0,0,0.7)'\n    });\n    dom.bind(_this2.__saturation_field, 'mousedown', fieldDown);\n    dom.bind(_this2.__saturation_field, 'touchstart', fieldDown);\n    dom.bind(_this2.__field_knob, 'mousedown', fieldDown);\n    dom.bind(_this2.__field_knob, 'touchstart', fieldDown);\n    dom.bind(_this2.__hue_field, 'mousedown', fieldDownH);\n    dom.bind(_this2.__hue_field, 'touchstart', fieldDownH);\n    function fieldDown(e) {\n      setSV(e);\n      dom.bind(window, 'mousemove', setSV);\n      dom.bind(window, 'touchmove', setSV);\n      dom.bind(window, 'mouseup', fieldUpSV);\n      dom.bind(window, 'touchend', fieldUpSV);\n    }\n    function fieldDownH(e) {\n      setH(e);\n      dom.bind(window, 'mousemove', setH);\n      dom.bind(window, 'touchmove', setH);\n      dom.bind(window, 'mouseup', fieldUpH);\n      dom.bind(window, 'touchend', fieldUpH);\n    }\n    function fieldUpSV() {\n      dom.unbind(window, 'mousemove', setSV);\n      dom.unbind(window, 'touchmove', setSV);\n      dom.unbind(window, 'mouseup', fieldUpSV);\n      dom.unbind(window, 'touchend', fieldUpSV);\n      onFinish();\n    }\n    function fieldUpH() {\n      dom.unbind(window, 'mousemove', setH);\n      dom.unbind(window, 'touchmove', setH);\n      dom.unbind(window, 'mouseup', fieldUpH);\n      dom.unbind(window, 'touchend', fieldUpH);\n      onFinish();\n    }\n    function onBlur() {\n      var i = interpret(this.value);\n      if (i !== false) {\n        _this.__color.__state = i;\n        _this.setValue(_this.__color.toOriginal());\n      } else {\n        this.value = _this.__color.toString();\n      }\n    }\n    function onFinish() {\n      if (_this.__onFinishChange) {\n        _this.__onFinishChange.call(_this, _this.__color.toOriginal());\n      }\n    }\n    _this2.__saturation_field.appendChild(valueField);\n    _this2.__selector.appendChild(_this2.__field_knob);\n    _this2.__selector.appendChild(_this2.__saturation_field);\n    _this2.__selector.appendChild(_this2.__hue_field);\n    _this2.__hue_field.appendChild(_this2.__hue_knob);\n    _this2.domElement.appendChild(_this2.__input);\n    _this2.domElement.appendChild(_this2.__selector);\n    _this2.updateDisplay();\n    function setSV(e) {\n      if (e.type.indexOf('touch') === -1) {\n        e.preventDefault();\n      }\n      var fieldRect = _this.__saturation_field.getBoundingClientRect();\n      var _ref = e.touches && e.touches[0] || e,\n          clientX = _ref.clientX,\n          clientY = _ref.clientY;\n      var s = (clientX - fieldRect.left) / (fieldRect.right - fieldRect.left);\n      var v = 1 - (clientY - fieldRect.top) / (fieldRect.bottom - fieldRect.top);\n      if (v > 1) {\n        v = 1;\n      } else if (v < 0) {\n        v = 0;\n      }\n      if (s > 1) {\n        s = 1;\n      } else if (s < 0) {\n        s = 0;\n      }\n      _this.__color.v = v;\n      _this.__color.s = s;\n      _this.setValue(_this.__color.toOriginal());\n      return false;\n    }\n    function setH(e) {\n      if (e.type.indexOf('touch') === -1) {\n        e.preventDefault();\n      }\n      var fieldRect = _this.__hue_field.getBoundingClientRect();\n      var _ref2 = e.touches && e.touches[0] || e,\n          clientY = _ref2.clientY;\n      var h = 1 - (clientY - fieldRect.top) / (fieldRect.bottom - fieldRect.top);\n      if (h > 1) {\n        h = 1;\n      } else if (h < 0) {\n        h = 0;\n      }\n      _this.__color.h = h * 360;\n      _this.setValue(_this.__color.toOriginal());\n      return false;\n    }\n    return _this2;\n  }\n  createClass(ColorController, [{\n    key: 'updateDisplay',\n    value: function updateDisplay() {\n      var i = interpret(this.getValue());\n      if (i !== false) {\n        var mismatch = false;\n        Common.each(Color.COMPONENTS, function (component) {\n          if (!Common.isUndefined(i[component]) && !Common.isUndefined(this.__color.__state[component]) && i[component] !== this.__color.__state[component]) {\n            mismatch = true;\n            return {};\n          }\n        }, this);\n        if (mismatch) {\n          Common.extend(this.__color.__state, i);\n        }\n      }\n      Common.extend(this.__temp.__state, this.__color.__state);\n      this.__temp.a = 1;\n      var flip = this.__color.v < 0.5 || this.__color.s > 0.5 ? 255 : 0;\n      var _flip = 255 - flip;\n      Common.extend(this.__field_knob.style, {\n        marginLeft: 100 * this.__color.s - 7 + 'px',\n        marginTop: 100 * (1 - this.__color.v) - 7 + 'px',\n        backgroundColor: this.__temp.toHexString(),\n        border: this.__field_knob_border + 'rgb(' + flip + ',' + flip + ',' + flip + ')'\n      });\n      this.__hue_knob.style.marginTop = (1 - this.__color.h / 360) * 100 + 'px';\n      this.__temp.s = 1;\n      this.__temp.v = 1;\n      linearGradient(this.__saturation_field, 'left', '#fff', this.__temp.toHexString());\n      this.__input.value = this.__color.toString();\n      Common.extend(this.__input.style, {\n        backgroundColor: this.__color.toHexString(),\n        color: 'rgb(' + flip + ',' + flip + ',' + flip + ')',\n        textShadow: this.__input_textShadow + 'rgba(' + _flip + ',' + _flip + ',' + _flip + ',.7)'\n      });\n    }\n  }]);\n  return ColorController;\n}(Controller);\nvar vendors = ['-moz-', '-o-', '-webkit-', '-ms-', ''];\nfunction linearGradient(elem, x, a, b) {\n  elem.style.background = '';\n  Common.each(vendors, function (vendor) {\n    elem.style.cssText += 'background: ' + vendor + 'linear-gradient(' + x + ', ' + a + ' 0%, ' + b + ' 100%); ';\n  });\n}\nfunction hueGradient(elem) {\n  elem.style.background = '';\n  elem.style.cssText += 'background: -moz-linear-gradient(top,  #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);';\n  elem.style.cssText += 'background: -webkit-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);';\n  elem.style.cssText += 'background: -o-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);';\n  elem.style.cssText += 'background: -ms-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);';\n  elem.style.cssText += 'background: linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);';\n}\n\nvar css = {\n  load: function load(url, indoc) {\n    var doc = indoc || document;\n    var link = doc.createElement('link');\n    link.type = 'text/css';\n    link.rel = 'stylesheet';\n    link.href = url;\n    doc.getElementsByTagName('head')[0].appendChild(link);\n  },\n  inject: function inject(cssContent, indoc) {\n    var doc = indoc || document;\n    var injected = document.createElement('style');\n    injected.type = 'text/css';\n    injected.innerHTML = cssContent;\n    var head = doc.getElementsByTagName('head')[0];\n    try {\n      head.appendChild(injected);\n    } catch (e) {\n    }\n  }\n};\n\nvar saveDialogContents = \"<div id=\\\"dg-save\\\" class=\\\"dg dialogue\\\">\\n\\n  Here's the new load parameter for your <code>GUI</code>'s constructor:\\n\\n  <textarea id=\\\"dg-new-constructor\\\"></textarea>\\n\\n  <div id=\\\"dg-save-locally\\\">\\n\\n    <input id=\\\"dg-local-storage\\\" type=\\\"checkbox\\\"/> Automatically save\\n    values to <code>localStorage</code> on exit.\\n\\n    <div id=\\\"dg-local-explain\\\">The values saved to <code>localStorage</code> will\\n      override those passed to <code>dat.GUI</code>'s constructor. This makes it\\n      easier to work incrementally, but <code>localStorage</code> is fragile,\\n      and your friends may not see the same values you do.\\n\\n    </div>\\n\\n  </div>\\n\\n</div>\";\n\nvar ControllerFactory = function ControllerFactory(object, property) {\n  var initialValue = object[property];\n  if (Common.isArray(arguments[2]) || Common.isObject(arguments[2])) {\n    return new OptionController(object, property, arguments[2]);\n  }\n  if (Common.isNumber(initialValue)) {\n    if (Common.isNumber(arguments[2]) && Common.isNumber(arguments[3])) {\n      if (Common.isNumber(arguments[4])) {\n        return new NumberControllerSlider(object, property, arguments[2], arguments[3], arguments[4]);\n      }\n      return new NumberControllerSlider(object, property, arguments[2], arguments[3]);\n    }\n    if (Common.isNumber(arguments[4])) {\n      return new NumberControllerBox(object, property, { min: arguments[2], max: arguments[3], step: arguments[4] });\n    }\n    return new NumberControllerBox(object, property, { min: arguments[2], max: arguments[3] });\n  }\n  if (Common.isString(initialValue)) {\n    return new StringController(object, property);\n  }\n  if (Common.isFunction(initialValue)) {\n    return new FunctionController(object, property, '');\n  }\n  if (Common.isBoolean(initialValue)) {\n    return new BooleanController(object, property);\n  }\n  return null;\n};\n\nfunction requestAnimationFrame(callback) {\n  setTimeout(callback, 1000 / 60);\n}\nvar requestAnimationFrame$1 = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || requestAnimationFrame;\n\nvar CenteredDiv = function () {\n  function CenteredDiv() {\n    classCallCheck(this, CenteredDiv);\n    this.backgroundElement = document.createElement('div');\n    Common.extend(this.backgroundElement.style, {\n      backgroundColor: 'rgba(0,0,0,0.8)',\n      top: 0,\n      left: 0,\n      display: 'none',\n      zIndex: '1000',\n      opacity: 0,\n      WebkitTransition: 'opacity 0.2s linear',\n      transition: 'opacity 0.2s linear'\n    });\n    dom.makeFullscreen(this.backgroundElement);\n    this.backgroundElement.style.position = 'fixed';\n    this.domElement = document.createElement('div');\n    Common.extend(this.domElement.style, {\n      position: 'fixed',\n      display: 'none',\n      zIndex: '1001',\n      opacity: 0,\n      WebkitTransition: '-webkit-transform 0.2s ease-out, opacity 0.2s linear',\n      transition: 'transform 0.2s ease-out, opacity 0.2s linear'\n    });\n    document.body.appendChild(this.backgroundElement);\n    document.body.appendChild(this.domElement);\n    var _this = this;\n    dom.bind(this.backgroundElement, 'click', function () {\n      _this.hide();\n    });\n  }\n  createClass(CenteredDiv, [{\n    key: 'show',\n    value: function show() {\n      var _this = this;\n      this.backgroundElement.style.display = 'block';\n      this.domElement.style.display = 'block';\n      this.domElement.style.opacity = 0;\n      this.domElement.style.webkitTransform = 'scale(1.1)';\n      this.layout();\n      Common.defer(function () {\n        _this.backgroundElement.style.opacity = 1;\n        _this.domElement.style.opacity = 1;\n        _this.domElement.style.webkitTransform = 'scale(1)';\n      });\n    }\n  }, {\n    key: 'hide',\n    value: function hide() {\n      var _this = this;\n      var hide = function hide() {\n        _this.domElement.style.display = 'none';\n        _this.backgroundElement.style.display = 'none';\n        dom.unbind(_this.domElement, 'webkitTransitionEnd', hide);\n        dom.unbind(_this.domElement, 'transitionend', hide);\n        dom.unbind(_this.domElement, 'oTransitionEnd', hide);\n      };\n      dom.bind(this.domElement, 'webkitTransitionEnd', hide);\n      dom.bind(this.domElement, 'transitionend', hide);\n      dom.bind(this.domElement, 'oTransitionEnd', hide);\n      this.backgroundElement.style.opacity = 0;\n      this.domElement.style.opacity = 0;\n      this.domElement.style.webkitTransform = 'scale(1.1)';\n    }\n  }, {\n    key: 'layout',\n    value: function layout() {\n      this.domElement.style.left = window.innerWidth / 2 - dom.getWidth(this.domElement) / 2 + 'px';\n      this.domElement.style.top = window.innerHeight / 2 - dom.getHeight(this.domElement) / 2 + 'px';\n    }\n  }]);\n  return CenteredDiv;\n}();\n\nvar styleSheet = ___$insertStyle(\".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\\n\");\n\ncss.inject(styleSheet);\nvar CSS_NAMESPACE = 'dg';\nvar HIDE_KEY_CODE = 72;\nvar CLOSE_BUTTON_HEIGHT = 20;\nvar DEFAULT_DEFAULT_PRESET_NAME = 'Default';\nvar SUPPORTS_LOCAL_STORAGE = function () {\n  try {\n    return !!window.localStorage;\n  } catch (e) {\n    return false;\n  }\n}();\nvar SAVE_DIALOGUE = void 0;\nvar autoPlaceVirgin = true;\nvar autoPlaceContainer = void 0;\nvar hide = false;\nvar hideableGuis = [];\nvar GUI = function GUI(pars) {\n  var _this = this;\n  var params = pars || {};\n  this.domElement = document.createElement('div');\n  this.__ul = document.createElement('ul');\n  this.domElement.appendChild(this.__ul);\n  dom.addClass(this.domElement, CSS_NAMESPACE);\n  this.__folders = {};\n  this.__controllers = [];\n  this.__rememberedObjects = [];\n  this.__rememberedObjectIndecesToControllers = [];\n  this.__listening = [];\n  params = Common.defaults(params, {\n    closeOnTop: false,\n    autoPlace: true,\n    width: GUI.DEFAULT_WIDTH\n  });\n  params = Common.defaults(params, {\n    resizable: params.autoPlace,\n    hideable: params.autoPlace\n  });\n  if (!Common.isUndefined(params.load)) {\n    if (params.preset) {\n      params.load.preset = params.preset;\n    }\n  } else {\n    params.load = { preset: DEFAULT_DEFAULT_PRESET_NAME };\n  }\n  if (Common.isUndefined(params.parent) && params.hideable) {\n    hideableGuis.push(this);\n  }\n  params.resizable = Common.isUndefined(params.parent) && params.resizable;\n  if (params.autoPlace && Common.isUndefined(params.scrollable)) {\n    params.scrollable = true;\n  }\n  var useLocalStorage = SUPPORTS_LOCAL_STORAGE && localStorage.getItem(getLocalStorageHash(this, 'isLocal')) === 'true';\n  var saveToLocalStorage = void 0;\n  Object.defineProperties(this,\n  {\n    parent: {\n      get: function get$$1() {\n        return params.parent;\n      }\n    },\n    scrollable: {\n      get: function get$$1() {\n        return params.scrollable;\n      }\n    },\n    autoPlace: {\n      get: function get$$1() {\n        return params.autoPlace;\n      }\n    },\n    closeOnTop: {\n      get: function get$$1() {\n        return params.closeOnTop;\n      }\n    },\n    preset: {\n      get: function get$$1() {\n        if (_this.parent) {\n          return _this.getRoot().preset;\n        }\n        return params.load.preset;\n      },\n      set: function set$$1(v) {\n        if (_this.parent) {\n          _this.getRoot().preset = v;\n        } else {\n          params.load.preset = v;\n        }\n        setPresetSelectIndex(this);\n        _this.revert();\n      }\n    },\n    width: {\n      get: function get$$1() {\n        return params.width;\n      },\n      set: function set$$1(v) {\n        params.width = v;\n        setWidth(_this, v);\n      }\n    },\n    name: {\n      get: function get$$1() {\n        return params.name;\n      },\n      set: function set$$1(v) {\n        params.name = v;\n        if (titleRowName) {\n          titleRowName.innerHTML = params.name;\n        }\n      }\n    },\n    closed: {\n      get: function get$$1() {\n        return params.closed;\n      },\n      set: function set$$1(v) {\n        params.closed = v;\n        if (params.closed) {\n          dom.addClass(_this.__ul, GUI.CLASS_CLOSED);\n        } else {\n          dom.removeClass(_this.__ul, GUI.CLASS_CLOSED);\n        }\n        this.onResize();\n        if (_this.__closeButton) {\n          _this.__closeButton.innerHTML = v ? GUI.TEXT_OPEN : GUI.TEXT_CLOSED;\n        }\n      }\n    },\n    load: {\n      get: function get$$1() {\n        return params.load;\n      }\n    },\n    useLocalStorage: {\n      get: function get$$1() {\n        return useLocalStorage;\n      },\n      set: function set$$1(bool) {\n        if (SUPPORTS_LOCAL_STORAGE) {\n          useLocalStorage = bool;\n          if (bool) {\n            dom.bind(window, 'unload', saveToLocalStorage);\n          } else {\n            dom.unbind(window, 'unload', saveToLocalStorage);\n          }\n          localStorage.setItem(getLocalStorageHash(_this, 'isLocal'), bool);\n        }\n      }\n    }\n  });\n  if (Common.isUndefined(params.parent)) {\n    params.closed = false;\n    dom.addClass(this.domElement, GUI.CLASS_MAIN);\n    dom.makeSelectable(this.domElement, false);\n    if (SUPPORTS_LOCAL_STORAGE) {\n      if (useLocalStorage) {\n        _this.useLocalStorage = true;\n        var savedGui = localStorage.getItem(getLocalStorageHash(this, 'gui'));\n        if (savedGui) {\n          params.load = JSON.parse(savedGui);\n        }\n      }\n    }\n    this.__closeButton = document.createElement('div');\n    this.__closeButton.innerHTML = GUI.TEXT_CLOSED;\n    dom.addClass(this.__closeButton, GUI.CLASS_CLOSE_BUTTON);\n    if (params.closeOnTop) {\n      dom.addClass(this.__closeButton, GUI.CLASS_CLOSE_TOP);\n      this.domElement.insertBefore(this.__closeButton, this.domElement.childNodes[0]);\n    } else {\n      dom.addClass(this.__closeButton, GUI.CLASS_CLOSE_BOTTOM);\n      this.domElement.appendChild(this.__closeButton);\n    }\n    dom.bind(this.__closeButton, 'click', function () {\n      _this.closed = !_this.closed;\n    });\n  } else {\n    if (params.closed === undefined) {\n      params.closed = true;\n    }\n    var _titleRowName = document.createTextNode(params.name);\n    dom.addClass(_titleRowName, 'controller-name');\n    var titleRow = addRow(_this, _titleRowName);\n    var onClickTitle = function onClickTitle(e) {\n      e.preventDefault();\n      _this.closed = !_this.closed;\n      return false;\n    };\n    dom.addClass(this.__ul, GUI.CLASS_CLOSED);\n    dom.addClass(titleRow, 'title');\n    dom.bind(titleRow, 'click', onClickTitle);\n    if (!params.closed) {\n      this.closed = false;\n    }\n  }\n  if (params.autoPlace) {\n    if (Common.isUndefined(params.parent)) {\n      if (autoPlaceVirgin) {\n        autoPlaceContainer = document.createElement('div');\n        dom.addClass(autoPlaceContainer, CSS_NAMESPACE);\n        dom.addClass(autoPlaceContainer, GUI.CLASS_AUTO_PLACE_CONTAINER);\n        document.body.appendChild(autoPlaceContainer);\n        autoPlaceVirgin = false;\n      }\n      autoPlaceContainer.appendChild(this.domElement);\n      dom.addClass(this.domElement, GUI.CLASS_AUTO_PLACE);\n    }\n    if (!this.parent) {\n      setWidth(_this, params.width);\n    }\n  }\n  this.__resizeHandler = function () {\n    _this.onResizeDebounced();\n  };\n  dom.bind(window, 'resize', this.__resizeHandler);\n  dom.bind(this.__ul, 'webkitTransitionEnd', this.__resizeHandler);\n  dom.bind(this.__ul, 'transitionend', this.__resizeHandler);\n  dom.bind(this.__ul, 'oTransitionEnd', this.__resizeHandler);\n  this.onResize();\n  if (params.resizable) {\n    addResizeHandle(this);\n  }\n  saveToLocalStorage = function saveToLocalStorage() {\n    if (SUPPORTS_LOCAL_STORAGE && localStorage.getItem(getLocalStorageHash(_this, 'isLocal')) === 'true') {\n      localStorage.setItem(getLocalStorageHash(_this, 'gui'), JSON.stringify(_this.getSaveObject()));\n    }\n  };\n  this.saveToLocalStorageIfPossible = saveToLocalStorage;\n  function resetWidth() {\n    var root = _this.getRoot();\n    root.width += 1;\n    Common.defer(function () {\n      root.width -= 1;\n    });\n  }\n  if (!params.parent) {\n    resetWidth();\n  }\n};\nGUI.toggleHide = function () {\n  hide = !hide;\n  Common.each(hideableGuis, function (gui) {\n    gui.domElement.style.display = hide ? 'none' : '';\n  });\n};\nGUI.CLASS_AUTO_PLACE = 'a';\nGUI.CLASS_AUTO_PLACE_CONTAINER = 'ac';\nGUI.CLASS_MAIN = 'main';\nGUI.CLASS_CONTROLLER_ROW = 'cr';\nGUI.CLASS_TOO_TALL = 'taller-than-window';\nGUI.CLASS_CLOSED = 'closed';\nGUI.CLASS_CLOSE_BUTTON = 'close-button';\nGUI.CLASS_CLOSE_TOP = 'close-top';\nGUI.CLASS_CLOSE_BOTTOM = 'close-bottom';\nGUI.CLASS_DRAG = 'drag';\nGUI.DEFAULT_WIDTH = 245;\nGUI.TEXT_CLOSED = 'Close Controls';\nGUI.TEXT_OPEN = 'Open Controls';\nGUI._keydownHandler = function (e) {\n  if (document.activeElement.type !== 'text' && (e.which === HIDE_KEY_CODE || e.keyCode === HIDE_KEY_CODE)) {\n    GUI.toggleHide();\n  }\n};\ndom.bind(window, 'keydown', GUI._keydownHandler, false);\nCommon.extend(GUI.prototype,\n{\n  add: function add(object, property) {\n    return _add(this, object, property, {\n      factoryArgs: Array.prototype.slice.call(arguments, 2)\n    });\n  },\n  addColor: function addColor(object, property) {\n    return _add(this, object, property, {\n      color: true\n    });\n  },\n  remove: function remove(controller) {\n    this.__ul.removeChild(controller.__li);\n    this.__controllers.splice(this.__controllers.indexOf(controller), 1);\n    var _this = this;\n    Common.defer(function () {\n      _this.onResize();\n    });\n  },\n  destroy: function destroy() {\n    if (this.parent) {\n      throw new Error('Only the root GUI should be removed with .destroy(). ' + 'For subfolders, use gui.removeFolder(folder) instead.');\n    }\n    if (this.autoPlace) {\n      autoPlaceContainer.removeChild(this.domElement);\n    }\n    var _this = this;\n    Common.each(this.__folders, function (subfolder) {\n      _this.removeFolder(subfolder);\n    });\n    dom.unbind(window, 'keydown', GUI._keydownHandler, false);\n    removeListeners(this);\n  },\n  addFolder: function addFolder(name) {\n    if (this.__folders[name] !== undefined) {\n      throw new Error('You already have a folder in this GUI by the' + ' name \"' + name + '\"');\n    }\n    var newGuiParams = { name: name, parent: this };\n    newGuiParams.autoPlace = this.autoPlace;\n    if (this.load &&\n    this.load.folders &&\n    this.load.folders[name]) {\n      newGuiParams.closed = this.load.folders[name].closed;\n      newGuiParams.load = this.load.folders[name];\n    }\n    var gui = new GUI(newGuiParams);\n    this.__folders[name] = gui;\n    var li = addRow(this, gui.domElement);\n    dom.addClass(li, 'folder');\n    return gui;\n  },\n  removeFolder: function removeFolder(folder) {\n    this.__ul.removeChild(folder.domElement.parentElement);\n    delete this.__folders[folder.name];\n    if (this.load &&\n    this.load.folders &&\n    this.load.folders[folder.name]) {\n      delete this.load.folders[folder.name];\n    }\n    removeListeners(folder);\n    var _this = this;\n    Common.each(folder.__folders, function (subfolder) {\n      folder.removeFolder(subfolder);\n    });\n    Common.defer(function () {\n      _this.onResize();\n    });\n  },\n  open: function open() {\n    this.closed = false;\n  },\n  close: function close() {\n    this.closed = true;\n  },\n  onResize: function onResize() {\n    var root = this.getRoot();\n    if (root.scrollable) {\n      var top = dom.getOffset(root.__ul).top;\n      var h = 0;\n      Common.each(root.__ul.childNodes, function (node) {\n        if (!(root.autoPlace && node === root.__save_row)) {\n          h += dom.getHeight(node);\n        }\n      });\n      if (window.innerHeight - top - CLOSE_BUTTON_HEIGHT < h) {\n        dom.addClass(root.domElement, GUI.CLASS_TOO_TALL);\n        root.__ul.style.height = window.innerHeight - top - CLOSE_BUTTON_HEIGHT + 'px';\n      } else {\n        dom.removeClass(root.domElement, GUI.CLASS_TOO_TALL);\n        root.__ul.style.height = 'auto';\n      }\n    }\n    if (root.__resize_handle) {\n      Common.defer(function () {\n        root.__resize_handle.style.height = root.__ul.offsetHeight + 'px';\n      });\n    }\n    if (root.__closeButton) {\n      root.__closeButton.style.width = root.width + 'px';\n    }\n  },\n  onResizeDebounced: Common.debounce(function () {\n    this.onResize();\n  }, 50),\n  remember: function remember() {\n    if (Common.isUndefined(SAVE_DIALOGUE)) {\n      SAVE_DIALOGUE = new CenteredDiv();\n      SAVE_DIALOGUE.domElement.innerHTML = saveDialogContents;\n    }\n    if (this.parent) {\n      throw new Error('You can only call remember on a top level GUI.');\n    }\n    var _this = this;\n    Common.each(Array.prototype.slice.call(arguments), function (object) {\n      if (_this.__rememberedObjects.length === 0) {\n        addSaveMenu(_this);\n      }\n      if (_this.__rememberedObjects.indexOf(object) === -1) {\n        _this.__rememberedObjects.push(object);\n      }\n    });\n    if (this.autoPlace) {\n      setWidth(this, this.width);\n    }\n  },\n  getRoot: function getRoot() {\n    var gui = this;\n    while (gui.parent) {\n      gui = gui.parent;\n    }\n    return gui;\n  },\n  getSaveObject: function getSaveObject() {\n    var toReturn = this.load;\n    toReturn.closed = this.closed;\n    if (this.__rememberedObjects.length > 0) {\n      toReturn.preset = this.preset;\n      if (!toReturn.remembered) {\n        toReturn.remembered = {};\n      }\n      toReturn.remembered[this.preset] = getCurrentPreset(this);\n    }\n    toReturn.folders = {};\n    Common.each(this.__folders, function (element, key) {\n      toReturn.folders[key] = element.getSaveObject();\n    });\n    return toReturn;\n  },\n  save: function save() {\n    if (!this.load.remembered) {\n      this.load.remembered = {};\n    }\n    this.load.remembered[this.preset] = getCurrentPreset(this);\n    markPresetModified(this, false);\n    this.saveToLocalStorageIfPossible();\n  },\n  saveAs: function saveAs(presetName) {\n    if (!this.load.remembered) {\n      this.load.remembered = {};\n      this.load.remembered[DEFAULT_DEFAULT_PRESET_NAME] = getCurrentPreset(this, true);\n    }\n    this.load.remembered[presetName] = getCurrentPreset(this);\n    this.preset = presetName;\n    addPresetOption(this, presetName, true);\n    this.saveToLocalStorageIfPossible();\n  },\n  revert: function revert(gui) {\n    Common.each(this.__controllers, function (controller) {\n      if (!this.getRoot().load.remembered) {\n        controller.setValue(controller.initialValue);\n      } else {\n        recallSavedValue(gui || this.getRoot(), controller);\n      }\n      if (controller.__onFinishChange) {\n        controller.__onFinishChange.call(controller, controller.getValue());\n      }\n    }, this);\n    Common.each(this.__folders, function (folder) {\n      folder.revert(folder);\n    });\n    if (!gui) {\n      markPresetModified(this.getRoot(), false);\n    }\n  },\n  listen: function listen(controller) {\n    var init = this.__listening.length === 0;\n    this.__listening.push(controller);\n    if (init) {\n      updateDisplays(this.__listening);\n    }\n  },\n  updateDisplay: function updateDisplay() {\n    Common.each(this.__controllers, function (controller) {\n      controller.updateDisplay();\n    });\n    Common.each(this.__folders, function (folder) {\n      folder.updateDisplay();\n    });\n  }\n});\nfunction addRow(gui, newDom, liBefore) {\n  var li = document.createElement('li');\n  if (newDom) {\n    li.appendChild(newDom);\n  }\n  if (liBefore) {\n    gui.__ul.insertBefore(li, liBefore);\n  } else {\n    gui.__ul.appendChild(li);\n  }\n  gui.onResize();\n  return li;\n}\nfunction removeListeners(gui) {\n  dom.unbind(window, 'resize', gui.__resizeHandler);\n  if (gui.saveToLocalStorageIfPossible) {\n    dom.unbind(window, 'unload', gui.saveToLocalStorageIfPossible);\n  }\n}\nfunction markPresetModified(gui, modified) {\n  var opt = gui.__preset_select[gui.__preset_select.selectedIndex];\n  if (modified) {\n    opt.innerHTML = opt.value + '*';\n  } else {\n    opt.innerHTML = opt.value;\n  }\n}\nfunction augmentController(gui, li, controller) {\n  controller.__li = li;\n  controller.__gui = gui;\n  Common.extend(controller,                                   {\n    options: function options(_options) {\n      if (arguments.length > 1) {\n        var nextSibling = controller.__li.nextElementSibling;\n        controller.remove();\n        return _add(gui, controller.object, controller.property, {\n          before: nextSibling,\n          factoryArgs: [Common.toArray(arguments)]\n        });\n      }\n      if (Common.isArray(_options) || Common.isObject(_options)) {\n        var _nextSibling = controller.__li.nextElementSibling;\n        controller.remove();\n        return _add(gui, controller.object, controller.property, {\n          before: _nextSibling,\n          factoryArgs: [_options]\n        });\n      }\n    },\n    name: function name(_name) {\n      controller.__li.firstElementChild.firstElementChild.innerHTML = _name;\n      return controller;\n    },\n    listen: function listen() {\n      controller.__gui.listen(controller);\n      return controller;\n    },\n    remove: function remove() {\n      controller.__gui.remove(controller);\n      return controller;\n    }\n  });\n  if (controller instanceof NumberControllerSlider) {\n    var box = new NumberControllerBox(controller.object, controller.property, { min: controller.__min, max: controller.__max, step: controller.__step });\n    Common.each(['updateDisplay', 'onChange', 'onFinishChange', 'step'], function (method) {\n      var pc = controller[method];\n      var pb = box[method];\n      controller[method] = box[method] = function () {\n        var args = Array.prototype.slice.call(arguments);\n        pb.apply(box, args);\n        return pc.apply(controller, args);\n      };\n    });\n    dom.addClass(li, 'has-slider');\n    controller.domElement.insertBefore(box.domElement, controller.domElement.firstElementChild);\n  } else if (controller instanceof NumberControllerBox) {\n    var r = function r(returned) {\n      if (Common.isNumber(controller.__min) && Common.isNumber(controller.__max)) {\n        var oldName = controller.__li.firstElementChild.firstElementChild.innerHTML;\n        var wasListening = controller.__gui.__listening.indexOf(controller) > -1;\n        controller.remove();\n        var newController = _add(gui, controller.object, controller.property, {\n          before: controller.__li.nextElementSibling,\n          factoryArgs: [controller.__min, controller.__max, controller.__step]\n        });\n        newController.name(oldName);\n        if (wasListening) newController.listen();\n        return newController;\n      }\n      return returned;\n    };\n    controller.min = Common.compose(r, controller.min);\n    controller.max = Common.compose(r, controller.max);\n  } else if (controller instanceof BooleanController) {\n    dom.bind(li, 'click', function () {\n      dom.fakeEvent(controller.__checkbox, 'click');\n    });\n    dom.bind(controller.__checkbox, 'click', function (e) {\n      e.stopPropagation();\n    });\n  } else if (controller instanceof FunctionController) {\n    dom.bind(li, 'click', function () {\n      dom.fakeEvent(controller.__button, 'click');\n    });\n    dom.bind(li, 'mouseover', function () {\n      dom.addClass(controller.__button, 'hover');\n    });\n    dom.bind(li, 'mouseout', function () {\n      dom.removeClass(controller.__button, 'hover');\n    });\n  } else if (controller instanceof ColorController) {\n    dom.addClass(li, 'color');\n    controller.updateDisplay = Common.compose(function (val) {\n      li.style.borderLeftColor = controller.__color.toString();\n      return val;\n    }, controller.updateDisplay);\n    controller.updateDisplay();\n  }\n  controller.setValue = Common.compose(function (val) {\n    if (gui.getRoot().__preset_select && controller.isModified()) {\n      markPresetModified(gui.getRoot(), true);\n    }\n    return val;\n  }, controller.setValue);\n}\nfunction recallSavedValue(gui, controller) {\n  var root = gui.getRoot();\n  var matchedIndex = root.__rememberedObjects.indexOf(controller.object);\n  if (matchedIndex !== -1) {\n    var controllerMap = root.__rememberedObjectIndecesToControllers[matchedIndex];\n    if (controllerMap === undefined) {\n      controllerMap = {};\n      root.__rememberedObjectIndecesToControllers[matchedIndex] = controllerMap;\n    }\n    controllerMap[controller.property] = controller;\n    if (root.load && root.load.remembered) {\n      var presetMap = root.load.remembered;\n      var preset = void 0;\n      if (presetMap[gui.preset]) {\n        preset = presetMap[gui.preset];\n      } else if (presetMap[DEFAULT_DEFAULT_PRESET_NAME]) {\n        preset = presetMap[DEFAULT_DEFAULT_PRESET_NAME];\n      } else {\n        return;\n      }\n      if (preset[matchedIndex] && preset[matchedIndex][controller.property] !== undefined) {\n        var value = preset[matchedIndex][controller.property];\n        controller.initialValue = value;\n        controller.setValue(value);\n      }\n    }\n  }\n}\nfunction _add(gui, object, property, params) {\n  if (object[property] === undefined) {\n    throw new Error('Object \"' + object + '\" has no property \"' + property + '\"');\n  }\n  var controller = void 0;\n  if (params.color) {\n    controller = new ColorController(object, property);\n  } else {\n    var factoryArgs = [object, property].concat(params.factoryArgs);\n    controller = ControllerFactory.apply(gui, factoryArgs);\n  }\n  if (params.before instanceof Controller) {\n    params.before = params.before.__li;\n  }\n  recallSavedValue(gui, controller);\n  dom.addClass(controller.domElement, 'c');\n  var name = document.createElement('span');\n  dom.addClass(name, 'property-name');\n  name.innerHTML = controller.property;\n  var container = document.createElement('div');\n  container.appendChild(name);\n  container.appendChild(controller.domElement);\n  var li = addRow(gui, container, params.before);\n  dom.addClass(li, GUI.CLASS_CONTROLLER_ROW);\n  if (controller instanceof ColorController) {\n    dom.addClass(li, 'color');\n  } else {\n    dom.addClass(li, _typeof(controller.getValue()));\n  }\n  augmentController(gui, li, controller);\n  gui.__controllers.push(controller);\n  return controller;\n}\nfunction getLocalStorageHash(gui, key) {\n  return document.location.href + '.' + key;\n}\nfunction addPresetOption(gui, name, setSelected) {\n  var opt = document.createElement('option');\n  opt.innerHTML = name;\n  opt.value = name;\n  gui.__preset_select.appendChild(opt);\n  if (setSelected) {\n    gui.__preset_select.selectedIndex = gui.__preset_select.length - 1;\n  }\n}\nfunction showHideExplain(gui, explain) {\n  explain.style.display = gui.useLocalStorage ? 'block' : 'none';\n}\nfunction addSaveMenu(gui) {\n  var div = gui.__save_row = document.createElement('li');\n  dom.addClass(gui.domElement, 'has-save');\n  gui.__ul.insertBefore(div, gui.__ul.firstChild);\n  dom.addClass(div, 'save-row');\n  var gears = document.createElement('span');\n  gears.innerHTML = '&nbsp;';\n  dom.addClass(gears, 'button gears');\n  var button = document.createElement('span');\n  button.innerHTML = 'Save';\n  dom.addClass(button, 'button');\n  dom.addClass(button, 'save');\n  var button2 = document.createElement('span');\n  button2.innerHTML = 'New';\n  dom.addClass(button2, 'button');\n  dom.addClass(button2, 'save-as');\n  var button3 = document.createElement('span');\n  button3.innerHTML = 'Revert';\n  dom.addClass(button3, 'button');\n  dom.addClass(button3, 'revert');\n  var select = gui.__preset_select = document.createElement('select');\n  if (gui.load && gui.load.remembered) {\n    Common.each(gui.load.remembered, function (value, key) {\n      addPresetOption(gui, key, key === gui.preset);\n    });\n  } else {\n    addPresetOption(gui, DEFAULT_DEFAULT_PRESET_NAME, false);\n  }\n  dom.bind(select, 'change', function () {\n    for (var index = 0; index < gui.__preset_select.length; index++) {\n      gui.__preset_select[index].innerHTML = gui.__preset_select[index].value;\n    }\n    gui.preset = this.value;\n  });\n  div.appendChild(select);\n  div.appendChild(gears);\n  div.appendChild(button);\n  div.appendChild(button2);\n  div.appendChild(button3);\n  if (SUPPORTS_LOCAL_STORAGE) {\n    var explain = document.getElementById('dg-local-explain');\n    var localStorageCheckBox = document.getElementById('dg-local-storage');\n    var saveLocally = document.getElementById('dg-save-locally');\n    saveLocally.style.display = 'block';\n    if (localStorage.getItem(getLocalStorageHash(gui, 'isLocal')) === 'true') {\n      localStorageCheckBox.setAttribute('checked', 'checked');\n    }\n    showHideExplain(gui, explain);\n    dom.bind(localStorageCheckBox, 'change', function () {\n      gui.useLocalStorage = !gui.useLocalStorage;\n      showHideExplain(gui, explain);\n    });\n  }\n  var newConstructorTextArea = document.getElementById('dg-new-constructor');\n  dom.bind(newConstructorTextArea, 'keydown', function (e) {\n    if (e.metaKey && (e.which === 67 || e.keyCode === 67)) {\n      SAVE_DIALOGUE.hide();\n    }\n  });\n  dom.bind(gears, 'click', function () {\n    newConstructorTextArea.innerHTML = JSON.stringify(gui.getSaveObject(), undefined, 2);\n    SAVE_DIALOGUE.show();\n    newConstructorTextArea.focus();\n    newConstructorTextArea.select();\n  });\n  dom.bind(button, 'click', function () {\n    gui.save();\n  });\n  dom.bind(button2, 'click', function () {\n    var presetName = prompt('Enter a new preset name.');\n    if (presetName) {\n      gui.saveAs(presetName);\n    }\n  });\n  dom.bind(button3, 'click', function () {\n    gui.revert();\n  });\n}\nfunction addResizeHandle(gui) {\n  var pmouseX = void 0;\n  gui.__resize_handle = document.createElement('div');\n  Common.extend(gui.__resize_handle.style, {\n    width: '6px',\n    marginLeft: '-3px',\n    height: '200px',\n    cursor: 'ew-resize',\n    position: 'absolute'\n  });\n  function drag(e) {\n    e.preventDefault();\n    gui.width += pmouseX - e.clientX;\n    gui.onResize();\n    pmouseX = e.clientX;\n    return false;\n  }\n  function dragStop() {\n    dom.removeClass(gui.__closeButton, GUI.CLASS_DRAG);\n    dom.unbind(window, 'mousemove', drag);\n    dom.unbind(window, 'mouseup', dragStop);\n  }\n  function dragStart(e) {\n    e.preventDefault();\n    pmouseX = e.clientX;\n    dom.addClass(gui.__closeButton, GUI.CLASS_DRAG);\n    dom.bind(window, 'mousemove', drag);\n    dom.bind(window, 'mouseup', dragStop);\n    return false;\n  }\n  dom.bind(gui.__resize_handle, 'mousedown', dragStart);\n  dom.bind(gui.__closeButton, 'mousedown', dragStart);\n  gui.domElement.insertBefore(gui.__resize_handle, gui.domElement.firstElementChild);\n}\nfunction setWidth(gui, w) {\n  gui.domElement.style.width = w + 'px';\n  if (gui.__save_row && gui.autoPlace) {\n    gui.__save_row.style.width = w + 'px';\n  }\n  if (gui.__closeButton) {\n    gui.__closeButton.style.width = w + 'px';\n  }\n}\nfunction getCurrentPreset(gui, useInitialValues) {\n  var toReturn = {};\n  Common.each(gui.__rememberedObjects, function (val, index) {\n    var savedValues = {};\n    var controllerMap = gui.__rememberedObjectIndecesToControllers[index];\n    Common.each(controllerMap, function (controller, property) {\n      savedValues[property] = useInitialValues ? controller.initialValue : controller.getValue();\n    });\n    toReturn[index] = savedValues;\n  });\n  return toReturn;\n}\nfunction setPresetSelectIndex(gui) {\n  for (var index = 0; index < gui.__preset_select.length; index++) {\n    if (gui.__preset_select[index].value === gui.preset) {\n      gui.__preset_select.selectedIndex = index;\n    }\n  }\n}\nfunction updateDisplays(controllerArray) {\n  if (controllerArray.length !== 0) {\n    requestAnimationFrame$1.call(window, function () {\n      updateDisplays(controllerArray);\n    });\n  }\n  Common.each(controllerArray, function (c) {\n    c.updateDisplay();\n  });\n}\n\nvar color = {\n  Color: Color,\n  math: ColorMath,\n  interpret: interpret\n};\nvar controllers = {\n  Controller: Controller,\n  BooleanController: BooleanController,\n  OptionController: OptionController,\n  StringController: StringController,\n  NumberController: NumberController,\n  NumberControllerBox: NumberControllerBox,\n  NumberControllerSlider: NumberControllerSlider,\n  FunctionController: FunctionController,\n  ColorController: ColorController\n};\nvar dom$1 = { dom: dom };\nvar gui = { GUI: GUI };\nvar GUI$1 = GUI;\nvar index = {\n  color: color,\n  controllers: controllers,\n  dom: dom$1,\n  gui: gui,\n  GUI: GUI$1\n};\n\nexports.color = color;\nexports.controllers = controllers;\nexports.dom = dom$1;\nexports.gui = gui;\nexports.GUI = GUI$1;\nexports['default'] = index;\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\n})));\n//# sourceMappingURL=dat.gui.js.map\n"
  },
  {
    "path": "WebContent/js/libs/stats.js",
    "content": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(global.Stats = factory());\n}(this, (function () { 'use strict';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nvar Stats = function () {\n\n\tvar mode = 0;\n\n\tvar container = document.createElement( 'div' );\n\tcontainer.style.cssText = 'position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000';\n\tcontainer.addEventListener( 'click', function ( event ) {\n\n\t\tevent.preventDefault();\n\t\tshowPanel( ++ mode % container.children.length );\n\n\t}, false );\n\n\t//\n\n\tfunction addPanel( panel ) {\n\n\t\tcontainer.appendChild( panel.dom );\n\t\treturn panel;\n\n\t}\n\n\tfunction showPanel( id ) {\n\n\t\tfor ( var i = 0; i < container.children.length; i ++ ) {\n\n\t\t\tcontainer.children[ i ].style.display = i === id ? 'block' : 'none';\n\n\t\t}\n\n\t\tmode = id;\n\n\t}\n\n\t//\n\n\tvar beginTime = ( performance || Date ).now(), prevTime = beginTime, frames = 0;\n\n\tvar fpsPanel = addPanel( new Stats.Panel( 'FPS', '#0ff', '#002' ) );\n\tvar msPanel = addPanel( new Stats.Panel( 'MS', '#0f0', '#020' ) );\n\n\tif ( self.performance && self.performance.memory ) {\n\n\t\tvar memPanel = addPanel( new Stats.Panel( 'MB', '#f08', '#201' ) );\n\n\t}\n\n\tshowPanel( 0 );\n\n\treturn {\n\n\t\tREVISION: 16,\n\n\t\tdom: container,\n\n\t\taddPanel: addPanel,\n\t\tshowPanel: showPanel,\n\n\t\tbegin: function () {\n\n\t\t\tbeginTime = ( performance || Date ).now();\n\n\t\t},\n\n\t\tend: function () {\n\n\t\t\tframes ++;\n\n\t\t\tvar time = ( performance || Date ).now();\n\n\t\t\tmsPanel.update( time - beginTime, 200 );\n\n\t\t\tif ( time > prevTime + 1000 ) {\n\n\t\t\t\tfpsPanel.update( ( frames * 1000 ) / ( time - prevTime ), 100 );\n\n\t\t\t\tprevTime = time;\n\t\t\t\tframes = 0;\n\n\t\t\t\tif ( memPanel ) {\n\n\t\t\t\t\tvar memory = performance.memory;\n\t\t\t\t\tmemPanel.update( memory.usedJSHeapSize / 1048576, memory.jsHeapSizeLimit / 1048576 );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn time;\n\n\t\t},\n\n\t\tupdate: function () {\n\n\t\t\tbeginTime = this.end();\n\n\t\t},\n\n\t\t// Backwards Compatibility\n\n\t\tdomElement: container,\n\t\tsetMode: showPanel\n\n\t};\n\n};\n\nStats.Panel = function ( name, fg, bg ) {\n\n\tvar min = Infinity, max = 0, round = Math.round;\n\tvar PR = round( window.devicePixelRatio || 1 );\n\n\tvar WIDTH = 80 * PR, HEIGHT = 48 * PR,\n\t\t\tTEXT_X = 3 * PR, TEXT_Y = 2 * PR,\n\t\t\tGRAPH_X = 3 * PR, GRAPH_Y = 15 * PR,\n\t\t\tGRAPH_WIDTH = 74 * PR, GRAPH_HEIGHT = 30 * PR;\n\n\tvar canvas = document.createElement( 'canvas' );\n\tcanvas.width = WIDTH;\n\tcanvas.height = HEIGHT;\n\tcanvas.style.cssText = 'width:80px;height:48px';\n\n\tvar context = canvas.getContext( '2d' );\n\tcontext.font = 'bold ' + ( 9 * PR ) + 'px Helvetica,Arial,sans-serif';\n\tcontext.textBaseline = 'top';\n\n\tcontext.fillStyle = bg;\n\tcontext.fillRect( 0, 0, WIDTH, HEIGHT );\n\n\tcontext.fillStyle = fg;\n\tcontext.fillText( name, TEXT_X, TEXT_Y );\n\tcontext.fillRect( GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT );\n\n\tcontext.fillStyle = bg;\n\tcontext.globalAlpha = 0.9;\n\tcontext.fillRect( GRAPH_X, GRAPH_Y, GRAPH_WIDTH, GRAPH_HEIGHT );\n\n\treturn {\n\n\t\tdom: canvas,\n\n\t\tupdate: function ( value, maxValue ) {\n\n\t\t\tmin = Math.min( min, value );\n\t\t\tmax = Math.max( max, value );\n\n\t\t\tcontext.fillStyle = bg;\n\t\t\tcontext.globalAlpha = 1;\n\t\t\tcontext.fillRect( 0, 0, WIDTH, GRAPH_Y );\n\t\t\tcontext.fillStyle = fg;\n\t\t\tcontext.fillText( round( value ) + ' ' + name + ' (' + round( min ) + '-' + round( max ) + ')', TEXT_X, TEXT_Y );\n\n\t\t\tcontext.drawImage( canvas, GRAPH_X + PR, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT, GRAPH_X, GRAPH_Y, GRAPH_WIDTH - PR, GRAPH_HEIGHT );\n\n\t\t\tcontext.fillRect( GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, GRAPH_HEIGHT );\n\n\t\t\tcontext.fillStyle = bg;\n\t\t\tcontext.globalAlpha = 0.9;\n\t\t\tcontext.fillRect( GRAPH_X + GRAPH_WIDTH - PR, GRAPH_Y, PR, round( ( 1 - ( value / maxValue ) ) * GRAPH_HEIGHT ) );\n\n\t\t}\n\n\t};\n\n};\n\nreturn Stats;\n\n})));\n"
  },
  {
    "path": "WebContent/js/libs/three.js",
    "content": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\n\ttypeof define === 'function' && define.amd ? define(['exports'], factory) :\n\t(factory((global.THREE = {})));\n}(this, (function (exports) { 'use strict';\n\n\t// Polyfills\n\n\tif ( Number.EPSILON === undefined ) {\n\n\t\tNumber.EPSILON = Math.pow( 2, - 52 );\n\n\t}\n\n\tif ( Number.isInteger === undefined ) {\n\n\t\t// Missing in IE\n\t\t// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger\n\n\t\tNumber.isInteger = function ( value ) {\n\n\t\t\treturn typeof value === 'number' && isFinite( value ) && Math.floor( value ) === value;\n\n\t\t};\n\n\t}\n\n\t//\n\n\tif ( Math.sign === undefined ) {\n\n\t\t// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign\n\n\t\tMath.sign = function ( x ) {\n\n\t\t\treturn ( x < 0 ) ? - 1 : ( x > 0 ) ? 1 : + x;\n\n\t\t};\n\n\t}\n\n\tif ( 'name' in Function.prototype === false ) {\n\n\t\t// Missing in IE\n\t\t// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name\n\n\t\tObject.defineProperty( Function.prototype, 'name', {\n\n\t\t\tget: function () {\n\n\t\t\t\treturn this.toString().match( /^\\s*function\\s*([^\\(\\s]*)/ )[ 1 ];\n\n\t\t\t}\n\n\t\t} );\n\n\t}\n\n\tif ( Object.assign === undefined ) {\n\n\t\t// Missing in IE\n\t\t// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\n\n\t\t( function () {\n\n\t\t\tObject.assign = function ( target ) {\n\n\t\t\t\tif ( target === undefined || target === null ) {\n\n\t\t\t\t\tthrow new TypeError( 'Cannot convert undefined or null to object' );\n\n\t\t\t\t}\n\n\t\t\t\tvar output = Object( target );\n\n\t\t\t\tfor ( var index = 1; index < arguments.length; index ++ ) {\n\n\t\t\t\t\tvar source = arguments[ index ];\n\n\t\t\t\t\tif ( source !== undefined && source !== null ) {\n\n\t\t\t\t\t\tfor ( var nextKey in source ) {\n\n\t\t\t\t\t\t\tif ( Object.prototype.hasOwnProperty.call( source, nextKey ) ) {\n\n\t\t\t\t\t\t\t\toutput[ nextKey ] = source[ nextKey ];\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\treturn output;\n\n\t\t\t};\n\n\t\t} )();\n\n\t}\n\n\t/**\n\t * https://github.com/mrdoob/eventdispatcher.js/\n\t */\n\n\tfunction EventDispatcher() {}\n\n\tObject.assign( EventDispatcher.prototype, {\n\n\t\taddEventListener: function ( type, listener ) {\n\n\t\t\tif ( this._listeners === undefined ) this._listeners = {};\n\n\t\t\tvar listeners = this._listeners;\n\n\t\t\tif ( listeners[ type ] === undefined ) {\n\n\t\t\t\tlisteners[ type ] = [];\n\n\t\t\t}\n\n\t\t\tif ( listeners[ type ].indexOf( listener ) === - 1 ) {\n\n\t\t\t\tlisteners[ type ].push( listener );\n\n\t\t\t}\n\n\t\t},\n\n\t\thasEventListener: function ( type, listener ) {\n\n\t\t\tif ( this._listeners === undefined ) return false;\n\n\t\t\tvar listeners = this._listeners;\n\n\t\t\treturn listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1;\n\n\t\t},\n\n\t\tremoveEventListener: function ( type, listener ) {\n\n\t\t\tif ( this._listeners === undefined ) return;\n\n\t\t\tvar listeners = this._listeners;\n\t\t\tvar listenerArray = listeners[ type ];\n\n\t\t\tif ( listenerArray !== undefined ) {\n\n\t\t\t\tvar index = listenerArray.indexOf( listener );\n\n\t\t\t\tif ( index !== - 1 ) {\n\n\t\t\t\t\tlistenerArray.splice( index, 1 );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t},\n\n\t\tdispatchEvent: function ( event ) {\n\n\t\t\tif ( this._listeners === undefined ) return;\n\n\t\t\tvar listeners = this._listeners;\n\t\t\tvar listenerArray = listeners[ event.type ];\n\n\t\t\tif ( listenerArray !== undefined ) {\n\n\t\t\t\tevent.target = this;\n\n\t\t\t\tvar array = listenerArray.slice( 0 );\n\n\t\t\t\tfor ( var i = 0, l = array.length; i < l; i ++ ) {\n\n\t\t\t\t\tarray[ i ].call( this, event );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t} );\n\n\tvar REVISION = '100';\n\tvar MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2 };\n\tvar CullFaceNone = 0;\n\tvar CullFaceBack = 1;\n\tvar CullFaceFront = 2;\n\tvar CullFaceFrontBack = 3;\n\tvar FrontFaceDirectionCW = 0;\n\tvar FrontFaceDirectionCCW = 1;\n\tvar BasicShadowMap = 0;\n\tvar PCFShadowMap = 1;\n\tvar PCFSoftShadowMap = 2;\n\tvar FrontSide = 0;\n\tvar BackSide = 1;\n\tvar DoubleSide = 2;\n\tvar FlatShading = 1;\n\tvar SmoothShading = 2;\n\tvar NoColors = 0;\n\tvar FaceColors = 1;\n\tvar VertexColors = 2;\n\tvar NoBlending = 0;\n\tvar NormalBlending = 1;\n\tvar AdditiveBlending = 2;\n\tvar SubtractiveBlending = 3;\n\tvar MultiplyBlending = 4;\n\tvar CustomBlending = 5;\n\tvar AddEquation = 100;\n\tvar SubtractEquation = 101;\n\tvar ReverseSubtractEquation = 102;\n\tvar MinEquation = 103;\n\tvar MaxEquation = 104;\n\tvar ZeroFactor = 200;\n\tvar OneFactor = 201;\n\tvar SrcColorFactor = 202;\n\tvar OneMinusSrcColorFactor = 203;\n\tvar SrcAlphaFactor = 204;\n\tvar OneMinusSrcAlphaFactor = 205;\n\tvar DstAlphaFactor = 206;\n\tvar OneMinusDstAlphaFactor = 207;\n\tvar DstColorFactor = 208;\n\tvar OneMinusDstColorFactor = 209;\n\tvar SrcAlphaSaturateFactor = 210;\n\tvar NeverDepth = 0;\n\tvar AlwaysDepth = 1;\n\tvar LessDepth = 2;\n\tvar LessEqualDepth = 3;\n\tvar EqualDepth = 4;\n\tvar GreaterEqualDepth = 5;\n\tvar GreaterDepth = 6;\n\tvar NotEqualDepth = 7;\n\tvar MultiplyOperation = 0;\n\tvar MixOperation = 1;\n\tvar AddOperation = 2;\n\tvar NoToneMapping = 0;\n\tvar LinearToneMapping = 1;\n\tvar ReinhardToneMapping = 2;\n\tvar Uncharted2ToneMapping = 3;\n\tvar CineonToneMapping = 4;\n\tvar ACESFilmicToneMapping = 5;\n\n\tvar UVMapping = 300;\n\tvar CubeReflectionMapping = 301;\n\tvar CubeRefractionMapping = 302;\n\tvar EquirectangularReflectionMapping = 303;\n\tvar EquirectangularRefractionMapping = 304;\n\tvar SphericalReflectionMapping = 305;\n\tvar CubeUVReflectionMapping = 306;\n\tvar CubeUVRefractionMapping = 307;\n\tvar RepeatWrapping = 1000;\n\tvar ClampToEdgeWrapping = 1001;\n\tvar MirroredRepeatWrapping = 1002;\n\tvar NearestFilter = 1003;\n\tvar NearestMipMapNearestFilter = 1004;\n\tvar NearestMipMapLinearFilter = 1005;\n\tvar LinearFilter = 1006;\n\tvar LinearMipMapNearestFilter = 1007;\n\tvar LinearMipMapLinearFilter = 1008;\n\tvar UnsignedByteType = 1009;\n\tvar ByteType = 1010;\n\tvar ShortType = 1011;\n\tvar UnsignedShortType = 1012;\n\tvar IntType = 1013;\n\tvar UnsignedIntType = 1014;\n\tvar FloatType = 1015;\n\tvar HalfFloatType = 1016;\n\tvar UnsignedShort4444Type = 1017;\n\tvar UnsignedShort5551Type = 1018;\n\tvar UnsignedShort565Type = 1019;\n\tvar UnsignedInt248Type = 1020;\n\tvar AlphaFormat = 1021;\n\tvar RGBFormat = 1022;\n\tvar RGBAFormat = 1023;\n\tvar LuminanceFormat = 1024;\n\tvar LuminanceAlphaFormat = 1025;\n\tvar RGBEFormat = RGBAFormat;\n\tvar DepthFormat = 1026;\n\tvar DepthStencilFormat = 1027;\n\tvar RedFormat = 1028;\n\tvar RGB_S3TC_DXT1_Format = 33776;\n\tvar RGBA_S3TC_DXT1_Format = 33777;\n\tvar RGBA_S3TC_DXT3_Format = 33778;\n\tvar RGBA_S3TC_DXT5_Format = 33779;\n\tvar RGB_PVRTC_4BPPV1_Format = 35840;\n\tvar RGB_PVRTC_2BPPV1_Format = 35841;\n\tvar RGBA_PVRTC_4BPPV1_Format = 35842;\n\tvar RGBA_PVRTC_2BPPV1_Format = 35843;\n\tvar RGB_ETC1_Format = 36196;\n\tvar RGBA_ASTC_4x4_Format = 37808;\n\tvar RGBA_ASTC_5x4_Format = 37809;\n\tvar RGBA_ASTC_5x5_Format = 37810;\n\tvar RGBA_ASTC_6x5_Format = 37811;\n\tvar RGBA_ASTC_6x6_Format = 37812;\n\tvar RGBA_ASTC_8x5_Format = 37813;\n\tvar RGBA_ASTC_8x6_Format = 37814;\n\tvar RGBA_ASTC_8x8_Format = 37815;\n\tvar RGBA_ASTC_10x5_Format = 37816;\n\tvar RGBA_ASTC_10x6_Format = 37817;\n\tvar RGBA_ASTC_10x8_Format = 37818;\n\tvar RGBA_ASTC_10x10_Format = 37819;\n\tvar RGBA_ASTC_12x10_Format = 37820;\n\tvar RGBA_ASTC_12x12_Format = 37821;\n\tvar LoopOnce = 2200;\n\tvar LoopRepeat = 2201;\n\tvar LoopPingPong = 2202;\n\tvar InterpolateDiscrete = 2300;\n\tvar InterpolateLinear = 2301;\n\tvar InterpolateSmooth = 2302;\n\tvar ZeroCurvatureEnding = 2400;\n\tvar ZeroSlopeEnding = 2401;\n\tvar WrapAroundEnding = 2402;\n\tvar TrianglesDrawMode = 0;\n\tvar TriangleStripDrawMode = 1;\n\tvar TriangleFanDrawMode = 2;\n\tvar LinearEncoding = 3000;\n\tvar sRGBEncoding = 3001;\n\tvar GammaEncoding = 3007;\n\tvar RGBEEncoding = 3002;\n\tvar LogLuvEncoding = 3003;\n\tvar RGBM7Encoding = 3004;\n\tvar RGBM16Encoding = 3005;\n\tvar RGBDEncoding = 3006;\n\tvar BasicDepthPacking = 3200;\n\tvar RGBADepthPacking = 3201;\n\tvar TangentSpaceNormalMap = 0;\n\tvar ObjectSpaceNormalMap = 1;\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tvar _Math = {\n\n\t\tDEG2RAD: Math.PI / 180,\n\t\tRAD2DEG: 180 / Math.PI,\n\n\t\tgenerateUUID: ( function () {\n\n\t\t\t// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136\n\n\t\t\tvar lut = [];\n\n\t\t\tfor ( var i = 0; i < 256; i ++ ) {\n\n\t\t\t\tlut[ i ] = ( i < 16 ? '0' : '' ) + ( i ).toString( 16 );\n\n\t\t\t}\n\n\t\t\treturn function generateUUID() {\n\n\t\t\t\tvar d0 = Math.random() * 0xffffffff | 0;\n\t\t\t\tvar d1 = Math.random() * 0xffffffff | 0;\n\t\t\t\tvar d2 = Math.random() * 0xffffffff | 0;\n\t\t\t\tvar d3 = Math.random() * 0xffffffff | 0;\n\t\t\t\tvar uuid = lut[ d0 & 0xff ] + lut[ d0 >> 8 & 0xff ] + lut[ d0 >> 16 & 0xff ] + lut[ d0 >> 24 & 0xff ] + '-' +\n\t\t\t\t\tlut[ d1 & 0xff ] + lut[ d1 >> 8 & 0xff ] + '-' + lut[ d1 >> 16 & 0x0f | 0x40 ] + lut[ d1 >> 24 & 0xff ] + '-' +\n\t\t\t\t\tlut[ d2 & 0x3f | 0x80 ] + lut[ d2 >> 8 & 0xff ] + '-' + lut[ d2 >> 16 & 0xff ] + lut[ d2 >> 24 & 0xff ] +\n\t\t\t\t\tlut[ d3 & 0xff ] + lut[ d3 >> 8 & 0xff ] + lut[ d3 >> 16 & 0xff ] + lut[ d3 >> 24 & 0xff ];\n\n\t\t\t\t// .toUpperCase() here flattens concatenated strings to save heap memory space.\n\t\t\t\treturn uuid.toUpperCase();\n\n\t\t\t};\n\n\t\t} )(),\n\n\t\tclamp: function ( value, min, max ) {\n\n\t\t\treturn Math.max( min, Math.min( max, value ) );\n\n\t\t},\n\n\t\t// compute euclidian modulo of m % n\n\t\t// https://en.wikipedia.org/wiki/Modulo_operation\n\n\t\teuclideanModulo: function ( n, m ) {\n\n\t\t\treturn ( ( n % m ) + m ) % m;\n\n\t\t},\n\n\t\t// Linear mapping from range <a1, a2> to range <b1, b2>\n\n\t\tmapLinear: function ( x, a1, a2, b1, b2 ) {\n\n\t\t\treturn b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 );\n\n\t\t},\n\n\t\t// https://en.wikipedia.org/wiki/Linear_interpolation\n\n\t\tlerp: function ( x, y, t ) {\n\n\t\t\treturn ( 1 - t ) * x + t * y;\n\n\t\t},\n\n\t\t// http://en.wikipedia.org/wiki/Smoothstep\n\n\t\tsmoothstep: function ( x, min, max ) {\n\n\t\t\tif ( x <= min ) return 0;\n\t\t\tif ( x >= max ) return 1;\n\n\t\t\tx = ( x - min ) / ( max - min );\n\n\t\t\treturn x * x * ( 3 - 2 * x );\n\n\t\t},\n\n\t\tsmootherstep: function ( x, min, max ) {\n\n\t\t\tif ( x <= min ) return 0;\n\t\t\tif ( x >= max ) return 1;\n\n\t\t\tx = ( x - min ) / ( max - min );\n\n\t\t\treturn x * x * x * ( x * ( x * 6 - 15 ) + 10 );\n\n\t\t},\n\n\t\t// Random integer from <low, high> interval\n\n\t\trandInt: function ( low, high ) {\n\n\t\t\treturn low + Math.floor( Math.random() * ( high - low + 1 ) );\n\n\t\t},\n\n\t\t// Random float from <low, high> interval\n\n\t\trandFloat: function ( low, high ) {\n\n\t\t\treturn low + Math.random() * ( high - low );\n\n\t\t},\n\n\t\t// Random float from <-range/2, range/2> interval\n\n\t\trandFloatSpread: function ( range ) {\n\n\t\t\treturn range * ( 0.5 - Math.random() );\n\n\t\t},\n\n\t\tdegToRad: function ( degrees ) {\n\n\t\t\treturn degrees * _Math.DEG2RAD;\n\n\t\t},\n\n\t\tradToDeg: function ( radians ) {\n\n\t\t\treturn radians * _Math.RAD2DEG;\n\n\t\t},\n\n\t\tisPowerOfTwo: function ( value ) {\n\n\t\t\treturn ( value & ( value - 1 ) ) === 0 && value !== 0;\n\n\t\t},\n\n\t\tceilPowerOfTwo: function ( value ) {\n\n\t\t\treturn Math.pow( 2, Math.ceil( Math.log( value ) / Math.LN2 ) );\n\n\t\t},\n\n\t\tfloorPowerOfTwo: function ( value ) {\n\n\t\t\treturn Math.pow( 2, Math.floor( Math.log( value ) / Math.LN2 ) );\n\n\t\t}\n\n\t};\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author philogb / http://blog.thejit.org/\n\t * @author egraether / http://egraether.com/\n\t * @author zz85 / http://www.lab4games.net/zz85/blog\n\t */\n\n\tfunction Vector2( x, y ) {\n\n\t\tthis.x = x || 0;\n\t\tthis.y = y || 0;\n\n\t}\n\n\tObject.defineProperties( Vector2.prototype, {\n\n\t\t\"width\": {\n\n\t\t\tget: function () {\n\n\t\t\t\treturn this.x;\n\n\t\t\t},\n\n\t\t\tset: function ( value ) {\n\n\t\t\t\tthis.x = value;\n\n\t\t\t}\n\n\t\t},\n\n\t\t\"height\": {\n\n\t\t\tget: function () {\n\n\t\t\t\treturn this.y;\n\n\t\t\t},\n\n\t\t\tset: function ( value ) {\n\n\t\t\t\tthis.y = value;\n\n\t\t\t}\n\n\t\t}\n\n\t} );\n\n\tObject.assign( Vector2.prototype, {\n\n\t\tisVector2: true,\n\n\t\tset: function ( x, y ) {\n\n\t\t\tthis.x = x;\n\t\t\tthis.y = y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetScalar: function ( scalar ) {\n\n\t\t\tthis.x = scalar;\n\t\t\tthis.y = scalar;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetX: function ( x ) {\n\n\t\t\tthis.x = x;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetY: function ( y ) {\n\n\t\t\tthis.y = y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetComponent: function ( index, value ) {\n\n\t\t\tswitch ( index ) {\n\n\t\t\t\tcase 0: this.x = value; break;\n\t\t\t\tcase 1: this.y = value; break;\n\t\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetComponent: function ( index ) {\n\n\t\t\tswitch ( index ) {\n\n\t\t\t\tcase 0: return this.x;\n\t\t\t\tcase 1: return this.y;\n\t\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t\t}\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor( this.x, this.y );\n\n\t\t},\n\n\t\tcopy: function ( v ) {\n\n\t\t\tthis.x = v.x;\n\t\t\tthis.y = v.y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tadd: function ( v, w ) {\n\n\t\t\tif ( w !== undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );\n\t\t\t\treturn this.addVectors( v, w );\n\n\t\t\t}\n\n\t\t\tthis.x += v.x;\n\t\t\tthis.y += v.y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\taddScalar: function ( s ) {\n\n\t\t\tthis.x += s;\n\t\t\tthis.y += s;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\taddVectors: function ( a, b ) {\n\n\t\t\tthis.x = a.x + b.x;\n\t\t\tthis.y = a.y + b.y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\taddScaledVector: function ( v, s ) {\n\n\t\t\tthis.x += v.x * s;\n\t\t\tthis.y += v.y * s;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsub: function ( v, w ) {\n\n\t\t\tif ( w !== undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );\n\t\t\t\treturn this.subVectors( v, w );\n\n\t\t\t}\n\n\t\t\tthis.x -= v.x;\n\t\t\tthis.y -= v.y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsubScalar: function ( s ) {\n\n\t\t\tthis.x -= s;\n\t\t\tthis.y -= s;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsubVectors: function ( a, b ) {\n\n\t\t\tthis.x = a.x - b.x;\n\t\t\tthis.y = a.y - b.y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmultiply: function ( v ) {\n\n\t\t\tthis.x *= v.x;\n\t\t\tthis.y *= v.y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmultiplyScalar: function ( scalar ) {\n\n\t\t\tthis.x *= scalar;\n\t\t\tthis.y *= scalar;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tdivide: function ( v ) {\n\n\t\t\tthis.x /= v.x;\n\t\t\tthis.y /= v.y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tdivideScalar: function ( scalar ) {\n\n\t\t\treturn this.multiplyScalar( 1 / scalar );\n\n\t\t},\n\n\t\tapplyMatrix3: function ( m ) {\n\n\t\t\tvar x = this.x, y = this.y;\n\t\t\tvar e = m.elements;\n\n\t\t\tthis.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ];\n\t\t\tthis.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ];\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmin: function ( v ) {\n\n\t\t\tthis.x = Math.min( this.x, v.x );\n\t\t\tthis.y = Math.min( this.y, v.y );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmax: function ( v ) {\n\n\t\t\tthis.x = Math.max( this.x, v.x );\n\t\t\tthis.y = Math.max( this.y, v.y );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclamp: function ( min, max ) {\n\n\t\t\t// assumes min < max, componentwise\n\n\t\t\tthis.x = Math.max( min.x, Math.min( max.x, this.x ) );\n\t\t\tthis.y = Math.max( min.y, Math.min( max.y, this.y ) );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclampScalar: function () {\n\n\t\t\tvar min = new Vector2();\n\t\t\tvar max = new Vector2();\n\n\t\t\treturn function clampScalar( minVal, maxVal ) {\n\n\t\t\t\tmin.set( minVal, minVal );\n\t\t\t\tmax.set( maxVal, maxVal );\n\n\t\t\t\treturn this.clamp( min, max );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tclampLength: function ( min, max ) {\n\n\t\t\tvar length = this.length();\n\n\t\t\treturn this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );\n\n\t\t},\n\n\t\tfloor: function () {\n\n\t\t\tthis.x = Math.floor( this.x );\n\t\t\tthis.y = Math.floor( this.y );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tceil: function () {\n\n\t\t\tthis.x = Math.ceil( this.x );\n\t\t\tthis.y = Math.ceil( this.y );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tround: function () {\n\n\t\t\tthis.x = Math.round( this.x );\n\t\t\tthis.y = Math.round( this.y );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\troundToZero: function () {\n\n\t\t\tthis.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );\n\t\t\tthis.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tnegate: function () {\n\n\t\t\tthis.x = - this.x;\n\t\t\tthis.y = - this.y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tdot: function ( v ) {\n\n\t\t\treturn this.x * v.x + this.y * v.y;\n\n\t\t},\n\n\t\tcross: function ( v ) {\n\n\t\t\treturn this.x * v.y - this.y * v.x;\n\n\t\t},\n\n\t\tlengthSq: function () {\n\n\t\t\treturn this.x * this.x + this.y * this.y;\n\n\t\t},\n\n\t\tlength: function () {\n\n\t\t\treturn Math.sqrt( this.x * this.x + this.y * this.y );\n\n\t\t},\n\n\t\tmanhattanLength: function () {\n\n\t\t\treturn Math.abs( this.x ) + Math.abs( this.y );\n\n\t\t},\n\n\t\tnormalize: function () {\n\n\t\t\treturn this.divideScalar( this.length() || 1 );\n\n\t\t},\n\n\t\tangle: function () {\n\n\t\t\t// computes the angle in radians with respect to the positive x-axis\n\n\t\t\tvar angle = Math.atan2( this.y, this.x );\n\n\t\t\tif ( angle < 0 ) angle += 2 * Math.PI;\n\n\t\t\treturn angle;\n\n\t\t},\n\n\t\tdistanceTo: function ( v ) {\n\n\t\t\treturn Math.sqrt( this.distanceToSquared( v ) );\n\n\t\t},\n\n\t\tdistanceToSquared: function ( v ) {\n\n\t\t\tvar dx = this.x - v.x, dy = this.y - v.y;\n\t\t\treturn dx * dx + dy * dy;\n\n\t\t},\n\n\t\tmanhattanDistanceTo: function ( v ) {\n\n\t\t\treturn Math.abs( this.x - v.x ) + Math.abs( this.y - v.y );\n\n\t\t},\n\n\t\tsetLength: function ( length ) {\n\n\t\t\treturn this.normalize().multiplyScalar( length );\n\n\t\t},\n\n\t\tlerp: function ( v, alpha ) {\n\n\t\t\tthis.x += ( v.x - this.x ) * alpha;\n\t\t\tthis.y += ( v.y - this.y ) * alpha;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tlerpVectors: function ( v1, v2, alpha ) {\n\n\t\t\treturn this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );\n\n\t\t},\n\n\t\tequals: function ( v ) {\n\n\t\t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) );\n\n\t\t},\n\n\t\tfromArray: function ( array, offset ) {\n\n\t\t\tif ( offset === undefined ) offset = 0;\n\n\t\t\tthis.x = array[ offset ];\n\t\t\tthis.y = array[ offset + 1 ];\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttoArray: function ( array, offset ) {\n\n\t\t\tif ( array === undefined ) array = [];\n\t\t\tif ( offset === undefined ) offset = 0;\n\n\t\t\tarray[ offset ] = this.x;\n\t\t\tarray[ offset + 1 ] = this.y;\n\n\t\t\treturn array;\n\n\t\t},\n\n\t\tfromBufferAttribute: function ( attribute, index, offset ) {\n\n\t\t\tif ( offset !== undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Vector2: offset has been removed from .fromBufferAttribute().' );\n\n\t\t\t}\n\n\t\t\tthis.x = attribute.getX( index );\n\t\t\tthis.y = attribute.getY( index );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\trotateAround: function ( center, angle ) {\n\n\t\t\tvar c = Math.cos( angle ), s = Math.sin( angle );\n\n\t\t\tvar x = this.x - center.x;\n\t\t\tvar y = this.y - center.y;\n\n\t\t\tthis.x = x * c - y * s + center.x;\n\t\t\tthis.y = x * s + y * c + center.y;\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author supereggbert / http://www.paulbrunt.co.uk/\n\t * @author philogb / http://blog.thejit.org/\n\t * @author jordi_ros / http://plattsoft.com\n\t * @author D1plo1d / http://github.com/D1plo1d\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author mikael emtinger / http://gomo.se/\n\t * @author timknip / http://www.floorplanner.com/\n\t * @author bhouston / http://clara.io\n\t * @author WestLangley / http://github.com/WestLangley\n\t */\n\n\tfunction Matrix4() {\n\n\t\tthis.elements = [\n\n\t\t\t1, 0, 0, 0,\n\t\t\t0, 1, 0, 0,\n\t\t\t0, 0, 1, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t];\n\n\t\tif ( arguments.length > 0 ) {\n\n\t\t\tconsole.error( 'THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.' );\n\n\t\t}\n\n\t}\n\n\tObject.assign( Matrix4.prototype, {\n\n\t\tisMatrix4: true,\n\n\t\tset: function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {\n\n\t\t\tvar te = this.elements;\n\n\t\t\tte[ 0 ] = n11; te[ 4 ] = n12; te[ 8 ] = n13; te[ 12 ] = n14;\n\t\t\tte[ 1 ] = n21; te[ 5 ] = n22; te[ 9 ] = n23; te[ 13 ] = n24;\n\t\t\tte[ 2 ] = n31; te[ 6 ] = n32; te[ 10 ] = n33; te[ 14 ] = n34;\n\t\t\tte[ 3 ] = n41; te[ 7 ] = n42; te[ 11 ] = n43; te[ 15 ] = n44;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tidentity: function () {\n\n\t\t\tthis.set(\n\n\t\t\t\t1, 0, 0, 0,\n\t\t\t\t0, 1, 0, 0,\n\t\t\t\t0, 0, 1, 0,\n\t\t\t\t0, 0, 0, 1\n\n\t\t\t);\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new Matrix4().fromArray( this.elements );\n\n\t\t},\n\n\t\tcopy: function ( m ) {\n\n\t\t\tvar te = this.elements;\n\t\t\tvar me = m.elements;\n\n\t\t\tte[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; te[ 3 ] = me[ 3 ];\n\t\t\tte[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ];\n\t\t\tte[ 8 ] = me[ 8 ]; te[ 9 ] = me[ 9 ]; te[ 10 ] = me[ 10 ]; te[ 11 ] = me[ 11 ];\n\t\t\tte[ 12 ] = me[ 12 ]; te[ 13 ] = me[ 13 ]; te[ 14 ] = me[ 14 ]; te[ 15 ] = me[ 15 ];\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcopyPosition: function ( m ) {\n\n\t\t\tvar te = this.elements, me = m.elements;\n\n\t\t\tte[ 12 ] = me[ 12 ];\n\t\t\tte[ 13 ] = me[ 13 ];\n\t\t\tte[ 14 ] = me[ 14 ];\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\textractBasis: function ( xAxis, yAxis, zAxis ) {\n\n\t\t\txAxis.setFromMatrixColumn( this, 0 );\n\t\t\tyAxis.setFromMatrixColumn( this, 1 );\n\t\t\tzAxis.setFromMatrixColumn( this, 2 );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmakeBasis: function ( xAxis, yAxis, zAxis ) {\n\n\t\t\tthis.set(\n\t\t\t\txAxis.x, yAxis.x, zAxis.x, 0,\n\t\t\t\txAxis.y, yAxis.y, zAxis.y, 0,\n\t\t\t\txAxis.z, yAxis.z, zAxis.z, 0,\n\t\t\t\t0, 0, 0, 1\n\t\t\t);\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\textractRotation: function () {\n\n\t\t\tvar v1 = new Vector3();\n\n\t\t\treturn function extractRotation( m ) {\n\n\t\t\t\t// this method does not support reflection matrices\n\n\t\t\t\tvar te = this.elements;\n\t\t\t\tvar me = m.elements;\n\n\t\t\t\tvar scaleX = 1 / v1.setFromMatrixColumn( m, 0 ).length();\n\t\t\t\tvar scaleY = 1 / v1.setFromMatrixColumn( m, 1 ).length();\n\t\t\t\tvar scaleZ = 1 / v1.setFromMatrixColumn( m, 2 ).length();\n\n\t\t\t\tte[ 0 ] = me[ 0 ] * scaleX;\n\t\t\t\tte[ 1 ] = me[ 1 ] * scaleX;\n\t\t\t\tte[ 2 ] = me[ 2 ] * scaleX;\n\t\t\t\tte[ 3 ] = 0;\n\n\t\t\t\tte[ 4 ] = me[ 4 ] * scaleY;\n\t\t\t\tte[ 5 ] = me[ 5 ] * scaleY;\n\t\t\t\tte[ 6 ] = me[ 6 ] * scaleY;\n\t\t\t\tte[ 7 ] = 0;\n\n\t\t\t\tte[ 8 ] = me[ 8 ] * scaleZ;\n\t\t\t\tte[ 9 ] = me[ 9 ] * scaleZ;\n\t\t\t\tte[ 10 ] = me[ 10 ] * scaleZ;\n\t\t\t\tte[ 11 ] = 0;\n\n\t\t\t\tte[ 12 ] = 0;\n\t\t\t\tte[ 13 ] = 0;\n\t\t\t\tte[ 14 ] = 0;\n\t\t\t\tte[ 15 ] = 1;\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tmakeRotationFromEuler: function ( euler ) {\n\n\t\t\tif ( ! ( euler && euler.isEuler ) ) {\n\n\t\t\t\tconsole.error( 'THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.' );\n\n\t\t\t}\n\n\t\t\tvar te = this.elements;\n\n\t\t\tvar x = euler.x, y = euler.y, z = euler.z;\n\t\t\tvar a = Math.cos( x ), b = Math.sin( x );\n\t\t\tvar c = Math.cos( y ), d = Math.sin( y );\n\t\t\tvar e = Math.cos( z ), f = Math.sin( z );\n\n\t\t\tif ( euler.order === 'XYZ' ) {\n\n\t\t\t\tvar ae = a * e, af = a * f, be = b * e, bf = b * f;\n\n\t\t\t\tte[ 0 ] = c * e;\n\t\t\t\tte[ 4 ] = - c * f;\n\t\t\t\tte[ 8 ] = d;\n\n\t\t\t\tte[ 1 ] = af + be * d;\n\t\t\t\tte[ 5 ] = ae - bf * d;\n\t\t\t\tte[ 9 ] = - b * c;\n\n\t\t\t\tte[ 2 ] = bf - ae * d;\n\t\t\t\tte[ 6 ] = be + af * d;\n\t\t\t\tte[ 10 ] = a * c;\n\n\t\t\t} else if ( euler.order === 'YXZ' ) {\n\n\t\t\t\tvar ce = c * e, cf = c * f, de = d * e, df = d * f;\n\n\t\t\t\tte[ 0 ] = ce + df * b;\n\t\t\t\tte[ 4 ] = de * b - cf;\n\t\t\t\tte[ 8 ] = a * d;\n\n\t\t\t\tte[ 1 ] = a * f;\n\t\t\t\tte[ 5 ] = a * e;\n\t\t\t\tte[ 9 ] = - b;\n\n\t\t\t\tte[ 2 ] = cf * b - de;\n\t\t\t\tte[ 6 ] = df + ce * b;\n\t\t\t\tte[ 10 ] = a * c;\n\n\t\t\t} else if ( euler.order === 'ZXY' ) {\n\n\t\t\t\tvar ce = c * e, cf = c * f, de = d * e, df = d * f;\n\n\t\t\t\tte[ 0 ] = ce - df * b;\n\t\t\t\tte[ 4 ] = - a * f;\n\t\t\t\tte[ 8 ] = de + cf * b;\n\n\t\t\t\tte[ 1 ] = cf + de * b;\n\t\t\t\tte[ 5 ] = a * e;\n\t\t\t\tte[ 9 ] = df - ce * b;\n\n\t\t\t\tte[ 2 ] = - a * d;\n\t\t\t\tte[ 6 ] = b;\n\t\t\t\tte[ 10 ] = a * c;\n\n\t\t\t} else if ( euler.order === 'ZYX' ) {\n\n\t\t\t\tvar ae = a * e, af = a * f, be = b * e, bf = b * f;\n\n\t\t\t\tte[ 0 ] = c * e;\n\t\t\t\tte[ 4 ] = be * d - af;\n\t\t\t\tte[ 8 ] = ae * d + bf;\n\n\t\t\t\tte[ 1 ] = c * f;\n\t\t\t\tte[ 5 ] = bf * d + ae;\n\t\t\t\tte[ 9 ] = af * d - be;\n\n\t\t\t\tte[ 2 ] = - d;\n\t\t\t\tte[ 6 ] = b * c;\n\t\t\t\tte[ 10 ] = a * c;\n\n\t\t\t} else if ( euler.order === 'YZX' ) {\n\n\t\t\t\tvar ac = a * c, ad = a * d, bc = b * c, bd = b * d;\n\n\t\t\t\tte[ 0 ] = c * e;\n\t\t\t\tte[ 4 ] = bd - ac * f;\n\t\t\t\tte[ 8 ] = bc * f + ad;\n\n\t\t\t\tte[ 1 ] = f;\n\t\t\t\tte[ 5 ] = a * e;\n\t\t\t\tte[ 9 ] = - b * e;\n\n\t\t\t\tte[ 2 ] = - d * e;\n\t\t\t\tte[ 6 ] = ad * f + bc;\n\t\t\t\tte[ 10 ] = ac - bd * f;\n\n\t\t\t} else if ( euler.order === 'XZY' ) {\n\n\t\t\t\tvar ac = a * c, ad = a * d, bc = b * c, bd = b * d;\n\n\t\t\t\tte[ 0 ] = c * e;\n\t\t\t\tte[ 4 ] = - f;\n\t\t\t\tte[ 8 ] = d * e;\n\n\t\t\t\tte[ 1 ] = ac * f + bd;\n\t\t\t\tte[ 5 ] = a * e;\n\t\t\t\tte[ 9 ] = ad * f - bc;\n\n\t\t\t\tte[ 2 ] = bc * f - ad;\n\t\t\t\tte[ 6 ] = b * e;\n\t\t\t\tte[ 10 ] = bd * f + ac;\n\n\t\t\t}\n\n\t\t\t// bottom row\n\t\t\tte[ 3 ] = 0;\n\t\t\tte[ 7 ] = 0;\n\t\t\tte[ 11 ] = 0;\n\n\t\t\t// last column\n\t\t\tte[ 12 ] = 0;\n\t\t\tte[ 13 ] = 0;\n\t\t\tte[ 14 ] = 0;\n\t\t\tte[ 15 ] = 1;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmakeRotationFromQuaternion: function () {\n\n\t\t\tvar zero = new Vector3( 0, 0, 0 );\n\t\t\tvar one = new Vector3( 1, 1, 1 );\n\n\t\t\treturn function makeRotationFromQuaternion( q ) {\n\n\t\t\t\treturn this.compose( zero, q, one );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tlookAt: function () {\n\n\t\t\tvar x = new Vector3();\n\t\t\tvar y = new Vector3();\n\t\t\tvar z = new Vector3();\n\n\t\t\treturn function lookAt( eye, target, up ) {\n\n\t\t\t\tvar te = this.elements;\n\n\t\t\t\tz.subVectors( eye, target );\n\n\t\t\t\tif ( z.lengthSq() === 0 ) {\n\n\t\t\t\t\t// eye and target are in the same position\n\n\t\t\t\t\tz.z = 1;\n\n\t\t\t\t}\n\n\t\t\t\tz.normalize();\n\t\t\t\tx.crossVectors( up, z );\n\n\t\t\t\tif ( x.lengthSq() === 0 ) {\n\n\t\t\t\t\t// up and z are parallel\n\n\t\t\t\t\tif ( Math.abs( up.z ) === 1 ) {\n\n\t\t\t\t\t\tz.x += 0.0001;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tz.z += 0.0001;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tz.normalize();\n\t\t\t\t\tx.crossVectors( up, z );\n\n\t\t\t\t}\n\n\t\t\t\tx.normalize();\n\t\t\t\ty.crossVectors( z, x );\n\n\t\t\t\tte[ 0 ] = x.x; te[ 4 ] = y.x; te[ 8 ] = z.x;\n\t\t\t\tte[ 1 ] = x.y; te[ 5 ] = y.y; te[ 9 ] = z.y;\n\t\t\t\tte[ 2 ] = x.z; te[ 6 ] = y.z; te[ 10 ] = z.z;\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tmultiply: function ( m, n ) {\n\n\t\t\tif ( n !== undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.' );\n\t\t\t\treturn this.multiplyMatrices( m, n );\n\n\t\t\t}\n\n\t\t\treturn this.multiplyMatrices( this, m );\n\n\t\t},\n\n\t\tpremultiply: function ( m ) {\n\n\t\t\treturn this.multiplyMatrices( m, this );\n\n\t\t},\n\n\t\tmultiplyMatrices: function ( a, b ) {\n\n\t\t\tvar ae = a.elements;\n\t\t\tvar be = b.elements;\n\t\t\tvar te = this.elements;\n\n\t\t\tvar a11 = ae[ 0 ], a12 = ae[ 4 ], a13 = ae[ 8 ], a14 = ae[ 12 ];\n\t\t\tvar a21 = ae[ 1 ], a22 = ae[ 5 ], a23 = ae[ 9 ], a24 = ae[ 13 ];\n\t\t\tvar a31 = ae[ 2 ], a32 = ae[ 6 ], a33 = ae[ 10 ], a34 = ae[ 14 ];\n\t\t\tvar a41 = ae[ 3 ], a42 = ae[ 7 ], a43 = ae[ 11 ], a44 = ae[ 15 ];\n\n\t\t\tvar b11 = be[ 0 ], b12 = be[ 4 ], b13 = be[ 8 ], b14 = be[ 12 ];\n\t\t\tvar b21 = be[ 1 ], b22 = be[ 5 ], b23 = be[ 9 ], b24 = be[ 13 ];\n\t\t\tvar b31 = be[ 2 ], b32 = be[ 6 ], b33 = be[ 10 ], b34 = be[ 14 ];\n\t\t\tvar b41 = be[ 3 ], b42 = be[ 7 ], b43 = be[ 11 ], b44 = be[ 15 ];\n\n\t\t\tte[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;\n\t\t\tte[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;\n\t\t\tte[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;\n\t\t\tte[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;\n\n\t\t\tte[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;\n\t\t\tte[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;\n\t\t\tte[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;\n\t\t\tte[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;\n\n\t\t\tte[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;\n\t\t\tte[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;\n\t\t\tte[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;\n\t\t\tte[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;\n\n\t\t\tte[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;\n\t\t\tte[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;\n\t\t\tte[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;\n\t\t\tte[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmultiplyScalar: function ( s ) {\n\n\t\t\tvar te = this.elements;\n\n\t\t\tte[ 0 ] *= s; te[ 4 ] *= s; te[ 8 ] *= s; te[ 12 ] *= s;\n\t\t\tte[ 1 ] *= s; te[ 5 ] *= s; te[ 9 ] *= s; te[ 13 ] *= s;\n\t\t\tte[ 2 ] *= s; te[ 6 ] *= s; te[ 10 ] *= s; te[ 14 ] *= s;\n\t\t\tte[ 3 ] *= s; te[ 7 ] *= s; te[ 11 ] *= s; te[ 15 ] *= s;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tapplyToBufferAttribute: function () {\n\n\t\t\tvar v1 = new Vector3();\n\n\t\t\treturn function applyToBufferAttribute( attribute ) {\n\n\t\t\t\tfor ( var i = 0, l = attribute.count; i < l; i ++ ) {\n\n\t\t\t\t\tv1.x = attribute.getX( i );\n\t\t\t\t\tv1.y = attribute.getY( i );\n\t\t\t\t\tv1.z = attribute.getZ( i );\n\n\t\t\t\t\tv1.applyMatrix4( this );\n\n\t\t\t\t\tattribute.setXYZ( i, v1.x, v1.y, v1.z );\n\n\t\t\t\t}\n\n\t\t\t\treturn attribute;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tdeterminant: function () {\n\n\t\t\tvar te = this.elements;\n\n\t\t\tvar n11 = te[ 0 ], n12 = te[ 4 ], n13 = te[ 8 ], n14 = te[ 12 ];\n\t\t\tvar n21 = te[ 1 ], n22 = te[ 5 ], n23 = te[ 9 ], n24 = te[ 13 ];\n\t\t\tvar n31 = te[ 2 ], n32 = te[ 6 ], n33 = te[ 10 ], n34 = te[ 14 ];\n\t\t\tvar n41 = te[ 3 ], n42 = te[ 7 ], n43 = te[ 11 ], n44 = te[ 15 ];\n\n\t\t\t//TODO: make this more efficient\n\t\t\t//( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )\n\n\t\t\treturn (\n\t\t\t\tn41 * (\n\t\t\t\t\t+ n14 * n23 * n32\n\t\t\t\t\t - n13 * n24 * n32\n\t\t\t\t\t - n14 * n22 * n33\n\t\t\t\t\t + n12 * n24 * n33\n\t\t\t\t\t + n13 * n22 * n34\n\t\t\t\t\t - n12 * n23 * n34\n\t\t\t\t) +\n\t\t\t\tn42 * (\n\t\t\t\t\t+ n11 * n23 * n34\n\t\t\t\t\t - n11 * n24 * n33\n\t\t\t\t\t + n14 * n21 * n33\n\t\t\t\t\t - n13 * n21 * n34\n\t\t\t\t\t + n13 * n24 * n31\n\t\t\t\t\t - n14 * n23 * n31\n\t\t\t\t) +\n\t\t\t\tn43 * (\n\t\t\t\t\t+ n11 * n24 * n32\n\t\t\t\t\t - n11 * n22 * n34\n\t\t\t\t\t - n14 * n21 * n32\n\t\t\t\t\t + n12 * n21 * n34\n\t\t\t\t\t + n14 * n22 * n31\n\t\t\t\t\t - n12 * n24 * n31\n\t\t\t\t) +\n\t\t\t\tn44 * (\n\t\t\t\t\t- n13 * n22 * n31\n\t\t\t\t\t - n11 * n23 * n32\n\t\t\t\t\t + n11 * n22 * n33\n\t\t\t\t\t + n13 * n21 * n32\n\t\t\t\t\t - n12 * n21 * n33\n\t\t\t\t\t + n12 * n23 * n31\n\t\t\t\t)\n\n\t\t\t);\n\n\t\t},\n\n\t\ttranspose: function () {\n\n\t\t\tvar te = this.elements;\n\t\t\tvar tmp;\n\n\t\t\ttmp = te[ 1 ]; te[ 1 ] = te[ 4 ]; te[ 4 ] = tmp;\n\t\t\ttmp = te[ 2 ]; te[ 2 ] = te[ 8 ]; te[ 8 ] = tmp;\n\t\t\ttmp = te[ 6 ]; te[ 6 ] = te[ 9 ]; te[ 9 ] = tmp;\n\n\t\t\ttmp = te[ 3 ]; te[ 3 ] = te[ 12 ]; te[ 12 ] = tmp;\n\t\t\ttmp = te[ 7 ]; te[ 7 ] = te[ 13 ]; te[ 13 ] = tmp;\n\t\t\ttmp = te[ 11 ]; te[ 11 ] = te[ 14 ]; te[ 14 ] = tmp;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetPosition: function ( v ) {\n\n\t\t\tvar te = this.elements;\n\n\t\t\tte[ 12 ] = v.x;\n\t\t\tte[ 13 ] = v.y;\n\t\t\tte[ 14 ] = v.z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetInverse: function ( m, throwOnDegenerate ) {\n\n\t\t\t// based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm\n\t\t\tvar te = this.elements,\n\t\t\t\tme = m.elements,\n\n\t\t\t\tn11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ], n41 = me[ 3 ],\n\t\t\t\tn12 = me[ 4 ], n22 = me[ 5 ], n32 = me[ 6 ], n42 = me[ 7 ],\n\t\t\t\tn13 = me[ 8 ], n23 = me[ 9 ], n33 = me[ 10 ], n43 = me[ 11 ],\n\t\t\t\tn14 = me[ 12 ], n24 = me[ 13 ], n34 = me[ 14 ], n44 = me[ 15 ],\n\n\t\t\t\tt11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,\n\t\t\t\tt12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,\n\t\t\t\tt13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,\n\t\t\t\tt14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;\n\n\t\t\tvar det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;\n\n\t\t\tif ( det === 0 ) {\n\n\t\t\t\tvar msg = \"THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0\";\n\n\t\t\t\tif ( throwOnDegenerate === true ) {\n\n\t\t\t\t\tthrow new Error( msg );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( msg );\n\n\t\t\t\t}\n\n\t\t\t\treturn this.identity();\n\n\t\t\t}\n\n\t\t\tvar detInv = 1 / det;\n\n\t\t\tte[ 0 ] = t11 * detInv;\n\t\t\tte[ 1 ] = ( n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44 ) * detInv;\n\t\t\tte[ 2 ] = ( n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44 ) * detInv;\n\t\t\tte[ 3 ] = ( n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43 ) * detInv;\n\n\t\t\tte[ 4 ] = t12 * detInv;\n\t\t\tte[ 5 ] = ( n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44 ) * detInv;\n\t\t\tte[ 6 ] = ( n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44 ) * detInv;\n\t\t\tte[ 7 ] = ( n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43 ) * detInv;\n\n\t\t\tte[ 8 ] = t13 * detInv;\n\t\t\tte[ 9 ] = ( n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44 ) * detInv;\n\t\t\tte[ 10 ] = ( n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44 ) * detInv;\n\t\t\tte[ 11 ] = ( n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43 ) * detInv;\n\n\t\t\tte[ 12 ] = t14 * detInv;\n\t\t\tte[ 13 ] = ( n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34 ) * detInv;\n\t\t\tte[ 14 ] = ( n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34 ) * detInv;\n\t\t\tte[ 15 ] = ( n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33 ) * detInv;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tscale: function ( v ) {\n\n\t\t\tvar te = this.elements;\n\t\t\tvar x = v.x, y = v.y, z = v.z;\n\n\t\t\tte[ 0 ] *= x; te[ 4 ] *= y; te[ 8 ] *= z;\n\t\t\tte[ 1 ] *= x; te[ 5 ] *= y; te[ 9 ] *= z;\n\t\t\tte[ 2 ] *= x; te[ 6 ] *= y; te[ 10 ] *= z;\n\t\t\tte[ 3 ] *= x; te[ 7 ] *= y; te[ 11 ] *= z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetMaxScaleOnAxis: function () {\n\n\t\t\tvar te = this.elements;\n\n\t\t\tvar scaleXSq = te[ 0 ] * te[ 0 ] + te[ 1 ] * te[ 1 ] + te[ 2 ] * te[ 2 ];\n\t\t\tvar scaleYSq = te[ 4 ] * te[ 4 ] + te[ 5 ] * te[ 5 ] + te[ 6 ] * te[ 6 ];\n\t\t\tvar scaleZSq = te[ 8 ] * te[ 8 ] + te[ 9 ] * te[ 9 ] + te[ 10 ] * te[ 10 ];\n\n\t\t\treturn Math.sqrt( Math.max( scaleXSq, scaleYSq, scaleZSq ) );\n\n\t\t},\n\n\t\tmakeTranslation: function ( x, y, z ) {\n\n\t\t\tthis.set(\n\n\t\t\t\t1, 0, 0, x,\n\t\t\t\t0, 1, 0, y,\n\t\t\t\t0, 0, 1, z,\n\t\t\t\t0, 0, 0, 1\n\n\t\t\t);\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmakeRotationX: function ( theta ) {\n\n\t\t\tvar c = Math.cos( theta ), s = Math.sin( theta );\n\n\t\t\tthis.set(\n\n\t\t\t\t1, 0, 0, 0,\n\t\t\t\t0, c, - s, 0,\n\t\t\t\t0, s, c, 0,\n\t\t\t\t0, 0, 0, 1\n\n\t\t\t);\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmakeRotationY: function ( theta ) {\n\n\t\t\tvar c = Math.cos( theta ), s = Math.sin( theta );\n\n\t\t\tthis.set(\n\n\t\t\t\t c, 0, s, 0,\n\t\t\t\t 0, 1, 0, 0,\n\t\t\t\t- s, 0, c, 0,\n\t\t\t\t 0, 0, 0, 1\n\n\t\t\t);\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmakeRotationZ: function ( theta ) {\n\n\t\t\tvar c = Math.cos( theta ), s = Math.sin( theta );\n\n\t\t\tthis.set(\n\n\t\t\t\tc, - s, 0, 0,\n\t\t\t\ts, c, 0, 0,\n\t\t\t\t0, 0, 1, 0,\n\t\t\t\t0, 0, 0, 1\n\n\t\t\t);\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmakeRotationAxis: function ( axis, angle ) {\n\n\t\t\t// Based on http://www.gamedev.net/reference/articles/article1199.asp\n\n\t\t\tvar c = Math.cos( angle );\n\t\t\tvar s = Math.sin( angle );\n\t\t\tvar t = 1 - c;\n\t\t\tvar x = axis.x, y = axis.y, z = axis.z;\n\t\t\tvar tx = t * x, ty = t * y;\n\n\t\t\tthis.set(\n\n\t\t\t\ttx * x + c, tx * y - s * z, tx * z + s * y, 0,\n\t\t\t\ttx * y + s * z, ty * y + c, ty * z - s * x, 0,\n\t\t\t\ttx * z - s * y, ty * z + s * x, t * z * z + c, 0,\n\t\t\t\t0, 0, 0, 1\n\n\t\t\t);\n\n\t\t\t return this;\n\n\t\t},\n\n\t\tmakeScale: function ( x, y, z ) {\n\n\t\t\tthis.set(\n\n\t\t\t\tx, 0, 0, 0,\n\t\t\t\t0, y, 0, 0,\n\t\t\t\t0, 0, z, 0,\n\t\t\t\t0, 0, 0, 1\n\n\t\t\t);\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmakeShear: function ( x, y, z ) {\n\n\t\t\tthis.set(\n\n\t\t\t\t1, y, z, 0,\n\t\t\t\tx, 1, z, 0,\n\t\t\t\tx, y, 1, 0,\n\t\t\t\t0, 0, 0, 1\n\n\t\t\t);\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcompose: function ( position, quaternion, scale ) {\n\n\t\t\tvar te = this.elements;\n\n\t\t\tvar x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;\n\t\t\tvar x2 = x + x,\ty2 = y + y, z2 = z + z;\n\t\t\tvar xx = x * x2, xy = x * y2, xz = x * z2;\n\t\t\tvar yy = y * y2, yz = y * z2, zz = z * z2;\n\t\t\tvar wx = w * x2, wy = w * y2, wz = w * z2;\n\n\t\t\tvar sx = scale.x, sy = scale.y, sz = scale.z;\n\n\t\t        te[ 0 ] = ( 1 - ( yy + zz ) ) * sx;\n\t\t        te[ 1 ] = ( xy + wz ) * sx;\n\t\t        te[ 2 ] = ( xz - wy ) * sx;\n\t\t        te[ 3 ] = 0;\n\n\t\t        te[ 4 ] = ( xy - wz ) * sy;\n\t\t        te[ 5 ] = ( 1 - ( xx + zz ) ) * sy;\n\t\t        te[ 6 ] = ( yz + wx ) * sy;\n\t\t        te[ 7 ] = 0;\n\n\t\t        te[ 8 ] = ( xz + wy ) * sz;\n\t\t        te[ 9 ] = ( yz - wx ) * sz;\n\t\t        te[ 10 ] = ( 1 - ( xx + yy ) ) * sz;\n\t\t        te[ 11 ] = 0;\n\n\t\t        te[ 12 ] = position.x;\n\t\t        te[ 13 ] = position.y;\n\t\t        te[ 14 ] = position.z;\n\t\t        te[ 15 ] = 1;\n\n\t\t        return this;\n\n\t\t},\n\n\t\tdecompose: function () {\n\n\t\t\tvar vector = new Vector3();\n\t\t\tvar matrix = new Matrix4();\n\n\t\t\treturn function decompose( position, quaternion, scale ) {\n\n\t\t\t\tvar te = this.elements;\n\n\t\t\t\tvar sx = vector.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();\n\t\t\t\tvar sy = vector.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length();\n\t\t\t\tvar sz = vector.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length();\n\n\t\t\t\t// if determine is negative, we need to invert one scale\n\t\t\t\tvar det = this.determinant();\n\t\t\t\tif ( det < 0 ) sx = - sx;\n\n\t\t\t\tposition.x = te[ 12 ];\n\t\t\t\tposition.y = te[ 13 ];\n\t\t\t\tposition.z = te[ 14 ];\n\n\t\t\t\t// scale the rotation part\n\t\t\t\tmatrix.copy( this );\n\n\t\t\t\tvar invSX = 1 / sx;\n\t\t\t\tvar invSY = 1 / sy;\n\t\t\t\tvar invSZ = 1 / sz;\n\n\t\t\t\tmatrix.elements[ 0 ] *= invSX;\n\t\t\t\tmatrix.elements[ 1 ] *= invSX;\n\t\t\t\tmatrix.elements[ 2 ] *= invSX;\n\n\t\t\t\tmatrix.elements[ 4 ] *= invSY;\n\t\t\t\tmatrix.elements[ 5 ] *= invSY;\n\t\t\t\tmatrix.elements[ 6 ] *= invSY;\n\n\t\t\t\tmatrix.elements[ 8 ] *= invSZ;\n\t\t\t\tmatrix.elements[ 9 ] *= invSZ;\n\t\t\t\tmatrix.elements[ 10 ] *= invSZ;\n\n\t\t\t\tquaternion.setFromRotationMatrix( matrix );\n\n\t\t\t\tscale.x = sx;\n\t\t\t\tscale.y = sy;\n\t\t\t\tscale.z = sz;\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tmakePerspective: function ( left, right, top, bottom, near, far ) {\n\n\t\t\tif ( far === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.' );\n\n\t\t\t}\n\n\t\t\tvar te = this.elements;\n\t\t\tvar x = 2 * near / ( right - left );\n\t\t\tvar y = 2 * near / ( top - bottom );\n\n\t\t\tvar a = ( right + left ) / ( right - left );\n\t\t\tvar b = ( top + bottom ) / ( top - bottom );\n\t\t\tvar c = - ( far + near ) / ( far - near );\n\t\t\tvar d = - 2 * far * near / ( far - near );\n\n\t\t\tte[ 0 ] = x;\tte[ 4 ] = 0;\tte[ 8 ] = a;\tte[ 12 ] = 0;\n\t\t\tte[ 1 ] = 0;\tte[ 5 ] = y;\tte[ 9 ] = b;\tte[ 13 ] = 0;\n\t\t\tte[ 2 ] = 0;\tte[ 6 ] = 0;\tte[ 10 ] = c;\tte[ 14 ] = d;\n\t\t\tte[ 3 ] = 0;\tte[ 7 ] = 0;\tte[ 11 ] = - 1;\tte[ 15 ] = 0;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmakeOrthographic: function ( left, right, top, bottom, near, far ) {\n\n\t\t\tvar te = this.elements;\n\t\t\tvar w = 1.0 / ( right - left );\n\t\t\tvar h = 1.0 / ( top - bottom );\n\t\t\tvar p = 1.0 / ( far - near );\n\n\t\t\tvar x = ( right + left ) * w;\n\t\t\tvar y = ( top + bottom ) * h;\n\t\t\tvar z = ( far + near ) * p;\n\n\t\t\tte[ 0 ] = 2 * w;\tte[ 4 ] = 0;\tte[ 8 ] = 0;\tte[ 12 ] = - x;\n\t\t\tte[ 1 ] = 0;\tte[ 5 ] = 2 * h;\tte[ 9 ] = 0;\tte[ 13 ] = - y;\n\t\t\tte[ 2 ] = 0;\tte[ 6 ] = 0;\tte[ 10 ] = - 2 * p;\tte[ 14 ] = - z;\n\t\t\tte[ 3 ] = 0;\tte[ 7 ] = 0;\tte[ 11 ] = 0;\tte[ 15 ] = 1;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tequals: function ( matrix ) {\n\n\t\t\tvar te = this.elements;\n\t\t\tvar me = matrix.elements;\n\n\t\t\tfor ( var i = 0; i < 16; i ++ ) {\n\n\t\t\t\tif ( te[ i ] !== me[ i ] ) return false;\n\n\t\t\t}\n\n\t\t\treturn true;\n\n\t\t},\n\n\t\tfromArray: function ( array, offset ) {\n\n\t\t\tif ( offset === undefined ) offset = 0;\n\n\t\t\tfor ( var i = 0; i < 16; i ++ ) {\n\n\t\t\t\tthis.elements[ i ] = array[ i + offset ];\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttoArray: function ( array, offset ) {\n\n\t\t\tif ( array === undefined ) array = [];\n\t\t\tif ( offset === undefined ) offset = 0;\n\n\t\t\tvar te = this.elements;\n\n\t\t\tarray[ offset ] = te[ 0 ];\n\t\t\tarray[ offset + 1 ] = te[ 1 ];\n\t\t\tarray[ offset + 2 ] = te[ 2 ];\n\t\t\tarray[ offset + 3 ] = te[ 3 ];\n\n\t\t\tarray[ offset + 4 ] = te[ 4 ];\n\t\t\tarray[ offset + 5 ] = te[ 5 ];\n\t\t\tarray[ offset + 6 ] = te[ 6 ];\n\t\t\tarray[ offset + 7 ] = te[ 7 ];\n\n\t\t\tarray[ offset + 8 ] = te[ 8 ];\n\t\t\tarray[ offset + 9 ] = te[ 9 ];\n\t\t\tarray[ offset + 10 ] = te[ 10 ];\n\t\t\tarray[ offset + 11 ] = te[ 11 ];\n\n\t\t\tarray[ offset + 12 ] = te[ 12 ];\n\t\t\tarray[ offset + 13 ] = te[ 13 ];\n\t\t\tarray[ offset + 14 ] = te[ 14 ];\n\t\t\tarray[ offset + 15 ] = te[ 15 ];\n\n\t\t\treturn array;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mikael emtinger / http://gomo.se/\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author WestLangley / http://github.com/WestLangley\n\t * @author bhouston / http://clara.io\n\t */\n\n\tfunction Quaternion( x, y, z, w ) {\n\n\t\tthis._x = x || 0;\n\t\tthis._y = y || 0;\n\t\tthis._z = z || 0;\n\t\tthis._w = ( w !== undefined ) ? w : 1;\n\n\t}\n\n\tObject.assign( Quaternion, {\n\n\t\tslerp: function ( qa, qb, qm, t ) {\n\n\t\t\treturn qm.copy( qa ).slerp( qb, t );\n\n\t\t},\n\n\t\tslerpFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {\n\n\t\t\t// fuzz-free, array-based Quaternion SLERP operation\n\n\t\t\tvar x0 = src0[ srcOffset0 + 0 ],\n\t\t\t\ty0 = src0[ srcOffset0 + 1 ],\n\t\t\t\tz0 = src0[ srcOffset0 + 2 ],\n\t\t\t\tw0 = src0[ srcOffset0 + 3 ],\n\n\t\t\t\tx1 = src1[ srcOffset1 + 0 ],\n\t\t\t\ty1 = src1[ srcOffset1 + 1 ],\n\t\t\t\tz1 = src1[ srcOffset1 + 2 ],\n\t\t\t\tw1 = src1[ srcOffset1 + 3 ];\n\n\t\t\tif ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) {\n\n\t\t\t\tvar s = 1 - t,\n\n\t\t\t\t\tcos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1,\n\n\t\t\t\t\tdir = ( cos >= 0 ? 1 : - 1 ),\n\t\t\t\t\tsqrSin = 1 - cos * cos;\n\n\t\t\t\t// Skip the Slerp for tiny steps to avoid numeric problems:\n\t\t\t\tif ( sqrSin > Number.EPSILON ) {\n\n\t\t\t\t\tvar sin = Math.sqrt( sqrSin ),\n\t\t\t\t\t\tlen = Math.atan2( sin, cos * dir );\n\n\t\t\t\t\ts = Math.sin( s * len ) / sin;\n\t\t\t\t\tt = Math.sin( t * len ) / sin;\n\n\t\t\t\t}\n\n\t\t\t\tvar tDir = t * dir;\n\n\t\t\t\tx0 = x0 * s + x1 * tDir;\n\t\t\t\ty0 = y0 * s + y1 * tDir;\n\t\t\t\tz0 = z0 * s + z1 * tDir;\n\t\t\t\tw0 = w0 * s + w1 * tDir;\n\n\t\t\t\t// Normalize in case we just did a lerp:\n\t\t\t\tif ( s === 1 - t ) {\n\n\t\t\t\t\tvar f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 );\n\n\t\t\t\t\tx0 *= f;\n\t\t\t\t\ty0 *= f;\n\t\t\t\t\tz0 *= f;\n\t\t\t\t\tw0 *= f;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tdst[ dstOffset ] = x0;\n\t\t\tdst[ dstOffset + 1 ] = y0;\n\t\t\tdst[ dstOffset + 2 ] = z0;\n\t\t\tdst[ dstOffset + 3 ] = w0;\n\n\t\t}\n\n\t} );\n\n\tObject.defineProperties( Quaternion.prototype, {\n\n\t\tx: {\n\n\t\t\tget: function () {\n\n\t\t\t\treturn this._x;\n\n\t\t\t},\n\n\t\t\tset: function ( value ) {\n\n\t\t\t\tthis._x = value;\n\t\t\t\tthis.onChangeCallback();\n\n\t\t\t}\n\n\t\t},\n\n\t\ty: {\n\n\t\t\tget: function () {\n\n\t\t\t\treturn this._y;\n\n\t\t\t},\n\n\t\t\tset: function ( value ) {\n\n\t\t\t\tthis._y = value;\n\t\t\t\tthis.onChangeCallback();\n\n\t\t\t}\n\n\t\t},\n\n\t\tz: {\n\n\t\t\tget: function () {\n\n\t\t\t\treturn this._z;\n\n\t\t\t},\n\n\t\t\tset: function ( value ) {\n\n\t\t\t\tthis._z = value;\n\t\t\t\tthis.onChangeCallback();\n\n\t\t\t}\n\n\t\t},\n\n\t\tw: {\n\n\t\t\tget: function () {\n\n\t\t\t\treturn this._w;\n\n\t\t\t},\n\n\t\t\tset: function ( value ) {\n\n\t\t\t\tthis._w = value;\n\t\t\t\tthis.onChangeCallback();\n\n\t\t\t}\n\n\t\t}\n\n\t} );\n\n\tObject.assign( Quaternion.prototype, {\n\n\t\tisQuaternion: true,\n\n\t\tset: function ( x, y, z, w ) {\n\n\t\t\tthis._x = x;\n\t\t\tthis._y = y;\n\t\t\tthis._z = z;\n\t\t\tthis._w = w;\n\n\t\t\tthis.onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor( this._x, this._y, this._z, this._w );\n\n\t\t},\n\n\t\tcopy: function ( quaternion ) {\n\n\t\t\tthis._x = quaternion.x;\n\t\t\tthis._y = quaternion.y;\n\t\t\tthis._z = quaternion.z;\n\t\t\tthis._w = quaternion.w;\n\n\t\t\tthis.onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromEuler: function ( euler, update ) {\n\n\t\t\tif ( ! ( euler && euler.isEuler ) ) {\n\n\t\t\t\tthrow new Error( 'THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.' );\n\n\t\t\t}\n\n\t\t\tvar x = euler._x, y = euler._y, z = euler._z, order = euler.order;\n\n\t\t\t// http://www.mathworks.com/matlabcentral/fileexchange/\n\t\t\t// \t20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/\n\t\t\t//\tcontent/SpinCalc.m\n\n\t\t\tvar cos = Math.cos;\n\t\t\tvar sin = Math.sin;\n\n\t\t\tvar c1 = cos( x / 2 );\n\t\t\tvar c2 = cos( y / 2 );\n\t\t\tvar c3 = cos( z / 2 );\n\n\t\t\tvar s1 = sin( x / 2 );\n\t\t\tvar s2 = sin( y / 2 );\n\t\t\tvar s3 = sin( z / 2 );\n\n\t\t\tif ( order === 'XYZ' ) {\n\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\n\t\t\t} else if ( order === 'YXZ' ) {\n\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\n\t\t\t} else if ( order === 'ZXY' ) {\n\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\n\t\t\t} else if ( order === 'ZYX' ) {\n\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\n\t\t\t} else if ( order === 'YZX' ) {\n\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\n\t\t\t} else if ( order === 'XZY' ) {\n\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\n\t\t\t}\n\n\t\t\tif ( update !== false ) this.onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromAxisAngle: function ( axis, angle ) {\n\n\t\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm\n\n\t\t\t// assumes axis is normalized\n\n\t\t\tvar halfAngle = angle / 2, s = Math.sin( halfAngle );\n\n\t\t\tthis._x = axis.x * s;\n\t\t\tthis._y = axis.y * s;\n\t\t\tthis._z = axis.z * s;\n\t\t\tthis._w = Math.cos( halfAngle );\n\n\t\t\tthis.onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromRotationMatrix: function ( m ) {\n\n\t\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm\n\n\t\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\t\tvar te = m.elements,\n\n\t\t\t\tm11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],\n\t\t\t\tm21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],\n\t\t\t\tm31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ],\n\n\t\t\t\ttrace = m11 + m22 + m33,\n\t\t\t\ts;\n\n\t\t\tif ( trace > 0 ) {\n\n\t\t\t\ts = 0.5 / Math.sqrt( trace + 1.0 );\n\n\t\t\t\tthis._w = 0.25 / s;\n\t\t\t\tthis._x = ( m32 - m23 ) * s;\n\t\t\t\tthis._y = ( m13 - m31 ) * s;\n\t\t\t\tthis._z = ( m21 - m12 ) * s;\n\n\t\t\t} else if ( m11 > m22 && m11 > m33 ) {\n\n\t\t\t\ts = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 );\n\n\t\t\t\tthis._w = ( m32 - m23 ) / s;\n\t\t\t\tthis._x = 0.25 * s;\n\t\t\t\tthis._y = ( m12 + m21 ) / s;\n\t\t\t\tthis._z = ( m13 + m31 ) / s;\n\n\t\t\t} else if ( m22 > m33 ) {\n\n\t\t\t\ts = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 );\n\n\t\t\t\tthis._w = ( m13 - m31 ) / s;\n\t\t\t\tthis._x = ( m12 + m21 ) / s;\n\t\t\t\tthis._y = 0.25 * s;\n\t\t\t\tthis._z = ( m23 + m32 ) / s;\n\n\t\t\t} else {\n\n\t\t\t\ts = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 );\n\n\t\t\t\tthis._w = ( m21 - m12 ) / s;\n\t\t\t\tthis._x = ( m13 + m31 ) / s;\n\t\t\t\tthis._y = ( m23 + m32 ) / s;\n\t\t\t\tthis._z = 0.25 * s;\n\n\t\t\t}\n\n\t\t\tthis.onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromUnitVectors: function () {\n\n\t\t\t// assumes direction vectors vFrom and vTo are normalized\n\n\t\t\tvar v1 = new Vector3();\n\t\t\tvar r;\n\n\t\t\tvar EPS = 0.000001;\n\n\t\t\treturn function setFromUnitVectors( vFrom, vTo ) {\n\n\t\t\t\tif ( v1 === undefined ) v1 = new Vector3();\n\n\t\t\t\tr = vFrom.dot( vTo ) + 1;\n\n\t\t\t\tif ( r < EPS ) {\n\n\t\t\t\t\tr = 0;\n\n\t\t\t\t\tif ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) {\n\n\t\t\t\t\t\tv1.set( - vFrom.y, vFrom.x, 0 );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tv1.set( 0, - vFrom.z, vFrom.y );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tv1.crossVectors( vFrom, vTo );\n\n\t\t\t\t}\n\n\t\t\t\tthis._x = v1.x;\n\t\t\t\tthis._y = v1.y;\n\t\t\t\tthis._z = v1.z;\n\t\t\t\tthis._w = r;\n\n\t\t\t\treturn this.normalize();\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tangleTo: function ( q ) {\n\n\t\t\treturn 2 * Math.acos( Math.abs( _Math.clamp( this.dot( q ), - 1, 1 ) ) );\n\n\t\t},\n\n\t\trotateTowards: function ( q, step ) {\n\n\t\t\tvar angle = this.angleTo( q );\n\n\t\t\tif ( angle === 0 ) return this;\n\n\t\t\tvar t = Math.min( 1, step / angle );\n\n\t\t\tthis.slerp( q, t );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tinverse: function () {\n\n\t\t\t// quaternion is assumed to have unit length\n\n\t\t\treturn this.conjugate();\n\n\t\t},\n\n\t\tconjugate: function () {\n\n\t\t\tthis._x *= - 1;\n\t\t\tthis._y *= - 1;\n\t\t\tthis._z *= - 1;\n\n\t\t\tthis.onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tdot: function ( v ) {\n\n\t\t\treturn this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;\n\n\t\t},\n\n\t\tlengthSq: function () {\n\n\t\t\treturn this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;\n\n\t\t},\n\n\t\tlength: function () {\n\n\t\t\treturn Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w );\n\n\t\t},\n\n\t\tnormalize: function () {\n\n\t\t\tvar l = this.length();\n\n\t\t\tif ( l === 0 ) {\n\n\t\t\t\tthis._x = 0;\n\t\t\t\tthis._y = 0;\n\t\t\t\tthis._z = 0;\n\t\t\t\tthis._w = 1;\n\n\t\t\t} else {\n\n\t\t\t\tl = 1 / l;\n\n\t\t\t\tthis._x = this._x * l;\n\t\t\t\tthis._y = this._y * l;\n\t\t\t\tthis._z = this._z * l;\n\t\t\t\tthis._w = this._w * l;\n\n\t\t\t}\n\n\t\t\tthis.onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmultiply: function ( q, p ) {\n\n\t\t\tif ( p !== undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' );\n\t\t\t\treturn this.multiplyQuaternions( q, p );\n\n\t\t\t}\n\n\t\t\treturn this.multiplyQuaternions( this, q );\n\n\t\t},\n\n\t\tpremultiply: function ( q ) {\n\n\t\t\treturn this.multiplyQuaternions( q, this );\n\n\t\t},\n\n\t\tmultiplyQuaternions: function ( a, b ) {\n\n\t\t\t// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm\n\n\t\t\tvar qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;\n\t\t\tvar qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;\n\n\t\t\tthis._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;\n\t\t\tthis._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;\n\t\t\tthis._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;\n\t\t\tthis._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;\n\n\t\t\tthis.onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tslerp: function ( qb, t ) {\n\n\t\t\tif ( t === 0 ) return this;\n\t\t\tif ( t === 1 ) return this.copy( qb );\n\n\t\t\tvar x = this._x, y = this._y, z = this._z, w = this._w;\n\n\t\t\t// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/\n\n\t\t\tvar cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;\n\n\t\t\tif ( cosHalfTheta < 0 ) {\n\n\t\t\t\tthis._w = - qb._w;\n\t\t\t\tthis._x = - qb._x;\n\t\t\t\tthis._y = - qb._y;\n\t\t\t\tthis._z = - qb._z;\n\n\t\t\t\tcosHalfTheta = - cosHalfTheta;\n\n\t\t\t} else {\n\n\t\t\t\tthis.copy( qb );\n\n\t\t\t}\n\n\t\t\tif ( cosHalfTheta >= 1.0 ) {\n\n\t\t\t\tthis._w = w;\n\t\t\t\tthis._x = x;\n\t\t\t\tthis._y = y;\n\t\t\t\tthis._z = z;\n\n\t\t\t\treturn this;\n\n\t\t\t}\n\n\t\t\tvar sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;\n\n\t\t\tif ( sqrSinHalfTheta <= Number.EPSILON ) {\n\n\t\t\t\tvar s = 1 - t;\n\t\t\t\tthis._w = s * w + t * this._w;\n\t\t\t\tthis._x = s * x + t * this._x;\n\t\t\t\tthis._y = s * y + t * this._y;\n\t\t\t\tthis._z = s * z + t * this._z;\n\n\t\t\t\treturn this.normalize();\n\n\t\t\t}\n\n\t\t\tvar sinHalfTheta = Math.sqrt( sqrSinHalfTheta );\n\t\t\tvar halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta );\n\t\t\tvar ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta,\n\t\t\t\tratioB = Math.sin( t * halfTheta ) / sinHalfTheta;\n\n\t\t\tthis._w = ( w * ratioA + this._w * ratioB );\n\t\t\tthis._x = ( x * ratioA + this._x * ratioB );\n\t\t\tthis._y = ( y * ratioA + this._y * ratioB );\n\t\t\tthis._z = ( z * ratioA + this._z * ratioB );\n\n\t\t\tthis.onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tequals: function ( quaternion ) {\n\n\t\t\treturn ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w );\n\n\t\t},\n\n\t\tfromArray: function ( array, offset ) {\n\n\t\t\tif ( offset === undefined ) offset = 0;\n\n\t\t\tthis._x = array[ offset ];\n\t\t\tthis._y = array[ offset + 1 ];\n\t\t\tthis._z = array[ offset + 2 ];\n\t\t\tthis._w = array[ offset + 3 ];\n\n\t\t\tthis.onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttoArray: function ( array, offset ) {\n\n\t\t\tif ( array === undefined ) array = [];\n\t\t\tif ( offset === undefined ) offset = 0;\n\n\t\t\tarray[ offset ] = this._x;\n\t\t\tarray[ offset + 1 ] = this._y;\n\t\t\tarray[ offset + 2 ] = this._z;\n\t\t\tarray[ offset + 3 ] = this._w;\n\n\t\t\treturn array;\n\n\t\t},\n\n\t\tonChange: function ( callback ) {\n\n\t\t\tthis.onChangeCallback = callback;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tonChangeCallback: function () {}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author kile / http://kile.stravaganza.org/\n\t * @author philogb / http://blog.thejit.org/\n\t * @author mikael emtinger / http://gomo.se/\n\t * @author egraether / http://egraether.com/\n\t * @author WestLangley / http://github.com/WestLangley\n\t */\n\n\tfunction Vector3( x, y, z ) {\n\n\t\tthis.x = x || 0;\n\t\tthis.y = y || 0;\n\t\tthis.z = z || 0;\n\n\t}\n\n\tObject.assign( Vector3.prototype, {\n\n\t\tisVector3: true,\n\n\t\tset: function ( x, y, z ) {\n\n\t\t\tthis.x = x;\n\t\t\tthis.y = y;\n\t\t\tthis.z = z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetScalar: function ( scalar ) {\n\n\t\t\tthis.x = scalar;\n\t\t\tthis.y = scalar;\n\t\t\tthis.z = scalar;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetX: function ( x ) {\n\n\t\t\tthis.x = x;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetY: function ( y ) {\n\n\t\t\tthis.y = y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetZ: function ( z ) {\n\n\t\t\tthis.z = z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetComponent: function ( index, value ) {\n\n\t\t\tswitch ( index ) {\n\n\t\t\t\tcase 0: this.x = value; break;\n\t\t\t\tcase 1: this.y = value; break;\n\t\t\t\tcase 2: this.z = value; break;\n\t\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetComponent: function ( index ) {\n\n\t\t\tswitch ( index ) {\n\n\t\t\t\tcase 0: return this.x;\n\t\t\t\tcase 1: return this.y;\n\t\t\t\tcase 2: return this.z;\n\t\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t\t}\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor( this.x, this.y, this.z );\n\n\t\t},\n\n\t\tcopy: function ( v ) {\n\n\t\t\tthis.x = v.x;\n\t\t\tthis.y = v.y;\n\t\t\tthis.z = v.z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tadd: function ( v, w ) {\n\n\t\t\tif ( w !== undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );\n\t\t\t\treturn this.addVectors( v, w );\n\n\t\t\t}\n\n\t\t\tthis.x += v.x;\n\t\t\tthis.y += v.y;\n\t\t\tthis.z += v.z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\taddScalar: function ( s ) {\n\n\t\t\tthis.x += s;\n\t\t\tthis.y += s;\n\t\t\tthis.z += s;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\taddVectors: function ( a, b ) {\n\n\t\t\tthis.x = a.x + b.x;\n\t\t\tthis.y = a.y + b.y;\n\t\t\tthis.z = a.z + b.z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\taddScaledVector: function ( v, s ) {\n\n\t\t\tthis.x += v.x * s;\n\t\t\tthis.y += v.y * s;\n\t\t\tthis.z += v.z * s;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsub: function ( v, w ) {\n\n\t\t\tif ( w !== undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );\n\t\t\t\treturn this.subVectors( v, w );\n\n\t\t\t}\n\n\t\t\tthis.x -= v.x;\n\t\t\tthis.y -= v.y;\n\t\t\tthis.z -= v.z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsubScalar: function ( s ) {\n\n\t\t\tthis.x -= s;\n\t\t\tthis.y -= s;\n\t\t\tthis.z -= s;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsubVectors: function ( a, b ) {\n\n\t\t\tthis.x = a.x - b.x;\n\t\t\tthis.y = a.y - b.y;\n\t\t\tthis.z = a.z - b.z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmultiply: function ( v, w ) {\n\n\t\t\tif ( w !== undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.' );\n\t\t\t\treturn this.multiplyVectors( v, w );\n\n\t\t\t}\n\n\t\t\tthis.x *= v.x;\n\t\t\tthis.y *= v.y;\n\t\t\tthis.z *= v.z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmultiplyScalar: function ( scalar ) {\n\n\t\t\tthis.x *= scalar;\n\t\t\tthis.y *= scalar;\n\t\t\tthis.z *= scalar;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmultiplyVectors: function ( a, b ) {\n\n\t\t\tthis.x = a.x * b.x;\n\t\t\tthis.y = a.y * b.y;\n\t\t\tthis.z = a.z * b.z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tapplyEuler: function () {\n\n\t\t\tvar quaternion = new Quaternion();\n\n\t\t\treturn function applyEuler( euler ) {\n\n\t\t\t\tif ( ! ( euler && euler.isEuler ) ) {\n\n\t\t\t\t\tconsole.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );\n\n\t\t\t\t}\n\n\t\t\t\treturn this.applyQuaternion( quaternion.setFromEuler( euler ) );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tapplyAxisAngle: function () {\n\n\t\t\tvar quaternion = new Quaternion();\n\n\t\t\treturn function applyAxisAngle( axis, angle ) {\n\n\t\t\t\treturn this.applyQuaternion( quaternion.setFromAxisAngle( axis, angle ) );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tapplyMatrix3: function ( m ) {\n\n\t\t\tvar x = this.x, y = this.y, z = this.z;\n\t\t\tvar e = m.elements;\n\n\t\t\tthis.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z;\n\t\t\tthis.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z;\n\t\t\tthis.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tapplyMatrix4: function ( m ) {\n\n\t\t\tvar x = this.x, y = this.y, z = this.z;\n\t\t\tvar e = m.elements;\n\n\t\t\tvar w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] );\n\n\t\t\tthis.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * w;\n\t\t\tthis.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * w;\n\t\t\tthis.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * w;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tapplyQuaternion: function ( q ) {\n\n\t\t\tvar x = this.x, y = this.y, z = this.z;\n\t\t\tvar qx = q.x, qy = q.y, qz = q.z, qw = q.w;\n\n\t\t\t// calculate quat * vector\n\n\t\t\tvar ix = qw * x + qy * z - qz * y;\n\t\t\tvar iy = qw * y + qz * x - qx * z;\n\t\t\tvar iz = qw * z + qx * y - qy * x;\n\t\t\tvar iw = - qx * x - qy * y - qz * z;\n\n\t\t\t// calculate result * inverse quat\n\n\t\t\tthis.x = ix * qw + iw * - qx + iy * - qz - iz * - qy;\n\t\t\tthis.y = iy * qw + iw * - qy + iz * - qx - ix * - qz;\n\t\t\tthis.z = iz * qw + iw * - qz + ix * - qy - iy * - qx;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tproject: function ( camera ) {\n\n\t\t\treturn this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix );\n\n\t\t},\n\n\t\tunproject: function () {\n\n\t\t\tvar matrix = new Matrix4();\n\n\t\t\treturn function unproject( camera ) {\n\n\t\t\t\treturn this.applyMatrix4( matrix.getInverse( camera.projectionMatrix ) ).applyMatrix4( camera.matrixWorld );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\ttransformDirection: function ( m ) {\n\n\t\t\t// input: THREE.Matrix4 affine matrix\n\t\t\t// vector interpreted as a direction\n\n\t\t\tvar x = this.x, y = this.y, z = this.z;\n\t\t\tvar e = m.elements;\n\n\t\t\tthis.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z;\n\t\t\tthis.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z;\n\t\t\tthis.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z;\n\n\t\t\treturn this.normalize();\n\n\t\t},\n\n\t\tdivide: function ( v ) {\n\n\t\t\tthis.x /= v.x;\n\t\t\tthis.y /= v.y;\n\t\t\tthis.z /= v.z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tdivideScalar: function ( scalar ) {\n\n\t\t\treturn this.multiplyScalar( 1 / scalar );\n\n\t\t},\n\n\t\tmin: function ( v ) {\n\n\t\t\tthis.x = Math.min( this.x, v.x );\n\t\t\tthis.y = Math.min( this.y, v.y );\n\t\t\tthis.z = Math.min( this.z, v.z );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmax: function ( v ) {\n\n\t\t\tthis.x = Math.max( this.x, v.x );\n\t\t\tthis.y = Math.max( this.y, v.y );\n\t\t\tthis.z = Math.max( this.z, v.z );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclamp: function ( min, max ) {\n\n\t\t\t// assumes min < max, componentwise\n\n\t\t\tthis.x = Math.max( min.x, Math.min( max.x, this.x ) );\n\t\t\tthis.y = Math.max( min.y, Math.min( max.y, this.y ) );\n\t\t\tthis.z = Math.max( min.z, Math.min( max.z, this.z ) );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclampScalar: function () {\n\n\t\t\tvar min = new Vector3();\n\t\t\tvar max = new Vector3();\n\n\t\t\treturn function clampScalar( minVal, maxVal ) {\n\n\t\t\t\tmin.set( minVal, minVal, minVal );\n\t\t\t\tmax.set( maxVal, maxVal, maxVal );\n\n\t\t\t\treturn this.clamp( min, max );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tclampLength: function ( min, max ) {\n\n\t\t\tvar length = this.length();\n\n\t\t\treturn this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );\n\n\t\t},\n\n\t\tfloor: function () {\n\n\t\t\tthis.x = Math.floor( this.x );\n\t\t\tthis.y = Math.floor( this.y );\n\t\t\tthis.z = Math.floor( this.z );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tceil: function () {\n\n\t\t\tthis.x = Math.ceil( this.x );\n\t\t\tthis.y = Math.ceil( this.y );\n\t\t\tthis.z = Math.ceil( this.z );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tround: function () {\n\n\t\t\tthis.x = Math.round( this.x );\n\t\t\tthis.y = Math.round( this.y );\n\t\t\tthis.z = Math.round( this.z );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\troundToZero: function () {\n\n\t\t\tthis.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );\n\t\t\tthis.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );\n\t\t\tthis.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tnegate: function () {\n\n\t\t\tthis.x = - this.x;\n\t\t\tthis.y = - this.y;\n\t\t\tthis.z = - this.z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tdot: function ( v ) {\n\n\t\t\treturn this.x * v.x + this.y * v.y + this.z * v.z;\n\n\t\t},\n\n\t\t// TODO lengthSquared?\n\n\t\tlengthSq: function () {\n\n\t\t\treturn this.x * this.x + this.y * this.y + this.z * this.z;\n\n\t\t},\n\n\t\tlength: function () {\n\n\t\t\treturn Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );\n\n\t\t},\n\n\t\tmanhattanLength: function () {\n\n\t\t\treturn Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );\n\n\t\t},\n\n\t\tnormalize: function () {\n\n\t\t\treturn this.divideScalar( this.length() || 1 );\n\n\t\t},\n\n\t\tsetLength: function ( length ) {\n\n\t\t\treturn this.normalize().multiplyScalar( length );\n\n\t\t},\n\n\t\tlerp: function ( v, alpha ) {\n\n\t\t\tthis.x += ( v.x - this.x ) * alpha;\n\t\t\tthis.y += ( v.y - this.y ) * alpha;\n\t\t\tthis.z += ( v.z - this.z ) * alpha;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tlerpVectors: function ( v1, v2, alpha ) {\n\n\t\t\treturn this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );\n\n\t\t},\n\n\t\tcross: function ( v, w ) {\n\n\t\t\tif ( w !== undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.' );\n\t\t\t\treturn this.crossVectors( v, w );\n\n\t\t\t}\n\n\t\t\treturn this.crossVectors( this, v );\n\n\t\t},\n\n\t\tcrossVectors: function ( a, b ) {\n\n\t\t\tvar ax = a.x, ay = a.y, az = a.z;\n\t\t\tvar bx = b.x, by = b.y, bz = b.z;\n\n\t\t\tthis.x = ay * bz - az * by;\n\t\t\tthis.y = az * bx - ax * bz;\n\t\t\tthis.z = ax * by - ay * bx;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tprojectOnVector: function ( vector ) {\n\n\t\t\tvar scalar = vector.dot( this ) / vector.lengthSq();\n\n\t\t\treturn this.copy( vector ).multiplyScalar( scalar );\n\n\t\t},\n\n\t\tprojectOnPlane: function () {\n\n\t\t\tvar v1 = new Vector3();\n\n\t\t\treturn function projectOnPlane( planeNormal ) {\n\n\t\t\t\tv1.copy( this ).projectOnVector( planeNormal );\n\n\t\t\t\treturn this.sub( v1 );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\treflect: function () {\n\n\t\t\t// reflect incident vector off plane orthogonal to normal\n\t\t\t// normal is assumed to have unit length\n\n\t\t\tvar v1 = new Vector3();\n\n\t\t\treturn function reflect( normal ) {\n\n\t\t\t\treturn this.sub( v1.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tangleTo: function ( v ) {\n\n\t\t\tvar theta = this.dot( v ) / ( Math.sqrt( this.lengthSq() * v.lengthSq() ) );\n\n\t\t\t// clamp, to handle numerical problems\n\n\t\t\treturn Math.acos( _Math.clamp( theta, - 1, 1 ) );\n\n\t\t},\n\n\t\tdistanceTo: function ( v ) {\n\n\t\t\treturn Math.sqrt( this.distanceToSquared( v ) );\n\n\t\t},\n\n\t\tdistanceToSquared: function ( v ) {\n\n\t\t\tvar dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;\n\n\t\t\treturn dx * dx + dy * dy + dz * dz;\n\n\t\t},\n\n\t\tmanhattanDistanceTo: function ( v ) {\n\n\t\t\treturn Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );\n\n\t\t},\n\n\t\tsetFromSpherical: function ( s ) {\n\n\t\t\treturn this.setFromSphericalCoords( s.radius, s.phi, s.theta );\n\n\t\t},\n\n\t\tsetFromSphericalCoords: function ( radius, phi, theta ) {\n\n\t\t\tvar sinPhiRadius = Math.sin( phi ) * radius;\n\n\t\t\tthis.x = sinPhiRadius * Math.sin( theta );\n\t\t\tthis.y = Math.cos( phi ) * radius;\n\t\t\tthis.z = sinPhiRadius * Math.cos( theta );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromCylindrical: function ( c ) {\n\n\t\t\treturn this.setFromCylindricalCoords( c.radius, c.theta, c.y );\n\n\t\t},\n\n\t\tsetFromCylindricalCoords: function ( radius, theta, y ) {\n\n\t\t\tthis.x = radius * Math.sin( theta );\n\t\t\tthis.y = y;\n\t\t\tthis.z = radius * Math.cos( theta );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromMatrixPosition: function ( m ) {\n\n\t\t\tvar e = m.elements;\n\n\t\t\tthis.x = e[ 12 ];\n\t\t\tthis.y = e[ 13 ];\n\t\t\tthis.z = e[ 14 ];\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromMatrixScale: function ( m ) {\n\n\t\t\tvar sx = this.setFromMatrixColumn( m, 0 ).length();\n\t\t\tvar sy = this.setFromMatrixColumn( m, 1 ).length();\n\t\t\tvar sz = this.setFromMatrixColumn( m, 2 ).length();\n\n\t\t\tthis.x = sx;\n\t\t\tthis.y = sy;\n\t\t\tthis.z = sz;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromMatrixColumn: function ( m, index ) {\n\n\t\t\treturn this.fromArray( m.elements, index * 4 );\n\n\t\t},\n\n\t\tequals: function ( v ) {\n\n\t\t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) );\n\n\t\t},\n\n\t\tfromArray: function ( array, offset ) {\n\n\t\t\tif ( offset === undefined ) offset = 0;\n\n\t\t\tthis.x = array[ offset ];\n\t\t\tthis.y = array[ offset + 1 ];\n\t\t\tthis.z = array[ offset + 2 ];\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttoArray: function ( array, offset ) {\n\n\t\t\tif ( array === undefined ) array = [];\n\t\t\tif ( offset === undefined ) offset = 0;\n\n\t\t\tarray[ offset ] = this.x;\n\t\t\tarray[ offset + 1 ] = this.y;\n\t\t\tarray[ offset + 2 ] = this.z;\n\n\t\t\treturn array;\n\n\t\t},\n\n\t\tfromBufferAttribute: function ( attribute, index, offset ) {\n\n\t\t\tif ( offset !== undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' );\n\n\t\t\t}\n\n\t\t\tthis.x = attribute.getX( index );\n\t\t\tthis.y = attribute.getY( index );\n\t\t\tthis.z = attribute.getZ( index );\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author WestLangley / http://github.com/WestLangley\n\t * @author bhouston / http://clara.io\n\t * @author tschw\n\t */\n\n\tfunction Matrix3() {\n\n\t\tthis.elements = [\n\n\t\t\t1, 0, 0,\n\t\t\t0, 1, 0,\n\t\t\t0, 0, 1\n\n\t\t];\n\n\t\tif ( arguments.length > 0 ) {\n\n\t\t\tconsole.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' );\n\n\t\t}\n\n\t}\n\n\tObject.assign( Matrix3.prototype, {\n\n\t\tisMatrix3: true,\n\n\t\tset: function ( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) {\n\n\t\t\tvar te = this.elements;\n\n\t\t\tte[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31;\n\t\t\tte[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32;\n\t\t\tte[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tidentity: function () {\n\n\t\t\tthis.set(\n\n\t\t\t\t1, 0, 0,\n\t\t\t\t0, 1, 0,\n\t\t\t\t0, 0, 1\n\n\t\t\t);\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().fromArray( this.elements );\n\n\t\t},\n\n\t\tcopy: function ( m ) {\n\n\t\t\tvar te = this.elements;\n\t\t\tvar me = m.elements;\n\n\t\t\tte[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ];\n\t\t\tte[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ];\n\t\t\tte[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ];\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromMatrix4: function ( m ) {\n\n\t\t\tvar me = m.elements;\n\n\t\t\tthis.set(\n\n\t\t\t\tme[ 0 ], me[ 4 ], me[ 8 ],\n\t\t\t\tme[ 1 ], me[ 5 ], me[ 9 ],\n\t\t\t\tme[ 2 ], me[ 6 ], me[ 10 ]\n\n\t\t\t);\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tapplyToBufferAttribute: function () {\n\n\t\t\tvar v1 = new Vector3();\n\n\t\t\treturn function applyToBufferAttribute( attribute ) {\n\n\t\t\t\tfor ( var i = 0, l = attribute.count; i < l; i ++ ) {\n\n\t\t\t\t\tv1.x = attribute.getX( i );\n\t\t\t\t\tv1.y = attribute.getY( i );\n\t\t\t\t\tv1.z = attribute.getZ( i );\n\n\t\t\t\t\tv1.applyMatrix3( this );\n\n\t\t\t\t\tattribute.setXYZ( i, v1.x, v1.y, v1.z );\n\n\t\t\t\t}\n\n\t\t\t\treturn attribute;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tmultiply: function ( m ) {\n\n\t\t\treturn this.multiplyMatrices( this, m );\n\n\t\t},\n\n\t\tpremultiply: function ( m ) {\n\n\t\t\treturn this.multiplyMatrices( m, this );\n\n\t\t},\n\n\t\tmultiplyMatrices: function ( a, b ) {\n\n\t\t\tvar ae = a.elements;\n\t\t\tvar be = b.elements;\n\t\t\tvar te = this.elements;\n\n\t\t\tvar a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ];\n\t\t\tvar a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ];\n\t\t\tvar a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ];\n\n\t\t\tvar b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ];\n\t\t\tvar b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ];\n\t\t\tvar b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ];\n\n\t\t\tte[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31;\n\t\t\tte[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32;\n\t\t\tte[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33;\n\n\t\t\tte[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31;\n\t\t\tte[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32;\n\t\t\tte[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33;\n\n\t\t\tte[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31;\n\t\t\tte[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32;\n\t\t\tte[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmultiplyScalar: function ( s ) {\n\n\t\t\tvar te = this.elements;\n\n\t\t\tte[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s;\n\t\t\tte[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s;\n\t\t\tte[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tdeterminant: function () {\n\n\t\t\tvar te = this.elements;\n\n\t\t\tvar a = te[ 0 ], b = te[ 1 ], c = te[ 2 ],\n\t\t\t\td = te[ 3 ], e = te[ 4 ], f = te[ 5 ],\n\t\t\t\tg = te[ 6 ], h = te[ 7 ], i = te[ 8 ];\n\n\t\t\treturn a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;\n\n\t\t},\n\n\t\tgetInverse: function ( matrix, throwOnDegenerate ) {\n\n\t\t\tif ( matrix && matrix.isMatrix4 ) {\n\n\t\t\t\tconsole.error( \"THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument.\" );\n\n\t\t\t}\n\n\t\t\tvar me = matrix.elements,\n\t\t\t\tte = this.elements,\n\n\t\t\t\tn11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ],\n\t\t\t\tn12 = me[ 3 ], n22 = me[ 4 ], n32 = me[ 5 ],\n\t\t\t\tn13 = me[ 6 ], n23 = me[ 7 ], n33 = me[ 8 ],\n\n\t\t\t\tt11 = n33 * n22 - n32 * n23,\n\t\t\t\tt12 = n32 * n13 - n33 * n12,\n\t\t\t\tt13 = n23 * n12 - n22 * n13,\n\n\t\t\t\tdet = n11 * t11 + n21 * t12 + n31 * t13;\n\n\t\t\tif ( det === 0 ) {\n\n\t\t\t\tvar msg = \"THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0\";\n\n\t\t\t\tif ( throwOnDegenerate === true ) {\n\n\t\t\t\t\tthrow new Error( msg );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( msg );\n\n\t\t\t\t}\n\n\t\t\t\treturn this.identity();\n\n\t\t\t}\n\n\t\t\tvar detInv = 1 / det;\n\n\t\t\tte[ 0 ] = t11 * detInv;\n\t\t\tte[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv;\n\t\t\tte[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv;\n\n\t\t\tte[ 3 ] = t12 * detInv;\n\t\t\tte[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv;\n\t\t\tte[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv;\n\n\t\t\tte[ 6 ] = t13 * detInv;\n\t\t\tte[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv;\n\t\t\tte[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttranspose: function () {\n\n\t\t\tvar tmp, m = this.elements;\n\n\t\t\ttmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp;\n\t\t\ttmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp;\n\t\t\ttmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetNormalMatrix: function ( matrix4 ) {\n\n\t\t\treturn this.setFromMatrix4( matrix4 ).getInverse( this ).transpose();\n\n\t\t},\n\n\t\ttransposeIntoArray: function ( r ) {\n\n\t\t\tvar m = this.elements;\n\n\t\t\tr[ 0 ] = m[ 0 ];\n\t\t\tr[ 1 ] = m[ 3 ];\n\t\t\tr[ 2 ] = m[ 6 ];\n\t\t\tr[ 3 ] = m[ 1 ];\n\t\t\tr[ 4 ] = m[ 4 ];\n\t\t\tr[ 5 ] = m[ 7 ];\n\t\t\tr[ 6 ] = m[ 2 ];\n\t\t\tr[ 7 ] = m[ 5 ];\n\t\t\tr[ 8 ] = m[ 8 ];\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetUvTransform: function ( tx, ty, sx, sy, rotation, cx, cy ) {\n\n\t\t\tvar c = Math.cos( rotation );\n\t\t\tvar s = Math.sin( rotation );\n\n\t\t\tthis.set(\n\t\t\t\tsx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx,\n\t\t\t\t- sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty,\n\t\t\t\t0, 0, 1\n\t\t\t);\n\n\t\t},\n\n\t\tscale: function ( sx, sy ) {\n\n\t\t\tvar te = this.elements;\n\n\t\t\tte[ 0 ] *= sx; te[ 3 ] *= sx; te[ 6 ] *= sx;\n\t\t\tte[ 1 ] *= sy; te[ 4 ] *= sy; te[ 7 ] *= sy;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\trotate: function ( theta ) {\n\n\t\t\tvar c = Math.cos( theta );\n\t\t\tvar s = Math.sin( theta );\n\n\t\t\tvar te = this.elements;\n\n\t\t\tvar a11 = te[ 0 ], a12 = te[ 3 ], a13 = te[ 6 ];\n\t\t\tvar a21 = te[ 1 ], a22 = te[ 4 ], a23 = te[ 7 ];\n\n\t\t\tte[ 0 ] = c * a11 + s * a21;\n\t\t\tte[ 3 ] = c * a12 + s * a22;\n\t\t\tte[ 6 ] = c * a13 + s * a23;\n\n\t\t\tte[ 1 ] = - s * a11 + c * a21;\n\t\t\tte[ 4 ] = - s * a12 + c * a22;\n\t\t\tte[ 7 ] = - s * a13 + c * a23;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttranslate: function ( tx, ty ) {\n\n\t\t\tvar te = this.elements;\n\n\t\t\tte[ 0 ] += tx * te[ 2 ]; te[ 3 ] += tx * te[ 5 ]; te[ 6 ] += tx * te[ 8 ];\n\t\t\tte[ 1 ] += ty * te[ 2 ]; te[ 4 ] += ty * te[ 5 ]; te[ 7 ] += ty * te[ 8 ];\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tequals: function ( matrix ) {\n\n\t\t\tvar te = this.elements;\n\t\t\tvar me = matrix.elements;\n\n\t\t\tfor ( var i = 0; i < 9; i ++ ) {\n\n\t\t\t\tif ( te[ i ] !== me[ i ] ) return false;\n\n\t\t\t}\n\n\t\t\treturn true;\n\n\t\t},\n\n\t\tfromArray: function ( array, offset ) {\n\n\t\t\tif ( offset === undefined ) offset = 0;\n\n\t\t\tfor ( var i = 0; i < 9; i ++ ) {\n\n\t\t\t\tthis.elements[ i ] = array[ i + offset ];\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttoArray: function ( array, offset ) {\n\n\t\t\tif ( array === undefined ) array = [];\n\t\t\tif ( offset === undefined ) offset = 0;\n\n\t\t\tvar te = this.elements;\n\n\t\t\tarray[ offset ] = te[ 0 ];\n\t\t\tarray[ offset + 1 ] = te[ 1 ];\n\t\t\tarray[ offset + 2 ] = te[ 2 ];\n\n\t\t\tarray[ offset + 3 ] = te[ 3 ];\n\t\t\tarray[ offset + 4 ] = te[ 4 ];\n\t\t\tarray[ offset + 5 ] = te[ 5 ];\n\n\t\t\tarray[ offset + 6 ] = te[ 6 ];\n\t\t\tarray[ offset + 7 ] = te[ 7 ];\n\t\t\tarray[ offset + 8 ] = te[ 8 ];\n\n\t\t\treturn array;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author szimek / https://github.com/szimek/\n\t */\n\n\tvar _canvas;\n\n\tvar ImageUtils = {\n\n\t\tgetDataURL: function ( image ) {\n\n\t\t\tvar canvas;\n\n\t\t\tif ( typeof HTMLCanvasElement == 'undefined' ) {\n\n\t\t\t\treturn image.src;\n\n\t\t\t} else if ( image instanceof HTMLCanvasElement ) {\n\n\t\t\t\tcanvas = image;\n\n\t\t\t} else {\n\n\t\t\t\tif ( _canvas === undefined ) _canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );\n\n\t\t\t\t_canvas.width = image.width;\n\t\t\t\t_canvas.height = image.height;\n\n\t\t\t\tvar context = _canvas.getContext( '2d' );\n\n\t\t\t\tif ( image instanceof ImageData ) {\n\n\t\t\t\t\tcontext.putImageData( image, 0, 0 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tcontext.drawImage( image, 0, 0, image.width, image.height );\n\n\t\t\t\t}\n\n\t\t\t\tcanvas = _canvas;\n\n\t\t\t}\n\n\t\t\tif ( canvas.width > 2048 || canvas.height > 2048 ) {\n\n\t\t\t\treturn canvas.toDataURL( 'image/jpeg', 0.6 );\n\n\t\t\t} else {\n\n\t\t\t\treturn canvas.toDataURL( 'image/png' );\n\n\t\t\t}\n\n\t\t}\n\n\t};\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author szimek / https://github.com/szimek/\n\t */\n\n\tvar textureId = 0;\n\n\tfunction Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {\n\n\t\tObject.defineProperty( this, 'id', { value: textureId ++ } );\n\n\t\tthis.uuid = _Math.generateUUID();\n\n\t\tthis.name = '';\n\n\t\tthis.image = image !== undefined ? image : Texture.DEFAULT_IMAGE;\n\t\tthis.mipmaps = [];\n\n\t\tthis.mapping = mapping !== undefined ? mapping : Texture.DEFAULT_MAPPING;\n\n\t\tthis.wrapS = wrapS !== undefined ? wrapS : ClampToEdgeWrapping;\n\t\tthis.wrapT = wrapT !== undefined ? wrapT : ClampToEdgeWrapping;\n\n\t\tthis.magFilter = magFilter !== undefined ? magFilter : LinearFilter;\n\t\tthis.minFilter = minFilter !== undefined ? minFilter : LinearMipMapLinearFilter;\n\n\t\tthis.anisotropy = anisotropy !== undefined ? anisotropy : 1;\n\n\t\tthis.format = format !== undefined ? format : RGBAFormat;\n\t\tthis.type = type !== undefined ? type : UnsignedByteType;\n\n\t\tthis.offset = new Vector2( 0, 0 );\n\t\tthis.repeat = new Vector2( 1, 1 );\n\t\tthis.center = new Vector2( 0, 0 );\n\t\tthis.rotation = 0;\n\n\t\tthis.matrixAutoUpdate = true;\n\t\tthis.matrix = new Matrix3();\n\n\t\tthis.generateMipmaps = true;\n\t\tthis.premultiplyAlpha = false;\n\t\tthis.flipY = true;\n\t\tthis.unpackAlignment = 4;\t// valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)\n\n\t\t// Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap.\n\t\t//\n\t\t// Also changing the encoding after already used by a Material will not automatically make the Material\n\t\t// update.  You need to explicitly call Material.needsUpdate to trigger it to recompile.\n\t\tthis.encoding = encoding !== undefined ? encoding : LinearEncoding;\n\n\t\tthis.version = 0;\n\t\tthis.onUpdate = null;\n\n\t}\n\n\tTexture.DEFAULT_IMAGE = undefined;\n\tTexture.DEFAULT_MAPPING = UVMapping;\n\n\tTexture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\t\tconstructor: Texture,\n\n\t\tisTexture: true,\n\n\t\tupdateMatrix: function () {\n\n\t\t\tthis.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y );\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t},\n\n\t\tcopy: function ( source ) {\n\n\t\t\tthis.name = source.name;\n\n\t\t\tthis.image = source.image;\n\t\t\tthis.mipmaps = source.mipmaps.slice( 0 );\n\n\t\t\tthis.mapping = source.mapping;\n\n\t\t\tthis.wrapS = source.wrapS;\n\t\t\tthis.wrapT = source.wrapT;\n\n\t\t\tthis.magFilter = source.magFilter;\n\t\t\tthis.minFilter = source.minFilter;\n\n\t\t\tthis.anisotropy = source.anisotropy;\n\n\t\t\tthis.format = source.format;\n\t\t\tthis.type = source.type;\n\n\t\t\tthis.offset.copy( source.offset );\n\t\t\tthis.repeat.copy( source.repeat );\n\t\t\tthis.center.copy( source.center );\n\t\t\tthis.rotation = source.rotation;\n\n\t\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\t\t\tthis.matrix.copy( source.matrix );\n\n\t\t\tthis.generateMipmaps = source.generateMipmaps;\n\t\t\tthis.premultiplyAlpha = source.premultiplyAlpha;\n\t\t\tthis.flipY = source.flipY;\n\t\t\tthis.unpackAlignment = source.unpackAlignment;\n\t\t\tthis.encoding = source.encoding;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttoJSON: function ( meta ) {\n\n\t\t\tvar isRootObject = ( meta === undefined || typeof meta === 'string' );\n\n\t\t\tif ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) {\n\n\t\t\t\treturn meta.textures[ this.uuid ];\n\n\t\t\t}\n\n\t\t\tvar output = {\n\n\t\t\t\tmetadata: {\n\t\t\t\t\tversion: 4.5,\n\t\t\t\t\ttype: 'Texture',\n\t\t\t\t\tgenerator: 'Texture.toJSON'\n\t\t\t\t},\n\n\t\t\t\tuuid: this.uuid,\n\t\t\t\tname: this.name,\n\n\t\t\t\tmapping: this.mapping,\n\n\t\t\t\trepeat: [ this.repeat.x, this.repeat.y ],\n\t\t\t\toffset: [ this.offset.x, this.offset.y ],\n\t\t\t\tcenter: [ this.center.x, this.center.y ],\n\t\t\t\trotation: this.rotation,\n\n\t\t\t\twrap: [ this.wrapS, this.wrapT ],\n\n\t\t\t\tformat: this.format,\n\t\t\t\ttype: this.type,\n\t\t\t\tencoding: this.encoding,\n\n\t\t\t\tminFilter: this.minFilter,\n\t\t\t\tmagFilter: this.magFilter,\n\t\t\t\tanisotropy: this.anisotropy,\n\n\t\t\t\tflipY: this.flipY,\n\n\t\t\t\tpremultiplyAlpha: this.premultiplyAlpha,\n\t\t\t\tunpackAlignment: this.unpackAlignment\n\n\t\t\t};\n\n\t\t\tif ( this.image !== undefined ) {\n\n\t\t\t\t// TODO: Move to THREE.Image\n\n\t\t\t\tvar image = this.image;\n\n\t\t\t\tif ( image.uuid === undefined ) {\n\n\t\t\t\t\timage.uuid = _Math.generateUUID(); // UGH\n\n\t\t\t\t}\n\n\t\t\t\tif ( ! isRootObject && meta.images[ image.uuid ] === undefined ) {\n\n\t\t\t\t\tvar url;\n\n\t\t\t\t\tif ( Array.isArray( image ) ) {\n\n\t\t\t\t\t\t// process array of images e.g. CubeTexture\n\n\t\t\t\t\t\turl = [];\n\n\t\t\t\t\t\tfor ( var i = 0, l = image.length; i < l; i ++ ) {\n\n\t\t\t\t\t\t\turl.push( ImageUtils.getDataURL( image[ i ] ) );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// process single image\n\n\t\t\t\t\t\turl = ImageUtils.getDataURL( image );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tmeta.images[ image.uuid ] = {\n\t\t\t\t\t\tuuid: image.uuid,\n\t\t\t\t\t\turl: url\n\t\t\t\t\t};\n\n\t\t\t\t}\n\n\t\t\t\toutput.image = image.uuid;\n\n\t\t\t}\n\n\t\t\tif ( ! isRootObject ) {\n\n\t\t\t\tmeta.textures[ this.uuid ] = output;\n\n\t\t\t}\n\n\t\t\treturn output;\n\n\t\t},\n\n\t\tdispose: function () {\n\n\t\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t\t},\n\n\t\ttransformUv: function ( uv ) {\n\n\t\t\tif ( this.mapping !== UVMapping ) return uv;\n\n\t\t\tuv.applyMatrix3( this.matrix );\n\n\t\t\tif ( uv.x < 0 || uv.x > 1 ) {\n\n\t\t\t\tswitch ( this.wrapS ) {\n\n\t\t\t\t\tcase RepeatWrapping:\n\n\t\t\t\t\t\tuv.x = uv.x - Math.floor( uv.x );\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase ClampToEdgeWrapping:\n\n\t\t\t\t\t\tuv.x = uv.x < 0 ? 0 : 1;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase MirroredRepeatWrapping:\n\n\t\t\t\t\t\tif ( Math.abs( Math.floor( uv.x ) % 2 ) === 1 ) {\n\n\t\t\t\t\t\t\tuv.x = Math.ceil( uv.x ) - uv.x;\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tuv.x = uv.x - Math.floor( uv.x );\n\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( uv.y < 0 || uv.y > 1 ) {\n\n\t\t\t\tswitch ( this.wrapT ) {\n\n\t\t\t\t\tcase RepeatWrapping:\n\n\t\t\t\t\t\tuv.y = uv.y - Math.floor( uv.y );\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase ClampToEdgeWrapping:\n\n\t\t\t\t\t\tuv.y = uv.y < 0 ? 0 : 1;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase MirroredRepeatWrapping:\n\n\t\t\t\t\t\tif ( Math.abs( Math.floor( uv.y ) % 2 ) === 1 ) {\n\n\t\t\t\t\t\t\tuv.y = Math.ceil( uv.y ) - uv.y;\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tuv.y = uv.y - Math.floor( uv.y );\n\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( this.flipY ) {\n\n\t\t\t\tuv.y = 1 - uv.y;\n\n\t\t\t}\n\n\t\t\treturn uv;\n\n\t\t}\n\n\t} );\n\n\tObject.defineProperty( Texture.prototype, \"needsUpdate\", {\n\n\t\tset: function ( value ) {\n\n\t\t\tif ( value === true ) this.version ++;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author supereggbert / http://www.paulbrunt.co.uk/\n\t * @author philogb / http://blog.thejit.org/\n\t * @author mikael emtinger / http://gomo.se/\n\t * @author egraether / http://egraether.com/\n\t * @author WestLangley / http://github.com/WestLangley\n\t */\n\n\tfunction Vector4( x, y, z, w ) {\n\n\t\tthis.x = x || 0;\n\t\tthis.y = y || 0;\n\t\tthis.z = z || 0;\n\t\tthis.w = ( w !== undefined ) ? w : 1;\n\n\t}\n\n\tObject.assign( Vector4.prototype, {\n\n\t\tisVector4: true,\n\n\t\tset: function ( x, y, z, w ) {\n\n\t\t\tthis.x = x;\n\t\t\tthis.y = y;\n\t\t\tthis.z = z;\n\t\t\tthis.w = w;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetScalar: function ( scalar ) {\n\n\t\t\tthis.x = scalar;\n\t\t\tthis.y = scalar;\n\t\t\tthis.z = scalar;\n\t\t\tthis.w = scalar;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetX: function ( x ) {\n\n\t\t\tthis.x = x;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetY: function ( y ) {\n\n\t\t\tthis.y = y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetZ: function ( z ) {\n\n\t\t\tthis.z = z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetW: function ( w ) {\n\n\t\t\tthis.w = w;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetComponent: function ( index, value ) {\n\n\t\t\tswitch ( index ) {\n\n\t\t\t\tcase 0: this.x = value; break;\n\t\t\t\tcase 1: this.y = value; break;\n\t\t\t\tcase 2: this.z = value; break;\n\t\t\t\tcase 3: this.w = value; break;\n\t\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetComponent: function ( index ) {\n\n\t\t\tswitch ( index ) {\n\n\t\t\t\tcase 0: return this.x;\n\t\t\t\tcase 1: return this.y;\n\t\t\t\tcase 2: return this.z;\n\t\t\t\tcase 3: return this.w;\n\t\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t\t}\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor( this.x, this.y, this.z, this.w );\n\n\t\t},\n\n\t\tcopy: function ( v ) {\n\n\t\t\tthis.x = v.x;\n\t\t\tthis.y = v.y;\n\t\t\tthis.z = v.z;\n\t\t\tthis.w = ( v.w !== undefined ) ? v.w : 1;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tadd: function ( v, w ) {\n\n\t\t\tif ( w !== undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );\n\t\t\t\treturn this.addVectors( v, w );\n\n\t\t\t}\n\n\t\t\tthis.x += v.x;\n\t\t\tthis.y += v.y;\n\t\t\tthis.z += v.z;\n\t\t\tthis.w += v.w;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\taddScalar: function ( s ) {\n\n\t\t\tthis.x += s;\n\t\t\tthis.y += s;\n\t\t\tthis.z += s;\n\t\t\tthis.w += s;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\taddVectors: function ( a, b ) {\n\n\t\t\tthis.x = a.x + b.x;\n\t\t\tthis.y = a.y + b.y;\n\t\t\tthis.z = a.z + b.z;\n\t\t\tthis.w = a.w + b.w;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\taddScaledVector: function ( v, s ) {\n\n\t\t\tthis.x += v.x * s;\n\t\t\tthis.y += v.y * s;\n\t\t\tthis.z += v.z * s;\n\t\t\tthis.w += v.w * s;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsub: function ( v, w ) {\n\n\t\t\tif ( w !== undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );\n\t\t\t\treturn this.subVectors( v, w );\n\n\t\t\t}\n\n\t\t\tthis.x -= v.x;\n\t\t\tthis.y -= v.y;\n\t\t\tthis.z -= v.z;\n\t\t\tthis.w -= v.w;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsubScalar: function ( s ) {\n\n\t\t\tthis.x -= s;\n\t\t\tthis.y -= s;\n\t\t\tthis.z -= s;\n\t\t\tthis.w -= s;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsubVectors: function ( a, b ) {\n\n\t\t\tthis.x = a.x - b.x;\n\t\t\tthis.y = a.y - b.y;\n\t\t\tthis.z = a.z - b.z;\n\t\t\tthis.w = a.w - b.w;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmultiplyScalar: function ( scalar ) {\n\n\t\t\tthis.x *= scalar;\n\t\t\tthis.y *= scalar;\n\t\t\tthis.z *= scalar;\n\t\t\tthis.w *= scalar;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tapplyMatrix4: function ( m ) {\n\n\t\t\tvar x = this.x, y = this.y, z = this.z, w = this.w;\n\t\t\tvar e = m.elements;\n\n\t\t\tthis.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] * w;\n\t\t\tthis.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] * w;\n\t\t\tthis.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] * w;\n\t\t\tthis.w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] * w;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tdivideScalar: function ( scalar ) {\n\n\t\t\treturn this.multiplyScalar( 1 / scalar );\n\n\t\t},\n\n\t\tsetAxisAngleFromQuaternion: function ( q ) {\n\n\t\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm\n\n\t\t\t// q is assumed to be normalized\n\n\t\t\tthis.w = 2 * Math.acos( q.w );\n\n\t\t\tvar s = Math.sqrt( 1 - q.w * q.w );\n\n\t\t\tif ( s < 0.0001 ) {\n\n\t\t\t\tthis.x = 1;\n\t\t\t\tthis.y = 0;\n\t\t\t\tthis.z = 0;\n\n\t\t\t} else {\n\n\t\t\t\tthis.x = q.x / s;\n\t\t\t\tthis.y = q.y / s;\n\t\t\t\tthis.z = q.z / s;\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetAxisAngleFromRotationMatrix: function ( m ) {\n\n\t\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm\n\n\t\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\t\tvar angle, x, y, z,\t\t// variables for result\n\t\t\t\tepsilon = 0.01,\t\t// margin to allow for rounding errors\n\t\t\t\tepsilon2 = 0.1,\t\t// margin to distinguish between 0 and 180 degrees\n\n\t\t\t\tte = m.elements,\n\n\t\t\t\tm11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],\n\t\t\t\tm21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],\n\t\t\t\tm31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];\n\n\t\t\tif ( ( Math.abs( m12 - m21 ) < epsilon ) &&\n\t\t\t     ( Math.abs( m13 - m31 ) < epsilon ) &&\n\t\t\t     ( Math.abs( m23 - m32 ) < epsilon ) ) {\n\n\t\t\t\t// singularity found\n\t\t\t\t// first check for identity matrix which must have +1 for all terms\n\t\t\t\t// in leading diagonal and zero in other terms\n\n\t\t\t\tif ( ( Math.abs( m12 + m21 ) < epsilon2 ) &&\n\t\t\t\t     ( Math.abs( m13 + m31 ) < epsilon2 ) &&\n\t\t\t\t     ( Math.abs( m23 + m32 ) < epsilon2 ) &&\n\t\t\t\t     ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) {\n\n\t\t\t\t\t// this singularity is identity matrix so angle = 0\n\n\t\t\t\t\tthis.set( 1, 0, 0, 0 );\n\n\t\t\t\t\treturn this; // zero angle, arbitrary axis\n\n\t\t\t\t}\n\n\t\t\t\t// otherwise this singularity is angle = 180\n\n\t\t\t\tangle = Math.PI;\n\n\t\t\t\tvar xx = ( m11 + 1 ) / 2;\n\t\t\t\tvar yy = ( m22 + 1 ) / 2;\n\t\t\t\tvar zz = ( m33 + 1 ) / 2;\n\t\t\t\tvar xy = ( m12 + m21 ) / 4;\n\t\t\t\tvar xz = ( m13 + m31 ) / 4;\n\t\t\t\tvar yz = ( m23 + m32 ) / 4;\n\n\t\t\t\tif ( ( xx > yy ) && ( xx > zz ) ) {\n\n\t\t\t\t\t// m11 is the largest diagonal term\n\n\t\t\t\t\tif ( xx < epsilon ) {\n\n\t\t\t\t\t\tx = 0;\n\t\t\t\t\t\ty = 0.707106781;\n\t\t\t\t\t\tz = 0.707106781;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tx = Math.sqrt( xx );\n\t\t\t\t\t\ty = xy / x;\n\t\t\t\t\t\tz = xz / x;\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( yy > zz ) {\n\n\t\t\t\t\t// m22 is the largest diagonal term\n\n\t\t\t\t\tif ( yy < epsilon ) {\n\n\t\t\t\t\t\tx = 0.707106781;\n\t\t\t\t\t\ty = 0;\n\t\t\t\t\t\tz = 0.707106781;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\ty = Math.sqrt( yy );\n\t\t\t\t\t\tx = xy / y;\n\t\t\t\t\t\tz = yz / y;\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// m33 is the largest diagonal term so base result on this\n\n\t\t\t\t\tif ( zz < epsilon ) {\n\n\t\t\t\t\t\tx = 0.707106781;\n\t\t\t\t\t\ty = 0.707106781;\n\t\t\t\t\t\tz = 0;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tz = Math.sqrt( zz );\n\t\t\t\t\t\tx = xz / z;\n\t\t\t\t\t\ty = yz / z;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tthis.set( x, y, z, angle );\n\n\t\t\t\treturn this; // return 180 deg rotation\n\n\t\t\t}\n\n\t\t\t// as we have reached here there are no singularities so we can handle normally\n\n\t\t\tvar s = Math.sqrt( ( m32 - m23 ) * ( m32 - m23 ) +\n\t\t\t                   ( m13 - m31 ) * ( m13 - m31 ) +\n\t\t\t                   ( m21 - m12 ) * ( m21 - m12 ) ); // used to normalize\n\n\t\t\tif ( Math.abs( s ) < 0.001 ) s = 1;\n\n\t\t\t// prevent divide by zero, should not happen if matrix is orthogonal and should be\n\t\t\t// caught by singularity test above, but I've left it in just in case\n\n\t\t\tthis.x = ( m32 - m23 ) / s;\n\t\t\tthis.y = ( m13 - m31 ) / s;\n\t\t\tthis.z = ( m21 - m12 ) / s;\n\t\t\tthis.w = Math.acos( ( m11 + m22 + m33 - 1 ) / 2 );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmin: function ( v ) {\n\n\t\t\tthis.x = Math.min( this.x, v.x );\n\t\t\tthis.y = Math.min( this.y, v.y );\n\t\t\tthis.z = Math.min( this.z, v.z );\n\t\t\tthis.w = Math.min( this.w, v.w );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmax: function ( v ) {\n\n\t\t\tthis.x = Math.max( this.x, v.x );\n\t\t\tthis.y = Math.max( this.y, v.y );\n\t\t\tthis.z = Math.max( this.z, v.z );\n\t\t\tthis.w = Math.max( this.w, v.w );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclamp: function ( min, max ) {\n\n\t\t\t// assumes min < max, componentwise\n\n\t\t\tthis.x = Math.max( min.x, Math.min( max.x, this.x ) );\n\t\t\tthis.y = Math.max( min.y, Math.min( max.y, this.y ) );\n\t\t\tthis.z = Math.max( min.z, Math.min( max.z, this.z ) );\n\t\t\tthis.w = Math.max( min.w, Math.min( max.w, this.w ) );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclampScalar: function () {\n\n\t\t\tvar min, max;\n\n\t\t\treturn function clampScalar( minVal, maxVal ) {\n\n\t\t\t\tif ( min === undefined ) {\n\n\t\t\t\t\tmin = new Vector4();\n\t\t\t\t\tmax = new Vector4();\n\n\t\t\t\t}\n\n\t\t\t\tmin.set( minVal, minVal, minVal, minVal );\n\t\t\t\tmax.set( maxVal, maxVal, maxVal, maxVal );\n\n\t\t\t\treturn this.clamp( min, max );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tclampLength: function ( min, max ) {\n\n\t\t\tvar length = this.length();\n\n\t\t\treturn this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );\n\n\t\t},\n\n\t\tfloor: function () {\n\n\t\t\tthis.x = Math.floor( this.x );\n\t\t\tthis.y = Math.floor( this.y );\n\t\t\tthis.z = Math.floor( this.z );\n\t\t\tthis.w = Math.floor( this.w );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tceil: function () {\n\n\t\t\tthis.x = Math.ceil( this.x );\n\t\t\tthis.y = Math.ceil( this.y );\n\t\t\tthis.z = Math.ceil( this.z );\n\t\t\tthis.w = Math.ceil( this.w );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tround: function () {\n\n\t\t\tthis.x = Math.round( this.x );\n\t\t\tthis.y = Math.round( this.y );\n\t\t\tthis.z = Math.round( this.z );\n\t\t\tthis.w = Math.round( this.w );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\troundToZero: function () {\n\n\t\t\tthis.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );\n\t\t\tthis.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );\n\t\t\tthis.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );\n\t\t\tthis.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tnegate: function () {\n\n\t\t\tthis.x = - this.x;\n\t\t\tthis.y = - this.y;\n\t\t\tthis.z = - this.z;\n\t\t\tthis.w = - this.w;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tdot: function ( v ) {\n\n\t\t\treturn this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;\n\n\t\t},\n\n\t\tlengthSq: function () {\n\n\t\t\treturn this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;\n\n\t\t},\n\n\t\tlength: function () {\n\n\t\t\treturn Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );\n\n\t\t},\n\n\t\tmanhattanLength: function () {\n\n\t\t\treturn Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w );\n\n\t\t},\n\n\t\tnormalize: function () {\n\n\t\t\treturn this.divideScalar( this.length() || 1 );\n\n\t\t},\n\n\t\tsetLength: function ( length ) {\n\n\t\t\treturn this.normalize().multiplyScalar( length );\n\n\t\t},\n\n\t\tlerp: function ( v, alpha ) {\n\n\t\t\tthis.x += ( v.x - this.x ) * alpha;\n\t\t\tthis.y += ( v.y - this.y ) * alpha;\n\t\t\tthis.z += ( v.z - this.z ) * alpha;\n\t\t\tthis.w += ( v.w - this.w ) * alpha;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tlerpVectors: function ( v1, v2, alpha ) {\n\n\t\t\treturn this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 );\n\n\t\t},\n\n\t\tequals: function ( v ) {\n\n\t\t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) );\n\n\t\t},\n\n\t\tfromArray: function ( array, offset ) {\n\n\t\t\tif ( offset === undefined ) offset = 0;\n\n\t\t\tthis.x = array[ offset ];\n\t\t\tthis.y = array[ offset + 1 ];\n\t\t\tthis.z = array[ offset + 2 ];\n\t\t\tthis.w = array[ offset + 3 ];\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttoArray: function ( array, offset ) {\n\n\t\t\tif ( array === undefined ) array = [];\n\t\t\tif ( offset === undefined ) offset = 0;\n\n\t\t\tarray[ offset ] = this.x;\n\t\t\tarray[ offset + 1 ] = this.y;\n\t\t\tarray[ offset + 2 ] = this.z;\n\t\t\tarray[ offset + 3 ] = this.w;\n\n\t\t\treturn array;\n\n\t\t},\n\n\t\tfromBufferAttribute: function ( attribute, index, offset ) {\n\n\t\t\tif ( offset !== undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' );\n\n\t\t\t}\n\n\t\t\tthis.x = attribute.getX( index );\n\t\t\tthis.y = attribute.getY( index );\n\t\t\tthis.z = attribute.getZ( index );\n\t\t\tthis.w = attribute.getW( index );\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author szimek / https://github.com/szimek/\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author Marius Kintel / https://github.com/kintel\n\t */\n\n\t/*\n\t In options, we can specify:\n\t * Texture parameters for an auto-generated target texture\n\t * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers\n\t*/\n\tfunction WebGLRenderTarget( width, height, options ) {\n\n\t\tthis.width = width;\n\t\tthis.height = height;\n\n\t\tthis.scissor = new Vector4( 0, 0, width, height );\n\t\tthis.scissorTest = false;\n\n\t\tthis.viewport = new Vector4( 0, 0, width, height );\n\n\t\toptions = options || {};\n\n\t\tthis.texture = new Texture( undefined, undefined, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );\n\n\t\tthis.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;\n\t\tthis.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;\n\n\t\tthis.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;\n\t\tthis.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;\n\t\tthis.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;\n\n\t}\n\n\tWebGLRenderTarget.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\t\tconstructor: WebGLRenderTarget,\n\n\t\tisWebGLRenderTarget: true,\n\n\t\tsetSize: function ( width, height ) {\n\n\t\t\tif ( this.width !== width || this.height !== height ) {\n\n\t\t\t\tthis.width = width;\n\t\t\t\tthis.height = height;\n\n\t\t\t\tthis.dispose();\n\n\t\t\t}\n\n\t\t\tthis.viewport.set( 0, 0, width, height );\n\t\t\tthis.scissor.set( 0, 0, width, height );\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t},\n\n\t\tcopy: function ( source ) {\n\n\t\t\tthis.width = source.width;\n\t\t\tthis.height = source.height;\n\n\t\t\tthis.viewport.copy( source.viewport );\n\n\t\t\tthis.texture = source.texture.clone();\n\n\t\t\tthis.depthBuffer = source.depthBuffer;\n\t\t\tthis.stencilBuffer = source.stencilBuffer;\n\t\t\tthis.depthTexture = source.depthTexture;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tdispose: function () {\n\n\t\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com\n\t */\n\n\tfunction WebGLRenderTargetCube( width, height, options ) {\n\n\t\tWebGLRenderTarget.call( this, width, height, options );\n\n\t\tthis.activeCubeFace = 0; // PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5\n\t\tthis.activeMipMapLevel = 0;\n\n\t}\n\n\tWebGLRenderTargetCube.prototype = Object.create( WebGLRenderTarget.prototype );\n\tWebGLRenderTargetCube.prototype.constructor = WebGLRenderTargetCube;\n\n\tWebGLRenderTargetCube.prototype.isWebGLRenderTargetCube = true;\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t */\n\n\tfunction DataTexture( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {\n\n\t\tTexture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );\n\n\t\tthis.image = { data: data, width: width, height: height };\n\n\t\tthis.magFilter = magFilter !== undefined ? magFilter : NearestFilter;\n\t\tthis.minFilter = minFilter !== undefined ? minFilter : NearestFilter;\n\n\t\tthis.generateMipmaps = false;\n\t\tthis.flipY = false;\n\t\tthis.unpackAlignment = 1;\n\n\t}\n\n\tDataTexture.prototype = Object.create( Texture.prototype );\n\tDataTexture.prototype.constructor = DataTexture;\n\n\tDataTexture.prototype.isDataTexture = true;\n\n\t/**\n\t * @author bhouston / http://clara.io\n\t * @author WestLangley / http://github.com/WestLangley\n\t */\n\n\tfunction Box3( min, max ) {\n\n\t\tthis.min = ( min !== undefined ) ? min : new Vector3( + Infinity, + Infinity, + Infinity );\n\t\tthis.max = ( max !== undefined ) ? max : new Vector3( - Infinity, - Infinity, - Infinity );\n\n\t}\n\n\tObject.assign( Box3.prototype, {\n\n\t\tisBox3: true,\n\n\t\tset: function ( min, max ) {\n\n\t\t\tthis.min.copy( min );\n\t\t\tthis.max.copy( max );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromArray: function ( array ) {\n\n\t\t\tvar minX = + Infinity;\n\t\t\tvar minY = + Infinity;\n\t\t\tvar minZ = + Infinity;\n\n\t\t\tvar maxX = - Infinity;\n\t\t\tvar maxY = - Infinity;\n\t\t\tvar maxZ = - Infinity;\n\n\t\t\tfor ( var i = 0, l = array.length; i < l; i += 3 ) {\n\n\t\t\t\tvar x = array[ i ];\n\t\t\t\tvar y = array[ i + 1 ];\n\t\t\t\tvar z = array[ i + 2 ];\n\n\t\t\t\tif ( x < minX ) minX = x;\n\t\t\t\tif ( y < minY ) minY = y;\n\t\t\t\tif ( z < minZ ) minZ = z;\n\n\t\t\t\tif ( x > maxX ) maxX = x;\n\t\t\t\tif ( y > maxY ) maxY = y;\n\t\t\t\tif ( z > maxZ ) maxZ = z;\n\n\t\t\t}\n\n\t\t\tthis.min.set( minX, minY, minZ );\n\t\t\tthis.max.set( maxX, maxY, maxZ );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromBufferAttribute: function ( attribute ) {\n\n\t\t\tvar minX = + Infinity;\n\t\t\tvar minY = + Infinity;\n\t\t\tvar minZ = + Infinity;\n\n\t\t\tvar maxX = - Infinity;\n\t\t\tvar maxY = - Infinity;\n\t\t\tvar maxZ = - Infinity;\n\n\t\t\tfor ( var i = 0, l = attribute.count; i < l; i ++ ) {\n\n\t\t\t\tvar x = attribute.getX( i );\n\t\t\t\tvar y = attribute.getY( i );\n\t\t\t\tvar z = attribute.getZ( i );\n\n\t\t\t\tif ( x < minX ) minX = x;\n\t\t\t\tif ( y < minY ) minY = y;\n\t\t\t\tif ( z < minZ ) minZ = z;\n\n\t\t\t\tif ( x > maxX ) maxX = x;\n\t\t\t\tif ( y > maxY ) maxY = y;\n\t\t\t\tif ( z > maxZ ) maxZ = z;\n\n\t\t\t}\n\n\t\t\tthis.min.set( minX, minY, minZ );\n\t\t\tthis.max.set( maxX, maxY, maxZ );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromPoints: function ( points ) {\n\n\t\t\tthis.makeEmpty();\n\n\t\t\tfor ( var i = 0, il = points.length; i < il; i ++ ) {\n\n\t\t\t\tthis.expandByPoint( points[ i ] );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromCenterAndSize: function () {\n\n\t\t\tvar v1 = new Vector3();\n\n\t\t\treturn function setFromCenterAndSize( center, size ) {\n\n\t\t\t\tvar halfSize = v1.copy( size ).multiplyScalar( 0.5 );\n\n\t\t\t\tthis.min.copy( center ).sub( halfSize );\n\t\t\t\tthis.max.copy( center ).add( halfSize );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tsetFromObject: function ( object ) {\n\n\t\t\tthis.makeEmpty();\n\n\t\t\treturn this.expandByObject( object );\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t},\n\n\t\tcopy: function ( box ) {\n\n\t\t\tthis.min.copy( box.min );\n\t\t\tthis.max.copy( box.max );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmakeEmpty: function () {\n\n\t\t\tthis.min.x = this.min.y = this.min.z = + Infinity;\n\t\t\tthis.max.x = this.max.y = this.max.z = - Infinity;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tisEmpty: function () {\n\n\t\t\t// this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes\n\n\t\t\treturn ( this.max.x < this.min.x ) || ( this.max.y < this.min.y ) || ( this.max.z < this.min.z );\n\n\t\t},\n\n\t\tgetCenter: function ( target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Box3: .getCenter() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\treturn this.isEmpty() ? target.set( 0, 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 );\n\n\t\t},\n\n\t\tgetSize: function ( target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Box3: .getSize() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\treturn this.isEmpty() ? target.set( 0, 0, 0 ) : target.subVectors( this.max, this.min );\n\n\t\t},\n\n\t\texpandByPoint: function ( point ) {\n\n\t\t\tthis.min.min( point );\n\t\t\tthis.max.max( point );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\texpandByVector: function ( vector ) {\n\n\t\t\tthis.min.sub( vector );\n\t\t\tthis.max.add( vector );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\texpandByScalar: function ( scalar ) {\n\n\t\t\tthis.min.addScalar( - scalar );\n\t\t\tthis.max.addScalar( scalar );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\texpandByObject: function () {\n\n\t\t\t// Computes the world-axis-aligned bounding box of an object (including its children),\n\t\t\t// accounting for both the object's, and children's, world transforms\n\n\t\t\tvar scope, i, l;\n\n\t\t\tvar v1 = new Vector3();\n\n\t\t\tfunction traverse( node ) {\n\n\t\t\t\tvar geometry = node.geometry;\n\n\t\t\t\tif ( geometry !== undefined ) {\n\n\t\t\t\t\tif ( geometry.isGeometry ) {\n\n\t\t\t\t\t\tvar vertices = geometry.vertices;\n\n\t\t\t\t\t\tfor ( i = 0, l = vertices.length; i < l; i ++ ) {\n\n\t\t\t\t\t\t\tv1.copy( vertices[ i ] );\n\t\t\t\t\t\t\tv1.applyMatrix4( node.matrixWorld );\n\n\t\t\t\t\t\t\tscope.expandByPoint( v1 );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else if ( geometry.isBufferGeometry ) {\n\n\t\t\t\t\t\tvar attribute = geometry.attributes.position;\n\n\t\t\t\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\t\t\t\tfor ( i = 0, l = attribute.count; i < l; i ++ ) {\n\n\t\t\t\t\t\t\t\tv1.fromBufferAttribute( attribute, i ).applyMatrix4( node.matrixWorld );\n\n\t\t\t\t\t\t\t\tscope.expandByPoint( v1 );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn function expandByObject( object ) {\n\n\t\t\t\tscope = this;\n\n\t\t\t\tobject.updateMatrixWorld( true );\n\n\t\t\t\tobject.traverse( traverse );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tcontainsPoint: function ( point ) {\n\n\t\t\treturn point.x < this.min.x || point.x > this.max.x ||\n\t\t\t\tpoint.y < this.min.y || point.y > this.max.y ||\n\t\t\t\tpoint.z < this.min.z || point.z > this.max.z ? false : true;\n\n\t\t},\n\n\t\tcontainsBox: function ( box ) {\n\n\t\t\treturn this.min.x <= box.min.x && box.max.x <= this.max.x &&\n\t\t\t\tthis.min.y <= box.min.y && box.max.y <= this.max.y &&\n\t\t\t\tthis.min.z <= box.min.z && box.max.z <= this.max.z;\n\n\t\t},\n\n\t\tgetParameter: function ( point, target ) {\n\n\t\t\t// This can potentially have a divide by zero if the box\n\t\t\t// has a size dimension of 0.\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Box3: .getParameter() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\treturn target.set(\n\t\t\t\t( point.x - this.min.x ) / ( this.max.x - this.min.x ),\n\t\t\t\t( point.y - this.min.y ) / ( this.max.y - this.min.y ),\n\t\t\t\t( point.z - this.min.z ) / ( this.max.z - this.min.z )\n\t\t\t);\n\n\t\t},\n\n\t\tintersectsBox: function ( box ) {\n\n\t\t\t// using 6 splitting planes to rule out intersections.\n\t\t\treturn box.max.x < this.min.x || box.min.x > this.max.x ||\n\t\t\t\tbox.max.y < this.min.y || box.min.y > this.max.y ||\n\t\t\t\tbox.max.z < this.min.z || box.min.z > this.max.z ? false : true;\n\n\t\t},\n\n\t\tintersectsSphere: ( function () {\n\n\t\t\tvar closestPoint = new Vector3();\n\n\t\t\treturn function intersectsSphere( sphere ) {\n\n\t\t\t\t// Find the point on the AABB closest to the sphere center.\n\t\t\t\tthis.clampPoint( sphere.center, closestPoint );\n\n\t\t\t\t// If that point is inside the sphere, the AABB and sphere intersect.\n\t\t\t\treturn closestPoint.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );\n\n\t\t\t};\n\n\t\t} )(),\n\n\t\tintersectsPlane: function ( plane ) {\n\n\t\t\t// We compute the minimum and maximum dot product values. If those values\n\t\t\t// are on the same side (back or front) of the plane, then there is no intersection.\n\n\t\t\tvar min, max;\n\n\t\t\tif ( plane.normal.x > 0 ) {\n\n\t\t\t\tmin = plane.normal.x * this.min.x;\n\t\t\t\tmax = plane.normal.x * this.max.x;\n\n\t\t\t} else {\n\n\t\t\t\tmin = plane.normal.x * this.max.x;\n\t\t\t\tmax = plane.normal.x * this.min.x;\n\n\t\t\t}\n\n\t\t\tif ( plane.normal.y > 0 ) {\n\n\t\t\t\tmin += plane.normal.y * this.min.y;\n\t\t\t\tmax += plane.normal.y * this.max.y;\n\n\t\t\t} else {\n\n\t\t\t\tmin += plane.normal.y * this.max.y;\n\t\t\t\tmax += plane.normal.y * this.min.y;\n\n\t\t\t}\n\n\t\t\tif ( plane.normal.z > 0 ) {\n\n\t\t\t\tmin += plane.normal.z * this.min.z;\n\t\t\t\tmax += plane.normal.z * this.max.z;\n\n\t\t\t} else {\n\n\t\t\t\tmin += plane.normal.z * this.max.z;\n\t\t\t\tmax += plane.normal.z * this.min.z;\n\n\t\t\t}\n\n\t\t\treturn ( min <= - plane.constant && max >= - plane.constant );\n\n\t\t},\n\n\t\tintersectsTriangle: ( function () {\n\n\t\t\t// triangle centered vertices\n\t\t\tvar v0 = new Vector3();\n\t\t\tvar v1 = new Vector3();\n\t\t\tvar v2 = new Vector3();\n\n\t\t\t// triangle edge vectors\n\t\t\tvar f0 = new Vector3();\n\t\t\tvar f1 = new Vector3();\n\t\t\tvar f2 = new Vector3();\n\n\t\t\tvar testAxis = new Vector3();\n\n\t\t\tvar center = new Vector3();\n\t\t\tvar extents = new Vector3();\n\n\t\t\tvar triangleNormal = new Vector3();\n\n\t\t\tfunction satForAxes( axes ) {\n\n\t\t\t\tvar i, j;\n\n\t\t\t\tfor ( i = 0, j = axes.length - 3; i <= j; i += 3 ) {\n\n\t\t\t\t\ttestAxis.fromArray( axes, i );\n\t\t\t\t\t// project the aabb onto the seperating axis\n\t\t\t\t\tvar r = extents.x * Math.abs( testAxis.x ) + extents.y * Math.abs( testAxis.y ) + extents.z * Math.abs( testAxis.z );\n\t\t\t\t\t// project all 3 vertices of the triangle onto the seperating axis\n\t\t\t\t\tvar p0 = v0.dot( testAxis );\n\t\t\t\t\tvar p1 = v1.dot( testAxis );\n\t\t\t\t\tvar p2 = v2.dot( testAxis );\n\t\t\t\t\t// actual test, basically see if either of the most extreme of the triangle points intersects r\n\t\t\t\t\tif ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) {\n\n\t\t\t\t\t\t// points of the projected triangle are outside the projected half-length of the aabb\n\t\t\t\t\t\t// the axis is seperating and we can exit\n\t\t\t\t\t\treturn false;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\n\t\t\t}\n\n\t\t\treturn function intersectsTriangle( triangle ) {\n\n\t\t\t\tif ( this.isEmpty() ) {\n\n\t\t\t\t\treturn false;\n\n\t\t\t\t}\n\n\t\t\t\t// compute box center and extents\n\t\t\t\tthis.getCenter( center );\n\t\t\t\textents.subVectors( this.max, center );\n\n\t\t\t\t// translate triangle to aabb origin\n\t\t\t\tv0.subVectors( triangle.a, center );\n\t\t\t\tv1.subVectors( triangle.b, center );\n\t\t\t\tv2.subVectors( triangle.c, center );\n\n\t\t\t\t// compute edge vectors for triangle\n\t\t\t\tf0.subVectors( v1, v0 );\n\t\t\t\tf1.subVectors( v2, v1 );\n\t\t\t\tf2.subVectors( v0, v2 );\n\n\t\t\t\t// test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb\n\t\t\t\t// make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation\n\t\t\t\t// axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned)\n\t\t\t\tvar axes = [\n\t\t\t\t\t0, - f0.z, f0.y, 0, - f1.z, f1.y, 0, - f2.z, f2.y,\n\t\t\t\t\tf0.z, 0, - f0.x, f1.z, 0, - f1.x, f2.z, 0, - f2.x,\n\t\t\t\t\t- f0.y, f0.x, 0, - f1.y, f1.x, 0, - f2.y, f2.x, 0\n\t\t\t\t];\n\t\t\t\tif ( ! satForAxes( axes ) ) {\n\n\t\t\t\t\treturn false;\n\n\t\t\t\t}\n\n\t\t\t\t// test 3 face normals from the aabb\n\t\t\t\taxes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];\n\t\t\t\tif ( ! satForAxes( axes ) ) {\n\n\t\t\t\t\treturn false;\n\n\t\t\t\t}\n\n\t\t\t\t// finally testing the face normal of the triangle\n\t\t\t\t// use already existing triangle edge vectors here\n\t\t\t\ttriangleNormal.crossVectors( f0, f1 );\n\t\t\t\taxes = [ triangleNormal.x, triangleNormal.y, triangleNormal.z ];\n\t\t\t\treturn satForAxes( axes );\n\n\t\t\t};\n\n\t\t} )(),\n\n\t\tclampPoint: function ( point, target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Box3: .clampPoint() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\treturn target.copy( point ).clamp( this.min, this.max );\n\n\t\t},\n\n\t\tdistanceToPoint: function () {\n\n\t\t\tvar v1 = new Vector3();\n\n\t\t\treturn function distanceToPoint( point ) {\n\n\t\t\t\tvar clampedPoint = v1.copy( point ).clamp( this.min, this.max );\n\t\t\t\treturn clampedPoint.sub( point ).length();\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tgetBoundingSphere: function () {\n\n\t\t\tvar v1 = new Vector3();\n\n\t\t\treturn function getBoundingSphere( target ) {\n\n\t\t\t\tif ( target === undefined ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.Box3: .getBoundingSphere() target is now required' );\n\t\t\t\t\ttarget = new Sphere();\n\n\t\t\t\t}\n\n\t\t\t\tthis.getCenter( target.center );\n\n\t\t\t\ttarget.radius = this.getSize( v1 ).length() * 0.5;\n\n\t\t\t\treturn target;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tintersect: function ( box ) {\n\n\t\t\tthis.min.max( box.min );\n\t\t\tthis.max.min( box.max );\n\n\t\t\t// ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values.\n\t\t\tif ( this.isEmpty() ) this.makeEmpty();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tunion: function ( box ) {\n\n\t\t\tthis.min.min( box.min );\n\t\t\tthis.max.max( box.max );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tapplyMatrix4: function () {\n\n\t\t\tvar points = [\n\t\t\t\tnew Vector3(),\n\t\t\t\tnew Vector3(),\n\t\t\t\tnew Vector3(),\n\t\t\t\tnew Vector3(),\n\t\t\t\tnew Vector3(),\n\t\t\t\tnew Vector3(),\n\t\t\t\tnew Vector3(),\n\t\t\t\tnew Vector3()\n\t\t\t];\n\n\t\t\treturn function applyMatrix4( matrix ) {\n\n\t\t\t\t// transform of empty box is an empty box.\n\t\t\t\tif ( this.isEmpty() ) return this;\n\n\t\t\t\t// NOTE: I am using a binary pattern to specify all 2^3 combinations below\n\t\t\t\tpoints[ 0 ].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000\n\t\t\t\tpoints[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001\n\t\t\t\tpoints[ 2 ].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010\n\t\t\t\tpoints[ 3 ].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011\n\t\t\t\tpoints[ 4 ].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100\n\t\t\t\tpoints[ 5 ].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101\n\t\t\t\tpoints[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110\n\t\t\t\tpoints[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111\n\n\t\t\t\tthis.setFromPoints( points );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\ttranslate: function ( offset ) {\n\n\t\t\tthis.min.add( offset );\n\t\t\tthis.max.add( offset );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tequals: function ( box ) {\n\n\t\t\treturn box.min.equals( this.min ) && box.max.equals( this.max );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author bhouston / http://clara.io\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction Sphere( center, radius ) {\n\n\t\tthis.center = ( center !== undefined ) ? center : new Vector3();\n\t\tthis.radius = ( radius !== undefined ) ? radius : 0;\n\n\t}\n\n\tObject.assign( Sphere.prototype, {\n\n\t\tset: function ( center, radius ) {\n\n\t\t\tthis.center.copy( center );\n\t\t\tthis.radius = radius;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromPoints: function () {\n\n\t\t\tvar box = new Box3();\n\n\t\t\treturn function setFromPoints( points, optionalCenter ) {\n\n\t\t\t\tvar center = this.center;\n\n\t\t\t\tif ( optionalCenter !== undefined ) {\n\n\t\t\t\t\tcenter.copy( optionalCenter );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tbox.setFromPoints( points ).getCenter( center );\n\n\t\t\t\t}\n\n\t\t\t\tvar maxRadiusSq = 0;\n\n\t\t\t\tfor ( var i = 0, il = points.length; i < il; i ++ ) {\n\n\t\t\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( points[ i ] ) );\n\n\t\t\t\t}\n\n\t\t\t\tthis.radius = Math.sqrt( maxRadiusSq );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t},\n\n\t\tcopy: function ( sphere ) {\n\n\t\t\tthis.center.copy( sphere.center );\n\t\t\tthis.radius = sphere.radius;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tempty: function () {\n\n\t\t\treturn ( this.radius <= 0 );\n\n\t\t},\n\n\t\tcontainsPoint: function ( point ) {\n\n\t\t\treturn ( point.distanceToSquared( this.center ) <= ( this.radius * this.radius ) );\n\n\t\t},\n\n\t\tdistanceToPoint: function ( point ) {\n\n\t\t\treturn ( point.distanceTo( this.center ) - this.radius );\n\n\t\t},\n\n\t\tintersectsSphere: function ( sphere ) {\n\n\t\t\tvar radiusSum = this.radius + sphere.radius;\n\n\t\t\treturn sphere.center.distanceToSquared( this.center ) <= ( radiusSum * radiusSum );\n\n\t\t},\n\n\t\tintersectsBox: function ( box ) {\n\n\t\t\treturn box.intersectsSphere( this );\n\n\t\t},\n\n\t\tintersectsPlane: function ( plane ) {\n\n\t\t\treturn Math.abs( plane.distanceToPoint( this.center ) ) <= this.radius;\n\n\t\t},\n\n\t\tclampPoint: function ( point, target ) {\n\n\t\t\tvar deltaLengthSq = this.center.distanceToSquared( point );\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Sphere: .clampPoint() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\ttarget.copy( point );\n\n\t\t\tif ( deltaLengthSq > ( this.radius * this.radius ) ) {\n\n\t\t\t\ttarget.sub( this.center ).normalize();\n\t\t\t\ttarget.multiplyScalar( this.radius ).add( this.center );\n\n\t\t\t}\n\n\t\t\treturn target;\n\n\t\t},\n\n\t\tgetBoundingBox: function ( target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Sphere: .getBoundingBox() target is now required' );\n\t\t\t\ttarget = new Box3();\n\n\t\t\t}\n\n\t\t\ttarget.set( this.center, this.center );\n\t\t\ttarget.expandByScalar( this.radius );\n\n\t\t\treturn target;\n\n\t\t},\n\n\t\tapplyMatrix4: function ( matrix ) {\n\n\t\t\tthis.center.applyMatrix4( matrix );\n\t\t\tthis.radius = this.radius * matrix.getMaxScaleOnAxis();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttranslate: function ( offset ) {\n\n\t\t\tthis.center.add( offset );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tequals: function ( sphere ) {\n\n\t\t\treturn sphere.center.equals( this.center ) && ( sphere.radius === this.radius );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author bhouston / http://clara.io\n\t */\n\n\tfunction Plane( normal, constant ) {\n\n\t\t// normal is assumed to be normalized\n\n\t\tthis.normal = ( normal !== undefined ) ? normal : new Vector3( 1, 0, 0 );\n\t\tthis.constant = ( constant !== undefined ) ? constant : 0;\n\n\t}\n\n\tObject.assign( Plane.prototype, {\n\n\t\tset: function ( normal, constant ) {\n\n\t\t\tthis.normal.copy( normal );\n\t\t\tthis.constant = constant;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetComponents: function ( x, y, z, w ) {\n\n\t\t\tthis.normal.set( x, y, z );\n\t\t\tthis.constant = w;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromNormalAndCoplanarPoint: function ( normal, point ) {\n\n\t\t\tthis.normal.copy( normal );\n\t\t\tthis.constant = - point.dot( this.normal );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromCoplanarPoints: function () {\n\n\t\t\tvar v1 = new Vector3();\n\t\t\tvar v2 = new Vector3();\n\n\t\t\treturn function setFromCoplanarPoints( a, b, c ) {\n\n\t\t\t\tvar normal = v1.subVectors( c, b ).cross( v2.subVectors( a, b ) ).normalize();\n\n\t\t\t\t// Q: should an error be thrown if normal is zero (e.g. degenerate plane)?\n\n\t\t\t\tthis.setFromNormalAndCoplanarPoint( normal, a );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t},\n\n\t\tcopy: function ( plane ) {\n\n\t\t\tthis.normal.copy( plane.normal );\n\t\t\tthis.constant = plane.constant;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tnormalize: function () {\n\n\t\t\t// Note: will lead to a divide by zero if the plane is invalid.\n\n\t\t\tvar inverseNormalLength = 1.0 / this.normal.length();\n\t\t\tthis.normal.multiplyScalar( inverseNormalLength );\n\t\t\tthis.constant *= inverseNormalLength;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tnegate: function () {\n\n\t\t\tthis.constant *= - 1;\n\t\t\tthis.normal.negate();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tdistanceToPoint: function ( point ) {\n\n\t\t\treturn this.normal.dot( point ) + this.constant;\n\n\t\t},\n\n\t\tdistanceToSphere: function ( sphere ) {\n\n\t\t\treturn this.distanceToPoint( sphere.center ) - sphere.radius;\n\n\t\t},\n\n\t\tprojectPoint: function ( point, target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Plane: .projectPoint() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\treturn target.copy( this.normal ).multiplyScalar( - this.distanceToPoint( point ) ).add( point );\n\n\t\t},\n\n\t\tintersectLine: function () {\n\n\t\t\tvar v1 = new Vector3();\n\n\t\t\treturn function intersectLine( line, target ) {\n\n\t\t\t\tif ( target === undefined ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.Plane: .intersectLine() target is now required' );\n\t\t\t\t\ttarget = new Vector3();\n\n\t\t\t\t}\n\n\t\t\t\tvar direction = line.delta( v1 );\n\n\t\t\t\tvar denominator = this.normal.dot( direction );\n\n\t\t\t\tif ( denominator === 0 ) {\n\n\t\t\t\t\t// line is coplanar, return origin\n\t\t\t\t\tif ( this.distanceToPoint( line.start ) === 0 ) {\n\n\t\t\t\t\t\treturn target.copy( line.start );\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// Unsure if this is the correct method to handle this case.\n\t\t\t\t\treturn undefined;\n\n\t\t\t\t}\n\n\t\t\t\tvar t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;\n\n\t\t\t\tif ( t < 0 || t > 1 ) {\n\n\t\t\t\t\treturn undefined;\n\n\t\t\t\t}\n\n\t\t\t\treturn target.copy( direction ).multiplyScalar( t ).add( line.start );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tintersectsLine: function ( line ) {\n\n\t\t\t// Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it.\n\n\t\t\tvar startSign = this.distanceToPoint( line.start );\n\t\t\tvar endSign = this.distanceToPoint( line.end );\n\n\t\t\treturn ( startSign < 0 && endSign > 0 ) || ( endSign < 0 && startSign > 0 );\n\n\t\t},\n\n\t\tintersectsBox: function ( box ) {\n\n\t\t\treturn box.intersectsPlane( this );\n\n\t\t},\n\n\t\tintersectsSphere: function ( sphere ) {\n\n\t\t\treturn sphere.intersectsPlane( this );\n\n\t\t},\n\n\t\tcoplanarPoint: function ( target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Plane: .coplanarPoint() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\treturn target.copy( this.normal ).multiplyScalar( - this.constant );\n\n\t\t},\n\n\t\tapplyMatrix4: function () {\n\n\t\t\tvar v1 = new Vector3();\n\t\t\tvar m1 = new Matrix3();\n\n\t\t\treturn function applyMatrix4( matrix, optionalNormalMatrix ) {\n\n\t\t\t\tvar normalMatrix = optionalNormalMatrix || m1.getNormalMatrix( matrix );\n\n\t\t\t\tvar referencePoint = this.coplanarPoint( v1 ).applyMatrix4( matrix );\n\n\t\t\t\tvar normal = this.normal.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t\tthis.constant = - referencePoint.dot( normal );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\ttranslate: function ( offset ) {\n\n\t\t\tthis.constant -= offset.dot( this.normal );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tequals: function ( plane ) {\n\n\t\t\treturn plane.normal.equals( this.normal ) && ( plane.constant === this.constant );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author bhouston / http://clara.io\n\t */\n\n\tfunction Frustum( p0, p1, p2, p3, p4, p5 ) {\n\n\t\tthis.planes = [\n\n\t\t\t( p0 !== undefined ) ? p0 : new Plane(),\n\t\t\t( p1 !== undefined ) ? p1 : new Plane(),\n\t\t\t( p2 !== undefined ) ? p2 : new Plane(),\n\t\t\t( p3 !== undefined ) ? p3 : new Plane(),\n\t\t\t( p4 !== undefined ) ? p4 : new Plane(),\n\t\t\t( p5 !== undefined ) ? p5 : new Plane()\n\n\t\t];\n\n\t}\n\n\tObject.assign( Frustum.prototype, {\n\n\t\tset: function ( p0, p1, p2, p3, p4, p5 ) {\n\n\t\t\tvar planes = this.planes;\n\n\t\t\tplanes[ 0 ].copy( p0 );\n\t\t\tplanes[ 1 ].copy( p1 );\n\t\t\tplanes[ 2 ].copy( p2 );\n\t\t\tplanes[ 3 ].copy( p3 );\n\t\t\tplanes[ 4 ].copy( p4 );\n\t\t\tplanes[ 5 ].copy( p5 );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t},\n\n\t\tcopy: function ( frustum ) {\n\n\t\t\tvar planes = this.planes;\n\n\t\t\tfor ( var i = 0; i < 6; i ++ ) {\n\n\t\t\t\tplanes[ i ].copy( frustum.planes[ i ] );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromMatrix: function ( m ) {\n\n\t\t\tvar planes = this.planes;\n\t\t\tvar me = m.elements;\n\t\t\tvar me0 = me[ 0 ], me1 = me[ 1 ], me2 = me[ 2 ], me3 = me[ 3 ];\n\t\t\tvar me4 = me[ 4 ], me5 = me[ 5 ], me6 = me[ 6 ], me7 = me[ 7 ];\n\t\t\tvar me8 = me[ 8 ], me9 = me[ 9 ], me10 = me[ 10 ], me11 = me[ 11 ];\n\t\t\tvar me12 = me[ 12 ], me13 = me[ 13 ], me14 = me[ 14 ], me15 = me[ 15 ];\n\n\t\t\tplanes[ 0 ].setComponents( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ).normalize();\n\t\t\tplanes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize();\n\t\t\tplanes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize();\n\t\t\tplanes[ 3 ].setComponents( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ).normalize();\n\t\t\tplanes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize();\n\t\t\tplanes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tintersectsObject: function () {\n\n\t\t\tvar sphere = new Sphere();\n\n\t\t\treturn function intersectsObject( object ) {\n\n\t\t\t\tvar geometry = object.geometry;\n\n\t\t\t\tif ( geometry.boundingSphere === null )\n\t\t\t\t\tgeometry.computeBoundingSphere();\n\n\t\t\t\tsphere.copy( geometry.boundingSphere )\n\t\t\t\t\t.applyMatrix4( object.matrixWorld );\n\n\t\t\t\treturn this.intersectsSphere( sphere );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tintersectsSprite: function () {\n\n\t\t\tvar sphere = new Sphere();\n\n\t\t\treturn function intersectsSprite( sprite ) {\n\n\t\t\t\tsphere.center.set( 0, 0, 0 );\n\t\t\t\tsphere.radius = 0.7071067811865476;\n\t\t\t\tsphere.applyMatrix4( sprite.matrixWorld );\n\n\t\t\t\treturn this.intersectsSphere( sphere );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tintersectsSphere: function ( sphere ) {\n\n\t\t\tvar planes = this.planes;\n\t\t\tvar center = sphere.center;\n\t\t\tvar negRadius = - sphere.radius;\n\n\t\t\tfor ( var i = 0; i < 6; i ++ ) {\n\n\t\t\t\tvar distance = planes[ i ].distanceToPoint( center );\n\n\t\t\t\tif ( distance < negRadius ) {\n\n\t\t\t\t\treturn false;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn true;\n\n\t\t},\n\n\t\tintersectsBox: function () {\n\n\t\t\tvar p = new Vector3();\n\n\t\t\treturn function intersectsBox( box ) {\n\n\t\t\t\tvar planes = this.planes;\n\n\t\t\t\tfor ( var i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\tvar plane = planes[ i ];\n\n\t\t\t\t\t// corner at max distance\n\n\t\t\t\t\tp.x = plane.normal.x > 0 ? box.max.x : box.min.x;\n\t\t\t\t\tp.y = plane.normal.y > 0 ? box.max.y : box.min.y;\n\t\t\t\t\tp.z = plane.normal.z > 0 ? box.max.z : box.min.z;\n\n\t\t\t\t\tif ( plane.distanceToPoint( p ) < 0 ) {\n\n\t\t\t\t\t\treturn false;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tcontainsPoint: function ( point ) {\n\n\t\t\tvar planes = this.planes;\n\n\t\t\tfor ( var i = 0; i < 6; i ++ ) {\n\n\t\t\t\tif ( planes[ i ].distanceToPoint( point ) < 0 ) {\n\n\t\t\t\t\treturn false;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn true;\n\n\t\t}\n\n\t} );\n\n\tvar alphamap_fragment = \"#ifdef USE_ALPHAMAP\\n\\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\\n#endif\";\n\n\tvar alphamap_pars_fragment = \"#ifdef USE_ALPHAMAP\\n\\tuniform sampler2D alphaMap;\\n#endif\";\n\n\tvar alphatest_fragment = \"#ifdef ALPHATEST\\n\\tif ( diffuseColor.a < ALPHATEST ) discard;\\n#endif\";\n\n\tvar aomap_fragment = \"#ifdef USE_AOMAP\\n\\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\\n\\treflectedLight.indirectDiffuse *= ambientOcclusion;\\n\\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\\n\\t\\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\\n\\t\\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\\n\\t#endif\\n#endif\";\n\n\tvar aomap_pars_fragment = \"#ifdef USE_AOMAP\\n\\tuniform sampler2D aoMap;\\n\\tuniform float aoMapIntensity;\\n#endif\";\n\n\tvar begin_vertex = \"vec3 transformed = vec3( position );\";\n\n\tvar beginnormal_vertex = \"vec3 objectNormal = vec3( normal );\";\n\n\tvar bsdfs = \"float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\\n\\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\\n\\tif( cutoffDistance > 0.0 ) {\\n\\t\\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\\n\\t}\\n\\treturn distanceFalloff;\\n#else\\n\\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\\n\\t\\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\\n\\t}\\n\\treturn 1.0;\\n#endif\\n}\\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\\n\\treturn RECIPROCAL_PI * diffuseColor;\\n}\\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\\n\\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\\n\\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\\n}\\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\\n\\tfloat a2 = pow2( alpha );\\n\\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\\n\\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\\n\\treturn 1.0 / ( gl * gv );\\n}\\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\\n\\tfloat a2 = pow2( alpha );\\n\\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\\n\\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\\n\\treturn 0.5 / max( gv + gl, EPSILON );\\n}\\nfloat D_GGX( const in float alpha, const in float dotNH ) {\\n\\tfloat a2 = pow2( alpha );\\n\\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\\n\\treturn RECIPROCAL_PI * a2 / pow2( denom );\\n}\\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\\n\\tfloat alpha = pow2( roughness );\\n\\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\\n\\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\\n\\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\\n\\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\\n\\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\\n\\tvec3 F = F_Schlick( specularColor, dotLH );\\n\\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\\n\\tfloat D = D_GGX( alpha, dotNH );\\n\\treturn F * ( G * D );\\n}\\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\\n\\tconst float LUT_SIZE  = 64.0;\\n\\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\\n\\tconst float LUT_BIAS  = 0.5 / LUT_SIZE;\\n\\tfloat dotNV = saturate( dot( N, V ) );\\n\\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\\n\\tuv = uv * LUT_SCALE + LUT_BIAS;\\n\\treturn uv;\\n}\\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\\n\\tfloat l = length( f );\\n\\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\\n}\\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\\n\\tfloat x = dot( v1, v2 );\\n\\tfloat y = abs( x );\\n\\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\\n\\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\\n\\tfloat v = a / b;\\n\\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\\n\\treturn cross( v1, v2 ) * theta_sintheta;\\n}\\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\\n\\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\\n\\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\\n\\tvec3 lightNormal = cross( v1, v2 );\\n\\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\\n\\tvec3 T1, T2;\\n\\tT1 = normalize( V - N * dot( V, N ) );\\n\\tT2 = - cross( N, T1 );\\n\\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\\n\\tvec3 coords[ 4 ];\\n\\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\\n\\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\\n\\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\\n\\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\\n\\tcoords[ 0 ] = normalize( coords[ 0 ] );\\n\\tcoords[ 1 ] = normalize( coords[ 1 ] );\\n\\tcoords[ 2 ] = normalize( coords[ 2 ] );\\n\\tcoords[ 3 ] = normalize( coords[ 3 ] );\\n\\tvec3 vectorFormFactor = vec3( 0.0 );\\n\\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\\n\\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\\n\\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\\n\\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\\n\\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\\n\\treturn vec3( result );\\n}\\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\\n\\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\\n\\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\\n\\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\\n\\tvec4 r = roughness * c0 + c1;\\n\\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\\n\\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\\n\\treturn specularColor * AB.x + AB.y;\\n}\\nfloat G_BlinnPhong_Implicit( ) {\\n\\treturn 0.25;\\n}\\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\\n\\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\\n}\\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\\n\\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\\n\\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\\n\\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\\n\\tvec3 F = F_Schlick( specularColor, dotLH );\\n\\tfloat G = G_BlinnPhong_Implicit( );\\n\\tfloat D = D_BlinnPhong( shininess, dotNH );\\n\\treturn F * ( G * D );\\n}\\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\\n\\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\\n}\\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\\n\\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\\n}\";\n\n\tvar bumpmap_pars_fragment = \"#ifdef USE_BUMPMAP\\n\\tuniform sampler2D bumpMap;\\n\\tuniform float bumpScale;\\n\\tvec2 dHdxy_fwd() {\\n\\t\\tvec2 dSTdx = dFdx( vUv );\\n\\t\\tvec2 dSTdy = dFdy( vUv );\\n\\t\\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\\n\\t\\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\\n\\t\\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\\n\\t\\treturn vec2( dBx, dBy );\\n\\t}\\n\\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\\n\\t\\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\\n\\t\\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\\n\\t\\tvec3 vN = surf_norm;\\n\\t\\tvec3 R1 = cross( vSigmaY, vN );\\n\\t\\tvec3 R2 = cross( vN, vSigmaX );\\n\\t\\tfloat fDet = dot( vSigmaX, R1 );\\n\\t\\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\\n\\t\\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\\n\\t\\treturn normalize( abs( fDet ) * surf_norm - vGrad );\\n\\t}\\n#endif\";\n\n\tvar clipping_planes_fragment = \"#if NUM_CLIPPING_PLANES > 0\\n\\tvec4 plane;\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\\n\\t\\tplane = clippingPlanes[ i ];\\n\\t\\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\\n\\t}\\n\\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\\n\\t\\tbool clipped = true;\\n\\t\\t#pragma unroll_loop\\n\\t\\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\\n\\t\\t\\tplane = clippingPlanes[ i ];\\n\\t\\t\\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\\n\\t\\t}\\n\\t\\tif ( clipped ) discard;\\n\\t#endif\\n#endif\";\n\n\tvar clipping_planes_pars_fragment = \"#if NUM_CLIPPING_PLANES > 0\\n\\t#if ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )\\n\\t\\tvarying vec3 vViewPosition;\\n\\t#endif\\n\\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\\n#endif\";\n\n\tvar clipping_planes_pars_vertex = \"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )\\n\\tvarying vec3 vViewPosition;\\n#endif\";\n\n\tvar clipping_planes_vertex = \"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )\\n\\tvViewPosition = - mvPosition.xyz;\\n#endif\";\n\n\tvar color_fragment = \"#ifdef USE_COLOR\\n\\tdiffuseColor.rgb *= vColor;\\n#endif\";\n\n\tvar color_pars_fragment = \"#ifdef USE_COLOR\\n\\tvarying vec3 vColor;\\n#endif\";\n\n\tvar color_pars_vertex = \"#ifdef USE_COLOR\\n\\tvarying vec3 vColor;\\n#endif\";\n\n\tvar color_vertex = \"#ifdef USE_COLOR\\n\\tvColor.xyz = color.xyz;\\n#endif\";\n\n\tvar common = \"#define PI 3.14159265359\\n#define PI2 6.28318530718\\n#define PI_HALF 1.5707963267949\\n#define RECIPROCAL_PI 0.31830988618\\n#define RECIPROCAL_PI2 0.15915494\\n#define LOG2 1.442695\\n#define EPSILON 1e-6\\n#define saturate(a) clamp( a, 0.0, 1.0 )\\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\\nfloat pow2( const in float x ) { return x*x; }\\nfloat pow3( const in float x ) { return x*x*x; }\\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\\nhighp float rand( const in vec2 uv ) {\\n\\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\\n\\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\\n\\treturn fract(sin(sn) * c);\\n}\\nstruct IncidentLight {\\n\\tvec3 color;\\n\\tvec3 direction;\\n\\tbool visible;\\n};\\nstruct ReflectedLight {\\n\\tvec3 directDiffuse;\\n\\tvec3 directSpecular;\\n\\tvec3 indirectDiffuse;\\n\\tvec3 indirectSpecular;\\n};\\nstruct GeometricContext {\\n\\tvec3 position;\\n\\tvec3 normal;\\n\\tvec3 viewDir;\\n};\\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\\n\\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\\n}\\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\\n\\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\\n}\\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\\n\\tfloat distance = dot( planeNormal, point - pointOnPlane );\\n\\treturn - distance * planeNormal + point;\\n}\\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\\n\\treturn sign( dot( point - pointOnPlane, planeNormal ) );\\n}\\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\\n\\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\\n}\\nmat3 transposeMat3( const in mat3 m ) {\\n\\tmat3 tmp;\\n\\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\\n\\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\\n\\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\\n\\treturn tmp;\\n}\\nfloat linearToRelativeLuminance( const in vec3 color ) {\\n\\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\\n\\treturn dot( weights, color.rgb );\\n}\";\n\n\tvar cube_uv_reflection_fragment = \"#ifdef ENVMAP_TYPE_CUBE_UV\\n#define cubeUV_textureSize (1024.0)\\nint getFaceFromDirection(vec3 direction) {\\n\\tvec3 absDirection = abs(direction);\\n\\tint face = -1;\\n\\tif( absDirection.x > absDirection.z ) {\\n\\t\\tif(absDirection.x > absDirection.y )\\n\\t\\t\\tface = direction.x > 0.0 ? 0 : 3;\\n\\t\\telse\\n\\t\\t\\tface = direction.y > 0.0 ? 1 : 4;\\n\\t}\\n\\telse {\\n\\t\\tif(absDirection.z > absDirection.y )\\n\\t\\t\\tface = direction.z > 0.0 ? 2 : 5;\\n\\t\\telse\\n\\t\\t\\tface = direction.y > 0.0 ? 1 : 4;\\n\\t}\\n\\treturn face;\\n}\\n#define cubeUV_maxLods1  (log2(cubeUV_textureSize*0.25) - 1.0)\\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\\n\\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\\n\\tfloat dxRoughness = dFdx(roughness);\\n\\tfloat dyRoughness = dFdy(roughness);\\n\\tvec3 dx = dFdx( vec * scale * dxRoughness );\\n\\tvec3 dy = dFdy( vec * scale * dyRoughness );\\n\\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\\n\\td = clamp(d, 1.0, cubeUV_rangeClamp);\\n\\tfloat mipLevel = 0.5 * log2(d);\\n\\treturn vec2(floor(mipLevel), fract(mipLevel));\\n}\\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\\n\\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\\n\\tfloat a = 16.0 * cubeUV_rcpTextureSize;\\n\\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\\n\\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\\n\\tfloat powScale = exp2_packed.x * exp2_packed.y;\\n\\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\\n\\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\\n\\tbool bRes = mipLevel == 0.0;\\n\\tscale =  bRes && (scale < a) ? a : scale;\\n\\tvec3 r;\\n\\tvec2 offset;\\n\\tint face = getFaceFromDirection(direction);\\n\\tfloat rcpPowScale = 1.0 / powScale;\\n\\tif( face == 0) {\\n\\t\\tr = vec3(direction.x, -direction.z, direction.y);\\n\\t\\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\\n\\t\\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\\n\\t}\\n\\telse if( face == 1) {\\n\\t\\tr = vec3(direction.y, direction.x, direction.z);\\n\\t\\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\\n\\t\\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\\n\\t}\\n\\telse if( face == 2) {\\n\\t\\tr = vec3(direction.z, direction.x, direction.y);\\n\\t\\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\\n\\t\\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\\n\\t}\\n\\telse if( face == 3) {\\n\\t\\tr = vec3(direction.x, direction.z, direction.y);\\n\\t\\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\\n\\t\\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\\n\\t}\\n\\telse if( face == 4) {\\n\\t\\tr = vec3(direction.y, direction.x, -direction.z);\\n\\t\\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\\n\\t\\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\\n\\t}\\n\\telse {\\n\\t\\tr = vec3(direction.z, -direction.x, direction.y);\\n\\t\\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\\n\\t\\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\\n\\t}\\n\\tr = normalize(r);\\n\\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\\n\\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\\n\\tvec2 base = offset + vec2( texelOffset );\\n\\treturn base + s * ( scale - 2.0 * texelOffset );\\n}\\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\\n\\tfloat roughnessVal = roughness* cubeUV_maxLods3;\\n\\tfloat r1 = floor(roughnessVal);\\n\\tfloat r2 = r1 + 1.0;\\n\\tfloat t = fract(roughnessVal);\\n\\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\\n\\tfloat s = mipInfo.y;\\n\\tfloat level0 = mipInfo.x;\\n\\tfloat level1 = level0 + 1.0;\\n\\tlevel1 = level1 > 5.0 ? 5.0 : level1;\\n\\tlevel0 += min( floor( s + 0.5 ), 5.0 );\\n\\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\\n\\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\\n\\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\\n\\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\\n\\tvec4 result = mix(color10, color20, t);\\n\\treturn vec4(result.rgb, 1.0);\\n}\\n#endif\";\n\n\tvar defaultnormal_vertex = \"vec3 transformedNormal = normalMatrix * objectNormal;\\n#ifdef FLIP_SIDED\\n\\ttransformedNormal = - transformedNormal;\\n#endif\";\n\n\tvar displacementmap_pars_vertex = \"#ifdef USE_DISPLACEMENTMAP\\n\\tuniform sampler2D displacementMap;\\n\\tuniform float displacementScale;\\n\\tuniform float displacementBias;\\n#endif\";\n\n\tvar displacementmap_vertex = \"#ifdef USE_DISPLACEMENTMAP\\n\\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\\n#endif\";\n\n\tvar emissivemap_fragment = \"#ifdef USE_EMISSIVEMAP\\n\\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\\n\\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\\n\\ttotalEmissiveRadiance *= emissiveColor.rgb;\\n#endif\";\n\n\tvar emissivemap_pars_fragment = \"#ifdef USE_EMISSIVEMAP\\n\\tuniform sampler2D emissiveMap;\\n#endif\";\n\n\tvar encodings_fragment = \"gl_FragColor = linearToOutputTexel( gl_FragColor );\";\n\n\tvar encodings_pars_fragment = \"\\nvec4 LinearToLinear( in vec4 value ) {\\n\\treturn value;\\n}\\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\\n\\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\\n}\\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\\n\\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\\n}\\nvec4 sRGBToLinear( in vec4 value ) {\\n\\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\\n}\\nvec4 LinearTosRGB( in vec4 value ) {\\n\\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\\n}\\nvec4 RGBEToLinear( in vec4 value ) {\\n\\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\\n}\\nvec4 LinearToRGBE( in vec4 value ) {\\n\\tfloat maxComponent = max( max( value.r, value.g ), value.b );\\n\\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\\n\\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\\n}\\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\\n\\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\\n}\\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\\n\\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\\n\\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\\n\\tM = ceil( M * 255.0 ) / 255.0;\\n\\treturn vec4( value.rgb / ( M * maxRange ), M );\\n}\\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\\n\\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\\n}\\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\\n\\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\\n\\tfloat D = max( maxRange / maxRGB, 1.0 );\\n\\tD = min( floor( D ) / 255.0, 1.0 );\\n\\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\\n}\\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\\nvec4 LinearToLogLuv( in vec4 value )  {\\n\\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\\n\\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\\n\\tvec4 vResult;\\n\\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\\n\\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\\n\\tvResult.w = fract( Le );\\n\\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\\n\\treturn vResult;\\n}\\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\\nvec4 LogLuvToLinear( in vec4 value ) {\\n\\tfloat Le = value.z * 255.0 + value.w;\\n\\tvec3 Xp_Y_XYZp;\\n\\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\\n\\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\\n\\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\\n\\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\\n\\treturn vec4( max( vRGB, 0.0 ), 1.0 );\\n}\";\n\n\tvar envmap_fragment = \"#ifdef USE_ENVMAP\\n\\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\\n\\t\\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\\n\\t\\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\\n\\t\\t#ifdef ENVMAP_MODE_REFLECTION\\n\\t\\t\\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\\n\\t\\t#else\\n\\t\\t\\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\\n\\t\\t#endif\\n\\t#else\\n\\t\\tvec3 reflectVec = vReflect;\\n\\t#endif\\n\\t#ifdef ENVMAP_TYPE_CUBE\\n\\t\\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\\n\\t#elif defined( ENVMAP_TYPE_EQUIREC )\\n\\t\\tvec2 sampleUV;\\n\\t\\treflectVec = normalize( reflectVec );\\n\\t\\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\\n\\t\\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\\n\\t\\tvec4 envColor = texture2D( envMap, sampleUV );\\n\\t#elif defined( ENVMAP_TYPE_SPHERE )\\n\\t\\treflectVec = normalize( reflectVec );\\n\\t\\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\\n\\t\\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\\n\\t#else\\n\\t\\tvec4 envColor = vec4( 0.0 );\\n\\t#endif\\n\\tenvColor = envMapTexelToLinear( envColor );\\n\\t#ifdef ENVMAP_BLENDING_MULTIPLY\\n\\t\\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\\n\\t#elif defined( ENVMAP_BLENDING_MIX )\\n\\t\\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\\n\\t#elif defined( ENVMAP_BLENDING_ADD )\\n\\t\\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\\n\\t#endif\\n#endif\";\n\n\tvar envmap_pars_fragment = \"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\\n\\tuniform float reflectivity;\\n\\tuniform float envMapIntensity;\\n#endif\\n#ifdef USE_ENVMAP\\n\\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\\n\\t\\tvarying vec3 vWorldPosition;\\n\\t#endif\\n\\t#ifdef ENVMAP_TYPE_CUBE\\n\\t\\tuniform samplerCube envMap;\\n\\t#else\\n\\t\\tuniform sampler2D envMap;\\n\\t#endif\\n\\tuniform float flipEnvMap;\\n\\tuniform int maxMipLevel;\\n\\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\\n\\t\\tuniform float refractionRatio;\\n\\t#else\\n\\t\\tvarying vec3 vReflect;\\n\\t#endif\\n#endif\";\n\n\tvar envmap_pars_vertex = \"#ifdef USE_ENVMAP\\n\\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\\n\\t\\tvarying vec3 vWorldPosition;\\n\\t#else\\n\\t\\tvarying vec3 vReflect;\\n\\t\\tuniform float refractionRatio;\\n\\t#endif\\n#endif\";\n\n\tvar envmap_vertex = \"#ifdef USE_ENVMAP\\n\\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\\n\\t\\tvWorldPosition = worldPosition.xyz;\\n\\t#else\\n\\t\\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\\n\\t\\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\\n\\t\\t#ifdef ENVMAP_MODE_REFLECTION\\n\\t\\t\\tvReflect = reflect( cameraToVertex, worldNormal );\\n\\t\\t#else\\n\\t\\t\\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\\n\\t\\t#endif\\n\\t#endif\\n#endif\";\n\n\tvar fog_vertex = \"#ifdef USE_FOG\\n\\tfogDepth = -mvPosition.z;\\n#endif\";\n\n\tvar fog_pars_vertex = \"#ifdef USE_FOG\\n\\tvarying float fogDepth;\\n#endif\";\n\n\tvar fog_fragment = \"#ifdef USE_FOG\\n\\t#ifdef FOG_EXP2\\n\\t\\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\\n\\t#else\\n\\t\\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\\n\\t#endif\\n\\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\\n#endif\";\n\n\tvar fog_pars_fragment = \"#ifdef USE_FOG\\n\\tuniform vec3 fogColor;\\n\\tvarying float fogDepth;\\n\\t#ifdef FOG_EXP2\\n\\t\\tuniform float fogDensity;\\n\\t#else\\n\\t\\tuniform float fogNear;\\n\\t\\tuniform float fogFar;\\n\\t#endif\\n#endif\";\n\n\tvar gradientmap_pars_fragment = \"#ifdef TOON\\n\\tuniform sampler2D gradientMap;\\n\\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\\n\\t\\tfloat dotNL = dot( normal, lightDirection );\\n\\t\\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\\n\\t\\t#ifdef USE_GRADIENTMAP\\n\\t\\t\\treturn texture2D( gradientMap, coord ).rgb;\\n\\t\\t#else\\n\\t\\t\\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\\n\\t\\t#endif\\n\\t}\\n#endif\";\n\n\tvar lightmap_fragment = \"#ifdef USE_LIGHTMAP\\n\\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\\n#endif\";\n\n\tvar lightmap_pars_fragment = \"#ifdef USE_LIGHTMAP\\n\\tuniform sampler2D lightMap;\\n\\tuniform float lightMapIntensity;\\n#endif\";\n\n\tvar lights_lambert_vertex = \"vec3 diffuse = vec3( 1.0 );\\nGeometricContext geometry;\\ngeometry.position = mvPosition.xyz;\\ngeometry.normal = normalize( transformedNormal );\\ngeometry.viewDir = normalize( -mvPosition.xyz );\\nGeometricContext backGeometry;\\nbackGeometry.position = geometry.position;\\nbackGeometry.normal = -geometry.normal;\\nbackGeometry.viewDir = geometry.viewDir;\\nvLightFront = vec3( 0.0 );\\n#ifdef DOUBLE_SIDED\\n\\tvLightBack = vec3( 0.0 );\\n#endif\\nIncidentLight directLight;\\nfloat dotNL;\\nvec3 directLightColor_Diffuse;\\n#if NUM_POINT_LIGHTS > 0\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\\n\\t\\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\\n\\t\\tdotNL = dot( geometry.normal, directLight.direction );\\n\\t\\tdirectLightColor_Diffuse = PI * directLight.color;\\n\\t\\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\\n\\t\\t#ifdef DOUBLE_SIDED\\n\\t\\t\\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\\n\\t\\t#endif\\n\\t}\\n#endif\\n#if NUM_SPOT_LIGHTS > 0\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\\n\\t\\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\\n\\t\\tdotNL = dot( geometry.normal, directLight.direction );\\n\\t\\tdirectLightColor_Diffuse = PI * directLight.color;\\n\\t\\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\\n\\t\\t#ifdef DOUBLE_SIDED\\n\\t\\t\\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\\n\\t\\t#endif\\n\\t}\\n#endif\\n#if NUM_DIR_LIGHTS > 0\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\\n\\t\\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\\n\\t\\tdotNL = dot( geometry.normal, directLight.direction );\\n\\t\\tdirectLightColor_Diffuse = PI * directLight.color;\\n\\t\\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\\n\\t\\t#ifdef DOUBLE_SIDED\\n\\t\\t\\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\\n\\t\\t#endif\\n\\t}\\n#endif\\n#if NUM_HEMI_LIGHTS > 0\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\\n\\t\\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\\n\\t\\t#ifdef DOUBLE_SIDED\\n\\t\\t\\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\\n\\t\\t#endif\\n\\t}\\n#endif\";\n\n\tvar lights_pars_begin = \"uniform vec3 ambientLightColor;\\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\\n\\tvec3 irradiance = ambientLightColor;\\n\\t#ifndef PHYSICALLY_CORRECT_LIGHTS\\n\\t\\tirradiance *= PI;\\n\\t#endif\\n\\treturn irradiance;\\n}\\n#if NUM_DIR_LIGHTS > 0\\n\\tstruct DirectionalLight {\\n\\t\\tvec3 direction;\\n\\t\\tvec3 color;\\n\\t\\tint shadow;\\n\\t\\tfloat shadowBias;\\n\\t\\tfloat shadowRadius;\\n\\t\\tvec2 shadowMapSize;\\n\\t};\\n\\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\\n\\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\\n\\t\\tdirectLight.color = directionalLight.color;\\n\\t\\tdirectLight.direction = directionalLight.direction;\\n\\t\\tdirectLight.visible = true;\\n\\t}\\n#endif\\n#if NUM_POINT_LIGHTS > 0\\n\\tstruct PointLight {\\n\\t\\tvec3 position;\\n\\t\\tvec3 color;\\n\\t\\tfloat distance;\\n\\t\\tfloat decay;\\n\\t\\tint shadow;\\n\\t\\tfloat shadowBias;\\n\\t\\tfloat shadowRadius;\\n\\t\\tvec2 shadowMapSize;\\n\\t\\tfloat shadowCameraNear;\\n\\t\\tfloat shadowCameraFar;\\n\\t};\\n\\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\\n\\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\\n\\t\\tvec3 lVector = pointLight.position - geometry.position;\\n\\t\\tdirectLight.direction = normalize( lVector );\\n\\t\\tfloat lightDistance = length( lVector );\\n\\t\\tdirectLight.color = pointLight.color;\\n\\t\\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\\n\\t\\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\\n\\t}\\n#endif\\n#if NUM_SPOT_LIGHTS > 0\\n\\tstruct SpotLight {\\n\\t\\tvec3 position;\\n\\t\\tvec3 direction;\\n\\t\\tvec3 color;\\n\\t\\tfloat distance;\\n\\t\\tfloat decay;\\n\\t\\tfloat coneCos;\\n\\t\\tfloat penumbraCos;\\n\\t\\tint shadow;\\n\\t\\tfloat shadowBias;\\n\\t\\tfloat shadowRadius;\\n\\t\\tvec2 shadowMapSize;\\n\\t};\\n\\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\\n\\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight  ) {\\n\\t\\tvec3 lVector = spotLight.position - geometry.position;\\n\\t\\tdirectLight.direction = normalize( lVector );\\n\\t\\tfloat lightDistance = length( lVector );\\n\\t\\tfloat angleCos = dot( directLight.direction, spotLight.direction );\\n\\t\\tif ( angleCos > spotLight.coneCos ) {\\n\\t\\t\\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\\n\\t\\t\\tdirectLight.color = spotLight.color;\\n\\t\\t\\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\\n\\t\\t\\tdirectLight.visible = true;\\n\\t\\t} else {\\n\\t\\t\\tdirectLight.color = vec3( 0.0 );\\n\\t\\t\\tdirectLight.visible = false;\\n\\t\\t}\\n\\t}\\n#endif\\n#if NUM_RECT_AREA_LIGHTS > 0\\n\\tstruct RectAreaLight {\\n\\t\\tvec3 color;\\n\\t\\tvec3 position;\\n\\t\\tvec3 halfWidth;\\n\\t\\tvec3 halfHeight;\\n\\t};\\n\\tuniform sampler2D ltc_1;\\tuniform sampler2D ltc_2;\\n\\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\\n#endif\\n#if NUM_HEMI_LIGHTS > 0\\n\\tstruct HemisphereLight {\\n\\t\\tvec3 direction;\\n\\t\\tvec3 skyColor;\\n\\t\\tvec3 groundColor;\\n\\t};\\n\\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\\n\\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\\n\\t\\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\\n\\t\\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\\n\\t\\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\\n\\t\\t#ifndef PHYSICALLY_CORRECT_LIGHTS\\n\\t\\t\\tirradiance *= PI;\\n\\t\\t#endif\\n\\t\\treturn irradiance;\\n\\t}\\n#endif\";\n\n\tvar envmap_physical_pars_fragment = \"#if defined( USE_ENVMAP ) && defined( PHYSICAL )\\n\\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\\n\\t\\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\\n\\t\\t#ifdef ENVMAP_TYPE_CUBE\\n\\t\\t\\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\\n\\t\\t\\t#ifdef TEXTURE_LOD_EXT\\n\\t\\t\\t\\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\\n\\t\\t\\t#else\\n\\t\\t\\t\\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\\n\\t\\t\\t#endif\\n\\t\\t\\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\\n\\t\\t#elif defined( ENVMAP_TYPE_CUBE_UV )\\n\\t\\t\\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\\n\\t\\t\\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\\n\\t\\t#else\\n\\t\\t\\tvec4 envMapColor = vec4( 0.0 );\\n\\t\\t#endif\\n\\t\\treturn PI * envMapColor.rgb * envMapIntensity;\\n\\t}\\n\\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\\n\\t\\tfloat maxMIPLevelScalar = float( maxMIPLevel );\\n\\t\\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\\n\\t\\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\\n\\t}\\n\\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\\n\\t\\t#ifdef ENVMAP_MODE_REFLECTION\\n\\t\\t\\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\\n\\t\\t#else\\n\\t\\t\\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\\n\\t\\t#endif\\n\\t\\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\\n\\t\\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\\n\\t\\t#ifdef ENVMAP_TYPE_CUBE\\n\\t\\t\\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\\n\\t\\t\\t#ifdef TEXTURE_LOD_EXT\\n\\t\\t\\t\\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\\n\\t\\t\\t#else\\n\\t\\t\\t\\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\\n\\t\\t\\t#endif\\n\\t\\t\\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\\n\\t\\t#elif defined( ENVMAP_TYPE_CUBE_UV )\\n\\t\\t\\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\\n\\t\\t\\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent ));\\n\\t\\t#elif defined( ENVMAP_TYPE_EQUIREC )\\n\\t\\t\\tvec2 sampleUV;\\n\\t\\t\\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\\n\\t\\t\\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\\n\\t\\t\\t#ifdef TEXTURE_LOD_EXT\\n\\t\\t\\t\\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\\n\\t\\t\\t#else\\n\\t\\t\\t\\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\\n\\t\\t\\t#endif\\n\\t\\t\\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\\n\\t\\t#elif defined( ENVMAP_TYPE_SPHERE )\\n\\t\\t\\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\\n\\t\\t\\t#ifdef TEXTURE_LOD_EXT\\n\\t\\t\\t\\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\\n\\t\\t\\t#else\\n\\t\\t\\t\\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\\n\\t\\t\\t#endif\\n\\t\\t\\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\\n\\t\\t#endif\\n\\t\\treturn envMapColor.rgb * envMapIntensity;\\n\\t}\\n#endif\";\n\n\tvar lights_phong_fragment = \"BlinnPhongMaterial material;\\nmaterial.diffuseColor = diffuseColor.rgb;\\nmaterial.specularColor = specular;\\nmaterial.specularShininess = shininess;\\nmaterial.specularStrength = specularStrength;\";\n\n\tvar lights_phong_pars_fragment = \"varying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\nstruct BlinnPhongMaterial {\\n\\tvec3\\tdiffuseColor;\\n\\tvec3\\tspecularColor;\\n\\tfloat\\tspecularShininess;\\n\\tfloat\\tspecularStrength;\\n};\\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\\n\\t#ifdef TOON\\n\\t\\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\\n\\t#else\\n\\t\\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\\n\\t\\tvec3 irradiance = dotNL * directLight.color;\\n\\t#endif\\n\\t#ifndef PHYSICALLY_CORRECT_LIGHTS\\n\\t\\tirradiance *= PI;\\n\\t#endif\\n\\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\\n\\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\\n}\\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\\n\\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\\n}\\n#define RE_Direct\\t\\t\\t\\tRE_Direct_BlinnPhong\\n#define RE_IndirectDiffuse\\t\\tRE_IndirectDiffuse_BlinnPhong\\n#define Material_LightProbeLOD( material )\\t(0)\";\n\n\tvar lights_physical_fragment = \"PhysicalMaterial material;\\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\\n#ifdef STANDARD\\n\\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\\n#else\\n\\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\\n\\tmaterial.clearCoat = saturate( clearCoat );\\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\\n#endif\";\n\n\tvar lights_physical_pars_fragment = \"struct PhysicalMaterial {\\n\\tvec3\\tdiffuseColor;\\n\\tfloat\\tspecularRoughness;\\n\\tvec3\\tspecularColor;\\n\\t#ifndef STANDARD\\n\\t\\tfloat clearCoat;\\n\\t\\tfloat clearCoatRoughness;\\n\\t#endif\\n};\\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\\n\\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\\n}\\n#if NUM_RECT_AREA_LIGHTS > 0\\n\\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\\n\\t\\tvec3 normal = geometry.normal;\\n\\t\\tvec3 viewDir = geometry.viewDir;\\n\\t\\tvec3 position = geometry.position;\\n\\t\\tvec3 lightPos = rectAreaLight.position;\\n\\t\\tvec3 halfWidth = rectAreaLight.halfWidth;\\n\\t\\tvec3 halfHeight = rectAreaLight.halfHeight;\\n\\t\\tvec3 lightColor = rectAreaLight.color;\\n\\t\\tfloat roughness = material.specularRoughness;\\n\\t\\tvec3 rectCoords[ 4 ];\\n\\t\\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\\t\\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\\n\\t\\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\\n\\t\\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\\n\\t\\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\\n\\t\\tvec4 t1 = texture2D( ltc_1, uv );\\n\\t\\tvec4 t2 = texture2D( ltc_2, uv );\\n\\t\\tmat3 mInv = mat3(\\n\\t\\t\\tvec3( t1.x, 0, t1.y ),\\n\\t\\t\\tvec3(    0, 1,    0 ),\\n\\t\\t\\tvec3( t1.z, 0, t1.w )\\n\\t\\t);\\n\\t\\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\\n\\t\\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\\n\\t\\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\\n\\t}\\n#endif\\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\\n\\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\\n\\tvec3 irradiance = dotNL * directLight.color;\\n\\t#ifndef PHYSICALLY_CORRECT_LIGHTS\\n\\t\\tirradiance *= PI;\\n\\t#endif\\n\\t#ifndef STANDARD\\n\\t\\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\\n\\t#else\\n\\t\\tfloat clearCoatDHR = 0.0;\\n\\t#endif\\n\\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\\n\\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\\n\\t#ifndef STANDARD\\n\\t\\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\\n\\t#endif\\n}\\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\\n\\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\\n}\\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\\n\\t#ifndef STANDARD\\n\\t\\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\\n\\t\\tfloat dotNL = dotNV;\\n\\t\\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\\n\\t#else\\n\\t\\tfloat clearCoatDHR = 0.0;\\n\\t#endif\\n\\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\\n\\t#ifndef STANDARD\\n\\t\\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\\n\\t#endif\\n}\\n#define RE_Direct\\t\\t\\t\\tRE_Direct_Physical\\n#define RE_Direct_RectArea\\t\\tRE_Direct_RectArea_Physical\\n#define RE_IndirectDiffuse\\t\\tRE_IndirectDiffuse_Physical\\n#define RE_IndirectSpecular\\t\\tRE_IndirectSpecular_Physical\\n#define Material_BlinnShininessExponent( material )   GGXRoughnessToBlinnExponent( material.specularRoughness )\\n#define Material_ClearCoat_BlinnShininessExponent( material )   GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\\n\\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\\n}\";\n\n\tvar lights_fragment_begin = \"\\nGeometricContext geometry;\\ngeometry.position = - vViewPosition;\\ngeometry.normal = normal;\\ngeometry.viewDir = normalize( vViewPosition );\\nIncidentLight directLight;\\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\\n\\tPointLight pointLight;\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\\n\\t\\tpointLight = pointLights[ i ];\\n\\t\\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\\n\\t\\t#ifdef USE_SHADOWMAP\\n\\t\\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\\n\\t\\t#endif\\n\\t\\tRE_Direct( directLight, geometry, material, reflectedLight );\\n\\t}\\n#endif\\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\\n\\tSpotLight spotLight;\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\\n\\t\\tspotLight = spotLights[ i ];\\n\\t\\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\\n\\t\\t#ifdef USE_SHADOWMAP\\n\\t\\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\\n\\t\\t#endif\\n\\t\\tRE_Direct( directLight, geometry, material, reflectedLight );\\n\\t}\\n#endif\\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\\n\\tDirectionalLight directionalLight;\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\\n\\t\\tdirectionalLight = directionalLights[ i ];\\n\\t\\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\\n\\t\\t#ifdef USE_SHADOWMAP\\n\\t\\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\\n\\t\\t#endif\\n\\t\\tRE_Direct( directLight, geometry, material, reflectedLight );\\n\\t}\\n#endif\\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\\n\\tRectAreaLight rectAreaLight;\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\\n\\t\\trectAreaLight = rectAreaLights[ i ];\\n\\t\\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\\n\\t}\\n#endif\\n#if defined( RE_IndirectDiffuse )\\n\\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\\n\\t#if ( NUM_HEMI_LIGHTS > 0 )\\n\\t\\t#pragma unroll_loop\\n\\t\\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\\n\\t\\t\\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\\n\\t\\t}\\n\\t#endif\\n#endif\\n#if defined( RE_IndirectSpecular )\\n\\tvec3 radiance = vec3( 0.0 );\\n\\tvec3 clearCoatRadiance = vec3( 0.0 );\\n#endif\";\n\n\tvar lights_fragment_maps = \"#if defined( RE_IndirectDiffuse )\\n\\t#ifdef USE_LIGHTMAP\\n\\t\\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\\n\\t\\t#ifndef PHYSICALLY_CORRECT_LIGHTS\\n\\t\\t\\tlightMapIrradiance *= PI;\\n\\t\\t#endif\\n\\t\\tirradiance += lightMapIrradiance;\\n\\t#endif\\n\\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\\n\\t\\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\\n\\t#endif\\n#endif\\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\\n\\tradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), maxMipLevel );\\n\\t#ifndef STANDARD\\n\\t\\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\\n\\t#endif\\n#endif\";\n\n\tvar lights_fragment_end = \"#if defined( RE_IndirectDiffuse )\\n\\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\\n#endif\\n#if defined( RE_IndirectSpecular )\\n\\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\\n#endif\";\n\n\tvar logdepthbuf_fragment = \"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\\n\\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\\n#endif\";\n\n\tvar logdepthbuf_pars_fragment = \"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\\n\\tuniform float logDepthBufFC;\\n\\tvarying float vFragDepth;\\n#endif\";\n\n\tvar logdepthbuf_pars_vertex = \"#ifdef USE_LOGDEPTHBUF\\n\\t#ifdef USE_LOGDEPTHBUF_EXT\\n\\t\\tvarying float vFragDepth;\\n\\t#else\\n\\t\\tuniform float logDepthBufFC;\\n\\t#endif\\n#endif\";\n\n\tvar logdepthbuf_vertex = \"#ifdef USE_LOGDEPTHBUF\\n\\t#ifdef USE_LOGDEPTHBUF_EXT\\n\\t\\tvFragDepth = 1.0 + gl_Position.w;\\n\\t#else\\n\\t\\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\\n\\t\\tgl_Position.z *= gl_Position.w;\\n\\t#endif\\n#endif\";\n\n\tvar map_fragment = \"#ifdef USE_MAP\\n\\tvec4 texelColor = texture2D( map, vUv );\\n\\ttexelColor = mapTexelToLinear( texelColor );\\n\\tdiffuseColor *= texelColor;\\n#endif\";\n\n\tvar map_pars_fragment = \"#ifdef USE_MAP\\n\\tuniform sampler2D map;\\n#endif\";\n\n\tvar map_particle_fragment = \"#ifdef USE_MAP\\n\\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\\n\\tvec4 mapTexel = texture2D( map, uv );\\n\\tdiffuseColor *= mapTexelToLinear( mapTexel );\\n#endif\";\n\n\tvar map_particle_pars_fragment = \"#ifdef USE_MAP\\n\\tuniform mat3 uvTransform;\\n\\tuniform sampler2D map;\\n#endif\";\n\n\tvar metalnessmap_fragment = \"float metalnessFactor = metalness;\\n#ifdef USE_METALNESSMAP\\n\\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\\n\\tmetalnessFactor *= texelMetalness.b;\\n#endif\";\n\n\tvar metalnessmap_pars_fragment = \"#ifdef USE_METALNESSMAP\\n\\tuniform sampler2D metalnessMap;\\n#endif\";\n\n\tvar morphnormal_vertex = \"#ifdef USE_MORPHNORMALS\\n\\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\\n\\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\\n\\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\\n\\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\\n#endif\";\n\n\tvar morphtarget_pars_vertex = \"#ifdef USE_MORPHTARGETS\\n\\t#ifndef USE_MORPHNORMALS\\n\\tuniform float morphTargetInfluences[ 8 ];\\n\\t#else\\n\\tuniform float morphTargetInfluences[ 4 ];\\n\\t#endif\\n#endif\";\n\n\tvar morphtarget_vertex = \"#ifdef USE_MORPHTARGETS\\n\\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\\n\\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\\n\\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\\n\\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\\n\\t#ifndef USE_MORPHNORMALS\\n\\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\\n\\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\\n\\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\\n\\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\\n\\t#endif\\n#endif\";\n\n\tvar normal_fragment_begin = \"#ifdef FLAT_SHADED\\n\\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\\n\\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\\n\\tvec3 normal = normalize( cross( fdx, fdy ) );\\n#else\\n\\tvec3 normal = normalize( vNormal );\\n\\t#ifdef DOUBLE_SIDED\\n\\t\\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\\n\\t#endif\\n#endif\";\n\n\tvar normal_fragment_maps = \"#ifdef USE_NORMALMAP\\n\\t#ifdef OBJECTSPACE_NORMALMAP\\n\\t\\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\\n\\t\\t#ifdef FLIP_SIDED\\n\\t\\t\\tnormal = - normal;\\n\\t\\t#endif\\n\\t\\t#ifdef DOUBLE_SIDED\\n\\t\\t\\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\\n\\t\\t#endif\\n\\t\\tnormal = normalize( normalMatrix * normal );\\n\\t#else\\n\\t\\tnormal = perturbNormal2Arb( -vViewPosition, normal );\\n\\t#endif\\n#elif defined( USE_BUMPMAP )\\n\\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\\n#endif\";\n\n\tvar normalmap_pars_fragment = \"#ifdef USE_NORMALMAP\\n\\tuniform sampler2D normalMap;\\n\\tuniform vec2 normalScale;\\n\\t#ifdef OBJECTSPACE_NORMALMAP\\n\\t\\tuniform mat3 normalMatrix;\\n\\t#else\\n\\t\\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\\n\\t\\t\\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\\n\\t\\t\\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\\n\\t\\t\\tvec2 st0 = dFdx( vUv.st );\\n\\t\\t\\tvec2 st1 = dFdy( vUv.st );\\n\\t\\t\\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\\n\\t\\t\\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\\n\\t\\t\\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\\n\\t\\t\\tvec3 N = normalize( surf_norm );\\n\\t\\t\\tmat3 tsn = mat3( S, T, N );\\n\\t\\t\\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\\n\\t\\t\\tmapN.xy *= normalScale;\\n\\t\\t\\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\\n\\t\\t\\treturn normalize( tsn * mapN );\\n\\t\\t}\\n\\t#endif\\n#endif\";\n\n\tvar packing = \"vec3 packNormalToRGB( const in vec3 normal ) {\\n\\treturn normalize( normal ) * 0.5 + 0.5;\\n}\\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\\n\\treturn 2.0 * rgb.xyz - 1.0;\\n}\\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256.,  256. );\\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\\nconst float ShiftRight8 = 1. / 256.;\\nvec4 packDepthToRGBA( const in float v ) {\\n\\tvec4 r = vec4( fract( v * PackFactors ), v );\\n\\tr.yzw -= r.xyz * ShiftRight8;\\treturn r * PackUpscale;\\n}\\nfloat unpackRGBAToDepth( const in vec4 v ) {\\n\\treturn dot( v, UnpackFactors );\\n}\\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\\n\\treturn ( viewZ + near ) / ( near - far );\\n}\\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\\n\\treturn linearClipZ * ( near - far ) - near;\\n}\\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\\n\\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\\n}\\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\\n\\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\\n}\";\n\n\tvar premultiplied_alpha_fragment = \"#ifdef PREMULTIPLIED_ALPHA\\n\\tgl_FragColor.rgb *= gl_FragColor.a;\\n#endif\";\n\n\tvar project_vertex = \"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\\ngl_Position = projectionMatrix * mvPosition;\";\n\n\tvar dithering_fragment = \"#if defined( DITHERING )\\n  gl_FragColor.rgb = dithering( gl_FragColor.rgb );\\n#endif\";\n\n\tvar dithering_pars_fragment = \"#if defined( DITHERING )\\n\\tvec3 dithering( vec3 color ) {\\n\\t\\tfloat grid_position = rand( gl_FragCoord.xy );\\n\\t\\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\\n\\t\\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\\n\\t\\treturn color + dither_shift_RGB;\\n\\t}\\n#endif\";\n\n\tvar roughnessmap_fragment = \"float roughnessFactor = roughness;\\n#ifdef USE_ROUGHNESSMAP\\n\\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\\n\\troughnessFactor *= texelRoughness.g;\\n#endif\";\n\n\tvar roughnessmap_pars_fragment = \"#ifdef USE_ROUGHNESSMAP\\n\\tuniform sampler2D roughnessMap;\\n#endif\";\n\n\tvar shadowmap_pars_fragment = \"#ifdef USE_SHADOWMAP\\n\\t#if NUM_DIR_LIGHTS > 0\\n\\t\\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\\n\\t\\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\\n\\t#endif\\n\\t#if NUM_SPOT_LIGHTS > 0\\n\\t\\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\\n\\t\\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\\n\\t#endif\\n\\t#if NUM_POINT_LIGHTS > 0\\n\\t\\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\\n\\t\\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\\n\\t#endif\\n\\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\\n\\t\\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\\n\\t}\\n\\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\\n\\t\\tconst vec2 offset = vec2( 0.0, 1.0 );\\n\\t\\tvec2 texelSize = vec2( 1.0 ) / size;\\n\\t\\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\\n\\t\\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\\n\\t\\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\\n\\t\\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\\n\\t\\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\\n\\t\\tvec2 f = fract( uv * size + 0.5 );\\n\\t\\tfloat a = mix( lb, lt, f.y );\\n\\t\\tfloat b = mix( rb, rt, f.y );\\n\\t\\tfloat c = mix( a, b, f.x );\\n\\t\\treturn c;\\n\\t}\\n\\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\\n\\t\\tfloat shadow = 1.0;\\n\\t\\tshadowCoord.xyz /= shadowCoord.w;\\n\\t\\tshadowCoord.z += shadowBias;\\n\\t\\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\\n\\t\\tbool inFrustum = all( inFrustumVec );\\n\\t\\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\\n\\t\\tbool frustumTest = all( frustumTestVec );\\n\\t\\tif ( frustumTest ) {\\n\\t\\t#if defined( SHADOWMAP_TYPE_PCF )\\n\\t\\t\\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\\n\\t\\t\\tfloat dx0 = - texelSize.x * shadowRadius;\\n\\t\\t\\tfloat dy0 = - texelSize.y * shadowRadius;\\n\\t\\t\\tfloat dx1 = + texelSize.x * shadowRadius;\\n\\t\\t\\tfloat dy1 = + texelSize.y * shadowRadius;\\n\\t\\t\\tshadow = (\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\\n\\t\\t\\t) * ( 1.0 / 9.0 );\\n\\t\\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\\n\\t\\t\\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\\n\\t\\t\\tfloat dx0 = - texelSize.x * shadowRadius;\\n\\t\\t\\tfloat dy0 = - texelSize.y * shadowRadius;\\n\\t\\t\\tfloat dx1 = + texelSize.x * shadowRadius;\\n\\t\\t\\tfloat dy1 = + texelSize.y * shadowRadius;\\n\\t\\t\\tshadow = (\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\\n\\t\\t\\t) * ( 1.0 / 9.0 );\\n\\t\\t#else\\n\\t\\t\\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\\n\\t\\t#endif\\n\\t\\t}\\n\\t\\treturn shadow;\\n\\t}\\n\\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\\n\\t\\tvec3 absV = abs( v );\\n\\t\\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\\n\\t\\tabsV *= scaleToCube;\\n\\t\\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\\n\\t\\tvec2 planar = v.xy;\\n\\t\\tfloat almostATexel = 1.5 * texelSizeY;\\n\\t\\tfloat almostOne = 1.0 - almostATexel;\\n\\t\\tif ( absV.z >= almostOne ) {\\n\\t\\t\\tif ( v.z > 0.0 )\\n\\t\\t\\t\\tplanar.x = 4.0 - v.x;\\n\\t\\t} else if ( absV.x >= almostOne ) {\\n\\t\\t\\tfloat signX = sign( v.x );\\n\\t\\t\\tplanar.x = v.z * signX + 2.0 * signX;\\n\\t\\t} else if ( absV.y >= almostOne ) {\\n\\t\\t\\tfloat signY = sign( v.y );\\n\\t\\t\\tplanar.x = v.x + 2.0 * signY + 2.0;\\n\\t\\t\\tplanar.y = v.z * signY - 2.0;\\n\\t\\t}\\n\\t\\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\\n\\t}\\n\\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\\n\\t\\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\\n\\t\\tvec3 lightToPosition = shadowCoord.xyz;\\n\\t\\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\\t\\tdp += shadowBias;\\n\\t\\tvec3 bd3D = normalize( lightToPosition );\\n\\t\\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\\n\\t\\t\\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\\n\\t\\t\\treturn (\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\\n\\t\\t\\t) * ( 1.0 / 9.0 );\\n\\t\\t#else\\n\\t\\t\\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\\n\\t\\t#endif\\n\\t}\\n#endif\";\n\n\tvar shadowmap_pars_vertex = \"#ifdef USE_SHADOWMAP\\n\\t#if NUM_DIR_LIGHTS > 0\\n\\t\\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\\n\\t\\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\\n\\t#endif\\n\\t#if NUM_SPOT_LIGHTS > 0\\n\\t\\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\\n\\t\\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\\n\\t#endif\\n\\t#if NUM_POINT_LIGHTS > 0\\n\\t\\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\\n\\t\\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\\n\\t#endif\\n#endif\";\n\n\tvar shadowmap_vertex = \"#ifdef USE_SHADOWMAP\\n\\t#if NUM_DIR_LIGHTS > 0\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\\n\\t\\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\\n\\t}\\n\\t#endif\\n\\t#if NUM_SPOT_LIGHTS > 0\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\\n\\t\\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\\n\\t}\\n\\t#endif\\n\\t#if NUM_POINT_LIGHTS > 0\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\\n\\t\\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\\n\\t}\\n\\t#endif\\n#endif\";\n\n\tvar shadowmask_pars_fragment = \"float getShadowMask() {\\n\\tfloat shadow = 1.0;\\n\\t#ifdef USE_SHADOWMAP\\n\\t#if NUM_DIR_LIGHTS > 0\\n\\tDirectionalLight directionalLight;\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\\n\\t\\tdirectionalLight = directionalLights[ i ];\\n\\t\\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\\n\\t}\\n\\t#endif\\n\\t#if NUM_SPOT_LIGHTS > 0\\n\\tSpotLight spotLight;\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\\n\\t\\tspotLight = spotLights[ i ];\\n\\t\\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\\n\\t}\\n\\t#endif\\n\\t#if NUM_POINT_LIGHTS > 0\\n\\tPointLight pointLight;\\n\\t#pragma unroll_loop\\n\\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\\n\\t\\tpointLight = pointLights[ i ];\\n\\t\\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\\n\\t}\\n\\t#endif\\n\\t#endif\\n\\treturn shadow;\\n}\";\n\n\tvar skinbase_vertex = \"#ifdef USE_SKINNING\\n\\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\\n\\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\\n\\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\\n\\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\\n#endif\";\n\n\tvar skinning_pars_vertex = \"#ifdef USE_SKINNING\\n\\tuniform mat4 bindMatrix;\\n\\tuniform mat4 bindMatrixInverse;\\n\\t#ifdef BONE_TEXTURE\\n\\t\\tuniform sampler2D boneTexture;\\n\\t\\tuniform int boneTextureSize;\\n\\t\\tmat4 getBoneMatrix( const in float i ) {\\n\\t\\t\\tfloat j = i * 4.0;\\n\\t\\t\\tfloat x = mod( j, float( boneTextureSize ) );\\n\\t\\t\\tfloat y = floor( j / float( boneTextureSize ) );\\n\\t\\t\\tfloat dx = 1.0 / float( boneTextureSize );\\n\\t\\t\\tfloat dy = 1.0 / float( boneTextureSize );\\n\\t\\t\\ty = dy * ( y + 0.5 );\\n\\t\\t\\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\\n\\t\\t\\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\\n\\t\\t\\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\\n\\t\\t\\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\\n\\t\\t\\tmat4 bone = mat4( v1, v2, v3, v4 );\\n\\t\\t\\treturn bone;\\n\\t\\t}\\n\\t#else\\n\\t\\tuniform mat4 boneMatrices[ MAX_BONES ];\\n\\t\\tmat4 getBoneMatrix( const in float i ) {\\n\\t\\t\\tmat4 bone = boneMatrices[ int(i) ];\\n\\t\\t\\treturn bone;\\n\\t\\t}\\n\\t#endif\\n#endif\";\n\n\tvar skinning_vertex = \"#ifdef USE_SKINNING\\n\\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\\n\\tvec4 skinned = vec4( 0.0 );\\n\\tskinned += boneMatX * skinVertex * skinWeight.x;\\n\\tskinned += boneMatY * skinVertex * skinWeight.y;\\n\\tskinned += boneMatZ * skinVertex * skinWeight.z;\\n\\tskinned += boneMatW * skinVertex * skinWeight.w;\\n\\ttransformed = ( bindMatrixInverse * skinned ).xyz;\\n#endif\";\n\n\tvar skinnormal_vertex = \"#ifdef USE_SKINNING\\n\\tmat4 skinMatrix = mat4( 0.0 );\\n\\tskinMatrix += skinWeight.x * boneMatX;\\n\\tskinMatrix += skinWeight.y * boneMatY;\\n\\tskinMatrix += skinWeight.z * boneMatZ;\\n\\tskinMatrix += skinWeight.w * boneMatW;\\n\\tskinMatrix  = bindMatrixInverse * skinMatrix * bindMatrix;\\n\\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\\n#endif\";\n\n\tvar specularmap_fragment = \"float specularStrength;\\n#ifdef USE_SPECULARMAP\\n\\tvec4 texelSpecular = texture2D( specularMap, vUv );\\n\\tspecularStrength = texelSpecular.r;\\n#else\\n\\tspecularStrength = 1.0;\\n#endif\";\n\n\tvar specularmap_pars_fragment = \"#ifdef USE_SPECULARMAP\\n\\tuniform sampler2D specularMap;\\n#endif\";\n\n\tvar tonemapping_fragment = \"#if defined( TONE_MAPPING )\\n  gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\\n#endif\";\n\n\tvar tonemapping_pars_fragment = \"#ifndef saturate\\n\\t#define saturate(a) clamp( a, 0.0, 1.0 )\\n#endif\\nuniform float toneMappingExposure;\\nuniform float toneMappingWhitePoint;\\nvec3 LinearToneMapping( vec3 color ) {\\n\\treturn toneMappingExposure * color;\\n}\\nvec3 ReinhardToneMapping( vec3 color ) {\\n\\tcolor *= toneMappingExposure;\\n\\treturn saturate( color / ( vec3( 1.0 ) + color ) );\\n}\\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\\nvec3 Uncharted2ToneMapping( vec3 color ) {\\n\\tcolor *= toneMappingExposure;\\n\\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\\n}\\nvec3 OptimizedCineonToneMapping( vec3 color ) {\\n\\tcolor *= toneMappingExposure;\\n\\tcolor = max( vec3( 0.0 ), color - 0.004 );\\n\\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\\n}\\nvec3 ACESFilmicToneMapping( vec3 color ) {\\n\\tcolor *= toneMappingExposure;\\n\\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\\n}\";\n\n\tvar uv_pars_fragment = \"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\\n\\tvarying vec2 vUv;\\n#endif\";\n\n\tvar uv_pars_vertex = \"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\\n\\tvarying vec2 vUv;\\n\\tuniform mat3 uvTransform;\\n#endif\";\n\n\tvar uv_vertex = \"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\\n\\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\\n#endif\";\n\n\tvar uv2_pars_fragment = \"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\\n\\tvarying vec2 vUv2;\\n#endif\";\n\n\tvar uv2_pars_vertex = \"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\\n\\tattribute vec2 uv2;\\n\\tvarying vec2 vUv2;\\n#endif\";\n\n\tvar uv2_vertex = \"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\\n\\tvUv2 = uv2;\\n#endif\";\n\n\tvar worldpos_vertex = \"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\\n\\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\\n#endif\";\n\n\tvar background_frag = \"uniform sampler2D t2D;\\nvarying vec2 vUv;\\nvoid main() {\\n\\tvec4 texColor = texture2D( t2D, vUv );\\n\\tgl_FragColor = mapTexelToLinear( texColor );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n}\";\n\n\tvar background_vert = \"varying vec2 vUv;\\nuniform mat3 uvTransform;\\nvoid main() {\\n\\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\\n\\tgl_Position = vec4( position.xy, 1.0, 1.0 );\\n}\";\n\n\tvar cube_frag = \"uniform samplerCube tCube;\\nuniform float tFlip;\\nuniform float opacity;\\nvarying vec3 vWorldDirection;\\nvoid main() {\\n\\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\\n\\tgl_FragColor = mapTexelToLinear( texColor );\\n\\tgl_FragColor.a *= opacity;\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n}\";\n\n\tvar cube_vert = \"varying vec3 vWorldDirection;\\n#include <common>\\nvoid main() {\\n\\tvWorldDirection = transformDirection( position, modelMatrix );\\n\\t#include <begin_vertex>\\n\\t#include <project_vertex>\\n\\tgl_Position.z = gl_Position.w;\\n}\";\n\n\tvar depth_frag = \"#if DEPTH_PACKING == 3200\\n\\tuniform float opacity;\\n#endif\\n#include <common>\\n#include <packing>\\n#include <uv_pars_fragment>\\n#include <map_pars_fragment>\\n#include <alphamap_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tvec4 diffuseColor = vec4( 1.0 );\\n\\t#if DEPTH_PACKING == 3200\\n\\t\\tdiffuseColor.a = opacity;\\n\\t#endif\\n\\t#include <map_fragment>\\n\\t#include <alphamap_fragment>\\n\\t#include <alphatest_fragment>\\n\\t#include <logdepthbuf_fragment>\\n\\t#if DEPTH_PACKING == 3200\\n\\t\\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\\n\\t#elif DEPTH_PACKING == 3201\\n\\t\\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\\n\\t#endif\\n}\";\n\n\tvar depth_vert = \"#include <common>\\n#include <uv_pars_vertex>\\n#include <displacementmap_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <skinning_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#ifdef USE_DISPLACEMENTMAP\\n\\t\\t#include <beginnormal_vertex>\\n\\t\\t#include <morphnormal_vertex>\\n\\t\\t#include <skinnormal_vertex>\\n\\t#endif\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <skinning_vertex>\\n\\t#include <displacementmap_vertex>\\n\\t#include <project_vertex>\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n}\";\n\n\tvar distanceRGBA_frag = \"#define DISTANCE\\nuniform vec3 referencePosition;\\nuniform float nearDistance;\\nuniform float farDistance;\\nvarying vec3 vWorldPosition;\\n#include <common>\\n#include <packing>\\n#include <uv_pars_fragment>\\n#include <map_pars_fragment>\\n#include <alphamap_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main () {\\n\\t#include <clipping_planes_fragment>\\n\\tvec4 diffuseColor = vec4( 1.0 );\\n\\t#include <map_fragment>\\n\\t#include <alphamap_fragment>\\n\\t#include <alphatest_fragment>\\n\\tfloat dist = length( vWorldPosition - referencePosition );\\n\\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\\n\\tdist = saturate( dist );\\n\\tgl_FragColor = packDepthToRGBA( dist );\\n}\";\n\n\tvar distanceRGBA_vert = \"#define DISTANCE\\nvarying vec3 vWorldPosition;\\n#include <common>\\n#include <uv_pars_vertex>\\n#include <displacementmap_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <skinning_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#ifdef USE_DISPLACEMENTMAP\\n\\t\\t#include <beginnormal_vertex>\\n\\t\\t#include <morphnormal_vertex>\\n\\t\\t#include <skinnormal_vertex>\\n\\t#endif\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <skinning_vertex>\\n\\t#include <displacementmap_vertex>\\n\\t#include <project_vertex>\\n\\t#include <worldpos_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\tvWorldPosition = worldPosition.xyz;\\n}\";\n\n\tvar equirect_frag = \"uniform sampler2D tEquirect;\\nvarying vec3 vWorldDirection;\\n#include <common>\\nvoid main() {\\n\\tvec3 direction = normalize( vWorldDirection );\\n\\tvec2 sampleUV;\\n\\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\\n\\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\\n\\tvec4 texColor = texture2D( tEquirect, sampleUV );\\n\\tgl_FragColor = mapTexelToLinear( texColor );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n}\";\n\n\tvar equirect_vert = \"varying vec3 vWorldDirection;\\n#include <common>\\nvoid main() {\\n\\tvWorldDirection = transformDirection( position, modelMatrix );\\n\\t#include <begin_vertex>\\n\\t#include <project_vertex>\\n}\";\n\n\tvar linedashed_frag = \"uniform vec3 diffuse;\\nuniform float opacity;\\nuniform float dashSize;\\nuniform float totalSize;\\nvarying float vLineDistance;\\n#include <common>\\n#include <color_pars_fragment>\\n#include <fog_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\\n\\t\\tdiscard;\\n\\t}\\n\\tvec3 outgoingLight = vec3( 0.0 );\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <color_fragment>\\n\\toutgoingLight = diffuseColor.rgb;\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include <premultiplied_alpha_fragment>\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n}\";\n\n\tvar linedashed_vert = \"uniform float scale;\\nattribute float lineDistance;\\nvarying float vLineDistance;\\n#include <common>\\n#include <color_pars_vertex>\\n#include <fog_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <color_vertex>\\n\\tvLineDistance = scale * lineDistance;\\n\\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\\n\\tgl_Position = projectionMatrix * mvPosition;\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\t#include <fog_vertex>\\n}\";\n\n\tvar meshbasic_frag = \"uniform vec3 diffuse;\\nuniform float opacity;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include <common>\\n#include <color_pars_fragment>\\n#include <uv_pars_fragment>\\n#include <uv2_pars_fragment>\\n#include <map_pars_fragment>\\n#include <alphamap_pars_fragment>\\n#include <aomap_pars_fragment>\\n#include <lightmap_pars_fragment>\\n#include <envmap_pars_fragment>\\n#include <fog_pars_fragment>\\n#include <specularmap_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <map_fragment>\\n\\t#include <color_fragment>\\n\\t#include <alphamap_fragment>\\n\\t#include <alphatest_fragment>\\n\\t#include <specularmap_fragment>\\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\t#ifdef USE_LIGHTMAP\\n\\t\\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\\n\\t#else\\n\\t\\treflectedLight.indirectDiffuse += vec3( 1.0 );\\n\\t#endif\\n\\t#include <aomap_fragment>\\n\\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\\n\\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\\n\\t#include <envmap_fragment>\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include <premultiplied_alpha_fragment>\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n}\";\n\n\tvar meshbasic_vert = \"#include <common>\\n#include <uv_pars_vertex>\\n#include <uv2_pars_vertex>\\n#include <envmap_pars_vertex>\\n#include <color_pars_vertex>\\n#include <fog_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <skinning_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\t#include <uv2_vertex>\\n\\t#include <color_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#ifdef USE_ENVMAP\\n\\t#include <beginnormal_vertex>\\n\\t#include <morphnormal_vertex>\\n\\t#include <skinnormal_vertex>\\n\\t#include <defaultnormal_vertex>\\n\\t#endif\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <skinning_vertex>\\n\\t#include <project_vertex>\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <worldpos_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\t#include <envmap_vertex>\\n\\t#include <fog_vertex>\\n}\";\n\n\tvar meshlambert_frag = \"uniform vec3 diffuse;\\nuniform vec3 emissive;\\nuniform float opacity;\\nvarying vec3 vLightFront;\\n#ifdef DOUBLE_SIDED\\n\\tvarying vec3 vLightBack;\\n#endif\\n#include <common>\\n#include <packing>\\n#include <dithering_pars_fragment>\\n#include <color_pars_fragment>\\n#include <uv_pars_fragment>\\n#include <uv2_pars_fragment>\\n#include <map_pars_fragment>\\n#include <alphamap_pars_fragment>\\n#include <aomap_pars_fragment>\\n#include <lightmap_pars_fragment>\\n#include <emissivemap_pars_fragment>\\n#include <envmap_pars_fragment>\\n#include <bsdfs>\\n#include <lights_pars_begin>\\n#include <fog_pars_fragment>\\n#include <shadowmap_pars_fragment>\\n#include <shadowmask_pars_fragment>\\n#include <specularmap_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\tvec3 totalEmissiveRadiance = emissive;\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <map_fragment>\\n\\t#include <color_fragment>\\n\\t#include <alphamap_fragment>\\n\\t#include <alphatest_fragment>\\n\\t#include <specularmap_fragment>\\n\\t#include <emissivemap_fragment>\\n\\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\\n\\t#include <lightmap_fragment>\\n\\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\\n\\t#ifdef DOUBLE_SIDED\\n\\t\\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\\n\\t#else\\n\\t\\treflectedLight.directDiffuse = vLightFront;\\n\\t#endif\\n\\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\\n\\t#include <aomap_fragment>\\n\\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\\n\\t#include <envmap_fragment>\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n\\t#include <premultiplied_alpha_fragment>\\n\\t#include <dithering_fragment>\\n}\";\n\n\tvar meshlambert_vert = \"#define LAMBERT\\nvarying vec3 vLightFront;\\n#ifdef DOUBLE_SIDED\\n\\tvarying vec3 vLightBack;\\n#endif\\n#include <common>\\n#include <uv_pars_vertex>\\n#include <uv2_pars_vertex>\\n#include <envmap_pars_vertex>\\n#include <bsdfs>\\n#include <lights_pars_begin>\\n#include <color_pars_vertex>\\n#include <fog_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <skinning_pars_vertex>\\n#include <shadowmap_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\t#include <uv2_vertex>\\n\\t#include <color_vertex>\\n\\t#include <beginnormal_vertex>\\n\\t#include <morphnormal_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#include <skinnormal_vertex>\\n\\t#include <defaultnormal_vertex>\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <skinning_vertex>\\n\\t#include <project_vertex>\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\t#include <worldpos_vertex>\\n\\t#include <envmap_vertex>\\n\\t#include <lights_lambert_vertex>\\n\\t#include <shadowmap_vertex>\\n\\t#include <fog_vertex>\\n}\";\n\n\tvar meshmatcap_frag = \"#define MATCAP\\nuniform vec3 diffuse;\\nuniform float opacity;\\nuniform sampler2D matcap;\\nvarying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include <common>\\n#include <uv_pars_fragment>\\n#include <map_pars_fragment>\\n#include <alphamap_pars_fragment>\\n#include <fog_pars_fragment>\\n#include <bumpmap_pars_fragment>\\n#include <normalmap_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <map_fragment>\\n\\t#include <alphamap_fragment>\\n\\t#include <alphatest_fragment>\\n\\t#include <normal_fragment_begin>\\n\\t#include <normal_fragment_maps>\\n\\tvec3 viewDir = normalize( vViewPosition );\\n\\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\\n\\tvec3 y = cross( viewDir, x );\\n\\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\\n\\t#ifdef USE_MATCAP\\n\\t\\tvec4 matcapColor = texture2D( matcap, uv );\\n\\t\\tmatcapColor = matcapTexelToLinear( matcapColor );\\n\\t#else\\n\\t\\tvec4 matcapColor = vec4( 1.0 );\\n\\t#endif\\n\\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include <premultiplied_alpha_fragment>\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n}\";\n\n\tvar meshmatcap_vert = \"#define MATCAP\\nvarying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include <common>\\n#include <uv_pars_vertex>\\n#include <displacementmap_pars_vertex>\\n#include <fog_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <skinning_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\t#include <beginnormal_vertex>\\n\\t#include <morphnormal_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#include <skinnormal_vertex>\\n\\t#include <defaultnormal_vertex>\\n\\t#ifndef FLAT_SHADED\\n\\t\\tvNormal = normalize( transformedNormal );\\n\\t#endif\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <skinning_vertex>\\n\\t#include <displacementmap_vertex>\\n\\t#include <project_vertex>\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\t#include <fog_vertex>\\n\\tvViewPosition = - mvPosition.xyz;\\n}\";\n\n\tvar meshphong_frag = \"#define PHONG\\nuniform vec3 diffuse;\\nuniform vec3 emissive;\\nuniform vec3 specular;\\nuniform float shininess;\\nuniform float opacity;\\n#include <common>\\n#include <packing>\\n#include <dithering_pars_fragment>\\n#include <color_pars_fragment>\\n#include <uv_pars_fragment>\\n#include <uv2_pars_fragment>\\n#include <map_pars_fragment>\\n#include <alphamap_pars_fragment>\\n#include <aomap_pars_fragment>\\n#include <lightmap_pars_fragment>\\n#include <emissivemap_pars_fragment>\\n#include <envmap_pars_fragment>\\n#include <gradientmap_pars_fragment>\\n#include <fog_pars_fragment>\\n#include <bsdfs>\\n#include <lights_pars_begin>\\n#include <lights_phong_pars_fragment>\\n#include <shadowmap_pars_fragment>\\n#include <bumpmap_pars_fragment>\\n#include <normalmap_pars_fragment>\\n#include <specularmap_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\tvec3 totalEmissiveRadiance = emissive;\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <map_fragment>\\n\\t#include <color_fragment>\\n\\t#include <alphamap_fragment>\\n\\t#include <alphatest_fragment>\\n\\t#include <specularmap_fragment>\\n\\t#include <normal_fragment_begin>\\n\\t#include <normal_fragment_maps>\\n\\t#include <emissivemap_fragment>\\n\\t#include <lights_phong_fragment>\\n\\t#include <lights_fragment_begin>\\n\\t#include <lights_fragment_maps>\\n\\t#include <lights_fragment_end>\\n\\t#include <aomap_fragment>\\n\\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\\n\\t#include <envmap_fragment>\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n\\t#include <premultiplied_alpha_fragment>\\n\\t#include <dithering_fragment>\\n}\";\n\n\tvar meshphong_vert = \"#define PHONG\\nvarying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include <common>\\n#include <uv_pars_vertex>\\n#include <uv2_pars_vertex>\\n#include <displacementmap_pars_vertex>\\n#include <envmap_pars_vertex>\\n#include <color_pars_vertex>\\n#include <fog_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <skinning_pars_vertex>\\n#include <shadowmap_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\t#include <uv2_vertex>\\n\\t#include <color_vertex>\\n\\t#include <beginnormal_vertex>\\n\\t#include <morphnormal_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#include <skinnormal_vertex>\\n\\t#include <defaultnormal_vertex>\\n#ifndef FLAT_SHADED\\n\\tvNormal = normalize( transformedNormal );\\n#endif\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <skinning_vertex>\\n\\t#include <displacementmap_vertex>\\n\\t#include <project_vertex>\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\tvViewPosition = - mvPosition.xyz;\\n\\t#include <worldpos_vertex>\\n\\t#include <envmap_vertex>\\n\\t#include <shadowmap_vertex>\\n\\t#include <fog_vertex>\\n}\";\n\n\tvar meshphysical_frag = \"#define PHYSICAL\\nuniform vec3 diffuse;\\nuniform vec3 emissive;\\nuniform float roughness;\\nuniform float metalness;\\nuniform float opacity;\\n#ifndef STANDARD\\n\\tuniform float clearCoat;\\n\\tuniform float clearCoatRoughness;\\n#endif\\nvarying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include <common>\\n#include <packing>\\n#include <dithering_pars_fragment>\\n#include <color_pars_fragment>\\n#include <uv_pars_fragment>\\n#include <uv2_pars_fragment>\\n#include <map_pars_fragment>\\n#include <alphamap_pars_fragment>\\n#include <aomap_pars_fragment>\\n#include <lightmap_pars_fragment>\\n#include <emissivemap_pars_fragment>\\n#include <bsdfs>\\n#include <cube_uv_reflection_fragment>\\n#include <envmap_pars_fragment>\\n#include <envmap_physical_pars_fragment>\\n#include <fog_pars_fragment>\\n#include <lights_pars_begin>\\n#include <lights_physical_pars_fragment>\\n#include <shadowmap_pars_fragment>\\n#include <bumpmap_pars_fragment>\\n#include <normalmap_pars_fragment>\\n#include <roughnessmap_pars_fragment>\\n#include <metalnessmap_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\tvec3 totalEmissiveRadiance = emissive;\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <map_fragment>\\n\\t#include <color_fragment>\\n\\t#include <alphamap_fragment>\\n\\t#include <alphatest_fragment>\\n\\t#include <roughnessmap_fragment>\\n\\t#include <metalnessmap_fragment>\\n\\t#include <normal_fragment_begin>\\n\\t#include <normal_fragment_maps>\\n\\t#include <emissivemap_fragment>\\n\\t#include <lights_physical_fragment>\\n\\t#include <lights_fragment_begin>\\n\\t#include <lights_fragment_maps>\\n\\t#include <lights_fragment_end>\\n\\t#include <aomap_fragment>\\n\\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n\\t#include <premultiplied_alpha_fragment>\\n\\t#include <dithering_fragment>\\n}\";\n\n\tvar meshphysical_vert = \"#define PHYSICAL\\nvarying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include <common>\\n#include <uv_pars_vertex>\\n#include <uv2_pars_vertex>\\n#include <displacementmap_pars_vertex>\\n#include <color_pars_vertex>\\n#include <fog_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <skinning_pars_vertex>\\n#include <shadowmap_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\t#include <uv2_vertex>\\n\\t#include <color_vertex>\\n\\t#include <beginnormal_vertex>\\n\\t#include <morphnormal_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#include <skinnormal_vertex>\\n\\t#include <defaultnormal_vertex>\\n#ifndef FLAT_SHADED\\n\\tvNormal = normalize( transformedNormal );\\n#endif\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <skinning_vertex>\\n\\t#include <displacementmap_vertex>\\n\\t#include <project_vertex>\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\tvViewPosition = - mvPosition.xyz;\\n\\t#include <worldpos_vertex>\\n\\t#include <shadowmap_vertex>\\n\\t#include <fog_vertex>\\n}\";\n\n\tvar normal_frag = \"#define NORMAL\\nuniform float opacity;\\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\\n\\tvarying vec3 vViewPosition;\\n#endif\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include <packing>\\n#include <uv_pars_fragment>\\n#include <bumpmap_pars_fragment>\\n#include <normalmap_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\nvoid main() {\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <normal_fragment_begin>\\n\\t#include <normal_fragment_maps>\\n\\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\\n}\";\n\n\tvar normal_vert = \"#define NORMAL\\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\\n\\tvarying vec3 vViewPosition;\\n#endif\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include <uv_pars_vertex>\\n#include <displacementmap_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <skinning_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\t#include <beginnormal_vertex>\\n\\t#include <morphnormal_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#include <skinnormal_vertex>\\n\\t#include <defaultnormal_vertex>\\n#ifndef FLAT_SHADED\\n\\tvNormal = normalize( transformedNormal );\\n#endif\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <skinning_vertex>\\n\\t#include <displacementmap_vertex>\\n\\t#include <project_vertex>\\n\\t#include <logdepthbuf_vertex>\\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\\n\\tvViewPosition = - mvPosition.xyz;\\n#endif\\n}\";\n\n\tvar points_frag = \"uniform vec3 diffuse;\\nuniform float opacity;\\n#include <common>\\n#include <color_pars_fragment>\\n#include <map_particle_pars_fragment>\\n#include <fog_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tvec3 outgoingLight = vec3( 0.0 );\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <map_particle_fragment>\\n\\t#include <color_fragment>\\n\\t#include <alphatest_fragment>\\n\\toutgoingLight = diffuseColor.rgb;\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include <premultiplied_alpha_fragment>\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n}\";\n\n\tvar points_vert = \"uniform float size;\\nuniform float scale;\\n#include <common>\\n#include <color_pars_vertex>\\n#include <fog_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <color_vertex>\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <project_vertex>\\n\\tgl_PointSize = size;\\n\\t#ifdef USE_SIZEATTENUATION\\n\\t\\tbool isPerspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 );\\n\\t\\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\\n\\t#endif\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\t#include <worldpos_vertex>\\n\\t#include <fog_vertex>\\n}\";\n\n\tvar shadow_frag = \"uniform vec3 color;\\nuniform float opacity;\\n#include <common>\\n#include <packing>\\n#include <fog_pars_fragment>\\n#include <bsdfs>\\n#include <lights_pars_begin>\\n#include <shadowmap_pars_fragment>\\n#include <shadowmask_pars_fragment>\\nvoid main() {\\n\\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\\n\\t#include <fog_fragment>\\n}\";\n\n\tvar shadow_vert = \"#include <fog_pars_vertex>\\n#include <shadowmap_pars_vertex>\\nvoid main() {\\n\\t#include <begin_vertex>\\n\\t#include <project_vertex>\\n\\t#include <worldpos_vertex>\\n\\t#include <shadowmap_vertex>\\n\\t#include <fog_vertex>\\n}\";\n\n\tvar sprite_frag = \"uniform vec3 diffuse;\\nuniform float opacity;\\n#include <common>\\n#include <uv_pars_fragment>\\n#include <map_pars_fragment>\\n#include <fog_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tvec3 outgoingLight = vec3( 0.0 );\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <map_fragment>\\n\\t#include <alphatest_fragment>\\n\\toutgoingLight = diffuseColor.rgb;\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n}\";\n\n\tvar sprite_vert = \"uniform float rotation;\\nuniform vec2 center;\\n#include <common>\\n#include <uv_pars_vertex>\\n#include <fog_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\\n\\tvec2 scale;\\n\\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\\n\\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\\n\\t#ifndef USE_SIZEATTENUATION\\n\\t\\tbool isPerspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 );\\n\\t\\tif ( isPerspective ) scale *= - mvPosition.z;\\n\\t#endif\\n\\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\\n\\tvec2 rotatedPosition;\\n\\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\\n\\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\\n\\tmvPosition.xy += rotatedPosition;\\n\\tgl_Position = projectionMatrix * mvPosition;\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\t#include <fog_vertex>\\n}\";\n\n\tvar ShaderChunk = {\n\t\talphamap_fragment: alphamap_fragment,\n\t\talphamap_pars_fragment: alphamap_pars_fragment,\n\t\talphatest_fragment: alphatest_fragment,\n\t\taomap_fragment: aomap_fragment,\n\t\taomap_pars_fragment: aomap_pars_fragment,\n\t\tbegin_vertex: begin_vertex,\n\t\tbeginnormal_vertex: beginnormal_vertex,\n\t\tbsdfs: bsdfs,\n\t\tbumpmap_pars_fragment: bumpmap_pars_fragment,\n\t\tclipping_planes_fragment: clipping_planes_fragment,\n\t\tclipping_planes_pars_fragment: clipping_planes_pars_fragment,\n\t\tclipping_planes_pars_vertex: clipping_planes_pars_vertex,\n\t\tclipping_planes_vertex: clipping_planes_vertex,\n\t\tcolor_fragment: color_fragment,\n\t\tcolor_pars_fragment: color_pars_fragment,\n\t\tcolor_pars_vertex: color_pars_vertex,\n\t\tcolor_vertex: color_vertex,\n\t\tcommon: common,\n\t\tcube_uv_reflection_fragment: cube_uv_reflection_fragment,\n\t\tdefaultnormal_vertex: defaultnormal_vertex,\n\t\tdisplacementmap_pars_vertex: displacementmap_pars_vertex,\n\t\tdisplacementmap_vertex: displacementmap_vertex,\n\t\temissivemap_fragment: emissivemap_fragment,\n\t\temissivemap_pars_fragment: emissivemap_pars_fragment,\n\t\tencodings_fragment: encodings_fragment,\n\t\tencodings_pars_fragment: encodings_pars_fragment,\n\t\tenvmap_fragment: envmap_fragment,\n\t\tenvmap_pars_fragment: envmap_pars_fragment,\n\t\tenvmap_pars_vertex: envmap_pars_vertex,\n\t\tenvmap_physical_pars_fragment: envmap_physical_pars_fragment,\n\t\tenvmap_vertex: envmap_vertex,\n\t\tfog_vertex: fog_vertex,\n\t\tfog_pars_vertex: fog_pars_vertex,\n\t\tfog_fragment: fog_fragment,\n\t\tfog_pars_fragment: fog_pars_fragment,\n\t\tgradientmap_pars_fragment: gradientmap_pars_fragment,\n\t\tlightmap_fragment: lightmap_fragment,\n\t\tlightmap_pars_fragment: lightmap_pars_fragment,\n\t\tlights_lambert_vertex: lights_lambert_vertex,\n\t\tlights_pars_begin: lights_pars_begin,\n\t\tlights_phong_fragment: lights_phong_fragment,\n\t\tlights_phong_pars_fragment: lights_phong_pars_fragment,\n\t\tlights_physical_fragment: lights_physical_fragment,\n\t\tlights_physical_pars_fragment: lights_physical_pars_fragment,\n\t\tlights_fragment_begin: lights_fragment_begin,\n\t\tlights_fragment_maps: lights_fragment_maps,\n\t\tlights_fragment_end: lights_fragment_end,\n\t\tlogdepthbuf_fragment: logdepthbuf_fragment,\n\t\tlogdepthbuf_pars_fragment: logdepthbuf_pars_fragment,\n\t\tlogdepthbuf_pars_vertex: logdepthbuf_pars_vertex,\n\t\tlogdepthbuf_vertex: logdepthbuf_vertex,\n\t\tmap_fragment: map_fragment,\n\t\tmap_pars_fragment: map_pars_fragment,\n\t\tmap_particle_fragment: map_particle_fragment,\n\t\tmap_particle_pars_fragment: map_particle_pars_fragment,\n\t\tmetalnessmap_fragment: metalnessmap_fragment,\n\t\tmetalnessmap_pars_fragment: metalnessmap_pars_fragment,\n\t\tmorphnormal_vertex: morphnormal_vertex,\n\t\tmorphtarget_pars_vertex: morphtarget_pars_vertex,\n\t\tmorphtarget_vertex: morphtarget_vertex,\n\t\tnormal_fragment_begin: normal_fragment_begin,\n\t\tnormal_fragment_maps: normal_fragment_maps,\n\t\tnormalmap_pars_fragment: normalmap_pars_fragment,\n\t\tpacking: packing,\n\t\tpremultiplied_alpha_fragment: premultiplied_alpha_fragment,\n\t\tproject_vertex: project_vertex,\n\t\tdithering_fragment: dithering_fragment,\n\t\tdithering_pars_fragment: dithering_pars_fragment,\n\t\troughnessmap_fragment: roughnessmap_fragment,\n\t\troughnessmap_pars_fragment: roughnessmap_pars_fragment,\n\t\tshadowmap_pars_fragment: shadowmap_pars_fragment,\n\t\tshadowmap_pars_vertex: shadowmap_pars_vertex,\n\t\tshadowmap_vertex: shadowmap_vertex,\n\t\tshadowmask_pars_fragment: shadowmask_pars_fragment,\n\t\tskinbase_vertex: skinbase_vertex,\n\t\tskinning_pars_vertex: skinning_pars_vertex,\n\t\tskinning_vertex: skinning_vertex,\n\t\tskinnormal_vertex: skinnormal_vertex,\n\t\tspecularmap_fragment: specularmap_fragment,\n\t\tspecularmap_pars_fragment: specularmap_pars_fragment,\n\t\ttonemapping_fragment: tonemapping_fragment,\n\t\ttonemapping_pars_fragment: tonemapping_pars_fragment,\n\t\tuv_pars_fragment: uv_pars_fragment,\n\t\tuv_pars_vertex: uv_pars_vertex,\n\t\tuv_vertex: uv_vertex,\n\t\tuv2_pars_fragment: uv2_pars_fragment,\n\t\tuv2_pars_vertex: uv2_pars_vertex,\n\t\tuv2_vertex: uv2_vertex,\n\t\tworldpos_vertex: worldpos_vertex,\n\n\t\tbackground_frag: background_frag,\n\t\tbackground_vert: background_vert,\n\t\tcube_frag: cube_frag,\n\t\tcube_vert: cube_vert,\n\t\tdepth_frag: depth_frag,\n\t\tdepth_vert: depth_vert,\n\t\tdistanceRGBA_frag: distanceRGBA_frag,\n\t\tdistanceRGBA_vert: distanceRGBA_vert,\n\t\tequirect_frag: equirect_frag,\n\t\tequirect_vert: equirect_vert,\n\t\tlinedashed_frag: linedashed_frag,\n\t\tlinedashed_vert: linedashed_vert,\n\t\tmeshbasic_frag: meshbasic_frag,\n\t\tmeshbasic_vert: meshbasic_vert,\n\t\tmeshlambert_frag: meshlambert_frag,\n\t\tmeshlambert_vert: meshlambert_vert,\n\t\tmeshmatcap_frag: meshmatcap_frag,\n\t\tmeshmatcap_vert: meshmatcap_vert,\n\t\tmeshphong_frag: meshphong_frag,\n\t\tmeshphong_vert: meshphong_vert,\n\t\tmeshphysical_frag: meshphysical_frag,\n\t\tmeshphysical_vert: meshphysical_vert,\n\t\tnormal_frag: normal_frag,\n\t\tnormal_vert: normal_vert,\n\t\tpoints_frag: points_frag,\n\t\tpoints_vert: points_vert,\n\t\tshadow_frag: shadow_frag,\n\t\tshadow_vert: shadow_vert,\n\t\tsprite_frag: sprite_frag,\n\t\tsprite_vert: sprite_vert\n\t};\n\n\t/**\n\t * Uniform Utilities\n\t */\n\n\tfunction cloneUniforms( src ) {\n\n\t\tvar dst = {};\n\n\t\tfor ( var u in src ) {\n\n\t\t\tdst[ u ] = {};\n\n\t\t\tfor ( var p in src[ u ] ) {\n\n\t\t\t\tvar property = src[ u ][ p ];\n\n\t\t\t\tif ( property && ( property.isColor ||\n\t\t\t\t\tproperty.isMatrix3 || property.isMatrix4 ||\n\t\t\t\t\tproperty.isVector2 || property.isVector3 || property.isVector4 ||\n\t\t\t\t\tproperty.isTexture ) ) {\n\n\t\t\t\t\tdst[ u ][ p ] = property.clone();\n\n\t\t\t\t} else if ( Array.isArray( property ) ) {\n\n\t\t\t\t\tdst[ u ][ p ] = property.slice();\n\n\t\t\t\t} else {\n\n\t\t\t\t\tdst[ u ][ p ] = property;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn dst;\n\n\t}\n\n\tfunction mergeUniforms( uniforms ) {\n\n\t\tvar merged = {};\n\n\t\tfor ( var u = 0; u < uniforms.length; u ++ ) {\n\n\t\t\tvar tmp = cloneUniforms( uniforms[ u ] );\n\n\t\t\tfor ( var p in tmp ) {\n\n\t\t\t\tmerged[ p ] = tmp[ p ];\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn merged;\n\n\t}\n\n\t// Legacy\n\n\tvar UniformsUtils = { clone: cloneUniforms, merge: mergeUniforms };\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tvar ColorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,\n\t\t'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,\n\t\t'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,\n\t\t'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B,\n\t\t'darkgoldenrod': 0xB8860B, 'darkgray': 0xA9A9A9, 'darkgreen': 0x006400, 'darkgrey': 0xA9A9A9, 'darkkhaki': 0xBDB76B, 'darkmagenta': 0x8B008B,\n\t\t'darkolivegreen': 0x556B2F, 'darkorange': 0xFF8C00, 'darkorchid': 0x9932CC, 'darkred': 0x8B0000, 'darksalmon': 0xE9967A, 'darkseagreen': 0x8FBC8F,\n\t\t'darkslateblue': 0x483D8B, 'darkslategray': 0x2F4F4F, 'darkslategrey': 0x2F4F4F, 'darkturquoise': 0x00CED1, 'darkviolet': 0x9400D3,\n\t\t'deeppink': 0xFF1493, 'deepskyblue': 0x00BFFF, 'dimgray': 0x696969, 'dimgrey': 0x696969, 'dodgerblue': 0x1E90FF, 'firebrick': 0xB22222,\n\t\t'floralwhite': 0xFFFAF0, 'forestgreen': 0x228B22, 'fuchsia': 0xFF00FF, 'gainsboro': 0xDCDCDC, 'ghostwhite': 0xF8F8FF, 'gold': 0xFFD700,\n\t\t'goldenrod': 0xDAA520, 'gray': 0x808080, 'green': 0x008000, 'greenyellow': 0xADFF2F, 'grey': 0x808080, 'honeydew': 0xF0FFF0, 'hotpink': 0xFF69B4,\n\t\t'indianred': 0xCD5C5C, 'indigo': 0x4B0082, 'ivory': 0xFFFFF0, 'khaki': 0xF0E68C, 'lavender': 0xE6E6FA, 'lavenderblush': 0xFFF0F5, 'lawngreen': 0x7CFC00,\n\t\t'lemonchiffon': 0xFFFACD, 'lightblue': 0xADD8E6, 'lightcoral': 0xF08080, 'lightcyan': 0xE0FFFF, 'lightgoldenrodyellow': 0xFAFAD2, 'lightgray': 0xD3D3D3,\n\t\t'lightgreen': 0x90EE90, 'lightgrey': 0xD3D3D3, 'lightpink': 0xFFB6C1, 'lightsalmon': 0xFFA07A, 'lightseagreen': 0x20B2AA, 'lightskyblue': 0x87CEFA,\n\t\t'lightslategray': 0x778899, 'lightslategrey': 0x778899, 'lightsteelblue': 0xB0C4DE, 'lightyellow': 0xFFFFE0, 'lime': 0x00FF00, 'limegreen': 0x32CD32,\n\t\t'linen': 0xFAF0E6, 'magenta': 0xFF00FF, 'maroon': 0x800000, 'mediumaquamarine': 0x66CDAA, 'mediumblue': 0x0000CD, 'mediumorchid': 0xBA55D3,\n\t\t'mediumpurple': 0x9370DB, 'mediumseagreen': 0x3CB371, 'mediumslateblue': 0x7B68EE, 'mediumspringgreen': 0x00FA9A, 'mediumturquoise': 0x48D1CC,\n\t\t'mediumvioletred': 0xC71585, 'midnightblue': 0x191970, 'mintcream': 0xF5FFFA, 'mistyrose': 0xFFE4E1, 'moccasin': 0xFFE4B5, 'navajowhite': 0xFFDEAD,\n\t\t'navy': 0x000080, 'oldlace': 0xFDF5E6, 'olive': 0x808000, 'olivedrab': 0x6B8E23, 'orange': 0xFFA500, 'orangered': 0xFF4500, 'orchid': 0xDA70D6,\n\t\t'palegoldenrod': 0xEEE8AA, 'palegreen': 0x98FB98, 'paleturquoise': 0xAFEEEE, 'palevioletred': 0xDB7093, 'papayawhip': 0xFFEFD5, 'peachpuff': 0xFFDAB9,\n\t\t'peru': 0xCD853F, 'pink': 0xFFC0CB, 'plum': 0xDDA0DD, 'powderblue': 0xB0E0E6, 'purple': 0x800080, 'rebeccapurple': 0x663399, 'red': 0xFF0000, 'rosybrown': 0xBC8F8F,\n\t\t'royalblue': 0x4169E1, 'saddlebrown': 0x8B4513, 'salmon': 0xFA8072, 'sandybrown': 0xF4A460, 'seagreen': 0x2E8B57, 'seashell': 0xFFF5EE,\n\t\t'sienna': 0xA0522D, 'silver': 0xC0C0C0, 'skyblue': 0x87CEEB, 'slateblue': 0x6A5ACD, 'slategray': 0x708090, 'slategrey': 0x708090, 'snow': 0xFFFAFA,\n\t\t'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0,\n\t\t'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 };\n\n\tfunction Color( r, g, b ) {\n\n\t\tif ( g === undefined && b === undefined ) {\n\n\t\t\t// r is THREE.Color, hex or string\n\t\t\treturn this.set( r );\n\n\t\t}\n\n\t\treturn this.setRGB( r, g, b );\n\n\t}\n\n\tObject.assign( Color.prototype, {\n\n\t\tisColor: true,\n\n\t\tr: 1, g: 1, b: 1,\n\n\t\tset: function ( value ) {\n\n\t\t\tif ( value && value.isColor ) {\n\n\t\t\t\tthis.copy( value );\n\n\t\t\t} else if ( typeof value === 'number' ) {\n\n\t\t\t\tthis.setHex( value );\n\n\t\t\t} else if ( typeof value === 'string' ) {\n\n\t\t\t\tthis.setStyle( value );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetScalar: function ( scalar ) {\n\n\t\t\tthis.r = scalar;\n\t\t\tthis.g = scalar;\n\t\t\tthis.b = scalar;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetHex: function ( hex ) {\n\n\t\t\thex = Math.floor( hex );\n\n\t\t\tthis.r = ( hex >> 16 & 255 ) / 255;\n\t\t\tthis.g = ( hex >> 8 & 255 ) / 255;\n\t\t\tthis.b = ( hex & 255 ) / 255;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetRGB: function ( r, g, b ) {\n\n\t\t\tthis.r = r;\n\t\t\tthis.g = g;\n\t\t\tthis.b = b;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetHSL: function () {\n\n\t\t\tfunction hue2rgb( p, q, t ) {\n\n\t\t\t\tif ( t < 0 ) t += 1;\n\t\t\t\tif ( t > 1 ) t -= 1;\n\t\t\t\tif ( t < 1 / 6 ) return p + ( q - p ) * 6 * t;\n\t\t\t\tif ( t < 1 / 2 ) return q;\n\t\t\t\tif ( t < 2 / 3 ) return p + ( q - p ) * 6 * ( 2 / 3 - t );\n\t\t\t\treturn p;\n\n\t\t\t}\n\n\t\t\treturn function setHSL( h, s, l ) {\n\n\t\t\t\t// h,s,l ranges are in 0.0 - 1.0\n\t\t\t\th = _Math.euclideanModulo( h, 1 );\n\t\t\t\ts = _Math.clamp( s, 0, 1 );\n\t\t\t\tl = _Math.clamp( l, 0, 1 );\n\n\t\t\t\tif ( s === 0 ) {\n\n\t\t\t\t\tthis.r = this.g = this.b = l;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tvar p = l <= 0.5 ? l * ( 1 + s ) : l + s - ( l * s );\n\t\t\t\t\tvar q = ( 2 * l ) - p;\n\n\t\t\t\t\tthis.r = hue2rgb( q, p, h + 1 / 3 );\n\t\t\t\t\tthis.g = hue2rgb( q, p, h );\n\t\t\t\t\tthis.b = hue2rgb( q, p, h - 1 / 3 );\n\n\t\t\t\t}\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tsetStyle: function ( style ) {\n\n\t\t\tfunction handleAlpha( string ) {\n\n\t\t\t\tif ( string === undefined ) return;\n\n\t\t\t\tif ( parseFloat( string ) < 1 ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.Color: Alpha component of ' + style + ' will be ignored.' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\n\t\t\tvar m;\n\n\t\t\tif ( m = /^((?:rgb|hsl)a?)\\(\\s*([^\\)]*)\\)/.exec( style ) ) {\n\n\t\t\t\t// rgb / hsl\n\n\t\t\t\tvar color;\n\t\t\t\tvar name = m[ 1 ];\n\t\t\t\tvar components = m[ 2 ];\n\n\t\t\t\tswitch ( name ) {\n\n\t\t\t\t\tcase 'rgb':\n\t\t\t\t\tcase 'rgba':\n\n\t\t\t\t\t\tif ( color = /^(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec( components ) ) {\n\n\t\t\t\t\t\t\t// rgb(255,0,0) rgba(255,0,0,0.5)\n\t\t\t\t\t\t\tthis.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255;\n\t\t\t\t\t\t\tthis.g = Math.min( 255, parseInt( color[ 2 ], 10 ) ) / 255;\n\t\t\t\t\t\t\tthis.b = Math.min( 255, parseInt( color[ 3 ], 10 ) ) / 255;\n\n\t\t\t\t\t\t\thandleAlpha( color[ 5 ] );\n\n\t\t\t\t\t\t\treturn this;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( color = /^(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec( components ) ) {\n\n\t\t\t\t\t\t\t// rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)\n\t\t\t\t\t\t\tthis.r = Math.min( 100, parseInt( color[ 1 ], 10 ) ) / 100;\n\t\t\t\t\t\t\tthis.g = Math.min( 100, parseInt( color[ 2 ], 10 ) ) / 100;\n\t\t\t\t\t\t\tthis.b = Math.min( 100, parseInt( color[ 3 ], 10 ) ) / 100;\n\n\t\t\t\t\t\t\thandleAlpha( color[ 5 ] );\n\n\t\t\t\t\t\t\treturn this;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'hsl':\n\t\t\t\t\tcase 'hsla':\n\n\t\t\t\t\t\tif ( color = /^([0-9]*\\.?[0-9]+)\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec( components ) ) {\n\n\t\t\t\t\t\t\t// hsl(120,50%,50%) hsla(120,50%,50%,0.5)\n\t\t\t\t\t\t\tvar h = parseFloat( color[ 1 ] ) / 360;\n\t\t\t\t\t\t\tvar s = parseInt( color[ 2 ], 10 ) / 100;\n\t\t\t\t\t\t\tvar l = parseInt( color[ 3 ], 10 ) / 100;\n\n\t\t\t\t\t\t\thandleAlpha( color[ 5 ] );\n\n\t\t\t\t\t\t\treturn this.setHSL( h, s, l );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t} else if ( m = /^\\#([A-Fa-f0-9]+)$/.exec( style ) ) {\n\n\t\t\t\t// hex color\n\n\t\t\t\tvar hex = m[ 1 ];\n\t\t\t\tvar size = hex.length;\n\n\t\t\t\tif ( size === 3 ) {\n\n\t\t\t\t\t// #ff0\n\t\t\t\t\tthis.r = parseInt( hex.charAt( 0 ) + hex.charAt( 0 ), 16 ) / 255;\n\t\t\t\t\tthis.g = parseInt( hex.charAt( 1 ) + hex.charAt( 1 ), 16 ) / 255;\n\t\t\t\t\tthis.b = parseInt( hex.charAt( 2 ) + hex.charAt( 2 ), 16 ) / 255;\n\n\t\t\t\t\treturn this;\n\n\t\t\t\t} else if ( size === 6 ) {\n\n\t\t\t\t\t// #ff0000\n\t\t\t\t\tthis.r = parseInt( hex.charAt( 0 ) + hex.charAt( 1 ), 16 ) / 255;\n\t\t\t\t\tthis.g = parseInt( hex.charAt( 2 ) + hex.charAt( 3 ), 16 ) / 255;\n\t\t\t\t\tthis.b = parseInt( hex.charAt( 4 ) + hex.charAt( 5 ), 16 ) / 255;\n\n\t\t\t\t\treturn this;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( style && style.length > 0 ) {\n\n\t\t\t\t// color keywords\n\t\t\t\tvar hex = ColorKeywords[ style ];\n\n\t\t\t\tif ( hex !== undefined ) {\n\n\t\t\t\t\t// red\n\t\t\t\t\tthis.setHex( hex );\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// unknown color\n\t\t\t\t\tconsole.warn( 'THREE.Color: Unknown color ' + style );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor( this.r, this.g, this.b );\n\n\t\t},\n\n\t\tcopy: function ( color ) {\n\n\t\t\tthis.r = color.r;\n\t\t\tthis.g = color.g;\n\t\t\tthis.b = color.b;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcopyGammaToLinear: function ( color, gammaFactor ) {\n\n\t\t\tif ( gammaFactor === undefined ) gammaFactor = 2.0;\n\n\t\t\tthis.r = Math.pow( color.r, gammaFactor );\n\t\t\tthis.g = Math.pow( color.g, gammaFactor );\n\t\t\tthis.b = Math.pow( color.b, gammaFactor );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcopyLinearToGamma: function ( color, gammaFactor ) {\n\n\t\t\tif ( gammaFactor === undefined ) gammaFactor = 2.0;\n\n\t\t\tvar safeInverse = ( gammaFactor > 0 ) ? ( 1.0 / gammaFactor ) : 1.0;\n\n\t\t\tthis.r = Math.pow( color.r, safeInverse );\n\t\t\tthis.g = Math.pow( color.g, safeInverse );\n\t\t\tthis.b = Math.pow( color.b, safeInverse );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tconvertGammaToLinear: function ( gammaFactor ) {\n\n\t\t\tthis.copyGammaToLinear( this, gammaFactor );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tconvertLinearToGamma: function ( gammaFactor ) {\n\n\t\t\tthis.copyLinearToGamma( this, gammaFactor );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcopySRGBToLinear: function () {\n\n\t\t\tfunction SRGBToLinear( c ) {\n\n\t\t\t\treturn ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );\n\n\t\t\t}\n\n\t\t\treturn function copySRGBToLinear( color ) {\n\n\t\t\t\tthis.r = SRGBToLinear( color.r );\n\t\t\t\tthis.g = SRGBToLinear( color.g );\n\t\t\t\tthis.b = SRGBToLinear( color.b );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tcopyLinearToSRGB: function () {\n\n\t\t\tfunction LinearToSRGB( c ) {\n\n\t\t\t\treturn ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;\n\n\t\t\t}\n\n\t\t\treturn function copyLinearToSRGB( color ) {\n\n\t\t\t\tthis.r = LinearToSRGB( color.r );\n\t\t\t\tthis.g = LinearToSRGB( color.g );\n\t\t\t\tthis.b = LinearToSRGB( color.b );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tconvertSRGBToLinear: function () {\n\n\t\t\tthis.copySRGBToLinear( this );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tconvertLinearToSRGB: function () {\n\n\t\t\tthis.copyLinearToSRGB( this );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetHex: function () {\n\n\t\t\treturn ( this.r * 255 ) << 16 ^ ( this.g * 255 ) << 8 ^ ( this.b * 255 ) << 0;\n\n\t\t},\n\n\t\tgetHexString: function () {\n\n\t\t\treturn ( '000000' + this.getHex().toString( 16 ) ).slice( - 6 );\n\n\t\t},\n\n\t\tgetHSL: function ( target ) {\n\n\t\t\t// h,s,l ranges are in 0.0 - 1.0\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Color: .getHSL() target is now required' );\n\t\t\t\ttarget = { h: 0, s: 0, l: 0 };\n\n\t\t\t}\n\n\t\t\tvar r = this.r, g = this.g, b = this.b;\n\n\t\t\tvar max = Math.max( r, g, b );\n\t\t\tvar min = Math.min( r, g, b );\n\n\t\t\tvar hue, saturation;\n\t\t\tvar lightness = ( min + max ) / 2.0;\n\n\t\t\tif ( min === max ) {\n\n\t\t\t\thue = 0;\n\t\t\t\tsaturation = 0;\n\n\t\t\t} else {\n\n\t\t\t\tvar delta = max - min;\n\n\t\t\t\tsaturation = lightness <= 0.5 ? delta / ( max + min ) : delta / ( 2 - max - min );\n\n\t\t\t\tswitch ( max ) {\n\n\t\t\t\t\tcase r: hue = ( g - b ) / delta + ( g < b ? 6 : 0 ); break;\n\t\t\t\t\tcase g: hue = ( b - r ) / delta + 2; break;\n\t\t\t\t\tcase b: hue = ( r - g ) / delta + 4; break;\n\n\t\t\t\t}\n\n\t\t\t\thue /= 6;\n\n\t\t\t}\n\n\t\t\ttarget.h = hue;\n\t\t\ttarget.s = saturation;\n\t\t\ttarget.l = lightness;\n\n\t\t\treturn target;\n\n\t\t},\n\n\t\tgetStyle: function () {\n\n\t\t\treturn 'rgb(' + ( ( this.r * 255 ) | 0 ) + ',' + ( ( this.g * 255 ) | 0 ) + ',' + ( ( this.b * 255 ) | 0 ) + ')';\n\n\t\t},\n\n\t\toffsetHSL: function () {\n\n\t\t\tvar hsl = {};\n\n\t\t\treturn function ( h, s, l ) {\n\n\t\t\t\tthis.getHSL( hsl );\n\n\t\t\t\thsl.h += h; hsl.s += s; hsl.l += l;\n\n\t\t\t\tthis.setHSL( hsl.h, hsl.s, hsl.l );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tadd: function ( color ) {\n\n\t\t\tthis.r += color.r;\n\t\t\tthis.g += color.g;\n\t\t\tthis.b += color.b;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\taddColors: function ( color1, color2 ) {\n\n\t\t\tthis.r = color1.r + color2.r;\n\t\t\tthis.g = color1.g + color2.g;\n\t\t\tthis.b = color1.b + color2.b;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\taddScalar: function ( s ) {\n\n\t\t\tthis.r += s;\n\t\t\tthis.g += s;\n\t\t\tthis.b += s;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsub: function ( color ) {\n\n\t\t\tthis.r = Math.max( 0, this.r - color.r );\n\t\t\tthis.g = Math.max( 0, this.g - color.g );\n\t\t\tthis.b = Math.max( 0, this.b - color.b );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmultiply: function ( color ) {\n\n\t\t\tthis.r *= color.r;\n\t\t\tthis.g *= color.g;\n\t\t\tthis.b *= color.b;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmultiplyScalar: function ( s ) {\n\n\t\t\tthis.r *= s;\n\t\t\tthis.g *= s;\n\t\t\tthis.b *= s;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tlerp: function ( color, alpha ) {\n\n\t\t\tthis.r += ( color.r - this.r ) * alpha;\n\t\t\tthis.g += ( color.g - this.g ) * alpha;\n\t\t\tthis.b += ( color.b - this.b ) * alpha;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tlerpHSL: function () {\n\n\t\t\tvar hslA = { h: 0, s: 0, l: 0 };\n\t\t\tvar hslB = { h: 0, s: 0, l: 0 };\n\n\t\t\treturn function lerpHSL( color, alpha ) {\n\n\t\t\t\tthis.getHSL( hslA );\n\t\t\t\tcolor.getHSL( hslB );\n\n\t\t\t\tvar h = _Math.lerp( hslA.h, hslB.h, alpha );\n\t\t\t\tvar s = _Math.lerp( hslA.s, hslB.s, alpha );\n\t\t\t\tvar l = _Math.lerp( hslA.l, hslB.l, alpha );\n\n\t\t\t\tthis.setHSL( h, s, l );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tequals: function ( c ) {\n\n\t\t\treturn ( c.r === this.r ) && ( c.g === this.g ) && ( c.b === this.b );\n\n\t\t},\n\n\t\tfromArray: function ( array, offset ) {\n\n\t\t\tif ( offset === undefined ) offset = 0;\n\n\t\t\tthis.r = array[ offset ];\n\t\t\tthis.g = array[ offset + 1 ];\n\t\t\tthis.b = array[ offset + 2 ];\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttoArray: function ( array, offset ) {\n\n\t\t\tif ( array === undefined ) array = [];\n\t\t\tif ( offset === undefined ) offset = 0;\n\n\t\t\tarray[ offset ] = this.r;\n\t\t\tarray[ offset + 1 ] = this.g;\n\t\t\tarray[ offset + 2 ] = this.b;\n\n\t\t\treturn array;\n\n\t\t},\n\n\t\ttoJSON: function () {\n\n\t\t\treturn this.getHex();\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * Uniforms library for shared webgl shaders\n\t */\n\n\tvar UniformsLib = {\n\n\t\tcommon: {\n\n\t\t\tdiffuse: { value: new Color( 0xeeeeee ) },\n\t\t\topacity: { value: 1.0 },\n\n\t\t\tmap: { value: null },\n\t\t\tuvTransform: { value: new Matrix3() },\n\n\t\t\talphaMap: { value: null },\n\n\t\t},\n\n\t\tspecularmap: {\n\n\t\t\tspecularMap: { value: null },\n\n\t\t},\n\n\t\tenvmap: {\n\n\t\t\tenvMap: { value: null },\n\t\t\tflipEnvMap: { value: - 1 },\n\t\t\treflectivity: { value: 1.0 },\n\t\t\trefractionRatio: { value: 0.98 },\n\t\t\tmaxMipLevel: { value: 0 }\n\n\t\t},\n\n\t\taomap: {\n\n\t\t\taoMap: { value: null },\n\t\t\taoMapIntensity: { value: 1 }\n\n\t\t},\n\n\t\tlightmap: {\n\n\t\t\tlightMap: { value: null },\n\t\t\tlightMapIntensity: { value: 1 }\n\n\t\t},\n\n\t\temissivemap: {\n\n\t\t\temissiveMap: { value: null }\n\n\t\t},\n\n\t\tbumpmap: {\n\n\t\t\tbumpMap: { value: null },\n\t\t\tbumpScale: { value: 1 }\n\n\t\t},\n\n\t\tnormalmap: {\n\n\t\t\tnormalMap: { value: null },\n\t\t\tnormalScale: { value: new Vector2( 1, 1 ) }\n\n\t\t},\n\n\t\tdisplacementmap: {\n\n\t\t\tdisplacementMap: { value: null },\n\t\t\tdisplacementScale: { value: 1 },\n\t\t\tdisplacementBias: { value: 0 }\n\n\t\t},\n\n\t\troughnessmap: {\n\n\t\t\troughnessMap: { value: null }\n\n\t\t},\n\n\t\tmetalnessmap: {\n\n\t\t\tmetalnessMap: { value: null }\n\n\t\t},\n\n\t\tgradientmap: {\n\n\t\t\tgradientMap: { value: null }\n\n\t\t},\n\n\t\tfog: {\n\n\t\t\tfogDensity: { value: 0.00025 },\n\t\t\tfogNear: { value: 1 },\n\t\t\tfogFar: { value: 2000 },\n\t\t\tfogColor: { value: new Color( 0xffffff ) }\n\n\t\t},\n\n\t\tlights: {\n\n\t\t\tambientLightColor: { value: [] },\n\n\t\t\tdirectionalLights: { value: [], properties: {\n\t\t\t\tdirection: {},\n\t\t\t\tcolor: {},\n\n\t\t\t\tshadow: {},\n\t\t\t\tshadowBias: {},\n\t\t\t\tshadowRadius: {},\n\t\t\t\tshadowMapSize: {}\n\t\t\t} },\n\n\t\t\tdirectionalShadowMap: { value: [] },\n\t\t\tdirectionalShadowMatrix: { value: [] },\n\n\t\t\tspotLights: { value: [], properties: {\n\t\t\t\tcolor: {},\n\t\t\t\tposition: {},\n\t\t\t\tdirection: {},\n\t\t\t\tdistance: {},\n\t\t\t\tconeCos: {},\n\t\t\t\tpenumbraCos: {},\n\t\t\t\tdecay: {},\n\n\t\t\t\tshadow: {},\n\t\t\t\tshadowBias: {},\n\t\t\t\tshadowRadius: {},\n\t\t\t\tshadowMapSize: {}\n\t\t\t} },\n\n\t\t\tspotShadowMap: { value: [] },\n\t\t\tspotShadowMatrix: { value: [] },\n\n\t\t\tpointLights: { value: [], properties: {\n\t\t\t\tcolor: {},\n\t\t\t\tposition: {},\n\t\t\t\tdecay: {},\n\t\t\t\tdistance: {},\n\n\t\t\t\tshadow: {},\n\t\t\t\tshadowBias: {},\n\t\t\t\tshadowRadius: {},\n\t\t\t\tshadowMapSize: {},\n\t\t\t\tshadowCameraNear: {},\n\t\t\t\tshadowCameraFar: {}\n\t\t\t} },\n\n\t\t\tpointShadowMap: { value: [] },\n\t\t\tpointShadowMatrix: { value: [] },\n\n\t\t\themisphereLights: { value: [], properties: {\n\t\t\t\tdirection: {},\n\t\t\t\tskyColor: {},\n\t\t\t\tgroundColor: {}\n\t\t\t} },\n\n\t\t\t// TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src\n\t\t\trectAreaLights: { value: [], properties: {\n\t\t\t\tcolor: {},\n\t\t\t\tposition: {},\n\t\t\t\twidth: {},\n\t\t\t\theight: {}\n\t\t\t} }\n\n\t\t},\n\n\t\tpoints: {\n\n\t\t\tdiffuse: { value: new Color( 0xeeeeee ) },\n\t\t\topacity: { value: 1.0 },\n\t\t\tsize: { value: 1.0 },\n\t\t\tscale: { value: 1.0 },\n\t\t\tmap: { value: null },\n\t\t\tuvTransform: { value: new Matrix3() }\n\n\t\t},\n\n\t\tsprite: {\n\n\t\t\tdiffuse: { value: new Color( 0xeeeeee ) },\n\t\t\topacity: { value: 1.0 },\n\t\t\tcenter: { value: new Vector2( 0.5, 0.5 ) },\n\t\t\trotation: { value: 0.0 },\n\t\t\tmap: { value: null },\n\t\t\tuvTransform: { value: new Matrix3() }\n\n\t\t}\n\n\t};\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author mikael emtinger / http://gomo.se/\n\t */\n\n\tvar ShaderLib = {\n\n\t\tbasic: {\n\n\t\t\tuniforms: mergeUniforms( [\n\t\t\t\tUniformsLib.common,\n\t\t\t\tUniformsLib.specularmap,\n\t\t\t\tUniformsLib.envmap,\n\t\t\t\tUniformsLib.aomap,\n\t\t\t\tUniformsLib.lightmap,\n\t\t\t\tUniformsLib.fog\n\t\t\t] ),\n\n\t\t\tvertexShader: ShaderChunk.meshbasic_vert,\n\t\t\tfragmentShader: ShaderChunk.meshbasic_frag\n\n\t\t},\n\n\t\tlambert: {\n\n\t\t\tuniforms: mergeUniforms( [\n\t\t\t\tUniformsLib.common,\n\t\t\t\tUniformsLib.specularmap,\n\t\t\t\tUniformsLib.envmap,\n\t\t\t\tUniformsLib.aomap,\n\t\t\t\tUniformsLib.lightmap,\n\t\t\t\tUniformsLib.emissivemap,\n\t\t\t\tUniformsLib.fog,\n\t\t\t\tUniformsLib.lights,\n\t\t\t\t{\n\t\t\t\t\temissive: { value: new Color( 0x000000 ) }\n\t\t\t\t}\n\t\t\t] ),\n\n\t\t\tvertexShader: ShaderChunk.meshlambert_vert,\n\t\t\tfragmentShader: ShaderChunk.meshlambert_frag\n\n\t\t},\n\n\t\tphong: {\n\n\t\t\tuniforms: mergeUniforms( [\n\t\t\t\tUniformsLib.common,\n\t\t\t\tUniformsLib.specularmap,\n\t\t\t\tUniformsLib.envmap,\n\t\t\t\tUniformsLib.aomap,\n\t\t\t\tUniformsLib.lightmap,\n\t\t\t\tUniformsLib.emissivemap,\n\t\t\t\tUniformsLib.bumpmap,\n\t\t\t\tUniformsLib.normalmap,\n\t\t\t\tUniformsLib.displacementmap,\n\t\t\t\tUniformsLib.gradientmap,\n\t\t\t\tUniformsLib.fog,\n\t\t\t\tUniformsLib.lights,\n\t\t\t\t{\n\t\t\t\t\temissive: { value: new Color( 0x000000 ) },\n\t\t\t\t\tspecular: { value: new Color( 0x111111 ) },\n\t\t\t\t\tshininess: { value: 30 }\n\t\t\t\t}\n\t\t\t] ),\n\n\t\t\tvertexShader: ShaderChunk.meshphong_vert,\n\t\t\tfragmentShader: ShaderChunk.meshphong_frag\n\n\t\t},\n\n\t\tstandard: {\n\n\t\t\tuniforms: mergeUniforms( [\n\t\t\t\tUniformsLib.common,\n\t\t\t\tUniformsLib.envmap,\n\t\t\t\tUniformsLib.aomap,\n\t\t\t\tUniformsLib.lightmap,\n\t\t\t\tUniformsLib.emissivemap,\n\t\t\t\tUniformsLib.bumpmap,\n\t\t\t\tUniformsLib.normalmap,\n\t\t\t\tUniformsLib.displacementmap,\n\t\t\t\tUniformsLib.roughnessmap,\n\t\t\t\tUniformsLib.metalnessmap,\n\t\t\t\tUniformsLib.fog,\n\t\t\t\tUniformsLib.lights,\n\t\t\t\t{\n\t\t\t\t\temissive: { value: new Color( 0x000000 ) },\n\t\t\t\t\troughness: { value: 0.5 },\n\t\t\t\t\tmetalness: { value: 0.5 },\n\t\t\t\t\tenvMapIntensity: { value: 1 } // temporary\n\t\t\t\t}\n\t\t\t] ),\n\n\t\t\tvertexShader: ShaderChunk.meshphysical_vert,\n\t\t\tfragmentShader: ShaderChunk.meshphysical_frag\n\n\t\t},\n\n\t\tmatcap: {\n\n\t\t\tuniforms: mergeUniforms( [\n\t\t\t\tUniformsLib.common,\n\t\t\t\tUniformsLib.bumpmap,\n\t\t\t\tUniformsLib.normalmap,\n\t\t\t\tUniformsLib.displacementmap,\n\t\t\t\tUniformsLib.fog,\n\t\t\t\t{\n\t\t\t\t\tmatcap: { value: null }\n\t\t\t\t}\n\t\t\t] ),\n\n\t\t\tvertexShader: ShaderChunk.meshmatcap_vert,\n\t\t\tfragmentShader: ShaderChunk.meshmatcap_frag\n\n\t\t},\n\n\t\tpoints: {\n\n\t\t\tuniforms: mergeUniforms( [\n\t\t\t\tUniformsLib.points,\n\t\t\t\tUniformsLib.fog\n\t\t\t] ),\n\n\t\t\tvertexShader: ShaderChunk.points_vert,\n\t\t\tfragmentShader: ShaderChunk.points_frag\n\n\t\t},\n\n\t\tdashed: {\n\n\t\t\tuniforms: mergeUniforms( [\n\t\t\t\tUniformsLib.common,\n\t\t\t\tUniformsLib.fog,\n\t\t\t\t{\n\t\t\t\t\tscale: { value: 1 },\n\t\t\t\t\tdashSize: { value: 1 },\n\t\t\t\t\ttotalSize: { value: 2 }\n\t\t\t\t}\n\t\t\t] ),\n\n\t\t\tvertexShader: ShaderChunk.linedashed_vert,\n\t\t\tfragmentShader: ShaderChunk.linedashed_frag\n\n\t\t},\n\n\t\tdepth: {\n\n\t\t\tuniforms: mergeUniforms( [\n\t\t\t\tUniformsLib.common,\n\t\t\t\tUniformsLib.displacementmap\n\t\t\t] ),\n\n\t\t\tvertexShader: ShaderChunk.depth_vert,\n\t\t\tfragmentShader: ShaderChunk.depth_frag\n\n\t\t},\n\n\t\tnormal: {\n\n\t\t\tuniforms: mergeUniforms( [\n\t\t\t\tUniformsLib.common,\n\t\t\t\tUniformsLib.bumpmap,\n\t\t\t\tUniformsLib.normalmap,\n\t\t\t\tUniformsLib.displacementmap,\n\t\t\t\t{\n\t\t\t\t\topacity: { value: 1.0 }\n\t\t\t\t}\n\t\t\t] ),\n\n\t\t\tvertexShader: ShaderChunk.normal_vert,\n\t\t\tfragmentShader: ShaderChunk.normal_frag\n\n\t\t},\n\n\t\tsprite: {\n\n\t\t\tuniforms: mergeUniforms( [\n\t\t\t\tUniformsLib.sprite,\n\t\t\t\tUniformsLib.fog\n\t\t\t] ),\n\n\t\t\tvertexShader: ShaderChunk.sprite_vert,\n\t\t\tfragmentShader: ShaderChunk.sprite_frag\n\n\t\t},\n\n\t\tbackground: {\n\n\t\t\tuniforms: {\n\t\t\t\tuvTransform: { value: new Matrix3() },\n\t\t\t\tt2D: { value: null },\n\t\t\t},\n\n\t\t\tvertexShader: ShaderChunk.background_vert,\n\t\t\tfragmentShader: ShaderChunk.background_frag\n\n\t\t},\n\t\t/* -------------------------------------------------------------------------\n\t\t//\tCube map shader\n\t\t ------------------------------------------------------------------------- */\n\n\t\tcube: {\n\n\t\t\tuniforms: {\n\t\t\t\ttCube: { value: null },\n\t\t\t\ttFlip: { value: - 1 },\n\t\t\t\topacity: { value: 1.0 }\n\t\t\t},\n\n\t\t\tvertexShader: ShaderChunk.cube_vert,\n\t\t\tfragmentShader: ShaderChunk.cube_frag\n\n\t\t},\n\n\t\tequirect: {\n\n\t\t\tuniforms: {\n\t\t\t\ttEquirect: { value: null },\n\t\t\t},\n\n\t\t\tvertexShader: ShaderChunk.equirect_vert,\n\t\t\tfragmentShader: ShaderChunk.equirect_frag\n\n\t\t},\n\n\t\tdistanceRGBA: {\n\n\t\t\tuniforms: mergeUniforms( [\n\t\t\t\tUniformsLib.common,\n\t\t\t\tUniformsLib.displacementmap,\n\t\t\t\t{\n\t\t\t\t\treferencePosition: { value: new Vector3() },\n\t\t\t\t\tnearDistance: { value: 1 },\n\t\t\t\t\tfarDistance: { value: 1000 }\n\t\t\t\t}\n\t\t\t] ),\n\n\t\t\tvertexShader: ShaderChunk.distanceRGBA_vert,\n\t\t\tfragmentShader: ShaderChunk.distanceRGBA_frag\n\n\t\t},\n\n\t\tshadow: {\n\n\t\t\tuniforms: mergeUniforms( [\n\t\t\t\tUniformsLib.lights,\n\t\t\t\tUniformsLib.fog,\n\t\t\t\t{\n\t\t\t\t\tcolor: { value: new Color( 0x00000 ) },\n\t\t\t\t\topacity: { value: 1.0 }\n\t\t\t\t},\n\t\t\t] ),\n\n\t\t\tvertexShader: ShaderChunk.shadow_vert,\n\t\t\tfragmentShader: ShaderChunk.shadow_frag\n\n\t\t}\n\n\t};\n\n\tShaderLib.physical = {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tShaderLib.standard.uniforms,\n\t\t\t{\n\t\t\t\tclearCoat: { value: 0 },\n\t\t\t\tclearCoatRoughness: { value: 0 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshphysical_vert,\n\t\tfragmentShader: ShaderChunk.meshphysical_frag\n\n\t};\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction WebGLAnimation() {\n\n\t\tvar context = null;\n\t\tvar isAnimating = false;\n\t\tvar animationLoop = null;\n\n\t\tfunction onAnimationFrame( time, frame ) {\n\n\t\t\tif ( isAnimating === false ) return;\n\n\t\t\tanimationLoop( time, frame );\n\n\t\t\tcontext.requestAnimationFrame( onAnimationFrame );\n\n\t\t}\n\n\t\treturn {\n\n\t\t\tstart: function () {\n\n\t\t\t\tif ( isAnimating === true ) return;\n\t\t\t\tif ( animationLoop === null ) return;\n\n\t\t\t\tcontext.requestAnimationFrame( onAnimationFrame );\n\n\t\t\t\tisAnimating = true;\n\n\t\t\t},\n\n\t\t\tstop: function () {\n\n\t\t\t\tisAnimating = false;\n\n\t\t\t},\n\n\t\t\tsetAnimationLoop: function ( callback ) {\n\n\t\t\t\tanimationLoop = callback;\n\n\t\t\t},\n\n\t\t\tsetContext: function ( value ) {\n\n\t\t\t\tcontext = value;\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction WebGLAttributes( gl ) {\n\n\t\tvar buffers = new WeakMap();\n\n\t\tfunction createBuffer( attribute, bufferType ) {\n\n\t\t\tvar array = attribute.array;\n\t\t\tvar usage = attribute.dynamic ? 35048 : 35044;\n\n\t\t\tvar buffer = gl.createBuffer();\n\n\t\t\tgl.bindBuffer( bufferType, buffer );\n\t\t\tgl.bufferData( bufferType, array, usage );\n\n\t\t\tattribute.onUploadCallback();\n\n\t\t\tvar type = 5126;\n\n\t\t\tif ( array instanceof Float32Array ) {\n\n\t\t\t\ttype = 5126;\n\n\t\t\t} else if ( array instanceof Float64Array ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.' );\n\n\t\t\t} else if ( array instanceof Uint16Array ) {\n\n\t\t\t\ttype = 5123;\n\n\t\t\t} else if ( array instanceof Int16Array ) {\n\n\t\t\t\ttype = 5122;\n\n\t\t\t} else if ( array instanceof Uint32Array ) {\n\n\t\t\t\ttype = 5125;\n\n\t\t\t} else if ( array instanceof Int32Array ) {\n\n\t\t\t\ttype = 5124;\n\n\t\t\t} else if ( array instanceof Int8Array ) {\n\n\t\t\t\ttype = 5120;\n\n\t\t\t} else if ( array instanceof Uint8Array ) {\n\n\t\t\t\ttype = 5121;\n\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tbuffer: buffer,\n\t\t\t\ttype: type,\n\t\t\t\tbytesPerElement: array.BYTES_PER_ELEMENT,\n\t\t\t\tversion: attribute.version\n\t\t\t};\n\n\t\t}\n\n\t\tfunction updateBuffer( buffer, attribute, bufferType ) {\n\n\t\t\tvar array = attribute.array;\n\t\t\tvar updateRange = attribute.updateRange;\n\n\t\t\tgl.bindBuffer( bufferType, buffer );\n\n\t\t\tif ( attribute.dynamic === false ) {\n\n\t\t\t\tgl.bufferData( bufferType, array, 35044 );\n\n\t\t\t} else if ( updateRange.count === - 1 ) {\n\n\t\t\t\t// Not using update ranges\n\n\t\t\t\tgl.bufferSubData( bufferType, 0, array );\n\n\t\t\t} else if ( updateRange.count === 0 ) {\n\n\t\t\t\tconsole.error( 'THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually.' );\n\n\t\t\t} else {\n\n\t\t\t\tgl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,\n\t\t\t\t\tarray.subarray( updateRange.offset, updateRange.offset + updateRange.count ) );\n\n\t\t\t\tupdateRange.count = - 1; // reset range\n\n\t\t\t}\n\n\t\t}\n\n\t\t//\n\n\t\tfunction get( attribute ) {\n\n\t\t\tif ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;\n\n\t\t\treturn buffers.get( attribute );\n\n\t\t}\n\n\t\tfunction remove( attribute ) {\n\n\t\t\tif ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;\n\n\t\t\tvar data = buffers.get( attribute );\n\n\t\t\tif ( data ) {\n\n\t\t\t\tgl.deleteBuffer( data.buffer );\n\n\t\t\t\tbuffers.delete( attribute );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction update( attribute, bufferType ) {\n\n\t\t\tif ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;\n\n\t\t\tvar data = buffers.get( attribute );\n\n\t\t\tif ( data === undefined ) {\n\n\t\t\t\tbuffers.set( attribute, createBuffer( attribute, bufferType ) );\n\n\t\t\t} else if ( data.version < attribute.version ) {\n\n\t\t\t\tupdateBuffer( data.buffer, attribute, bufferType );\n\n\t\t\t\tdata.version = attribute.version;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn {\n\n\t\t\tget: get,\n\t\t\tremove: remove,\n\t\t\tupdate: update\n\n\t\t};\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author alteredq / http://alteredqualia.com/\n\t */\n\n\tfunction Face3( a, b, c, normal, color, materialIndex ) {\n\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t\tthis.c = c;\n\n\t\tthis.normal = ( normal && normal.isVector3 ) ? normal : new Vector3();\n\t\tthis.vertexNormals = Array.isArray( normal ) ? normal : [];\n\n\t\tthis.color = ( color && color.isColor ) ? color : new Color();\n\t\tthis.vertexColors = Array.isArray( color ) ? color : [];\n\n\t\tthis.materialIndex = materialIndex !== undefined ? materialIndex : 0;\n\n\t}\n\n\tObject.assign( Face3.prototype, {\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t},\n\n\t\tcopy: function ( source ) {\n\n\t\t\tthis.a = source.a;\n\t\t\tthis.b = source.b;\n\t\t\tthis.c = source.c;\n\n\t\t\tthis.normal.copy( source.normal );\n\t\t\tthis.color.copy( source.color );\n\n\t\t\tthis.materialIndex = source.materialIndex;\n\n\t\t\tfor ( var i = 0, il = source.vertexNormals.length; i < il; i ++ ) {\n\n\t\t\t\tthis.vertexNormals[ i ] = source.vertexNormals[ i ].clone();\n\n\t\t\t}\n\n\t\t\tfor ( var i = 0, il = source.vertexColors.length; i < il; i ++ ) {\n\n\t\t\t\tthis.vertexColors[ i ] = source.vertexColors[ i ].clone();\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author WestLangley / http://github.com/WestLangley\n\t * @author bhouston / http://clara.io\n\t */\n\n\tfunction Euler( x, y, z, order ) {\n\n\t\tthis._x = x || 0;\n\t\tthis._y = y || 0;\n\t\tthis._z = z || 0;\n\t\tthis._order = order || Euler.DefaultOrder;\n\n\t}\n\n\tEuler.RotationOrders = [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ];\n\n\tEuler.DefaultOrder = 'XYZ';\n\n\tObject.defineProperties( Euler.prototype, {\n\n\t\tx: {\n\n\t\t\tget: function () {\n\n\t\t\t\treturn this._x;\n\n\t\t\t},\n\n\t\t\tset: function ( value ) {\n\n\t\t\t\tthis._x = value;\n\t\t\t\tthis.onChangeCallback();\n\n\t\t\t}\n\n\t\t},\n\n\t\ty: {\n\n\t\t\tget: function () {\n\n\t\t\t\treturn this._y;\n\n\t\t\t},\n\n\t\t\tset: function ( value ) {\n\n\t\t\t\tthis._y = value;\n\t\t\t\tthis.onChangeCallback();\n\n\t\t\t}\n\n\t\t},\n\n\t\tz: {\n\n\t\t\tget: function () {\n\n\t\t\t\treturn this._z;\n\n\t\t\t},\n\n\t\t\tset: function ( value ) {\n\n\t\t\t\tthis._z = value;\n\t\t\t\tthis.onChangeCallback();\n\n\t\t\t}\n\n\t\t},\n\n\t\torder: {\n\n\t\t\tget: function () {\n\n\t\t\t\treturn this._order;\n\n\t\t\t},\n\n\t\t\tset: function ( value ) {\n\n\t\t\t\tthis._order = value;\n\t\t\t\tthis.onChangeCallback();\n\n\t\t\t}\n\n\t\t}\n\n\t} );\n\n\tObject.assign( Euler.prototype, {\n\n\t\tisEuler: true,\n\n\t\tset: function ( x, y, z, order ) {\n\n\t\t\tthis._x = x;\n\t\t\tthis._y = y;\n\t\t\tthis._z = z;\n\t\t\tthis._order = order || this._order;\n\n\t\t\tthis.onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor( this._x, this._y, this._z, this._order );\n\n\t\t},\n\n\t\tcopy: function ( euler ) {\n\n\t\t\tthis._x = euler._x;\n\t\t\tthis._y = euler._y;\n\t\t\tthis._z = euler._z;\n\t\t\tthis._order = euler._order;\n\n\t\t\tthis.onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromRotationMatrix: function ( m, order, update ) {\n\n\t\t\tvar clamp = _Math.clamp;\n\n\t\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\t\tvar te = m.elements;\n\t\t\tvar m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ];\n\t\t\tvar m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ];\n\t\t\tvar m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];\n\n\t\t\torder = order || this._order;\n\n\t\t\tif ( order === 'XYZ' ) {\n\n\t\t\t\tthis._y = Math.asin( clamp( m13, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m13 ) < 0.99999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( - m23, m33 );\n\t\t\t\t\tthis._z = Math.atan2( - m12, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = Math.atan2( m32, m22 );\n\t\t\t\t\tthis._z = 0;\n\n\t\t\t\t}\n\n\t\t\t} else if ( order === 'YXZ' ) {\n\n\t\t\t\tthis._x = Math.asin( - clamp( m23, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m23 ) < 0.99999 ) {\n\n\t\t\t\t\tthis._y = Math.atan2( m13, m33 );\n\t\t\t\t\tthis._z = Math.atan2( m21, m22 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._y = Math.atan2( - m31, m11 );\n\t\t\t\t\tthis._z = 0;\n\n\t\t\t\t}\n\n\t\t\t} else if ( order === 'ZXY' ) {\n\n\t\t\t\tthis._x = Math.asin( clamp( m32, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m32 ) < 0.99999 ) {\n\n\t\t\t\t\tthis._y = Math.atan2( - m31, m33 );\n\t\t\t\t\tthis._z = Math.atan2( - m12, m22 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._y = 0;\n\t\t\t\t\tthis._z = Math.atan2( m21, m11 );\n\n\t\t\t\t}\n\n\t\t\t} else if ( order === 'ZYX' ) {\n\n\t\t\t\tthis._y = Math.asin( - clamp( m31, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m31 ) < 0.99999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( m32, m33 );\n\t\t\t\t\tthis._z = Math.atan2( m21, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = 0;\n\t\t\t\t\tthis._z = Math.atan2( - m12, m22 );\n\n\t\t\t\t}\n\n\t\t\t} else if ( order === 'YZX' ) {\n\n\t\t\t\tthis._z = Math.asin( clamp( m21, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m21 ) < 0.99999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( - m23, m22 );\n\t\t\t\t\tthis._y = Math.atan2( - m31, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = 0;\n\t\t\t\t\tthis._y = Math.atan2( m13, m33 );\n\n\t\t\t\t}\n\n\t\t\t} else if ( order === 'XZY' ) {\n\n\t\t\t\tthis._z = Math.asin( - clamp( m12, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m12 ) < 0.99999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( m32, m22 );\n\t\t\t\t\tthis._y = Math.atan2( m13, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = Math.atan2( - m23, m33 );\n\t\t\t\t\tthis._y = 0;\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tconsole.warn( 'THREE.Euler: .setFromRotationMatrix() given unsupported order: ' + order );\n\n\t\t\t}\n\n\t\t\tthis._order = order;\n\n\t\t\tif ( update !== false ) this.onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromQuaternion: function () {\n\n\t\t\tvar matrix = new Matrix4();\n\n\t\t\treturn function setFromQuaternion( q, order, update ) {\n\n\t\t\t\tmatrix.makeRotationFromQuaternion( q );\n\n\t\t\t\treturn this.setFromRotationMatrix( matrix, order, update );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tsetFromVector3: function ( v, order ) {\n\n\t\t\treturn this.set( v.x, v.y, v.z, order || this._order );\n\n\t\t},\n\n\t\treorder: function () {\n\n\t\t\t// WARNING: this discards revolution information -bhouston\n\n\t\t\tvar q = new Quaternion();\n\n\t\t\treturn function reorder( newOrder ) {\n\n\t\t\t\tq.setFromEuler( this );\n\n\t\t\t\treturn this.setFromQuaternion( q, newOrder );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tequals: function ( euler ) {\n\n\t\t\treturn ( euler._x === this._x ) && ( euler._y === this._y ) && ( euler._z === this._z ) && ( euler._order === this._order );\n\n\t\t},\n\n\t\tfromArray: function ( array ) {\n\n\t\t\tthis._x = array[ 0 ];\n\t\t\tthis._y = array[ 1 ];\n\t\t\tthis._z = array[ 2 ];\n\t\t\tif ( array[ 3 ] !== undefined ) this._order = array[ 3 ];\n\n\t\t\tthis.onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttoArray: function ( array, offset ) {\n\n\t\t\tif ( array === undefined ) array = [];\n\t\t\tif ( offset === undefined ) offset = 0;\n\n\t\t\tarray[ offset ] = this._x;\n\t\t\tarray[ offset + 1 ] = this._y;\n\t\t\tarray[ offset + 2 ] = this._z;\n\t\t\tarray[ offset + 3 ] = this._order;\n\n\t\t\treturn array;\n\n\t\t},\n\n\t\ttoVector3: function ( optionalResult ) {\n\n\t\t\tif ( optionalResult ) {\n\n\t\t\t\treturn optionalResult.set( this._x, this._y, this._z );\n\n\t\t\t} else {\n\n\t\t\t\treturn new Vector3( this._x, this._y, this._z );\n\n\t\t\t}\n\n\t\t},\n\n\t\tonChange: function ( callback ) {\n\n\t\t\tthis.onChangeCallback = callback;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tonChangeCallback: function () {}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction Layers() {\n\n\t\tthis.mask = 1 | 0;\n\n\t}\n\n\tObject.assign( Layers.prototype, {\n\n\t\tset: function ( channel ) {\n\n\t\t\tthis.mask = 1 << channel | 0;\n\n\t\t},\n\n\t\tenable: function ( channel ) {\n\n\t\t\tthis.mask |= 1 << channel | 0;\n\n\t\t},\n\n\t\ttoggle: function ( channel ) {\n\n\t\t\tthis.mask ^= 1 << channel | 0;\n\n\t\t},\n\n\t\tdisable: function ( channel ) {\n\n\t\t\tthis.mask &= ~ ( 1 << channel | 0 );\n\n\t\t},\n\n\t\ttest: function ( layers ) {\n\n\t\t\treturn ( this.mask & layers.mask ) !== 0;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author mikael emtinger / http://gomo.se/\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author WestLangley / http://github.com/WestLangley\n\t * @author elephantatwork / www.elephantatwork.ch\n\t */\n\n\tvar object3DId = 0;\n\n\tfunction Object3D() {\n\n\t\tObject.defineProperty( this, 'id', { value: object3DId ++ } );\n\n\t\tthis.uuid = _Math.generateUUID();\n\n\t\tthis.name = '';\n\t\tthis.type = 'Object3D';\n\n\t\tthis.parent = null;\n\t\tthis.children = [];\n\n\t\tthis.up = Object3D.DefaultUp.clone();\n\n\t\tvar position = new Vector3();\n\t\tvar rotation = new Euler();\n\t\tvar quaternion = new Quaternion();\n\t\tvar scale = new Vector3( 1, 1, 1 );\n\n\t\tfunction onRotationChange() {\n\n\t\t\tquaternion.setFromEuler( rotation, false );\n\n\t\t}\n\n\t\tfunction onQuaternionChange() {\n\n\t\t\trotation.setFromQuaternion( quaternion, undefined, false );\n\n\t\t}\n\n\t\trotation.onChange( onRotationChange );\n\t\tquaternion.onChange( onQuaternionChange );\n\n\t\tObject.defineProperties( this, {\n\t\t\tposition: {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tvalue: position\n\t\t\t},\n\t\t\trotation: {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tvalue: rotation\n\t\t\t},\n\t\t\tquaternion: {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tvalue: quaternion\n\t\t\t},\n\t\t\tscale: {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tvalue: scale\n\t\t\t},\n\t\t\tmodelViewMatrix: {\n\t\t\t\tvalue: new Matrix4()\n\t\t\t},\n\t\t\tnormalMatrix: {\n\t\t\t\tvalue: new Matrix3()\n\t\t\t}\n\t\t} );\n\n\t\tthis.matrix = new Matrix4();\n\t\tthis.matrixWorld = new Matrix4();\n\n\t\tthis.matrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate;\n\t\tthis.matrixWorldNeedsUpdate = false;\n\n\t\tthis.layers = new Layers();\n\t\tthis.visible = true;\n\n\t\tthis.castShadow = false;\n\t\tthis.receiveShadow = false;\n\n\t\tthis.frustumCulled = true;\n\t\tthis.renderOrder = 0;\n\n\t\tthis.userData = {};\n\n\t}\n\n\tObject3D.DefaultUp = new Vector3( 0, 1, 0 );\n\tObject3D.DefaultMatrixAutoUpdate = true;\n\n\tObject3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\t\tconstructor: Object3D,\n\n\t\tisObject3D: true,\n\n\t\tonBeforeRender: function () {},\n\t\tonAfterRender: function () {},\n\n\t\tapplyMatrix: function ( matrix ) {\n\n\t\t\tthis.matrix.multiplyMatrices( matrix, this.matrix );\n\n\t\t\tthis.matrix.decompose( this.position, this.quaternion, this.scale );\n\n\t\t},\n\n\t\tapplyQuaternion: function ( q ) {\n\n\t\t\tthis.quaternion.premultiply( q );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetRotationFromAxisAngle: function ( axis, angle ) {\n\n\t\t\t// assumes axis is normalized\n\n\t\t\tthis.quaternion.setFromAxisAngle( axis, angle );\n\n\t\t},\n\n\t\tsetRotationFromEuler: function ( euler ) {\n\n\t\t\tthis.quaternion.setFromEuler( euler, true );\n\n\t\t},\n\n\t\tsetRotationFromMatrix: function ( m ) {\n\n\t\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\t\tthis.quaternion.setFromRotationMatrix( m );\n\n\t\t},\n\n\t\tsetRotationFromQuaternion: function ( q ) {\n\n\t\t\t// assumes q is normalized\n\n\t\t\tthis.quaternion.copy( q );\n\n\t\t},\n\n\t\trotateOnAxis: function () {\n\n\t\t\t// rotate object on axis in object space\n\t\t\t// axis is assumed to be normalized\n\n\t\t\tvar q1 = new Quaternion();\n\n\t\t\treturn function rotateOnAxis( axis, angle ) {\n\n\t\t\t\tq1.setFromAxisAngle( axis, angle );\n\n\t\t\t\tthis.quaternion.multiply( q1 );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\trotateOnWorldAxis: function () {\n\n\t\t\t// rotate object on axis in world space\n\t\t\t// axis is assumed to be normalized\n\t\t\t// method assumes no rotated parent\n\n\t\t\tvar q1 = new Quaternion();\n\n\t\t\treturn function rotateOnWorldAxis( axis, angle ) {\n\n\t\t\t\tq1.setFromAxisAngle( axis, angle );\n\n\t\t\t\tthis.quaternion.premultiply( q1 );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\trotateX: function () {\n\n\t\t\tvar v1 = new Vector3( 1, 0, 0 );\n\n\t\t\treturn function rotateX( angle ) {\n\n\t\t\t\treturn this.rotateOnAxis( v1, angle );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\trotateY: function () {\n\n\t\t\tvar v1 = new Vector3( 0, 1, 0 );\n\n\t\t\treturn function rotateY( angle ) {\n\n\t\t\t\treturn this.rotateOnAxis( v1, angle );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\trotateZ: function () {\n\n\t\t\tvar v1 = new Vector3( 0, 0, 1 );\n\n\t\t\treturn function rotateZ( angle ) {\n\n\t\t\t\treturn this.rotateOnAxis( v1, angle );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\ttranslateOnAxis: function () {\n\n\t\t\t// translate object by distance along axis in object space\n\t\t\t// axis is assumed to be normalized\n\n\t\t\tvar v1 = new Vector3();\n\n\t\t\treturn function translateOnAxis( axis, distance ) {\n\n\t\t\t\tv1.copy( axis ).applyQuaternion( this.quaternion );\n\n\t\t\t\tthis.position.add( v1.multiplyScalar( distance ) );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\ttranslateX: function () {\n\n\t\t\tvar v1 = new Vector3( 1, 0, 0 );\n\n\t\t\treturn function translateX( distance ) {\n\n\t\t\t\treturn this.translateOnAxis( v1, distance );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\ttranslateY: function () {\n\n\t\t\tvar v1 = new Vector3( 0, 1, 0 );\n\n\t\t\treturn function translateY( distance ) {\n\n\t\t\t\treturn this.translateOnAxis( v1, distance );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\ttranslateZ: function () {\n\n\t\t\tvar v1 = new Vector3( 0, 0, 1 );\n\n\t\t\treturn function translateZ( distance ) {\n\n\t\t\t\treturn this.translateOnAxis( v1, distance );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tlocalToWorld: function ( vector ) {\n\n\t\t\treturn vector.applyMatrix4( this.matrixWorld );\n\n\t\t},\n\n\t\tworldToLocal: function () {\n\n\t\t\tvar m1 = new Matrix4();\n\n\t\t\treturn function worldToLocal( vector ) {\n\n\t\t\t\treturn vector.applyMatrix4( m1.getInverse( this.matrixWorld ) );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tlookAt: function () {\n\n\t\t\t// This method does not support objects having non-uniformly-scaled parent(s)\n\n\t\t\tvar q1 = new Quaternion();\n\t\t\tvar m1 = new Matrix4();\n\t\t\tvar target = new Vector3();\n\t\t\tvar position = new Vector3();\n\n\t\t\treturn function lookAt( x, y, z ) {\n\n\t\t\t\tif ( x.isVector3 ) {\n\n\t\t\t\t\ttarget.copy( x );\n\n\t\t\t\t} else {\n\n\t\t\t\t\ttarget.set( x, y, z );\n\n\t\t\t\t}\n\n\t\t\t\tvar parent = this.parent;\n\n\t\t\t\tthis.updateWorldMatrix( true, false );\n\n\t\t\t\tposition.setFromMatrixPosition( this.matrixWorld );\n\n\t\t\t\tif ( this.isCamera || this.isLight ) {\n\n\t\t\t\t\tm1.lookAt( position, target, this.up );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tm1.lookAt( target, position, this.up );\n\n\t\t\t\t}\n\n\t\t\t\tthis.quaternion.setFromRotationMatrix( m1 );\n\n\t\t\t\tif ( parent ) {\n\n\t\t\t\t\tm1.extractRotation( parent.matrixWorld );\n\t\t\t\t\tq1.setFromRotationMatrix( m1 );\n\t\t\t\t\tthis.quaternion.premultiply( q1.inverse() );\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tadd: function ( object ) {\n\n\t\t\tif ( arguments.length > 1 ) {\n\n\t\t\t\tfor ( var i = 0; i < arguments.length; i ++ ) {\n\n\t\t\t\t\tthis.add( arguments[ i ] );\n\n\t\t\t\t}\n\n\t\t\t\treturn this;\n\n\t\t\t}\n\n\t\t\tif ( object === this ) {\n\n\t\t\t\tconsole.error( \"THREE.Object3D.add: object can't be added as a child of itself.\", object );\n\t\t\t\treturn this;\n\n\t\t\t}\n\n\t\t\tif ( ( object && object.isObject3D ) ) {\n\n\t\t\t\tif ( object.parent !== null ) {\n\n\t\t\t\t\tobject.parent.remove( object );\n\n\t\t\t\t}\n\n\t\t\t\tobject.parent = this;\n\t\t\t\tobject.dispatchEvent( { type: 'added' } );\n\n\t\t\t\tthis.children.push( object );\n\n\t\t\t} else {\n\n\t\t\t\tconsole.error( \"THREE.Object3D.add: object not an instance of THREE.Object3D.\", object );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tremove: function ( object ) {\n\n\t\t\tif ( arguments.length > 1 ) {\n\n\t\t\t\tfor ( var i = 0; i < arguments.length; i ++ ) {\n\n\t\t\t\t\tthis.remove( arguments[ i ] );\n\n\t\t\t\t}\n\n\t\t\t\treturn this;\n\n\t\t\t}\n\n\t\t\tvar index = this.children.indexOf( object );\n\n\t\t\tif ( index !== - 1 ) {\n\n\t\t\t\tobject.parent = null;\n\n\t\t\t\tobject.dispatchEvent( { type: 'removed' } );\n\n\t\t\t\tthis.children.splice( index, 1 );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetObjectById: function ( id ) {\n\n\t\t\treturn this.getObjectByProperty( 'id', id );\n\n\t\t},\n\n\t\tgetObjectByName: function ( name ) {\n\n\t\t\treturn this.getObjectByProperty( 'name', name );\n\n\t\t},\n\n\t\tgetObjectByProperty: function ( name, value ) {\n\n\t\t\tif ( this[ name ] === value ) return this;\n\n\t\t\tfor ( var i = 0, l = this.children.length; i < l; i ++ ) {\n\n\t\t\t\tvar child = this.children[ i ];\n\t\t\t\tvar object = child.getObjectByProperty( name, value );\n\n\t\t\t\tif ( object !== undefined ) {\n\n\t\t\t\t\treturn object;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn undefined;\n\n\t\t},\n\n\t\tgetWorldPosition: function ( target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Object3D: .getWorldPosition() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\tthis.updateMatrixWorld( true );\n\n\t\t\treturn target.setFromMatrixPosition( this.matrixWorld );\n\n\t\t},\n\n\t\tgetWorldQuaternion: function () {\n\n\t\t\tvar position = new Vector3();\n\t\t\tvar scale = new Vector3();\n\n\t\t\treturn function getWorldQuaternion( target ) {\n\n\t\t\t\tif ( target === undefined ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.Object3D: .getWorldQuaternion() target is now required' );\n\t\t\t\t\ttarget = new Quaternion();\n\n\t\t\t\t}\n\n\t\t\t\tthis.updateMatrixWorld( true );\n\n\t\t\t\tthis.matrixWorld.decompose( position, target, scale );\n\n\t\t\t\treturn target;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tgetWorldScale: function () {\n\n\t\t\tvar position = new Vector3();\n\t\t\tvar quaternion = new Quaternion();\n\n\t\t\treturn function getWorldScale( target ) {\n\n\t\t\t\tif ( target === undefined ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.Object3D: .getWorldScale() target is now required' );\n\t\t\t\t\ttarget = new Vector3();\n\n\t\t\t\t}\n\n\t\t\t\tthis.updateMatrixWorld( true );\n\n\t\t\t\tthis.matrixWorld.decompose( position, quaternion, target );\n\n\t\t\t\treturn target;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tgetWorldDirection: function ( target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Object3D: .getWorldDirection() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\tthis.updateMatrixWorld( true );\n\n\t\t\tvar e = this.matrixWorld.elements;\n\n\t\t\treturn target.set( e[ 8 ], e[ 9 ], e[ 10 ] ).normalize();\n\n\t\t},\n\n\t\traycast: function () {},\n\n\t\ttraverse: function ( callback ) {\n\n\t\t\tcallback( this );\n\n\t\t\tvar children = this.children;\n\n\t\t\tfor ( var i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\t\tchildren[ i ].traverse( callback );\n\n\t\t\t}\n\n\t\t},\n\n\t\ttraverseVisible: function ( callback ) {\n\n\t\t\tif ( this.visible === false ) return;\n\n\t\t\tcallback( this );\n\n\t\t\tvar children = this.children;\n\n\t\t\tfor ( var i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\t\tchildren[ i ].traverseVisible( callback );\n\n\t\t\t}\n\n\t\t},\n\n\t\ttraverseAncestors: function ( callback ) {\n\n\t\t\tvar parent = this.parent;\n\n\t\t\tif ( parent !== null ) {\n\n\t\t\t\tcallback( parent );\n\n\t\t\t\tparent.traverseAncestors( callback );\n\n\t\t\t}\n\n\t\t},\n\n\t\tupdateMatrix: function () {\n\n\t\t\tthis.matrix.compose( this.position, this.quaternion, this.scale );\n\n\t\t\tthis.matrixWorldNeedsUpdate = true;\n\n\t\t},\n\n\t\tupdateMatrixWorld: function ( force ) {\n\n\t\t\tif ( this.matrixAutoUpdate ) this.updateMatrix();\n\n\t\t\tif ( this.matrixWorldNeedsUpdate || force ) {\n\n\t\t\t\tif ( this.parent === null ) {\n\n\t\t\t\t\tthis.matrixWorld.copy( this.matrix );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );\n\n\t\t\t\t}\n\n\t\t\t\tthis.matrixWorldNeedsUpdate = false;\n\n\t\t\t\tforce = true;\n\n\t\t\t}\n\n\t\t\t// update children\n\n\t\t\tvar children = this.children;\n\n\t\t\tfor ( var i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\t\tchildren[ i ].updateMatrixWorld( force );\n\n\t\t\t}\n\n\t\t},\n\n\t\tupdateWorldMatrix: function ( updateParents, updateChildren ) {\n\n\t\t\tvar parent = this.parent;\n\n\t\t\tif ( updateParents === true && parent !== null ) {\n\n\t\t\t\tparent.updateWorldMatrix( true, false );\n\n\t\t\t}\n\n\t\t\tif ( this.matrixAutoUpdate ) this.updateMatrix();\n\n\t\t\tif ( this.parent === null ) {\n\n\t\t\t\tthis.matrixWorld.copy( this.matrix );\n\n\t\t\t} else {\n\n\t\t\t\tthis.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );\n\n\t\t\t}\n\n\t\t\t// update children\n\n\t\t\tif ( updateChildren === true ) {\n\n\t\t\t\tvar children = this.children;\n\n\t\t\t\tfor ( var i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\t\t\tchildren[ i ].updateWorldMatrix( false, true );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t},\n\n\t\ttoJSON: function ( meta ) {\n\n\t\t\t// meta is a string when called from JSON.stringify\n\t\t\tvar isRootObject = ( meta === undefined || typeof meta === 'string' );\n\n\t\t\tvar output = {};\n\n\t\t\t// meta is a hash used to collect geometries, materials.\n\t\t\t// not providing it implies that this is the root object\n\t\t\t// being serialized.\n\t\t\tif ( isRootObject ) {\n\n\t\t\t\t// initialize meta obj\n\t\t\t\tmeta = {\n\t\t\t\t\tgeometries: {},\n\t\t\t\t\tmaterials: {},\n\t\t\t\t\ttextures: {},\n\t\t\t\t\timages: {},\n\t\t\t\t\tshapes: {}\n\t\t\t\t};\n\n\t\t\t\toutput.metadata = {\n\t\t\t\t\tversion: 4.5,\n\t\t\t\t\ttype: 'Object',\n\t\t\t\t\tgenerator: 'Object3D.toJSON'\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\t// standard Object3D serialization\n\n\t\t\tvar object = {};\n\n\t\t\tobject.uuid = this.uuid;\n\t\t\tobject.type = this.type;\n\n\t\t\tif ( this.name !== '' ) object.name = this.name;\n\t\t\tif ( this.castShadow === true ) object.castShadow = true;\n\t\t\tif ( this.receiveShadow === true ) object.receiveShadow = true;\n\t\t\tif ( this.visible === false ) object.visible = false;\n\t\t\tif ( this.frustumCulled === false ) object.frustumCulled = false;\n\t\t\tif ( this.renderOrder !== 0 ) object.renderOrder = this.renderOrder;\n\t\t\tif ( JSON.stringify( this.userData ) !== '{}' ) object.userData = this.userData;\n\n\t\t\tobject.layers = this.layers.mask;\n\t\t\tobject.matrix = this.matrix.toArray();\n\n\t\t\tif ( this.matrixAutoUpdate === false ) object.matrixAutoUpdate = false;\n\n\t\t\t//\n\n\t\t\tfunction serialize( library, element ) {\n\n\t\t\t\tif ( library[ element.uuid ] === undefined ) {\n\n\t\t\t\t\tlibrary[ element.uuid ] = element.toJSON( meta );\n\n\t\t\t\t}\n\n\t\t\t\treturn element.uuid;\n\n\t\t\t}\n\n\t\t\tif ( this.isMesh || this.isLine || this.isPoints ) {\n\n\t\t\t\tobject.geometry = serialize( meta.geometries, this.geometry );\n\n\t\t\t\tvar parameters = this.geometry.parameters;\n\n\t\t\t\tif ( parameters !== undefined && parameters.shapes !== undefined ) {\n\n\t\t\t\t\tvar shapes = parameters.shapes;\n\n\t\t\t\t\tif ( Array.isArray( shapes ) ) {\n\n\t\t\t\t\t\tfor ( var i = 0, l = shapes.length; i < l; i ++ ) {\n\n\t\t\t\t\t\t\tvar shape = shapes[ i ];\n\n\t\t\t\t\t\t\tserialize( meta.shapes, shape );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tserialize( meta.shapes, shapes );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( this.material !== undefined ) {\n\n\t\t\t\tif ( Array.isArray( this.material ) ) {\n\n\t\t\t\t\tvar uuids = [];\n\n\t\t\t\t\tfor ( var i = 0, l = this.material.length; i < l; i ++ ) {\n\n\t\t\t\t\t\tuuids.push( serialize( meta.materials, this.material[ i ] ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tobject.material = uuids;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tobject.material = serialize( meta.materials, this.material );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t//\n\n\t\t\tif ( this.children.length > 0 ) {\n\n\t\t\t\tobject.children = [];\n\n\t\t\t\tfor ( var i = 0; i < this.children.length; i ++ ) {\n\n\t\t\t\t\tobject.children.push( this.children[ i ].toJSON( meta ).object );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( isRootObject ) {\n\n\t\t\t\tvar geometries = extractFromCache( meta.geometries );\n\t\t\t\tvar materials = extractFromCache( meta.materials );\n\t\t\t\tvar textures = extractFromCache( meta.textures );\n\t\t\t\tvar images = extractFromCache( meta.images );\n\t\t\t\tvar shapes = extractFromCache( meta.shapes );\n\n\t\t\t\tif ( geometries.length > 0 ) output.geometries = geometries;\n\t\t\t\tif ( materials.length > 0 ) output.materials = materials;\n\t\t\t\tif ( textures.length > 0 ) output.textures = textures;\n\t\t\t\tif ( images.length > 0 ) output.images = images;\n\t\t\t\tif ( shapes.length > 0 ) output.shapes = shapes;\n\n\t\t\t}\n\n\t\t\toutput.object = object;\n\n\t\t\treturn output;\n\n\t\t\t// extract data from the cache hash\n\t\t\t// remove metadata on each item\n\t\t\t// and return as array\n\t\t\tfunction extractFromCache( cache ) {\n\n\t\t\t\tvar values = [];\n\t\t\t\tfor ( var key in cache ) {\n\n\t\t\t\t\tvar data = cache[ key ];\n\t\t\t\t\tdelete data.metadata;\n\t\t\t\t\tvalues.push( data );\n\n\t\t\t\t}\n\t\t\t\treturn values;\n\n\t\t\t}\n\n\t\t},\n\n\t\tclone: function ( recursive ) {\n\n\t\t\treturn new this.constructor().copy( this, recursive );\n\n\t\t},\n\n\t\tcopy: function ( source, recursive ) {\n\n\t\t\tif ( recursive === undefined ) recursive = true;\n\n\t\t\tthis.name = source.name;\n\n\t\t\tthis.up.copy( source.up );\n\n\t\t\tthis.position.copy( source.position );\n\t\t\tthis.quaternion.copy( source.quaternion );\n\t\t\tthis.scale.copy( source.scale );\n\n\t\t\tthis.matrix.copy( source.matrix );\n\t\t\tthis.matrixWorld.copy( source.matrixWorld );\n\n\t\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\t\t\tthis.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;\n\n\t\t\tthis.layers.mask = source.layers.mask;\n\t\t\tthis.visible = source.visible;\n\n\t\t\tthis.castShadow = source.castShadow;\n\t\t\tthis.receiveShadow = source.receiveShadow;\n\n\t\t\tthis.frustumCulled = source.frustumCulled;\n\t\t\tthis.renderOrder = source.renderOrder;\n\n\t\t\tthis.userData = JSON.parse( JSON.stringify( source.userData ) );\n\n\t\t\tif ( recursive === true ) {\n\n\t\t\t\tfor ( var i = 0; i < source.children.length; i ++ ) {\n\n\t\t\t\t\tvar child = source.children[ i ];\n\t\t\t\t\tthis.add( child.clone() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author kile / http://kile.stravaganza.org/\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author mikael emtinger / http://gomo.se/\n\t * @author zz85 / http://www.lab4games.net/zz85/blog\n\t * @author bhouston / http://clara.io\n\t */\n\n\tvar geometryId = 0; // Geometry uses even numbers as Id\n\n\tfunction Geometry() {\n\n\t\tObject.defineProperty( this, 'id', { value: geometryId += 2 } );\n\n\t\tthis.uuid = _Math.generateUUID();\n\n\t\tthis.name = '';\n\t\tthis.type = 'Geometry';\n\n\t\tthis.vertices = [];\n\t\tthis.colors = [];\n\t\tthis.faces = [];\n\t\tthis.faceVertexUvs = [[]];\n\n\t\tthis.morphTargets = [];\n\t\tthis.morphNormals = [];\n\n\t\tthis.skinWeights = [];\n\t\tthis.skinIndices = [];\n\n\t\tthis.lineDistances = [];\n\n\t\tthis.boundingBox = null;\n\t\tthis.boundingSphere = null;\n\n\t\t// update flags\n\n\t\tthis.elementsNeedUpdate = false;\n\t\tthis.verticesNeedUpdate = false;\n\t\tthis.uvsNeedUpdate = false;\n\t\tthis.normalsNeedUpdate = false;\n\t\tthis.colorsNeedUpdate = false;\n\t\tthis.lineDistancesNeedUpdate = false;\n\t\tthis.groupsNeedUpdate = false;\n\n\t}\n\n\tGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\t\tconstructor: Geometry,\n\n\t\tisGeometry: true,\n\n\t\tapplyMatrix: function ( matrix ) {\n\n\t\t\tvar normalMatrix = new Matrix3().getNormalMatrix( matrix );\n\n\t\t\tfor ( var i = 0, il = this.vertices.length; i < il; i ++ ) {\n\n\t\t\t\tvar vertex = this.vertices[ i ];\n\t\t\t\tvertex.applyMatrix4( matrix );\n\n\t\t\t}\n\n\t\t\tfor ( var i = 0, il = this.faces.length; i < il; i ++ ) {\n\n\t\t\t\tvar face = this.faces[ i ];\n\t\t\t\tface.normal.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t\tfor ( var j = 0, jl = face.vertexNormals.length; j < jl; j ++ ) {\n\n\t\t\t\t\tface.vertexNormals[ j ].applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( this.boundingBox !== null ) {\n\n\t\t\t\tthis.computeBoundingBox();\n\n\t\t\t}\n\n\t\t\tif ( this.boundingSphere !== null ) {\n\n\t\t\t\tthis.computeBoundingSphere();\n\n\t\t\t}\n\n\t\t\tthis.verticesNeedUpdate = true;\n\t\t\tthis.normalsNeedUpdate = true;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\trotateX: function () {\n\n\t\t\t// rotate geometry around world x-axis\n\n\t\t\tvar m1 = new Matrix4();\n\n\t\t\treturn function rotateX( angle ) {\n\n\t\t\t\tm1.makeRotationX( angle );\n\n\t\t\t\tthis.applyMatrix( m1 );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\trotateY: function () {\n\n\t\t\t// rotate geometry around world y-axis\n\n\t\t\tvar m1 = new Matrix4();\n\n\t\t\treturn function rotateY( angle ) {\n\n\t\t\t\tm1.makeRotationY( angle );\n\n\t\t\t\tthis.applyMatrix( m1 );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\trotateZ: function () {\n\n\t\t\t// rotate geometry around world z-axis\n\n\t\t\tvar m1 = new Matrix4();\n\n\t\t\treturn function rotateZ( angle ) {\n\n\t\t\t\tm1.makeRotationZ( angle );\n\n\t\t\t\tthis.applyMatrix( m1 );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\ttranslate: function () {\n\n\t\t\t// translate geometry\n\n\t\t\tvar m1 = new Matrix4();\n\n\t\t\treturn function translate( x, y, z ) {\n\n\t\t\t\tm1.makeTranslation( x, y, z );\n\n\t\t\t\tthis.applyMatrix( m1 );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tscale: function () {\n\n\t\t\t// scale geometry\n\n\t\t\tvar m1 = new Matrix4();\n\n\t\t\treturn function scale( x, y, z ) {\n\n\t\t\t\tm1.makeScale( x, y, z );\n\n\t\t\t\tthis.applyMatrix( m1 );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tlookAt: function () {\n\n\t\t\tvar obj = new Object3D();\n\n\t\t\treturn function lookAt( vector ) {\n\n\t\t\t\tobj.lookAt( vector );\n\n\t\t\t\tobj.updateMatrix();\n\n\t\t\t\tthis.applyMatrix( obj.matrix );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tfromBufferGeometry: function ( geometry ) {\n\n\t\t\tvar scope = this;\n\n\t\t\tvar indices = geometry.index !== null ? geometry.index.array : undefined;\n\t\t\tvar attributes = geometry.attributes;\n\n\t\t\tvar positions = attributes.position.array;\n\t\t\tvar normals = attributes.normal !== undefined ? attributes.normal.array : undefined;\n\t\t\tvar colors = attributes.color !== undefined ? attributes.color.array : undefined;\n\t\t\tvar uvs = attributes.uv !== undefined ? attributes.uv.array : undefined;\n\t\t\tvar uvs2 = attributes.uv2 !== undefined ? attributes.uv2.array : undefined;\n\n\t\t\tif ( uvs2 !== undefined ) this.faceVertexUvs[ 1 ] = [];\n\n\t\t\tfor ( var i = 0, j = 0; i < positions.length; i += 3, j += 2 ) {\n\n\t\t\t\tscope.vertices.push( new Vector3().fromArray( positions, i ) );\n\n\t\t\t\tif ( colors !== undefined ) {\n\n\t\t\t\t\tscope.colors.push( new Color().fromArray( colors, i ) );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tfunction addFace( a, b, c, materialIndex ) {\n\n\t\t\t\tvar vertexColors = ( colors === undefined ) ? [] : [\n\t\t\t\t\tscope.colors[ a ].clone(),\n\t\t\t\t\tscope.colors[ b ].clone(),\n\t\t\t\t\tscope.colors[ c ].clone() ];\n\n\t\t\t\tvar vertexNormals = ( normals === undefined ) ? [] : [\n\t\t\t\t\tnew Vector3().fromArray( normals, a * 3 ),\n\t\t\t\t\tnew Vector3().fromArray( normals, b * 3 ),\n\t\t\t\t\tnew Vector3().fromArray( normals, c * 3 )\n\t\t\t\t];\n\n\t\t\t\tvar face = new Face3( a, b, c, vertexNormals, vertexColors, materialIndex );\n\n\t\t\t\tscope.faces.push( face );\n\n\t\t\t\tif ( uvs !== undefined ) {\n\n\t\t\t\t\tscope.faceVertexUvs[ 0 ].push( [\n\t\t\t\t\t\tnew Vector2().fromArray( uvs, a * 2 ),\n\t\t\t\t\t\tnew Vector2().fromArray( uvs, b * 2 ),\n\t\t\t\t\t\tnew Vector2().fromArray( uvs, c * 2 )\n\t\t\t\t\t] );\n\n\t\t\t\t}\n\n\t\t\t\tif ( uvs2 !== undefined ) {\n\n\t\t\t\t\tscope.faceVertexUvs[ 1 ].push( [\n\t\t\t\t\t\tnew Vector2().fromArray( uvs2, a * 2 ),\n\t\t\t\t\t\tnew Vector2().fromArray( uvs2, b * 2 ),\n\t\t\t\t\t\tnew Vector2().fromArray( uvs2, c * 2 )\n\t\t\t\t\t] );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tvar groups = geometry.groups;\n\n\t\t\tif ( groups.length > 0 ) {\n\n\t\t\t\tfor ( var i = 0; i < groups.length; i ++ ) {\n\n\t\t\t\t\tvar group = groups[ i ];\n\n\t\t\t\t\tvar start = group.start;\n\t\t\t\t\tvar count = group.count;\n\n\t\t\t\t\tfor ( var j = start, jl = start + count; j < jl; j += 3 ) {\n\n\t\t\t\t\t\tif ( indices !== undefined ) {\n\n\t\t\t\t\t\t\taddFace( indices[ j ], indices[ j + 1 ], indices[ j + 2 ], group.materialIndex );\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\taddFace( j, j + 1, j + 2, group.materialIndex );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tif ( indices !== undefined ) {\n\n\t\t\t\t\tfor ( var i = 0; i < indices.length; i += 3 ) {\n\n\t\t\t\t\t\taddFace( indices[ i ], indices[ i + 1 ], indices[ i + 2 ] );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tfor ( var i = 0; i < positions.length / 3; i += 3 ) {\n\n\t\t\t\t\t\taddFace( i, i + 1, i + 2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.computeFaceNormals();\n\n\t\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t\t}\n\n\t\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcenter: function () {\n\n\t\t\tvar offset = new Vector3();\n\n\t\t\treturn function center() {\n\n\t\t\t\tthis.computeBoundingBox();\n\n\t\t\t\tthis.boundingBox.getCenter( offset ).negate();\n\n\t\t\t\tthis.translate( offset.x, offset.y, offset.z );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tnormalize: function () {\n\n\t\t\tthis.computeBoundingSphere();\n\n\t\t\tvar center = this.boundingSphere.center;\n\t\t\tvar radius = this.boundingSphere.radius;\n\n\t\t\tvar s = radius === 0 ? 1 : 1.0 / radius;\n\n\t\t\tvar matrix = new Matrix4();\n\t\t\tmatrix.set(\n\t\t\t\ts, 0, 0, - s * center.x,\n\t\t\t\t0, s, 0, - s * center.y,\n\t\t\t\t0, 0, s, - s * center.z,\n\t\t\t\t0, 0, 0, 1\n\t\t\t);\n\n\t\t\tthis.applyMatrix( matrix );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcomputeFaceNormals: function () {\n\n\t\t\tvar cb = new Vector3(), ab = new Vector3();\n\n\t\t\tfor ( var f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\tvar face = this.faces[ f ];\n\n\t\t\t\tvar vA = this.vertices[ face.a ];\n\t\t\t\tvar vB = this.vertices[ face.b ];\n\t\t\t\tvar vC = this.vertices[ face.c ];\n\n\t\t\t\tcb.subVectors( vC, vB );\n\t\t\t\tab.subVectors( vA, vB );\n\t\t\t\tcb.cross( ab );\n\n\t\t\t\tcb.normalize();\n\n\t\t\t\tface.normal.copy( cb );\n\n\t\t\t}\n\n\t\t},\n\n\t\tcomputeVertexNormals: function ( areaWeighted ) {\n\n\t\t\tif ( areaWeighted === undefined ) areaWeighted = true;\n\n\t\t\tvar v, vl, f, fl, face, vertices;\n\n\t\t\tvertices = new Array( this.vertices.length );\n\n\t\t\tfor ( v = 0, vl = this.vertices.length; v < vl; v ++ ) {\n\n\t\t\t\tvertices[ v ] = new Vector3();\n\n\t\t\t}\n\n\t\t\tif ( areaWeighted ) {\n\n\t\t\t\t// vertex normals weighted by triangle areas\n\t\t\t\t// http://www.iquilezles.org/www/articles/normals/normals.htm\n\n\t\t\t\tvar vA, vB, vC;\n\t\t\t\tvar cb = new Vector3(), ab = new Vector3();\n\n\t\t\t\tfor ( f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\t\tface = this.faces[ f ];\n\n\t\t\t\t\tvA = this.vertices[ face.a ];\n\t\t\t\t\tvB = this.vertices[ face.b ];\n\t\t\t\t\tvC = this.vertices[ face.c ];\n\n\t\t\t\t\tcb.subVectors( vC, vB );\n\t\t\t\t\tab.subVectors( vA, vB );\n\t\t\t\t\tcb.cross( ab );\n\n\t\t\t\t\tvertices[ face.a ].add( cb );\n\t\t\t\t\tvertices[ face.b ].add( cb );\n\t\t\t\t\tvertices[ face.c ].add( cb );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tthis.computeFaceNormals();\n\n\t\t\t\tfor ( f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\t\tface = this.faces[ f ];\n\n\t\t\t\t\tvertices[ face.a ].add( face.normal );\n\t\t\t\t\tvertices[ face.b ].add( face.normal );\n\t\t\t\t\tvertices[ face.c ].add( face.normal );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tfor ( v = 0, vl = this.vertices.length; v < vl; v ++ ) {\n\n\t\t\t\tvertices[ v ].normalize();\n\n\t\t\t}\n\n\t\t\tfor ( f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\tface = this.faces[ f ];\n\n\t\t\t\tvar vertexNormals = face.vertexNormals;\n\n\t\t\t\tif ( vertexNormals.length === 3 ) {\n\n\t\t\t\t\tvertexNormals[ 0 ].copy( vertices[ face.a ] );\n\t\t\t\t\tvertexNormals[ 1 ].copy( vertices[ face.b ] );\n\t\t\t\t\tvertexNormals[ 2 ].copy( vertices[ face.c ] );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tvertexNormals[ 0 ] = vertices[ face.a ].clone();\n\t\t\t\t\tvertexNormals[ 1 ] = vertices[ face.b ].clone();\n\t\t\t\t\tvertexNormals[ 2 ] = vertices[ face.c ].clone();\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( this.faces.length > 0 ) {\n\n\t\t\t\tthis.normalsNeedUpdate = true;\n\n\t\t\t}\n\n\t\t},\n\n\t\tcomputeFlatVertexNormals: function () {\n\n\t\t\tvar f, fl, face;\n\n\t\t\tthis.computeFaceNormals();\n\n\t\t\tfor ( f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\tface = this.faces[ f ];\n\n\t\t\t\tvar vertexNormals = face.vertexNormals;\n\n\t\t\t\tif ( vertexNormals.length === 3 ) {\n\n\t\t\t\t\tvertexNormals[ 0 ].copy( face.normal );\n\t\t\t\t\tvertexNormals[ 1 ].copy( face.normal );\n\t\t\t\t\tvertexNormals[ 2 ].copy( face.normal );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tvertexNormals[ 0 ] = face.normal.clone();\n\t\t\t\t\tvertexNormals[ 1 ] = face.normal.clone();\n\t\t\t\t\tvertexNormals[ 2 ] = face.normal.clone();\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( this.faces.length > 0 ) {\n\n\t\t\t\tthis.normalsNeedUpdate = true;\n\n\t\t\t}\n\n\t\t},\n\n\t\tcomputeMorphNormals: function () {\n\n\t\t\tvar i, il, f, fl, face;\n\n\t\t\t// save original normals\n\t\t\t// - create temp variables on first access\n\t\t\t//   otherwise just copy (for faster repeated calls)\n\n\t\t\tfor ( f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\tface = this.faces[ f ];\n\n\t\t\t\tif ( ! face.__originalFaceNormal ) {\n\n\t\t\t\t\tface.__originalFaceNormal = face.normal.clone();\n\n\t\t\t\t} else {\n\n\t\t\t\t\tface.__originalFaceNormal.copy( face.normal );\n\n\t\t\t\t}\n\n\t\t\t\tif ( ! face.__originalVertexNormals ) face.__originalVertexNormals = [];\n\n\t\t\t\tfor ( i = 0, il = face.vertexNormals.length; i < il; i ++ ) {\n\n\t\t\t\t\tif ( ! face.__originalVertexNormals[ i ] ) {\n\n\t\t\t\t\t\tface.__originalVertexNormals[ i ] = face.vertexNormals[ i ].clone();\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tface.__originalVertexNormals[ i ].copy( face.vertexNormals[ i ] );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// use temp geometry to compute face and vertex normals for each morph\n\n\t\t\tvar tmpGeo = new Geometry();\n\t\t\ttmpGeo.faces = this.faces;\n\n\t\t\tfor ( i = 0, il = this.morphTargets.length; i < il; i ++ ) {\n\n\t\t\t\t// create on first access\n\n\t\t\t\tif ( ! this.morphNormals[ i ] ) {\n\n\t\t\t\t\tthis.morphNormals[ i ] = {};\n\t\t\t\t\tthis.morphNormals[ i ].faceNormals = [];\n\t\t\t\t\tthis.morphNormals[ i ].vertexNormals = [];\n\n\t\t\t\t\tvar dstNormalsFace = this.morphNormals[ i ].faceNormals;\n\t\t\t\t\tvar dstNormalsVertex = this.morphNormals[ i ].vertexNormals;\n\n\t\t\t\t\tvar faceNormal, vertexNormals;\n\n\t\t\t\t\tfor ( f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\t\t\tfaceNormal = new Vector3();\n\t\t\t\t\t\tvertexNormals = { a: new Vector3(), b: new Vector3(), c: new Vector3() };\n\n\t\t\t\t\t\tdstNormalsFace.push( faceNormal );\n\t\t\t\t\t\tdstNormalsVertex.push( vertexNormals );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tvar morphNormals = this.morphNormals[ i ];\n\n\t\t\t\t// set vertices to morph target\n\n\t\t\t\ttmpGeo.vertices = this.morphTargets[ i ].vertices;\n\n\t\t\t\t// compute morph normals\n\n\t\t\t\ttmpGeo.computeFaceNormals();\n\t\t\t\ttmpGeo.computeVertexNormals();\n\n\t\t\t\t// store morph normals\n\n\t\t\t\tvar faceNormal, vertexNormals;\n\n\t\t\t\tfor ( f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\t\tface = this.faces[ f ];\n\n\t\t\t\t\tfaceNormal = morphNormals.faceNormals[ f ];\n\t\t\t\t\tvertexNormals = morphNormals.vertexNormals[ f ];\n\n\t\t\t\t\tfaceNormal.copy( face.normal );\n\n\t\t\t\t\tvertexNormals.a.copy( face.vertexNormals[ 0 ] );\n\t\t\t\t\tvertexNormals.b.copy( face.vertexNormals[ 1 ] );\n\t\t\t\t\tvertexNormals.c.copy( face.vertexNormals[ 2 ] );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// restore original normals\n\n\t\t\tfor ( f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\tface = this.faces[ f ];\n\n\t\t\t\tface.normal = face.__originalFaceNormal;\n\t\t\t\tface.vertexNormals = face.__originalVertexNormals;\n\n\t\t\t}\n\n\t\t},\n\n\t\tcomputeBoundingBox: function () {\n\n\t\t\tif ( this.boundingBox === null ) {\n\n\t\t\t\tthis.boundingBox = new Box3();\n\n\t\t\t}\n\n\t\t\tthis.boundingBox.setFromPoints( this.vertices );\n\n\t\t},\n\n\t\tcomputeBoundingSphere: function () {\n\n\t\t\tif ( this.boundingSphere === null ) {\n\n\t\t\t\tthis.boundingSphere = new Sphere();\n\n\t\t\t}\n\n\t\t\tthis.boundingSphere.setFromPoints( this.vertices );\n\n\t\t},\n\n\t\tmerge: function ( geometry, matrix, materialIndexOffset ) {\n\n\t\t\tif ( ! ( geometry && geometry.isGeometry ) ) {\n\n\t\t\t\tconsole.error( 'THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.', geometry );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tvar normalMatrix,\n\t\t\t\tvertexOffset = this.vertices.length,\n\t\t\t\tvertices1 = this.vertices,\n\t\t\t\tvertices2 = geometry.vertices,\n\t\t\t\tfaces1 = this.faces,\n\t\t\t\tfaces2 = geometry.faces,\n\t\t\t\tuvs1 = this.faceVertexUvs[ 0 ],\n\t\t\t\tuvs2 = geometry.faceVertexUvs[ 0 ],\n\t\t\t\tcolors1 = this.colors,\n\t\t\t\tcolors2 = geometry.colors;\n\n\t\t\tif ( materialIndexOffset === undefined ) materialIndexOffset = 0;\n\n\t\t\tif ( matrix !== undefined ) {\n\n\t\t\t\tnormalMatrix = new Matrix3().getNormalMatrix( matrix );\n\n\t\t\t}\n\n\t\t\t// vertices\n\n\t\t\tfor ( var i = 0, il = vertices2.length; i < il; i ++ ) {\n\n\t\t\t\tvar vertex = vertices2[ i ];\n\n\t\t\t\tvar vertexCopy = vertex.clone();\n\n\t\t\t\tif ( matrix !== undefined ) vertexCopy.applyMatrix4( matrix );\n\n\t\t\t\tvertices1.push( vertexCopy );\n\n\t\t\t}\n\n\t\t\t// colors\n\n\t\t\tfor ( var i = 0, il = colors2.length; i < il; i ++ ) {\n\n\t\t\t\tcolors1.push( colors2[ i ].clone() );\n\n\t\t\t}\n\n\t\t\t// faces\n\n\t\t\tfor ( i = 0, il = faces2.length; i < il; i ++ ) {\n\n\t\t\t\tvar face = faces2[ i ], faceCopy, normal, color,\n\t\t\t\t\tfaceVertexNormals = face.vertexNormals,\n\t\t\t\t\tfaceVertexColors = face.vertexColors;\n\n\t\t\t\tfaceCopy = new Face3( face.a + vertexOffset, face.b + vertexOffset, face.c + vertexOffset );\n\t\t\t\tfaceCopy.normal.copy( face.normal );\n\n\t\t\t\tif ( normalMatrix !== undefined ) {\n\n\t\t\t\t\tfaceCopy.normal.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t\t}\n\n\t\t\t\tfor ( var j = 0, jl = faceVertexNormals.length; j < jl; j ++ ) {\n\n\t\t\t\t\tnormal = faceVertexNormals[ j ].clone();\n\n\t\t\t\t\tif ( normalMatrix !== undefined ) {\n\n\t\t\t\t\t\tnormal.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfaceCopy.vertexNormals.push( normal );\n\n\t\t\t\t}\n\n\t\t\t\tfaceCopy.color.copy( face.color );\n\n\t\t\t\tfor ( var j = 0, jl = faceVertexColors.length; j < jl; j ++ ) {\n\n\t\t\t\t\tcolor = faceVertexColors[ j ];\n\t\t\t\t\tfaceCopy.vertexColors.push( color.clone() );\n\n\t\t\t\t}\n\n\t\t\t\tfaceCopy.materialIndex = face.materialIndex + materialIndexOffset;\n\n\t\t\t\tfaces1.push( faceCopy );\n\n\t\t\t}\n\n\t\t\t// uvs\n\n\t\t\tfor ( i = 0, il = uvs2.length; i < il; i ++ ) {\n\n\t\t\t\tvar uv = uvs2[ i ], uvCopy = [];\n\n\t\t\t\tif ( uv === undefined ) {\n\n\t\t\t\t\tcontinue;\n\n\t\t\t\t}\n\n\t\t\t\tfor ( var j = 0, jl = uv.length; j < jl; j ++ ) {\n\n\t\t\t\t\tuvCopy.push( uv[ j ].clone() );\n\n\t\t\t\t}\n\n\t\t\t\tuvs1.push( uvCopy );\n\n\t\t\t}\n\n\t\t},\n\n\t\tmergeMesh: function ( mesh ) {\n\n\t\t\tif ( ! ( mesh && mesh.isMesh ) ) {\n\n\t\t\t\tconsole.error( 'THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.', mesh );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tif ( mesh.matrixAutoUpdate ) mesh.updateMatrix();\n\n\t\t\tthis.merge( mesh.geometry, mesh.matrix );\n\n\t\t},\n\n\t\t/*\n\t\t * Checks for duplicate vertices with hashmap.\n\t\t * Duplicated vertices are removed\n\t\t * and faces' vertices are updated.\n\t\t */\n\n\t\tmergeVertices: function () {\n\n\t\t\tvar verticesMap = {}; // Hashmap for looking up vertices by position coordinates (and making sure they are unique)\n\t\t\tvar unique = [], changes = [];\n\n\t\t\tvar v, key;\n\t\t\tvar precisionPoints = 4; // number of decimal points, e.g. 4 for epsilon of 0.0001\n\t\t\tvar precision = Math.pow( 10, precisionPoints );\n\t\t\tvar i, il, face;\n\t\t\tvar indices, j, jl;\n\n\t\t\tfor ( i = 0, il = this.vertices.length; i < il; i ++ ) {\n\n\t\t\t\tv = this.vertices[ i ];\n\t\t\t\tkey = Math.round( v.x * precision ) + '_' + Math.round( v.y * precision ) + '_' + Math.round( v.z * precision );\n\n\t\t\t\tif ( verticesMap[ key ] === undefined ) {\n\n\t\t\t\t\tverticesMap[ key ] = i;\n\t\t\t\t\tunique.push( this.vertices[ i ] );\n\t\t\t\t\tchanges[ i ] = unique.length - 1;\n\n\t\t\t\t} else {\n\n\t\t\t\t\t//console.log('Duplicate vertex found. ', i, ' could be using ', verticesMap[key]);\n\t\t\t\t\tchanges[ i ] = changes[ verticesMap[ key ] ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\n\t\t\t// if faces are completely degenerate after merging vertices, we\n\t\t\t// have to remove them from the geometry.\n\t\t\tvar faceIndicesToRemove = [];\n\n\t\t\tfor ( i = 0, il = this.faces.length; i < il; i ++ ) {\n\n\t\t\t\tface = this.faces[ i ];\n\n\t\t\t\tface.a = changes[ face.a ];\n\t\t\t\tface.b = changes[ face.b ];\n\t\t\t\tface.c = changes[ face.c ];\n\n\t\t\t\tindices = [ face.a, face.b, face.c ];\n\n\t\t\t\t// if any duplicate vertices are found in a Face3\n\t\t\t\t// we have to remove the face as nothing can be saved\n\t\t\t\tfor ( var n = 0; n < 3; n ++ ) {\n\n\t\t\t\t\tif ( indices[ n ] === indices[ ( n + 1 ) % 3 ] ) {\n\n\t\t\t\t\t\tfaceIndicesToRemove.push( i );\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tfor ( i = faceIndicesToRemove.length - 1; i >= 0; i -- ) {\n\n\t\t\t\tvar idx = faceIndicesToRemove[ i ];\n\n\t\t\t\tthis.faces.splice( idx, 1 );\n\n\t\t\t\tfor ( j = 0, jl = this.faceVertexUvs.length; j < jl; j ++ ) {\n\n\t\t\t\t\tthis.faceVertexUvs[ j ].splice( idx, 1 );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// Use unique set of vertices\n\n\t\t\tvar diff = this.vertices.length - unique.length;\n\t\t\tthis.vertices = unique;\n\t\t\treturn diff;\n\n\t\t},\n\n\t\tsetFromPoints: function ( points ) {\n\n\t\t\tthis.vertices = [];\n\n\t\t\tfor ( var i = 0, l = points.length; i < l; i ++ ) {\n\n\t\t\t\tvar point = points[ i ];\n\t\t\t\tthis.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsortFacesByMaterialIndex: function () {\n\n\t\t\tvar faces = this.faces;\n\t\t\tvar length = faces.length;\n\n\t\t\t// tag faces\n\n\t\t\tfor ( var i = 0; i < length; i ++ ) {\n\n\t\t\t\tfaces[ i ]._id = i;\n\n\t\t\t}\n\n\t\t\t// sort faces\n\n\t\t\tfunction materialIndexSort( a, b ) {\n\n\t\t\t\treturn a.materialIndex - b.materialIndex;\n\n\t\t\t}\n\n\t\t\tfaces.sort( materialIndexSort );\n\n\t\t\t// sort uvs\n\n\t\t\tvar uvs1 = this.faceVertexUvs[ 0 ];\n\t\t\tvar uvs2 = this.faceVertexUvs[ 1 ];\n\n\t\t\tvar newUvs1, newUvs2;\n\n\t\t\tif ( uvs1 && uvs1.length === length ) newUvs1 = [];\n\t\t\tif ( uvs2 && uvs2.length === length ) newUvs2 = [];\n\n\t\t\tfor ( var i = 0; i < length; i ++ ) {\n\n\t\t\t\tvar id = faces[ i ]._id;\n\n\t\t\t\tif ( newUvs1 ) newUvs1.push( uvs1[ id ] );\n\t\t\t\tif ( newUvs2 ) newUvs2.push( uvs2[ id ] );\n\n\t\t\t}\n\n\t\t\tif ( newUvs1 ) this.faceVertexUvs[ 0 ] = newUvs1;\n\t\t\tif ( newUvs2 ) this.faceVertexUvs[ 1 ] = newUvs2;\n\n\t\t},\n\n\t\ttoJSON: function () {\n\n\t\t\tvar data = {\n\t\t\t\tmetadata: {\n\t\t\t\t\tversion: 4.5,\n\t\t\t\t\ttype: 'Geometry',\n\t\t\t\t\tgenerator: 'Geometry.toJSON'\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// standard Geometry serialization\n\n\t\t\tdata.uuid = this.uuid;\n\t\t\tdata.type = this.type;\n\t\t\tif ( this.name !== '' ) data.name = this.name;\n\n\t\t\tif ( this.parameters !== undefined ) {\n\n\t\t\t\tvar parameters = this.parameters;\n\n\t\t\t\tfor ( var key in parameters ) {\n\n\t\t\t\t\tif ( parameters[ key ] !== undefined ) data[ key ] = parameters[ key ];\n\n\t\t\t\t}\n\n\t\t\t\treturn data;\n\n\t\t\t}\n\n\t\t\tvar vertices = [];\n\n\t\t\tfor ( var i = 0; i < this.vertices.length; i ++ ) {\n\n\t\t\t\tvar vertex = this.vertices[ i ];\n\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t}\n\n\t\t\tvar faces = [];\n\t\t\tvar normals = [];\n\t\t\tvar normalsHash = {};\n\t\t\tvar colors = [];\n\t\t\tvar colorsHash = {};\n\t\t\tvar uvs = [];\n\t\t\tvar uvsHash = {};\n\n\t\t\tfor ( var i = 0; i < this.faces.length; i ++ ) {\n\n\t\t\t\tvar face = this.faces[ i ];\n\n\t\t\t\tvar hasMaterial = true;\n\t\t\t\tvar hasFaceUv = false; // deprecated\n\t\t\t\tvar hasFaceVertexUv = this.faceVertexUvs[ 0 ][ i ] !== undefined;\n\t\t\t\tvar hasFaceNormal = face.normal.length() > 0;\n\t\t\t\tvar hasFaceVertexNormal = face.vertexNormals.length > 0;\n\t\t\t\tvar hasFaceColor = face.color.r !== 1 || face.color.g !== 1 || face.color.b !== 1;\n\t\t\t\tvar hasFaceVertexColor = face.vertexColors.length > 0;\n\n\t\t\t\tvar faceType = 0;\n\n\t\t\t\tfaceType = setBit( faceType, 0, 0 ); // isQuad\n\t\t\t\tfaceType = setBit( faceType, 1, hasMaterial );\n\t\t\t\tfaceType = setBit( faceType, 2, hasFaceUv );\n\t\t\t\tfaceType = setBit( faceType, 3, hasFaceVertexUv );\n\t\t\t\tfaceType = setBit( faceType, 4, hasFaceNormal );\n\t\t\t\tfaceType = setBit( faceType, 5, hasFaceVertexNormal );\n\t\t\t\tfaceType = setBit( faceType, 6, hasFaceColor );\n\t\t\t\tfaceType = setBit( faceType, 7, hasFaceVertexColor );\n\n\t\t\t\tfaces.push( faceType );\n\t\t\t\tfaces.push( face.a, face.b, face.c );\n\t\t\t\tfaces.push( face.materialIndex );\n\n\t\t\t\tif ( hasFaceVertexUv ) {\n\n\t\t\t\t\tvar faceVertexUvs = this.faceVertexUvs[ 0 ][ i ];\n\n\t\t\t\t\tfaces.push(\n\t\t\t\t\t\tgetUvIndex( faceVertexUvs[ 0 ] ),\n\t\t\t\t\t\tgetUvIndex( faceVertexUvs[ 1 ] ),\n\t\t\t\t\t\tgetUvIndex( faceVertexUvs[ 2 ] )\n\t\t\t\t\t);\n\n\t\t\t\t}\n\n\t\t\t\tif ( hasFaceNormal ) {\n\n\t\t\t\t\tfaces.push( getNormalIndex( face.normal ) );\n\n\t\t\t\t}\n\n\t\t\t\tif ( hasFaceVertexNormal ) {\n\n\t\t\t\t\tvar vertexNormals = face.vertexNormals;\n\n\t\t\t\t\tfaces.push(\n\t\t\t\t\t\tgetNormalIndex( vertexNormals[ 0 ] ),\n\t\t\t\t\t\tgetNormalIndex( vertexNormals[ 1 ] ),\n\t\t\t\t\t\tgetNormalIndex( vertexNormals[ 2 ] )\n\t\t\t\t\t);\n\n\t\t\t\t}\n\n\t\t\t\tif ( hasFaceColor ) {\n\n\t\t\t\t\tfaces.push( getColorIndex( face.color ) );\n\n\t\t\t\t}\n\n\t\t\t\tif ( hasFaceVertexColor ) {\n\n\t\t\t\t\tvar vertexColors = face.vertexColors;\n\n\t\t\t\t\tfaces.push(\n\t\t\t\t\t\tgetColorIndex( vertexColors[ 0 ] ),\n\t\t\t\t\t\tgetColorIndex( vertexColors[ 1 ] ),\n\t\t\t\t\t\tgetColorIndex( vertexColors[ 2 ] )\n\t\t\t\t\t);\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tfunction setBit( value, position, enabled ) {\n\n\t\t\t\treturn enabled ? value | ( 1 << position ) : value & ( ~ ( 1 << position ) );\n\n\t\t\t}\n\n\t\t\tfunction getNormalIndex( normal ) {\n\n\t\t\t\tvar hash = normal.x.toString() + normal.y.toString() + normal.z.toString();\n\n\t\t\t\tif ( normalsHash[ hash ] !== undefined ) {\n\n\t\t\t\t\treturn normalsHash[ hash ];\n\n\t\t\t\t}\n\n\t\t\t\tnormalsHash[ hash ] = normals.length / 3;\n\t\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\t\treturn normalsHash[ hash ];\n\n\t\t\t}\n\n\t\t\tfunction getColorIndex( color ) {\n\n\t\t\t\tvar hash = color.r.toString() + color.g.toString() + color.b.toString();\n\n\t\t\t\tif ( colorsHash[ hash ] !== undefined ) {\n\n\t\t\t\t\treturn colorsHash[ hash ];\n\n\t\t\t\t}\n\n\t\t\t\tcolorsHash[ hash ] = colors.length;\n\t\t\t\tcolors.push( color.getHex() );\n\n\t\t\t\treturn colorsHash[ hash ];\n\n\t\t\t}\n\n\t\t\tfunction getUvIndex( uv ) {\n\n\t\t\t\tvar hash = uv.x.toString() + uv.y.toString();\n\n\t\t\t\tif ( uvsHash[ hash ] !== undefined ) {\n\n\t\t\t\t\treturn uvsHash[ hash ];\n\n\t\t\t\t}\n\n\t\t\t\tuvsHash[ hash ] = uvs.length / 2;\n\t\t\t\tuvs.push( uv.x, uv.y );\n\n\t\t\t\treturn uvsHash[ hash ];\n\n\t\t\t}\n\n\t\t\tdata.data = {};\n\n\t\t\tdata.data.vertices = vertices;\n\t\t\tdata.data.normals = normals;\n\t\t\tif ( colors.length > 0 ) data.data.colors = colors;\n\t\t\tif ( uvs.length > 0 ) data.data.uvs = [ uvs ]; // temporal backward compatibility\n\t\t\tdata.data.faces = faces;\n\n\t\t\treturn data;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\t/*\n\t\t\t // Handle primitives\n\n\t\t\t var parameters = this.parameters;\n\n\t\t\t if ( parameters !== undefined ) {\n\n\t\t\t var values = [];\n\n\t\t\t for ( var key in parameters ) {\n\n\t\t\t values.push( parameters[ key ] );\n\n\t\t\t }\n\n\t\t\t var geometry = Object.create( this.constructor.prototype );\n\t\t\t this.constructor.apply( geometry, values );\n\t\t\t return geometry;\n\n\t\t\t }\n\n\t\t\t return new this.constructor().copy( this );\n\t\t\t */\n\n\t\t\treturn new Geometry().copy( this );\n\n\t\t},\n\n\t\tcopy: function ( source ) {\n\n\t\t\tvar i, il, j, jl, k, kl;\n\n\t\t\t// reset\n\n\t\t\tthis.vertices = [];\n\t\t\tthis.colors = [];\n\t\t\tthis.faces = [];\n\t\t\tthis.faceVertexUvs = [[]];\n\t\t\tthis.morphTargets = [];\n\t\t\tthis.morphNormals = [];\n\t\t\tthis.skinWeights = [];\n\t\t\tthis.skinIndices = [];\n\t\t\tthis.lineDistances = [];\n\t\t\tthis.boundingBox = null;\n\t\t\tthis.boundingSphere = null;\n\n\t\t\t// name\n\n\t\t\tthis.name = source.name;\n\n\t\t\t// vertices\n\n\t\t\tvar vertices = source.vertices;\n\n\t\t\tfor ( i = 0, il = vertices.length; i < il; i ++ ) {\n\n\t\t\t\tthis.vertices.push( vertices[ i ].clone() );\n\n\t\t\t}\n\n\t\t\t// colors\n\n\t\t\tvar colors = source.colors;\n\n\t\t\tfor ( i = 0, il = colors.length; i < il; i ++ ) {\n\n\t\t\t\tthis.colors.push( colors[ i ].clone() );\n\n\t\t\t}\n\n\t\t\t// faces\n\n\t\t\tvar faces = source.faces;\n\n\t\t\tfor ( i = 0, il = faces.length; i < il; i ++ ) {\n\n\t\t\t\tthis.faces.push( faces[ i ].clone() );\n\n\t\t\t}\n\n\t\t\t// face vertex uvs\n\n\t\t\tfor ( i = 0, il = source.faceVertexUvs.length; i < il; i ++ ) {\n\n\t\t\t\tvar faceVertexUvs = source.faceVertexUvs[ i ];\n\n\t\t\t\tif ( this.faceVertexUvs[ i ] === undefined ) {\n\n\t\t\t\t\tthis.faceVertexUvs[ i ] = [];\n\n\t\t\t\t}\n\n\t\t\t\tfor ( j = 0, jl = faceVertexUvs.length; j < jl; j ++ ) {\n\n\t\t\t\t\tvar uvs = faceVertexUvs[ j ], uvsCopy = [];\n\n\t\t\t\t\tfor ( k = 0, kl = uvs.length; k < kl; k ++ ) {\n\n\t\t\t\t\t\tvar uv = uvs[ k ];\n\n\t\t\t\t\t\tuvsCopy.push( uv.clone() );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.faceVertexUvs[ i ].push( uvsCopy );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// morph targets\n\n\t\t\tvar morphTargets = source.morphTargets;\n\n\t\t\tfor ( i = 0, il = morphTargets.length; i < il; i ++ ) {\n\n\t\t\t\tvar morphTarget = {};\n\t\t\t\tmorphTarget.name = morphTargets[ i ].name;\n\n\t\t\t\t// vertices\n\n\t\t\t\tif ( morphTargets[ i ].vertices !== undefined ) {\n\n\t\t\t\t\tmorphTarget.vertices = [];\n\n\t\t\t\t\tfor ( j = 0, jl = morphTargets[ i ].vertices.length; j < jl; j ++ ) {\n\n\t\t\t\t\t\tmorphTarget.vertices.push( morphTargets[ i ].vertices[ j ].clone() );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\t// normals\n\n\t\t\t\tif ( morphTargets[ i ].normals !== undefined ) {\n\n\t\t\t\t\tmorphTarget.normals = [];\n\n\t\t\t\t\tfor ( j = 0, jl = morphTargets[ i ].normals.length; j < jl; j ++ ) {\n\n\t\t\t\t\t\tmorphTarget.normals.push( morphTargets[ i ].normals[ j ].clone() );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tthis.morphTargets.push( morphTarget );\n\n\t\t\t}\n\n\t\t\t// morph normals\n\n\t\t\tvar morphNormals = source.morphNormals;\n\n\t\t\tfor ( i = 0, il = morphNormals.length; i < il; i ++ ) {\n\n\t\t\t\tvar morphNormal = {};\n\n\t\t\t\t// vertex normals\n\n\t\t\t\tif ( morphNormals[ i ].vertexNormals !== undefined ) {\n\n\t\t\t\t\tmorphNormal.vertexNormals = [];\n\n\t\t\t\t\tfor ( j = 0, jl = morphNormals[ i ].vertexNormals.length; j < jl; j ++ ) {\n\n\t\t\t\t\t\tvar srcVertexNormal = morphNormals[ i ].vertexNormals[ j ];\n\t\t\t\t\t\tvar destVertexNormal = {};\n\n\t\t\t\t\t\tdestVertexNormal.a = srcVertexNormal.a.clone();\n\t\t\t\t\t\tdestVertexNormal.b = srcVertexNormal.b.clone();\n\t\t\t\t\t\tdestVertexNormal.c = srcVertexNormal.c.clone();\n\n\t\t\t\t\t\tmorphNormal.vertexNormals.push( destVertexNormal );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\t// face normals\n\n\t\t\t\tif ( morphNormals[ i ].faceNormals !== undefined ) {\n\n\t\t\t\t\tmorphNormal.faceNormals = [];\n\n\t\t\t\t\tfor ( j = 0, jl = morphNormals[ i ].faceNormals.length; j < jl; j ++ ) {\n\n\t\t\t\t\t\tmorphNormal.faceNormals.push( morphNormals[ i ].faceNormals[ j ].clone() );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tthis.morphNormals.push( morphNormal );\n\n\t\t\t}\n\n\t\t\t// skin weights\n\n\t\t\tvar skinWeights = source.skinWeights;\n\n\t\t\tfor ( i = 0, il = skinWeights.length; i < il; i ++ ) {\n\n\t\t\t\tthis.skinWeights.push( skinWeights[ i ].clone() );\n\n\t\t\t}\n\n\t\t\t// skin indices\n\n\t\t\tvar skinIndices = source.skinIndices;\n\n\t\t\tfor ( i = 0, il = skinIndices.length; i < il; i ++ ) {\n\n\t\t\t\tthis.skinIndices.push( skinIndices[ i ].clone() );\n\n\t\t\t}\n\n\t\t\t// line distances\n\n\t\t\tvar lineDistances = source.lineDistances;\n\n\t\t\tfor ( i = 0, il = lineDistances.length; i < il; i ++ ) {\n\n\t\t\t\tthis.lineDistances.push( lineDistances[ i ] );\n\n\t\t\t}\n\n\t\t\t// bounding box\n\n\t\t\tvar boundingBox = source.boundingBox;\n\n\t\t\tif ( boundingBox !== null ) {\n\n\t\t\t\tthis.boundingBox = boundingBox.clone();\n\n\t\t\t}\n\n\t\t\t// bounding sphere\n\n\t\t\tvar boundingSphere = source.boundingSphere;\n\n\t\t\tif ( boundingSphere !== null ) {\n\n\t\t\t\tthis.boundingSphere = boundingSphere.clone();\n\n\t\t\t}\n\n\t\t\t// update flags\n\n\t\t\tthis.elementsNeedUpdate = source.elementsNeedUpdate;\n\t\t\tthis.verticesNeedUpdate = source.verticesNeedUpdate;\n\t\t\tthis.uvsNeedUpdate = source.uvsNeedUpdate;\n\t\t\tthis.normalsNeedUpdate = source.normalsNeedUpdate;\n\t\t\tthis.colorsNeedUpdate = source.colorsNeedUpdate;\n\t\t\tthis.lineDistancesNeedUpdate = source.lineDistancesNeedUpdate;\n\t\t\tthis.groupsNeedUpdate = source.groupsNeedUpdate;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tdispose: function () {\n\n\t\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction BufferAttribute( array, itemSize, normalized ) {\n\n\t\tif ( Array.isArray( array ) ) {\n\n\t\t\tthrow new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' );\n\n\t\t}\n\n\t\tthis.name = '';\n\n\t\tthis.array = array;\n\t\tthis.itemSize = itemSize;\n\t\tthis.count = array !== undefined ? array.length / itemSize : 0;\n\t\tthis.normalized = normalized === true;\n\n\t\tthis.dynamic = false;\n\t\tthis.updateRange = { offset: 0, count: - 1 };\n\n\t\tthis.version = 0;\n\n\t}\n\n\tObject.defineProperty( BufferAttribute.prototype, 'needsUpdate', {\n\n\t\tset: function ( value ) {\n\n\t\t\tif ( value === true ) this.version ++;\n\n\t\t}\n\n\t} );\n\n\tObject.assign( BufferAttribute.prototype, {\n\n\t\tisBufferAttribute: true,\n\n\t\tonUploadCallback: function () {},\n\n\t\tsetArray: function ( array ) {\n\n\t\t\tif ( Array.isArray( array ) ) {\n\n\t\t\t\tthrow new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' );\n\n\t\t\t}\n\n\t\t\tthis.count = array !== undefined ? array.length / this.itemSize : 0;\n\t\t\tthis.array = array;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetDynamic: function ( value ) {\n\n\t\t\tthis.dynamic = value;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcopy: function ( source ) {\n\n\t\t\tthis.name = source.name;\n\t\t\tthis.array = new source.array.constructor( source.array );\n\t\t\tthis.itemSize = source.itemSize;\n\t\t\tthis.count = source.count;\n\t\t\tthis.normalized = source.normalized;\n\n\t\t\tthis.dynamic = source.dynamic;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcopyAt: function ( index1, attribute, index2 ) {\n\n\t\t\tindex1 *= this.itemSize;\n\t\t\tindex2 *= attribute.itemSize;\n\n\t\t\tfor ( var i = 0, l = this.itemSize; i < l; i ++ ) {\n\n\t\t\t\tthis.array[ index1 + i ] = attribute.array[ index2 + i ];\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcopyArray: function ( array ) {\n\n\t\t\tthis.array.set( array );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcopyColorsArray: function ( colors ) {\n\n\t\t\tvar array = this.array, offset = 0;\n\n\t\t\tfor ( var i = 0, l = colors.length; i < l; i ++ ) {\n\n\t\t\t\tvar color = colors[ i ];\n\n\t\t\t\tif ( color === undefined ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyColorsArray(): color is undefined', i );\n\t\t\t\t\tcolor = new Color();\n\n\t\t\t\t}\n\n\t\t\t\tarray[ offset ++ ] = color.r;\n\t\t\t\tarray[ offset ++ ] = color.g;\n\t\t\t\tarray[ offset ++ ] = color.b;\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcopyVector2sArray: function ( vectors ) {\n\n\t\t\tvar array = this.array, offset = 0;\n\n\t\t\tfor ( var i = 0, l = vectors.length; i < l; i ++ ) {\n\n\t\t\t\tvar vector = vectors[ i ];\n\n\t\t\t\tif ( vector === undefined ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyVector2sArray(): vector is undefined', i );\n\t\t\t\t\tvector = new Vector2();\n\n\t\t\t\t}\n\n\t\t\t\tarray[ offset ++ ] = vector.x;\n\t\t\t\tarray[ offset ++ ] = vector.y;\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcopyVector3sArray: function ( vectors ) {\n\n\t\t\tvar array = this.array, offset = 0;\n\n\t\t\tfor ( var i = 0, l = vectors.length; i < l; i ++ ) {\n\n\t\t\t\tvar vector = vectors[ i ];\n\n\t\t\t\tif ( vector === undefined ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyVector3sArray(): vector is undefined', i );\n\t\t\t\t\tvector = new Vector3();\n\n\t\t\t\t}\n\n\t\t\t\tarray[ offset ++ ] = vector.x;\n\t\t\t\tarray[ offset ++ ] = vector.y;\n\t\t\t\tarray[ offset ++ ] = vector.z;\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcopyVector4sArray: function ( vectors ) {\n\n\t\t\tvar array = this.array, offset = 0;\n\n\t\t\tfor ( var i = 0, l = vectors.length; i < l; i ++ ) {\n\n\t\t\t\tvar vector = vectors[ i ];\n\n\t\t\t\tif ( vector === undefined ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyVector4sArray(): vector is undefined', i );\n\t\t\t\t\tvector = new Vector4();\n\n\t\t\t\t}\n\n\t\t\t\tarray[ offset ++ ] = vector.x;\n\t\t\t\tarray[ offset ++ ] = vector.y;\n\t\t\t\tarray[ offset ++ ] = vector.z;\n\t\t\t\tarray[ offset ++ ] = vector.w;\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tset: function ( value, offset ) {\n\n\t\t\tif ( offset === undefined ) offset = 0;\n\n\t\t\tthis.array.set( value, offset );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetX: function ( index ) {\n\n\t\t\treturn this.array[ index * this.itemSize ];\n\n\t\t},\n\n\t\tsetX: function ( index, x ) {\n\n\t\t\tthis.array[ index * this.itemSize ] = x;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetY: function ( index ) {\n\n\t\t\treturn this.array[ index * this.itemSize + 1 ];\n\n\t\t},\n\n\t\tsetY: function ( index, y ) {\n\n\t\t\tthis.array[ index * this.itemSize + 1 ] = y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetZ: function ( index ) {\n\n\t\t\treturn this.array[ index * this.itemSize + 2 ];\n\n\t\t},\n\n\t\tsetZ: function ( index, z ) {\n\n\t\t\tthis.array[ index * this.itemSize + 2 ] = z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetW: function ( index ) {\n\n\t\t\treturn this.array[ index * this.itemSize + 3 ];\n\n\t\t},\n\n\t\tsetW: function ( index, w ) {\n\n\t\t\tthis.array[ index * this.itemSize + 3 ] = w;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetXY: function ( index, x, y ) {\n\n\t\t\tindex *= this.itemSize;\n\n\t\t\tthis.array[ index + 0 ] = x;\n\t\t\tthis.array[ index + 1 ] = y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetXYZ: function ( index, x, y, z ) {\n\n\t\t\tindex *= this.itemSize;\n\n\t\t\tthis.array[ index + 0 ] = x;\n\t\t\tthis.array[ index + 1 ] = y;\n\t\t\tthis.array[ index + 2 ] = z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetXYZW: function ( index, x, y, z, w ) {\n\n\t\t\tindex *= this.itemSize;\n\n\t\t\tthis.array[ index + 0 ] = x;\n\t\t\tthis.array[ index + 1 ] = y;\n\t\t\tthis.array[ index + 2 ] = z;\n\t\t\tthis.array[ index + 3 ] = w;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tonUpload: function ( callback ) {\n\n\t\t\tthis.onUploadCallback = callback;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor( this.array, this.itemSize ).copy( this );\n\n\t\t}\n\n\t} );\n\n\t//\n\n\tfunction Int8BufferAttribute( array, itemSize, normalized ) {\n\n\t\tBufferAttribute.call( this, new Int8Array( array ), itemSize, normalized );\n\n\t}\n\n\tInt8BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\n\tInt8BufferAttribute.prototype.constructor = Int8BufferAttribute;\n\n\n\tfunction Uint8BufferAttribute( array, itemSize, normalized ) {\n\n\t\tBufferAttribute.call( this, new Uint8Array( array ), itemSize, normalized );\n\n\t}\n\n\tUint8BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\n\tUint8BufferAttribute.prototype.constructor = Uint8BufferAttribute;\n\n\n\tfunction Uint8ClampedBufferAttribute( array, itemSize, normalized ) {\n\n\t\tBufferAttribute.call( this, new Uint8ClampedArray( array ), itemSize, normalized );\n\n\t}\n\n\tUint8ClampedBufferAttribute.prototype = Object.create( BufferAttribute.prototype );\n\tUint8ClampedBufferAttribute.prototype.constructor = Uint8ClampedBufferAttribute;\n\n\n\tfunction Int16BufferAttribute( array, itemSize, normalized ) {\n\n\t\tBufferAttribute.call( this, new Int16Array( array ), itemSize, normalized );\n\n\t}\n\n\tInt16BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\n\tInt16BufferAttribute.prototype.constructor = Int16BufferAttribute;\n\n\n\tfunction Uint16BufferAttribute( array, itemSize, normalized ) {\n\n\t\tBufferAttribute.call( this, new Uint16Array( array ), itemSize, normalized );\n\n\t}\n\n\tUint16BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\n\tUint16BufferAttribute.prototype.constructor = Uint16BufferAttribute;\n\n\n\tfunction Int32BufferAttribute( array, itemSize, normalized ) {\n\n\t\tBufferAttribute.call( this, new Int32Array( array ), itemSize, normalized );\n\n\t}\n\n\tInt32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\n\tInt32BufferAttribute.prototype.constructor = Int32BufferAttribute;\n\n\n\tfunction Uint32BufferAttribute( array, itemSize, normalized ) {\n\n\t\tBufferAttribute.call( this, new Uint32Array( array ), itemSize, normalized );\n\n\t}\n\n\tUint32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\n\tUint32BufferAttribute.prototype.constructor = Uint32BufferAttribute;\n\n\n\tfunction Float32BufferAttribute( array, itemSize, normalized ) {\n\n\t\tBufferAttribute.call( this, new Float32Array( array ), itemSize, normalized );\n\n\t}\n\n\tFloat32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\n\tFloat32BufferAttribute.prototype.constructor = Float32BufferAttribute;\n\n\n\tfunction Float64BufferAttribute( array, itemSize, normalized ) {\n\n\t\tBufferAttribute.call( this, new Float64Array( array ), itemSize, normalized );\n\n\t}\n\n\tFloat64BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\n\tFloat64BufferAttribute.prototype.constructor = Float64BufferAttribute;\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction DirectGeometry() {\n\n\t\tthis.vertices = [];\n\t\tthis.normals = [];\n\t\tthis.colors = [];\n\t\tthis.uvs = [];\n\t\tthis.uvs2 = [];\n\n\t\tthis.groups = [];\n\n\t\tthis.morphTargets = {};\n\n\t\tthis.skinWeights = [];\n\t\tthis.skinIndices = [];\n\n\t\t// this.lineDistances = [];\n\n\t\tthis.boundingBox = null;\n\t\tthis.boundingSphere = null;\n\n\t\t// update flags\n\n\t\tthis.verticesNeedUpdate = false;\n\t\tthis.normalsNeedUpdate = false;\n\t\tthis.colorsNeedUpdate = false;\n\t\tthis.uvsNeedUpdate = false;\n\t\tthis.groupsNeedUpdate = false;\n\n\t}\n\n\tObject.assign( DirectGeometry.prototype, {\n\n\t\tcomputeGroups: function ( geometry ) {\n\n\t\t\tvar group;\n\t\t\tvar groups = [];\n\t\t\tvar materialIndex = undefined;\n\n\t\t\tvar faces = geometry.faces;\n\n\t\t\tfor ( var i = 0; i < faces.length; i ++ ) {\n\n\t\t\t\tvar face = faces[ i ];\n\n\t\t\t\t// materials\n\n\t\t\t\tif ( face.materialIndex !== materialIndex ) {\n\n\t\t\t\t\tmaterialIndex = face.materialIndex;\n\n\t\t\t\t\tif ( group !== undefined ) {\n\n\t\t\t\t\t\tgroup.count = ( i * 3 ) - group.start;\n\t\t\t\t\t\tgroups.push( group );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tgroup = {\n\t\t\t\t\t\tstart: i * 3,\n\t\t\t\t\t\tmaterialIndex: materialIndex\n\t\t\t\t\t};\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( group !== undefined ) {\n\n\t\t\t\tgroup.count = ( i * 3 ) - group.start;\n\t\t\t\tgroups.push( group );\n\n\t\t\t}\n\n\t\t\tthis.groups = groups;\n\n\t\t},\n\n\t\tfromGeometry: function ( geometry ) {\n\n\t\t\tvar faces = geometry.faces;\n\t\t\tvar vertices = geometry.vertices;\n\t\t\tvar faceVertexUvs = geometry.faceVertexUvs;\n\n\t\t\tvar hasFaceVertexUv = faceVertexUvs[ 0 ] && faceVertexUvs[ 0 ].length > 0;\n\t\t\tvar hasFaceVertexUv2 = faceVertexUvs[ 1 ] && faceVertexUvs[ 1 ].length > 0;\n\n\t\t\t// morphs\n\n\t\t\tvar morphTargets = geometry.morphTargets;\n\t\t\tvar morphTargetsLength = morphTargets.length;\n\n\t\t\tvar morphTargetsPosition;\n\n\t\t\tif ( morphTargetsLength > 0 ) {\n\n\t\t\t\tmorphTargetsPosition = [];\n\n\t\t\t\tfor ( var i = 0; i < morphTargetsLength; i ++ ) {\n\n\t\t\t\t\tmorphTargetsPosition[ i ] = {\n\t\t\t\t\t\tname: morphTargets[ i ].name,\n\t\t\t\t\t \tdata: []\n\t\t\t\t\t};\n\n\t\t\t\t}\n\n\t\t\t\tthis.morphTargets.position = morphTargetsPosition;\n\n\t\t\t}\n\n\t\t\tvar morphNormals = geometry.morphNormals;\n\t\t\tvar morphNormalsLength = morphNormals.length;\n\n\t\t\tvar morphTargetsNormal;\n\n\t\t\tif ( morphNormalsLength > 0 ) {\n\n\t\t\t\tmorphTargetsNormal = [];\n\n\t\t\t\tfor ( var i = 0; i < morphNormalsLength; i ++ ) {\n\n\t\t\t\t\tmorphTargetsNormal[ i ] = {\n\t\t\t\t\t\tname: morphNormals[ i ].name,\n\t\t\t\t\t \tdata: []\n\t\t\t\t\t};\n\n\t\t\t\t}\n\n\t\t\t\tthis.morphTargets.normal = morphTargetsNormal;\n\n\t\t\t}\n\n\t\t\t// skins\n\n\t\t\tvar skinIndices = geometry.skinIndices;\n\t\t\tvar skinWeights = geometry.skinWeights;\n\n\t\t\tvar hasSkinIndices = skinIndices.length === vertices.length;\n\t\t\tvar hasSkinWeights = skinWeights.length === vertices.length;\n\n\t\t\t//\n\n\t\t\tif ( vertices.length > 0 && faces.length === 0 ) {\n\n\t\t\t\tconsole.error( 'THREE.DirectGeometry: Faceless geometries are not supported.' );\n\n\t\t\t}\n\n\t\t\tfor ( var i = 0; i < faces.length; i ++ ) {\n\n\t\t\t\tvar face = faces[ i ];\n\n\t\t\t\tthis.vertices.push( vertices[ face.a ], vertices[ face.b ], vertices[ face.c ] );\n\n\t\t\t\tvar vertexNormals = face.vertexNormals;\n\n\t\t\t\tif ( vertexNormals.length === 3 ) {\n\n\t\t\t\t\tthis.normals.push( vertexNormals[ 0 ], vertexNormals[ 1 ], vertexNormals[ 2 ] );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tvar normal = face.normal;\n\n\t\t\t\t\tthis.normals.push( normal, normal, normal );\n\n\t\t\t\t}\n\n\t\t\t\tvar vertexColors = face.vertexColors;\n\n\t\t\t\tif ( vertexColors.length === 3 ) {\n\n\t\t\t\t\tthis.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tvar color = face.color;\n\n\t\t\t\t\tthis.colors.push( color, color, color );\n\n\t\t\t\t}\n\n\t\t\t\tif ( hasFaceVertexUv === true ) {\n\n\t\t\t\t\tvar vertexUvs = faceVertexUvs[ 0 ][ i ];\n\n\t\t\t\t\tif ( vertexUvs !== undefined ) {\n\n\t\t\t\t\t\tthis.uvs.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tconsole.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', i );\n\n\t\t\t\t\t\tthis.uvs.push( new Vector2(), new Vector2(), new Vector2() );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( hasFaceVertexUv2 === true ) {\n\n\t\t\t\t\tvar vertexUvs = faceVertexUvs[ 1 ][ i ];\n\n\t\t\t\t\tif ( vertexUvs !== undefined ) {\n\n\t\t\t\t\t\tthis.uvs2.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tconsole.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', i );\n\n\t\t\t\t\t\tthis.uvs2.push( new Vector2(), new Vector2(), new Vector2() );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\t// morphs\n\n\t\t\t\tfor ( var j = 0; j < morphTargetsLength; j ++ ) {\n\n\t\t\t\t\tvar morphTarget = morphTargets[ j ].vertices;\n\n\t\t\t\t\tmorphTargetsPosition[ j ].data.push( morphTarget[ face.a ], morphTarget[ face.b ], morphTarget[ face.c ] );\n\n\t\t\t\t}\n\n\t\t\t\tfor ( var j = 0; j < morphNormalsLength; j ++ ) {\n\n\t\t\t\t\tvar morphNormal = morphNormals[ j ].vertexNormals[ i ];\n\n\t\t\t\t\tmorphTargetsNormal[ j ].data.push( morphNormal.a, morphNormal.b, morphNormal.c );\n\n\t\t\t\t}\n\n\t\t\t\t// skins\n\n\t\t\t\tif ( hasSkinIndices ) {\n\n\t\t\t\t\tthis.skinIndices.push( skinIndices[ face.a ], skinIndices[ face.b ], skinIndices[ face.c ] );\n\n\t\t\t\t}\n\n\t\t\t\tif ( hasSkinWeights ) {\n\n\t\t\t\t\tthis.skinWeights.push( skinWeights[ face.a ], skinWeights[ face.b ], skinWeights[ face.c ] );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.computeGroups( geometry );\n\n\t\t\tthis.verticesNeedUpdate = geometry.verticesNeedUpdate;\n\t\t\tthis.normalsNeedUpdate = geometry.normalsNeedUpdate;\n\t\t\tthis.colorsNeedUpdate = geometry.colorsNeedUpdate;\n\t\t\tthis.uvsNeedUpdate = geometry.uvsNeedUpdate;\n\t\t\tthis.groupsNeedUpdate = geometry.groupsNeedUpdate;\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction arrayMax( array ) {\n\n\t\tif ( array.length === 0 ) return - Infinity;\n\n\t\tvar max = array[ 0 ];\n\n\t\tfor ( var i = 1, l = array.length; i < l; ++ i ) {\n\n\t\t\tif ( array[ i ] > max ) max = array[ i ];\n\n\t\t}\n\n\t\treturn max;\n\n\t}\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tvar bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id\n\n\tfunction BufferGeometry() {\n\n\t\tObject.defineProperty( this, 'id', { value: bufferGeometryId += 2 } );\n\n\t\tthis.uuid = _Math.generateUUID();\n\n\t\tthis.name = '';\n\t\tthis.type = 'BufferGeometry';\n\n\t\tthis.index = null;\n\t\tthis.attributes = {};\n\n\t\tthis.morphAttributes = {};\n\n\t\tthis.groups = [];\n\n\t\tthis.boundingBox = null;\n\t\tthis.boundingSphere = null;\n\n\t\tthis.drawRange = { start: 0, count: Infinity };\n\n\t\tthis.userData = {};\n\n\t}\n\n\tBufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\t\tconstructor: BufferGeometry,\n\n\t\tisBufferGeometry: true,\n\n\t\tgetIndex: function () {\n\n\t\t\treturn this.index;\n\n\t\t},\n\n\t\tsetIndex: function ( index ) {\n\n\t\t\tif ( Array.isArray( index ) ) {\n\n\t\t\t\tthis.index = new ( arrayMax( index ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( index, 1 );\n\n\t\t\t} else {\n\n\t\t\t\tthis.index = index;\n\n\t\t\t}\n\n\t\t},\n\n\t\taddAttribute: function ( name, attribute ) {\n\n\t\t\tif ( ! ( attribute && attribute.isBufferAttribute ) && ! ( attribute && attribute.isInterleavedBufferAttribute ) ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).' );\n\n\t\t\t\treturn this.addAttribute( name, new BufferAttribute( arguments[ 1 ], arguments[ 2 ] ) );\n\n\t\t\t}\n\n\t\t\tif ( name === 'index' ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute.' );\n\t\t\t\tthis.setIndex( attribute );\n\n\t\t\t\treturn this;\n\n\t\t\t}\n\n\t\t\tthis.attributes[ name ] = attribute;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetAttribute: function ( name ) {\n\n\t\t\treturn this.attributes[ name ];\n\n\t\t},\n\n\t\tremoveAttribute: function ( name ) {\n\n\t\t\tdelete this.attributes[ name ];\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\taddGroup: function ( start, count, materialIndex ) {\n\n\t\t\tthis.groups.push( {\n\n\t\t\t\tstart: start,\n\t\t\t\tcount: count,\n\t\t\t\tmaterialIndex: materialIndex !== undefined ? materialIndex : 0\n\n\t\t\t} );\n\n\t\t},\n\n\t\tclearGroups: function () {\n\n\t\t\tthis.groups = [];\n\n\t\t},\n\n\t\tsetDrawRange: function ( start, count ) {\n\n\t\t\tthis.drawRange.start = start;\n\t\t\tthis.drawRange.count = count;\n\n\t\t},\n\n\t\tapplyMatrix: function ( matrix ) {\n\n\t\t\tvar position = this.attributes.position;\n\n\t\t\tif ( position !== undefined ) {\n\n\t\t\t\tmatrix.applyToBufferAttribute( position );\n\t\t\t\tposition.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tvar normal = this.attributes.normal;\n\n\t\t\tif ( normal !== undefined ) {\n\n\t\t\t\tvar normalMatrix = new Matrix3().getNormalMatrix( matrix );\n\n\t\t\t\tnormalMatrix.applyToBufferAttribute( normal );\n\t\t\t\tnormal.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tif ( this.boundingBox !== null ) {\n\n\t\t\t\tthis.computeBoundingBox();\n\n\t\t\t}\n\n\t\t\tif ( this.boundingSphere !== null ) {\n\n\t\t\t\tthis.computeBoundingSphere();\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\trotateX: function () {\n\n\t\t\t// rotate geometry around world x-axis\n\n\t\t\tvar m1 = new Matrix4();\n\n\t\t\treturn function rotateX( angle ) {\n\n\t\t\t\tm1.makeRotationX( angle );\n\n\t\t\t\tthis.applyMatrix( m1 );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\trotateY: function () {\n\n\t\t\t// rotate geometry around world y-axis\n\n\t\t\tvar m1 = new Matrix4();\n\n\t\t\treturn function rotateY( angle ) {\n\n\t\t\t\tm1.makeRotationY( angle );\n\n\t\t\t\tthis.applyMatrix( m1 );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\trotateZ: function () {\n\n\t\t\t// rotate geometry around world z-axis\n\n\t\t\tvar m1 = new Matrix4();\n\n\t\t\treturn function rotateZ( angle ) {\n\n\t\t\t\tm1.makeRotationZ( angle );\n\n\t\t\t\tthis.applyMatrix( m1 );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\ttranslate: function () {\n\n\t\t\t// translate geometry\n\n\t\t\tvar m1 = new Matrix4();\n\n\t\t\treturn function translate( x, y, z ) {\n\n\t\t\t\tm1.makeTranslation( x, y, z );\n\n\t\t\t\tthis.applyMatrix( m1 );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tscale: function () {\n\n\t\t\t// scale geometry\n\n\t\t\tvar m1 = new Matrix4();\n\n\t\t\treturn function scale( x, y, z ) {\n\n\t\t\t\tm1.makeScale( x, y, z );\n\n\t\t\t\tthis.applyMatrix( m1 );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tlookAt: function () {\n\n\t\t\tvar obj = new Object3D();\n\n\t\t\treturn function lookAt( vector ) {\n\n\t\t\t\tobj.lookAt( vector );\n\n\t\t\t\tobj.updateMatrix();\n\n\t\t\t\tthis.applyMatrix( obj.matrix );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tcenter: function () {\n\n\t\t\tvar offset = new Vector3();\n\n\t\t\treturn function center() {\n\n\t\t\t\tthis.computeBoundingBox();\n\n\t\t\t\tthis.boundingBox.getCenter( offset ).negate();\n\n\t\t\t\tthis.translate( offset.x, offset.y, offset.z );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tsetFromObject: function ( object ) {\n\n\t\t\t// console.log( 'THREE.BufferGeometry.setFromObject(). Converting', object, this );\n\n\t\t\tvar geometry = object.geometry;\n\n\t\t\tif ( object.isPoints || object.isLine ) {\n\n\t\t\t\tvar positions = new Float32BufferAttribute( geometry.vertices.length * 3, 3 );\n\t\t\t\tvar colors = new Float32BufferAttribute( geometry.colors.length * 3, 3 );\n\n\t\t\t\tthis.addAttribute( 'position', positions.copyVector3sArray( geometry.vertices ) );\n\t\t\t\tthis.addAttribute( 'color', colors.copyColorsArray( geometry.colors ) );\n\n\t\t\t\tif ( geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length ) {\n\n\t\t\t\t\tvar lineDistances = new Float32BufferAttribute( geometry.lineDistances.length, 1 );\n\n\t\t\t\t\tthis.addAttribute( 'lineDistance', lineDistances.copyArray( geometry.lineDistances ) );\n\n\t\t\t\t}\n\n\t\t\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t\t\t}\n\n\t\t\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t\t\t}\n\n\t\t\t} else if ( object.isMesh ) {\n\n\t\t\t\tif ( geometry && geometry.isGeometry ) {\n\n\t\t\t\t\tthis.fromGeometry( geometry );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromPoints: function ( points ) {\n\n\t\t\tvar position = [];\n\n\t\t\tfor ( var i = 0, l = points.length; i < l; i ++ ) {\n\n\t\t\t\tvar point = points[ i ];\n\t\t\t\tposition.push( point.x, point.y, point.z || 0 );\n\n\t\t\t}\n\n\t\t\tthis.addAttribute( 'position', new Float32BufferAttribute( position, 3 ) );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tupdateFromObject: function ( object ) {\n\n\t\t\tvar geometry = object.geometry;\n\n\t\t\tif ( object.isMesh ) {\n\n\t\t\t\tvar direct = geometry.__directGeometry;\n\n\t\t\t\tif ( geometry.elementsNeedUpdate === true ) {\n\n\t\t\t\t\tdirect = undefined;\n\t\t\t\t\tgeometry.elementsNeedUpdate = false;\n\n\t\t\t\t}\n\n\t\t\t\tif ( direct === undefined ) {\n\n\t\t\t\t\treturn this.fromGeometry( geometry );\n\n\t\t\t\t}\n\n\t\t\t\tdirect.verticesNeedUpdate = geometry.verticesNeedUpdate;\n\t\t\t\tdirect.normalsNeedUpdate = geometry.normalsNeedUpdate;\n\t\t\t\tdirect.colorsNeedUpdate = geometry.colorsNeedUpdate;\n\t\t\t\tdirect.uvsNeedUpdate = geometry.uvsNeedUpdate;\n\t\t\t\tdirect.groupsNeedUpdate = geometry.groupsNeedUpdate;\n\n\t\t\t\tgeometry.verticesNeedUpdate = false;\n\t\t\t\tgeometry.normalsNeedUpdate = false;\n\t\t\t\tgeometry.colorsNeedUpdate = false;\n\t\t\t\tgeometry.uvsNeedUpdate = false;\n\t\t\t\tgeometry.groupsNeedUpdate = false;\n\n\t\t\t\tgeometry = direct;\n\n\t\t\t}\n\n\t\t\tvar attribute;\n\n\t\t\tif ( geometry.verticesNeedUpdate === true ) {\n\n\t\t\t\tattribute = this.attributes.position;\n\n\t\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\t\tattribute.copyVector3sArray( geometry.vertices );\n\t\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t\t}\n\n\t\t\t\tgeometry.verticesNeedUpdate = false;\n\n\t\t\t}\n\n\t\t\tif ( geometry.normalsNeedUpdate === true ) {\n\n\t\t\t\tattribute = this.attributes.normal;\n\n\t\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\t\tattribute.copyVector3sArray( geometry.normals );\n\t\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t\t}\n\n\t\t\t\tgeometry.normalsNeedUpdate = false;\n\n\t\t\t}\n\n\t\t\tif ( geometry.colorsNeedUpdate === true ) {\n\n\t\t\t\tattribute = this.attributes.color;\n\n\t\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\t\tattribute.copyColorsArray( geometry.colors );\n\t\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t\t}\n\n\t\t\t\tgeometry.colorsNeedUpdate = false;\n\n\t\t\t}\n\n\t\t\tif ( geometry.uvsNeedUpdate ) {\n\n\t\t\t\tattribute = this.attributes.uv;\n\n\t\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\t\tattribute.copyVector2sArray( geometry.uvs );\n\t\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t\t}\n\n\t\t\t\tgeometry.uvsNeedUpdate = false;\n\n\t\t\t}\n\n\t\t\tif ( geometry.lineDistancesNeedUpdate ) {\n\n\t\t\t\tattribute = this.attributes.lineDistance;\n\n\t\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\t\tattribute.copyArray( geometry.lineDistances );\n\t\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t\t}\n\n\t\t\t\tgeometry.lineDistancesNeedUpdate = false;\n\n\t\t\t}\n\n\t\t\tif ( geometry.groupsNeedUpdate ) {\n\n\t\t\t\tgeometry.computeGroups( object.geometry );\n\t\t\t\tthis.groups = geometry.groups;\n\n\t\t\t\tgeometry.groupsNeedUpdate = false;\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tfromGeometry: function ( geometry ) {\n\n\t\t\tgeometry.__directGeometry = new DirectGeometry().fromGeometry( geometry );\n\n\t\t\treturn this.fromDirectGeometry( geometry.__directGeometry );\n\n\t\t},\n\n\t\tfromDirectGeometry: function ( geometry ) {\n\n\t\t\tvar positions = new Float32Array( geometry.vertices.length * 3 );\n\t\t\tthis.addAttribute( 'position', new BufferAttribute( positions, 3 ).copyVector3sArray( geometry.vertices ) );\n\n\t\t\tif ( geometry.normals.length > 0 ) {\n\n\t\t\t\tvar normals = new Float32Array( geometry.normals.length * 3 );\n\t\t\t\tthis.addAttribute( 'normal', new BufferAttribute( normals, 3 ).copyVector3sArray( geometry.normals ) );\n\n\t\t\t}\n\n\t\t\tif ( geometry.colors.length > 0 ) {\n\n\t\t\t\tvar colors = new Float32Array( geometry.colors.length * 3 );\n\t\t\t\tthis.addAttribute( 'color', new BufferAttribute( colors, 3 ).copyColorsArray( geometry.colors ) );\n\n\t\t\t}\n\n\t\t\tif ( geometry.uvs.length > 0 ) {\n\n\t\t\t\tvar uvs = new Float32Array( geometry.uvs.length * 2 );\n\t\t\t\tthis.addAttribute( 'uv', new BufferAttribute( uvs, 2 ).copyVector2sArray( geometry.uvs ) );\n\n\t\t\t}\n\n\t\t\tif ( geometry.uvs2.length > 0 ) {\n\n\t\t\t\tvar uvs2 = new Float32Array( geometry.uvs2.length * 2 );\n\t\t\t\tthis.addAttribute( 'uv2', new BufferAttribute( uvs2, 2 ).copyVector2sArray( geometry.uvs2 ) );\n\n\t\t\t}\n\n\t\t\t// groups\n\n\t\t\tthis.groups = geometry.groups;\n\n\t\t\t// morphs\n\n\t\t\tfor ( var name in geometry.morphTargets ) {\n\n\t\t\t\tvar array = [];\n\t\t\t\tvar morphTargets = geometry.morphTargets[ name ];\n\n\t\t\t\tfor ( var i = 0, l = morphTargets.length; i < l; i ++ ) {\n\n\t\t\t\t\tvar morphTarget = morphTargets[ i ];\n\n\t\t\t\t\tvar attribute = new Float32BufferAttribute( morphTarget.data.length * 3, 3 );\n\t\t\t\t\tattribute.name = morphTarget.name;\n\n\t\t\t\t\tarray.push( attribute.copyVector3sArray( morphTarget.data ) );\n\n\t\t\t\t}\n\n\t\t\t\tthis.morphAttributes[ name ] = array;\n\n\t\t\t}\n\n\t\t\t// skinning\n\n\t\t\tif ( geometry.skinIndices.length > 0 ) {\n\n\t\t\t\tvar skinIndices = new Float32BufferAttribute( geometry.skinIndices.length * 4, 4 );\n\t\t\t\tthis.addAttribute( 'skinIndex', skinIndices.copyVector4sArray( geometry.skinIndices ) );\n\n\t\t\t}\n\n\t\t\tif ( geometry.skinWeights.length > 0 ) {\n\n\t\t\t\tvar skinWeights = new Float32BufferAttribute( geometry.skinWeights.length * 4, 4 );\n\t\t\t\tthis.addAttribute( 'skinWeight', skinWeights.copyVector4sArray( geometry.skinWeights ) );\n\n\t\t\t}\n\n\t\t\t//\n\n\t\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t\t}\n\n\t\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcomputeBoundingBox: function () {\n\n\t\t\tif ( this.boundingBox === null ) {\n\n\t\t\t\tthis.boundingBox = new Box3();\n\n\t\t\t}\n\n\t\t\tvar position = this.attributes.position;\n\n\t\t\tif ( position !== undefined ) {\n\n\t\t\t\tthis.boundingBox.setFromBufferAttribute( position );\n\n\t\t\t} else {\n\n\t\t\t\tthis.boundingBox.makeEmpty();\n\n\t\t\t}\n\n\t\t\tif ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) {\n\n\t\t\t\tconsole.error( 'THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The \"position\" attribute is likely to have NaN values.', this );\n\n\t\t\t}\n\n\t\t},\n\n\t\tcomputeBoundingSphere: function () {\n\n\t\t\tvar box = new Box3();\n\t\t\tvar vector = new Vector3();\n\n\t\t\treturn function computeBoundingSphere() {\n\n\t\t\t\tif ( this.boundingSphere === null ) {\n\n\t\t\t\t\tthis.boundingSphere = new Sphere();\n\n\t\t\t\t}\n\n\t\t\t\tvar position = this.attributes.position;\n\n\t\t\t\tif ( position ) {\n\n\t\t\t\t\tvar center = this.boundingSphere.center;\n\n\t\t\t\t\tbox.setFromBufferAttribute( position );\n\t\t\t\t\tbox.getCenter( center );\n\n\t\t\t\t\t// hoping to find a boundingSphere with a radius smaller than the\n\t\t\t\t\t// boundingSphere of the boundingBox: sqrt(3) smaller in the best case\n\n\t\t\t\t\tvar maxRadiusSq = 0;\n\n\t\t\t\t\tfor ( var i = 0, il = position.count; i < il; i ++ ) {\n\n\t\t\t\t\t\tvector.x = position.getX( i );\n\t\t\t\t\t\tvector.y = position.getY( i );\n\t\t\t\t\t\tvector.z = position.getZ( i );\n\t\t\t\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( vector ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.boundingSphere.radius = Math.sqrt( maxRadiusSq );\n\n\t\t\t\t\tif ( isNaN( this.boundingSphere.radius ) ) {\n\n\t\t\t\t\t\tconsole.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The \"position\" attribute is likely to have NaN values.', this );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tcomputeFaceNormals: function () {\n\n\t\t\t// backwards compatibility\n\n\t\t},\n\n\t\tcomputeVertexNormals: function () {\n\n\t\t\tvar index = this.index;\n\t\t\tvar attributes = this.attributes;\n\n\t\t\tif ( attributes.position ) {\n\n\t\t\t\tvar positions = attributes.position.array;\n\n\t\t\t\tif ( attributes.normal === undefined ) {\n\n\t\t\t\t\tthis.addAttribute( 'normal', new BufferAttribute( new Float32Array( positions.length ), 3 ) );\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// reset existing normals to zero\n\n\t\t\t\t\tvar array = attributes.normal.array;\n\n\t\t\t\t\tfor ( var i = 0, il = array.length; i < il; i ++ ) {\n\n\t\t\t\t\t\tarray[ i ] = 0;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tvar normals = attributes.normal.array;\n\n\t\t\t\tvar vA, vB, vC;\n\t\t\t\tvar pA = new Vector3(), pB = new Vector3(), pC = new Vector3();\n\t\t\t\tvar cb = new Vector3(), ab = new Vector3();\n\n\t\t\t\t// indexed elements\n\n\t\t\t\tif ( index ) {\n\n\t\t\t\t\tvar indices = index.array;\n\n\t\t\t\t\tfor ( var i = 0, il = index.count; i < il; i += 3 ) {\n\n\t\t\t\t\t\tvA = indices[ i + 0 ] * 3;\n\t\t\t\t\t\tvB = indices[ i + 1 ] * 3;\n\t\t\t\t\t\tvC = indices[ i + 2 ] * 3;\n\n\t\t\t\t\t\tpA.fromArray( positions, vA );\n\t\t\t\t\t\tpB.fromArray( positions, vB );\n\t\t\t\t\t\tpC.fromArray( positions, vC );\n\n\t\t\t\t\t\tcb.subVectors( pC, pB );\n\t\t\t\t\t\tab.subVectors( pA, pB );\n\t\t\t\t\t\tcb.cross( ab );\n\n\t\t\t\t\t\tnormals[ vA ] += cb.x;\n\t\t\t\t\t\tnormals[ vA + 1 ] += cb.y;\n\t\t\t\t\t\tnormals[ vA + 2 ] += cb.z;\n\n\t\t\t\t\t\tnormals[ vB ] += cb.x;\n\t\t\t\t\t\tnormals[ vB + 1 ] += cb.y;\n\t\t\t\t\t\tnormals[ vB + 2 ] += cb.z;\n\n\t\t\t\t\t\tnormals[ vC ] += cb.x;\n\t\t\t\t\t\tnormals[ vC + 1 ] += cb.y;\n\t\t\t\t\t\tnormals[ vC + 2 ] += cb.z;\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// non-indexed elements (unconnected triangle soup)\n\n\t\t\t\t\tfor ( var i = 0, il = positions.length; i < il; i += 9 ) {\n\n\t\t\t\t\t\tpA.fromArray( positions, i );\n\t\t\t\t\t\tpB.fromArray( positions, i + 3 );\n\t\t\t\t\t\tpC.fromArray( positions, i + 6 );\n\n\t\t\t\t\t\tcb.subVectors( pC, pB );\n\t\t\t\t\t\tab.subVectors( pA, pB );\n\t\t\t\t\t\tcb.cross( ab );\n\n\t\t\t\t\t\tnormals[ i ] = cb.x;\n\t\t\t\t\t\tnormals[ i + 1 ] = cb.y;\n\t\t\t\t\t\tnormals[ i + 2 ] = cb.z;\n\n\t\t\t\t\t\tnormals[ i + 3 ] = cb.x;\n\t\t\t\t\t\tnormals[ i + 4 ] = cb.y;\n\t\t\t\t\t\tnormals[ i + 5 ] = cb.z;\n\n\t\t\t\t\t\tnormals[ i + 6 ] = cb.x;\n\t\t\t\t\t\tnormals[ i + 7 ] = cb.y;\n\t\t\t\t\t\tnormals[ i + 8 ] = cb.z;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tthis.normalizeNormals();\n\n\t\t\t\tattributes.normal.needsUpdate = true;\n\n\t\t\t}\n\n\t\t},\n\n\t\tmerge: function ( geometry, offset ) {\n\n\t\t\tif ( ! ( geometry && geometry.isBufferGeometry ) ) {\n\n\t\t\t\tconsole.error( 'THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.', geometry );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tif ( offset === undefined ) {\n\n\t\t\t\toffset = 0;\n\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. '\n\t\t\t\t\t+ 'Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge.'\n\t\t\t\t);\n\n\t\t\t}\n\n\t\t\tvar attributes = this.attributes;\n\n\t\t\tfor ( var key in attributes ) {\n\n\t\t\t\tif ( geometry.attributes[ key ] === undefined ) continue;\n\n\t\t\t\tvar attribute1 = attributes[ key ];\n\t\t\t\tvar attributeArray1 = attribute1.array;\n\n\t\t\t\tvar attribute2 = geometry.attributes[ key ];\n\t\t\t\tvar attributeArray2 = attribute2.array;\n\n\t\t\t\tvar attributeSize = attribute2.itemSize;\n\n\t\t\t\tfor ( var i = 0, j = attributeSize * offset; i < attributeArray2.length; i ++, j ++ ) {\n\n\t\t\t\t\tattributeArray1[ j ] = attributeArray2[ i ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tnormalizeNormals: function () {\n\n\t\t\tvar vector = new Vector3();\n\n\t\t\treturn function normalizeNormals() {\n\n\t\t\t\tvar normals = this.attributes.normal;\n\n\t\t\t\tfor ( var i = 0, il = normals.count; i < il; i ++ ) {\n\n\t\t\t\t\tvector.x = normals.getX( i );\n\t\t\t\t\tvector.y = normals.getY( i );\n\t\t\t\t\tvector.z = normals.getZ( i );\n\n\t\t\t\t\tvector.normalize();\n\n\t\t\t\t\tnormals.setXYZ( i, vector.x, vector.y, vector.z );\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t}(),\n\n\t\ttoNonIndexed: function () {\n\n\t\t\tif ( this.index === null ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed.' );\n\t\t\t\treturn this;\n\n\t\t\t}\n\n\t\t\tvar geometry2 = new BufferGeometry();\n\n\t\t\tvar indices = this.index.array;\n\t\t\tvar attributes = this.attributes;\n\n\t\t\tfor ( var name in attributes ) {\n\n\t\t\t\tvar attribute = attributes[ name ];\n\n\t\t\t\tvar array = attribute.array;\n\t\t\t\tvar itemSize = attribute.itemSize;\n\n\t\t\t\tvar array2 = new array.constructor( indices.length * itemSize );\n\n\t\t\t\tvar index = 0, index2 = 0;\n\n\t\t\t\tfor ( var i = 0, l = indices.length; i < l; i ++ ) {\n\n\t\t\t\t\tindex = indices[ i ] * itemSize;\n\n\t\t\t\t\tfor ( var j = 0; j < itemSize; j ++ ) {\n\n\t\t\t\t\t\tarray2[ index2 ++ ] = array[ index ++ ];\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tgeometry2.addAttribute( name, new BufferAttribute( array2, itemSize ) );\n\n\t\t\t}\n\n\t\t\tvar groups = this.groups;\n\n\t\t\tfor ( var i = 0, l = groups.length; i < l; i ++ ) {\n\n\t\t\t\tvar group = groups[ i ];\n\t\t\t\tgeometry2.addGroup( group.start, group.count, group.materialIndex );\n\n\t\t\t}\n\n\t\t\treturn geometry2;\n\n\t\t},\n\n\t\ttoJSON: function () {\n\n\t\t\tvar data = {\n\t\t\t\tmetadata: {\n\t\t\t\t\tversion: 4.5,\n\t\t\t\t\ttype: 'BufferGeometry',\n\t\t\t\t\tgenerator: 'BufferGeometry.toJSON'\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// standard BufferGeometry serialization\n\n\t\t\tdata.uuid = this.uuid;\n\t\t\tdata.type = this.type;\n\t\t\tif ( this.name !== '' ) data.name = this.name;\n\t\t\tif ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData;\n\n\t\t\tif ( this.parameters !== undefined ) {\n\n\t\t\t\tvar parameters = this.parameters;\n\n\t\t\t\tfor ( var key in parameters ) {\n\n\t\t\t\t\tif ( parameters[ key ] !== undefined ) data[ key ] = parameters[ key ];\n\n\t\t\t\t}\n\n\t\t\t\treturn data;\n\n\t\t\t}\n\n\t\t\tdata.data = { attributes: {} };\n\n\t\t\tvar index = this.index;\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\tvar array = Array.prototype.slice.call( index.array );\n\n\t\t\t\tdata.data.index = {\n\t\t\t\t\ttype: index.array.constructor.name,\n\t\t\t\t\tarray: array\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\tvar attributes = this.attributes;\n\n\t\t\tfor ( var key in attributes ) {\n\n\t\t\t\tvar attribute = attributes[ key ];\n\n\t\t\t\tvar array = Array.prototype.slice.call( attribute.array );\n\n\t\t\t\tdata.data.attributes[ key ] = {\n\t\t\t\t\titemSize: attribute.itemSize,\n\t\t\t\t\ttype: attribute.array.constructor.name,\n\t\t\t\t\tarray: array,\n\t\t\t\t\tnormalized: attribute.normalized\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\tvar groups = this.groups;\n\n\t\t\tif ( groups.length > 0 ) {\n\n\t\t\t\tdata.data.groups = JSON.parse( JSON.stringify( groups ) );\n\n\t\t\t}\n\n\t\t\tvar boundingSphere = this.boundingSphere;\n\n\t\t\tif ( boundingSphere !== null ) {\n\n\t\t\t\tdata.data.boundingSphere = {\n\t\t\t\t\tcenter: boundingSphere.center.toArray(),\n\t\t\t\t\tradius: boundingSphere.radius\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\treturn data;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\t/*\n\t\t\t // Handle primitives\n\n\t\t\t var parameters = this.parameters;\n\n\t\t\t if ( parameters !== undefined ) {\n\n\t\t\t var values = [];\n\n\t\t\t for ( var key in parameters ) {\n\n\t\t\t values.push( parameters[ key ] );\n\n\t\t\t }\n\n\t\t\t var geometry = Object.create( this.constructor.prototype );\n\t\t\t this.constructor.apply( geometry, values );\n\t\t\t return geometry;\n\n\t\t\t }\n\n\t\t\t return new this.constructor().copy( this );\n\t\t\t */\n\n\t\t\treturn new BufferGeometry().copy( this );\n\n\t\t},\n\n\t\tcopy: function ( source ) {\n\n\t\t\tvar name, i, l;\n\n\t\t\t// reset\n\n\t\t\tthis.index = null;\n\t\t\tthis.attributes = {};\n\t\t\tthis.morphAttributes = {};\n\t\t\tthis.groups = [];\n\t\t\tthis.boundingBox = null;\n\t\t\tthis.boundingSphere = null;\n\n\t\t\t// name\n\n\t\t\tthis.name = source.name;\n\n\t\t\t// index\n\n\t\t\tvar index = source.index;\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\tthis.setIndex( index.clone() );\n\n\t\t\t}\n\n\t\t\t// attributes\n\n\t\t\tvar attributes = source.attributes;\n\n\t\t\tfor ( name in attributes ) {\n\n\t\t\t\tvar attribute = attributes[ name ];\n\t\t\t\tthis.addAttribute( name, attribute.clone() );\n\n\t\t\t}\n\n\t\t\t// morph attributes\n\n\t\t\tvar morphAttributes = source.morphAttributes;\n\n\t\t\tfor ( name in morphAttributes ) {\n\n\t\t\t\tvar array = [];\n\t\t\t\tvar morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes\n\n\t\t\t\tfor ( i = 0, l = morphAttribute.length; i < l; i ++ ) {\n\n\t\t\t\t\tarray.push( morphAttribute[ i ].clone() );\n\n\t\t\t\t}\n\n\t\t\t\tthis.morphAttributes[ name ] = array;\n\n\t\t\t}\n\n\t\t\t// groups\n\n\t\t\tvar groups = source.groups;\n\n\t\t\tfor ( i = 0, l = groups.length; i < l; i ++ ) {\n\n\t\t\t\tvar group = groups[ i ];\n\t\t\t\tthis.addGroup( group.start, group.count, group.materialIndex );\n\n\t\t\t}\n\n\t\t\t// bounding box\n\n\t\t\tvar boundingBox = source.boundingBox;\n\n\t\t\tif ( boundingBox !== null ) {\n\n\t\t\t\tthis.boundingBox = boundingBox.clone();\n\n\t\t\t}\n\n\t\t\t// bounding sphere\n\n\t\t\tvar boundingSphere = source.boundingSphere;\n\n\t\t\tif ( boundingSphere !== null ) {\n\n\t\t\t\tthis.boundingSphere = boundingSphere.clone();\n\n\t\t\t}\n\n\t\t\t// draw range\n\n\t\t\tthis.drawRange.start = source.drawRange.start;\n\t\t\tthis.drawRange.count = source.drawRange.count;\n\n\t\t\t// user data\n\n\t\t\tthis.userData = source.userData;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tdispose: function () {\n\n\t\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\t// BoxGeometry\n\n\tfunction BoxGeometry( width, height, depth, widthSegments, heightSegments, depthSegments ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'BoxGeometry';\n\n\t\tthis.parameters = {\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\tdepth: depth,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\tdepthSegments: depthSegments\n\t\t};\n\n\t\tthis.fromBufferGeometry( new BoxBufferGeometry( width, height, depth, widthSegments, heightSegments, depthSegments ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tBoxGeometry.prototype = Object.create( Geometry.prototype );\n\tBoxGeometry.prototype.constructor = BoxGeometry;\n\n\t// BoxBufferGeometry\n\n\tfunction BoxBufferGeometry( width, height, depth, widthSegments, heightSegments, depthSegments ) {\n\n\t\tBufferGeometry.call( this );\n\n\t\tthis.type = 'BoxBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\tdepth: depth,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\tdepthSegments: depthSegments\n\t\t};\n\n\t\tvar scope = this;\n\n\t\twidth = width || 1;\n\t\theight = height || 1;\n\t\tdepth = depth || 1;\n\n\t\t// segments\n\n\t\twidthSegments = Math.floor( widthSegments ) || 1;\n\t\theightSegments = Math.floor( heightSegments ) || 1;\n\t\tdepthSegments = Math.floor( depthSegments ) || 1;\n\n\t\t// buffers\n\n\t\tvar indices = [];\n\t\tvar vertices = [];\n\t\tvar normals = [];\n\t\tvar uvs = [];\n\n\t\t// helper variables\n\n\t\tvar numberOfVertices = 0;\n\t\tvar groupStart = 0;\n\n\t\t// build each side of the box geometry\n\n\t\tbuildPlane( 'z', 'y', 'x', - 1, - 1, depth, height, width, depthSegments, heightSegments, 0 ); // px\n\t\tbuildPlane( 'z', 'y', 'x', 1, - 1, depth, height, - width, depthSegments, heightSegments, 1 ); // nx\n\t\tbuildPlane( 'x', 'z', 'y', 1, 1, width, depth, height, widthSegments, depthSegments, 2 ); // py\n\t\tbuildPlane( 'x', 'z', 'y', 1, - 1, width, depth, - height, widthSegments, depthSegments, 3 ); // ny\n\t\tbuildPlane( 'x', 'y', 'z', 1, - 1, width, height, depth, widthSegments, heightSegments, 4 ); // pz\n\t\tbuildPlane( 'x', 'y', 'z', - 1, - 1, width, height, - depth, widthSegments, heightSegments, 5 ); // nz\n\n\t\t// build geometry\n\n\t\tthis.setIndex( indices );\n\t\tthis.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tthis.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\t\tthis.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\t\tfunction buildPlane( u, v, w, udir, vdir, width, height, depth, gridX, gridY, materialIndex ) {\n\n\t\t\tvar segmentWidth = width / gridX;\n\t\t\tvar segmentHeight = height / gridY;\n\n\t\t\tvar widthHalf = width / 2;\n\t\t\tvar heightHalf = height / 2;\n\t\t\tvar depthHalf = depth / 2;\n\n\t\t\tvar gridX1 = gridX + 1;\n\t\t\tvar gridY1 = gridY + 1;\n\n\t\t\tvar vertexCounter = 0;\n\t\t\tvar groupCount = 0;\n\n\t\t\tvar ix, iy;\n\n\t\t\tvar vector = new Vector3();\n\n\t\t\t// generate vertices, normals and uvs\n\n\t\t\tfor ( iy = 0; iy < gridY1; iy ++ ) {\n\n\t\t\t\tvar y = iy * segmentHeight - heightHalf;\n\n\t\t\t\tfor ( ix = 0; ix < gridX1; ix ++ ) {\n\n\t\t\t\t\tvar x = ix * segmentWidth - widthHalf;\n\n\t\t\t\t\t// set values to correct vector component\n\n\t\t\t\t\tvector[ u ] = x * udir;\n\t\t\t\t\tvector[ v ] = y * vdir;\n\t\t\t\t\tvector[ w ] = depthHalf;\n\n\t\t\t\t\t// now apply vector to vertex buffer\n\n\t\t\t\t\tvertices.push( vector.x, vector.y, vector.z );\n\n\t\t\t\t\t// set values to correct vector component\n\n\t\t\t\t\tvector[ u ] = 0;\n\t\t\t\t\tvector[ v ] = 0;\n\t\t\t\t\tvector[ w ] = depth > 0 ? 1 : - 1;\n\n\t\t\t\t\t// now apply vector to normal buffer\n\n\t\t\t\t\tnormals.push( vector.x, vector.y, vector.z );\n\n\t\t\t\t\t// uvs\n\n\t\t\t\t\tuvs.push( ix / gridX );\n\t\t\t\t\tuvs.push( 1 - ( iy / gridY ) );\n\n\t\t\t\t\t// counters\n\n\t\t\t\t\tvertexCounter += 1;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// indices\n\n\t\t\t// 1. you need three indices to draw a single face\n\t\t\t// 2. a single segment consists of two faces\n\t\t\t// 3. so we need to generate six (2*3) indices per segment\n\n\t\t\tfor ( iy = 0; iy < gridY; iy ++ ) {\n\n\t\t\t\tfor ( ix = 0; ix < gridX; ix ++ ) {\n\n\t\t\t\t\tvar a = numberOfVertices + ix + gridX1 * iy;\n\t\t\t\t\tvar b = numberOfVertices + ix + gridX1 * ( iy + 1 );\n\t\t\t\t\tvar c = numberOfVertices + ( ix + 1 ) + gridX1 * ( iy + 1 );\n\t\t\t\t\tvar d = numberOfVertices + ( ix + 1 ) + gridX1 * iy;\n\n\t\t\t\t\t// faces\n\n\t\t\t\t\tindices.push( a, b, d );\n\t\t\t\t\tindices.push( b, c, d );\n\n\t\t\t\t\t// increase counter\n\n\t\t\t\t\tgroupCount += 6;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// add a group to the geometry. this will ensure multi material support\n\n\t\t\tscope.addGroup( groupStart, groupCount, materialIndex );\n\n\t\t\t// calculate new start value for groups\n\n\t\t\tgroupStart += groupCount;\n\n\t\t\t// update total number of vertices\n\n\t\t\tnumberOfVertices += vertexCounter;\n\n\t\t}\n\n\t}\n\n\tBoxBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\n\tBoxBufferGeometry.prototype.constructor = BoxBufferGeometry;\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\t// PlaneGeometry\n\n\tfunction PlaneGeometry( width, height, widthSegments, heightSegments ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'PlaneGeometry';\n\n\t\tthis.parameters = {\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments\n\t\t};\n\n\t\tthis.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tPlaneGeometry.prototype = Object.create( Geometry.prototype );\n\tPlaneGeometry.prototype.constructor = PlaneGeometry;\n\n\t// PlaneBufferGeometry\n\n\tfunction PlaneBufferGeometry( width, height, widthSegments, heightSegments ) {\n\n\t\tBufferGeometry.call( this );\n\n\t\tthis.type = 'PlaneBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments\n\t\t};\n\n\t\twidth = width || 1;\n\t\theight = height || 1;\n\n\t\tvar width_half = width / 2;\n\t\tvar height_half = height / 2;\n\n\t\tvar gridX = Math.floor( widthSegments ) || 1;\n\t\tvar gridY = Math.floor( heightSegments ) || 1;\n\n\t\tvar gridX1 = gridX + 1;\n\t\tvar gridY1 = gridY + 1;\n\n\t\tvar segment_width = width / gridX;\n\t\tvar segment_height = height / gridY;\n\n\t\tvar ix, iy;\n\n\t\t// buffers\n\n\t\tvar indices = [];\n\t\tvar vertices = [];\n\t\tvar normals = [];\n\t\tvar uvs = [];\n\n\t\t// generate vertices, normals and uvs\n\n\t\tfor ( iy = 0; iy < gridY1; iy ++ ) {\n\n\t\t\tvar y = iy * segment_height - height_half;\n\n\t\t\tfor ( ix = 0; ix < gridX1; ix ++ ) {\n\n\t\t\t\tvar x = ix * segment_width - width_half;\n\n\t\t\t\tvertices.push( x, - y, 0 );\n\n\t\t\t\tnormals.push( 0, 0, 1 );\n\n\t\t\t\tuvs.push( ix / gridX );\n\t\t\t\tuvs.push( 1 - ( iy / gridY ) );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// indices\n\n\t\tfor ( iy = 0; iy < gridY; iy ++ ) {\n\n\t\t\tfor ( ix = 0; ix < gridX; ix ++ ) {\n\n\t\t\t\tvar a = ix + gridX1 * iy;\n\t\t\t\tvar b = ix + gridX1 * ( iy + 1 );\n\t\t\t\tvar c = ( ix + 1 ) + gridX1 * ( iy + 1 );\n\t\t\t\tvar d = ( ix + 1 ) + gridX1 * iy;\n\n\t\t\t\t// faces\n\n\t\t\t\tindices.push( a, b, d );\n\t\t\t\tindices.push( b, c, d );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// build geometry\n\n\t\tthis.setIndex( indices );\n\t\tthis.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tthis.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\t\tthis.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\t}\n\n\tPlaneBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\n\tPlaneBufferGeometry.prototype.constructor = PlaneBufferGeometry;\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author alteredq / http://alteredqualia.com/\n\t */\n\n\tvar materialId = 0;\n\n\tfunction Material() {\n\n\t\tObject.defineProperty( this, 'id', { value: materialId ++ } );\n\n\t\tthis.uuid = _Math.generateUUID();\n\n\t\tthis.name = '';\n\t\tthis.type = 'Material';\n\n\t\tthis.fog = true;\n\t\tthis.lights = true;\n\n\t\tthis.blending = NormalBlending;\n\t\tthis.side = FrontSide;\n\t\tthis.flatShading = false;\n\t\tthis.vertexColors = NoColors; // THREE.NoColors, THREE.VertexColors, THREE.FaceColors\n\n\t\tthis.opacity = 1;\n\t\tthis.transparent = false;\n\n\t\tthis.blendSrc = SrcAlphaFactor;\n\t\tthis.blendDst = OneMinusSrcAlphaFactor;\n\t\tthis.blendEquation = AddEquation;\n\t\tthis.blendSrcAlpha = null;\n\t\tthis.blendDstAlpha = null;\n\t\tthis.blendEquationAlpha = null;\n\n\t\tthis.depthFunc = LessEqualDepth;\n\t\tthis.depthTest = true;\n\t\tthis.depthWrite = true;\n\n\t\tthis.clippingPlanes = null;\n\t\tthis.clipIntersection = false;\n\t\tthis.clipShadows = false;\n\n\t\tthis.shadowSide = null;\n\n\t\tthis.colorWrite = true;\n\n\t\tthis.precision = null; // override the renderer's default precision for this material\n\n\t\tthis.polygonOffset = false;\n\t\tthis.polygonOffsetFactor = 0;\n\t\tthis.polygonOffsetUnits = 0;\n\n\t\tthis.dithering = false;\n\n\t\tthis.alphaTest = 0;\n\t\tthis.premultipliedAlpha = false;\n\n\t\tthis.visible = true;\n\n\t\tthis.userData = {};\n\n\t\tthis.needsUpdate = true;\n\n\t}\n\n\tMaterial.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\t\tconstructor: Material,\n\n\t\tisMaterial: true,\n\n\t\tonBeforeCompile: function () {},\n\n\t\tsetValues: function ( values ) {\n\n\t\t\tif ( values === undefined ) return;\n\n\t\t\tfor ( var key in values ) {\n\n\t\t\t\tvar newValue = values[ key ];\n\n\t\t\t\tif ( newValue === undefined ) {\n\n\t\t\t\t\tconsole.warn( \"THREE.Material: '\" + key + \"' parameter is undefined.\" );\n\t\t\t\t\tcontinue;\n\n\t\t\t\t}\n\n\t\t\t\t// for backward compatability if shading is set in the constructor\n\t\t\t\tif ( key === 'shading' ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.' );\n\t\t\t\t\tthis.flatShading = ( newValue === FlatShading ) ? true : false;\n\t\t\t\t\tcontinue;\n\n\t\t\t\t}\n\n\t\t\t\tvar currentValue = this[ key ];\n\n\t\t\t\tif ( currentValue === undefined ) {\n\n\t\t\t\t\tconsole.warn( \"THREE.\" + this.type + \": '\" + key + \"' is not a property of this material.\" );\n\t\t\t\t\tcontinue;\n\n\t\t\t\t}\n\n\t\t\t\tif ( currentValue && currentValue.isColor ) {\n\n\t\t\t\t\tcurrentValue.set( newValue );\n\n\t\t\t\t} else if ( ( currentValue && currentValue.isVector3 ) && ( newValue && newValue.isVector3 ) ) {\n\n\t\t\t\t\tcurrentValue.copy( newValue );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis[ key ] = newValue;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t},\n\n\t\ttoJSON: function ( meta ) {\n\n\t\t\tvar isRoot = ( meta === undefined || typeof meta === 'string' );\n\n\t\t\tif ( isRoot ) {\n\n\t\t\t\tmeta = {\n\t\t\t\t\ttextures: {},\n\t\t\t\t\timages: {}\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\tvar data = {\n\t\t\t\tmetadata: {\n\t\t\t\t\tversion: 4.5,\n\t\t\t\t\ttype: 'Material',\n\t\t\t\t\tgenerator: 'Material.toJSON'\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// standard Material serialization\n\t\t\tdata.uuid = this.uuid;\n\t\t\tdata.type = this.type;\n\n\t\t\tif ( this.name !== '' ) data.name = this.name;\n\n\t\t\tif ( this.color && this.color.isColor ) data.color = this.color.getHex();\n\n\t\t\tif ( this.roughness !== undefined ) data.roughness = this.roughness;\n\t\t\tif ( this.metalness !== undefined ) data.metalness = this.metalness;\n\n\t\t\tif ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex();\n\t\t\tif ( this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;\n\n\t\t\tif ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex();\n\t\t\tif ( this.shininess !== undefined ) data.shininess = this.shininess;\n\t\t\tif ( this.clearCoat !== undefined ) data.clearCoat = this.clearCoat;\n\t\t\tif ( this.clearCoatRoughness !== undefined ) data.clearCoatRoughness = this.clearCoatRoughness;\n\n\t\t\tif ( this.map && this.map.isTexture ) data.map = this.map.toJSON( meta ).uuid;\n\t\t\tif ( this.alphaMap && this.alphaMap.isTexture ) data.alphaMap = this.alphaMap.toJSON( meta ).uuid;\n\t\t\tif ( this.lightMap && this.lightMap.isTexture ) data.lightMap = this.lightMap.toJSON( meta ).uuid;\n\n\t\t\tif ( this.aoMap && this.aoMap.isTexture ) {\n\n\t\t\t\tdata.aoMap = this.aoMap.toJSON( meta ).uuid;\n\t\t\t\tdata.aoMapIntensity = this.aoMapIntensity;\n\n\t\t\t}\n\n\t\t\tif ( this.bumpMap && this.bumpMap.isTexture ) {\n\n\t\t\t\tdata.bumpMap = this.bumpMap.toJSON( meta ).uuid;\n\t\t\t\tdata.bumpScale = this.bumpScale;\n\n\t\t\t}\n\n\t\t\tif ( this.normalMap && this.normalMap.isTexture ) {\n\n\t\t\t\tdata.normalMap = this.normalMap.toJSON( meta ).uuid;\n\t\t\t\tdata.normalMapType = this.normalMapType;\n\t\t\t\tdata.normalScale = this.normalScale.toArray();\n\n\t\t\t}\n\n\t\t\tif ( this.displacementMap && this.displacementMap.isTexture ) {\n\n\t\t\t\tdata.displacementMap = this.displacementMap.toJSON( meta ).uuid;\n\t\t\t\tdata.displacementScale = this.displacementScale;\n\t\t\t\tdata.displacementBias = this.displacementBias;\n\n\t\t\t}\n\n\t\t\tif ( this.roughnessMap && this.roughnessMap.isTexture ) data.roughnessMap = this.roughnessMap.toJSON( meta ).uuid;\n\t\t\tif ( this.metalnessMap && this.metalnessMap.isTexture ) data.metalnessMap = this.metalnessMap.toJSON( meta ).uuid;\n\n\t\t\tif ( this.emissiveMap && this.emissiveMap.isTexture ) data.emissiveMap = this.emissiveMap.toJSON( meta ).uuid;\n\t\t\tif ( this.specularMap && this.specularMap.isTexture ) data.specularMap = this.specularMap.toJSON( meta ).uuid;\n\n\t\t\tif ( this.envMap && this.envMap.isTexture ) {\n\n\t\t\t\tdata.envMap = this.envMap.toJSON( meta ).uuid;\n\t\t\t\tdata.reflectivity = this.reflectivity; // Scale behind envMap\n\n\t\t\t\tif ( this.combine !== undefined ) data.combine = this.combine;\n\t\t\t\tif ( this.envMapIntensity !== undefined ) data.envMapIntensity = this.envMapIntensity;\n\n\t\t\t}\n\n\t\t\tif ( this.gradientMap && this.gradientMap.isTexture ) {\n\n\t\t\t\tdata.gradientMap = this.gradientMap.toJSON( meta ).uuid;\n\n\t\t\t}\n\n\t\t\tif ( this.size !== undefined ) data.size = this.size;\n\t\t\tif ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation;\n\n\t\t\tif ( this.blending !== NormalBlending ) data.blending = this.blending;\n\t\t\tif ( this.flatShading === true ) data.flatShading = this.flatShading;\n\t\t\tif ( this.side !== FrontSide ) data.side = this.side;\n\t\t\tif ( this.vertexColors !== NoColors ) data.vertexColors = this.vertexColors;\n\n\t\t\tif ( this.opacity < 1 ) data.opacity = this.opacity;\n\t\t\tif ( this.transparent === true ) data.transparent = this.transparent;\n\n\t\t\tdata.depthFunc = this.depthFunc;\n\t\t\tdata.depthTest = this.depthTest;\n\t\t\tdata.depthWrite = this.depthWrite;\n\n\t\t\t// rotation (SpriteMaterial)\n\t\t\tif ( this.rotation !== 0 ) data.rotation = this.rotation;\n\n\t\t\tif ( this.polygonOffset === true ) data.polygonOffset = true;\n\t\t\tif ( this.polygonOffsetFactor !== 0 ) data.polygonOffsetFactor = this.polygonOffsetFactor;\n\t\t\tif ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits;\n\n\t\t\tif ( this.linewidth !== 1 ) data.linewidth = this.linewidth;\n\t\t\tif ( this.dashSize !== undefined ) data.dashSize = this.dashSize;\n\t\t\tif ( this.gapSize !== undefined ) data.gapSize = this.gapSize;\n\t\t\tif ( this.scale !== undefined ) data.scale = this.scale;\n\n\t\t\tif ( this.dithering === true ) data.dithering = true;\n\n\t\t\tif ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest;\n\t\t\tif ( this.premultipliedAlpha === true ) data.premultipliedAlpha = this.premultipliedAlpha;\n\n\t\t\tif ( this.wireframe === true ) data.wireframe = this.wireframe;\n\t\t\tif ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;\n\t\t\tif ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap;\n\t\t\tif ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin;\n\n\t\t\tif ( this.morphTargets === true ) data.morphTargets = true;\n\t\t\tif ( this.skinning === true ) data.skinning = true;\n\n\t\t\tif ( this.visible === false ) data.visible = false;\n\t\t\tif ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData;\n\n\t\t\t// TODO: Copied from Object3D.toJSON\n\n\t\t\tfunction extractFromCache( cache ) {\n\n\t\t\t\tvar values = [];\n\n\t\t\t\tfor ( var key in cache ) {\n\n\t\t\t\t\tvar data = cache[ key ];\n\t\t\t\t\tdelete data.metadata;\n\t\t\t\t\tvalues.push( data );\n\n\t\t\t\t}\n\n\t\t\t\treturn values;\n\n\t\t\t}\n\n\t\t\tif ( isRoot ) {\n\n\t\t\t\tvar textures = extractFromCache( meta.textures );\n\t\t\t\tvar images = extractFromCache( meta.images );\n\n\t\t\t\tif ( textures.length > 0 ) data.textures = textures;\n\t\t\t\tif ( images.length > 0 ) data.images = images;\n\n\t\t\t}\n\n\t\t\treturn data;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t},\n\n\t\tcopy: function ( source ) {\n\n\t\t\tthis.name = source.name;\n\n\t\t\tthis.fog = source.fog;\n\t\t\tthis.lights = source.lights;\n\n\t\t\tthis.blending = source.blending;\n\t\t\tthis.side = source.side;\n\t\t\tthis.flatShading = source.flatShading;\n\t\t\tthis.vertexColors = source.vertexColors;\n\n\t\t\tthis.opacity = source.opacity;\n\t\t\tthis.transparent = source.transparent;\n\n\t\t\tthis.blendSrc = source.blendSrc;\n\t\t\tthis.blendDst = source.blendDst;\n\t\t\tthis.blendEquation = source.blendEquation;\n\t\t\tthis.blendSrcAlpha = source.blendSrcAlpha;\n\t\t\tthis.blendDstAlpha = source.blendDstAlpha;\n\t\t\tthis.blendEquationAlpha = source.blendEquationAlpha;\n\n\t\t\tthis.depthFunc = source.depthFunc;\n\t\t\tthis.depthTest = source.depthTest;\n\t\t\tthis.depthWrite = source.depthWrite;\n\n\t\t\tthis.colorWrite = source.colorWrite;\n\n\t\t\tthis.precision = source.precision;\n\n\t\t\tthis.polygonOffset = source.polygonOffset;\n\t\t\tthis.polygonOffsetFactor = source.polygonOffsetFactor;\n\t\t\tthis.polygonOffsetUnits = source.polygonOffsetUnits;\n\n\t\t\tthis.dithering = source.dithering;\n\n\t\t\tthis.alphaTest = source.alphaTest;\n\t\t\tthis.premultipliedAlpha = source.premultipliedAlpha;\n\n\t\t\tthis.visible = source.visible;\n\t\t\tthis.userData = JSON.parse( JSON.stringify( source.userData ) );\n\n\t\t\tthis.clipShadows = source.clipShadows;\n\t\t\tthis.clipIntersection = source.clipIntersection;\n\n\t\t\tvar srcPlanes = source.clippingPlanes,\n\t\t\t\tdstPlanes = null;\n\n\t\t\tif ( srcPlanes !== null ) {\n\n\t\t\t\tvar n = srcPlanes.length;\n\t\t\t\tdstPlanes = new Array( n );\n\n\t\t\t\tfor ( var i = 0; i !== n; ++ i )\n\t\t\t\t\tdstPlanes[ i ] = srcPlanes[ i ].clone();\n\n\t\t\t}\n\n\t\t\tthis.clippingPlanes = dstPlanes;\n\n\t\t\tthis.shadowSide = source.shadowSide;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tdispose: function () {\n\n\t\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t *\n\t * parameters = {\n\t *  defines: { \"label\" : \"value\" },\n\t *  uniforms: { \"parameter1\": { value: 1.0 }, \"parameter2\": { value2: 2 } },\n\t *\n\t *  fragmentShader: <string>,\n\t *  vertexShader: <string>,\n\t *\n\t *  wireframe: <boolean>,\n\t *  wireframeLinewidth: <float>,\n\t *\n\t *  lights: <bool>,\n\t *\n\t *  skinning: <bool>,\n\t *  morphTargets: <bool>,\n\t *  morphNormals: <bool>\n\t * }\n\t */\n\n\tfunction ShaderMaterial( parameters ) {\n\n\t\tMaterial.call( this );\n\n\t\tthis.type = 'ShaderMaterial';\n\n\t\tthis.defines = {};\n\t\tthis.uniforms = {};\n\n\t\tthis.vertexShader = 'void main() {\\n\\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\\n}';\n\t\tthis.fragmentShader = 'void main() {\\n\\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\\n}';\n\n\t\tthis.linewidth = 1;\n\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\n\t\tthis.fog = false; // set to use scene fog\n\t\tthis.lights = false; // set to use scene lights\n\t\tthis.clipping = false; // set to use user-defined clipping planes\n\n\t\tthis.skinning = false; // set to use skinning attribute streams\n\t\tthis.morphTargets = false; // set to use morph targets\n\t\tthis.morphNormals = false; // set to use morph normals\n\n\t\tthis.extensions = {\n\t\t\tderivatives: false, // set to use derivatives\n\t\t\tfragDepth: false, // set to use fragment depth values\n\t\t\tdrawBuffers: false, // set to use draw buffers\n\t\t\tshaderTextureLOD: false // set to use shader texture LOD\n\t\t};\n\n\t\t// When rendered geometry doesn't include these attributes but the material does,\n\t\t// use these default values in WebGL. This avoids errors when buffer data is missing.\n\t\tthis.defaultAttributeValues = {\n\t\t\t'color': [ 1, 1, 1 ],\n\t\t\t'uv': [ 0, 0 ],\n\t\t\t'uv2': [ 0, 0 ]\n\t\t};\n\n\t\tthis.index0AttributeName = undefined;\n\t\tthis.uniformsNeedUpdate = false;\n\n\t\tif ( parameters !== undefined ) {\n\n\t\t\tif ( parameters.attributes !== undefined ) {\n\n\t\t\t\tconsole.error( 'THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead.' );\n\n\t\t\t}\n\n\t\t\tthis.setValues( parameters );\n\n\t\t}\n\n\t}\n\n\tShaderMaterial.prototype = Object.create( Material.prototype );\n\tShaderMaterial.prototype.constructor = ShaderMaterial;\n\n\tShaderMaterial.prototype.isShaderMaterial = true;\n\n\tShaderMaterial.prototype.copy = function ( source ) {\n\n\t\tMaterial.prototype.copy.call( this, source );\n\n\t\tthis.fragmentShader = source.fragmentShader;\n\t\tthis.vertexShader = source.vertexShader;\n\n\t\tthis.uniforms = cloneUniforms( source.uniforms );\n\n\t\tthis.defines = Object.assign( {}, source.defines );\n\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\n\t\tthis.lights = source.lights;\n\t\tthis.clipping = source.clipping;\n\n\t\tthis.skinning = source.skinning;\n\n\t\tthis.morphTargets = source.morphTargets;\n\t\tthis.morphNormals = source.morphNormals;\n\n\t\tthis.extensions = source.extensions;\n\n\t\treturn this;\n\n\t};\n\n\tShaderMaterial.prototype.toJSON = function ( meta ) {\n\n\t\tvar data = Material.prototype.toJSON.call( this, meta );\n\n\t\tdata.uniforms = {};\n\n\t\tfor ( var name in this.uniforms ) {\n\n\t\t\tvar uniform = this.uniforms[ name ];\n\t\t\tvar value = uniform.value;\n\n\t\t\tif ( value && value.isTexture ) {\n\n\t\t\t\tdata.uniforms[ name ] = {\n\t\t\t\t\ttype: 't',\n\t\t\t\t\tvalue: value.toJSON( meta ).uuid\n\t\t\t\t};\n\n\t\t\t} else if ( value && value.isColor ) {\n\n\t\t\t\tdata.uniforms[ name ] = {\n\t\t\t\t\ttype: 'c',\n\t\t\t\t\tvalue: value.getHex()\n\t\t\t\t};\n\n\t\t\t} else if ( value && value.isVector2 ) {\n\n\t\t\t\tdata.uniforms[ name ] = {\n\t\t\t\t\ttype: 'v2',\n\t\t\t\t\tvalue: value.toArray()\n\t\t\t\t};\n\n\t\t\t} else if ( value && value.isVector3 ) {\n\n\t\t\t\tdata.uniforms[ name ] = {\n\t\t\t\t\ttype: 'v3',\n\t\t\t\t\tvalue: value.toArray()\n\t\t\t\t};\n\n\t\t\t} else if ( value && value.isVector4 ) {\n\n\t\t\t\tdata.uniforms[ name ] = {\n\t\t\t\t\ttype: 'v4',\n\t\t\t\t\tvalue: value.toArray()\n\t\t\t\t};\n\n\t\t\t} else if ( value && value.isMatrix4 ) {\n\n\t\t\t\tdata.uniforms[ name ] = {\n\t\t\t\t\ttype: 'm4',\n\t\t\t\t\tvalue: value.toArray()\n\t\t\t\t};\n\n\t\t\t} else {\n\n\t\t\t\tdata.uniforms[ name ] = {\n\t\t\t\t\tvalue: value\n\t\t\t\t};\n\n\t\t\t\t// note: the array variants v2v, v3v, v4v, m4v and tv are not supported so far\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( Object.keys( this.defines ).length > 0 ) data.defines = this.defines;\n\n\t\tdata.vertexShader = this.vertexShader;\n\t\tdata.fragmentShader = this.fragmentShader;\n\n\t\tvar extensions = {};\n\n\t\tfor ( var key in this.extensions ) {\n\n\t\t\tif ( this.extensions[ key ] === true ) extensions[ key ] = true;\n\n\t\t}\n\n\t\tif ( Object.keys( extensions ).length > 0 ) data.extensions = extensions;\n\n\t\treturn data;\n\n\t};\n\n\t/**\n\t * @author bhouston / http://clara.io\n\t */\n\n\tfunction Ray( origin, direction ) {\n\n\t\tthis.origin = ( origin !== undefined ) ? origin : new Vector3();\n\t\tthis.direction = ( direction !== undefined ) ? direction : new Vector3();\n\n\t}\n\n\tObject.assign( Ray.prototype, {\n\n\t\tset: function ( origin, direction ) {\n\n\t\t\tthis.origin.copy( origin );\n\t\t\tthis.direction.copy( direction );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t},\n\n\t\tcopy: function ( ray ) {\n\n\t\t\tthis.origin.copy( ray.origin );\n\t\t\tthis.direction.copy( ray.direction );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tat: function ( t, target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Ray: .at() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\treturn target.copy( this.direction ).multiplyScalar( t ).add( this.origin );\n\n\t\t},\n\n\t\tlookAt: function ( v ) {\n\n\t\t\tthis.direction.copy( v ).sub( this.origin ).normalize();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\trecast: function () {\n\n\t\t\tvar v1 = new Vector3();\n\n\t\t\treturn function recast( t ) {\n\n\t\t\t\tthis.origin.copy( this.at( t, v1 ) );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tclosestPointToPoint: function ( point, target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Ray: .closestPointToPoint() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\ttarget.subVectors( point, this.origin );\n\n\t\t\tvar directionDistance = target.dot( this.direction );\n\n\t\t\tif ( directionDistance < 0 ) {\n\n\t\t\t\treturn target.copy( this.origin );\n\n\t\t\t}\n\n\t\t\treturn target.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );\n\n\t\t},\n\n\t\tdistanceToPoint: function ( point ) {\n\n\t\t\treturn Math.sqrt( this.distanceSqToPoint( point ) );\n\n\t\t},\n\n\t\tdistanceSqToPoint: function () {\n\n\t\t\tvar v1 = new Vector3();\n\n\t\t\treturn function distanceSqToPoint( point ) {\n\n\t\t\t\tvar directionDistance = v1.subVectors( point, this.origin ).dot( this.direction );\n\n\t\t\t\t// point behind the ray\n\n\t\t\t\tif ( directionDistance < 0 ) {\n\n\t\t\t\t\treturn this.origin.distanceToSquared( point );\n\n\t\t\t\t}\n\n\t\t\t\tv1.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );\n\n\t\t\t\treturn v1.distanceToSquared( point );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tdistanceSqToSegment: function () {\n\n\t\t\tvar segCenter = new Vector3();\n\t\t\tvar segDir = new Vector3();\n\t\t\tvar diff = new Vector3();\n\n\t\t\treturn function distanceSqToSegment( v0, v1, optionalPointOnRay, optionalPointOnSegment ) {\n\n\t\t\t\t// from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistRaySegment.h\n\t\t\t\t// It returns the min distance between the ray and the segment\n\t\t\t\t// defined by v0 and v1\n\t\t\t\t// It can also set two optional targets :\n\t\t\t\t// - The closest point on the ray\n\t\t\t\t// - The closest point on the segment\n\n\t\t\t\tsegCenter.copy( v0 ).add( v1 ).multiplyScalar( 0.5 );\n\t\t\t\tsegDir.copy( v1 ).sub( v0 ).normalize();\n\t\t\t\tdiff.copy( this.origin ).sub( segCenter );\n\n\t\t\t\tvar segExtent = v0.distanceTo( v1 ) * 0.5;\n\t\t\t\tvar a01 = - this.direction.dot( segDir );\n\t\t\t\tvar b0 = diff.dot( this.direction );\n\t\t\t\tvar b1 = - diff.dot( segDir );\n\t\t\t\tvar c = diff.lengthSq();\n\t\t\t\tvar det = Math.abs( 1 - a01 * a01 );\n\t\t\t\tvar s0, s1, sqrDist, extDet;\n\n\t\t\t\tif ( det > 0 ) {\n\n\t\t\t\t\t// The ray and segment are not parallel.\n\n\t\t\t\t\ts0 = a01 * b1 - b0;\n\t\t\t\t\ts1 = a01 * b0 - b1;\n\t\t\t\t\textDet = segExtent * det;\n\n\t\t\t\t\tif ( s0 >= 0 ) {\n\n\t\t\t\t\t\tif ( s1 >= - extDet ) {\n\n\t\t\t\t\t\t\tif ( s1 <= extDet ) {\n\n\t\t\t\t\t\t\t\t// region 0\n\t\t\t\t\t\t\t\t// Minimum at interior points of ray and segment.\n\n\t\t\t\t\t\t\t\tvar invDet = 1 / det;\n\t\t\t\t\t\t\t\ts0 *= invDet;\n\t\t\t\t\t\t\t\ts1 *= invDet;\n\t\t\t\t\t\t\t\tsqrDist = s0 * ( s0 + a01 * s1 + 2 * b0 ) + s1 * ( a01 * s0 + s1 + 2 * b1 ) + c;\n\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t// region 1\n\n\t\t\t\t\t\t\t\ts1 = segExtent;\n\t\t\t\t\t\t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n\t\t\t\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t// region 5\n\n\t\t\t\t\t\t\ts1 = - segExtent;\n\t\t\t\t\t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n\t\t\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tif ( s1 <= - extDet ) {\n\n\t\t\t\t\t\t\t// region 4\n\n\t\t\t\t\t\t\ts0 = Math.max( 0, - ( - a01 * segExtent + b0 ) );\n\t\t\t\t\t\t\ts1 = ( s0 > 0 ) ? - segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );\n\t\t\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t\t\t} else if ( s1 <= extDet ) {\n\n\t\t\t\t\t\t\t// region 3\n\n\t\t\t\t\t\t\ts0 = 0;\n\t\t\t\t\t\t\ts1 = Math.min( Math.max( - segExtent, - b1 ), segExtent );\n\t\t\t\t\t\t\tsqrDist = s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t// region 2\n\n\t\t\t\t\t\t\ts0 = Math.max( 0, - ( a01 * segExtent + b0 ) );\n\t\t\t\t\t\t\ts1 = ( s0 > 0 ) ? segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );\n\t\t\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// Ray and segment are parallel.\n\n\t\t\t\t\ts1 = ( a01 > 0 ) ? - segExtent : segExtent;\n\t\t\t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t}\n\n\t\t\t\tif ( optionalPointOnRay ) {\n\n\t\t\t\t\toptionalPointOnRay.copy( this.direction ).multiplyScalar( s0 ).add( this.origin );\n\n\t\t\t\t}\n\n\t\t\t\tif ( optionalPointOnSegment ) {\n\n\t\t\t\t\toptionalPointOnSegment.copy( segDir ).multiplyScalar( s1 ).add( segCenter );\n\n\t\t\t\t}\n\n\t\t\t\treturn sqrDist;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tintersectSphere: function () {\n\n\t\t\tvar v1 = new Vector3();\n\n\t\t\treturn function intersectSphere( sphere, target ) {\n\n\t\t\t\tv1.subVectors( sphere.center, this.origin );\n\t\t\t\tvar tca = v1.dot( this.direction );\n\t\t\t\tvar d2 = v1.dot( v1 ) - tca * tca;\n\t\t\t\tvar radius2 = sphere.radius * sphere.radius;\n\n\t\t\t\tif ( d2 > radius2 ) return null;\n\n\t\t\t\tvar thc = Math.sqrt( radius2 - d2 );\n\n\t\t\t\t// t0 = first intersect point - entrance on front of sphere\n\t\t\t\tvar t0 = tca - thc;\n\n\t\t\t\t// t1 = second intersect point - exit point on back of sphere\n\t\t\t\tvar t1 = tca + thc;\n\n\t\t\t\t// test to see if both t0 and t1 are behind the ray - if so, return null\n\t\t\t\tif ( t0 < 0 && t1 < 0 ) return null;\n\n\t\t\t\t// test to see if t0 is behind the ray:\n\t\t\t\t// if it is, the ray is inside the sphere, so return the second exit point scaled by t1,\n\t\t\t\t// in order to always return an intersect point that is in front of the ray.\n\t\t\t\tif ( t0 < 0 ) return this.at( t1, target );\n\n\t\t\t\t// else t0 is in front of the ray, so return the first collision point scaled by t0\n\t\t\t\treturn this.at( t0, target );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tintersectsSphere: function ( sphere ) {\n\n\t\t\treturn this.distanceSqToPoint( sphere.center ) <= ( sphere.radius * sphere.radius );\n\n\t\t},\n\n\t\tdistanceToPlane: function ( plane ) {\n\n\t\t\tvar denominator = plane.normal.dot( this.direction );\n\n\t\t\tif ( denominator === 0 ) {\n\n\t\t\t\t// line is coplanar, return origin\n\t\t\t\tif ( plane.distanceToPoint( this.origin ) === 0 ) {\n\n\t\t\t\t\treturn 0;\n\n\t\t\t\t}\n\n\t\t\t\t// Null is preferable to undefined since undefined means.... it is undefined\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t\tvar t = - ( this.origin.dot( plane.normal ) + plane.constant ) / denominator;\n\n\t\t\t// Return if the ray never intersects the plane\n\n\t\t\treturn t >= 0 ? t : null;\n\n\t\t},\n\n\t\tintersectPlane: function ( plane, target ) {\n\n\t\t\tvar t = this.distanceToPlane( plane );\n\n\t\t\tif ( t === null ) {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t\treturn this.at( t, target );\n\n\t\t},\n\n\t\tintersectsPlane: function ( plane ) {\n\n\t\t\t// check if the ray lies on the plane first\n\n\t\t\tvar distToPoint = plane.distanceToPoint( this.origin );\n\n\t\t\tif ( distToPoint === 0 ) {\n\n\t\t\t\treturn true;\n\n\t\t\t}\n\n\t\t\tvar denominator = plane.normal.dot( this.direction );\n\n\t\t\tif ( denominator * distToPoint < 0 ) {\n\n\t\t\t\treturn true;\n\n\t\t\t}\n\n\t\t\t// ray origin is behind the plane (and is pointing behind it)\n\n\t\t\treturn false;\n\n\t\t},\n\n\t\tintersectBox: function ( box, target ) {\n\n\t\t\tvar tmin, tmax, tymin, tymax, tzmin, tzmax;\n\n\t\t\tvar invdirx = 1 / this.direction.x,\n\t\t\t\tinvdiry = 1 / this.direction.y,\n\t\t\t\tinvdirz = 1 / this.direction.z;\n\n\t\t\tvar origin = this.origin;\n\n\t\t\tif ( invdirx >= 0 ) {\n\n\t\t\t\ttmin = ( box.min.x - origin.x ) * invdirx;\n\t\t\t\ttmax = ( box.max.x - origin.x ) * invdirx;\n\n\t\t\t} else {\n\n\t\t\t\ttmin = ( box.max.x - origin.x ) * invdirx;\n\t\t\t\ttmax = ( box.min.x - origin.x ) * invdirx;\n\n\t\t\t}\n\n\t\t\tif ( invdiry >= 0 ) {\n\n\t\t\t\ttymin = ( box.min.y - origin.y ) * invdiry;\n\t\t\t\ttymax = ( box.max.y - origin.y ) * invdiry;\n\n\t\t\t} else {\n\n\t\t\t\ttymin = ( box.max.y - origin.y ) * invdiry;\n\t\t\t\ttymax = ( box.min.y - origin.y ) * invdiry;\n\n\t\t\t}\n\n\t\t\tif ( ( tmin > tymax ) || ( tymin > tmax ) ) return null;\n\n\t\t\t// These lines also handle the case where tmin or tmax is NaN\n\t\t\t// (result of 0 * Infinity). x !== x returns true if x is NaN\n\n\t\t\tif ( tymin > tmin || tmin !== tmin ) tmin = tymin;\n\n\t\t\tif ( tymax < tmax || tmax !== tmax ) tmax = tymax;\n\n\t\t\tif ( invdirz >= 0 ) {\n\n\t\t\t\ttzmin = ( box.min.z - origin.z ) * invdirz;\n\t\t\t\ttzmax = ( box.max.z - origin.z ) * invdirz;\n\n\t\t\t} else {\n\n\t\t\t\ttzmin = ( box.max.z - origin.z ) * invdirz;\n\t\t\t\ttzmax = ( box.min.z - origin.z ) * invdirz;\n\n\t\t\t}\n\n\t\t\tif ( ( tmin > tzmax ) || ( tzmin > tmax ) ) return null;\n\n\t\t\tif ( tzmin > tmin || tmin !== tmin ) tmin = tzmin;\n\n\t\t\tif ( tzmax < tmax || tmax !== tmax ) tmax = tzmax;\n\n\t\t\t//return point closest to the ray (positive side)\n\n\t\t\tif ( tmax < 0 ) return null;\n\n\t\t\treturn this.at( tmin >= 0 ? tmin : tmax, target );\n\n\t\t},\n\n\t\tintersectsBox: ( function () {\n\n\t\t\tvar v = new Vector3();\n\n\t\t\treturn function intersectsBox( box ) {\n\n\t\t\t\treturn this.intersectBox( box, v ) !== null;\n\n\t\t\t};\n\n\t\t} )(),\n\n\t\tintersectTriangle: function () {\n\n\t\t\t// Compute the offset origin, edges, and normal.\n\t\t\tvar diff = new Vector3();\n\t\t\tvar edge1 = new Vector3();\n\t\t\tvar edge2 = new Vector3();\n\t\t\tvar normal = new Vector3();\n\n\t\t\treturn function intersectTriangle( a, b, c, backfaceCulling, target ) {\n\n\t\t\t\t// from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h\n\n\t\t\t\tedge1.subVectors( b, a );\n\t\t\t\tedge2.subVectors( c, a );\n\t\t\t\tnormal.crossVectors( edge1, edge2 );\n\n\t\t\t\t// Solve Q + t*D = b1*E1 + b2*E2 (Q = kDiff, D = ray direction,\n\t\t\t\t// E1 = kEdge1, E2 = kEdge2, N = Cross(E1,E2)) by\n\t\t\t\t//   |Dot(D,N)|*b1 = sign(Dot(D,N))*Dot(D,Cross(Q,E2))\n\t\t\t\t//   |Dot(D,N)|*b2 = sign(Dot(D,N))*Dot(D,Cross(E1,Q))\n\t\t\t\t//   |Dot(D,N)|*t = -sign(Dot(D,N))*Dot(Q,N)\n\t\t\t\tvar DdN = this.direction.dot( normal );\n\t\t\t\tvar sign;\n\n\t\t\t\tif ( DdN > 0 ) {\n\n\t\t\t\t\tif ( backfaceCulling ) return null;\n\t\t\t\t\tsign = 1;\n\n\t\t\t\t} else if ( DdN < 0 ) {\n\n\t\t\t\t\tsign = - 1;\n\t\t\t\t\tDdN = - DdN;\n\n\t\t\t\t} else {\n\n\t\t\t\t\treturn null;\n\n\t\t\t\t}\n\n\t\t\t\tdiff.subVectors( this.origin, a );\n\t\t\t\tvar DdQxE2 = sign * this.direction.dot( edge2.crossVectors( diff, edge2 ) );\n\n\t\t\t\t// b1 < 0, no intersection\n\t\t\t\tif ( DdQxE2 < 0 ) {\n\n\t\t\t\t\treturn null;\n\n\t\t\t\t}\n\n\t\t\t\tvar DdE1xQ = sign * this.direction.dot( edge1.cross( diff ) );\n\n\t\t\t\t// b2 < 0, no intersection\n\t\t\t\tif ( DdE1xQ < 0 ) {\n\n\t\t\t\t\treturn null;\n\n\t\t\t\t}\n\n\t\t\t\t// b1+b2 > 1, no intersection\n\t\t\t\tif ( DdQxE2 + DdE1xQ > DdN ) {\n\n\t\t\t\t\treturn null;\n\n\t\t\t\t}\n\n\t\t\t\t// Line intersects triangle, check if ray does.\n\t\t\t\tvar QdN = - sign * diff.dot( normal );\n\n\t\t\t\t// t < 0, no intersection\n\t\t\t\tif ( QdN < 0 ) {\n\n\t\t\t\t\treturn null;\n\n\t\t\t\t}\n\n\t\t\t\t// Ray intersects triangle.\n\t\t\t\treturn this.at( QdN / DdN, target );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tapplyMatrix4: function ( matrix4 ) {\n\n\t\t\tthis.origin.applyMatrix4( matrix4 );\n\t\t\tthis.direction.transformDirection( matrix4 );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tequals: function ( ray ) {\n\n\t\t\treturn ray.origin.equals( this.origin ) && ray.direction.equals( this.direction );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author bhouston / http://clara.io\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction Triangle( a, b, c ) {\n\n\t\tthis.a = ( a !== undefined ) ? a : new Vector3();\n\t\tthis.b = ( b !== undefined ) ? b : new Vector3();\n\t\tthis.c = ( c !== undefined ) ? c : new Vector3();\n\n\t}\n\n\tObject.assign( Triangle, {\n\n\t\tgetNormal: function () {\n\n\t\t\tvar v0 = new Vector3();\n\n\t\t\treturn function getNormal( a, b, c, target ) {\n\n\t\t\t\tif ( target === undefined ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.Triangle: .getNormal() target is now required' );\n\t\t\t\t\ttarget = new Vector3();\n\n\t\t\t\t}\n\n\t\t\t\ttarget.subVectors( c, b );\n\t\t\t\tv0.subVectors( a, b );\n\t\t\t\ttarget.cross( v0 );\n\n\t\t\t\tvar targetLengthSq = target.lengthSq();\n\t\t\t\tif ( targetLengthSq > 0 ) {\n\n\t\t\t\t\treturn target.multiplyScalar( 1 / Math.sqrt( targetLengthSq ) );\n\n\t\t\t\t}\n\n\t\t\t\treturn target.set( 0, 0, 0 );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\t// static/instance method to calculate barycentric coordinates\n\t\t// based on: http://www.blackpawn.com/texts/pointinpoly/default.html\n\t\tgetBarycoord: function () {\n\n\t\t\tvar v0 = new Vector3();\n\t\t\tvar v1 = new Vector3();\n\t\t\tvar v2 = new Vector3();\n\n\t\t\treturn function getBarycoord( point, a, b, c, target ) {\n\n\t\t\t\tv0.subVectors( c, a );\n\t\t\t\tv1.subVectors( b, a );\n\t\t\t\tv2.subVectors( point, a );\n\n\t\t\t\tvar dot00 = v0.dot( v0 );\n\t\t\t\tvar dot01 = v0.dot( v1 );\n\t\t\t\tvar dot02 = v0.dot( v2 );\n\t\t\t\tvar dot11 = v1.dot( v1 );\n\t\t\t\tvar dot12 = v1.dot( v2 );\n\n\t\t\t\tvar denom = ( dot00 * dot11 - dot01 * dot01 );\n\n\t\t\t\tif ( target === undefined ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.Triangle: .getBarycoord() target is now required' );\n\t\t\t\t\ttarget = new Vector3();\n\n\t\t\t\t}\n\n\t\t\t\t// collinear or singular triangle\n\t\t\t\tif ( denom === 0 ) {\n\n\t\t\t\t\t// arbitrary location outside of triangle?\n\t\t\t\t\t// not sure if this is the best idea, maybe should be returning undefined\n\t\t\t\t\treturn target.set( - 2, - 1, - 1 );\n\n\t\t\t\t}\n\n\t\t\t\tvar invDenom = 1 / denom;\n\t\t\t\tvar u = ( dot11 * dot02 - dot01 * dot12 ) * invDenom;\n\t\t\t\tvar v = ( dot00 * dot12 - dot01 * dot02 ) * invDenom;\n\n\t\t\t\t// barycentric coordinates must always sum to 1\n\t\t\t\treturn target.set( 1 - u - v, v, u );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tcontainsPoint: function () {\n\n\t\t\tvar v1 = new Vector3();\n\n\t\t\treturn function containsPoint( point, a, b, c ) {\n\n\t\t\t\tTriangle.getBarycoord( point, a, b, c, v1 );\n\n\t\t\t\treturn ( v1.x >= 0 ) && ( v1.y >= 0 ) && ( ( v1.x + v1.y ) <= 1 );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tgetUV: function () {\n\n\t\t\tvar barycoord = new Vector3();\n\n\t\t\treturn function getUV( point, p1, p2, p3, uv1, uv2, uv3, target ) {\n\n\t\t\t\tthis.getBarycoord( point, p1, p2, p3, barycoord );\n\n\t\t\t\ttarget.set( 0, 0 );\n\t\t\t\ttarget.addScaledVector( uv1, barycoord.x );\n\t\t\t\ttarget.addScaledVector( uv2, barycoord.y );\n\t\t\t\ttarget.addScaledVector( uv3, barycoord.z );\n\n\t\t\t\treturn target;\n\n\t\t\t};\n\n\t\t}()\n\n\t} );\n\n\tObject.assign( Triangle.prototype, {\n\n\t\tset: function ( a, b, c ) {\n\n\t\t\tthis.a.copy( a );\n\t\t\tthis.b.copy( b );\n\t\t\tthis.c.copy( c );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromPointsAndIndices: function ( points, i0, i1, i2 ) {\n\n\t\t\tthis.a.copy( points[ i0 ] );\n\t\t\tthis.b.copy( points[ i1 ] );\n\t\t\tthis.c.copy( points[ i2 ] );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t},\n\n\t\tcopy: function ( triangle ) {\n\n\t\t\tthis.a.copy( triangle.a );\n\t\t\tthis.b.copy( triangle.b );\n\t\t\tthis.c.copy( triangle.c );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetArea: function () {\n\n\t\t\tvar v0 = new Vector3();\n\t\t\tvar v1 = new Vector3();\n\n\t\t\treturn function getArea() {\n\n\t\t\t\tv0.subVectors( this.c, this.b );\n\t\t\t\tv1.subVectors( this.a, this.b );\n\n\t\t\t\treturn v0.cross( v1 ).length() * 0.5;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tgetMidpoint: function ( target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Triangle: .getMidpoint() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\treturn target.addVectors( this.a, this.b ).add( this.c ).multiplyScalar( 1 / 3 );\n\n\t\t},\n\n\t\tgetNormal: function ( target ) {\n\n\t\t\treturn Triangle.getNormal( this.a, this.b, this.c, target );\n\n\t\t},\n\n\t\tgetPlane: function ( target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Triangle: .getPlane() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\treturn target.setFromCoplanarPoints( this.a, this.b, this.c );\n\n\t\t},\n\n\t\tgetBarycoord: function ( point, target ) {\n\n\t\t\treturn Triangle.getBarycoord( point, this.a, this.b, this.c, target );\n\n\t\t},\n\n\t\tcontainsPoint: function ( point ) {\n\n\t\t\treturn Triangle.containsPoint( point, this.a, this.b, this.c );\n\n\t\t},\n\n\t\tgetUV: function ( point, uv1, uv2, uv3, result ) {\n\n\t\t\treturn Triangle.getUV( point, this.a, this.b, this.c, uv1, uv2, uv3, result );\n\n\t\t},\n\n\t\tintersectsBox: function ( box ) {\n\n\t\t\treturn box.intersectsTriangle( this );\n\n\t\t},\n\n\t\tclosestPointToPoint: function () {\n\n\t\t\tvar vab = new Vector3();\n\t\t\tvar vac = new Vector3();\n\t\t\tvar vbc = new Vector3();\n\t\t\tvar vap = new Vector3();\n\t\t\tvar vbp = new Vector3();\n\t\t\tvar vcp = new Vector3();\n\n\t\t\treturn function closestPointToPoint( p, target ) {\n\n\t\t\t\tif ( target === undefined ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.Triangle: .closestPointToPoint() target is now required' );\n\t\t\t\t\ttarget = new Vector3();\n\n\t\t\t\t}\n\n\t\t\t\tvar a = this.a, b = this.b, c = this.c;\n\t\t\t\tvar v, w;\n\n\t\t\t\t// algorithm thanks to Real-Time Collision Detection by Christer Ericson,\n\t\t\t\t// published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc.,\n\t\t\t\t// under the accompanying license; see chapter 5.1.5 for detailed explanation.\n\t\t\t\t// basically, we're distinguishing which of the voronoi regions of the triangle\n\t\t\t\t// the point lies in with the minimum amount of redundant computation.\n\n\t\t\t\tvab.subVectors( b, a );\n\t\t\t\tvac.subVectors( c, a );\n\t\t\t\tvap.subVectors( p, a );\n\t\t\t\tvar d1 = vab.dot( vap );\n\t\t\t\tvar d2 = vac.dot( vap );\n\t\t\t\tif ( d1 <= 0 && d2 <= 0 ) {\n\n\t\t\t\t\t// vertex region of A; barycentric coords (1, 0, 0)\n\t\t\t\t\treturn target.copy( a );\n\n\t\t\t\t}\n\n\t\t\t\tvbp.subVectors( p, b );\n\t\t\t\tvar d3 = vab.dot( vbp );\n\t\t\t\tvar d4 = vac.dot( vbp );\n\t\t\t\tif ( d3 >= 0 && d4 <= d3 ) {\n\n\t\t\t\t\t// vertex region of B; barycentric coords (0, 1, 0)\n\t\t\t\t\treturn target.copy( b );\n\n\t\t\t\t}\n\n\t\t\t\tvar vc = d1 * d4 - d3 * d2;\n\t\t\t\tif ( vc <= 0 && d1 >= 0 && d3 <= 0 ) {\n\n\t\t\t\t\tv = d1 / ( d1 - d3 );\n\t\t\t\t\t// edge region of AB; barycentric coords (1-v, v, 0)\n\t\t\t\t\treturn target.copy( a ).addScaledVector( vab, v );\n\n\t\t\t\t}\n\n\t\t\t\tvcp.subVectors( p, c );\n\t\t\t\tvar d5 = vab.dot( vcp );\n\t\t\t\tvar d6 = vac.dot( vcp );\n\t\t\t\tif ( d6 >= 0 && d5 <= d6 ) {\n\n\t\t\t\t\t// vertex region of C; barycentric coords (0, 0, 1)\n\t\t\t\t\treturn target.copy( c );\n\n\t\t\t\t}\n\n\t\t\t\tvar vb = d5 * d2 - d1 * d6;\n\t\t\t\tif ( vb <= 0 && d2 >= 0 && d6 <= 0 ) {\n\n\t\t\t\t\tw = d2 / ( d2 - d6 );\n\t\t\t\t\t// edge region of AC; barycentric coords (1-w, 0, w)\n\t\t\t\t\treturn target.copy( a ).addScaledVector( vac, w );\n\n\t\t\t\t}\n\n\t\t\t\tvar va = d3 * d6 - d5 * d4;\n\t\t\t\tif ( va <= 0 && ( d4 - d3 ) >= 0 && ( d5 - d6 ) >= 0 ) {\n\n\t\t\t\t\tvbc.subVectors( c, b );\n\t\t\t\t\tw = ( d4 - d3 ) / ( ( d4 - d3 ) + ( d5 - d6 ) );\n\t\t\t\t\t// edge region of BC; barycentric coords (0, 1-w, w)\n\t\t\t\t\treturn target.copy( b ).addScaledVector( vbc, w ); // edge region of BC\n\n\t\t\t\t}\n\n\t\t\t\t// face region\n\t\t\t\tvar denom = 1 / ( va + vb + vc );\n\t\t\t\t// u = va * denom\n\t\t\t\tv = vb * denom;\n\t\t\t\tw = vc * denom;\n\t\t\t\treturn target.copy( a ).addScaledVector( vab, v ).addScaledVector( vac, w );\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tequals: function ( triangle ) {\n\n\t\t\treturn triangle.a.equals( this.a ) && triangle.b.equals( this.b ) && triangle.c.equals( this.c );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author alteredq / http://alteredqualia.com/\n\t *\n\t * parameters = {\n\t *  color: <hex>,\n\t *  opacity: <float>,\n\t *  map: new THREE.Texture( <Image> ),\n\t *\n\t *  lightMap: new THREE.Texture( <Image> ),\n\t *  lightMapIntensity: <float>\n\t *\n\t *  aoMap: new THREE.Texture( <Image> ),\n\t *  aoMapIntensity: <float>\n\t *\n\t *  specularMap: new THREE.Texture( <Image> ),\n\t *\n\t *  alphaMap: new THREE.Texture( <Image> ),\n\t *\n\t *  envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ),\n\t *  combine: THREE.Multiply,\n\t *  reflectivity: <float>,\n\t *  refractionRatio: <float>,\n\t *\n\t *  depthTest: <bool>,\n\t *  depthWrite: <bool>,\n\t *\n\t *  wireframe: <boolean>,\n\t *  wireframeLinewidth: <float>,\n\t *\n\t *  skinning: <bool>,\n\t *  morphTargets: <bool>\n\t * }\n\t */\n\n\tfunction MeshBasicMaterial( parameters ) {\n\n\t\tMaterial.call( this );\n\n\t\tthis.type = 'MeshBasicMaterial';\n\n\t\tthis.color = new Color( 0xffffff ); // emissive\n\n\t\tthis.map = null;\n\n\t\tthis.lightMap = null;\n\t\tthis.lightMapIntensity = 1.0;\n\n\t\tthis.aoMap = null;\n\t\tthis.aoMapIntensity = 1.0;\n\n\t\tthis.specularMap = null;\n\n\t\tthis.alphaMap = null;\n\n\t\tthis.envMap = null;\n\t\tthis.combine = MultiplyOperation;\n\t\tthis.reflectivity = 1;\n\t\tthis.refractionRatio = 0.98;\n\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.wireframeLinecap = 'round';\n\t\tthis.wireframeLinejoin = 'round';\n\n\t\tthis.skinning = false;\n\t\tthis.morphTargets = false;\n\n\t\tthis.lights = false;\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n\tMeshBasicMaterial.prototype = Object.create( Material.prototype );\n\tMeshBasicMaterial.prototype.constructor = MeshBasicMaterial;\n\n\tMeshBasicMaterial.prototype.isMeshBasicMaterial = true;\n\n\tMeshBasicMaterial.prototype.copy = function ( source ) {\n\n\t\tMaterial.prototype.copy.call( this, source );\n\n\t\tthis.color.copy( source.color );\n\n\t\tthis.map = source.map;\n\n\t\tthis.lightMap = source.lightMap;\n\t\tthis.lightMapIntensity = source.lightMapIntensity;\n\n\t\tthis.aoMap = source.aoMap;\n\t\tthis.aoMapIntensity = source.aoMapIntensity;\n\n\t\tthis.specularMap = source.specularMap;\n\n\t\tthis.alphaMap = source.alphaMap;\n\n\t\tthis.envMap = source.envMap;\n\t\tthis.combine = source.combine;\n\t\tthis.reflectivity = source.reflectivity;\n\t\tthis.refractionRatio = source.refractionRatio;\n\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.wireframeLinecap = source.wireframeLinecap;\n\t\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\n\t\treturn this;\n\n\t};\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author mikael emtinger / http://gomo.se/\n\t * @author jonobr1 / http://jonobr1.com/\n\t */\n\n\tfunction Mesh( geometry, material ) {\n\n\t\tObject3D.call( this );\n\n\t\tthis.type = 'Mesh';\n\n\t\tthis.geometry = geometry !== undefined ? geometry : new BufferGeometry();\n\t\tthis.material = material !== undefined ? material : new MeshBasicMaterial( { color: Math.random() * 0xffffff } );\n\n\t\tthis.drawMode = TrianglesDrawMode;\n\n\t\tthis.updateMorphTargets();\n\n\t}\n\n\tMesh.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\t\tconstructor: Mesh,\n\n\t\tisMesh: true,\n\n\t\tsetDrawMode: function ( value ) {\n\n\t\t\tthis.drawMode = value;\n\n\t\t},\n\n\t\tcopy: function ( source ) {\n\n\t\t\tObject3D.prototype.copy.call( this, source );\n\n\t\t\tthis.drawMode = source.drawMode;\n\n\t\t\tif ( source.morphTargetInfluences !== undefined ) {\n\n\t\t\t\tthis.morphTargetInfluences = source.morphTargetInfluences.slice();\n\n\t\t\t}\n\n\t\t\tif ( source.morphTargetDictionary !== undefined ) {\n\n\t\t\t\tthis.morphTargetDictionary = Object.assign( {}, source.morphTargetDictionary );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tupdateMorphTargets: function () {\n\n\t\t\tvar geometry = this.geometry;\n\t\t\tvar m, ml, name;\n\n\t\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\t\tvar morphAttributes = geometry.morphAttributes;\n\t\t\t\tvar keys = Object.keys( morphAttributes );\n\n\t\t\t\tif ( keys.length > 0 ) {\n\n\t\t\t\t\tvar morphAttribute = morphAttributes[ keys[ 0 ] ];\n\n\t\t\t\t\tif ( morphAttribute !== undefined ) {\n\n\t\t\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\t\t\tfor ( m = 0, ml = morphAttribute.length; m < ml; m ++ ) {\n\n\t\t\t\t\t\t\tname = morphAttribute[ m ].name || String( m );\n\n\t\t\t\t\t\t\tthis.morphTargetInfluences.push( 0 );\n\t\t\t\t\t\t\tthis.morphTargetDictionary[ name ] = m;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tvar morphTargets = geometry.morphTargets;\n\n\t\t\t\tif ( morphTargets !== undefined && morphTargets.length > 0 ) {\n\n\t\t\t\t\tconsole.error( 'THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t},\n\n\t\traycast: ( function () {\n\n\t\t\tvar inverseMatrix = new Matrix4();\n\t\t\tvar ray = new Ray();\n\t\t\tvar sphere = new Sphere();\n\n\t\t\tvar vA = new Vector3();\n\t\t\tvar vB = new Vector3();\n\t\t\tvar vC = new Vector3();\n\n\t\t\tvar tempA = new Vector3();\n\t\t\tvar tempB = new Vector3();\n\t\t\tvar tempC = new Vector3();\n\n\t\t\tvar uvA = new Vector2();\n\t\t\tvar uvB = new Vector2();\n\t\t\tvar uvC = new Vector2();\n\n\t\t\tvar intersectionPoint = new Vector3();\n\t\t\tvar intersectionPointWorld = new Vector3();\n\n\t\t\tfunction checkIntersection( object, material, raycaster, ray, pA, pB, pC, point ) {\n\n\t\t\t\tvar intersect;\n\n\t\t\t\tif ( material.side === BackSide ) {\n\n\t\t\t\t\tintersect = ray.intersectTriangle( pC, pB, pA, true, point );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tintersect = ray.intersectTriangle( pA, pB, pC, material.side !== DoubleSide, point );\n\n\t\t\t\t}\n\n\t\t\t\tif ( intersect === null ) return null;\n\n\t\t\t\tintersectionPointWorld.copy( point );\n\t\t\t\tintersectionPointWorld.applyMatrix4( object.matrixWorld );\n\n\t\t\t\tvar distance = raycaster.ray.origin.distanceTo( intersectionPointWorld );\n\n\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) return null;\n\n\t\t\t\treturn {\n\t\t\t\t\tdistance: distance,\n\t\t\t\t\tpoint: intersectionPointWorld.clone(),\n\t\t\t\t\tobject: object\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\tfunction checkBufferGeometryIntersection( object, material, raycaster, ray, position, uv, a, b, c ) {\n\n\t\t\t\tvA.fromBufferAttribute( position, a );\n\t\t\t\tvB.fromBufferAttribute( position, b );\n\t\t\t\tvC.fromBufferAttribute( position, c );\n\n\t\t\t\tvar intersection = checkIntersection( object, material, raycaster, ray, vA, vB, vC, intersectionPoint );\n\n\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\tif ( uv ) {\n\n\t\t\t\t\t\tuvA.fromBufferAttribute( uv, a );\n\t\t\t\t\t\tuvB.fromBufferAttribute( uv, b );\n\t\t\t\t\t\tuvC.fromBufferAttribute( uv, c );\n\n\t\t\t\t\t\tintersection.uv = Triangle.getUV( intersectionPoint, vA, vB, vC, uvA, uvB, uvC, new Vector2() );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tvar face = new Face3( a, b, c );\n\t\t\t\t\tTriangle.getNormal( vA, vB, vC, face.normal );\n\n\t\t\t\t\tintersection.face = face;\n\n\t\t\t\t}\n\n\t\t\t\treturn intersection;\n\n\t\t\t}\n\n\t\t\treturn function raycast( raycaster, intersects ) {\n\n\t\t\t\tvar geometry = this.geometry;\n\t\t\t\tvar material = this.material;\n\t\t\t\tvar matrixWorld = this.matrixWorld;\n\n\t\t\t\tif ( material === undefined ) return;\n\n\t\t\t\t// Checking boundingSphere distance to ray\n\n\t\t\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t\t\tsphere.copy( geometry.boundingSphere );\n\t\t\t\tsphere.applyMatrix4( matrixWorld );\n\n\t\t\t\tif ( raycaster.ray.intersectsSphere( sphere ) === false ) return;\n\n\t\t\t\t//\n\n\t\t\t\tinverseMatrix.getInverse( matrixWorld );\n\t\t\t\tray.copy( raycaster.ray ).applyMatrix4( inverseMatrix );\n\n\t\t\t\t// Check boundingBox before continuing\n\n\t\t\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\t\t\tif ( ray.intersectsBox( geometry.boundingBox ) === false ) return;\n\n\t\t\t\t}\n\n\t\t\t\tvar intersection;\n\n\t\t\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\t\t\tvar a, b, c;\n\t\t\t\t\tvar index = geometry.index;\n\t\t\t\t\tvar position = geometry.attributes.position;\n\t\t\t\t\tvar uv = geometry.attributes.uv;\n\t\t\t\t\tvar groups = geometry.groups;\n\t\t\t\t\tvar drawRange = geometry.drawRange;\n\t\t\t\t\tvar i, j, il, jl;\n\t\t\t\t\tvar group, groupMaterial;\n\t\t\t\t\tvar start, end;\n\n\t\t\t\t\tif ( index !== null ) {\n\n\t\t\t\t\t\t// indexed buffer geometry\n\n\t\t\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\t\t\tfor ( i = 0, il = groups.length; i < il; i ++ ) {\n\n\t\t\t\t\t\t\t\tgroup = groups[ i ];\n\t\t\t\t\t\t\t\tgroupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\t\t\tstart = Math.max( group.start, drawRange.start );\n\t\t\t\t\t\t\t\tend = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\t\t\t\tfor ( j = start, jl = end; j < jl; j += 3 ) {\n\n\t\t\t\t\t\t\t\t\ta = index.getX( j );\n\t\t\t\t\t\t\t\t\tb = index.getX( j + 1 );\n\t\t\t\t\t\t\t\t\tc = index.getX( j + 2 );\n\n\t\t\t\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, ray, position, uv, a, b, c );\n\n\t\t\t\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( j / 3 ); // triangle number in indexed buffer semantics\n\t\t\t\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tstart = Math.max( 0, drawRange.start );\n\t\t\t\t\t\t\tend = Math.min( index.count, ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\t\t\tfor ( i = start, il = end; i < il; i += 3 ) {\n\n\t\t\t\t\t\t\t\ta = index.getX( i );\n\t\t\t\t\t\t\t\tb = index.getX( i + 1 );\n\t\t\t\t\t\t\t\tc = index.getX( i + 2 );\n\n\t\t\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, material, raycaster, ray, position, uv, a, b, c );\n\n\t\t\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( i / 3 ); // triangle number in indexed buffer semantics\n\t\t\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else if ( position !== undefined ) {\n\n\t\t\t\t\t\t// non-indexed buffer geometry\n\n\t\t\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\t\t\tfor ( i = 0, il = groups.length; i < il; i ++ ) {\n\n\t\t\t\t\t\t\t\tgroup = groups[ i ];\n\t\t\t\t\t\t\t\tgroupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\t\t\tstart = Math.max( group.start, drawRange.start );\n\t\t\t\t\t\t\t\tend = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\t\t\t\tfor ( j = start, jl = end; j < jl; j += 3 ) {\n\n\t\t\t\t\t\t\t\t\ta = j;\n\t\t\t\t\t\t\t\t\tb = j + 1;\n\t\t\t\t\t\t\t\t\tc = j + 2;\n\n\t\t\t\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, ray, position, uv, a, b, c );\n\n\t\t\t\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( j / 3 ); // triangle number in non-indexed buffer semantics\n\t\t\t\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tstart = Math.max( 0, drawRange.start );\n\t\t\t\t\t\t\tend = Math.min( position.count, ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\t\t\tfor ( i = start, il = end; i < il; i += 3 ) {\n\n\t\t\t\t\t\t\t\ta = i;\n\t\t\t\t\t\t\t\tb = i + 1;\n\t\t\t\t\t\t\t\tc = i + 2;\n\n\t\t\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, material, raycaster, ray, position, uv, a, b, c );\n\n\t\t\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( i / 3 ); // triangle number in non-indexed buffer semantics\n\t\t\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\t\t\tvar fvA, fvB, fvC;\n\t\t\t\t\tvar isMultiMaterial = Array.isArray( material );\n\n\t\t\t\t\tvar vertices = geometry.vertices;\n\t\t\t\t\tvar faces = geometry.faces;\n\t\t\t\t\tvar uvs;\n\n\t\t\t\t\tvar faceVertexUvs = geometry.faceVertexUvs[ 0 ];\n\t\t\t\t\tif ( faceVertexUvs.length > 0 ) uvs = faceVertexUvs;\n\n\t\t\t\t\tfor ( var f = 0, fl = faces.length; f < fl; f ++ ) {\n\n\t\t\t\t\t\tvar face = faces[ f ];\n\t\t\t\t\t\tvar faceMaterial = isMultiMaterial ? material[ face.materialIndex ] : material;\n\n\t\t\t\t\t\tif ( faceMaterial === undefined ) continue;\n\n\t\t\t\t\t\tfvA = vertices[ face.a ];\n\t\t\t\t\t\tfvB = vertices[ face.b ];\n\t\t\t\t\t\tfvC = vertices[ face.c ];\n\n\t\t\t\t\t\tif ( faceMaterial.morphTargets === true ) {\n\n\t\t\t\t\t\t\tvar morphTargets = geometry.morphTargets;\n\t\t\t\t\t\t\tvar morphInfluences = this.morphTargetInfluences;\n\n\t\t\t\t\t\t\tvA.set( 0, 0, 0 );\n\t\t\t\t\t\t\tvB.set( 0, 0, 0 );\n\t\t\t\t\t\t\tvC.set( 0, 0, 0 );\n\n\t\t\t\t\t\t\tfor ( var t = 0, tl = morphTargets.length; t < tl; t ++ ) {\n\n\t\t\t\t\t\t\t\tvar influence = morphInfluences[ t ];\n\n\t\t\t\t\t\t\t\tif ( influence === 0 ) continue;\n\n\t\t\t\t\t\t\t\tvar targets = morphTargets[ t ].vertices;\n\n\t\t\t\t\t\t\t\tvA.addScaledVector( tempA.subVectors( targets[ face.a ], fvA ), influence );\n\t\t\t\t\t\t\t\tvB.addScaledVector( tempB.subVectors( targets[ face.b ], fvB ), influence );\n\t\t\t\t\t\t\t\tvC.addScaledVector( tempC.subVectors( targets[ face.c ], fvC ), influence );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tvA.add( fvA );\n\t\t\t\t\t\t\tvB.add( fvB );\n\t\t\t\t\t\t\tvC.add( fvC );\n\n\t\t\t\t\t\t\tfvA = vA;\n\t\t\t\t\t\t\tfvB = vB;\n\t\t\t\t\t\t\tfvC = vC;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tintersection = checkIntersection( this, faceMaterial, raycaster, ray, fvA, fvB, fvC, intersectionPoint );\n\n\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\tif ( uvs && uvs[ f ] ) {\n\n\t\t\t\t\t\t\t\tvar uvs_f = uvs[ f ];\n\t\t\t\t\t\t\t\tuvA.copy( uvs_f[ 0 ] );\n\t\t\t\t\t\t\t\tuvB.copy( uvs_f[ 1 ] );\n\t\t\t\t\t\t\t\tuvC.copy( uvs_f[ 2 ] );\n\n\t\t\t\t\t\t\t\tintersection.uv = Triangle.getUV( intersectionPoint, fvA, fvB, fvC, uvA, uvB, uvC, new Vector2() );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tintersection.face = face;\n\t\t\t\t\t\t\tintersection.faceIndex = f;\n\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t}() ),\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor( this.geometry, this.material ).copy( this );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction WebGLBackground( renderer, state, objects, premultipliedAlpha ) {\n\n\t\tvar clearColor = new Color( 0x000000 );\n\t\tvar clearAlpha = 0;\n\n\t\tvar planeMesh;\n\t\tvar boxMesh;\n\t\t// Store the current background texture and its `version`\n\t\t// so we can recompile the material accordingly.\n\t\tvar currentBackground = null;\n\t\tvar currentBackgroundVersion = 0;\n\n\t\tfunction render( renderList, scene, camera, forceClear ) {\n\n\t\t\tvar background = scene.background;\n\n\t\t\tif ( background === null ) {\n\n\t\t\t\tsetClear( clearColor, clearAlpha );\n\t\t\t\tcurrentBackground = null;\n\t\t\t\tcurrentBackgroundVersion = 0;\n\n\t\t\t} else if ( background && background.isColor ) {\n\n\t\t\t\tsetClear( background, 1 );\n\t\t\t\tforceClear = true;\n\t\t\t\tcurrentBackground = null;\n\t\t\t\tcurrentBackgroundVersion = 0;\n\n\t\t\t}\n\n\t\t\tif ( renderer.autoClear || forceClear ) {\n\n\t\t\t\trenderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );\n\n\t\t\t}\n\n\t\t\tif ( background && ( background.isCubeTexture || background.isWebGLRenderTargetCube ) ) {\n\n\t\t\t\tif ( boxMesh === undefined ) {\n\n\t\t\t\t\tboxMesh = new Mesh(\n\t\t\t\t\t\tnew BoxBufferGeometry( 1, 1, 1 ),\n\t\t\t\t\t\tnew ShaderMaterial( {\n\t\t\t\t\t\t\ttype: 'BackgroundCubeMaterial',\n\t\t\t\t\t\t\tuniforms: cloneUniforms( ShaderLib.cube.uniforms ),\n\t\t\t\t\t\t\tvertexShader: ShaderLib.cube.vertexShader,\n\t\t\t\t\t\t\tfragmentShader: ShaderLib.cube.fragmentShader,\n\t\t\t\t\t\t\tside: BackSide,\n\t\t\t\t\t\t\tdepthTest: true,\n\t\t\t\t\t\t\tdepthWrite: false,\n\t\t\t\t\t\t\tfog: false\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\n\t\t\t\t\tboxMesh.geometry.removeAttribute( 'normal' );\n\t\t\t\t\tboxMesh.geometry.removeAttribute( 'uv' );\n\n\t\t\t\t\tboxMesh.onBeforeRender = function ( renderer, scene, camera ) {\n\n\t\t\t\t\t\tthis.matrixWorld.copyPosition( camera.matrixWorld );\n\n\t\t\t\t\t};\n\n\t\t\t\t\t// enable code injection for non-built-in material\n\t\t\t\t\tObject.defineProperty( boxMesh.material, 'map', {\n\n\t\t\t\t\t\tget: function () {\n\n\t\t\t\t\t\t\treturn this.uniforms.tCube.value;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} );\n\n\t\t\t\t\tobjects.update( boxMesh );\n\n\t\t\t\t}\n\n\t\t\t\tvar texture = background.isWebGLRenderTargetCube ? background.texture : background;\n\t\t\t\tboxMesh.material.uniforms.tCube.value = texture;\n\t\t\t\tboxMesh.material.uniforms.tFlip.value = ( background.isWebGLRenderTargetCube ) ? 1 : - 1;\n\n\t\t\t\tif ( currentBackground !== background ||\n\t\t\t\t     currentBackgroundVersion !== texture.version ) {\n\n\t\t\t\t\tboxMesh.material.needsUpdate = true;\n\n\t\t\t\t\tcurrentBackground = background;\n\t\t\t\t\tcurrentBackgroundVersion = texture.version;\n\n\t\t\t\t}\n\n\t\t\t\t// push to the pre-sorted opaque render list\n\t\t\t\trenderList.unshift( boxMesh, boxMesh.geometry, boxMesh.material, 0, null );\n\n\t\t\t} else if ( background && background.isTexture ) {\n\n\t\t\t\tif ( planeMesh === undefined ) {\n\n\t\t\t\t\tplaneMesh = new Mesh(\n\t\t\t\t\t\tnew PlaneBufferGeometry( 2, 2 ),\n\t\t\t\t\t\tnew ShaderMaterial( {\n\t\t\t\t\t\t\ttype: 'BackgroundMaterial',\n\t\t\t\t\t\t\tuniforms: cloneUniforms( ShaderLib.background.uniforms ),\n\t\t\t\t\t\t\tvertexShader: ShaderLib.background.vertexShader,\n\t\t\t\t\t\t\tfragmentShader: ShaderLib.background.fragmentShader,\n\t\t\t\t\t\t\tside: FrontSide,\n\t\t\t\t\t\t\tdepthTest: false,\n\t\t\t\t\t\t\tdepthWrite: false,\n\t\t\t\t\t\t\tfog: false\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\n\t\t\t\t\tplaneMesh.geometry.removeAttribute( 'normal' );\n\n\t\t\t\t\t// enable code injection for non-built-in material\n\t\t\t\t\tObject.defineProperty( planeMesh.material, 'map', {\n\n\t\t\t\t\t\tget: function () {\n\n\t\t\t\t\t\t\treturn this.uniforms.t2D.value;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} );\n\n\t\t\t\t\tobjects.update( planeMesh );\n\n\t\t\t\t}\n\n\t\t\t\tplaneMesh.material.uniforms.t2D.value = background;\n\n\t\t\t\tif ( background.matrixAutoUpdate === true ) {\n\n\t\t\t\t\tbackground.updateMatrix();\n\n\t\t\t\t}\n\n\t\t\t\tplaneMesh.material.uniforms.uvTransform.value.copy( background.matrix );\n\n\t\t\t\tif ( currentBackground !== background ||\n\t\t\t\t\t   currentBackgroundVersion !== background.version ) {\n\n\t\t\t\t\tplaneMesh.material.needsUpdate = true;\n\n\t\t\t\t\tcurrentBackground = background;\n\t\t\t\t\tcurrentBackgroundVersion = background.version;\n\n\t\t\t\t}\n\n\n\t\t\t\t// push to the pre-sorted opaque render list\n\t\t\t\trenderList.unshift( planeMesh, planeMesh.geometry, planeMesh.material, 0, null );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction setClear( color, alpha ) {\n\n\t\t\tstate.buffers.color.setClear( color.r, color.g, color.b, alpha, premultipliedAlpha );\n\n\t\t}\n\n\t\treturn {\n\n\t\t\tgetClearColor: function () {\n\n\t\t\t\treturn clearColor;\n\n\t\t\t},\n\t\t\tsetClearColor: function ( color, alpha ) {\n\n\t\t\t\tclearColor.set( color );\n\t\t\t\tclearAlpha = alpha !== undefined ? alpha : 1;\n\t\t\t\tsetClear( clearColor, clearAlpha );\n\n\t\t\t},\n\t\t\tgetClearAlpha: function () {\n\n\t\t\t\treturn clearAlpha;\n\n\t\t\t},\n\t\t\tsetClearAlpha: function ( alpha ) {\n\n\t\t\t\tclearAlpha = alpha;\n\t\t\t\tsetClear( clearColor, clearAlpha );\n\n\t\t\t},\n\t\t\trender: render\n\n\t\t};\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction WebGLBufferRenderer( gl, extensions, info, capabilities ) {\n\n\t\tvar mode;\n\n\t\tfunction setMode( value ) {\n\n\t\t\tmode = value;\n\n\t\t}\n\n\t\tfunction render( start, count ) {\n\n\t\t\tgl.drawArrays( mode, start, count );\n\n\t\t\tinfo.update( count, mode );\n\n\t\t}\n\n\t\tfunction renderInstances( geometry, start, count ) {\n\n\t\t\tvar extension;\n\n\t\t\tif ( capabilities.isWebGL2 ) {\n\n\t\t\t\textension = gl;\n\n\t\t\t} else {\n\n\t\t\t\textension = extensions.get( 'ANGLE_instanced_arrays' );\n\n\t\t\t\tif ( extension === null ) {\n\n\t\t\t\t\tconsole.error( 'THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\textension[ capabilities.isWebGL2 ? 'drawArraysInstanced' : 'drawArraysInstancedANGLE' ]( mode, start, count, geometry.maxInstancedCount );\n\n\t\t\tinfo.update( count, mode, geometry.maxInstancedCount );\n\n\t\t}\n\n\t\t//\n\n\t\tthis.setMode = setMode;\n\t\tthis.render = render;\n\t\tthis.renderInstances = renderInstances;\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction WebGLCapabilities( gl, extensions, parameters ) {\n\n\t\tvar maxAnisotropy;\n\n\t\tfunction getMaxAnisotropy() {\n\n\t\t\tif ( maxAnisotropy !== undefined ) return maxAnisotropy;\n\n\t\t\tvar extension = extensions.get( 'EXT_texture_filter_anisotropic' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\tmaxAnisotropy = gl.getParameter( extension.MAX_TEXTURE_MAX_ANISOTROPY_EXT );\n\n\t\t\t} else {\n\n\t\t\t\tmaxAnisotropy = 0;\n\n\t\t\t}\n\n\t\t\treturn maxAnisotropy;\n\n\t\t}\n\n\t\tfunction getMaxPrecision( precision ) {\n\n\t\t\tif ( precision === 'highp' ) {\n\n\t\t\t\tif ( gl.getShaderPrecisionFormat( 35633, 36338 ).precision > 0 &&\n\t\t\t\t     gl.getShaderPrecisionFormat( 35632, 36338 ).precision > 0 ) {\n\n\t\t\t\t\treturn 'highp';\n\n\t\t\t\t}\n\n\t\t\t\tprecision = 'mediump';\n\n\t\t\t}\n\n\t\t\tif ( precision === 'mediump' ) {\n\n\t\t\t\tif ( gl.getShaderPrecisionFormat( 35633, 36337 ).precision > 0 &&\n\t\t\t\t     gl.getShaderPrecisionFormat( 35632, 36337 ).precision > 0 ) {\n\n\t\t\t\t\treturn 'mediump';\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn 'lowp';\n\n\t\t}\n\n\t\tvar isWebGL2 = typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext;\n\n\t\tvar precision = parameters.precision !== undefined ? parameters.precision : 'highp';\n\t\tvar maxPrecision = getMaxPrecision( precision );\n\n\t\tif ( maxPrecision !== precision ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer:', precision, 'not supported, using', maxPrecision, 'instead.' );\n\t\t\tprecision = maxPrecision;\n\n\t\t}\n\n\t\tvar logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;\n\n\t\tvar maxTextures = gl.getParameter( 34930 );\n\t\tvar maxVertexTextures = gl.getParameter( 35660 );\n\t\tvar maxTextureSize = gl.getParameter( 3379 );\n\t\tvar maxCubemapSize = gl.getParameter( 34076 );\n\n\t\tvar maxAttributes = gl.getParameter( 34921 );\n\t\tvar maxVertexUniforms = gl.getParameter( 36347 );\n\t\tvar maxVaryings = gl.getParameter( 36348 );\n\t\tvar maxFragmentUniforms = gl.getParameter( 36349 );\n\n\t\tvar vertexTextures = maxVertexTextures > 0;\n\t\tvar floatFragmentTextures = isWebGL2 || !! extensions.get( 'OES_texture_float' );\n\t\tvar floatVertexTextures = vertexTextures && floatFragmentTextures;\n\n\t\treturn {\n\n\t\t\tisWebGL2: isWebGL2,\n\n\t\t\tgetMaxAnisotropy: getMaxAnisotropy,\n\t\t\tgetMaxPrecision: getMaxPrecision,\n\n\t\t\tprecision: precision,\n\t\t\tlogarithmicDepthBuffer: logarithmicDepthBuffer,\n\n\t\t\tmaxTextures: maxTextures,\n\t\t\tmaxVertexTextures: maxVertexTextures,\n\t\t\tmaxTextureSize: maxTextureSize,\n\t\t\tmaxCubemapSize: maxCubemapSize,\n\n\t\t\tmaxAttributes: maxAttributes,\n\t\t\tmaxVertexUniforms: maxVertexUniforms,\n\t\t\tmaxVaryings: maxVaryings,\n\t\t\tmaxFragmentUniforms: maxFragmentUniforms,\n\n\t\t\tvertexTextures: vertexTextures,\n\t\t\tfloatFragmentTextures: floatFragmentTextures,\n\t\t\tfloatVertexTextures: floatVertexTextures\n\n\t\t};\n\n\t}\n\n\t/**\n\t * @author tschw\n\t */\n\n\tfunction WebGLClipping() {\n\n\t\tvar scope = this,\n\n\t\t\tglobalState = null,\n\t\t\tnumGlobalPlanes = 0,\n\t\t\tlocalClippingEnabled = false,\n\t\t\trenderingShadows = false,\n\n\t\t\tplane = new Plane(),\n\t\t\tviewNormalMatrix = new Matrix3(),\n\n\t\t\tuniform = { value: null, needsUpdate: false };\n\n\t\tthis.uniform = uniform;\n\t\tthis.numPlanes = 0;\n\t\tthis.numIntersection = 0;\n\n\t\tthis.init = function ( planes, enableLocalClipping, camera ) {\n\n\t\t\tvar enabled =\n\t\t\t\tplanes.length !== 0 ||\n\t\t\t\tenableLocalClipping ||\n\t\t\t\t// enable state of previous frame - the clipping code has to\n\t\t\t\t// run another frame in order to reset the state:\n\t\t\t\tnumGlobalPlanes !== 0 ||\n\t\t\t\tlocalClippingEnabled;\n\n\t\t\tlocalClippingEnabled = enableLocalClipping;\n\n\t\t\tglobalState = projectPlanes( planes, camera, 0 );\n\t\t\tnumGlobalPlanes = planes.length;\n\n\t\t\treturn enabled;\n\n\t\t};\n\n\t\tthis.beginShadows = function () {\n\n\t\t\trenderingShadows = true;\n\t\t\tprojectPlanes( null );\n\n\t\t};\n\n\t\tthis.endShadows = function () {\n\n\t\t\trenderingShadows = false;\n\t\t\tresetGlobalState();\n\n\t\t};\n\n\t\tthis.setState = function ( planes, clipIntersection, clipShadows, camera, cache, fromCache ) {\n\n\t\t\tif ( ! localClippingEnabled || planes === null || planes.length === 0 || renderingShadows && ! clipShadows ) {\n\n\t\t\t\t// there's no local clipping\n\n\t\t\t\tif ( renderingShadows ) {\n\n\t\t\t\t\t// there's no global clipping\n\n\t\t\t\t\tprojectPlanes( null );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tresetGlobalState();\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tvar nGlobal = renderingShadows ? 0 : numGlobalPlanes,\n\t\t\t\t\tlGlobal = nGlobal * 4,\n\n\t\t\t\t\tdstArray = cache.clippingState || null;\n\n\t\t\t\tuniform.value = dstArray; // ensure unique state\n\n\t\t\t\tdstArray = projectPlanes( planes, camera, lGlobal, fromCache );\n\n\t\t\t\tfor ( var i = 0; i !== lGlobal; ++ i ) {\n\n\t\t\t\t\tdstArray[ i ] = globalState[ i ];\n\n\t\t\t\t}\n\n\t\t\t\tcache.clippingState = dstArray;\n\t\t\t\tthis.numIntersection = clipIntersection ? this.numPlanes : 0;\n\t\t\t\tthis.numPlanes += nGlobal;\n\n\t\t\t}\n\n\n\t\t};\n\n\t\tfunction resetGlobalState() {\n\n\t\t\tif ( uniform.value !== globalState ) {\n\n\t\t\t\tuniform.value = globalState;\n\t\t\t\tuniform.needsUpdate = numGlobalPlanes > 0;\n\n\t\t\t}\n\n\t\t\tscope.numPlanes = numGlobalPlanes;\n\t\t\tscope.numIntersection = 0;\n\n\t\t}\n\n\t\tfunction projectPlanes( planes, camera, dstOffset, skipTransform ) {\n\n\t\t\tvar nPlanes = planes !== null ? planes.length : 0,\n\t\t\t\tdstArray = null;\n\n\t\t\tif ( nPlanes !== 0 ) {\n\n\t\t\t\tdstArray = uniform.value;\n\n\t\t\t\tif ( skipTransform !== true || dstArray === null ) {\n\n\t\t\t\t\tvar flatSize = dstOffset + nPlanes * 4,\n\t\t\t\t\t\tviewMatrix = camera.matrixWorldInverse;\n\n\t\t\t\t\tviewNormalMatrix.getNormalMatrix( viewMatrix );\n\n\t\t\t\t\tif ( dstArray === null || dstArray.length < flatSize ) {\n\n\t\t\t\t\t\tdstArray = new Float32Array( flatSize );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfor ( var i = 0, i4 = dstOffset; i !== nPlanes; ++ i, i4 += 4 ) {\n\n\t\t\t\t\t\tplane.copy( planes[ i ] ).applyMatrix4( viewMatrix, viewNormalMatrix );\n\n\t\t\t\t\t\tplane.normal.toArray( dstArray, i4 );\n\t\t\t\t\t\tdstArray[ i4 + 3 ] = plane.constant;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tuniform.value = dstArray;\n\t\t\t\tuniform.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tscope.numPlanes = nPlanes;\n\n\t\t\treturn dstArray;\n\n\t\t}\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction WebGLExtensions( gl ) {\n\n\t\tvar extensions = {};\n\n\t\treturn {\n\n\t\t\tget: function ( name ) {\n\n\t\t\t\tif ( extensions[ name ] !== undefined ) {\n\n\t\t\t\t\treturn extensions[ name ];\n\n\t\t\t\t}\n\n\t\t\t\tvar extension;\n\n\t\t\t\tswitch ( name ) {\n\n\t\t\t\t\tcase 'WEBGL_depth_texture':\n\t\t\t\t\t\textension = gl.getExtension( 'WEBGL_depth_texture' ) || gl.getExtension( 'MOZ_WEBGL_depth_texture' ) || gl.getExtension( 'WEBKIT_WEBGL_depth_texture' );\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'EXT_texture_filter_anisotropic':\n\t\t\t\t\t\textension = gl.getExtension( 'EXT_texture_filter_anisotropic' ) || gl.getExtension( 'MOZ_EXT_texture_filter_anisotropic' ) || gl.getExtension( 'WEBKIT_EXT_texture_filter_anisotropic' );\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'WEBGL_compressed_texture_s3tc':\n\t\t\t\t\t\textension = gl.getExtension( 'WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'MOZ_WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_s3tc' );\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'WEBGL_compressed_texture_pvrtc':\n\t\t\t\t\t\textension = gl.getExtension( 'WEBGL_compressed_texture_pvrtc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_pvrtc' );\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\textension = gl.getExtension( name );\n\n\t\t\t\t}\n\n\t\t\t\tif ( extension === null ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' );\n\n\t\t\t\t}\n\n\t\t\t\textensions[ name ] = extension;\n\n\t\t\t\treturn extension;\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction WebGLGeometries( gl, attributes, info ) {\n\n\t\tvar geometries = {};\n\t\tvar wireframeAttributes = {};\n\n\t\tfunction onGeometryDispose( event ) {\n\n\t\t\tvar geometry = event.target;\n\t\t\tvar buffergeometry = geometries[ geometry.id ];\n\n\t\t\tif ( buffergeometry.index !== null ) {\n\n\t\t\t\tattributes.remove( buffergeometry.index );\n\n\t\t\t}\n\n\t\t\tfor ( var name in buffergeometry.attributes ) {\n\n\t\t\t\tattributes.remove( buffergeometry.attributes[ name ] );\n\n\t\t\t}\n\n\t\t\tgeometry.removeEventListener( 'dispose', onGeometryDispose );\n\n\t\t\tdelete geometries[ geometry.id ];\n\n\t\t\tvar attribute = wireframeAttributes[ buffergeometry.id ];\n\n\t\t\tif ( attribute ) {\n\n\t\t\t\tattributes.remove( attribute );\n\t\t\t\tdelete wireframeAttributes[ buffergeometry.id ];\n\n\t\t\t}\n\n\t\t\t//\n\n\t\t\tinfo.memory.geometries --;\n\n\t\t}\n\n\t\tfunction get( object, geometry ) {\n\n\t\t\tvar buffergeometry = geometries[ geometry.id ];\n\n\t\t\tif ( buffergeometry ) return buffergeometry;\n\n\t\t\tgeometry.addEventListener( 'dispose', onGeometryDispose );\n\n\t\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\t\tbuffergeometry = geometry;\n\n\t\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\t\tif ( geometry._bufferGeometry === undefined ) {\n\n\t\t\t\t\tgeometry._bufferGeometry = new BufferGeometry().setFromObject( object );\n\n\t\t\t\t}\n\n\t\t\t\tbuffergeometry = geometry._bufferGeometry;\n\n\t\t\t}\n\n\t\t\tgeometries[ geometry.id ] = buffergeometry;\n\n\t\t\tinfo.memory.geometries ++;\n\n\t\t\treturn buffergeometry;\n\n\t\t}\n\n\t\tfunction update( geometry ) {\n\n\t\t\tvar index = geometry.index;\n\t\t\tvar geometryAttributes = geometry.attributes;\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\tattributes.update( index, 34963 );\n\n\t\t\t}\n\n\t\t\tfor ( var name in geometryAttributes ) {\n\n\t\t\t\tattributes.update( geometryAttributes[ name ], 34962 );\n\n\t\t\t}\n\n\t\t\t// morph targets\n\n\t\t\tvar morphAttributes = geometry.morphAttributes;\n\n\t\t\tfor ( var name in morphAttributes ) {\n\n\t\t\t\tvar array = morphAttributes[ name ];\n\n\t\t\t\tfor ( var i = 0, l = array.length; i < l; i ++ ) {\n\n\t\t\t\t\tattributes.update( array[ i ], 34962 );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction getWireframeAttribute( geometry ) {\n\n\t\t\tvar attribute = wireframeAttributes[ geometry.id ];\n\n\t\t\tif ( attribute ) return attribute;\n\n\t\t\tvar indices = [];\n\n\t\t\tvar geometryIndex = geometry.index;\n\t\t\tvar geometryAttributes = geometry.attributes;\n\n\t\t\t// console.time( 'wireframe' );\n\n\t\t\tif ( geometryIndex !== null ) {\n\n\t\t\t\tvar array = geometryIndex.array;\n\n\t\t\t\tfor ( var i = 0, l = array.length; i < l; i += 3 ) {\n\n\t\t\t\t\tvar a = array[ i + 0 ];\n\t\t\t\t\tvar b = array[ i + 1 ];\n\t\t\t\t\tvar c = array[ i + 2 ];\n\n\t\t\t\t\tindices.push( a, b, b, c, c, a );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tvar array = geometryAttributes.position.array;\n\n\t\t\t\tfor ( var i = 0, l = ( array.length / 3 ) - 1; i < l; i += 3 ) {\n\n\t\t\t\t\tvar a = i + 0;\n\t\t\t\t\tvar b = i + 1;\n\t\t\t\t\tvar c = i + 2;\n\n\t\t\t\t\tindices.push( a, b, b, c, c, a );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// console.timeEnd( 'wireframe' );\n\n\t\t\tattribute = new ( arrayMax( indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 );\n\n\t\t\tattributes.update( attribute, 34963 );\n\n\t\t\twireframeAttributes[ geometry.id ] = attribute;\n\n\t\t\treturn attribute;\n\n\t\t}\n\n\t\treturn {\n\n\t\t\tget: get,\n\t\t\tupdate: update,\n\n\t\t\tgetWireframeAttribute: getWireframeAttribute\n\n\t\t};\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {\n\n\t\tvar mode;\n\n\t\tfunction setMode( value ) {\n\n\t\t\tmode = value;\n\n\t\t}\n\n\t\tvar type, bytesPerElement;\n\n\t\tfunction setIndex( value ) {\n\n\t\t\ttype = value.type;\n\t\t\tbytesPerElement = value.bytesPerElement;\n\n\t\t}\n\n\t\tfunction render( start, count ) {\n\n\t\t\tgl.drawElements( mode, count, type, start * bytesPerElement );\n\n\t\t\tinfo.update( count, mode );\n\n\t\t}\n\n\t\tfunction renderInstances( geometry, start, count ) {\n\n\t\t\tvar extension;\n\n\t\t\tif ( capabilities.isWebGL2 ) {\n\n\t\t\t\textension = gl;\n\n\t\t\t} else {\n\n\t\t\t\tvar extension = extensions.get( 'ANGLE_instanced_arrays' );\n\n\t\t\t\tif ( extension === null ) {\n\n\t\t\t\t\tconsole.error( 'THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\textension[ capabilities.isWebGL2 ? 'drawElementsInstanced' : 'drawElementsInstancedANGLE' ]( mode, count, type, start * bytesPerElement, geometry.maxInstancedCount );\n\n\t\t\tinfo.update( count, mode, geometry.maxInstancedCount );\n\n\t\t}\n\n\t\t//\n\n\t\tthis.setMode = setMode;\n\t\tthis.setIndex = setIndex;\n\t\tthis.render = render;\n\t\tthis.renderInstances = renderInstances;\n\n\t}\n\n\t/**\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\tfunction WebGLInfo( gl ) {\n\n\t\tvar memory = {\n\t\t\tgeometries: 0,\n\t\t\ttextures: 0\n\t\t};\n\n\t\tvar render = {\n\t\t\tframe: 0,\n\t\t\tcalls: 0,\n\t\t\ttriangles: 0,\n\t\t\tpoints: 0,\n\t\t\tlines: 0\n\t\t};\n\n\t\tfunction update( count, mode, instanceCount ) {\n\n\t\t\tinstanceCount = instanceCount || 1;\n\n\t\t\trender.calls ++;\n\n\t\t\tswitch ( mode ) {\n\n\t\t\t\tcase 4:\n\t\t\t\t\trender.triangles += instanceCount * ( count / 3 );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 5:\n\t\t\t\tcase 6:\n\t\t\t\t\trender.triangles += instanceCount * ( count - 2 );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 1:\n\t\t\t\t\trender.lines += instanceCount * ( count / 2 );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 3:\n\t\t\t\t\trender.lines += instanceCount * ( count - 1 );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 2:\n\t\t\t\t\trender.lines += instanceCount * count;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 0:\n\t\t\t\t\trender.points += instanceCount * count;\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tconsole.error( 'THREE.WebGLInfo: Unknown draw mode:', mode );\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction reset() {\n\n\t\t\trender.frame ++;\n\t\t\trender.calls = 0;\n\t\t\trender.triangles = 0;\n\t\t\trender.points = 0;\n\t\t\trender.lines = 0;\n\n\t\t}\n\n\t\treturn {\n\t\t\tmemory: memory,\n\t\t\trender: render,\n\t\t\tprograms: null,\n\t\t\tautoReset: true,\n\t\t\treset: reset,\n\t\t\tupdate: update\n\t\t};\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction absNumericalSort( a, b ) {\n\n\t\treturn Math.abs( b[ 1 ] ) - Math.abs( a[ 1 ] );\n\n\t}\n\n\tfunction WebGLMorphtargets( gl ) {\n\n\t\tvar influencesList = {};\n\t\tvar morphInfluences = new Float32Array( 8 );\n\n\t\tfunction update( object, geometry, material, program ) {\n\n\t\t\tvar objectInfluences = object.morphTargetInfluences;\n\n\t\t\tvar length = objectInfluences.length;\n\n\t\t\tvar influences = influencesList[ geometry.id ];\n\n\t\t\tif ( influences === undefined ) {\n\n\t\t\t\t// initialise list\n\n\t\t\t\tinfluences = [];\n\n\t\t\t\tfor ( var i = 0; i < length; i ++ ) {\n\n\t\t\t\t\tinfluences[ i ] = [ i, 0 ];\n\n\t\t\t\t}\n\n\t\t\t\tinfluencesList[ geometry.id ] = influences;\n\n\t\t\t}\n\n\t\t\tvar morphTargets = material.morphTargets && geometry.morphAttributes.position;\n\t\t\tvar morphNormals = material.morphNormals && geometry.morphAttributes.normal;\n\n\t\t\t// Remove current morphAttributes\n\n\t\t\tfor ( var i = 0; i < length; i ++ ) {\n\n\t\t\t\tvar influence = influences[ i ];\n\n\t\t\t\tif ( influence[ 1 ] !== 0 ) {\n\n\t\t\t\t\tif ( morphTargets ) geometry.removeAttribute( 'morphTarget' + i );\n\t\t\t\t\tif ( morphNormals ) geometry.removeAttribute( 'morphNormal' + i );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// Collect influences\n\n\t\t\tfor ( var i = 0; i < length; i ++ ) {\n\n\t\t\t\tvar influence = influences[ i ];\n\n\t\t\t\tinfluence[ 0 ] = i;\n\t\t\t\tinfluence[ 1 ] = objectInfluences[ i ];\n\n\t\t\t}\n\n\t\t\tinfluences.sort( absNumericalSort );\n\n\t\t\t// Add morphAttributes\n\n\t\t\tfor ( var i = 0; i < 8; i ++ ) {\n\n\t\t\t\tvar influence = influences[ i ];\n\n\t\t\t\tif ( influence ) {\n\n\t\t\t\t\tvar index = influence[ 0 ];\n\t\t\t\t\tvar value = influence[ 1 ];\n\n\t\t\t\t\tif ( value ) {\n\n\t\t\t\t\t\tif ( morphTargets ) geometry.addAttribute( 'morphTarget' + i, morphTargets[ index ] );\n\t\t\t\t\t\tif ( morphNormals ) geometry.addAttribute( 'morphNormal' + i, morphNormals[ index ] );\n\n\t\t\t\t\t\tmorphInfluences[ i ] = value;\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tmorphInfluences[ i ] = 0;\n\n\t\t\t}\n\n\t\t\tprogram.getUniforms().setValue( gl, 'morphTargetInfluences', morphInfluences );\n\n\t\t}\n\n\t\treturn {\n\n\t\t\tupdate: update\n\n\t\t};\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction WebGLObjects( geometries, info ) {\n\n\t\tvar updateList = {};\n\n\t\tfunction update( object ) {\n\n\t\t\tvar frame = info.render.frame;\n\n\t\t\tvar geometry = object.geometry;\n\t\t\tvar buffergeometry = geometries.get( object, geometry );\n\n\t\t\t// Update once per frame\n\n\t\t\tif ( updateList[ buffergeometry.id ] !== frame ) {\n\n\t\t\t\tif ( geometry.isGeometry ) {\n\n\t\t\t\t\tbuffergeometry.updateFromObject( object );\n\n\t\t\t\t}\n\n\t\t\t\tgeometries.update( buffergeometry );\n\n\t\t\t\tupdateList[ buffergeometry.id ] = frame;\n\n\t\t\t}\n\n\t\t\treturn buffergeometry;\n\n\t\t}\n\n\t\tfunction dispose() {\n\n\t\t\tupdateList = {};\n\n\t\t}\n\n\t\treturn {\n\n\t\t\tupdate: update,\n\t\t\tdispose: dispose\n\n\t\t};\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction CubeTexture( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {\n\n\t\timages = images !== undefined ? images : [];\n\t\tmapping = mapping !== undefined ? mapping : CubeReflectionMapping;\n\n\t\tTexture.call( this, images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );\n\n\t\tthis.flipY = false;\n\n\t}\n\n\tCubeTexture.prototype = Object.create( Texture.prototype );\n\tCubeTexture.prototype.constructor = CubeTexture;\n\n\tCubeTexture.prototype.isCubeTexture = true;\n\n\tObject.defineProperty( CubeTexture.prototype, 'images', {\n\n\t\tget: function () {\n\n\t\t\treturn this.image;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis.image = value;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author Artur Trzesiok\n\t */\n\n\tfunction DataTexture3D( data, width, height, depth ) {\n\n\t\t// We're going to add .setXXX() methods for setting properties later.\n\t\t// Users can still set in DataTexture3D directly.\n\t\t//\n\t\t//\tvar texture = new THREE.DataTexture3D( data, width, height, depth );\n\t\t// \ttexture.anisotropy = 16;\n\t\t//\n\t\t// See #14839\n\n\t\tTexture.call( this, null );\n\n\t\tthis.image = { data: data, width: width, height: height, depth: depth };\n\n\t\tthis.magFilter = NearestFilter;\n\t\tthis.minFilter = NearestFilter;\n\n\t\tthis.generateMipmaps = false;\n\t\tthis.flipY = false;\n\n\t}\n\n\tDataTexture3D.prototype = Object.create( Texture.prototype );\n\tDataTexture3D.prototype.constructor = DataTexture3D;\n\tDataTexture3D.prototype.isDataTexture3D = true;\n\n\t/**\n\t * @author tschw\n\t * @author Mugen87 / https://github.com/Mugen87\n\t * @author mrdoob / http://mrdoob.com/\n\t *\n\t * Uniforms of a program.\n\t * Those form a tree structure with a special top-level container for the root,\n\t * which you get by calling 'new WebGLUniforms( gl, program, renderer )'.\n\t *\n\t *\n\t * Properties of inner nodes including the top-level container:\n\t *\n\t * .seq - array of nested uniforms\n\t * .map - nested uniforms by name\n\t *\n\t *\n\t * Methods of all nodes except the top-level container:\n\t *\n\t * .setValue( gl, value, [renderer] )\n\t *\n\t * \t\tuploads a uniform value(s)\n\t *  \tthe 'renderer' parameter is needed for sampler uniforms\n\t *\n\t *\n\t * Static methods of the top-level container (renderer factorizations):\n\t *\n\t * .upload( gl, seq, values, renderer )\n\t *\n\t * \t\tsets uniforms in 'seq' to 'values[id].value'\n\t *\n\t * .seqWithValue( seq, values ) : filteredSeq\n\t *\n\t * \t\tfilters 'seq' entries with corresponding entry in values\n\t *\n\t *\n\t * Methods of the top-level container (renderer factorizations):\n\t *\n\t * .setValue( gl, name, value )\n\t *\n\t * \t\tsets uniform with  name 'name' to 'value'\n\t *\n\t * .set( gl, obj, prop )\n\t *\n\t * \t\tsets uniform from object and property with same name than uniform\n\t *\n\t * .setOptional( gl, obj, prop )\n\t *\n\t * \t\tlike .set for an optional property of the object\n\t *\n\t */\n\n\tvar emptyTexture = new Texture();\n\tvar emptyTexture3d = new DataTexture3D();\n\tvar emptyCubeTexture = new CubeTexture();\n\n\t// --- Base for inner nodes (including the root) ---\n\n\tfunction UniformContainer() {\n\n\t\tthis.seq = [];\n\t\tthis.map = {};\n\n\t}\n\n\t// --- Utilities ---\n\n\t// Array Caches (provide typed arrays for temporary by size)\n\n\tvar arrayCacheF32 = [];\n\tvar arrayCacheI32 = [];\n\n\t// Float32Array caches used for uploading Matrix uniforms\n\n\tvar mat4array = new Float32Array( 16 );\n\tvar mat3array = new Float32Array( 9 );\n\tvar mat2array = new Float32Array( 4 );\n\n\t// Flattening for arrays of vectors and matrices\n\n\tfunction flatten( array, nBlocks, blockSize ) {\n\n\t\tvar firstElem = array[ 0 ];\n\n\t\tif ( firstElem <= 0 || firstElem > 0 ) return array;\n\t\t// unoptimized: ! isNaN( firstElem )\n\t\t// see http://jacksondunstan.com/articles/983\n\n\t\tvar n = nBlocks * blockSize,\n\t\t\tr = arrayCacheF32[ n ];\n\n\t\tif ( r === undefined ) {\n\n\t\t\tr = new Float32Array( n );\n\t\t\tarrayCacheF32[ n ] = r;\n\n\t\t}\n\n\t\tif ( nBlocks !== 0 ) {\n\n\t\t\tfirstElem.toArray( r, 0 );\n\n\t\t\tfor ( var i = 1, offset = 0; i !== nBlocks; ++ i ) {\n\n\t\t\t\toffset += blockSize;\n\t\t\t\tarray[ i ].toArray( r, offset );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn r;\n\n\t}\n\n\tfunction arraysEqual( a, b ) {\n\n\t\tif ( a.length !== b.length ) return false;\n\n\t\tfor ( var i = 0, l = a.length; i < l; i ++ ) {\n\n\t\t\tif ( a[ i ] !== b[ i ] ) return false;\n\n\t\t}\n\n\t\treturn true;\n\n\t}\n\n\tfunction copyArray( a, b ) {\n\n\t\tfor ( var i = 0, l = b.length; i < l; i ++ ) {\n\n\t\t\ta[ i ] = b[ i ];\n\n\t\t}\n\n\t}\n\n\t// Texture unit allocation\n\n\tfunction allocTexUnits( renderer, n ) {\n\n\t\tvar r = arrayCacheI32[ n ];\n\n\t\tif ( r === undefined ) {\n\n\t\t\tr = new Int32Array( n );\n\t\t\tarrayCacheI32[ n ] = r;\n\n\t\t}\n\n\t\tfor ( var i = 0; i !== n; ++ i )\n\t\t\tr[ i ] = renderer.allocTextureUnit();\n\n\t\treturn r;\n\n\t}\n\n\t// --- Setters ---\n\n\t// Note: Defining these methods externally, because they come in a bunch\n\t// and this way their names minify.\n\n\t// Single scalar\n\n\tfunction setValue1f( gl, v ) {\n\n\t\tvar cache = this.cache;\n\n\t\tif ( cache[ 0 ] === v ) return;\n\n\t\tgl.uniform1f( this.addr, v );\n\n\t\tcache[ 0 ] = v;\n\n\t}\n\n\tfunction setValue1i( gl, v ) {\n\n\t\tvar cache = this.cache;\n\n\t\tif ( cache[ 0 ] === v ) return;\n\n\t\tgl.uniform1i( this.addr, v );\n\n\t\tcache[ 0 ] = v;\n\n\t}\n\n\t// Single float vector (from flat array or THREE.VectorN)\n\n\tfunction setValue2fv( gl, v ) {\n\n\t\tvar cache = this.cache;\n\n\t\tif ( v.x !== undefined ) {\n\n\t\t\tif ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {\n\n\t\t\t\tgl.uniform2f( this.addr, v.x, v.y );\n\n\t\t\t\tcache[ 0 ] = v.x;\n\t\t\t\tcache[ 1 ] = v.y;\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\t\tgl.uniform2fv( this.addr, v );\n\n\t\t\tcopyArray( cache, v );\n\n\t\t}\n\n\t}\n\n\tfunction setValue3fv( gl, v ) {\n\n\t\tvar cache = this.cache;\n\n\t\tif ( v.x !== undefined ) {\n\n\t\t\tif ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {\n\n\t\t\t\tgl.uniform3f( this.addr, v.x, v.y, v.z );\n\n\t\t\t\tcache[ 0 ] = v.x;\n\t\t\t\tcache[ 1 ] = v.y;\n\t\t\t\tcache[ 2 ] = v.z;\n\n\t\t\t}\n\n\t\t} else if ( v.r !== undefined ) {\n\n\t\t\tif ( cache[ 0 ] !== v.r || cache[ 1 ] !== v.g || cache[ 2 ] !== v.b ) {\n\n\t\t\t\tgl.uniform3f( this.addr, v.r, v.g, v.b );\n\n\t\t\t\tcache[ 0 ] = v.r;\n\t\t\t\tcache[ 1 ] = v.g;\n\t\t\t\tcache[ 2 ] = v.b;\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\t\tgl.uniform3fv( this.addr, v );\n\n\t\t\tcopyArray( cache, v );\n\n\t\t}\n\n\t}\n\n\tfunction setValue4fv( gl, v ) {\n\n\t\tvar cache = this.cache;\n\n\t\tif ( v.x !== undefined ) {\n\n\t\t\tif ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {\n\n\t\t\t\tgl.uniform4f( this.addr, v.x, v.y, v.z, v.w );\n\n\t\t\t\tcache[ 0 ] = v.x;\n\t\t\t\tcache[ 1 ] = v.y;\n\t\t\t\tcache[ 2 ] = v.z;\n\t\t\t\tcache[ 3 ] = v.w;\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\t\tgl.uniform4fv( this.addr, v );\n\n\t\t\tcopyArray( cache, v );\n\n\t\t}\n\n\t}\n\n\t// Single matrix (from flat array or MatrixN)\n\n\tfunction setValue2fm( gl, v ) {\n\n\t\tvar cache = this.cache;\n\t\tvar elements = v.elements;\n\n\t\tif ( elements === undefined ) {\n\n\t\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\t\tgl.uniformMatrix2fv( this.addr, false, v );\n\n\t\t\tcopyArray( cache, v );\n\n\t\t} else {\n\n\t\t\tif ( arraysEqual( cache, elements ) ) return;\n\n\t\t\tmat2array.set( elements );\n\n\t\t\tgl.uniformMatrix2fv( this.addr, false, mat2array );\n\n\t\t\tcopyArray( cache, elements );\n\n\t\t}\n\n\t}\n\n\tfunction setValue3fm( gl, v ) {\n\n\t\tvar cache = this.cache;\n\t\tvar elements = v.elements;\n\n\t\tif ( elements === undefined ) {\n\n\t\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\t\tgl.uniformMatrix3fv( this.addr, false, v );\n\n\t\t\tcopyArray( cache, v );\n\n\t\t} else {\n\n\t\t\tif ( arraysEqual( cache, elements ) ) return;\n\n\t\t\tmat3array.set( elements );\n\n\t\t\tgl.uniformMatrix3fv( this.addr, false, mat3array );\n\n\t\t\tcopyArray( cache, elements );\n\n\t\t}\n\n\t}\n\n\tfunction setValue4fm( gl, v ) {\n\n\t\tvar cache = this.cache;\n\t\tvar elements = v.elements;\n\n\t\tif ( elements === undefined ) {\n\n\t\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\t\tgl.uniformMatrix4fv( this.addr, false, v );\n\n\t\t\tcopyArray( cache, v );\n\n\t\t} else {\n\n\t\t\tif ( arraysEqual( cache, elements ) ) return;\n\n\t\t\tmat4array.set( elements );\n\n\t\t\tgl.uniformMatrix4fv( this.addr, false, mat4array );\n\n\t\t\tcopyArray( cache, elements );\n\n\t\t}\n\n\t}\n\n\t// Single texture (2D / Cube)\n\n\tfunction setValueT1( gl, v, renderer ) {\n\n\t\tvar cache = this.cache;\n\t\tvar unit = renderer.allocTextureUnit();\n\n\t\tif ( cache[ 0 ] !== unit ) {\n\n\t\t\tgl.uniform1i( this.addr, unit );\n\t\t\tcache[ 0 ] = unit;\n\n\t\t}\n\n\t\trenderer.setTexture2D( v || emptyTexture, unit );\n\n\t}\n\n\tfunction setValueT3D1( gl, v, renderer ) {\n\n\t\tvar cache = this.cache;\n\t\tvar unit = renderer.allocTextureUnit();\n\n\t\tif ( cache[ 0 ] !== unit ) {\n\n\t\t\tgl.uniform1i( this.addr, unit );\n\t\t\tcache[ 0 ] = unit;\n\n\t\t}\n\n\t\trenderer.setTexture3D( v || emptyTexture3d, unit );\n\n\t}\n\n\tfunction setValueT6( gl, v, renderer ) {\n\n\t\tvar cache = this.cache;\n\t\tvar unit = renderer.allocTextureUnit();\n\n\t\tif ( cache[ 0 ] !== unit ) {\n\n\t\t\tgl.uniform1i( this.addr, unit );\n\t\t\tcache[ 0 ] = unit;\n\n\t\t}\n\n\t\trenderer.setTextureCube( v || emptyCubeTexture, unit );\n\n\t}\n\n\t// Integer / Boolean vectors or arrays thereof (always flat arrays)\n\n\tfunction setValue2iv( gl, v ) {\n\n\t\tvar cache = this.cache;\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniform2iv( this.addr, v );\n\n\t\tcopyArray( cache, v );\n\n\t}\n\n\tfunction setValue3iv( gl, v ) {\n\n\t\tvar cache = this.cache;\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniform3iv( this.addr, v );\n\n\t\tcopyArray( cache, v );\n\n\t}\n\n\tfunction setValue4iv( gl, v ) {\n\n\t\tvar cache = this.cache;\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniform4iv( this.addr, v );\n\n\t\tcopyArray( cache, v );\n\n\t}\n\n\t// Helper to pick the right setter for the singular case\n\n\tfunction getSingularSetter( type ) {\n\n\t\tswitch ( type ) {\n\n\t\t\tcase 0x1406: return setValue1f; // FLOAT\n\t\t\tcase 0x8b50: return setValue2fv; // _VEC2\n\t\t\tcase 0x8b51: return setValue3fv; // _VEC3\n\t\t\tcase 0x8b52: return setValue4fv; // _VEC4\n\n\t\t\tcase 0x8b5a: return setValue2fm; // _MAT2\n\t\t\tcase 0x8b5b: return setValue3fm; // _MAT3\n\t\t\tcase 0x8b5c: return setValue4fm; // _MAT4\n\n\t\t\tcase 0x8b5e: case 0x8d66: return setValueT1; // SAMPLER_2D, SAMPLER_EXTERNAL_OES\n\t\t\tcase 0x8B5F: return setValueT3D1; // SAMPLER_3D\n\t\t\tcase 0x8b60: return setValueT6; // SAMPLER_CUBE\n\n\t\t\tcase 0x1404: case 0x8b56: return setValue1i; // INT, BOOL\n\t\t\tcase 0x8b53: case 0x8b57: return setValue2iv; // _VEC2\n\t\t\tcase 0x8b54: case 0x8b58: return setValue3iv; // _VEC3\n\t\t\tcase 0x8b55: case 0x8b59: return setValue4iv; // _VEC4\n\n\t\t}\n\n\t}\n\n\t// Array of scalars\n\n\tfunction setValue1fv( gl, v ) {\n\n\t\tvar cache = this.cache;\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniform1fv( this.addr, v );\n\n\t\tcopyArray( cache, v );\n\n\t}\n\tfunction setValue1iv( gl, v ) {\n\n\t\tvar cache = this.cache;\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniform1iv( this.addr, v );\n\n\t\tcopyArray( cache, v );\n\n\t}\n\n\t// Array of vectors (flat or from THREE classes)\n\n\tfunction setValueV2a( gl, v ) {\n\n\t\tvar cache = this.cache;\n\t\tvar data = flatten( v, this.size, 2 );\n\n\t\tif ( arraysEqual( cache, data ) ) return;\n\n\t\tgl.uniform2fv( this.addr, data );\n\n\t\tthis.updateCache( data );\n\n\t}\n\n\tfunction setValueV3a( gl, v ) {\n\n\t\tvar cache = this.cache;\n\t\tvar data = flatten( v, this.size, 3 );\n\n\t\tif ( arraysEqual( cache, data ) ) return;\n\n\t\tgl.uniform3fv( this.addr, data );\n\n\t\tthis.updateCache( data );\n\n\t}\n\n\tfunction setValueV4a( gl, v ) {\n\n\t\tvar cache = this.cache;\n\t\tvar data = flatten( v, this.size, 4 );\n\n\t\tif ( arraysEqual( cache, data ) ) return;\n\n\t\tgl.uniform4fv( this.addr, data );\n\n\t\tthis.updateCache( data );\n\n\t}\n\n\t// Array of matrices (flat or from THREE clases)\n\n\tfunction setValueM2a( gl, v ) {\n\n\t\tvar cache = this.cache;\n\t\tvar data = flatten( v, this.size, 4 );\n\n\t\tif ( arraysEqual( cache, data ) ) return;\n\n\t\tgl.uniformMatrix2fv( this.addr, false, data );\n\n\t\tthis.updateCache( data );\n\n\t}\n\n\tfunction setValueM3a( gl, v ) {\n\n\t\tvar cache = this.cache;\n\t\tvar data = flatten( v, this.size, 9 );\n\n\t\tif ( arraysEqual( cache, data ) ) return;\n\n\t\tgl.uniformMatrix3fv( this.addr, false, data );\n\n\t\tthis.updateCache( data );\n\n\t}\n\n\tfunction setValueM4a( gl, v ) {\n\n\t\tvar cache = this.cache;\n\t\tvar data = flatten( v, this.size, 16 );\n\n\t\tif ( arraysEqual( cache, data ) ) return;\n\n\t\tgl.uniformMatrix4fv( this.addr, false, data );\n\n\t\tthis.updateCache( data );\n\n\t}\n\n\t// Array of textures (2D / Cube)\n\n\tfunction setValueT1a( gl, v, renderer ) {\n\n\t\tvar cache = this.cache;\n\t\tvar n = v.length;\n\n\t\tvar units = allocTexUnits( renderer, n );\n\n\t\tif ( arraysEqual( cache, units ) === false ) {\n\n\t\t\tgl.uniform1iv( this.addr, units );\n\t\t\tcopyArray( cache, units );\n\n\t\t}\n\n\t\tfor ( var i = 0; i !== n; ++ i ) {\n\n\t\t\trenderer.setTexture2D( v[ i ] || emptyTexture, units[ i ] );\n\n\t\t}\n\n\t}\n\n\tfunction setValueT6a( gl, v, renderer ) {\n\n\t\tvar cache = this.cache;\n\t\tvar n = v.length;\n\n\t\tvar units = allocTexUnits( renderer, n );\n\n\t\tif ( arraysEqual( cache, units ) === false ) {\n\n\t\t\tgl.uniform1iv( this.addr, units );\n\t\t\tcopyArray( cache, units );\n\n\t\t}\n\n\t\tfor ( var i = 0; i !== n; ++ i ) {\n\n\t\t\trenderer.setTextureCube( v[ i ] || emptyCubeTexture, units[ i ] );\n\n\t\t}\n\n\t}\n\n\t// Helper to pick the right setter for a pure (bottom-level) array\n\n\tfunction getPureArraySetter( type ) {\n\n\t\tswitch ( type ) {\n\n\t\t\tcase 0x1406: return setValue1fv; // FLOAT\n\t\t\tcase 0x8b50: return setValueV2a; // _VEC2\n\t\t\tcase 0x8b51: return setValueV3a; // _VEC3\n\t\t\tcase 0x8b52: return setValueV4a; // _VEC4\n\n\t\t\tcase 0x8b5a: return setValueM2a; // _MAT2\n\t\t\tcase 0x8b5b: return setValueM3a; // _MAT3\n\t\t\tcase 0x8b5c: return setValueM4a; // _MAT4\n\n\t\t\tcase 0x8b5e: return setValueT1a; // SAMPLER_2D\n\t\t\tcase 0x8b60: return setValueT6a; // SAMPLER_CUBE\n\n\t\t\tcase 0x1404: case 0x8b56: return setValue1iv; // INT, BOOL\n\t\t\tcase 0x8b53: case 0x8b57: return setValue2iv; // _VEC2\n\t\t\tcase 0x8b54: case 0x8b58: return setValue3iv; // _VEC3\n\t\t\tcase 0x8b55: case 0x8b59: return setValue4iv; // _VEC4\n\n\t\t}\n\n\t}\n\n\t// --- Uniform Classes ---\n\n\tfunction SingleUniform( id, activeInfo, addr ) {\n\n\t\tthis.id = id;\n\t\tthis.addr = addr;\n\t\tthis.cache = [];\n\t\tthis.setValue = getSingularSetter( activeInfo.type );\n\n\t\t// this.path = activeInfo.name; // DEBUG\n\n\t}\n\n\tfunction PureArrayUniform( id, activeInfo, addr ) {\n\n\t\tthis.id = id;\n\t\tthis.addr = addr;\n\t\tthis.cache = [];\n\t\tthis.size = activeInfo.size;\n\t\tthis.setValue = getPureArraySetter( activeInfo.type );\n\n\t\t// this.path = activeInfo.name; // DEBUG\n\n\t}\n\n\tPureArrayUniform.prototype.updateCache = function ( data ) {\n\n\t\tvar cache = this.cache;\n\n\t\tif ( data instanceof Float32Array && cache.length !== data.length ) {\n\n\t\t\tthis.cache = new Float32Array( data.length );\n\n\t\t}\n\n\t\tcopyArray( cache, data );\n\n\t};\n\n\tfunction StructuredUniform( id ) {\n\n\t\tthis.id = id;\n\n\t\tUniformContainer.call( this ); // mix-in\n\n\t}\n\n\tStructuredUniform.prototype.setValue = function ( gl, value, renderer ) {\n\n\t\tvar seq = this.seq;\n\n\t\tfor ( var i = 0, n = seq.length; i !== n; ++ i ) {\n\n\t\t\tvar u = seq[ i ];\n\t\t\tu.setValue( gl, value[ u.id ], renderer );\n\n\t\t}\n\n\t};\n\n\t// --- Top-level ---\n\n\t// Parser - builds up the property tree from the path strings\n\n\tvar RePathPart = /([\\w\\d_]+)(\\])?(\\[|\\.)?/g;\n\n\t// extracts\n\t// \t- the identifier (member name or array index)\n\t//  - followed by an optional right bracket (found when array index)\n\t//  - followed by an optional left bracket or dot (type of subscript)\n\t//\n\t// Note: These portions can be read in a non-overlapping fashion and\n\t// allow straightforward parsing of the hierarchy that WebGL encodes\n\t// in the uniform names.\n\n\tfunction addUniform( container, uniformObject ) {\n\n\t\tcontainer.seq.push( uniformObject );\n\t\tcontainer.map[ uniformObject.id ] = uniformObject;\n\n\t}\n\n\tfunction parseUniform( activeInfo, addr, container ) {\n\n\t\tvar path = activeInfo.name,\n\t\t\tpathLength = path.length;\n\n\t\t// reset RegExp object, because of the early exit of a previous run\n\t\tRePathPart.lastIndex = 0;\n\n\t\twhile ( true ) {\n\n\t\t\tvar match = RePathPart.exec( path ),\n\t\t\t\tmatchEnd = RePathPart.lastIndex,\n\n\t\t\t\tid = match[ 1 ],\n\t\t\t\tidIsIndex = match[ 2 ] === ']',\n\t\t\t\tsubscript = match[ 3 ];\n\n\t\t\tif ( idIsIndex ) id = id | 0; // convert to integer\n\n\t\t\tif ( subscript === undefined || subscript === '[' && matchEnd + 2 === pathLength ) {\n\n\t\t\t\t// bare name or \"pure\" bottom-level array \"[0]\" suffix\n\n\t\t\t\taddUniform( container, subscript === undefined ?\n\t\t\t\t\tnew SingleUniform( id, activeInfo, addr ) :\n\t\t\t\t\tnew PureArrayUniform( id, activeInfo, addr ) );\n\n\t\t\t\tbreak;\n\n\t\t\t} else {\n\n\t\t\t\t// step into inner node / create it in case it doesn't exist\n\n\t\t\t\tvar map = container.map, next = map[ id ];\n\n\t\t\t\tif ( next === undefined ) {\n\n\t\t\t\t\tnext = new StructuredUniform( id );\n\t\t\t\t\taddUniform( container, next );\n\n\t\t\t\t}\n\n\t\t\t\tcontainer = next;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\t// Root Container\n\n\tfunction WebGLUniforms( gl, program, renderer ) {\n\n\t\tUniformContainer.call( this );\n\n\t\tthis.renderer = renderer;\n\n\t\tvar n = gl.getProgramParameter( program, 35718 );\n\n\t\tfor ( var i = 0; i < n; ++ i ) {\n\n\t\t\tvar info = gl.getActiveUniform( program, i ),\n\t\t\t\taddr = gl.getUniformLocation( program, info.name );\n\n\t\t\tparseUniform( info, addr, this );\n\n\t\t}\n\n\t}\n\n\tWebGLUniforms.prototype.setValue = function ( gl, name, value ) {\n\n\t\tvar u = this.map[ name ];\n\n\t\tif ( u !== undefined ) u.setValue( gl, value, this.renderer );\n\n\t};\n\n\tWebGLUniforms.prototype.setOptional = function ( gl, object, name ) {\n\n\t\tvar v = object[ name ];\n\n\t\tif ( v !== undefined ) this.setValue( gl, name, v );\n\n\t};\n\n\n\t// Static interface\n\n\tWebGLUniforms.upload = function ( gl, seq, values, renderer ) {\n\n\t\tfor ( var i = 0, n = seq.length; i !== n; ++ i ) {\n\n\t\t\tvar u = seq[ i ],\n\t\t\t\tv = values[ u.id ];\n\n\t\t\tif ( v.needsUpdate !== false ) {\n\n\t\t\t\t// note: always updating when .needsUpdate is undefined\n\t\t\t\tu.setValue( gl, v.value, renderer );\n\n\t\t\t}\n\n\t\t}\n\n\t};\n\n\tWebGLUniforms.seqWithValue = function ( seq, values ) {\n\n\t\tvar r = [];\n\n\t\tfor ( var i = 0, n = seq.length; i !== n; ++ i ) {\n\n\t\t\tvar u = seq[ i ];\n\t\t\tif ( u.id in values ) r.push( u );\n\n\t\t}\n\n\t\treturn r;\n\n\t};\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction addLineNumbers( string ) {\n\n\t\tvar lines = string.split( '\\n' );\n\n\t\tfor ( var i = 0; i < lines.length; i ++ ) {\n\n\t\t\tlines[ i ] = ( i + 1 ) + ': ' + lines[ i ];\n\n\t\t}\n\n\t\treturn lines.join( '\\n' );\n\n\t}\n\n\tfunction WebGLShader( gl, type, string ) {\n\n\t\tvar shader = gl.createShader( type );\n\n\t\tgl.shaderSource( shader, string );\n\t\tgl.compileShader( shader );\n\n\t\tif ( gl.getShaderParameter( shader, 35713 ) === false ) {\n\n\t\t\tconsole.error( 'THREE.WebGLShader: Shader couldn\\'t compile.' );\n\n\t\t}\n\n\t\tif ( gl.getShaderInfoLog( shader ) !== '' ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLShader: gl.getShaderInfoLog()', type === 35633 ? 'vertex' : 'fragment', gl.getShaderInfoLog( shader ), addLineNumbers( string ) );\n\n\t\t}\n\n\t\t// --enable-privileged-webgl-extension\n\t\t// console.log( type, gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );\n\n\t\treturn shader;\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tvar programIdCount = 0;\n\n\tfunction getEncodingComponents( encoding ) {\n\n\t\tswitch ( encoding ) {\n\n\t\t\tcase LinearEncoding:\n\t\t\t\treturn [ 'Linear', '( value )' ];\n\t\t\tcase sRGBEncoding:\n\t\t\t\treturn [ 'sRGB', '( value )' ];\n\t\t\tcase RGBEEncoding:\n\t\t\t\treturn [ 'RGBE', '( value )' ];\n\t\t\tcase RGBM7Encoding:\n\t\t\t\treturn [ 'RGBM', '( value, 7.0 )' ];\n\t\t\tcase RGBM16Encoding:\n\t\t\t\treturn [ 'RGBM', '( value, 16.0 )' ];\n\t\t\tcase RGBDEncoding:\n\t\t\t\treturn [ 'RGBD', '( value, 256.0 )' ];\n\t\t\tcase GammaEncoding:\n\t\t\t\treturn [ 'Gamma', '( value, float( GAMMA_FACTOR ) )' ];\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'unsupported encoding: ' + encoding );\n\n\t\t}\n\n\t}\n\n\tfunction getTexelDecodingFunction( functionName, encoding ) {\n\n\t\tvar components = getEncodingComponents( encoding );\n\t\treturn 'vec4 ' + functionName + '( vec4 value ) { return ' + components[ 0 ] + 'ToLinear' + components[ 1 ] + '; }';\n\n\t}\n\n\tfunction getTexelEncodingFunction( functionName, encoding ) {\n\n\t\tvar components = getEncodingComponents( encoding );\n\t\treturn 'vec4 ' + functionName + '( vec4 value ) { return LinearTo' + components[ 0 ] + components[ 1 ] + '; }';\n\n\t}\n\n\tfunction getToneMappingFunction( functionName, toneMapping ) {\n\n\t\tvar toneMappingName;\n\n\t\tswitch ( toneMapping ) {\n\n\t\t\tcase LinearToneMapping:\n\t\t\t\ttoneMappingName = 'Linear';\n\t\t\t\tbreak;\n\n\t\t\tcase ReinhardToneMapping:\n\t\t\t\ttoneMappingName = 'Reinhard';\n\t\t\t\tbreak;\n\n\t\t\tcase Uncharted2ToneMapping:\n\t\t\t\ttoneMappingName = 'Uncharted2';\n\t\t\t\tbreak;\n\n\t\t\tcase CineonToneMapping:\n\t\t\t\ttoneMappingName = 'OptimizedCineon';\n\t\t\t\tbreak;\n\n\t\t\tcase ACESFilmicToneMapping:\n\t\t\t\ttoneMappingName = 'ACESFilmic';\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error( 'unsupported toneMapping: ' + toneMapping );\n\n\t\t}\n\n\t\treturn 'vec3 ' + functionName + '( vec3 color ) { return ' + toneMappingName + 'ToneMapping( color ); }';\n\n\t}\n\n\tfunction generateExtensions( extensions, parameters, rendererExtensions ) {\n\n\t\textensions = extensions || {};\n\n\t\tvar chunks = [\n\t\t\t( extensions.derivatives || parameters.envMapCubeUV || parameters.bumpMap || ( parameters.normalMap && ! parameters.objectSpaceNormalMap ) || parameters.flatShading ) ? '#extension GL_OES_standard_derivatives : enable' : '',\n\t\t\t( extensions.fragDepth || parameters.logarithmicDepthBuffer ) && rendererExtensions.get( 'EXT_frag_depth' ) ? '#extension GL_EXT_frag_depth : enable' : '',\n\t\t\t( extensions.drawBuffers ) && rendererExtensions.get( 'WEBGL_draw_buffers' ) ? '#extension GL_EXT_draw_buffers : require' : '',\n\t\t\t( extensions.shaderTextureLOD || parameters.envMap ) && rendererExtensions.get( 'EXT_shader_texture_lod' ) ? '#extension GL_EXT_shader_texture_lod : enable' : ''\n\t\t];\n\n\t\treturn chunks.filter( filterEmptyLine ).join( '\\n' );\n\n\t}\n\n\tfunction generateDefines( defines ) {\n\n\t\tvar chunks = [];\n\n\t\tfor ( var name in defines ) {\n\n\t\t\tvar value = defines[ name ];\n\n\t\t\tif ( value === false ) continue;\n\n\t\t\tchunks.push( '#define ' + name + ' ' + value );\n\n\t\t}\n\n\t\treturn chunks.join( '\\n' );\n\n\t}\n\n\tfunction fetchAttributeLocations( gl, program ) {\n\n\t\tvar attributes = {};\n\n\t\tvar n = gl.getProgramParameter( program, 35721 );\n\n\t\tfor ( var i = 0; i < n; i ++ ) {\n\n\t\t\tvar info = gl.getActiveAttrib( program, i );\n\t\t\tvar name = info.name;\n\n\t\t\t// console.log( 'THREE.WebGLProgram: ACTIVE VERTEX ATTRIBUTE:', name, i );\n\n\t\t\tattributes[ name ] = gl.getAttribLocation( program, name );\n\n\t\t}\n\n\t\treturn attributes;\n\n\t}\n\n\tfunction filterEmptyLine( string ) {\n\n\t\treturn string !== '';\n\n\t}\n\n\tfunction replaceLightNums( string, parameters ) {\n\n\t\treturn string\n\t\t\t.replace( /NUM_DIR_LIGHTS/g, parameters.numDirLights )\n\t\t\t.replace( /NUM_SPOT_LIGHTS/g, parameters.numSpotLights )\n\t\t\t.replace( /NUM_RECT_AREA_LIGHTS/g, parameters.numRectAreaLights )\n\t\t\t.replace( /NUM_POINT_LIGHTS/g, parameters.numPointLights )\n\t\t\t.replace( /NUM_HEMI_LIGHTS/g, parameters.numHemiLights );\n\n\t}\n\n\tfunction replaceClippingPlaneNums( string, parameters ) {\n\n\t\treturn string\n\t\t\t.replace( /NUM_CLIPPING_PLANES/g, parameters.numClippingPlanes )\n\t\t\t.replace( /UNION_CLIPPING_PLANES/g, ( parameters.numClippingPlanes - parameters.numClipIntersection ) );\n\n\t}\n\n\tfunction parseIncludes( string ) {\n\n\t\tvar pattern = /^[ \\t]*#include +<([\\w\\d./]+)>/gm;\n\n\t\tfunction replace( match, include ) {\n\n\t\t\tvar replace = ShaderChunk[ include ];\n\n\t\t\tif ( replace === undefined ) {\n\n\t\t\t\tthrow new Error( 'Can not resolve #include <' + include + '>' );\n\n\t\t\t}\n\n\t\t\treturn parseIncludes( replace );\n\n\t\t}\n\n\t\treturn string.replace( pattern, replace );\n\n\t}\n\n\tfunction unrollLoops( string ) {\n\n\t\tvar pattern = /#pragma unroll_loop[\\s]+?for \\( int i \\= (\\d+)\\; i < (\\d+)\\; i \\+\\+ \\) \\{([\\s\\S]+?)(?=\\})\\}/g;\n\n\t\tfunction replace( match, start, end, snippet ) {\n\n\t\t\tvar unroll = '';\n\n\t\t\tfor ( var i = parseInt( start ); i < parseInt( end ); i ++ ) {\n\n\t\t\t\tunroll += snippet.replace( /\\[ i \\]/g, '[ ' + i + ' ]' );\n\n\t\t\t}\n\n\t\t\treturn unroll;\n\n\t\t}\n\n\t\treturn string.replace( pattern, replace );\n\n\t}\n\n\tfunction WebGLProgram( renderer, extensions, code, material, shader, parameters, capabilities ) {\n\n\t\tvar gl = renderer.context;\n\n\t\tvar defines = material.defines;\n\n\t\tvar vertexShader = shader.vertexShader;\n\t\tvar fragmentShader = shader.fragmentShader;\n\n\t\tvar shadowMapTypeDefine = 'SHADOWMAP_TYPE_BASIC';\n\n\t\tif ( parameters.shadowMapType === PCFShadowMap ) {\n\n\t\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF';\n\n\t\t} else if ( parameters.shadowMapType === PCFSoftShadowMap ) {\n\n\t\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF_SOFT';\n\n\t\t}\n\n\t\tvar envMapTypeDefine = 'ENVMAP_TYPE_CUBE';\n\t\tvar envMapModeDefine = 'ENVMAP_MODE_REFLECTION';\n\t\tvar envMapBlendingDefine = 'ENVMAP_BLENDING_MULTIPLY';\n\n\t\tif ( parameters.envMap ) {\n\n\t\t\tswitch ( material.envMap.mapping ) {\n\n\t\t\t\tcase CubeReflectionMapping:\n\t\t\t\tcase CubeRefractionMapping:\n\t\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_CUBE';\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase CubeUVReflectionMapping:\n\t\t\t\tcase CubeUVRefractionMapping:\n\t\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_CUBE_UV';\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase EquirectangularReflectionMapping:\n\t\t\t\tcase EquirectangularRefractionMapping:\n\t\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_EQUIREC';\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase SphericalReflectionMapping:\n\t\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_SPHERE';\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t\tswitch ( material.envMap.mapping ) {\n\n\t\t\t\tcase CubeRefractionMapping:\n\t\t\t\tcase EquirectangularRefractionMapping:\n\t\t\t\t\tenvMapModeDefine = 'ENVMAP_MODE_REFRACTION';\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t\tswitch ( material.combine ) {\n\n\t\t\t\tcase MultiplyOperation:\n\t\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_MULTIPLY';\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MixOperation:\n\t\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_MIX';\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase AddOperation:\n\t\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_ADD';\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t}\n\n\t\tvar gammaFactorDefine = ( renderer.gammaFactor > 0 ) ? renderer.gammaFactor : 1.0;\n\n\t\t// console.log( 'building new program ' );\n\n\t\t//\n\n\t\tvar customExtensions = capabilities.isWebGL2 ? '' : generateExtensions( material.extensions, parameters, extensions );\n\n\t\tvar customDefines = generateDefines( defines );\n\n\t\t//\n\n\t\tvar program = gl.createProgram();\n\n\t\tvar prefixVertex, prefixFragment;\n\n\t\tif ( material.isRawShaderMaterial ) {\n\n\t\t\tprefixVertex = [\n\n\t\t\t\tcustomDefines\n\n\t\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t\t\tif ( prefixVertex.length > 0 ) {\n\n\t\t\t\tprefixVertex += '\\n';\n\n\t\t\t}\n\n\t\t\tprefixFragment = [\n\n\t\t\t\tcustomExtensions,\n\t\t\t\tcustomDefines\n\n\t\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t\t\tif ( prefixFragment.length > 0 ) {\n\n\t\t\t\tprefixFragment += '\\n';\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tprefixVertex = [\n\n\t\t\t\t'precision ' + parameters.precision + ' float;',\n\t\t\t\t'precision ' + parameters.precision + ' int;',\n\n\t\t\t\t'#define SHADER_NAME ' + shader.name,\n\n\t\t\t\tcustomDefines,\n\n\t\t\t\tparameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '',\n\n\t\t\t\t'#define GAMMA_FACTOR ' + gammaFactorDefine,\n\n\t\t\t\t'#define MAX_BONES ' + parameters.maxBones,\n\t\t\t\t( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '',\n\t\t\t\t( parameters.useFog && parameters.fogExp ) ? '#define FOG_EXP2' : '',\n\n\t\t\t\tparameters.map ? '#define USE_MAP' : '',\n\t\t\t\tparameters.envMap ? '#define USE_ENVMAP' : '',\n\t\t\t\tparameters.envMap ? '#define ' + envMapModeDefine : '',\n\t\t\t\tparameters.lightMap ? '#define USE_LIGHTMAP' : '',\n\t\t\t\tparameters.aoMap ? '#define USE_AOMAP' : '',\n\t\t\t\tparameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',\n\t\t\t\tparameters.bumpMap ? '#define USE_BUMPMAP' : '',\n\t\t\t\tparameters.normalMap ? '#define USE_NORMALMAP' : '',\n\t\t\t\t( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '',\n\t\t\t\tparameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '',\n\t\t\t\tparameters.specularMap ? '#define USE_SPECULARMAP' : '',\n\t\t\t\tparameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',\n\t\t\t\tparameters.metalnessMap ? '#define USE_METALNESSMAP' : '',\n\t\t\t\tparameters.alphaMap ? '#define USE_ALPHAMAP' : '',\n\t\t\t\tparameters.vertexColors ? '#define USE_COLOR' : '',\n\n\t\t\t\tparameters.flatShading ? '#define FLAT_SHADED' : '',\n\n\t\t\t\tparameters.skinning ? '#define USE_SKINNING' : '',\n\t\t\t\tparameters.useVertexTexture ? '#define BONE_TEXTURE' : '',\n\n\t\t\t\tparameters.morphTargets ? '#define USE_MORPHTARGETS' : '',\n\t\t\t\tparameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '',\n\t\t\t\tparameters.doubleSided ? '#define DOUBLE_SIDED' : '',\n\t\t\t\tparameters.flipSided ? '#define FLIP_SIDED' : '',\n\n\t\t\t\tparameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '',\n\t\t\t\tparameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '',\n\n\t\t\t\tparameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '',\n\n\t\t\t\tparameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',\n\t\t\t\tparameters.logarithmicDepthBuffer && ( capabilities.isWebGL2 || extensions.get( 'EXT_frag_depth' ) ) ? '#define USE_LOGDEPTHBUF_EXT' : '',\n\n\t\t\t\t'uniform mat4 modelMatrix;',\n\t\t\t\t'uniform mat4 modelViewMatrix;',\n\t\t\t\t'uniform mat4 projectionMatrix;',\n\t\t\t\t'uniform mat4 viewMatrix;',\n\t\t\t\t'uniform mat3 normalMatrix;',\n\t\t\t\t'uniform vec3 cameraPosition;',\n\n\t\t\t\t'attribute vec3 position;',\n\t\t\t\t'attribute vec3 normal;',\n\t\t\t\t'attribute vec2 uv;',\n\n\t\t\t\t'#ifdef USE_COLOR',\n\n\t\t\t\t'\tattribute vec3 color;',\n\n\t\t\t\t'#endif',\n\n\t\t\t\t'#ifdef USE_MORPHTARGETS',\n\n\t\t\t\t'\tattribute vec3 morphTarget0;',\n\t\t\t\t'\tattribute vec3 morphTarget1;',\n\t\t\t\t'\tattribute vec3 morphTarget2;',\n\t\t\t\t'\tattribute vec3 morphTarget3;',\n\n\t\t\t\t'\t#ifdef USE_MORPHNORMALS',\n\n\t\t\t\t'\t\tattribute vec3 morphNormal0;',\n\t\t\t\t'\t\tattribute vec3 morphNormal1;',\n\t\t\t\t'\t\tattribute vec3 morphNormal2;',\n\t\t\t\t'\t\tattribute vec3 morphNormal3;',\n\n\t\t\t\t'\t#else',\n\n\t\t\t\t'\t\tattribute vec3 morphTarget4;',\n\t\t\t\t'\t\tattribute vec3 morphTarget5;',\n\t\t\t\t'\t\tattribute vec3 morphTarget6;',\n\t\t\t\t'\t\tattribute vec3 morphTarget7;',\n\n\t\t\t\t'\t#endif',\n\n\t\t\t\t'#endif',\n\n\t\t\t\t'#ifdef USE_SKINNING',\n\n\t\t\t\t'\tattribute vec4 skinIndex;',\n\t\t\t\t'\tattribute vec4 skinWeight;',\n\n\t\t\t\t'#endif',\n\n\t\t\t\t'\\n'\n\n\t\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t\t\tprefixFragment = [\n\n\t\t\t\tcustomExtensions,\n\n\t\t\t\t'precision ' + parameters.precision + ' float;',\n\t\t\t\t'precision ' + parameters.precision + ' int;',\n\n\t\t\t\t'#define SHADER_NAME ' + shader.name,\n\n\t\t\t\tcustomDefines,\n\n\t\t\t\tparameters.alphaTest ? '#define ALPHATEST ' + parameters.alphaTest + ( parameters.alphaTest % 1 ? '' : '.0' ) : '', // add '.0' if integer\n\n\t\t\t\t'#define GAMMA_FACTOR ' + gammaFactorDefine,\n\n\t\t\t\t( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '',\n\t\t\t\t( parameters.useFog && parameters.fogExp ) ? '#define FOG_EXP2' : '',\n\n\t\t\t\tparameters.map ? '#define USE_MAP' : '',\n\t\t\t\tparameters.matcap ? '#define USE_MATCAP' : '',\n\t\t\t\tparameters.envMap ? '#define USE_ENVMAP' : '',\n\t\t\t\tparameters.envMap ? '#define ' + envMapTypeDefine : '',\n\t\t\t\tparameters.envMap ? '#define ' + envMapModeDefine : '',\n\t\t\t\tparameters.envMap ? '#define ' + envMapBlendingDefine : '',\n\t\t\t\tparameters.lightMap ? '#define USE_LIGHTMAP' : '',\n\t\t\t\tparameters.aoMap ? '#define USE_AOMAP' : '',\n\t\t\t\tparameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',\n\t\t\t\tparameters.bumpMap ? '#define USE_BUMPMAP' : '',\n\t\t\t\tparameters.normalMap ? '#define USE_NORMALMAP' : '',\n\t\t\t\t( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '',\n\t\t\t\tparameters.specularMap ? '#define USE_SPECULARMAP' : '',\n\t\t\t\tparameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',\n\t\t\t\tparameters.metalnessMap ? '#define USE_METALNESSMAP' : '',\n\t\t\t\tparameters.alphaMap ? '#define USE_ALPHAMAP' : '',\n\t\t\t\tparameters.vertexColors ? '#define USE_COLOR' : '',\n\n\t\t\t\tparameters.gradientMap ? '#define USE_GRADIENTMAP' : '',\n\n\t\t\t\tparameters.flatShading ? '#define FLAT_SHADED' : '',\n\n\t\t\t\tparameters.doubleSided ? '#define DOUBLE_SIDED' : '',\n\t\t\t\tparameters.flipSided ? '#define FLIP_SIDED' : '',\n\n\t\t\t\tparameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '',\n\t\t\t\tparameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '',\n\n\t\t\t\tparameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '',\n\n\t\t\t\tparameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '',\n\n\t\t\t\tparameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',\n\t\t\t\tparameters.logarithmicDepthBuffer && ( capabilities.isWebGL2 || extensions.get( 'EXT_frag_depth' ) ) ? '#define USE_LOGDEPTHBUF_EXT' : '',\n\n\t\t\t\tparameters.envMap && ( capabilities.isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) ) ? '#define TEXTURE_LOD_EXT' : '',\n\n\t\t\t\t'uniform mat4 viewMatrix;',\n\t\t\t\t'uniform vec3 cameraPosition;',\n\n\t\t\t\t( parameters.toneMapping !== NoToneMapping ) ? '#define TONE_MAPPING' : '',\n\t\t\t\t( parameters.toneMapping !== NoToneMapping ) ? ShaderChunk[ 'tonemapping_pars_fragment' ] : '', // this code is required here because it is used by the toneMapping() function defined below\n\t\t\t\t( parameters.toneMapping !== NoToneMapping ) ? getToneMappingFunction( 'toneMapping', parameters.toneMapping ) : '',\n\n\t\t\t\tparameters.dithering ? '#define DITHERING' : '',\n\n\t\t\t\t( parameters.outputEncoding || parameters.mapEncoding || parameters.matcapEncoding || parameters.envMapEncoding || parameters.emissiveMapEncoding ) ?\n\t\t\t\t\tShaderChunk[ 'encodings_pars_fragment' ] : '', // this code is required here because it is used by the various encoding/decoding function defined below\n\t\t\t\tparameters.mapEncoding ? getTexelDecodingFunction( 'mapTexelToLinear', parameters.mapEncoding ) : '',\n\t\t\t\tparameters.matcapEncoding ? getTexelDecodingFunction( 'matcapTexelToLinear', parameters.matcapEncoding ) : '',\n\t\t\t\tparameters.envMapEncoding ? getTexelDecodingFunction( 'envMapTexelToLinear', parameters.envMapEncoding ) : '',\n\t\t\t\tparameters.emissiveMapEncoding ? getTexelDecodingFunction( 'emissiveMapTexelToLinear', parameters.emissiveMapEncoding ) : '',\n\t\t\t\tparameters.outputEncoding ? getTexelEncodingFunction( 'linearToOutputTexel', parameters.outputEncoding ) : '',\n\n\t\t\t\tparameters.depthPacking ? '#define DEPTH_PACKING ' + material.depthPacking : '',\n\n\t\t\t\t'\\n'\n\n\t\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t\t}\n\n\t\tvertexShader = parseIncludes( vertexShader );\n\t\tvertexShader = replaceLightNums( vertexShader, parameters );\n\t\tvertexShader = replaceClippingPlaneNums( vertexShader, parameters );\n\n\t\tfragmentShader = parseIncludes( fragmentShader );\n\t\tfragmentShader = replaceLightNums( fragmentShader, parameters );\n\t\tfragmentShader = replaceClippingPlaneNums( fragmentShader, parameters );\n\n\t\tvertexShader = unrollLoops( vertexShader );\n\t\tfragmentShader = unrollLoops( fragmentShader );\n\n\t\tif ( capabilities.isWebGL2 && ! material.isRawShaderMaterial ) {\n\n\t\t\tvar isGLSL3ShaderMaterial = false;\n\n\t\t\tvar versionRegex = /^\\s*#version\\s+300\\s+es\\s*\\n/;\n\n\t\t\tif ( material.isShaderMaterial &&\n\t\t\t\tvertexShader.match( versionRegex ) !== null &&\n\t\t\t\tfragmentShader.match( versionRegex ) !== null ) {\n\n\t\t\t\tisGLSL3ShaderMaterial = true;\n\n\t\t\t\tvertexShader = vertexShader.replace( versionRegex, '' );\n\t\t\t\tfragmentShader = fragmentShader.replace( versionRegex, '' );\n\n\t\t\t}\n\n\t\t\t// GLSL 3.0 conversion\n\t\t\tprefixVertex = [\n\t\t\t\t'#version 300 es\\n',\n\t\t\t\t'#define attribute in',\n\t\t\t\t'#define varying out',\n\t\t\t\t'#define texture2D texture'\n\t\t\t].join( '\\n' ) + '\\n' + prefixVertex;\n\n\t\t\tprefixFragment = [\n\t\t\t\t'#version 300 es\\n',\n\t\t\t\t'#define varying in',\n\t\t\t\tisGLSL3ShaderMaterial ? '' : 'out highp vec4 pc_fragColor;',\n\t\t\t\tisGLSL3ShaderMaterial ? '' : '#define gl_FragColor pc_fragColor',\n\t\t\t\t'#define gl_FragDepthEXT gl_FragDepth',\n\t\t\t\t'#define texture2D texture',\n\t\t\t\t'#define textureCube texture',\n\t\t\t\t'#define texture2DProj textureProj',\n\t\t\t\t'#define texture2DLodEXT textureLod',\n\t\t\t\t'#define texture2DProjLodEXT textureProjLod',\n\t\t\t\t'#define textureCubeLodEXT textureLod',\n\t\t\t\t'#define texture2DGradEXT textureGrad',\n\t\t\t\t'#define texture2DProjGradEXT textureProjGrad',\n\t\t\t\t'#define textureCubeGradEXT textureGrad'\n\t\t\t].join( '\\n' ) + '\\n' + prefixFragment;\n\n\t\t}\n\n\t\tvar vertexGlsl = prefixVertex + vertexShader;\n\t\tvar fragmentGlsl = prefixFragment + fragmentShader;\n\n\t\t// console.log( '*VERTEX*', vertexGlsl );\n\t\t// console.log( '*FRAGMENT*', fragmentGlsl );\n\n\t\tvar glVertexShader = WebGLShader( gl, 35633, vertexGlsl );\n\t\tvar glFragmentShader = WebGLShader( gl, 35632, fragmentGlsl );\n\n\t\tgl.attachShader( program, glVertexShader );\n\t\tgl.attachShader( program, glFragmentShader );\n\n\t\t// Force a particular attribute to index 0.\n\n\t\tif ( material.index0AttributeName !== undefined ) {\n\n\t\t\tgl.bindAttribLocation( program, 0, material.index0AttributeName );\n\n\t\t} else if ( parameters.morphTargets === true ) {\n\n\t\t\t// programs with morphTargets displace position out of attribute 0\n\t\t\tgl.bindAttribLocation( program, 0, 'position' );\n\n\t\t}\n\n\t\tgl.linkProgram( program );\n\n\t\tvar programLog = gl.getProgramInfoLog( program ).trim();\n\t\tvar vertexLog = gl.getShaderInfoLog( glVertexShader ).trim();\n\t\tvar fragmentLog = gl.getShaderInfoLog( glFragmentShader ).trim();\n\n\t\tvar runnable = true;\n\t\tvar haveDiagnostics = true;\n\n\t\t// console.log( '**VERTEX**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( glVertexShader ) );\n\t\t// console.log( '**FRAGMENT**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( glFragmentShader ) );\n\n\t\tif ( gl.getProgramParameter( program, 35714 ) === false ) {\n\n\t\t\trunnable = false;\n\n\t\t\tconsole.error( 'THREE.WebGLProgram: shader error: ', gl.getError(), '35715', gl.getProgramParameter( program, 35715 ), 'gl.getProgramInfoLog', programLog, vertexLog, fragmentLog );\n\n\t\t} else if ( programLog !== '' ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLProgram: gl.getProgramInfoLog()', programLog );\n\n\t\t} else if ( vertexLog === '' || fragmentLog === '' ) {\n\n\t\t\thaveDiagnostics = false;\n\n\t\t}\n\n\t\tif ( haveDiagnostics ) {\n\n\t\t\tthis.diagnostics = {\n\n\t\t\t\trunnable: runnable,\n\t\t\t\tmaterial: material,\n\n\t\t\t\tprogramLog: programLog,\n\n\t\t\t\tvertexShader: {\n\n\t\t\t\t\tlog: vertexLog,\n\t\t\t\t\tprefix: prefixVertex\n\n\t\t\t\t},\n\n\t\t\t\tfragmentShader: {\n\n\t\t\t\t\tlog: fragmentLog,\n\t\t\t\t\tprefix: prefixFragment\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t}\n\n\t\t// clean up\n\n\t\tgl.deleteShader( glVertexShader );\n\t\tgl.deleteShader( glFragmentShader );\n\n\t\t// set up caching for uniform locations\n\n\t\tvar cachedUniforms;\n\n\t\tthis.getUniforms = function () {\n\n\t\t\tif ( cachedUniforms === undefined ) {\n\n\t\t\t\tcachedUniforms = new WebGLUniforms( gl, program, renderer );\n\n\t\t\t}\n\n\t\t\treturn cachedUniforms;\n\n\t\t};\n\n\t\t// set up caching for attribute locations\n\n\t\tvar cachedAttributes;\n\n\t\tthis.getAttributes = function () {\n\n\t\t\tif ( cachedAttributes === undefined ) {\n\n\t\t\t\tcachedAttributes = fetchAttributeLocations( gl, program );\n\n\t\t\t}\n\n\t\t\treturn cachedAttributes;\n\n\t\t};\n\n\t\t// free resource\n\n\t\tthis.destroy = function () {\n\n\t\t\tgl.deleteProgram( program );\n\t\t\tthis.program = undefined;\n\n\t\t};\n\n\t\t// DEPRECATED\n\n\t\tObject.defineProperties( this, {\n\n\t\t\tuniforms: {\n\t\t\t\tget: function () {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLProgram: .uniforms is now .getUniforms().' );\n\t\t\t\t\treturn this.getUniforms();\n\n\t\t\t\t}\n\t\t\t},\n\n\t\t\tattributes: {\n\t\t\t\tget: function () {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLProgram: .attributes is now .getAttributes().' );\n\t\t\t\t\treturn this.getAttributes();\n\n\t\t\t\t}\n\t\t\t}\n\n\t\t} );\n\n\n\t\t//\n\n\t\tthis.name = shader.name;\n\t\tthis.id = programIdCount ++;\n\t\tthis.code = code;\n\t\tthis.usedTimes = 1;\n\t\tthis.program = program;\n\t\tthis.vertexShader = glVertexShader;\n\t\tthis.fragmentShader = glFragmentShader;\n\n\t\treturn this;\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction WebGLPrograms( renderer, extensions, capabilities ) {\n\n\t\tvar programs = [];\n\n\t\tvar shaderIDs = {\n\t\t\tMeshDepthMaterial: 'depth',\n\t\t\tMeshDistanceMaterial: 'distanceRGBA',\n\t\t\tMeshNormalMaterial: 'normal',\n\t\t\tMeshBasicMaterial: 'basic',\n\t\t\tMeshLambertMaterial: 'lambert',\n\t\t\tMeshPhongMaterial: 'phong',\n\t\t\tMeshToonMaterial: 'phong',\n\t\t\tMeshStandardMaterial: 'physical',\n\t\t\tMeshPhysicalMaterial: 'physical',\n\t\t\tMeshMatcapMaterial: 'matcap',\n\t\t\tLineBasicMaterial: 'basic',\n\t\t\tLineDashedMaterial: 'dashed',\n\t\t\tPointsMaterial: 'points',\n\t\t\tShadowMaterial: 'shadow',\n\t\t\tSpriteMaterial: 'sprite'\n\t\t};\n\n\t\tvar parameterNames = [\n\t\t\t\"precision\", \"supportsVertexTextures\", \"map\", \"mapEncoding\", \"matcap\", \"matcapEncoding\", \"envMap\", \"envMapMode\", \"envMapEncoding\",\n\t\t\t\"lightMap\", \"aoMap\", \"emissiveMap\", \"emissiveMapEncoding\", \"bumpMap\", \"normalMap\", \"objectSpaceNormalMap\", \"displacementMap\", \"specularMap\",\n\t\t\t\"roughnessMap\", \"metalnessMap\", \"gradientMap\",\n\t\t\t\"alphaMap\", \"combine\", \"vertexColors\", \"fog\", \"useFog\", \"fogExp\",\n\t\t\t\"flatShading\", \"sizeAttenuation\", \"logarithmicDepthBuffer\", \"skinning\",\n\t\t\t\"maxBones\", \"useVertexTexture\", \"morphTargets\", \"morphNormals\",\n\t\t\t\"maxMorphTargets\", \"maxMorphNormals\", \"premultipliedAlpha\",\n\t\t\t\"numDirLights\", \"numPointLights\", \"numSpotLights\", \"numHemiLights\", \"numRectAreaLights\",\n\t\t\t\"shadowMapEnabled\", \"shadowMapType\", \"toneMapping\", 'physicallyCorrectLights',\n\t\t\t\"alphaTest\", \"doubleSided\", \"flipSided\", \"numClippingPlanes\", \"numClipIntersection\", \"depthPacking\", \"dithering\"\n\t\t];\n\n\n\t\tfunction allocateBones( object ) {\n\n\t\t\tvar skeleton = object.skeleton;\n\t\t\tvar bones = skeleton.bones;\n\n\t\t\tif ( capabilities.floatVertexTextures ) {\n\n\t\t\t\treturn 1024;\n\n\t\t\t} else {\n\n\t\t\t\t// default for when object is not specified\n\t\t\t\t// ( for example when prebuilding shader to be used with multiple objects )\n\t\t\t\t//\n\t\t\t\t//  - leave some extra space for other uniforms\n\t\t\t\t//  - limit here is ANGLE's 254 max uniform vectors\n\t\t\t\t//    (up to 54 should be safe)\n\n\t\t\t\tvar nVertexUniforms = capabilities.maxVertexUniforms;\n\t\t\t\tvar nVertexMatrices = Math.floor( ( nVertexUniforms - 20 ) / 4 );\n\n\t\t\t\tvar maxBones = Math.min( nVertexMatrices, bones.length );\n\n\t\t\t\tif ( maxBones < bones.length ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Skeleton has ' + bones.length + ' bones. This GPU supports ' + maxBones + '.' );\n\t\t\t\t\treturn 0;\n\n\t\t\t\t}\n\n\t\t\t\treturn maxBones;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction getTextureEncodingFromMap( map, gammaOverrideLinear ) {\n\n\t\t\tvar encoding;\n\n\t\t\tif ( ! map ) {\n\n\t\t\t\tencoding = LinearEncoding;\n\n\t\t\t} else if ( map.isTexture ) {\n\n\t\t\t\tencoding = map.encoding;\n\n\t\t\t} else if ( map.isWebGLRenderTarget ) {\n\n\t\t\t\tconsole.warn( \"THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead.\" );\n\t\t\t\tencoding = map.texture.encoding;\n\n\t\t\t}\n\n\t\t\t// add backwards compatibility for WebGLRenderer.gammaInput/gammaOutput parameter, should probably be removed at some point.\n\t\t\tif ( encoding === LinearEncoding && gammaOverrideLinear ) {\n\n\t\t\t\tencoding = GammaEncoding;\n\n\t\t\t}\n\n\t\t\treturn encoding;\n\n\t\t}\n\n\t\tthis.getParameters = function ( material, lights, shadows, fog, nClipPlanes, nClipIntersection, object ) {\n\n\t\t\tvar shaderID = shaderIDs[ material.type ];\n\n\t\t\t// heuristics to create shader parameters according to lights in the scene\n\t\t\t// (not to blow over maxLights budget)\n\n\t\t\tvar maxBones = object.isSkinnedMesh ? allocateBones( object ) : 0;\n\t\t\tvar precision = capabilities.precision;\n\n\t\t\tif ( material.precision !== null ) {\n\n\t\t\t\tprecision = capabilities.getMaxPrecision( material.precision );\n\n\t\t\t\tif ( precision !== material.precision ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLProgram.getParameters:', material.precision, 'not supported, using', precision, 'instead.' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tvar currentRenderTarget = renderer.getRenderTarget();\n\n\t\t\tvar parameters = {\n\n\t\t\t\tshaderID: shaderID,\n\n\t\t\t\tprecision: precision,\n\t\t\t\tsupportsVertexTextures: capabilities.vertexTextures,\n\t\t\t\toutputEncoding: getTextureEncodingFromMap( ( ! currentRenderTarget ) ? null : currentRenderTarget.texture, renderer.gammaOutput ),\n\t\t\t\tmap: !! material.map,\n\t\t\t\tmapEncoding: getTextureEncodingFromMap( material.map, renderer.gammaInput ),\n\t\t\t\tmatcap: !! material.matcap,\n\t\t\t\tmatcapEncoding: getTextureEncodingFromMap( material.matcap, renderer.gammaInput ),\n\t\t\t\tenvMap: !! material.envMap,\n\t\t\t\tenvMapMode: material.envMap && material.envMap.mapping,\n\t\t\t\tenvMapEncoding: getTextureEncodingFromMap( material.envMap, renderer.gammaInput ),\n\t\t\t\tenvMapCubeUV: ( !! material.envMap ) && ( ( material.envMap.mapping === CubeUVReflectionMapping ) || ( material.envMap.mapping === CubeUVRefractionMapping ) ),\n\t\t\t\tlightMap: !! material.lightMap,\n\t\t\t\taoMap: !! material.aoMap,\n\t\t\t\temissiveMap: !! material.emissiveMap,\n\t\t\t\temissiveMapEncoding: getTextureEncodingFromMap( material.emissiveMap, renderer.gammaInput ),\n\t\t\t\tbumpMap: !! material.bumpMap,\n\t\t\t\tnormalMap: !! material.normalMap,\n\t\t\t\tobjectSpaceNormalMap: material.normalMapType === ObjectSpaceNormalMap,\n\t\t\t\tdisplacementMap: !! material.displacementMap,\n\t\t\t\troughnessMap: !! material.roughnessMap,\n\t\t\t\tmetalnessMap: !! material.metalnessMap,\n\t\t\t\tspecularMap: !! material.specularMap,\n\t\t\t\talphaMap: !! material.alphaMap,\n\n\t\t\t\tgradientMap: !! material.gradientMap,\n\n\t\t\t\tcombine: material.combine,\n\n\t\t\t\tvertexColors: material.vertexColors,\n\n\t\t\t\tfog: !! fog,\n\t\t\t\tuseFog: material.fog,\n\t\t\t\tfogExp: ( fog && fog.isFogExp2 ),\n\n\t\t\t\tflatShading: material.flatShading,\n\n\t\t\t\tsizeAttenuation: material.sizeAttenuation,\n\t\t\t\tlogarithmicDepthBuffer: capabilities.logarithmicDepthBuffer,\n\n\t\t\t\tskinning: material.skinning && maxBones > 0,\n\t\t\t\tmaxBones: maxBones,\n\t\t\t\tuseVertexTexture: capabilities.floatVertexTextures,\n\n\t\t\t\tmorphTargets: material.morphTargets,\n\t\t\t\tmorphNormals: material.morphNormals,\n\t\t\t\tmaxMorphTargets: renderer.maxMorphTargets,\n\t\t\t\tmaxMorphNormals: renderer.maxMorphNormals,\n\n\t\t\t\tnumDirLights: lights.directional.length,\n\t\t\t\tnumPointLights: lights.point.length,\n\t\t\t\tnumSpotLights: lights.spot.length,\n\t\t\t\tnumRectAreaLights: lights.rectArea.length,\n\t\t\t\tnumHemiLights: lights.hemi.length,\n\n\t\t\t\tnumClippingPlanes: nClipPlanes,\n\t\t\t\tnumClipIntersection: nClipIntersection,\n\n\t\t\t\tdithering: material.dithering,\n\n\t\t\t\tshadowMapEnabled: renderer.shadowMap.enabled && object.receiveShadow && shadows.length > 0,\n\t\t\t\tshadowMapType: renderer.shadowMap.type,\n\n\t\t\t\ttoneMapping: renderer.toneMapping,\n\t\t\t\tphysicallyCorrectLights: renderer.physicallyCorrectLights,\n\n\t\t\t\tpremultipliedAlpha: material.premultipliedAlpha,\n\n\t\t\t\talphaTest: material.alphaTest,\n\t\t\t\tdoubleSided: material.side === DoubleSide,\n\t\t\t\tflipSided: material.side === BackSide,\n\n\t\t\t\tdepthPacking: ( material.depthPacking !== undefined ) ? material.depthPacking : false\n\n\t\t\t};\n\n\t\t\treturn parameters;\n\n\t\t};\n\n\t\tthis.getProgramCode = function ( material, parameters ) {\n\n\t\t\tvar array = [];\n\n\t\t\tif ( parameters.shaderID ) {\n\n\t\t\t\tarray.push( parameters.shaderID );\n\n\t\t\t} else {\n\n\t\t\t\tarray.push( material.fragmentShader );\n\t\t\t\tarray.push( material.vertexShader );\n\n\t\t\t}\n\n\t\t\tif ( material.defines !== undefined ) {\n\n\t\t\t\tfor ( var name in material.defines ) {\n\n\t\t\t\t\tarray.push( name );\n\t\t\t\t\tarray.push( material.defines[ name ] );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tfor ( var i = 0; i < parameterNames.length; i ++ ) {\n\n\t\t\t\tarray.push( parameters[ parameterNames[ i ] ] );\n\n\t\t\t}\n\n\t\t\tarray.push( material.onBeforeCompile.toString() );\n\n\t\t\tarray.push( renderer.gammaOutput );\n\n\t\t\tarray.push( renderer.gammaFactor );\n\n\t\t\treturn array.join();\n\n\t\t};\n\n\t\tthis.acquireProgram = function ( material, shader, parameters, code ) {\n\n\t\t\tvar program;\n\n\t\t\t// Check if code has been already compiled\n\t\t\tfor ( var p = 0, pl = programs.length; p < pl; p ++ ) {\n\n\t\t\t\tvar programInfo = programs[ p ];\n\n\t\t\t\tif ( programInfo.code === code ) {\n\n\t\t\t\t\tprogram = programInfo;\n\t\t\t\t\t++ program.usedTimes;\n\n\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( program === undefined ) {\n\n\t\t\t\tprogram = new WebGLProgram( renderer, extensions, code, material, shader, parameters, capabilities );\n\t\t\t\tprograms.push( program );\n\n\t\t\t}\n\n\t\t\treturn program;\n\n\t\t};\n\n\t\tthis.releaseProgram = function ( program ) {\n\n\t\t\tif ( -- program.usedTimes === 0 ) {\n\n\t\t\t\t// Remove from unordered set\n\t\t\t\tvar i = programs.indexOf( program );\n\t\t\t\tprograms[ i ] = programs[ programs.length - 1 ];\n\t\t\t\tprograms.pop();\n\n\t\t\t\t// Free WebGL resources\n\t\t\t\tprogram.destroy();\n\n\t\t\t}\n\n\t\t};\n\n\t\t// Exposed for resource monitoring & error feedback via renderer.info:\n\t\tthis.programs = programs;\n\n\t}\n\n\t/**\n\t * @author fordacious / fordacious.github.io\n\t */\n\n\tfunction WebGLProperties() {\n\n\t\tvar properties = new WeakMap();\n\n\t\tfunction get( object ) {\n\n\t\t\tvar map = properties.get( object );\n\n\t\t\tif ( map === undefined ) {\n\n\t\t\t\tmap = {};\n\t\t\t\tproperties.set( object, map );\n\n\t\t\t}\n\n\t\t\treturn map;\n\n\t\t}\n\n\t\tfunction remove( object ) {\n\n\t\t\tproperties.delete( object );\n\n\t\t}\n\n\t\tfunction update( object, key, value ) {\n\n\t\t\tproperties.get( object )[ key ] = value;\n\n\t\t}\n\n\t\tfunction dispose() {\n\n\t\t\tproperties = new WeakMap();\n\n\t\t}\n\n\t\treturn {\n\t\t\tget: get,\n\t\t\tremove: remove,\n\t\t\tupdate: update,\n\t\t\tdispose: dispose\n\t\t};\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction painterSortStable( a, b ) {\n\n\t\tif ( a.renderOrder !== b.renderOrder ) {\n\n\t\t\treturn a.renderOrder - b.renderOrder;\n\n\t\t} else if ( a.program && b.program && a.program !== b.program ) {\n\n\t\t\treturn a.program.id - b.program.id;\n\n\t\t} else if ( a.material.id !== b.material.id ) {\n\n\t\t\treturn a.material.id - b.material.id;\n\n\t\t} else if ( a.z !== b.z ) {\n\n\t\t\treturn a.z - b.z;\n\n\t\t} else {\n\n\t\t\treturn a.id - b.id;\n\n\t\t}\n\n\t}\n\n\tfunction reversePainterSortStable( a, b ) {\n\n\t\tif ( a.renderOrder !== b.renderOrder ) {\n\n\t\t\treturn a.renderOrder - b.renderOrder;\n\n\t\t} if ( a.z !== b.z ) {\n\n\t\t\treturn b.z - a.z;\n\n\t\t} else {\n\n\t\t\treturn a.id - b.id;\n\n\t\t}\n\n\t}\n\n\n\tfunction WebGLRenderList() {\n\n\t\tvar renderItems = [];\n\t\tvar renderItemsIndex = 0;\n\n\t\tvar opaque = [];\n\t\tvar transparent = [];\n\n\t\tfunction init() {\n\n\t\t\trenderItemsIndex = 0;\n\n\t\t\topaque.length = 0;\n\t\t\ttransparent.length = 0;\n\n\t\t}\n\n\t\tfunction getNextRenderItem( object, geometry, material, z, group ) {\n\n\t\t\tvar renderItem = renderItems[ renderItemsIndex ];\n\n\t\t\tif ( renderItem === undefined ) {\n\n\t\t\t\trenderItem = {\n\t\t\t\t\tid: object.id,\n\t\t\t\t\tobject: object,\n\t\t\t\t\tgeometry: geometry,\n\t\t\t\t\tmaterial: material,\n\t\t\t\t\tprogram: material.program,\n\t\t\t\t\trenderOrder: object.renderOrder,\n\t\t\t\t\tz: z,\n\t\t\t\t\tgroup: group\n\t\t\t\t};\n\n\t\t\t\trenderItems[ renderItemsIndex ] = renderItem;\n\n\t\t\t} else {\n\n\t\t\t\trenderItem.id = object.id;\n\t\t\t\trenderItem.object = object;\n\t\t\t\trenderItem.geometry = geometry;\n\t\t\t\trenderItem.material = material;\n\t\t\t\trenderItem.program = material.program;\n\t\t\t\trenderItem.renderOrder = object.renderOrder;\n\t\t\t\trenderItem.z = z;\n\t\t\t\trenderItem.group = group;\n\n\t\t\t}\n\n\t\t\trenderItemsIndex ++;\n\n\t\t\treturn renderItem;\n\n\t\t}\n\n\t\tfunction push( object, geometry, material, z, group ) {\n\n\t\t\tvar renderItem = getNextRenderItem( object, geometry, material, z, group );\n\n\t\t\t( material.transparent === true ? transparent : opaque ).push( renderItem );\n\n\t\t}\n\n\t\tfunction unshift( object, geometry, material, z, group ) {\n\n\t\t\tvar renderItem = getNextRenderItem( object, geometry, material, z, group );\n\n\t\t\t( material.transparent === true ? transparent : opaque ).unshift( renderItem );\n\n\t\t}\n\n\t\tfunction sort() {\n\n\t\t\tif ( opaque.length > 1 ) opaque.sort( painterSortStable );\n\t\t\tif ( transparent.length > 1 ) transparent.sort( reversePainterSortStable );\n\n\t\t}\n\n\t\treturn {\n\t\t\topaque: opaque,\n\t\t\ttransparent: transparent,\n\n\t\t\tinit: init,\n\t\t\tpush: push,\n\t\t\tunshift: unshift,\n\n\t\t\tsort: sort\n\t\t};\n\n\t}\n\n\tfunction WebGLRenderLists() {\n\n\t\tvar lists = {};\n\n\t\tfunction get( scene, camera ) {\n\n\t\t\tvar cameras = lists[ scene.id ];\n\t\t\tvar list;\n\t\t\tif ( cameras === undefined ) {\n\n\t\t\t\tlist = new WebGLRenderList();\n\t\t\t\tlists[ scene.id ] = {};\n\t\t\t\tlists[ scene.id ][ camera.id ] = list;\n\n\t\t\t} else {\n\n\t\t\t\tlist = cameras[ camera.id ];\n\t\t\t\tif ( list === undefined ) {\n\n\t\t\t\t\tlist = new WebGLRenderList();\n\t\t\t\t\tcameras[ camera.id ] = list;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn list;\n\n\t\t}\n\n\t\tfunction dispose() {\n\n\t\t\tlists = {};\n\n\t\t}\n\n\t\treturn {\n\t\t\tget: get,\n\t\t\tdispose: dispose\n\t\t};\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction UniformsCache() {\n\n\t\tvar lights = {};\n\n\t\treturn {\n\n\t\t\tget: function ( light ) {\n\n\t\t\t\tif ( lights[ light.id ] !== undefined ) {\n\n\t\t\t\t\treturn lights[ light.id ];\n\n\t\t\t\t}\n\n\t\t\t\tvar uniforms;\n\n\t\t\t\tswitch ( light.type ) {\n\n\t\t\t\t\tcase 'DirectionalLight':\n\t\t\t\t\t\tuniforms = {\n\t\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\t\tcolor: new Color(),\n\n\t\t\t\t\t\t\tshadow: false,\n\t\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\t\tshadowMapSize: new Vector2()\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'SpotLight':\n\t\t\t\t\t\tuniforms = {\n\t\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\t\tdistance: 0,\n\t\t\t\t\t\t\tconeCos: 0,\n\t\t\t\t\t\t\tpenumbraCos: 0,\n\t\t\t\t\t\t\tdecay: 0,\n\n\t\t\t\t\t\t\tshadow: false,\n\t\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\t\tshadowMapSize: new Vector2()\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'PointLight':\n\t\t\t\t\t\tuniforms = {\n\t\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\t\tdistance: 0,\n\t\t\t\t\t\t\tdecay: 0,\n\n\t\t\t\t\t\t\tshadow: false,\n\t\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\t\tshadowMapSize: new Vector2(),\n\t\t\t\t\t\t\tshadowCameraNear: 1,\n\t\t\t\t\t\t\tshadowCameraFar: 1000\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'HemisphereLight':\n\t\t\t\t\t\tuniforms = {\n\t\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\t\tskyColor: new Color(),\n\t\t\t\t\t\t\tgroundColor: new Color()\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'RectAreaLight':\n\t\t\t\t\t\tuniforms = {\n\t\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\t\thalfWidth: new Vector3(),\n\t\t\t\t\t\t\thalfHeight: new Vector3()\n\t\t\t\t\t\t\t// TODO (abelnation): set RectAreaLight shadow uniforms\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t\tlights[ light.id ] = uniforms;\n\n\t\t\t\treturn uniforms;\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\tvar count = 0;\n\n\tfunction WebGLLights() {\n\n\t\tvar cache = new UniformsCache();\n\n\t\tvar state = {\n\n\t\t\tid: count ++,\n\n\t\t\thash: {\n\t\t\t\tstateID: - 1,\n\t\t\t\tdirectionalLength: - 1,\n\t\t\t\tpointLength: - 1,\n\t\t\t\tspotLength: - 1,\n\t\t\t\trectAreaLength: - 1,\n\t\t\t\themiLength: - 1,\n\t\t\t\tshadowsLength: - 1\n\t\t\t},\n\n\t\t\tambient: [ 0, 0, 0 ],\n\t\t\tdirectional: [],\n\t\t\tdirectionalShadowMap: [],\n\t\t\tdirectionalShadowMatrix: [],\n\t\t\tspot: [],\n\t\t\tspotShadowMap: [],\n\t\t\tspotShadowMatrix: [],\n\t\t\trectArea: [],\n\t\t\tpoint: [],\n\t\t\tpointShadowMap: [],\n\t\t\tpointShadowMatrix: [],\n\t\t\themi: []\n\n\t\t};\n\n\t\tvar vector3 = new Vector3();\n\t\tvar matrix4 = new Matrix4();\n\t\tvar matrix42 = new Matrix4();\n\n\t\tfunction setup( lights, shadows, camera ) {\n\n\t\t\tvar r = 0, g = 0, b = 0;\n\n\t\t\tvar directionalLength = 0;\n\t\t\tvar pointLength = 0;\n\t\t\tvar spotLength = 0;\n\t\t\tvar rectAreaLength = 0;\n\t\t\tvar hemiLength = 0;\n\n\t\t\tvar viewMatrix = camera.matrixWorldInverse;\n\n\t\t\tfor ( var i = 0, l = lights.length; i < l; i ++ ) {\n\n\t\t\t\tvar light = lights[ i ];\n\n\t\t\t\tvar color = light.color;\n\t\t\t\tvar intensity = light.intensity;\n\t\t\t\tvar distance = light.distance;\n\n\t\t\t\tvar shadowMap = ( light.shadow && light.shadow.map ) ? light.shadow.map.texture : null;\n\n\t\t\t\tif ( light.isAmbientLight ) {\n\n\t\t\t\t\tr += color.r * intensity;\n\t\t\t\t\tg += color.g * intensity;\n\t\t\t\t\tb += color.b * intensity;\n\n\t\t\t\t} else if ( light.isDirectionalLight ) {\n\n\t\t\t\t\tvar uniforms = cache.get( light );\n\n\t\t\t\t\tuniforms.color.copy( light.color ).multiplyScalar( light.intensity );\n\t\t\t\t\tuniforms.direction.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\t\tvector3.setFromMatrixPosition( light.target.matrixWorld );\n\t\t\t\t\tuniforms.direction.sub( vector3 );\n\t\t\t\t\tuniforms.direction.transformDirection( viewMatrix );\n\n\t\t\t\t\tuniforms.shadow = light.castShadow;\n\n\t\t\t\t\tif ( light.castShadow ) {\n\n\t\t\t\t\t\tvar shadow = light.shadow;\n\n\t\t\t\t\t\tuniforms.shadowBias = shadow.bias;\n\t\t\t\t\t\tuniforms.shadowRadius = shadow.radius;\n\t\t\t\t\t\tuniforms.shadowMapSize = shadow.mapSize;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tstate.directionalShadowMap[ directionalLength ] = shadowMap;\n\t\t\t\t\tstate.directionalShadowMatrix[ directionalLength ] = light.shadow.matrix;\n\t\t\t\t\tstate.directional[ directionalLength ] = uniforms;\n\n\t\t\t\t\tdirectionalLength ++;\n\n\t\t\t\t} else if ( light.isSpotLight ) {\n\n\t\t\t\t\tvar uniforms = cache.get( light );\n\n\t\t\t\t\tuniforms.position.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\t\tuniforms.position.applyMatrix4( viewMatrix );\n\n\t\t\t\t\tuniforms.color.copy( color ).multiplyScalar( intensity );\n\t\t\t\t\tuniforms.distance = distance;\n\n\t\t\t\t\tuniforms.direction.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\t\tvector3.setFromMatrixPosition( light.target.matrixWorld );\n\t\t\t\t\tuniforms.direction.sub( vector3 );\n\t\t\t\t\tuniforms.direction.transformDirection( viewMatrix );\n\n\t\t\t\t\tuniforms.coneCos = Math.cos( light.angle );\n\t\t\t\t\tuniforms.penumbraCos = Math.cos( light.angle * ( 1 - light.penumbra ) );\n\t\t\t\t\tuniforms.decay = light.decay;\n\n\t\t\t\t\tuniforms.shadow = light.castShadow;\n\n\t\t\t\t\tif ( light.castShadow ) {\n\n\t\t\t\t\t\tvar shadow = light.shadow;\n\n\t\t\t\t\t\tuniforms.shadowBias = shadow.bias;\n\t\t\t\t\t\tuniforms.shadowRadius = shadow.radius;\n\t\t\t\t\t\tuniforms.shadowMapSize = shadow.mapSize;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tstate.spotShadowMap[ spotLength ] = shadowMap;\n\t\t\t\t\tstate.spotShadowMatrix[ spotLength ] = light.shadow.matrix;\n\t\t\t\t\tstate.spot[ spotLength ] = uniforms;\n\n\t\t\t\t\tspotLength ++;\n\n\t\t\t\t} else if ( light.isRectAreaLight ) {\n\n\t\t\t\t\tvar uniforms = cache.get( light );\n\n\t\t\t\t\t// (a) intensity is the total visible light emitted\n\t\t\t\t\t//uniforms.color.copy( color ).multiplyScalar( intensity / ( light.width * light.height * Math.PI ) );\n\n\t\t\t\t\t// (b) intensity is the brightness of the light\n\t\t\t\t\tuniforms.color.copy( color ).multiplyScalar( intensity );\n\n\t\t\t\t\tuniforms.position.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\t\tuniforms.position.applyMatrix4( viewMatrix );\n\n\t\t\t\t\t// extract local rotation of light to derive width/height half vectors\n\t\t\t\t\tmatrix42.identity();\n\t\t\t\t\tmatrix4.copy( light.matrixWorld );\n\t\t\t\t\tmatrix4.premultiply( viewMatrix );\n\t\t\t\t\tmatrix42.extractRotation( matrix4 );\n\n\t\t\t\t\tuniforms.halfWidth.set( light.width * 0.5, 0.0, 0.0 );\n\t\t\t\t\tuniforms.halfHeight.set( 0.0, light.height * 0.5, 0.0 );\n\n\t\t\t\t\tuniforms.halfWidth.applyMatrix4( matrix42 );\n\t\t\t\t\tuniforms.halfHeight.applyMatrix4( matrix42 );\n\n\t\t\t\t\t// TODO (abelnation): RectAreaLight distance?\n\t\t\t\t\t// uniforms.distance = distance;\n\n\t\t\t\t\tstate.rectArea[ rectAreaLength ] = uniforms;\n\n\t\t\t\t\trectAreaLength ++;\n\n\t\t\t\t} else if ( light.isPointLight ) {\n\n\t\t\t\t\tvar uniforms = cache.get( light );\n\n\t\t\t\t\tuniforms.position.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\t\tuniforms.position.applyMatrix4( viewMatrix );\n\n\t\t\t\t\tuniforms.color.copy( light.color ).multiplyScalar( light.intensity );\n\t\t\t\t\tuniforms.distance = light.distance;\n\t\t\t\t\tuniforms.decay = light.decay;\n\n\t\t\t\t\tuniforms.shadow = light.castShadow;\n\n\t\t\t\t\tif ( light.castShadow ) {\n\n\t\t\t\t\t\tvar shadow = light.shadow;\n\n\t\t\t\t\t\tuniforms.shadowBias = shadow.bias;\n\t\t\t\t\t\tuniforms.shadowRadius = shadow.radius;\n\t\t\t\t\t\tuniforms.shadowMapSize = shadow.mapSize;\n\t\t\t\t\t\tuniforms.shadowCameraNear = shadow.camera.near;\n\t\t\t\t\t\tuniforms.shadowCameraFar = shadow.camera.far;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tstate.pointShadowMap[ pointLength ] = shadowMap;\n\t\t\t\t\tstate.pointShadowMatrix[ pointLength ] = light.shadow.matrix;\n\t\t\t\t\tstate.point[ pointLength ] = uniforms;\n\n\t\t\t\t\tpointLength ++;\n\n\t\t\t\t} else if ( light.isHemisphereLight ) {\n\n\t\t\t\t\tvar uniforms = cache.get( light );\n\n\t\t\t\t\tuniforms.direction.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\t\tuniforms.direction.transformDirection( viewMatrix );\n\t\t\t\t\tuniforms.direction.normalize();\n\n\t\t\t\t\tuniforms.skyColor.copy( light.color ).multiplyScalar( intensity );\n\t\t\t\t\tuniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity );\n\n\t\t\t\t\tstate.hemi[ hemiLength ] = uniforms;\n\n\t\t\t\t\themiLength ++;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tstate.ambient[ 0 ] = r;\n\t\t\tstate.ambient[ 1 ] = g;\n\t\t\tstate.ambient[ 2 ] = b;\n\n\t\t\tstate.directional.length = directionalLength;\n\t\t\tstate.spot.length = spotLength;\n\t\t\tstate.rectArea.length = rectAreaLength;\n\t\t\tstate.point.length = pointLength;\n\t\t\tstate.hemi.length = hemiLength;\n\n\t\t\tstate.hash.stateID = state.id;\n\t\t\tstate.hash.directionalLength = directionalLength;\n\t\t\tstate.hash.pointLength = pointLength;\n\t\t\tstate.hash.spotLength = spotLength;\n\t\t\tstate.hash.rectAreaLength = rectAreaLength;\n\t\t\tstate.hash.hemiLength = hemiLength;\n\t\t\tstate.hash.shadowsLength = shadows.length;\n\n\t\t}\n\n\t\treturn {\n\t\t\tsetup: setup,\n\t\t\tstate: state\n\t\t};\n\n\t}\n\n\t/**\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\tfunction WebGLRenderState() {\n\n\t\tvar lights = new WebGLLights();\n\n\t\tvar lightsArray = [];\n\t\tvar shadowsArray = [];\n\n\t\tfunction init() {\n\n\t\t\tlightsArray.length = 0;\n\t\t\tshadowsArray.length = 0;\n\n\t\t}\n\n\t\tfunction pushLight( light ) {\n\n\t\t\tlightsArray.push( light );\n\n\t\t}\n\n\t\tfunction pushShadow( shadowLight ) {\n\n\t\t\tshadowsArray.push( shadowLight );\n\n\t\t}\n\n\t\tfunction setupLights( camera ) {\n\n\t\t\tlights.setup( lightsArray, shadowsArray, camera );\n\n\t\t}\n\n\t\tvar state = {\n\t\t\tlightsArray: lightsArray,\n\t\t\tshadowsArray: shadowsArray,\n\n\t\t\tlights: lights\n\t\t};\n\n\t\treturn {\n\t\t\tinit: init,\n\t\t\tstate: state,\n\t\t\tsetupLights: setupLights,\n\n\t\t\tpushLight: pushLight,\n\t\t\tpushShadow: pushShadow\n\t\t};\n\n\t}\n\n\tfunction WebGLRenderStates() {\n\n\t\tvar renderStates = {};\n\n\t\tfunction get( scene, camera ) {\n\n\t\t\tvar renderState;\n\n\t\t\tif ( renderStates[ scene.id ] === undefined ) {\n\n\t\t\t\trenderState = new WebGLRenderState();\n\t\t\t\trenderStates[ scene.id ] = {};\n\t\t\t\trenderStates[ scene.id ][ camera.id ] = renderState;\n\n\t\t\t} else {\n\n\t\t\t\tif ( renderStates[ scene.id ][ camera.id ] === undefined ) {\n\n\t\t\t\t\trenderState = new WebGLRenderState();\n\t\t\t\t\trenderStates[ scene.id ][ camera.id ] = renderState;\n\n\t\t\t\t} else {\n\n\t\t\t\t\trenderState = renderStates[ scene.id ][ camera.id ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn renderState;\n\n\t\t}\n\n\t\tfunction dispose() {\n\n\t\t\trenderStates = {};\n\n\t\t}\n\n\t\treturn {\n\t\t\tget: get,\n\t\t\tdispose: dispose\n\t\t};\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author bhouston / https://clara.io\n\t * @author WestLangley / http://github.com/WestLangley\n\t *\n\t * parameters = {\n\t *\n\t *  opacity: <float>,\n\t *\n\t *  map: new THREE.Texture( <Image> ),\n\t *\n\t *  alphaMap: new THREE.Texture( <Image> ),\n\t *\n\t *  displacementMap: new THREE.Texture( <Image> ),\n\t *  displacementScale: <float>,\n\t *  displacementBias: <float>,\n\t *\n\t *  wireframe: <boolean>,\n\t *  wireframeLinewidth: <float>\n\t * }\n\t */\n\n\tfunction MeshDepthMaterial( parameters ) {\n\n\t\tMaterial.call( this );\n\n\t\tthis.type = 'MeshDepthMaterial';\n\n\t\tthis.depthPacking = BasicDepthPacking;\n\n\t\tthis.skinning = false;\n\t\tthis.morphTargets = false;\n\n\t\tthis.map = null;\n\n\t\tthis.alphaMap = null;\n\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\n\t\tthis.fog = false;\n\t\tthis.lights = false;\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n\tMeshDepthMaterial.prototype = Object.create( Material.prototype );\n\tMeshDepthMaterial.prototype.constructor = MeshDepthMaterial;\n\n\tMeshDepthMaterial.prototype.isMeshDepthMaterial = true;\n\n\tMeshDepthMaterial.prototype.copy = function ( source ) {\n\n\t\tMaterial.prototype.copy.call( this, source );\n\n\t\tthis.depthPacking = source.depthPacking;\n\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\n\t\tthis.map = source.map;\n\n\t\tthis.alphaMap = source.alphaMap;\n\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\n\t\treturn this;\n\n\t};\n\n\t/**\n\t * @author WestLangley / http://github.com/WestLangley\n\t *\n\t * parameters = {\n\t *\n\t *  referencePosition: <float>,\n\t *  nearDistance: <float>,\n\t *  farDistance: <float>,\n\t *\n\t *  skinning: <bool>,\n\t *  morphTargets: <bool>,\n\t *\n\t *  map: new THREE.Texture( <Image> ),\n\t *\n\t *  alphaMap: new THREE.Texture( <Image> ),\n\t *\n\t *  displacementMap: new THREE.Texture( <Image> ),\n\t *  displacementScale: <float>,\n\t *  displacementBias: <float>\n\t *\n\t * }\n\t */\n\n\tfunction MeshDistanceMaterial( parameters ) {\n\n\t\tMaterial.call( this );\n\n\t\tthis.type = 'MeshDistanceMaterial';\n\n\t\tthis.referencePosition = new Vector3();\n\t\tthis.nearDistance = 1;\n\t\tthis.farDistance = 1000;\n\n\t\tthis.skinning = false;\n\t\tthis.morphTargets = false;\n\n\t\tthis.map = null;\n\n\t\tthis.alphaMap = null;\n\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\n\t\tthis.fog = false;\n\t\tthis.lights = false;\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n\tMeshDistanceMaterial.prototype = Object.create( Material.prototype );\n\tMeshDistanceMaterial.prototype.constructor = MeshDistanceMaterial;\n\n\tMeshDistanceMaterial.prototype.isMeshDistanceMaterial = true;\n\n\tMeshDistanceMaterial.prototype.copy = function ( source ) {\n\n\t\tMaterial.prototype.copy.call( this, source );\n\n\t\tthis.referencePosition.copy( source.referencePosition );\n\t\tthis.nearDistance = source.nearDistance;\n\t\tthis.farDistance = source.farDistance;\n\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\n\t\tthis.map = source.map;\n\n\t\tthis.alphaMap = source.alphaMap;\n\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\n\t\treturn this;\n\n\t};\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction WebGLShadowMap( _renderer, _objects, maxTextureSize ) {\n\n\t\tvar _frustum = new Frustum(),\n\t\t\t_projScreenMatrix = new Matrix4(),\n\n\t\t\t_shadowMapSize = new Vector2(),\n\t\t\t_maxShadowMapSize = new Vector2( maxTextureSize, maxTextureSize ),\n\n\t\t\t_lookTarget = new Vector3(),\n\t\t\t_lightPositionWorld = new Vector3(),\n\n\t\t\t_MorphingFlag = 1,\n\t\t\t_SkinningFlag = 2,\n\n\t\t\t_NumberOfMaterialVariants = ( _MorphingFlag | _SkinningFlag ) + 1,\n\n\t\t\t_depthMaterials = new Array( _NumberOfMaterialVariants ),\n\t\t\t_distanceMaterials = new Array( _NumberOfMaterialVariants ),\n\n\t\t\t_materialCache = {};\n\n\t\tvar shadowSide = { 0: BackSide, 1: FrontSide, 2: DoubleSide };\n\n\t\tvar cubeDirections = [\n\t\t\tnew Vector3( 1, 0, 0 ), new Vector3( - 1, 0, 0 ), new Vector3( 0, 0, 1 ),\n\t\t\tnew Vector3( 0, 0, - 1 ), new Vector3( 0, 1, 0 ), new Vector3( 0, - 1, 0 )\n\t\t];\n\n\t\tvar cubeUps = [\n\t\t\tnew Vector3( 0, 1, 0 ), new Vector3( 0, 1, 0 ), new Vector3( 0, 1, 0 ),\n\t\t\tnew Vector3( 0, 1, 0 ), new Vector3( 0, 0, 1 ),\tnew Vector3( 0, 0, - 1 )\n\t\t];\n\n\t\tvar cube2DViewPorts = [\n\t\t\tnew Vector4(), new Vector4(), new Vector4(),\n\t\t\tnew Vector4(), new Vector4(), new Vector4()\n\t\t];\n\n\t\t// init\n\n\t\tfor ( var i = 0; i !== _NumberOfMaterialVariants; ++ i ) {\n\n\t\t\tvar useMorphing = ( i & _MorphingFlag ) !== 0;\n\t\t\tvar useSkinning = ( i & _SkinningFlag ) !== 0;\n\n\t\t\tvar depthMaterial = new MeshDepthMaterial( {\n\n\t\t\t\tdepthPacking: RGBADepthPacking,\n\n\t\t\t\tmorphTargets: useMorphing,\n\t\t\t\tskinning: useSkinning\n\n\t\t\t} );\n\n\t\t\t_depthMaterials[ i ] = depthMaterial;\n\n\t\t\t//\n\n\t\t\tvar distanceMaterial = new MeshDistanceMaterial( {\n\n\t\t\t\tmorphTargets: useMorphing,\n\t\t\t\tskinning: useSkinning\n\n\t\t\t} );\n\n\t\t\t_distanceMaterials[ i ] = distanceMaterial;\n\n\t\t}\n\n\t\t//\n\n\t\tvar scope = this;\n\n\t\tthis.enabled = false;\n\n\t\tthis.autoUpdate = true;\n\t\tthis.needsUpdate = false;\n\n\t\tthis.type = PCFShadowMap;\n\n\t\tthis.render = function ( lights, scene, camera ) {\n\n\t\t\tif ( scope.enabled === false ) return;\n\t\t\tif ( scope.autoUpdate === false && scope.needsUpdate === false ) return;\n\n\t\t\tif ( lights.length === 0 ) return;\n\n\t\t\t// TODO Clean up (needed in case of contextlost)\n\t\t\tvar _gl = _renderer.context;\n\t\t\tvar _state = _renderer.state;\n\n\t\t\t// Set GL state for depth map.\n\t\t\t_state.disable( 3042 );\n\t\t\t_state.buffers.color.setClear( 1, 1, 1, 1 );\n\t\t\t_state.buffers.depth.setTest( true );\n\t\t\t_state.setScissorTest( false );\n\n\t\t\t// render depth map\n\n\t\t\tvar faceCount;\n\n\t\t\tfor ( var i = 0, il = lights.length; i < il; i ++ ) {\n\n\t\t\t\tvar light = lights[ i ];\n\t\t\t\tvar shadow = light.shadow;\n\t\t\t\tvar isPointLight = light && light.isPointLight;\n\n\t\t\t\tif ( shadow === undefined ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLShadowMap:', light, 'has no shadow.' );\n\t\t\t\t\tcontinue;\n\n\t\t\t\t}\n\n\t\t\t\tvar shadowCamera = shadow.camera;\n\n\t\t\t\t_shadowMapSize.copy( shadow.mapSize );\n\t\t\t\t_shadowMapSize.min( _maxShadowMapSize );\n\n\t\t\t\tif ( isPointLight ) {\n\n\t\t\t\t\tvar vpWidth = _shadowMapSize.x;\n\t\t\t\t\tvar vpHeight = _shadowMapSize.y;\n\n\t\t\t\t\t// These viewports map a cube-map onto a 2D texture with the\n\t\t\t\t\t// following orientation:\n\t\t\t\t\t//\n\t\t\t\t\t//  xzXZ\n\t\t\t\t\t//   y Y\n\t\t\t\t\t//\n\t\t\t\t\t// X - Positive x direction\n\t\t\t\t\t// x - Negative x direction\n\t\t\t\t\t// Y - Positive y direction\n\t\t\t\t\t// y - Negative y direction\n\t\t\t\t\t// Z - Positive z direction\n\t\t\t\t\t// z - Negative z direction\n\n\t\t\t\t\t// positive X\n\t\t\t\t\tcube2DViewPorts[ 0 ].set( vpWidth * 2, vpHeight, vpWidth, vpHeight );\n\t\t\t\t\t// negative X\n\t\t\t\t\tcube2DViewPorts[ 1 ].set( 0, vpHeight, vpWidth, vpHeight );\n\t\t\t\t\t// positive Z\n\t\t\t\t\tcube2DViewPorts[ 2 ].set( vpWidth * 3, vpHeight, vpWidth, vpHeight );\n\t\t\t\t\t// negative Z\n\t\t\t\t\tcube2DViewPorts[ 3 ].set( vpWidth, vpHeight, vpWidth, vpHeight );\n\t\t\t\t\t// positive Y\n\t\t\t\t\tcube2DViewPorts[ 4 ].set( vpWidth * 3, 0, vpWidth, vpHeight );\n\t\t\t\t\t// negative Y\n\t\t\t\t\tcube2DViewPorts[ 5 ].set( vpWidth, 0, vpWidth, vpHeight );\n\n\t\t\t\t\t_shadowMapSize.x *= 4.0;\n\t\t\t\t\t_shadowMapSize.y *= 2.0;\n\n\t\t\t\t}\n\n\t\t\t\tif ( shadow.map === null ) {\n\n\t\t\t\t\tvar pars = { minFilter: NearestFilter, magFilter: NearestFilter, format: RGBAFormat };\n\n\t\t\t\t\tshadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );\n\t\t\t\t\tshadow.map.texture.name = light.name + \".shadowMap\";\n\n\t\t\t\t\tshadowCamera.updateProjectionMatrix();\n\n\t\t\t\t}\n\n\t\t\t\tif ( shadow.isSpotLightShadow ) {\n\n\t\t\t\t\tshadow.update( light );\n\n\t\t\t\t}\n\n\t\t\t\tvar shadowMap = shadow.map;\n\t\t\t\tvar shadowMatrix = shadow.matrix;\n\n\t\t\t\t_lightPositionWorld.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tshadowCamera.position.copy( _lightPositionWorld );\n\n\t\t\t\tif ( isPointLight ) {\n\n\t\t\t\t\tfaceCount = 6;\n\n\t\t\t\t\t// for point lights we set the shadow matrix to be a translation-only matrix\n\t\t\t\t\t// equal to inverse of the light's position\n\n\t\t\t\t\tshadowMatrix.makeTranslation( - _lightPositionWorld.x, - _lightPositionWorld.y, - _lightPositionWorld.z );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tfaceCount = 1;\n\n\t\t\t\t\t_lookTarget.setFromMatrixPosition( light.target.matrixWorld );\n\t\t\t\t\tshadowCamera.lookAt( _lookTarget );\n\t\t\t\t\tshadowCamera.updateMatrixWorld();\n\n\t\t\t\t\t// compute shadow matrix\n\n\t\t\t\t\tshadowMatrix.set(\n\t\t\t\t\t\t0.5, 0.0, 0.0, 0.5,\n\t\t\t\t\t\t0.0, 0.5, 0.0, 0.5,\n\t\t\t\t\t\t0.0, 0.0, 0.5, 0.5,\n\t\t\t\t\t\t0.0, 0.0, 0.0, 1.0\n\t\t\t\t\t);\n\n\t\t\t\t\tshadowMatrix.multiply( shadowCamera.projectionMatrix );\n\t\t\t\t\tshadowMatrix.multiply( shadowCamera.matrixWorldInverse );\n\n\t\t\t\t}\n\n\t\t\t\t_renderer.setRenderTarget( shadowMap );\n\t\t\t\t_renderer.clear();\n\n\t\t\t\t// render shadow map for each cube face (if omni-directional) or\n\t\t\t\t// run a single pass if not\n\n\t\t\t\tfor ( var face = 0; face < faceCount; face ++ ) {\n\n\t\t\t\t\tif ( isPointLight ) {\n\n\t\t\t\t\t\t_lookTarget.copy( shadowCamera.position );\n\t\t\t\t\t\t_lookTarget.add( cubeDirections[ face ] );\n\t\t\t\t\t\tshadowCamera.up.copy( cubeUps[ face ] );\n\t\t\t\t\t\tshadowCamera.lookAt( _lookTarget );\n\t\t\t\t\t\tshadowCamera.updateMatrixWorld();\n\n\t\t\t\t\t\tvar vpDimensions = cube2DViewPorts[ face ];\n\t\t\t\t\t\t_state.viewport( vpDimensions );\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// update camera matrices and frustum\n\n\t\t\t\t\t_projScreenMatrix.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );\n\t\t\t\t\t_frustum.setFromMatrix( _projScreenMatrix );\n\n\t\t\t\t\t// set object matrices & frustum culling\n\n\t\t\t\t\trenderObject( scene, camera, shadowCamera, isPointLight );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tscope.needsUpdate = false;\n\n\t\t};\n\n\t\tfunction getDepthMaterial( object, material, isPointLight, lightPositionWorld, shadowCameraNear, shadowCameraFar ) {\n\n\t\t\tvar geometry = object.geometry;\n\n\t\t\tvar result = null;\n\n\t\t\tvar materialVariants = _depthMaterials;\n\t\t\tvar customMaterial = object.customDepthMaterial;\n\n\t\t\tif ( isPointLight ) {\n\n\t\t\t\tmaterialVariants = _distanceMaterials;\n\t\t\t\tcustomMaterial = object.customDistanceMaterial;\n\n\t\t\t}\n\n\t\t\tif ( ! customMaterial ) {\n\n\t\t\t\tvar useMorphing = false;\n\n\t\t\t\tif ( material.morphTargets ) {\n\n\t\t\t\t\tif ( geometry && geometry.isBufferGeometry ) {\n\n\t\t\t\t\t\tuseMorphing = geometry.morphAttributes && geometry.morphAttributes.position && geometry.morphAttributes.position.length > 0;\n\n\t\t\t\t\t} else if ( geometry && geometry.isGeometry ) {\n\n\t\t\t\t\t\tuseMorphing = geometry.morphTargets && geometry.morphTargets.length > 0;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( object.isSkinnedMesh && material.skinning === false ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:', object );\n\n\t\t\t\t}\n\n\t\t\t\tvar useSkinning = object.isSkinnedMesh && material.skinning;\n\n\t\t\t\tvar variantIndex = 0;\n\n\t\t\t\tif ( useMorphing ) variantIndex |= _MorphingFlag;\n\t\t\t\tif ( useSkinning ) variantIndex |= _SkinningFlag;\n\n\t\t\t\tresult = materialVariants[ variantIndex ];\n\n\t\t\t} else {\n\n\t\t\t\tresult = customMaterial;\n\n\t\t\t}\n\n\t\t\tif ( _renderer.localClippingEnabled &&\n\t\t\t\t\tmaterial.clipShadows === true &&\n\t\t\t\t\tmaterial.clippingPlanes.length !== 0 ) {\n\n\t\t\t\t// in this case we need a unique material instance reflecting the\n\t\t\t\t// appropriate state\n\n\t\t\t\tvar keyA = result.uuid, keyB = material.uuid;\n\n\t\t\t\tvar materialsForVariant = _materialCache[ keyA ];\n\n\t\t\t\tif ( materialsForVariant === undefined ) {\n\n\t\t\t\t\tmaterialsForVariant = {};\n\t\t\t\t\t_materialCache[ keyA ] = materialsForVariant;\n\n\t\t\t\t}\n\n\t\t\t\tvar cachedMaterial = materialsForVariant[ keyB ];\n\n\t\t\t\tif ( cachedMaterial === undefined ) {\n\n\t\t\t\t\tcachedMaterial = result.clone();\n\t\t\t\t\tmaterialsForVariant[ keyB ] = cachedMaterial;\n\n\t\t\t\t}\n\n\t\t\t\tresult = cachedMaterial;\n\n\t\t\t}\n\n\t\t\tresult.visible = material.visible;\n\t\t\tresult.wireframe = material.wireframe;\n\n\t\t\tresult.side = ( material.shadowSide != null ) ? material.shadowSide : shadowSide[ material.side ];\n\n\t\t\tresult.clipShadows = material.clipShadows;\n\t\t\tresult.clippingPlanes = material.clippingPlanes;\n\t\t\tresult.clipIntersection = material.clipIntersection;\n\n\t\t\tresult.wireframeLinewidth = material.wireframeLinewidth;\n\t\t\tresult.linewidth = material.linewidth;\n\n\t\t\tif ( isPointLight && result.isMeshDistanceMaterial ) {\n\n\t\t\t\tresult.referencePosition.copy( lightPositionWorld );\n\t\t\t\tresult.nearDistance = shadowCameraNear;\n\t\t\t\tresult.farDistance = shadowCameraFar;\n\n\t\t\t}\n\n\t\t\treturn result;\n\n\t\t}\n\n\t\tfunction renderObject( object, camera, shadowCamera, isPointLight ) {\n\n\t\t\tif ( object.visible === false ) return;\n\n\t\t\tvar visible = object.layers.test( camera.layers );\n\n\t\t\tif ( visible && ( object.isMesh || object.isLine || object.isPoints ) ) {\n\n\t\t\t\tif ( object.castShadow && ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) ) {\n\n\t\t\t\t\tobject.modelViewMatrix.multiplyMatrices( shadowCamera.matrixWorldInverse, object.matrixWorld );\n\n\t\t\t\t\tvar geometry = _objects.update( object );\n\t\t\t\t\tvar material = object.material;\n\n\t\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\t\tvar groups = geometry.groups;\n\n\t\t\t\t\t\tfor ( var k = 0, kl = groups.length; k < kl; k ++ ) {\n\n\t\t\t\t\t\t\tvar group = groups[ k ];\n\t\t\t\t\t\t\tvar groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\t\tif ( groupMaterial && groupMaterial.visible ) {\n\n\t\t\t\t\t\t\t\tvar depthMaterial = getDepthMaterial( object, groupMaterial, isPointLight, _lightPositionWorld, shadowCamera.near, shadowCamera.far );\n\t\t\t\t\t\t\t\t_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else if ( material.visible ) {\n\n\t\t\t\t\t\tvar depthMaterial = getDepthMaterial( object, material, isPointLight, _lightPositionWorld, shadowCamera.near, shadowCamera.far );\n\t\t\t\t\t\t_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tvar children = object.children;\n\n\t\t\tfor ( var i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\t\trenderObject( children[ i ], camera, shadowCamera, isPointLight );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction WebGLState( gl, extensions, utils, capabilities ) {\n\n\t\tfunction ColorBuffer() {\n\n\t\t\tvar locked = false;\n\n\t\t\tvar color = new Vector4();\n\t\t\tvar currentColorMask = null;\n\t\t\tvar currentColorClear = new Vector4( 0, 0, 0, 0 );\n\n\t\t\treturn {\n\n\t\t\t\tsetMask: function ( colorMask ) {\n\n\t\t\t\t\tif ( currentColorMask !== colorMask && ! locked ) {\n\n\t\t\t\t\t\tgl.colorMask( colorMask, colorMask, colorMask, colorMask );\n\t\t\t\t\t\tcurrentColorMask = colorMask;\n\n\t\t\t\t\t}\n\n\t\t\t\t},\n\n\t\t\t\tsetLocked: function ( lock ) {\n\n\t\t\t\t\tlocked = lock;\n\n\t\t\t\t},\n\n\t\t\t\tsetClear: function ( r, g, b, a, premultipliedAlpha ) {\n\n\t\t\t\t\tif ( premultipliedAlpha === true ) {\n\n\t\t\t\t\t\tr *= a; g *= a; b *= a;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tcolor.set( r, g, b, a );\n\n\t\t\t\t\tif ( currentColorClear.equals( color ) === false ) {\n\n\t\t\t\t\t\tgl.clearColor( r, g, b, a );\n\t\t\t\t\t\tcurrentColorClear.copy( color );\n\n\t\t\t\t\t}\n\n\t\t\t\t},\n\n\t\t\t\treset: function () {\n\n\t\t\t\t\tlocked = false;\n\n\t\t\t\t\tcurrentColorMask = null;\n\t\t\t\t\tcurrentColorClear.set( - 1, 0, 0, 0 ); // set to invalid state\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t}\n\n\t\tfunction DepthBuffer() {\n\n\t\t\tvar locked = false;\n\n\t\t\tvar currentDepthMask = null;\n\t\t\tvar currentDepthFunc = null;\n\t\t\tvar currentDepthClear = null;\n\n\t\t\treturn {\n\n\t\t\t\tsetTest: function ( depthTest ) {\n\n\t\t\t\t\tif ( depthTest ) {\n\n\t\t\t\t\t\tenable( 2929 );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tdisable( 2929 );\n\n\t\t\t\t\t}\n\n\t\t\t\t},\n\n\t\t\t\tsetMask: function ( depthMask ) {\n\n\t\t\t\t\tif ( currentDepthMask !== depthMask && ! locked ) {\n\n\t\t\t\t\t\tgl.depthMask( depthMask );\n\t\t\t\t\t\tcurrentDepthMask = depthMask;\n\n\t\t\t\t\t}\n\n\t\t\t\t},\n\n\t\t\t\tsetFunc: function ( depthFunc ) {\n\n\t\t\t\t\tif ( currentDepthFunc !== depthFunc ) {\n\n\t\t\t\t\t\tif ( depthFunc ) {\n\n\t\t\t\t\t\t\tswitch ( depthFunc ) {\n\n\t\t\t\t\t\t\t\tcase NeverDepth:\n\n\t\t\t\t\t\t\t\t\tgl.depthFunc( 512 );\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase AlwaysDepth:\n\n\t\t\t\t\t\t\t\t\tgl.depthFunc( 519 );\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase LessDepth:\n\n\t\t\t\t\t\t\t\t\tgl.depthFunc( 513 );\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase LessEqualDepth:\n\n\t\t\t\t\t\t\t\t\tgl.depthFunc( 515 );\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase EqualDepth:\n\n\t\t\t\t\t\t\t\t\tgl.depthFunc( 514 );\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase GreaterEqualDepth:\n\n\t\t\t\t\t\t\t\t\tgl.depthFunc( 518 );\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase GreaterDepth:\n\n\t\t\t\t\t\t\t\t\tgl.depthFunc( 516 );\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase NotEqualDepth:\n\n\t\t\t\t\t\t\t\t\tgl.depthFunc( 517 );\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tdefault:\n\n\t\t\t\t\t\t\t\t\tgl.depthFunc( 515 );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tgl.depthFunc( 515 );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcurrentDepthFunc = depthFunc;\n\n\t\t\t\t\t}\n\n\t\t\t\t},\n\n\t\t\t\tsetLocked: function ( lock ) {\n\n\t\t\t\t\tlocked = lock;\n\n\t\t\t\t},\n\n\t\t\t\tsetClear: function ( depth ) {\n\n\t\t\t\t\tif ( currentDepthClear !== depth ) {\n\n\t\t\t\t\t\tgl.clearDepth( depth );\n\t\t\t\t\t\tcurrentDepthClear = depth;\n\n\t\t\t\t\t}\n\n\t\t\t\t},\n\n\t\t\t\treset: function () {\n\n\t\t\t\t\tlocked = false;\n\n\t\t\t\t\tcurrentDepthMask = null;\n\t\t\t\t\tcurrentDepthFunc = null;\n\t\t\t\t\tcurrentDepthClear = null;\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t}\n\n\t\tfunction StencilBuffer() {\n\n\t\t\tvar locked = false;\n\n\t\t\tvar currentStencilMask = null;\n\t\t\tvar currentStencilFunc = null;\n\t\t\tvar currentStencilRef = null;\n\t\t\tvar currentStencilFuncMask = null;\n\t\t\tvar currentStencilFail = null;\n\t\t\tvar currentStencilZFail = null;\n\t\t\tvar currentStencilZPass = null;\n\t\t\tvar currentStencilClear = null;\n\n\t\t\treturn {\n\n\t\t\t\tsetTest: function ( stencilTest ) {\n\n\t\t\t\t\tif ( stencilTest ) {\n\n\t\t\t\t\t\tenable( 2960 );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tdisable( 2960 );\n\n\t\t\t\t\t}\n\n\t\t\t\t},\n\n\t\t\t\tsetMask: function ( stencilMask ) {\n\n\t\t\t\t\tif ( currentStencilMask !== stencilMask && ! locked ) {\n\n\t\t\t\t\t\tgl.stencilMask( stencilMask );\n\t\t\t\t\t\tcurrentStencilMask = stencilMask;\n\n\t\t\t\t\t}\n\n\t\t\t\t},\n\n\t\t\t\tsetFunc: function ( stencilFunc, stencilRef, stencilMask ) {\n\n\t\t\t\t\tif ( currentStencilFunc !== stencilFunc ||\n\t\t\t\t\t     currentStencilRef \t!== stencilRef \t||\n\t\t\t\t\t     currentStencilFuncMask !== stencilMask ) {\n\n\t\t\t\t\t\tgl.stencilFunc( stencilFunc, stencilRef, stencilMask );\n\n\t\t\t\t\t\tcurrentStencilFunc = stencilFunc;\n\t\t\t\t\t\tcurrentStencilRef = stencilRef;\n\t\t\t\t\t\tcurrentStencilFuncMask = stencilMask;\n\n\t\t\t\t\t}\n\n\t\t\t\t},\n\n\t\t\t\tsetOp: function ( stencilFail, stencilZFail, stencilZPass ) {\n\n\t\t\t\t\tif ( currentStencilFail\t !== stencilFail \t||\n\t\t\t\t\t     currentStencilZFail !== stencilZFail ||\n\t\t\t\t\t     currentStencilZPass !== stencilZPass ) {\n\n\t\t\t\t\t\tgl.stencilOp( stencilFail, stencilZFail, stencilZPass );\n\n\t\t\t\t\t\tcurrentStencilFail = stencilFail;\n\t\t\t\t\t\tcurrentStencilZFail = stencilZFail;\n\t\t\t\t\t\tcurrentStencilZPass = stencilZPass;\n\n\t\t\t\t\t}\n\n\t\t\t\t},\n\n\t\t\t\tsetLocked: function ( lock ) {\n\n\t\t\t\t\tlocked = lock;\n\n\t\t\t\t},\n\n\t\t\t\tsetClear: function ( stencil ) {\n\n\t\t\t\t\tif ( currentStencilClear !== stencil ) {\n\n\t\t\t\t\t\tgl.clearStencil( stencil );\n\t\t\t\t\t\tcurrentStencilClear = stencil;\n\n\t\t\t\t\t}\n\n\t\t\t\t},\n\n\t\t\t\treset: function () {\n\n\t\t\t\t\tlocked = false;\n\n\t\t\t\t\tcurrentStencilMask = null;\n\t\t\t\t\tcurrentStencilFunc = null;\n\t\t\t\t\tcurrentStencilRef = null;\n\t\t\t\t\tcurrentStencilFuncMask = null;\n\t\t\t\t\tcurrentStencilFail = null;\n\t\t\t\t\tcurrentStencilZFail = null;\n\t\t\t\t\tcurrentStencilZPass = null;\n\t\t\t\t\tcurrentStencilClear = null;\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t}\n\n\t\t//\n\n\t\tvar colorBuffer = new ColorBuffer();\n\t\tvar depthBuffer = new DepthBuffer();\n\t\tvar stencilBuffer = new StencilBuffer();\n\n\t\tvar maxVertexAttributes = gl.getParameter( 34921 );\n\t\tvar newAttributes = new Uint8Array( maxVertexAttributes );\n\t\tvar enabledAttributes = new Uint8Array( maxVertexAttributes );\n\t\tvar attributeDivisors = new Uint8Array( maxVertexAttributes );\n\n\t\tvar enabledCapabilities = {};\n\n\t\tvar compressedTextureFormats = null;\n\n\t\tvar currentProgram = null;\n\n\t\tvar currentBlendingEnabled = null;\n\t\tvar currentBlending = null;\n\t\tvar currentBlendEquation = null;\n\t\tvar currentBlendSrc = null;\n\t\tvar currentBlendDst = null;\n\t\tvar currentBlendEquationAlpha = null;\n\t\tvar currentBlendSrcAlpha = null;\n\t\tvar currentBlendDstAlpha = null;\n\t\tvar currentPremultipledAlpha = false;\n\n\t\tvar currentFlipSided = null;\n\t\tvar currentCullFace = null;\n\n\t\tvar currentLineWidth = null;\n\n\t\tvar currentPolygonOffsetFactor = null;\n\t\tvar currentPolygonOffsetUnits = null;\n\n\t\tvar maxTextures = gl.getParameter( 35661 );\n\n\t\tvar lineWidthAvailable = false;\n\t\tvar version = 0;\n\t\tvar glVersion = gl.getParameter( 7938 );\n\n\t\tif ( glVersion.indexOf( 'WebGL' ) !== - 1 ) {\n\n\t\t\tversion = parseFloat( /^WebGL\\ ([0-9])/.exec( glVersion )[ 1 ] );\n\t\t\tlineWidthAvailable = ( version >= 1.0 );\n\n\t\t} else if ( glVersion.indexOf( 'OpenGL ES' ) !== - 1 ) {\n\n\t\t\tversion = parseFloat( /^OpenGL\\ ES\\ ([0-9])/.exec( glVersion )[ 1 ] );\n\t\t\tlineWidthAvailable = ( version >= 2.0 );\n\n\t\t}\n\n\t\tvar currentTextureSlot = null;\n\t\tvar currentBoundTextures = {};\n\n\t\tvar currentScissor = new Vector4();\n\t\tvar currentViewport = new Vector4();\n\n\t\tfunction createTexture( type, target, count ) {\n\n\t\t\tvar data = new Uint8Array( 4 ); // 4 is required to match default unpack alignment of 4.\n\t\t\tvar texture = gl.createTexture();\n\n\t\t\tgl.bindTexture( type, texture );\n\t\t\tgl.texParameteri( type, 10241, 9728 );\n\t\t\tgl.texParameteri( type, 10240, 9728 );\n\n\t\t\tfor ( var i = 0; i < count; i ++ ) {\n\n\t\t\t\tgl.texImage2D( target + i, 0, 6408, 1, 1, 0, 6408, 5121, data );\n\n\t\t\t}\n\n\t\t\treturn texture;\n\n\t\t}\n\n\t\tvar emptyTextures = {};\n\t\temptyTextures[ 3553 ] = createTexture( 3553, 3553, 1 );\n\t\temptyTextures[ 34067 ] = createTexture( 34067, 34069, 6 );\n\n\t\t// init\n\n\t\tcolorBuffer.setClear( 0, 0, 0, 1 );\n\t\tdepthBuffer.setClear( 1 );\n\t\tstencilBuffer.setClear( 0 );\n\n\t\tenable( 2929 );\n\t\tdepthBuffer.setFunc( LessEqualDepth );\n\n\t\tsetFlipSided( false );\n\t\tsetCullFace( CullFaceBack );\n\t\tenable( 2884 );\n\n\t\tsetBlending( NoBlending );\n\n\t\t//\n\n\t\tfunction initAttributes() {\n\n\t\t\tfor ( var i = 0, l = newAttributes.length; i < l; i ++ ) {\n\n\t\t\t\tnewAttributes[ i ] = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction enableAttribute( attribute ) {\n\n\t\t\tenableAttributeAndDivisor( attribute, 0 );\n\n\t\t}\n\n\t\tfunction enableAttributeAndDivisor( attribute, meshPerAttribute ) {\n\n\t\t\tnewAttributes[ attribute ] = 1;\n\n\t\t\tif ( enabledAttributes[ attribute ] === 0 ) {\n\n\t\t\t\tgl.enableVertexAttribArray( attribute );\n\t\t\t\tenabledAttributes[ attribute ] = 1;\n\n\t\t\t}\n\n\t\t\tif ( attributeDivisors[ attribute ] !== meshPerAttribute ) {\n\n\t\t\t\tvar extension = capabilities.isWebGL2 ? gl : extensions.get( 'ANGLE_instanced_arrays' );\n\n\t\t\t\textension[ capabilities.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE' ]( attribute, meshPerAttribute );\n\t\t\t\tattributeDivisors[ attribute ] = meshPerAttribute;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction disableUnusedAttributes() {\n\n\t\t\tfor ( var i = 0, l = enabledAttributes.length; i !== l; ++ i ) {\n\n\t\t\t\tif ( enabledAttributes[ i ] !== newAttributes[ i ] ) {\n\n\t\t\t\t\tgl.disableVertexAttribArray( i );\n\t\t\t\t\tenabledAttributes[ i ] = 0;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction enable( id ) {\n\n\t\t\tif ( enabledCapabilities[ id ] !== true ) {\n\n\t\t\t\tgl.enable( id );\n\t\t\t\tenabledCapabilities[ id ] = true;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction disable( id ) {\n\n\t\t\tif ( enabledCapabilities[ id ] !== false ) {\n\n\t\t\t\tgl.disable( id );\n\t\t\t\tenabledCapabilities[ id ] = false;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction getCompressedTextureFormats() {\n\n\t\t\tif ( compressedTextureFormats === null ) {\n\n\t\t\t\tcompressedTextureFormats = [];\n\n\t\t\t\tif ( extensions.get( 'WEBGL_compressed_texture_pvrtc' ) ||\n\t\t\t\t     extensions.get( 'WEBGL_compressed_texture_s3tc' ) ||\n\t\t\t\t     extensions.get( 'WEBGL_compressed_texture_etc1' ) ||\n\t\t\t\t     extensions.get( 'WEBGL_compressed_texture_astc' ) ) {\n\n\t\t\t\t\tvar formats = gl.getParameter( 34467 );\n\n\t\t\t\t\tfor ( var i = 0; i < formats.length; i ++ ) {\n\n\t\t\t\t\t\tcompressedTextureFormats.push( formats[ i ] );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn compressedTextureFormats;\n\n\t\t}\n\n\t\tfunction useProgram( program ) {\n\n\t\t\tif ( currentProgram !== program ) {\n\n\t\t\t\tgl.useProgram( program );\n\n\t\t\t\tcurrentProgram = program;\n\n\t\t\t\treturn true;\n\n\t\t\t}\n\n\t\t\treturn false;\n\n\t\t}\n\n\t\tfunction setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha ) {\n\n\t\t\tif ( blending === NoBlending ) {\n\n\t\t\t\tif ( currentBlendingEnabled ) {\n\n\t\t\t\t\tdisable( 3042 );\n\t\t\t\t\tcurrentBlendingEnabled = false;\n\n\t\t\t\t}\n\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tif ( ! currentBlendingEnabled ) {\n\n\t\t\t\tenable( 3042 );\n\t\t\t\tcurrentBlendingEnabled = true;\n\n\t\t\t}\n\n\t\t\tif ( blending !== CustomBlending ) {\n\n\t\t\t\tif ( blending !== currentBlending || premultipliedAlpha !== currentPremultipledAlpha ) {\n\n\t\t\t\t\tif ( currentBlendEquation !== AddEquation || currentBlendEquationAlpha !== AddEquation ) {\n\n\t\t\t\t\t\tgl.blendEquation( 32774 );\n\n\t\t\t\t\t\tcurrentBlendEquation = AddEquation;\n\t\t\t\t\t\tcurrentBlendEquationAlpha = AddEquation;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( premultipliedAlpha ) {\n\n\t\t\t\t\t\tswitch ( blending ) {\n\n\t\t\t\t\t\t\tcase NormalBlending:\n\t\t\t\t\t\t\t\tgl.blendFuncSeparate( 1, 771, 1, 771 );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase AdditiveBlending:\n\t\t\t\t\t\t\t\tgl.blendFunc( 1, 1 );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase SubtractiveBlending:\n\t\t\t\t\t\t\t\tgl.blendFuncSeparate( 0, 0, 769, 771 );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase MultiplyBlending:\n\t\t\t\t\t\t\t\tgl.blendFuncSeparate( 0, 768, 0, 770 );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tconsole.error( 'THREE.WebGLState: Invalid blending: ', blending );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tswitch ( blending ) {\n\n\t\t\t\t\t\t\tcase NormalBlending:\n\t\t\t\t\t\t\t\tgl.blendFuncSeparate( 770, 771, 1, 771 );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase AdditiveBlending:\n\t\t\t\t\t\t\t\tgl.blendFunc( 770, 1 );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase SubtractiveBlending:\n\t\t\t\t\t\t\t\tgl.blendFunc( 0, 769 );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase MultiplyBlending:\n\t\t\t\t\t\t\t\tgl.blendFunc( 0, 768 );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tconsole.error( 'THREE.WebGLState: Invalid blending: ', blending );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrentBlendSrc = null;\n\t\t\t\t\tcurrentBlendDst = null;\n\t\t\t\t\tcurrentBlendSrcAlpha = null;\n\t\t\t\t\tcurrentBlendDstAlpha = null;\n\n\t\t\t\t\tcurrentBlending = blending;\n\t\t\t\t\tcurrentPremultipledAlpha = premultipliedAlpha;\n\n\t\t\t\t}\n\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\t// custom blending\n\n\t\t\tblendEquationAlpha = blendEquationAlpha || blendEquation;\n\t\t\tblendSrcAlpha = blendSrcAlpha || blendSrc;\n\t\t\tblendDstAlpha = blendDstAlpha || blendDst;\n\n\t\t\tif ( blendEquation !== currentBlendEquation || blendEquationAlpha !== currentBlendEquationAlpha ) {\n\n\t\t\t\tgl.blendEquationSeparate( utils.convert( blendEquation ), utils.convert( blendEquationAlpha ) );\n\n\t\t\t\tcurrentBlendEquation = blendEquation;\n\t\t\t\tcurrentBlendEquationAlpha = blendEquationAlpha;\n\n\t\t\t}\n\n\t\t\tif ( blendSrc !== currentBlendSrc || blendDst !== currentBlendDst || blendSrcAlpha !== currentBlendSrcAlpha || blendDstAlpha !== currentBlendDstAlpha ) {\n\n\t\t\t\tgl.blendFuncSeparate( utils.convert( blendSrc ), utils.convert( blendDst ), utils.convert( blendSrcAlpha ), utils.convert( blendDstAlpha ) );\n\n\t\t\t\tcurrentBlendSrc = blendSrc;\n\t\t\t\tcurrentBlendDst = blendDst;\n\t\t\t\tcurrentBlendSrcAlpha = blendSrcAlpha;\n\t\t\t\tcurrentBlendDstAlpha = blendDstAlpha;\n\n\t\t\t}\n\n\t\t\tcurrentBlending = blending;\n\t\t\tcurrentPremultipledAlpha = null;\n\n\t\t}\n\n\t\tfunction setMaterial( material, frontFaceCW ) {\n\n\t\t\tmaterial.side === DoubleSide\n\t\t\t\t? disable( 2884 )\n\t\t\t\t: enable( 2884 );\n\n\t\t\tvar flipSided = ( material.side === BackSide );\n\t\t\tif ( frontFaceCW ) flipSided = ! flipSided;\n\n\t\t\tsetFlipSided( flipSided );\n\n\t\t\t( material.blending === NormalBlending && material.transparent === false )\n\t\t\t\t? setBlending( NoBlending )\n\t\t\t\t: setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.premultipliedAlpha );\n\n\t\t\tdepthBuffer.setFunc( material.depthFunc );\n\t\t\tdepthBuffer.setTest( material.depthTest );\n\t\t\tdepthBuffer.setMask( material.depthWrite );\n\t\t\tcolorBuffer.setMask( material.colorWrite );\n\n\t\t\tsetPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits );\n\n\t\t}\n\n\t\t//\n\n\t\tfunction setFlipSided( flipSided ) {\n\n\t\t\tif ( currentFlipSided !== flipSided ) {\n\n\t\t\t\tif ( flipSided ) {\n\n\t\t\t\t\tgl.frontFace( 2304 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tgl.frontFace( 2305 );\n\n\t\t\t\t}\n\n\t\t\t\tcurrentFlipSided = flipSided;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction setCullFace( cullFace ) {\n\n\t\t\tif ( cullFace !== CullFaceNone ) {\n\n\t\t\t\tenable( 2884 );\n\n\t\t\t\tif ( cullFace !== currentCullFace ) {\n\n\t\t\t\t\tif ( cullFace === CullFaceBack ) {\n\n\t\t\t\t\t\tgl.cullFace( 1029 );\n\n\t\t\t\t\t} else if ( cullFace === CullFaceFront ) {\n\n\t\t\t\t\t\tgl.cullFace( 1028 );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tgl.cullFace( 1032 );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tdisable( 2884 );\n\n\t\t\t}\n\n\t\t\tcurrentCullFace = cullFace;\n\n\t\t}\n\n\t\tfunction setLineWidth( width ) {\n\n\t\t\tif ( width !== currentLineWidth ) {\n\n\t\t\t\tif ( lineWidthAvailable ) gl.lineWidth( width );\n\n\t\t\t\tcurrentLineWidth = width;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction setPolygonOffset( polygonOffset, factor, units ) {\n\n\t\t\tif ( polygonOffset ) {\n\n\t\t\t\tenable( 32823 );\n\n\t\t\t\tif ( currentPolygonOffsetFactor !== factor || currentPolygonOffsetUnits !== units ) {\n\n\t\t\t\t\tgl.polygonOffset( factor, units );\n\n\t\t\t\t\tcurrentPolygonOffsetFactor = factor;\n\t\t\t\t\tcurrentPolygonOffsetUnits = units;\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tdisable( 32823 );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction setScissorTest( scissorTest ) {\n\n\t\t\tif ( scissorTest ) {\n\n\t\t\t\tenable( 3089 );\n\n\t\t\t} else {\n\n\t\t\t\tdisable( 3089 );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// texture\n\n\t\tfunction activeTexture( webglSlot ) {\n\n\t\t\tif ( webglSlot === undefined ) webglSlot = 33984 + maxTextures - 1;\n\n\t\t\tif ( currentTextureSlot !== webglSlot ) {\n\n\t\t\t\tgl.activeTexture( webglSlot );\n\t\t\t\tcurrentTextureSlot = webglSlot;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction bindTexture( webglType, webglTexture ) {\n\n\t\t\tif ( currentTextureSlot === null ) {\n\n\t\t\t\tactiveTexture();\n\n\t\t\t}\n\n\t\t\tvar boundTexture = currentBoundTextures[ currentTextureSlot ];\n\n\t\t\tif ( boundTexture === undefined ) {\n\n\t\t\t\tboundTexture = { type: undefined, texture: undefined };\n\t\t\t\tcurrentBoundTextures[ currentTextureSlot ] = boundTexture;\n\n\t\t\t}\n\n\t\t\tif ( boundTexture.type !== webglType || boundTexture.texture !== webglTexture ) {\n\n\t\t\t\tgl.bindTexture( webglType, webglTexture || emptyTextures[ webglType ] );\n\n\t\t\t\tboundTexture.type = webglType;\n\t\t\t\tboundTexture.texture = webglTexture;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction compressedTexImage2D() {\n\n\t\t\ttry {\n\n\t\t\t\tgl.compressedTexImage2D.apply( gl, arguments );\n\n\t\t\t} catch ( error ) {\n\n\t\t\t\tconsole.error( 'THREE.WebGLState:', error );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction texImage2D() {\n\n\t\t\ttry {\n\n\t\t\t\tgl.texImage2D.apply( gl, arguments );\n\n\t\t\t} catch ( error ) {\n\n\t\t\t\tconsole.error( 'THREE.WebGLState:', error );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction texImage3D() {\n\n\t\t\ttry {\n\n\t\t\t\tgl.texImage3D.apply( gl, arguments );\n\n\t\t\t} catch ( error ) {\n\n\t\t\t\tconsole.error( 'THREE.WebGLState:', error );\n\n\t\t\t}\n\n\t\t}\n\n\t\t//\n\n\t\tfunction scissor( scissor ) {\n\n\t\t\tif ( currentScissor.equals( scissor ) === false ) {\n\n\t\t\t\tgl.scissor( scissor.x, scissor.y, scissor.z, scissor.w );\n\t\t\t\tcurrentScissor.copy( scissor );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction viewport( viewport ) {\n\n\t\t\tif ( currentViewport.equals( viewport ) === false ) {\n\n\t\t\t\tgl.viewport( viewport.x, viewport.y, viewport.z, viewport.w );\n\t\t\t\tcurrentViewport.copy( viewport );\n\n\t\t\t}\n\n\t\t}\n\n\t\t//\n\n\t\tfunction reset() {\n\n\t\t\tfor ( var i = 0; i < enabledAttributes.length; i ++ ) {\n\n\t\t\t\tif ( enabledAttributes[ i ] === 1 ) {\n\n\t\t\t\t\tgl.disableVertexAttribArray( i );\n\t\t\t\t\tenabledAttributes[ i ] = 0;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tenabledCapabilities = {};\n\n\t\t\tcompressedTextureFormats = null;\n\n\t\t\tcurrentTextureSlot = null;\n\t\t\tcurrentBoundTextures = {};\n\n\t\t\tcurrentProgram = null;\n\n\t\t\tcurrentBlending = null;\n\n\t\t\tcurrentFlipSided = null;\n\t\t\tcurrentCullFace = null;\n\n\t\t\tcolorBuffer.reset();\n\t\t\tdepthBuffer.reset();\n\t\t\tstencilBuffer.reset();\n\n\t\t}\n\n\t\treturn {\n\n\t\t\tbuffers: {\n\t\t\t\tcolor: colorBuffer,\n\t\t\t\tdepth: depthBuffer,\n\t\t\t\tstencil: stencilBuffer\n\t\t\t},\n\n\t\t\tinitAttributes: initAttributes,\n\t\t\tenableAttribute: enableAttribute,\n\t\t\tenableAttributeAndDivisor: enableAttributeAndDivisor,\n\t\t\tdisableUnusedAttributes: disableUnusedAttributes,\n\t\t\tenable: enable,\n\t\t\tdisable: disable,\n\t\t\tgetCompressedTextureFormats: getCompressedTextureFormats,\n\n\t\t\tuseProgram: useProgram,\n\n\t\t\tsetBlending: setBlending,\n\t\t\tsetMaterial: setMaterial,\n\n\t\t\tsetFlipSided: setFlipSided,\n\t\t\tsetCullFace: setCullFace,\n\n\t\t\tsetLineWidth: setLineWidth,\n\t\t\tsetPolygonOffset: setPolygonOffset,\n\n\t\t\tsetScissorTest: setScissorTest,\n\n\t\t\tactiveTexture: activeTexture,\n\t\t\tbindTexture: bindTexture,\n\t\t\tcompressedTexImage2D: compressedTexImage2D,\n\t\t\ttexImage2D: texImage2D,\n\t\t\ttexImage3D: texImage3D,\n\n\t\t\tscissor: scissor,\n\t\t\tviewport: viewport,\n\n\t\t\treset: reset\n\n\t\t};\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {\n\n\t\tvar _videoTextures = {};\n\t\tvar _canvas;\n\n\t\t//\n\n\t\tfunction clampToMaxSize( image, maxSize ) {\n\n\t\t\tif ( image.width > maxSize || image.height > maxSize ) {\n\n\t\t\t\tif ( 'data' in image ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: image in DataTexture is too big (' + image.width + 'x' + image.height + ').' );\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t\t// Warning: Scaling through the canvas will only work with images that use\n\t\t\t\t// premultiplied alpha.\n\n\t\t\t\tvar scale = maxSize / Math.max( image.width, image.height );\n\n\t\t\t\tvar canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );\n\t\t\t\tcanvas.width = Math.floor( image.width * scale );\n\t\t\t\tcanvas.height = Math.floor( image.height * scale );\n\n\t\t\t\tvar context = canvas.getContext( '2d' );\n\t\t\t\tcontext.drawImage( image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height );\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: image is too big (' + image.width + 'x' + image.height + '). Resized to ' + canvas.width + 'x' + canvas.height );\n\n\t\t\t\treturn canvas;\n\n\t\t\t}\n\n\t\t\treturn image;\n\n\t\t}\n\n\t\tfunction isPowerOfTwo( image ) {\n\n\t\t\treturn _Math.isPowerOfTwo( image.width ) && _Math.isPowerOfTwo( image.height );\n\n\t\t}\n\n\t\tfunction makePowerOfTwo( image ) {\n\n\t\t\tif ( image instanceof HTMLImageElement || image instanceof HTMLCanvasElement || image instanceof ImageBitmap ) {\n\n\t\t\t\tif ( _canvas === undefined ) _canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );\n\n\t\t\t\t_canvas.width = _Math.floorPowerOfTwo( image.width );\n\t\t\t\t_canvas.height = _Math.floorPowerOfTwo( image.height );\n\n\t\t\t\tvar context = _canvas.getContext( '2d' );\n\t\t\t\tcontext.drawImage( image, 0, 0, _canvas.width, _canvas.height );\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: image is not power of two (' + image.width + 'x' + image.height + '). Resized to ' + _canvas.width + 'x' + _canvas.height );\n\n\t\t\t\treturn _canvas;\n\n\t\t\t}\n\n\t\t\treturn image;\n\n\t\t}\n\n\t\tfunction textureNeedsPowerOfTwo( texture ) {\n\n\t\t\tif ( capabilities.isWebGL2 ) return false;\n\n\t\t\treturn ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) ||\n\t\t\t\t( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter );\n\n\t\t}\n\n\t\tfunction textureNeedsGenerateMipmaps( texture, isPowerOfTwo ) {\n\n\t\t\treturn texture.generateMipmaps && isPowerOfTwo &&\n\t\t\t\ttexture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;\n\n\t\t}\n\n\t\tfunction generateMipmap( target, texture, width, height ) {\n\n\t\t\t_gl.generateMipmap( target );\n\n\t\t\tvar textureProperties = properties.get( texture );\n\n\t\t\t// Note: Math.log( x ) * Math.LOG2E used instead of Math.log2( x ) which is not supported by IE11\n\t\t\ttextureProperties.__maxMipLevel = Math.log( Math.max( width, height ) ) * Math.LOG2E;\n\n\t\t}\n\n\t\tfunction getInternalFormat( glFormat, glType ) {\n\n\t\t\tif ( ! capabilities.isWebGL2 ) return glFormat;\n\n\t\t\tif ( glFormat === 6403 ) {\n\n\t\t\t\tif ( glType === 5126 ) return 33326;\n\t\t\t\tif ( glType === 5131 ) return 33325;\n\t\t\t\tif ( glType === 5121 ) return 33321;\n\n\t\t\t}\n\n\t\t\tif ( glFormat === 6407 ) {\n\n\t\t\t\tif ( glType === 5126 ) return 34837;\n\t\t\t\tif ( glType === 5131 ) return 34843;\n\t\t\t\tif ( glType === 5121 ) return 32849;\n\n\t\t\t}\n\n\t\t\tif ( glFormat === 6408 ) {\n\n\t\t\t\tif ( glType === 5126 ) return 34836;\n\t\t\t\tif ( glType === 5131 ) return 34842;\n\t\t\t\tif ( glType === 5121 ) return 32856;\n\n\t\t\t}\n\n\t\t\treturn glFormat;\n\n\t\t}\n\n\t\t// Fallback filters for non-power-of-2 textures\n\n\t\tfunction filterFallback( f ) {\n\n\t\t\tif ( f === NearestFilter || f === NearestMipMapNearestFilter || f === NearestMipMapLinearFilter ) {\n\n\t\t\t\treturn 9728;\n\n\t\t\t}\n\n\t\t\treturn 9729;\n\n\t\t}\n\n\t\t//\n\n\t\tfunction onTextureDispose( event ) {\n\n\t\t\tvar texture = event.target;\n\n\t\t\ttexture.removeEventListener( 'dispose', onTextureDispose );\n\n\t\t\tdeallocateTexture( texture );\n\n\t\t\tif ( texture.isVideoTexture ) {\n\n\t\t\t\tdelete _videoTextures[ texture.id ];\n\n\t\t\t}\n\n\t\t\tinfo.memory.textures --;\n\n\t\t}\n\n\t\tfunction onRenderTargetDispose( event ) {\n\n\t\t\tvar renderTarget = event.target;\n\n\t\t\trenderTarget.removeEventListener( 'dispose', onRenderTargetDispose );\n\n\t\t\tdeallocateRenderTarget( renderTarget );\n\n\t\t\tinfo.memory.textures --;\n\n\t\t}\n\n\t\t//\n\n\t\tfunction deallocateTexture( texture ) {\n\n\t\t\tvar textureProperties = properties.get( texture );\n\n\t\t\tif ( texture.image && textureProperties.__image__webglTextureCube ) {\n\n\t\t\t\t// cube texture\n\n\t\t\t\t_gl.deleteTexture( textureProperties.__image__webglTextureCube );\n\n\t\t\t} else {\n\n\t\t\t\t// 2D texture\n\n\t\t\t\tif ( textureProperties.__webglInit === undefined ) return;\n\n\t\t\t\t_gl.deleteTexture( textureProperties.__webglTexture );\n\n\t\t\t}\n\n\t\t\t// remove all webgl properties\n\t\t\tproperties.remove( texture );\n\n\t\t}\n\n\t\tfunction deallocateRenderTarget( renderTarget ) {\n\n\t\t\tvar renderTargetProperties = properties.get( renderTarget );\n\t\t\tvar textureProperties = properties.get( renderTarget.texture );\n\n\t\t\tif ( ! renderTarget ) return;\n\n\t\t\tif ( textureProperties.__webglTexture !== undefined ) {\n\n\t\t\t\t_gl.deleteTexture( textureProperties.__webglTexture );\n\n\t\t\t}\n\n\t\t\tif ( renderTarget.depthTexture ) {\n\n\t\t\t\trenderTarget.depthTexture.dispose();\n\n\t\t\t}\n\n\t\t\tif ( renderTarget.isWebGLRenderTargetCube ) {\n\n\t\t\t\tfor ( var i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\t_gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer[ i ] );\n\t\t\t\t\tif ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer[ i ] );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t_gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer );\n\t\t\t\tif ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer );\n\n\t\t\t}\n\n\t\t\tproperties.remove( renderTarget.texture );\n\t\t\tproperties.remove( renderTarget );\n\n\t\t}\n\n\t\t//\n\n\n\n\t\tfunction setTexture2D( texture, slot ) {\n\n\t\t\tvar textureProperties = properties.get( texture );\n\n\t\t\tif ( texture.isVideoTexture ) updateVideoTexture( texture );\n\n\t\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\t\tvar image = texture.image;\n\n\t\t\t\tif ( image === undefined ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture marked for update but image is undefined' );\n\n\t\t\t\t} else if ( image.complete === false ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture marked for update but image is incomplete' );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tuploadTexture( textureProperties, texture, slot );\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tstate.activeTexture( 33984 + slot );\n\t\t\tstate.bindTexture( 3553, textureProperties.__webglTexture );\n\n\t\t}\n\n\t\tfunction setTexture3D( texture, slot ) {\n\n\t\t\tvar textureProperties = properties.get( texture );\n\n\t\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\t\tuploadTexture( textureProperties, texture, slot );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tstate.activeTexture( 33984 + slot );\n\t\t\tstate.bindTexture( 32879, textureProperties.__webglTexture );\n\n\t\t}\n\n\n\t\tfunction setTextureCube( texture, slot ) {\n\n\t\t\tvar textureProperties = properties.get( texture );\n\n\t\t\tif ( texture.image.length === 6 ) {\n\n\t\t\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\t\t\tif ( ! textureProperties.__image__webglTextureCube ) {\n\n\t\t\t\t\t\ttexture.addEventListener( 'dispose', onTextureDispose );\n\n\t\t\t\t\t\ttextureProperties.__image__webglTextureCube = _gl.createTexture();\n\n\t\t\t\t\t\tinfo.memory.textures ++;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tstate.activeTexture( 33984 + slot );\n\t\t\t\t\tstate.bindTexture( 34067, textureProperties.__image__webglTextureCube );\n\n\t\t\t\t\t_gl.pixelStorei( 37440, texture.flipY );\n\n\t\t\t\t\tvar isCompressed = ( texture && texture.isCompressedTexture );\n\t\t\t\t\tvar isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture );\n\n\t\t\t\t\tvar cubeImage = [];\n\n\t\t\t\t\tfor ( var i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\t\tif ( ! isCompressed && ! isDataTexture ) {\n\n\t\t\t\t\t\t\tcubeImage[ i ] = clampToMaxSize( texture.image[ i ], capabilities.maxCubemapSize );\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tcubeImage[ i ] = isDataTexture ? texture.image[ i ].image : texture.image[ i ];\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tvar image = cubeImage[ 0 ],\n\t\t\t\t\t\tisPowerOfTwoImage = isPowerOfTwo( image ),\n\t\t\t\t\t\tglFormat = utils.convert( texture.format ),\n\t\t\t\t\t\tglType = utils.convert( texture.type ),\n\t\t\t\t\t\tglInternalFormat = getInternalFormat( glFormat, glType );\n\n\t\t\t\t\tsetTextureParameters( 34067, texture, isPowerOfTwoImage );\n\n\t\t\t\t\tfor ( var i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\t\tif ( ! isCompressed ) {\n\n\t\t\t\t\t\t\tif ( isDataTexture ) {\n\n\t\t\t\t\t\t\t\tstate.texImage2D( 34069 + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data );\n\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\tstate.texImage2D( 34069 + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tvar mipmap, mipmaps = cubeImage[ i ].mipmaps;\n\n\t\t\t\t\t\t\tfor ( var j = 0, jl = mipmaps.length; j < jl; j ++ ) {\n\n\t\t\t\t\t\t\t\tmipmap = mipmaps[ j ];\n\n\t\t\t\t\t\t\t\tif ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) {\n\n\t\t\t\t\t\t\t\t\tif ( state.getCompressedTextureFormats().indexOf( glFormat ) > - 1 ) {\n\n\t\t\t\t\t\t\t\t\t\tstate.compressedTexImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );\n\n\t\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' );\n\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\tstate.texImage2D( 34069 + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( ! isCompressed ) {\n\n\t\t\t\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( textureNeedsGenerateMipmaps( texture, isPowerOfTwoImage ) ) {\n\n\t\t\t\t\t\t// We assume images for cube map have the same size.\n\t\t\t\t\t\tgenerateMipmap( 34067, texture, image.width, image.height );\n\n\t\t\t\t\t}\n\n\t\t\t\t\ttextureProperties.__version = texture.version;\n\n\t\t\t\t\tif ( texture.onUpdate ) texture.onUpdate( texture );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tstate.activeTexture( 33984 + slot );\n\t\t\t\t\tstate.bindTexture( 34067, textureProperties.__image__webglTextureCube );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction setTextureCubeDynamic( texture, slot ) {\n\n\t\t\tstate.activeTexture( 33984 + slot );\n\t\t\tstate.bindTexture( 34067, properties.get( texture ).__webglTexture );\n\n\t\t}\n\n\t\tfunction setTextureParameters( textureType, texture, isPowerOfTwoImage ) {\n\n\t\t\tvar extension;\n\n\t\t\tif ( isPowerOfTwoImage ) {\n\n\t\t\t\t_gl.texParameteri( textureType, 10242, utils.convert( texture.wrapS ) );\n\t\t\t\t_gl.texParameteri( textureType, 10243, utils.convert( texture.wrapT ) );\n\n\t\t\t\t_gl.texParameteri( textureType, 10240, utils.convert( texture.magFilter ) );\n\t\t\t\t_gl.texParameteri( textureType, 10241, utils.convert( texture.minFilter ) );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.texParameteri( textureType, 10242, 33071 );\n\t\t\t\t_gl.texParameteri( textureType, 10243, 33071 );\n\n\t\t\t\tif ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.' );\n\n\t\t\t\t}\n\n\t\t\t\t_gl.texParameteri( textureType, 10240, filterFallback( texture.magFilter ) );\n\t\t\t\t_gl.texParameteri( textureType, 10241, filterFallback( texture.minFilter ) );\n\n\t\t\t\tif ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\textension = extensions.get( 'EXT_texture_filter_anisotropic' );\n\n\t\t\tif ( extension ) {\n\n\t\t\t\tif ( texture.type === FloatType && extensions.get( 'OES_texture_float_linear' ) === null ) return;\n\t\t\t\tif ( texture.type === HalfFloatType && ( capabilities.isWebGL2 || extensions.get( 'OES_texture_half_float_linear' ) ) === null ) return;\n\n\t\t\t\tif ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {\n\n\t\t\t\t\t_gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, capabilities.getMaxAnisotropy() ) );\n\t\t\t\t\tproperties.get( texture ).__currentAnisotropy = texture.anisotropy;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction uploadTexture( textureProperties, texture, slot ) {\n\n\t\t\tvar textureType;\n\n\t\t\tif ( texture.isDataTexture3D ) {\n\n\t\t\t\ttextureType = 32879;\n\n\t\t\t} else {\n\n\t\t\t\ttextureType = 3553;\n\n\t\t\t}\n\n\n\t\t\tif ( textureProperties.__webglInit === undefined ) {\n\n\t\t\t\ttextureProperties.__webglInit = true;\n\n\t\t\t\ttexture.addEventListener( 'dispose', onTextureDispose );\n\n\t\t\t\ttextureProperties.__webglTexture = _gl.createTexture();\n\n\t\t\t\tinfo.memory.textures ++;\n\n\t\t\t}\n\t\t\tstate.activeTexture( 33984 + slot );\n\n\n\t\t\tstate.bindTexture( textureType, textureProperties.__webglTexture );\n\n\n\n\t\t\t_gl.pixelStorei( 37440, texture.flipY );\n\t\t\t_gl.pixelStorei( 37441, texture.premultiplyAlpha );\n\t\t\t_gl.pixelStorei( 3317, texture.unpackAlignment );\n\n\t\t\tvar image = clampToMaxSize( texture.image, capabilities.maxTextureSize );\n\n\t\t\tif ( textureNeedsPowerOfTwo( texture ) && isPowerOfTwo( image ) === false ) {\n\n\t\t\t\timage = makePowerOfTwo( image );\n\n\t\t\t}\n\n\t\t\tvar isPowerOfTwoImage = isPowerOfTwo( image ),\n\t\t\t\tglFormat = utils.convert( texture.format ),\n\t\t\t\tglType = utils.convert( texture.type ),\n\t\t\t\tglInternalFormat = getInternalFormat( glFormat, glType );\n\n\t\t\tsetTextureParameters( textureType, texture, isPowerOfTwoImage );\n\n\t\t\tvar mipmap, mipmaps = texture.mipmaps;\n\n\t\t\tif ( texture.isDepthTexture ) {\n\n\t\t\t\t// populate depth texture with dummy data\n\n\t\t\t\tglInternalFormat = 6402;\n\n\t\t\t\tif ( texture.type === FloatType ) {\n\n\t\t\t\t\tif ( ! capabilities.isWebGL2 ) throw new Error( 'Float Depth Texture only supported in WebGL2.0' );\n\t\t\t\t\tglInternalFormat = 36012;\n\n\t\t\t\t} else if ( capabilities.isWebGL2 ) {\n\n\t\t\t\t\t// WebGL 2.0 requires signed internalformat for glTexImage2D\n\t\t\t\t\tglInternalFormat = 33189;\n\n\t\t\t\t}\n\n\t\t\t\tif ( texture.format === DepthFormat && glInternalFormat === 6402 ) {\n\n\t\t\t\t\t// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are\n\t\t\t\t\t// DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT\n\t\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\t\tif ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) {\n\n\t\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' );\n\n\t\t\t\t\t\ttexture.type = UnsignedShortType;\n\t\t\t\t\t\tglType = utils.convert( texture.type );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\t// Depth stencil textures need the DEPTH_STENCIL internal format\n\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\tif ( texture.format === DepthStencilFormat ) {\n\n\t\t\t\t\tglInternalFormat = 34041;\n\n\t\t\t\t\t// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are\n\t\t\t\t\t// DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.\n\t\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\t\tif ( texture.type !== UnsignedInt248Type ) {\n\n\t\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.' );\n\n\t\t\t\t\t\ttexture.type = UnsignedInt248Type;\n\t\t\t\t\t\tglType = utils.convert( texture.type );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tstate.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );\n\n\t\t\t} else if ( texture.isDataTexture ) {\n\n\t\t\t\t// use manually created mipmaps if available\n\t\t\t\t// if there are no manual mipmaps\n\t\t\t\t// set 0 level mipmap and then use GL to generate other mipmap levels\n\n\t\t\t\tif ( mipmaps.length > 0 && isPowerOfTwoImage ) {\n\n\t\t\t\t\tfor ( var i = 0, il = mipmaps.length; i < il; i ++ ) {\n\n\t\t\t\t\t\tmipmap = mipmaps[ i ];\n\t\t\t\t\t\tstate.texImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );\n\n\t\t\t\t\t}\n\n\t\t\t\t\ttexture.generateMipmaps = false;\n\t\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tstate.texImage2D( 3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data );\n\t\t\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t\t\t}\n\n\t\t\t} else if ( texture.isCompressedTexture ) {\n\n\t\t\t\tfor ( var i = 0, il = mipmaps.length; i < il; i ++ ) {\n\n\t\t\t\t\tmipmap = mipmaps[ i ];\n\n\t\t\t\t\tif ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) {\n\n\t\t\t\t\t\tif ( state.getCompressedTextureFormats().indexOf( glFormat ) > - 1 ) {\n\n\t\t\t\t\t\t\tstate.compressedTexImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tstate.texImage2D( 3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t\t} else if ( texture.isDataTexture3D ) {\n\n\t\t\t\tstate.texImage3D( 32879, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );\n\t\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t\t} else {\n\n\t\t\t\t// regular Texture (image, video, canvas)\n\n\t\t\t\t// use manually created mipmaps if available\n\t\t\t\t// if there are no manual mipmaps\n\t\t\t\t// set 0 level mipmap and then use GL to generate other mipmap levels\n\n\t\t\t\tif ( mipmaps.length > 0 && isPowerOfTwoImage ) {\n\n\t\t\t\t\tfor ( var i = 0, il = mipmaps.length; i < il; i ++ ) {\n\n\t\t\t\t\t\tmipmap = mipmaps[ i ];\n\t\t\t\t\t\tstate.texImage2D( 3553, i, glInternalFormat, glFormat, glType, mipmap );\n\n\t\t\t\t\t}\n\n\t\t\t\t\ttexture.generateMipmaps = false;\n\t\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tstate.texImage2D( 3553, 0, glInternalFormat, glFormat, glType, image );\n\t\t\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( textureNeedsGenerateMipmaps( texture, isPowerOfTwoImage ) ) {\n\n\t\t\t\tgenerateMipmap( 3553, texture, image.width, image.height );\n\n\t\t\t}\n\n\t\t\ttextureProperties.__version = texture.version;\n\n\t\t\tif ( texture.onUpdate ) texture.onUpdate( texture );\n\n\t\t}\n\n\t\t// Render targets\n\n\t\t// Setup storage for target texture and bind it to correct framebuffer\n\t\tfunction setupFrameBufferTexture( framebuffer, renderTarget, attachment, textureTarget ) {\n\n\t\t\tvar glFormat = utils.convert( renderTarget.texture.format );\n\t\t\tvar glType = utils.convert( renderTarget.texture.type );\n\t\t\tvar glInternalFormat = getInternalFormat( glFormat, glType );\n\t\t\tstate.texImage2D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );\n\t\t\t_gl.bindFramebuffer( 36160, framebuffer );\n\t\t\t_gl.framebufferTexture2D( 36160, attachment, textureTarget, properties.get( renderTarget.texture ).__webglTexture, 0 );\n\t\t\t_gl.bindFramebuffer( 36160, null );\n\n\t\t}\n\n\t\t// Setup storage for internal depth/stencil buffers and bind to correct framebuffer\n\t\tfunction setupRenderBufferStorage( renderbuffer, renderTarget ) {\n\n\t\t\t_gl.bindRenderbuffer( 36161, renderbuffer );\n\n\t\t\tif ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {\n\n\t\t\t\t_gl.renderbufferStorage( 36161, 33189, renderTarget.width, renderTarget.height );\n\t\t\t\t_gl.framebufferRenderbuffer( 36160, 36096, 36161, renderbuffer );\n\n\t\t\t} else if ( renderTarget.depthBuffer && renderTarget.stencilBuffer ) {\n\n\t\t\t\t_gl.renderbufferStorage( 36161, 34041, renderTarget.width, renderTarget.height );\n\t\t\t\t_gl.framebufferRenderbuffer( 36160, 33306, 36161, renderbuffer );\n\n\t\t\t} else {\n\n\t\t\t\t// FIXME: We don't support !depth !stencil\n\t\t\t\t_gl.renderbufferStorage( 36161, 32854, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\t\t\t_gl.bindRenderbuffer( 36161, null );\n\n\t\t}\n\n\t\t// Setup resources for a Depth Texture for a FBO (needs an extension)\n\t\tfunction setupDepthTexture( framebuffer, renderTarget ) {\n\n\t\t\tvar isCube = ( renderTarget && renderTarget.isWebGLRenderTargetCube );\n\t\t\tif ( isCube ) throw new Error( 'Depth Texture with cube render targets is not supported' );\n\n\t\t\t_gl.bindFramebuffer( 36160, framebuffer );\n\n\t\t\tif ( ! ( renderTarget.depthTexture && renderTarget.depthTexture.isDepthTexture ) ) {\n\n\t\t\t\tthrow new Error( 'renderTarget.depthTexture must be an instance of THREE.DepthTexture' );\n\n\t\t\t}\n\n\t\t\t// upload an empty depth texture with framebuffer size\n\t\t\tif ( ! properties.get( renderTarget.depthTexture ).__webglTexture ||\n\t\t\t\t\trenderTarget.depthTexture.image.width !== renderTarget.width ||\n\t\t\t\t\trenderTarget.depthTexture.image.height !== renderTarget.height ) {\n\n\t\t\t\trenderTarget.depthTexture.image.width = renderTarget.width;\n\t\t\t\trenderTarget.depthTexture.image.height = renderTarget.height;\n\t\t\t\trenderTarget.depthTexture.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tsetTexture2D( renderTarget.depthTexture, 0 );\n\n\t\t\tvar webglDepthTexture = properties.get( renderTarget.depthTexture ).__webglTexture;\n\n\t\t\tif ( renderTarget.depthTexture.format === DepthFormat ) {\n\n\t\t\t\t_gl.framebufferTexture2D( 36160, 36096, 3553, webglDepthTexture, 0 );\n\n\t\t\t} else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {\n\n\t\t\t\t_gl.framebufferTexture2D( 36160, 33306, 3553, webglDepthTexture, 0 );\n\n\t\t\t} else {\n\n\t\t\t\tthrow new Error( 'Unknown depthTexture format' );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Setup GL resources for a non-texture depth buffer\n\t\tfunction setupDepthRenderbuffer( renderTarget ) {\n\n\t\t\tvar renderTargetProperties = properties.get( renderTarget );\n\n\t\t\tvar isCube = ( renderTarget.isWebGLRenderTargetCube === true );\n\n\t\t\tif ( renderTarget.depthTexture ) {\n\n\t\t\t\tif ( isCube ) throw new Error( 'target.depthTexture not supported in Cube render targets' );\n\n\t\t\t\tsetupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget );\n\n\t\t\t} else {\n\n\t\t\t\tif ( isCube ) {\n\n\t\t\t\t\trenderTargetProperties.__webglDepthbuffer = [];\n\n\t\t\t\t\tfor ( var i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\t\t_gl.bindFramebuffer( 36160, renderTargetProperties.__webglFramebuffer[ i ] );\n\t\t\t\t\t\trenderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer();\n\t\t\t\t\t\tsetupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\t_gl.bindFramebuffer( 36160, renderTargetProperties.__webglFramebuffer );\n\t\t\t\t\trenderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();\n\t\t\t\t\tsetupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t_gl.bindFramebuffer( 36160, null );\n\n\t\t}\n\n\t\t// Set up GL resources for the render target\n\t\tfunction setupRenderTarget( renderTarget ) {\n\n\t\t\tvar renderTargetProperties = properties.get( renderTarget );\n\t\t\tvar textureProperties = properties.get( renderTarget.texture );\n\n\t\t\trenderTarget.addEventListener( 'dispose', onRenderTargetDispose );\n\n\t\t\ttextureProperties.__webglTexture = _gl.createTexture();\n\n\t\t\tinfo.memory.textures ++;\n\n\t\t\tvar isCube = ( renderTarget.isWebGLRenderTargetCube === true );\n\t\t\tvar isTargetPowerOfTwo = isPowerOfTwo( renderTarget );\n\n\t\t\t// Setup framebuffer\n\n\t\t\tif ( isCube ) {\n\n\t\t\t\trenderTargetProperties.__webglFramebuffer = [];\n\n\t\t\t\tfor ( var i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\trenderTargetProperties.__webglFramebuffer[ i ] = _gl.createFramebuffer();\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\trenderTargetProperties.__webglFramebuffer = _gl.createFramebuffer();\n\n\t\t\t}\n\n\t\t\t// Setup color buffer\n\n\t\t\tif ( isCube ) {\n\n\t\t\t\tstate.bindTexture( 34067, textureProperties.__webglTexture );\n\t\t\t\tsetTextureParameters( 34067, renderTarget.texture, isTargetPowerOfTwo );\n\n\t\t\t\tfor ( var i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\tsetupFrameBufferTexture( renderTargetProperties.__webglFramebuffer[ i ], renderTarget, 36064, 34069 + i );\n\n\t\t\t\t}\n\n\t\t\t\tif ( textureNeedsGenerateMipmaps( renderTarget.texture, isTargetPowerOfTwo ) ) {\n\n\t\t\t\t\tgenerateMipmap( 34067, renderTarget.texture, renderTarget.width, renderTarget.height );\n\n\t\t\t\t}\n\n\t\t\t\tstate.bindTexture( 34067, null );\n\n\t\t\t} else {\n\n\t\t\t\tstate.bindTexture( 3553, textureProperties.__webglTexture );\n\t\t\t\tsetTextureParameters( 3553, renderTarget.texture, isTargetPowerOfTwo );\n\t\t\t\tsetupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, 36064, 3553 );\n\n\t\t\t\tif ( textureNeedsGenerateMipmaps( renderTarget.texture, isTargetPowerOfTwo ) ) {\n\n\t\t\t\t\tgenerateMipmap( 3553, renderTarget.texture, renderTarget.width, renderTarget.height );\n\n\t\t\t\t}\n\n\t\t\t\tstate.bindTexture( 3553, null );\n\n\t\t\t}\n\n\t\t\t// Setup depth and stencil buffers\n\n\t\t\tif ( renderTarget.depthBuffer ) {\n\n\t\t\t\tsetupDepthRenderbuffer( renderTarget );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction updateRenderTargetMipmap( renderTarget ) {\n\n\t\t\tvar texture = renderTarget.texture;\n\t\t\tvar isTargetPowerOfTwo = isPowerOfTwo( renderTarget );\n\n\t\t\tif ( textureNeedsGenerateMipmaps( texture, isTargetPowerOfTwo ) ) {\n\n\t\t\t\tvar target = renderTarget.isWebGLRenderTargetCube ? 34067 : 3553;\n\t\t\t\tvar webglTexture = properties.get( texture ).__webglTexture;\n\n\t\t\t\tstate.bindTexture( target, webglTexture );\n\t\t\t\tgenerateMipmap( target, texture, renderTarget.width, renderTarget.height );\n\t\t\t\tstate.bindTexture( target, null );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction updateVideoTexture( texture ) {\n\n\t\t\tvar id = texture.id;\n\t\t\tvar frame = info.render.frame;\n\n\t\t\t// Check the last frame we updated the VideoTexture\n\n\t\t\tif ( _videoTextures[ id ] !== frame ) {\n\n\t\t\t\t_videoTextures[ id ] = frame;\n\t\t\t\ttexture.update();\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.setTexture2D = setTexture2D;\n\t\tthis.setTexture3D = setTexture3D;\n\t\tthis.setTextureCube = setTextureCube;\n\t\tthis.setTextureCubeDynamic = setTextureCubeDynamic;\n\t\tthis.setupRenderTarget = setupRenderTarget;\n\t\tthis.updateRenderTargetMipmap = updateRenderTargetMipmap;\n\n\t}\n\n\t/**\n\t * @author thespite / http://www.twitter.com/thespite\n\t */\n\n\tfunction WebGLUtils( gl, extensions, capabilities ) {\n\n\t\tfunction convert( p ) {\n\n\t\t\tvar extension;\n\n\t\t\tif ( p === RepeatWrapping ) return 10497;\n\t\t\tif ( p === ClampToEdgeWrapping ) return 33071;\n\t\t\tif ( p === MirroredRepeatWrapping ) return 33648;\n\n\t\t\tif ( p === NearestFilter ) return 9728;\n\t\t\tif ( p === NearestMipMapNearestFilter ) return 9984;\n\t\t\tif ( p === NearestMipMapLinearFilter ) return 9986;\n\n\t\t\tif ( p === LinearFilter ) return 9729;\n\t\t\tif ( p === LinearMipMapNearestFilter ) return 9985;\n\t\t\tif ( p === LinearMipMapLinearFilter ) return 9987;\n\n\t\t\tif ( p === UnsignedByteType ) return 5121;\n\t\t\tif ( p === UnsignedShort4444Type ) return 32819;\n\t\t\tif ( p === UnsignedShort5551Type ) return 32820;\n\t\t\tif ( p === UnsignedShort565Type ) return 33635;\n\n\t\t\tif ( p === ByteType ) return 5120;\n\t\t\tif ( p === ShortType ) return 5122;\n\t\t\tif ( p === UnsignedShortType ) return 5123;\n\t\t\tif ( p === IntType ) return 5124;\n\t\t\tif ( p === UnsignedIntType ) return 5125;\n\t\t\tif ( p === FloatType ) return 5126;\n\n\t\t\tif ( p === HalfFloatType ) {\n\n\t\t\t\tif ( capabilities.isWebGL2 ) return 5131;\n\n\t\t\t\textension = extensions.get( 'OES_texture_half_float' );\n\n\t\t\t\tif ( extension !== null ) return extension.HALF_FLOAT_OES;\n\n\t\t\t}\n\n\t\t\tif ( p === AlphaFormat ) return 6406;\n\t\t\tif ( p === RGBFormat ) return 6407;\n\t\t\tif ( p === RGBAFormat ) return 6408;\n\t\t\tif ( p === LuminanceFormat ) return 6409;\n\t\t\tif ( p === LuminanceAlphaFormat ) return 6410;\n\t\t\tif ( p === DepthFormat ) return 6402;\n\t\t\tif ( p === DepthStencilFormat ) return 34041;\n\t\t\tif ( p === RedFormat ) return 6403;\n\n\t\t\tif ( p === AddEquation ) return 32774;\n\t\t\tif ( p === SubtractEquation ) return 32778;\n\t\t\tif ( p === ReverseSubtractEquation ) return 32779;\n\n\t\t\tif ( p === ZeroFactor ) return 0;\n\t\t\tif ( p === OneFactor ) return 1;\n\t\t\tif ( p === SrcColorFactor ) return 768;\n\t\t\tif ( p === OneMinusSrcColorFactor ) return 769;\n\t\t\tif ( p === SrcAlphaFactor ) return 770;\n\t\t\tif ( p === OneMinusSrcAlphaFactor ) return 771;\n\t\t\tif ( p === DstAlphaFactor ) return 772;\n\t\t\tif ( p === OneMinusDstAlphaFactor ) return 773;\n\n\t\t\tif ( p === DstColorFactor ) return 774;\n\t\t\tif ( p === OneMinusDstColorFactor ) return 775;\n\t\t\tif ( p === SrcAlphaSaturateFactor ) return 776;\n\n\t\t\tif ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format ||\n\t\t\t\tp === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {\n\n\t\t\t\textension = extensions.get( 'WEBGL_compressed_texture_s3tc' );\n\n\t\t\t\tif ( extension !== null ) {\n\n\t\t\t\t\tif ( p === RGB_S3TC_DXT1_Format ) return extension.COMPRESSED_RGB_S3TC_DXT1_EXT;\n\t\t\t\t\tif ( p === RGBA_S3TC_DXT1_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT;\n\t\t\t\t\tif ( p === RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT;\n\t\t\t\t\tif ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( p === RGB_PVRTC_4BPPV1_Format || p === RGB_PVRTC_2BPPV1_Format ||\n\t\t\t\tp === RGBA_PVRTC_4BPPV1_Format || p === RGBA_PVRTC_2BPPV1_Format ) {\n\n\t\t\t\textension = extensions.get( 'WEBGL_compressed_texture_pvrtc' );\n\n\t\t\t\tif ( extension !== null ) {\n\n\t\t\t\t\tif ( p === RGB_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;\n\t\t\t\t\tif ( p === RGB_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;\n\t\t\t\t\tif ( p === RGBA_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;\n\t\t\t\t\tif ( p === RGBA_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( p === RGB_ETC1_Format ) {\n\n\t\t\t\textension = extensions.get( 'WEBGL_compressed_texture_etc1' );\n\n\t\t\t\tif ( extension !== null ) return extension.COMPRESSED_RGB_ETC1_WEBGL;\n\n\t\t\t}\n\n\t\t\tif ( p === RGBA_ASTC_4x4_Format || p === RGBA_ASTC_5x4_Format || p === RGBA_ASTC_5x5_Format ||\n\t\t\t\tp === RGBA_ASTC_6x5_Format || p === RGBA_ASTC_6x6_Format || p === RGBA_ASTC_8x5_Format ||\n\t\t\t\tp === RGBA_ASTC_8x6_Format || p === RGBA_ASTC_8x8_Format || p === RGBA_ASTC_10x5_Format ||\n\t\t\t\tp === RGBA_ASTC_10x6_Format || p === RGBA_ASTC_10x8_Format || p === RGBA_ASTC_10x10_Format ||\n\t\t\t\tp === RGBA_ASTC_12x10_Format || p === RGBA_ASTC_12x12_Format ) {\n\n\t\t\t\textension = extensions.get( 'WEBGL_compressed_texture_astc' );\n\n\t\t\t\tif ( extension !== null ) {\n\n\t\t\t\t\treturn p;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( p === MinEquation || p === MaxEquation ) {\n\n\t\t\t\tif ( capabilities.isWebGL2 ) {\n\n\t\t\t\t\tif ( p === MinEquation ) return 32775;\n\t\t\t\t\tif ( p === MaxEquation ) return 32776;\n\n\t\t\t\t}\n\n\t\t\t\textension = extensions.get( 'EXT_blend_minmax' );\n\n\t\t\t\tif ( extension !== null ) {\n\n\t\t\t\t\tif ( p === MinEquation ) return extension.MIN_EXT;\n\t\t\t\t\tif ( p === MaxEquation ) return extension.MAX_EXT;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( p === UnsignedInt248Type ) {\n\n\t\t\t\tif ( capabilities.isWebGL2 ) return 34042;\n\n\t\t\t\textension = extensions.get( 'WEBGL_depth_texture' );\n\n\t\t\t\tif ( extension !== null ) return extension.UNSIGNED_INT_24_8_WEBGL;\n\n\t\t\t}\n\n\t\t\treturn 0;\n\n\t\t}\n\n\t\treturn { convert: convert };\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction Group() {\n\n\t\tObject3D.call( this );\n\n\t\tthis.type = 'Group';\n\n\t}\n\n\tGroup.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\t\tconstructor: Group,\n\n\t\tisGroup: true\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author mikael emtinger / http://gomo.se/\n\t * @author WestLangley / http://github.com/WestLangley\n\t*/\n\n\tfunction Camera() {\n\n\t\tObject3D.call( this );\n\n\t\tthis.type = 'Camera';\n\n\t\tthis.matrixWorldInverse = new Matrix4();\n\n\t\tthis.projectionMatrix = new Matrix4();\n\t\tthis.projectionMatrixInverse = new Matrix4();\n\n\t}\n\n\tCamera.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\t\tconstructor: Camera,\n\n\t\tisCamera: true,\n\n\t\tcopy: function ( source, recursive ) {\n\n\t\t\tObject3D.prototype.copy.call( this, source, recursive );\n\n\t\t\tthis.matrixWorldInverse.copy( source.matrixWorldInverse );\n\n\t\t\tthis.projectionMatrix.copy( source.projectionMatrix );\n\t\t\tthis.projectionMatrixInverse.copy( source.projectionMatrixInverse );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetWorldDirection: function ( target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Camera: .getWorldDirection() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\tthis.updateMatrixWorld( true );\n\n\t\t\tvar e = this.matrixWorld.elements;\n\n\t\t\treturn target.set( - e[ 8 ], - e[ 9 ], - e[ 10 ] ).normalize();\n\n\t\t},\n\n\t\tupdateMatrixWorld: function ( force ) {\n\n\t\t\tObject3D.prototype.updateMatrixWorld.call( this, force );\n\n\t\t\tthis.matrixWorldInverse.getInverse( this.matrixWorld );\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author greggman / http://games.greggman.com/\n\t * @author zz85 / http://www.lab4games.net/zz85/blog\n\t * @author tschw\n\t */\n\n\tfunction PerspectiveCamera( fov, aspect, near, far ) {\n\n\t\tCamera.call( this );\n\n\t\tthis.type = 'PerspectiveCamera';\n\n\t\tthis.fov = fov !== undefined ? fov : 50;\n\t\tthis.zoom = 1;\n\n\t\tthis.near = near !== undefined ? near : 0.1;\n\t\tthis.far = far !== undefined ? far : 2000;\n\t\tthis.focus = 10;\n\n\t\tthis.aspect = aspect !== undefined ? aspect : 1;\n\t\tthis.view = null;\n\n\t\tthis.filmGauge = 35;\t// width of the film (default in millimeters)\n\t\tthis.filmOffset = 0;\t// horizontal film offset (same unit as gauge)\n\n\t\tthis.updateProjectionMatrix();\n\n\t}\n\n\tPerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ), {\n\n\t\tconstructor: PerspectiveCamera,\n\n\t\tisPerspectiveCamera: true,\n\n\t\tcopy: function ( source, recursive ) {\n\n\t\t\tCamera.prototype.copy.call( this, source, recursive );\n\n\t\t\tthis.fov = source.fov;\n\t\t\tthis.zoom = source.zoom;\n\n\t\t\tthis.near = source.near;\n\t\t\tthis.far = source.far;\n\t\t\tthis.focus = source.focus;\n\n\t\t\tthis.aspect = source.aspect;\n\t\t\tthis.view = source.view === null ? null : Object.assign( {}, source.view );\n\n\t\t\tthis.filmGauge = source.filmGauge;\n\t\t\tthis.filmOffset = source.filmOffset;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\t/**\n\t\t * Sets the FOV by focal length in respect to the current .filmGauge.\n\t\t *\n\t\t * The default film gauge is 35, so that the focal length can be specified for\n\t\t * a 35mm (full frame) camera.\n\t\t *\n\t\t * Values for focal length and film gauge must have the same unit.\n\t\t */\n\t\tsetFocalLength: function ( focalLength ) {\n\n\t\t\t// see http://www.bobatkins.com/photography/technical/field_of_view.html\n\t\t\tvar vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;\n\n\t\t\tthis.fov = _Math.RAD2DEG * 2 * Math.atan( vExtentSlope );\n\t\t\tthis.updateProjectionMatrix();\n\n\t\t},\n\n\t\t/**\n\t\t * Calculates the focal length from the current .fov and .filmGauge.\n\t\t */\n\t\tgetFocalLength: function () {\n\n\t\t\tvar vExtentSlope = Math.tan( _Math.DEG2RAD * 0.5 * this.fov );\n\n\t\t\treturn 0.5 * this.getFilmHeight() / vExtentSlope;\n\n\t\t},\n\n\t\tgetEffectiveFOV: function () {\n\n\t\t\treturn _Math.RAD2DEG * 2 * Math.atan(\n\t\t\t\tMath.tan( _Math.DEG2RAD * 0.5 * this.fov ) / this.zoom );\n\n\t\t},\n\n\t\tgetFilmWidth: function () {\n\n\t\t\t// film not completely covered in portrait format (aspect < 1)\n\t\t\treturn this.filmGauge * Math.min( this.aspect, 1 );\n\n\t\t},\n\n\t\tgetFilmHeight: function () {\n\n\t\t\t// film not completely covered in landscape format (aspect > 1)\n\t\t\treturn this.filmGauge / Math.max( this.aspect, 1 );\n\n\t\t},\n\n\t\t/**\n\t\t * Sets an offset in a larger frustum. This is useful for multi-window or\n\t\t * multi-monitor/multi-machine setups.\n\t\t *\n\t\t * For example, if you have 3x2 monitors and each monitor is 1920x1080 and\n\t\t * the monitors are in grid like this\n\t\t *\n\t\t *   +---+---+---+\n\t\t *   | A | B | C |\n\t\t *   +---+---+---+\n\t\t *   | D | E | F |\n\t\t *   +---+---+---+\n\t\t *\n\t\t * then for each monitor you would call it like this\n\t\t *\n\t\t *   var w = 1920;\n\t\t *   var h = 1080;\n\t\t *   var fullWidth = w * 3;\n\t\t *   var fullHeight = h * 2;\n\t\t *\n\t\t *   --A--\n\t\t *   camera.setOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );\n\t\t *   --B--\n\t\t *   camera.setOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );\n\t\t *   --C--\n\t\t *   camera.setOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );\n\t\t *   --D--\n\t\t *   camera.setOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );\n\t\t *   --E--\n\t\t *   camera.setOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );\n\t\t *   --F--\n\t\t *   camera.setOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );\n\t\t *\n\t\t *   Note there is no reason monitors have to be the same size or in a grid.\n\t\t */\n\t\tsetViewOffset: function ( fullWidth, fullHeight, x, y, width, height ) {\n\n\t\t\tthis.aspect = fullWidth / fullHeight;\n\n\t\t\tif ( this.view === null ) {\n\n\t\t\t\tthis.view = {\n\t\t\t\t\tenabled: true,\n\t\t\t\t\tfullWidth: 1,\n\t\t\t\t\tfullHeight: 1,\n\t\t\t\t\toffsetX: 0,\n\t\t\t\t\toffsetY: 0,\n\t\t\t\t\twidth: 1,\n\t\t\t\t\theight: 1\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\tthis.view.enabled = true;\n\t\t\tthis.view.fullWidth = fullWidth;\n\t\t\tthis.view.fullHeight = fullHeight;\n\t\t\tthis.view.offsetX = x;\n\t\t\tthis.view.offsetY = y;\n\t\t\tthis.view.width = width;\n\t\t\tthis.view.height = height;\n\n\t\t\tthis.updateProjectionMatrix();\n\n\t\t},\n\n\t\tclearViewOffset: function () {\n\n\t\t\tif ( this.view !== null ) {\n\n\t\t\t\tthis.view.enabled = false;\n\n\t\t\t}\n\n\t\t\tthis.updateProjectionMatrix();\n\n\t\t},\n\n\t\tupdateProjectionMatrix: function () {\n\n\t\t\tvar near = this.near,\n\t\t\t\ttop = near * Math.tan( _Math.DEG2RAD * 0.5 * this.fov ) / this.zoom,\n\t\t\t\theight = 2 * top,\n\t\t\t\twidth = this.aspect * height,\n\t\t\t\tleft = - 0.5 * width,\n\t\t\t\tview = this.view;\n\n\t\t\tif ( this.view !== null && this.view.enabled ) {\n\n\t\t\t\tvar fullWidth = view.fullWidth,\n\t\t\t\t\tfullHeight = view.fullHeight;\n\n\t\t\t\tleft += view.offsetX * width / fullWidth;\n\t\t\t\ttop -= view.offsetY * height / fullHeight;\n\t\t\t\twidth *= view.width / fullWidth;\n\t\t\t\theight *= view.height / fullHeight;\n\n\t\t\t}\n\n\t\t\tvar skew = this.filmOffset;\n\t\t\tif ( skew !== 0 ) left += near * skew / this.getFilmWidth();\n\n\t\t\tthis.projectionMatrix.makePerspective( left, left + width, top, top - height, near, this.far );\n\n\t\t\tthis.projectionMatrixInverse.getInverse( this.projectionMatrix );\n\n\t\t},\n\n\t\ttoJSON: function ( meta ) {\n\n\t\t\tvar data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\t\tdata.object.fov = this.fov;\n\t\t\tdata.object.zoom = this.zoom;\n\n\t\t\tdata.object.near = this.near;\n\t\t\tdata.object.far = this.far;\n\t\t\tdata.object.focus = this.focus;\n\n\t\t\tdata.object.aspect = this.aspect;\n\n\t\t\tif ( this.view !== null ) data.object.view = Object.assign( {}, this.view );\n\n\t\t\tdata.object.filmGauge = this.filmGauge;\n\t\t\tdata.object.filmOffset = this.filmOffset;\n\n\t\t\treturn data;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction ArrayCamera( array ) {\n\n\t\tPerspectiveCamera.call( this );\n\n\t\tthis.cameras = array || [];\n\n\t}\n\n\tArrayCamera.prototype = Object.assign( Object.create( PerspectiveCamera.prototype ), {\n\n\t\tconstructor: ArrayCamera,\n\n\t\tisArrayCamera: true\n\n\t} );\n\n\t/**\n\t * @author jsantell / https://www.jsantell.com/\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tvar cameraLPos = new Vector3();\n\tvar cameraRPos = new Vector3();\n\n\t/**\n\t * Assumes 2 cameras that are parallel and share an X-axis, and that\n\t * the cameras' projection and world matrices have already been set.\n\t * And that near and far planes are identical for both cameras.\n\t * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765\n\t */\n\tfunction setProjectionFromUnion( camera, cameraL, cameraR ) {\n\n\t\tcameraLPos.setFromMatrixPosition( cameraL.matrixWorld );\n\t\tcameraRPos.setFromMatrixPosition( cameraR.matrixWorld );\n\n\t\tvar ipd = cameraLPos.distanceTo( cameraRPos );\n\n\t\tvar projL = cameraL.projectionMatrix.elements;\n\t\tvar projR = cameraR.projectionMatrix.elements;\n\n\t\t// VR systems will have identical far and near planes, and\n\t\t// most likely identical top and bottom frustum extents.\n\t\t// Use the left camera for these values.\n\t\tvar near = projL[ 14 ] / ( projL[ 10 ] - 1 );\n\t\tvar far = projL[ 14 ] / ( projL[ 10 ] + 1 );\n\t\tvar topFov = ( projL[ 9 ] + 1 ) / projL[ 5 ];\n\t\tvar bottomFov = ( projL[ 9 ] - 1 ) / projL[ 5 ];\n\n\t\tvar leftFov = ( projL[ 8 ] - 1 ) / projL[ 0 ];\n\t\tvar rightFov = ( projR[ 8 ] + 1 ) / projR[ 0 ];\n\t\tvar left = near * leftFov;\n\t\tvar right = near * rightFov;\n\n\t\t// Calculate the new camera's position offset from the\n\t\t// left camera. xOffset should be roughly half `ipd`.\n\t\tvar zOffset = ipd / ( - leftFov + rightFov );\n\t\tvar xOffset = zOffset * - leftFov;\n\n\t\t// TODO: Better way to apply this offset?\n\t\tcameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale );\n\t\tcamera.translateX( xOffset );\n\t\tcamera.translateZ( zOffset );\n\t\tcamera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );\n\t\tcamera.matrixWorldInverse.getInverse( camera.matrixWorld );\n\n\t\t// Find the union of the frustum values of the cameras and scale\n\t\t// the values so that the near plane's position does not change in world space,\n\t\t// although must now be relative to the new union camera.\n\t\tvar near2 = near + zOffset;\n\t\tvar far2 = far + zOffset;\n\t\tvar left2 = left - xOffset;\n\t\tvar right2 = right + ( ipd - xOffset );\n\t\tvar top2 = topFov * far / far2 * near2;\n\t\tvar bottom2 = bottomFov * far / far2 * near2;\n\n\t\tcamera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction WebVRManager( renderer ) {\n\n\t\tvar scope = this;\n\n\t\tvar device = null;\n\t\tvar frameData = null;\n\n\t\tvar poseTarget = null;\n\n\t\tvar controllers = [];\n\t\tvar standingMatrix = new Matrix4();\n\t\tvar standingMatrixInverse = new Matrix4();\n\n\t\tvar framebufferScaleFactor = 1.0;\n\n\t\tvar frameOfReferenceType = 'stage';\n\n\t\tif ( typeof window !== 'undefined' && 'VRFrameData' in window ) {\n\n\t\t\tframeData = new window.VRFrameData();\n\t\t\twindow.addEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange, false );\n\n\t\t}\n\n\t\tvar matrixWorldInverse = new Matrix4();\n\t\tvar tempQuaternion = new Quaternion();\n\t\tvar tempPosition = new Vector3();\n\n\t\tvar cameraL = new PerspectiveCamera();\n\t\tcameraL.bounds = new Vector4( 0.0, 0.0, 0.5, 1.0 );\n\t\tcameraL.layers.enable( 1 );\n\n\t\tvar cameraR = new PerspectiveCamera();\n\t\tcameraR.bounds = new Vector4( 0.5, 0.0, 0.5, 1.0 );\n\t\tcameraR.layers.enable( 2 );\n\n\t\tvar cameraVR = new ArrayCamera( [ cameraL, cameraR ] );\n\t\tcameraVR.layers.enable( 1 );\n\t\tcameraVR.layers.enable( 2 );\n\n\t\t//\n\n\t\tfunction isPresenting() {\n\n\t\t\treturn device !== null && device.isPresenting === true;\n\n\t\t}\n\n\t\tvar currentSize, currentPixelRatio;\n\n\t\tfunction onVRDisplayPresentChange() {\n\n\t\t\tif ( isPresenting() ) {\n\n\t\t\t\tvar eyeParameters = device.getEyeParameters( 'left' );\n\t\t\t\tvar renderWidth = eyeParameters.renderWidth * framebufferScaleFactor;\n\t\t\t\tvar renderHeight = eyeParameters.renderHeight * framebufferScaleFactor;\n\n\t\t\t\tcurrentPixelRatio = renderer.getPixelRatio();\n\t\t\t\tcurrentSize = renderer.getSize();\n\n\t\t\t\trenderer.setDrawingBufferSize( renderWidth * 2, renderHeight, 1 );\n\n\t\t\t\tanimation.start();\n\n\t\t\t} else {\n\n\t\t\t\tif ( scope.enabled ) {\n\n\t\t\t\t\trenderer.setDrawingBufferSize( currentSize.width, currentSize.height, currentPixelRatio );\n\n\t\t\t\t}\n\n\t\t\t\tanimation.stop();\n\n\t\t\t}\n\n\t\t}\n\n\t\t//\n\n\t\tvar triggers = [];\n\n\t\tfunction findGamepad( id ) {\n\n\t\t\tvar gamepads = navigator.getGamepads && navigator.getGamepads();\n\n\t\t\tfor ( var i = 0, j = 0, l = gamepads.length; i < l; i ++ ) {\n\n\t\t\t\tvar gamepad = gamepads[ i ];\n\n\t\t\t\tif ( gamepad && ( gamepad.id === 'Daydream Controller' ||\n\t\t\t\t\tgamepad.id === 'Gear VR Controller' || gamepad.id === 'Oculus Go Controller' ||\n\t\t\t\t\tgamepad.id === 'OpenVR Gamepad' || gamepad.id.startsWith( 'Oculus Touch' ) ||\n\t\t\t\t\tgamepad.id.startsWith( 'Spatial Controller' ) ) ) {\n\n\t\t\t\t\tif ( j === id ) return gamepad;\n\n\t\t\t\t\tj ++;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction updateControllers() {\n\n\t\t\tfor ( var i = 0; i < controllers.length; i ++ ) {\n\n\t\t\t\tvar controller = controllers[ i ];\n\n\t\t\t\tvar gamepad = findGamepad( i );\n\n\t\t\t\tif ( gamepad !== undefined && gamepad.pose !== undefined ) {\n\n\t\t\t\t\tif ( gamepad.pose === null ) return;\n\n\t\t\t\t\t//  Pose\n\n\t\t\t\t\tvar pose = gamepad.pose;\n\n\t\t\t\t\tif ( pose.hasPosition === false ) controller.position.set( 0.2, - 0.6, - 0.05 );\n\n\t\t\t\t\tif ( pose.position !== null ) controller.position.fromArray( pose.position );\n\t\t\t\t\tif ( pose.orientation !== null ) controller.quaternion.fromArray( pose.orientation );\n\t\t\t\t\tcontroller.matrix.compose( controller.position, controller.quaternion, controller.scale );\n\t\t\t\t\tcontroller.matrix.premultiply( standingMatrix );\n\t\t\t\t\tcontroller.matrix.decompose( controller.position, controller.quaternion, controller.scale );\n\t\t\t\t\tcontroller.matrixWorldNeedsUpdate = true;\n\t\t\t\t\tcontroller.visible = true;\n\n\t\t\t\t\t//  Trigger\n\n\t\t\t\t\tvar buttonId = gamepad.id === 'Daydream Controller' ? 0 : 1;\n\n\t\t\t\t\tif ( triggers[ i ] !== gamepad.buttons[ buttonId ].pressed ) {\n\n\t\t\t\t\t\ttriggers[ i ] = gamepad.buttons[ buttonId ].pressed;\n\n\t\t\t\t\t\tif ( triggers[ i ] === true ) {\n\n\t\t\t\t\t\t\tcontroller.dispatchEvent( { type: 'selectstart' } );\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tcontroller.dispatchEvent( { type: 'selectend' } );\n\t\t\t\t\t\t\tcontroller.dispatchEvent( { type: 'select' } );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tcontroller.visible = false;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t//\n\n\t\tthis.enabled = false;\n\n\t\tthis.getController = function ( id ) {\n\n\t\t\tvar controller = controllers[ id ];\n\n\t\t\tif ( controller === undefined ) {\n\n\t\t\t\tcontroller = new Group();\n\t\t\t\tcontroller.matrixAutoUpdate = false;\n\t\t\t\tcontroller.visible = false;\n\n\t\t\t\tcontrollers[ id ] = controller;\n\n\t\t\t}\n\n\t\t\treturn controller;\n\n\t\t};\n\n\t\tthis.getDevice = function () {\n\n\t\t\treturn device;\n\n\t\t};\n\n\t\tthis.setDevice = function ( value ) {\n\n\t\t\tif ( value !== undefined ) device = value;\n\n\t\t\tanimation.setContext( value );\n\n\t\t};\n\n\t\tthis.setFramebufferScaleFactor = function ( value ) {\n\n\t\t\tframebufferScaleFactor = value;\n\n\t\t};\n\n\t\tthis.setFrameOfReferenceType = function ( value ) {\n\n\t\t\tframeOfReferenceType = value;\n\n\t\t};\n\n\t\tthis.setPoseTarget = function ( object ) {\n\n\t\t\tif ( object !== undefined ) poseTarget = object;\n\n\t\t};\n\n\t\tthis.getCamera = function ( camera ) {\n\n\t\t\tvar userHeight = frameOfReferenceType === 'stage' ? 1.6 : 0;\n\n\t\t\tif ( device === null ) {\n\n\t\t\t\tcamera.position.set( 0, userHeight, 0 );\n\t\t\t\treturn camera;\n\n\t\t\t}\n\n\t\t\tdevice.depthNear = camera.near;\n\t\t\tdevice.depthFar = camera.far;\n\n\t\t\tdevice.getFrameData( frameData );\n\n\t\t\t//\n\n\t\t\tif ( frameOfReferenceType === 'stage' ) {\n\n\t\t\t\tvar stageParameters = device.stageParameters;\n\n\t\t\t\tif ( stageParameters ) {\n\n\t\t\t\t\tstandingMatrix.fromArray( stageParameters.sittingToStandingTransform );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tstandingMatrix.makeTranslation( 0, userHeight, 0 );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\n\t\t\tvar pose = frameData.pose;\n\t\t\tvar poseObject = poseTarget !== null ? poseTarget : camera;\n\n\t\t\t// We want to manipulate poseObject by its position and quaternion components since users may rely on them.\n\t\t\tposeObject.matrix.copy( standingMatrix );\n\t\t\tposeObject.matrix.decompose( poseObject.position, poseObject.quaternion, poseObject.scale );\n\n\t\t\tif ( pose.orientation !== null ) {\n\n\t\t\t\ttempQuaternion.fromArray( pose.orientation );\n\t\t\t\tposeObject.quaternion.multiply( tempQuaternion );\n\n\t\t\t}\n\n\t\t\tif ( pose.position !== null ) {\n\n\t\t\t\ttempQuaternion.setFromRotationMatrix( standingMatrix );\n\t\t\t\ttempPosition.fromArray( pose.position );\n\t\t\t\ttempPosition.applyQuaternion( tempQuaternion );\n\t\t\t\tposeObject.position.add( tempPosition );\n\n\t\t\t}\n\n\t\t\tposeObject.updateMatrixWorld();\n\n\t\t\tif ( device.isPresenting === false ) return camera;\n\n\t\t\t//\n\n\t\t\tcameraL.near = camera.near;\n\t\t\tcameraR.near = camera.near;\n\n\t\t\tcameraL.far = camera.far;\n\t\t\tcameraR.far = camera.far;\n\n\t\t\tcameraL.matrixWorldInverse.fromArray( frameData.leftViewMatrix );\n\t\t\tcameraR.matrixWorldInverse.fromArray( frameData.rightViewMatrix );\n\n\t\t\t// TODO (mrdoob) Double check this code\n\n\t\t\tstandingMatrixInverse.getInverse( standingMatrix );\n\n\t\t\tif ( frameOfReferenceType === 'stage' ) {\n\n\t\t\t\tcameraL.matrixWorldInverse.multiply( standingMatrixInverse );\n\t\t\t\tcameraR.matrixWorldInverse.multiply( standingMatrixInverse );\n\n\t\t\t}\n\n\t\t\tvar parent = poseObject.parent;\n\n\t\t\tif ( parent !== null ) {\n\n\t\t\t\tmatrixWorldInverse.getInverse( parent.matrixWorld );\n\n\t\t\t\tcameraL.matrixWorldInverse.multiply( matrixWorldInverse );\n\t\t\t\tcameraR.matrixWorldInverse.multiply( matrixWorldInverse );\n\n\t\t\t}\n\n\t\t\t// envMap and Mirror needs camera.matrixWorld\n\n\t\t\tcameraL.matrixWorld.getInverse( cameraL.matrixWorldInverse );\n\t\t\tcameraR.matrixWorld.getInverse( cameraR.matrixWorldInverse );\n\n\t\t\tcameraL.projectionMatrix.fromArray( frameData.leftProjectionMatrix );\n\t\t\tcameraR.projectionMatrix.fromArray( frameData.rightProjectionMatrix );\n\n\t\t\tsetProjectionFromUnion( cameraVR, cameraL, cameraR );\n\n\t\t\t//\n\n\t\t\tvar layers = device.getLayers();\n\n\t\t\tif ( layers.length ) {\n\n\t\t\t\tvar layer = layers[ 0 ];\n\n\t\t\t\tif ( layer.leftBounds !== null && layer.leftBounds.length === 4 ) {\n\n\t\t\t\t\tcameraL.bounds.fromArray( layer.leftBounds );\n\n\t\t\t\t}\n\n\t\t\t\tif ( layer.rightBounds !== null && layer.rightBounds.length === 4 ) {\n\n\t\t\t\t\tcameraR.bounds.fromArray( layer.rightBounds );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tupdateControllers();\n\n\t\t\treturn cameraVR;\n\n\t\t};\n\n\t\tthis.getStandingMatrix = function () {\n\n\t\t\treturn standingMatrix;\n\n\t\t};\n\n\t\tthis.isPresenting = isPresenting;\n\n\t\t// Animation Loop\n\n\t\tvar animation = new WebGLAnimation();\n\n\t\tthis.setAnimationLoop = function ( callback ) {\n\n\t\t\tanimation.setAnimationLoop( callback );\n\n\t\t};\n\n\t\tthis.submitFrame = function () {\n\n\t\t\tif ( isPresenting() ) device.submitFrame();\n\n\t\t};\n\n\t\tthis.dispose = function () {\n\n\t\t\tif ( typeof window !== 'undefined' ) {\n\n\t\t\t\twindow.removeEventListener( 'vrdisplaypresentchange', onVRDisplayPresentChange );\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction WebXRManager( renderer ) {\n\n\t\tvar gl = renderer.context;\n\n\t\tvar device = null;\n\t\tvar session = null;\n\n\t\tvar framebufferScaleFactor = 1.0;\n\n\t\tvar frameOfReference = null;\n\t\tvar frameOfReferenceType = 'stage';\n\n\t\tvar pose = null;\n\n\t\tvar controllers = [];\n\t\tvar inputSources = [];\n\n\t\tfunction isPresenting() {\n\n\t\t\treturn session !== null && frameOfReference !== null;\n\n\t\t}\n\n\t\t//\n\n\t\tvar cameraL = new PerspectiveCamera();\n\t\tcameraL.layers.enable( 1 );\n\t\tcameraL.viewport = new Vector4();\n\n\t\tvar cameraR = new PerspectiveCamera();\n\t\tcameraR.layers.enable( 2 );\n\t\tcameraR.viewport = new Vector4();\n\n\t\tvar cameraVR = new ArrayCamera( [ cameraL, cameraR ] );\n\t\tcameraVR.layers.enable( 1 );\n\t\tcameraVR.layers.enable( 2 );\n\n\t\t//\n\n\t\tthis.enabled = false;\n\n\t\tthis.getController = function ( id ) {\n\n\t\t\tvar controller = controllers[ id ];\n\n\t\t\tif ( controller === undefined ) {\n\n\t\t\t\tcontroller = new Group();\n\t\t\t\tcontroller.matrixAutoUpdate = false;\n\t\t\t\tcontroller.visible = false;\n\n\t\t\t\tcontrollers[ id ] = controller;\n\n\t\t\t}\n\n\t\t\treturn controller;\n\n\t\t};\n\n\t\tthis.getDevice = function () {\n\n\t\t\treturn device;\n\n\t\t};\n\n\t\tthis.setDevice = function ( value ) {\n\n\t\t\tif ( value !== undefined ) device = value;\n\t\t\tif ( value instanceof XRDevice ) gl.setCompatibleXRDevice( value );\n\n\t\t};\n\n\t\t//\n\n\t\tfunction onSessionEvent( event ) {\n\n\t\t\tvar controller = controllers[ inputSources.indexOf( event.inputSource ) ];\n\t\t\tif ( controller ) controller.dispatchEvent( { type: event.type } );\n\n\t\t}\n\n\t\tfunction onSessionEnd() {\n\n\t\t\trenderer.setFramebuffer( null );\n\t\t\tanimation.stop();\n\n\t\t}\n\n\t\tthis.setFramebufferScaleFactor = function ( value ) {\n\n\t\t\tframebufferScaleFactor = value;\n\n\t\t};\n\n\t\tthis.setFrameOfReferenceType = function ( value ) {\n\n\t\t\tframeOfReferenceType = value;\n\n\t\t};\n\n\t\tthis.setSession = function ( value ) {\n\n\t\t\tsession = value;\n\n\t\t\tif ( session !== null ) {\n\n\t\t\t\tsession.addEventListener( 'select', onSessionEvent );\n\t\t\t\tsession.addEventListener( 'selectstart', onSessionEvent );\n\t\t\t\tsession.addEventListener( 'selectend', onSessionEvent );\n\t\t\t\tsession.addEventListener( 'end', onSessionEnd );\n\n\t\t\t\tsession.baseLayer = new XRWebGLLayer( session, gl, { framebufferScaleFactor: framebufferScaleFactor } );\n\t\t\t\tsession.requestFrameOfReference( frameOfReferenceType ).then( function ( value ) {\n\n\t\t\t\t\tframeOfReference = value;\n\n\t\t\t\t\trenderer.setFramebuffer( session.baseLayer.framebuffer );\n\n\t\t\t\t\tanimation.setContext( session );\n\t\t\t\t\tanimation.start();\n\n\t\t\t\t} );\n\n\t\t\t\t//\n\n\t\t\t\tinputSources = session.getInputSources();\n\n\t\t\t\tsession.addEventListener( 'inputsourceschange', function () {\n\n\t\t\t\t\tinputSources = session.getInputSources();\n\t\t\t\t\tconsole.log( inputSources );\n\n\t\t\t\t\tfor ( var i = 0; i < controllers.length; i ++ ) {\n\n\t\t\t\t\t\tvar controller = controllers[ i ];\n\t\t\t\t\t\tcontroller.userData.inputSource = inputSources[ i ];\n\n\t\t\t\t\t}\n\n\t\t\t\t} );\n\n\t\t\t}\n\n\t\t};\n\n\t\tfunction updateCamera( camera, parent ) {\n\n\t\t\tif ( parent === null ) {\n\n\t\t\t\tcamera.matrixWorld.copy( camera.matrix );\n\n\t\t\t} else {\n\n\t\t\t\tcamera.matrixWorld.multiplyMatrices( parent.matrixWorld, camera.matrix );\n\n\t\t\t}\n\n\t\t\tcamera.matrixWorldInverse.getInverse( camera.matrixWorld );\n\n\t\t}\n\n\t\tthis.getCamera = function ( camera ) {\n\n\t\t\tif ( isPresenting() ) {\n\n\t\t\t\tvar parent = camera.parent;\n\t\t\t\tvar cameras = cameraVR.cameras;\n\n\t\t\t\tupdateCamera( cameraVR, parent );\n\n\t\t\t\tfor ( var i = 0; i < cameras.length; i ++ ) {\n\n\t\t\t\t\tupdateCamera( cameras[ i ], parent );\n\n\t\t\t\t}\n\n\t\t\t\t// update camera and its children\n\n\t\t\t\tcamera.matrixWorld.copy( cameraVR.matrixWorld );\n\n\t\t\t\tvar children = camera.children;\n\n\t\t\t\tfor ( var i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\t\t\tchildren[ i ].updateMatrixWorld( true );\n\n\t\t\t\t}\n\n\t\t\t\tsetProjectionFromUnion( cameraVR, cameraL, cameraR );\n\n\t\t\t\treturn cameraVR;\n\n\t\t\t}\n\n\t\t\treturn camera;\n\n\t\t};\n\n\t\tthis.isPresenting = isPresenting;\n\n\t\t// Animation Loop\n\n\t\tvar onAnimationFrameCallback = null;\n\n\t\tfunction onAnimationFrame( time, frame ) {\n\n\t\t\tpose = frame.getDevicePose( frameOfReference );\n\n\t\t\tif ( pose !== null ) {\n\n\t\t\t\tvar layer = session.baseLayer;\n\t\t\t\tvar views = frame.views;\n\n\t\t\t\tfor ( var i = 0; i < views.length; i ++ ) {\n\n\t\t\t\t\tvar view = views[ i ];\n\t\t\t\t\tvar viewport = layer.getViewport( view );\n\t\t\t\t\tvar viewMatrix = pose.getViewMatrix( view );\n\n\t\t\t\t\tvar camera = cameraVR.cameras[ i ];\n\t\t\t\t\tcamera.matrix.fromArray( viewMatrix ).getInverse( camera.matrix );\n\t\t\t\t\tcamera.projectionMatrix.fromArray( view.projectionMatrix );\n\t\t\t\t\tcamera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );\n\n\t\t\t\t\tif ( i === 0 ) {\n\n\t\t\t\t\t\tcameraVR.matrix.copy( camera.matrix );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t//\n\n\t\t\tfor ( var i = 0; i < controllers.length; i ++ ) {\n\n\t\t\t\tvar controller = controllers[ i ];\n\n\t\t\t\tvar inputSource = inputSources[ i ];\n\n\t\t\t\tif ( inputSource ) {\n\n\t\t\t\t\tvar inputPose = frame.getInputPose( inputSource, frameOfReference );\n\n\t\t\t\t\tif ( inputPose !== null ) {\n\n\t\t\t\t\t\tif ( 'targetRay' in inputPose ) {\n\n\t\t\t\t\t\t\tcontroller.matrix.elements = inputPose.targetRay.transformMatrix;\n\n\t\t\t\t\t\t} else if ( 'pointerMatrix' in inputPose ) {\n\n\t\t\t\t\t\t\t// DEPRECATED\n\n\t\t\t\t\t\t\tcontroller.matrix.elements = inputPose.pointerMatrix;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontroller.matrix.decompose( controller.position, controller.rotation, controller.scale );\n\t\t\t\t\t\tcontroller.visible = true;\n\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tcontroller.visible = false;\n\n\t\t\t}\n\n\t\t\tif ( onAnimationFrameCallback ) onAnimationFrameCallback( time );\n\n\t\t}\n\n\t\tvar animation = new WebGLAnimation();\n\t\tanimation.setAnimationLoop( onAnimationFrame );\n\n\t\tthis.setAnimationLoop = function ( callback ) {\n\n\t\t\tonAnimationFrameCallback = callback;\n\n\t\t};\n\n\t\tthis.dispose = function () {};\n\n\t\t// DEPRECATED\n\n\t\tthis.getStandingMatrix = function () {\n\n\t\t\tconsole.warn( 'THREE.WebXRManager: getStandingMatrix() is no longer needed.' );\n\t\t\treturn new THREE.Matrix4();\n\n\t\t};\n\n\t\tthis.submitFrame = function () {};\n\n\t}\n\n\t/**\n\t * @author supereggbert / http://www.paulbrunt.co.uk/\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author szimek / https://github.com/szimek/\n\t * @author tschw\n\t */\n\n\tfunction WebGLRenderer( parameters ) {\n\n\t\tconsole.log( 'THREE.WebGLRenderer', REVISION );\n\n\t\tparameters = parameters || {};\n\n\t\tvar _canvas = parameters.canvas !== undefined ? parameters.canvas : document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ),\n\t\t\t_context = parameters.context !== undefined ? parameters.context : null,\n\n\t\t\t_alpha = parameters.alpha !== undefined ? parameters.alpha : false,\n\t\t\t_depth = parameters.depth !== undefined ? parameters.depth : true,\n\t\t\t_stencil = parameters.stencil !== undefined ? parameters.stencil : true,\n\t\t\t_antialias = parameters.antialias !== undefined ? parameters.antialias : false,\n\t\t\t_premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true,\n\t\t\t_preserveDrawingBuffer = parameters.preserveDrawingBuffer !== undefined ? parameters.preserveDrawingBuffer : false,\n\t\t\t_powerPreference = parameters.powerPreference !== undefined ? parameters.powerPreference : 'default';\n\n\t\tvar currentRenderList = null;\n\t\tvar currentRenderState = null;\n\n\t\t// public properties\n\n\t\tthis.domElement = _canvas;\n\t\tthis.context = null;\n\n\t\t// clearing\n\n\t\tthis.autoClear = true;\n\t\tthis.autoClearColor = true;\n\t\tthis.autoClearDepth = true;\n\t\tthis.autoClearStencil = true;\n\n\t\t// scene graph\n\n\t\tthis.sortObjects = true;\n\n\t\t// user-defined clipping\n\n\t\tthis.clippingPlanes = [];\n\t\tthis.localClippingEnabled = false;\n\n\t\t// physically based shading\n\n\t\tthis.gammaFactor = 2.0;\t// for backwards compatibility\n\t\tthis.gammaInput = false;\n\t\tthis.gammaOutput = false;\n\n\t\t// physical lights\n\n\t\tthis.physicallyCorrectLights = false;\n\n\t\t// tone mapping\n\n\t\tthis.toneMapping = LinearToneMapping;\n\t\tthis.toneMappingExposure = 1.0;\n\t\tthis.toneMappingWhitePoint = 1.0;\n\n\t\t// morphs\n\n\t\tthis.maxMorphTargets = 8;\n\t\tthis.maxMorphNormals = 4;\n\n\t\t// internal properties\n\n\t\tvar _this = this,\n\n\t\t\t_isContextLost = false,\n\n\t\t\t// internal state cache\n\n\t\t\t_framebuffer = null,\n\n\t\t\t_currentRenderTarget = null,\n\t\t\t_currentFramebuffer = null,\n\t\t\t_currentMaterialId = - 1,\n\n\t\t\t// geometry and program caching\n\n\t\t\t_currentGeometryProgram = {\n\t\t\t\tgeometry: null,\n\t\t\t\tprogram: null,\n\t\t\t\twireframe: false\n\t\t\t},\n\n\t\t\t_currentCamera = null,\n\t\t\t_currentArrayCamera = null,\n\n\t\t\t_currentViewport = new Vector4(),\n\t\t\t_currentScissor = new Vector4(),\n\t\t\t_currentScissorTest = null,\n\n\t\t\t//\n\n\t\t\t_usedTextureUnits = 0,\n\n\t\t\t//\n\n\t\t\t_width = _canvas.width,\n\t\t\t_height = _canvas.height,\n\n\t\t\t_pixelRatio = 1,\n\n\t\t\t_viewport = new Vector4( 0, 0, _width, _height ),\n\t\t\t_scissor = new Vector4( 0, 0, _width, _height ),\n\t\t\t_scissorTest = false,\n\n\t\t\t// frustum\n\n\t\t\t_frustum = new Frustum(),\n\n\t\t\t// clipping\n\n\t\t\t_clipping = new WebGLClipping(),\n\t\t\t_clippingEnabled = false,\n\t\t\t_localClippingEnabled = false,\n\n\t\t\t// camera matrices cache\n\n\t\t\t_projScreenMatrix = new Matrix4(),\n\n\t\t\t_vector3 = new Vector3();\n\n\t\tfunction getTargetPixelRatio() {\n\n\t\t\treturn _currentRenderTarget === null ? _pixelRatio : 1;\n\n\t\t}\n\n\t\t// initialize\n\n\t\tvar _gl;\n\n\t\ttry {\n\n\t\t\tvar contextAttributes = {\n\t\t\t\talpha: _alpha,\n\t\t\t\tdepth: _depth,\n\t\t\t\tstencil: _stencil,\n\t\t\t\tantialias: _antialias,\n\t\t\t\tpremultipliedAlpha: _premultipliedAlpha,\n\t\t\t\tpreserveDrawingBuffer: _preserveDrawingBuffer,\n\t\t\t\tpowerPreference: _powerPreference\n\t\t\t};\n\n\t\t\t// event listeners must be registered before WebGL context is created, see #12753\n\n\t\t\t_canvas.addEventListener( 'webglcontextlost', onContextLost, false );\n\t\t\t_canvas.addEventListener( 'webglcontextrestored', onContextRestore, false );\n\n\t\t\t_gl = _context || _canvas.getContext( 'webgl', contextAttributes ) || _canvas.getContext( 'experimental-webgl', contextAttributes );\n\n\t\t\tif ( _gl === null ) {\n\n\t\t\t\tif ( _canvas.getContext( 'webgl' ) !== null ) {\n\n\t\t\t\t\tthrow new Error( 'Error creating WebGL context with your selected attributes.' );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthrow new Error( 'Error creating WebGL context.' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// Some experimental-webgl implementations do not have getShaderPrecisionFormat\n\n\t\t\tif ( _gl.getShaderPrecisionFormat === undefined ) {\n\n\t\t\t\t_gl.getShaderPrecisionFormat = function () {\n\n\t\t\t\t\treturn { 'rangeMin': 1, 'rangeMax': 1, 'precision': 1 };\n\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t} catch ( error ) {\n\n\t\t\tconsole.error( 'THREE.WebGLRenderer: ' + error.message );\n\n\t\t}\n\n\t\tvar extensions, capabilities, state, info;\n\t\tvar properties, textures, attributes, geometries, objects;\n\t\tvar programCache, renderLists, renderStates;\n\n\t\tvar background, morphtargets, bufferRenderer, indexedBufferRenderer;\n\n\t\tvar utils;\n\n\t\tfunction initGLContext() {\n\n\t\t\textensions = new WebGLExtensions( _gl );\n\n\t\t\tcapabilities = new WebGLCapabilities( _gl, extensions, parameters );\n\n\t\t\tif ( ! capabilities.isWebGL2 ) {\n\n\t\t\t\textensions.get( 'WEBGL_depth_texture' );\n\t\t\t\textensions.get( 'OES_texture_float' );\n\t\t\t\textensions.get( 'OES_texture_half_float' );\n\t\t\t\textensions.get( 'OES_texture_half_float_linear' );\n\t\t\t\textensions.get( 'OES_standard_derivatives' );\n\t\t\t\textensions.get( 'OES_element_index_uint' );\n\t\t\t\textensions.get( 'ANGLE_instanced_arrays' );\n\n\t\t\t}\n\n\t\t\textensions.get( 'OES_texture_float_linear' );\n\n\t\t\tutils = new WebGLUtils( _gl, extensions, capabilities );\n\n\t\t\tstate = new WebGLState( _gl, extensions, utils, capabilities );\n\t\t\tstate.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ) );\n\t\t\tstate.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ) );\n\n\t\t\tinfo = new WebGLInfo( _gl );\n\t\t\tproperties = new WebGLProperties();\n\t\t\ttextures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );\n\t\t\tattributes = new WebGLAttributes( _gl );\n\t\t\tgeometries = new WebGLGeometries( _gl, attributes, info );\n\t\t\tobjects = new WebGLObjects( geometries, info );\n\t\t\tmorphtargets = new WebGLMorphtargets( _gl );\n\t\t\tprogramCache = new WebGLPrograms( _this, extensions, capabilities );\n\t\t\trenderLists = new WebGLRenderLists();\n\t\t\trenderStates = new WebGLRenderStates();\n\n\t\t\tbackground = new WebGLBackground( _this, state, objects, _premultipliedAlpha );\n\n\t\t\tbufferRenderer = new WebGLBufferRenderer( _gl, extensions, info, capabilities );\n\t\t\tindexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info, capabilities );\n\n\t\t\tinfo.programs = programCache.programs;\n\n\t\t\t_this.context = _gl;\n\t\t\t_this.capabilities = capabilities;\n\t\t\t_this.extensions = extensions;\n\t\t\t_this.properties = properties;\n\t\t\t_this.renderLists = renderLists;\n\t\t\t_this.state = state;\n\t\t\t_this.info = info;\n\n\t\t}\n\n\t\tinitGLContext();\n\n\t\t// vr\n\n\t\tvar vr = null;\n\n\t\tif ( typeof navigator !== 'undefined' ) {\n\n\t\t\tvr = ( 'xr' in navigator ) ? new WebXRManager( _this ) : new WebVRManager( _this );\n\n\t\t}\n\n\t\tthis.vr = vr;\n\n\t\t// shadow map\n\n\t\tvar shadowMap = new WebGLShadowMap( _this, objects, capabilities.maxTextureSize );\n\n\t\tthis.shadowMap = shadowMap;\n\n\t\t// API\n\n\t\tthis.getContext = function () {\n\n\t\t\treturn _gl;\n\n\t\t};\n\n\t\tthis.getContextAttributes = function () {\n\n\t\t\treturn _gl.getContextAttributes();\n\n\t\t};\n\n\t\tthis.forceContextLoss = function () {\n\n\t\t\tvar extension = extensions.get( 'WEBGL_lose_context' );\n\t\t\tif ( extension ) extension.loseContext();\n\n\t\t};\n\n\t\tthis.forceContextRestore = function () {\n\n\t\t\tvar extension = extensions.get( 'WEBGL_lose_context' );\n\t\t\tif ( extension ) extension.restoreContext();\n\n\t\t};\n\n\t\tthis.getPixelRatio = function () {\n\n\t\t\treturn _pixelRatio;\n\n\t\t};\n\n\t\tthis.setPixelRatio = function ( value ) {\n\n\t\t\tif ( value === undefined ) return;\n\n\t\t\t_pixelRatio = value;\n\n\t\t\tthis.setSize( _width, _height, false );\n\n\t\t};\n\n\t\tthis.getSize = function () {\n\n\t\t\treturn {\n\t\t\t\twidth: _width,\n\t\t\t\theight: _height\n\t\t\t};\n\n\t\t};\n\n\t\tthis.setSize = function ( width, height, updateStyle ) {\n\n\t\t\tif ( vr.isPresenting() ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Can\\'t change size while VR device is presenting.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\t_width = width;\n\t\t\t_height = height;\n\n\t\t\t_canvas.width = width * _pixelRatio;\n\t\t\t_canvas.height = height * _pixelRatio;\n\n\t\t\tif ( updateStyle !== false ) {\n\n\t\t\t\t_canvas.style.width = width + 'px';\n\t\t\t\t_canvas.style.height = height + 'px';\n\n\t\t\t}\n\n\t\t\tthis.setViewport( 0, 0, width, height );\n\n\t\t};\n\n\t\tthis.getDrawingBufferSize = function () {\n\n\t\t\treturn {\n\t\t\t\twidth: _width * _pixelRatio,\n\t\t\t\theight: _height * _pixelRatio\n\t\t\t};\n\n\t\t};\n\n\t\tthis.setDrawingBufferSize = function ( width, height, pixelRatio ) {\n\n\t\t\t_width = width;\n\t\t\t_height = height;\n\n\t\t\t_pixelRatio = pixelRatio;\n\n\t\t\t_canvas.width = width * pixelRatio;\n\t\t\t_canvas.height = height * pixelRatio;\n\n\t\t\tthis.setViewport( 0, 0, width, height );\n\n\t\t};\n\n\t\tthis.getCurrentViewport = function () {\n\n\t\t\treturn _currentViewport;\n\n\t\t};\n\n\t\tthis.setViewport = function ( x, y, width, height ) {\n\n\t\t\t_viewport.set( x, _height - y - height, width, height );\n\t\t\tstate.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ) );\n\n\t\t};\n\n\t\tthis.setScissor = function ( x, y, width, height ) {\n\n\t\t\t_scissor.set( x, _height - y - height, width, height );\n\t\t\tstate.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ) );\n\n\t\t};\n\n\t\tthis.setScissorTest = function ( boolean ) {\n\n\t\t\tstate.setScissorTest( _scissorTest = boolean );\n\n\t\t};\n\n\t\t// Clearing\n\n\t\tthis.getClearColor = function () {\n\n\t\t\treturn background.getClearColor();\n\n\t\t};\n\n\t\tthis.setClearColor = function () {\n\n\t\t\tbackground.setClearColor.apply( background, arguments );\n\n\t\t};\n\n\t\tthis.getClearAlpha = function () {\n\n\t\t\treturn background.getClearAlpha();\n\n\t\t};\n\n\t\tthis.setClearAlpha = function () {\n\n\t\t\tbackground.setClearAlpha.apply( background, arguments );\n\n\t\t};\n\n\t\tthis.clear = function ( color, depth, stencil ) {\n\n\t\t\tvar bits = 0;\n\n\t\t\tif ( color === undefined || color ) bits |= 16384;\n\t\t\tif ( depth === undefined || depth ) bits |= 256;\n\t\t\tif ( stencil === undefined || stencil ) bits |= 1024;\n\n\t\t\t_gl.clear( bits );\n\n\t\t};\n\n\t\tthis.clearColor = function () {\n\n\t\t\tthis.clear( true, false, false );\n\n\t\t};\n\n\t\tthis.clearDepth = function () {\n\n\t\t\tthis.clear( false, true, false );\n\n\t\t};\n\n\t\tthis.clearStencil = function () {\n\n\t\t\tthis.clear( false, false, true );\n\n\t\t};\n\n\t\t//\n\n\t\tthis.dispose = function () {\n\n\t\t\t_canvas.removeEventListener( 'webglcontextlost', onContextLost, false );\n\t\t\t_canvas.removeEventListener( 'webglcontextrestored', onContextRestore, false );\n\n\t\t\trenderLists.dispose();\n\t\t\trenderStates.dispose();\n\t\t\tproperties.dispose();\n\t\t\tobjects.dispose();\n\n\t\t\tvr.dispose();\n\n\t\t\tanimation.stop();\n\n\t\t};\n\n\t\t// Events\n\n\t\tfunction onContextLost( event ) {\n\n\t\t\tevent.preventDefault();\n\n\t\t\tconsole.log( 'THREE.WebGLRenderer: Context Lost.' );\n\n\t\t\t_isContextLost = true;\n\n\t\t}\n\n\t\tfunction onContextRestore( /* event */ ) {\n\n\t\t\tconsole.log( 'THREE.WebGLRenderer: Context Restored.' );\n\n\t\t\t_isContextLost = false;\n\n\t\t\tinitGLContext();\n\n\t\t}\n\n\t\tfunction onMaterialDispose( event ) {\n\n\t\t\tvar material = event.target;\n\n\t\t\tmaterial.removeEventListener( 'dispose', onMaterialDispose );\n\n\t\t\tdeallocateMaterial( material );\n\n\t\t}\n\n\t\t// Buffer deallocation\n\n\t\tfunction deallocateMaterial( material ) {\n\n\t\t\treleaseMaterialProgramReference( material );\n\n\t\t\tproperties.remove( material );\n\n\t\t}\n\n\n\t\tfunction releaseMaterialProgramReference( material ) {\n\n\t\t\tvar programInfo = properties.get( material ).program;\n\n\t\t\tmaterial.program = undefined;\n\n\t\t\tif ( programInfo !== undefined ) {\n\n\t\t\t\tprogramCache.releaseProgram( programInfo );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Buffer rendering\n\n\t\tfunction renderObjectImmediate( object, program ) {\n\n\t\t\tobject.render( function ( object ) {\n\n\t\t\t\t_this.renderBufferImmediate( object, program );\n\n\t\t\t} );\n\n\t\t}\n\n\t\tthis.renderBufferImmediate = function ( object, program ) {\n\n\t\t\tstate.initAttributes();\n\n\t\t\tvar buffers = properties.get( object );\n\n\t\t\tif ( object.hasPositions && ! buffers.position ) buffers.position = _gl.createBuffer();\n\t\t\tif ( object.hasNormals && ! buffers.normal ) buffers.normal = _gl.createBuffer();\n\t\t\tif ( object.hasUvs && ! buffers.uv ) buffers.uv = _gl.createBuffer();\n\t\t\tif ( object.hasColors && ! buffers.color ) buffers.color = _gl.createBuffer();\n\n\t\t\tvar programAttributes = program.getAttributes();\n\n\t\t\tif ( object.hasPositions ) {\n\n\t\t\t\t_gl.bindBuffer( 34962, buffers.position );\n\t\t\t\t_gl.bufferData( 34962, object.positionArray, 35048 );\n\n\t\t\t\tstate.enableAttribute( programAttributes.position );\n\t\t\t\t_gl.vertexAttribPointer( programAttributes.position, 3, 5126, false, 0, 0 );\n\n\t\t\t}\n\n\t\t\tif ( object.hasNormals ) {\n\n\t\t\t\t_gl.bindBuffer( 34962, buffers.normal );\n\t\t\t\t_gl.bufferData( 34962, object.normalArray, 35048 );\n\n\t\t\t\tstate.enableAttribute( programAttributes.normal );\n\t\t\t\t_gl.vertexAttribPointer( programAttributes.normal, 3, 5126, false, 0, 0 );\n\n\t\t\t}\n\n\t\t\tif ( object.hasUvs ) {\n\n\t\t\t\t_gl.bindBuffer( 34962, buffers.uv );\n\t\t\t\t_gl.bufferData( 34962, object.uvArray, 35048 );\n\n\t\t\t\tstate.enableAttribute( programAttributes.uv );\n\t\t\t\t_gl.vertexAttribPointer( programAttributes.uv, 2, 5126, false, 0, 0 );\n\n\t\t\t}\n\n\t\t\tif ( object.hasColors ) {\n\n\t\t\t\t_gl.bindBuffer( 34962, buffers.color );\n\t\t\t\t_gl.bufferData( 34962, object.colorArray, 35048 );\n\n\t\t\t\tstate.enableAttribute( programAttributes.color );\n\t\t\t\t_gl.vertexAttribPointer( programAttributes.color, 3, 5126, false, 0, 0 );\n\n\t\t\t}\n\n\t\t\tstate.disableUnusedAttributes();\n\n\t\t\t_gl.drawArrays( 4, 0, object.count );\n\n\t\t\tobject.count = 0;\n\n\t\t};\n\n\t\tthis.renderBufferDirect = function ( camera, fog, geometry, material, object, group ) {\n\n\t\t\tvar frontFaceCW = ( object.isMesh && object.normalMatrix.determinant() < 0 );\n\n\t\t\tstate.setMaterial( material, frontFaceCW );\n\n\t\t\tvar program = setProgram( camera, fog, material, object );\n\n\t\t\tvar updateBuffers = false;\n\n\t\t\tif ( _currentGeometryProgram.geometry !== geometry.id ||\n\t\t\t\t_currentGeometryProgram.program !== program.id ||\n\t\t\t\t_currentGeometryProgram.wireframe !== ( material.wireframe === true ) ) {\n\n\t\t\t\t_currentGeometryProgram.geometry = geometry.id;\n\t\t\t\t_currentGeometryProgram.program = program.id;\n\t\t\t\t_currentGeometryProgram.wireframe = material.wireframe === true;\n\t\t\t\tupdateBuffers = true;\n\n\t\t\t}\n\n\t\t\tif ( object.morphTargetInfluences ) {\n\n\t\t\t\tmorphtargets.update( object, geometry, material, program );\n\n\t\t\t\tupdateBuffers = true;\n\n\t\t\t}\n\n\t\t\t//\n\n\t\t\tvar index = geometry.index;\n\t\t\tvar position = geometry.attributes.position;\n\t\t\tvar rangeFactor = 1;\n\n\t\t\tif ( material.wireframe === true ) {\n\n\t\t\t\tindex = geometries.getWireframeAttribute( geometry );\n\t\t\t\trangeFactor = 2;\n\n\t\t\t}\n\n\t\t\tvar attribute;\n\t\t\tvar renderer = bufferRenderer;\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\tattribute = attributes.get( index );\n\n\t\t\t\trenderer = indexedBufferRenderer;\n\t\t\t\trenderer.setIndex( attribute );\n\n\t\t\t}\n\n\t\t\tif ( updateBuffers ) {\n\n\t\t\t\tsetupVertexAttributes( material, program, geometry );\n\n\t\t\t\tif ( index !== null ) {\n\n\t\t\t\t\t_gl.bindBuffer( 34963, attribute.buffer );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t//\n\n\t\t\tvar dataCount = Infinity;\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\tdataCount = index.count;\n\n\t\t\t} else if ( position !== undefined ) {\n\n\t\t\t\tdataCount = position.count;\n\n\t\t\t}\n\n\t\t\tvar rangeStart = geometry.drawRange.start * rangeFactor;\n\t\t\tvar rangeCount = geometry.drawRange.count * rangeFactor;\n\n\t\t\tvar groupStart = group !== null ? group.start * rangeFactor : 0;\n\t\t\tvar groupCount = group !== null ? group.count * rangeFactor : Infinity;\n\n\t\t\tvar drawStart = Math.max( rangeStart, groupStart );\n\t\t\tvar drawEnd = Math.min( dataCount, rangeStart + rangeCount, groupStart + groupCount ) - 1;\n\n\t\t\tvar drawCount = Math.max( 0, drawEnd - drawStart + 1 );\n\n\t\t\tif ( drawCount === 0 ) return;\n\n\t\t\t//\n\n\t\t\tif ( object.isMesh ) {\n\n\t\t\t\tif ( material.wireframe === true ) {\n\n\t\t\t\t\tstate.setLineWidth( material.wireframeLinewidth * getTargetPixelRatio() );\n\t\t\t\t\trenderer.setMode( 1 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tswitch ( object.drawMode ) {\n\n\t\t\t\t\t\tcase TrianglesDrawMode:\n\t\t\t\t\t\t\trenderer.setMode( 4 );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase TriangleStripDrawMode:\n\t\t\t\t\t\t\trenderer.setMode( 5 );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase TriangleFanDrawMode:\n\t\t\t\t\t\t\trenderer.setMode( 6 );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\n\t\t\t} else if ( object.isLine ) {\n\n\t\t\t\tvar lineWidth = material.linewidth;\n\n\t\t\t\tif ( lineWidth === undefined ) lineWidth = 1; // Not using Line*Material\n\n\t\t\t\tstate.setLineWidth( lineWidth * getTargetPixelRatio() );\n\n\t\t\t\tif ( object.isLineSegments ) {\n\n\t\t\t\t\trenderer.setMode( 1 );\n\n\t\t\t\t} else if ( object.isLineLoop ) {\n\n\t\t\t\t\trenderer.setMode( 2 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\trenderer.setMode( 3 );\n\n\t\t\t\t}\n\n\t\t\t} else if ( object.isPoints ) {\n\n\t\t\t\trenderer.setMode( 0 );\n\n\t\t\t} else if ( object.isSprite ) {\n\n\t\t\t\trenderer.setMode( 4 );\n\n\t\t\t}\n\n\t\t\tif ( geometry && geometry.isInstancedBufferGeometry ) {\n\n\t\t\t\tif ( geometry.maxInstancedCount > 0 ) {\n\n\t\t\t\t\trenderer.renderInstances( geometry, drawStart, drawCount );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\trenderer.render( drawStart, drawCount );\n\n\t\t\t}\n\n\t\t};\n\n\t\tfunction setupVertexAttributes( material, program, geometry ) {\n\n\t\t\tif ( geometry && geometry.isInstancedBufferGeometry & ! capabilities.isWebGL2 ) {\n\n\t\t\t\tif ( extensions.get( 'ANGLE_instanced_arrays' ) === null ) {\n\n\t\t\t\t\tconsole.error( 'THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tstate.initAttributes();\n\n\t\t\tvar geometryAttributes = geometry.attributes;\n\n\t\t\tvar programAttributes = program.getAttributes();\n\n\t\t\tvar materialDefaultAttributeValues = material.defaultAttributeValues;\n\n\t\t\tfor ( var name in programAttributes ) {\n\n\t\t\t\tvar programAttribute = programAttributes[ name ];\n\n\t\t\t\tif ( programAttribute >= 0 ) {\n\n\t\t\t\t\tvar geometryAttribute = geometryAttributes[ name ];\n\n\t\t\t\t\tif ( geometryAttribute !== undefined ) {\n\n\t\t\t\t\t\tvar normalized = geometryAttribute.normalized;\n\t\t\t\t\t\tvar size = geometryAttribute.itemSize;\n\n\t\t\t\t\t\tvar attribute = attributes.get( geometryAttribute );\n\n\t\t\t\t\t\t// TODO Attribute may not be available on context restore\n\n\t\t\t\t\t\tif ( attribute === undefined ) continue;\n\n\t\t\t\t\t\tvar buffer = attribute.buffer;\n\t\t\t\t\t\tvar type = attribute.type;\n\t\t\t\t\t\tvar bytesPerElement = attribute.bytesPerElement;\n\n\t\t\t\t\t\tif ( geometryAttribute.isInterleavedBufferAttribute ) {\n\n\t\t\t\t\t\t\tvar data = geometryAttribute.data;\n\t\t\t\t\t\t\tvar stride = data.stride;\n\t\t\t\t\t\t\tvar offset = geometryAttribute.offset;\n\n\t\t\t\t\t\t\tif ( data && data.isInstancedInterleavedBuffer ) {\n\n\t\t\t\t\t\t\t\tstate.enableAttributeAndDivisor( programAttribute, data.meshPerAttribute );\n\n\t\t\t\t\t\t\t\tif ( geometry.maxInstancedCount === undefined ) {\n\n\t\t\t\t\t\t\t\t\tgeometry.maxInstancedCount = data.meshPerAttribute * data.count;\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\tstate.enableAttribute( programAttribute );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t_gl.bindBuffer( 34962, buffer );\n\t\t\t\t\t\t\t_gl.vertexAttribPointer( programAttribute, size, type, normalized, stride * bytesPerElement, offset * bytesPerElement );\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tif ( geometryAttribute.isInstancedBufferAttribute ) {\n\n\t\t\t\t\t\t\t\tstate.enableAttributeAndDivisor( programAttribute, geometryAttribute.meshPerAttribute );\n\n\t\t\t\t\t\t\t\tif ( geometry.maxInstancedCount === undefined ) {\n\n\t\t\t\t\t\t\t\t\tgeometry.maxInstancedCount = geometryAttribute.meshPerAttribute * geometryAttribute.count;\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\tstate.enableAttribute( programAttribute );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t_gl.bindBuffer( 34962, buffer );\n\t\t\t\t\t\t\t_gl.vertexAttribPointer( programAttribute, size, type, normalized, 0, 0 );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else if ( materialDefaultAttributeValues !== undefined ) {\n\n\t\t\t\t\t\tvar value = materialDefaultAttributeValues[ name ];\n\n\t\t\t\t\t\tif ( value !== undefined ) {\n\n\t\t\t\t\t\t\tswitch ( value.length ) {\n\n\t\t\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\t\t\t_gl.vertexAttrib2fv( programAttribute, value );\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase 3:\n\t\t\t\t\t\t\t\t\t_gl.vertexAttrib3fv( programAttribute, value );\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase 4:\n\t\t\t\t\t\t\t\t\t_gl.vertexAttrib4fv( programAttribute, value );\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\t_gl.vertexAttrib1fv( programAttribute, value );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tstate.disableUnusedAttributes();\n\n\t\t}\n\n\t\t// Compile\n\n\t\tthis.compile = function ( scene, camera ) {\n\n\t\t\tcurrentRenderState = renderStates.get( scene, camera );\n\t\t\tcurrentRenderState.init();\n\n\t\t\tscene.traverse( function ( object ) {\n\n\t\t\t\tif ( object.isLight ) {\n\n\t\t\t\t\tcurrentRenderState.pushLight( object );\n\n\t\t\t\t\tif ( object.castShadow ) {\n\n\t\t\t\t\t\tcurrentRenderState.pushShadow( object );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} );\n\n\t\t\tcurrentRenderState.setupLights( camera );\n\n\t\t\tscene.traverse( function ( object ) {\n\n\t\t\t\tif ( object.material ) {\n\n\t\t\t\t\tif ( Array.isArray( object.material ) ) {\n\n\t\t\t\t\t\tfor ( var i = 0; i < object.material.length; i ++ ) {\n\n\t\t\t\t\t\t\tinitMaterial( object.material[ i ], scene.fog, object );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tinitMaterial( object.material, scene.fog, object );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} );\n\n\t\t};\n\n\t\t// Animation Loop\n\n\t\tvar onAnimationFrameCallback = null;\n\n\t\tfunction onAnimationFrame( time ) {\n\n\t\t\tif ( vr.isPresenting() ) return;\n\t\t\tif ( onAnimationFrameCallback ) onAnimationFrameCallback( time );\n\n\t\t}\n\n\t\tvar animation = new WebGLAnimation();\n\t\tanimation.setAnimationLoop( onAnimationFrame );\n\n\t\tif ( typeof window !== 'undefined' ) animation.setContext( window );\n\n\t\tthis.setAnimationLoop = function ( callback ) {\n\n\t\t\tonAnimationFrameCallback = callback;\n\t\t\tvr.setAnimationLoop( callback );\n\n\t\t\tanimation.start();\n\n\t\t};\n\n\t\t// Rendering\n\n\t\tthis.render = function ( scene, camera, renderTarget, forceClear ) {\n\n\t\t\tif ( ! ( camera && camera.isCamera ) ) {\n\n\t\t\t\tconsole.error( 'THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tif ( _isContextLost ) return;\n\n\t\t\t// reset caching for this frame\n\n\t\t\t_currentGeometryProgram.geometry = null;\n\t\t\t_currentGeometryProgram.program = null;\n\t\t\t_currentGeometryProgram.wireframe = false;\n\t\t\t_currentMaterialId = - 1;\n\t\t\t_currentCamera = null;\n\n\t\t\t// update scene graph\n\n\t\t\tif ( scene.autoUpdate === true ) scene.updateMatrixWorld();\n\n\t\t\t// update camera matrices and frustum\n\n\t\t\tif ( camera.parent === null ) camera.updateMatrixWorld();\n\n\t\t\tif ( vr.enabled ) {\n\n\t\t\t\tcamera = vr.getCamera( camera );\n\n\t\t\t}\n\n\t\t\t//\n\n\t\t\tcurrentRenderState = renderStates.get( scene, camera );\n\t\t\tcurrentRenderState.init();\n\n\t\t\tscene.onBeforeRender( _this, scene, camera, renderTarget );\n\n\t\t\t_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );\n\t\t\t_frustum.setFromMatrix( _projScreenMatrix );\n\n\t\t\t_localClippingEnabled = this.localClippingEnabled;\n\t\t\t_clippingEnabled = _clipping.init( this.clippingPlanes, _localClippingEnabled, camera );\n\n\t\t\tcurrentRenderList = renderLists.get( scene, camera );\n\t\t\tcurrentRenderList.init();\n\n\t\t\tprojectObject( scene, camera, _this.sortObjects );\n\n\t\t\tif ( _this.sortObjects === true ) {\n\n\t\t\t\tcurrentRenderList.sort();\n\n\t\t\t}\n\n\t\t\t//\n\n\t\t\tif ( _clippingEnabled ) _clipping.beginShadows();\n\n\t\t\tvar shadowsArray = currentRenderState.state.shadowsArray;\n\n\t\t\tshadowMap.render( shadowsArray, scene, camera );\n\n\t\t\tcurrentRenderState.setupLights( camera );\n\n\t\t\tif ( _clippingEnabled ) _clipping.endShadows();\n\n\t\t\t//\n\n\t\t\tif ( this.info.autoReset ) this.info.reset();\n\n\t\t\tif ( renderTarget === undefined ) {\n\n\t\t\t\trenderTarget = null;\n\n\t\t\t}\n\n\t\t\tthis.setRenderTarget( renderTarget );\n\n\t\t\t//\n\n\t\t\tbackground.render( currentRenderList, scene, camera, forceClear );\n\n\t\t\t// render scene\n\n\t\t\tvar opaqueObjects = currentRenderList.opaque;\n\t\t\tvar transparentObjects = currentRenderList.transparent;\n\n\t\t\tif ( scene.overrideMaterial ) {\n\n\t\t\t\tvar overrideMaterial = scene.overrideMaterial;\n\n\t\t\t\tif ( opaqueObjects.length ) renderObjects( opaqueObjects, scene, camera, overrideMaterial );\n\t\t\t\tif ( transparentObjects.length ) renderObjects( transparentObjects, scene, camera, overrideMaterial );\n\n\t\t\t} else {\n\n\t\t\t\t// opaque pass (front-to-back order)\n\n\t\t\t\tif ( opaqueObjects.length ) renderObjects( opaqueObjects, scene, camera );\n\n\t\t\t\t// transparent pass (back-to-front order)\n\n\t\t\t\tif ( transparentObjects.length ) renderObjects( transparentObjects, scene, camera );\n\n\t\t\t}\n\n\t\t\t// Generate mipmap if we're using any kind of mipmap filtering\n\n\t\t\tif ( renderTarget ) {\n\n\t\t\t\ttextures.updateRenderTargetMipmap( renderTarget );\n\n\t\t\t}\n\n\t\t\t// Ensure depth buffer writing is enabled so it can be cleared on next render\n\n\t\t\tstate.buffers.depth.setTest( true );\n\t\t\tstate.buffers.depth.setMask( true );\n\t\t\tstate.buffers.color.setMask( true );\n\n\t\t\tstate.setPolygonOffset( false );\n\n\t\t\tscene.onAfterRender( _this, scene, camera );\n\n\t\t\tif ( vr.enabled ) {\n\n\t\t\t\tvr.submitFrame();\n\n\t\t\t}\n\n\t\t\t// _gl.finish();\n\n\t\t\tcurrentRenderList = null;\n\t\t\tcurrentRenderState = null;\n\n\t\t};\n\n\t\tfunction projectObject( object, camera, sortObjects ) {\n\n\t\t\tif ( object.visible === false ) return;\n\n\t\t\tvar visible = object.layers.test( camera.layers );\n\n\t\t\tif ( visible ) {\n\n\t\t\t\tif ( object.isLight ) {\n\n\t\t\t\t\tcurrentRenderState.pushLight( object );\n\n\t\t\t\t\tif ( object.castShadow ) {\n\n\t\t\t\t\t\tcurrentRenderState.pushShadow( object );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( object.isSprite ) {\n\n\t\t\t\t\tif ( ! object.frustumCulled || _frustum.intersectsSprite( object ) ) {\n\n\t\t\t\t\t\tif ( sortObjects ) {\n\n\t\t\t\t\t\t\t_vector3.setFromMatrixPosition( object.matrixWorld )\n\t\t\t\t\t\t\t\t.applyMatrix4( _projScreenMatrix );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvar geometry = objects.update( object );\n\t\t\t\t\t\tvar material = object.material;\n\n\t\t\t\t\t\tcurrentRenderList.push( object, geometry, material, _vector3.z, null );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( object.isImmediateRenderObject ) {\n\n\t\t\t\t\tif ( sortObjects ) {\n\n\t\t\t\t\t\t_vector3.setFromMatrixPosition( object.matrixWorld )\n\t\t\t\t\t\t\t.applyMatrix4( _projScreenMatrix );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrentRenderList.push( object, null, object.material, _vector3.z, null );\n\n\t\t\t\t} else if ( object.isMesh || object.isLine || object.isPoints ) {\n\n\t\t\t\t\tif ( object.isSkinnedMesh ) {\n\n\t\t\t\t\t\tobject.skeleton.update();\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) {\n\n\t\t\t\t\t\tif ( sortObjects ) {\n\n\t\t\t\t\t\t\t_vector3.setFromMatrixPosition( object.matrixWorld )\n\t\t\t\t\t\t\t\t.applyMatrix4( _projScreenMatrix );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvar geometry = objects.update( object );\n\t\t\t\t\t\tvar material = object.material;\n\n\t\t\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\t\t\tvar groups = geometry.groups;\n\n\t\t\t\t\t\t\tfor ( var i = 0, l = groups.length; i < l; i ++ ) {\n\n\t\t\t\t\t\t\t\tvar group = groups[ i ];\n\t\t\t\t\t\t\t\tvar groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\t\t\tif ( groupMaterial && groupMaterial.visible ) {\n\n\t\t\t\t\t\t\t\t\tcurrentRenderList.push( object, geometry, groupMaterial, _vector3.z, group );\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else if ( material.visible ) {\n\n\t\t\t\t\t\t\tcurrentRenderList.push( object, geometry, material, _vector3.z, null );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tvar children = object.children;\n\n\t\t\tfor ( var i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\t\tprojectObject( children[ i ], camera, sortObjects );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction renderObjects( renderList, scene, camera, overrideMaterial ) {\n\n\t\t\tfor ( var i = 0, l = renderList.length; i < l; i ++ ) {\n\n\t\t\t\tvar renderItem = renderList[ i ];\n\n\t\t\t\tvar object = renderItem.object;\n\t\t\t\tvar geometry = renderItem.geometry;\n\t\t\t\tvar material = overrideMaterial === undefined ? renderItem.material : overrideMaterial;\n\t\t\t\tvar group = renderItem.group;\n\n\t\t\t\tif ( camera.isArrayCamera ) {\n\n\t\t\t\t\t_currentArrayCamera = camera;\n\n\t\t\t\t\tvar cameras = camera.cameras;\n\n\t\t\t\t\tfor ( var j = 0, jl = cameras.length; j < jl; j ++ ) {\n\n\t\t\t\t\t\tvar camera2 = cameras[ j ];\n\n\t\t\t\t\t\tif ( object.layers.test( camera2.layers ) ) {\n\n\t\t\t\t\t\t\tif ( 'viewport' in camera2 ) { // XR\n\n\t\t\t\t\t\t\t\tstate.viewport( _currentViewport.copy( camera2.viewport ) );\n\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\tvar bounds = camera2.bounds;\n\n\t\t\t\t\t\t\t\tvar x = bounds.x * _width;\n\t\t\t\t\t\t\t\tvar y = bounds.y * _height;\n\t\t\t\t\t\t\t\tvar width = bounds.z * _width;\n\t\t\t\t\t\t\t\tvar height = bounds.w * _height;\n\n\t\t\t\t\t\t\t\tstate.viewport( _currentViewport.set( x, y, width, height ).multiplyScalar( _pixelRatio ) );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcurrentRenderState.setupLights( camera2 );\n\n\t\t\t\t\t\t\trenderObject( object, scene, camera2, geometry, material, group );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\t_currentArrayCamera = null;\n\n\t\t\t\t\trenderObject( object, scene, camera, geometry, material, group );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction renderObject( object, scene, camera, geometry, material, group ) {\n\n\t\t\tobject.onBeforeRender( _this, scene, camera, geometry, material, group );\n\t\t\tcurrentRenderState = renderStates.get( scene, _currentArrayCamera || camera );\n\n\t\t\tobject.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );\n\t\t\tobject.normalMatrix.getNormalMatrix( object.modelViewMatrix );\n\n\t\t\tif ( object.isImmediateRenderObject ) {\n\n\t\t\t\tstate.setMaterial( material );\n\n\t\t\t\tvar program = setProgram( camera, scene.fog, material, object );\n\n\t\t\t\t_currentGeometryProgram.geometry = null;\n\t\t\t\t_currentGeometryProgram.program = null;\n\t\t\t\t_currentGeometryProgram.wireframe = false;\n\n\t\t\t\trenderObjectImmediate( object, program );\n\n\t\t\t} else {\n\n\t\t\t\t_this.renderBufferDirect( camera, scene.fog, geometry, material, object, group );\n\n\t\t\t}\n\n\t\t\tobject.onAfterRender( _this, scene, camera, geometry, material, group );\n\t\t\tcurrentRenderState = renderStates.get( scene, _currentArrayCamera || camera );\n\n\t\t}\n\n\t\tfunction initMaterial( material, fog, object ) {\n\n\t\t\tvar materialProperties = properties.get( material );\n\n\t\t\tvar lights = currentRenderState.state.lights;\n\t\t\tvar shadowsArray = currentRenderState.state.shadowsArray;\n\n\t\t\tvar lightsHash = materialProperties.lightsHash;\n\t\t\tvar lightsStateHash = lights.state.hash;\n\n\t\t\tvar parameters = programCache.getParameters(\n\t\t\t\tmaterial, lights.state, shadowsArray, fog, _clipping.numPlanes, _clipping.numIntersection, object );\n\n\t\t\tvar code = programCache.getProgramCode( material, parameters );\n\n\t\t\tvar program = materialProperties.program;\n\t\t\tvar programChange = true;\n\n\t\t\tif ( program === undefined ) {\n\n\t\t\t\t// new material\n\t\t\t\tmaterial.addEventListener( 'dispose', onMaterialDispose );\n\n\t\t\t} else if ( program.code !== code ) {\n\n\t\t\t\t// changed glsl or parameters\n\t\t\t\treleaseMaterialProgramReference( material );\n\n\t\t\t} else if ( lightsHash.stateID !== lightsStateHash.stateID ||\n\t\t\t\tlightsHash.directionalLength !== lightsStateHash.directionalLength ||\n\t\t\t\tlightsHash.pointLength !== lightsStateHash.pointLength ||\n\t\t\t\tlightsHash.spotLength !== lightsStateHash.spotLength ||\n\t\t\t\tlightsHash.rectAreaLength !== lightsStateHash.rectAreaLength ||\n\t\t\t\tlightsHash.hemiLength !== lightsStateHash.hemiLength ||\n\t\t\t\tlightsHash.shadowsLength !== lightsStateHash.shadowsLength ) {\n\n\t\t\t\tlightsHash.stateID = lightsStateHash.stateID;\n\t\t\t\tlightsHash.directionalLength = lightsStateHash.directionalLength;\n\t\t\t\tlightsHash.pointLength = lightsStateHash.pointLength;\n\t\t\t\tlightsHash.spotLength = lightsStateHash.spotLength;\n\t\t\t\tlightsHash.rectAreaLength = lightsStateHash.rectAreaLength;\n\t\t\t\tlightsHash.hemiLength = lightsStateHash.hemiLength;\n\t\t\t\tlightsHash.shadowsLength = lightsStateHash.shadowsLength;\n\n\t\t\t\tprogramChange = false;\n\n\t\t\t} else if ( parameters.shaderID !== undefined ) {\n\n\t\t\t\t// same glsl and uniform list\n\t\t\t\treturn;\n\n\t\t\t} else {\n\n\t\t\t\t// only rebuild uniform list\n\t\t\t\tprogramChange = false;\n\n\t\t\t}\n\n\t\t\tif ( programChange ) {\n\n\t\t\t\tif ( parameters.shaderID ) {\n\n\t\t\t\t\tvar shader = ShaderLib[ parameters.shaderID ];\n\n\t\t\t\t\tmaterialProperties.shader = {\n\t\t\t\t\t\tname: material.type,\n\t\t\t\t\t\tuniforms: cloneUniforms( shader.uniforms ),\n\t\t\t\t\t\tvertexShader: shader.vertexShader,\n\t\t\t\t\t\tfragmentShader: shader.fragmentShader\n\t\t\t\t\t};\n\n\t\t\t\t} else {\n\n\t\t\t\t\tmaterialProperties.shader = {\n\t\t\t\t\t\tname: material.type,\n\t\t\t\t\t\tuniforms: material.uniforms,\n\t\t\t\t\t\tvertexShader: material.vertexShader,\n\t\t\t\t\t\tfragmentShader: material.fragmentShader\n\t\t\t\t\t};\n\n\t\t\t\t}\n\n\t\t\t\tmaterial.onBeforeCompile( materialProperties.shader, _this );\n\n\t\t\t\t// Computing code again as onBeforeCompile may have changed the shaders\n\t\t\t\tcode = programCache.getProgramCode( material, parameters );\n\n\t\t\t\tprogram = programCache.acquireProgram( material, materialProperties.shader, parameters, code );\n\n\t\t\t\tmaterialProperties.program = program;\n\t\t\t\tmaterial.program = program;\n\n\t\t\t}\n\n\t\t\tvar programAttributes = program.getAttributes();\n\n\t\t\tif ( material.morphTargets ) {\n\n\t\t\t\tmaterial.numSupportedMorphTargets = 0;\n\n\t\t\t\tfor ( var i = 0; i < _this.maxMorphTargets; i ++ ) {\n\n\t\t\t\t\tif ( programAttributes[ 'morphTarget' + i ] >= 0 ) {\n\n\t\t\t\t\t\tmaterial.numSupportedMorphTargets ++;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( material.morphNormals ) {\n\n\t\t\t\tmaterial.numSupportedMorphNormals = 0;\n\n\t\t\t\tfor ( var i = 0; i < _this.maxMorphNormals; i ++ ) {\n\n\t\t\t\t\tif ( programAttributes[ 'morphNormal' + i ] >= 0 ) {\n\n\t\t\t\t\t\tmaterial.numSupportedMorphNormals ++;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tvar uniforms = materialProperties.shader.uniforms;\n\n\t\t\tif ( ! material.isShaderMaterial &&\n\t\t\t\t! material.isRawShaderMaterial ||\n\t\t\t\tmaterial.clipping === true ) {\n\n\t\t\t\tmaterialProperties.numClippingPlanes = _clipping.numPlanes;\n\t\t\t\tmaterialProperties.numIntersection = _clipping.numIntersection;\n\t\t\t\tuniforms.clippingPlanes = _clipping.uniform;\n\n\t\t\t}\n\n\t\t\tmaterialProperties.fog = fog;\n\n\t\t\t// store the light setup it was created for\n\t\t\tif ( lightsHash === undefined ) {\n\n\t\t\t\tmaterialProperties.lightsHash = lightsHash = {};\n\n\t\t\t}\n\n\t\t\tlightsHash.stateID = lightsStateHash.stateID;\n\t\t\tlightsHash.directionalLength = lightsStateHash.directionalLength;\n\t\t\tlightsHash.pointLength = lightsStateHash.pointLength;\n\t\t\tlightsHash.spotLength = lightsStateHash.spotLength;\n\t\t\tlightsHash.rectAreaLength = lightsStateHash.rectAreaLength;\n\t\t\tlightsHash.hemiLength = lightsStateHash.hemiLength;\n\t\t\tlightsHash.shadowsLength = lightsStateHash.shadowsLength;\n\n\t\t\tif ( material.lights ) {\n\n\t\t\t\t// wire up the material to this renderer's lighting state\n\n\t\t\t\tuniforms.ambientLightColor.value = lights.state.ambient;\n\t\t\t\tuniforms.directionalLights.value = lights.state.directional;\n\t\t\t\tuniforms.spotLights.value = lights.state.spot;\n\t\t\t\tuniforms.rectAreaLights.value = lights.state.rectArea;\n\t\t\t\tuniforms.pointLights.value = lights.state.point;\n\t\t\t\tuniforms.hemisphereLights.value = lights.state.hemi;\n\n\t\t\t\tuniforms.directionalShadowMap.value = lights.state.directionalShadowMap;\n\t\t\t\tuniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix;\n\t\t\t\tuniforms.spotShadowMap.value = lights.state.spotShadowMap;\n\t\t\t\tuniforms.spotShadowMatrix.value = lights.state.spotShadowMatrix;\n\t\t\t\tuniforms.pointShadowMap.value = lights.state.pointShadowMap;\n\t\t\t\tuniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;\n\t\t\t\t// TODO (abelnation): add area lights shadow info to uniforms\n\n\t\t\t}\n\n\t\t\tvar progUniforms = materialProperties.program.getUniforms(),\n\t\t\t\tuniformsList =\n\t\t\t\t\tWebGLUniforms.seqWithValue( progUniforms.seq, uniforms );\n\n\t\t\tmaterialProperties.uniformsList = uniformsList;\n\n\t\t}\n\n\t\tfunction setProgram( camera, fog, material, object ) {\n\n\t\t\t_usedTextureUnits = 0;\n\n\t\t\tvar materialProperties = properties.get( material );\n\t\t\tvar lights = currentRenderState.state.lights;\n\n\t\t\tvar lightsHash = materialProperties.lightsHash;\n\t\t\tvar lightsStateHash = lights.state.hash;\n\n\t\t\tif ( _clippingEnabled ) {\n\n\t\t\t\tif ( _localClippingEnabled || camera !== _currentCamera ) {\n\n\t\t\t\t\tvar useCache =\n\t\t\t\t\t\tcamera === _currentCamera &&\n\t\t\t\t\t\tmaterial.id === _currentMaterialId;\n\n\t\t\t\t\t// we might want to call this function with some ClippingGroup\n\t\t\t\t\t// object instead of the material, once it becomes feasible\n\t\t\t\t\t// (#8465, #8379)\n\t\t\t\t\t_clipping.setState(\n\t\t\t\t\t\tmaterial.clippingPlanes, material.clipIntersection, material.clipShadows,\n\t\t\t\t\t\tcamera, materialProperties, useCache );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( material.needsUpdate === false ) {\n\n\t\t\t\tif ( materialProperties.program === undefined ) {\n\n\t\t\t\t\tmaterial.needsUpdate = true;\n\n\t\t\t\t} else if ( material.fog && materialProperties.fog !== fog ) {\n\n\t\t\t\t\tmaterial.needsUpdate = true;\n\n\t\t\t\t} else if ( material.lights && ( lightsHash.stateID !== lightsStateHash.stateID ||\n\t\t\t\t\tlightsHash.directionalLength !== lightsStateHash.directionalLength ||\n\t\t\t\t\tlightsHash.pointLength !== lightsStateHash.pointLength ||\n\t\t\t\t\tlightsHash.spotLength !== lightsStateHash.spotLength ||\n\t\t\t\t\tlightsHash.rectAreaLength !== lightsStateHash.rectAreaLength ||\n\t\t\t\t\tlightsHash.hemiLength !== lightsStateHash.hemiLength ||\n\t\t\t\t\tlightsHash.shadowsLength !== lightsStateHash.shadowsLength ) ) {\n\n\t\t\t\t\tmaterial.needsUpdate = true;\n\n\t\t\t\t} else if ( materialProperties.numClippingPlanes !== undefined &&\n\t\t\t\t\t( materialProperties.numClippingPlanes !== _clipping.numPlanes ||\n\t\t\t\t\tmaterialProperties.numIntersection !== _clipping.numIntersection ) ) {\n\n\t\t\t\t\tmaterial.needsUpdate = true;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( material.needsUpdate ) {\n\n\t\t\t\tinitMaterial( material, fog, object );\n\t\t\t\tmaterial.needsUpdate = false;\n\n\t\t\t}\n\n\t\t\tvar refreshProgram = false;\n\t\t\tvar refreshMaterial = false;\n\t\t\tvar refreshLights = false;\n\n\t\t\tvar program = materialProperties.program,\n\t\t\t\tp_uniforms = program.getUniforms(),\n\t\t\t\tm_uniforms = materialProperties.shader.uniforms;\n\n\t\t\tif ( state.useProgram( program.program ) ) {\n\n\t\t\t\trefreshProgram = true;\n\t\t\t\trefreshMaterial = true;\n\t\t\t\trefreshLights = true;\n\n\t\t\t}\n\n\t\t\tif ( material.id !== _currentMaterialId ) {\n\n\t\t\t\t_currentMaterialId = material.id;\n\n\t\t\t\trefreshMaterial = true;\n\n\t\t\t}\n\n\t\t\tif ( refreshProgram || _currentCamera !== camera ) {\n\n\t\t\t\tp_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );\n\n\t\t\t\tif ( capabilities.logarithmicDepthBuffer ) {\n\n\t\t\t\t\tp_uniforms.setValue( _gl, 'logDepthBufFC',\n\t\t\t\t\t\t2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );\n\n\t\t\t\t}\n\n\t\t\t\tif ( _currentCamera !== camera ) {\n\n\t\t\t\t\t_currentCamera = camera;\n\n\t\t\t\t\t// lighting uniforms depend on the camera so enforce an update\n\t\t\t\t\t// now, in case this material supports lights - or later, when\n\t\t\t\t\t// the next material that does gets activated:\n\n\t\t\t\t\trefreshMaterial = true;\t\t// set to true on material change\n\t\t\t\t\trefreshLights = true;\t\t// remains set until update done\n\n\t\t\t\t}\n\n\t\t\t\t// load material specific uniforms\n\t\t\t\t// (shader material also gets them for the sake of genericity)\n\n\t\t\t\tif ( material.isShaderMaterial ||\n\t\t\t\t\tmaterial.isMeshPhongMaterial ||\n\t\t\t\t\tmaterial.isMeshStandardMaterial ||\n\t\t\t\t\tmaterial.envMap ) {\n\n\t\t\t\t\tvar uCamPos = p_uniforms.map.cameraPosition;\n\n\t\t\t\t\tif ( uCamPos !== undefined ) {\n\n\t\t\t\t\t\tuCamPos.setValue( _gl,\n\t\t\t\t\t\t\t_vector3.setFromMatrixPosition( camera.matrixWorld ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( material.isMeshPhongMaterial ||\n\t\t\t\t\tmaterial.isMeshLambertMaterial ||\n\t\t\t\t\tmaterial.isMeshBasicMaterial ||\n\t\t\t\t\tmaterial.isMeshStandardMaterial ||\n\t\t\t\t\tmaterial.isShaderMaterial ||\n\t\t\t\t\tmaterial.skinning ) {\n\n\t\t\t\t\tp_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// skinning uniforms must be set even if material didn't change\n\t\t\t// auto-setting of texture unit for bone texture must go before other textures\n\t\t\t// not sure why, but otherwise weird things happen\n\n\t\t\tif ( material.skinning ) {\n\n\t\t\t\tp_uniforms.setOptional( _gl, object, 'bindMatrix' );\n\t\t\t\tp_uniforms.setOptional( _gl, object, 'bindMatrixInverse' );\n\n\t\t\t\tvar skeleton = object.skeleton;\n\n\t\t\t\tif ( skeleton ) {\n\n\t\t\t\t\tvar bones = skeleton.bones;\n\n\t\t\t\t\tif ( capabilities.floatVertexTextures ) {\n\n\t\t\t\t\t\tif ( skeleton.boneTexture === undefined ) {\n\n\t\t\t\t\t\t\t// layout (1 matrix = 4 pixels)\n\t\t\t\t\t\t\t//      RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)\n\t\t\t\t\t\t\t//  with  8x8  pixel texture max   16 bones * 4 pixels =  (8 * 8)\n\t\t\t\t\t\t\t//       16x16 pixel texture max   64 bones * 4 pixels = (16 * 16)\n\t\t\t\t\t\t\t//       32x32 pixel texture max  256 bones * 4 pixels = (32 * 32)\n\t\t\t\t\t\t\t//       64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)\n\n\n\t\t\t\t\t\t\tvar size = Math.sqrt( bones.length * 4 ); // 4 pixels needed for 1 matrix\n\t\t\t\t\t\t\tsize = _Math.ceilPowerOfTwo( size );\n\t\t\t\t\t\t\tsize = Math.max( size, 4 );\n\n\t\t\t\t\t\t\tvar boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel\n\t\t\t\t\t\t\tboneMatrices.set( skeleton.boneMatrices ); // copy current values\n\n\t\t\t\t\t\t\tvar boneTexture = new DataTexture( boneMatrices, size, size, RGBAFormat, FloatType );\n\t\t\t\t\t\t\tboneTexture.needsUpdate = true;\n\n\t\t\t\t\t\t\tskeleton.boneMatrices = boneMatrices;\n\t\t\t\t\t\t\tskeleton.boneTexture = boneTexture;\n\t\t\t\t\t\t\tskeleton.boneTextureSize = size;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tp_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture );\n\t\t\t\t\t\tp_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tp_uniforms.setOptional( _gl, skeleton, 'boneMatrices' );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( refreshMaterial ) {\n\n\t\t\t\tp_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );\n\t\t\t\tp_uniforms.setValue( _gl, 'toneMappingWhitePoint', _this.toneMappingWhitePoint );\n\n\t\t\t\tif ( material.lights ) {\n\n\t\t\t\t\t// the current material requires lighting info\n\n\t\t\t\t\t// note: all lighting uniforms are always set correctly\n\t\t\t\t\t// they simply reference the renderer's state for their\n\t\t\t\t\t// values\n\t\t\t\t\t//\n\t\t\t\t\t// use the current material's .needsUpdate flags to set\n\t\t\t\t\t// the GL state when required\n\n\t\t\t\t\tmarkUniformsLightsNeedsUpdate( m_uniforms, refreshLights );\n\n\t\t\t\t}\n\n\t\t\t\t// refresh uniforms common to several materials\n\n\t\t\t\tif ( fog && material.fog ) {\n\n\t\t\t\t\trefreshUniformsFog( m_uniforms, fog );\n\n\t\t\t\t}\n\n\t\t\t\tif ( material.isMeshBasicMaterial ) {\n\n\t\t\t\t\trefreshUniformsCommon( m_uniforms, material );\n\n\t\t\t\t} else if ( material.isMeshLambertMaterial ) {\n\n\t\t\t\t\trefreshUniformsCommon( m_uniforms, material );\n\t\t\t\t\trefreshUniformsLambert( m_uniforms, material );\n\n\t\t\t\t} else if ( material.isMeshPhongMaterial ) {\n\n\t\t\t\t\trefreshUniformsCommon( m_uniforms, material );\n\n\t\t\t\t\tif ( material.isMeshToonMaterial ) {\n\n\t\t\t\t\t\trefreshUniformsToon( m_uniforms, material );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\trefreshUniformsPhong( m_uniforms, material );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( material.isMeshStandardMaterial ) {\n\n\t\t\t\t\trefreshUniformsCommon( m_uniforms, material );\n\n\t\t\t\t\tif ( material.isMeshPhysicalMaterial ) {\n\n\t\t\t\t\t\trefreshUniformsPhysical( m_uniforms, material );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\trefreshUniformsStandard( m_uniforms, material );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( material.isMeshMatcapMaterial ) {\n\n\t\t\t\t\trefreshUniformsCommon( m_uniforms, material );\n\n\t\t\t\t\trefreshUniformsMatcap( m_uniforms, material );\n\n\t\t\t\t} else if ( material.isMeshDepthMaterial ) {\n\n\t\t\t\t\trefreshUniformsCommon( m_uniforms, material );\n\t\t\t\t\trefreshUniformsDepth( m_uniforms, material );\n\n\t\t\t\t} else if ( material.isMeshDistanceMaterial ) {\n\n\t\t\t\t\trefreshUniformsCommon( m_uniforms, material );\n\t\t\t\t\trefreshUniformsDistance( m_uniforms, material );\n\n\t\t\t\t} else if ( material.isMeshNormalMaterial ) {\n\n\t\t\t\t\trefreshUniformsCommon( m_uniforms, material );\n\t\t\t\t\trefreshUniformsNormal( m_uniforms, material );\n\n\t\t\t\t} else if ( material.isLineBasicMaterial ) {\n\n\t\t\t\t\trefreshUniformsLine( m_uniforms, material );\n\n\t\t\t\t\tif ( material.isLineDashedMaterial ) {\n\n\t\t\t\t\t\trefreshUniformsDash( m_uniforms, material );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( material.isPointsMaterial ) {\n\n\t\t\t\t\trefreshUniformsPoints( m_uniforms, material );\n\n\t\t\t\t} else if ( material.isSpriteMaterial ) {\n\n\t\t\t\t\trefreshUniformsSprites( m_uniforms, material );\n\n\t\t\t\t} else if ( material.isShadowMaterial ) {\n\n\t\t\t\t\tm_uniforms.color.value = material.color;\n\t\t\t\t\tm_uniforms.opacity.value = material.opacity;\n\n\t\t\t\t}\n\n\t\t\t\t// RectAreaLight Texture\n\t\t\t\t// TODO (mrdoob): Find a nicer implementation\n\n\t\t\t\tif ( m_uniforms.ltc_1 !== undefined ) m_uniforms.ltc_1.value = UniformsLib.LTC_1;\n\t\t\t\tif ( m_uniforms.ltc_2 !== undefined ) m_uniforms.ltc_2.value = UniformsLib.LTC_2;\n\n\t\t\t\tWebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, _this );\n\n\t\t\t}\n\n\t\t\tif ( material.isShaderMaterial && material.uniformsNeedUpdate === true ) {\n\n\t\t\t\tWebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, _this );\n\t\t\t\tmaterial.uniformsNeedUpdate = false;\n\n\t\t\t}\n\n\t\t\tif ( material.isSpriteMaterial ) {\n\n\t\t\t\tp_uniforms.setValue( _gl, 'center', object.center );\n\n\t\t\t}\n\n\t\t\t// common matrices\n\n\t\t\tp_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );\n\t\t\tp_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );\n\t\t\tp_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );\n\n\t\t\treturn program;\n\n\t\t}\n\n\t\t// Uniforms (refresh uniforms objects)\n\n\t\tfunction refreshUniformsCommon( uniforms, material ) {\n\n\t\t\tuniforms.opacity.value = material.opacity;\n\n\t\t\tif ( material.color ) {\n\n\t\t\t\tuniforms.diffuse.value = material.color;\n\n\t\t\t}\n\n\t\t\tif ( material.emissive ) {\n\n\t\t\t\tuniforms.emissive.value.copy( material.emissive ).multiplyScalar( material.emissiveIntensity );\n\n\t\t\t}\n\n\t\t\tif ( material.map ) {\n\n\t\t\t\tuniforms.map.value = material.map;\n\n\t\t\t}\n\n\t\t\tif ( material.alphaMap ) {\n\n\t\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\n\t\t\t}\n\n\t\t\tif ( material.specularMap ) {\n\n\t\t\t\tuniforms.specularMap.value = material.specularMap;\n\n\t\t\t}\n\n\t\t\tif ( material.envMap ) {\n\n\t\t\t\tuniforms.envMap.value = material.envMap;\n\n\t\t\t\t// don't flip CubeTexture envMaps, flip everything else:\n\t\t\t\t//  WebGLRenderTargetCube will be flipped for backwards compatibility\n\t\t\t\t//  WebGLRenderTargetCube.texture will be flipped because it's a Texture and NOT a CubeTexture\n\t\t\t\t// this check must be handled differently, or removed entirely, if WebGLRenderTargetCube uses a CubeTexture in the future\n\t\t\t\tuniforms.flipEnvMap.value = material.envMap.isCubeTexture ? - 1 : 1;\n\n\t\t\t\tuniforms.reflectivity.value = material.reflectivity;\n\t\t\t\tuniforms.refractionRatio.value = material.refractionRatio;\n\n\t\t\t\tuniforms.maxMipLevel.value = properties.get( material.envMap ).__maxMipLevel;\n\n\t\t\t}\n\n\t\t\tif ( material.lightMap ) {\n\n\t\t\t\tuniforms.lightMap.value = material.lightMap;\n\t\t\t\tuniforms.lightMapIntensity.value = material.lightMapIntensity;\n\n\t\t\t}\n\n\t\t\tif ( material.aoMap ) {\n\n\t\t\t\tuniforms.aoMap.value = material.aoMap;\n\t\t\t\tuniforms.aoMapIntensity.value = material.aoMapIntensity;\n\n\t\t\t}\n\n\t\t\t// uv repeat and offset setting priorities\n\t\t\t// 1. color map\n\t\t\t// 2. specular map\n\t\t\t// 3. normal map\n\t\t\t// 4. bump map\n\t\t\t// 5. alpha map\n\t\t\t// 6. emissive map\n\n\t\t\tvar uvScaleMap;\n\n\t\t\tif ( material.map ) {\n\n\t\t\t\tuvScaleMap = material.map;\n\n\t\t\t} else if ( material.specularMap ) {\n\n\t\t\t\tuvScaleMap = material.specularMap;\n\n\t\t\t} else if ( material.displacementMap ) {\n\n\t\t\t\tuvScaleMap = material.displacementMap;\n\n\t\t\t} else if ( material.normalMap ) {\n\n\t\t\t\tuvScaleMap = material.normalMap;\n\n\t\t\t} else if ( material.bumpMap ) {\n\n\t\t\t\tuvScaleMap = material.bumpMap;\n\n\t\t\t} else if ( material.roughnessMap ) {\n\n\t\t\t\tuvScaleMap = material.roughnessMap;\n\n\t\t\t} else if ( material.metalnessMap ) {\n\n\t\t\t\tuvScaleMap = material.metalnessMap;\n\n\t\t\t} else if ( material.alphaMap ) {\n\n\t\t\t\tuvScaleMap = material.alphaMap;\n\n\t\t\t} else if ( material.emissiveMap ) {\n\n\t\t\t\tuvScaleMap = material.emissiveMap;\n\n\t\t\t}\n\n\t\t\tif ( uvScaleMap !== undefined ) {\n\n\t\t\t\t// backwards compatibility\n\t\t\t\tif ( uvScaleMap.isWebGLRenderTarget ) {\n\n\t\t\t\t\tuvScaleMap = uvScaleMap.texture;\n\n\t\t\t\t}\n\n\t\t\t\tif ( uvScaleMap.matrixAutoUpdate === true ) {\n\n\t\t\t\t\tuvScaleMap.updateMatrix();\n\n\t\t\t\t}\n\n\t\t\t\tuniforms.uvTransform.value.copy( uvScaleMap.matrix );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction refreshUniformsLine( uniforms, material ) {\n\n\t\t\tuniforms.diffuse.value = material.color;\n\t\t\tuniforms.opacity.value = material.opacity;\n\n\t\t}\n\n\t\tfunction refreshUniformsDash( uniforms, material ) {\n\n\t\t\tuniforms.dashSize.value = material.dashSize;\n\t\t\tuniforms.totalSize.value = material.dashSize + material.gapSize;\n\t\t\tuniforms.scale.value = material.scale;\n\n\t\t}\n\n\t\tfunction refreshUniformsPoints( uniforms, material ) {\n\n\t\t\tuniforms.diffuse.value = material.color;\n\t\t\tuniforms.opacity.value = material.opacity;\n\t\t\tuniforms.size.value = material.size * _pixelRatio;\n\t\t\tuniforms.scale.value = _height * 0.5;\n\n\t\t\tuniforms.map.value = material.map;\n\n\t\t\tif ( material.map !== null ) {\n\n\t\t\t\tif ( material.map.matrixAutoUpdate === true ) {\n\n\t\t\t\t\tmaterial.map.updateMatrix();\n\n\t\t\t\t}\n\n\t\t\t\tuniforms.uvTransform.value.copy( material.map.matrix );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction refreshUniformsSprites( uniforms, material ) {\n\n\t\t\tuniforms.diffuse.value = material.color;\n\t\t\tuniforms.opacity.value = material.opacity;\n\t\t\tuniforms.rotation.value = material.rotation;\n\t\t\tuniforms.map.value = material.map;\n\n\t\t\tif ( material.map !== null ) {\n\n\t\t\t\tif ( material.map.matrixAutoUpdate === true ) {\n\n\t\t\t\t\tmaterial.map.updateMatrix();\n\n\t\t\t\t}\n\n\t\t\t\tuniforms.uvTransform.value.copy( material.map.matrix );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction refreshUniformsFog( uniforms, fog ) {\n\n\t\t\tuniforms.fogColor.value = fog.color;\n\n\t\t\tif ( fog.isFog ) {\n\n\t\t\t\tuniforms.fogNear.value = fog.near;\n\t\t\t\tuniforms.fogFar.value = fog.far;\n\n\t\t\t} else if ( fog.isFogExp2 ) {\n\n\t\t\t\tuniforms.fogDensity.value = fog.density;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction refreshUniformsLambert( uniforms, material ) {\n\n\t\t\tif ( material.emissiveMap ) {\n\n\t\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction refreshUniformsPhong( uniforms, material ) {\n\n\t\t\tuniforms.specular.value = material.specular;\n\t\t\tuniforms.shininess.value = Math.max( material.shininess, 1e-4 ); // to prevent pow( 0.0, 0.0 )\n\n\t\t\tif ( material.emissiveMap ) {\n\n\t\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t\t}\n\n\t\t\tif ( material.bumpMap ) {\n\n\t\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t\t}\n\n\t\t\tif ( material.normalMap ) {\n\n\t\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t\t}\n\n\t\t\tif ( material.displacementMap ) {\n\n\t\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction refreshUniformsToon( uniforms, material ) {\n\n\t\t\trefreshUniformsPhong( uniforms, material );\n\n\t\t\tif ( material.gradientMap ) {\n\n\t\t\t\tuniforms.gradientMap.value = material.gradientMap;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction refreshUniformsStandard( uniforms, material ) {\n\n\t\t\tuniforms.roughness.value = material.roughness;\n\t\t\tuniforms.metalness.value = material.metalness;\n\n\t\t\tif ( material.roughnessMap ) {\n\n\t\t\t\tuniforms.roughnessMap.value = material.roughnessMap;\n\n\t\t\t}\n\n\t\t\tif ( material.metalnessMap ) {\n\n\t\t\t\tuniforms.metalnessMap.value = material.metalnessMap;\n\n\t\t\t}\n\n\t\t\tif ( material.emissiveMap ) {\n\n\t\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t\t}\n\n\t\t\tif ( material.bumpMap ) {\n\n\t\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t\t}\n\n\t\t\tif ( material.normalMap ) {\n\n\t\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t\t}\n\n\t\t\tif ( material.displacementMap ) {\n\n\t\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t\t}\n\n\t\t\tif ( material.envMap ) {\n\n\t\t\t\t//uniforms.envMap.value = material.envMap; // part of uniforms common\n\t\t\t\tuniforms.envMapIntensity.value = material.envMapIntensity;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction refreshUniformsPhysical( uniforms, material ) {\n\n\t\t\trefreshUniformsStandard( uniforms, material );\n\n\t\t\tuniforms.reflectivity.value = material.reflectivity; // also part of uniforms common\n\n\t\t\tuniforms.clearCoat.value = material.clearCoat;\n\t\t\tuniforms.clearCoatRoughness.value = material.clearCoatRoughness;\n\n\t\t}\n\n\t\tfunction refreshUniformsMatcap( uniforms, material ) {\n\n\t\t\tif ( material.matcap ) {\n\n\t\t\t\tuniforms.matcap.value = material.matcap;\n\n\t\t\t}\n\n\t\t\tif ( material.bumpMap ) {\n\n\t\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t\t}\n\n\t\t\tif ( material.normalMap ) {\n\n\t\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t\t}\n\n\t\t\tif ( material.displacementMap ) {\n\n\t\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction refreshUniformsDepth( uniforms, material ) {\n\n\t\t\tif ( material.displacementMap ) {\n\n\t\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction refreshUniformsDistance( uniforms, material ) {\n\n\t\t\tif ( material.displacementMap ) {\n\n\t\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t\t}\n\n\t\t\tuniforms.referencePosition.value.copy( material.referencePosition );\n\t\t\tuniforms.nearDistance.value = material.nearDistance;\n\t\t\tuniforms.farDistance.value = material.farDistance;\n\n\t\t}\n\n\t\tfunction refreshUniformsNormal( uniforms, material ) {\n\n\t\t\tif ( material.bumpMap ) {\n\n\t\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t\t}\n\n\t\t\tif ( material.normalMap ) {\n\n\t\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t\t}\n\n\t\t\tif ( material.displacementMap ) {\n\n\t\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t\t}\n\n\t\t}\n\n\t\t// If uniforms are marked as clean, they don't need to be loaded to the GPU.\n\n\t\tfunction markUniformsLightsNeedsUpdate( uniforms, value ) {\n\n\t\t\tuniforms.ambientLightColor.needsUpdate = value;\n\n\t\t\tuniforms.directionalLights.needsUpdate = value;\n\t\t\tuniforms.pointLights.needsUpdate = value;\n\t\t\tuniforms.spotLights.needsUpdate = value;\n\t\t\tuniforms.rectAreaLights.needsUpdate = value;\n\t\t\tuniforms.hemisphereLights.needsUpdate = value;\n\n\t\t}\n\n\t\t// Textures\n\n\t\tfunction allocTextureUnit() {\n\n\t\t\tvar textureUnit = _usedTextureUnits;\n\n\t\t\tif ( textureUnit >= capabilities.maxTextures ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + capabilities.maxTextures );\n\n\t\t\t}\n\n\t\t\t_usedTextureUnits += 1;\n\n\t\t\treturn textureUnit;\n\n\t\t}\n\n\t\tthis.allocTextureUnit = allocTextureUnit;\n\n\t\t// this.setTexture2D = setTexture2D;\n\t\tthis.setTexture2D = ( function () {\n\n\t\t\tvar warned = false;\n\n\t\t\t// backwards compatibility: peel texture.texture\n\t\t\treturn function setTexture2D( texture, slot ) {\n\n\t\t\t\tif ( texture && texture.isWebGLRenderTarget ) {\n\n\t\t\t\t\tif ( ! warned ) {\n\n\t\t\t\t\t\tconsole.warn( \"THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead.\" );\n\t\t\t\t\t\twarned = true;\n\n\t\t\t\t\t}\n\n\t\t\t\t\ttexture = texture.texture;\n\n\t\t\t\t}\n\n\t\t\t\ttextures.setTexture2D( texture, slot );\n\n\t\t\t};\n\n\t\t}() );\n\n\t\tthis.setTexture3D = ( function () {\n\n\t\t\t// backwards compatibility: peel texture.texture\n\t\t\treturn function setTexture3D( texture, slot ) {\n\n\t\t\t\ttextures.setTexture3D( texture, slot );\n\n\t\t\t};\n\n\t\t}() );\n\n\t\tthis.setTexture = ( function () {\n\n\t\t\tvar warned = false;\n\n\t\t\treturn function setTexture( texture, slot ) {\n\n\t\t\t\tif ( ! warned ) {\n\n\t\t\t\t\tconsole.warn( \"THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead.\" );\n\t\t\t\t\twarned = true;\n\n\t\t\t\t}\n\n\t\t\t\ttextures.setTexture2D( texture, slot );\n\n\t\t\t};\n\n\t\t}() );\n\n\t\tthis.setTextureCube = ( function () {\n\n\t\t\tvar warned = false;\n\n\t\t\treturn function setTextureCube( texture, slot ) {\n\n\t\t\t\t// backwards compatibility: peel texture.texture\n\t\t\t\tif ( texture && texture.isWebGLRenderTargetCube ) {\n\n\t\t\t\t\tif ( ! warned ) {\n\n\t\t\t\t\t\tconsole.warn( \"THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead.\" );\n\t\t\t\t\t\twarned = true;\n\n\t\t\t\t\t}\n\n\t\t\t\t\ttexture = texture.texture;\n\n\t\t\t\t}\n\n\t\t\t\t// currently relying on the fact that WebGLRenderTargetCube.texture is a Texture and NOT a CubeTexture\n\t\t\t\t// TODO: unify these code paths\n\t\t\t\tif ( ( texture && texture.isCubeTexture ) ||\n\t\t\t\t\t( Array.isArray( texture.image ) && texture.image.length === 6 ) ) {\n\n\t\t\t\t\t// CompressedTexture can have Array in image :/\n\n\t\t\t\t\t// this function alone should take care of cube textures\n\t\t\t\t\ttextures.setTextureCube( texture, slot );\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// assumed: texture property of THREE.WebGLRenderTargetCube\n\n\t\t\t\t\ttextures.setTextureCubeDynamic( texture, slot );\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t}() );\n\n\t\t//\n\n\t\tthis.setFramebuffer = function ( value ) {\n\n\t\t\t_framebuffer = value;\n\n\t\t};\n\n\t\tthis.getRenderTarget = function () {\n\n\t\t\treturn _currentRenderTarget;\n\n\t\t};\n\n\t\tthis.setRenderTarget = function ( renderTarget ) {\n\n\t\t\t_currentRenderTarget = renderTarget;\n\n\t\t\tif ( renderTarget && properties.get( renderTarget ).__webglFramebuffer === undefined ) {\n\n\t\t\t\ttextures.setupRenderTarget( renderTarget );\n\n\t\t\t}\n\n\t\t\tvar framebuffer = _framebuffer;\n\t\t\tvar isCube = false;\n\n\t\t\tif ( renderTarget ) {\n\n\t\t\t\tvar __webglFramebuffer = properties.get( renderTarget ).__webglFramebuffer;\n\n\t\t\t\tif ( renderTarget.isWebGLRenderTargetCube ) {\n\n\t\t\t\t\tframebuffer = __webglFramebuffer[ renderTarget.activeCubeFace ];\n\t\t\t\t\tisCube = true;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tframebuffer = __webglFramebuffer;\n\n\t\t\t\t}\n\n\t\t\t\t_currentViewport.copy( renderTarget.viewport );\n\t\t\t\t_currentScissor.copy( renderTarget.scissor );\n\t\t\t\t_currentScissorTest = renderTarget.scissorTest;\n\n\t\t\t} else {\n\n\t\t\t\t_currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio );\n\t\t\t\t_currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio );\n\t\t\t\t_currentScissorTest = _scissorTest;\n\n\t\t\t}\n\n\t\t\tif ( _currentFramebuffer !== framebuffer ) {\n\n\t\t\t\t_gl.bindFramebuffer( 36160, framebuffer );\n\t\t\t\t_currentFramebuffer = framebuffer;\n\n\t\t\t}\n\n\t\t\tstate.viewport( _currentViewport );\n\t\t\tstate.scissor( _currentScissor );\n\t\t\tstate.setScissorTest( _currentScissorTest );\n\n\t\t\tif ( isCube ) {\n\n\t\t\t\tvar textureProperties = properties.get( renderTarget.texture );\n\t\t\t\t_gl.framebufferTexture2D( 36160, 36064, 34069 + renderTarget.activeCubeFace, textureProperties.__webglTexture, renderTarget.activeMipMapLevel );\n\n\t\t\t}\n\n\t\t};\n\n\t\tthis.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer ) {\n\n\t\t\tif ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {\n\n\t\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tvar framebuffer = properties.get( renderTarget ).__webglFramebuffer;\n\n\t\t\tif ( framebuffer ) {\n\n\t\t\t\tvar restore = false;\n\n\t\t\t\tif ( framebuffer !== _currentFramebuffer ) {\n\n\t\t\t\t\t_gl.bindFramebuffer( 36160, framebuffer );\n\n\t\t\t\t\trestore = true;\n\n\t\t\t\t}\n\n\t\t\t\ttry {\n\n\t\t\t\t\tvar texture = renderTarget.texture;\n\t\t\t\t\tvar textureFormat = texture.format;\n\t\t\t\t\tvar textureType = texture.type;\n\n\t\t\t\t\tif ( textureFormat !== RGBAFormat && utils.convert( textureFormat ) !== _gl.getParameter( 35739 ) ) {\n\n\t\t\t\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );\n\t\t\t\t\t\treturn;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( 35738 ) && // IE11, Edge and Chrome Mac < 52 (#9513)\n\t\t\t\t\t\t! ( textureType === FloatType && ( capabilities.isWebGL2 || extensions.get( 'OES_texture_float' ) || extensions.get( 'WEBGL_color_buffer_float' ) ) ) && // Chrome Mac >= 52 and Firefox\n\t\t\t\t\t\t! ( textureType === HalfFloatType && ( capabilities.isWebGL2 ? extensions.get( 'EXT_color_buffer_float' ) : extensions.get( 'EXT_color_buffer_half_float' ) ) ) ) {\n\n\t\t\t\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );\n\t\t\t\t\t\treturn;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( _gl.checkFramebufferStatus( 36160 ) === 36053 ) {\n\n\t\t\t\t\t\t// the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)\n\n\t\t\t\t\t\tif ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {\n\n\t\t\t\t\t\t\t_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), buffer );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.' );\n\n\t\t\t\t\t}\n\n\t\t\t\t} finally {\n\n\t\t\t\t\tif ( restore ) {\n\n\t\t\t\t\t\t_gl.bindFramebuffer( 36160, _currentFramebuffer );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t};\n\n\t\tthis.copyFramebufferToTexture = function ( position, texture, level ) {\n\n\t\t\tvar width = texture.image.width;\n\t\t\tvar height = texture.image.height;\n\t\t\tvar glFormat = utils.convert( texture.format );\n\n\t\t\tthis.setTexture2D( texture, 0 );\n\n\t\t\t_gl.copyTexImage2D( 3553, level || 0, glFormat, position.x, position.y, width, height, 0 );\n\n\t\t};\n\n\t\tthis.copyTextureToTexture = function ( position, srcTexture, dstTexture, level ) {\n\n\t\t\tvar width = srcTexture.image.width;\n\t\t\tvar height = srcTexture.image.height;\n\t\t\tvar glFormat = utils.convert( dstTexture.format );\n\t\t\tvar glType = utils.convert( dstTexture.type );\n\n\t\t\tthis.setTexture2D( dstTexture, 0 );\n\n\t\t\tif ( srcTexture.isDataTexture ) {\n\n\t\t\t\t_gl.texSubImage2D( 3553, level || 0, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.texSubImage2D( 3553, level || 0, position.x, position.y, glFormat, glType, srcTexture.image );\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author alteredq / http://alteredqualia.com/\n\t */\n\n\tfunction FogExp2( color, density ) {\n\n\t\tthis.name = '';\n\n\t\tthis.color = new Color( color );\n\t\tthis.density = ( density !== undefined ) ? density : 0.00025;\n\n\t}\n\n\tFogExp2.prototype.isFogExp2 = true;\n\n\tFogExp2.prototype.clone = function () {\n\n\t\treturn new FogExp2( this.color, this.density );\n\n\t};\n\n\tFogExp2.prototype.toJSON = function ( /* meta */ ) {\n\n\t\treturn {\n\t\t\ttype: 'FogExp2',\n\t\t\tcolor: this.color.getHex(),\n\t\t\tdensity: this.density\n\t\t};\n\n\t};\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author alteredq / http://alteredqualia.com/\n\t */\n\n\tfunction Fog( color, near, far ) {\n\n\t\tthis.name = '';\n\n\t\tthis.color = new Color( color );\n\n\t\tthis.near = ( near !== undefined ) ? near : 1;\n\t\tthis.far = ( far !== undefined ) ? far : 1000;\n\n\t}\n\n\tFog.prototype.isFog = true;\n\n\tFog.prototype.clone = function () {\n\n\t\treturn new Fog( this.color, this.near, this.far );\n\n\t};\n\n\tFog.prototype.toJSON = function ( /* meta */ ) {\n\n\t\treturn {\n\t\t\ttype: 'Fog',\n\t\t\tcolor: this.color.getHex(),\n\t\t\tnear: this.near,\n\t\t\tfar: this.far\n\t\t};\n\n\t};\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction Scene() {\n\n\t\tObject3D.call( this );\n\n\t\tthis.type = 'Scene';\n\n\t\tthis.background = null;\n\t\tthis.fog = null;\n\t\tthis.overrideMaterial = null;\n\n\t\tthis.autoUpdate = true; // checked by the renderer\n\n\t}\n\n\tScene.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\t\tconstructor: Scene,\n\n\t\tcopy: function ( source, recursive ) {\n\n\t\t\tObject3D.prototype.copy.call( this, source, recursive );\n\n\t\t\tif ( source.background !== null ) this.background = source.background.clone();\n\t\t\tif ( source.fog !== null ) this.fog = source.fog.clone();\n\t\t\tif ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone();\n\n\t\t\tthis.autoUpdate = source.autoUpdate;\n\t\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttoJSON: function ( meta ) {\n\n\t\t\tvar data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\t\tif ( this.background !== null ) data.object.background = this.background.toJSON( meta );\n\t\t\tif ( this.fog !== null ) data.object.fog = this.fog.toJSON();\n\n\t\t\treturn data;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author benaadams / https://twitter.com/ben_a_adams\n\t */\n\n\tfunction InterleavedBuffer( array, stride ) {\n\n\t\tthis.array = array;\n\t\tthis.stride = stride;\n\t\tthis.count = array !== undefined ? array.length / stride : 0;\n\n\t\tthis.dynamic = false;\n\t\tthis.updateRange = { offset: 0, count: - 1 };\n\n\t\tthis.version = 0;\n\n\t}\n\n\tObject.defineProperty( InterleavedBuffer.prototype, 'needsUpdate', {\n\n\t\tset: function ( value ) {\n\n\t\t\tif ( value === true ) this.version ++;\n\n\t\t}\n\n\t} );\n\n\tObject.assign( InterleavedBuffer.prototype, {\n\n\t\tisInterleavedBuffer: true,\n\n\t\tonUploadCallback: function () {},\n\n\t\tsetArray: function ( array ) {\n\n\t\t\tif ( Array.isArray( array ) ) {\n\n\t\t\t\tthrow new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' );\n\n\t\t\t}\n\n\t\t\tthis.count = array !== undefined ? array.length / this.stride : 0;\n\t\t\tthis.array = array;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetDynamic: function ( value ) {\n\n\t\t\tthis.dynamic = value;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcopy: function ( source ) {\n\n\t\t\tthis.array = new source.array.constructor( source.array );\n\t\t\tthis.count = source.count;\n\t\t\tthis.stride = source.stride;\n\t\t\tthis.dynamic = source.dynamic;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcopyAt: function ( index1, attribute, index2 ) {\n\n\t\t\tindex1 *= this.stride;\n\t\t\tindex2 *= attribute.stride;\n\n\t\t\tfor ( var i = 0, l = this.stride; i < l; i ++ ) {\n\n\t\t\t\tthis.array[ index1 + i ] = attribute.array[ index2 + i ];\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tset: function ( value, offset ) {\n\n\t\t\tif ( offset === undefined ) offset = 0;\n\n\t\t\tthis.array.set( value, offset );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t},\n\n\t\tonUpload: function ( callback ) {\n\n\t\t\tthis.onUploadCallback = callback;\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author benaadams / https://twitter.com/ben_a_adams\n\t */\n\n\tfunction InterleavedBufferAttribute( interleavedBuffer, itemSize, offset, normalized ) {\n\n\t\tthis.data = interleavedBuffer;\n\t\tthis.itemSize = itemSize;\n\t\tthis.offset = offset;\n\n\t\tthis.normalized = normalized === true;\n\n\t}\n\n\tObject.defineProperties( InterleavedBufferAttribute.prototype, {\n\n\t\tcount: {\n\n\t\t\tget: function () {\n\n\t\t\t\treturn this.data.count;\n\n\t\t\t}\n\n\t\t},\n\n\t\tarray: {\n\n\t\t\tget: function () {\n\n\t\t\t\treturn this.data.array;\n\n\t\t\t}\n\n\t\t}\n\n\t} );\n\n\tObject.assign( InterleavedBufferAttribute.prototype, {\n\n\t\tisInterleavedBufferAttribute: true,\n\n\t\tsetX: function ( index, x ) {\n\n\t\t\tthis.data.array[ index * this.data.stride + this.offset ] = x;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetY: function ( index, y ) {\n\n\t\t\tthis.data.array[ index * this.data.stride + this.offset + 1 ] = y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetZ: function ( index, z ) {\n\n\t\t\tthis.data.array[ index * this.data.stride + this.offset + 2 ] = z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetW: function ( index, w ) {\n\n\t\t\tthis.data.array[ index * this.data.stride + this.offset + 3 ] = w;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetX: function ( index ) {\n\n\t\t\treturn this.data.array[ index * this.data.stride + this.offset ];\n\n\t\t},\n\n\t\tgetY: function ( index ) {\n\n\t\t\treturn this.data.array[ index * this.data.stride + this.offset + 1 ];\n\n\t\t},\n\n\t\tgetZ: function ( index ) {\n\n\t\t\treturn this.data.array[ index * this.data.stride + this.offset + 2 ];\n\n\t\t},\n\n\t\tgetW: function ( index ) {\n\n\t\t\treturn this.data.array[ index * this.data.stride + this.offset + 3 ];\n\n\t\t},\n\n\t\tsetXY: function ( index, x, y ) {\n\n\t\t\tindex = index * this.data.stride + this.offset;\n\n\t\t\tthis.data.array[ index + 0 ] = x;\n\t\t\tthis.data.array[ index + 1 ] = y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetXYZ: function ( index, x, y, z ) {\n\n\t\t\tindex = index * this.data.stride + this.offset;\n\n\t\t\tthis.data.array[ index + 0 ] = x;\n\t\t\tthis.data.array[ index + 1 ] = y;\n\t\t\tthis.data.array[ index + 2 ] = z;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetXYZW: function ( index, x, y, z, w ) {\n\n\t\t\tindex = index * this.data.stride + this.offset;\n\n\t\t\tthis.data.array[ index + 0 ] = x;\n\t\t\tthis.data.array[ index + 1 ] = y;\n\t\t\tthis.data.array[ index + 2 ] = z;\n\t\t\tthis.data.array[ index + 3 ] = w;\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t *\n\t * parameters = {\n\t *  color: <hex>,\n\t *  map: new THREE.Texture( <Image> ),\n\t *  rotation: <float>,\n\t *  sizeAttenuation: <bool>\n\t * }\n\t */\n\n\tfunction SpriteMaterial( parameters ) {\n\n\t\tMaterial.call( this );\n\n\t\tthis.type = 'SpriteMaterial';\n\n\t\tthis.color = new Color( 0xffffff );\n\t\tthis.map = null;\n\n\t\tthis.rotation = 0;\n\n\t\tthis.sizeAttenuation = true;\n\n\t\tthis.lights = false;\n\t\tthis.transparent = true;\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n\tSpriteMaterial.prototype = Object.create( Material.prototype );\n\tSpriteMaterial.prototype.constructor = SpriteMaterial;\n\tSpriteMaterial.prototype.isSpriteMaterial = true;\n\n\tSpriteMaterial.prototype.copy = function ( source ) {\n\n\t\tMaterial.prototype.copy.call( this, source );\n\n\t\tthis.color.copy( source.color );\n\t\tthis.map = source.map;\n\n\t\tthis.rotation = source.rotation;\n\n\t\tthis.sizeAttenuation = source.sizeAttenuation;\n\n\t\treturn this;\n\n\t};\n\n\t/**\n\t * @author mikael emtinger / http://gomo.se/\n\t * @author alteredq / http://alteredqualia.com/\n\t */\n\n\tvar geometry;\n\n\tfunction Sprite( material ) {\n\n\t\tObject3D.call( this );\n\n\t\tthis.type = 'Sprite';\n\n\t\tif ( geometry === undefined ) {\n\n\t\t\tgeometry = new BufferGeometry();\n\n\t\t\tvar float32Array = new Float32Array( [\n\t\t\t\t- 0.5, - 0.5, 0, 0, 0,\n\t\t\t\t0.5, - 0.5, 0, 1, 0,\n\t\t\t\t0.5, 0.5, 0, 1, 1,\n\t\t\t\t- 0.5, 0.5, 0, 0, 1\n\t\t\t] );\n\n\t\t\tvar interleavedBuffer = new InterleavedBuffer( float32Array, 5 );\n\n\t\t\tgeometry.setIndex( [ 0, 1, 2,\t0, 2, 3 ] );\n\t\t\tgeometry.addAttribute( 'position', new InterleavedBufferAttribute( interleavedBuffer, 3, 0, false ) );\n\t\t\tgeometry.addAttribute( 'uv', new InterleavedBufferAttribute( interleavedBuffer, 2, 3, false ) );\n\n\t\t}\n\n\t\tthis.geometry = geometry;\n\t\tthis.material = ( material !== undefined ) ? material : new SpriteMaterial();\n\n\t\tthis.center = new Vector2( 0.5, 0.5 );\n\n\t}\n\n\tSprite.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\t\tconstructor: Sprite,\n\n\t\tisSprite: true,\n\n\t\traycast: ( function () {\n\n\t\t\tvar intersectPoint = new Vector3();\n\t\t\tvar worldScale = new Vector3();\n\t\t\tvar mvPosition = new Vector3();\n\n\t\t\tvar alignedPosition = new Vector2();\n\t\t\tvar rotatedPosition = new Vector2();\n\t\t\tvar viewWorldMatrix = new Matrix4();\n\n\t\t\tvar vA = new Vector3();\n\t\t\tvar vB = new Vector3();\n\t\t\tvar vC = new Vector3();\n\n\t\t\tvar uvA = new Vector2();\n\t\t\tvar uvB = new Vector2();\n\t\t\tvar uvC = new Vector2();\n\n\t\t\tfunction transformVertex( vertexPosition, mvPosition, center, scale, sin, cos ) {\n\n\t\t\t\t// compute position in camera space\n\t\t\t\talignedPosition.subVectors( vertexPosition, center ).addScalar( 0.5 ).multiply( scale );\n\n\t\t\t\t// to check if rotation is not zero\n\t\t\t\tif ( sin !== undefined ) {\n\n\t\t\t\t\trotatedPosition.x = ( cos * alignedPosition.x ) - ( sin * alignedPosition.y );\n\t\t\t\t\trotatedPosition.y = ( sin * alignedPosition.x ) + ( cos * alignedPosition.y );\n\n\t\t\t\t} else {\n\n\t\t\t\t\trotatedPosition.copy( alignedPosition );\n\n\t\t\t\t}\n\n\n\t\t\t\tvertexPosition.copy( mvPosition );\n\t\t\t\tvertexPosition.x += rotatedPosition.x;\n\t\t\t\tvertexPosition.y += rotatedPosition.y;\n\n\t\t\t\t// transform to world space\n\t\t\t\tvertexPosition.applyMatrix4( viewWorldMatrix );\n\n\t\t\t}\n\n\t\t\treturn function raycast( raycaster, intersects ) {\n\n\t\t\t\tworldScale.setFromMatrixScale( this.matrixWorld );\n\t\t\t\tviewWorldMatrix.getInverse( this.modelViewMatrix ).premultiply( this.matrixWorld );\n\t\t\t\tmvPosition.setFromMatrixPosition( this.modelViewMatrix );\n\n\t\t\t\tvar rotation = this.material.rotation;\n\t\t\t\tvar sin, cos;\n\t\t\t\tif ( rotation !== 0 ) {\n\n\t\t\t\t\tcos = Math.cos( rotation );\n\t\t\t\t\tsin = Math.sin( rotation );\n\n\t\t\t\t}\n\n\t\t\t\tvar center = this.center;\n\n\t\t\t\ttransformVertex( vA.set( - 0.5, - 0.5, 0 ), mvPosition, center, worldScale, sin, cos );\n\t\t\t\ttransformVertex( vB.set( 0.5, - 0.5, 0 ), mvPosition, center, worldScale, sin, cos );\n\t\t\t\ttransformVertex( vC.set( 0.5, 0.5, 0 ), mvPosition, center, worldScale, sin, cos );\n\n\t\t\t\tuvA.set( 0, 0 );\n\t\t\t\tuvB.set( 1, 0 );\n\t\t\t\tuvC.set( 1, 1 );\n\n\t\t\t\t// check first triangle\n\t\t\t\tvar intersect = raycaster.ray.intersectTriangle( vA, vB, vC, false, intersectPoint );\n\n\t\t\t\tif ( intersect === null ) {\n\n\t\t\t\t\t// check second triangle\n\t\t\t\t\ttransformVertex( vB.set( - 0.5, 0.5, 0 ), mvPosition, center, worldScale, sin, cos );\n\t\t\t\t\tuvB.set( 0, 1 );\n\n\t\t\t\t\tintersect = raycaster.ray.intersectTriangle( vA, vC, vB, false, intersectPoint );\n\t\t\t\t\tif ( intersect === null ) {\n\n\t\t\t\t\t\treturn;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tvar distance = raycaster.ray.origin.distanceTo( intersectPoint );\n\n\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) return;\n\n\t\t\t\tintersects.push( {\n\n\t\t\t\t\tdistance: distance,\n\t\t\t\t\tpoint: intersectPoint.clone(),\n\t\t\t\t\tuv: Triangle.getUV( intersectPoint, vA, vB, vC, uvA, uvB, uvC, new Vector2() ),\n\t\t\t\t\tface: null,\n\t\t\t\t\tobject: this\n\n\t\t\t\t} );\n\n\t\t\t};\n\n\t\t}() ),\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor( this.material ).copy( this );\n\n\t\t},\n\n\t\tcopy: function ( source ) {\n\n\t\t\tObject3D.prototype.copy.call( this, source );\n\n\t\t\tif ( source.center !== undefined ) this.center.copy( source.center );\n\n\t\t\treturn this;\n\n\t\t}\n\n\n\t} );\n\n\t/**\n\t * @author mikael emtinger / http://gomo.se/\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction LOD() {\n\n\t\tObject3D.call( this );\n\n\t\tthis.type = 'LOD';\n\n\t\tObject.defineProperties( this, {\n\t\t\tlevels: {\n\t\t\t\tenumerable: true,\n\t\t\t\tvalue: []\n\t\t\t}\n\t\t} );\n\n\t}\n\n\tLOD.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\t\tconstructor: LOD,\n\n\t\tcopy: function ( source ) {\n\n\t\t\tObject3D.prototype.copy.call( this, source, false );\n\n\t\t\tvar levels = source.levels;\n\n\t\t\tfor ( var i = 0, l = levels.length; i < l; i ++ ) {\n\n\t\t\t\tvar level = levels[ i ];\n\n\t\t\t\tthis.addLevel( level.object.clone(), level.distance );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\taddLevel: function ( object, distance ) {\n\n\t\t\tif ( distance === undefined ) distance = 0;\n\n\t\t\tdistance = Math.abs( distance );\n\n\t\t\tvar levels = this.levels;\n\n\t\t\tfor ( var l = 0; l < levels.length; l ++ ) {\n\n\t\t\t\tif ( distance < levels[ l ].distance ) {\n\n\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tlevels.splice( l, 0, { distance: distance, object: object } );\n\n\t\t\tthis.add( object );\n\n\t\t},\n\n\t\tgetObjectForDistance: function ( distance ) {\n\n\t\t\tvar levels = this.levels;\n\n\t\t\tfor ( var i = 1, l = levels.length; i < l; i ++ ) {\n\n\t\t\t\tif ( distance < levels[ i ].distance ) {\n\n\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn levels[ i - 1 ].object;\n\n\t\t},\n\n\t\traycast: ( function () {\n\n\t\t\tvar matrixPosition = new Vector3();\n\n\t\t\treturn function raycast( raycaster, intersects ) {\n\n\t\t\t\tmatrixPosition.setFromMatrixPosition( this.matrixWorld );\n\n\t\t\t\tvar distance = raycaster.ray.origin.distanceTo( matrixPosition );\n\n\t\t\t\tthis.getObjectForDistance( distance ).raycast( raycaster, intersects );\n\n\t\t\t};\n\n\t\t}() ),\n\n\t\tupdate: function () {\n\n\t\t\tvar v1 = new Vector3();\n\t\t\tvar v2 = new Vector3();\n\n\t\t\treturn function update( camera ) {\n\n\t\t\t\tvar levels = this.levels;\n\n\t\t\t\tif ( levels.length > 1 ) {\n\n\t\t\t\t\tv1.setFromMatrixPosition( camera.matrixWorld );\n\t\t\t\t\tv2.setFromMatrixPosition( this.matrixWorld );\n\n\t\t\t\t\tvar distance = v1.distanceTo( v2 );\n\n\t\t\t\t\tlevels[ 0 ].object.visible = true;\n\n\t\t\t\t\tfor ( var i = 1, l = levels.length; i < l; i ++ ) {\n\n\t\t\t\t\t\tif ( distance >= levels[ i ].distance ) {\n\n\t\t\t\t\t\t\tlevels[ i - 1 ].object.visible = false;\n\t\t\t\t\t\t\tlevels[ i ].object.visible = true;\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfor ( ; i < l; i ++ ) {\n\n\t\t\t\t\t\tlevels[ i ].object.visible = false;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t}(),\n\n\t\ttoJSON: function ( meta ) {\n\n\t\t\tvar data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\t\tdata.object.levels = [];\n\n\t\t\tvar levels = this.levels;\n\n\t\t\tfor ( var i = 0, l = levels.length; i < l; i ++ ) {\n\n\t\t\t\tvar level = levels[ i ];\n\n\t\t\t\tdata.object.levels.push( {\n\t\t\t\t\tobject: level.object.uuid,\n\t\t\t\t\tdistance: level.distance\n\t\t\t\t} );\n\n\t\t\t}\n\n\t\t\treturn data;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mikael emtinger / http://gomo.se/\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author ikerr / http://verold.com\n\t */\n\n\tfunction SkinnedMesh( geometry, material ) {\n\n\t\tif ( geometry && geometry.isGeometry ) {\n\n\t\t\tconsole.error( 'THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );\n\n\t\t}\n\n\t\tMesh.call( this, geometry, material );\n\n\t\tthis.type = 'SkinnedMesh';\n\n\t\tthis.bindMode = 'attached';\n\t\tthis.bindMatrix = new Matrix4();\n\t\tthis.bindMatrixInverse = new Matrix4();\n\n\t}\n\n\tSkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {\n\n\t\tconstructor: SkinnedMesh,\n\n\t\tisSkinnedMesh: true,\n\n\t\tbind: function ( skeleton, bindMatrix ) {\n\n\t\t\tthis.skeleton = skeleton;\n\n\t\t\tif ( bindMatrix === undefined ) {\n\n\t\t\t\tthis.updateMatrixWorld( true );\n\n\t\t\t\tthis.skeleton.calculateInverses();\n\n\t\t\t\tbindMatrix = this.matrixWorld;\n\n\t\t\t}\n\n\t\t\tthis.bindMatrix.copy( bindMatrix );\n\t\t\tthis.bindMatrixInverse.getInverse( bindMatrix );\n\n\t\t},\n\n\t\tpose: function () {\n\n\t\t\tthis.skeleton.pose();\n\n\t\t},\n\n\t\tnormalizeSkinWeights: function () {\n\n\t\t\tvar vector = new Vector4();\n\n\t\t\tvar skinWeight = this.geometry.attributes.skinWeight;\n\n\t\t\tfor ( var i = 0, l = skinWeight.count; i < l; i ++ ) {\n\n\t\t\t\tvector.x = skinWeight.getX( i );\n\t\t\t\tvector.y = skinWeight.getY( i );\n\t\t\t\tvector.z = skinWeight.getZ( i );\n\t\t\t\tvector.w = skinWeight.getW( i );\n\n\t\t\t\tvar scale = 1.0 / vector.manhattanLength();\n\n\t\t\t\tif ( scale !== Infinity ) {\n\n\t\t\t\t\tvector.multiplyScalar( scale );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tvector.set( 1, 0, 0, 0 ); // do something reasonable\n\n\t\t\t\t}\n\n\t\t\t\tskinWeight.setXYZW( i, vector.x, vector.y, vector.z, vector.w );\n\n\t\t\t}\n\n\t\t},\n\n\t\tupdateMatrixWorld: function ( force ) {\n\n\t\t\tMesh.prototype.updateMatrixWorld.call( this, force );\n\n\t\t\tif ( this.bindMode === 'attached' ) {\n\n\t\t\t\tthis.bindMatrixInverse.getInverse( this.matrixWorld );\n\n\t\t\t} else if ( this.bindMode === 'detached' ) {\n\n\t\t\t\tthis.bindMatrixInverse.getInverse( this.bindMatrix );\n\n\t\t\t} else {\n\n\t\t\t\tconsole.warn( 'THREE.SkinnedMesh: Unrecognized bindMode: ' + this.bindMode );\n\n\t\t\t}\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor( this.geometry, this.material ).copy( this );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mikael emtinger / http://gomo.se/\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author michael guerrero / http://realitymeltdown.com\n\t * @author ikerr / http://verold.com\n\t */\n\n\tfunction Skeleton( bones, boneInverses ) {\n\n\t\t// copy the bone array\n\n\t\tbones = bones || [];\n\n\t\tthis.bones = bones.slice( 0 );\n\t\tthis.boneMatrices = new Float32Array( this.bones.length * 16 );\n\n\t\t// use the supplied bone inverses or calculate the inverses\n\n\t\tif ( boneInverses === undefined ) {\n\n\t\t\tthis.calculateInverses();\n\n\t\t} else {\n\n\t\t\tif ( this.bones.length === boneInverses.length ) {\n\n\t\t\t\tthis.boneInverses = boneInverses.slice( 0 );\n\n\t\t\t} else {\n\n\t\t\t\tconsole.warn( 'THREE.Skeleton boneInverses is the wrong length.' );\n\n\t\t\t\tthis.boneInverses = [];\n\n\t\t\t\tfor ( var i = 0, il = this.bones.length; i < il; i ++ ) {\n\n\t\t\t\t\tthis.boneInverses.push( new Matrix4() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tObject.assign( Skeleton.prototype, {\n\n\t\tcalculateInverses: function () {\n\n\t\t\tthis.boneInverses = [];\n\n\t\t\tfor ( var i = 0, il = this.bones.length; i < il; i ++ ) {\n\n\t\t\t\tvar inverse = new Matrix4();\n\n\t\t\t\tif ( this.bones[ i ] ) {\n\n\t\t\t\t\tinverse.getInverse( this.bones[ i ].matrixWorld );\n\n\t\t\t\t}\n\n\t\t\t\tthis.boneInverses.push( inverse );\n\n\t\t\t}\n\n\t\t},\n\n\t\tpose: function () {\n\n\t\t\tvar bone, i, il;\n\n\t\t\t// recover the bind-time world matrices\n\n\t\t\tfor ( i = 0, il = this.bones.length; i < il; i ++ ) {\n\n\t\t\t\tbone = this.bones[ i ];\n\n\t\t\t\tif ( bone ) {\n\n\t\t\t\t\tbone.matrixWorld.getInverse( this.boneInverses[ i ] );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// compute the local matrices, positions, rotations and scales\n\n\t\t\tfor ( i = 0, il = this.bones.length; i < il; i ++ ) {\n\n\t\t\t\tbone = this.bones[ i ];\n\n\t\t\t\tif ( bone ) {\n\n\t\t\t\t\tif ( bone.parent && bone.parent.isBone ) {\n\n\t\t\t\t\t\tbone.matrix.getInverse( bone.parent.matrixWorld );\n\t\t\t\t\t\tbone.matrix.multiply( bone.matrixWorld );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tbone.matrix.copy( bone.matrixWorld );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbone.matrix.decompose( bone.position, bone.quaternion, bone.scale );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t},\n\n\t\tupdate: ( function () {\n\n\t\t\tvar offsetMatrix = new Matrix4();\n\t\t\tvar identityMatrix = new Matrix4();\n\n\t\t\treturn function update() {\n\n\t\t\t\tvar bones = this.bones;\n\t\t\t\tvar boneInverses = this.boneInverses;\n\t\t\t\tvar boneMatrices = this.boneMatrices;\n\t\t\t\tvar boneTexture = this.boneTexture;\n\n\t\t\t\t// flatten bone matrices to array\n\n\t\t\t\tfor ( var i = 0, il = bones.length; i < il; i ++ ) {\n\n\t\t\t\t\t// compute the offset between the current and the original transform\n\n\t\t\t\t\tvar matrix = bones[ i ] ? bones[ i ].matrixWorld : identityMatrix;\n\n\t\t\t\t\toffsetMatrix.multiplyMatrices( matrix, boneInverses[ i ] );\n\t\t\t\t\toffsetMatrix.toArray( boneMatrices, i * 16 );\n\n\t\t\t\t}\n\n\t\t\t\tif ( boneTexture !== undefined ) {\n\n\t\t\t\t\tboneTexture.needsUpdate = true;\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t} )(),\n\n\t\tclone: function () {\n\n\t\t\treturn new Skeleton( this.bones, this.boneInverses );\n\n\t\t},\n\n\t\tgetBoneByName: function ( name ) {\n\n\t\t\tfor ( var i = 0, il = this.bones.length; i < il; i ++ ) {\n\n\t\t\t\tvar bone = this.bones[ i ];\n\n\t\t\t\tif ( bone.name === name ) {\n\n\t\t\t\t\treturn bone;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn undefined;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mikael emtinger / http://gomo.se/\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author ikerr / http://verold.com\n\t */\n\n\tfunction Bone() {\n\n\t\tObject3D.call( this );\n\n\t\tthis.type = 'Bone';\n\n\t}\n\n\tBone.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\t\tconstructor: Bone,\n\n\t\tisBone: true\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author alteredq / http://alteredqualia.com/\n\t *\n\t * parameters = {\n\t *  color: <hex>,\n\t *  opacity: <float>,\n\t *\n\t *  linewidth: <float>,\n\t *  linecap: \"round\",\n\t *  linejoin: \"round\"\n\t * }\n\t */\n\n\tfunction LineBasicMaterial( parameters ) {\n\n\t\tMaterial.call( this );\n\n\t\tthis.type = 'LineBasicMaterial';\n\n\t\tthis.color = new Color( 0xffffff );\n\n\t\tthis.linewidth = 1;\n\t\tthis.linecap = 'round';\n\t\tthis.linejoin = 'round';\n\n\t\tthis.lights = false;\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n\tLineBasicMaterial.prototype = Object.create( Material.prototype );\n\tLineBasicMaterial.prototype.constructor = LineBasicMaterial;\n\n\tLineBasicMaterial.prototype.isLineBasicMaterial = true;\n\n\tLineBasicMaterial.prototype.copy = function ( source ) {\n\n\t\tMaterial.prototype.copy.call( this, source );\n\n\t\tthis.color.copy( source.color );\n\n\t\tthis.linewidth = source.linewidth;\n\t\tthis.linecap = source.linecap;\n\t\tthis.linejoin = source.linejoin;\n\n\t\treturn this;\n\n\t};\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction Line( geometry, material, mode ) {\n\n\t\tif ( mode === 1 ) {\n\n\t\t\tconsole.error( 'THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead.' );\n\n\t\t}\n\n\t\tObject3D.call( this );\n\n\t\tthis.type = 'Line';\n\n\t\tthis.geometry = geometry !== undefined ? geometry : new BufferGeometry();\n\t\tthis.material = material !== undefined ? material : new LineBasicMaterial( { color: Math.random() * 0xffffff } );\n\n\t}\n\n\tLine.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\t\tconstructor: Line,\n\n\t\tisLine: true,\n\n\t\tcomputeLineDistances: ( function () {\n\n\t\t\tvar start = new Vector3();\n\t\t\tvar end = new Vector3();\n\n\t\t\treturn function computeLineDistances() {\n\n\t\t\t\tvar geometry = this.geometry;\n\n\t\t\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\t\t\t// we assume non-indexed geometry\n\n\t\t\t\t\tif ( geometry.index === null ) {\n\n\t\t\t\t\t\tvar positionAttribute = geometry.attributes.position;\n\t\t\t\t\t\tvar lineDistances = [ 0 ];\n\n\t\t\t\t\t\tfor ( var i = 1, l = positionAttribute.count; i < l; i ++ ) {\n\n\t\t\t\t\t\t\tstart.fromBufferAttribute( positionAttribute, i - 1 );\n\t\t\t\t\t\t\tend.fromBufferAttribute( positionAttribute, i );\n\n\t\t\t\t\t\t\tlineDistances[ i ] = lineDistances[ i - 1 ];\n\t\t\t\t\t\t\tlineDistances[ i ] += start.distanceTo( end );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tgeometry.addAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tconsole.warn( 'THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\t\t\tvar vertices = geometry.vertices;\n\t\t\t\t\tvar lineDistances = geometry.lineDistances;\n\n\t\t\t\t\tlineDistances[ 0 ] = 0;\n\n\t\t\t\t\tfor ( var i = 1, l = vertices.length; i < l; i ++ ) {\n\n\t\t\t\t\t\tlineDistances[ i ] = lineDistances[ i - 1 ];\n\t\t\t\t\t\tlineDistances[ i ] += vertices[ i - 1 ].distanceTo( vertices[ i ] );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}() ),\n\n\t\traycast: ( function () {\n\n\t\t\tvar inverseMatrix = new Matrix4();\n\t\t\tvar ray = new Ray();\n\t\t\tvar sphere = new Sphere();\n\n\t\t\treturn function raycast( raycaster, intersects ) {\n\n\t\t\t\tvar precision = raycaster.linePrecision;\n\n\t\t\t\tvar geometry = this.geometry;\n\t\t\t\tvar matrixWorld = this.matrixWorld;\n\n\t\t\t\t// Checking boundingSphere distance to ray\n\n\t\t\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t\t\tsphere.copy( geometry.boundingSphere );\n\t\t\t\tsphere.applyMatrix4( matrixWorld );\n\t\t\t\tsphere.radius += precision;\n\n\t\t\t\tif ( raycaster.ray.intersectsSphere( sphere ) === false ) return;\n\n\t\t\t\t//\n\n\t\t\t\tinverseMatrix.getInverse( matrixWorld );\n\t\t\t\tray.copy( raycaster.ray ).applyMatrix4( inverseMatrix );\n\n\t\t\t\tvar localPrecision = precision / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );\n\t\t\t\tvar localPrecisionSq = localPrecision * localPrecision;\n\n\t\t\t\tvar vStart = new Vector3();\n\t\t\t\tvar vEnd = new Vector3();\n\t\t\t\tvar interSegment = new Vector3();\n\t\t\t\tvar interRay = new Vector3();\n\t\t\t\tvar step = ( this && this.isLineSegments ) ? 2 : 1;\n\n\t\t\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\t\t\tvar index = geometry.index;\n\t\t\t\t\tvar attributes = geometry.attributes;\n\t\t\t\t\tvar positions = attributes.position.array;\n\n\t\t\t\t\tif ( index !== null ) {\n\n\t\t\t\t\t\tvar indices = index.array;\n\n\t\t\t\t\t\tfor ( var i = 0, l = indices.length - 1; i < l; i += step ) {\n\n\t\t\t\t\t\t\tvar a = indices[ i ];\n\t\t\t\t\t\t\tvar b = indices[ i + 1 ];\n\n\t\t\t\t\t\t\tvStart.fromArray( positions, a * 3 );\n\t\t\t\t\t\t\tvEnd.fromArray( positions, b * 3 );\n\n\t\t\t\t\t\t\tvar distSq = ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );\n\n\t\t\t\t\t\t\tif ( distSq > localPrecisionSq ) continue;\n\n\t\t\t\t\t\t\tinterRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation\n\n\t\t\t\t\t\t\tvar distance = raycaster.ray.origin.distanceTo( interRay );\n\n\t\t\t\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) continue;\n\n\t\t\t\t\t\t\tintersects.push( {\n\n\t\t\t\t\t\t\t\tdistance: distance,\n\t\t\t\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\t\t\t\tpoint: interSegment.clone().applyMatrix4( this.matrixWorld ),\n\t\t\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\t\t\tface: null,\n\t\t\t\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\t\t\t\tobject: this\n\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tfor ( var i = 0, l = positions.length / 3 - 1; i < l; i += step ) {\n\n\t\t\t\t\t\t\tvStart.fromArray( positions, 3 * i );\n\t\t\t\t\t\t\tvEnd.fromArray( positions, 3 * i + 3 );\n\n\t\t\t\t\t\t\tvar distSq = ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );\n\n\t\t\t\t\t\t\tif ( distSq > localPrecisionSq ) continue;\n\n\t\t\t\t\t\t\tinterRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation\n\n\t\t\t\t\t\t\tvar distance = raycaster.ray.origin.distanceTo( interRay );\n\n\t\t\t\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) continue;\n\n\t\t\t\t\t\t\tintersects.push( {\n\n\t\t\t\t\t\t\t\tdistance: distance,\n\t\t\t\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\t\t\t\tpoint: interSegment.clone().applyMatrix4( this.matrixWorld ),\n\t\t\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\t\t\tface: null,\n\t\t\t\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\t\t\t\tobject: this\n\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\t\t\tvar vertices = geometry.vertices;\n\t\t\t\t\tvar nbVertices = vertices.length;\n\n\t\t\t\t\tfor ( var i = 0; i < nbVertices - 1; i += step ) {\n\n\t\t\t\t\t\tvar distSq = ray.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment );\n\n\t\t\t\t\t\tif ( distSq > localPrecisionSq ) continue;\n\n\t\t\t\t\t\tinterRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation\n\n\t\t\t\t\t\tvar distance = raycaster.ray.origin.distanceTo( interRay );\n\n\t\t\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) continue;\n\n\t\t\t\t\t\tintersects.push( {\n\n\t\t\t\t\t\t\tdistance: distance,\n\t\t\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\t\t\tpoint: interSegment.clone().applyMatrix4( this.matrixWorld ),\n\t\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\t\tface: null,\n\t\t\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\t\t\tobject: this\n\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t}() ),\n\n\t\tcopy: function ( source ) {\n\n\t\t\tObject3D.prototype.copy.call( this, source );\n\n\t\t\tthis.geometry.copy( source.geometry );\n\t\t\tthis.material.copy( source.material );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction LineSegments( geometry, material ) {\n\n\t\tLine.call( this, geometry, material );\n\n\t\tthis.type = 'LineSegments';\n\n\t}\n\n\tLineSegments.prototype = Object.assign( Object.create( Line.prototype ), {\n\n\t\tconstructor: LineSegments,\n\n\t\tisLineSegments: true,\n\n\t\tcomputeLineDistances: ( function () {\n\n\t\t\tvar start = new Vector3();\n\t\t\tvar end = new Vector3();\n\n\t\t\treturn function computeLineDistances() {\n\n\t\t\t\tvar geometry = this.geometry;\n\n\t\t\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\t\t\t// we assume non-indexed geometry\n\n\t\t\t\t\tif ( geometry.index === null ) {\n\n\t\t\t\t\t\tvar positionAttribute = geometry.attributes.position;\n\t\t\t\t\t\tvar lineDistances = [];\n\n\t\t\t\t\t\tfor ( var i = 0, l = positionAttribute.count; i < l; i += 2 ) {\n\n\t\t\t\t\t\t\tstart.fromBufferAttribute( positionAttribute, i );\n\t\t\t\t\t\t\tend.fromBufferAttribute( positionAttribute, i + 1 );\n\n\t\t\t\t\t\t\tlineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ];\n\t\t\t\t\t\t\tlineDistances[ i + 1 ] = lineDistances[ i ] + start.distanceTo( end );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tgeometry.addAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tconsole.warn( 'THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\t\t\tvar vertices = geometry.vertices;\n\t\t\t\t\tvar lineDistances = geometry.lineDistances;\n\n\t\t\t\t\tfor ( var i = 0, l = vertices.length; i < l; i += 2 ) {\n\n\t\t\t\t\t\tstart.copy( vertices[ i ] );\n\t\t\t\t\t\tend.copy( vertices[ i + 1 ] );\n\n\t\t\t\t\t\tlineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ];\n\t\t\t\t\t\tlineDistances[ i + 1 ] = lineDistances[ i ] + start.distanceTo( end );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}() )\n\n\t} );\n\n\t/**\n\t * @author mgreter / http://github.com/mgreter\n\t */\n\n\tfunction LineLoop( geometry, material ) {\n\n\t\tLine.call( this, geometry, material );\n\n\t\tthis.type = 'LineLoop';\n\n\t}\n\n\tLineLoop.prototype = Object.assign( Object.create( Line.prototype ), {\n\n\t\tconstructor: LineLoop,\n\n\t\tisLineLoop: true,\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author alteredq / http://alteredqualia.com/\n\t *\n\t * parameters = {\n\t *  color: <hex>,\n\t *  opacity: <float>,\n\t *  map: new THREE.Texture( <Image> ),\n\t *\n\t *  size: <float>,\n\t *  sizeAttenuation: <bool>\n\t *\n\t *  morphTargets: <bool>\n\t * }\n\t */\n\n\tfunction PointsMaterial( parameters ) {\n\n\t\tMaterial.call( this );\n\n\t\tthis.type = 'PointsMaterial';\n\n\t\tthis.color = new Color( 0xffffff );\n\n\t\tthis.map = null;\n\n\t\tthis.size = 1;\n\t\tthis.sizeAttenuation = true;\n\n\t\tthis.morphTargets = false;\n\n\t\tthis.lights = false;\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n\tPointsMaterial.prototype = Object.create( Material.prototype );\n\tPointsMaterial.prototype.constructor = PointsMaterial;\n\n\tPointsMaterial.prototype.isPointsMaterial = true;\n\n\tPointsMaterial.prototype.copy = function ( source ) {\n\n\t\tMaterial.prototype.copy.call( this, source );\n\n\t\tthis.color.copy( source.color );\n\n\t\tthis.map = source.map;\n\n\t\tthis.size = source.size;\n\t\tthis.sizeAttenuation = source.sizeAttenuation;\n\n\t\tthis.morphTargets = source.morphTargets;\n\n\t\treturn this;\n\n\t};\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t */\n\n\tfunction Points( geometry, material ) {\n\n\t\tObject3D.call( this );\n\n\t\tthis.type = 'Points';\n\n\t\tthis.geometry = geometry !== undefined ? geometry : new BufferGeometry();\n\t\tthis.material = material !== undefined ? material : new PointsMaterial( { color: Math.random() * 0xffffff } );\n\n\t}\n\n\tPoints.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\t\tconstructor: Points,\n\n\t\tisPoints: true,\n\n\t\traycast: ( function () {\n\n\t\t\tvar inverseMatrix = new Matrix4();\n\t\t\tvar ray = new Ray();\n\t\t\tvar sphere = new Sphere();\n\n\t\t\treturn function raycast( raycaster, intersects ) {\n\n\t\t\t\tvar object = this;\n\t\t\t\tvar geometry = this.geometry;\n\t\t\t\tvar matrixWorld = this.matrixWorld;\n\t\t\t\tvar threshold = raycaster.params.Points.threshold;\n\n\t\t\t\t// Checking boundingSphere distance to ray\n\n\t\t\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t\t\tsphere.copy( geometry.boundingSphere );\n\t\t\t\tsphere.applyMatrix4( matrixWorld );\n\t\t\t\tsphere.radius += threshold;\n\n\t\t\t\tif ( raycaster.ray.intersectsSphere( sphere ) === false ) return;\n\n\t\t\t\t//\n\n\t\t\t\tinverseMatrix.getInverse( matrixWorld );\n\t\t\t\tray.copy( raycaster.ray ).applyMatrix4( inverseMatrix );\n\n\t\t\t\tvar localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );\n\t\t\t\tvar localThresholdSq = localThreshold * localThreshold;\n\t\t\t\tvar position = new Vector3();\n\t\t\t\tvar intersectPoint = new Vector3();\n\n\t\t\t\tfunction testPoint( point, index ) {\n\n\t\t\t\t\tvar rayPointDistanceSq = ray.distanceSqToPoint( point );\n\n\t\t\t\t\tif ( rayPointDistanceSq < localThresholdSq ) {\n\n\t\t\t\t\t\tray.closestPointToPoint( point, intersectPoint );\n\t\t\t\t\t\tintersectPoint.applyMatrix4( matrixWorld );\n\n\t\t\t\t\t\tvar distance = raycaster.ray.origin.distanceTo( intersectPoint );\n\n\t\t\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) return;\n\n\t\t\t\t\t\tintersects.push( {\n\n\t\t\t\t\t\t\tdistance: distance,\n\t\t\t\t\t\t\tdistanceToRay: Math.sqrt( rayPointDistanceSq ),\n\t\t\t\t\t\t\tpoint: intersectPoint.clone(),\n\t\t\t\t\t\t\tindex: index,\n\t\t\t\t\t\t\tface: null,\n\t\t\t\t\t\t\tobject: object\n\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\t\t\tvar index = geometry.index;\n\t\t\t\t\tvar attributes = geometry.attributes;\n\t\t\t\t\tvar positions = attributes.position.array;\n\n\t\t\t\t\tif ( index !== null ) {\n\n\t\t\t\t\t\tvar indices = index.array;\n\n\t\t\t\t\t\tfor ( var i = 0, il = indices.length; i < il; i ++ ) {\n\n\t\t\t\t\t\t\tvar a = indices[ i ];\n\n\t\t\t\t\t\t\tposition.fromArray( positions, a * 3 );\n\n\t\t\t\t\t\t\ttestPoint( position, a );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tfor ( var i = 0, l = positions.length / 3; i < l; i ++ ) {\n\n\t\t\t\t\t\t\tposition.fromArray( positions, i * 3 );\n\n\t\t\t\t\t\t\ttestPoint( position, i );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tvar vertices = geometry.vertices;\n\n\t\t\t\t\tfor ( var i = 0, l = vertices.length; i < l; i ++ ) {\n\n\t\t\t\t\t\ttestPoint( vertices[ i ], i );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t}() ),\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor( this.geometry, this.material ).copy( this );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction VideoTexture( video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {\n\n\t\tTexture.call( this, video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );\n\n\t\tthis.format = format !== undefined ? format : RGBFormat;\n\n\t\tthis.minFilter = minFilter !== undefined ? minFilter : LinearFilter;\n\t\tthis.magFilter = magFilter !== undefined ? magFilter : LinearFilter;\n\n\t\tthis.generateMipmaps = false;\n\n\t}\n\n\tVideoTexture.prototype = Object.assign( Object.create( Texture.prototype ), {\n\n\t\tconstructor: VideoTexture,\n\n\t\tisVideoTexture: true,\n\n\t\tupdate: function () {\n\n\t\t\tvar video = this.image;\n\n\t\t\tif ( video.readyState >= video.HAVE_CURRENT_DATA ) {\n\n\t\t\t\tthis.needsUpdate = true;\n\n\t\t\t}\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t */\n\n\tfunction CompressedTexture( mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {\n\n\t\tTexture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );\n\n\t\tthis.image = { width: width, height: height };\n\t\tthis.mipmaps = mipmaps;\n\n\t\t// no flipping for cube textures\n\t\t// (also flipping doesn't work for compressed textures )\n\n\t\tthis.flipY = false;\n\n\t\t// can't generate mipmaps for compressed textures\n\t\t// mips must be embedded in DDS files\n\n\t\tthis.generateMipmaps = false;\n\n\t}\n\n\tCompressedTexture.prototype = Object.create( Texture.prototype );\n\tCompressedTexture.prototype.constructor = CompressedTexture;\n\n\tCompressedTexture.prototype.isCompressedTexture = true;\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction CanvasTexture( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {\n\n\t\tTexture.call( this, canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );\n\n\t\tthis.needsUpdate = true;\n\n\t}\n\n\tCanvasTexture.prototype = Object.create( Texture.prototype );\n\tCanvasTexture.prototype.constructor = CanvasTexture;\n\tCanvasTexture.prototype.isCanvasTexture = true;\n\n\t/**\n\t * @author Matt DesLauriers / @mattdesl\n\t * @author atix / arthursilber.de\n\t */\n\n\tfunction DepthTexture( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) {\n\n\t\tformat = format !== undefined ? format : DepthFormat;\n\n\t\tif ( format !== DepthFormat && format !== DepthStencilFormat ) {\n\n\t\t\tthrow new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' );\n\n\t\t}\n\n\t\tif ( type === undefined && format === DepthFormat ) type = UnsignedShortType;\n\t\tif ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type;\n\n\t\tTexture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );\n\n\t\tthis.image = { width: width, height: height };\n\n\t\tthis.magFilter = magFilter !== undefined ? magFilter : NearestFilter;\n\t\tthis.minFilter = minFilter !== undefined ? minFilter : NearestFilter;\n\n\t\tthis.flipY = false;\n\t\tthis.generateMipmaps\t= false;\n\n\t}\n\n\tDepthTexture.prototype = Object.create( Texture.prototype );\n\tDepthTexture.prototype.constructor = DepthTexture;\n\tDepthTexture.prototype.isDepthTexture = true;\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\tfunction WireframeGeometry( geometry ) {\n\n\t\tBufferGeometry.call( this );\n\n\t\tthis.type = 'WireframeGeometry';\n\n\t\t// buffer\n\n\t\tvar vertices = [];\n\n\t\t// helper variables\n\n\t\tvar i, j, l, o, ol;\n\t\tvar edge = [ 0, 0 ], edges = {}, e, edge1, edge2;\n\t\tvar key, keys = [ 'a', 'b', 'c' ];\n\t\tvar vertex;\n\n\t\t// different logic for Geometry and BufferGeometry\n\n\t\tif ( geometry && geometry.isGeometry ) {\n\n\t\t\t// create a data structure that contains all edges without duplicates\n\n\t\t\tvar faces = geometry.faces;\n\n\t\t\tfor ( i = 0, l = faces.length; i < l; i ++ ) {\n\n\t\t\t\tvar face = faces[ i ];\n\n\t\t\t\tfor ( j = 0; j < 3; j ++ ) {\n\n\t\t\t\t\tedge1 = face[ keys[ j ] ];\n\t\t\t\t\tedge2 = face[ keys[ ( j + 1 ) % 3 ] ];\n\t\t\t\t\tedge[ 0 ] = Math.min( edge1, edge2 ); // sorting prevents duplicates\n\t\t\t\t\tedge[ 1 ] = Math.max( edge1, edge2 );\n\n\t\t\t\t\tkey = edge[ 0 ] + ',' + edge[ 1 ];\n\n\t\t\t\t\tif ( edges[ key ] === undefined ) {\n\n\t\t\t\t\t\tedges[ key ] = { index1: edge[ 0 ], index2: edge[ 1 ] };\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// generate vertices\n\n\t\t\tfor ( key in edges ) {\n\n\t\t\t\te = edges[ key ];\n\n\t\t\t\tvertex = geometry.vertices[ e.index1 ];\n\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t\tvertex = geometry.vertices[ e.index2 ];\n\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t}\n\n\t\t} else if ( geometry && geometry.isBufferGeometry ) {\n\n\t\t\tvar position, indices, groups;\n\t\t\tvar group, start, count;\n\t\t\tvar index1, index2;\n\n\t\t\tvertex = new Vector3();\n\n\t\t\tif ( geometry.index !== null ) {\n\n\t\t\t\t// indexed BufferGeometry\n\n\t\t\t\tposition = geometry.attributes.position;\n\t\t\t\tindices = geometry.index;\n\t\t\t\tgroups = geometry.groups;\n\n\t\t\t\tif ( groups.length === 0 ) {\n\n\t\t\t\t\tgroups = [ { start: 0, count: indices.count, materialIndex: 0 } ];\n\n\t\t\t\t}\n\n\t\t\t\t// create a data structure that contains all eges without duplicates\n\n\t\t\t\tfor ( o = 0, ol = groups.length; o < ol; ++ o ) {\n\n\t\t\t\t\tgroup = groups[ o ];\n\n\t\t\t\t\tstart = group.start;\n\t\t\t\t\tcount = group.count;\n\n\t\t\t\t\tfor ( i = start, l = ( start + count ); i < l; i += 3 ) {\n\n\t\t\t\t\t\tfor ( j = 0; j < 3; j ++ ) {\n\n\t\t\t\t\t\t\tedge1 = indices.getX( i + j );\n\t\t\t\t\t\t\tedge2 = indices.getX( i + ( j + 1 ) % 3 );\n\t\t\t\t\t\t\tedge[ 0 ] = Math.min( edge1, edge2 ); // sorting prevents duplicates\n\t\t\t\t\t\t\tedge[ 1 ] = Math.max( edge1, edge2 );\n\n\t\t\t\t\t\t\tkey = edge[ 0 ] + ',' + edge[ 1 ];\n\n\t\t\t\t\t\t\tif ( edges[ key ] === undefined ) {\n\n\t\t\t\t\t\t\t\tedges[ key ] = { index1: edge[ 0 ], index2: edge[ 1 ] };\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\t// generate vertices\n\n\t\t\t\tfor ( key in edges ) {\n\n\t\t\t\t\te = edges[ key ];\n\n\t\t\t\t\tvertex.fromBufferAttribute( position, e.index1 );\n\t\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t\t\tvertex.fromBufferAttribute( position, e.index2 );\n\t\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t// non-indexed BufferGeometry\n\n\t\t\t\tposition = geometry.attributes.position;\n\n\t\t\t\tfor ( i = 0, l = ( position.count / 3 ); i < l; i ++ ) {\n\n\t\t\t\t\tfor ( j = 0; j < 3; j ++ ) {\n\n\t\t\t\t\t\t// three edges per triangle, an edge is represented as (index1, index2)\n\t\t\t\t\t\t// e.g. the first triangle has the following edges: (0,1),(1,2),(2,0)\n\n\t\t\t\t\t\tindex1 = 3 * i + j;\n\t\t\t\t\t\tvertex.fromBufferAttribute( position, index1 );\n\t\t\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t\t\t\tindex2 = 3 * i + ( ( j + 1 ) % 3 );\n\t\t\t\t\t\tvertex.fromBufferAttribute( position, index2 );\n\t\t\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// build geometry\n\n\t\tthis.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\n\t}\n\n\tWireframeGeometry.prototype = Object.create( BufferGeometry.prototype );\n\tWireframeGeometry.prototype.constructor = WireframeGeometry;\n\n\t/**\n\t * @author zz85 / https://github.com/zz85\n\t * @author Mugen87 / https://github.com/Mugen87\n\t *\n\t * Parametric Surfaces Geometry\n\t * based on the brilliant article by @prideout http://prideout.net/blog/?p=44\n\t */\n\n\t// ParametricGeometry\n\n\tfunction ParametricGeometry( func, slices, stacks ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'ParametricGeometry';\n\n\t\tthis.parameters = {\n\t\t\tfunc: func,\n\t\t\tslices: slices,\n\t\t\tstacks: stacks\n\t\t};\n\n\t\tthis.fromBufferGeometry( new ParametricBufferGeometry( func, slices, stacks ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tParametricGeometry.prototype = Object.create( Geometry.prototype );\n\tParametricGeometry.prototype.constructor = ParametricGeometry;\n\n\t// ParametricBufferGeometry\n\n\tfunction ParametricBufferGeometry( func, slices, stacks ) {\n\n\t\tBufferGeometry.call( this );\n\n\t\tthis.type = 'ParametricBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\tfunc: func,\n\t\t\tslices: slices,\n\t\t\tstacks: stacks\n\t\t};\n\n\t\t// buffers\n\n\t\tvar indices = [];\n\t\tvar vertices = [];\n\t\tvar normals = [];\n\t\tvar uvs = [];\n\n\t\tvar EPS = 0.00001;\n\n\t\tvar normal = new Vector3();\n\n\t\tvar p0 = new Vector3(), p1 = new Vector3();\n\t\tvar pu = new Vector3(), pv = new Vector3();\n\n\t\tvar i, j;\n\n\t\tif ( func.length < 3 ) {\n\n\t\t\tconsole.error( 'THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.' );\n\n\t\t}\n\n\t\t// generate vertices, normals and uvs\n\n\t\tvar sliceCount = slices + 1;\n\n\t\tfor ( i = 0; i <= stacks; i ++ ) {\n\n\t\t\tvar v = i / stacks;\n\n\t\t\tfor ( j = 0; j <= slices; j ++ ) {\n\n\t\t\t\tvar u = j / slices;\n\n\t\t\t\t// vertex\n\n\t\t\t\tfunc( u, v, p0 );\n\t\t\t\tvertices.push( p0.x, p0.y, p0.z );\n\n\t\t\t\t// normal\n\n\t\t\t\t// approximate tangent vectors via finite differences\n\n\t\t\t\tif ( u - EPS >= 0 ) {\n\n\t\t\t\t\tfunc( u - EPS, v, p1 );\n\t\t\t\t\tpu.subVectors( p0, p1 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tfunc( u + EPS, v, p1 );\n\t\t\t\t\tpu.subVectors( p1, p0 );\n\n\t\t\t\t}\n\n\t\t\t\tif ( v - EPS >= 0 ) {\n\n\t\t\t\t\tfunc( u, v - EPS, p1 );\n\t\t\t\t\tpv.subVectors( p0, p1 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tfunc( u, v + EPS, p1 );\n\t\t\t\t\tpv.subVectors( p1, p0 );\n\n\t\t\t\t}\n\n\t\t\t\t// cross product of tangent vectors returns surface normal\n\n\t\t\t\tnormal.crossVectors( pu, pv ).normalize();\n\t\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\t\t// uv\n\n\t\t\t\tuvs.push( u, v );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// generate indices\n\n\t\tfor ( i = 0; i < stacks; i ++ ) {\n\n\t\t\tfor ( j = 0; j < slices; j ++ ) {\n\n\t\t\t\tvar a = i * sliceCount + j;\n\t\t\t\tvar b = i * sliceCount + j + 1;\n\t\t\t\tvar c = ( i + 1 ) * sliceCount + j + 1;\n\t\t\t\tvar d = ( i + 1 ) * sliceCount + j;\n\n\t\t\t\t// faces one and two\n\n\t\t\t\tindices.push( a, b, d );\n\t\t\t\tindices.push( b, c, d );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// build geometry\n\n\t\tthis.setIndex( indices );\n\t\tthis.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tthis.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\t\tthis.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\t}\n\n\tParametricBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\n\tParametricBufferGeometry.prototype.constructor = ParametricBufferGeometry;\n\n\t/**\n\t * @author clockworkgeek / https://github.com/clockworkgeek\n\t * @author timothypratley / https://github.com/timothypratley\n\t * @author WestLangley / http://github.com/WestLangley\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\t// PolyhedronGeometry\n\n\tfunction PolyhedronGeometry( vertices, indices, radius, detail ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'PolyhedronGeometry';\n\n\t\tthis.parameters = {\n\t\t\tvertices: vertices,\n\t\t\tindices: indices,\n\t\t\tradius: radius,\n\t\t\tdetail: detail\n\t\t};\n\n\t\tthis.fromBufferGeometry( new PolyhedronBufferGeometry( vertices, indices, radius, detail ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tPolyhedronGeometry.prototype = Object.create( Geometry.prototype );\n\tPolyhedronGeometry.prototype.constructor = PolyhedronGeometry;\n\n\t// PolyhedronBufferGeometry\n\n\tfunction PolyhedronBufferGeometry( vertices, indices, radius, detail ) {\n\n\t\tBufferGeometry.call( this );\n\n\t\tthis.type = 'PolyhedronBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\tvertices: vertices,\n\t\t\tindices: indices,\n\t\t\tradius: radius,\n\t\t\tdetail: detail\n\t\t};\n\n\t\tradius = radius || 1;\n\t\tdetail = detail || 0;\n\n\t\t// default buffer data\n\n\t\tvar vertexBuffer = [];\n\t\tvar uvBuffer = [];\n\n\t\t// the subdivision creates the vertex buffer data\n\n\t\tsubdivide( detail );\n\n\t\t// all vertices should lie on a conceptual sphere with a given radius\n\n\t\tappplyRadius( radius );\n\n\t\t// finally, create the uv data\n\n\t\tgenerateUVs();\n\n\t\t// build non-indexed geometry\n\n\t\tthis.addAttribute( 'position', new Float32BufferAttribute( vertexBuffer, 3 ) );\n\t\tthis.addAttribute( 'normal', new Float32BufferAttribute( vertexBuffer.slice(), 3 ) );\n\t\tthis.addAttribute( 'uv', new Float32BufferAttribute( uvBuffer, 2 ) );\n\n\t\tif ( detail === 0 ) {\n\n\t\t\tthis.computeVertexNormals(); // flat normals\n\n\t\t} else {\n\n\t\t\tthis.normalizeNormals(); // smooth normals\n\n\t\t}\n\n\t\t// helper functions\n\n\t\tfunction subdivide( detail ) {\n\n\t\t\tvar a = new Vector3();\n\t\t\tvar b = new Vector3();\n\t\t\tvar c = new Vector3();\n\n\t\t\t// iterate over all faces and apply a subdivison with the given detail value\n\n\t\t\tfor ( var i = 0; i < indices.length; i += 3 ) {\n\n\t\t\t\t// get the vertices of the face\n\n\t\t\t\tgetVertexByIndex( indices[ i + 0 ], a );\n\t\t\t\tgetVertexByIndex( indices[ i + 1 ], b );\n\t\t\t\tgetVertexByIndex( indices[ i + 2 ], c );\n\n\t\t\t\t// perform subdivision\n\n\t\t\t\tsubdivideFace( a, b, c, detail );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction subdivideFace( a, b, c, detail ) {\n\n\t\t\tvar cols = Math.pow( 2, detail );\n\n\t\t\t// we use this multidimensional array as a data structure for creating the subdivision\n\n\t\t\tvar v = [];\n\n\t\t\tvar i, j;\n\n\t\t\t// construct all of the vertices for this subdivision\n\n\t\t\tfor ( i = 0; i <= cols; i ++ ) {\n\n\t\t\t\tv[ i ] = [];\n\n\t\t\t\tvar aj = a.clone().lerp( c, i / cols );\n\t\t\t\tvar bj = b.clone().lerp( c, i / cols );\n\n\t\t\t\tvar rows = cols - i;\n\n\t\t\t\tfor ( j = 0; j <= rows; j ++ ) {\n\n\t\t\t\t\tif ( j === 0 && i === cols ) {\n\n\t\t\t\t\t\tv[ i ][ j ] = aj;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tv[ i ][ j ] = aj.clone().lerp( bj, j / rows );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// construct all of the faces\n\n\t\t\tfor ( i = 0; i < cols; i ++ ) {\n\n\t\t\t\tfor ( j = 0; j < 2 * ( cols - i ) - 1; j ++ ) {\n\n\t\t\t\t\tvar k = Math.floor( j / 2 );\n\n\t\t\t\t\tif ( j % 2 === 0 ) {\n\n\t\t\t\t\t\tpushVertex( v[ i ][ k + 1 ] );\n\t\t\t\t\t\tpushVertex( v[ i + 1 ][ k ] );\n\t\t\t\t\t\tpushVertex( v[ i ][ k ] );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tpushVertex( v[ i ][ k + 1 ] );\n\t\t\t\t\t\tpushVertex( v[ i + 1 ][ k + 1 ] );\n\t\t\t\t\t\tpushVertex( v[ i + 1 ][ k ] );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction appplyRadius( radius ) {\n\n\t\t\tvar vertex = new Vector3();\n\n\t\t\t// iterate over the entire buffer and apply the radius to each vertex\n\n\t\t\tfor ( var i = 0; i < vertexBuffer.length; i += 3 ) {\n\n\t\t\t\tvertex.x = vertexBuffer[ i + 0 ];\n\t\t\t\tvertex.y = vertexBuffer[ i + 1 ];\n\t\t\t\tvertex.z = vertexBuffer[ i + 2 ];\n\n\t\t\t\tvertex.normalize().multiplyScalar( radius );\n\n\t\t\t\tvertexBuffer[ i + 0 ] = vertex.x;\n\t\t\t\tvertexBuffer[ i + 1 ] = vertex.y;\n\t\t\t\tvertexBuffer[ i + 2 ] = vertex.z;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction generateUVs() {\n\n\t\t\tvar vertex = new Vector3();\n\n\t\t\tfor ( var i = 0; i < vertexBuffer.length; i += 3 ) {\n\n\t\t\t\tvertex.x = vertexBuffer[ i + 0 ];\n\t\t\t\tvertex.y = vertexBuffer[ i + 1 ];\n\t\t\t\tvertex.z = vertexBuffer[ i + 2 ];\n\n\t\t\t\tvar u = azimuth( vertex ) / 2 / Math.PI + 0.5;\n\t\t\t\tvar v = inclination( vertex ) / Math.PI + 0.5;\n\t\t\t\tuvBuffer.push( u, 1 - v );\n\n\t\t\t}\n\n\t\t\tcorrectUVs();\n\n\t\t\tcorrectSeam();\n\n\t\t}\n\n\t\tfunction correctSeam() {\n\n\t\t\t// handle case when face straddles the seam, see #3269\n\n\t\t\tfor ( var i = 0; i < uvBuffer.length; i += 6 ) {\n\n\t\t\t\t// uv data of a single face\n\n\t\t\t\tvar x0 = uvBuffer[ i + 0 ];\n\t\t\t\tvar x1 = uvBuffer[ i + 2 ];\n\t\t\t\tvar x2 = uvBuffer[ i + 4 ];\n\n\t\t\t\tvar max = Math.max( x0, x1, x2 );\n\t\t\t\tvar min = Math.min( x0, x1, x2 );\n\n\t\t\t\t// 0.9 is somewhat arbitrary\n\n\t\t\t\tif ( max > 0.9 && min < 0.1 ) {\n\n\t\t\t\t\tif ( x0 < 0.2 ) uvBuffer[ i + 0 ] += 1;\n\t\t\t\t\tif ( x1 < 0.2 ) uvBuffer[ i + 2 ] += 1;\n\t\t\t\t\tif ( x2 < 0.2 ) uvBuffer[ i + 4 ] += 1;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction pushVertex( vertex ) {\n\n\t\t\tvertexBuffer.push( vertex.x, vertex.y, vertex.z );\n\n\t\t}\n\n\t\tfunction getVertexByIndex( index, vertex ) {\n\n\t\t\tvar stride = index * 3;\n\n\t\t\tvertex.x = vertices[ stride + 0 ];\n\t\t\tvertex.y = vertices[ stride + 1 ];\n\t\t\tvertex.z = vertices[ stride + 2 ];\n\n\t\t}\n\n\t\tfunction correctUVs() {\n\n\t\t\tvar a = new Vector3();\n\t\t\tvar b = new Vector3();\n\t\t\tvar c = new Vector3();\n\n\t\t\tvar centroid = new Vector3();\n\n\t\t\tvar uvA = new Vector2();\n\t\t\tvar uvB = new Vector2();\n\t\t\tvar uvC = new Vector2();\n\n\t\t\tfor ( var i = 0, j = 0; i < vertexBuffer.length; i += 9, j += 6 ) {\n\n\t\t\t\ta.set( vertexBuffer[ i + 0 ], vertexBuffer[ i + 1 ], vertexBuffer[ i + 2 ] );\n\t\t\t\tb.set( vertexBuffer[ i + 3 ], vertexBuffer[ i + 4 ], vertexBuffer[ i + 5 ] );\n\t\t\t\tc.set( vertexBuffer[ i + 6 ], vertexBuffer[ i + 7 ], vertexBuffer[ i + 8 ] );\n\n\t\t\t\tuvA.set( uvBuffer[ j + 0 ], uvBuffer[ j + 1 ] );\n\t\t\t\tuvB.set( uvBuffer[ j + 2 ], uvBuffer[ j + 3 ] );\n\t\t\t\tuvC.set( uvBuffer[ j + 4 ], uvBuffer[ j + 5 ] );\n\n\t\t\t\tcentroid.copy( a ).add( b ).add( c ).divideScalar( 3 );\n\n\t\t\t\tvar azi = azimuth( centroid );\n\n\t\t\t\tcorrectUV( uvA, j + 0, a, azi );\n\t\t\t\tcorrectUV( uvB, j + 2, b, azi );\n\t\t\t\tcorrectUV( uvC, j + 4, c, azi );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction correctUV( uv, stride, vector, azimuth ) {\n\n\t\t\tif ( ( azimuth < 0 ) && ( uv.x === 1 ) ) {\n\n\t\t\t\tuvBuffer[ stride ] = uv.x - 1;\n\n\t\t\t}\n\n\t\t\tif ( ( vector.x === 0 ) && ( vector.z === 0 ) ) {\n\n\t\t\t\tuvBuffer[ stride ] = azimuth / 2 / Math.PI + 0.5;\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Angle around the Y axis, counter-clockwise when looking from above.\n\n\t\tfunction azimuth( vector ) {\n\n\t\t\treturn Math.atan2( vector.z, - vector.x );\n\n\t\t}\n\n\n\t\t// Angle above the XZ plane.\n\n\t\tfunction inclination( vector ) {\n\n\t\t\treturn Math.atan2( - vector.y, Math.sqrt( ( vector.x * vector.x ) + ( vector.z * vector.z ) ) );\n\n\t\t}\n\n\t}\n\n\tPolyhedronBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\n\tPolyhedronBufferGeometry.prototype.constructor = PolyhedronBufferGeometry;\n\n\t/**\n\t * @author timothypratley / https://github.com/timothypratley\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\t// TetrahedronGeometry\n\n\tfunction TetrahedronGeometry( radius, detail ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'TetrahedronGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\tdetail: detail\n\t\t};\n\n\t\tthis.fromBufferGeometry( new TetrahedronBufferGeometry( radius, detail ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tTetrahedronGeometry.prototype = Object.create( Geometry.prototype );\n\tTetrahedronGeometry.prototype.constructor = TetrahedronGeometry;\n\n\t// TetrahedronBufferGeometry\n\n\tfunction TetrahedronBufferGeometry( radius, detail ) {\n\n\t\tvar vertices = [\n\t\t\t1, 1, 1, \t- 1, - 1, 1, \t- 1, 1, - 1, \t1, - 1, - 1\n\t\t];\n\n\t\tvar indices = [\n\t\t\t2, 1, 0, \t0, 3, 2,\t1, 3, 0,\t2, 3, 1\n\t\t];\n\n\t\tPolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );\n\n\t\tthis.type = 'TetrahedronBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\tdetail: detail\n\t\t};\n\n\t}\n\n\tTetrahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );\n\tTetrahedronBufferGeometry.prototype.constructor = TetrahedronBufferGeometry;\n\n\t/**\n\t * @author timothypratley / https://github.com/timothypratley\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\t// OctahedronGeometry\n\n\tfunction OctahedronGeometry( radius, detail ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'OctahedronGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\tdetail: detail\n\t\t};\n\n\t\tthis.fromBufferGeometry( new OctahedronBufferGeometry( radius, detail ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tOctahedronGeometry.prototype = Object.create( Geometry.prototype );\n\tOctahedronGeometry.prototype.constructor = OctahedronGeometry;\n\n\t// OctahedronBufferGeometry\n\n\tfunction OctahedronBufferGeometry( radius, detail ) {\n\n\t\tvar vertices = [\n\t\t\t1, 0, 0, \t- 1, 0, 0,\t0, 1, 0,\n\t\t\t0, - 1, 0, \t0, 0, 1,\t0, 0, - 1\n\t\t];\n\n\t\tvar indices = [\n\t\t\t0, 2, 4,\t0, 4, 3,\t0, 3, 5,\n\t\t\t0, 5, 2,\t1, 2, 5,\t1, 5, 3,\n\t\t\t1, 3, 4,\t1, 4, 2\n\t\t];\n\n\t\tPolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );\n\n\t\tthis.type = 'OctahedronBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\tdetail: detail\n\t\t};\n\n\t}\n\n\tOctahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );\n\tOctahedronBufferGeometry.prototype.constructor = OctahedronBufferGeometry;\n\n\t/**\n\t * @author timothypratley / https://github.com/timothypratley\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\t// IcosahedronGeometry\n\n\tfunction IcosahedronGeometry( radius, detail ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'IcosahedronGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\tdetail: detail\n\t\t};\n\n\t\tthis.fromBufferGeometry( new IcosahedronBufferGeometry( radius, detail ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tIcosahedronGeometry.prototype = Object.create( Geometry.prototype );\n\tIcosahedronGeometry.prototype.constructor = IcosahedronGeometry;\n\n\t// IcosahedronBufferGeometry\n\n\tfunction IcosahedronBufferGeometry( radius, detail ) {\n\n\t\tvar t = ( 1 + Math.sqrt( 5 ) ) / 2;\n\n\t\tvar vertices = [\n\t\t\t- 1, t, 0, \t1, t, 0, \t- 1, - t, 0, \t1, - t, 0,\n\t\t\t 0, - 1, t, \t0, 1, t,\t0, - 1, - t, \t0, 1, - t,\n\t\t\t t, 0, - 1, \tt, 0, 1, \t- t, 0, - 1, \t- t, 0, 1\n\t\t];\n\n\t\tvar indices = [\n\t\t\t 0, 11, 5, \t0, 5, 1, \t0, 1, 7, \t0, 7, 10, \t0, 10, 11,\n\t\t\t 1, 5, 9, \t5, 11, 4,\t11, 10, 2,\t10, 7, 6,\t7, 1, 8,\n\t\t\t 3, 9, 4, \t3, 4, 2,\t3, 2, 6,\t3, 6, 8,\t3, 8, 9,\n\t\t\t 4, 9, 5, \t2, 4, 11,\t6, 2, 10,\t8, 6, 7,\t9, 8, 1\n\t\t];\n\n\t\tPolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );\n\n\t\tthis.type = 'IcosahedronBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\tdetail: detail\n\t\t};\n\n\t}\n\n\tIcosahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );\n\tIcosahedronBufferGeometry.prototype.constructor = IcosahedronBufferGeometry;\n\n\t/**\n\t * @author Abe Pazos / https://hamoid.com\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\t// DodecahedronGeometry\n\n\tfunction DodecahedronGeometry( radius, detail ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'DodecahedronGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\tdetail: detail\n\t\t};\n\n\t\tthis.fromBufferGeometry( new DodecahedronBufferGeometry( radius, detail ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tDodecahedronGeometry.prototype = Object.create( Geometry.prototype );\n\tDodecahedronGeometry.prototype.constructor = DodecahedronGeometry;\n\n\t// DodecahedronBufferGeometry\n\n\tfunction DodecahedronBufferGeometry( radius, detail ) {\n\n\t\tvar t = ( 1 + Math.sqrt( 5 ) ) / 2;\n\t\tvar r = 1 / t;\n\n\t\tvar vertices = [\n\n\t\t\t// (±1, ±1, ±1)\n\t\t\t- 1, - 1, - 1,\t- 1, - 1, 1,\n\t\t\t- 1, 1, - 1, - 1, 1, 1,\n\t\t\t1, - 1, - 1, 1, - 1, 1,\n\t\t\t1, 1, - 1, 1, 1, 1,\n\n\t\t\t// (0, ±1/φ, ±φ)\n\t\t\t 0, - r, - t, 0, - r, t,\n\t\t\t 0, r, - t, 0, r, t,\n\n\t\t\t// (±1/φ, ±φ, 0)\n\t\t\t- r, - t, 0, - r, t, 0,\n\t\t\t r, - t, 0, r, t, 0,\n\n\t\t\t// (±φ, 0, ±1/φ)\n\t\t\t- t, 0, - r, t, 0, - r,\n\t\t\t- t, 0, r, t, 0, r\n\t\t];\n\n\t\tvar indices = [\n\t\t\t3, 11, 7, \t3, 7, 15, \t3, 15, 13,\n\t\t\t7, 19, 17, \t7, 17, 6, \t7, 6, 15,\n\t\t\t17, 4, 8, \t17, 8, 10, \t17, 10, 6,\n\t\t\t8, 0, 16, \t8, 16, 2, \t8, 2, 10,\n\t\t\t0, 12, 1, \t0, 1, 18, \t0, 18, 16,\n\t\t\t6, 10, 2, \t6, 2, 13, \t6, 13, 15,\n\t\t\t2, 16, 18, \t2, 18, 3, \t2, 3, 13,\n\t\t\t18, 1, 9, \t18, 9, 11, \t18, 11, 3,\n\t\t\t4, 14, 12, \t4, 12, 0, \t4, 0, 8,\n\t\t\t11, 9, 5, \t11, 5, 19, \t11, 19, 7,\n\t\t\t19, 5, 14, \t19, 14, 4, \t19, 4, 17,\n\t\t\t1, 12, 14, \t1, 14, 5, \t1, 5, 9\n\t\t];\n\n\t\tPolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );\n\n\t\tthis.type = 'DodecahedronBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\tdetail: detail\n\t\t};\n\n\t}\n\n\tDodecahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );\n\tDodecahedronBufferGeometry.prototype.constructor = DodecahedronBufferGeometry;\n\n\t/**\n\t * @author oosmoxiecode / https://github.com/oosmoxiecode\n\t * @author WestLangley / https://github.com/WestLangley\n\t * @author zz85 / https://github.com/zz85\n\t * @author miningold / https://github.com/miningold\n\t * @author jonobr1 / https://github.com/jonobr1\n\t * @author Mugen87 / https://github.com/Mugen87\n\t *\n\t */\n\n\t// TubeGeometry\n\n\tfunction TubeGeometry( path, tubularSegments, radius, radialSegments, closed, taper ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'TubeGeometry';\n\n\t\tthis.parameters = {\n\t\t\tpath: path,\n\t\t\ttubularSegments: tubularSegments,\n\t\t\tradius: radius,\n\t\t\tradialSegments: radialSegments,\n\t\t\tclosed: closed\n\t\t};\n\n\t\tif ( taper !== undefined ) console.warn( 'THREE.TubeGeometry: taper has been removed.' );\n\n\t\tvar bufferGeometry = new TubeBufferGeometry( path, tubularSegments, radius, radialSegments, closed );\n\n\t\t// expose internals\n\n\t\tthis.tangents = bufferGeometry.tangents;\n\t\tthis.normals = bufferGeometry.normals;\n\t\tthis.binormals = bufferGeometry.binormals;\n\n\t\t// create geometry\n\n\t\tthis.fromBufferGeometry( bufferGeometry );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tTubeGeometry.prototype = Object.create( Geometry.prototype );\n\tTubeGeometry.prototype.constructor = TubeGeometry;\n\n\t// TubeBufferGeometry\n\n\tfunction TubeBufferGeometry( path, tubularSegments, radius, radialSegments, closed ) {\n\n\t\tBufferGeometry.call( this );\n\n\t\tthis.type = 'TubeBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\tpath: path,\n\t\t\ttubularSegments: tubularSegments,\n\t\t\tradius: radius,\n\t\t\tradialSegments: radialSegments,\n\t\t\tclosed: closed\n\t\t};\n\n\t\ttubularSegments = tubularSegments || 64;\n\t\tradius = radius || 1;\n\t\tradialSegments = radialSegments || 8;\n\t\tclosed = closed || false;\n\n\t\tvar frames = path.computeFrenetFrames( tubularSegments, closed );\n\n\t\t// expose internals\n\n\t\tthis.tangents = frames.tangents;\n\t\tthis.normals = frames.normals;\n\t\tthis.binormals = frames.binormals;\n\n\t\t// helper variables\n\n\t\tvar vertex = new Vector3();\n\t\tvar normal = new Vector3();\n\t\tvar uv = new Vector2();\n\t\tvar P = new Vector3();\n\n\t\tvar i, j;\n\n\t\t// buffer\n\n\t\tvar vertices = [];\n\t\tvar normals = [];\n\t\tvar uvs = [];\n\t\tvar indices = [];\n\n\t\t// create buffer data\n\n\t\tgenerateBufferData();\n\n\t\t// build geometry\n\n\t\tthis.setIndex( indices );\n\t\tthis.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tthis.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\t\tthis.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\t\t// functions\n\n\t\tfunction generateBufferData() {\n\n\t\t\tfor ( i = 0; i < tubularSegments; i ++ ) {\n\n\t\t\t\tgenerateSegment( i );\n\n\t\t\t}\n\n\t\t\t// if the geometry is not closed, generate the last row of vertices and normals\n\t\t\t// at the regular position on the given path\n\t\t\t//\n\t\t\t// if the geometry is closed, duplicate the first row of vertices and normals (uvs will differ)\n\n\t\t\tgenerateSegment( ( closed === false ) ? tubularSegments : 0 );\n\n\t\t\t// uvs are generated in a separate function.\n\t\t\t// this makes it easy compute correct values for closed geometries\n\n\t\t\tgenerateUVs();\n\n\t\t\t// finally create faces\n\n\t\t\tgenerateIndices();\n\n\t\t}\n\n\t\tfunction generateSegment( i ) {\n\n\t\t\t// we use getPointAt to sample evenly distributed points from the given path\n\n\t\t\tP = path.getPointAt( i / tubularSegments, P );\n\n\t\t\t// retrieve corresponding normal and binormal\n\n\t\t\tvar N = frames.normals[ i ];\n\t\t\tvar B = frames.binormals[ i ];\n\n\t\t\t// generate normals and vertices for the current segment\n\n\t\t\tfor ( j = 0; j <= radialSegments; j ++ ) {\n\n\t\t\t\tvar v = j / radialSegments * Math.PI * 2;\n\n\t\t\t\tvar sin = Math.sin( v );\n\t\t\t\tvar cos = - Math.cos( v );\n\n\t\t\t\t// normal\n\n\t\t\t\tnormal.x = ( cos * N.x + sin * B.x );\n\t\t\t\tnormal.y = ( cos * N.y + sin * B.y );\n\t\t\t\tnormal.z = ( cos * N.z + sin * B.z );\n\t\t\t\tnormal.normalize();\n\n\t\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\t\t// vertex\n\n\t\t\t\tvertex.x = P.x + radius * normal.x;\n\t\t\t\tvertex.y = P.y + radius * normal.y;\n\t\t\t\tvertex.z = P.z + radius * normal.z;\n\n\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction generateIndices() {\n\n\t\t\tfor ( j = 1; j <= tubularSegments; j ++ ) {\n\n\t\t\t\tfor ( i = 1; i <= radialSegments; i ++ ) {\n\n\t\t\t\t\tvar a = ( radialSegments + 1 ) * ( j - 1 ) + ( i - 1 );\n\t\t\t\t\tvar b = ( radialSegments + 1 ) * j + ( i - 1 );\n\t\t\t\t\tvar c = ( radialSegments + 1 ) * j + i;\n\t\t\t\t\tvar d = ( radialSegments + 1 ) * ( j - 1 ) + i;\n\n\t\t\t\t\t// faces\n\n\t\t\t\t\tindices.push( a, b, d );\n\t\t\t\t\tindices.push( b, c, d );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction generateUVs() {\n\n\t\t\tfor ( i = 0; i <= tubularSegments; i ++ ) {\n\n\t\t\t\tfor ( j = 0; j <= radialSegments; j ++ ) {\n\n\t\t\t\t\tuv.x = i / tubularSegments;\n\t\t\t\t\tuv.y = j / radialSegments;\n\n\t\t\t\t\tuvs.push( uv.x, uv.y );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tTubeBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\n\tTubeBufferGeometry.prototype.constructor = TubeBufferGeometry;\n\n\t/**\n\t * @author oosmoxiecode\n\t * @author Mugen87 / https://github.com/Mugen87\n\t *\n\t * based on http://www.blackpawn.com/texts/pqtorus/\n\t */\n\n\t// TorusKnotGeometry\n\n\tfunction TorusKnotGeometry( radius, tube, tubularSegments, radialSegments, p, q, heightScale ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'TorusKnotGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\ttube: tube,\n\t\t\ttubularSegments: tubularSegments,\n\t\t\tradialSegments: radialSegments,\n\t\t\tp: p,\n\t\t\tq: q\n\t\t};\n\n\t\tif ( heightScale !== undefined ) console.warn( 'THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead.' );\n\n\t\tthis.fromBufferGeometry( new TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments, p, q ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tTorusKnotGeometry.prototype = Object.create( Geometry.prototype );\n\tTorusKnotGeometry.prototype.constructor = TorusKnotGeometry;\n\n\t// TorusKnotBufferGeometry\n\n\tfunction TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments, p, q ) {\n\n\t\tBufferGeometry.call( this );\n\n\t\tthis.type = 'TorusKnotBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\ttube: tube,\n\t\t\ttubularSegments: tubularSegments,\n\t\t\tradialSegments: radialSegments,\n\t\t\tp: p,\n\t\t\tq: q\n\t\t};\n\n\t\tradius = radius || 1;\n\t\ttube = tube || 0.4;\n\t\ttubularSegments = Math.floor( tubularSegments ) || 64;\n\t\tradialSegments = Math.floor( radialSegments ) || 8;\n\t\tp = p || 2;\n\t\tq = q || 3;\n\n\t\t// buffers\n\n\t\tvar indices = [];\n\t\tvar vertices = [];\n\t\tvar normals = [];\n\t\tvar uvs = [];\n\n\t\t// helper variables\n\n\t\tvar i, j;\n\n\t\tvar vertex = new Vector3();\n\t\tvar normal = new Vector3();\n\n\t\tvar P1 = new Vector3();\n\t\tvar P2 = new Vector3();\n\n\t\tvar B = new Vector3();\n\t\tvar T = new Vector3();\n\t\tvar N = new Vector3();\n\n\t\t// generate vertices, normals and uvs\n\n\t\tfor ( i = 0; i <= tubularSegments; ++ i ) {\n\n\t\t\t// the radian \"u\" is used to calculate the position on the torus curve of the current tubular segement\n\n\t\t\tvar u = i / tubularSegments * p * Math.PI * 2;\n\n\t\t\t// now we calculate two points. P1 is our current position on the curve, P2 is a little farther ahead.\n\t\t\t// these points are used to create a special \"coordinate space\", which is necessary to calculate the correct vertex positions\n\n\t\t\tcalculatePositionOnCurve( u, p, q, radius, P1 );\n\t\t\tcalculatePositionOnCurve( u + 0.01, p, q, radius, P2 );\n\n\t\t\t// calculate orthonormal basis\n\n\t\t\tT.subVectors( P2, P1 );\n\t\t\tN.addVectors( P2, P1 );\n\t\t\tB.crossVectors( T, N );\n\t\t\tN.crossVectors( B, T );\n\n\t\t\t// normalize B, N. T can be ignored, we don't use it\n\n\t\t\tB.normalize();\n\t\t\tN.normalize();\n\n\t\t\tfor ( j = 0; j <= radialSegments; ++ j ) {\n\n\t\t\t\t// now calculate the vertices. they are nothing more than an extrusion of the torus curve.\n\t\t\t\t// because we extrude a shape in the xy-plane, there is no need to calculate a z-value.\n\n\t\t\t\tvar v = j / radialSegments * Math.PI * 2;\n\t\t\t\tvar cx = - tube * Math.cos( v );\n\t\t\t\tvar cy = tube * Math.sin( v );\n\n\t\t\t\t// now calculate the final vertex position.\n\t\t\t\t// first we orient the extrusion with our basis vectos, then we add it to the current position on the curve\n\n\t\t\t\tvertex.x = P1.x + ( cx * N.x + cy * B.x );\n\t\t\t\tvertex.y = P1.y + ( cx * N.y + cy * B.y );\n\t\t\t\tvertex.z = P1.z + ( cx * N.z + cy * B.z );\n\n\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t\t// normal (P1 is always the center/origin of the extrusion, thus we can use it to calculate the normal)\n\n\t\t\t\tnormal.subVectors( vertex, P1 ).normalize();\n\n\t\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\t\t// uv\n\n\t\t\t\tuvs.push( i / tubularSegments );\n\t\t\t\tuvs.push( j / radialSegments );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// generate indices\n\n\t\tfor ( j = 1; j <= tubularSegments; j ++ ) {\n\n\t\t\tfor ( i = 1; i <= radialSegments; i ++ ) {\n\n\t\t\t\t// indices\n\n\t\t\t\tvar a = ( radialSegments + 1 ) * ( j - 1 ) + ( i - 1 );\n\t\t\t\tvar b = ( radialSegments + 1 ) * j + ( i - 1 );\n\t\t\t\tvar c = ( radialSegments + 1 ) * j + i;\n\t\t\t\tvar d = ( radialSegments + 1 ) * ( j - 1 ) + i;\n\n\t\t\t\t// faces\n\n\t\t\t\tindices.push( a, b, d );\n\t\t\t\tindices.push( b, c, d );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// build geometry\n\n\t\tthis.setIndex( indices );\n\t\tthis.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tthis.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\t\tthis.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\t\t// this function calculates the current position on the torus curve\n\n\t\tfunction calculatePositionOnCurve( u, p, q, radius, position ) {\n\n\t\t\tvar cu = Math.cos( u );\n\t\t\tvar su = Math.sin( u );\n\t\t\tvar quOverP = q / p * u;\n\t\t\tvar cs = Math.cos( quOverP );\n\n\t\t\tposition.x = radius * ( 2 + cs ) * 0.5 * cu;\n\t\t\tposition.y = radius * ( 2 + cs ) * su * 0.5;\n\t\t\tposition.z = radius * Math.sin( quOverP ) * 0.5;\n\n\t\t}\n\n\t}\n\n\tTorusKnotBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\n\tTorusKnotBufferGeometry.prototype.constructor = TorusKnotBufferGeometry;\n\n\t/**\n\t * @author oosmoxiecode\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\t// TorusGeometry\n\n\tfunction TorusGeometry( radius, tube, radialSegments, tubularSegments, arc ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'TorusGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\ttube: tube,\n\t\t\tradialSegments: radialSegments,\n\t\t\ttubularSegments: tubularSegments,\n\t\t\tarc: arc\n\t\t};\n\n\t\tthis.fromBufferGeometry( new TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tTorusGeometry.prototype = Object.create( Geometry.prototype );\n\tTorusGeometry.prototype.constructor = TorusGeometry;\n\n\t// TorusBufferGeometry\n\n\tfunction TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) {\n\n\t\tBufferGeometry.call( this );\n\n\t\tthis.type = 'TorusBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\ttube: tube,\n\t\t\tradialSegments: radialSegments,\n\t\t\ttubularSegments: tubularSegments,\n\t\t\tarc: arc\n\t\t};\n\n\t\tradius = radius || 1;\n\t\ttube = tube || 0.4;\n\t\tradialSegments = Math.floor( radialSegments ) || 8;\n\t\ttubularSegments = Math.floor( tubularSegments ) || 6;\n\t\tarc = arc || Math.PI * 2;\n\n\t\t// buffers\n\n\t\tvar indices = [];\n\t\tvar vertices = [];\n\t\tvar normals = [];\n\t\tvar uvs = [];\n\n\t\t// helper variables\n\n\t\tvar center = new Vector3();\n\t\tvar vertex = new Vector3();\n\t\tvar normal = new Vector3();\n\n\t\tvar j, i;\n\n\t\t// generate vertices, normals and uvs\n\n\t\tfor ( j = 0; j <= radialSegments; j ++ ) {\n\n\t\t\tfor ( i = 0; i <= tubularSegments; i ++ ) {\n\n\t\t\t\tvar u = i / tubularSegments * arc;\n\t\t\t\tvar v = j / radialSegments * Math.PI * 2;\n\n\t\t\t\t// vertex\n\n\t\t\t\tvertex.x = ( radius + tube * Math.cos( v ) ) * Math.cos( u );\n\t\t\t\tvertex.y = ( radius + tube * Math.cos( v ) ) * Math.sin( u );\n\t\t\t\tvertex.z = tube * Math.sin( v );\n\n\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t\t// normal\n\n\t\t\t\tcenter.x = radius * Math.cos( u );\n\t\t\t\tcenter.y = radius * Math.sin( u );\n\t\t\t\tnormal.subVectors( vertex, center ).normalize();\n\n\t\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\t\t// uv\n\n\t\t\t\tuvs.push( i / tubularSegments );\n\t\t\t\tuvs.push( j / radialSegments );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// generate indices\n\n\t\tfor ( j = 1; j <= radialSegments; j ++ ) {\n\n\t\t\tfor ( i = 1; i <= tubularSegments; i ++ ) {\n\n\t\t\t\t// indices\n\n\t\t\t\tvar a = ( tubularSegments + 1 ) * j + i - 1;\n\t\t\t\tvar b = ( tubularSegments + 1 ) * ( j - 1 ) + i - 1;\n\t\t\t\tvar c = ( tubularSegments + 1 ) * ( j - 1 ) + i;\n\t\t\t\tvar d = ( tubularSegments + 1 ) * j + i;\n\n\t\t\t\t// faces\n\n\t\t\t\tindices.push( a, b, d );\n\t\t\t\tindices.push( b, c, d );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// build geometry\n\n\t\tthis.setIndex( indices );\n\t\tthis.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tthis.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\t\tthis.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\t}\n\n\tTorusBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\n\tTorusBufferGeometry.prototype.constructor = TorusBufferGeometry;\n\n\t/**\n\t * @author Mugen87 / https://github.com/Mugen87\n\t * Port from https://github.com/mapbox/earcut (v2.1.2)\n\t */\n\n\tvar Earcut = {\n\n\t\ttriangulate: function ( data, holeIndices, dim ) {\n\n\t\t\tdim = dim || 2;\n\n\t\t\tvar hasHoles = holeIndices && holeIndices.length,\n\t\t\t\touterLen = hasHoles ? holeIndices[ 0 ] * dim : data.length,\n\t\t\t\touterNode = linkedList( data, 0, outerLen, dim, true ),\n\t\t\t\ttriangles = [];\n\n\t\t\tif ( ! outerNode ) return triangles;\n\n\t\t\tvar minX, minY, maxX, maxY, x, y, invSize;\n\n\t\t\tif ( hasHoles ) outerNode = eliminateHoles( data, holeIndices, outerNode, dim );\n\n\t\t\t// if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox\n\n\t\t\tif ( data.length > 80 * dim ) {\n\n\t\t\t\tminX = maxX = data[ 0 ];\n\t\t\t\tminY = maxY = data[ 1 ];\n\n\t\t\t\tfor ( var i = dim; i < outerLen; i += dim ) {\n\n\t\t\t\t\tx = data[ i ];\n\t\t\t\t\ty = data[ i + 1 ];\n\t\t\t\t\tif ( x < minX ) minX = x;\n\t\t\t\t\tif ( y < minY ) minY = y;\n\t\t\t\t\tif ( x > maxX ) maxX = x;\n\t\t\t\t\tif ( y > maxY ) maxY = y;\n\n\t\t\t\t}\n\n\t\t\t\t// minX, minY and invSize are later used to transform coords into integers for z-order calculation\n\n\t\t\t\tinvSize = Math.max( maxX - minX, maxY - minY );\n\t\t\t\tinvSize = invSize !== 0 ? 1 / invSize : 0;\n\n\t\t\t}\n\n\t\t\tearcutLinked( outerNode, triangles, dim, minX, minY, invSize );\n\n\t\t\treturn triangles;\n\n\t\t}\n\n\t};\n\n\t// create a circular doubly linked list from polygon points in the specified winding order\n\n\tfunction linkedList( data, start, end, dim, clockwise ) {\n\n\t\tvar i, last;\n\n\t\tif ( clockwise === ( signedArea( data, start, end, dim ) > 0 ) ) {\n\n\t\t\tfor ( i = start; i < end; i += dim ) last = insertNode( i, data[ i ], data[ i + 1 ], last );\n\n\t\t} else {\n\n\t\t\tfor ( i = end - dim; i >= start; i -= dim ) last = insertNode( i, data[ i ], data[ i + 1 ], last );\n\n\t\t}\n\n\t\tif ( last && equals( last, last.next ) ) {\n\n\t\t\tremoveNode( last );\n\t\t\tlast = last.next;\n\n\t\t}\n\n\t\treturn last;\n\n\t}\n\n\t// eliminate colinear or duplicate points\n\n\tfunction filterPoints( start, end ) {\n\n\t\tif ( ! start ) return start;\n\t\tif ( ! end ) end = start;\n\n\t\tvar p = start, again;\n\n\t\tdo {\n\n\t\t\tagain = false;\n\n\t\t\tif ( ! p.steiner && ( equals( p, p.next ) || area( p.prev, p, p.next ) === 0 ) ) {\n\n\t\t\t\tremoveNode( p );\n\t\t\t\tp = end = p.prev;\n\t\t\t\tif ( p === p.next ) break;\n\t\t\t\tagain = true;\n\n\t\t\t} else {\n\n\t\t\t\tp = p.next;\n\n\t\t\t}\n\n\t\t} while ( again || p !== end );\n\n\t\treturn end;\n\n\t}\n\n\t// main ear slicing loop which triangulates a polygon (given as a linked list)\n\n\tfunction earcutLinked( ear, triangles, dim, minX, minY, invSize, pass ) {\n\n\t\tif ( ! ear ) return;\n\n\t\t// interlink polygon nodes in z-order\n\n\t\tif ( ! pass && invSize ) indexCurve( ear, minX, minY, invSize );\n\n\t\tvar stop = ear, prev, next;\n\n\t\t// iterate through ears, slicing them one by one\n\n\t\twhile ( ear.prev !== ear.next ) {\n\n\t\t\tprev = ear.prev;\n\t\t\tnext = ear.next;\n\n\t\t\tif ( invSize ? isEarHashed( ear, minX, minY, invSize ) : isEar( ear ) ) {\n\n\t\t\t\t// cut off the triangle\n\t\t\t\ttriangles.push( prev.i / dim );\n\t\t\t\ttriangles.push( ear.i / dim );\n\t\t\t\ttriangles.push( next.i / dim );\n\n\t\t\t\tremoveNode( ear );\n\n\t\t\t\t// skipping the next vertice leads to less sliver triangles\n\t\t\t\tear = next.next;\n\t\t\t\tstop = next.next;\n\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\tear = next;\n\n\t\t\t// if we looped through the whole remaining polygon and can't find any more ears\n\n\t\t\tif ( ear === stop ) {\n\n\t\t\t\t// try filtering points and slicing again\n\n\t\t\t\tif ( ! pass ) {\n\n\t\t\t\t\tearcutLinked( filterPoints( ear ), triangles, dim, minX, minY, invSize, 1 );\n\n\t\t\t\t\t// if this didn't work, try curing all small self-intersections locally\n\n\t\t\t\t} else if ( pass === 1 ) {\n\n\t\t\t\t\tear = cureLocalIntersections( ear, triangles, dim );\n\t\t\t\t\tearcutLinked( ear, triangles, dim, minX, minY, invSize, 2 );\n\n\t\t\t\t\t// as a last resort, try splitting the remaining polygon into two\n\n\t\t\t\t} else if ( pass === 2 ) {\n\n\t\t\t\t\tsplitEarcut( ear, triangles, dim, minX, minY, invSize );\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\t// check whether a polygon node forms a valid ear with adjacent nodes\n\n\tfunction isEar( ear ) {\n\n\t\tvar a = ear.prev,\n\t\t\tb = ear,\n\t\t\tc = ear.next;\n\n\t\tif ( area( a, b, c ) >= 0 ) return false; // reflex, can't be an ear\n\n\t\t// now make sure we don't have other points inside the potential ear\n\t\tvar p = ear.next.next;\n\n\t\twhile ( p !== ear.prev ) {\n\n\t\t\tif ( pointInTriangle( a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y ) && area( p.prev, p, p.next ) >= 0 ) {\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t\tp = p.next;\n\n\t\t}\n\n\t\treturn true;\n\n\t}\n\n\tfunction isEarHashed( ear, minX, minY, invSize ) {\n\n\t\tvar a = ear.prev,\n\t\t\tb = ear,\n\t\t\tc = ear.next;\n\n\t\tif ( area( a, b, c ) >= 0 ) return false; // reflex, can't be an ear\n\n\t\t// triangle bbox; min & max are calculated like this for speed\n\n\t\tvar minTX = a.x < b.x ? ( a.x < c.x ? a.x : c.x ) : ( b.x < c.x ? b.x : c.x ),\n\t\t\tminTY = a.y < b.y ? ( a.y < c.y ? a.y : c.y ) : ( b.y < c.y ? b.y : c.y ),\n\t\t\tmaxTX = a.x > b.x ? ( a.x > c.x ? a.x : c.x ) : ( b.x > c.x ? b.x : c.x ),\n\t\t\tmaxTY = a.y > b.y ? ( a.y > c.y ? a.y : c.y ) : ( b.y > c.y ? b.y : c.y );\n\n\t\t// z-order range for the current triangle bbox;\n\n\t\tvar minZ = zOrder( minTX, minTY, minX, minY, invSize ),\n\t\t\tmaxZ = zOrder( maxTX, maxTY, minX, minY, invSize );\n\n\t\t// first look for points inside the triangle in increasing z-order\n\n\t\tvar p = ear.nextZ;\n\n\t\twhile ( p && p.z <= maxZ ) {\n\n\t\t\tif ( p !== ear.prev && p !== ear.next &&\n\t\t\t\t\tpointInTriangle( a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y ) &&\n\t\t\t\t\tarea( p.prev, p, p.next ) >= 0 ) return false;\n\t\t\tp = p.nextZ;\n\n\t\t}\n\n\t\t// then look for points in decreasing z-order\n\n\t\tp = ear.prevZ;\n\n\t\twhile ( p && p.z >= minZ ) {\n\n\t\t\tif ( p !== ear.prev && p !== ear.next &&\n\t\t\t\t\tpointInTriangle( a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y ) &&\n\t\t\t\t\tarea( p.prev, p, p.next ) >= 0 ) return false;\n\n\t\t\tp = p.prevZ;\n\n\t\t}\n\n\t\treturn true;\n\n\t}\n\n\t// go through all polygon nodes and cure small local self-intersections\n\n\tfunction cureLocalIntersections( start, triangles, dim ) {\n\n\t\tvar p = start;\n\n\t\tdo {\n\n\t\t\tvar a = p.prev, b = p.next.next;\n\n\t\t\tif ( ! equals( a, b ) && intersects( a, p, p.next, b ) && locallyInside( a, b ) && locallyInside( b, a ) ) {\n\n\t\t\t\ttriangles.push( a.i / dim );\n\t\t\t\ttriangles.push( p.i / dim );\n\t\t\t\ttriangles.push( b.i / dim );\n\n\t\t\t\t// remove two nodes involved\n\n\t\t\t\tremoveNode( p );\n\t\t\t\tremoveNode( p.next );\n\n\t\t\t\tp = start = b;\n\n\t\t\t}\n\n\t\t\tp = p.next;\n\n\t\t} while ( p !== start );\n\n\t\treturn p;\n\n\t}\n\n\t// try splitting polygon into two and triangulate them independently\n\n\tfunction splitEarcut( start, triangles, dim, minX, minY, invSize ) {\n\n\t\t// look for a valid diagonal that divides the polygon into two\n\n\t\tvar a = start;\n\n\t\tdo {\n\n\t\t\tvar b = a.next.next;\n\n\t\t\twhile ( b !== a.prev ) {\n\n\t\t\t\tif ( a.i !== b.i && isValidDiagonal( a, b ) ) {\n\n\t\t\t\t\t// split the polygon in two by the diagonal\n\n\t\t\t\t\tvar c = splitPolygon( a, b );\n\n\t\t\t\t\t// filter colinear points around the cuts\n\n\t\t\t\t\ta = filterPoints( a, a.next );\n\t\t\t\t\tc = filterPoints( c, c.next );\n\n\t\t\t\t\t// run earcut on each half\n\n\t\t\t\t\tearcutLinked( a, triangles, dim, minX, minY, invSize );\n\t\t\t\t\tearcutLinked( c, triangles, dim, minX, minY, invSize );\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t\tb = b.next;\n\n\t\t\t}\n\n\t\t\ta = a.next;\n\n\t\t} while ( a !== start );\n\n\t}\n\n\t// link every hole into the outer loop, producing a single-ring polygon without holes\n\n\tfunction eliminateHoles( data, holeIndices, outerNode, dim ) {\n\n\t\tvar queue = [], i, len, start, end, list;\n\n\t\tfor ( i = 0, len = holeIndices.length; i < len; i ++ ) {\n\n\t\t\tstart = holeIndices[ i ] * dim;\n\t\t\tend = i < len - 1 ? holeIndices[ i + 1 ] * dim : data.length;\n\t\t\tlist = linkedList( data, start, end, dim, false );\n\t\t\tif ( list === list.next ) list.steiner = true;\n\t\t\tqueue.push( getLeftmost( list ) );\n\n\t\t}\n\n\t\tqueue.sort( compareX );\n\n\t\t// process holes from left to right\n\n\t\tfor ( i = 0; i < queue.length; i ++ ) {\n\n\t\t\teliminateHole( queue[ i ], outerNode );\n\t\t\touterNode = filterPoints( outerNode, outerNode.next );\n\n\t\t}\n\n\t\treturn outerNode;\n\n\t}\n\n\tfunction compareX( a, b ) {\n\n\t\treturn a.x - b.x;\n\n\t}\n\n\t// find a bridge between vertices that connects hole with an outer ring and and link it\n\n\tfunction eliminateHole( hole, outerNode ) {\n\n\t\touterNode = findHoleBridge( hole, outerNode );\n\n\t\tif ( outerNode ) {\n\n\t\t\tvar b = splitPolygon( outerNode, hole );\n\n\t\t\tfilterPoints( b, b.next );\n\n\t\t}\n\n\t}\n\n\t// David Eberly's algorithm for finding a bridge between hole and outer polygon\n\n\tfunction findHoleBridge( hole, outerNode ) {\n\n\t\tvar p = outerNode,\n\t\t\thx = hole.x,\n\t\t\thy = hole.y,\n\t\t\tqx = - Infinity,\n\t\t\tm;\n\n\t\t// find a segment intersected by a ray from the hole's leftmost point to the left;\n\t\t// segment's endpoint with lesser x will be potential connection point\n\n\t\tdo {\n\n\t\t\tif ( hy <= p.y && hy >= p.next.y && p.next.y !== p.y ) {\n\n\t\t\t\tvar x = p.x + ( hy - p.y ) * ( p.next.x - p.x ) / ( p.next.y - p.y );\n\n\t\t\t\tif ( x <= hx && x > qx ) {\n\n\t\t\t\t\tqx = x;\n\n\t\t\t\t\tif ( x === hx ) {\n\n\t\t\t\t\t\tif ( hy === p.y ) return p;\n\t\t\t\t\t\tif ( hy === p.next.y ) return p.next;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tm = p.x < p.next.x ? p : p.next;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tp = p.next;\n\n\t\t} while ( p !== outerNode );\n\n\t\tif ( ! m ) return null;\n\n\t\tif ( hx === qx ) return m.prev; // hole touches outer segment; pick lower endpoint\n\n\t\t// look for points inside the triangle of hole point, segment intersection and endpoint;\n\t\t// if there are no points found, we have a valid connection;\n\t\t// otherwise choose the point of the minimum angle with the ray as connection point\n\n\t\tvar stop = m,\n\t\t\tmx = m.x,\n\t\t\tmy = m.y,\n\t\t\ttanMin = Infinity,\n\t\t\ttan;\n\n\t\tp = m.next;\n\n\t\twhile ( p !== stop ) {\n\n\t\t\tif ( hx >= p.x && p.x >= mx && hx !== p.x &&\n\t\t\t\t\t\t\tpointInTriangle( hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y ) ) {\n\n\t\t\t\ttan = Math.abs( hy - p.y ) / ( hx - p.x ); // tangential\n\n\t\t\t\tif ( ( tan < tanMin || ( tan === tanMin && p.x > m.x ) ) && locallyInside( p, hole ) ) {\n\n\t\t\t\t\tm = p;\n\t\t\t\t\ttanMin = tan;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tp = p.next;\n\n\t\t}\n\n\t\treturn m;\n\n\t}\n\n\t// interlink polygon nodes in z-order\n\n\tfunction indexCurve( start, minX, minY, invSize ) {\n\n\t\tvar p = start;\n\n\t\tdo {\n\n\t\t\tif ( p.z === null ) p.z = zOrder( p.x, p.y, minX, minY, invSize );\n\t\t\tp.prevZ = p.prev;\n\t\t\tp.nextZ = p.next;\n\t\t\tp = p.next;\n\n\t\t} while ( p !== start );\n\n\t\tp.prevZ.nextZ = null;\n\t\tp.prevZ = null;\n\n\t\tsortLinked( p );\n\n\t}\n\n\t// Simon Tatham's linked list merge sort algorithm\n\t// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html\n\n\tfunction sortLinked( list ) {\n\n\t\tvar i, p, q, e, tail, numMerges, pSize, qSize, inSize = 1;\n\n\t\tdo {\n\n\t\t\tp = list;\n\t\t\tlist = null;\n\t\t\ttail = null;\n\t\t\tnumMerges = 0;\n\n\t\t\twhile ( p ) {\n\n\t\t\t\tnumMerges ++;\n\t\t\t\tq = p;\n\t\t\t\tpSize = 0;\n\n\t\t\t\tfor ( i = 0; i < inSize; i ++ ) {\n\n\t\t\t\t\tpSize ++;\n\t\t\t\t\tq = q.nextZ;\n\t\t\t\t\tif ( ! q ) break;\n\n\t\t\t\t}\n\n\t\t\t\tqSize = inSize;\n\n\t\t\t\twhile ( pSize > 0 || ( qSize > 0 && q ) ) {\n\n\t\t\t\t\tif ( pSize !== 0 && ( qSize === 0 || ! q || p.z <= q.z ) ) {\n\n\t\t\t\t\t\te = p;\n\t\t\t\t\t\tp = p.nextZ;\n\t\t\t\t\t\tpSize --;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\te = q;\n\t\t\t\t\t\tq = q.nextZ;\n\t\t\t\t\t\tqSize --;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( tail ) tail.nextZ = e;\n\t\t\t\t\telse list = e;\n\n\t\t\t\t\te.prevZ = tail;\n\t\t\t\t\ttail = e;\n\n\t\t\t\t}\n\n\t\t\t\tp = q;\n\n\t\t\t}\n\n\t\t\ttail.nextZ = null;\n\t\t\tinSize *= 2;\n\n\t\t} while ( numMerges > 1 );\n\n\t\treturn list;\n\n\t}\n\n\t// z-order of a point given coords and inverse of the longer side of data bbox\n\n\tfunction zOrder( x, y, minX, minY, invSize ) {\n\n\t\t// coords are transformed into non-negative 15-bit integer range\n\n\t\tx = 32767 * ( x - minX ) * invSize;\n\t\ty = 32767 * ( y - minY ) * invSize;\n\n\t\tx = ( x | ( x << 8 ) ) & 0x00FF00FF;\n\t\tx = ( x | ( x << 4 ) ) & 0x0F0F0F0F;\n\t\tx = ( x | ( x << 2 ) ) & 0x33333333;\n\t\tx = ( x | ( x << 1 ) ) & 0x55555555;\n\n\t\ty = ( y | ( y << 8 ) ) & 0x00FF00FF;\n\t\ty = ( y | ( y << 4 ) ) & 0x0F0F0F0F;\n\t\ty = ( y | ( y << 2 ) ) & 0x33333333;\n\t\ty = ( y | ( y << 1 ) ) & 0x55555555;\n\n\t\treturn x | ( y << 1 );\n\n\t}\n\n\t// find the leftmost node of a polygon ring\n\n\tfunction getLeftmost( start ) {\n\n\t\tvar p = start, leftmost = start;\n\n\t\tdo {\n\n\t\t\tif ( p.x < leftmost.x ) leftmost = p;\n\t\t\tp = p.next;\n\n\t\t} while ( p !== start );\n\n\t\treturn leftmost;\n\n\t}\n\n\t// check if a point lies within a convex triangle\n\n\tfunction pointInTriangle( ax, ay, bx, by, cx, cy, px, py ) {\n\n\t\treturn ( cx - px ) * ( ay - py ) - ( ax - px ) * ( cy - py ) >= 0 &&\n\t\t ( ax - px ) * ( by - py ) - ( bx - px ) * ( ay - py ) >= 0 &&\n\t\t ( bx - px ) * ( cy - py ) - ( cx - px ) * ( by - py ) >= 0;\n\n\t}\n\n\t// check if a diagonal between two polygon nodes is valid (lies in polygon interior)\n\n\tfunction isValidDiagonal( a, b ) {\n\n\t\treturn a.next.i !== b.i && a.prev.i !== b.i && ! intersectsPolygon( a, b ) &&\n\t\t\tlocallyInside( a, b ) && locallyInside( b, a ) && middleInside( a, b );\n\n\t}\n\n\t// signed area of a triangle\n\n\tfunction area( p, q, r ) {\n\n\t\treturn ( q.y - p.y ) * ( r.x - q.x ) - ( q.x - p.x ) * ( r.y - q.y );\n\n\t}\n\n\t// check if two points are equal\n\n\tfunction equals( p1, p2 ) {\n\n\t\treturn p1.x === p2.x && p1.y === p2.y;\n\n\t}\n\n\t// check if two segments intersect\n\n\tfunction intersects( p1, q1, p2, q2 ) {\n\n\t\tif ( ( equals( p1, q1 ) && equals( p2, q2 ) ) ||\n\t\t\t\t( equals( p1, q2 ) && equals( p2, q1 ) ) ) return true;\n\n\t\treturn area( p1, q1, p2 ) > 0 !== area( p1, q1, q2 ) > 0 &&\n\t\t\t\t\t area( p2, q2, p1 ) > 0 !== area( p2, q2, q1 ) > 0;\n\n\t}\n\n\t// check if a polygon diagonal intersects any polygon segments\n\n\tfunction intersectsPolygon( a, b ) {\n\n\t\tvar p = a;\n\n\t\tdo {\n\n\t\t\tif ( p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&\n\t\t\t\t\t\t\tintersects( p, p.next, a, b ) ) {\n\n\t\t\t\treturn true;\n\n\t\t\t}\n\n\t\t\tp = p.next;\n\n\t\t} while ( p !== a );\n\n\t\treturn false;\n\n\t}\n\n\t// check if a polygon diagonal is locally inside the polygon\n\n\tfunction locallyInside( a, b ) {\n\n\t\treturn area( a.prev, a, a.next ) < 0 ?\n\t\t\tarea( a, b, a.next ) >= 0 && area( a, a.prev, b ) >= 0 :\n\t\t\tarea( a, b, a.prev ) < 0 || area( a, a.next, b ) < 0;\n\n\t}\n\n\t// check if the middle point of a polygon diagonal is inside the polygon\n\n\tfunction middleInside( a, b ) {\n\n\t\tvar p = a,\n\t\t\tinside = false,\n\t\t\tpx = ( a.x + b.x ) / 2,\n\t\t\tpy = ( a.y + b.y ) / 2;\n\n\t\tdo {\n\n\t\t\tif ( ( ( p.y > py ) !== ( p.next.y > py ) ) && p.next.y !== p.y &&\n\t\t\t\t\t\t\t( px < ( p.next.x - p.x ) * ( py - p.y ) / ( p.next.y - p.y ) + p.x ) ) {\n\n\t\t\t\tinside = ! inside;\n\n\t\t\t}\n\n\t\t\tp = p.next;\n\n\t\t} while ( p !== a );\n\n\t\treturn inside;\n\n\t}\n\n\t// link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;\n\t// if one belongs to the outer ring and another to a hole, it merges it into a single ring\n\n\tfunction splitPolygon( a, b ) {\n\n\t\tvar a2 = new Node( a.i, a.x, a.y ),\n\t\t\tb2 = new Node( b.i, b.x, b.y ),\n\t\t\tan = a.next,\n\t\t\tbp = b.prev;\n\n\t\ta.next = b;\n\t\tb.prev = a;\n\n\t\ta2.next = an;\n\t\tan.prev = a2;\n\n\t\tb2.next = a2;\n\t\ta2.prev = b2;\n\n\t\tbp.next = b2;\n\t\tb2.prev = bp;\n\n\t\treturn b2;\n\n\t}\n\n\t// create a node and optionally link it with previous one (in a circular doubly linked list)\n\n\tfunction insertNode( i, x, y, last ) {\n\n\t\tvar p = new Node( i, x, y );\n\n\t\tif ( ! last ) {\n\n\t\t\tp.prev = p;\n\t\t\tp.next = p;\n\n\t\t} else {\n\n\t\t\tp.next = last.next;\n\t\t\tp.prev = last;\n\t\t\tlast.next.prev = p;\n\t\t\tlast.next = p;\n\n\t\t}\n\n\t\treturn p;\n\n\t}\n\n\tfunction removeNode( p ) {\n\n\t\tp.next.prev = p.prev;\n\t\tp.prev.next = p.next;\n\n\t\tif ( p.prevZ ) p.prevZ.nextZ = p.nextZ;\n\t\tif ( p.nextZ ) p.nextZ.prevZ = p.prevZ;\n\n\t}\n\n\tfunction Node( i, x, y ) {\n\n\t\t// vertice index in coordinates array\n\t\tthis.i = i;\n\n\t\t// vertex coordinates\n\t\tthis.x = x;\n\t\tthis.y = y;\n\n\t\t// previous and next vertice nodes in a polygon ring\n\t\tthis.prev = null;\n\t\tthis.next = null;\n\n\t\t// z-order curve value\n\t\tthis.z = null;\n\n\t\t// previous and next nodes in z-order\n\t\tthis.prevZ = null;\n\t\tthis.nextZ = null;\n\n\t\t// indicates whether this is a steiner point\n\t\tthis.steiner = false;\n\n\t}\n\n\tfunction signedArea( data, start, end, dim ) {\n\n\t\tvar sum = 0;\n\n\t\tfor ( var i = start, j = end - dim; i < end; i += dim ) {\n\n\t\t\tsum += ( data[ j ] - data[ i ] ) * ( data[ i + 1 ] + data[ j + 1 ] );\n\t\t\tj = i;\n\n\t\t}\n\n\t\treturn sum;\n\n\t}\n\n\t/**\n\t * @author zz85 / http://www.lab4games.net/zz85/blog\n\t */\n\n\tvar ShapeUtils = {\n\n\t\t// calculate area of the contour polygon\n\n\t\tarea: function ( contour ) {\n\n\t\t\tvar n = contour.length;\n\t\t\tvar a = 0.0;\n\n\t\t\tfor ( var p = n - 1, q = 0; q < n; p = q ++ ) {\n\n\t\t\t\ta += contour[ p ].x * contour[ q ].y - contour[ q ].x * contour[ p ].y;\n\n\t\t\t}\n\n\t\t\treturn a * 0.5;\n\n\t\t},\n\n\t\tisClockWise: function ( pts ) {\n\n\t\t\treturn ShapeUtils.area( pts ) < 0;\n\n\t\t},\n\n\t\ttriangulateShape: function ( contour, holes ) {\n\n\t\t\tvar vertices = []; // flat array of vertices like [ x0,y0, x1,y1, x2,y2, ... ]\n\t\t\tvar holeIndices = []; // array of hole indices\n\t\t\tvar faces = []; // final array of vertex indices like [ [ a,b,d ], [ b,c,d ] ]\n\n\t\t\tremoveDupEndPts( contour );\n\t\t\taddContour( vertices, contour );\n\n\t\t\t//\n\n\t\t\tvar holeIndex = contour.length;\n\n\t\t\tholes.forEach( removeDupEndPts );\n\n\t\t\tfor ( var i = 0; i < holes.length; i ++ ) {\n\n\t\t\t\tholeIndices.push( holeIndex );\n\t\t\t\tholeIndex += holes[ i ].length;\n\t\t\t\taddContour( vertices, holes[ i ] );\n\n\t\t\t}\n\n\t\t\t//\n\n\t\t\tvar triangles = Earcut.triangulate( vertices, holeIndices );\n\n\t\t\t//\n\n\t\t\tfor ( var i = 0; i < triangles.length; i += 3 ) {\n\n\t\t\t\tfaces.push( triangles.slice( i, i + 3 ) );\n\n\t\t\t}\n\n\t\t\treturn faces;\n\n\t\t}\n\n\t};\n\n\tfunction removeDupEndPts( points ) {\n\n\t\tvar l = points.length;\n\n\t\tif ( l > 2 && points[ l - 1 ].equals( points[ 0 ] ) ) {\n\n\t\t\tpoints.pop();\n\n\t\t}\n\n\t}\n\n\tfunction addContour( vertices, contour ) {\n\n\t\tfor ( var i = 0; i < contour.length; i ++ ) {\n\n\t\t\tvertices.push( contour[ i ].x );\n\t\t\tvertices.push( contour[ i ].y );\n\n\t\t}\n\n\t}\n\n\t/**\n\t * @author zz85 / http://www.lab4games.net/zz85/blog\n\t *\n\t * Creates extruded geometry from a path shape.\n\t *\n\t * parameters = {\n\t *\n\t *  curveSegments: <int>, // number of points on the curves\n\t *  steps: <int>, // number of points for z-side extrusions / used for subdividing segments of extrude spline too\n\t *  depth: <float>, // Depth to extrude the shape\n\t *\n\t *  bevelEnabled: <bool>, // turn on bevel\n\t *  bevelThickness: <float>, // how deep into the original shape bevel goes\n\t *  bevelSize: <float>, // how far from shape outline is bevel\n\t *  bevelSegments: <int>, // number of bevel layers\n\t *\n\t *  extrudePath: <THREE.Curve> // curve to extrude shape along\n\t *\n\t *  UVGenerator: <Object> // object that provides UV generator functions\n\t *\n\t * }\n\t */\n\n\t// ExtrudeGeometry\n\n\tfunction ExtrudeGeometry( shapes, options ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'ExtrudeGeometry';\n\n\t\tthis.parameters = {\n\t\t\tshapes: shapes,\n\t\t\toptions: options\n\t\t};\n\n\t\tthis.fromBufferGeometry( new ExtrudeBufferGeometry( shapes, options ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tExtrudeGeometry.prototype = Object.create( Geometry.prototype );\n\tExtrudeGeometry.prototype.constructor = ExtrudeGeometry;\n\n\tExtrudeGeometry.prototype.toJSON = function () {\n\n\t\tvar data = Geometry.prototype.toJSON.call( this );\n\n\t\tvar shapes = this.parameters.shapes;\n\t\tvar options = this.parameters.options;\n\n\t\treturn toJSON( shapes, options, data );\n\n\t};\n\n\t// ExtrudeBufferGeometry\n\n\tfunction ExtrudeBufferGeometry( shapes, options ) {\n\n\t\tBufferGeometry.call( this );\n\n\t\tthis.type = 'ExtrudeBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\tshapes: shapes,\n\t\t\toptions: options\n\t\t};\n\n\t\tshapes = Array.isArray( shapes ) ? shapes : [ shapes ];\n\n\t\tvar scope = this;\n\n\t\tvar verticesArray = [];\n\t\tvar uvArray = [];\n\n\t\tfor ( var i = 0, l = shapes.length; i < l; i ++ ) {\n\n\t\t\tvar shape = shapes[ i ];\n\t\t\taddShape( shape );\n\n\t\t}\n\n\t\t// build geometry\n\n\t\tthis.addAttribute( 'position', new Float32BufferAttribute( verticesArray, 3 ) );\n\t\tthis.addAttribute( 'uv', new Float32BufferAttribute( uvArray, 2 ) );\n\n\t\tthis.computeVertexNormals();\n\n\t\t// functions\n\n\t\tfunction addShape( shape ) {\n\n\t\t\tvar placeholder = [];\n\n\t\t\t// options\n\n\t\t\tvar curveSegments = options.curveSegments !== undefined ? options.curveSegments : 12;\n\t\t\tvar steps = options.steps !== undefined ? options.steps : 1;\n\t\t\tvar depth = options.depth !== undefined ? options.depth : 100;\n\n\t\t\tvar bevelEnabled = options.bevelEnabled !== undefined ? options.bevelEnabled : true;\n\t\t\tvar bevelThickness = options.bevelThickness !== undefined ? options.bevelThickness : 6;\n\t\t\tvar bevelSize = options.bevelSize !== undefined ? options.bevelSize : bevelThickness - 2;\n\t\t\tvar bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3;\n\n\t\t\tvar extrudePath = options.extrudePath;\n\n\t\t\tvar uvgen = options.UVGenerator !== undefined ? options.UVGenerator : WorldUVGenerator;\n\n\t\t\t// deprecated options\n\n\t\t\tif ( options.amount !== undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.ExtrudeBufferGeometry: amount has been renamed to depth.' );\n\t\t\t\tdepth = options.amount;\n\n\t\t\t}\n\n\t\t\t//\n\n\t\t\tvar extrudePts, extrudeByPath = false;\n\t\t\tvar splineTube, binormal, normal, position2;\n\n\t\t\tif ( extrudePath ) {\n\n\t\t\t\textrudePts = extrudePath.getSpacedPoints( steps );\n\n\t\t\t\textrudeByPath = true;\n\t\t\t\tbevelEnabled = false; // bevels not supported for path extrusion\n\n\t\t\t\t// SETUP TNB variables\n\n\t\t\t\t// TODO1 - have a .isClosed in spline?\n\n\t\t\t\tsplineTube = extrudePath.computeFrenetFrames( steps, false );\n\n\t\t\t\t// console.log(splineTube, 'splineTube', splineTube.normals.length, 'steps', steps, 'extrudePts', extrudePts.length);\n\n\t\t\t\tbinormal = new Vector3();\n\t\t\t\tnormal = new Vector3();\n\t\t\t\tposition2 = new Vector3();\n\n\t\t\t}\n\n\t\t\t// Safeguards if bevels are not enabled\n\n\t\t\tif ( ! bevelEnabled ) {\n\n\t\t\t\tbevelSegments = 0;\n\t\t\t\tbevelThickness = 0;\n\t\t\t\tbevelSize = 0;\n\n\t\t\t}\n\n\t\t\t// Variables initialization\n\n\t\t\tvar ahole, h, hl; // looping of holes\n\n\t\t\tvar shapePoints = shape.extractPoints( curveSegments );\n\n\t\t\tvar vertices = shapePoints.shape;\n\t\t\tvar holes = shapePoints.holes;\n\n\t\t\tvar reverse = ! ShapeUtils.isClockWise( vertices );\n\n\t\t\tif ( reverse ) {\n\n\t\t\t\tvertices = vertices.reverse();\n\n\t\t\t\t// Maybe we should also check if holes are in the opposite direction, just to be safe ...\n\n\t\t\t\tfor ( h = 0, hl = holes.length; h < hl; h ++ ) {\n\n\t\t\t\t\tahole = holes[ h ];\n\n\t\t\t\t\tif ( ShapeUtils.isClockWise( ahole ) ) {\n\n\t\t\t\t\t\tholes[ h ] = ahole.reverse();\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\n\t\t\tvar faces = ShapeUtils.triangulateShape( vertices, holes );\n\n\t\t\t/* Vertices */\n\n\t\t\tvar contour = vertices; // vertices has all points but contour has only points of circumference\n\n\t\t\tfor ( h = 0, hl = holes.length; h < hl; h ++ ) {\n\n\t\t\t\tahole = holes[ h ];\n\n\t\t\t\tvertices = vertices.concat( ahole );\n\n\t\t\t}\n\n\n\t\t\tfunction scalePt2( pt, vec, size ) {\n\n\t\t\t\tif ( ! vec ) console.error( \"THREE.ExtrudeGeometry: vec does not exist\" );\n\n\t\t\t\treturn vec.clone().multiplyScalar( size ).add( pt );\n\n\t\t\t}\n\n\t\t\tvar b, bs, t, z,\n\t\t\t\tvert, vlen = vertices.length,\n\t\t\t\tface, flen = faces.length;\n\n\n\t\t\t// Find directions for point movement\n\n\n\t\t\tfunction getBevelVec( inPt, inPrev, inNext ) {\n\n\t\t\t\t// computes for inPt the corresponding point inPt' on a new contour\n\t\t\t\t//   shifted by 1 unit (length of normalized vector) to the left\n\t\t\t\t// if we walk along contour clockwise, this new contour is outside the old one\n\t\t\t\t//\n\t\t\t\t// inPt' is the intersection of the two lines parallel to the two\n\t\t\t\t//  adjacent edges of inPt at a distance of 1 unit on the left side.\n\n\t\t\t\tvar v_trans_x, v_trans_y, shrink_by; // resulting translation vector for inPt\n\n\t\t\t\t// good reading for geometry algorithms (here: line-line intersection)\n\t\t\t\t// http://geomalgorithms.com/a05-_intersect-1.html\n\n\t\t\t\tvar v_prev_x = inPt.x - inPrev.x,\n\t\t\t\t\tv_prev_y = inPt.y - inPrev.y;\n\t\t\t\tvar v_next_x = inNext.x - inPt.x,\n\t\t\t\t\tv_next_y = inNext.y - inPt.y;\n\n\t\t\t\tvar v_prev_lensq = ( v_prev_x * v_prev_x + v_prev_y * v_prev_y );\n\n\t\t\t\t// check for collinear edges\n\t\t\t\tvar collinear0 = ( v_prev_x * v_next_y - v_prev_y * v_next_x );\n\n\t\t\t\tif ( Math.abs( collinear0 ) > Number.EPSILON ) {\n\n\t\t\t\t\t// not collinear\n\n\t\t\t\t\t// length of vectors for normalizing\n\n\t\t\t\t\tvar v_prev_len = Math.sqrt( v_prev_lensq );\n\t\t\t\t\tvar v_next_len = Math.sqrt( v_next_x * v_next_x + v_next_y * v_next_y );\n\n\t\t\t\t\t// shift adjacent points by unit vectors to the left\n\n\t\t\t\t\tvar ptPrevShift_x = ( inPrev.x - v_prev_y / v_prev_len );\n\t\t\t\t\tvar ptPrevShift_y = ( inPrev.y + v_prev_x / v_prev_len );\n\n\t\t\t\t\tvar ptNextShift_x = ( inNext.x - v_next_y / v_next_len );\n\t\t\t\t\tvar ptNextShift_y = ( inNext.y + v_next_x / v_next_len );\n\n\t\t\t\t\t// scaling factor for v_prev to intersection point\n\n\t\t\t\t\tvar sf = ( ( ptNextShift_x - ptPrevShift_x ) * v_next_y -\n\t\t\t\t\t\t\t( ptNextShift_y - ptPrevShift_y ) * v_next_x ) /\n\t\t\t\t\t\t( v_prev_x * v_next_y - v_prev_y * v_next_x );\n\n\t\t\t\t\t// vector from inPt to intersection point\n\n\t\t\t\t\tv_trans_x = ( ptPrevShift_x + v_prev_x * sf - inPt.x );\n\t\t\t\t\tv_trans_y = ( ptPrevShift_y + v_prev_y * sf - inPt.y );\n\n\t\t\t\t\t// Don't normalize!, otherwise sharp corners become ugly\n\t\t\t\t\t//  but prevent crazy spikes\n\t\t\t\t\tvar v_trans_lensq = ( v_trans_x * v_trans_x + v_trans_y * v_trans_y );\n\t\t\t\t\tif ( v_trans_lensq <= 2 ) {\n\n\t\t\t\t\t\treturn new Vector2( v_trans_x, v_trans_y );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tshrink_by = Math.sqrt( v_trans_lensq / 2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// handle special case of collinear edges\n\n\t\t\t\t\tvar direction_eq = false; // assumes: opposite\n\t\t\t\t\tif ( v_prev_x > Number.EPSILON ) {\n\n\t\t\t\t\t\tif ( v_next_x > Number.EPSILON ) {\n\n\t\t\t\t\t\t\tdirection_eq = true;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tif ( v_prev_x < - Number.EPSILON ) {\n\n\t\t\t\t\t\t\tif ( v_next_x < - Number.EPSILON ) {\n\n\t\t\t\t\t\t\t\tdirection_eq = true;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tif ( Math.sign( v_prev_y ) === Math.sign( v_next_y ) ) {\n\n\t\t\t\t\t\t\t\tdirection_eq = true;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( direction_eq ) {\n\n\t\t\t\t\t\t// console.log(\"Warning: lines are a straight sequence\");\n\t\t\t\t\t\tv_trans_x = - v_prev_y;\n\t\t\t\t\t\tv_trans_y = v_prev_x;\n\t\t\t\t\t\tshrink_by = Math.sqrt( v_prev_lensq );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// console.log(\"Warning: lines are a straight spike\");\n\t\t\t\t\t\tv_trans_x = v_prev_x;\n\t\t\t\t\t\tv_trans_y = v_prev_y;\n\t\t\t\t\t\tshrink_by = Math.sqrt( v_prev_lensq / 2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\treturn new Vector2( v_trans_x / shrink_by, v_trans_y / shrink_by );\n\n\t\t\t}\n\n\n\t\t\tvar contourMovements = [];\n\n\t\t\tfor ( var i = 0, il = contour.length, j = il - 1, k = i + 1; i < il; i ++, j ++, k ++ ) {\n\n\t\t\t\tif ( j === il ) j = 0;\n\t\t\t\tif ( k === il ) k = 0;\n\n\t\t\t\t//  (j)---(i)---(k)\n\t\t\t\t// console.log('i,j,k', i, j , k)\n\n\t\t\t\tcontourMovements[ i ] = getBevelVec( contour[ i ], contour[ j ], contour[ k ] );\n\n\t\t\t}\n\n\t\t\tvar holesMovements = [],\n\t\t\t\toneHoleMovements, verticesMovements = contourMovements.concat();\n\n\t\t\tfor ( h = 0, hl = holes.length; h < hl; h ++ ) {\n\n\t\t\t\tahole = holes[ h ];\n\n\t\t\t\toneHoleMovements = [];\n\n\t\t\t\tfor ( i = 0, il = ahole.length, j = il - 1, k = i + 1; i < il; i ++, j ++, k ++ ) {\n\n\t\t\t\t\tif ( j === il ) j = 0;\n\t\t\t\t\tif ( k === il ) k = 0;\n\n\t\t\t\t\t//  (j)---(i)---(k)\n\t\t\t\t\toneHoleMovements[ i ] = getBevelVec( ahole[ i ], ahole[ j ], ahole[ k ] );\n\n\t\t\t\t}\n\n\t\t\t\tholesMovements.push( oneHoleMovements );\n\t\t\t\tverticesMovements = verticesMovements.concat( oneHoleMovements );\n\n\t\t\t}\n\n\n\t\t\t// Loop bevelSegments, 1 for the front, 1 for the back\n\n\t\t\tfor ( b = 0; b < bevelSegments; b ++ ) {\n\n\t\t\t\t//for ( b = bevelSegments; b > 0; b -- ) {\n\n\t\t\t\tt = b / bevelSegments;\n\t\t\t\tz = bevelThickness * Math.cos( t * Math.PI / 2 );\n\t\t\t\tbs = bevelSize * Math.sin( t * Math.PI / 2 );\n\n\t\t\t\t// contract shape\n\n\t\t\t\tfor ( i = 0, il = contour.length; i < il; i ++ ) {\n\n\t\t\t\t\tvert = scalePt2( contour[ i ], contourMovements[ i ], bs );\n\n\t\t\t\t\tv( vert.x, vert.y, - z );\n\n\t\t\t\t}\n\n\t\t\t\t// expand holes\n\n\t\t\t\tfor ( h = 0, hl = holes.length; h < hl; h ++ ) {\n\n\t\t\t\t\tahole = holes[ h ];\n\t\t\t\t\toneHoleMovements = holesMovements[ h ];\n\n\t\t\t\t\tfor ( i = 0, il = ahole.length; i < il; i ++ ) {\n\n\t\t\t\t\t\tvert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs );\n\n\t\t\t\t\t\tv( vert.x, vert.y, - z );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tbs = bevelSize;\n\n\t\t\t// Back facing vertices\n\n\t\t\tfor ( i = 0; i < vlen; i ++ ) {\n\n\t\t\t\tvert = bevelEnabled ? scalePt2( vertices[ i ], verticesMovements[ i ], bs ) : vertices[ i ];\n\n\t\t\t\tif ( ! extrudeByPath ) {\n\n\t\t\t\t\tv( vert.x, vert.y, 0 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// v( vert.x, vert.y + extrudePts[ 0 ].y, extrudePts[ 0 ].x );\n\n\t\t\t\t\tnormal.copy( splineTube.normals[ 0 ] ).multiplyScalar( vert.x );\n\t\t\t\t\tbinormal.copy( splineTube.binormals[ 0 ] ).multiplyScalar( vert.y );\n\n\t\t\t\t\tposition2.copy( extrudePts[ 0 ] ).add( normal ).add( binormal );\n\n\t\t\t\t\tv( position2.x, position2.y, position2.z );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// Add stepped vertices...\n\t\t\t// Including front facing vertices\n\n\t\t\tvar s;\n\n\t\t\tfor ( s = 1; s <= steps; s ++ ) {\n\n\t\t\t\tfor ( i = 0; i < vlen; i ++ ) {\n\n\t\t\t\t\tvert = bevelEnabled ? scalePt2( vertices[ i ], verticesMovements[ i ], bs ) : vertices[ i ];\n\n\t\t\t\t\tif ( ! extrudeByPath ) {\n\n\t\t\t\t\t\tv( vert.x, vert.y, depth / steps * s );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// v( vert.x, vert.y + extrudePts[ s - 1 ].y, extrudePts[ s - 1 ].x );\n\n\t\t\t\t\t\tnormal.copy( splineTube.normals[ s ] ).multiplyScalar( vert.x );\n\t\t\t\t\t\tbinormal.copy( splineTube.binormals[ s ] ).multiplyScalar( vert.y );\n\n\t\t\t\t\t\tposition2.copy( extrudePts[ s ] ).add( normal ).add( binormal );\n\n\t\t\t\t\t\tv( position2.x, position2.y, position2.z );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\n\t\t\t// Add bevel segments planes\n\n\t\t\t//for ( b = 1; b <= bevelSegments; b ++ ) {\n\t\t\tfor ( b = bevelSegments - 1; b >= 0; b -- ) {\n\n\t\t\t\tt = b / bevelSegments;\n\t\t\t\tz = bevelThickness * Math.cos( t * Math.PI / 2 );\n\t\t\t\tbs = bevelSize * Math.sin( t * Math.PI / 2 );\n\n\t\t\t\t// contract shape\n\n\t\t\t\tfor ( i = 0, il = contour.length; i < il; i ++ ) {\n\n\t\t\t\t\tvert = scalePt2( contour[ i ], contourMovements[ i ], bs );\n\t\t\t\t\tv( vert.x, vert.y, depth + z );\n\n\t\t\t\t}\n\n\t\t\t\t// expand holes\n\n\t\t\t\tfor ( h = 0, hl = holes.length; h < hl; h ++ ) {\n\n\t\t\t\t\tahole = holes[ h ];\n\t\t\t\t\toneHoleMovements = holesMovements[ h ];\n\n\t\t\t\t\tfor ( i = 0, il = ahole.length; i < il; i ++ ) {\n\n\t\t\t\t\t\tvert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs );\n\n\t\t\t\t\t\tif ( ! extrudeByPath ) {\n\n\t\t\t\t\t\t\tv( vert.x, vert.y, depth + z );\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tv( vert.x, vert.y + extrudePts[ steps - 1 ].y, extrudePts[ steps - 1 ].x + z );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t/* Faces */\n\n\t\t\t// Top and bottom faces\n\n\t\t\tbuildLidFaces();\n\n\t\t\t// Sides faces\n\n\t\t\tbuildSideFaces();\n\n\n\t\t\t/////  Internal functions\n\n\t\t\tfunction buildLidFaces() {\n\n\t\t\t\tvar start = verticesArray.length / 3;\n\n\t\t\t\tif ( bevelEnabled ) {\n\n\t\t\t\t\tvar layer = 0; // steps + 1\n\t\t\t\t\tvar offset = vlen * layer;\n\n\t\t\t\t\t// Bottom faces\n\n\t\t\t\t\tfor ( i = 0; i < flen; i ++ ) {\n\n\t\t\t\t\t\tface = faces[ i ];\n\t\t\t\t\t\tf3( face[ 2 ] + offset, face[ 1 ] + offset, face[ 0 ] + offset );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tlayer = steps + bevelSegments * 2;\n\t\t\t\t\toffset = vlen * layer;\n\n\t\t\t\t\t// Top faces\n\n\t\t\t\t\tfor ( i = 0; i < flen; i ++ ) {\n\n\t\t\t\t\t\tface = faces[ i ];\n\t\t\t\t\t\tf3( face[ 0 ] + offset, face[ 1 ] + offset, face[ 2 ] + offset );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// Bottom faces\n\n\t\t\t\t\tfor ( i = 0; i < flen; i ++ ) {\n\n\t\t\t\t\t\tface = faces[ i ];\n\t\t\t\t\t\tf3( face[ 2 ], face[ 1 ], face[ 0 ] );\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// Top faces\n\n\t\t\t\t\tfor ( i = 0; i < flen; i ++ ) {\n\n\t\t\t\t\t\tface = faces[ i ];\n\t\t\t\t\t\tf3( face[ 0 ] + vlen * steps, face[ 1 ] + vlen * steps, face[ 2 ] + vlen * steps );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tscope.addGroup( start, verticesArray.length / 3 - start, 0 );\n\n\t\t\t}\n\n\t\t\t// Create faces for the z-sides of the shape\n\n\t\t\tfunction buildSideFaces() {\n\n\t\t\t\tvar start = verticesArray.length / 3;\n\t\t\t\tvar layeroffset = 0;\n\t\t\t\tsidewalls( contour, layeroffset );\n\t\t\t\tlayeroffset += contour.length;\n\n\t\t\t\tfor ( h = 0, hl = holes.length; h < hl; h ++ ) {\n\n\t\t\t\t\tahole = holes[ h ];\n\t\t\t\t\tsidewalls( ahole, layeroffset );\n\n\t\t\t\t\t//, true\n\t\t\t\t\tlayeroffset += ahole.length;\n\n\t\t\t\t}\n\n\n\t\t\t\tscope.addGroup( start, verticesArray.length / 3 - start, 1 );\n\n\n\t\t\t}\n\n\t\t\tfunction sidewalls( contour, layeroffset ) {\n\n\t\t\t\tvar j, k;\n\t\t\t\ti = contour.length;\n\n\t\t\t\twhile ( -- i >= 0 ) {\n\n\t\t\t\t\tj = i;\n\t\t\t\t\tk = i - 1;\n\t\t\t\t\tif ( k < 0 ) k = contour.length - 1;\n\n\t\t\t\t\t//console.log('b', i,j, i-1, k,vertices.length);\n\n\t\t\t\t\tvar s = 0,\n\t\t\t\t\t\tsl = steps + bevelSegments * 2;\n\n\t\t\t\t\tfor ( s = 0; s < sl; s ++ ) {\n\n\t\t\t\t\t\tvar slen1 = vlen * s;\n\t\t\t\t\t\tvar slen2 = vlen * ( s + 1 );\n\n\t\t\t\t\t\tvar a = layeroffset + j + slen1,\n\t\t\t\t\t\t\tb = layeroffset + k + slen1,\n\t\t\t\t\t\t\tc = layeroffset + k + slen2,\n\t\t\t\t\t\t\td = layeroffset + j + slen2;\n\n\t\t\t\t\t\tf4( a, b, c, d );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tfunction v( x, y, z ) {\n\n\t\t\t\tplaceholder.push( x );\n\t\t\t\tplaceholder.push( y );\n\t\t\t\tplaceholder.push( z );\n\n\t\t\t}\n\n\n\t\t\tfunction f3( a, b, c ) {\n\n\t\t\t\taddVertex( a );\n\t\t\t\taddVertex( b );\n\t\t\t\taddVertex( c );\n\n\t\t\t\tvar nextIndex = verticesArray.length / 3;\n\t\t\t\tvar uvs = uvgen.generateTopUV( scope, verticesArray, nextIndex - 3, nextIndex - 2, nextIndex - 1 );\n\n\t\t\t\taddUV( uvs[ 0 ] );\n\t\t\t\taddUV( uvs[ 1 ] );\n\t\t\t\taddUV( uvs[ 2 ] );\n\n\t\t\t}\n\n\t\t\tfunction f4( a, b, c, d ) {\n\n\t\t\t\taddVertex( a );\n\t\t\t\taddVertex( b );\n\t\t\t\taddVertex( d );\n\n\t\t\t\taddVertex( b );\n\t\t\t\taddVertex( c );\n\t\t\t\taddVertex( d );\n\n\n\t\t\t\tvar nextIndex = verticesArray.length / 3;\n\t\t\t\tvar uvs = uvgen.generateSideWallUV( scope, verticesArray, nextIndex - 6, nextIndex - 3, nextIndex - 2, nextIndex - 1 );\n\n\t\t\t\taddUV( uvs[ 0 ] );\n\t\t\t\taddUV( uvs[ 1 ] );\n\t\t\t\taddUV( uvs[ 3 ] );\n\n\t\t\t\taddUV( uvs[ 1 ] );\n\t\t\t\taddUV( uvs[ 2 ] );\n\t\t\t\taddUV( uvs[ 3 ] );\n\n\t\t\t}\n\n\t\t\tfunction addVertex( index ) {\n\n\t\t\t\tverticesArray.push( placeholder[ index * 3 + 0 ] );\n\t\t\t\tverticesArray.push( placeholder[ index * 3 + 1 ] );\n\t\t\t\tverticesArray.push( placeholder[ index * 3 + 2 ] );\n\n\t\t\t}\n\n\n\t\t\tfunction addUV( vector2 ) {\n\n\t\t\t\tuvArray.push( vector2.x );\n\t\t\t\tuvArray.push( vector2.y );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tExtrudeBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\n\tExtrudeBufferGeometry.prototype.constructor = ExtrudeBufferGeometry;\n\n\tExtrudeBufferGeometry.prototype.toJSON = function () {\n\n\t\tvar data = BufferGeometry.prototype.toJSON.call( this );\n\n\t\tvar shapes = this.parameters.shapes;\n\t\tvar options = this.parameters.options;\n\n\t\treturn toJSON( shapes, options, data );\n\n\t};\n\n\t//\n\n\tvar WorldUVGenerator = {\n\n\t\tgenerateTopUV: function ( geometry, vertices, indexA, indexB, indexC ) {\n\n\t\t\tvar a_x = vertices[ indexA * 3 ];\n\t\t\tvar a_y = vertices[ indexA * 3 + 1 ];\n\t\t\tvar b_x = vertices[ indexB * 3 ];\n\t\t\tvar b_y = vertices[ indexB * 3 + 1 ];\n\t\t\tvar c_x = vertices[ indexC * 3 ];\n\t\t\tvar c_y = vertices[ indexC * 3 + 1 ];\n\n\t\t\treturn [\n\t\t\t\tnew Vector2( a_x, a_y ),\n\t\t\t\tnew Vector2( b_x, b_y ),\n\t\t\t\tnew Vector2( c_x, c_y )\n\t\t\t];\n\n\t\t},\n\n\t\tgenerateSideWallUV: function ( geometry, vertices, indexA, indexB, indexC, indexD ) {\n\n\t\t\tvar a_x = vertices[ indexA * 3 ];\n\t\t\tvar a_y = vertices[ indexA * 3 + 1 ];\n\t\t\tvar a_z = vertices[ indexA * 3 + 2 ];\n\t\t\tvar b_x = vertices[ indexB * 3 ];\n\t\t\tvar b_y = vertices[ indexB * 3 + 1 ];\n\t\t\tvar b_z = vertices[ indexB * 3 + 2 ];\n\t\t\tvar c_x = vertices[ indexC * 3 ];\n\t\t\tvar c_y = vertices[ indexC * 3 + 1 ];\n\t\t\tvar c_z = vertices[ indexC * 3 + 2 ];\n\t\t\tvar d_x = vertices[ indexD * 3 ];\n\t\t\tvar d_y = vertices[ indexD * 3 + 1 ];\n\t\t\tvar d_z = vertices[ indexD * 3 + 2 ];\n\n\t\t\tif ( Math.abs( a_y - b_y ) < 0.01 ) {\n\n\t\t\t\treturn [\n\t\t\t\t\tnew Vector2( a_x, 1 - a_z ),\n\t\t\t\t\tnew Vector2( b_x, 1 - b_z ),\n\t\t\t\t\tnew Vector2( c_x, 1 - c_z ),\n\t\t\t\t\tnew Vector2( d_x, 1 - d_z )\n\t\t\t\t];\n\n\t\t\t} else {\n\n\t\t\t\treturn [\n\t\t\t\t\tnew Vector2( a_y, 1 - a_z ),\n\t\t\t\t\tnew Vector2( b_y, 1 - b_z ),\n\t\t\t\t\tnew Vector2( c_y, 1 - c_z ),\n\t\t\t\t\tnew Vector2( d_y, 1 - d_z )\n\t\t\t\t];\n\n\t\t\t}\n\n\t\t}\n\t};\n\n\tfunction toJSON( shapes, options, data ) {\n\n\t\t//\n\n\t\tdata.shapes = [];\n\n\t\tif ( Array.isArray( shapes ) ) {\n\n\t\t\tfor ( var i = 0, l = shapes.length; i < l; i ++ ) {\n\n\t\t\t\tvar shape = shapes[ i ];\n\n\t\t\t\tdata.shapes.push( shape.uuid );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tdata.shapes.push( shapes.uuid );\n\n\t\t}\n\n\t\t//\n\n\t\tif ( options.extrudePath !== undefined ) data.options.extrudePath = options.extrudePath.toJSON();\n\n\t\treturn data;\n\n\t}\n\n\t/**\n\t * @author zz85 / http://www.lab4games.net/zz85/blog\n\t * @author alteredq / http://alteredqualia.com/\n\t *\n\t * Text = 3D Text\n\t *\n\t * parameters = {\n\t *  font: <THREE.Font>, // font\n\t *\n\t *  size: <float>, // size of the text\n\t *  height: <float>, // thickness to extrude text\n\t *  curveSegments: <int>, // number of points on the curves\n\t *\n\t *  bevelEnabled: <bool>, // turn on bevel\n\t *  bevelThickness: <float>, // how deep into text bevel goes\n\t *  bevelSize: <float> // how far from text outline is bevel\n\t * }\n\t */\n\n\t// TextGeometry\n\n\tfunction TextGeometry( text, parameters ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'TextGeometry';\n\n\t\tthis.parameters = {\n\t\t\ttext: text,\n\t\t\tparameters: parameters\n\t\t};\n\n\t\tthis.fromBufferGeometry( new TextBufferGeometry( text, parameters ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tTextGeometry.prototype = Object.create( Geometry.prototype );\n\tTextGeometry.prototype.constructor = TextGeometry;\n\n\t// TextBufferGeometry\n\n\tfunction TextBufferGeometry( text, parameters ) {\n\n\t\tparameters = parameters || {};\n\n\t\tvar font = parameters.font;\n\n\t\tif ( ! ( font && font.isFont ) ) {\n\n\t\t\tconsole.error( 'THREE.TextGeometry: font parameter is not an instance of THREE.Font.' );\n\t\t\treturn new Geometry();\n\n\t\t}\n\n\t\tvar shapes = font.generateShapes( text, parameters.size );\n\n\t\t// translate parameters to ExtrudeGeometry API\n\n\t\tparameters.depth = parameters.height !== undefined ? parameters.height : 50;\n\n\t\t// defaults\n\n\t\tif ( parameters.bevelThickness === undefined ) parameters.bevelThickness = 10;\n\t\tif ( parameters.bevelSize === undefined ) parameters.bevelSize = 8;\n\t\tif ( parameters.bevelEnabled === undefined ) parameters.bevelEnabled = false;\n\n\t\tExtrudeBufferGeometry.call( this, shapes, parameters );\n\n\t\tthis.type = 'TextBufferGeometry';\n\n\t}\n\n\tTextBufferGeometry.prototype = Object.create( ExtrudeBufferGeometry.prototype );\n\tTextBufferGeometry.prototype.constructor = TextBufferGeometry;\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author benaadams / https://twitter.com/ben_a_adams\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\t// SphereGeometry\n\n\tfunction SphereGeometry( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'SphereGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\tphiStart: phiStart,\n\t\t\tphiLength: phiLength,\n\t\t\tthetaStart: thetaStart,\n\t\t\tthetaLength: thetaLength\n\t\t};\n\n\t\tthis.fromBufferGeometry( new SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tSphereGeometry.prototype = Object.create( Geometry.prototype );\n\tSphereGeometry.prototype.constructor = SphereGeometry;\n\n\t// SphereBufferGeometry\n\n\tfunction SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) {\n\n\t\tBufferGeometry.call( this );\n\n\t\tthis.type = 'SphereBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\tphiStart: phiStart,\n\t\t\tphiLength: phiLength,\n\t\t\tthetaStart: thetaStart,\n\t\t\tthetaLength: thetaLength\n\t\t};\n\n\t\tradius = radius || 1;\n\n\t\twidthSegments = Math.max( 3, Math.floor( widthSegments ) || 8 );\n\t\theightSegments = Math.max( 2, Math.floor( heightSegments ) || 6 );\n\n\t\tphiStart = phiStart !== undefined ? phiStart : 0;\n\t\tphiLength = phiLength !== undefined ? phiLength : Math.PI * 2;\n\n\t\tthetaStart = thetaStart !== undefined ? thetaStart : 0;\n\t\tthetaLength = thetaLength !== undefined ? thetaLength : Math.PI;\n\n\t\tvar thetaEnd = thetaStart + thetaLength;\n\n\t\tvar ix, iy;\n\n\t\tvar index = 0;\n\t\tvar grid = [];\n\n\t\tvar vertex = new Vector3();\n\t\tvar normal = new Vector3();\n\n\t\t// buffers\n\n\t\tvar indices = [];\n\t\tvar vertices = [];\n\t\tvar normals = [];\n\t\tvar uvs = [];\n\n\t\t// generate vertices, normals and uvs\n\n\t\tfor ( iy = 0; iy <= heightSegments; iy ++ ) {\n\n\t\t\tvar verticesRow = [];\n\n\t\t\tvar v = iy / heightSegments;\n\n\t\t\tfor ( ix = 0; ix <= widthSegments; ix ++ ) {\n\n\t\t\t\tvar u = ix / widthSegments;\n\n\t\t\t\t// vertex\n\n\t\t\t\tvertex.x = - radius * Math.cos( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );\n\t\t\t\tvertex.y = radius * Math.cos( thetaStart + v * thetaLength );\n\t\t\t\tvertex.z = radius * Math.sin( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength );\n\n\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t\t// normal\n\n\t\t\t\tnormal.set( vertex.x, vertex.y, vertex.z ).normalize();\n\t\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\t\t// uv\n\n\t\t\t\tuvs.push( u, 1 - v );\n\n\t\t\t\tverticesRow.push( index ++ );\n\n\t\t\t}\n\n\t\t\tgrid.push( verticesRow );\n\n\t\t}\n\n\t\t// indices\n\n\t\tfor ( iy = 0; iy < heightSegments; iy ++ ) {\n\n\t\t\tfor ( ix = 0; ix < widthSegments; ix ++ ) {\n\n\t\t\t\tvar a = grid[ iy ][ ix + 1 ];\n\t\t\t\tvar b = grid[ iy ][ ix ];\n\t\t\t\tvar c = grid[ iy + 1 ][ ix ];\n\t\t\t\tvar d = grid[ iy + 1 ][ ix + 1 ];\n\n\t\t\t\tif ( iy !== 0 || thetaStart > 0 ) indices.push( a, b, d );\n\t\t\t\tif ( iy !== heightSegments - 1 || thetaEnd < Math.PI ) indices.push( b, c, d );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// build geometry\n\n\t\tthis.setIndex( indices );\n\t\tthis.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tthis.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\t\tthis.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\t}\n\n\tSphereBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\n\tSphereBufferGeometry.prototype.constructor = SphereBufferGeometry;\n\n\t/**\n\t * @author Kaleb Murphy\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\t// RingGeometry\n\n\tfunction RingGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'RingGeometry';\n\n\t\tthis.parameters = {\n\t\t\tinnerRadius: innerRadius,\n\t\t\touterRadius: outerRadius,\n\t\t\tthetaSegments: thetaSegments,\n\t\t\tphiSegments: phiSegments,\n\t\t\tthetaStart: thetaStart,\n\t\t\tthetaLength: thetaLength\n\t\t};\n\n\t\tthis.fromBufferGeometry( new RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tRingGeometry.prototype = Object.create( Geometry.prototype );\n\tRingGeometry.prototype.constructor = RingGeometry;\n\n\t// RingBufferGeometry\n\n\tfunction RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) {\n\n\t\tBufferGeometry.call( this );\n\n\t\tthis.type = 'RingBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\tinnerRadius: innerRadius,\n\t\t\touterRadius: outerRadius,\n\t\t\tthetaSegments: thetaSegments,\n\t\t\tphiSegments: phiSegments,\n\t\t\tthetaStart: thetaStart,\n\t\t\tthetaLength: thetaLength\n\t\t};\n\n\t\tinnerRadius = innerRadius || 0.5;\n\t\touterRadius = outerRadius || 1;\n\n\t\tthetaStart = thetaStart !== undefined ? thetaStart : 0;\n\t\tthetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;\n\n\t\tthetaSegments = thetaSegments !== undefined ? Math.max( 3, thetaSegments ) : 8;\n\t\tphiSegments = phiSegments !== undefined ? Math.max( 1, phiSegments ) : 1;\n\n\t\t// buffers\n\n\t\tvar indices = [];\n\t\tvar vertices = [];\n\t\tvar normals = [];\n\t\tvar uvs = [];\n\n\t\t// some helper variables\n\n\t\tvar segment;\n\t\tvar radius = innerRadius;\n\t\tvar radiusStep = ( ( outerRadius - innerRadius ) / phiSegments );\n\t\tvar vertex = new Vector3();\n\t\tvar uv = new Vector2();\n\t\tvar j, i;\n\n\t\t// generate vertices, normals and uvs\n\n\t\tfor ( j = 0; j <= phiSegments; j ++ ) {\n\n\t\t\tfor ( i = 0; i <= thetaSegments; i ++ ) {\n\n\t\t\t\t// values are generate from the inside of the ring to the outside\n\n\t\t\t\tsegment = thetaStart + i / thetaSegments * thetaLength;\n\n\t\t\t\t// vertex\n\n\t\t\t\tvertex.x = radius * Math.cos( segment );\n\t\t\t\tvertex.y = radius * Math.sin( segment );\n\n\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t\t// normal\n\n\t\t\t\tnormals.push( 0, 0, 1 );\n\n\t\t\t\t// uv\n\n\t\t\t\tuv.x = ( vertex.x / outerRadius + 1 ) / 2;\n\t\t\t\tuv.y = ( vertex.y / outerRadius + 1 ) / 2;\n\n\t\t\t\tuvs.push( uv.x, uv.y );\n\n\t\t\t}\n\n\t\t\t// increase the radius for next row of vertices\n\n\t\t\tradius += radiusStep;\n\n\t\t}\n\n\t\t// indices\n\n\t\tfor ( j = 0; j < phiSegments; j ++ ) {\n\n\t\t\tvar thetaSegmentLevel = j * ( thetaSegments + 1 );\n\n\t\t\tfor ( i = 0; i < thetaSegments; i ++ ) {\n\n\t\t\t\tsegment = i + thetaSegmentLevel;\n\n\t\t\t\tvar a = segment;\n\t\t\t\tvar b = segment + thetaSegments + 1;\n\t\t\t\tvar c = segment + thetaSegments + 2;\n\t\t\t\tvar d = segment + 1;\n\n\t\t\t\t// faces\n\n\t\t\t\tindices.push( a, b, d );\n\t\t\t\tindices.push( b, c, d );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// build geometry\n\n\t\tthis.setIndex( indices );\n\t\tthis.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tthis.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\t\tthis.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\t}\n\n\tRingBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\n\tRingBufferGeometry.prototype.constructor = RingBufferGeometry;\n\n\t/**\n\t * @author zz85 / https://github.com/zz85\n\t * @author bhouston / http://clara.io\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\t// LatheGeometry\n\n\tfunction LatheGeometry( points, segments, phiStart, phiLength ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'LatheGeometry';\n\n\t\tthis.parameters = {\n\t\t\tpoints: points,\n\t\t\tsegments: segments,\n\t\t\tphiStart: phiStart,\n\t\t\tphiLength: phiLength\n\t\t};\n\n\t\tthis.fromBufferGeometry( new LatheBufferGeometry( points, segments, phiStart, phiLength ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tLatheGeometry.prototype = Object.create( Geometry.prototype );\n\tLatheGeometry.prototype.constructor = LatheGeometry;\n\n\t// LatheBufferGeometry\n\n\tfunction LatheBufferGeometry( points, segments, phiStart, phiLength ) {\n\n\t\tBufferGeometry.call( this );\n\n\t\tthis.type = 'LatheBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\tpoints: points,\n\t\t\tsegments: segments,\n\t\t\tphiStart: phiStart,\n\t\t\tphiLength: phiLength\n\t\t};\n\n\t\tsegments = Math.floor( segments ) || 12;\n\t\tphiStart = phiStart || 0;\n\t\tphiLength = phiLength || Math.PI * 2;\n\n\t\t// clamp phiLength so it's in range of [ 0, 2PI ]\n\n\t\tphiLength = _Math.clamp( phiLength, 0, Math.PI * 2 );\n\n\n\t\t// buffers\n\n\t\tvar indices = [];\n\t\tvar vertices = [];\n\t\tvar uvs = [];\n\n\t\t// helper variables\n\n\t\tvar base;\n\t\tvar inverseSegments = 1.0 / segments;\n\t\tvar vertex = new Vector3();\n\t\tvar uv = new Vector2();\n\t\tvar i, j;\n\n\t\t// generate vertices and uvs\n\n\t\tfor ( i = 0; i <= segments; i ++ ) {\n\n\t\t\tvar phi = phiStart + i * inverseSegments * phiLength;\n\n\t\t\tvar sin = Math.sin( phi );\n\t\t\tvar cos = Math.cos( phi );\n\n\t\t\tfor ( j = 0; j <= ( points.length - 1 ); j ++ ) {\n\n\t\t\t\t// vertex\n\n\t\t\t\tvertex.x = points[ j ].x * sin;\n\t\t\t\tvertex.y = points[ j ].y;\n\t\t\t\tvertex.z = points[ j ].x * cos;\n\n\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t\t// uv\n\n\t\t\t\tuv.x = i / segments;\n\t\t\t\tuv.y = j / ( points.length - 1 );\n\n\t\t\t\tuvs.push( uv.x, uv.y );\n\n\n\t\t\t}\n\n\t\t}\n\n\t\t// indices\n\n\t\tfor ( i = 0; i < segments; i ++ ) {\n\n\t\t\tfor ( j = 0; j < ( points.length - 1 ); j ++ ) {\n\n\t\t\t\tbase = j + i * points.length;\n\n\t\t\t\tvar a = base;\n\t\t\t\tvar b = base + points.length;\n\t\t\t\tvar c = base + points.length + 1;\n\t\t\t\tvar d = base + 1;\n\n\t\t\t\t// faces\n\n\t\t\t\tindices.push( a, b, d );\n\t\t\t\tindices.push( b, c, d );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// build geometry\n\n\t\tthis.setIndex( indices );\n\t\tthis.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tthis.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\t\t// generate normals\n\n\t\tthis.computeVertexNormals();\n\n\t\t// if the geometry is closed, we need to average the normals along the seam.\n\t\t// because the corresponding vertices are identical (but still have different UVs).\n\n\t\tif ( phiLength === Math.PI * 2 ) {\n\n\t\t\tvar normals = this.attributes.normal.array;\n\t\t\tvar n1 = new Vector3();\n\t\t\tvar n2 = new Vector3();\n\t\t\tvar n = new Vector3();\n\n\t\t\t// this is the buffer offset for the last line of vertices\n\n\t\t\tbase = segments * points.length * 3;\n\n\t\t\tfor ( i = 0, j = 0; i < points.length; i ++, j += 3 ) {\n\n\t\t\t\t// select the normal of the vertex in the first line\n\n\t\t\t\tn1.x = normals[ j + 0 ];\n\t\t\t\tn1.y = normals[ j + 1 ];\n\t\t\t\tn1.z = normals[ j + 2 ];\n\n\t\t\t\t// select the normal of the vertex in the last line\n\n\t\t\t\tn2.x = normals[ base + j + 0 ];\n\t\t\t\tn2.y = normals[ base + j + 1 ];\n\t\t\t\tn2.z = normals[ base + j + 2 ];\n\n\t\t\t\t// average normals\n\n\t\t\t\tn.addVectors( n1, n2 ).normalize();\n\n\t\t\t\t// assign the new values to both normals\n\n\t\t\t\tnormals[ j + 0 ] = normals[ base + j + 0 ] = n.x;\n\t\t\t\tnormals[ j + 1 ] = normals[ base + j + 1 ] = n.y;\n\t\t\t\tnormals[ j + 2 ] = normals[ base + j + 2 ] = n.z;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tLatheBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\n\tLatheBufferGeometry.prototype.constructor = LatheBufferGeometry;\n\n\t/**\n\t * @author jonobr1 / http://jonobr1.com\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\t// ShapeGeometry\n\n\tfunction ShapeGeometry( shapes, curveSegments ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'ShapeGeometry';\n\n\t\tif ( typeof curveSegments === 'object' ) {\n\n\t\t\tconsole.warn( 'THREE.ShapeGeometry: Options parameter has been removed.' );\n\n\t\t\tcurveSegments = curveSegments.curveSegments;\n\n\t\t}\n\n\t\tthis.parameters = {\n\t\t\tshapes: shapes,\n\t\t\tcurveSegments: curveSegments\n\t\t};\n\n\t\tthis.fromBufferGeometry( new ShapeBufferGeometry( shapes, curveSegments ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tShapeGeometry.prototype = Object.create( Geometry.prototype );\n\tShapeGeometry.prototype.constructor = ShapeGeometry;\n\n\tShapeGeometry.prototype.toJSON = function () {\n\n\t\tvar data = Geometry.prototype.toJSON.call( this );\n\n\t\tvar shapes = this.parameters.shapes;\n\n\t\treturn toJSON$1( shapes, data );\n\n\t};\n\n\t// ShapeBufferGeometry\n\n\tfunction ShapeBufferGeometry( shapes, curveSegments ) {\n\n\t\tBufferGeometry.call( this );\n\n\t\tthis.type = 'ShapeBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\tshapes: shapes,\n\t\t\tcurveSegments: curveSegments\n\t\t};\n\n\t\tcurveSegments = curveSegments || 12;\n\n\t\t// buffers\n\n\t\tvar indices = [];\n\t\tvar vertices = [];\n\t\tvar normals = [];\n\t\tvar uvs = [];\n\n\t\t// helper variables\n\n\t\tvar groupStart = 0;\n\t\tvar groupCount = 0;\n\n\t\t// allow single and array values for \"shapes\" parameter\n\n\t\tif ( Array.isArray( shapes ) === false ) {\n\n\t\t\taddShape( shapes );\n\n\t\t} else {\n\n\t\t\tfor ( var i = 0; i < shapes.length; i ++ ) {\n\n\t\t\t\taddShape( shapes[ i ] );\n\n\t\t\t\tthis.addGroup( groupStart, groupCount, i ); // enables MultiMaterial support\n\n\t\t\t\tgroupStart += groupCount;\n\t\t\t\tgroupCount = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t\t// build geometry\n\n\t\tthis.setIndex( indices );\n\t\tthis.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tthis.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\t\tthis.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\n\t\t// helper functions\n\n\t\tfunction addShape( shape ) {\n\n\t\t\tvar i, l, shapeHole;\n\n\t\t\tvar indexOffset = vertices.length / 3;\n\t\t\tvar points = shape.extractPoints( curveSegments );\n\n\t\t\tvar shapeVertices = points.shape;\n\t\t\tvar shapeHoles = points.holes;\n\n\t\t\t// check direction of vertices\n\n\t\t\tif ( ShapeUtils.isClockWise( shapeVertices ) === false ) {\n\n\t\t\t\tshapeVertices = shapeVertices.reverse();\n\n\t\t\t}\n\n\t\t\tfor ( i = 0, l = shapeHoles.length; i < l; i ++ ) {\n\n\t\t\t\tshapeHole = shapeHoles[ i ];\n\n\t\t\t\tif ( ShapeUtils.isClockWise( shapeHole ) === true ) {\n\n\t\t\t\t\tshapeHoles[ i ] = shapeHole.reverse();\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tvar faces = ShapeUtils.triangulateShape( shapeVertices, shapeHoles );\n\n\t\t\t// join vertices of inner and outer paths to a single array\n\n\t\t\tfor ( i = 0, l = shapeHoles.length; i < l; i ++ ) {\n\n\t\t\t\tshapeHole = shapeHoles[ i ];\n\t\t\t\tshapeVertices = shapeVertices.concat( shapeHole );\n\n\t\t\t}\n\n\t\t\t// vertices, normals, uvs\n\n\t\t\tfor ( i = 0, l = shapeVertices.length; i < l; i ++ ) {\n\n\t\t\t\tvar vertex = shapeVertices[ i ];\n\n\t\t\t\tvertices.push( vertex.x, vertex.y, 0 );\n\t\t\t\tnormals.push( 0, 0, 1 );\n\t\t\t\tuvs.push( vertex.x, vertex.y ); // world uvs\n\n\t\t\t}\n\n\t\t\t// incides\n\n\t\t\tfor ( i = 0, l = faces.length; i < l; i ++ ) {\n\n\t\t\t\tvar face = faces[ i ];\n\n\t\t\t\tvar a = face[ 0 ] + indexOffset;\n\t\t\t\tvar b = face[ 1 ] + indexOffset;\n\t\t\t\tvar c = face[ 2 ] + indexOffset;\n\n\t\t\t\tindices.push( a, b, c );\n\t\t\t\tgroupCount += 3;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tShapeBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\n\tShapeBufferGeometry.prototype.constructor = ShapeBufferGeometry;\n\n\tShapeBufferGeometry.prototype.toJSON = function () {\n\n\t\tvar data = BufferGeometry.prototype.toJSON.call( this );\n\n\t\tvar shapes = this.parameters.shapes;\n\n\t\treturn toJSON$1( shapes, data );\n\n\t};\n\n\t//\n\n\tfunction toJSON$1( shapes, data ) {\n\n\t\tdata.shapes = [];\n\n\t\tif ( Array.isArray( shapes ) ) {\n\n\t\t\tfor ( var i = 0, l = shapes.length; i < l; i ++ ) {\n\n\t\t\t\tvar shape = shapes[ i ];\n\n\t\t\t\tdata.shapes.push( shape.uuid );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tdata.shapes.push( shapes.uuid );\n\n\t\t}\n\n\t\treturn data;\n\n\t}\n\n\t/**\n\t * @author WestLangley / http://github.com/WestLangley\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\tfunction EdgesGeometry( geometry, thresholdAngle ) {\n\n\t\tBufferGeometry.call( this );\n\n\t\tthis.type = 'EdgesGeometry';\n\n\t\tthis.parameters = {\n\t\t\tthresholdAngle: thresholdAngle\n\t\t};\n\n\t\tthresholdAngle = ( thresholdAngle !== undefined ) ? thresholdAngle : 1;\n\n\t\t// buffer\n\n\t\tvar vertices = [];\n\n\t\t// helper variables\n\n\t\tvar thresholdDot = Math.cos( _Math.DEG2RAD * thresholdAngle );\n\t\tvar edge = [ 0, 0 ], edges = {}, edge1, edge2;\n\t\tvar key, keys = [ 'a', 'b', 'c' ];\n\n\t\t// prepare source geometry\n\n\t\tvar geometry2;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tgeometry2 = new Geometry();\n\t\t\tgeometry2.fromBufferGeometry( geometry );\n\n\t\t} else {\n\n\t\t\tgeometry2 = geometry.clone();\n\n\t\t}\n\n\t\tgeometry2.mergeVertices();\n\t\tgeometry2.computeFaceNormals();\n\n\t\tvar sourceVertices = geometry2.vertices;\n\t\tvar faces = geometry2.faces;\n\n\t\t// now create a data structure where each entry represents an edge with its adjoining faces\n\n\t\tfor ( var i = 0, l = faces.length; i < l; i ++ ) {\n\n\t\t\tvar face = faces[ i ];\n\n\t\t\tfor ( var j = 0; j < 3; j ++ ) {\n\n\t\t\t\tedge1 = face[ keys[ j ] ];\n\t\t\t\tedge2 = face[ keys[ ( j + 1 ) % 3 ] ];\n\t\t\t\tedge[ 0 ] = Math.min( edge1, edge2 );\n\t\t\t\tedge[ 1 ] = Math.max( edge1, edge2 );\n\n\t\t\t\tkey = edge[ 0 ] + ',' + edge[ 1 ];\n\n\t\t\t\tif ( edges[ key ] === undefined ) {\n\n\t\t\t\t\tedges[ key ] = { index1: edge[ 0 ], index2: edge[ 1 ], face1: i, face2: undefined };\n\n\t\t\t\t} else {\n\n\t\t\t\t\tedges[ key ].face2 = i;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// generate vertices\n\n\t\tfor ( key in edges ) {\n\n\t\t\tvar e = edges[ key ];\n\n\t\t\t// an edge is only rendered if the angle (in degrees) between the face normals of the adjoining faces exceeds this value. default = 1 degree.\n\n\t\t\tif ( e.face2 === undefined || faces[ e.face1 ].normal.dot( faces[ e.face2 ].normal ) <= thresholdDot ) {\n\n\t\t\t\tvar vertex = sourceVertices[ e.index1 ];\n\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t\tvertex = sourceVertices[ e.index2 ];\n\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// build geometry\n\n\t\tthis.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\n\t}\n\n\tEdgesGeometry.prototype = Object.create( BufferGeometry.prototype );\n\tEdgesGeometry.prototype.constructor = EdgesGeometry;\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\t// CylinderGeometry\n\n\tfunction CylinderGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'CylinderGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradiusTop: radiusTop,\n\t\t\tradiusBottom: radiusBottom,\n\t\t\theight: height,\n\t\t\tradialSegments: radialSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\topenEnded: openEnded,\n\t\t\tthetaStart: thetaStart,\n\t\t\tthetaLength: thetaLength\n\t\t};\n\n\t\tthis.fromBufferGeometry( new CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tCylinderGeometry.prototype = Object.create( Geometry.prototype );\n\tCylinderGeometry.prototype.constructor = CylinderGeometry;\n\n\t// CylinderBufferGeometry\n\n\tfunction CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\t\tBufferGeometry.call( this );\n\n\t\tthis.type = 'CylinderBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradiusTop: radiusTop,\n\t\t\tradiusBottom: radiusBottom,\n\t\t\theight: height,\n\t\t\tradialSegments: radialSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\topenEnded: openEnded,\n\t\t\tthetaStart: thetaStart,\n\t\t\tthetaLength: thetaLength\n\t\t};\n\n\t\tvar scope = this;\n\n\t\tradiusTop = radiusTop !== undefined ? radiusTop : 1;\n\t\tradiusBottom = radiusBottom !== undefined ? radiusBottom : 1;\n\t\theight = height || 1;\n\n\t\tradialSegments = Math.floor( radialSegments ) || 8;\n\t\theightSegments = Math.floor( heightSegments ) || 1;\n\n\t\topenEnded = openEnded !== undefined ? openEnded : false;\n\t\tthetaStart = thetaStart !== undefined ? thetaStart : 0.0;\n\t\tthetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;\n\n\t\t// buffers\n\n\t\tvar indices = [];\n\t\tvar vertices = [];\n\t\tvar normals = [];\n\t\tvar uvs = [];\n\n\t\t// helper variables\n\n\t\tvar index = 0;\n\t\tvar indexArray = [];\n\t\tvar halfHeight = height / 2;\n\t\tvar groupStart = 0;\n\n\t\t// generate geometry\n\n\t\tgenerateTorso();\n\n\t\tif ( openEnded === false ) {\n\n\t\t\tif ( radiusTop > 0 ) generateCap( true );\n\t\t\tif ( radiusBottom > 0 ) generateCap( false );\n\n\t\t}\n\n\t\t// build geometry\n\n\t\tthis.setIndex( indices );\n\t\tthis.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tthis.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\t\tthis.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\t\tfunction generateTorso() {\n\n\t\t\tvar x, y;\n\t\t\tvar normal = new Vector3();\n\t\t\tvar vertex = new Vector3();\n\n\t\t\tvar groupCount = 0;\n\n\t\t\t// this will be used to calculate the normal\n\t\t\tvar slope = ( radiusBottom - radiusTop ) / height;\n\n\t\t\t// generate vertices, normals and uvs\n\n\t\t\tfor ( y = 0; y <= heightSegments; y ++ ) {\n\n\t\t\t\tvar indexRow = [];\n\n\t\t\t\tvar v = y / heightSegments;\n\n\t\t\t\t// calculate the radius of the current row\n\n\t\t\t\tvar radius = v * ( radiusBottom - radiusTop ) + radiusTop;\n\n\t\t\t\tfor ( x = 0; x <= radialSegments; x ++ ) {\n\n\t\t\t\t\tvar u = x / radialSegments;\n\n\t\t\t\t\tvar theta = u * thetaLength + thetaStart;\n\n\t\t\t\t\tvar sinTheta = Math.sin( theta );\n\t\t\t\t\tvar cosTheta = Math.cos( theta );\n\n\t\t\t\t\t// vertex\n\n\t\t\t\t\tvertex.x = radius * sinTheta;\n\t\t\t\t\tvertex.y = - v * height + halfHeight;\n\t\t\t\t\tvertex.z = radius * cosTheta;\n\t\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t\t\t// normal\n\n\t\t\t\t\tnormal.set( sinTheta, slope, cosTheta ).normalize();\n\t\t\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\t\t\t// uv\n\n\t\t\t\t\tuvs.push( u, 1 - v );\n\n\t\t\t\t\t// save index of vertex in respective row\n\n\t\t\t\t\tindexRow.push( index ++ );\n\n\t\t\t\t}\n\n\t\t\t\t// now save vertices of the row in our index array\n\n\t\t\t\tindexArray.push( indexRow );\n\n\t\t\t}\n\n\t\t\t// generate indices\n\n\t\t\tfor ( x = 0; x < radialSegments; x ++ ) {\n\n\t\t\t\tfor ( y = 0; y < heightSegments; y ++ ) {\n\n\t\t\t\t\t// we use the index array to access the correct indices\n\n\t\t\t\t\tvar a = indexArray[ y ][ x ];\n\t\t\t\t\tvar b = indexArray[ y + 1 ][ x ];\n\t\t\t\t\tvar c = indexArray[ y + 1 ][ x + 1 ];\n\t\t\t\t\tvar d = indexArray[ y ][ x + 1 ];\n\n\t\t\t\t\t// faces\n\n\t\t\t\t\tindices.push( a, b, d );\n\t\t\t\t\tindices.push( b, c, d );\n\n\t\t\t\t\t// update group counter\n\n\t\t\t\t\tgroupCount += 6;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// add a group to the geometry. this will ensure multi material support\n\n\t\t\tscope.addGroup( groupStart, groupCount, 0 );\n\n\t\t\t// calculate new start value for groups\n\n\t\t\tgroupStart += groupCount;\n\n\t\t}\n\n\t\tfunction generateCap( top ) {\n\n\t\t\tvar x, centerIndexStart, centerIndexEnd;\n\n\t\t\tvar uv = new Vector2();\n\t\t\tvar vertex = new Vector3();\n\n\t\t\tvar groupCount = 0;\n\n\t\t\tvar radius = ( top === true ) ? radiusTop : radiusBottom;\n\t\t\tvar sign = ( top === true ) ? 1 : - 1;\n\n\t\t\t// save the index of the first center vertex\n\t\t\tcenterIndexStart = index;\n\n\t\t\t// first we generate the center vertex data of the cap.\n\t\t\t// because the geometry needs one set of uvs per face,\n\t\t\t// we must generate a center vertex per face/segment\n\n\t\t\tfor ( x = 1; x <= radialSegments; x ++ ) {\n\n\t\t\t\t// vertex\n\n\t\t\t\tvertices.push( 0, halfHeight * sign, 0 );\n\n\t\t\t\t// normal\n\n\t\t\t\tnormals.push( 0, sign, 0 );\n\n\t\t\t\t// uv\n\n\t\t\t\tuvs.push( 0.5, 0.5 );\n\n\t\t\t\t// increase index\n\n\t\t\t\tindex ++;\n\n\t\t\t}\n\n\t\t\t// save the index of the last center vertex\n\n\t\t\tcenterIndexEnd = index;\n\n\t\t\t// now we generate the surrounding vertices, normals and uvs\n\n\t\t\tfor ( x = 0; x <= radialSegments; x ++ ) {\n\n\t\t\t\tvar u = x / radialSegments;\n\t\t\t\tvar theta = u * thetaLength + thetaStart;\n\n\t\t\t\tvar cosTheta = Math.cos( theta );\n\t\t\t\tvar sinTheta = Math.sin( theta );\n\n\t\t\t\t// vertex\n\n\t\t\t\tvertex.x = radius * sinTheta;\n\t\t\t\tvertex.y = halfHeight * sign;\n\t\t\t\tvertex.z = radius * cosTheta;\n\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t\t// normal\n\n\t\t\t\tnormals.push( 0, sign, 0 );\n\n\t\t\t\t// uv\n\n\t\t\t\tuv.x = ( cosTheta * 0.5 ) + 0.5;\n\t\t\t\tuv.y = ( sinTheta * 0.5 * sign ) + 0.5;\n\t\t\t\tuvs.push( uv.x, uv.y );\n\n\t\t\t\t// increase index\n\n\t\t\t\tindex ++;\n\n\t\t\t}\n\n\t\t\t// generate indices\n\n\t\t\tfor ( x = 0; x < radialSegments; x ++ ) {\n\n\t\t\t\tvar c = centerIndexStart + x;\n\t\t\t\tvar i = centerIndexEnd + x;\n\n\t\t\t\tif ( top === true ) {\n\n\t\t\t\t\t// face top\n\n\t\t\t\t\tindices.push( i, i + 1, c );\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// face bottom\n\n\t\t\t\t\tindices.push( i + 1, i, c );\n\n\t\t\t\t}\n\n\t\t\t\tgroupCount += 3;\n\n\t\t\t}\n\n\t\t\t// add a group to the geometry. this will ensure multi material support\n\n\t\t\tscope.addGroup( groupStart, groupCount, top === true ? 1 : 2 );\n\n\t\t\t// calculate new start value for groups\n\n\t\t\tgroupStart += groupCount;\n\n\t\t}\n\n\t}\n\n\tCylinderBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\n\tCylinderBufferGeometry.prototype.constructor = CylinderBufferGeometry;\n\n\t/**\n\t * @author abelnation / http://github.com/abelnation\n\t */\n\n\t// ConeGeometry\n\n\tfunction ConeGeometry( radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\t\tCylinderGeometry.call( this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength );\n\n\t\tthis.type = 'ConeGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\theight: height,\n\t\t\tradialSegments: radialSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\topenEnded: openEnded,\n\t\t\tthetaStart: thetaStart,\n\t\t\tthetaLength: thetaLength\n\t\t};\n\n\t}\n\n\tConeGeometry.prototype = Object.create( CylinderGeometry.prototype );\n\tConeGeometry.prototype.constructor = ConeGeometry;\n\n\t// ConeBufferGeometry\n\n\tfunction ConeBufferGeometry( radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\t\tCylinderBufferGeometry.call( this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength );\n\n\t\tthis.type = 'ConeBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\theight: height,\n\t\t\tradialSegments: radialSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\topenEnded: openEnded,\n\t\t\tthetaStart: thetaStart,\n\t\t\tthetaLength: thetaLength\n\t\t};\n\n\t}\n\n\tConeBufferGeometry.prototype = Object.create( CylinderBufferGeometry.prototype );\n\tConeBufferGeometry.prototype.constructor = ConeBufferGeometry;\n\n\t/**\n\t * @author benaadams / https://twitter.com/ben_a_adams\n\t * @author Mugen87 / https://github.com/Mugen87\n\t * @author hughes\n\t */\n\n\t// CircleGeometry\n\n\tfunction CircleGeometry( radius, segments, thetaStart, thetaLength ) {\n\n\t\tGeometry.call( this );\n\n\t\tthis.type = 'CircleGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\tsegments: segments,\n\t\t\tthetaStart: thetaStart,\n\t\t\tthetaLength: thetaLength\n\t\t};\n\n\t\tthis.fromBufferGeometry( new CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n\tCircleGeometry.prototype = Object.create( Geometry.prototype );\n\tCircleGeometry.prototype.constructor = CircleGeometry;\n\n\t// CircleBufferGeometry\n\n\tfunction CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) {\n\n\t\tBufferGeometry.call( this );\n\n\t\tthis.type = 'CircleBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\tradius: radius,\n\t\t\tsegments: segments,\n\t\t\tthetaStart: thetaStart,\n\t\t\tthetaLength: thetaLength\n\t\t};\n\n\t\tradius = radius || 1;\n\t\tsegments = segments !== undefined ? Math.max( 3, segments ) : 8;\n\n\t\tthetaStart = thetaStart !== undefined ? thetaStart : 0;\n\t\tthetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;\n\n\t\t// buffers\n\n\t\tvar indices = [];\n\t\tvar vertices = [];\n\t\tvar normals = [];\n\t\tvar uvs = [];\n\n\t\t// helper variables\n\n\t\tvar i, s;\n\t\tvar vertex = new Vector3();\n\t\tvar uv = new Vector2();\n\n\t\t// center point\n\n\t\tvertices.push( 0, 0, 0 );\n\t\tnormals.push( 0, 0, 1 );\n\t\tuvs.push( 0.5, 0.5 );\n\n\t\tfor ( s = 0, i = 3; s <= segments; s ++, i += 3 ) {\n\n\t\t\tvar segment = thetaStart + s / segments * thetaLength;\n\n\t\t\t// vertex\n\n\t\t\tvertex.x = radius * Math.cos( segment );\n\t\t\tvertex.y = radius * Math.sin( segment );\n\n\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t// normal\n\n\t\t\tnormals.push( 0, 0, 1 );\n\n\t\t\t// uvs\n\n\t\t\tuv.x = ( vertices[ i ] / radius + 1 ) / 2;\n\t\t\tuv.y = ( vertices[ i + 1 ] / radius + 1 ) / 2;\n\n\t\t\tuvs.push( uv.x, uv.y );\n\n\t\t}\n\n\t\t// indices\n\n\t\tfor ( i = 1; i <= segments; i ++ ) {\n\n\t\t\tindices.push( i, i + 1, 0 );\n\n\t\t}\n\n\t\t// build geometry\n\n\t\tthis.setIndex( indices );\n\t\tthis.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tthis.addAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\t\tthis.addAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\t}\n\n\tCircleBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\n\tCircleBufferGeometry.prototype.constructor = CircleBufferGeometry;\n\n\n\n\tvar Geometries = /*#__PURE__*/Object.freeze({\n\t\tWireframeGeometry: WireframeGeometry,\n\t\tParametricGeometry: ParametricGeometry,\n\t\tParametricBufferGeometry: ParametricBufferGeometry,\n\t\tTetrahedronGeometry: TetrahedronGeometry,\n\t\tTetrahedronBufferGeometry: TetrahedronBufferGeometry,\n\t\tOctahedronGeometry: OctahedronGeometry,\n\t\tOctahedronBufferGeometry: OctahedronBufferGeometry,\n\t\tIcosahedronGeometry: IcosahedronGeometry,\n\t\tIcosahedronBufferGeometry: IcosahedronBufferGeometry,\n\t\tDodecahedronGeometry: DodecahedronGeometry,\n\t\tDodecahedronBufferGeometry: DodecahedronBufferGeometry,\n\t\tPolyhedronGeometry: PolyhedronGeometry,\n\t\tPolyhedronBufferGeometry: PolyhedronBufferGeometry,\n\t\tTubeGeometry: TubeGeometry,\n\t\tTubeBufferGeometry: TubeBufferGeometry,\n\t\tTorusKnotGeometry: TorusKnotGeometry,\n\t\tTorusKnotBufferGeometry: TorusKnotBufferGeometry,\n\t\tTorusGeometry: TorusGeometry,\n\t\tTorusBufferGeometry: TorusBufferGeometry,\n\t\tTextGeometry: TextGeometry,\n\t\tTextBufferGeometry: TextBufferGeometry,\n\t\tSphereGeometry: SphereGeometry,\n\t\tSphereBufferGeometry: SphereBufferGeometry,\n\t\tRingGeometry: RingGeometry,\n\t\tRingBufferGeometry: RingBufferGeometry,\n\t\tPlaneGeometry: PlaneGeometry,\n\t\tPlaneBufferGeometry: PlaneBufferGeometry,\n\t\tLatheGeometry: LatheGeometry,\n\t\tLatheBufferGeometry: LatheBufferGeometry,\n\t\tShapeGeometry: ShapeGeometry,\n\t\tShapeBufferGeometry: ShapeBufferGeometry,\n\t\tExtrudeGeometry: ExtrudeGeometry,\n\t\tExtrudeBufferGeometry: ExtrudeBufferGeometry,\n\t\tEdgesGeometry: EdgesGeometry,\n\t\tConeGeometry: ConeGeometry,\n\t\tConeBufferGeometry: ConeBufferGeometry,\n\t\tCylinderGeometry: CylinderGeometry,\n\t\tCylinderBufferGeometry: CylinderBufferGeometry,\n\t\tCircleGeometry: CircleGeometry,\n\t\tCircleBufferGeometry: CircleBufferGeometry,\n\t\tBoxGeometry: BoxGeometry,\n\t\tBoxBufferGeometry: BoxBufferGeometry\n\t});\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t *\n\t * parameters = {\n\t *  color: <THREE.Color>\n\t * }\n\t */\n\n\tfunction ShadowMaterial( parameters ) {\n\n\t\tMaterial.call( this );\n\n\t\tthis.type = 'ShadowMaterial';\n\n\t\tthis.color = new Color( 0x000000 );\n\t\tthis.transparent = true;\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n\tShadowMaterial.prototype = Object.create( Material.prototype );\n\tShadowMaterial.prototype.constructor = ShadowMaterial;\n\n\tShadowMaterial.prototype.isShadowMaterial = true;\n\n\tShadowMaterial.prototype.copy = function ( source ) {\n\n\t\tMaterial.prototype.copy.call( this, source );\n\n\t\tthis.color.copy( source.color );\n\n\t\treturn this;\n\n\t};\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction RawShaderMaterial( parameters ) {\n\n\t\tShaderMaterial.call( this, parameters );\n\n\t\tthis.type = 'RawShaderMaterial';\n\n\t}\n\n\tRawShaderMaterial.prototype = Object.create( ShaderMaterial.prototype );\n\tRawShaderMaterial.prototype.constructor = RawShaderMaterial;\n\n\tRawShaderMaterial.prototype.isRawShaderMaterial = true;\n\n\t/**\n\t * @author WestLangley / http://github.com/WestLangley\n\t *\n\t * parameters = {\n\t *  color: <hex>,\n\t *  roughness: <float>,\n\t *  metalness: <float>,\n\t *  opacity: <float>,\n\t *\n\t *  map: new THREE.Texture( <Image> ),\n\t *\n\t *  lightMap: new THREE.Texture( <Image> ),\n\t *  lightMapIntensity: <float>\n\t *\n\t *  aoMap: new THREE.Texture( <Image> ),\n\t *  aoMapIntensity: <float>\n\t *\n\t *  emissive: <hex>,\n\t *  emissiveIntensity: <float>\n\t *  emissiveMap: new THREE.Texture( <Image> ),\n\t *\n\t *  bumpMap: new THREE.Texture( <Image> ),\n\t *  bumpScale: <float>,\n\t *\n\t *  normalMap: new THREE.Texture( <Image> ),\n\t *  normalMapType: THREE.TangentSpaceNormalMap,\n\t *  normalScale: <Vector2>,\n\t *\n\t *  displacementMap: new THREE.Texture( <Image> ),\n\t *  displacementScale: <float>,\n\t *  displacementBias: <float>,\n\t *\n\t *  roughnessMap: new THREE.Texture( <Image> ),\n\t *\n\t *  metalnessMap: new THREE.Texture( <Image> ),\n\t *\n\t *  alphaMap: new THREE.Texture( <Image> ),\n\t *\n\t *  envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ),\n\t *  envMapIntensity: <float>\n\t *\n\t *  refractionRatio: <float>,\n\t *\n\t *  wireframe: <boolean>,\n\t *  wireframeLinewidth: <float>,\n\t *\n\t *  skinning: <bool>,\n\t *  morphTargets: <bool>,\n\t *  morphNormals: <bool>\n\t * }\n\t */\n\n\tfunction MeshStandardMaterial( parameters ) {\n\n\t\tMaterial.call( this );\n\n\t\tthis.defines = { 'STANDARD': '' };\n\n\t\tthis.type = 'MeshStandardMaterial';\n\n\t\tthis.color = new Color( 0xffffff ); // diffuse\n\t\tthis.roughness = 0.5;\n\t\tthis.metalness = 0.5;\n\n\t\tthis.map = null;\n\n\t\tthis.lightMap = null;\n\t\tthis.lightMapIntensity = 1.0;\n\n\t\tthis.aoMap = null;\n\t\tthis.aoMapIntensity = 1.0;\n\n\t\tthis.emissive = new Color( 0x000000 );\n\t\tthis.emissiveIntensity = 1.0;\n\t\tthis.emissiveMap = null;\n\n\t\tthis.bumpMap = null;\n\t\tthis.bumpScale = 1;\n\n\t\tthis.normalMap = null;\n\t\tthis.normalMapType = TangentSpaceNormalMap;\n\t\tthis.normalScale = new Vector2( 1, 1 );\n\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\n\t\tthis.roughnessMap = null;\n\n\t\tthis.metalnessMap = null;\n\n\t\tthis.alphaMap = null;\n\n\t\tthis.envMap = null;\n\t\tthis.envMapIntensity = 1.0;\n\n\t\tthis.refractionRatio = 0.98;\n\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.wireframeLinecap = 'round';\n\t\tthis.wireframeLinejoin = 'round';\n\n\t\tthis.skinning = false;\n\t\tthis.morphTargets = false;\n\t\tthis.morphNormals = false;\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n\tMeshStandardMaterial.prototype = Object.create( Material.prototype );\n\tMeshStandardMaterial.prototype.constructor = MeshStandardMaterial;\n\n\tMeshStandardMaterial.prototype.isMeshStandardMaterial = true;\n\n\tMeshStandardMaterial.prototype.copy = function ( source ) {\n\n\t\tMaterial.prototype.copy.call( this, source );\n\n\t\tthis.defines = { 'STANDARD': '' };\n\n\t\tthis.color.copy( source.color );\n\t\tthis.roughness = source.roughness;\n\t\tthis.metalness = source.metalness;\n\n\t\tthis.map = source.map;\n\n\t\tthis.lightMap = source.lightMap;\n\t\tthis.lightMapIntensity = source.lightMapIntensity;\n\n\t\tthis.aoMap = source.aoMap;\n\t\tthis.aoMapIntensity = source.aoMapIntensity;\n\n\t\tthis.emissive.copy( source.emissive );\n\t\tthis.emissiveMap = source.emissiveMap;\n\t\tthis.emissiveIntensity = source.emissiveIntensity;\n\n\t\tthis.bumpMap = source.bumpMap;\n\t\tthis.bumpScale = source.bumpScale;\n\n\t\tthis.normalMap = source.normalMap;\n\t\tthis.normalMapType = source.normalMapType;\n\t\tthis.normalScale.copy( source.normalScale );\n\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\n\t\tthis.roughnessMap = source.roughnessMap;\n\n\t\tthis.metalnessMap = source.metalnessMap;\n\n\t\tthis.alphaMap = source.alphaMap;\n\n\t\tthis.envMap = source.envMap;\n\t\tthis.envMapIntensity = source.envMapIntensity;\n\n\t\tthis.refractionRatio = source.refractionRatio;\n\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.wireframeLinecap = source.wireframeLinecap;\n\t\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\t\tthis.morphNormals = source.morphNormals;\n\n\t\treturn this;\n\n\t};\n\n\t/**\n\t * @author WestLangley / http://github.com/WestLangley\n\t *\n\t * parameters = {\n\t *  reflectivity: <float>\n\t * }\n\t */\n\n\tfunction MeshPhysicalMaterial( parameters ) {\n\n\t\tMeshStandardMaterial.call( this );\n\n\t\tthis.defines = { 'PHYSICAL': '' };\n\n\t\tthis.type = 'MeshPhysicalMaterial';\n\n\t\tthis.reflectivity = 0.5; // maps to F0 = 0.04\n\n\t\tthis.clearCoat = 0.0;\n\t\tthis.clearCoatRoughness = 0.0;\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n\tMeshPhysicalMaterial.prototype = Object.create( MeshStandardMaterial.prototype );\n\tMeshPhysicalMaterial.prototype.constructor = MeshPhysicalMaterial;\n\n\tMeshPhysicalMaterial.prototype.isMeshPhysicalMaterial = true;\n\n\tMeshPhysicalMaterial.prototype.copy = function ( source ) {\n\n\t\tMeshStandardMaterial.prototype.copy.call( this, source );\n\n\t\tthis.defines = { 'PHYSICAL': '' };\n\n\t\tthis.reflectivity = source.reflectivity;\n\n\t\tthis.clearCoat = source.clearCoat;\n\t\tthis.clearCoatRoughness = source.clearCoatRoughness;\n\n\t\treturn this;\n\n\t};\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author alteredq / http://alteredqualia.com/\n\t *\n\t * parameters = {\n\t *  color: <hex>,\n\t *  specular: <hex>,\n\t *  shininess: <float>,\n\t *  opacity: <float>,\n\t *\n\t *  map: new THREE.Texture( <Image> ),\n\t *\n\t *  lightMap: new THREE.Texture( <Image> ),\n\t *  lightMapIntensity: <float>\n\t *\n\t *  aoMap: new THREE.Texture( <Image> ),\n\t *  aoMapIntensity: <float>\n\t *\n\t *  emissive: <hex>,\n\t *  emissiveIntensity: <float>\n\t *  emissiveMap: new THREE.Texture( <Image> ),\n\t *\n\t *  bumpMap: new THREE.Texture( <Image> ),\n\t *  bumpScale: <float>,\n\t *\n\t *  normalMap: new THREE.Texture( <Image> ),\n\t *  normalMapType: THREE.TangentSpaceNormalMap,\n\t *  normalScale: <Vector2>,\n\t *\n\t *  displacementMap: new THREE.Texture( <Image> ),\n\t *  displacementScale: <float>,\n\t *  displacementBias: <float>,\n\t *\n\t *  specularMap: new THREE.Texture( <Image> ),\n\t *\n\t *  alphaMap: new THREE.Texture( <Image> ),\n\t *\n\t *  envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ),\n\t *  combine: THREE.Multiply,\n\t *  reflectivity: <float>,\n\t *  refractionRatio: <float>,\n\t *\n\t *  wireframe: <boolean>,\n\t *  wireframeLinewidth: <float>,\n\t *\n\t *  skinning: <bool>,\n\t *  morphTargets: <bool>,\n\t *  morphNormals: <bool>\n\t * }\n\t */\n\n\tfunction MeshPhongMaterial( parameters ) {\n\n\t\tMaterial.call( this );\n\n\t\tthis.type = 'MeshPhongMaterial';\n\n\t\tthis.color = new Color( 0xffffff ); // diffuse\n\t\tthis.specular = new Color( 0x111111 );\n\t\tthis.shininess = 30;\n\n\t\tthis.map = null;\n\n\t\tthis.lightMap = null;\n\t\tthis.lightMapIntensity = 1.0;\n\n\t\tthis.aoMap = null;\n\t\tthis.aoMapIntensity = 1.0;\n\n\t\tthis.emissive = new Color( 0x000000 );\n\t\tthis.emissiveIntensity = 1.0;\n\t\tthis.emissiveMap = null;\n\n\t\tthis.bumpMap = null;\n\t\tthis.bumpScale = 1;\n\n\t\tthis.normalMap = null;\n\t\tthis.normalMapType = TangentSpaceNormalMap;\n\t\tthis.normalScale = new Vector2( 1, 1 );\n\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\n\t\tthis.specularMap = null;\n\n\t\tthis.alphaMap = null;\n\n\t\tthis.envMap = null;\n\t\tthis.combine = MultiplyOperation;\n\t\tthis.reflectivity = 1;\n\t\tthis.refractionRatio = 0.98;\n\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.wireframeLinecap = 'round';\n\t\tthis.wireframeLinejoin = 'round';\n\n\t\tthis.skinning = false;\n\t\tthis.morphTargets = false;\n\t\tthis.morphNormals = false;\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n\tMeshPhongMaterial.prototype = Object.create( Material.prototype );\n\tMeshPhongMaterial.prototype.constructor = MeshPhongMaterial;\n\n\tMeshPhongMaterial.prototype.isMeshPhongMaterial = true;\n\n\tMeshPhongMaterial.prototype.copy = function ( source ) {\n\n\t\tMaterial.prototype.copy.call( this, source );\n\n\t\tthis.color.copy( source.color );\n\t\tthis.specular.copy( source.specular );\n\t\tthis.shininess = source.shininess;\n\n\t\tthis.map = source.map;\n\n\t\tthis.lightMap = source.lightMap;\n\t\tthis.lightMapIntensity = source.lightMapIntensity;\n\n\t\tthis.aoMap = source.aoMap;\n\t\tthis.aoMapIntensity = source.aoMapIntensity;\n\n\t\tthis.emissive.copy( source.emissive );\n\t\tthis.emissiveMap = source.emissiveMap;\n\t\tthis.emissiveIntensity = source.emissiveIntensity;\n\n\t\tthis.bumpMap = source.bumpMap;\n\t\tthis.bumpScale = source.bumpScale;\n\n\t\tthis.normalMap = source.normalMap;\n\t\tthis.normalMapType = source.normalMapType;\n\t\tthis.normalScale.copy( source.normalScale );\n\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\n\t\tthis.specularMap = source.specularMap;\n\n\t\tthis.alphaMap = source.alphaMap;\n\n\t\tthis.envMap = source.envMap;\n\t\tthis.combine = source.combine;\n\t\tthis.reflectivity = source.reflectivity;\n\t\tthis.refractionRatio = source.refractionRatio;\n\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.wireframeLinecap = source.wireframeLinecap;\n\t\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\t\tthis.morphNormals = source.morphNormals;\n\n\t\treturn this;\n\n\t};\n\n\t/**\n\t * @author takahirox / http://github.com/takahirox\n\t *\n\t * parameters = {\n\t *  gradientMap: new THREE.Texture( <Image> )\n\t * }\n\t */\n\n\tfunction MeshToonMaterial( parameters ) {\n\n\t\tMeshPhongMaterial.call( this );\n\n\t\tthis.defines = { 'TOON': '' };\n\n\t\tthis.type = 'MeshToonMaterial';\n\n\t\tthis.gradientMap = null;\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n\tMeshToonMaterial.prototype = Object.create( MeshPhongMaterial.prototype );\n\tMeshToonMaterial.prototype.constructor = MeshToonMaterial;\n\n\tMeshToonMaterial.prototype.isMeshToonMaterial = true;\n\n\tMeshToonMaterial.prototype.copy = function ( source ) {\n\n\t\tMeshPhongMaterial.prototype.copy.call( this, source );\n\n\t\tthis.gradientMap = source.gradientMap;\n\n\t\treturn this;\n\n\t};\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author WestLangley / http://github.com/WestLangley\n\t *\n\t * parameters = {\n\t *  opacity: <float>,\n\t *\n\t *  bumpMap: new THREE.Texture( <Image> ),\n\t *  bumpScale: <float>,\n\t *\n\t *  normalMap: new THREE.Texture( <Image> ),\n\t *  normalMapType: THREE.TangentSpaceNormalMap,\n\t *  normalScale: <Vector2>,\n\t *\n\t *  displacementMap: new THREE.Texture( <Image> ),\n\t *  displacementScale: <float>,\n\t *  displacementBias: <float>,\n\t *\n\t *  wireframe: <boolean>,\n\t *  wireframeLinewidth: <float>\n\t *\n\t *  skinning: <bool>,\n\t *  morphTargets: <bool>,\n\t *  morphNormals: <bool>\n\t * }\n\t */\n\n\tfunction MeshNormalMaterial( parameters ) {\n\n\t\tMaterial.call( this );\n\n\t\tthis.type = 'MeshNormalMaterial';\n\n\t\tthis.bumpMap = null;\n\t\tthis.bumpScale = 1;\n\n\t\tthis.normalMap = null;\n\t\tthis.normalMapType = TangentSpaceNormalMap;\n\t\tthis.normalScale = new Vector2( 1, 1 );\n\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\n\t\tthis.fog = false;\n\t\tthis.lights = false;\n\n\t\tthis.skinning = false;\n\t\tthis.morphTargets = false;\n\t\tthis.morphNormals = false;\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n\tMeshNormalMaterial.prototype = Object.create( Material.prototype );\n\tMeshNormalMaterial.prototype.constructor = MeshNormalMaterial;\n\n\tMeshNormalMaterial.prototype.isMeshNormalMaterial = true;\n\n\tMeshNormalMaterial.prototype.copy = function ( source ) {\n\n\t\tMaterial.prototype.copy.call( this, source );\n\n\t\tthis.bumpMap = source.bumpMap;\n\t\tthis.bumpScale = source.bumpScale;\n\n\t\tthis.normalMap = source.normalMap;\n\t\tthis.normalMapType = source.normalMapType;\n\t\tthis.normalScale.copy( source.normalScale );\n\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\t\tthis.morphNormals = source.morphNormals;\n\n\t\treturn this;\n\n\t};\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author alteredq / http://alteredqualia.com/\n\t *\n\t * parameters = {\n\t *  color: <hex>,\n\t *  opacity: <float>,\n\t *\n\t *  map: new THREE.Texture( <Image> ),\n\t *\n\t *  lightMap: new THREE.Texture( <Image> ),\n\t *  lightMapIntensity: <float>\n\t *\n\t *  aoMap: new THREE.Texture( <Image> ),\n\t *  aoMapIntensity: <float>\n\t *\n\t *  emissive: <hex>,\n\t *  emissiveIntensity: <float>\n\t *  emissiveMap: new THREE.Texture( <Image> ),\n\t *\n\t *  specularMap: new THREE.Texture( <Image> ),\n\t *\n\t *  alphaMap: new THREE.Texture( <Image> ),\n\t *\n\t *  envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ),\n\t *  combine: THREE.Multiply,\n\t *  reflectivity: <float>,\n\t *  refractionRatio: <float>,\n\t *\n\t *  wireframe: <boolean>,\n\t *  wireframeLinewidth: <float>,\n\t *\n\t *  skinning: <bool>,\n\t *  morphTargets: <bool>,\n\t *  morphNormals: <bool>\n\t * }\n\t */\n\n\tfunction MeshLambertMaterial( parameters ) {\n\n\t\tMaterial.call( this );\n\n\t\tthis.type = 'MeshLambertMaterial';\n\n\t\tthis.color = new Color( 0xffffff ); // diffuse\n\n\t\tthis.map = null;\n\n\t\tthis.lightMap = null;\n\t\tthis.lightMapIntensity = 1.0;\n\n\t\tthis.aoMap = null;\n\t\tthis.aoMapIntensity = 1.0;\n\n\t\tthis.emissive = new Color( 0x000000 );\n\t\tthis.emissiveIntensity = 1.0;\n\t\tthis.emissiveMap = null;\n\n\t\tthis.specularMap = null;\n\n\t\tthis.alphaMap = null;\n\n\t\tthis.envMap = null;\n\t\tthis.combine = MultiplyOperation;\n\t\tthis.reflectivity = 1;\n\t\tthis.refractionRatio = 0.98;\n\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.wireframeLinecap = 'round';\n\t\tthis.wireframeLinejoin = 'round';\n\n\t\tthis.skinning = false;\n\t\tthis.morphTargets = false;\n\t\tthis.morphNormals = false;\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n\tMeshLambertMaterial.prototype = Object.create( Material.prototype );\n\tMeshLambertMaterial.prototype.constructor = MeshLambertMaterial;\n\n\tMeshLambertMaterial.prototype.isMeshLambertMaterial = true;\n\n\tMeshLambertMaterial.prototype.copy = function ( source ) {\n\n\t\tMaterial.prototype.copy.call( this, source );\n\n\t\tthis.color.copy( source.color );\n\n\t\tthis.map = source.map;\n\n\t\tthis.lightMap = source.lightMap;\n\t\tthis.lightMapIntensity = source.lightMapIntensity;\n\n\t\tthis.aoMap = source.aoMap;\n\t\tthis.aoMapIntensity = source.aoMapIntensity;\n\n\t\tthis.emissive.copy( source.emissive );\n\t\tthis.emissiveMap = source.emissiveMap;\n\t\tthis.emissiveIntensity = source.emissiveIntensity;\n\n\t\tthis.specularMap = source.specularMap;\n\n\t\tthis.alphaMap = source.alphaMap;\n\n\t\tthis.envMap = source.envMap;\n\t\tthis.combine = source.combine;\n\t\tthis.reflectivity = source.reflectivity;\n\t\tthis.refractionRatio = source.refractionRatio;\n\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.wireframeLinecap = source.wireframeLinecap;\n\t\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\t\tthis.morphNormals = source.morphNormals;\n\n\t\treturn this;\n\n\t};\n\n\t/**\n\t * @author WestLangley / http://github.com/WestLangley\n\t *\n\t * parameters = {\n\t *  color: <hex>,\n\t *  opacity: <float>,\n\t *\n\t *  matcap: new THREE.Texture( <Image> ),\n\t *\n\t *  map: new THREE.Texture( <Image> ),\n\t *\n\t *  bumpMap: new THREE.Texture( <Image> ),\n\t *  bumpScale: <float>,\n\t *\n\t *  normalMap: new THREE.Texture( <Image> ),\n\t *  normalMapType: THREE.TangentSpaceNormalMap,\n\t *  normalScale: <Vector2>,\n\t *\n\t *  displacementMap: new THREE.Texture( <Image> ),\n\t *  displacementScale: <float>,\n\t *  displacementBias: <float>,\n\t *\n\t *  alphaMap: new THREE.Texture( <Image> ),\n\t *\n\t *  skinning: <bool>,\n\t *  morphTargets: <bool>,\n\t *  morphNormals: <bool>\n\t * }\n\t */\n\n\tfunction MeshMatcapMaterial( parameters ) {\n\n\t\tMaterial.call( this );\n\n\t\tthis.defines = { 'MATCAP': '' };\n\n\t\tthis.type = 'MeshMatcapMaterial';\n\n\t\tthis.color = new Color( 0xffffff ); // diffuse\n\n\t\tthis.matcap = null;\n\n\t\tthis.map = null;\n\n\t\tthis.bumpMap = null;\n\t\tthis.bumpScale = 1;\n\n\t\tthis.normalMap = null;\n\t\tthis.normalMapType = TangentSpaceNormalMap;\n\t\tthis.normalScale = new Vector2( 1, 1 );\n\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\n\t\tthis.alphaMap = null;\n\n\t\tthis.skinning = false;\n\t\tthis.morphTargets = false;\n\t\tthis.morphNormals = false;\n\n\t\tthis.lights = false;\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n\tMeshMatcapMaterial.prototype = Object.create( Material.prototype );\n\tMeshMatcapMaterial.prototype.constructor = MeshMatcapMaterial;\n\n\tMeshMatcapMaterial.prototype.isMeshMatcapMaterial = true;\n\n\tMeshMatcapMaterial.prototype.copy = function ( source ) {\n\n\t\tMaterial.prototype.copy.call( this, source );\n\n\t\tthis.defines = { 'MATCAP': '' };\n\n\t\tthis.color.copy( source.color );\n\n\t\tthis.matcap = source.matcap;\n\n\t\tthis.map = source.map;\n\n\t\tthis.bumpMap = source.bumpMap;\n\t\tthis.bumpScale = source.bumpScale;\n\n\t\tthis.normalMap = source.normalMap;\n\t\tthis.normalMapType = source.normalMapType;\n\t\tthis.normalScale.copy( source.normalScale );\n\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\n\t\tthis.alphaMap = source.alphaMap;\n\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\t\tthis.morphNormals = source.morphNormals;\n\n\t\treturn this;\n\n\t};\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t *\n\t * parameters = {\n\t *  color: <hex>,\n\t *  opacity: <float>,\n\t *\n\t *  linewidth: <float>,\n\t *\n\t *  scale: <float>,\n\t *  dashSize: <float>,\n\t *  gapSize: <float>\n\t * }\n\t */\n\n\tfunction LineDashedMaterial( parameters ) {\n\n\t\tLineBasicMaterial.call( this );\n\n\t\tthis.type = 'LineDashedMaterial';\n\n\t\tthis.scale = 1;\n\t\tthis.dashSize = 3;\n\t\tthis.gapSize = 1;\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n\tLineDashedMaterial.prototype = Object.create( LineBasicMaterial.prototype );\n\tLineDashedMaterial.prototype.constructor = LineDashedMaterial;\n\n\tLineDashedMaterial.prototype.isLineDashedMaterial = true;\n\n\tLineDashedMaterial.prototype.copy = function ( source ) {\n\n\t\tLineBasicMaterial.prototype.copy.call( this, source );\n\n\t\tthis.scale = source.scale;\n\t\tthis.dashSize = source.dashSize;\n\t\tthis.gapSize = source.gapSize;\n\n\t\treturn this;\n\n\t};\n\n\n\n\tvar Materials = /*#__PURE__*/Object.freeze({\n\t\tShadowMaterial: ShadowMaterial,\n\t\tSpriteMaterial: SpriteMaterial,\n\t\tRawShaderMaterial: RawShaderMaterial,\n\t\tShaderMaterial: ShaderMaterial,\n\t\tPointsMaterial: PointsMaterial,\n\t\tMeshPhysicalMaterial: MeshPhysicalMaterial,\n\t\tMeshStandardMaterial: MeshStandardMaterial,\n\t\tMeshPhongMaterial: MeshPhongMaterial,\n\t\tMeshToonMaterial: MeshToonMaterial,\n\t\tMeshNormalMaterial: MeshNormalMaterial,\n\t\tMeshLambertMaterial: MeshLambertMaterial,\n\t\tMeshDepthMaterial: MeshDepthMaterial,\n\t\tMeshDistanceMaterial: MeshDistanceMaterial,\n\t\tMeshBasicMaterial: MeshBasicMaterial,\n\t\tMeshMatcapMaterial: MeshMatcapMaterial,\n\t\tLineDashedMaterial: LineDashedMaterial,\n\t\tLineBasicMaterial: LineBasicMaterial,\n\t\tMaterial: Material\n\t});\n\n\t/**\n\t * @author tschw\n\t * @author Ben Houston / http://clara.io/\n\t * @author David Sarno / http://lighthaus.us/\n\t */\n\n\tvar AnimationUtils = {\n\n\t\t// same as Array.prototype.slice, but also works on typed arrays\n\t\tarraySlice: function ( array, from, to ) {\n\n\t\t\tif ( AnimationUtils.isTypedArray( array ) ) {\n\n\t\t\t\t// in ios9 array.subarray(from, undefined) will return empty array\n\t\t\t\t// but array.subarray(from) or array.subarray(from, len) is correct\n\t\t\t\treturn new array.constructor( array.subarray( from, to !== undefined ? to : array.length ) );\n\n\t\t\t}\n\n\t\t\treturn array.slice( from, to );\n\n\t\t},\n\n\t\t// converts an array to a specific type\n\t\tconvertArray: function ( array, type, forceClone ) {\n\n\t\t\tif ( ! array || // let 'undefined' and 'null' pass\n\t\t\t\t! forceClone && array.constructor === type ) return array;\n\n\t\t\tif ( typeof type.BYTES_PER_ELEMENT === 'number' ) {\n\n\t\t\t\treturn new type( array ); // create typed array\n\n\t\t\t}\n\n\t\t\treturn Array.prototype.slice.call( array ); // create Array\n\n\t\t},\n\n\t\tisTypedArray: function ( object ) {\n\n\t\t\treturn ArrayBuffer.isView( object ) &&\n\t\t\t\t! ( object instanceof DataView );\n\n\t\t},\n\n\t\t// returns an array by which times and values can be sorted\n\t\tgetKeyframeOrder: function ( times ) {\n\n\t\t\tfunction compareTime( i, j ) {\n\n\t\t\t\treturn times[ i ] - times[ j ];\n\n\t\t\t}\n\n\t\t\tvar n = times.length;\n\t\t\tvar result = new Array( n );\n\t\t\tfor ( var i = 0; i !== n; ++ i ) result[ i ] = i;\n\n\t\t\tresult.sort( compareTime );\n\n\t\t\treturn result;\n\n\t\t},\n\n\t\t// uses the array previously returned by 'getKeyframeOrder' to sort data\n\t\tsortedArray: function ( values, stride, order ) {\n\n\t\t\tvar nValues = values.length;\n\t\t\tvar result = new values.constructor( nValues );\n\n\t\t\tfor ( var i = 0, dstOffset = 0; dstOffset !== nValues; ++ i ) {\n\n\t\t\t\tvar srcOffset = order[ i ] * stride;\n\n\t\t\t\tfor ( var j = 0; j !== stride; ++ j ) {\n\n\t\t\t\t\tresult[ dstOffset ++ ] = values[ srcOffset + j ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn result;\n\n\t\t},\n\n\t\t// function for parsing AOS keyframe formats\n\t\tflattenJSON: function ( jsonKeys, times, values, valuePropertyName ) {\n\n\t\t\tvar i = 1, key = jsonKeys[ 0 ];\n\n\t\t\twhile ( key !== undefined && key[ valuePropertyName ] === undefined ) {\n\n\t\t\t\tkey = jsonKeys[ i ++ ];\n\n\t\t\t}\n\n\t\t\tif ( key === undefined ) return; // no data\n\n\t\t\tvar value = key[ valuePropertyName ];\n\t\t\tif ( value === undefined ) return; // no data\n\n\t\t\tif ( Array.isArray( value ) ) {\n\n\t\t\t\tdo {\n\n\t\t\t\t\tvalue = key[ valuePropertyName ];\n\n\t\t\t\t\tif ( value !== undefined ) {\n\n\t\t\t\t\t\ttimes.push( key.time );\n\t\t\t\t\t\tvalues.push.apply( values, value ); // push all elements\n\n\t\t\t\t\t}\n\n\t\t\t\t\tkey = jsonKeys[ i ++ ];\n\n\t\t\t\t} while ( key !== undefined );\n\n\t\t\t} else if ( value.toArray !== undefined ) {\n\n\t\t\t\t// ...assume THREE.Math-ish\n\n\t\t\t\tdo {\n\n\t\t\t\t\tvalue = key[ valuePropertyName ];\n\n\t\t\t\t\tif ( value !== undefined ) {\n\n\t\t\t\t\t\ttimes.push( key.time );\n\t\t\t\t\t\tvalue.toArray( values, values.length );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tkey = jsonKeys[ i ++ ];\n\n\t\t\t\t} while ( key !== undefined );\n\n\t\t\t} else {\n\n\t\t\t\t// otherwise push as-is\n\n\t\t\t\tdo {\n\n\t\t\t\t\tvalue = key[ valuePropertyName ];\n\n\t\t\t\t\tif ( value !== undefined ) {\n\n\t\t\t\t\t\ttimes.push( key.time );\n\t\t\t\t\t\tvalues.push( value );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tkey = jsonKeys[ i ++ ];\n\n\t\t\t\t} while ( key !== undefined );\n\n\t\t\t}\n\n\t\t}\n\n\t};\n\n\t/**\n\t * Abstract base class of interpolants over parametric samples.\n\t *\n\t * The parameter domain is one dimensional, typically the time or a path\n\t * along a curve defined by the data.\n\t *\n\t * The sample values can have any dimensionality and derived classes may\n\t * apply special interpretations to the data.\n\t *\n\t * This class provides the interval seek in a Template Method, deferring\n\t * the actual interpolation to derived classes.\n\t *\n\t * Time complexity is O(1) for linear access crossing at most two points\n\t * and O(log N) for random access, where N is the number of positions.\n\t *\n\t * References:\n\t *\n\t * \t\thttp://www.oodesign.com/template-method-pattern.html\n\t *\n\t * @author tschw\n\t */\n\n\tfunction Interpolant( parameterPositions, sampleValues, sampleSize, resultBuffer ) {\n\n\t\tthis.parameterPositions = parameterPositions;\n\t\tthis._cachedIndex = 0;\n\n\t\tthis.resultBuffer = resultBuffer !== undefined ?\n\t\t\tresultBuffer : new sampleValues.constructor( sampleSize );\n\t\tthis.sampleValues = sampleValues;\n\t\tthis.valueSize = sampleSize;\n\n\t}\n\n\tObject.assign( Interpolant.prototype, {\n\n\t\tevaluate: function ( t ) {\n\n\t\t\tvar pp = this.parameterPositions,\n\t\t\t\ti1 = this._cachedIndex,\n\n\t\t\t\tt1 = pp[ i1 ],\n\t\t\t\tt0 = pp[ i1 - 1 ];\n\n\t\t\tvalidate_interval: {\n\n\t\t\t\tseek: {\n\n\t\t\t\t\tvar right;\n\n\t\t\t\t\tlinear_scan: {\n\n\t\t\t\t\t\t//- See http://jsperf.com/comparison-to-undefined/3\n\t\t\t\t\t\t//- slower code:\n\t\t\t\t\t\t//-\n\t\t\t\t\t\t//- \t\t\t\tif ( t >= t1 || t1 === undefined ) {\n\t\t\t\t\t\tforward_scan: if ( ! ( t < t1 ) ) {\n\n\t\t\t\t\t\t\tfor ( var giveUpAt = i1 + 2; ; ) {\n\n\t\t\t\t\t\t\t\tif ( t1 === undefined ) {\n\n\t\t\t\t\t\t\t\t\tif ( t < t0 ) break forward_scan;\n\n\t\t\t\t\t\t\t\t\t// after end\n\n\t\t\t\t\t\t\t\t\ti1 = pp.length;\n\t\t\t\t\t\t\t\t\tthis._cachedIndex = i1;\n\t\t\t\t\t\t\t\t\treturn this.afterEnd_( i1 - 1, t, t0 );\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif ( i1 === giveUpAt ) break; // this loop\n\n\t\t\t\t\t\t\t\tt0 = t1;\n\t\t\t\t\t\t\t\tt1 = pp[ ++ i1 ];\n\n\t\t\t\t\t\t\t\tif ( t < t1 ) {\n\n\t\t\t\t\t\t\t\t\t// we have arrived at the sought interval\n\t\t\t\t\t\t\t\t\tbreak seek;\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// prepare binary search on the right side of the index\n\t\t\t\t\t\t\tright = pp.length;\n\t\t\t\t\t\t\tbreak linear_scan;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t//- slower code:\n\t\t\t\t\t\t//-\t\t\t\t\tif ( t < t0 || t0 === undefined ) {\n\t\t\t\t\t\tif ( ! ( t >= t0 ) ) {\n\n\t\t\t\t\t\t\t// looping?\n\n\t\t\t\t\t\t\tvar t1global = pp[ 1 ];\n\n\t\t\t\t\t\t\tif ( t < t1global ) {\n\n\t\t\t\t\t\t\t\ti1 = 2; // + 1, using the scan for the details\n\t\t\t\t\t\t\t\tt0 = t1global;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// linear reverse scan\n\n\t\t\t\t\t\t\tfor ( var giveUpAt = i1 - 2; ; ) {\n\n\t\t\t\t\t\t\t\tif ( t0 === undefined ) {\n\n\t\t\t\t\t\t\t\t\t// before start\n\n\t\t\t\t\t\t\t\t\tthis._cachedIndex = 0;\n\t\t\t\t\t\t\t\t\treturn this.beforeStart_( 0, t, t1 );\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif ( i1 === giveUpAt ) break; // this loop\n\n\t\t\t\t\t\t\t\tt1 = t0;\n\t\t\t\t\t\t\t\tt0 = pp[ -- i1 - 1 ];\n\n\t\t\t\t\t\t\t\tif ( t >= t0 ) {\n\n\t\t\t\t\t\t\t\t\t// we have arrived at the sought interval\n\t\t\t\t\t\t\t\t\tbreak seek;\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// prepare binary search on the left side of the index\n\t\t\t\t\t\t\tright = i1;\n\t\t\t\t\t\t\ti1 = 0;\n\t\t\t\t\t\t\tbreak linear_scan;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// the interval is valid\n\n\t\t\t\t\t\tbreak validate_interval;\n\n\t\t\t\t\t} // linear scan\n\n\t\t\t\t\t// binary search\n\n\t\t\t\t\twhile ( i1 < right ) {\n\n\t\t\t\t\t\tvar mid = ( i1 + right ) >>> 1;\n\n\t\t\t\t\t\tif ( t < pp[ mid ] ) {\n\n\t\t\t\t\t\t\tright = mid;\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\ti1 = mid + 1;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tt1 = pp[ i1 ];\n\t\t\t\t\tt0 = pp[ i1 - 1 ];\n\n\t\t\t\t\t// check boundary cases, again\n\n\t\t\t\t\tif ( t0 === undefined ) {\n\n\t\t\t\t\t\tthis._cachedIndex = 0;\n\t\t\t\t\t\treturn this.beforeStart_( 0, t, t1 );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( t1 === undefined ) {\n\n\t\t\t\t\t\ti1 = pp.length;\n\t\t\t\t\t\tthis._cachedIndex = i1;\n\t\t\t\t\t\treturn this.afterEnd_( i1 - 1, t0, t );\n\n\t\t\t\t\t}\n\n\t\t\t\t} // seek\n\n\t\t\t\tthis._cachedIndex = i1;\n\n\t\t\t\tthis.intervalChanged_( i1, t0, t1 );\n\n\t\t\t} // validate_interval\n\n\t\t\treturn this.interpolate_( i1, t0, t, t1 );\n\n\t\t},\n\n\t\tsettings: null, // optional, subclass-specific settings structure\n\t\t// Note: The indirection allows central control of many interpolants.\n\n\t\t// --- Protected interface\n\n\t\tDefaultSettings_: {},\n\n\t\tgetSettings_: function () {\n\n\t\t\treturn this.settings || this.DefaultSettings_;\n\n\t\t},\n\n\t\tcopySampleValue_: function ( index ) {\n\n\t\t\t// copies a sample value to the result buffer\n\n\t\t\tvar result = this.resultBuffer,\n\t\t\t\tvalues = this.sampleValues,\n\t\t\t\tstride = this.valueSize,\n\t\t\t\toffset = index * stride;\n\n\t\t\tfor ( var i = 0; i !== stride; ++ i ) {\n\n\t\t\t\tresult[ i ] = values[ offset + i ];\n\n\t\t\t}\n\n\t\t\treturn result;\n\n\t\t},\n\n\t\t// Template methods for derived classes:\n\n\t\tinterpolate_: function ( /* i1, t0, t, t1 */ ) {\n\n\t\t\tthrow new Error( 'call to abstract method' );\n\t\t\t// implementations shall return this.resultBuffer\n\n\t\t},\n\n\t\tintervalChanged_: function ( /* i1, t0, t1 */ ) {\n\n\t\t\t// empty\n\n\t\t}\n\n\t} );\n\n\t//!\\ DECLARE ALIAS AFTER assign prototype !\n\tObject.assign( Interpolant.prototype, {\n\n\t\t//( 0, t, t0 ), returns this.resultBuffer\n\t\tbeforeStart_: Interpolant.prototype.copySampleValue_,\n\n\t\t//( N-1, tN-1, t ), returns this.resultBuffer\n\t\tafterEnd_: Interpolant.prototype.copySampleValue_,\n\n\t} );\n\n\t/**\n\t * Fast and simple cubic spline interpolant.\n\t *\n\t * It was derived from a Hermitian construction setting the first derivative\n\t * at each sample position to the linear slope between neighboring positions\n\t * over their parameter interval.\n\t *\n\t * @author tschw\n\t */\n\n\tfunction CubicInterpolant( parameterPositions, sampleValues, sampleSize, resultBuffer ) {\n\n\t\tInterpolant.call( this, parameterPositions, sampleValues, sampleSize, resultBuffer );\n\n\t\tthis._weightPrev = - 0;\n\t\tthis._offsetPrev = - 0;\n\t\tthis._weightNext = - 0;\n\t\tthis._offsetNext = - 0;\n\n\t}\n\n\tCubicInterpolant.prototype = Object.assign( Object.create( Interpolant.prototype ), {\n\n\t\tconstructor: CubicInterpolant,\n\n\t\tDefaultSettings_: {\n\n\t\t\tendingStart: ZeroCurvatureEnding,\n\t\t\tendingEnd: ZeroCurvatureEnding\n\n\t\t},\n\n\t\tintervalChanged_: function ( i1, t0, t1 ) {\n\n\t\t\tvar pp = this.parameterPositions,\n\t\t\t\tiPrev = i1 - 2,\n\t\t\t\tiNext = i1 + 1,\n\n\t\t\t\ttPrev = pp[ iPrev ],\n\t\t\t\ttNext = pp[ iNext ];\n\n\t\t\tif ( tPrev === undefined ) {\n\n\t\t\t\tswitch ( this.getSettings_().endingStart ) {\n\n\t\t\t\t\tcase ZeroSlopeEnding:\n\n\t\t\t\t\t\t// f'(t0) = 0\n\t\t\t\t\t\tiPrev = i1;\n\t\t\t\t\t\ttPrev = 2 * t0 - t1;\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase WrapAroundEnding:\n\n\t\t\t\t\t\t// use the other end of the curve\n\t\t\t\t\t\tiPrev = pp.length - 2;\n\t\t\t\t\t\ttPrev = t0 + pp[ iPrev ] - pp[ iPrev + 1 ];\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault: // ZeroCurvatureEnding\n\n\t\t\t\t\t\t// f''(t0) = 0 a.k.a. Natural Spline\n\t\t\t\t\t\tiPrev = i1;\n\t\t\t\t\t\ttPrev = t1;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( tNext === undefined ) {\n\n\t\t\t\tswitch ( this.getSettings_().endingEnd ) {\n\n\t\t\t\t\tcase ZeroSlopeEnding:\n\n\t\t\t\t\t\t// f'(tN) = 0\n\t\t\t\t\t\tiNext = i1;\n\t\t\t\t\t\ttNext = 2 * t1 - t0;\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase WrapAroundEnding:\n\n\t\t\t\t\t\t// use the other end of the curve\n\t\t\t\t\t\tiNext = 1;\n\t\t\t\t\t\ttNext = t1 + pp[ 1 ] - pp[ 0 ];\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault: // ZeroCurvatureEnding\n\n\t\t\t\t\t\t// f''(tN) = 0, a.k.a. Natural Spline\n\t\t\t\t\t\tiNext = i1 - 1;\n\t\t\t\t\t\ttNext = t0;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tvar halfDt = ( t1 - t0 ) * 0.5,\n\t\t\t\tstride = this.valueSize;\n\n\t\t\tthis._weightPrev = halfDt / ( t0 - tPrev );\n\t\t\tthis._weightNext = halfDt / ( tNext - t1 );\n\t\t\tthis._offsetPrev = iPrev * stride;\n\t\t\tthis._offsetNext = iNext * stride;\n\n\t\t},\n\n\t\tinterpolate_: function ( i1, t0, t, t1 ) {\n\n\t\t\tvar result = this.resultBuffer,\n\t\t\t\tvalues = this.sampleValues,\n\t\t\t\tstride = this.valueSize,\n\n\t\t\t\to1 = i1 * stride,\t\to0 = o1 - stride,\n\t\t\t\toP = this._offsetPrev, \toN = this._offsetNext,\n\t\t\t\twP = this._weightPrev,\twN = this._weightNext,\n\n\t\t\t\tp = ( t - t0 ) / ( t1 - t0 ),\n\t\t\t\tpp = p * p,\n\t\t\t\tppp = pp * p;\n\n\t\t\t// evaluate polynomials\n\n\t\t\tvar sP = - wP * ppp + 2 * wP * pp - wP * p;\n\t\t\tvar s0 = ( 1 + wP ) * ppp + ( - 1.5 - 2 * wP ) * pp + ( - 0.5 + wP ) * p + 1;\n\t\t\tvar s1 = ( - 1 - wN ) * ppp + ( 1.5 + wN ) * pp + 0.5 * p;\n\t\t\tvar sN = wN * ppp - wN * pp;\n\n\t\t\t// combine data linearly\n\n\t\t\tfor ( var i = 0; i !== stride; ++ i ) {\n\n\t\t\t\tresult[ i ] =\n\t\t\t\t\t\tsP * values[ oP + i ] +\n\t\t\t\t\t\ts0 * values[ o0 + i ] +\n\t\t\t\t\t\ts1 * values[ o1 + i ] +\n\t\t\t\t\t\tsN * values[ oN + i ];\n\n\t\t\t}\n\n\t\t\treturn result;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author tschw\n\t */\n\n\tfunction LinearInterpolant( parameterPositions, sampleValues, sampleSize, resultBuffer ) {\n\n\t\tInterpolant.call( this, parameterPositions, sampleValues, sampleSize, resultBuffer );\n\n\t}\n\n\tLinearInterpolant.prototype = Object.assign( Object.create( Interpolant.prototype ), {\n\n\t\tconstructor: LinearInterpolant,\n\n\t\tinterpolate_: function ( i1, t0, t, t1 ) {\n\n\t\t\tvar result = this.resultBuffer,\n\t\t\t\tvalues = this.sampleValues,\n\t\t\t\tstride = this.valueSize,\n\n\t\t\t\toffset1 = i1 * stride,\n\t\t\t\toffset0 = offset1 - stride,\n\n\t\t\t\tweight1 = ( t - t0 ) / ( t1 - t0 ),\n\t\t\t\tweight0 = 1 - weight1;\n\n\t\t\tfor ( var i = 0; i !== stride; ++ i ) {\n\n\t\t\t\tresult[ i ] =\n\t\t\t\t\t\tvalues[ offset0 + i ] * weight0 +\n\t\t\t\t\t\tvalues[ offset1 + i ] * weight1;\n\n\t\t\t}\n\n\t\t\treturn result;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t *\n\t * Interpolant that evaluates to the sample value at the position preceeding\n\t * the parameter.\n\t *\n\t * @author tschw\n\t */\n\n\tfunction DiscreteInterpolant( parameterPositions, sampleValues, sampleSize, resultBuffer ) {\n\n\t\tInterpolant.call( this, parameterPositions, sampleValues, sampleSize, resultBuffer );\n\n\t}\n\n\tDiscreteInterpolant.prototype = Object.assign( Object.create( Interpolant.prototype ), {\n\n\t\tconstructor: DiscreteInterpolant,\n\n\t\tinterpolate_: function ( i1 /*, t0, t, t1 */ ) {\n\n\t\t\treturn this.copySampleValue_( i1 - 1 );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t *\n\t * A timed sequence of keyframes for a specific property.\n\t *\n\t *\n\t * @author Ben Houston / http://clara.io/\n\t * @author David Sarno / http://lighthaus.us/\n\t * @author tschw\n\t */\n\n\tfunction KeyframeTrack( name, times, values, interpolation ) {\n\n\t\tif ( name === undefined ) throw new Error( 'THREE.KeyframeTrack: track name is undefined' );\n\t\tif ( times === undefined || times.length === 0 ) throw new Error( 'THREE.KeyframeTrack: no keyframes in track named ' + name );\n\n\t\tthis.name = name;\n\n\t\tthis.times = AnimationUtils.convertArray( times, this.TimeBufferType );\n\t\tthis.values = AnimationUtils.convertArray( values, this.ValueBufferType );\n\n\t\tthis.setInterpolation( interpolation || this.DefaultInterpolation );\n\n\t}\n\n\t// Static methods\n\n\tObject.assign( KeyframeTrack, {\n\n\t\t// Serialization (in static context, because of constructor invocation\n\t\t// and automatic invocation of .toJSON):\n\n\t\ttoJSON: function ( track ) {\n\n\t\t\tvar trackType = track.constructor;\n\n\t\t\tvar json;\n\n\t\t\t// derived classes can define a static toJSON method\n\t\t\tif ( trackType.toJSON !== undefined ) {\n\n\t\t\t\tjson = trackType.toJSON( track );\n\n\t\t\t} else {\n\n\t\t\t\t// by default, we assume the data can be serialized as-is\n\t\t\t\tjson = {\n\n\t\t\t\t\t'name': track.name,\n\t\t\t\t\t'times': AnimationUtils.convertArray( track.times, Array ),\n\t\t\t\t\t'values': AnimationUtils.convertArray( track.values, Array )\n\n\t\t\t\t};\n\n\t\t\t\tvar interpolation = track.getInterpolation();\n\n\t\t\t\tif ( interpolation !== track.DefaultInterpolation ) {\n\n\t\t\t\t\tjson.interpolation = interpolation;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tjson.type = track.ValueTypeName; // mandatory\n\n\t\t\treturn json;\n\n\t\t}\n\n\t} );\n\n\tObject.assign( KeyframeTrack.prototype, {\n\n\t\tconstructor: KeyframeTrack,\n\n\t\tTimeBufferType: Float32Array,\n\n\t\tValueBufferType: Float32Array,\n\n\t\tDefaultInterpolation: InterpolateLinear,\n\n\t\tInterpolantFactoryMethodDiscrete: function ( result ) {\n\n\t\t\treturn new DiscreteInterpolant( this.times, this.values, this.getValueSize(), result );\n\n\t\t},\n\n\t\tInterpolantFactoryMethodLinear: function ( result ) {\n\n\t\t\treturn new LinearInterpolant( this.times, this.values, this.getValueSize(), result );\n\n\t\t},\n\n\t\tInterpolantFactoryMethodSmooth: function ( result ) {\n\n\t\t\treturn new CubicInterpolant( this.times, this.values, this.getValueSize(), result );\n\n\t\t},\n\n\t\tsetInterpolation: function ( interpolation ) {\n\n\t\t\tvar factoryMethod;\n\n\t\t\tswitch ( interpolation ) {\n\n\t\t\t\tcase InterpolateDiscrete:\n\n\t\t\t\t\tfactoryMethod = this.InterpolantFactoryMethodDiscrete;\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase InterpolateLinear:\n\n\t\t\t\t\tfactoryMethod = this.InterpolantFactoryMethodLinear;\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase InterpolateSmooth:\n\n\t\t\t\t\tfactoryMethod = this.InterpolantFactoryMethodSmooth;\n\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t\tif ( factoryMethod === undefined ) {\n\n\t\t\t\tvar message = \"unsupported interpolation for \" +\n\t\t\t\t\tthis.ValueTypeName + \" keyframe track named \" + this.name;\n\n\t\t\t\tif ( this.createInterpolant === undefined ) {\n\n\t\t\t\t\t// fall back to default, unless the default itself is messed up\n\t\t\t\t\tif ( interpolation !== this.DefaultInterpolation ) {\n\n\t\t\t\t\t\tthis.setInterpolation( this.DefaultInterpolation );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tthrow new Error( message ); // fatal, in this case\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tconsole.warn( 'THREE.KeyframeTrack:', message );\n\t\t\t\treturn this;\n\n\t\t\t}\n\n\t\t\tthis.createInterpolant = factoryMethod;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetInterpolation: function () {\n\n\t\t\tswitch ( this.createInterpolant ) {\n\n\t\t\t\tcase this.InterpolantFactoryMethodDiscrete:\n\n\t\t\t\t\treturn InterpolateDiscrete;\n\n\t\t\t\tcase this.InterpolantFactoryMethodLinear:\n\n\t\t\t\t\treturn InterpolateLinear;\n\n\t\t\t\tcase this.InterpolantFactoryMethodSmooth:\n\n\t\t\t\t\treturn InterpolateSmooth;\n\n\t\t\t}\n\n\t\t},\n\n\t\tgetValueSize: function () {\n\n\t\t\treturn this.values.length / this.times.length;\n\n\t\t},\n\n\t\t// move all keyframes either forwards or backwards in time\n\t\tshift: function ( timeOffset ) {\n\n\t\t\tif ( timeOffset !== 0.0 ) {\n\n\t\t\t\tvar times = this.times;\n\n\t\t\t\tfor ( var i = 0, n = times.length; i !== n; ++ i ) {\n\n\t\t\t\t\ttimes[ i ] += timeOffset;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\t// scale all keyframe times by a factor (useful for frame <-> seconds conversions)\n\t\tscale: function ( timeScale ) {\n\n\t\t\tif ( timeScale !== 1.0 ) {\n\n\t\t\t\tvar times = this.times;\n\n\t\t\t\tfor ( var i = 0, n = times.length; i !== n; ++ i ) {\n\n\t\t\t\t\ttimes[ i ] *= timeScale;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\t// removes keyframes before and after animation without changing any values within the range [startTime, endTime].\n\t\t// IMPORTANT: We do not shift around keys to the start of the track time, because for interpolated keys this will change their values\n\t\ttrim: function ( startTime, endTime ) {\n\n\t\t\tvar times = this.times,\n\t\t\t\tnKeys = times.length,\n\t\t\t\tfrom = 0,\n\t\t\t\tto = nKeys - 1;\n\n\t\t\twhile ( from !== nKeys && times[ from ] < startTime ) {\n\n\t\t\t\t++ from;\n\n\t\t\t}\n\n\t\t\twhile ( to !== - 1 && times[ to ] > endTime ) {\n\n\t\t\t\t-- to;\n\n\t\t\t}\n\n\t\t\t++ to; // inclusive -> exclusive bound\n\n\t\t\tif ( from !== 0 || to !== nKeys ) {\n\n\t\t\t\t// empty tracks are forbidden, so keep at least one keyframe\n\t\t\t\tif ( from >= to ) to = Math.max( to, 1 ), from = to - 1;\n\n\t\t\t\tvar stride = this.getValueSize();\n\t\t\t\tthis.times = AnimationUtils.arraySlice( times, from, to );\n\t\t\t\tthis.values = AnimationUtils.arraySlice( this.values, from * stride, to * stride );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\t// ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable\n\t\tvalidate: function () {\n\n\t\t\tvar valid = true;\n\n\t\t\tvar valueSize = this.getValueSize();\n\t\t\tif ( valueSize - Math.floor( valueSize ) !== 0 ) {\n\n\t\t\t\tconsole.error( 'THREE.KeyframeTrack: Invalid value size in track.', this );\n\t\t\t\tvalid = false;\n\n\t\t\t}\n\n\t\t\tvar times = this.times,\n\t\t\t\tvalues = this.values,\n\n\t\t\t\tnKeys = times.length;\n\n\t\t\tif ( nKeys === 0 ) {\n\n\t\t\t\tconsole.error( 'THREE.KeyframeTrack: Track is empty.', this );\n\t\t\t\tvalid = false;\n\n\t\t\t}\n\n\t\t\tvar prevTime = null;\n\n\t\t\tfor ( var i = 0; i !== nKeys; i ++ ) {\n\n\t\t\t\tvar currTime = times[ i ];\n\n\t\t\t\tif ( typeof currTime === 'number' && isNaN( currTime ) ) {\n\n\t\t\t\t\tconsole.error( 'THREE.KeyframeTrack: Time is not a valid number.', this, i, currTime );\n\t\t\t\t\tvalid = false;\n\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t\tif ( prevTime !== null && prevTime > currTime ) {\n\n\t\t\t\t\tconsole.error( 'THREE.KeyframeTrack: Out of order keys.', this, i, currTime, prevTime );\n\t\t\t\t\tvalid = false;\n\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t\tprevTime = currTime;\n\n\t\t\t}\n\n\t\t\tif ( values !== undefined ) {\n\n\t\t\t\tif ( AnimationUtils.isTypedArray( values ) ) {\n\n\t\t\t\t\tfor ( var i = 0, n = values.length; i !== n; ++ i ) {\n\n\t\t\t\t\t\tvar value = values[ i ];\n\n\t\t\t\t\t\tif ( isNaN( value ) ) {\n\n\t\t\t\t\t\t\tconsole.error( 'THREE.KeyframeTrack: Value is not a valid number.', this, i, value );\n\t\t\t\t\t\t\tvalid = false;\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn valid;\n\n\t\t},\n\n\t\t// removes equivalent sequential keys as common in morph target sequences\n\t\t// (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0)\n\t\toptimize: function () {\n\n\t\t\tvar times = this.times,\n\t\t\t\tvalues = this.values,\n\t\t\t\tstride = this.getValueSize(),\n\n\t\t\t\tsmoothInterpolation = this.getInterpolation() === InterpolateSmooth,\n\n\t\t\t\twriteIndex = 1,\n\t\t\t\tlastIndex = times.length - 1;\n\n\t\t\tfor ( var i = 1; i < lastIndex; ++ i ) {\n\n\t\t\t\tvar keep = false;\n\n\t\t\t\tvar time = times[ i ];\n\t\t\t\tvar timeNext = times[ i + 1 ];\n\n\t\t\t\t// remove adjacent keyframes scheduled at the same time\n\n\t\t\t\tif ( time !== timeNext && ( i !== 1 || time !== time[ 0 ] ) ) {\n\n\t\t\t\t\tif ( ! smoothInterpolation ) {\n\n\t\t\t\t\t\t// remove unnecessary keyframes same as their neighbors\n\n\t\t\t\t\t\tvar offset = i * stride,\n\t\t\t\t\t\t\toffsetP = offset - stride,\n\t\t\t\t\t\t\toffsetN = offset + stride;\n\n\t\t\t\t\t\tfor ( var j = 0; j !== stride; ++ j ) {\n\n\t\t\t\t\t\t\tvar value = values[ offset + j ];\n\n\t\t\t\t\t\t\tif ( value !== values[ offsetP + j ] ||\n\t\t\t\t\t\t\t\tvalue !== values[ offsetN + j ] ) {\n\n\t\t\t\t\t\t\t\tkeep = true;\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tkeep = true;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\t// in-place compaction\n\n\t\t\t\tif ( keep ) {\n\n\t\t\t\t\tif ( i !== writeIndex ) {\n\n\t\t\t\t\t\ttimes[ writeIndex ] = times[ i ];\n\n\t\t\t\t\t\tvar readOffset = i * stride,\n\t\t\t\t\t\t\twriteOffset = writeIndex * stride;\n\n\t\t\t\t\t\tfor ( var j = 0; j !== stride; ++ j ) {\n\n\t\t\t\t\t\t\tvalues[ writeOffset + j ] = values[ readOffset + j ];\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\t++ writeIndex;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// flush last keyframe (compaction looks ahead)\n\n\t\t\tif ( lastIndex > 0 ) {\n\n\t\t\t\ttimes[ writeIndex ] = times[ lastIndex ];\n\n\t\t\t\tfor ( var readOffset = lastIndex * stride, writeOffset = writeIndex * stride, j = 0; j !== stride; ++ j ) {\n\n\t\t\t\t\tvalues[ writeOffset + j ] = values[ readOffset + j ];\n\n\t\t\t\t}\n\n\t\t\t\t++ writeIndex;\n\n\t\t\t}\n\n\t\t\tif ( writeIndex !== times.length ) {\n\n\t\t\t\tthis.times = AnimationUtils.arraySlice( times, 0, writeIndex );\n\t\t\t\tthis.values = AnimationUtils.arraySlice( values, 0, writeIndex * stride );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t *\n\t * A Track of Boolean keyframe values.\n\t *\n\t *\n\t * @author Ben Houston / http://clara.io/\n\t * @author David Sarno / http://lighthaus.us/\n\t * @author tschw\n\t */\n\n\tfunction BooleanKeyframeTrack( name, times, values ) {\n\n\t\tKeyframeTrack.call( this, name, times, values );\n\n\t}\n\n\tBooleanKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrack.prototype ), {\n\n\t\tconstructor: BooleanKeyframeTrack,\n\n\t\tValueTypeName: 'bool',\n\t\tValueBufferType: Array,\n\n\t\tDefaultInterpolation: InterpolateDiscrete,\n\n\t\tInterpolantFactoryMethodLinear: undefined,\n\t\tInterpolantFactoryMethodSmooth: undefined\n\n\t\t// Note: Actually this track could have a optimized / compressed\n\t\t// representation of a single value and a custom interpolant that\n\t\t// computes \"firstValue ^ isOdd( index )\".\n\n\t} );\n\n\t/**\n\t *\n\t * A Track of keyframe values that represent color.\n\t *\n\t *\n\t * @author Ben Houston / http://clara.io/\n\t * @author David Sarno / http://lighthaus.us/\n\t * @author tschw\n\t */\n\n\tfunction ColorKeyframeTrack( name, times, values, interpolation ) {\n\n\t\tKeyframeTrack.call( this, name, times, values, interpolation );\n\n\t}\n\n\tColorKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrack.prototype ), {\n\n\t\tconstructor: ColorKeyframeTrack,\n\n\t\tValueTypeName: 'color'\n\n\t\t// ValueBufferType is inherited\n\n\t\t// DefaultInterpolation is inherited\n\n\t\t// Note: Very basic implementation and nothing special yet.\n\t\t// However, this is the place for color space parameterization.\n\n\t} );\n\n\t/**\n\t *\n\t * A Track of numeric keyframe values.\n\t *\n\t * @author Ben Houston / http://clara.io/\n\t * @author David Sarno / http://lighthaus.us/\n\t * @author tschw\n\t */\n\n\tfunction NumberKeyframeTrack( name, times, values, interpolation ) {\n\n\t\tKeyframeTrack.call( this, name, times, values, interpolation );\n\n\t}\n\n\tNumberKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrack.prototype ), {\n\n\t\tconstructor: NumberKeyframeTrack,\n\n\t\tValueTypeName: 'number'\n\n\t\t// ValueBufferType is inherited\n\n\t\t// DefaultInterpolation is inherited\n\n\t} );\n\n\t/**\n\t * Spherical linear unit quaternion interpolant.\n\t *\n\t * @author tschw\n\t */\n\n\tfunction QuaternionLinearInterpolant( parameterPositions, sampleValues, sampleSize, resultBuffer ) {\n\n\t\tInterpolant.call( this, parameterPositions, sampleValues, sampleSize, resultBuffer );\n\n\t}\n\n\tQuaternionLinearInterpolant.prototype = Object.assign( Object.create( Interpolant.prototype ), {\n\n\t\tconstructor: QuaternionLinearInterpolant,\n\n\t\tinterpolate_: function ( i1, t0, t, t1 ) {\n\n\t\t\tvar result = this.resultBuffer,\n\t\t\t\tvalues = this.sampleValues,\n\t\t\t\tstride = this.valueSize,\n\n\t\t\t\toffset = i1 * stride,\n\n\t\t\t\talpha = ( t - t0 ) / ( t1 - t0 );\n\n\t\t\tfor ( var end = offset + stride; offset !== end; offset += 4 ) {\n\n\t\t\t\tQuaternion.slerpFlat( result, 0, values, offset - stride, values, offset, alpha );\n\n\t\t\t}\n\n\t\t\treturn result;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t *\n\t * A Track of quaternion keyframe values.\n\t *\n\t * @author Ben Houston / http://clara.io/\n\t * @author David Sarno / http://lighthaus.us/\n\t * @author tschw\n\t */\n\n\tfunction QuaternionKeyframeTrack( name, times, values, interpolation ) {\n\n\t\tKeyframeTrack.call( this, name, times, values, interpolation );\n\n\t}\n\n\tQuaternionKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrack.prototype ), {\n\n\t\tconstructor: QuaternionKeyframeTrack,\n\n\t\tValueTypeName: 'quaternion',\n\n\t\t// ValueBufferType is inherited\n\n\t\tDefaultInterpolation: InterpolateLinear,\n\n\t\tInterpolantFactoryMethodLinear: function ( result ) {\n\n\t\t\treturn new QuaternionLinearInterpolant( this.times, this.values, this.getValueSize(), result );\n\n\t\t},\n\n\t\tInterpolantFactoryMethodSmooth: undefined // not yet implemented\n\n\t} );\n\n\t/**\n\t *\n\t * A Track that interpolates Strings\n\t *\n\t *\n\t * @author Ben Houston / http://clara.io/\n\t * @author David Sarno / http://lighthaus.us/\n\t * @author tschw\n\t */\n\n\tfunction StringKeyframeTrack( name, times, values, interpolation ) {\n\n\t\tKeyframeTrack.call( this, name, times, values, interpolation );\n\n\t}\n\n\tStringKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrack.prototype ), {\n\n\t\tconstructor: StringKeyframeTrack,\n\n\t\tValueTypeName: 'string',\n\t\tValueBufferType: Array,\n\n\t\tDefaultInterpolation: InterpolateDiscrete,\n\n\t\tInterpolantFactoryMethodLinear: undefined,\n\n\t\tInterpolantFactoryMethodSmooth: undefined\n\n\t} );\n\n\t/**\n\t *\n\t * A Track of vectored keyframe values.\n\t *\n\t *\n\t * @author Ben Houston / http://clara.io/\n\t * @author David Sarno / http://lighthaus.us/\n\t * @author tschw\n\t */\n\n\tfunction VectorKeyframeTrack( name, times, values, interpolation ) {\n\n\t\tKeyframeTrack.call( this, name, times, values, interpolation );\n\n\t}\n\n\tVectorKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrack.prototype ), {\n\n\t\tconstructor: VectorKeyframeTrack,\n\n\t\tValueTypeName: 'vector'\n\n\t\t// ValueBufferType is inherited\n\n\t\t// DefaultInterpolation is inherited\n\n\t} );\n\n\t/**\n\t *\n\t * Reusable set of Tracks that represent an animation.\n\t *\n\t * @author Ben Houston / http://clara.io/\n\t * @author David Sarno / http://lighthaus.us/\n\t */\n\n\tfunction AnimationClip( name, duration, tracks ) {\n\n\t\tthis.name = name;\n\t\tthis.tracks = tracks;\n\t\tthis.duration = ( duration !== undefined ) ? duration : - 1;\n\n\t\tthis.uuid = _Math.generateUUID();\n\n\t\t// this means it should figure out its duration by scanning the tracks\n\t\tif ( this.duration < 0 ) {\n\n\t\t\tthis.resetDuration();\n\n\t\t}\n\n\t}\n\n\tfunction getTrackTypeForValueTypeName( typeName ) {\n\n\t\tswitch ( typeName.toLowerCase() ) {\n\n\t\t\tcase 'scalar':\n\t\t\tcase 'double':\n\t\t\tcase 'float':\n\t\t\tcase 'number':\n\t\t\tcase 'integer':\n\n\t\t\t\treturn NumberKeyframeTrack;\n\n\t\t\tcase 'vector':\n\t\t\tcase 'vector2':\n\t\t\tcase 'vector3':\n\t\t\tcase 'vector4':\n\n\t\t\t\treturn VectorKeyframeTrack;\n\n\t\t\tcase 'color':\n\n\t\t\t\treturn ColorKeyframeTrack;\n\n\t\t\tcase 'quaternion':\n\n\t\t\t\treturn QuaternionKeyframeTrack;\n\n\t\t\tcase 'bool':\n\t\t\tcase 'boolean':\n\n\t\t\t\treturn BooleanKeyframeTrack;\n\n\t\t\tcase 'string':\n\n\t\t\t\treturn StringKeyframeTrack;\n\n\t\t}\n\n\t\tthrow new Error( 'THREE.KeyframeTrack: Unsupported typeName: ' + typeName );\n\n\t}\n\n\tfunction parseKeyframeTrack( json ) {\n\n\t\tif ( json.type === undefined ) {\n\n\t\t\tthrow new Error( 'THREE.KeyframeTrack: track type undefined, can not parse' );\n\n\t\t}\n\n\t\tvar trackType = getTrackTypeForValueTypeName( json.type );\n\n\t\tif ( json.times === undefined ) {\n\n\t\t\tvar times = [], values = [];\n\n\t\t\tAnimationUtils.flattenJSON( json.keys, times, values, 'value' );\n\n\t\t\tjson.times = times;\n\t\t\tjson.values = values;\n\n\t\t}\n\n\t\t// derived classes can define a static parse method\n\t\tif ( trackType.parse !== undefined ) {\n\n\t\t\treturn trackType.parse( json );\n\n\t\t} else {\n\n\t\t\t// by default, we assume a constructor compatible with the base\n\t\t\treturn new trackType( json.name, json.times, json.values, json.interpolation );\n\n\t\t}\n\n\t}\n\n\tObject.assign( AnimationClip, {\n\n\t\tparse: function ( json ) {\n\n\t\t\tvar tracks = [],\n\t\t\t\tjsonTracks = json.tracks,\n\t\t\t\tframeTime = 1.0 / ( json.fps || 1.0 );\n\n\t\t\tfor ( var i = 0, n = jsonTracks.length; i !== n; ++ i ) {\n\n\t\t\t\ttracks.push( parseKeyframeTrack( jsonTracks[ i ] ).scale( frameTime ) );\n\n\t\t\t}\n\n\t\t\treturn new AnimationClip( json.name, json.duration, tracks );\n\n\t\t},\n\n\t\ttoJSON: function ( clip ) {\n\n\t\t\tvar tracks = [],\n\t\t\t\tclipTracks = clip.tracks;\n\n\t\t\tvar json = {\n\n\t\t\t\t'name': clip.name,\n\t\t\t\t'duration': clip.duration,\n\t\t\t\t'tracks': tracks,\n\t\t\t\t'uuid': clip.uuid\n\n\t\t\t};\n\n\t\t\tfor ( var i = 0, n = clipTracks.length; i !== n; ++ i ) {\n\n\t\t\t\ttracks.push( KeyframeTrack.toJSON( clipTracks[ i ] ) );\n\n\t\t\t}\n\n\t\t\treturn json;\n\n\t\t},\n\n\t\tCreateFromMorphTargetSequence: function ( name, morphTargetSequence, fps, noLoop ) {\n\n\t\t\tvar numMorphTargets = morphTargetSequence.length;\n\t\t\tvar tracks = [];\n\n\t\t\tfor ( var i = 0; i < numMorphTargets; i ++ ) {\n\n\t\t\t\tvar times = [];\n\t\t\t\tvar values = [];\n\n\t\t\t\ttimes.push(\n\t\t\t\t\t( i + numMorphTargets - 1 ) % numMorphTargets,\n\t\t\t\t\ti,\n\t\t\t\t\t( i + 1 ) % numMorphTargets );\n\n\t\t\t\tvalues.push( 0, 1, 0 );\n\n\t\t\t\tvar order = AnimationUtils.getKeyframeOrder( times );\n\t\t\t\ttimes = AnimationUtils.sortedArray( times, 1, order );\n\t\t\t\tvalues = AnimationUtils.sortedArray( values, 1, order );\n\n\t\t\t\t// if there is a key at the first frame, duplicate it as the\n\t\t\t\t// last frame as well for perfect loop.\n\t\t\t\tif ( ! noLoop && times[ 0 ] === 0 ) {\n\n\t\t\t\t\ttimes.push( numMorphTargets );\n\t\t\t\t\tvalues.push( values[ 0 ] );\n\n\t\t\t\t}\n\n\t\t\t\ttracks.push(\n\t\t\t\t\tnew NumberKeyframeTrack(\n\t\t\t\t\t\t'.morphTargetInfluences[' + morphTargetSequence[ i ].name + ']',\n\t\t\t\t\t\ttimes, values\n\t\t\t\t\t).scale( 1.0 / fps ) );\n\n\t\t\t}\n\n\t\t\treturn new AnimationClip( name, - 1, tracks );\n\n\t\t},\n\n\t\tfindByName: function ( objectOrClipArray, name ) {\n\n\t\t\tvar clipArray = objectOrClipArray;\n\n\t\t\tif ( ! Array.isArray( objectOrClipArray ) ) {\n\n\t\t\t\tvar o = objectOrClipArray;\n\t\t\t\tclipArray = o.geometry && o.geometry.animations || o.animations;\n\n\t\t\t}\n\n\t\t\tfor ( var i = 0; i < clipArray.length; i ++ ) {\n\n\t\t\t\tif ( clipArray[ i ].name === name ) {\n\n\t\t\t\t\treturn clipArray[ i ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn null;\n\n\t\t},\n\n\t\tCreateClipsFromMorphTargetSequences: function ( morphTargets, fps, noLoop ) {\n\n\t\t\tvar animationToMorphTargets = {};\n\n\t\t\t// tested with https://regex101.com/ on trick sequences\n\t\t\t// such flamingo_flyA_003, flamingo_run1_003, crdeath0059\n\t\t\tvar pattern = /^([\\w-]*?)([\\d]+)$/;\n\n\t\t\t// sort morph target names into animation groups based\n\t\t\t// patterns like Walk_001, Walk_002, Run_001, Run_002\n\t\t\tfor ( var i = 0, il = morphTargets.length; i < il; i ++ ) {\n\n\t\t\t\tvar morphTarget = morphTargets[ i ];\n\t\t\t\tvar parts = morphTarget.name.match( pattern );\n\n\t\t\t\tif ( parts && parts.length > 1 ) {\n\n\t\t\t\t\tvar name = parts[ 1 ];\n\n\t\t\t\t\tvar animationMorphTargets = animationToMorphTargets[ name ];\n\t\t\t\t\tif ( ! animationMorphTargets ) {\n\n\t\t\t\t\t\tanimationToMorphTargets[ name ] = animationMorphTargets = [];\n\n\t\t\t\t\t}\n\n\t\t\t\t\tanimationMorphTargets.push( morphTarget );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tvar clips = [];\n\n\t\t\tfor ( var name in animationToMorphTargets ) {\n\n\t\t\t\tclips.push( AnimationClip.CreateFromMorphTargetSequence( name, animationToMorphTargets[ name ], fps, noLoop ) );\n\n\t\t\t}\n\n\t\t\treturn clips;\n\n\t\t},\n\n\t\t// parse the animation.hierarchy format\n\t\tparseAnimation: function ( animation, bones ) {\n\n\t\t\tif ( ! animation ) {\n\n\t\t\t\tconsole.error( 'THREE.AnimationClip: No animation in JSONLoader data.' );\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t\tvar addNonemptyTrack = function ( trackType, trackName, animationKeys, propertyName, destTracks ) {\n\n\t\t\t\t// only return track if there are actually keys.\n\t\t\t\tif ( animationKeys.length !== 0 ) {\n\n\t\t\t\t\tvar times = [];\n\t\t\t\t\tvar values = [];\n\n\t\t\t\t\tAnimationUtils.flattenJSON( animationKeys, times, values, propertyName );\n\n\t\t\t\t\t// empty keys are filtered out, so check again\n\t\t\t\t\tif ( times.length !== 0 ) {\n\n\t\t\t\t\t\tdestTracks.push( new trackType( trackName, times, values ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t\tvar tracks = [];\n\n\t\t\tvar clipName = animation.name || 'default';\n\t\t\t// automatic length determination in AnimationClip.\n\t\t\tvar duration = animation.length || - 1;\n\t\t\tvar fps = animation.fps || 30;\n\n\t\t\tvar hierarchyTracks = animation.hierarchy || [];\n\n\t\t\tfor ( var h = 0; h < hierarchyTracks.length; h ++ ) {\n\n\t\t\t\tvar animationKeys = hierarchyTracks[ h ].keys;\n\n\t\t\t\t// skip empty tracks\n\t\t\t\tif ( ! animationKeys || animationKeys.length === 0 ) continue;\n\n\t\t\t\t// process morph targets\n\t\t\t\tif ( animationKeys[ 0 ].morphTargets ) {\n\n\t\t\t\t\t// figure out all morph targets used in this track\n\t\t\t\t\tvar morphTargetNames = {};\n\n\t\t\t\t\tfor ( var k = 0; k < animationKeys.length; k ++ ) {\n\n\t\t\t\t\t\tif ( animationKeys[ k ].morphTargets ) {\n\n\t\t\t\t\t\t\tfor ( var m = 0; m < animationKeys[ k ].morphTargets.length; m ++ ) {\n\n\t\t\t\t\t\t\t\tmorphTargetNames[ animationKeys[ k ].morphTargets[ m ] ] = - 1;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// create a track for each morph target with all zero\n\t\t\t\t\t// morphTargetInfluences except for the keys in which\n\t\t\t\t\t// the morphTarget is named.\n\t\t\t\t\tfor ( var morphTargetName in morphTargetNames ) {\n\n\t\t\t\t\t\tvar times = [];\n\t\t\t\t\t\tvar values = [];\n\n\t\t\t\t\t\tfor ( var m = 0; m !== animationKeys[ k ].morphTargets.length; ++ m ) {\n\n\t\t\t\t\t\t\tvar animationKey = animationKeys[ k ];\n\n\t\t\t\t\t\t\ttimes.push( animationKey.time );\n\t\t\t\t\t\t\tvalues.push( ( animationKey.morphTarget === morphTargetName ) ? 1 : 0 );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttracks.push( new NumberKeyframeTrack( '.morphTargetInfluence[' + morphTargetName + ']', times, values ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tduration = morphTargetNames.length * ( fps || 1.0 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// ...assume skeletal animation\n\n\t\t\t\t\tvar boneName = '.bones[' + bones[ h ].name + ']';\n\n\t\t\t\t\taddNonemptyTrack(\n\t\t\t\t\t\tVectorKeyframeTrack, boneName + '.position',\n\t\t\t\t\t\tanimationKeys, 'pos', tracks );\n\n\t\t\t\t\taddNonemptyTrack(\n\t\t\t\t\t\tQuaternionKeyframeTrack, boneName + '.quaternion',\n\t\t\t\t\t\tanimationKeys, 'rot', tracks );\n\n\t\t\t\t\taddNonemptyTrack(\n\t\t\t\t\t\tVectorKeyframeTrack, boneName + '.scale',\n\t\t\t\t\t\tanimationKeys, 'scl', tracks );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( tracks.length === 0 ) {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t\tvar clip = new AnimationClip( clipName, duration, tracks );\n\n\t\t\treturn clip;\n\n\t\t}\n\n\t} );\n\n\tObject.assign( AnimationClip.prototype, {\n\n\t\tresetDuration: function () {\n\n\t\t\tvar tracks = this.tracks, duration = 0;\n\n\t\t\tfor ( var i = 0, n = tracks.length; i !== n; ++ i ) {\n\n\t\t\t\tvar track = this.tracks[ i ];\n\n\t\t\t\tduration = Math.max( duration, track.times[ track.times.length - 1 ] );\n\n\t\t\t}\n\n\t\t\tthis.duration = duration;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttrim: function () {\n\n\t\t\tfor ( var i = 0; i < this.tracks.length; i ++ ) {\n\n\t\t\t\tthis.tracks[ i ].trim( 0, this.duration );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tvalidate: function () {\n\n\t\t\tvar valid = true;\n\n\t\t\tfor ( var i = 0; i < this.tracks.length; i ++ ) {\n\n\t\t\t\tvalid = valid && this.tracks[ i ].validate();\n\n\t\t\t}\n\n\t\t\treturn valid;\n\n\t\t},\n\n\t\toptimize: function () {\n\n\t\t\tfor ( var i = 0; i < this.tracks.length; i ++ ) {\n\n\t\t\t\tthis.tracks[ i ].optimize();\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tvar Cache = {\n\n\t\tenabled: false,\n\n\t\tfiles: {},\n\n\t\tadd: function ( key, file ) {\n\n\t\t\tif ( this.enabled === false ) return;\n\n\t\t\t// console.log( 'THREE.Cache', 'Adding key:', key );\n\n\t\t\tthis.files[ key ] = file;\n\n\t\t},\n\n\t\tget: function ( key ) {\n\n\t\t\tif ( this.enabled === false ) return;\n\n\t\t\t// console.log( 'THREE.Cache', 'Checking key:', key );\n\n\t\t\treturn this.files[ key ];\n\n\t\t},\n\n\t\tremove: function ( key ) {\n\n\t\t\tdelete this.files[ key ];\n\n\t\t},\n\n\t\tclear: function () {\n\n\t\t\tthis.files = {};\n\n\t\t}\n\n\t};\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction LoadingManager( onLoad, onProgress, onError ) {\n\n\t\tvar scope = this;\n\n\t\tvar isLoading = false;\n\t\tvar itemsLoaded = 0;\n\t\tvar itemsTotal = 0;\n\t\tvar urlModifier = undefined;\n\n\t\t// Refer to #5689 for the reason why we don't set .onStart\n\t\t// in the constructor\n\n\t\tthis.onStart = undefined;\n\t\tthis.onLoad = onLoad;\n\t\tthis.onProgress = onProgress;\n\t\tthis.onError = onError;\n\n\t\tthis.itemStart = function ( url ) {\n\n\t\t\titemsTotal ++;\n\n\t\t\tif ( isLoading === false ) {\n\n\t\t\t\tif ( scope.onStart !== undefined ) {\n\n\t\t\t\t\tscope.onStart( url, itemsLoaded, itemsTotal );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tisLoading = true;\n\n\t\t};\n\n\t\tthis.itemEnd = function ( url ) {\n\n\t\t\titemsLoaded ++;\n\n\t\t\tif ( scope.onProgress !== undefined ) {\n\n\t\t\t\tscope.onProgress( url, itemsLoaded, itemsTotal );\n\n\t\t\t}\n\n\t\t\tif ( itemsLoaded === itemsTotal ) {\n\n\t\t\t\tisLoading = false;\n\n\t\t\t\tif ( scope.onLoad !== undefined ) {\n\n\t\t\t\t\tscope.onLoad();\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t};\n\n\t\tthis.itemError = function ( url ) {\n\n\t\t\tif ( scope.onError !== undefined ) {\n\n\t\t\t\tscope.onError( url );\n\n\t\t\t}\n\n\t\t};\n\n\t\tthis.resolveURL = function ( url ) {\n\n\t\t\tif ( urlModifier ) {\n\n\t\t\t\treturn urlModifier( url );\n\n\t\t\t}\n\n\t\t\treturn url;\n\n\t\t};\n\n\t\tthis.setURLModifier = function ( transform ) {\n\n\t\t\turlModifier = transform;\n\t\t\treturn this;\n\n\t\t};\n\n\t}\n\n\tvar DefaultLoadingManager = new LoadingManager();\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tvar loading = {};\n\n\tfunction FileLoader( manager ) {\n\n\t\tthis.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;\n\n\t}\n\n\tObject.assign( FileLoader.prototype, {\n\n\t\tload: function ( url, onLoad, onProgress, onError ) {\n\n\t\t\tif ( url === undefined ) url = '';\n\n\t\t\tif ( this.path !== undefined ) url = this.path + url;\n\n\t\t\turl = this.manager.resolveURL( url );\n\n\t\t\tvar scope = this;\n\n\t\t\tvar cached = Cache.get( url );\n\n\t\t\tif ( cached !== undefined ) {\n\n\t\t\t\tscope.manager.itemStart( url );\n\n\t\t\t\tsetTimeout( function () {\n\n\t\t\t\t\tif ( onLoad ) onLoad( cached );\n\n\t\t\t\t\tscope.manager.itemEnd( url );\n\n\t\t\t\t}, 0 );\n\n\t\t\t\treturn cached;\n\n\t\t\t}\n\n\t\t\t// Check if request is duplicate\n\n\t\t\tif ( loading[ url ] !== undefined ) {\n\n\t\t\t\tloading[ url ].push( {\n\n\t\t\t\t\tonLoad: onLoad,\n\t\t\t\t\tonProgress: onProgress,\n\t\t\t\t\tonError: onError\n\n\t\t\t\t} );\n\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\t// Check for data: URI\n\t\t\tvar dataUriRegex = /^data:(.*?)(;base64)?,(.*)$/;\n\t\t\tvar dataUriRegexResult = url.match( dataUriRegex );\n\n\t\t\t// Safari can not handle Data URIs through XMLHttpRequest so process manually\n\t\t\tif ( dataUriRegexResult ) {\n\n\t\t\t\tvar mimeType = dataUriRegexResult[ 1 ];\n\t\t\t\tvar isBase64 = !! dataUriRegexResult[ 2 ];\n\t\t\t\tvar data = dataUriRegexResult[ 3 ];\n\n\t\t\t\tdata = decodeURIComponent( data );\n\n\t\t\t\tif ( isBase64 ) data = atob( data );\n\n\t\t\t\ttry {\n\n\t\t\t\t\tvar response;\n\t\t\t\t\tvar responseType = ( this.responseType || '' ).toLowerCase();\n\n\t\t\t\t\tswitch ( responseType ) {\n\n\t\t\t\t\t\tcase 'arraybuffer':\n\t\t\t\t\t\tcase 'blob':\n\n\t\t\t\t\t\t\tvar view = new Uint8Array( data.length );\n\n\t\t\t\t\t\t\tfor ( var i = 0; i < data.length; i ++ ) {\n\n\t\t\t\t\t\t\t\tview[ i ] = data.charCodeAt( i );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ( responseType === 'blob' ) {\n\n\t\t\t\t\t\t\t\tresponse = new Blob( [ view.buffer ], { type: mimeType } );\n\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\tresponse = view.buffer;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'document':\n\n\t\t\t\t\t\t\tvar parser = new DOMParser();\n\t\t\t\t\t\t\tresponse = parser.parseFromString( data, mimeType );\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'json':\n\n\t\t\t\t\t\t\tresponse = JSON.parse( data );\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault: // 'text' or other\n\n\t\t\t\t\t\t\tresponse = data;\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\t// Wait for next browser tick like standard XMLHttpRequest event dispatching does\n\t\t\t\t\tsetTimeout( function () {\n\n\t\t\t\t\t\tif ( onLoad ) onLoad( response );\n\n\t\t\t\t\t\tscope.manager.itemEnd( url );\n\n\t\t\t\t\t}, 0 );\n\n\t\t\t\t} catch ( error ) {\n\n\t\t\t\t\t// Wait for next browser tick like standard XMLHttpRequest event dispatching does\n\t\t\t\t\tsetTimeout( function () {\n\n\t\t\t\t\t\tif ( onError ) onError( error );\n\n\t\t\t\t\t\tscope.manager.itemError( url );\n\t\t\t\t\t\tscope.manager.itemEnd( url );\n\n\t\t\t\t\t}, 0 );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t// Initialise array for duplicate requests\n\n\t\t\t\tloading[ url ] = [];\n\n\t\t\t\tloading[ url ].push( {\n\n\t\t\t\t\tonLoad: onLoad,\n\t\t\t\t\tonProgress: onProgress,\n\t\t\t\t\tonError: onError\n\n\t\t\t\t} );\n\n\t\t\t\tvar request = new XMLHttpRequest();\n\n\t\t\t\trequest.open( 'GET', url, true );\n\n\t\t\t\trequest.addEventListener( 'load', function ( event ) {\n\n\t\t\t\t\tvar response = this.response;\n\n\t\t\t\t\tCache.add( url, response );\n\n\t\t\t\t\tvar callbacks = loading[ url ];\n\n\t\t\t\t\tdelete loading[ url ];\n\n\t\t\t\t\tif ( this.status === 200 || this.status === 0 ) {\n\n\t\t\t\t\t\t// Some browsers return HTTP Status 0 when using non-http protocol\n\t\t\t\t\t\t// e.g. 'file://' or 'data://'. Handle as success.\n\n\t\t\t\t\t\tif ( this.status === 0 ) console.warn( 'THREE.FileLoader: HTTP Status 0 received.' );\n\n\t\t\t\t\t\tfor ( var i = 0, il = callbacks.length; i < il; i ++ ) {\n\n\t\t\t\t\t\t\tvar callback = callbacks[ i ];\n\t\t\t\t\t\t\tif ( callback.onLoad ) callback.onLoad( response );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tscope.manager.itemEnd( url );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tfor ( var i = 0, il = callbacks.length; i < il; i ++ ) {\n\n\t\t\t\t\t\t\tvar callback = callbacks[ i ];\n\t\t\t\t\t\t\tif ( callback.onError ) callback.onError( event );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tscope.manager.itemError( url );\n\t\t\t\t\t\tscope.manager.itemEnd( url );\n\n\t\t\t\t\t}\n\n\t\t\t\t}, false );\n\n\t\t\t\trequest.addEventListener( 'progress', function ( event ) {\n\n\t\t\t\t\tvar callbacks = loading[ url ];\n\n\t\t\t\t\tfor ( var i = 0, il = callbacks.length; i < il; i ++ ) {\n\n\t\t\t\t\t\tvar callback = callbacks[ i ];\n\t\t\t\t\t\tif ( callback.onProgress ) callback.onProgress( event );\n\n\t\t\t\t\t}\n\n\t\t\t\t}, false );\n\n\t\t\t\trequest.addEventListener( 'error', function ( event ) {\n\n\t\t\t\t\tvar callbacks = loading[ url ];\n\n\t\t\t\t\tdelete loading[ url ];\n\n\t\t\t\t\tfor ( var i = 0, il = callbacks.length; i < il; i ++ ) {\n\n\t\t\t\t\t\tvar callback = callbacks[ i ];\n\t\t\t\t\t\tif ( callback.onError ) callback.onError( event );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tscope.manager.itemError( url );\n\t\t\t\t\tscope.manager.itemEnd( url );\n\n\t\t\t\t}, false );\n\n\t\t\t\trequest.addEventListener( 'abort', function ( event ) {\n\n\t\t\t\t\tvar callbacks = loading[ url ];\n\n\t\t\t\t\tdelete loading[ url ];\n\n\t\t\t\t\tfor ( var i = 0, il = callbacks.length; i < il; i ++ ) {\n\n\t\t\t\t\t\tvar callback = callbacks[ i ];\n\t\t\t\t\t\tif ( callback.onError ) callback.onError( event );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tscope.manager.itemError( url );\n\t\t\t\t\tscope.manager.itemEnd( url );\n\n\t\t\t\t}, false );\n\n\t\t\t\tif ( this.responseType !== undefined ) request.responseType = this.responseType;\n\t\t\t\tif ( this.withCredentials !== undefined ) request.withCredentials = this.withCredentials;\n\n\t\t\t\tif ( request.overrideMimeType ) request.overrideMimeType( this.mimeType !== undefined ? this.mimeType : 'text/plain' );\n\n\t\t\t\tfor ( var header in this.requestHeader ) {\n\n\t\t\t\t\trequest.setRequestHeader( header, this.requestHeader[ header ] );\n\n\t\t\t\t}\n\n\t\t\t\trequest.send( null );\n\n\t\t\t}\n\n\t\t\tscope.manager.itemStart( url );\n\n\t\t\treturn request;\n\n\t\t},\n\n\t\tsetPath: function ( value ) {\n\n\t\t\tthis.path = value;\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetResponseType: function ( value ) {\n\n\t\t\tthis.responseType = value;\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetWithCredentials: function ( value ) {\n\n\t\t\tthis.withCredentials = value;\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetMimeType: function ( value ) {\n\n\t\t\tthis.mimeType = value;\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetRequestHeader: function ( value ) {\n\n\t\t\tthis.requestHeader = value;\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author bhouston / http://clara.io/\n\t */\n\n\tfunction AnimationLoader( manager ) {\n\n\t\tthis.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;\n\n\t}\n\n\tObject.assign( AnimationLoader.prototype, {\n\n\t\tload: function ( url, onLoad, onProgress, onError ) {\n\n\t\t\tvar scope = this;\n\n\t\t\tvar loader = new FileLoader( scope.manager );\n\t\t\tloader.setPath( scope.path );\n\t\t\tloader.load( url, function ( text ) {\n\n\t\t\t\tonLoad( scope.parse( JSON.parse( text ) ) );\n\n\t\t\t}, onProgress, onError );\n\n\t\t},\n\n\t\tparse: function ( json, onLoad ) {\n\n\t\t\tvar animations = [];\n\n\t\t\tfor ( var i = 0; i < json.length; i ++ ) {\n\n\t\t\t\tvar clip = AnimationClip.parse( json[ i ] );\n\n\t\t\t\tanimations.push( clip );\n\n\t\t\t}\n\n\t\t\tonLoad( animations );\n\n\t\t},\n\n\t\tsetPath: function ( value ) {\n\n\t\t\tthis.path = value;\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t *\n\t * Abstract Base class to block based textures loader (dds, pvr, ...)\n\t */\n\n\tfunction CompressedTextureLoader( manager ) {\n\n\t\tthis.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;\n\n\t\t// override in sub classes\n\t\tthis._parser = null;\n\n\t}\n\n\tObject.assign( CompressedTextureLoader.prototype, {\n\n\t\tload: function ( url, onLoad, onProgress, onError ) {\n\n\t\t\tvar scope = this;\n\n\t\t\tvar images = [];\n\n\t\t\tvar texture = new CompressedTexture();\n\t\t\ttexture.image = images;\n\n\t\t\tvar loader = new FileLoader( this.manager );\n\t\t\tloader.setPath( this.path );\n\t\t\tloader.setResponseType( 'arraybuffer' );\n\n\t\t\tfunction loadTexture( i ) {\n\n\t\t\t\tloader.load( url[ i ], function ( buffer ) {\n\n\t\t\t\t\tvar texDatas = scope._parser( buffer, true );\n\n\t\t\t\t\timages[ i ] = {\n\t\t\t\t\t\twidth: texDatas.width,\n\t\t\t\t\t\theight: texDatas.height,\n\t\t\t\t\t\tformat: texDatas.format,\n\t\t\t\t\t\tmipmaps: texDatas.mipmaps\n\t\t\t\t\t};\n\n\t\t\t\t\tloaded += 1;\n\n\t\t\t\t\tif ( loaded === 6 ) {\n\n\t\t\t\t\t\tif ( texDatas.mipmapCount === 1 )\n\t\t\t\t\t\t\ttexture.minFilter = LinearFilter;\n\n\t\t\t\t\t\ttexture.format = texDatas.format;\n\t\t\t\t\t\ttexture.needsUpdate = true;\n\n\t\t\t\t\t\tif ( onLoad ) onLoad( texture );\n\n\t\t\t\t\t}\n\n\t\t\t\t}, onProgress, onError );\n\n\t\t\t}\n\n\t\t\tif ( Array.isArray( url ) ) {\n\n\t\t\t\tvar loaded = 0;\n\n\t\t\t\tfor ( var i = 0, il = url.length; i < il; ++ i ) {\n\n\t\t\t\t\tloadTexture( i );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t// compressed cubemap texture stored in a single DDS file\n\n\t\t\t\tloader.load( url, function ( buffer ) {\n\n\t\t\t\t\tvar texDatas = scope._parser( buffer, true );\n\n\t\t\t\t\tif ( texDatas.isCubemap ) {\n\n\t\t\t\t\t\tvar faces = texDatas.mipmaps.length / texDatas.mipmapCount;\n\n\t\t\t\t\t\tfor ( var f = 0; f < faces; f ++ ) {\n\n\t\t\t\t\t\t\timages[ f ] = { mipmaps: [] };\n\n\t\t\t\t\t\t\tfor ( var i = 0; i < texDatas.mipmapCount; i ++ ) {\n\n\t\t\t\t\t\t\t\timages[ f ].mipmaps.push( texDatas.mipmaps[ f * texDatas.mipmapCount + i ] );\n\t\t\t\t\t\t\t\timages[ f ].format = texDatas.format;\n\t\t\t\t\t\t\t\timages[ f ].width = texDatas.width;\n\t\t\t\t\t\t\t\timages[ f ].height = texDatas.height;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\ttexture.image.width = texDatas.width;\n\t\t\t\t\t\ttexture.image.height = texDatas.height;\n\t\t\t\t\t\ttexture.mipmaps = texDatas.mipmaps;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( texDatas.mipmapCount === 1 ) {\n\n\t\t\t\t\t\ttexture.minFilter = LinearFilter;\n\n\t\t\t\t\t}\n\n\t\t\t\t\ttexture.format = texDatas.format;\n\t\t\t\t\ttexture.needsUpdate = true;\n\n\t\t\t\t\tif ( onLoad ) onLoad( texture );\n\n\t\t\t\t}, onProgress, onError );\n\n\t\t\t}\n\n\t\t\treturn texture;\n\n\t\t},\n\n\t\tsetPath: function ( value ) {\n\n\t\t\tthis.path = value;\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author Nikos M. / https://github.com/foo123/\n\t *\n\t * Abstract Base class to load generic binary textures formats (rgbe, hdr, ...)\n\t */\n\n\tfunction DataTextureLoader( manager ) {\n\n\t\tthis.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;\n\n\t\t// override in sub classes\n\t\tthis._parser = null;\n\n\t}\n\n\tObject.assign( DataTextureLoader.prototype, {\n\n\t\tload: function ( url, onLoad, onProgress, onError ) {\n\n\t\t\tvar scope = this;\n\n\t\t\tvar texture = new DataTexture();\n\n\t\t\tvar loader = new FileLoader( this.manager );\n\t\t\tloader.setResponseType( 'arraybuffer' );\n\t\t\tloader.setPath( this.path );\n\t\t\tloader.load( url, function ( buffer ) {\n\n\t\t\t\tvar texData = scope._parser( buffer );\n\n\t\t\t\tif ( ! texData ) return;\n\n\t\t\t\tif ( texData.image !== undefined ) {\n\n\t\t\t\t\ttexture.image = texData.image;\n\n\t\t\t\t} else if ( texData.data !== undefined ) {\n\n\t\t\t\t\ttexture.image.width = texData.width;\n\t\t\t\t\ttexture.image.height = texData.height;\n\t\t\t\t\ttexture.image.data = texData.data;\n\n\t\t\t\t}\n\n\t\t\t\ttexture.wrapS = texData.wrapS !== undefined ? texData.wrapS : ClampToEdgeWrapping;\n\t\t\t\ttexture.wrapT = texData.wrapT !== undefined ? texData.wrapT : ClampToEdgeWrapping;\n\n\t\t\t\ttexture.magFilter = texData.magFilter !== undefined ? texData.magFilter : LinearFilter;\n\t\t\t\ttexture.minFilter = texData.minFilter !== undefined ? texData.minFilter : LinearMipMapLinearFilter;\n\n\t\t\t\ttexture.anisotropy = texData.anisotropy !== undefined ? texData.anisotropy : 1;\n\n\t\t\t\tif ( texData.format !== undefined ) {\n\n\t\t\t\t\ttexture.format = texData.format;\n\n\t\t\t\t}\n\t\t\t\tif ( texData.type !== undefined ) {\n\n\t\t\t\t\ttexture.type = texData.type;\n\n\t\t\t\t}\n\n\t\t\t\tif ( texData.mipmaps !== undefined ) {\n\n\t\t\t\t\ttexture.mipmaps = texData.mipmaps;\n\n\t\t\t\t}\n\n\t\t\t\tif ( texData.mipmapCount === 1 ) {\n\n\t\t\t\t\ttexture.minFilter = LinearFilter;\n\n\t\t\t\t}\n\n\t\t\t\ttexture.needsUpdate = true;\n\n\t\t\t\tif ( onLoad ) onLoad( texture, texData );\n\n\t\t\t}, onProgress, onError );\n\n\n\t\t\treturn texture;\n\n\t\t},\n\n\t\tsetPath: function ( value ) {\n\n\t\t\tthis.path = value;\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\n\tfunction ImageLoader( manager ) {\n\n\t\tthis.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;\n\n\t}\n\n\tObject.assign( ImageLoader.prototype, {\n\n\t\tcrossOrigin: 'anonymous',\n\n\t\tload: function ( url, onLoad, onProgress, onError ) {\n\n\t\t\tif ( url === undefined ) url = '';\n\n\t\t\tif ( this.path !== undefined ) url = this.path + url;\n\n\t\t\turl = this.manager.resolveURL( url );\n\n\t\t\tvar scope = this;\n\n\t\t\tvar cached = Cache.get( url );\n\n\t\t\tif ( cached !== undefined ) {\n\n\t\t\t\tscope.manager.itemStart( url );\n\n\t\t\t\tsetTimeout( function () {\n\n\t\t\t\t\tif ( onLoad ) onLoad( cached );\n\n\t\t\t\t\tscope.manager.itemEnd( url );\n\n\t\t\t\t}, 0 );\n\n\t\t\t\treturn cached;\n\n\t\t\t}\n\n\t\t\tvar image = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'img' );\n\n\t\t\tfunction onImageLoad() {\n\n\t\t\t\timage.removeEventListener( 'load', onImageLoad, false );\n\t\t\t\timage.removeEventListener( 'error', onImageError, false );\n\n\t\t\t\tCache.add( url, this );\n\n\t\t\t\tif ( onLoad ) onLoad( this );\n\n\t\t\t\tscope.manager.itemEnd( url );\n\n\t\t\t}\n\n\t\t\tfunction onImageError( event ) {\n\n\t\t\t\timage.removeEventListener( 'load', onImageLoad, false );\n\t\t\t\timage.removeEventListener( 'error', onImageError, false );\n\n\t\t\t\tif ( onError ) onError( event );\n\n\t\t\t\tscope.manager.itemError( url );\n\t\t\t\tscope.manager.itemEnd( url );\n\n\t\t\t}\n\n\t\t\timage.addEventListener( 'load', onImageLoad, false );\n\t\t\timage.addEventListener( 'error', onImageError, false );\n\n\t\t\tif ( url.substr( 0, 5 ) !== 'data:' ) {\n\n\t\t\t\tif ( this.crossOrigin !== undefined ) image.crossOrigin = this.crossOrigin;\n\n\t\t\t}\n\n\t\t\tscope.manager.itemStart( url );\n\n\t\t\timage.src = url;\n\n\t\t\treturn image;\n\n\t\t},\n\n\t\tsetCrossOrigin: function ( value ) {\n\n\t\t\tthis.crossOrigin = value;\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetPath: function ( value ) {\n\n\t\t\tthis.path = value;\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\n\tfunction CubeTextureLoader( manager ) {\n\n\t\tthis.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;\n\n\t}\n\n\tObject.assign( CubeTextureLoader.prototype, {\n\n\t\tcrossOrigin: 'anonymous',\n\n\t\tload: function ( urls, onLoad, onProgress, onError ) {\n\n\t\t\tvar texture = new CubeTexture();\n\n\t\t\tvar loader = new ImageLoader( this.manager );\n\t\t\tloader.setCrossOrigin( this.crossOrigin );\n\t\t\tloader.setPath( this.path );\n\n\t\t\tvar loaded = 0;\n\n\t\t\tfunction loadTexture( i ) {\n\n\t\t\t\tloader.load( urls[ i ], function ( image ) {\n\n\t\t\t\t\ttexture.images[ i ] = image;\n\n\t\t\t\t\tloaded ++;\n\n\t\t\t\t\tif ( loaded === 6 ) {\n\n\t\t\t\t\t\ttexture.needsUpdate = true;\n\n\t\t\t\t\t\tif ( onLoad ) onLoad( texture );\n\n\t\t\t\t\t}\n\n\t\t\t\t}, undefined, onError );\n\n\t\t\t}\n\n\t\t\tfor ( var i = 0; i < urls.length; ++ i ) {\n\n\t\t\t\tloadTexture( i );\n\n\t\t\t}\n\n\t\t\treturn texture;\n\n\t\t},\n\n\t\tsetCrossOrigin: function ( value ) {\n\n\t\t\tthis.crossOrigin = value;\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetPath: function ( value ) {\n\n\t\t\tthis.path = value;\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\n\tfunction TextureLoader( manager ) {\n\n\t\tthis.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;\n\n\t}\n\n\tObject.assign( TextureLoader.prototype, {\n\n\t\tcrossOrigin: 'anonymous',\n\n\t\tload: function ( url, onLoad, onProgress, onError ) {\n\n\t\t\tvar texture = new Texture();\n\n\t\t\tvar loader = new ImageLoader( this.manager );\n\t\t\tloader.setCrossOrigin( this.crossOrigin );\n\t\t\tloader.setPath( this.path );\n\n\t\t\tloader.load( url, function ( image ) {\n\n\t\t\t\ttexture.image = image;\n\n\t\t\t\t// JPEGs can't have an alpha channel, so memory can be saved by storing them as RGB.\n\t\t\t\tvar isJPEG = url.search( /\\.jpe?g($|\\?)/i ) > 0 || url.search( /^data\\:image\\/jpeg/ ) === 0;\n\n\t\t\t\ttexture.format = isJPEG ? RGBFormat : RGBAFormat;\n\t\t\t\ttexture.needsUpdate = true;\n\n\t\t\t\tif ( onLoad !== undefined ) {\n\n\t\t\t\t\tonLoad( texture );\n\n\t\t\t\t}\n\n\t\t\t}, onProgress, onError );\n\n\t\t\treturn texture;\n\n\t\t},\n\n\t\tsetCrossOrigin: function ( value ) {\n\n\t\t\tthis.crossOrigin = value;\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetPath: function ( value ) {\n\n\t\t\tthis.path = value;\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author zz85 / http://www.lab4games.net/zz85/blog\n\t * Extensible curve object\n\t *\n\t * Some common of curve methods:\n\t * .getPoint( t, optionalTarget ), .getTangent( t )\n\t * .getPointAt( u, optionalTarget ), .getTangentAt( u )\n\t * .getPoints(), .getSpacedPoints()\n\t * .getLength()\n\t * .updateArcLengths()\n\t *\n\t * This following curves inherit from THREE.Curve:\n\t *\n\t * -- 2D curves --\n\t * THREE.ArcCurve\n\t * THREE.CubicBezierCurve\n\t * THREE.EllipseCurve\n\t * THREE.LineCurve\n\t * THREE.QuadraticBezierCurve\n\t * THREE.SplineCurve\n\t *\n\t * -- 3D curves --\n\t * THREE.CatmullRomCurve3\n\t * THREE.CubicBezierCurve3\n\t * THREE.LineCurve3\n\t * THREE.QuadraticBezierCurve3\n\t *\n\t * A series of curves can be represented as a THREE.CurvePath.\n\t *\n\t **/\n\n\t/**************************************************************\n\t *\tAbstract Curve base class\n\t **************************************************************/\n\n\tfunction Curve() {\n\n\t\tthis.type = 'Curve';\n\n\t\tthis.arcLengthDivisions = 200;\n\n\t}\n\n\tObject.assign( Curve.prototype, {\n\n\t\t// Virtual base class method to overwrite and implement in subclasses\n\t\t//\t- t [0 .. 1]\n\n\t\tgetPoint: function ( /* t, optionalTarget */ ) {\n\n\t\t\tconsole.warn( 'THREE.Curve: .getPoint() not implemented.' );\n\t\t\treturn null;\n\n\t\t},\n\n\t\t// Get point at relative position in curve according to arc length\n\t\t// - u [0 .. 1]\n\n\t\tgetPointAt: function ( u, optionalTarget ) {\n\n\t\t\tvar t = this.getUtoTmapping( u );\n\t\t\treturn this.getPoint( t, optionalTarget );\n\n\t\t},\n\n\t\t// Get sequence of points using getPoint( t )\n\n\t\tgetPoints: function ( divisions ) {\n\n\t\t\tif ( divisions === undefined ) divisions = 5;\n\n\t\t\tvar points = [];\n\n\t\t\tfor ( var d = 0; d <= divisions; d ++ ) {\n\n\t\t\t\tpoints.push( this.getPoint( d / divisions ) );\n\n\t\t\t}\n\n\t\t\treturn points;\n\n\t\t},\n\n\t\t// Get sequence of points using getPointAt( u )\n\n\t\tgetSpacedPoints: function ( divisions ) {\n\n\t\t\tif ( divisions === undefined ) divisions = 5;\n\n\t\t\tvar points = [];\n\n\t\t\tfor ( var d = 0; d <= divisions; d ++ ) {\n\n\t\t\t\tpoints.push( this.getPointAt( d / divisions ) );\n\n\t\t\t}\n\n\t\t\treturn points;\n\n\t\t},\n\n\t\t// Get total curve arc length\n\n\t\tgetLength: function () {\n\n\t\t\tvar lengths = this.getLengths();\n\t\t\treturn lengths[ lengths.length - 1 ];\n\n\t\t},\n\n\t\t// Get list of cumulative segment lengths\n\n\t\tgetLengths: function ( divisions ) {\n\n\t\t\tif ( divisions === undefined ) divisions = this.arcLengthDivisions;\n\n\t\t\tif ( this.cacheArcLengths &&\n\t\t\t\t( this.cacheArcLengths.length === divisions + 1 ) &&\n\t\t\t\t! this.needsUpdate ) {\n\n\t\t\t\treturn this.cacheArcLengths;\n\n\t\t\t}\n\n\t\t\tthis.needsUpdate = false;\n\n\t\t\tvar cache = [];\n\t\t\tvar current, last = this.getPoint( 0 );\n\t\t\tvar p, sum = 0;\n\n\t\t\tcache.push( 0 );\n\n\t\t\tfor ( p = 1; p <= divisions; p ++ ) {\n\n\t\t\t\tcurrent = this.getPoint( p / divisions );\n\t\t\t\tsum += current.distanceTo( last );\n\t\t\t\tcache.push( sum );\n\t\t\t\tlast = current;\n\n\t\t\t}\n\n\t\t\tthis.cacheArcLengths = cache;\n\n\t\t\treturn cache; // { sums: cache, sum: sum }; Sum is in the last element.\n\n\t\t},\n\n\t\tupdateArcLengths: function () {\n\n\t\t\tthis.needsUpdate = true;\n\t\t\tthis.getLengths();\n\n\t\t},\n\n\t\t// Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant\n\n\t\tgetUtoTmapping: function ( u, distance ) {\n\n\t\t\tvar arcLengths = this.getLengths();\n\n\t\t\tvar i = 0, il = arcLengths.length;\n\n\t\t\tvar targetArcLength; // The targeted u distance value to get\n\n\t\t\tif ( distance ) {\n\n\t\t\t\ttargetArcLength = distance;\n\n\t\t\t} else {\n\n\t\t\t\ttargetArcLength = u * arcLengths[ il - 1 ];\n\n\t\t\t}\n\n\t\t\t// binary search for the index with largest value smaller than target u distance\n\n\t\t\tvar low = 0, high = il - 1, comparison;\n\n\t\t\twhile ( low <= high ) {\n\n\t\t\t\ti = Math.floor( low + ( high - low ) / 2 ); // less likely to overflow, though probably not issue here, JS doesn't really have integers, all numbers are floats\n\n\t\t\t\tcomparison = arcLengths[ i ] - targetArcLength;\n\n\t\t\t\tif ( comparison < 0 ) {\n\n\t\t\t\t\tlow = i + 1;\n\n\t\t\t\t} else if ( comparison > 0 ) {\n\n\t\t\t\t\thigh = i - 1;\n\n\t\t\t\t} else {\n\n\t\t\t\t\thigh = i;\n\t\t\t\t\tbreak;\n\n\t\t\t\t\t// DONE\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\ti = high;\n\n\t\t\tif ( arcLengths[ i ] === targetArcLength ) {\n\n\t\t\t\treturn i / ( il - 1 );\n\n\t\t\t}\n\n\t\t\t// we could get finer grain at lengths, or use simple interpolation between two points\n\n\t\t\tvar lengthBefore = arcLengths[ i ];\n\t\t\tvar lengthAfter = arcLengths[ i + 1 ];\n\n\t\t\tvar segmentLength = lengthAfter - lengthBefore;\n\n\t\t\t// determine where we are between the 'before' and 'after' points\n\n\t\t\tvar segmentFraction = ( targetArcLength - lengthBefore ) / segmentLength;\n\n\t\t\t// add that fractional amount to t\n\n\t\t\tvar t = ( i + segmentFraction ) / ( il - 1 );\n\n\t\t\treturn t;\n\n\t\t},\n\n\t\t// Returns a unit vector tangent at t\n\t\t// In case any sub curve does not implement its tangent derivation,\n\t\t// 2 points a small delta apart will be used to find its gradient\n\t\t// which seems to give a reasonable approximation\n\n\t\tgetTangent: function ( t ) {\n\n\t\t\tvar delta = 0.0001;\n\t\t\tvar t1 = t - delta;\n\t\t\tvar t2 = t + delta;\n\n\t\t\t// Capping in case of danger\n\n\t\t\tif ( t1 < 0 ) t1 = 0;\n\t\t\tif ( t2 > 1 ) t2 = 1;\n\n\t\t\tvar pt1 = this.getPoint( t1 );\n\t\t\tvar pt2 = this.getPoint( t2 );\n\n\t\t\tvar vec = pt2.clone().sub( pt1 );\n\t\t\treturn vec.normalize();\n\n\t\t},\n\n\t\tgetTangentAt: function ( u ) {\n\n\t\t\tvar t = this.getUtoTmapping( u );\n\t\t\treturn this.getTangent( t );\n\n\t\t},\n\n\t\tcomputeFrenetFrames: function ( segments, closed ) {\n\n\t\t\t// see http://www.cs.indiana.edu/pub/techreports/TR425.pdf\n\n\t\t\tvar normal = new Vector3();\n\n\t\t\tvar tangents = [];\n\t\t\tvar normals = [];\n\t\t\tvar binormals = [];\n\n\t\t\tvar vec = new Vector3();\n\t\t\tvar mat = new Matrix4();\n\n\t\t\tvar i, u, theta;\n\n\t\t\t// compute the tangent vectors for each segment on the curve\n\n\t\t\tfor ( i = 0; i <= segments; i ++ ) {\n\n\t\t\t\tu = i / segments;\n\n\t\t\t\ttangents[ i ] = this.getTangentAt( u );\n\t\t\t\ttangents[ i ].normalize();\n\n\t\t\t}\n\n\t\t\t// select an initial normal vector perpendicular to the first tangent vector,\n\t\t\t// and in the direction of the minimum tangent xyz component\n\n\t\t\tnormals[ 0 ] = new Vector3();\n\t\t\tbinormals[ 0 ] = new Vector3();\n\t\t\tvar min = Number.MAX_VALUE;\n\t\t\tvar tx = Math.abs( tangents[ 0 ].x );\n\t\t\tvar ty = Math.abs( tangents[ 0 ].y );\n\t\t\tvar tz = Math.abs( tangents[ 0 ].z );\n\n\t\t\tif ( tx <= min ) {\n\n\t\t\t\tmin = tx;\n\t\t\t\tnormal.set( 1, 0, 0 );\n\n\t\t\t}\n\n\t\t\tif ( ty <= min ) {\n\n\t\t\t\tmin = ty;\n\t\t\t\tnormal.set( 0, 1, 0 );\n\n\t\t\t}\n\n\t\t\tif ( tz <= min ) {\n\n\t\t\t\tnormal.set( 0, 0, 1 );\n\n\t\t\t}\n\n\t\t\tvec.crossVectors( tangents[ 0 ], normal ).normalize();\n\n\t\t\tnormals[ 0 ].crossVectors( tangents[ 0 ], vec );\n\t\t\tbinormals[ 0 ].crossVectors( tangents[ 0 ], normals[ 0 ] );\n\n\n\t\t\t// compute the slowly-varying normal and binormal vectors for each segment on the curve\n\n\t\t\tfor ( i = 1; i <= segments; i ++ ) {\n\n\t\t\t\tnormals[ i ] = normals[ i - 1 ].clone();\n\n\t\t\t\tbinormals[ i ] = binormals[ i - 1 ].clone();\n\n\t\t\t\tvec.crossVectors( tangents[ i - 1 ], tangents[ i ] );\n\n\t\t\t\tif ( vec.length() > Number.EPSILON ) {\n\n\t\t\t\t\tvec.normalize();\n\n\t\t\t\t\ttheta = Math.acos( _Math.clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors\n\n\t\t\t\t\tnormals[ i ].applyMatrix4( mat.makeRotationAxis( vec, theta ) );\n\n\t\t\t\t}\n\n\t\t\t\tbinormals[ i ].crossVectors( tangents[ i ], normals[ i ] );\n\n\t\t\t}\n\n\t\t\t// if the curve is closed, postprocess the vectors so the first and last normal vectors are the same\n\n\t\t\tif ( closed === true ) {\n\n\t\t\t\ttheta = Math.acos( _Math.clamp( normals[ 0 ].dot( normals[ segments ] ), - 1, 1 ) );\n\t\t\t\ttheta /= segments;\n\n\t\t\t\tif ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ segments ] ) ) > 0 ) {\n\n\t\t\t\t\ttheta = - theta;\n\n\t\t\t\t}\n\n\t\t\t\tfor ( i = 1; i <= segments; i ++ ) {\n\n\t\t\t\t\t// twist a little...\n\t\t\t\t\tnormals[ i ].applyMatrix4( mat.makeRotationAxis( tangents[ i ], theta * i ) );\n\t\t\t\t\tbinormals[ i ].crossVectors( tangents[ i ], normals[ i ] );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttangents: tangents,\n\t\t\t\tnormals: normals,\n\t\t\t\tbinormals: binormals\n\t\t\t};\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t},\n\n\t\tcopy: function ( source ) {\n\n\t\t\tthis.arcLengthDivisions = source.arcLengthDivisions;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttoJSON: function () {\n\n\t\t\tvar data = {\n\t\t\t\tmetadata: {\n\t\t\t\t\tversion: 4.5,\n\t\t\t\t\ttype: 'Curve',\n\t\t\t\t\tgenerator: 'Curve.toJSON'\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tdata.arcLengthDivisions = this.arcLengthDivisions;\n\t\t\tdata.type = this.type;\n\n\t\t\treturn data;\n\n\t\t},\n\n\t\tfromJSON: function ( json ) {\n\n\t\t\tthis.arcLengthDivisions = json.arcLengthDivisions;\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\tfunction EllipseCurve( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) {\n\n\t\tCurve.call( this );\n\n\t\tthis.type = 'EllipseCurve';\n\n\t\tthis.aX = aX || 0;\n\t\tthis.aY = aY || 0;\n\n\t\tthis.xRadius = xRadius || 1;\n\t\tthis.yRadius = yRadius || 1;\n\n\t\tthis.aStartAngle = aStartAngle || 0;\n\t\tthis.aEndAngle = aEndAngle || 2 * Math.PI;\n\n\t\tthis.aClockwise = aClockwise || false;\n\n\t\tthis.aRotation = aRotation || 0;\n\n\t}\n\n\tEllipseCurve.prototype = Object.create( Curve.prototype );\n\tEllipseCurve.prototype.constructor = EllipseCurve;\n\n\tEllipseCurve.prototype.isEllipseCurve = true;\n\n\tEllipseCurve.prototype.getPoint = function ( t, optionalTarget ) {\n\n\t\tvar point = optionalTarget || new Vector2();\n\n\t\tvar twoPi = Math.PI * 2;\n\t\tvar deltaAngle = this.aEndAngle - this.aStartAngle;\n\t\tvar samePoints = Math.abs( deltaAngle ) < Number.EPSILON;\n\n\t\t// ensures that deltaAngle is 0 .. 2 PI\n\t\twhile ( deltaAngle < 0 ) deltaAngle += twoPi;\n\t\twhile ( deltaAngle > twoPi ) deltaAngle -= twoPi;\n\n\t\tif ( deltaAngle < Number.EPSILON ) {\n\n\t\t\tif ( samePoints ) {\n\n\t\t\t\tdeltaAngle = 0;\n\n\t\t\t} else {\n\n\t\t\t\tdeltaAngle = twoPi;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.aClockwise === true && ! samePoints ) {\n\n\t\t\tif ( deltaAngle === twoPi ) {\n\n\t\t\t\tdeltaAngle = - twoPi;\n\n\t\t\t} else {\n\n\t\t\t\tdeltaAngle = deltaAngle - twoPi;\n\n\t\t\t}\n\n\t\t}\n\n\t\tvar angle = this.aStartAngle + t * deltaAngle;\n\t\tvar x = this.aX + this.xRadius * Math.cos( angle );\n\t\tvar y = this.aY + this.yRadius * Math.sin( angle );\n\n\t\tif ( this.aRotation !== 0 ) {\n\n\t\t\tvar cos = Math.cos( this.aRotation );\n\t\t\tvar sin = Math.sin( this.aRotation );\n\n\t\t\tvar tx = x - this.aX;\n\t\t\tvar ty = y - this.aY;\n\n\t\t\t// Rotate the point about the center of the ellipse.\n\t\t\tx = tx * cos - ty * sin + this.aX;\n\t\t\ty = tx * sin + ty * cos + this.aY;\n\n\t\t}\n\n\t\treturn point.set( x, y );\n\n\t};\n\n\tEllipseCurve.prototype.copy = function ( source ) {\n\n\t\tCurve.prototype.copy.call( this, source );\n\n\t\tthis.aX = source.aX;\n\t\tthis.aY = source.aY;\n\n\t\tthis.xRadius = source.xRadius;\n\t\tthis.yRadius = source.yRadius;\n\n\t\tthis.aStartAngle = source.aStartAngle;\n\t\tthis.aEndAngle = source.aEndAngle;\n\n\t\tthis.aClockwise = source.aClockwise;\n\n\t\tthis.aRotation = source.aRotation;\n\n\t\treturn this;\n\n\t};\n\n\n\tEllipseCurve.prototype.toJSON = function () {\n\n\t\tvar data = Curve.prototype.toJSON.call( this );\n\n\t\tdata.aX = this.aX;\n\t\tdata.aY = this.aY;\n\n\t\tdata.xRadius = this.xRadius;\n\t\tdata.yRadius = this.yRadius;\n\n\t\tdata.aStartAngle = this.aStartAngle;\n\t\tdata.aEndAngle = this.aEndAngle;\n\n\t\tdata.aClockwise = this.aClockwise;\n\n\t\tdata.aRotation = this.aRotation;\n\n\t\treturn data;\n\n\t};\n\n\tEllipseCurve.prototype.fromJSON = function ( json ) {\n\n\t\tCurve.prototype.fromJSON.call( this, json );\n\n\t\tthis.aX = json.aX;\n\t\tthis.aY = json.aY;\n\n\t\tthis.xRadius = json.xRadius;\n\t\tthis.yRadius = json.yRadius;\n\n\t\tthis.aStartAngle = json.aStartAngle;\n\t\tthis.aEndAngle = json.aEndAngle;\n\n\t\tthis.aClockwise = json.aClockwise;\n\n\t\tthis.aRotation = json.aRotation;\n\n\t\treturn this;\n\n\t};\n\n\tfunction ArcCurve( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) {\n\n\t\tEllipseCurve.call( this, aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise );\n\n\t\tthis.type = 'ArcCurve';\n\n\t}\n\n\tArcCurve.prototype = Object.create( EllipseCurve.prototype );\n\tArcCurve.prototype.constructor = ArcCurve;\n\n\tArcCurve.prototype.isArcCurve = true;\n\n\t/**\n\t * @author zz85 https://github.com/zz85\n\t *\n\t * Centripetal CatmullRom Curve - which is useful for avoiding\n\t * cusps and self-intersections in non-uniform catmull rom curves.\n\t * http://www.cemyuksel.com/research/catmullrom_param/catmullrom.pdf\n\t *\n\t * curve.type accepts centripetal(default), chordal and catmullrom\n\t * curve.tension is used for catmullrom which defaults to 0.5\n\t */\n\n\n\t/*\n\tBased on an optimized c++ solution in\n\t - http://stackoverflow.com/questions/9489736/catmull-rom-curve-with-no-cusps-and-no-self-intersections/\n\t - http://ideone.com/NoEbVM\n\n\tThis CubicPoly class could be used for reusing some variables and calculations,\n\tbut for three.js curve use, it could be possible inlined and flatten into a single function call\n\twhich can be placed in CurveUtils.\n\t*/\n\n\tfunction CubicPoly() {\n\n\t\tvar c0 = 0, c1 = 0, c2 = 0, c3 = 0;\n\n\t\t/*\n\t\t * Compute coefficients for a cubic polynomial\n\t\t *   p(s) = c0 + c1*s + c2*s^2 + c3*s^3\n\t\t * such that\n\t\t *   p(0) = x0, p(1) = x1\n\t\t *  and\n\t\t *   p'(0) = t0, p'(1) = t1.\n\t\t */\n\t\tfunction init( x0, x1, t0, t1 ) {\n\n\t\t\tc0 = x0;\n\t\t\tc1 = t0;\n\t\t\tc2 = - 3 * x0 + 3 * x1 - 2 * t0 - t1;\n\t\t\tc3 = 2 * x0 - 2 * x1 + t0 + t1;\n\n\t\t}\n\n\t\treturn {\n\n\t\t\tinitCatmullRom: function ( x0, x1, x2, x3, tension ) {\n\n\t\t\t\tinit( x1, x2, tension * ( x2 - x0 ), tension * ( x3 - x1 ) );\n\n\t\t\t},\n\n\t\t\tinitNonuniformCatmullRom: function ( x0, x1, x2, x3, dt0, dt1, dt2 ) {\n\n\t\t\t\t// compute tangents when parameterized in [t1,t2]\n\t\t\t\tvar t1 = ( x1 - x0 ) / dt0 - ( x2 - x0 ) / ( dt0 + dt1 ) + ( x2 - x1 ) / dt1;\n\t\t\t\tvar t2 = ( x2 - x1 ) / dt1 - ( x3 - x1 ) / ( dt1 + dt2 ) + ( x3 - x2 ) / dt2;\n\n\t\t\t\t// rescale tangents for parametrization in [0,1]\n\t\t\t\tt1 *= dt1;\n\t\t\t\tt2 *= dt1;\n\n\t\t\t\tinit( x1, x2, t1, t2 );\n\n\t\t\t},\n\n\t\t\tcalc: function ( t ) {\n\n\t\t\t\tvar t2 = t * t;\n\t\t\t\tvar t3 = t2 * t;\n\t\t\t\treturn c0 + c1 * t + c2 * t2 + c3 * t3;\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\t//\n\n\tvar tmp = new Vector3();\n\tvar px = new CubicPoly(), py = new CubicPoly(), pz = new CubicPoly();\n\n\tfunction CatmullRomCurve3( points, closed, curveType, tension ) {\n\n\t\tCurve.call( this );\n\n\t\tthis.type = 'CatmullRomCurve3';\n\n\t\tthis.points = points || [];\n\t\tthis.closed = closed || false;\n\t\tthis.curveType = curveType || 'centripetal';\n\t\tthis.tension = tension || 0.5;\n\n\t}\n\n\tCatmullRomCurve3.prototype = Object.create( Curve.prototype );\n\tCatmullRomCurve3.prototype.constructor = CatmullRomCurve3;\n\n\tCatmullRomCurve3.prototype.isCatmullRomCurve3 = true;\n\n\tCatmullRomCurve3.prototype.getPoint = function ( t, optionalTarget ) {\n\n\t\tvar point = optionalTarget || new Vector3();\n\n\t\tvar points = this.points;\n\t\tvar l = points.length;\n\n\t\tvar p = ( l - ( this.closed ? 0 : 1 ) ) * t;\n\t\tvar intPoint = Math.floor( p );\n\t\tvar weight = p - intPoint;\n\n\t\tif ( this.closed ) {\n\n\t\t\tintPoint += intPoint > 0 ? 0 : ( Math.floor( Math.abs( intPoint ) / l ) + 1 ) * l;\n\n\t\t} else if ( weight === 0 && intPoint === l - 1 ) {\n\n\t\t\tintPoint = l - 2;\n\t\t\tweight = 1;\n\n\t\t}\n\n\t\tvar p0, p1, p2, p3; // 4 points\n\n\t\tif ( this.closed || intPoint > 0 ) {\n\n\t\t\tp0 = points[ ( intPoint - 1 ) % l ];\n\n\t\t} else {\n\n\t\t\t// extrapolate first point\n\t\t\ttmp.subVectors( points[ 0 ], points[ 1 ] ).add( points[ 0 ] );\n\t\t\tp0 = tmp;\n\n\t\t}\n\n\t\tp1 = points[ intPoint % l ];\n\t\tp2 = points[ ( intPoint + 1 ) % l ];\n\n\t\tif ( this.closed || intPoint + 2 < l ) {\n\n\t\t\tp3 = points[ ( intPoint + 2 ) % l ];\n\n\t\t} else {\n\n\t\t\t// extrapolate last point\n\t\t\ttmp.subVectors( points[ l - 1 ], points[ l - 2 ] ).add( points[ l - 1 ] );\n\t\t\tp3 = tmp;\n\n\t\t}\n\n\t\tif ( this.curveType === 'centripetal' || this.curveType === 'chordal' ) {\n\n\t\t\t// init Centripetal / Chordal Catmull-Rom\n\t\t\tvar pow = this.curveType === 'chordal' ? 0.5 : 0.25;\n\t\t\tvar dt0 = Math.pow( p0.distanceToSquared( p1 ), pow );\n\t\t\tvar dt1 = Math.pow( p1.distanceToSquared( p2 ), pow );\n\t\t\tvar dt2 = Math.pow( p2.distanceToSquared( p3 ), pow );\n\n\t\t\t// safety check for repeated points\n\t\t\tif ( dt1 < 1e-4 ) dt1 = 1.0;\n\t\t\tif ( dt0 < 1e-4 ) dt0 = dt1;\n\t\t\tif ( dt2 < 1e-4 ) dt2 = dt1;\n\n\t\t\tpx.initNonuniformCatmullRom( p0.x, p1.x, p2.x, p3.x, dt0, dt1, dt2 );\n\t\t\tpy.initNonuniformCatmullRom( p0.y, p1.y, p2.y, p3.y, dt0, dt1, dt2 );\n\t\t\tpz.initNonuniformCatmullRom( p0.z, p1.z, p2.z, p3.z, dt0, dt1, dt2 );\n\n\t\t} else if ( this.curveType === 'catmullrom' ) {\n\n\t\t\tpx.initCatmullRom( p0.x, p1.x, p2.x, p3.x, this.tension );\n\t\t\tpy.initCatmullRom( p0.y, p1.y, p2.y, p3.y, this.tension );\n\t\t\tpz.initCatmullRom( p0.z, p1.z, p2.z, p3.z, this.tension );\n\n\t\t}\n\n\t\tpoint.set(\n\t\t\tpx.calc( weight ),\n\t\t\tpy.calc( weight ),\n\t\t\tpz.calc( weight )\n\t\t);\n\n\t\treturn point;\n\n\t};\n\n\tCatmullRomCurve3.prototype.copy = function ( source ) {\n\n\t\tCurve.prototype.copy.call( this, source );\n\n\t\tthis.points = [];\n\n\t\tfor ( var i = 0, l = source.points.length; i < l; i ++ ) {\n\n\t\t\tvar point = source.points[ i ];\n\n\t\t\tthis.points.push( point.clone() );\n\n\t\t}\n\n\t\tthis.closed = source.closed;\n\t\tthis.curveType = source.curveType;\n\t\tthis.tension = source.tension;\n\n\t\treturn this;\n\n\t};\n\n\tCatmullRomCurve3.prototype.toJSON = function () {\n\n\t\tvar data = Curve.prototype.toJSON.call( this );\n\n\t\tdata.points = [];\n\n\t\tfor ( var i = 0, l = this.points.length; i < l; i ++ ) {\n\n\t\t\tvar point = this.points[ i ];\n\t\t\tdata.points.push( point.toArray() );\n\n\t\t}\n\n\t\tdata.closed = this.closed;\n\t\tdata.curveType = this.curveType;\n\t\tdata.tension = this.tension;\n\n\t\treturn data;\n\n\t};\n\n\tCatmullRomCurve3.prototype.fromJSON = function ( json ) {\n\n\t\tCurve.prototype.fromJSON.call( this, json );\n\n\t\tthis.points = [];\n\n\t\tfor ( var i = 0, l = json.points.length; i < l; i ++ ) {\n\n\t\t\tvar point = json.points[ i ];\n\t\t\tthis.points.push( new Vector3().fromArray( point ) );\n\n\t\t}\n\n\t\tthis.closed = json.closed;\n\t\tthis.curveType = json.curveType;\n\t\tthis.tension = json.tension;\n\n\t\treturn this;\n\n\t};\n\n\t/**\n\t * @author zz85 / http://www.lab4games.net/zz85/blog\n\t *\n\t * Bezier Curves formulas obtained from\n\t * http://en.wikipedia.org/wiki/Bézier_curve\n\t */\n\n\tfunction CatmullRom( t, p0, p1, p2, p3 ) {\n\n\t\tvar v0 = ( p2 - p0 ) * 0.5;\n\t\tvar v1 = ( p3 - p1 ) * 0.5;\n\t\tvar t2 = t * t;\n\t\tvar t3 = t * t2;\n\t\treturn ( 2 * p1 - 2 * p2 + v0 + v1 ) * t3 + ( - 3 * p1 + 3 * p2 - 2 * v0 - v1 ) * t2 + v0 * t + p1;\n\n\t}\n\n\t//\n\n\tfunction QuadraticBezierP0( t, p ) {\n\n\t\tvar k = 1 - t;\n\t\treturn k * k * p;\n\n\t}\n\n\tfunction QuadraticBezierP1( t, p ) {\n\n\t\treturn 2 * ( 1 - t ) * t * p;\n\n\t}\n\n\tfunction QuadraticBezierP2( t, p ) {\n\n\t\treturn t * t * p;\n\n\t}\n\n\tfunction QuadraticBezier( t, p0, p1, p2 ) {\n\n\t\treturn QuadraticBezierP0( t, p0 ) + QuadraticBezierP1( t, p1 ) +\n\t\t\tQuadraticBezierP2( t, p2 );\n\n\t}\n\n\t//\n\n\tfunction CubicBezierP0( t, p ) {\n\n\t\tvar k = 1 - t;\n\t\treturn k * k * k * p;\n\n\t}\n\n\tfunction CubicBezierP1( t, p ) {\n\n\t\tvar k = 1 - t;\n\t\treturn 3 * k * k * t * p;\n\n\t}\n\n\tfunction CubicBezierP2( t, p ) {\n\n\t\treturn 3 * ( 1 - t ) * t * t * p;\n\n\t}\n\n\tfunction CubicBezierP3( t, p ) {\n\n\t\treturn t * t * t * p;\n\n\t}\n\n\tfunction CubicBezier( t, p0, p1, p2, p3 ) {\n\n\t\treturn CubicBezierP0( t, p0 ) + CubicBezierP1( t, p1 ) + CubicBezierP2( t, p2 ) +\n\t\t\tCubicBezierP3( t, p3 );\n\n\t}\n\n\tfunction CubicBezierCurve( v0, v1, v2, v3 ) {\n\n\t\tCurve.call( this );\n\n\t\tthis.type = 'CubicBezierCurve';\n\n\t\tthis.v0 = v0 || new Vector2();\n\t\tthis.v1 = v1 || new Vector2();\n\t\tthis.v2 = v2 || new Vector2();\n\t\tthis.v3 = v3 || new Vector2();\n\n\t}\n\n\tCubicBezierCurve.prototype = Object.create( Curve.prototype );\n\tCubicBezierCurve.prototype.constructor = CubicBezierCurve;\n\n\tCubicBezierCurve.prototype.isCubicBezierCurve = true;\n\n\tCubicBezierCurve.prototype.getPoint = function ( t, optionalTarget ) {\n\n\t\tvar point = optionalTarget || new Vector2();\n\n\t\tvar v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3;\n\n\t\tpoint.set(\n\t\t\tCubicBezier( t, v0.x, v1.x, v2.x, v3.x ),\n\t\t\tCubicBezier( t, v0.y, v1.y, v2.y, v3.y )\n\t\t);\n\n\t\treturn point;\n\n\t};\n\n\tCubicBezierCurve.prototype.copy = function ( source ) {\n\n\t\tCurve.prototype.copy.call( this, source );\n\n\t\tthis.v0.copy( source.v0 );\n\t\tthis.v1.copy( source.v1 );\n\t\tthis.v2.copy( source.v2 );\n\t\tthis.v3.copy( source.v3 );\n\n\t\treturn this;\n\n\t};\n\n\tCubicBezierCurve.prototype.toJSON = function () {\n\n\t\tvar data = Curve.prototype.toJSON.call( this );\n\n\t\tdata.v0 = this.v0.toArray();\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\t\tdata.v3 = this.v3.toArray();\n\n\t\treturn data;\n\n\t};\n\n\tCubicBezierCurve.prototype.fromJSON = function ( json ) {\n\n\t\tCurve.prototype.fromJSON.call( this, json );\n\n\t\tthis.v0.fromArray( json.v0 );\n\t\tthis.v1.fromArray( json.v1 );\n\t\tthis.v2.fromArray( json.v2 );\n\t\tthis.v3.fromArray( json.v3 );\n\n\t\treturn this;\n\n\t};\n\n\tfunction CubicBezierCurve3( v0, v1, v2, v3 ) {\n\n\t\tCurve.call( this );\n\n\t\tthis.type = 'CubicBezierCurve3';\n\n\t\tthis.v0 = v0 || new Vector3();\n\t\tthis.v1 = v1 || new Vector3();\n\t\tthis.v2 = v2 || new Vector3();\n\t\tthis.v3 = v3 || new Vector3();\n\n\t}\n\n\tCubicBezierCurve3.prototype = Object.create( Curve.prototype );\n\tCubicBezierCurve3.prototype.constructor = CubicBezierCurve3;\n\n\tCubicBezierCurve3.prototype.isCubicBezierCurve3 = true;\n\n\tCubicBezierCurve3.prototype.getPoint = function ( t, optionalTarget ) {\n\n\t\tvar point = optionalTarget || new Vector3();\n\n\t\tvar v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3;\n\n\t\tpoint.set(\n\t\t\tCubicBezier( t, v0.x, v1.x, v2.x, v3.x ),\n\t\t\tCubicBezier( t, v0.y, v1.y, v2.y, v3.y ),\n\t\t\tCubicBezier( t, v0.z, v1.z, v2.z, v3.z )\n\t\t);\n\n\t\treturn point;\n\n\t};\n\n\tCubicBezierCurve3.prototype.copy = function ( source ) {\n\n\t\tCurve.prototype.copy.call( this, source );\n\n\t\tthis.v0.copy( source.v0 );\n\t\tthis.v1.copy( source.v1 );\n\t\tthis.v2.copy( source.v2 );\n\t\tthis.v3.copy( source.v3 );\n\n\t\treturn this;\n\n\t};\n\n\tCubicBezierCurve3.prototype.toJSON = function () {\n\n\t\tvar data = Curve.prototype.toJSON.call( this );\n\n\t\tdata.v0 = this.v0.toArray();\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\t\tdata.v3 = this.v3.toArray();\n\n\t\treturn data;\n\n\t};\n\n\tCubicBezierCurve3.prototype.fromJSON = function ( json ) {\n\n\t\tCurve.prototype.fromJSON.call( this, json );\n\n\t\tthis.v0.fromArray( json.v0 );\n\t\tthis.v1.fromArray( json.v1 );\n\t\tthis.v2.fromArray( json.v2 );\n\t\tthis.v3.fromArray( json.v3 );\n\n\t\treturn this;\n\n\t};\n\n\tfunction LineCurve( v1, v2 ) {\n\n\t\tCurve.call( this );\n\n\t\tthis.type = 'LineCurve';\n\n\t\tthis.v1 = v1 || new Vector2();\n\t\tthis.v2 = v2 || new Vector2();\n\n\t}\n\n\tLineCurve.prototype = Object.create( Curve.prototype );\n\tLineCurve.prototype.constructor = LineCurve;\n\n\tLineCurve.prototype.isLineCurve = true;\n\n\tLineCurve.prototype.getPoint = function ( t, optionalTarget ) {\n\n\t\tvar point = optionalTarget || new Vector2();\n\n\t\tif ( t === 1 ) {\n\n\t\t\tpoint.copy( this.v2 );\n\n\t\t} else {\n\n\t\t\tpoint.copy( this.v2 ).sub( this.v1 );\n\t\t\tpoint.multiplyScalar( t ).add( this.v1 );\n\n\t\t}\n\n\t\treturn point;\n\n\t};\n\n\t// Line curve is linear, so we can overwrite default getPointAt\n\n\tLineCurve.prototype.getPointAt = function ( u, optionalTarget ) {\n\n\t\treturn this.getPoint( u, optionalTarget );\n\n\t};\n\n\tLineCurve.prototype.getTangent = function ( /* t */ ) {\n\n\t\tvar tangent = this.v2.clone().sub( this.v1 );\n\n\t\treturn tangent.normalize();\n\n\t};\n\n\tLineCurve.prototype.copy = function ( source ) {\n\n\t\tCurve.prototype.copy.call( this, source );\n\n\t\tthis.v1.copy( source.v1 );\n\t\tthis.v2.copy( source.v2 );\n\n\t\treturn this;\n\n\t};\n\n\tLineCurve.prototype.toJSON = function () {\n\n\t\tvar data = Curve.prototype.toJSON.call( this );\n\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\n\t\treturn data;\n\n\t};\n\n\tLineCurve.prototype.fromJSON = function ( json ) {\n\n\t\tCurve.prototype.fromJSON.call( this, json );\n\n\t\tthis.v1.fromArray( json.v1 );\n\t\tthis.v2.fromArray( json.v2 );\n\n\t\treturn this;\n\n\t};\n\n\tfunction LineCurve3( v1, v2 ) {\n\n\t\tCurve.call( this );\n\n\t\tthis.type = 'LineCurve3';\n\n\t\tthis.v1 = v1 || new Vector3();\n\t\tthis.v2 = v2 || new Vector3();\n\n\t}\n\n\tLineCurve3.prototype = Object.create( Curve.prototype );\n\tLineCurve3.prototype.constructor = LineCurve3;\n\n\tLineCurve3.prototype.isLineCurve3 = true;\n\n\tLineCurve3.prototype.getPoint = function ( t, optionalTarget ) {\n\n\t\tvar point = optionalTarget || new Vector3();\n\n\t\tif ( t === 1 ) {\n\n\t\t\tpoint.copy( this.v2 );\n\n\t\t} else {\n\n\t\t\tpoint.copy( this.v2 ).sub( this.v1 );\n\t\t\tpoint.multiplyScalar( t ).add( this.v1 );\n\n\t\t}\n\n\t\treturn point;\n\n\t};\n\n\t// Line curve is linear, so we can overwrite default getPointAt\n\n\tLineCurve3.prototype.getPointAt = function ( u, optionalTarget ) {\n\n\t\treturn this.getPoint( u, optionalTarget );\n\n\t};\n\n\tLineCurve3.prototype.copy = function ( source ) {\n\n\t\tCurve.prototype.copy.call( this, source );\n\n\t\tthis.v1.copy( source.v1 );\n\t\tthis.v2.copy( source.v2 );\n\n\t\treturn this;\n\n\t};\n\n\tLineCurve3.prototype.toJSON = function () {\n\n\t\tvar data = Curve.prototype.toJSON.call( this );\n\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\n\t\treturn data;\n\n\t};\n\n\tLineCurve3.prototype.fromJSON = function ( json ) {\n\n\t\tCurve.prototype.fromJSON.call( this, json );\n\n\t\tthis.v1.fromArray( json.v1 );\n\t\tthis.v2.fromArray( json.v2 );\n\n\t\treturn this;\n\n\t};\n\n\tfunction QuadraticBezierCurve( v0, v1, v2 ) {\n\n\t\tCurve.call( this );\n\n\t\tthis.type = 'QuadraticBezierCurve';\n\n\t\tthis.v0 = v0 || new Vector2();\n\t\tthis.v1 = v1 || new Vector2();\n\t\tthis.v2 = v2 || new Vector2();\n\n\t}\n\n\tQuadraticBezierCurve.prototype = Object.create( Curve.prototype );\n\tQuadraticBezierCurve.prototype.constructor = QuadraticBezierCurve;\n\n\tQuadraticBezierCurve.prototype.isQuadraticBezierCurve = true;\n\n\tQuadraticBezierCurve.prototype.getPoint = function ( t, optionalTarget ) {\n\n\t\tvar point = optionalTarget || new Vector2();\n\n\t\tvar v0 = this.v0, v1 = this.v1, v2 = this.v2;\n\n\t\tpoint.set(\n\t\t\tQuadraticBezier( t, v0.x, v1.x, v2.x ),\n\t\t\tQuadraticBezier( t, v0.y, v1.y, v2.y )\n\t\t);\n\n\t\treturn point;\n\n\t};\n\n\tQuadraticBezierCurve.prototype.copy = function ( source ) {\n\n\t\tCurve.prototype.copy.call( this, source );\n\n\t\tthis.v0.copy( source.v0 );\n\t\tthis.v1.copy( source.v1 );\n\t\tthis.v2.copy( source.v2 );\n\n\t\treturn this;\n\n\t};\n\n\tQuadraticBezierCurve.prototype.toJSON = function () {\n\n\t\tvar data = Curve.prototype.toJSON.call( this );\n\n\t\tdata.v0 = this.v0.toArray();\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\n\t\treturn data;\n\n\t};\n\n\tQuadraticBezierCurve.prototype.fromJSON = function ( json ) {\n\n\t\tCurve.prototype.fromJSON.call( this, json );\n\n\t\tthis.v0.fromArray( json.v0 );\n\t\tthis.v1.fromArray( json.v1 );\n\t\tthis.v2.fromArray( json.v2 );\n\n\t\treturn this;\n\n\t};\n\n\tfunction QuadraticBezierCurve3( v0, v1, v2 ) {\n\n\t\tCurve.call( this );\n\n\t\tthis.type = 'QuadraticBezierCurve3';\n\n\t\tthis.v0 = v0 || new Vector3();\n\t\tthis.v1 = v1 || new Vector3();\n\t\tthis.v2 = v2 || new Vector3();\n\n\t}\n\n\tQuadraticBezierCurve3.prototype = Object.create( Curve.prototype );\n\tQuadraticBezierCurve3.prototype.constructor = QuadraticBezierCurve3;\n\n\tQuadraticBezierCurve3.prototype.isQuadraticBezierCurve3 = true;\n\n\tQuadraticBezierCurve3.prototype.getPoint = function ( t, optionalTarget ) {\n\n\t\tvar point = optionalTarget || new Vector3();\n\n\t\tvar v0 = this.v0, v1 = this.v1, v2 = this.v2;\n\n\t\tpoint.set(\n\t\t\tQuadraticBezier( t, v0.x, v1.x, v2.x ),\n\t\t\tQuadraticBezier( t, v0.y, v1.y, v2.y ),\n\t\t\tQuadraticBezier( t, v0.z, v1.z, v2.z )\n\t\t);\n\n\t\treturn point;\n\n\t};\n\n\tQuadraticBezierCurve3.prototype.copy = function ( source ) {\n\n\t\tCurve.prototype.copy.call( this, source );\n\n\t\tthis.v0.copy( source.v0 );\n\t\tthis.v1.copy( source.v1 );\n\t\tthis.v2.copy( source.v2 );\n\n\t\treturn this;\n\n\t};\n\n\tQuadraticBezierCurve3.prototype.toJSON = function () {\n\n\t\tvar data = Curve.prototype.toJSON.call( this );\n\n\t\tdata.v0 = this.v0.toArray();\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\n\t\treturn data;\n\n\t};\n\n\tQuadraticBezierCurve3.prototype.fromJSON = function ( json ) {\n\n\t\tCurve.prototype.fromJSON.call( this, json );\n\n\t\tthis.v0.fromArray( json.v0 );\n\t\tthis.v1.fromArray( json.v1 );\n\t\tthis.v2.fromArray( json.v2 );\n\n\t\treturn this;\n\n\t};\n\n\tfunction SplineCurve( points /* array of Vector2 */ ) {\n\n\t\tCurve.call( this );\n\n\t\tthis.type = 'SplineCurve';\n\n\t\tthis.points = points || [];\n\n\t}\n\n\tSplineCurve.prototype = Object.create( Curve.prototype );\n\tSplineCurve.prototype.constructor = SplineCurve;\n\n\tSplineCurve.prototype.isSplineCurve = true;\n\n\tSplineCurve.prototype.getPoint = function ( t, optionalTarget ) {\n\n\t\tvar point = optionalTarget || new Vector2();\n\n\t\tvar points = this.points;\n\t\tvar p = ( points.length - 1 ) * t;\n\n\t\tvar intPoint = Math.floor( p );\n\t\tvar weight = p - intPoint;\n\n\t\tvar p0 = points[ intPoint === 0 ? intPoint : intPoint - 1 ];\n\t\tvar p1 = points[ intPoint ];\n\t\tvar p2 = points[ intPoint > points.length - 2 ? points.length - 1 : intPoint + 1 ];\n\t\tvar p3 = points[ intPoint > points.length - 3 ? points.length - 1 : intPoint + 2 ];\n\n\t\tpoint.set(\n\t\t\tCatmullRom( weight, p0.x, p1.x, p2.x, p3.x ),\n\t\t\tCatmullRom( weight, p0.y, p1.y, p2.y, p3.y )\n\t\t);\n\n\t\treturn point;\n\n\t};\n\n\tSplineCurve.prototype.copy = function ( source ) {\n\n\t\tCurve.prototype.copy.call( this, source );\n\n\t\tthis.points = [];\n\n\t\tfor ( var i = 0, l = source.points.length; i < l; i ++ ) {\n\n\t\t\tvar point = source.points[ i ];\n\n\t\t\tthis.points.push( point.clone() );\n\n\t\t}\n\n\t\treturn this;\n\n\t};\n\n\tSplineCurve.prototype.toJSON = function () {\n\n\t\tvar data = Curve.prototype.toJSON.call( this );\n\n\t\tdata.points = [];\n\n\t\tfor ( var i = 0, l = this.points.length; i < l; i ++ ) {\n\n\t\t\tvar point = this.points[ i ];\n\t\t\tdata.points.push( point.toArray() );\n\n\t\t}\n\n\t\treturn data;\n\n\t};\n\n\tSplineCurve.prototype.fromJSON = function ( json ) {\n\n\t\tCurve.prototype.fromJSON.call( this, json );\n\n\t\tthis.points = [];\n\n\t\tfor ( var i = 0, l = json.points.length; i < l; i ++ ) {\n\n\t\t\tvar point = json.points[ i ];\n\t\t\tthis.points.push( new Vector2().fromArray( point ) );\n\n\t\t}\n\n\t\treturn this;\n\n\t};\n\n\n\n\tvar Curves = /*#__PURE__*/Object.freeze({\n\t\tArcCurve: ArcCurve,\n\t\tCatmullRomCurve3: CatmullRomCurve3,\n\t\tCubicBezierCurve: CubicBezierCurve,\n\t\tCubicBezierCurve3: CubicBezierCurve3,\n\t\tEllipseCurve: EllipseCurve,\n\t\tLineCurve: LineCurve,\n\t\tLineCurve3: LineCurve3,\n\t\tQuadraticBezierCurve: QuadraticBezierCurve,\n\t\tQuadraticBezierCurve3: QuadraticBezierCurve3,\n\t\tSplineCurve: SplineCurve\n\t});\n\n\t/**\n\t * @author zz85 / http://www.lab4games.net/zz85/blog\n\t *\n\t **/\n\n\t/**************************************************************\n\t *\tCurved Path - a curve path is simply a array of connected\n\t *  curves, but retains the api of a curve\n\t **************************************************************/\n\n\tfunction CurvePath() {\n\n\t\tCurve.call( this );\n\n\t\tthis.type = 'CurvePath';\n\n\t\tthis.curves = [];\n\t\tthis.autoClose = false; // Automatically closes the path\n\n\t}\n\n\tCurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {\n\n\t\tconstructor: CurvePath,\n\n\t\tadd: function ( curve ) {\n\n\t\t\tthis.curves.push( curve );\n\n\t\t},\n\n\t\tclosePath: function () {\n\n\t\t\t// Add a line curve if start and end of lines are not connected\n\t\t\tvar startPoint = this.curves[ 0 ].getPoint( 0 );\n\t\t\tvar endPoint = this.curves[ this.curves.length - 1 ].getPoint( 1 );\n\n\t\t\tif ( ! startPoint.equals( endPoint ) ) {\n\n\t\t\t\tthis.curves.push( new LineCurve( endPoint, startPoint ) );\n\n\t\t\t}\n\n\t\t},\n\n\t\t// To get accurate point with reference to\n\t\t// entire path distance at time t,\n\t\t// following has to be done:\n\n\t\t// 1. Length of each sub path have to be known\n\t\t// 2. Locate and identify type of curve\n\t\t// 3. Get t for the curve\n\t\t// 4. Return curve.getPointAt(t')\n\n\t\tgetPoint: function ( t ) {\n\n\t\t\tvar d = t * this.getLength();\n\t\t\tvar curveLengths = this.getCurveLengths();\n\t\t\tvar i = 0;\n\n\t\t\t// To think about boundaries points.\n\n\t\t\twhile ( i < curveLengths.length ) {\n\n\t\t\t\tif ( curveLengths[ i ] >= d ) {\n\n\t\t\t\t\tvar diff = curveLengths[ i ] - d;\n\t\t\t\t\tvar curve = this.curves[ i ];\n\n\t\t\t\t\tvar segmentLength = curve.getLength();\n\t\t\t\t\tvar u = segmentLength === 0 ? 0 : 1 - diff / segmentLength;\n\n\t\t\t\t\treturn curve.getPointAt( u );\n\n\t\t\t\t}\n\n\t\t\t\ti ++;\n\n\t\t\t}\n\n\t\t\treturn null;\n\n\t\t\t// loop where sum != 0, sum > d , sum+1 <d\n\n\t\t},\n\n\t\t// We cannot use the default THREE.Curve getPoint() with getLength() because in\n\t\t// THREE.Curve, getLength() depends on getPoint() but in THREE.CurvePath\n\t\t// getPoint() depends on getLength\n\n\t\tgetLength: function () {\n\n\t\t\tvar lens = this.getCurveLengths();\n\t\t\treturn lens[ lens.length - 1 ];\n\n\t\t},\n\n\t\t// cacheLengths must be recalculated.\n\t\tupdateArcLengths: function () {\n\n\t\t\tthis.needsUpdate = true;\n\t\t\tthis.cacheLengths = null;\n\t\t\tthis.getCurveLengths();\n\n\t\t},\n\n\t\t// Compute lengths and cache them\n\t\t// We cannot overwrite getLengths() because UtoT mapping uses it.\n\n\t\tgetCurveLengths: function () {\n\n\t\t\t// We use cache values if curves and cache array are same length\n\n\t\t\tif ( this.cacheLengths && this.cacheLengths.length === this.curves.length ) {\n\n\t\t\t\treturn this.cacheLengths;\n\n\t\t\t}\n\n\t\t\t// Get length of sub-curve\n\t\t\t// Push sums into cached array\n\n\t\t\tvar lengths = [], sums = 0;\n\n\t\t\tfor ( var i = 0, l = this.curves.length; i < l; i ++ ) {\n\n\t\t\t\tsums += this.curves[ i ].getLength();\n\t\t\t\tlengths.push( sums );\n\n\t\t\t}\n\n\t\t\tthis.cacheLengths = lengths;\n\n\t\t\treturn lengths;\n\n\t\t},\n\n\t\tgetSpacedPoints: function ( divisions ) {\n\n\t\t\tif ( divisions === undefined ) divisions = 40;\n\n\t\t\tvar points = [];\n\n\t\t\tfor ( var i = 0; i <= divisions; i ++ ) {\n\n\t\t\t\tpoints.push( this.getPoint( i / divisions ) );\n\n\t\t\t}\n\n\t\t\tif ( this.autoClose ) {\n\n\t\t\t\tpoints.push( points[ 0 ] );\n\n\t\t\t}\n\n\t\t\treturn points;\n\n\t\t},\n\n\t\tgetPoints: function ( divisions ) {\n\n\t\t\tdivisions = divisions || 12;\n\n\t\t\tvar points = [], last;\n\n\t\t\tfor ( var i = 0, curves = this.curves; i < curves.length; i ++ ) {\n\n\t\t\t\tvar curve = curves[ i ];\n\t\t\t\tvar resolution = ( curve && curve.isEllipseCurve ) ? divisions * 2\n\t\t\t\t\t: ( curve && ( curve.isLineCurve || curve.isLineCurve3 ) ) ? 1\n\t\t\t\t\t\t: ( curve && curve.isSplineCurve ) ? divisions * curve.points.length\n\t\t\t\t\t\t\t: divisions;\n\n\t\t\t\tvar pts = curve.getPoints( resolution );\n\n\t\t\t\tfor ( var j = 0; j < pts.length; j ++ ) {\n\n\t\t\t\t\tvar point = pts[ j ];\n\n\t\t\t\t\tif ( last && last.equals( point ) ) continue; // ensures no consecutive points are duplicates\n\n\t\t\t\t\tpoints.push( point );\n\t\t\t\t\tlast = point;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( this.autoClose && points.length > 1 && ! points[ points.length - 1 ].equals( points[ 0 ] ) ) {\n\n\t\t\t\tpoints.push( points[ 0 ] );\n\n\t\t\t}\n\n\t\t\treturn points;\n\n\t\t},\n\n\t\tcopy: function ( source ) {\n\n\t\t\tCurve.prototype.copy.call( this, source );\n\n\t\t\tthis.curves = [];\n\n\t\t\tfor ( var i = 0, l = source.curves.length; i < l; i ++ ) {\n\n\t\t\t\tvar curve = source.curves[ i ];\n\n\t\t\t\tthis.curves.push( curve.clone() );\n\n\t\t\t}\n\n\t\t\tthis.autoClose = source.autoClose;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttoJSON: function () {\n\n\t\t\tvar data = Curve.prototype.toJSON.call( this );\n\n\t\t\tdata.autoClose = this.autoClose;\n\t\t\tdata.curves = [];\n\n\t\t\tfor ( var i = 0, l = this.curves.length; i < l; i ++ ) {\n\n\t\t\t\tvar curve = this.curves[ i ];\n\t\t\t\tdata.curves.push( curve.toJSON() );\n\n\t\t\t}\n\n\t\t\treturn data;\n\n\t\t},\n\n\t\tfromJSON: function ( json ) {\n\n\t\t\tCurve.prototype.fromJSON.call( this, json );\n\n\t\t\tthis.autoClose = json.autoClose;\n\t\t\tthis.curves = [];\n\n\t\t\tfor ( var i = 0, l = json.curves.length; i < l; i ++ ) {\n\n\t\t\t\tvar curve = json.curves[ i ];\n\t\t\t\tthis.curves.push( new Curves[ curve.type ]().fromJSON( curve ) );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author zz85 / http://www.lab4games.net/zz85/blog\n\t * Creates free form 2d path using series of points, lines or curves.\n\t **/\n\n\tfunction Path( points ) {\n\n\t\tCurvePath.call( this );\n\n\t\tthis.type = 'Path';\n\n\t\tthis.currentPoint = new Vector2();\n\n\t\tif ( points ) {\n\n\t\t\tthis.setFromPoints( points );\n\n\t\t}\n\n\t}\n\n\tPath.prototype = Object.assign( Object.create( CurvePath.prototype ), {\n\n\t\tconstructor: Path,\n\n\t\tsetFromPoints: function ( points ) {\n\n\t\t\tthis.moveTo( points[ 0 ].x, points[ 0 ].y );\n\n\t\t\tfor ( var i = 1, l = points.length; i < l; i ++ ) {\n\n\t\t\t\tthis.lineTo( points[ i ].x, points[ i ].y );\n\n\t\t\t}\n\n\t\t},\n\n\t\tmoveTo: function ( x, y ) {\n\n\t\t\tthis.currentPoint.set( x, y ); // TODO consider referencing vectors instead of copying?\n\n\t\t},\n\n\t\tlineTo: function ( x, y ) {\n\n\t\t\tvar curve = new LineCurve( this.currentPoint.clone(), new Vector2( x, y ) );\n\t\t\tthis.curves.push( curve );\n\n\t\t\tthis.currentPoint.set( x, y );\n\n\t\t},\n\n\t\tquadraticCurveTo: function ( aCPx, aCPy, aX, aY ) {\n\n\t\t\tvar curve = new QuadraticBezierCurve(\n\t\t\t\tthis.currentPoint.clone(),\n\t\t\t\tnew Vector2( aCPx, aCPy ),\n\t\t\t\tnew Vector2( aX, aY )\n\t\t\t);\n\n\t\t\tthis.curves.push( curve );\n\n\t\t\tthis.currentPoint.set( aX, aY );\n\n\t\t},\n\n\t\tbezierCurveTo: function ( aCP1x, aCP1y, aCP2x, aCP2y, aX, aY ) {\n\n\t\t\tvar curve = new CubicBezierCurve(\n\t\t\t\tthis.currentPoint.clone(),\n\t\t\t\tnew Vector2( aCP1x, aCP1y ),\n\t\t\t\tnew Vector2( aCP2x, aCP2y ),\n\t\t\t\tnew Vector2( aX, aY )\n\t\t\t);\n\n\t\t\tthis.curves.push( curve );\n\n\t\t\tthis.currentPoint.set( aX, aY );\n\n\t\t},\n\n\t\tsplineThru: function ( pts /*Array of Vector*/ ) {\n\n\t\t\tvar npts = [ this.currentPoint.clone() ].concat( pts );\n\n\t\t\tvar curve = new SplineCurve( npts );\n\t\t\tthis.curves.push( curve );\n\n\t\t\tthis.currentPoint.copy( pts[ pts.length - 1 ] );\n\n\t\t},\n\n\t\tarc: function ( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) {\n\n\t\t\tvar x0 = this.currentPoint.x;\n\t\t\tvar y0 = this.currentPoint.y;\n\n\t\t\tthis.absarc( aX + x0, aY + y0, aRadius,\n\t\t\t\taStartAngle, aEndAngle, aClockwise );\n\n\t\t},\n\n\t\tabsarc: function ( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) {\n\n\t\t\tthis.absellipse( aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise );\n\n\t\t},\n\n\t\tellipse: function ( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) {\n\n\t\t\tvar x0 = this.currentPoint.x;\n\t\t\tvar y0 = this.currentPoint.y;\n\n\t\t\tthis.absellipse( aX + x0, aY + y0, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation );\n\n\t\t},\n\n\t\tabsellipse: function ( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) {\n\n\t\t\tvar curve = new EllipseCurve( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation );\n\n\t\t\tif ( this.curves.length > 0 ) {\n\n\t\t\t\t// if a previous curve is present, attempt to join\n\t\t\t\tvar firstPoint = curve.getPoint( 0 );\n\n\t\t\t\tif ( ! firstPoint.equals( this.currentPoint ) ) {\n\n\t\t\t\t\tthis.lineTo( firstPoint.x, firstPoint.y );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.curves.push( curve );\n\n\t\t\tvar lastPoint = curve.getPoint( 1 );\n\t\t\tthis.currentPoint.copy( lastPoint );\n\n\t\t},\n\n\t\tcopy: function ( source ) {\n\n\t\t\tCurvePath.prototype.copy.call( this, source );\n\n\t\t\tthis.currentPoint.copy( source.currentPoint );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttoJSON: function () {\n\n\t\t\tvar data = CurvePath.prototype.toJSON.call( this );\n\n\t\t\tdata.currentPoint = this.currentPoint.toArray();\n\n\t\t\treturn data;\n\n\t\t},\n\n\t\tfromJSON: function ( json ) {\n\n\t\t\tCurvePath.prototype.fromJSON.call( this, json );\n\n\t\t\tthis.currentPoint.fromArray( json.currentPoint );\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author zz85 / http://www.lab4games.net/zz85/blog\n\t * Defines a 2d shape plane using paths.\n\t **/\n\n\t// STEP 1 Create a path.\n\t// STEP 2 Turn path into shape.\n\t// STEP 3 ExtrudeGeometry takes in Shape/Shapes\n\t// STEP 3a - Extract points from each shape, turn to vertices\n\t// STEP 3b - Triangulate each shape, add faces.\n\n\tfunction Shape( points ) {\n\n\t\tPath.call( this, points );\n\n\t\tthis.uuid = _Math.generateUUID();\n\n\t\tthis.type = 'Shape';\n\n\t\tthis.holes = [];\n\n\t}\n\n\tShape.prototype = Object.assign( Object.create( Path.prototype ), {\n\n\t\tconstructor: Shape,\n\n\t\tgetPointsHoles: function ( divisions ) {\n\n\t\t\tvar holesPts = [];\n\n\t\t\tfor ( var i = 0, l = this.holes.length; i < l; i ++ ) {\n\n\t\t\t\tholesPts[ i ] = this.holes[ i ].getPoints( divisions );\n\n\t\t\t}\n\n\t\t\treturn holesPts;\n\n\t\t},\n\n\t\t// get points of shape and holes (keypoints based on segments parameter)\n\n\t\textractPoints: function ( divisions ) {\n\n\t\t\treturn {\n\n\t\t\t\tshape: this.getPoints( divisions ),\n\t\t\t\tholes: this.getPointsHoles( divisions )\n\n\t\t\t};\n\n\t\t},\n\n\t\tcopy: function ( source ) {\n\n\t\t\tPath.prototype.copy.call( this, source );\n\n\t\t\tthis.holes = [];\n\n\t\t\tfor ( var i = 0, l = source.holes.length; i < l; i ++ ) {\n\n\t\t\t\tvar hole = source.holes[ i ];\n\n\t\t\t\tthis.holes.push( hole.clone() );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttoJSON: function () {\n\n\t\t\tvar data = Path.prototype.toJSON.call( this );\n\n\t\t\tdata.uuid = this.uuid;\n\t\t\tdata.holes = [];\n\n\t\t\tfor ( var i = 0, l = this.holes.length; i < l; i ++ ) {\n\n\t\t\t\tvar hole = this.holes[ i ];\n\t\t\t\tdata.holes.push( hole.toJSON() );\n\n\t\t\t}\n\n\t\t\treturn data;\n\n\t\t},\n\n\t\tfromJSON: function ( json ) {\n\n\t\t\tPath.prototype.fromJSON.call( this, json );\n\n\t\t\tthis.uuid = json.uuid;\n\t\t\tthis.holes = [];\n\n\t\t\tfor ( var i = 0, l = json.holes.length; i < l; i ++ ) {\n\n\t\t\t\tvar hole = json.holes[ i ];\n\t\t\t\tthis.holes.push( new Path().fromJSON( hole ) );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author alteredq / http://alteredqualia.com/\n\t */\n\n\tfunction Light( color, intensity ) {\n\n\t\tObject3D.call( this );\n\n\t\tthis.type = 'Light';\n\n\t\tthis.color = new Color( color );\n\t\tthis.intensity = intensity !== undefined ? intensity : 1;\n\n\t\tthis.receiveShadow = undefined;\n\n\t}\n\n\tLight.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\t\tconstructor: Light,\n\n\t\tisLight: true,\n\n\t\tcopy: function ( source ) {\n\n\t\t\tObject3D.prototype.copy.call( this, source );\n\n\t\t\tthis.color.copy( source.color );\n\t\t\tthis.intensity = source.intensity;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttoJSON: function ( meta ) {\n\n\t\t\tvar data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\t\tdata.object.color = this.color.getHex();\n\t\t\tdata.object.intensity = this.intensity;\n\n\t\t\tif ( this.groundColor !== undefined ) data.object.groundColor = this.groundColor.getHex();\n\n\t\t\tif ( this.distance !== undefined ) data.object.distance = this.distance;\n\t\t\tif ( this.angle !== undefined ) data.object.angle = this.angle;\n\t\t\tif ( this.decay !== undefined ) data.object.decay = this.decay;\n\t\t\tif ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra;\n\n\t\t\tif ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON();\n\n\t\t\treturn data;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t */\n\n\tfunction HemisphereLight( skyColor, groundColor, intensity ) {\n\n\t\tLight.call( this, skyColor, intensity );\n\n\t\tthis.type = 'HemisphereLight';\n\n\t\tthis.castShadow = undefined;\n\n\t\tthis.position.copy( Object3D.DefaultUp );\n\t\tthis.updateMatrix();\n\n\t\tthis.groundColor = new Color( groundColor );\n\n\t}\n\n\tHemisphereLight.prototype = Object.assign( Object.create( Light.prototype ), {\n\n\t\tconstructor: HemisphereLight,\n\n\t\tisHemisphereLight: true,\n\n\t\tcopy: function ( source ) {\n\n\t\t\tLight.prototype.copy.call( this, source );\n\n\t\t\tthis.groundColor.copy( source.groundColor );\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction LightShadow( camera ) {\n\n\t\tthis.camera = camera;\n\n\t\tthis.bias = 0;\n\t\tthis.radius = 1;\n\n\t\tthis.mapSize = new Vector2( 512, 512 );\n\n\t\tthis.map = null;\n\t\tthis.matrix = new Matrix4();\n\n\t}\n\n\tObject.assign( LightShadow.prototype, {\n\n\t\tcopy: function ( source ) {\n\n\t\t\tthis.camera = source.camera.clone();\n\n\t\t\tthis.bias = source.bias;\n\t\t\tthis.radius = source.radius;\n\n\t\t\tthis.mapSize.copy( source.mapSize );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t},\n\n\t\ttoJSON: function () {\n\n\t\t\tvar object = {};\n\n\t\t\tif ( this.bias !== 0 ) object.bias = this.bias;\n\t\t\tif ( this.radius !== 1 ) object.radius = this.radius;\n\t\t\tif ( this.mapSize.x !== 512 || this.mapSize.y !== 512 ) object.mapSize = this.mapSize.toArray();\n\n\t\t\tobject.camera = this.camera.toJSON( false ).object;\n\t\t\tdelete object.camera.matrix;\n\n\t\t\treturn object;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction SpotLightShadow() {\n\n\t\tLightShadow.call( this, new PerspectiveCamera( 50, 1, 0.5, 500 ) );\n\n\t}\n\n\tSpotLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype ), {\n\n\t\tconstructor: SpotLightShadow,\n\n\t\tisSpotLightShadow: true,\n\n\t\tupdate: function ( light ) {\n\n\t\t\tvar camera = this.camera;\n\n\t\t\tvar fov = _Math.RAD2DEG * 2 * light.angle;\n\t\t\tvar aspect = this.mapSize.width / this.mapSize.height;\n\t\t\tvar far = light.distance || camera.far;\n\n\t\t\tif ( fov !== camera.fov || aspect !== camera.aspect || far !== camera.far ) {\n\n\t\t\t\tcamera.fov = fov;\n\t\t\t\tcamera.aspect = aspect;\n\t\t\t\tcamera.far = far;\n\t\t\t\tcamera.updateProjectionMatrix();\n\n\t\t\t}\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t */\n\n\tfunction SpotLight( color, intensity, distance, angle, penumbra, decay ) {\n\n\t\tLight.call( this, color, intensity );\n\n\t\tthis.type = 'SpotLight';\n\n\t\tthis.position.copy( Object3D.DefaultUp );\n\t\tthis.updateMatrix();\n\n\t\tthis.target = new Object3D();\n\n\t\tObject.defineProperty( this, 'power', {\n\t\t\tget: function () {\n\n\t\t\t\t// intensity = power per solid angle.\n\t\t\t\t// ref: equation (17) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t\t\t\treturn this.intensity * Math.PI;\n\n\t\t\t},\n\t\t\tset: function ( power ) {\n\n\t\t\t\t// intensity = power per solid angle.\n\t\t\t\t// ref: equation (17) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t\t\t\tthis.intensity = power / Math.PI;\n\n\t\t\t}\n\t\t} );\n\n\t\tthis.distance = ( distance !== undefined ) ? distance : 0;\n\t\tthis.angle = ( angle !== undefined ) ? angle : Math.PI / 3;\n\t\tthis.penumbra = ( penumbra !== undefined ) ? penumbra : 0;\n\t\tthis.decay = ( decay !== undefined ) ? decay : 1;\t// for physically correct lights, should be 2.\n\n\t\tthis.shadow = new SpotLightShadow();\n\n\t}\n\n\tSpotLight.prototype = Object.assign( Object.create( Light.prototype ), {\n\n\t\tconstructor: SpotLight,\n\n\t\tisSpotLight: true,\n\n\t\tcopy: function ( source ) {\n\n\t\t\tLight.prototype.copy.call( this, source );\n\n\t\t\tthis.distance = source.distance;\n\t\t\tthis.angle = source.angle;\n\t\t\tthis.penumbra = source.penumbra;\n\t\t\tthis.decay = source.decay;\n\n\t\t\tthis.target = source.target.clone();\n\n\t\t\tthis.shadow = source.shadow.clone();\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\n\tfunction PointLight( color, intensity, distance, decay ) {\n\n\t\tLight.call( this, color, intensity );\n\n\t\tthis.type = 'PointLight';\n\n\t\tObject.defineProperty( this, 'power', {\n\t\t\tget: function () {\n\n\t\t\t\t// intensity = power per solid angle.\n\t\t\t\t// ref: equation (15) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t\t\t\treturn this.intensity * 4 * Math.PI;\n\n\t\t\t},\n\t\t\tset: function ( power ) {\n\n\t\t\t\t// intensity = power per solid angle.\n\t\t\t\t// ref: equation (15) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t\t\t\tthis.intensity = power / ( 4 * Math.PI );\n\n\t\t\t}\n\t\t} );\n\n\t\tthis.distance = ( distance !== undefined ) ? distance : 0;\n\t\tthis.decay = ( decay !== undefined ) ? decay : 1;\t// for physically correct lights, should be 2.\n\n\t\tthis.shadow = new LightShadow( new PerspectiveCamera( 90, 1, 0.5, 500 ) );\n\n\t}\n\n\tPointLight.prototype = Object.assign( Object.create( Light.prototype ), {\n\n\t\tconstructor: PointLight,\n\n\t\tisPointLight: true,\n\n\t\tcopy: function ( source ) {\n\n\t\t\tLight.prototype.copy.call( this, source );\n\n\t\t\tthis.distance = source.distance;\n\t\t\tthis.decay = source.decay;\n\n\t\t\tthis.shadow = source.shadow.clone();\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author arose / http://github.com/arose\n\t */\n\n\tfunction OrthographicCamera( left, right, top, bottom, near, far ) {\n\n\t\tCamera.call( this );\n\n\t\tthis.type = 'OrthographicCamera';\n\n\t\tthis.zoom = 1;\n\t\tthis.view = null;\n\n\t\tthis.left = ( left !== undefined ) ? left : - 1;\n\t\tthis.right = ( right !== undefined ) ? right : 1;\n\t\tthis.top = ( top !== undefined ) ? top : 1;\n\t\tthis.bottom = ( bottom !== undefined ) ? bottom : - 1;\n\n\t\tthis.near = ( near !== undefined ) ? near : 0.1;\n\t\tthis.far = ( far !== undefined ) ? far : 2000;\n\n\t\tthis.updateProjectionMatrix();\n\n\t}\n\n\tOrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ), {\n\n\t\tconstructor: OrthographicCamera,\n\n\t\tisOrthographicCamera: true,\n\n\t\tcopy: function ( source, recursive ) {\n\n\t\t\tCamera.prototype.copy.call( this, source, recursive );\n\n\t\t\tthis.left = source.left;\n\t\t\tthis.right = source.right;\n\t\t\tthis.top = source.top;\n\t\t\tthis.bottom = source.bottom;\n\t\t\tthis.near = source.near;\n\t\t\tthis.far = source.far;\n\n\t\t\tthis.zoom = source.zoom;\n\t\t\tthis.view = source.view === null ? null : Object.assign( {}, source.view );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetViewOffset: function ( fullWidth, fullHeight, x, y, width, height ) {\n\n\t\t\tif ( this.view === null ) {\n\n\t\t\t\tthis.view = {\n\t\t\t\t\tenabled: true,\n\t\t\t\t\tfullWidth: 1,\n\t\t\t\t\tfullHeight: 1,\n\t\t\t\t\toffsetX: 0,\n\t\t\t\t\toffsetY: 0,\n\t\t\t\t\twidth: 1,\n\t\t\t\t\theight: 1\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\tthis.view.enabled = true;\n\t\t\tthis.view.fullWidth = fullWidth;\n\t\t\tthis.view.fullHeight = fullHeight;\n\t\t\tthis.view.offsetX = x;\n\t\t\tthis.view.offsetY = y;\n\t\t\tthis.view.width = width;\n\t\t\tthis.view.height = height;\n\n\t\t\tthis.updateProjectionMatrix();\n\n\t\t},\n\n\t\tclearViewOffset: function () {\n\n\t\t\tif ( this.view !== null ) {\n\n\t\t\t\tthis.view.enabled = false;\n\n\t\t\t}\n\n\t\t\tthis.updateProjectionMatrix();\n\n\t\t},\n\n\t\tupdateProjectionMatrix: function () {\n\n\t\t\tvar dx = ( this.right - this.left ) / ( 2 * this.zoom );\n\t\t\tvar dy = ( this.top - this.bottom ) / ( 2 * this.zoom );\n\t\t\tvar cx = ( this.right + this.left ) / 2;\n\t\t\tvar cy = ( this.top + this.bottom ) / 2;\n\n\t\t\tvar left = cx - dx;\n\t\t\tvar right = cx + dx;\n\t\t\tvar top = cy + dy;\n\t\t\tvar bottom = cy - dy;\n\n\t\t\tif ( this.view !== null && this.view.enabled ) {\n\n\t\t\t\tvar zoomW = this.zoom / ( this.view.width / this.view.fullWidth );\n\t\t\t\tvar zoomH = this.zoom / ( this.view.height / this.view.fullHeight );\n\t\t\t\tvar scaleW = ( this.right - this.left ) / this.view.width;\n\t\t\t\tvar scaleH = ( this.top - this.bottom ) / this.view.height;\n\n\t\t\t\tleft += scaleW * ( this.view.offsetX / zoomW );\n\t\t\t\tright = left + scaleW * ( this.view.width / zoomW );\n\t\t\t\ttop -= scaleH * ( this.view.offsetY / zoomH );\n\t\t\t\tbottom = top - scaleH * ( this.view.height / zoomH );\n\n\t\t\t}\n\n\t\t\tthis.projectionMatrix.makeOrthographic( left, right, top, bottom, this.near, this.far );\n\n\t\t\tthis.projectionMatrixInverse.getInverse( this.projectionMatrix );\n\n\t\t},\n\n\t\ttoJSON: function ( meta ) {\n\n\t\t\tvar data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\t\tdata.object.zoom = this.zoom;\n\t\t\tdata.object.left = this.left;\n\t\t\tdata.object.right = this.right;\n\t\t\tdata.object.top = this.top;\n\t\t\tdata.object.bottom = this.bottom;\n\t\t\tdata.object.near = this.near;\n\t\t\tdata.object.far = this.far;\n\n\t\t\tif ( this.view !== null ) data.object.view = Object.assign( {}, this.view );\n\n\t\t\treturn data;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction DirectionalLightShadow( ) {\n\n\t\tLightShadow.call( this, new OrthographicCamera( - 5, 5, 5, - 5, 0.5, 500 ) );\n\n\t}\n\n\tDirectionalLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype ), {\n\n\t\tconstructor: DirectionalLightShadow\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author alteredq / http://alteredqualia.com/\n\t */\n\n\tfunction DirectionalLight( color, intensity ) {\n\n\t\tLight.call( this, color, intensity );\n\n\t\tthis.type = 'DirectionalLight';\n\n\t\tthis.position.copy( Object3D.DefaultUp );\n\t\tthis.updateMatrix();\n\n\t\tthis.target = new Object3D();\n\n\t\tthis.shadow = new DirectionalLightShadow();\n\n\t}\n\n\tDirectionalLight.prototype = Object.assign( Object.create( Light.prototype ), {\n\n\t\tconstructor: DirectionalLight,\n\n\t\tisDirectionalLight: true,\n\n\t\tcopy: function ( source ) {\n\n\t\t\tLight.prototype.copy.call( this, source );\n\n\t\t\tthis.target = source.target.clone();\n\n\t\t\tthis.shadow = source.shadow.clone();\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction AmbientLight( color, intensity ) {\n\n\t\tLight.call( this, color, intensity );\n\n\t\tthis.type = 'AmbientLight';\n\n\t\tthis.castShadow = undefined;\n\n\t}\n\n\tAmbientLight.prototype = Object.assign( Object.create( Light.prototype ), {\n\n\t\tconstructor: AmbientLight,\n\n\t\tisAmbientLight: true\n\n\t} );\n\n\t/**\n\t * @author abelnation / http://github.com/abelnation\n\t */\n\n\tfunction RectAreaLight( color, intensity, width, height ) {\n\n\t\tLight.call( this, color, intensity );\n\n\t\tthis.type = 'RectAreaLight';\n\n\t\tthis.width = ( width !== undefined ) ? width : 10;\n\t\tthis.height = ( height !== undefined ) ? height : 10;\n\n\t}\n\n\tRectAreaLight.prototype = Object.assign( Object.create( Light.prototype ), {\n\n\t\tconstructor: RectAreaLight,\n\n\t\tisRectAreaLight: true,\n\n\t\tcopy: function ( source ) {\n\n\t\t\tLight.prototype.copy.call( this, source );\n\n\t\t\tthis.width = source.width;\n\t\t\tthis.height = source.height;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttoJSON: function ( meta ) {\n\n\t\t\tvar data = Light.prototype.toJSON.call( this, meta );\n\n\t\t\tdata.object.width = this.width;\n\t\t\tdata.object.height = this.height;\n\n\t\t\treturn data;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction MaterialLoader( manager ) {\n\n\t\tthis.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;\n\t\tthis.textures = {};\n\n\t}\n\n\tObject.assign( MaterialLoader.prototype, {\n\n\t\tload: function ( url, onLoad, onProgress, onError ) {\n\n\t\t\tvar scope = this;\n\n\t\t\tvar loader = new FileLoader( scope.manager );\n\t\t\tloader.setPath( scope.path );\n\t\t\tloader.load( url, function ( text ) {\n\n\t\t\t\tonLoad( scope.parse( JSON.parse( text ) ) );\n\n\t\t\t}, onProgress, onError );\n\n\t\t},\n\n\t\tparse: function ( json ) {\n\n\t\t\tvar textures = this.textures;\n\n\t\t\tfunction getTexture( name ) {\n\n\t\t\t\tif ( textures[ name ] === undefined ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.MaterialLoader: Undefined texture', name );\n\n\t\t\t\t}\n\n\t\t\t\treturn textures[ name ];\n\n\t\t\t}\n\n\t\t\tvar material = new Materials[ json.type ]();\n\n\t\t\tif ( json.uuid !== undefined ) material.uuid = json.uuid;\n\t\t\tif ( json.name !== undefined ) material.name = json.name;\n\t\t\tif ( json.color !== undefined ) material.color.setHex( json.color );\n\t\t\tif ( json.roughness !== undefined ) material.roughness = json.roughness;\n\t\t\tif ( json.metalness !== undefined ) material.metalness = json.metalness;\n\t\t\tif ( json.emissive !== undefined ) material.emissive.setHex( json.emissive );\n\t\t\tif ( json.specular !== undefined ) material.specular.setHex( json.specular );\n\t\t\tif ( json.shininess !== undefined ) material.shininess = json.shininess;\n\t\t\tif ( json.clearCoat !== undefined ) material.clearCoat = json.clearCoat;\n\t\t\tif ( json.clearCoatRoughness !== undefined ) material.clearCoatRoughness = json.clearCoatRoughness;\n\t\t\tif ( json.vertexColors !== undefined ) material.vertexColors = json.vertexColors;\n\t\t\tif ( json.fog !== undefined ) material.fog = json.fog;\n\t\t\tif ( json.flatShading !== undefined ) material.flatShading = json.flatShading;\n\t\t\tif ( json.blending !== undefined ) material.blending = json.blending;\n\t\t\tif ( json.combine !== undefined ) material.combine = json.combine;\n\t\t\tif ( json.side !== undefined ) material.side = json.side;\n\t\t\tif ( json.opacity !== undefined ) material.opacity = json.opacity;\n\t\t\tif ( json.transparent !== undefined ) material.transparent = json.transparent;\n\t\t\tif ( json.alphaTest !== undefined ) material.alphaTest = json.alphaTest;\n\t\t\tif ( json.depthTest !== undefined ) material.depthTest = json.depthTest;\n\t\t\tif ( json.depthWrite !== undefined ) material.depthWrite = json.depthWrite;\n\t\t\tif ( json.colorWrite !== undefined ) material.colorWrite = json.colorWrite;\n\t\t\tif ( json.wireframe !== undefined ) material.wireframe = json.wireframe;\n\t\t\tif ( json.wireframeLinewidth !== undefined ) material.wireframeLinewidth = json.wireframeLinewidth;\n\t\t\tif ( json.wireframeLinecap !== undefined ) material.wireframeLinecap = json.wireframeLinecap;\n\t\t\tif ( json.wireframeLinejoin !== undefined ) material.wireframeLinejoin = json.wireframeLinejoin;\n\n\t\t\tif ( json.rotation !== undefined ) material.rotation = json.rotation;\n\n\t\t\tif ( json.linewidth !== 1 ) material.linewidth = json.linewidth;\n\t\t\tif ( json.dashSize !== undefined ) material.dashSize = json.dashSize;\n\t\t\tif ( json.gapSize !== undefined ) material.gapSize = json.gapSize;\n\t\t\tif ( json.scale !== undefined ) material.scale = json.scale;\n\n\t\t\tif ( json.polygonOffset !== undefined ) material.polygonOffset = json.polygonOffset;\n\t\t\tif ( json.polygonOffsetFactor !== undefined ) material.polygonOffsetFactor = json.polygonOffsetFactor;\n\t\t\tif ( json.polygonOffsetUnits !== undefined ) material.polygonOffsetUnits = json.polygonOffsetUnits;\n\n\t\t\tif ( json.skinning !== undefined ) material.skinning = json.skinning;\n\t\t\tif ( json.morphTargets !== undefined ) material.morphTargets = json.morphTargets;\n\t\t\tif ( json.dithering !== undefined ) material.dithering = json.dithering;\n\n\t\t\tif ( json.visible !== undefined ) material.visible = json.visible;\n\t\t\tif ( json.userData !== undefined ) material.userData = json.userData;\n\n\t\t\t// Shader Material\n\n\t\t\tif ( json.uniforms !== undefined ) {\n\n\t\t\t\tfor ( var name in json.uniforms ) {\n\n\t\t\t\t\tvar uniform = json.uniforms[ name ];\n\n\t\t\t\t\tmaterial.uniforms[ name ] = {};\n\n\t\t\t\t\tswitch ( uniform.type ) {\n\n\t\t\t\t\t\tcase 't':\n\t\t\t\t\t\t\tmaterial.uniforms[ name ].value = getTexture( uniform.value );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'c':\n\t\t\t\t\t\t\tmaterial.uniforms[ name ].value = new Color().setHex( uniform.value );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'v2':\n\t\t\t\t\t\t\tmaterial.uniforms[ name ].value = new Vector2().fromArray( uniform.value );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'v3':\n\t\t\t\t\t\t\tmaterial.uniforms[ name ].value = new Vector3().fromArray( uniform.value );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'v4':\n\t\t\t\t\t\t\tmaterial.uniforms[ name ].value = new Vector4().fromArray( uniform.value );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'm4':\n\t\t\t\t\t\t\tmaterial.uniforms[ name ].value = new Matrix4().fromArray( uniform.value );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tmaterial.uniforms[ name ].value = uniform.value;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( json.defines !== undefined ) material.defines = json.defines;\n\t\t\tif ( json.vertexShader !== undefined ) material.vertexShader = json.vertexShader;\n\t\t\tif ( json.fragmentShader !== undefined ) material.fragmentShader = json.fragmentShader;\n\n\t\t\tif ( json.extensions !== undefined ) {\n\n\t\t\t\tfor ( var key in json.extensions ) {\n\n\t\t\t\t\tmaterial.extensions[ key ] = json.extensions[ key ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// Deprecated\n\n\t\t\tif ( json.shading !== undefined ) material.flatShading = json.shading === 1; // THREE.FlatShading\n\n\t\t\t// for PointsMaterial\n\n\t\t\tif ( json.size !== undefined ) material.size = json.size;\n\t\t\tif ( json.sizeAttenuation !== undefined ) material.sizeAttenuation = json.sizeAttenuation;\n\n\t\t\t// maps\n\n\t\t\tif ( json.map !== undefined ) material.map = getTexture( json.map );\n\n\t\t\tif ( json.alphaMap !== undefined ) {\n\n\t\t\t\tmaterial.alphaMap = getTexture( json.alphaMap );\n\t\t\t\tmaterial.transparent = true;\n\n\t\t\t}\n\n\t\t\tif ( json.bumpMap !== undefined ) material.bumpMap = getTexture( json.bumpMap );\n\t\t\tif ( json.bumpScale !== undefined ) material.bumpScale = json.bumpScale;\n\n\t\t\tif ( json.normalMap !== undefined ) material.normalMap = getTexture( json.normalMap );\n\t\t\tif ( json.normalMapType !== undefined ) material.normalMapType = json.normalMapType;\n\t\t\tif ( json.normalScale !== undefined ) {\n\n\t\t\t\tvar normalScale = json.normalScale;\n\n\t\t\t\tif ( Array.isArray( normalScale ) === false ) {\n\n\t\t\t\t\t// Blender exporter used to export a scalar. See #7459\n\n\t\t\t\t\tnormalScale = [ normalScale, normalScale ];\n\n\t\t\t\t}\n\n\t\t\t\tmaterial.normalScale = new Vector2().fromArray( normalScale );\n\n\t\t\t}\n\n\t\t\tif ( json.displacementMap !== undefined ) material.displacementMap = getTexture( json.displacementMap );\n\t\t\tif ( json.displacementScale !== undefined ) material.displacementScale = json.displacementScale;\n\t\t\tif ( json.displacementBias !== undefined ) material.displacementBias = json.displacementBias;\n\n\t\t\tif ( json.roughnessMap !== undefined ) material.roughnessMap = getTexture( json.roughnessMap );\n\t\t\tif ( json.metalnessMap !== undefined ) material.metalnessMap = getTexture( json.metalnessMap );\n\n\t\t\tif ( json.emissiveMap !== undefined ) material.emissiveMap = getTexture( json.emissiveMap );\n\t\t\tif ( json.emissiveIntensity !== undefined ) material.emissiveIntensity = json.emissiveIntensity;\n\n\t\t\tif ( json.specularMap !== undefined ) material.specularMap = getTexture( json.specularMap );\n\n\t\t\tif ( json.envMap !== undefined ) material.envMap = getTexture( json.envMap );\n\t\t\tif ( json.envMapIntensity !== undefined ) material.envMapIntensity = json.envMapIntensity;\n\n\t\t\tif ( json.reflectivity !== undefined ) material.reflectivity = json.reflectivity;\n\n\t\t\tif ( json.lightMap !== undefined ) material.lightMap = getTexture( json.lightMap );\n\t\t\tif ( json.lightMapIntensity !== undefined ) material.lightMapIntensity = json.lightMapIntensity;\n\n\t\t\tif ( json.aoMap !== undefined ) material.aoMap = getTexture( json.aoMap );\n\t\t\tif ( json.aoMapIntensity !== undefined ) material.aoMapIntensity = json.aoMapIntensity;\n\n\t\t\tif ( json.gradientMap !== undefined ) material.gradientMap = getTexture( json.gradientMap );\n\n\t\t\treturn material;\n\n\t\t},\n\n\t\tsetPath: function ( value ) {\n\n\t\t\tthis.path = value;\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetTextures: function ( value ) {\n\n\t\t\tthis.textures = value;\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author Don McCurdy / https://www.donmccurdy.com\n\t */\n\n\tvar LoaderUtils = {\n\n\t\tdecodeText: function ( array ) {\n\n\t\t\tif ( typeof TextDecoder !== 'undefined' ) {\n\n\t\t\t\treturn new TextDecoder().decode( array );\n\n\t\t\t}\n\n\t\t\t// Avoid the String.fromCharCode.apply(null, array) shortcut, which\n\t\t\t// throws a \"maximum call stack size exceeded\" error for large arrays.\n\n\t\t\tvar s = '';\n\n\t\t\tfor ( var i = 0, il = array.length; i < il; i ++ ) {\n\n\t\t\t\t// Implicitly assumes little-endian.\n\t\t\t\ts += String.fromCharCode( array[ i ] );\n\n\t\t\t}\n\n\t\t\t// Merges multi-byte utf-8 characters.\n\t\t\treturn decodeURIComponent( escape( s ) );\n\n\t\t},\n\n\t\textractUrlBase: function ( url ) {\n\n\t\t\tvar index = url.lastIndexOf( '/' );\n\n\t\t\tif ( index === - 1 ) return './';\n\n\t\t\treturn url.substr( 0, index + 1 );\n\n\t\t}\n\n\t};\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction BufferGeometryLoader( manager ) {\n\n\t\tthis.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;\n\n\t}\n\n\tObject.assign( BufferGeometryLoader.prototype, {\n\n\t\tload: function ( url, onLoad, onProgress, onError ) {\n\n\t\t\tvar scope = this;\n\n\t\t\tvar loader = new FileLoader( scope.manager );\n\t\t\tloader.setPath( scope.path );\n\t\t\tloader.load( url, function ( text ) {\n\n\t\t\t\tonLoad( scope.parse( JSON.parse( text ) ) );\n\n\t\t\t}, onProgress, onError );\n\n\t\t},\n\n\t\tparse: function ( json ) {\n\n\t\t\tvar geometry = new BufferGeometry();\n\n\t\t\tvar index = json.data.index;\n\n\t\t\tif ( index !== undefined ) {\n\n\t\t\t\tvar typedArray = new TYPED_ARRAYS[ index.type ]( index.array );\n\t\t\t\tgeometry.setIndex( new BufferAttribute( typedArray, 1 ) );\n\n\t\t\t}\n\n\t\t\tvar attributes = json.data.attributes;\n\n\t\t\tfor ( var key in attributes ) {\n\n\t\t\t\tvar attribute = attributes[ key ];\n\t\t\t\tvar typedArray = new TYPED_ARRAYS[ attribute.type ]( attribute.array );\n\n\t\t\t\tgeometry.addAttribute( key, new BufferAttribute( typedArray, attribute.itemSize, attribute.normalized ) );\n\n\t\t\t}\n\n\t\t\tvar groups = json.data.groups || json.data.drawcalls || json.data.offsets;\n\n\t\t\tif ( groups !== undefined ) {\n\n\t\t\t\tfor ( var i = 0, n = groups.length; i !== n; ++ i ) {\n\n\t\t\t\t\tvar group = groups[ i ];\n\n\t\t\t\t\tgeometry.addGroup( group.start, group.count, group.materialIndex );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tvar boundingSphere = json.data.boundingSphere;\n\n\t\t\tif ( boundingSphere !== undefined ) {\n\n\t\t\t\tvar center = new Vector3();\n\n\t\t\t\tif ( boundingSphere.center !== undefined ) {\n\n\t\t\t\t\tcenter.fromArray( boundingSphere.center );\n\n\t\t\t\t}\n\n\t\t\t\tgeometry.boundingSphere = new Sphere( center, boundingSphere.radius );\n\n\t\t\t}\n\n\t\t\tif ( json.name ) geometry.name = json.name;\n\t\t\tif ( json.userData ) geometry.userData = json.userData;\n\n\t\t\treturn geometry;\n\n\t\t},\n\n\t\tsetPath: function ( value ) {\n\n\t\t\tthis.path = value;\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\tvar TYPED_ARRAYS = {\n\t\tInt8Array: Int8Array,\n\t\tUint8Array: Uint8Array,\n\t\t// Workaround for IE11 pre KB2929437. See #11440\n\t\tUint8ClampedArray: typeof Uint8ClampedArray !== 'undefined' ? Uint8ClampedArray : Uint8Array,\n\t\tInt16Array: Int16Array,\n\t\tUint16Array: Uint16Array,\n\t\tInt32Array: Int32Array,\n\t\tUint32Array: Uint32Array,\n\t\tFloat32Array: Float32Array,\n\t\tFloat64Array: Float64Array\n\t};\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction ObjectLoader( manager ) {\n\n\t\tthis.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;\n\t\tthis.resourcePath = '';\n\n\t}\n\n\tObject.assign( ObjectLoader.prototype, {\n\n\t\tcrossOrigin: 'anonymous',\n\n\t\tload: function ( url, onLoad, onProgress, onError ) {\n\n\t\t\tvar scope = this;\n\n\t\t\tvar path = ( this.path === undefined ) ? LoaderUtils.extractUrlBase( url ) : this.path;\n\t\t\tthis.resourcePath = this.resourcePath || path;\n\n\t\t\tvar loader = new FileLoader( scope.manager );\n\t\t\tloader.setPath( this.path );\n\t\t\tloader.load( url, function ( text ) {\n\n\t\t\t\tvar json = null;\n\n\t\t\t\ttry {\n\n\t\t\t\t\tjson = JSON.parse( text );\n\n\t\t\t\t} catch ( error ) {\n\n\t\t\t\t\tif ( onError !== undefined ) onError( error );\n\n\t\t\t\t\tconsole.error( 'THREE:ObjectLoader: Can\\'t parse ' + url + '.', error.message );\n\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t\tvar metadata = json.metadata;\n\n\t\t\t\tif ( metadata === undefined || metadata.type === undefined || metadata.type.toLowerCase() === 'geometry' ) {\n\n\t\t\t\t\tconsole.error( 'THREE.ObjectLoader: Can\\'t load ' + url );\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t\tscope.parse( json, onLoad );\n\n\t\t\t}, onProgress, onError );\n\n\t\t},\n\n\t\tsetPath: function ( value ) {\n\n\t\t\tthis.path = value;\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetResourcePath: function ( value ) {\n\n\t\t\tthis.resourcePath = value;\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetCrossOrigin: function ( value ) {\n\n\t\t\tthis.crossOrigin = value;\n\t\t\treturn this;\n\n\t\t},\n\n\t\tparse: function ( json, onLoad ) {\n\n\t\t\tvar shapes = this.parseShape( json.shapes );\n\t\t\tvar geometries = this.parseGeometries( json.geometries, shapes );\n\n\t\t\tvar images = this.parseImages( json.images, function () {\n\n\t\t\t\tif ( onLoad !== undefined ) onLoad( object );\n\n\t\t\t} );\n\n\t\t\tvar textures = this.parseTextures( json.textures, images );\n\t\t\tvar materials = this.parseMaterials( json.materials, textures );\n\n\t\t\tvar object = this.parseObject( json.object, geometries, materials );\n\n\t\t\tif ( json.animations ) {\n\n\t\t\t\tobject.animations = this.parseAnimations( json.animations );\n\n\t\t\t}\n\n\t\t\tif ( json.images === undefined || json.images.length === 0 ) {\n\n\t\t\t\tif ( onLoad !== undefined ) onLoad( object );\n\n\t\t\t}\n\n\t\t\treturn object;\n\n\t\t},\n\n\t\tparseShape: function ( json ) {\n\n\t\t\tvar shapes = {};\n\n\t\t\tif ( json !== undefined ) {\n\n\t\t\t\tfor ( var i = 0, l = json.length; i < l; i ++ ) {\n\n\t\t\t\t\tvar shape = new Shape().fromJSON( json[ i ] );\n\n\t\t\t\t\tshapes[ shape.uuid ] = shape;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn shapes;\n\n\t\t},\n\n\t\tparseGeometries: function ( json, shapes ) {\n\n\t\t\tvar geometries = {};\n\n\t\t\tif ( json !== undefined ) {\n\n\t\t\t\tvar bufferGeometryLoader = new BufferGeometryLoader();\n\n\t\t\t\tfor ( var i = 0, l = json.length; i < l; i ++ ) {\n\n\t\t\t\t\tvar geometry;\n\t\t\t\t\tvar data = json[ i ];\n\n\t\t\t\t\tswitch ( data.type ) {\n\n\t\t\t\t\t\tcase 'PlaneGeometry':\n\t\t\t\t\t\tcase 'PlaneBufferGeometry':\n\n\t\t\t\t\t\t\tgeometry = new Geometries[ data.type ](\n\t\t\t\t\t\t\t\tdata.width,\n\t\t\t\t\t\t\t\tdata.height,\n\t\t\t\t\t\t\t\tdata.widthSegments,\n\t\t\t\t\t\t\t\tdata.heightSegments\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'BoxGeometry':\n\t\t\t\t\t\tcase 'BoxBufferGeometry':\n\t\t\t\t\t\tcase 'CubeGeometry': // backwards compatible\n\n\t\t\t\t\t\t\tgeometry = new Geometries[ data.type ](\n\t\t\t\t\t\t\t\tdata.width,\n\t\t\t\t\t\t\t\tdata.height,\n\t\t\t\t\t\t\t\tdata.depth,\n\t\t\t\t\t\t\t\tdata.widthSegments,\n\t\t\t\t\t\t\t\tdata.heightSegments,\n\t\t\t\t\t\t\t\tdata.depthSegments\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'CircleGeometry':\n\t\t\t\t\t\tcase 'CircleBufferGeometry':\n\n\t\t\t\t\t\t\tgeometry = new Geometries[ data.type ](\n\t\t\t\t\t\t\t\tdata.radius,\n\t\t\t\t\t\t\t\tdata.segments,\n\t\t\t\t\t\t\t\tdata.thetaStart,\n\t\t\t\t\t\t\t\tdata.thetaLength\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'CylinderGeometry':\n\t\t\t\t\t\tcase 'CylinderBufferGeometry':\n\n\t\t\t\t\t\t\tgeometry = new Geometries[ data.type ](\n\t\t\t\t\t\t\t\tdata.radiusTop,\n\t\t\t\t\t\t\t\tdata.radiusBottom,\n\t\t\t\t\t\t\t\tdata.height,\n\t\t\t\t\t\t\t\tdata.radialSegments,\n\t\t\t\t\t\t\t\tdata.heightSegments,\n\t\t\t\t\t\t\t\tdata.openEnded,\n\t\t\t\t\t\t\t\tdata.thetaStart,\n\t\t\t\t\t\t\t\tdata.thetaLength\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'ConeGeometry':\n\t\t\t\t\t\tcase 'ConeBufferGeometry':\n\n\t\t\t\t\t\t\tgeometry = new Geometries[ data.type ](\n\t\t\t\t\t\t\t\tdata.radius,\n\t\t\t\t\t\t\t\tdata.height,\n\t\t\t\t\t\t\t\tdata.radialSegments,\n\t\t\t\t\t\t\t\tdata.heightSegments,\n\t\t\t\t\t\t\t\tdata.openEnded,\n\t\t\t\t\t\t\t\tdata.thetaStart,\n\t\t\t\t\t\t\t\tdata.thetaLength\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'SphereGeometry':\n\t\t\t\t\t\tcase 'SphereBufferGeometry':\n\n\t\t\t\t\t\t\tgeometry = new Geometries[ data.type ](\n\t\t\t\t\t\t\t\tdata.radius,\n\t\t\t\t\t\t\t\tdata.widthSegments,\n\t\t\t\t\t\t\t\tdata.heightSegments,\n\t\t\t\t\t\t\t\tdata.phiStart,\n\t\t\t\t\t\t\t\tdata.phiLength,\n\t\t\t\t\t\t\t\tdata.thetaStart,\n\t\t\t\t\t\t\t\tdata.thetaLength\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'DodecahedronGeometry':\n\t\t\t\t\t\tcase 'DodecahedronBufferGeometry':\n\t\t\t\t\t\tcase 'IcosahedronGeometry':\n\t\t\t\t\t\tcase 'IcosahedronBufferGeometry':\n\t\t\t\t\t\tcase 'OctahedronGeometry':\n\t\t\t\t\t\tcase 'OctahedronBufferGeometry':\n\t\t\t\t\t\tcase 'TetrahedronGeometry':\n\t\t\t\t\t\tcase 'TetrahedronBufferGeometry':\n\n\t\t\t\t\t\t\tgeometry = new Geometries[ data.type ](\n\t\t\t\t\t\t\t\tdata.radius,\n\t\t\t\t\t\t\t\tdata.detail\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'RingGeometry':\n\t\t\t\t\t\tcase 'RingBufferGeometry':\n\n\t\t\t\t\t\t\tgeometry = new Geometries[ data.type ](\n\t\t\t\t\t\t\t\tdata.innerRadius,\n\t\t\t\t\t\t\t\tdata.outerRadius,\n\t\t\t\t\t\t\t\tdata.thetaSegments,\n\t\t\t\t\t\t\t\tdata.phiSegments,\n\t\t\t\t\t\t\t\tdata.thetaStart,\n\t\t\t\t\t\t\t\tdata.thetaLength\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'TorusGeometry':\n\t\t\t\t\t\tcase 'TorusBufferGeometry':\n\n\t\t\t\t\t\t\tgeometry = new Geometries[ data.type ](\n\t\t\t\t\t\t\t\tdata.radius,\n\t\t\t\t\t\t\t\tdata.tube,\n\t\t\t\t\t\t\t\tdata.radialSegments,\n\t\t\t\t\t\t\t\tdata.tubularSegments,\n\t\t\t\t\t\t\t\tdata.arc\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'TorusKnotGeometry':\n\t\t\t\t\t\tcase 'TorusKnotBufferGeometry':\n\n\t\t\t\t\t\t\tgeometry = new Geometries[ data.type ](\n\t\t\t\t\t\t\t\tdata.radius,\n\t\t\t\t\t\t\t\tdata.tube,\n\t\t\t\t\t\t\t\tdata.tubularSegments,\n\t\t\t\t\t\t\t\tdata.radialSegments,\n\t\t\t\t\t\t\t\tdata.p,\n\t\t\t\t\t\t\t\tdata.q\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'LatheGeometry':\n\t\t\t\t\t\tcase 'LatheBufferGeometry':\n\n\t\t\t\t\t\t\tgeometry = new Geometries[ data.type ](\n\t\t\t\t\t\t\t\tdata.points,\n\t\t\t\t\t\t\t\tdata.segments,\n\t\t\t\t\t\t\t\tdata.phiStart,\n\t\t\t\t\t\t\t\tdata.phiLength\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'PolyhedronGeometry':\n\t\t\t\t\t\tcase 'PolyhedronBufferGeometry':\n\n\t\t\t\t\t\t\tgeometry = new Geometries[ data.type ](\n\t\t\t\t\t\t\t\tdata.vertices,\n\t\t\t\t\t\t\t\tdata.indices,\n\t\t\t\t\t\t\t\tdata.radius,\n\t\t\t\t\t\t\t\tdata.details\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'ShapeGeometry':\n\t\t\t\t\t\tcase 'ShapeBufferGeometry':\n\n\t\t\t\t\t\t\tvar geometryShapes = [];\n\n\t\t\t\t\t\t\tfor ( var j = 0, jl = data.shapes.length; j < jl; j ++ ) {\n\n\t\t\t\t\t\t\t\tvar shape = shapes[ data.shapes[ j ] ];\n\n\t\t\t\t\t\t\t\tgeometryShapes.push( shape );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tgeometry = new Geometries[ data.type ](\n\t\t\t\t\t\t\t\tgeometryShapes,\n\t\t\t\t\t\t\t\tdata.curveSegments\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tbreak;\n\n\n\t\t\t\t\t\tcase 'ExtrudeGeometry':\n\t\t\t\t\t\tcase 'ExtrudeBufferGeometry':\n\n\t\t\t\t\t\t\tvar geometryShapes = [];\n\n\t\t\t\t\t\t\tfor ( var j = 0, jl = data.shapes.length; j < jl; j ++ ) {\n\n\t\t\t\t\t\t\t\tvar shape = shapes[ data.shapes[ j ] ];\n\n\t\t\t\t\t\t\t\tgeometryShapes.push( shape );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tvar extrudePath = data.options.extrudePath;\n\n\t\t\t\t\t\t\tif ( extrudePath !== undefined ) {\n\n\t\t\t\t\t\t\t\tdata.options.extrudePath = new Curves[ extrudePath.type ]().fromJSON( extrudePath );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tgeometry = new Geometries[ data.type ](\n\t\t\t\t\t\t\t\tgeometryShapes,\n\t\t\t\t\t\t\t\tdata.options\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'BufferGeometry':\n\n\t\t\t\t\t\t\tgeometry = bufferGeometryLoader.parse( data );\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'Geometry':\n\n\t\t\t\t\t\t\tif ( 'THREE' in window && 'LegacyJSONLoader' in THREE ) {\n\n\t\t\t\t\t\t\t\tvar geometryLoader = new THREE.LegacyJSONLoader();\n\t\t\t\t\t\t\t\tgeometry = geometryLoader.parse( data, this.resourcePath ).geometry;\n\n\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\tconsole.error( 'THREE.ObjectLoader: You have to import LegacyJSONLoader in order load geometry data of type \"Geometry\".' );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\n\t\t\t\t\t\t\tconsole.warn( 'THREE.ObjectLoader: Unsupported geometry type \"' + data.type + '\"' );\n\n\t\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tgeometry.uuid = data.uuid;\n\n\t\t\t\t\tif ( data.name !== undefined ) geometry.name = data.name;\n\t\t\t\t\tif ( geometry.isBufferGeometry === true && data.userData !== undefined ) geometry.userData = data.userData;\n\n\t\t\t\t\tgeometries[ data.uuid ] = geometry;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn geometries;\n\n\t\t},\n\n\t\tparseMaterials: function ( json, textures ) {\n\n\t\t\tvar cache = {}; // MultiMaterial\n\t\t\tvar materials = {};\n\n\t\t\tif ( json !== undefined ) {\n\n\t\t\t\tvar loader = new MaterialLoader();\n\t\t\t\tloader.setTextures( textures );\n\n\t\t\t\tfor ( var i = 0, l = json.length; i < l; i ++ ) {\n\n\t\t\t\t\tvar data = json[ i ];\n\n\t\t\t\t\tif ( data.type === 'MultiMaterial' ) {\n\n\t\t\t\t\t\t// Deprecated\n\n\t\t\t\t\t\tvar array = [];\n\n\t\t\t\t\t\tfor ( var j = 0; j < data.materials.length; j ++ ) {\n\n\t\t\t\t\t\t\tvar material = data.materials[ j ];\n\n\t\t\t\t\t\t\tif ( cache[ material.uuid ] === undefined ) {\n\n\t\t\t\t\t\t\t\tcache[ material.uuid ] = loader.parse( material );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tarray.push( cache[ material.uuid ] );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tmaterials[ data.uuid ] = array;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tmaterials[ data.uuid ] = loader.parse( data );\n\t\t\t\t\t\tcache[ data.uuid ] = materials[ data.uuid ];\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn materials;\n\n\t\t},\n\n\t\tparseAnimations: function ( json ) {\n\n\t\t\tvar animations = [];\n\n\t\t\tfor ( var i = 0; i < json.length; i ++ ) {\n\n\t\t\t\tvar data = json[ i ];\n\n\t\t\t\tvar clip = AnimationClip.parse( data );\n\n\t\t\t\tif ( data.uuid !== undefined ) clip.uuid = data.uuid;\n\n\t\t\t\tanimations.push( clip );\n\n\t\t\t}\n\n\t\t\treturn animations;\n\n\t\t},\n\n\t\tparseImages: function ( json, onLoad ) {\n\n\t\t\tvar scope = this;\n\t\t\tvar images = {};\n\n\t\t\tfunction loadImage( url ) {\n\n\t\t\t\tscope.manager.itemStart( url );\n\n\t\t\t\treturn loader.load( url, function () {\n\n\t\t\t\t\tscope.manager.itemEnd( url );\n\n\t\t\t\t}, undefined, function () {\n\n\t\t\t\t\tscope.manager.itemError( url );\n\t\t\t\t\tscope.manager.itemEnd( url );\n\n\t\t\t\t} );\n\n\t\t\t}\n\n\t\t\tif ( json !== undefined && json.length > 0 ) {\n\n\t\t\t\tvar manager = new LoadingManager( onLoad );\n\n\t\t\t\tvar loader = new ImageLoader( manager );\n\t\t\t\tloader.setCrossOrigin( this.crossOrigin );\n\n\t\t\t\tfor ( var i = 0, il = json.length; i < il; i ++ ) {\n\n\t\t\t\t\tvar image = json[ i ];\n\t\t\t\t\tvar url = image.url;\n\n\t\t\t\t\tif ( Array.isArray( url ) ) {\n\n\t\t\t\t\t\t// load array of images e.g CubeTexture\n\n\t\t\t\t\t\timages[ image.uuid ] = [];\n\n\t\t\t\t\t\tfor ( var j = 0, jl = url.length; j < jl; j ++ ) {\n\n\t\t\t\t\t\t\tvar currentUrl = url[ j ];\n\n\t\t\t\t\t\t\tvar path = /^(\\/\\/)|([a-z]+:(\\/\\/)?)/i.test( currentUrl ) ? currentUrl : scope.resourcePath + currentUrl;\n\n\t\t\t\t\t\t\timages[ image.uuid ].push( loadImage( path ) );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// load single image\n\n\t\t\t\t\t\tvar path = /^(\\/\\/)|([a-z]+:(\\/\\/)?)/i.test( image.url ) ? image.url : scope.resourcePath + image.url;\n\n\t\t\t\t\t\timages[ image.uuid ] = loadImage( path );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn images;\n\n\t\t},\n\n\t\tparseTextures: function ( json, images ) {\n\n\t\t\tfunction parseConstant( value, type ) {\n\n\t\t\t\tif ( typeof value === 'number' ) return value;\n\n\t\t\t\tconsole.warn( 'THREE.ObjectLoader.parseTexture: Constant should be in numeric form.', value );\n\n\t\t\t\treturn type[ value ];\n\n\t\t\t}\n\n\t\t\tvar textures = {};\n\n\t\t\tif ( json !== undefined ) {\n\n\t\t\t\tfor ( var i = 0, l = json.length; i < l; i ++ ) {\n\n\t\t\t\t\tvar data = json[ i ];\n\n\t\t\t\t\tif ( data.image === undefined ) {\n\n\t\t\t\t\t\tconsole.warn( 'THREE.ObjectLoader: No \"image\" specified for', data.uuid );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( images[ data.image ] === undefined ) {\n\n\t\t\t\t\t\tconsole.warn( 'THREE.ObjectLoader: Undefined image', data.image );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tvar texture;\n\n\t\t\t\t\tif ( Array.isArray( images[ data.image ] ) ) {\n\n\t\t\t\t\t\ttexture = new CubeTexture( images[ data.image ] );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\ttexture = new Texture( images[ data.image ] );\n\n\t\t\t\t\t}\n\n\t\t\t\t\ttexture.needsUpdate = true;\n\n\t\t\t\t\ttexture.uuid = data.uuid;\n\n\t\t\t\t\tif ( data.name !== undefined ) texture.name = data.name;\n\n\t\t\t\t\tif ( data.mapping !== undefined ) texture.mapping = parseConstant( data.mapping, TEXTURE_MAPPING );\n\n\t\t\t\t\tif ( data.offset !== undefined ) texture.offset.fromArray( data.offset );\n\t\t\t\t\tif ( data.repeat !== undefined ) texture.repeat.fromArray( data.repeat );\n\t\t\t\t\tif ( data.center !== undefined ) texture.center.fromArray( data.center );\n\t\t\t\t\tif ( data.rotation !== undefined ) texture.rotation = data.rotation;\n\n\t\t\t\t\tif ( data.wrap !== undefined ) {\n\n\t\t\t\t\t\ttexture.wrapS = parseConstant( data.wrap[ 0 ], TEXTURE_WRAPPING );\n\t\t\t\t\t\ttexture.wrapT = parseConstant( data.wrap[ 1 ], TEXTURE_WRAPPING );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( data.format !== undefined ) texture.format = data.format;\n\t\t\t\t\tif ( data.type !== undefined ) texture.type = data.type;\n\t\t\t\t\tif ( data.encoding !== undefined ) texture.encoding = data.encoding;\n\n\t\t\t\t\tif ( data.minFilter !== undefined ) texture.minFilter = parseConstant( data.minFilter, TEXTURE_FILTER );\n\t\t\t\t\tif ( data.magFilter !== undefined ) texture.magFilter = parseConstant( data.magFilter, TEXTURE_FILTER );\n\t\t\t\t\tif ( data.anisotropy !== undefined ) texture.anisotropy = data.anisotropy;\n\n\t\t\t\t\tif ( data.flipY !== undefined ) texture.flipY = data.flipY;\n\n\t\t\t\t\tif ( data.premultiplyAlpha !== undefined ) texture.premultiplyAlpha = data.premultiplyAlpha;\n\t\t\t\t\tif ( data.unpackAlignment !== undefined ) texture.unpackAlignment = data.unpackAlignment;\n\n\t\t\t\t\ttextures[ data.uuid ] = texture;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn textures;\n\n\t\t},\n\n\t\tparseObject: function ( data, geometries, materials ) {\n\n\t\t\tvar object;\n\n\t\t\tfunction getGeometry( name ) {\n\n\t\t\t\tif ( geometries[ name ] === undefined ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.ObjectLoader: Undefined geometry', name );\n\n\t\t\t\t}\n\n\t\t\t\treturn geometries[ name ];\n\n\t\t\t}\n\n\t\t\tfunction getMaterial( name ) {\n\n\t\t\t\tif ( name === undefined ) return undefined;\n\n\t\t\t\tif ( Array.isArray( name ) ) {\n\n\t\t\t\t\tvar array = [];\n\n\t\t\t\t\tfor ( var i = 0, l = name.length; i < l; i ++ ) {\n\n\t\t\t\t\t\tvar uuid = name[ i ];\n\n\t\t\t\t\t\tif ( materials[ uuid ] === undefined ) {\n\n\t\t\t\t\t\t\tconsole.warn( 'THREE.ObjectLoader: Undefined material', uuid );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tarray.push( materials[ uuid ] );\n\n\t\t\t\t\t}\n\n\t\t\t\t\treturn array;\n\n\t\t\t\t}\n\n\t\t\t\tif ( materials[ name ] === undefined ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.ObjectLoader: Undefined material', name );\n\n\t\t\t\t}\n\n\t\t\t\treturn materials[ name ];\n\n\t\t\t}\n\n\t\t\tswitch ( data.type ) {\n\n\t\t\t\tcase 'Scene':\n\n\t\t\t\t\tobject = new Scene();\n\n\t\t\t\t\tif ( data.background !== undefined ) {\n\n\t\t\t\t\t\tif ( Number.isInteger( data.background ) ) {\n\n\t\t\t\t\t\t\tobject.background = new Color( data.background );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( data.fog !== undefined ) {\n\n\t\t\t\t\t\tif ( data.fog.type === 'Fog' ) {\n\n\t\t\t\t\t\t\tobject.fog = new Fog( data.fog.color, data.fog.near, data.fog.far );\n\n\t\t\t\t\t\t} else if ( data.fog.type === 'FogExp2' ) {\n\n\t\t\t\t\t\t\tobject.fog = new FogExp2( data.fog.color, data.fog.density );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'PerspectiveCamera':\n\n\t\t\t\t\tobject = new PerspectiveCamera( data.fov, data.aspect, data.near, data.far );\n\n\t\t\t\t\tif ( data.focus !== undefined ) object.focus = data.focus;\n\t\t\t\t\tif ( data.zoom !== undefined ) object.zoom = data.zoom;\n\t\t\t\t\tif ( data.filmGauge !== undefined ) object.filmGauge = data.filmGauge;\n\t\t\t\t\tif ( data.filmOffset !== undefined ) object.filmOffset = data.filmOffset;\n\t\t\t\t\tif ( data.view !== undefined ) object.view = Object.assign( {}, data.view );\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'OrthographicCamera':\n\n\t\t\t\t\tobject = new OrthographicCamera( data.left, data.right, data.top, data.bottom, data.near, data.far );\n\n\t\t\t\t\tif ( data.zoom !== undefined ) object.zoom = data.zoom;\n\t\t\t\t\tif ( data.view !== undefined ) object.view = Object.assign( {}, data.view );\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'AmbientLight':\n\n\t\t\t\t\tobject = new AmbientLight( data.color, data.intensity );\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'DirectionalLight':\n\n\t\t\t\t\tobject = new DirectionalLight( data.color, data.intensity );\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'PointLight':\n\n\t\t\t\t\tobject = new PointLight( data.color, data.intensity, data.distance, data.decay );\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'RectAreaLight':\n\n\t\t\t\t\tobject = new RectAreaLight( data.color, data.intensity, data.width, data.height );\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'SpotLight':\n\n\t\t\t\t\tobject = new SpotLight( data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay );\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'HemisphereLight':\n\n\t\t\t\t\tobject = new HemisphereLight( data.color, data.groundColor, data.intensity );\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'SkinnedMesh':\n\n\t\t\t\t\tconsole.warn( 'THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.' );\n\n\t\t\t\tcase 'Mesh':\n\n\t\t\t\t\tvar geometry = getGeometry( data.geometry );\n\t\t\t\t\tvar material = getMaterial( data.material );\n\n\t\t\t\t\tif ( geometry.bones && geometry.bones.length > 0 ) {\n\n\t\t\t\t\t\tobject = new SkinnedMesh( geometry, material );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tobject = new Mesh( geometry, material );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'LOD':\n\n\t\t\t\t\tobject = new LOD();\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Line':\n\n\t\t\t\t\tobject = new Line( getGeometry( data.geometry ), getMaterial( data.material ), data.mode );\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'LineLoop':\n\n\t\t\t\t\tobject = new LineLoop( getGeometry( data.geometry ), getMaterial( data.material ) );\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'LineSegments':\n\n\t\t\t\t\tobject = new LineSegments( getGeometry( data.geometry ), getMaterial( data.material ) );\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'PointCloud':\n\t\t\t\tcase 'Points':\n\n\t\t\t\t\tobject = new Points( getGeometry( data.geometry ), getMaterial( data.material ) );\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Sprite':\n\n\t\t\t\t\tobject = new Sprite( getMaterial( data.material ) );\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Group':\n\n\t\t\t\t\tobject = new Group();\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\n\t\t\t\t\tobject = new Object3D();\n\n\t\t\t}\n\n\t\t\tobject.uuid = data.uuid;\n\n\t\t\tif ( data.name !== undefined ) object.name = data.name;\n\n\t\t\tif ( data.matrix !== undefined ) {\n\n\t\t\t\tobject.matrix.fromArray( data.matrix );\n\n\t\t\t\tif ( data.matrixAutoUpdate !== undefined ) object.matrixAutoUpdate = data.matrixAutoUpdate;\n\t\t\t\tif ( object.matrixAutoUpdate ) object.matrix.decompose( object.position, object.quaternion, object.scale );\n\n\t\t\t} else {\n\n\t\t\t\tif ( data.position !== undefined ) object.position.fromArray( data.position );\n\t\t\t\tif ( data.rotation !== undefined ) object.rotation.fromArray( data.rotation );\n\t\t\t\tif ( data.quaternion !== undefined ) object.quaternion.fromArray( data.quaternion );\n\t\t\t\tif ( data.scale !== undefined ) object.scale.fromArray( data.scale );\n\n\t\t\t}\n\n\t\t\tif ( data.castShadow !== undefined ) object.castShadow = data.castShadow;\n\t\t\tif ( data.receiveShadow !== undefined ) object.receiveShadow = data.receiveShadow;\n\n\t\t\tif ( data.shadow ) {\n\n\t\t\t\tif ( data.shadow.bias !== undefined ) object.shadow.bias = data.shadow.bias;\n\t\t\t\tif ( data.shadow.radius !== undefined ) object.shadow.radius = data.shadow.radius;\n\t\t\t\tif ( data.shadow.mapSize !== undefined ) object.shadow.mapSize.fromArray( data.shadow.mapSize );\n\t\t\t\tif ( data.shadow.camera !== undefined ) object.shadow.camera = this.parseObject( data.shadow.camera );\n\n\t\t\t}\n\n\t\t\tif ( data.visible !== undefined ) object.visible = data.visible;\n\t\t\tif ( data.frustumCulled !== undefined ) object.frustumCulled = data.frustumCulled;\n\t\t\tif ( data.renderOrder !== undefined ) object.renderOrder = data.renderOrder;\n\t\t\tif ( data.userData !== undefined ) object.userData = data.userData;\n\t\t\tif ( data.layers !== undefined ) object.layers.mask = data.layers;\n\n\t\t\tif ( data.children !== undefined ) {\n\n\t\t\t\tvar children = data.children;\n\n\t\t\t\tfor ( var i = 0; i < children.length; i ++ ) {\n\n\t\t\t\t\tobject.add( this.parseObject( children[ i ], geometries, materials ) );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( data.type === 'LOD' ) {\n\n\t\t\t\tvar levels = data.levels;\n\n\t\t\t\tfor ( var l = 0; l < levels.length; l ++ ) {\n\n\t\t\t\t\tvar level = levels[ l ];\n\t\t\t\t\tvar child = object.getObjectByProperty( 'uuid', level.object );\n\n\t\t\t\t\tif ( child !== undefined ) {\n\n\t\t\t\t\t\tobject.addLevel( child, level.distance );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn object;\n\n\t\t}\n\n\t} );\n\n\tvar TEXTURE_MAPPING = {\n\t\tUVMapping: UVMapping,\n\t\tCubeReflectionMapping: CubeReflectionMapping,\n\t\tCubeRefractionMapping: CubeRefractionMapping,\n\t\tEquirectangularReflectionMapping: EquirectangularReflectionMapping,\n\t\tEquirectangularRefractionMapping: EquirectangularRefractionMapping,\n\t\tSphericalReflectionMapping: SphericalReflectionMapping,\n\t\tCubeUVReflectionMapping: CubeUVReflectionMapping,\n\t\tCubeUVRefractionMapping: CubeUVRefractionMapping\n\t};\n\n\tvar TEXTURE_WRAPPING = {\n\t\tRepeatWrapping: RepeatWrapping,\n\t\tClampToEdgeWrapping: ClampToEdgeWrapping,\n\t\tMirroredRepeatWrapping: MirroredRepeatWrapping\n\t};\n\n\tvar TEXTURE_FILTER = {\n\t\tNearestFilter: NearestFilter,\n\t\tNearestMipMapNearestFilter: NearestMipMapNearestFilter,\n\t\tNearestMipMapLinearFilter: NearestMipMapLinearFilter,\n\t\tLinearFilter: LinearFilter,\n\t\tLinearMipMapNearestFilter: LinearMipMapNearestFilter,\n\t\tLinearMipMapLinearFilter: LinearMipMapLinearFilter\n\t};\n\n\t/**\n\t * @author thespite / http://clicktorelease.com/\n\t */\n\n\n\tfunction ImageBitmapLoader( manager ) {\n\n\t\tif ( typeof createImageBitmap === 'undefined' ) {\n\n\t\t\tconsole.warn( 'THREE.ImageBitmapLoader: createImageBitmap() not supported.' );\n\n\t\t}\n\n\t\tif ( typeof fetch === 'undefined' ) {\n\n\t\t\tconsole.warn( 'THREE.ImageBitmapLoader: fetch() not supported.' );\n\n\t\t}\n\n\t\tthis.manager = manager !== undefined ? manager : DefaultLoadingManager;\n\t\tthis.options = undefined;\n\n\t}\n\n\tImageBitmapLoader.prototype = {\n\n\t\tconstructor: ImageBitmapLoader,\n\n\t\tsetOptions: function setOptions( options ) {\n\n\t\t\tthis.options = options;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tload: function ( url, onLoad, onProgress, onError ) {\n\n\t\t\tif ( url === undefined ) url = '';\n\n\t\t\tif ( this.path !== undefined ) url = this.path + url;\n\n\t\t\turl = this.manager.resolveURL( url );\n\n\t\t\tvar scope = this;\n\n\t\t\tvar cached = Cache.get( url );\n\n\t\t\tif ( cached !== undefined ) {\n\n\t\t\t\tscope.manager.itemStart( url );\n\n\t\t\t\tsetTimeout( function () {\n\n\t\t\t\t\tif ( onLoad ) onLoad( cached );\n\n\t\t\t\t\tscope.manager.itemEnd( url );\n\n\t\t\t\t}, 0 );\n\n\t\t\t\treturn cached;\n\n\t\t\t}\n\n\t\t\tfetch( url ).then( function ( res ) {\n\n\t\t\t\treturn res.blob();\n\n\t\t\t} ).then( function ( blob ) {\n\n\t\t\t\treturn createImageBitmap( blob, scope.options );\n\n\t\t\t} ).then( function ( imageBitmap ) {\n\n\t\t\t\tCache.add( url, imageBitmap );\n\n\t\t\t\tif ( onLoad ) onLoad( imageBitmap );\n\n\t\t\t\tscope.manager.itemEnd( url );\n\n\t\t\t} ).catch( function ( e ) {\n\n\t\t\t\tif ( onError ) onError( e );\n\n\t\t\t\tscope.manager.itemError( url );\n\t\t\t\tscope.manager.itemEnd( url );\n\n\t\t\t} );\n\n\t\t},\n\n\t\tsetCrossOrigin: function ( /* value */ ) {\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetPath: function ( value ) {\n\n\t\t\tthis.path = value;\n\t\t\treturn this;\n\n\t\t}\n\n\t};\n\n\t/**\n\t * @author zz85 / http://www.lab4games.net/zz85/blog\n\t * minimal class for proxing functions to Path. Replaces old \"extractSubpaths()\"\n\t **/\n\n\tfunction ShapePath() {\n\n\t\tthis.type = 'ShapePath';\n\n\t\tthis.color = new Color();\n\n\t\tthis.subPaths = [];\n\t\tthis.currentPath = null;\n\n\t}\n\n\tObject.assign( ShapePath.prototype, {\n\n\t\tmoveTo: function ( x, y ) {\n\n\t\t\tthis.currentPath = new Path();\n\t\t\tthis.subPaths.push( this.currentPath );\n\t\t\tthis.currentPath.moveTo( x, y );\n\n\t\t},\n\n\t\tlineTo: function ( x, y ) {\n\n\t\t\tthis.currentPath.lineTo( x, y );\n\n\t\t},\n\n\t\tquadraticCurveTo: function ( aCPx, aCPy, aX, aY ) {\n\n\t\t\tthis.currentPath.quadraticCurveTo( aCPx, aCPy, aX, aY );\n\n\t\t},\n\n\t\tbezierCurveTo: function ( aCP1x, aCP1y, aCP2x, aCP2y, aX, aY ) {\n\n\t\t\tthis.currentPath.bezierCurveTo( aCP1x, aCP1y, aCP2x, aCP2y, aX, aY );\n\n\t\t},\n\n\t\tsplineThru: function ( pts ) {\n\n\t\t\tthis.currentPath.splineThru( pts );\n\n\t\t},\n\n\t\ttoShapes: function ( isCCW, noHoles ) {\n\n\t\t\tfunction toShapesNoHoles( inSubpaths ) {\n\n\t\t\t\tvar shapes = [];\n\n\t\t\t\tfor ( var i = 0, l = inSubpaths.length; i < l; i ++ ) {\n\n\t\t\t\t\tvar tmpPath = inSubpaths[ i ];\n\n\t\t\t\t\tvar tmpShape = new Shape();\n\t\t\t\t\ttmpShape.curves = tmpPath.curves;\n\n\t\t\t\t\tshapes.push( tmpShape );\n\n\t\t\t\t}\n\n\t\t\t\treturn shapes;\n\n\t\t\t}\n\n\t\t\tfunction isPointInsidePolygon( inPt, inPolygon ) {\n\n\t\t\t\tvar polyLen = inPolygon.length;\n\n\t\t\t\t// inPt on polygon contour => immediate success    or\n\t\t\t\t// toggling of inside/outside at every single! intersection point of an edge\n\t\t\t\t//  with the horizontal line through inPt, left of inPt\n\t\t\t\t//  not counting lowerY endpoints of edges and whole edges on that line\n\t\t\t\tvar inside = false;\n\t\t\t\tfor ( var p = polyLen - 1, q = 0; q < polyLen; p = q ++ ) {\n\n\t\t\t\t\tvar edgeLowPt = inPolygon[ p ];\n\t\t\t\t\tvar edgeHighPt = inPolygon[ q ];\n\n\t\t\t\t\tvar edgeDx = edgeHighPt.x - edgeLowPt.x;\n\t\t\t\t\tvar edgeDy = edgeHighPt.y - edgeLowPt.y;\n\n\t\t\t\t\tif ( Math.abs( edgeDy ) > Number.EPSILON ) {\n\n\t\t\t\t\t\t// not parallel\n\t\t\t\t\t\tif ( edgeDy < 0 ) {\n\n\t\t\t\t\t\t\tedgeLowPt = inPolygon[ q ]; edgeDx = - edgeDx;\n\t\t\t\t\t\t\tedgeHighPt = inPolygon[ p ]; edgeDy = - edgeDy;\n\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( ( inPt.y < edgeLowPt.y ) || ( inPt.y > edgeHighPt.y ) ) \t\tcontinue;\n\n\t\t\t\t\t\tif ( inPt.y === edgeLowPt.y ) {\n\n\t\t\t\t\t\t\tif ( inPt.x === edgeLowPt.x )\t\treturn\ttrue;\t\t// inPt is on contour ?\n\t\t\t\t\t\t\t// continue;\t\t\t\t// no intersection or edgeLowPt => doesn't count !!!\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tvar perpEdge = edgeDy * ( inPt.x - edgeLowPt.x ) - edgeDx * ( inPt.y - edgeLowPt.y );\n\t\t\t\t\t\t\tif ( perpEdge === 0 )\t\t\t\treturn\ttrue;\t\t// inPt is on contour ?\n\t\t\t\t\t\t\tif ( perpEdge < 0 ) \t\t\t\tcontinue;\n\t\t\t\t\t\t\tinside = ! inside;\t\t// true intersection left of inPt\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// parallel or collinear\n\t\t\t\t\t\tif ( inPt.y !== edgeLowPt.y ) \t\tcontinue;\t\t\t// parallel\n\t\t\t\t\t\t// edge lies on the same horizontal line as inPt\n\t\t\t\t\t\tif ( ( ( edgeHighPt.x <= inPt.x ) && ( inPt.x <= edgeLowPt.x ) ) ||\n\t\t\t\t\t\t\t ( ( edgeLowPt.x <= inPt.x ) && ( inPt.x <= edgeHighPt.x ) ) )\t\treturn\ttrue;\t// inPt: Point on contour !\n\t\t\t\t\t\t// continue;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\treturn\tinside;\n\n\t\t\t}\n\n\t\t\tvar isClockWise = ShapeUtils.isClockWise;\n\n\t\t\tvar subPaths = this.subPaths;\n\t\t\tif ( subPaths.length === 0 ) return [];\n\n\t\t\tif ( noHoles === true )\treturn\ttoShapesNoHoles( subPaths );\n\n\n\t\t\tvar solid, tmpPath, tmpShape, shapes = [];\n\n\t\t\tif ( subPaths.length === 1 ) {\n\n\t\t\t\ttmpPath = subPaths[ 0 ];\n\t\t\t\ttmpShape = new Shape();\n\t\t\t\ttmpShape.curves = tmpPath.curves;\n\t\t\t\tshapes.push( tmpShape );\n\t\t\t\treturn shapes;\n\n\t\t\t}\n\n\t\t\tvar holesFirst = ! isClockWise( subPaths[ 0 ].getPoints() );\n\t\t\tholesFirst = isCCW ? ! holesFirst : holesFirst;\n\n\t\t\t// console.log(\"Holes first\", holesFirst);\n\n\t\t\tvar betterShapeHoles = [];\n\t\t\tvar newShapes = [];\n\t\t\tvar newShapeHoles = [];\n\t\t\tvar mainIdx = 0;\n\t\t\tvar tmpPoints;\n\n\t\t\tnewShapes[ mainIdx ] = undefined;\n\t\t\tnewShapeHoles[ mainIdx ] = [];\n\n\t\t\tfor ( var i = 0, l = subPaths.length; i < l; i ++ ) {\n\n\t\t\t\ttmpPath = subPaths[ i ];\n\t\t\t\ttmpPoints = tmpPath.getPoints();\n\t\t\t\tsolid = isClockWise( tmpPoints );\n\t\t\t\tsolid = isCCW ? ! solid : solid;\n\n\t\t\t\tif ( solid ) {\n\n\t\t\t\t\tif ( ( ! holesFirst ) && ( newShapes[ mainIdx ] ) )\tmainIdx ++;\n\n\t\t\t\t\tnewShapes[ mainIdx ] = { s: new Shape(), p: tmpPoints };\n\t\t\t\t\tnewShapes[ mainIdx ].s.curves = tmpPath.curves;\n\n\t\t\t\t\tif ( holesFirst )\tmainIdx ++;\n\t\t\t\t\tnewShapeHoles[ mainIdx ] = [];\n\n\t\t\t\t\t//console.log('cw', i);\n\n\t\t\t\t} else {\n\n\t\t\t\t\tnewShapeHoles[ mainIdx ].push( { h: tmpPath, p: tmpPoints[ 0 ] } );\n\n\t\t\t\t\t//console.log('ccw', i);\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// only Holes? -> probably all Shapes with wrong orientation\n\t\t\tif ( ! newShapes[ 0 ] )\treturn\ttoShapesNoHoles( subPaths );\n\n\n\t\t\tif ( newShapes.length > 1 ) {\n\n\t\t\t\tvar ambiguous = false;\n\t\t\t\tvar toChange = [];\n\n\t\t\t\tfor ( var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) {\n\n\t\t\t\t\tbetterShapeHoles[ sIdx ] = [];\n\n\t\t\t\t}\n\n\t\t\t\tfor ( var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) {\n\n\t\t\t\t\tvar sho = newShapeHoles[ sIdx ];\n\n\t\t\t\t\tfor ( var hIdx = 0; hIdx < sho.length; hIdx ++ ) {\n\n\t\t\t\t\t\tvar ho = sho[ hIdx ];\n\t\t\t\t\t\tvar hole_unassigned = true;\n\n\t\t\t\t\t\tfor ( var s2Idx = 0; s2Idx < newShapes.length; s2Idx ++ ) {\n\n\t\t\t\t\t\t\tif ( isPointInsidePolygon( ho.p, newShapes[ s2Idx ].p ) ) {\n\n\t\t\t\t\t\t\t\tif ( sIdx !== s2Idx )\ttoChange.push( { froms: sIdx, tos: s2Idx, hole: hIdx } );\n\t\t\t\t\t\t\t\tif ( hole_unassigned ) {\n\n\t\t\t\t\t\t\t\t\thole_unassigned = false;\n\t\t\t\t\t\t\t\t\tbetterShapeHoles[ s2Idx ].push( ho );\n\n\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\tambiguous = true;\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( hole_unassigned ) {\n\n\t\t\t\t\t\t\tbetterShapeHoles[ sIdx ].push( ho );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t\t// console.log(\"ambiguous: \", ambiguous);\n\t\t\t\tif ( toChange.length > 0 ) {\n\n\t\t\t\t\t// console.log(\"to change: \", toChange);\n\t\t\t\t\tif ( ! ambiguous )\tnewShapeHoles = betterShapeHoles;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tvar tmpHoles;\n\n\t\t\tfor ( var i = 0, il = newShapes.length; i < il; i ++ ) {\n\n\t\t\t\ttmpShape = newShapes[ i ].s;\n\t\t\t\tshapes.push( tmpShape );\n\t\t\t\ttmpHoles = newShapeHoles[ i ];\n\n\t\t\t\tfor ( var j = 0, jl = tmpHoles.length; j < jl; j ++ ) {\n\n\t\t\t\t\ttmpShape.holes.push( tmpHoles[ j ].h );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t//console.log(\"shape\", shapes);\n\n\t\t\treturn shapes;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author zz85 / http://www.lab4games.net/zz85/blog\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\n\tfunction Font( data ) {\n\n\t\tthis.type = 'Font';\n\n\t\tthis.data = data;\n\n\t}\n\n\tObject.assign( Font.prototype, {\n\n\t\tisFont: true,\n\n\t\tgenerateShapes: function ( text, size ) {\n\n\t\t\tif ( size === undefined ) size = 100;\n\n\t\t\tvar shapes = [];\n\t\t\tvar paths = createPaths( text, size, this.data );\n\n\t\t\tfor ( var p = 0, pl = paths.length; p < pl; p ++ ) {\n\n\t\t\t\tArray.prototype.push.apply( shapes, paths[ p ].toShapes() );\n\n\t\t\t}\n\n\t\t\treturn shapes;\n\n\t\t}\n\n\t} );\n\n\tfunction createPaths( text, size, data ) {\n\n\t\tvar chars = Array.from ? Array.from( text ) : String( text ).split( '' ); // see #13988\n\t\tvar scale = size / data.resolution;\n\t\tvar line_height = ( data.boundingBox.yMax - data.boundingBox.yMin + data.underlineThickness ) * scale;\n\n\t\tvar paths = [];\n\n\t\tvar offsetX = 0, offsetY = 0;\n\n\t\tfor ( var i = 0; i < chars.length; i ++ ) {\n\n\t\t\tvar char = chars[ i ];\n\n\t\t\tif ( char === '\\n' ) {\n\n\t\t\t\toffsetX = 0;\n\t\t\t\toffsetY -= line_height;\n\n\t\t\t} else {\n\n\t\t\t\tvar ret = createPath( char, scale, offsetX, offsetY, data );\n\t\t\t\toffsetX += ret.offsetX;\n\t\t\t\tpaths.push( ret.path );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn paths;\n\n\t}\n\n\tfunction createPath( char, scale, offsetX, offsetY, data ) {\n\n\t\tvar glyph = data.glyphs[ char ] || data.glyphs[ '?' ];\n\n\t\tif ( ! glyph ) return;\n\n\t\tvar path = new ShapePath();\n\n\t\tvar x, y, cpx, cpy, cpx1, cpy1, cpx2, cpy2;\n\n\t\tif ( glyph.o ) {\n\n\t\t\tvar outline = glyph._cachedOutline || ( glyph._cachedOutline = glyph.o.split( ' ' ) );\n\n\t\t\tfor ( var i = 0, l = outline.length; i < l; ) {\n\n\t\t\t\tvar action = outline[ i ++ ];\n\n\t\t\t\tswitch ( action ) {\n\n\t\t\t\t\tcase 'm': // moveTo\n\n\t\t\t\t\t\tx = outline[ i ++ ] * scale + offsetX;\n\t\t\t\t\t\ty = outline[ i ++ ] * scale + offsetY;\n\n\t\t\t\t\t\tpath.moveTo( x, y );\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'l': // lineTo\n\n\t\t\t\t\t\tx = outline[ i ++ ] * scale + offsetX;\n\t\t\t\t\t\ty = outline[ i ++ ] * scale + offsetY;\n\n\t\t\t\t\t\tpath.lineTo( x, y );\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'q': // quadraticCurveTo\n\n\t\t\t\t\t\tcpx = outline[ i ++ ] * scale + offsetX;\n\t\t\t\t\t\tcpy = outline[ i ++ ] * scale + offsetY;\n\t\t\t\t\t\tcpx1 = outline[ i ++ ] * scale + offsetX;\n\t\t\t\t\t\tcpy1 = outline[ i ++ ] * scale + offsetY;\n\n\t\t\t\t\t\tpath.quadraticCurveTo( cpx1, cpy1, cpx, cpy );\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'b': // bezierCurveTo\n\n\t\t\t\t\t\tcpx = outline[ i ++ ] * scale + offsetX;\n\t\t\t\t\t\tcpy = outline[ i ++ ] * scale + offsetY;\n\t\t\t\t\t\tcpx1 = outline[ i ++ ] * scale + offsetX;\n\t\t\t\t\t\tcpy1 = outline[ i ++ ] * scale + offsetY;\n\t\t\t\t\t\tcpx2 = outline[ i ++ ] * scale + offsetX;\n\t\t\t\t\t\tcpy2 = outline[ i ++ ] * scale + offsetY;\n\n\t\t\t\t\t\tpath.bezierCurveTo( cpx1, cpy1, cpx2, cpy2, cpx, cpy );\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn { offsetX: glyph.ha * scale, path: path };\n\n\t}\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction FontLoader( manager ) {\n\n\t\tthis.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;\n\n\t}\n\n\tObject.assign( FontLoader.prototype, {\n\n\t\tload: function ( url, onLoad, onProgress, onError ) {\n\n\t\t\tvar scope = this;\n\n\t\t\tvar loader = new FileLoader( this.manager );\n\t\t\tloader.setPath( this.path );\n\t\t\tloader.load( url, function ( text ) {\n\n\t\t\t\tvar json;\n\n\t\t\t\ttry {\n\n\t\t\t\t\tjson = JSON.parse( text );\n\n\t\t\t\t} catch ( e ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead.' );\n\t\t\t\t\tjson = JSON.parse( text.substring( 65, text.length - 2 ) );\n\n\t\t\t\t}\n\n\t\t\t\tvar font = scope.parse( json );\n\n\t\t\t\tif ( onLoad ) onLoad( font );\n\n\t\t\t}, onProgress, onError );\n\n\t\t},\n\n\t\tparse: function ( json ) {\n\n\t\t\treturn new Font( json );\n\n\t\t},\n\n\t\tsetPath: function ( value ) {\n\n\t\t\tthis.path = value;\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t */\n\n\tfunction Loader() {}\n\n\tLoader.Handlers = {\n\n\t\thandlers: [],\n\n\t\tadd: function ( regex, loader ) {\n\n\t\t\tthis.handlers.push( regex, loader );\n\n\t\t},\n\n\t\tget: function ( file ) {\n\n\t\t\tvar handlers = this.handlers;\n\n\t\t\tfor ( var i = 0, l = handlers.length; i < l; i += 2 ) {\n\n\t\t\t\tvar regex = handlers[ i ];\n\t\t\t\tvar loader = handlers[ i + 1 ];\n\n\t\t\t\tif ( regex.test( file ) ) {\n\n\t\t\t\t\treturn loader;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn null;\n\n\t\t}\n\n\t};\n\n\tObject.assign( Loader.prototype, {\n\n\t\tcrossOrigin: 'anonymous',\n\n\t\tonLoadStart: function () {},\n\n\t\tonLoadProgress: function () {},\n\n\t\tonLoadComplete: function () {},\n\n\t\tinitMaterials: function ( materials, texturePath, crossOrigin ) {\n\n\t\t\tvar array = [];\n\n\t\t\tfor ( var i = 0; i < materials.length; ++ i ) {\n\n\t\t\t\tarray[ i ] = this.createMaterial( materials[ i ], texturePath, crossOrigin );\n\n\t\t\t}\n\n\t\t\treturn array;\n\n\t\t},\n\n\t\tcreateMaterial: ( function () {\n\n\t\t\tvar BlendingMode = {\n\t\t\t\tNoBlending: NoBlending,\n\t\t\t\tNormalBlending: NormalBlending,\n\t\t\t\tAdditiveBlending: AdditiveBlending,\n\t\t\t\tSubtractiveBlending: SubtractiveBlending,\n\t\t\t\tMultiplyBlending: MultiplyBlending,\n\t\t\t\tCustomBlending: CustomBlending\n\t\t\t};\n\n\t\t\tvar color = new Color();\n\t\t\tvar textureLoader = new TextureLoader();\n\t\t\tvar materialLoader = new MaterialLoader();\n\n\t\t\treturn function createMaterial( m, texturePath, crossOrigin ) {\n\n\t\t\t\t// convert from old material format\n\n\t\t\t\tvar textures = {};\n\n\t\t\t\tfunction loadTexture( path, repeat, offset, wrap, anisotropy ) {\n\n\t\t\t\t\tvar fullPath = texturePath + path;\n\t\t\t\t\tvar loader = Loader.Handlers.get( fullPath );\n\n\t\t\t\t\tvar texture;\n\n\t\t\t\t\tif ( loader !== null ) {\n\n\t\t\t\t\t\ttexture = loader.load( fullPath );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\ttextureLoader.setCrossOrigin( crossOrigin );\n\t\t\t\t\t\ttexture = textureLoader.load( fullPath );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( repeat !== undefined ) {\n\n\t\t\t\t\t\ttexture.repeat.fromArray( repeat );\n\n\t\t\t\t\t\tif ( repeat[ 0 ] !== 1 ) texture.wrapS = RepeatWrapping;\n\t\t\t\t\t\tif ( repeat[ 1 ] !== 1 ) texture.wrapT = RepeatWrapping;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( offset !== undefined ) {\n\n\t\t\t\t\t\ttexture.offset.fromArray( offset );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( wrap !== undefined ) {\n\n\t\t\t\t\t\tif ( wrap[ 0 ] === 'repeat' ) texture.wrapS = RepeatWrapping;\n\t\t\t\t\t\tif ( wrap[ 0 ] === 'mirror' ) texture.wrapS = MirroredRepeatWrapping;\n\n\t\t\t\t\t\tif ( wrap[ 1 ] === 'repeat' ) texture.wrapT = RepeatWrapping;\n\t\t\t\t\t\tif ( wrap[ 1 ] === 'mirror' ) texture.wrapT = MirroredRepeatWrapping;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( anisotropy !== undefined ) {\n\n\t\t\t\t\t\ttexture.anisotropy = anisotropy;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tvar uuid = _Math.generateUUID();\n\n\t\t\t\t\ttextures[ uuid ] = texture;\n\n\t\t\t\t\treturn uuid;\n\n\t\t\t\t}\n\n\t\t\t\t//\n\n\t\t\t\tvar json = {\n\t\t\t\t\tuuid: _Math.generateUUID(),\n\t\t\t\t\ttype: 'MeshLambertMaterial'\n\t\t\t\t};\n\n\t\t\t\tfor ( var name in m ) {\n\n\t\t\t\t\tvar value = m[ name ];\n\n\t\t\t\t\tswitch ( name ) {\n\n\t\t\t\t\t\tcase 'DbgColor':\n\t\t\t\t\t\tcase 'DbgIndex':\n\t\t\t\t\t\tcase 'opticalDensity':\n\t\t\t\t\t\tcase 'illumination':\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'DbgName':\n\t\t\t\t\t\t\tjson.name = value;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'blending':\n\t\t\t\t\t\t\tjson.blending = BlendingMode[ value ];\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'colorAmbient':\n\t\t\t\t\t\tcase 'mapAmbient':\n\t\t\t\t\t\t\tconsole.warn( 'THREE.Loader.createMaterial:', name, 'is no longer supported.' );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'colorDiffuse':\n\t\t\t\t\t\t\tjson.color = color.fromArray( value ).getHex();\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'colorSpecular':\n\t\t\t\t\t\t\tjson.specular = color.fromArray( value ).getHex();\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'colorEmissive':\n\t\t\t\t\t\t\tjson.emissive = color.fromArray( value ).getHex();\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'specularCoef':\n\t\t\t\t\t\t\tjson.shininess = value;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'shading':\n\t\t\t\t\t\t\tif ( value.toLowerCase() === 'basic' ) json.type = 'MeshBasicMaterial';\n\t\t\t\t\t\t\tif ( value.toLowerCase() === 'phong' ) json.type = 'MeshPhongMaterial';\n\t\t\t\t\t\t\tif ( value.toLowerCase() === 'standard' ) json.type = 'MeshStandardMaterial';\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapDiffuse':\n\t\t\t\t\t\t\tjson.map = loadTexture( value, m.mapDiffuseRepeat, m.mapDiffuseOffset, m.mapDiffuseWrap, m.mapDiffuseAnisotropy );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapDiffuseRepeat':\n\t\t\t\t\t\tcase 'mapDiffuseOffset':\n\t\t\t\t\t\tcase 'mapDiffuseWrap':\n\t\t\t\t\t\tcase 'mapDiffuseAnisotropy':\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapEmissive':\n\t\t\t\t\t\t\tjson.emissiveMap = loadTexture( value, m.mapEmissiveRepeat, m.mapEmissiveOffset, m.mapEmissiveWrap, m.mapEmissiveAnisotropy );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapEmissiveRepeat':\n\t\t\t\t\t\tcase 'mapEmissiveOffset':\n\t\t\t\t\t\tcase 'mapEmissiveWrap':\n\t\t\t\t\t\tcase 'mapEmissiveAnisotropy':\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapLight':\n\t\t\t\t\t\t\tjson.lightMap = loadTexture( value, m.mapLightRepeat, m.mapLightOffset, m.mapLightWrap, m.mapLightAnisotropy );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapLightRepeat':\n\t\t\t\t\t\tcase 'mapLightOffset':\n\t\t\t\t\t\tcase 'mapLightWrap':\n\t\t\t\t\t\tcase 'mapLightAnisotropy':\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapAO':\n\t\t\t\t\t\t\tjson.aoMap = loadTexture( value, m.mapAORepeat, m.mapAOOffset, m.mapAOWrap, m.mapAOAnisotropy );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapAORepeat':\n\t\t\t\t\t\tcase 'mapAOOffset':\n\t\t\t\t\t\tcase 'mapAOWrap':\n\t\t\t\t\t\tcase 'mapAOAnisotropy':\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapBump':\n\t\t\t\t\t\t\tjson.bumpMap = loadTexture( value, m.mapBumpRepeat, m.mapBumpOffset, m.mapBumpWrap, m.mapBumpAnisotropy );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapBumpScale':\n\t\t\t\t\t\t\tjson.bumpScale = value;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapBumpRepeat':\n\t\t\t\t\t\tcase 'mapBumpOffset':\n\t\t\t\t\t\tcase 'mapBumpWrap':\n\t\t\t\t\t\tcase 'mapBumpAnisotropy':\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapNormal':\n\t\t\t\t\t\t\tjson.normalMap = loadTexture( value, m.mapNormalRepeat, m.mapNormalOffset, m.mapNormalWrap, m.mapNormalAnisotropy );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapNormalFactor':\n\t\t\t\t\t\t\tjson.normalScale = value;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapNormalRepeat':\n\t\t\t\t\t\tcase 'mapNormalOffset':\n\t\t\t\t\t\tcase 'mapNormalWrap':\n\t\t\t\t\t\tcase 'mapNormalAnisotropy':\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapSpecular':\n\t\t\t\t\t\t\tjson.specularMap = loadTexture( value, m.mapSpecularRepeat, m.mapSpecularOffset, m.mapSpecularWrap, m.mapSpecularAnisotropy );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapSpecularRepeat':\n\t\t\t\t\t\tcase 'mapSpecularOffset':\n\t\t\t\t\t\tcase 'mapSpecularWrap':\n\t\t\t\t\t\tcase 'mapSpecularAnisotropy':\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapMetalness':\n\t\t\t\t\t\t\tjson.metalnessMap = loadTexture( value, m.mapMetalnessRepeat, m.mapMetalnessOffset, m.mapMetalnessWrap, m.mapMetalnessAnisotropy );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapMetalnessRepeat':\n\t\t\t\t\t\tcase 'mapMetalnessOffset':\n\t\t\t\t\t\tcase 'mapMetalnessWrap':\n\t\t\t\t\t\tcase 'mapMetalnessAnisotropy':\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapRoughness':\n\t\t\t\t\t\t\tjson.roughnessMap = loadTexture( value, m.mapRoughnessRepeat, m.mapRoughnessOffset, m.mapRoughnessWrap, m.mapRoughnessAnisotropy );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapRoughnessRepeat':\n\t\t\t\t\t\tcase 'mapRoughnessOffset':\n\t\t\t\t\t\tcase 'mapRoughnessWrap':\n\t\t\t\t\t\tcase 'mapRoughnessAnisotropy':\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapAlpha':\n\t\t\t\t\t\t\tjson.alphaMap = loadTexture( value, m.mapAlphaRepeat, m.mapAlphaOffset, m.mapAlphaWrap, m.mapAlphaAnisotropy );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'mapAlphaRepeat':\n\t\t\t\t\t\tcase 'mapAlphaOffset':\n\t\t\t\t\t\tcase 'mapAlphaWrap':\n\t\t\t\t\t\tcase 'mapAlphaAnisotropy':\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'flipSided':\n\t\t\t\t\t\t\tjson.side = BackSide;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'doubleSided':\n\t\t\t\t\t\t\tjson.side = DoubleSide;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'transparency':\n\t\t\t\t\t\t\tconsole.warn( 'THREE.Loader.createMaterial: transparency has been renamed to opacity' );\n\t\t\t\t\t\t\tjson.opacity = value;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'depthTest':\n\t\t\t\t\t\tcase 'depthWrite':\n\t\t\t\t\t\tcase 'colorWrite':\n\t\t\t\t\t\tcase 'opacity':\n\t\t\t\t\t\tcase 'reflectivity':\n\t\t\t\t\t\tcase 'transparent':\n\t\t\t\t\t\tcase 'visible':\n\t\t\t\t\t\tcase 'wireframe':\n\t\t\t\t\t\t\tjson[ name ] = value;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'vertexColors':\n\t\t\t\t\t\t\tif ( value === true ) json.vertexColors = VertexColors;\n\t\t\t\t\t\t\tif ( value === 'face' ) json.vertexColors = FaceColors;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tconsole.error( 'THREE.Loader.createMaterial: Unsupported', name, value );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( json.type === 'MeshBasicMaterial' ) delete json.emissive;\n\t\t\t\tif ( json.type !== 'MeshPhongMaterial' ) delete json.specular;\n\n\t\t\t\tif ( json.opacity < 1 ) json.transparent = true;\n\n\t\t\t\tmaterialLoader.setTextures( textures );\n\n\t\t\t\treturn materialLoader.parse( json );\n\n\t\t\t};\n\n\t\t} )()\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tvar context;\n\n\tvar AudioContext = {\n\n\t\tgetContext: function () {\n\n\t\t\tif ( context === undefined ) {\n\n\t\t\t\tcontext = new ( window.AudioContext || window.webkitAudioContext )();\n\n\t\t\t}\n\n\t\t\treturn context;\n\n\t\t},\n\n\t\tsetContext: function ( value ) {\n\n\t\t\tcontext = value;\n\n\t\t}\n\n\t};\n\n\t/**\n\t * @author Reece Aaron Lecrivain / http://reecenotes.com/\n\t */\n\n\tfunction AudioLoader( manager ) {\n\n\t\tthis.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager;\n\n\t}\n\n\tObject.assign( AudioLoader.prototype, {\n\n\t\tload: function ( url, onLoad, onProgress, onError ) {\n\n\t\t\tvar loader = new FileLoader( this.manager );\n\t\t\tloader.setResponseType( 'arraybuffer' );\n\t\t\tloader.setPath( this.path );\n\t\t\tloader.load( url, function ( buffer ) {\n\n\t\t\t\t// Create a copy of the buffer. The `decodeAudioData` method\n\t\t\t\t// detaches the buffer when complete, preventing reuse.\n\t\t\t\tvar bufferCopy = buffer.slice( 0 );\n\n\t\t\t\tvar context = AudioContext.getContext();\n\t\t\t\tcontext.decodeAudioData( bufferCopy, function ( audioBuffer ) {\n\n\t\t\t\t\tonLoad( audioBuffer );\n\n\t\t\t\t} );\n\n\t\t\t}, onProgress, onError );\n\n\t\t},\n\n\t\tsetPath: function ( value ) {\n\n\t\t\tthis.path = value;\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction StereoCamera() {\n\n\t\tthis.type = 'StereoCamera';\n\n\t\tthis.aspect = 1;\n\n\t\tthis.eyeSep = 0.064;\n\n\t\tthis.cameraL = new PerspectiveCamera();\n\t\tthis.cameraL.layers.enable( 1 );\n\t\tthis.cameraL.matrixAutoUpdate = false;\n\n\t\tthis.cameraR = new PerspectiveCamera();\n\t\tthis.cameraR.layers.enable( 2 );\n\t\tthis.cameraR.matrixAutoUpdate = false;\n\n\t}\n\n\tObject.assign( StereoCamera.prototype, {\n\n\t\tupdate: ( function () {\n\n\t\t\tvar instance, focus, fov, aspect, near, far, zoom, eyeSep;\n\n\t\t\tvar eyeRight = new Matrix4();\n\t\t\tvar eyeLeft = new Matrix4();\n\n\t\t\treturn function update( camera ) {\n\n\t\t\t\tvar needsUpdate = instance !== this || focus !== camera.focus || fov !== camera.fov ||\n\t\t\t\t\t\t\t\t\t\t\t\t\taspect !== camera.aspect * this.aspect || near !== camera.near ||\n\t\t\t\t\t\t\t\t\t\t\t\t\tfar !== camera.far || zoom !== camera.zoom || eyeSep !== this.eyeSep;\n\n\t\t\t\tif ( needsUpdate ) {\n\n\t\t\t\t\tinstance = this;\n\t\t\t\t\tfocus = camera.focus;\n\t\t\t\t\tfov = camera.fov;\n\t\t\t\t\taspect = camera.aspect * this.aspect;\n\t\t\t\t\tnear = camera.near;\n\t\t\t\t\tfar = camera.far;\n\t\t\t\t\tzoom = camera.zoom;\n\n\t\t\t\t\t// Off-axis stereoscopic effect based on\n\t\t\t\t\t// http://paulbourke.net/stereographics/stereorender/\n\n\t\t\t\t\tvar projectionMatrix = camera.projectionMatrix.clone();\n\t\t\t\t\teyeSep = this.eyeSep / 2;\n\t\t\t\t\tvar eyeSepOnProjection = eyeSep * near / focus;\n\t\t\t\t\tvar ymax = ( near * Math.tan( _Math.DEG2RAD * fov * 0.5 ) ) / zoom;\n\t\t\t\t\tvar xmin, xmax;\n\n\t\t\t\t\t// translate xOffset\n\n\t\t\t\t\teyeLeft.elements[ 12 ] = - eyeSep;\n\t\t\t\t\teyeRight.elements[ 12 ] = eyeSep;\n\n\t\t\t\t\t// for left eye\n\n\t\t\t\t\txmin = - ymax * aspect + eyeSepOnProjection;\n\t\t\t\t\txmax = ymax * aspect + eyeSepOnProjection;\n\n\t\t\t\t\tprojectionMatrix.elements[ 0 ] = 2 * near / ( xmax - xmin );\n\t\t\t\t\tprojectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin );\n\n\t\t\t\t\tthis.cameraL.projectionMatrix.copy( projectionMatrix );\n\n\t\t\t\t\t// for right eye\n\n\t\t\t\t\txmin = - ymax * aspect - eyeSepOnProjection;\n\t\t\t\t\txmax = ymax * aspect - eyeSepOnProjection;\n\n\t\t\t\t\tprojectionMatrix.elements[ 0 ] = 2 * near / ( xmax - xmin );\n\t\t\t\t\tprojectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin );\n\n\t\t\t\t\tthis.cameraR.projectionMatrix.copy( projectionMatrix );\n\n\t\t\t\t}\n\n\t\t\t\tthis.cameraL.matrixWorld.copy( camera.matrixWorld ).multiply( eyeLeft );\n\t\t\t\tthis.cameraR.matrixWorld.copy( camera.matrixWorld ).multiply( eyeRight );\n\n\t\t\t};\n\n\t\t} )()\n\n\t} );\n\n\t/**\n\t * Camera for rendering cube maps\n\t *\t- renders scene into axis-aligned cube\n\t *\n\t * @author alteredq / http://alteredqualia.com/\n\t */\n\n\tfunction CubeCamera( near, far, cubeResolution, options ) {\n\n\t\tObject3D.call( this );\n\n\t\tthis.type = 'CubeCamera';\n\n\t\tvar fov = 90, aspect = 1;\n\n\t\tvar cameraPX = new PerspectiveCamera( fov, aspect, near, far );\n\t\tcameraPX.up.set( 0, - 1, 0 );\n\t\tcameraPX.lookAt( new Vector3( 1, 0, 0 ) );\n\t\tthis.add( cameraPX );\n\n\t\tvar cameraNX = new PerspectiveCamera( fov, aspect, near, far );\n\t\tcameraNX.up.set( 0, - 1, 0 );\n\t\tcameraNX.lookAt( new Vector3( - 1, 0, 0 ) );\n\t\tthis.add( cameraNX );\n\n\t\tvar cameraPY = new PerspectiveCamera( fov, aspect, near, far );\n\t\tcameraPY.up.set( 0, 0, 1 );\n\t\tcameraPY.lookAt( new Vector3( 0, 1, 0 ) );\n\t\tthis.add( cameraPY );\n\n\t\tvar cameraNY = new PerspectiveCamera( fov, aspect, near, far );\n\t\tcameraNY.up.set( 0, 0, - 1 );\n\t\tcameraNY.lookAt( new Vector3( 0, - 1, 0 ) );\n\t\tthis.add( cameraNY );\n\n\t\tvar cameraPZ = new PerspectiveCamera( fov, aspect, near, far );\n\t\tcameraPZ.up.set( 0, - 1, 0 );\n\t\tcameraPZ.lookAt( new Vector3( 0, 0, 1 ) );\n\t\tthis.add( cameraPZ );\n\n\t\tvar cameraNZ = new PerspectiveCamera( fov, aspect, near, far );\n\t\tcameraNZ.up.set( 0, - 1, 0 );\n\t\tcameraNZ.lookAt( new Vector3( 0, 0, - 1 ) );\n\t\tthis.add( cameraNZ );\n\n\t\toptions = options || { format: RGBFormat, magFilter: LinearFilter, minFilter: LinearFilter };\n\n\t\tthis.renderTarget = new WebGLRenderTargetCube( cubeResolution, cubeResolution, options );\n\t\tthis.renderTarget.texture.name = \"CubeCamera\";\n\n\t\tthis.update = function ( renderer, scene ) {\n\n\t\t\tif ( this.parent === null ) this.updateMatrixWorld();\n\n\t\t\tvar renderTarget = this.renderTarget;\n\t\t\tvar generateMipmaps = renderTarget.texture.generateMipmaps;\n\n\t\t\trenderTarget.texture.generateMipmaps = false;\n\n\t\t\trenderTarget.activeCubeFace = 0;\n\t\t\trenderer.render( scene, cameraPX, renderTarget );\n\n\t\t\trenderTarget.activeCubeFace = 1;\n\t\t\trenderer.render( scene, cameraNX, renderTarget );\n\n\t\t\trenderTarget.activeCubeFace = 2;\n\t\t\trenderer.render( scene, cameraPY, renderTarget );\n\n\t\t\trenderTarget.activeCubeFace = 3;\n\t\t\trenderer.render( scene, cameraNY, renderTarget );\n\n\t\t\trenderTarget.activeCubeFace = 4;\n\t\t\trenderer.render( scene, cameraPZ, renderTarget );\n\n\t\t\trenderTarget.texture.generateMipmaps = generateMipmaps;\n\n\t\t\trenderTarget.activeCubeFace = 5;\n\t\t\trenderer.render( scene, cameraNZ, renderTarget );\n\n\t\t\trenderer.setRenderTarget( null );\n\n\t\t};\n\n\t\tthis.clear = function ( renderer, color, depth, stencil ) {\n\n\t\t\tvar renderTarget = this.renderTarget;\n\n\t\t\tfor ( var i = 0; i < 6; i ++ ) {\n\n\t\t\t\trenderTarget.activeCubeFace = i;\n\t\t\t\trenderer.setRenderTarget( renderTarget );\n\n\t\t\t\trenderer.clear( color, depth, stencil );\n\n\t\t\t}\n\n\t\t\trenderer.setRenderTarget( null );\n\n\t\t};\n\n\t}\n\n\tCubeCamera.prototype = Object.create( Object3D.prototype );\n\tCubeCamera.prototype.constructor = CubeCamera;\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t */\n\n\tfunction Clock( autoStart ) {\n\n\t\tthis.autoStart = ( autoStart !== undefined ) ? autoStart : true;\n\n\t\tthis.startTime = 0;\n\t\tthis.oldTime = 0;\n\t\tthis.elapsedTime = 0;\n\n\t\tthis.running = false;\n\n\t}\n\n\tObject.assign( Clock.prototype, {\n\n\t\tstart: function () {\n\n\t\t\tthis.startTime = ( typeof performance === 'undefined' ? Date : performance ).now(); // see #10732\n\n\t\t\tthis.oldTime = this.startTime;\n\t\t\tthis.elapsedTime = 0;\n\t\t\tthis.running = true;\n\n\t\t},\n\n\t\tstop: function () {\n\n\t\t\tthis.getElapsedTime();\n\t\t\tthis.running = false;\n\t\t\tthis.autoStart = false;\n\n\t\t},\n\n\t\tgetElapsedTime: function () {\n\n\t\t\tthis.getDelta();\n\t\t\treturn this.elapsedTime;\n\n\t\t},\n\n\t\tgetDelta: function () {\n\n\t\t\tvar diff = 0;\n\n\t\t\tif ( this.autoStart && ! this.running ) {\n\n\t\t\t\tthis.start();\n\t\t\t\treturn 0;\n\n\t\t\t}\n\n\t\t\tif ( this.running ) {\n\n\t\t\t\tvar newTime = ( typeof performance === 'undefined' ? Date : performance ).now();\n\n\t\t\t\tdiff = ( newTime - this.oldTime ) / 1000;\n\t\t\t\tthis.oldTime = newTime;\n\n\t\t\t\tthis.elapsedTime += diff;\n\n\t\t\t}\n\n\t\t\treturn diff;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction AudioListener() {\n\n\t\tObject3D.call( this );\n\n\t\tthis.type = 'AudioListener';\n\n\t\tthis.context = AudioContext.getContext();\n\n\t\tthis.gain = this.context.createGain();\n\t\tthis.gain.connect( this.context.destination );\n\n\t\tthis.filter = null;\n\n\t\tthis.timeDelta = 0;\n\n\t}\n\n\tAudioListener.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\t\tconstructor: AudioListener,\n\n\t\tgetInput: function () {\n\n\t\t\treturn this.gain;\n\n\t\t},\n\n\t\tremoveFilter: function ( ) {\n\n\t\t\tif ( this.filter !== null ) {\n\n\t\t\t\tthis.gain.disconnect( this.filter );\n\t\t\t\tthis.filter.disconnect( this.context.destination );\n\t\t\t\tthis.gain.connect( this.context.destination );\n\t\t\t\tthis.filter = null;\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetFilter: function () {\n\n\t\t\treturn this.filter;\n\n\t\t},\n\n\t\tsetFilter: function ( value ) {\n\n\t\t\tif ( this.filter !== null ) {\n\n\t\t\t\tthis.gain.disconnect( this.filter );\n\t\t\t\tthis.filter.disconnect( this.context.destination );\n\n\t\t\t} else {\n\n\t\t\t\tthis.gain.disconnect( this.context.destination );\n\n\t\t\t}\n\n\t\t\tthis.filter = value;\n\t\t\tthis.gain.connect( this.filter );\n\t\t\tthis.filter.connect( this.context.destination );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetMasterVolume: function () {\n\n\t\t\treturn this.gain.gain.value;\n\n\t\t},\n\n\t\tsetMasterVolume: function ( value ) {\n\n\t\t\tthis.gain.gain.setTargetAtTime( value, this.context.currentTime, 0.01 );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tupdateMatrixWorld: ( function () {\n\n\t\t\tvar position = new Vector3();\n\t\t\tvar quaternion = new Quaternion();\n\t\t\tvar scale = new Vector3();\n\n\t\t\tvar orientation = new Vector3();\n\t\t\tvar clock = new Clock();\n\n\t\t\treturn function updateMatrixWorld( force ) {\n\n\t\t\t\tObject3D.prototype.updateMatrixWorld.call( this, force );\n\n\t\t\t\tvar listener = this.context.listener;\n\t\t\t\tvar up = this.up;\n\n\t\t\t\tthis.timeDelta = clock.getDelta();\n\n\t\t\t\tthis.matrixWorld.decompose( position, quaternion, scale );\n\n\t\t\t\torientation.set( 0, 0, - 1 ).applyQuaternion( quaternion );\n\n\t\t\t\tif ( listener.positionX ) {\n\n\t\t\t\t\t// code path for Chrome (see #14393)\n\n\t\t\t\t\tvar endTime = this.context.currentTime + this.timeDelta;\n\n\t\t\t\t\tlistener.positionX.linearRampToValueAtTime( position.x, endTime );\n\t\t\t\t\tlistener.positionY.linearRampToValueAtTime( position.y, endTime );\n\t\t\t\t\tlistener.positionZ.linearRampToValueAtTime( position.z, endTime );\n\t\t\t\t\tlistener.forwardX.linearRampToValueAtTime( orientation.x, endTime );\n\t\t\t\t\tlistener.forwardY.linearRampToValueAtTime( orientation.y, endTime );\n\t\t\t\t\tlistener.forwardZ.linearRampToValueAtTime( orientation.z, endTime );\n\t\t\t\t\tlistener.upX.linearRampToValueAtTime( up.x, endTime );\n\t\t\t\t\tlistener.upY.linearRampToValueAtTime( up.y, endTime );\n\t\t\t\t\tlistener.upZ.linearRampToValueAtTime( up.z, endTime );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tlistener.setPosition( position.x, position.y, position.z );\n\t\t\t\t\tlistener.setOrientation( orientation.x, orientation.y, orientation.z, up.x, up.y, up.z );\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t} )()\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author Reece Aaron Lecrivain / http://reecenotes.com/\n\t */\n\n\tfunction Audio( listener ) {\n\n\t\tObject3D.call( this );\n\n\t\tthis.type = 'Audio';\n\n\t\tthis.listener = listener;\n\t\tthis.context = listener.context;\n\n\t\tthis.gain = this.context.createGain();\n\t\tthis.gain.connect( listener.getInput() );\n\n\t\tthis.autoplay = false;\n\n\t\tthis.buffer = null;\n\t\tthis.detune = 0;\n\t\tthis.loop = false;\n\t\tthis.startTime = 0;\n\t\tthis.offset = 0;\n\t\tthis.playbackRate = 1;\n\t\tthis.isPlaying = false;\n\t\tthis.hasPlaybackControl = true;\n\t\tthis.sourceType = 'empty';\n\n\t\tthis.filters = [];\n\n\t}\n\n\tAudio.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\t\tconstructor: Audio,\n\n\t\tgetOutput: function () {\n\n\t\t\treturn this.gain;\n\n\t\t},\n\n\t\tsetNodeSource: function ( audioNode ) {\n\n\t\t\tthis.hasPlaybackControl = false;\n\t\t\tthis.sourceType = 'audioNode';\n\t\t\tthis.source = audioNode;\n\t\t\tthis.connect();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetMediaElementSource: function ( mediaElement ) {\n\n\t\t\tthis.hasPlaybackControl = false;\n\t\t\tthis.sourceType = 'mediaNode';\n\t\t\tthis.source = this.context.createMediaElementSource( mediaElement );\n\t\t\tthis.connect();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetBuffer: function ( audioBuffer ) {\n\n\t\t\tthis.buffer = audioBuffer;\n\t\t\tthis.sourceType = 'buffer';\n\n\t\t\tif ( this.autoplay ) this.play();\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tplay: function () {\n\n\t\t\tif ( this.isPlaying === true ) {\n\n\t\t\t\tconsole.warn( 'THREE.Audio: Audio is already playing.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tif ( this.hasPlaybackControl === false ) {\n\n\t\t\t\tconsole.warn( 'THREE.Audio: this Audio has no playback control.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tvar source = this.context.createBufferSource();\n\n\t\t\tsource.buffer = this.buffer;\n\t\t\tsource.detune.value = this.detune;\n\t\t\tsource.loop = this.loop;\n\t\t\tsource.onended = this.onEnded.bind( this );\n\t\t\tsource.playbackRate.setValueAtTime( this.playbackRate, this.startTime );\n\t\t\tthis.startTime = this.context.currentTime;\n\t\t\tsource.start( this.startTime, this.offset );\n\n\t\t\tthis.isPlaying = true;\n\n\t\t\tthis.source = source;\n\n\t\t\treturn this.connect();\n\n\t\t},\n\n\t\tpause: function () {\n\n\t\t\tif ( this.hasPlaybackControl === false ) {\n\n\t\t\t\tconsole.warn( 'THREE.Audio: this Audio has no playback control.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tif ( this.isPlaying === true ) {\n\n\t\t\t\tthis.source.stop();\n\t\t\t\tthis.source.onended = null;\n\t\t\t\tthis.offset += ( this.context.currentTime - this.startTime ) * this.playbackRate;\n\t\t\t\tthis.isPlaying = false;\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tstop: function () {\n\n\t\t\tif ( this.hasPlaybackControl === false ) {\n\n\t\t\t\tconsole.warn( 'THREE.Audio: this Audio has no playback control.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tthis.source.stop();\n\t\t\tthis.source.onended = null;\n\t\t\tthis.offset = 0;\n\t\t\tthis.isPlaying = false;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tconnect: function () {\n\n\t\t\tif ( this.filters.length > 0 ) {\n\n\t\t\t\tthis.source.connect( this.filters[ 0 ] );\n\n\t\t\t\tfor ( var i = 1, l = this.filters.length; i < l; i ++ ) {\n\n\t\t\t\t\tthis.filters[ i - 1 ].connect( this.filters[ i ] );\n\n\t\t\t\t}\n\n\t\t\t\tthis.filters[ this.filters.length - 1 ].connect( this.getOutput() );\n\n\t\t\t} else {\n\n\t\t\t\tthis.source.connect( this.getOutput() );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tdisconnect: function () {\n\n\t\t\tif ( this.filters.length > 0 ) {\n\n\t\t\t\tthis.source.disconnect( this.filters[ 0 ] );\n\n\t\t\t\tfor ( var i = 1, l = this.filters.length; i < l; i ++ ) {\n\n\t\t\t\t\tthis.filters[ i - 1 ].disconnect( this.filters[ i ] );\n\n\t\t\t\t}\n\n\t\t\t\tthis.filters[ this.filters.length - 1 ].disconnect( this.getOutput() );\n\n\t\t\t} else {\n\n\t\t\t\tthis.source.disconnect( this.getOutput() );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetFilters: function () {\n\n\t\t\treturn this.filters;\n\n\t\t},\n\n\t\tsetFilters: function ( value ) {\n\n\t\t\tif ( ! value ) value = [];\n\n\t\t\tif ( this.isPlaying === true ) {\n\n\t\t\t\tthis.disconnect();\n\t\t\t\tthis.filters = value;\n\t\t\t\tthis.connect();\n\n\t\t\t} else {\n\n\t\t\t\tthis.filters = value;\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetDetune: function ( value ) {\n\n\t\t\tthis.detune = value;\n\n\t\t\tif ( this.isPlaying === true ) {\n\n\t\t\t\tthis.source.detune.setTargetAtTime( this.detune, this.context.currentTime, 0.01 );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetDetune: function () {\n\n\t\t\treturn this.detune;\n\n\t\t},\n\n\t\tgetFilter: function () {\n\n\t\t\treturn this.getFilters()[ 0 ];\n\n\t\t},\n\n\t\tsetFilter: function ( filter ) {\n\n\t\t\treturn this.setFilters( filter ? [ filter ] : [] );\n\n\t\t},\n\n\t\tsetPlaybackRate: function ( value ) {\n\n\t\t\tif ( this.hasPlaybackControl === false ) {\n\n\t\t\t\tconsole.warn( 'THREE.Audio: this Audio has no playback control.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tthis.playbackRate = value;\n\n\t\t\tif ( this.isPlaying === true ) {\n\n\t\t\t\tthis.source.playbackRate.setTargetAtTime( this.playbackRate, this.context.currentTime, 0.01 );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetPlaybackRate: function () {\n\n\t\t\treturn this.playbackRate;\n\n\t\t},\n\n\t\tonEnded: function () {\n\n\t\t\tthis.isPlaying = false;\n\n\t\t},\n\n\t\tgetLoop: function () {\n\n\t\t\tif ( this.hasPlaybackControl === false ) {\n\n\t\t\t\tconsole.warn( 'THREE.Audio: this Audio has no playback control.' );\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t\treturn this.loop;\n\n\t\t},\n\n\t\tsetLoop: function ( value ) {\n\n\t\t\tif ( this.hasPlaybackControl === false ) {\n\n\t\t\t\tconsole.warn( 'THREE.Audio: this Audio has no playback control.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tthis.loop = value;\n\n\t\t\tif ( this.isPlaying === true ) {\n\n\t\t\t\tthis.source.loop = this.loop;\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetVolume: function () {\n\n\t\t\treturn this.gain.gain.value;\n\n\t\t},\n\n\t\tsetVolume: function ( value ) {\n\n\t\t\tthis.gain.gain.setTargetAtTime( value, this.context.currentTime, 0.01 );\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction PositionalAudio( listener ) {\n\n\t\tAudio.call( this, listener );\n\n\t\tthis.panner = this.context.createPanner();\n\t\tthis.panner.connect( this.gain );\n\n\t}\n\n\tPositionalAudio.prototype = Object.assign( Object.create( Audio.prototype ), {\n\n\t\tconstructor: PositionalAudio,\n\n\t\tgetOutput: function () {\n\n\t\t\treturn this.panner;\n\n\t\t},\n\n\t\tgetRefDistance: function () {\n\n\t\t\treturn this.panner.refDistance;\n\n\t\t},\n\n\t\tsetRefDistance: function ( value ) {\n\n\t\t\tthis.panner.refDistance = value;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetRolloffFactor: function () {\n\n\t\t\treturn this.panner.rolloffFactor;\n\n\t\t},\n\n\t\tsetRolloffFactor: function ( value ) {\n\n\t\t\tthis.panner.rolloffFactor = value;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetDistanceModel: function () {\n\n\t\t\treturn this.panner.distanceModel;\n\n\t\t},\n\n\t\tsetDistanceModel: function ( value ) {\n\n\t\t\tthis.panner.distanceModel = value;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetMaxDistance: function () {\n\n\t\t\treturn this.panner.maxDistance;\n\n\t\t},\n\n\t\tsetMaxDistance: function ( value ) {\n\n\t\t\tthis.panner.maxDistance = value;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetDirectionalCone: function ( coneInnerAngle, coneOuterAngle, coneOuterGain ) {\n\n\t\t\tthis.panner.coneInnerAngle = coneInnerAngle;\n\t\t\tthis.panner.coneOuterAngle = coneOuterAngle;\n\t\t\tthis.panner.coneOuterGain = coneOuterGain;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tupdateMatrixWorld: ( function () {\n\n\t\t\tvar position = new Vector3();\n\t\t\tvar quaternion = new Quaternion();\n\t\t\tvar scale = new Vector3();\n\n\t\t\tvar orientation = new Vector3();\n\n\t\t\treturn function updateMatrixWorld( force ) {\n\n\t\t\t\tObject3D.prototype.updateMatrixWorld.call( this, force );\n\n\t\t\t\tif ( this.isPlaying === false ) return;\n\n\t\t\t\tthis.matrixWorld.decompose( position, quaternion, scale );\n\n\t\t\t\torientation.set( 0, 0, 1 ).applyQuaternion( quaternion );\n\n\t\t\t\tvar panner = this.panner;\n\n\t\t\t\tif ( panner.positionX ) {\n\n\t\t\t\t\t// code path for Chrome and Firefox (see #14393)\n\n\t\t\t\t\tvar endTime = this.context.currentTime + this.listener.timeDelta;\n\n\t\t\t\t\tpanner.positionX.linearRampToValueAtTime( position.x, endTime );\n\t\t\t\t\tpanner.positionY.linearRampToValueAtTime( position.y, endTime );\n\t\t\t\t\tpanner.positionZ.linearRampToValueAtTime( position.z, endTime );\n\t\t\t\t\tpanner.orientationX.linearRampToValueAtTime( orientation.x, endTime );\n\t\t\t\t\tpanner.orientationY.linearRampToValueAtTime( orientation.y, endTime );\n\t\t\t\t\tpanner.orientationZ.linearRampToValueAtTime( orientation.z, endTime );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tpanner.setPosition( position.x, position.y, position.z );\n\t\t\t\t\tpanner.setOrientation( orientation.x, orientation.y, orientation.z );\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t} )()\n\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction AudioAnalyser( audio, fftSize ) {\n\n\t\tthis.analyser = audio.context.createAnalyser();\n\t\tthis.analyser.fftSize = fftSize !== undefined ? fftSize : 2048;\n\n\t\tthis.data = new Uint8Array( this.analyser.frequencyBinCount );\n\n\t\taudio.getOutput().connect( this.analyser );\n\n\t}\n\n\tObject.assign( AudioAnalyser.prototype, {\n\n\t\tgetFrequencyData: function () {\n\n\t\t\tthis.analyser.getByteFrequencyData( this.data );\n\n\t\t\treturn this.data;\n\n\t\t},\n\n\t\tgetAverageFrequency: function () {\n\n\t\t\tvar value = 0, data = this.getFrequencyData();\n\n\t\t\tfor ( var i = 0; i < data.length; i ++ ) {\n\n\t\t\t\tvalue += data[ i ];\n\n\t\t\t}\n\n\t\t\treturn value / data.length;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t *\n\t * Buffered scene graph property that allows weighted accumulation.\n\t *\n\t *\n\t * @author Ben Houston / http://clara.io/\n\t * @author David Sarno / http://lighthaus.us/\n\t * @author tschw\n\t */\n\n\tfunction PropertyMixer( binding, typeName, valueSize ) {\n\n\t\tthis.binding = binding;\n\t\tthis.valueSize = valueSize;\n\n\t\tvar bufferType = Float64Array,\n\t\t\tmixFunction;\n\n\t\tswitch ( typeName ) {\n\n\t\t\tcase 'quaternion':\n\t\t\t\tmixFunction = this._slerp;\n\t\t\t\tbreak;\n\n\t\t\tcase 'string':\n\t\t\tcase 'bool':\n\t\t\t\tbufferType = Array;\n\t\t\t\tmixFunction = this._select;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tmixFunction = this._lerp;\n\n\t\t}\n\n\t\tthis.buffer = new bufferType( valueSize * 4 );\n\t\t// layout: [ incoming | accu0 | accu1 | orig ]\n\t\t//\n\t\t// interpolators can use .buffer as their .result\n\t\t// the data then goes to 'incoming'\n\t\t//\n\t\t// 'accu0' and 'accu1' are used frame-interleaved for\n\t\t// the cumulative result and are compared to detect\n\t\t// changes\n\t\t//\n\t\t// 'orig' stores the original state of the property\n\n\t\tthis._mixBufferRegion = mixFunction;\n\n\t\tthis.cumulativeWeight = 0;\n\n\t\tthis.useCount = 0;\n\t\tthis.referenceCount = 0;\n\n\t}\n\n\tObject.assign( PropertyMixer.prototype, {\n\n\t\t// accumulate data in the 'incoming' region into 'accu<i>'\n\t\taccumulate: function ( accuIndex, weight ) {\n\n\t\t\t// note: happily accumulating nothing when weight = 0, the caller knows\n\t\t\t// the weight and shouldn't have made the call in the first place\n\n\t\t\tvar buffer = this.buffer,\n\t\t\t\tstride = this.valueSize,\n\t\t\t\toffset = accuIndex * stride + stride,\n\n\t\t\t\tcurrentWeight = this.cumulativeWeight;\n\n\t\t\tif ( currentWeight === 0 ) {\n\n\t\t\t\t// accuN := incoming * weight\n\n\t\t\t\tfor ( var i = 0; i !== stride; ++ i ) {\n\n\t\t\t\t\tbuffer[ offset + i ] = buffer[ i ];\n\n\t\t\t\t}\n\n\t\t\t\tcurrentWeight = weight;\n\n\t\t\t} else {\n\n\t\t\t\t// accuN := accuN + incoming * weight\n\n\t\t\t\tcurrentWeight += weight;\n\t\t\t\tvar mix = weight / currentWeight;\n\t\t\t\tthis._mixBufferRegion( buffer, offset, 0, mix, stride );\n\n\t\t\t}\n\n\t\t\tthis.cumulativeWeight = currentWeight;\n\n\t\t},\n\n\t\t// apply the state of 'accu<i>' to the binding when accus differ\n\t\tapply: function ( accuIndex ) {\n\n\t\t\tvar stride = this.valueSize,\n\t\t\t\tbuffer = this.buffer,\n\t\t\t\toffset = accuIndex * stride + stride,\n\n\t\t\t\tweight = this.cumulativeWeight,\n\n\t\t\t\tbinding = this.binding;\n\n\t\t\tthis.cumulativeWeight = 0;\n\n\t\t\tif ( weight < 1 ) {\n\n\t\t\t\t// accuN := accuN + original * ( 1 - cumulativeWeight )\n\n\t\t\t\tvar originalValueOffset = stride * 3;\n\n\t\t\t\tthis._mixBufferRegion(\n\t\t\t\t\tbuffer, offset, originalValueOffset, 1 - weight, stride );\n\n\t\t\t}\n\n\t\t\tfor ( var i = stride, e = stride + stride; i !== e; ++ i ) {\n\n\t\t\t\tif ( buffer[ i ] !== buffer[ i + stride ] ) {\n\n\t\t\t\t\t// value has changed -> update scene graph\n\n\t\t\t\t\tbinding.setValue( buffer, offset );\n\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t},\n\n\t\t// remember the state of the bound property and copy it to both accus\n\t\tsaveOriginalState: function () {\n\n\t\t\tvar binding = this.binding;\n\n\t\t\tvar buffer = this.buffer,\n\t\t\t\tstride = this.valueSize,\n\n\t\t\t\toriginalValueOffset = stride * 3;\n\n\t\t\tbinding.getValue( buffer, originalValueOffset );\n\n\t\t\t// accu[0..1] := orig -- initially detect changes against the original\n\t\t\tfor ( var i = stride, e = originalValueOffset; i !== e; ++ i ) {\n\n\t\t\t\tbuffer[ i ] = buffer[ originalValueOffset + ( i % stride ) ];\n\n\t\t\t}\n\n\t\t\tthis.cumulativeWeight = 0;\n\n\t\t},\n\n\t\t// apply the state previously taken via 'saveOriginalState' to the binding\n\t\trestoreOriginalState: function () {\n\n\t\t\tvar originalValueOffset = this.valueSize * 3;\n\t\t\tthis.binding.setValue( this.buffer, originalValueOffset );\n\n\t\t},\n\n\n\t\t// mix functions\n\n\t\t_select: function ( buffer, dstOffset, srcOffset, t, stride ) {\n\n\t\t\tif ( t >= 0.5 ) {\n\n\t\t\t\tfor ( var i = 0; i !== stride; ++ i ) {\n\n\t\t\t\t\tbuffer[ dstOffset + i ] = buffer[ srcOffset + i ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t},\n\n\t\t_slerp: function ( buffer, dstOffset, srcOffset, t ) {\n\n\t\t\tQuaternion.slerpFlat( buffer, dstOffset, buffer, dstOffset, buffer, srcOffset, t );\n\n\t\t},\n\n\t\t_lerp: function ( buffer, dstOffset, srcOffset, t, stride ) {\n\n\t\t\tvar s = 1 - t;\n\n\t\t\tfor ( var i = 0; i !== stride; ++ i ) {\n\n\t\t\t\tvar j = dstOffset + i;\n\n\t\t\t\tbuffer[ j ] = buffer[ j ] * s + buffer[ srcOffset + i ] * t;\n\n\t\t\t}\n\n\t\t}\n\n\t} );\n\n\t/**\n\t *\n\t * A reference to a real property in the scene graph.\n\t *\n\t *\n\t * @author Ben Houston / http://clara.io/\n\t * @author David Sarno / http://lighthaus.us/\n\t * @author tschw\n\t */\n\n\t// Characters [].:/ are reserved for track binding syntax.\n\tvar RESERVED_CHARS_RE = '\\\\[\\\\]\\\\.:\\\\/';\n\n\tfunction Composite( targetGroup, path, optionalParsedPath ) {\n\n\t\tvar parsedPath = optionalParsedPath || PropertyBinding.parseTrackName( path );\n\n\t\tthis._targetGroup = targetGroup;\n\t\tthis._bindings = targetGroup.subscribe_( path, parsedPath );\n\n\t}\n\n\tObject.assign( Composite.prototype, {\n\n\t\tgetValue: function ( array, offset ) {\n\n\t\t\tthis.bind(); // bind all binding\n\n\t\t\tvar firstValidIndex = this._targetGroup.nCachedObjects_,\n\t\t\t\tbinding = this._bindings[ firstValidIndex ];\n\n\t\t\t// and only call .getValue on the first\n\t\t\tif ( binding !== undefined ) binding.getValue( array, offset );\n\n\t\t},\n\n\t\tsetValue: function ( array, offset ) {\n\n\t\t\tvar bindings = this._bindings;\n\n\t\t\tfor ( var i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++ i ) {\n\n\t\t\t\tbindings[ i ].setValue( array, offset );\n\n\t\t\t}\n\n\t\t},\n\n\t\tbind: function () {\n\n\t\t\tvar bindings = this._bindings;\n\n\t\t\tfor ( var i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++ i ) {\n\n\t\t\t\tbindings[ i ].bind();\n\n\t\t\t}\n\n\t\t},\n\n\t\tunbind: function () {\n\n\t\t\tvar bindings = this._bindings;\n\n\t\t\tfor ( var i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++ i ) {\n\n\t\t\t\tbindings[ i ].unbind();\n\n\t\t\t}\n\n\t\t}\n\n\t} );\n\n\n\tfunction PropertyBinding( rootNode, path, parsedPath ) {\n\n\t\tthis.path = path;\n\t\tthis.parsedPath = parsedPath || PropertyBinding.parseTrackName( path );\n\n\t\tthis.node = PropertyBinding.findNode( rootNode, this.parsedPath.nodeName ) || rootNode;\n\n\t\tthis.rootNode = rootNode;\n\n\t}\n\n\tObject.assign( PropertyBinding, {\n\n\t\tComposite: Composite,\n\n\t\tcreate: function ( root, path, parsedPath ) {\n\n\t\t\tif ( ! ( root && root.isAnimationObjectGroup ) ) {\n\n\t\t\t\treturn new PropertyBinding( root, path, parsedPath );\n\n\t\t\t} else {\n\n\t\t\t\treturn new PropertyBinding.Composite( root, path, parsedPath );\n\n\t\t\t}\n\n\t\t},\n\n\t\t/**\n\t\t * Replaces spaces with underscores and removes unsupported characters from\n\t\t * node names, to ensure compatibility with parseTrackName().\n\t\t *\n\t\t * @param  {string} name Node name to be sanitized.\n\t\t * @return {string}\n\t\t */\n\t\tsanitizeNodeName: ( function () {\n\n\t\t\tvar reservedRe = new RegExp( '[' + RESERVED_CHARS_RE + ']', 'g' );\n\n\t\t\treturn function sanitizeNodeName( name ) {\n\n\t\t\t\treturn name.replace( /\\s/g, '_' ).replace( reservedRe, '' );\n\n\t\t\t};\n\n\t\t}() ),\n\n\t\tparseTrackName: function () {\n\n\t\t\t// Attempts to allow node names from any language. ES5's `\\w` regexp matches\n\t\t\t// only latin characters, and the unicode \\p{L} is not yet supported. So\n\t\t\t// instead, we exclude reserved characters and match everything else.\n\t\t\tvar wordChar = '[^' + RESERVED_CHARS_RE + ']';\n\t\t\tvar wordCharOrDot = '[^' + RESERVED_CHARS_RE.replace( '\\\\.', '' ) + ']';\n\n\t\t\t// Parent directories, delimited by '/' or ':'. Currently unused, but must\n\t\t\t// be matched to parse the rest of the track name.\n\t\t\tvar directoryRe = /((?:WC+[\\/:])*)/.source.replace( 'WC', wordChar );\n\n\t\t\t// Target node. May contain word characters (a-zA-Z0-9_) and '.' or '-'.\n\t\t\tvar nodeRe = /(WCOD+)?/.source.replace( 'WCOD', wordCharOrDot );\n\n\t\t\t// Object on target node, and accessor. May not contain reserved\n\t\t\t// characters. Accessor may contain any character except closing bracket.\n\t\t\tvar objectRe = /(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace( 'WC', wordChar );\n\n\t\t\t// Property and accessor. May not contain reserved characters. Accessor may\n\t\t\t// contain any non-bracket characters.\n\t\t\tvar propertyRe = /\\.(WC+)(?:\\[(.+)\\])?/.source.replace( 'WC', wordChar );\n\n\t\t\tvar trackRe = new RegExp( ''\n\t\t\t\t+ '^'\n\t\t\t\t+ directoryRe\n\t\t\t\t+ nodeRe\n\t\t\t\t+ objectRe\n\t\t\t\t+ propertyRe\n\t\t\t\t+ '$'\n\t\t\t);\n\n\t\t\tvar supportedObjectNames = [ 'material', 'materials', 'bones' ];\n\n\t\t\treturn function parseTrackName( trackName ) {\n\n\t\t\t\tvar matches = trackRe.exec( trackName );\n\n\t\t\t\tif ( ! matches ) {\n\n\t\t\t\t\tthrow new Error( 'PropertyBinding: Cannot parse trackName: ' + trackName );\n\n\t\t\t\t}\n\n\t\t\t\tvar results = {\n\t\t\t\t\t// directoryName: matches[ 1 ], // (tschw) currently unused\n\t\t\t\t\tnodeName: matches[ 2 ],\n\t\t\t\t\tobjectName: matches[ 3 ],\n\t\t\t\t\tobjectIndex: matches[ 4 ],\n\t\t\t\t\tpropertyName: matches[ 5 ], // required\n\t\t\t\t\tpropertyIndex: matches[ 6 ]\n\t\t\t\t};\n\n\t\t\t\tvar lastDot = results.nodeName && results.nodeName.lastIndexOf( '.' );\n\n\t\t\t\tif ( lastDot !== undefined && lastDot !== - 1 ) {\n\n\t\t\t\t\tvar objectName = results.nodeName.substring( lastDot + 1 );\n\n\t\t\t\t\t// Object names must be checked against a whitelist. Otherwise, there\n\t\t\t\t\t// is no way to parse 'foo.bar.baz': 'baz' must be a property, but\n\t\t\t\t\t// 'bar' could be the objectName, or part of a nodeName (which can\n\t\t\t\t\t// include '.' characters).\n\t\t\t\t\tif ( supportedObjectNames.indexOf( objectName ) !== - 1 ) {\n\n\t\t\t\t\t\tresults.nodeName = results.nodeName.substring( 0, lastDot );\n\t\t\t\t\t\tresults.objectName = objectName;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( results.propertyName === null || results.propertyName.length === 0 ) {\n\n\t\t\t\t\tthrow new Error( 'PropertyBinding: can not parse propertyName from trackName: ' + trackName );\n\n\t\t\t\t}\n\n\t\t\t\treturn results;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tfindNode: function ( root, nodeName ) {\n\n\t\t\tif ( ! nodeName || nodeName === \"\" || nodeName === \"root\" || nodeName === \".\" || nodeName === - 1 || nodeName === root.name || nodeName === root.uuid ) {\n\n\t\t\t\treturn root;\n\n\t\t\t}\n\n\t\t\t// search into skeleton bones.\n\t\t\tif ( root.skeleton ) {\n\n\t\t\t\tvar bone = root.skeleton.getBoneByName( nodeName );\n\n\t\t\t\tif ( bone !== undefined ) {\n\n\t\t\t\t\treturn bone;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// search into node subtree.\n\t\t\tif ( root.children ) {\n\n\t\t\t\tvar searchNodeSubtree = function ( children ) {\n\n\t\t\t\t\tfor ( var i = 0; i < children.length; i ++ ) {\n\n\t\t\t\t\t\tvar childNode = children[ i ];\n\n\t\t\t\t\t\tif ( childNode.name === nodeName || childNode.uuid === nodeName ) {\n\n\t\t\t\t\t\t\treturn childNode;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvar result = searchNodeSubtree( childNode.children );\n\n\t\t\t\t\t\tif ( result ) return result;\n\n\t\t\t\t\t}\n\n\t\t\t\t\treturn null;\n\n\t\t\t\t};\n\n\t\t\t\tvar subTreeNode = searchNodeSubtree( root.children );\n\n\t\t\t\tif ( subTreeNode ) {\n\n\t\t\t\t\treturn subTreeNode;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn null;\n\n\t\t}\n\n\t} );\n\n\tObject.assign( PropertyBinding.prototype, { // prototype, continued\n\n\t\t// these are used to \"bind\" a nonexistent property\n\t\t_getValue_unavailable: function () {},\n\t\t_setValue_unavailable: function () {},\n\n\t\tBindingType: {\n\t\t\tDirect: 0,\n\t\t\tEntireArray: 1,\n\t\t\tArrayElement: 2,\n\t\t\tHasFromToArray: 3\n\t\t},\n\n\t\tVersioning: {\n\t\t\tNone: 0,\n\t\t\tNeedsUpdate: 1,\n\t\t\tMatrixWorldNeedsUpdate: 2\n\t\t},\n\n\t\tGetterByBindingType: [\n\n\t\t\tfunction getValue_direct( buffer, offset ) {\n\n\t\t\t\tbuffer[ offset ] = this.node[ this.propertyName ];\n\n\t\t\t},\n\n\t\t\tfunction getValue_array( buffer, offset ) {\n\n\t\t\t\tvar source = this.resolvedProperty;\n\n\t\t\t\tfor ( var i = 0, n = source.length; i !== n; ++ i ) {\n\n\t\t\t\t\tbuffer[ offset ++ ] = source[ i ];\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tfunction getValue_arrayElement( buffer, offset ) {\n\n\t\t\t\tbuffer[ offset ] = this.resolvedProperty[ this.propertyIndex ];\n\n\t\t\t},\n\n\t\t\tfunction getValue_toArray( buffer, offset ) {\n\n\t\t\t\tthis.resolvedProperty.toArray( buffer, offset );\n\n\t\t\t}\n\n\t\t],\n\n\t\tSetterByBindingTypeAndVersioning: [\n\n\t\t\t[\n\t\t\t\t// Direct\n\n\t\t\t\tfunction setValue_direct( buffer, offset ) {\n\n\t\t\t\t\tthis.targetObject[ this.propertyName ] = buffer[ offset ];\n\n\t\t\t\t},\n\n\t\t\t\tfunction setValue_direct_setNeedsUpdate( buffer, offset ) {\n\n\t\t\t\t\tthis.targetObject[ this.propertyName ] = buffer[ offset ];\n\t\t\t\t\tthis.targetObject.needsUpdate = true;\n\n\t\t\t\t},\n\n\t\t\t\tfunction setValue_direct_setMatrixWorldNeedsUpdate( buffer, offset ) {\n\n\t\t\t\t\tthis.targetObject[ this.propertyName ] = buffer[ offset ];\n\t\t\t\t\tthis.targetObject.matrixWorldNeedsUpdate = true;\n\n\t\t\t\t}\n\n\t\t\t], [\n\n\t\t\t\t// EntireArray\n\n\t\t\t\tfunction setValue_array( buffer, offset ) {\n\n\t\t\t\t\tvar dest = this.resolvedProperty;\n\n\t\t\t\t\tfor ( var i = 0, n = dest.length; i !== n; ++ i ) {\n\n\t\t\t\t\t\tdest[ i ] = buffer[ offset ++ ];\n\n\t\t\t\t\t}\n\n\t\t\t\t},\n\n\t\t\t\tfunction setValue_array_setNeedsUpdate( buffer, offset ) {\n\n\t\t\t\t\tvar dest = this.resolvedProperty;\n\n\t\t\t\t\tfor ( var i = 0, n = dest.length; i !== n; ++ i ) {\n\n\t\t\t\t\t\tdest[ i ] = buffer[ offset ++ ];\n\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.targetObject.needsUpdate = true;\n\n\t\t\t\t},\n\n\t\t\t\tfunction setValue_array_setMatrixWorldNeedsUpdate( buffer, offset ) {\n\n\t\t\t\t\tvar dest = this.resolvedProperty;\n\n\t\t\t\t\tfor ( var i = 0, n = dest.length; i !== n; ++ i ) {\n\n\t\t\t\t\t\tdest[ i ] = buffer[ offset ++ ];\n\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.targetObject.matrixWorldNeedsUpdate = true;\n\n\t\t\t\t}\n\n\t\t\t], [\n\n\t\t\t\t// ArrayElement\n\n\t\t\t\tfunction setValue_arrayElement( buffer, offset ) {\n\n\t\t\t\t\tthis.resolvedProperty[ this.propertyIndex ] = buffer[ offset ];\n\n\t\t\t\t},\n\n\t\t\t\tfunction setValue_arrayElement_setNeedsUpdate( buffer, offset ) {\n\n\t\t\t\t\tthis.resolvedProperty[ this.propertyIndex ] = buffer[ offset ];\n\t\t\t\t\tthis.targetObject.needsUpdate = true;\n\n\t\t\t\t},\n\n\t\t\t\tfunction setValue_arrayElement_setMatrixWorldNeedsUpdate( buffer, offset ) {\n\n\t\t\t\t\tthis.resolvedProperty[ this.propertyIndex ] = buffer[ offset ];\n\t\t\t\t\tthis.targetObject.matrixWorldNeedsUpdate = true;\n\n\t\t\t\t}\n\n\t\t\t], [\n\n\t\t\t\t// HasToFromArray\n\n\t\t\t\tfunction setValue_fromArray( buffer, offset ) {\n\n\t\t\t\t\tthis.resolvedProperty.fromArray( buffer, offset );\n\n\t\t\t\t},\n\n\t\t\t\tfunction setValue_fromArray_setNeedsUpdate( buffer, offset ) {\n\n\t\t\t\t\tthis.resolvedProperty.fromArray( buffer, offset );\n\t\t\t\t\tthis.targetObject.needsUpdate = true;\n\n\t\t\t\t},\n\n\t\t\t\tfunction setValue_fromArray_setMatrixWorldNeedsUpdate( buffer, offset ) {\n\n\t\t\t\t\tthis.resolvedProperty.fromArray( buffer, offset );\n\t\t\t\t\tthis.targetObject.matrixWorldNeedsUpdate = true;\n\n\t\t\t\t}\n\n\t\t\t]\n\n\t\t],\n\n\t\tgetValue: function getValue_unbound( targetArray, offset ) {\n\n\t\t\tthis.bind();\n\t\t\tthis.getValue( targetArray, offset );\n\n\t\t\t// Note: This class uses a State pattern on a per-method basis:\n\t\t\t// 'bind' sets 'this.getValue' / 'setValue' and shadows the\n\t\t\t// prototype version of these methods with one that represents\n\t\t\t// the bound state. When the property is not found, the methods\n\t\t\t// become no-ops.\n\n\t\t},\n\n\t\tsetValue: function getValue_unbound( sourceArray, offset ) {\n\n\t\t\tthis.bind();\n\t\t\tthis.setValue( sourceArray, offset );\n\n\t\t},\n\n\t\t// create getter / setter pair for a property in the scene graph\n\t\tbind: function () {\n\n\t\t\tvar targetObject = this.node,\n\t\t\t\tparsedPath = this.parsedPath,\n\n\t\t\t\tobjectName = parsedPath.objectName,\n\t\t\t\tpropertyName = parsedPath.propertyName,\n\t\t\t\tpropertyIndex = parsedPath.propertyIndex;\n\n\t\t\tif ( ! targetObject ) {\n\n\t\t\t\ttargetObject = PropertyBinding.findNode( this.rootNode, parsedPath.nodeName ) || this.rootNode;\n\n\t\t\t\tthis.node = targetObject;\n\n\t\t\t}\n\n\t\t\t// set fail state so we can just 'return' on error\n\t\t\tthis.getValue = this._getValue_unavailable;\n\t\t\tthis.setValue = this._setValue_unavailable;\n\n\t\t\t// ensure there is a value node\n\t\t\tif ( ! targetObject ) {\n\n\t\t\t\tconsole.error( 'THREE.PropertyBinding: Trying to update node for track: ' + this.path + ' but it wasn\\'t found.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tif ( objectName ) {\n\n\t\t\t\tvar objectIndex = parsedPath.objectIndex;\n\n\t\t\t\t// special cases were we need to reach deeper into the hierarchy to get the face materials....\n\t\t\t\tswitch ( objectName ) {\n\n\t\t\t\t\tcase 'materials':\n\n\t\t\t\t\t\tif ( ! targetObject.material ) {\n\n\t\t\t\t\t\t\tconsole.error( 'THREE.PropertyBinding: Can not bind to material as node does not have a material.', this );\n\t\t\t\t\t\t\treturn;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( ! targetObject.material.materials ) {\n\n\t\t\t\t\t\t\tconsole.error( 'THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.', this );\n\t\t\t\t\t\t\treturn;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttargetObject = targetObject.material.materials;\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'bones':\n\n\t\t\t\t\t\tif ( ! targetObject.skeleton ) {\n\n\t\t\t\t\t\t\tconsole.error( 'THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.', this );\n\t\t\t\t\t\t\treturn;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// potential future optimization: skip this if propertyIndex is already an integer\n\t\t\t\t\t\t// and convert the integer string to a true integer.\n\n\t\t\t\t\t\ttargetObject = targetObject.skeleton.bones;\n\n\t\t\t\t\t\t// support resolving morphTarget names into indices.\n\t\t\t\t\t\tfor ( var i = 0; i < targetObject.length; i ++ ) {\n\n\t\t\t\t\t\t\tif ( targetObject[ i ].name === objectIndex ) {\n\n\t\t\t\t\t\t\t\tobjectIndex = i;\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault:\n\n\t\t\t\t\t\tif ( targetObject[ objectName ] === undefined ) {\n\n\t\t\t\t\t\t\tconsole.error( 'THREE.PropertyBinding: Can not bind to objectName of node undefined.', this );\n\t\t\t\t\t\t\treturn;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttargetObject = targetObject[ objectName ];\n\n\t\t\t\t}\n\n\n\t\t\t\tif ( objectIndex !== undefined ) {\n\n\t\t\t\t\tif ( targetObject[ objectIndex ] === undefined ) {\n\n\t\t\t\t\t\tconsole.error( 'THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.', this, targetObject );\n\t\t\t\t\t\treturn;\n\n\t\t\t\t\t}\n\n\t\t\t\t\ttargetObject = targetObject[ objectIndex ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// resolve property\n\t\t\tvar nodeProperty = targetObject[ propertyName ];\n\n\t\t\tif ( nodeProperty === undefined ) {\n\n\t\t\t\tvar nodeName = parsedPath.nodeName;\n\n\t\t\t\tconsole.error( 'THREE.PropertyBinding: Trying to update property for track: ' + nodeName +\n\t\t\t\t\t'.' + propertyName + ' but it wasn\\'t found.', targetObject );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\t// determine versioning scheme\n\t\t\tvar versioning = this.Versioning.None;\n\n\t\t\tthis.targetObject = targetObject;\n\n\t\t\tif ( targetObject.needsUpdate !== undefined ) { // material\n\n\t\t\t\tversioning = this.Versioning.NeedsUpdate;\n\n\t\t\t} else if ( targetObject.matrixWorldNeedsUpdate !== undefined ) { // node transform\n\n\t\t\t\tversioning = this.Versioning.MatrixWorldNeedsUpdate;\n\n\t\t\t}\n\n\t\t\t// determine how the property gets bound\n\t\t\tvar bindingType = this.BindingType.Direct;\n\n\t\t\tif ( propertyIndex !== undefined ) {\n\n\t\t\t\t// access a sub element of the property array (only primitives are supported right now)\n\n\t\t\t\tif ( propertyName === \"morphTargetInfluences\" ) {\n\n\t\t\t\t\t// potential optimization, skip this if propertyIndex is already an integer, and convert the integer string to a true integer.\n\n\t\t\t\t\t// support resolving morphTarget names into indices.\n\t\t\t\t\tif ( ! targetObject.geometry ) {\n\n\t\t\t\t\t\tconsole.error( 'THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.', this );\n\t\t\t\t\t\treturn;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( targetObject.geometry.isBufferGeometry ) {\n\n\t\t\t\t\t\tif ( ! targetObject.geometry.morphAttributes ) {\n\n\t\t\t\t\t\t\tconsole.error( 'THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.', this );\n\t\t\t\t\t\t\treturn;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor ( var i = 0; i < this.node.geometry.morphAttributes.position.length; i ++ ) {\n\n\t\t\t\t\t\t\tif ( targetObject.geometry.morphAttributes.position[ i ].name === propertyIndex ) {\n\n\t\t\t\t\t\t\t\tpropertyIndex = i;\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tif ( ! targetObject.geometry.morphTargets ) {\n\n\t\t\t\t\t\t\tconsole.error( 'THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphTargets.', this );\n\t\t\t\t\t\t\treturn;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor ( var i = 0; i < this.node.geometry.morphTargets.length; i ++ ) {\n\n\t\t\t\t\t\t\tif ( targetObject.geometry.morphTargets[ i ].name === propertyIndex ) {\n\n\t\t\t\t\t\t\t\tpropertyIndex = i;\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tbindingType = this.BindingType.ArrayElement;\n\n\t\t\t\tthis.resolvedProperty = nodeProperty;\n\t\t\t\tthis.propertyIndex = propertyIndex;\n\n\t\t\t} else if ( nodeProperty.fromArray !== undefined && nodeProperty.toArray !== undefined ) {\n\n\t\t\t\t// must use copy for Object3D.Euler/Quaternion\n\n\t\t\t\tbindingType = this.BindingType.HasFromToArray;\n\n\t\t\t\tthis.resolvedProperty = nodeProperty;\n\n\t\t\t} else if ( Array.isArray( nodeProperty ) ) {\n\n\t\t\t\tbindingType = this.BindingType.EntireArray;\n\n\t\t\t\tthis.resolvedProperty = nodeProperty;\n\n\t\t\t} else {\n\n\t\t\t\tthis.propertyName = propertyName;\n\n\t\t\t}\n\n\t\t\t// select getter / setter\n\t\t\tthis.getValue = this.GetterByBindingType[ bindingType ];\n\t\t\tthis.setValue = this.SetterByBindingTypeAndVersioning[ bindingType ][ versioning ];\n\n\t\t},\n\n\t\tunbind: function () {\n\n\t\t\tthis.node = null;\n\n\t\t\t// back to the prototype version of getValue / setValue\n\t\t\t// note: avoiding to mutate the shape of 'this' via 'delete'\n\t\t\tthis.getValue = this._getValue_unbound;\n\t\t\tthis.setValue = this._setValue_unbound;\n\n\t\t}\n\n\t} );\n\n\t//!\\ DECLARE ALIAS AFTER assign prototype !\n\tObject.assign( PropertyBinding.prototype, {\n\n\t\t// initial state of these methods that calls 'bind'\n\t\t_getValue_unbound: PropertyBinding.prototype.getValue,\n\t\t_setValue_unbound: PropertyBinding.prototype.setValue,\n\n\t} );\n\n\t/**\n\t *\n\t * A group of objects that receives a shared animation state.\n\t *\n\t * Usage:\n\t *\n\t *  - Add objects you would otherwise pass as 'root' to the\n\t *    constructor or the .clipAction method of AnimationMixer.\n\t *\n\t *  - Instead pass this object as 'root'.\n\t *\n\t *  - You can also add and remove objects later when the mixer\n\t *    is running.\n\t *\n\t * Note:\n\t *\n\t *    Objects of this class appear as one object to the mixer,\n\t *    so cache control of the individual objects must be done\n\t *    on the group.\n\t *\n\t * Limitation:\n\t *\n\t *  - The animated properties must be compatible among the\n\t *    all objects in the group.\n\t *\n\t *  - A single property can either be controlled through a\n\t *    target group or directly, but not both.\n\t *\n\t * @author tschw\n\t */\n\n\tfunction AnimationObjectGroup() {\n\n\t\tthis.uuid = _Math.generateUUID();\n\n\t\t// cached objects followed by the active ones\n\t\tthis._objects = Array.prototype.slice.call( arguments );\n\n\t\tthis.nCachedObjects_ = 0; // threshold\n\t\t// note: read by PropertyBinding.Composite\n\n\t\tvar indices = {};\n\t\tthis._indicesByUUID = indices; // for bookkeeping\n\n\t\tfor ( var i = 0, n = arguments.length; i !== n; ++ i ) {\n\n\t\t\tindices[ arguments[ i ].uuid ] = i;\n\n\t\t}\n\n\t\tthis._paths = []; // inside: string\n\t\tthis._parsedPaths = []; // inside: { we don't care, here }\n\t\tthis._bindings = []; // inside: Array< PropertyBinding >\n\t\tthis._bindingsIndicesByPath = {}; // inside: indices in these arrays\n\n\t\tvar scope = this;\n\n\t\tthis.stats = {\n\n\t\t\tobjects: {\n\t\t\t\tget total() {\n\n\t\t\t\t\treturn scope._objects.length;\n\n\t\t\t\t},\n\t\t\t\tget inUse() {\n\n\t\t\t\t\treturn this.total - scope.nCachedObjects_;\n\n\t\t\t\t}\n\t\t\t},\n\t\t\tget bindingsPerObject() {\n\n\t\t\t\treturn scope._bindings.length;\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\tObject.assign( AnimationObjectGroup.prototype, {\n\n\t\tisAnimationObjectGroup: true,\n\n\t\tadd: function () {\n\n\t\t\tvar objects = this._objects,\n\t\t\t\tnObjects = objects.length,\n\t\t\t\tnCachedObjects = this.nCachedObjects_,\n\t\t\t\tindicesByUUID = this._indicesByUUID,\n\t\t\t\tpaths = this._paths,\n\t\t\t\tparsedPaths = this._parsedPaths,\n\t\t\t\tbindings = this._bindings,\n\t\t\t\tnBindings = bindings.length,\n\t\t\t\tknownObject = undefined;\n\n\t\t\tfor ( var i = 0, n = arguments.length; i !== n; ++ i ) {\n\n\t\t\t\tvar object = arguments[ i ],\n\t\t\t\t\tuuid = object.uuid,\n\t\t\t\t\tindex = indicesByUUID[ uuid ];\n\n\t\t\t\tif ( index === undefined ) {\n\n\t\t\t\t\t// unknown object -> add it to the ACTIVE region\n\n\t\t\t\t\tindex = nObjects ++;\n\t\t\t\t\tindicesByUUID[ uuid ] = index;\n\t\t\t\t\tobjects.push( object );\n\n\t\t\t\t\t// accounting is done, now do the same for all bindings\n\n\t\t\t\t\tfor ( var j = 0, m = nBindings; j !== m; ++ j ) {\n\n\t\t\t\t\t\tbindings[ j ].push( new PropertyBinding( object, paths[ j ], parsedPaths[ j ] ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( index < nCachedObjects ) {\n\n\t\t\t\t\tknownObject = objects[ index ];\n\n\t\t\t\t\t// move existing object to the ACTIVE region\n\n\t\t\t\t\tvar firstActiveIndex = -- nCachedObjects,\n\t\t\t\t\t\tlastCachedObject = objects[ firstActiveIndex ];\n\n\t\t\t\t\tindicesByUUID[ lastCachedObject.uuid ] = index;\n\t\t\t\t\tobjects[ index ] = lastCachedObject;\n\n\t\t\t\t\tindicesByUUID[ uuid ] = firstActiveIndex;\n\t\t\t\t\tobjects[ firstActiveIndex ] = object;\n\n\t\t\t\t\t// accounting is done, now do the same for all bindings\n\n\t\t\t\t\tfor ( var j = 0, m = nBindings; j !== m; ++ j ) {\n\n\t\t\t\t\t\tvar bindingsForPath = bindings[ j ],\n\t\t\t\t\t\t\tlastCached = bindingsForPath[ firstActiveIndex ],\n\t\t\t\t\t\t\tbinding = bindingsForPath[ index ];\n\n\t\t\t\t\t\tbindingsForPath[ index ] = lastCached;\n\n\t\t\t\t\t\tif ( binding === undefined ) {\n\n\t\t\t\t\t\t\t// since we do not bother to create new bindings\n\t\t\t\t\t\t\t// for objects that are cached, the binding may\n\t\t\t\t\t\t\t// or may not exist\n\n\t\t\t\t\t\t\tbinding = new PropertyBinding( object, paths[ j ], parsedPaths[ j ] );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbindingsForPath[ firstActiveIndex ] = binding;\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( objects[ index ] !== knownObject ) {\n\n\t\t\t\t\tconsole.error( 'THREE.AnimationObjectGroup: Different objects with the same UUID ' +\n\t\t\t\t\t\t'detected. Clean the caches or recreate your infrastructure when reloading scenes.' );\n\n\t\t\t\t} // else the object is already where we want it to be\n\n\t\t\t} // for arguments\n\n\t\t\tthis.nCachedObjects_ = nCachedObjects;\n\n\t\t},\n\n\t\tremove: function () {\n\n\t\t\tvar objects = this._objects,\n\t\t\t\tnCachedObjects = this.nCachedObjects_,\n\t\t\t\tindicesByUUID = this._indicesByUUID,\n\t\t\t\tbindings = this._bindings,\n\t\t\t\tnBindings = bindings.length;\n\n\t\t\tfor ( var i = 0, n = arguments.length; i !== n; ++ i ) {\n\n\t\t\t\tvar object = arguments[ i ],\n\t\t\t\t\tuuid = object.uuid,\n\t\t\t\t\tindex = indicesByUUID[ uuid ];\n\n\t\t\t\tif ( index !== undefined && index >= nCachedObjects ) {\n\n\t\t\t\t\t// move existing object into the CACHED region\n\n\t\t\t\t\tvar lastCachedIndex = nCachedObjects ++,\n\t\t\t\t\t\tfirstActiveObject = objects[ lastCachedIndex ];\n\n\t\t\t\t\tindicesByUUID[ firstActiveObject.uuid ] = index;\n\t\t\t\t\tobjects[ index ] = firstActiveObject;\n\n\t\t\t\t\tindicesByUUID[ uuid ] = lastCachedIndex;\n\t\t\t\t\tobjects[ lastCachedIndex ] = object;\n\n\t\t\t\t\t// accounting is done, now do the same for all bindings\n\n\t\t\t\t\tfor ( var j = 0, m = nBindings; j !== m; ++ j ) {\n\n\t\t\t\t\t\tvar bindingsForPath = bindings[ j ],\n\t\t\t\t\t\t\tfirstActive = bindingsForPath[ lastCachedIndex ],\n\t\t\t\t\t\t\tbinding = bindingsForPath[ index ];\n\n\t\t\t\t\t\tbindingsForPath[ index ] = firstActive;\n\t\t\t\t\t\tbindingsForPath[ lastCachedIndex ] = binding;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} // for arguments\n\n\t\t\tthis.nCachedObjects_ = nCachedObjects;\n\n\t\t},\n\n\t\t// remove & forget\n\t\tuncache: function () {\n\n\t\t\tvar objects = this._objects,\n\t\t\t\tnObjects = objects.length,\n\t\t\t\tnCachedObjects = this.nCachedObjects_,\n\t\t\t\tindicesByUUID = this._indicesByUUID,\n\t\t\t\tbindings = this._bindings,\n\t\t\t\tnBindings = bindings.length;\n\n\t\t\tfor ( var i = 0, n = arguments.length; i !== n; ++ i ) {\n\n\t\t\t\tvar object = arguments[ i ],\n\t\t\t\t\tuuid = object.uuid,\n\t\t\t\t\tindex = indicesByUUID[ uuid ];\n\n\t\t\t\tif ( index !== undefined ) {\n\n\t\t\t\t\tdelete indicesByUUID[ uuid ];\n\n\t\t\t\t\tif ( index < nCachedObjects ) {\n\n\t\t\t\t\t\t// object is cached, shrink the CACHED region\n\n\t\t\t\t\t\tvar firstActiveIndex = -- nCachedObjects,\n\t\t\t\t\t\t\tlastCachedObject = objects[ firstActiveIndex ],\n\t\t\t\t\t\t\tlastIndex = -- nObjects,\n\t\t\t\t\t\t\tlastObject = objects[ lastIndex ];\n\n\t\t\t\t\t\t// last cached object takes this object's place\n\t\t\t\t\t\tindicesByUUID[ lastCachedObject.uuid ] = index;\n\t\t\t\t\t\tobjects[ index ] = lastCachedObject;\n\n\t\t\t\t\t\t// last object goes to the activated slot and pop\n\t\t\t\t\t\tindicesByUUID[ lastObject.uuid ] = firstActiveIndex;\n\t\t\t\t\t\tobjects[ firstActiveIndex ] = lastObject;\n\t\t\t\t\t\tobjects.pop();\n\n\t\t\t\t\t\t// accounting is done, now do the same for all bindings\n\n\t\t\t\t\t\tfor ( var j = 0, m = nBindings; j !== m; ++ j ) {\n\n\t\t\t\t\t\t\tvar bindingsForPath = bindings[ j ],\n\t\t\t\t\t\t\t\tlastCached = bindingsForPath[ firstActiveIndex ],\n\t\t\t\t\t\t\t\tlast = bindingsForPath[ lastIndex ];\n\n\t\t\t\t\t\t\tbindingsForPath[ index ] = lastCached;\n\t\t\t\t\t\t\tbindingsForPath[ firstActiveIndex ] = last;\n\t\t\t\t\t\t\tbindingsForPath.pop();\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// object is active, just swap with the last and pop\n\n\t\t\t\t\t\tvar lastIndex = -- nObjects,\n\t\t\t\t\t\t\tlastObject = objects[ lastIndex ];\n\n\t\t\t\t\t\tindicesByUUID[ lastObject.uuid ] = index;\n\t\t\t\t\t\tobjects[ index ] = lastObject;\n\t\t\t\t\t\tobjects.pop();\n\n\t\t\t\t\t\t// accounting is done, now do the same for all bindings\n\n\t\t\t\t\t\tfor ( var j = 0, m = nBindings; j !== m; ++ j ) {\n\n\t\t\t\t\t\t\tvar bindingsForPath = bindings[ j ];\n\n\t\t\t\t\t\t\tbindingsForPath[ index ] = bindingsForPath[ lastIndex ];\n\t\t\t\t\t\t\tbindingsForPath.pop();\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} // cached or active\n\n\t\t\t\t} // if object is known\n\n\t\t\t} // for arguments\n\n\t\t\tthis.nCachedObjects_ = nCachedObjects;\n\n\t\t},\n\n\t\t// Internal interface used by befriended PropertyBinding.Composite:\n\n\t\tsubscribe_: function ( path, parsedPath ) {\n\n\t\t\t// returns an array of bindings for the given path that is changed\n\t\t\t// according to the contained objects in the group\n\n\t\t\tvar indicesByPath = this._bindingsIndicesByPath,\n\t\t\t\tindex = indicesByPath[ path ],\n\t\t\t\tbindings = this._bindings;\n\n\t\t\tif ( index !== undefined ) return bindings[ index ];\n\n\t\t\tvar paths = this._paths,\n\t\t\t\tparsedPaths = this._parsedPaths,\n\t\t\t\tobjects = this._objects,\n\t\t\t\tnObjects = objects.length,\n\t\t\t\tnCachedObjects = this.nCachedObjects_,\n\t\t\t\tbindingsForPath = new Array( nObjects );\n\n\t\t\tindex = bindings.length;\n\n\t\t\tindicesByPath[ path ] = index;\n\n\t\t\tpaths.push( path );\n\t\t\tparsedPaths.push( parsedPath );\n\t\t\tbindings.push( bindingsForPath );\n\n\t\t\tfor ( var i = nCachedObjects, n = objects.length; i !== n; ++ i ) {\n\n\t\t\t\tvar object = objects[ i ];\n\t\t\t\tbindingsForPath[ i ] = new PropertyBinding( object, path, parsedPath );\n\n\t\t\t}\n\n\t\t\treturn bindingsForPath;\n\n\t\t},\n\n\t\tunsubscribe_: function ( path ) {\n\n\t\t\t// tells the group to forget about a property path and no longer\n\t\t\t// update the array previously obtained with 'subscribe_'\n\n\t\t\tvar indicesByPath = this._bindingsIndicesByPath,\n\t\t\t\tindex = indicesByPath[ path ];\n\n\t\t\tif ( index !== undefined ) {\n\n\t\t\t\tvar paths = this._paths,\n\t\t\t\t\tparsedPaths = this._parsedPaths,\n\t\t\t\t\tbindings = this._bindings,\n\t\t\t\t\tlastBindingsIndex = bindings.length - 1,\n\t\t\t\t\tlastBindings = bindings[ lastBindingsIndex ],\n\t\t\t\t\tlastBindingsPath = path[ lastBindingsIndex ];\n\n\t\t\t\tindicesByPath[ lastBindingsPath ] = index;\n\n\t\t\t\tbindings[ index ] = lastBindings;\n\t\t\t\tbindings.pop();\n\n\t\t\t\tparsedPaths[ index ] = parsedPaths[ lastBindingsIndex ];\n\t\t\t\tparsedPaths.pop();\n\n\t\t\t\tpaths[ index ] = paths[ lastBindingsIndex ];\n\t\t\t\tpaths.pop();\n\n\t\t\t}\n\n\t\t}\n\n\t} );\n\n\t/**\n\t *\n\t * Action provided by AnimationMixer for scheduling clip playback on specific\n\t * objects.\n\t *\n\t * @author Ben Houston / http://clara.io/\n\t * @author David Sarno / http://lighthaus.us/\n\t * @author tschw\n\t *\n\t */\n\n\tfunction AnimationAction( mixer, clip, localRoot ) {\n\n\t\tthis._mixer = mixer;\n\t\tthis._clip = clip;\n\t\tthis._localRoot = localRoot || null;\n\n\t\tvar tracks = clip.tracks,\n\t\t\tnTracks = tracks.length,\n\t\t\tinterpolants = new Array( nTracks );\n\n\t\tvar interpolantSettings = {\n\t\t\tendingStart: ZeroCurvatureEnding,\n\t\t\tendingEnd: ZeroCurvatureEnding\n\t\t};\n\n\t\tfor ( var i = 0; i !== nTracks; ++ i ) {\n\n\t\t\tvar interpolant = tracks[ i ].createInterpolant( null );\n\t\t\tinterpolants[ i ] = interpolant;\n\t\t\tinterpolant.settings = interpolantSettings;\n\n\t\t}\n\n\t\tthis._interpolantSettings = interpolantSettings;\n\n\t\tthis._interpolants = interpolants; // bound by the mixer\n\n\t\t// inside: PropertyMixer (managed by the mixer)\n\t\tthis._propertyBindings = new Array( nTracks );\n\n\t\tthis._cacheIndex = null; // for the memory manager\n\t\tthis._byClipCacheIndex = null; // for the memory manager\n\n\t\tthis._timeScaleInterpolant = null;\n\t\tthis._weightInterpolant = null;\n\n\t\tthis.loop = LoopRepeat;\n\t\tthis._loopCount = - 1;\n\n\t\t// global mixer time when the action is to be started\n\t\t// it's set back to 'null' upon start of the action\n\t\tthis._startTime = null;\n\n\t\t// scaled local time of the action\n\t\t// gets clamped or wrapped to 0..clip.duration according to loop\n\t\tthis.time = 0;\n\n\t\tthis.timeScale = 1;\n\t\tthis._effectiveTimeScale = 1;\n\n\t\tthis.weight = 1;\n\t\tthis._effectiveWeight = 1;\n\n\t\tthis.repetitions = Infinity; // no. of repetitions when looping\n\n\t\tthis.paused = false; // true -> zero effective time scale\n\t\tthis.enabled = true; // false -> zero effective weight\n\n\t\tthis.clampWhenFinished = false;// keep feeding the last frame?\n\n\t\tthis.zeroSlopeAtStart = true;// for smooth interpolation w/o separate\n\t\tthis.zeroSlopeAtEnd = true;// clips for start, loop and end\n\n\t}\n\n\tObject.assign( AnimationAction.prototype, {\n\n\t\t// State & Scheduling\n\n\t\tplay: function () {\n\n\t\t\tthis._mixer._activateAction( this );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tstop: function () {\n\n\t\t\tthis._mixer._deactivateAction( this );\n\n\t\t\treturn this.reset();\n\n\t\t},\n\n\t\treset: function () {\n\n\t\t\tthis.paused = false;\n\t\t\tthis.enabled = true;\n\n\t\t\tthis.time = 0; // restart clip\n\t\t\tthis._loopCount = - 1;// forget previous loops\n\t\t\tthis._startTime = null;// forget scheduling\n\n\t\t\treturn this.stopFading().stopWarping();\n\n\t\t},\n\n\t\tisRunning: function () {\n\n\t\t\treturn this.enabled && ! this.paused && this.timeScale !== 0 &&\n\t\t\t\tthis._startTime === null && this._mixer._isActiveAction( this );\n\n\t\t},\n\n\t\t// return true when play has been called\n\t\tisScheduled: function () {\n\n\t\t\treturn this._mixer._isActiveAction( this );\n\n\t\t},\n\n\t\tstartAt: function ( time ) {\n\n\t\t\tthis._startTime = time;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetLoop: function ( mode, repetitions ) {\n\n\t\t\tthis.loop = mode;\n\t\t\tthis.repetitions = repetitions;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\t// Weight\n\n\t\t// set the weight stopping any scheduled fading\n\t\t// although .enabled = false yields an effective weight of zero, this\n\t\t// method does *not* change .enabled, because it would be confusing\n\t\tsetEffectiveWeight: function ( weight ) {\n\n\t\t\tthis.weight = weight;\n\n\t\t\t// note: same logic as when updated at runtime\n\t\t\tthis._effectiveWeight = this.enabled ? weight : 0;\n\n\t\t\treturn this.stopFading();\n\n\t\t},\n\n\t\t// return the weight considering fading and .enabled\n\t\tgetEffectiveWeight: function () {\n\n\t\t\treturn this._effectiveWeight;\n\n\t\t},\n\n\t\tfadeIn: function ( duration ) {\n\n\t\t\treturn this._scheduleFading( duration, 0, 1 );\n\n\t\t},\n\n\t\tfadeOut: function ( duration ) {\n\n\t\t\treturn this._scheduleFading( duration, 1, 0 );\n\n\t\t},\n\n\t\tcrossFadeFrom: function ( fadeOutAction, duration, warp ) {\n\n\t\t\tfadeOutAction.fadeOut( duration );\n\t\t\tthis.fadeIn( duration );\n\n\t\t\tif ( warp ) {\n\n\t\t\t\tvar fadeInDuration = this._clip.duration,\n\t\t\t\t\tfadeOutDuration = fadeOutAction._clip.duration,\n\n\t\t\t\t\tstartEndRatio = fadeOutDuration / fadeInDuration,\n\t\t\t\t\tendStartRatio = fadeInDuration / fadeOutDuration;\n\n\t\t\t\tfadeOutAction.warp( 1.0, startEndRatio, duration );\n\t\t\t\tthis.warp( endStartRatio, 1.0, duration );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcrossFadeTo: function ( fadeInAction, duration, warp ) {\n\n\t\t\treturn fadeInAction.crossFadeFrom( this, duration, warp );\n\n\t\t},\n\n\t\tstopFading: function () {\n\n\t\t\tvar weightInterpolant = this._weightInterpolant;\n\n\t\t\tif ( weightInterpolant !== null ) {\n\n\t\t\t\tthis._weightInterpolant = null;\n\t\t\t\tthis._mixer._takeBackControlInterpolant( weightInterpolant );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\t// Time Scale Control\n\n\t\t// set the time scale stopping any scheduled warping\n\t\t// although .paused = true yields an effective time scale of zero, this\n\t\t// method does *not* change .paused, because it would be confusing\n\t\tsetEffectiveTimeScale: function ( timeScale ) {\n\n\t\t\tthis.timeScale = timeScale;\n\t\t\tthis._effectiveTimeScale = this.paused ? 0 : timeScale;\n\n\t\t\treturn this.stopWarping();\n\n\t\t},\n\n\t\t// return the time scale considering warping and .paused\n\t\tgetEffectiveTimeScale: function () {\n\n\t\t\treturn this._effectiveTimeScale;\n\n\t\t},\n\n\t\tsetDuration: function ( duration ) {\n\n\t\t\tthis.timeScale = this._clip.duration / duration;\n\n\t\t\treturn this.stopWarping();\n\n\t\t},\n\n\t\tsyncWith: function ( action ) {\n\n\t\t\tthis.time = action.time;\n\t\t\tthis.timeScale = action.timeScale;\n\n\t\t\treturn this.stopWarping();\n\n\t\t},\n\n\t\thalt: function ( duration ) {\n\n\t\t\treturn this.warp( this._effectiveTimeScale, 0, duration );\n\n\t\t},\n\n\t\twarp: function ( startTimeScale, endTimeScale, duration ) {\n\n\t\t\tvar mixer = this._mixer, now = mixer.time,\n\t\t\t\tinterpolant = this._timeScaleInterpolant,\n\n\t\t\t\ttimeScale = this.timeScale;\n\n\t\t\tif ( interpolant === null ) {\n\n\t\t\t\tinterpolant = mixer._lendControlInterpolant();\n\t\t\t\tthis._timeScaleInterpolant = interpolant;\n\n\t\t\t}\n\n\t\t\tvar times = interpolant.parameterPositions,\n\t\t\t\tvalues = interpolant.sampleValues;\n\n\t\t\ttimes[ 0 ] = now;\n\t\t\ttimes[ 1 ] = now + duration;\n\n\t\t\tvalues[ 0 ] = startTimeScale / timeScale;\n\t\t\tvalues[ 1 ] = endTimeScale / timeScale;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tstopWarping: function () {\n\n\t\t\tvar timeScaleInterpolant = this._timeScaleInterpolant;\n\n\t\t\tif ( timeScaleInterpolant !== null ) {\n\n\t\t\t\tthis._timeScaleInterpolant = null;\n\t\t\t\tthis._mixer._takeBackControlInterpolant( timeScaleInterpolant );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\t// Object Accessors\n\n\t\tgetMixer: function () {\n\n\t\t\treturn this._mixer;\n\n\t\t},\n\n\t\tgetClip: function () {\n\n\t\t\treturn this._clip;\n\n\t\t},\n\n\t\tgetRoot: function () {\n\n\t\t\treturn this._localRoot || this._mixer._root;\n\n\t\t},\n\n\t\t// Interna\n\n\t\t_update: function ( time, deltaTime, timeDirection, accuIndex ) {\n\n\t\t\t// called by the mixer\n\n\t\t\tif ( ! this.enabled ) {\n\n\t\t\t\t// call ._updateWeight() to update ._effectiveWeight\n\n\t\t\t\tthis._updateWeight( time );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tvar startTime = this._startTime;\n\n\t\t\tif ( startTime !== null ) {\n\n\t\t\t\t// check for scheduled start of action\n\n\t\t\t\tvar timeRunning = ( time - startTime ) * timeDirection;\n\t\t\t\tif ( timeRunning < 0 || timeDirection === 0 ) {\n\n\t\t\t\t\treturn; // yet to come / don't decide when delta = 0\n\n\t\t\t\t}\n\n\t\t\t\t// start\n\n\t\t\t\tthis._startTime = null; // unschedule\n\t\t\t\tdeltaTime = timeDirection * timeRunning;\n\n\t\t\t}\n\n\t\t\t// apply time scale and advance time\n\n\t\t\tdeltaTime *= this._updateTimeScale( time );\n\t\t\tvar clipTime = this._updateTime( deltaTime );\n\n\t\t\t// note: _updateTime may disable the action resulting in\n\t\t\t// an effective weight of 0\n\n\t\t\tvar weight = this._updateWeight( time );\n\n\t\t\tif ( weight > 0 ) {\n\n\t\t\t\tvar interpolants = this._interpolants;\n\t\t\t\tvar propertyMixers = this._propertyBindings;\n\n\t\t\t\tfor ( var j = 0, m = interpolants.length; j !== m; ++ j ) {\n\n\t\t\t\t\tinterpolants[ j ].evaluate( clipTime );\n\t\t\t\t\tpropertyMixers[ j ].accumulate( accuIndex, weight );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t},\n\n\t\t_updateWeight: function ( time ) {\n\n\t\t\tvar weight = 0;\n\n\t\t\tif ( this.enabled ) {\n\n\t\t\t\tweight = this.weight;\n\t\t\t\tvar interpolant = this._weightInterpolant;\n\n\t\t\t\tif ( interpolant !== null ) {\n\n\t\t\t\t\tvar interpolantValue = interpolant.evaluate( time )[ 0 ];\n\n\t\t\t\t\tweight *= interpolantValue;\n\n\t\t\t\t\tif ( time > interpolant.parameterPositions[ 1 ] ) {\n\n\t\t\t\t\t\tthis.stopFading();\n\n\t\t\t\t\t\tif ( interpolantValue === 0 ) {\n\n\t\t\t\t\t\t\t// faded out, disable\n\t\t\t\t\t\t\tthis.enabled = false;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis._effectiveWeight = weight;\n\t\t\treturn weight;\n\n\t\t},\n\n\t\t_updateTimeScale: function ( time ) {\n\n\t\t\tvar timeScale = 0;\n\n\t\t\tif ( ! this.paused ) {\n\n\t\t\t\ttimeScale = this.timeScale;\n\n\t\t\t\tvar interpolant = this._timeScaleInterpolant;\n\n\t\t\t\tif ( interpolant !== null ) {\n\n\t\t\t\t\tvar interpolantValue = interpolant.evaluate( time )[ 0 ];\n\n\t\t\t\t\ttimeScale *= interpolantValue;\n\n\t\t\t\t\tif ( time > interpolant.parameterPositions[ 1 ] ) {\n\n\t\t\t\t\t\tthis.stopWarping();\n\n\t\t\t\t\t\tif ( timeScale === 0 ) {\n\n\t\t\t\t\t\t\t// motion has halted, pause\n\t\t\t\t\t\t\tthis.paused = true;\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t// warp done - apply final time scale\n\t\t\t\t\t\t\tthis.timeScale = timeScale;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis._effectiveTimeScale = timeScale;\n\t\t\treturn timeScale;\n\n\t\t},\n\n\t\t_updateTime: function ( deltaTime ) {\n\n\t\t\tvar time = this.time + deltaTime;\n\t\t\tvar duration = this._clip.duration;\n\t\t\tvar loop = this.loop;\n\t\t\tvar loopCount = this._loopCount;\n\n\t\t\tvar pingPong = ( loop === LoopPingPong );\n\n\t\t\tif ( deltaTime === 0 ) {\n\n\t\t\t\tif ( loopCount === - 1 ) return time;\n\n\t\t\t\treturn ( pingPong && ( loopCount & 1 ) === 1 ) ? duration - time : time;\n\n\t\t\t}\n\n\t\t\tif ( loop === LoopOnce ) {\n\n\t\t\t\tif ( loopCount === - 1 ) {\n\n\t\t\t\t\t// just started\n\n\t\t\t\t\tthis._loopCount = 0;\n\t\t\t\t\tthis._setEndings( true, true, false );\n\n\t\t\t\t}\n\n\t\t\t\thandle_stop: {\n\n\t\t\t\t\tif ( time >= duration ) {\n\n\t\t\t\t\t\ttime = duration;\n\n\t\t\t\t\t} else if ( time < 0 ) {\n\n\t\t\t\t\t\ttime = 0;\n\n\t\t\t\t\t} else break handle_stop;\n\n\t\t\t\t\tif ( this.clampWhenFinished ) this.paused = true;\n\t\t\t\t\telse this.enabled = false;\n\n\t\t\t\t\tthis._mixer.dispatchEvent( {\n\t\t\t\t\t\ttype: 'finished', action: this,\n\t\t\t\t\t\tdirection: deltaTime < 0 ? - 1 : 1\n\t\t\t\t\t} );\n\n\t\t\t\t}\n\n\t\t\t} else { // repetitive Repeat or PingPong\n\n\t\t\t\tif ( loopCount === - 1 ) {\n\n\t\t\t\t\t// just started\n\n\t\t\t\t\tif ( deltaTime >= 0 ) {\n\n\t\t\t\t\t\tloopCount = 0;\n\n\t\t\t\t\t\tthis._setEndings( true, this.repetitions === 0, pingPong );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// when looping in reverse direction, the initial\n\t\t\t\t\t\t// transition through zero counts as a repetition,\n\t\t\t\t\t\t// so leave loopCount at -1\n\n\t\t\t\t\t\tthis._setEndings( this.repetitions === 0, true, pingPong );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( time >= duration || time < 0 ) {\n\n\t\t\t\t\t// wrap around\n\n\t\t\t\t\tvar loopDelta = Math.floor( time / duration ); // signed\n\t\t\t\t\ttime -= duration * loopDelta;\n\n\t\t\t\t\tloopCount += Math.abs( loopDelta );\n\n\t\t\t\t\tvar pending = this.repetitions - loopCount;\n\n\t\t\t\t\tif ( pending <= 0 ) {\n\n\t\t\t\t\t\t// have to stop (switch state, clamp time, fire event)\n\n\t\t\t\t\t\tif ( this.clampWhenFinished ) this.paused = true;\n\t\t\t\t\t\telse this.enabled = false;\n\n\t\t\t\t\t\ttime = deltaTime > 0 ? duration : 0;\n\n\t\t\t\t\t\tthis._mixer.dispatchEvent( {\n\t\t\t\t\t\t\ttype: 'finished', action: this,\n\t\t\t\t\t\t\tdirection: deltaTime > 0 ? 1 : - 1\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// keep running\n\n\t\t\t\t\t\tif ( pending === 1 ) {\n\n\t\t\t\t\t\t\t// entering the last round\n\n\t\t\t\t\t\t\tvar atStart = deltaTime < 0;\n\t\t\t\t\t\t\tthis._setEndings( atStart, ! atStart, pingPong );\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tthis._setEndings( false, false, pingPong );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis._loopCount = loopCount;\n\n\t\t\t\t\t\tthis._mixer.dispatchEvent( {\n\t\t\t\t\t\t\ttype: 'loop', action: this, loopDelta: loopDelta\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( pingPong && ( loopCount & 1 ) === 1 ) {\n\n\t\t\t\t\t// invert time for the \"pong round\"\n\n\t\t\t\t\tthis.time = time;\n\t\t\t\t\treturn duration - time;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.time = time;\n\t\t\treturn time;\n\n\t\t},\n\n\t\t_setEndings: function ( atStart, atEnd, pingPong ) {\n\n\t\t\tvar settings = this._interpolantSettings;\n\n\t\t\tif ( pingPong ) {\n\n\t\t\t\tsettings.endingStart = ZeroSlopeEnding;\n\t\t\t\tsettings.endingEnd = ZeroSlopeEnding;\n\n\t\t\t} else {\n\n\t\t\t\t// assuming for LoopOnce atStart == atEnd == true\n\n\t\t\t\tif ( atStart ) {\n\n\t\t\t\t\tsettings.endingStart = this.zeroSlopeAtStart ? ZeroSlopeEnding : ZeroCurvatureEnding;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tsettings.endingStart = WrapAroundEnding;\n\n\t\t\t\t}\n\n\t\t\t\tif ( atEnd ) {\n\n\t\t\t\t\tsettings.endingEnd = this.zeroSlopeAtEnd ? ZeroSlopeEnding : ZeroCurvatureEnding;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tsettings.endingEnd \t = WrapAroundEnding;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t},\n\n\t\t_scheduleFading: function ( duration, weightNow, weightThen ) {\n\n\t\t\tvar mixer = this._mixer, now = mixer.time,\n\t\t\t\tinterpolant = this._weightInterpolant;\n\n\t\t\tif ( interpolant === null ) {\n\n\t\t\t\tinterpolant = mixer._lendControlInterpolant();\n\t\t\t\tthis._weightInterpolant = interpolant;\n\n\t\t\t}\n\n\t\t\tvar times = interpolant.parameterPositions,\n\t\t\t\tvalues = interpolant.sampleValues;\n\n\t\t\ttimes[ 0 ] = now;\n\t\t\tvalues[ 0 ] = weightNow;\n\t\t\ttimes[ 1 ] = now + duration;\n\t\t\tvalues[ 1 ] = weightThen;\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t *\n\t * Player for AnimationClips.\n\t *\n\t *\n\t * @author Ben Houston / http://clara.io/\n\t * @author David Sarno / http://lighthaus.us/\n\t * @author tschw\n\t */\n\n\tfunction AnimationMixer( root ) {\n\n\t\tthis._root = root;\n\t\tthis._initMemoryManager();\n\t\tthis._accuIndex = 0;\n\n\t\tthis.time = 0;\n\n\t\tthis.timeScale = 1.0;\n\n\t}\n\n\tAnimationMixer.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\t\tconstructor: AnimationMixer,\n\n\t\t_bindAction: function ( action, prototypeAction ) {\n\n\t\t\tvar root = action._localRoot || this._root,\n\t\t\t\ttracks = action._clip.tracks,\n\t\t\t\tnTracks = tracks.length,\n\t\t\t\tbindings = action._propertyBindings,\n\t\t\t\tinterpolants = action._interpolants,\n\t\t\t\trootUuid = root.uuid,\n\t\t\t\tbindingsByRoot = this._bindingsByRootAndName,\n\t\t\t\tbindingsByName = bindingsByRoot[ rootUuid ];\n\n\t\t\tif ( bindingsByName === undefined ) {\n\n\t\t\t\tbindingsByName = {};\n\t\t\t\tbindingsByRoot[ rootUuid ] = bindingsByName;\n\n\t\t\t}\n\n\t\t\tfor ( var i = 0; i !== nTracks; ++ i ) {\n\n\t\t\t\tvar track = tracks[ i ],\n\t\t\t\t\ttrackName = track.name,\n\t\t\t\t\tbinding = bindingsByName[ trackName ];\n\n\t\t\t\tif ( binding !== undefined ) {\n\n\t\t\t\t\tbindings[ i ] = binding;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tbinding = bindings[ i ];\n\n\t\t\t\t\tif ( binding !== undefined ) {\n\n\t\t\t\t\t\t// existing binding, make sure the cache knows\n\n\t\t\t\t\t\tif ( binding._cacheIndex === null ) {\n\n\t\t\t\t\t\t\t++ binding.referenceCount;\n\t\t\t\t\t\t\tthis._addInactiveBinding( binding, rootUuid, trackName );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tvar path = prototypeAction && prototypeAction.\n\t\t\t\t\t\t_propertyBindings[ i ].binding.parsedPath;\n\n\t\t\t\t\tbinding = new PropertyMixer(\n\t\t\t\t\t\tPropertyBinding.create( root, trackName, path ),\n\t\t\t\t\t\ttrack.ValueTypeName, track.getValueSize() );\n\n\t\t\t\t\t++ binding.referenceCount;\n\t\t\t\t\tthis._addInactiveBinding( binding, rootUuid, trackName );\n\n\t\t\t\t\tbindings[ i ] = binding;\n\n\t\t\t\t}\n\n\t\t\t\tinterpolants[ i ].resultBuffer = binding.buffer;\n\n\t\t\t}\n\n\t\t},\n\n\t\t_activateAction: function ( action ) {\n\n\t\t\tif ( ! this._isActiveAction( action ) ) {\n\n\t\t\t\tif ( action._cacheIndex === null ) {\n\n\t\t\t\t\t// this action has been forgotten by the cache, but the user\n\t\t\t\t\t// appears to be still using it -> rebind\n\n\t\t\t\t\tvar rootUuid = ( action._localRoot || this._root ).uuid,\n\t\t\t\t\t\tclipUuid = action._clip.uuid,\n\t\t\t\t\t\tactionsForClip = this._actionsByClip[ clipUuid ];\n\n\t\t\t\t\tthis._bindAction( action,\n\t\t\t\t\t\tactionsForClip && actionsForClip.knownActions[ 0 ] );\n\n\t\t\t\t\tthis._addInactiveAction( action, clipUuid, rootUuid );\n\n\t\t\t\t}\n\n\t\t\t\tvar bindings = action._propertyBindings;\n\n\t\t\t\t// increment reference counts / sort out state\n\t\t\t\tfor ( var i = 0, n = bindings.length; i !== n; ++ i ) {\n\n\t\t\t\t\tvar binding = bindings[ i ];\n\n\t\t\t\t\tif ( binding.useCount ++ === 0 ) {\n\n\t\t\t\t\t\tthis._lendBinding( binding );\n\t\t\t\t\t\tbinding.saveOriginalState();\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tthis._lendAction( action );\n\n\t\t\t}\n\n\t\t},\n\n\t\t_deactivateAction: function ( action ) {\n\n\t\t\tif ( this._isActiveAction( action ) ) {\n\n\t\t\t\tvar bindings = action._propertyBindings;\n\n\t\t\t\t// decrement reference counts / sort out state\n\t\t\t\tfor ( var i = 0, n = bindings.length; i !== n; ++ i ) {\n\n\t\t\t\t\tvar binding = bindings[ i ];\n\n\t\t\t\t\tif ( -- binding.useCount === 0 ) {\n\n\t\t\t\t\t\tbinding.restoreOriginalState();\n\t\t\t\t\t\tthis._takeBackBinding( binding );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tthis._takeBackAction( action );\n\n\t\t\t}\n\n\t\t},\n\n\t\t// Memory manager\n\n\t\t_initMemoryManager: function () {\n\n\t\t\tthis._actions = []; // 'nActiveActions' followed by inactive ones\n\t\t\tthis._nActiveActions = 0;\n\n\t\t\tthis._actionsByClip = {};\n\t\t\t// inside:\n\t\t\t// {\n\t\t\t// \tknownActions: Array< AnimationAction > - used as prototypes\n\t\t\t// \tactionByRoot: AnimationAction - lookup\n\t\t\t// }\n\n\n\t\t\tthis._bindings = []; // 'nActiveBindings' followed by inactive ones\n\t\t\tthis._nActiveBindings = 0;\n\n\t\t\tthis._bindingsByRootAndName = {}; // inside: Map< name, PropertyMixer >\n\n\n\t\t\tthis._controlInterpolants = []; // same game as above\n\t\t\tthis._nActiveControlInterpolants = 0;\n\n\t\t\tvar scope = this;\n\n\t\t\tthis.stats = {\n\n\t\t\t\tactions: {\n\t\t\t\t\tget total() {\n\n\t\t\t\t\t\treturn scope._actions.length;\n\n\t\t\t\t\t},\n\t\t\t\t\tget inUse() {\n\n\t\t\t\t\t\treturn scope._nActiveActions;\n\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tbindings: {\n\t\t\t\t\tget total() {\n\n\t\t\t\t\t\treturn scope._bindings.length;\n\n\t\t\t\t\t},\n\t\t\t\t\tget inUse() {\n\n\t\t\t\t\t\treturn scope._nActiveBindings;\n\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tcontrolInterpolants: {\n\t\t\t\t\tget total() {\n\n\t\t\t\t\t\treturn scope._controlInterpolants.length;\n\n\t\t\t\t\t},\n\t\t\t\t\tget inUse() {\n\n\t\t\t\t\t\treturn scope._nActiveControlInterpolants;\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t},\n\n\t\t// Memory management for AnimationAction objects\n\n\t\t_isActiveAction: function ( action ) {\n\n\t\t\tvar index = action._cacheIndex;\n\t\t\treturn index !== null && index < this._nActiveActions;\n\n\t\t},\n\n\t\t_addInactiveAction: function ( action, clipUuid, rootUuid ) {\n\n\t\t\tvar actions = this._actions,\n\t\t\t\tactionsByClip = this._actionsByClip,\n\t\t\t\tactionsForClip = actionsByClip[ clipUuid ];\n\n\t\t\tif ( actionsForClip === undefined ) {\n\n\t\t\t\tactionsForClip = {\n\n\t\t\t\t\tknownActions: [ action ],\n\t\t\t\t\tactionByRoot: {}\n\n\t\t\t\t};\n\n\t\t\t\taction._byClipCacheIndex = 0;\n\n\t\t\t\tactionsByClip[ clipUuid ] = actionsForClip;\n\n\t\t\t} else {\n\n\t\t\t\tvar knownActions = actionsForClip.knownActions;\n\n\t\t\t\taction._byClipCacheIndex = knownActions.length;\n\t\t\t\tknownActions.push( action );\n\n\t\t\t}\n\n\t\t\taction._cacheIndex = actions.length;\n\t\t\tactions.push( action );\n\n\t\t\tactionsForClip.actionByRoot[ rootUuid ] = action;\n\n\t\t},\n\n\t\t_removeInactiveAction: function ( action ) {\n\n\t\t\tvar actions = this._actions,\n\t\t\t\tlastInactiveAction = actions[ actions.length - 1 ],\n\t\t\t\tcacheIndex = action._cacheIndex;\n\n\t\t\tlastInactiveAction._cacheIndex = cacheIndex;\n\t\t\tactions[ cacheIndex ] = lastInactiveAction;\n\t\t\tactions.pop();\n\n\t\t\taction._cacheIndex = null;\n\n\n\t\t\tvar clipUuid = action._clip.uuid,\n\t\t\t\tactionsByClip = this._actionsByClip,\n\t\t\t\tactionsForClip = actionsByClip[ clipUuid ],\n\t\t\t\tknownActionsForClip = actionsForClip.knownActions,\n\n\t\t\t\tlastKnownAction =\n\t\t\t\t\tknownActionsForClip[ knownActionsForClip.length - 1 ],\n\n\t\t\t\tbyClipCacheIndex = action._byClipCacheIndex;\n\n\t\t\tlastKnownAction._byClipCacheIndex = byClipCacheIndex;\n\t\t\tknownActionsForClip[ byClipCacheIndex ] = lastKnownAction;\n\t\t\tknownActionsForClip.pop();\n\n\t\t\taction._byClipCacheIndex = null;\n\n\n\t\t\tvar actionByRoot = actionsForClip.actionByRoot,\n\t\t\t\trootUuid = ( action._localRoot || this._root ).uuid;\n\n\t\t\tdelete actionByRoot[ rootUuid ];\n\n\t\t\tif ( knownActionsForClip.length === 0 ) {\n\n\t\t\t\tdelete actionsByClip[ clipUuid ];\n\n\t\t\t}\n\n\t\t\tthis._removeInactiveBindingsForAction( action );\n\n\t\t},\n\n\t\t_removeInactiveBindingsForAction: function ( action ) {\n\n\t\t\tvar bindings = action._propertyBindings;\n\t\t\tfor ( var i = 0, n = bindings.length; i !== n; ++ i ) {\n\n\t\t\t\tvar binding = bindings[ i ];\n\n\t\t\t\tif ( -- binding.referenceCount === 0 ) {\n\n\t\t\t\t\tthis._removeInactiveBinding( binding );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t},\n\n\t\t_lendAction: function ( action ) {\n\n\t\t\t// [ active actions |  inactive actions  ]\n\t\t\t// [  active actions >| inactive actions ]\n\t\t\t//                 s        a\n\t\t\t//                  <-swap->\n\t\t\t//                 a        s\n\n\t\t\tvar actions = this._actions,\n\t\t\t\tprevIndex = action._cacheIndex,\n\n\t\t\t\tlastActiveIndex = this._nActiveActions ++,\n\n\t\t\t\tfirstInactiveAction = actions[ lastActiveIndex ];\n\n\t\t\taction._cacheIndex = lastActiveIndex;\n\t\t\tactions[ lastActiveIndex ] = action;\n\n\t\t\tfirstInactiveAction._cacheIndex = prevIndex;\n\t\t\tactions[ prevIndex ] = firstInactiveAction;\n\n\t\t},\n\n\t\t_takeBackAction: function ( action ) {\n\n\t\t\t// [  active actions  | inactive actions ]\n\t\t\t// [ active actions |< inactive actions  ]\n\t\t\t//        a        s\n\t\t\t//         <-swap->\n\t\t\t//        s        a\n\n\t\t\tvar actions = this._actions,\n\t\t\t\tprevIndex = action._cacheIndex,\n\n\t\t\t\tfirstInactiveIndex = -- this._nActiveActions,\n\n\t\t\t\tlastActiveAction = actions[ firstInactiveIndex ];\n\n\t\t\taction._cacheIndex = firstInactiveIndex;\n\t\t\tactions[ firstInactiveIndex ] = action;\n\n\t\t\tlastActiveAction._cacheIndex = prevIndex;\n\t\t\tactions[ prevIndex ] = lastActiveAction;\n\n\t\t},\n\n\t\t// Memory management for PropertyMixer objects\n\n\t\t_addInactiveBinding: function ( binding, rootUuid, trackName ) {\n\n\t\t\tvar bindingsByRoot = this._bindingsByRootAndName,\n\t\t\t\tbindingByName = bindingsByRoot[ rootUuid ],\n\n\t\t\t\tbindings = this._bindings;\n\n\t\t\tif ( bindingByName === undefined ) {\n\n\t\t\t\tbindingByName = {};\n\t\t\t\tbindingsByRoot[ rootUuid ] = bindingByName;\n\n\t\t\t}\n\n\t\t\tbindingByName[ trackName ] = binding;\n\n\t\t\tbinding._cacheIndex = bindings.length;\n\t\t\tbindings.push( binding );\n\n\t\t},\n\n\t\t_removeInactiveBinding: function ( binding ) {\n\n\t\t\tvar bindings = this._bindings,\n\t\t\t\tpropBinding = binding.binding,\n\t\t\t\trootUuid = propBinding.rootNode.uuid,\n\t\t\t\ttrackName = propBinding.path,\n\t\t\t\tbindingsByRoot = this._bindingsByRootAndName,\n\t\t\t\tbindingByName = bindingsByRoot[ rootUuid ],\n\n\t\t\t\tlastInactiveBinding = bindings[ bindings.length - 1 ],\n\t\t\t\tcacheIndex = binding._cacheIndex;\n\n\t\t\tlastInactiveBinding._cacheIndex = cacheIndex;\n\t\t\tbindings[ cacheIndex ] = lastInactiveBinding;\n\t\t\tbindings.pop();\n\n\t\t\tdelete bindingByName[ trackName ];\n\n\t\t\tremove_empty_map: {\n\n\t\t\t\tfor ( var _ in bindingByName ) break remove_empty_map; // eslint-disable-line no-unused-vars\n\n\t\t\t\tdelete bindingsByRoot[ rootUuid ];\n\n\t\t\t}\n\n\t\t},\n\n\t\t_lendBinding: function ( binding ) {\n\n\t\t\tvar bindings = this._bindings,\n\t\t\t\tprevIndex = binding._cacheIndex,\n\n\t\t\t\tlastActiveIndex = this._nActiveBindings ++,\n\n\t\t\t\tfirstInactiveBinding = bindings[ lastActiveIndex ];\n\n\t\t\tbinding._cacheIndex = lastActiveIndex;\n\t\t\tbindings[ lastActiveIndex ] = binding;\n\n\t\t\tfirstInactiveBinding._cacheIndex = prevIndex;\n\t\t\tbindings[ prevIndex ] = firstInactiveBinding;\n\n\t\t},\n\n\t\t_takeBackBinding: function ( binding ) {\n\n\t\t\tvar bindings = this._bindings,\n\t\t\t\tprevIndex = binding._cacheIndex,\n\n\t\t\t\tfirstInactiveIndex = -- this._nActiveBindings,\n\n\t\t\t\tlastActiveBinding = bindings[ firstInactiveIndex ];\n\n\t\t\tbinding._cacheIndex = firstInactiveIndex;\n\t\t\tbindings[ firstInactiveIndex ] = binding;\n\n\t\t\tlastActiveBinding._cacheIndex = prevIndex;\n\t\t\tbindings[ prevIndex ] = lastActiveBinding;\n\n\t\t},\n\n\n\t\t// Memory management of Interpolants for weight and time scale\n\n\t\t_lendControlInterpolant: function () {\n\n\t\t\tvar interpolants = this._controlInterpolants,\n\t\t\t\tlastActiveIndex = this._nActiveControlInterpolants ++,\n\t\t\t\tinterpolant = interpolants[ lastActiveIndex ];\n\n\t\t\tif ( interpolant === undefined ) {\n\n\t\t\t\tinterpolant = new LinearInterpolant(\n\t\t\t\t\tnew Float32Array( 2 ), new Float32Array( 2 ),\n\t\t\t\t\t1, this._controlInterpolantsResultBuffer );\n\n\t\t\t\tinterpolant.__cacheIndex = lastActiveIndex;\n\t\t\t\tinterpolants[ lastActiveIndex ] = interpolant;\n\n\t\t\t}\n\n\t\t\treturn interpolant;\n\n\t\t},\n\n\t\t_takeBackControlInterpolant: function ( interpolant ) {\n\n\t\t\tvar interpolants = this._controlInterpolants,\n\t\t\t\tprevIndex = interpolant.__cacheIndex,\n\n\t\t\t\tfirstInactiveIndex = -- this._nActiveControlInterpolants,\n\n\t\t\t\tlastActiveInterpolant = interpolants[ firstInactiveIndex ];\n\n\t\t\tinterpolant.__cacheIndex = firstInactiveIndex;\n\t\t\tinterpolants[ firstInactiveIndex ] = interpolant;\n\n\t\t\tlastActiveInterpolant.__cacheIndex = prevIndex;\n\t\t\tinterpolants[ prevIndex ] = lastActiveInterpolant;\n\n\t\t},\n\n\t\t_controlInterpolantsResultBuffer: new Float32Array( 1 ),\n\n\t\t// return an action for a clip optionally using a custom root target\n\t\t// object (this method allocates a lot of dynamic memory in case a\n\t\t// previously unknown clip/root combination is specified)\n\t\tclipAction: function ( clip, optionalRoot ) {\n\n\t\t\tvar root = optionalRoot || this._root,\n\t\t\t\trootUuid = root.uuid,\n\n\t\t\t\tclipObject = typeof clip === 'string' ?\n\t\t\t\t\tAnimationClip.findByName( root, clip ) : clip,\n\n\t\t\t\tclipUuid = clipObject !== null ? clipObject.uuid : clip,\n\n\t\t\t\tactionsForClip = this._actionsByClip[ clipUuid ],\n\t\t\t\tprototypeAction = null;\n\n\t\t\tif ( actionsForClip !== undefined ) {\n\n\t\t\t\tvar existingAction =\n\t\t\t\t\t\tactionsForClip.actionByRoot[ rootUuid ];\n\n\t\t\t\tif ( existingAction !== undefined ) {\n\n\t\t\t\t\treturn existingAction;\n\n\t\t\t\t}\n\n\t\t\t\t// we know the clip, so we don't have to parse all\n\t\t\t\t// the bindings again but can just copy\n\t\t\t\tprototypeAction = actionsForClip.knownActions[ 0 ];\n\n\t\t\t\t// also, take the clip from the prototype action\n\t\t\t\tif ( clipObject === null )\n\t\t\t\t\tclipObject = prototypeAction._clip;\n\n\t\t\t}\n\n\t\t\t// clip must be known when specified via string\n\t\t\tif ( clipObject === null ) return null;\n\n\t\t\t// allocate all resources required to run it\n\t\t\tvar newAction = new AnimationAction( this, clipObject, optionalRoot );\n\n\t\t\tthis._bindAction( newAction, prototypeAction );\n\n\t\t\t// and make the action known to the memory manager\n\t\t\tthis._addInactiveAction( newAction, clipUuid, rootUuid );\n\n\t\t\treturn newAction;\n\n\t\t},\n\n\t\t// get an existing action\n\t\texistingAction: function ( clip, optionalRoot ) {\n\n\t\t\tvar root = optionalRoot || this._root,\n\t\t\t\trootUuid = root.uuid,\n\n\t\t\t\tclipObject = typeof clip === 'string' ?\n\t\t\t\t\tAnimationClip.findByName( root, clip ) : clip,\n\n\t\t\t\tclipUuid = clipObject ? clipObject.uuid : clip,\n\n\t\t\t\tactionsForClip = this._actionsByClip[ clipUuid ];\n\n\t\t\tif ( actionsForClip !== undefined ) {\n\n\t\t\t\treturn actionsForClip.actionByRoot[ rootUuid ] || null;\n\n\t\t\t}\n\n\t\t\treturn null;\n\n\t\t},\n\n\t\t// deactivates all previously scheduled actions\n\t\tstopAllAction: function () {\n\n\t\t\tvar actions = this._actions,\n\t\t\t\tnActions = this._nActiveActions,\n\t\t\t\tbindings = this._bindings,\n\t\t\t\tnBindings = this._nActiveBindings;\n\n\t\t\tthis._nActiveActions = 0;\n\t\t\tthis._nActiveBindings = 0;\n\n\t\t\tfor ( var i = 0; i !== nActions; ++ i ) {\n\n\t\t\t\tactions[ i ].reset();\n\n\t\t\t}\n\n\t\t\tfor ( var i = 0; i !== nBindings; ++ i ) {\n\n\t\t\t\tbindings[ i ].useCount = 0;\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\t// advance the time and update apply the animation\n\t\tupdate: function ( deltaTime ) {\n\n\t\t\tdeltaTime *= this.timeScale;\n\n\t\t\tvar actions = this._actions,\n\t\t\t\tnActions = this._nActiveActions,\n\n\t\t\t\ttime = this.time += deltaTime,\n\t\t\t\ttimeDirection = Math.sign( deltaTime ),\n\n\t\t\t\taccuIndex = this._accuIndex ^= 1;\n\n\t\t\t// run active actions\n\n\t\t\tfor ( var i = 0; i !== nActions; ++ i ) {\n\n\t\t\t\tvar action = actions[ i ];\n\n\t\t\t\taction._update( time, deltaTime, timeDirection, accuIndex );\n\n\t\t\t}\n\n\t\t\t// update scene graph\n\n\t\t\tvar bindings = this._bindings,\n\t\t\t\tnBindings = this._nActiveBindings;\n\n\t\t\tfor ( var i = 0; i !== nBindings; ++ i ) {\n\n\t\t\t\tbindings[ i ].apply( accuIndex );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\t// return this mixer's root target object\n\t\tgetRoot: function () {\n\n\t\t\treturn this._root;\n\n\t\t},\n\n\t\t// free all resources specific to a particular clip\n\t\tuncacheClip: function ( clip ) {\n\n\t\t\tvar actions = this._actions,\n\t\t\t\tclipUuid = clip.uuid,\n\t\t\t\tactionsByClip = this._actionsByClip,\n\t\t\t\tactionsForClip = actionsByClip[ clipUuid ];\n\n\t\t\tif ( actionsForClip !== undefined ) {\n\n\t\t\t\t// note: just calling _removeInactiveAction would mess up the\n\t\t\t\t// iteration state and also require updating the state we can\n\t\t\t\t// just throw away\n\n\t\t\t\tvar actionsToRemove = actionsForClip.knownActions;\n\n\t\t\t\tfor ( var i = 0, n = actionsToRemove.length; i !== n; ++ i ) {\n\n\t\t\t\t\tvar action = actionsToRemove[ i ];\n\n\t\t\t\t\tthis._deactivateAction( action );\n\n\t\t\t\t\tvar cacheIndex = action._cacheIndex,\n\t\t\t\t\t\tlastInactiveAction = actions[ actions.length - 1 ];\n\n\t\t\t\t\taction._cacheIndex = null;\n\t\t\t\t\taction._byClipCacheIndex = null;\n\n\t\t\t\t\tlastInactiveAction._cacheIndex = cacheIndex;\n\t\t\t\t\tactions[ cacheIndex ] = lastInactiveAction;\n\t\t\t\t\tactions.pop();\n\n\t\t\t\t\tthis._removeInactiveBindingsForAction( action );\n\n\t\t\t\t}\n\n\t\t\t\tdelete actionsByClip[ clipUuid ];\n\n\t\t\t}\n\n\t\t},\n\n\t\t// free all resources specific to a particular root target object\n\t\tuncacheRoot: function ( root ) {\n\n\t\t\tvar rootUuid = root.uuid,\n\t\t\t\tactionsByClip = this._actionsByClip;\n\n\t\t\tfor ( var clipUuid in actionsByClip ) {\n\n\t\t\t\tvar actionByRoot = actionsByClip[ clipUuid ].actionByRoot,\n\t\t\t\t\taction = actionByRoot[ rootUuid ];\n\n\t\t\t\tif ( action !== undefined ) {\n\n\t\t\t\t\tthis._deactivateAction( action );\n\t\t\t\t\tthis._removeInactiveAction( action );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tvar bindingsByRoot = this._bindingsByRootAndName,\n\t\t\t\tbindingByName = bindingsByRoot[ rootUuid ];\n\n\t\t\tif ( bindingByName !== undefined ) {\n\n\t\t\t\tfor ( var trackName in bindingByName ) {\n\n\t\t\t\t\tvar binding = bindingByName[ trackName ];\n\t\t\t\t\tbinding.restoreOriginalState();\n\t\t\t\t\tthis._removeInactiveBinding( binding );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t},\n\n\t\t// remove a targeted clip from the cache\n\t\tuncacheAction: function ( clip, optionalRoot ) {\n\n\t\t\tvar action = this.existingAction( clip, optionalRoot );\n\n\t\t\tif ( action !== null ) {\n\n\t\t\t\tthis._deactivateAction( action );\n\t\t\t\tthis._removeInactiveAction( action );\n\n\t\t\t}\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction Uniform( value ) {\n\n\t\tif ( typeof value === 'string' ) {\n\n\t\t\tconsole.warn( 'THREE.Uniform: Type parameter is no longer needed.' );\n\t\t\tvalue = arguments[ 1 ];\n\n\t\t}\n\n\t\tthis.value = value;\n\n\t}\n\n\tUniform.prototype.clone = function () {\n\n\t\treturn new Uniform( this.value.clone === undefined ? this.value : this.value.clone() );\n\n\t};\n\n\t/**\n\t * @author benaadams / https://twitter.com/ben_a_adams\n\t */\n\n\tfunction InstancedBufferGeometry() {\n\n\t\tBufferGeometry.call( this );\n\n\t\tthis.type = 'InstancedBufferGeometry';\n\t\tthis.maxInstancedCount = undefined;\n\n\t}\n\n\tInstancedBufferGeometry.prototype = Object.assign( Object.create( BufferGeometry.prototype ), {\n\n\t\tconstructor: InstancedBufferGeometry,\n\n\t\tisInstancedBufferGeometry: true,\n\n\t\tcopy: function ( source ) {\n\n\t\t\tBufferGeometry.prototype.copy.call( this, source );\n\n\t\t\tthis.maxInstancedCount = source.maxInstancedCount;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author benaadams / https://twitter.com/ben_a_adams\n\t */\n\n\tfunction InstancedInterleavedBuffer( array, stride, meshPerAttribute ) {\n\n\t\tInterleavedBuffer.call( this, array, stride );\n\n\t\tthis.meshPerAttribute = meshPerAttribute || 1;\n\n\t}\n\n\tInstancedInterleavedBuffer.prototype = Object.assign( Object.create( InterleavedBuffer.prototype ), {\n\n\t\tconstructor: InstancedInterleavedBuffer,\n\n\t\tisInstancedInterleavedBuffer: true,\n\n\t\tcopy: function ( source ) {\n\n\t\t\tInterleavedBuffer.prototype.copy.call( this, source );\n\n\t\t\tthis.meshPerAttribute = source.meshPerAttribute;\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author benaadams / https://twitter.com/ben_a_adams\n\t */\n\n\tfunction InstancedBufferAttribute( array, itemSize, normalized, meshPerAttribute ) {\n\n\t\tif ( typeof ( normalized ) === 'number' ) {\n\n\t\t\tmeshPerAttribute = normalized;\n\n\t\t\tnormalized = false;\n\n\t\t\tconsole.error( 'THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.' );\n\n\t\t}\n\n\t\tBufferAttribute.call( this, array, itemSize, normalized );\n\n\t\tthis.meshPerAttribute = meshPerAttribute || 1;\n\n\t}\n\n\tInstancedBufferAttribute.prototype = Object.assign( Object.create( BufferAttribute.prototype ), {\n\n\t\tconstructor: InstancedBufferAttribute,\n\n\t\tisInstancedBufferAttribute: true,\n\n\t\tcopy: function ( source ) {\n\n\t\t\tBufferAttribute.prototype.copy.call( this, source );\n\n\t\t\tthis.meshPerAttribute = source.meshPerAttribute;\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author bhouston / http://clara.io/\n\t * @author stephomi / http://stephaneginier.com/\n\t */\n\n\tfunction Raycaster( origin, direction, near, far ) {\n\n\t\tthis.ray = new Ray( origin, direction );\n\t\t// direction is assumed to be normalized (for accurate distance calculations)\n\n\t\tthis.near = near || 0;\n\t\tthis.far = far || Infinity;\n\n\t\tthis.params = {\n\t\t\tMesh: {},\n\t\t\tLine: {},\n\t\t\tLOD: {},\n\t\t\tPoints: { threshold: 1 },\n\t\t\tSprite: {}\n\t\t};\n\n\t\tObject.defineProperties( this.params, {\n\t\t\tPointCloud: {\n\t\t\t\tget: function () {\n\n\t\t\t\t\tconsole.warn( 'THREE.Raycaster: params.PointCloud has been renamed to params.Points.' );\n\t\t\t\t\treturn this.Points;\n\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\n\t}\n\n\tfunction ascSort( a, b ) {\n\n\t\treturn a.distance - b.distance;\n\n\t}\n\n\tfunction intersectObject( object, raycaster, intersects, recursive ) {\n\n\t\tif ( object.visible === false ) return;\n\n\t\tobject.raycast( raycaster, intersects );\n\n\t\tif ( recursive === true ) {\n\n\t\t\tvar children = object.children;\n\n\t\t\tfor ( var i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\t\tintersectObject( children[ i ], raycaster, intersects, true );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tObject.assign( Raycaster.prototype, {\n\n\t\tlinePrecision: 1,\n\n\t\tset: function ( origin, direction ) {\n\n\t\t\t// direction is assumed to be normalized (for accurate distance calculations)\n\n\t\t\tthis.ray.set( origin, direction );\n\n\t\t},\n\n\t\tsetFromCamera: function ( coords, camera ) {\n\n\t\t\tif ( ( camera && camera.isPerspectiveCamera ) ) {\n\n\t\t\t\tthis.ray.origin.setFromMatrixPosition( camera.matrixWorld );\n\t\t\t\tthis.ray.direction.set( coords.x, coords.y, 0.5 ).unproject( camera ).sub( this.ray.origin ).normalize();\n\n\t\t\t} else if ( ( camera && camera.isOrthographicCamera ) ) {\n\n\t\t\t\tthis.ray.origin.set( coords.x, coords.y, ( camera.near + camera.far ) / ( camera.near - camera.far ) ).unproject( camera ); // set origin in plane of camera\n\t\t\t\tthis.ray.direction.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld );\n\n\t\t\t} else {\n\n\t\t\t\tconsole.error( 'THREE.Raycaster: Unsupported camera type.' );\n\n\t\t\t}\n\n\t\t},\n\n\t\tintersectObject: function ( object, recursive, optionalTarget ) {\n\n\t\t\tvar intersects = optionalTarget || [];\n\n\t\t\tintersectObject( object, this, intersects, recursive );\n\n\t\t\tintersects.sort( ascSort );\n\n\t\t\treturn intersects;\n\n\t\t},\n\n\t\tintersectObjects: function ( objects, recursive, optionalTarget ) {\n\n\t\t\tvar intersects = optionalTarget || [];\n\n\t\t\tif ( Array.isArray( objects ) === false ) {\n\n\t\t\t\tconsole.warn( 'THREE.Raycaster.intersectObjects: objects is not an Array.' );\n\t\t\t\treturn intersects;\n\n\t\t\t}\n\n\t\t\tfor ( var i = 0, l = objects.length; i < l; i ++ ) {\n\n\t\t\t\tintersectObject( objects[ i ], this, intersects, recursive );\n\n\t\t\t}\n\n\t\t\tintersects.sort( ascSort );\n\n\t\t\treturn intersects;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author bhouston / http://clara.io\n\t * @author WestLangley / http://github.com/WestLangley\n\t *\n\t * Ref: https://en.wikipedia.org/wiki/Spherical_coordinate_system\n\t *\n\t * The polar angle (phi) is measured from the positive y-axis. The positive y-axis is up.\n\t * The azimuthal angle (theta) is measured from the positive z-axiz.\n\t */\n\n\tfunction Spherical( radius, phi, theta ) {\n\n\t\tthis.radius = ( radius !== undefined ) ? radius : 1.0;\n\t\tthis.phi = ( phi !== undefined ) ? phi : 0; // polar angle\n\t\tthis.theta = ( theta !== undefined ) ? theta : 0; // azimuthal angle\n\n\t\treturn this;\n\n\t}\n\n\tObject.assign( Spherical.prototype, {\n\n\t\tset: function ( radius, phi, theta ) {\n\n\t\t\tthis.radius = radius;\n\t\t\tthis.phi = phi;\n\t\t\tthis.theta = theta;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t},\n\n\t\tcopy: function ( other ) {\n\n\t\t\tthis.radius = other.radius;\n\t\t\tthis.phi = other.phi;\n\t\t\tthis.theta = other.theta;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\t// restrict phi to be betwee EPS and PI-EPS\n\t\tmakeSafe: function () {\n\n\t\t\tvar EPS = 0.000001;\n\t\t\tthis.phi = Math.max( EPS, Math.min( Math.PI - EPS, this.phi ) );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromVector3: function ( v ) {\n\n\t\t\treturn this.setFromCartesianCoords( v.x, v.y, v.z );\n\n\t\t},\n\n\t\tsetFromCartesianCoords: function ( x, y, z ) {\n\n\t\t\tthis.radius = Math.sqrt( x * x + y * y + z * z );\n\n\t\t\tif ( this.radius === 0 ) {\n\n\t\t\t\tthis.theta = 0;\n\t\t\t\tthis.phi = 0;\n\n\t\t\t} else {\n\n\t\t\t\tthis.theta = Math.atan2( x, z );\n\t\t\t\tthis.phi = Math.acos( _Math.clamp( y / this.radius, - 1, 1 ) );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author Mugen87 / https://github.com/Mugen87\n\t *\n\t * Ref: https://en.wikipedia.org/wiki/Cylindrical_coordinate_system\n\t *\n\t */\n\n\tfunction Cylindrical( radius, theta, y ) {\n\n\t\tthis.radius = ( radius !== undefined ) ? radius : 1.0; // distance from the origin to a point in the x-z plane\n\t\tthis.theta = ( theta !== undefined ) ? theta : 0; // counterclockwise angle in the x-z plane measured in radians from the positive z-axis\n\t\tthis.y = ( y !== undefined ) ? y : 0; // height above the x-z plane\n\n\t\treturn this;\n\n\t}\n\n\tObject.assign( Cylindrical.prototype, {\n\n\t\tset: function ( radius, theta, y ) {\n\n\t\t\tthis.radius = radius;\n\t\t\tthis.theta = theta;\n\t\t\tthis.y = y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t},\n\n\t\tcopy: function ( other ) {\n\n\t\t\tthis.radius = other.radius;\n\t\t\tthis.theta = other.theta;\n\t\t\tthis.y = other.y;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromVector3: function ( v ) {\n\n\t\t\treturn this.setFromCartesianCoords( v.x, v.y, v.z );\n\n\t\t},\n\n\t\tsetFromCartesianCoords: function ( x, y, z ) {\n\n\t\t\tthis.radius = Math.sqrt( x * x + z * z );\n\t\t\tthis.theta = Math.atan2( x, z );\n\t\t\tthis.y = y;\n\n\t\t\treturn this;\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author bhouston / http://clara.io\n\t */\n\n\tfunction Box2( min, max ) {\n\n\t\tthis.min = ( min !== undefined ) ? min : new Vector2( + Infinity, + Infinity );\n\t\tthis.max = ( max !== undefined ) ? max : new Vector2( - Infinity, - Infinity );\n\n\t}\n\n\tObject.assign( Box2.prototype, {\n\n\t\tset: function ( min, max ) {\n\n\t\t\tthis.min.copy( min );\n\t\t\tthis.max.copy( max );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromPoints: function ( points ) {\n\n\t\t\tthis.makeEmpty();\n\n\t\t\tfor ( var i = 0, il = points.length; i < il; i ++ ) {\n\n\t\t\t\tthis.expandByPoint( points[ i ] );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tsetFromCenterAndSize: function () {\n\n\t\t\tvar v1 = new Vector2();\n\n\t\t\treturn function setFromCenterAndSize( center, size ) {\n\n\t\t\t\tvar halfSize = v1.copy( size ).multiplyScalar( 0.5 );\n\t\t\t\tthis.min.copy( center ).sub( halfSize );\n\t\t\t\tthis.max.copy( center ).add( halfSize );\n\n\t\t\t\treturn this;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t},\n\n\t\tcopy: function ( box ) {\n\n\t\t\tthis.min.copy( box.min );\n\t\t\tthis.max.copy( box.max );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tmakeEmpty: function () {\n\n\t\t\tthis.min.x = this.min.y = + Infinity;\n\t\t\tthis.max.x = this.max.y = - Infinity;\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tisEmpty: function () {\n\n\t\t\t// this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes\n\n\t\t\treturn ( this.max.x < this.min.x ) || ( this.max.y < this.min.y );\n\n\t\t},\n\n\t\tgetCenter: function ( target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Box2: .getCenter() target is now required' );\n\t\t\t\ttarget = new Vector2();\n\n\t\t\t}\n\n\t\t\treturn this.isEmpty() ? target.set( 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 );\n\n\t\t},\n\n\t\tgetSize: function ( target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Box2: .getSize() target is now required' );\n\t\t\t\ttarget = new Vector2();\n\n\t\t\t}\n\n\t\t\treturn this.isEmpty() ? target.set( 0, 0 ) : target.subVectors( this.max, this.min );\n\n\t\t},\n\n\t\texpandByPoint: function ( point ) {\n\n\t\t\tthis.min.min( point );\n\t\t\tthis.max.max( point );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\texpandByVector: function ( vector ) {\n\n\t\t\tthis.min.sub( vector );\n\t\t\tthis.max.add( vector );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\texpandByScalar: function ( scalar ) {\n\n\t\t\tthis.min.addScalar( - scalar );\n\t\t\tthis.max.addScalar( scalar );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tcontainsPoint: function ( point ) {\n\n\t\t\treturn point.x < this.min.x || point.x > this.max.x ||\n\t\t\t\tpoint.y < this.min.y || point.y > this.max.y ? false : true;\n\n\t\t},\n\n\t\tcontainsBox: function ( box ) {\n\n\t\t\treturn this.min.x <= box.min.x && box.max.x <= this.max.x &&\n\t\t\t\tthis.min.y <= box.min.y && box.max.y <= this.max.y;\n\n\t\t},\n\n\t\tgetParameter: function ( point, target ) {\n\n\t\t\t// This can potentially have a divide by zero if the box\n\t\t\t// has a size dimension of 0.\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Box2: .getParameter() target is now required' );\n\t\t\t\ttarget = new Vector2();\n\n\t\t\t}\n\n\t\t\treturn target.set(\n\t\t\t\t( point.x - this.min.x ) / ( this.max.x - this.min.x ),\n\t\t\t\t( point.y - this.min.y ) / ( this.max.y - this.min.y )\n\t\t\t);\n\n\t\t},\n\n\t\tintersectsBox: function ( box ) {\n\n\t\t\t// using 4 splitting planes to rule out intersections\n\n\t\t\treturn box.max.x < this.min.x || box.min.x > this.max.x ||\n\t\t\t\tbox.max.y < this.min.y || box.min.y > this.max.y ? false : true;\n\n\t\t},\n\n\t\tclampPoint: function ( point, target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Box2: .clampPoint() target is now required' );\n\t\t\t\ttarget = new Vector2();\n\n\t\t\t}\n\n\t\t\treturn target.copy( point ).clamp( this.min, this.max );\n\n\t\t},\n\n\t\tdistanceToPoint: function () {\n\n\t\t\tvar v1 = new Vector2();\n\n\t\t\treturn function distanceToPoint( point ) {\n\n\t\t\t\tvar clampedPoint = v1.copy( point ).clamp( this.min, this.max );\n\t\t\t\treturn clampedPoint.sub( point ).length();\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tintersect: function ( box ) {\n\n\t\t\tthis.min.max( box.min );\n\t\t\tthis.max.min( box.max );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tunion: function ( box ) {\n\n\t\t\tthis.min.min( box.min );\n\t\t\tthis.max.max( box.max );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\ttranslate: function ( offset ) {\n\n\t\t\tthis.min.add( offset );\n\t\t\tthis.max.add( offset );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tequals: function ( box ) {\n\n\t\t\treturn box.min.equals( this.min ) && box.max.equals( this.max );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author bhouston / http://clara.io\n\t */\n\n\tfunction Line3( start, end ) {\n\n\t\tthis.start = ( start !== undefined ) ? start : new Vector3();\n\t\tthis.end = ( end !== undefined ) ? end : new Vector3();\n\n\t}\n\n\tObject.assign( Line3.prototype, {\n\n\t\tset: function ( start, end ) {\n\n\t\t\tthis.start.copy( start );\n\t\t\tthis.end.copy( end );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tclone: function () {\n\n\t\t\treturn new this.constructor().copy( this );\n\n\t\t},\n\n\t\tcopy: function ( line ) {\n\n\t\t\tthis.start.copy( line.start );\n\t\t\tthis.end.copy( line.end );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tgetCenter: function ( target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Line3: .getCenter() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\treturn target.addVectors( this.start, this.end ).multiplyScalar( 0.5 );\n\n\t\t},\n\n\t\tdelta: function ( target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Line3: .delta() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\treturn target.subVectors( this.end, this.start );\n\n\t\t},\n\n\t\tdistanceSq: function () {\n\n\t\t\treturn this.start.distanceToSquared( this.end );\n\n\t\t},\n\n\t\tdistance: function () {\n\n\t\t\treturn this.start.distanceTo( this.end );\n\n\t\t},\n\n\t\tat: function ( t, target ) {\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Line3: .at() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\treturn this.delta( target ).multiplyScalar( t ).add( this.start );\n\n\t\t},\n\n\t\tclosestPointToPointParameter: function () {\n\n\t\t\tvar startP = new Vector3();\n\t\t\tvar startEnd = new Vector3();\n\n\t\t\treturn function closestPointToPointParameter( point, clampToLine ) {\n\n\t\t\t\tstartP.subVectors( point, this.start );\n\t\t\t\tstartEnd.subVectors( this.end, this.start );\n\n\t\t\t\tvar startEnd2 = startEnd.dot( startEnd );\n\t\t\t\tvar startEnd_startP = startEnd.dot( startP );\n\n\t\t\t\tvar t = startEnd_startP / startEnd2;\n\n\t\t\t\tif ( clampToLine ) {\n\n\t\t\t\t\tt = _Math.clamp( t, 0, 1 );\n\n\t\t\t\t}\n\n\t\t\t\treturn t;\n\n\t\t\t};\n\n\t\t}(),\n\n\t\tclosestPointToPoint: function ( point, clampToLine, target ) {\n\n\t\t\tvar t = this.closestPointToPointParameter( point, clampToLine );\n\n\t\t\tif ( target === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.Line3: .closestPointToPoint() target is now required' );\n\t\t\t\ttarget = new Vector3();\n\n\t\t\t}\n\n\t\t\treturn this.delta( target ).multiplyScalar( t ).add( this.start );\n\n\t\t},\n\n\t\tapplyMatrix4: function ( matrix ) {\n\n\t\t\tthis.start.applyMatrix4( matrix );\n\t\t\tthis.end.applyMatrix4( matrix );\n\n\t\t\treturn this;\n\n\t\t},\n\n\t\tequals: function ( line ) {\n\n\t\t\treturn line.start.equals( this.start ) && line.end.equals( this.end );\n\n\t\t}\n\n\t} );\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t */\n\n\tfunction ImmediateRenderObject( material ) {\n\n\t\tObject3D.call( this );\n\n\t\tthis.material = material;\n\t\tthis.render = function ( /* renderCallback */ ) {};\n\n\t}\n\n\tImmediateRenderObject.prototype = Object.create( Object3D.prototype );\n\tImmediateRenderObject.prototype.constructor = ImmediateRenderObject;\n\n\tImmediateRenderObject.prototype.isImmediateRenderObject = true;\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author WestLangley / http://github.com/WestLangley\n\t */\n\n\tfunction VertexNormalsHelper( object, size, hex, linewidth ) {\n\n\t\tthis.object = object;\n\n\t\tthis.size = ( size !== undefined ) ? size : 1;\n\n\t\tvar color = ( hex !== undefined ) ? hex : 0xff0000;\n\n\t\tvar width = ( linewidth !== undefined ) ? linewidth : 1;\n\n\t\t//\n\n\t\tvar nNormals = 0;\n\n\t\tvar objGeometry = this.object.geometry;\n\n\t\tif ( objGeometry && objGeometry.isGeometry ) {\n\n\t\t\tnNormals = objGeometry.faces.length * 3;\n\n\t\t} else if ( objGeometry && objGeometry.isBufferGeometry ) {\n\n\t\t\tnNormals = objGeometry.attributes.normal.count;\n\n\t\t}\n\n\t\t//\n\n\t\tvar geometry = new BufferGeometry();\n\n\t\tvar positions = new Float32BufferAttribute( nNormals * 2 * 3, 3 );\n\n\t\tgeometry.addAttribute( 'position', positions );\n\n\t\tLineSegments.call( this, geometry, new LineBasicMaterial( { color: color, linewidth: width } ) );\n\n\t\t//\n\n\t\tthis.matrixAutoUpdate = false;\n\n\t\tthis.update();\n\n\t}\n\n\tVertexNormalsHelper.prototype = Object.create( LineSegments.prototype );\n\tVertexNormalsHelper.prototype.constructor = VertexNormalsHelper;\n\n\tVertexNormalsHelper.prototype.update = ( function () {\n\n\t\tvar v1 = new Vector3();\n\t\tvar v2 = new Vector3();\n\t\tvar normalMatrix = new Matrix3();\n\n\t\treturn function update() {\n\n\t\t\tvar keys = [ 'a', 'b', 'c' ];\n\n\t\t\tthis.object.updateMatrixWorld( true );\n\n\t\t\tnormalMatrix.getNormalMatrix( this.object.matrixWorld );\n\n\t\t\tvar matrixWorld = this.object.matrixWorld;\n\n\t\t\tvar position = this.geometry.attributes.position;\n\n\t\t\t//\n\n\t\t\tvar objGeometry = this.object.geometry;\n\n\t\t\tif ( objGeometry && objGeometry.isGeometry ) {\n\n\t\t\t\tvar vertices = objGeometry.vertices;\n\n\t\t\t\tvar faces = objGeometry.faces;\n\n\t\t\t\tvar idx = 0;\n\n\t\t\t\tfor ( var i = 0, l = faces.length; i < l; i ++ ) {\n\n\t\t\t\t\tvar face = faces[ i ];\n\n\t\t\t\t\tfor ( var j = 0, jl = face.vertexNormals.length; j < jl; j ++ ) {\n\n\t\t\t\t\t\tvar vertex = vertices[ face[ keys[ j ] ] ];\n\n\t\t\t\t\t\tvar normal = face.vertexNormals[ j ];\n\n\t\t\t\t\t\tv1.copy( vertex ).applyMatrix4( matrixWorld );\n\n\t\t\t\t\t\tv2.copy( normal ).applyMatrix3( normalMatrix ).normalize().multiplyScalar( this.size ).add( v1 );\n\n\t\t\t\t\t\tposition.setXYZ( idx, v1.x, v1.y, v1.z );\n\n\t\t\t\t\t\tidx = idx + 1;\n\n\t\t\t\t\t\tposition.setXYZ( idx, v2.x, v2.y, v2.z );\n\n\t\t\t\t\t\tidx = idx + 1;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} else if ( objGeometry && objGeometry.isBufferGeometry ) {\n\n\t\t\t\tvar objPos = objGeometry.attributes.position;\n\n\t\t\t\tvar objNorm = objGeometry.attributes.normal;\n\n\t\t\t\tvar idx = 0;\n\n\t\t\t\t// for simplicity, ignore index and drawcalls, and render every normal\n\n\t\t\t\tfor ( var j = 0, jl = objPos.count; j < jl; j ++ ) {\n\n\t\t\t\t\tv1.set( objPos.getX( j ), objPos.getY( j ), objPos.getZ( j ) ).applyMatrix4( matrixWorld );\n\n\t\t\t\t\tv2.set( objNorm.getX( j ), objNorm.getY( j ), objNorm.getZ( j ) );\n\n\t\t\t\t\tv2.applyMatrix3( normalMatrix ).normalize().multiplyScalar( this.size ).add( v1 );\n\n\t\t\t\t\tposition.setXYZ( idx, v1.x, v1.y, v1.z );\n\n\t\t\t\t\tidx = idx + 1;\n\n\t\t\t\t\tposition.setXYZ( idx, v2.x, v2.y, v2.z );\n\n\t\t\t\t\tidx = idx + 1;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tposition.needsUpdate = true;\n\n\t\t};\n\n\t}() );\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author WestLangley / http://github.com/WestLangley\n\t */\n\n\tfunction SpotLightHelper( light, color ) {\n\n\t\tObject3D.call( this );\n\n\t\tthis.light = light;\n\t\tthis.light.updateMatrixWorld();\n\n\t\tthis.matrix = light.matrixWorld;\n\t\tthis.matrixAutoUpdate = false;\n\n\t\tthis.color = color;\n\n\t\tvar geometry = new BufferGeometry();\n\n\t\tvar positions = [\n\t\t\t0, 0, 0, \t0, 0, 1,\n\t\t\t0, 0, 0, \t1, 0, 1,\n\t\t\t0, 0, 0,\t- 1, 0, 1,\n\t\t\t0, 0, 0, \t0, 1, 1,\n\t\t\t0, 0, 0, \t0, - 1, 1\n\t\t];\n\n\t\tfor ( var i = 0, j = 1, l = 32; i < l; i ++, j ++ ) {\n\n\t\t\tvar p1 = ( i / l ) * Math.PI * 2;\n\t\t\tvar p2 = ( j / l ) * Math.PI * 2;\n\n\t\t\tpositions.push(\n\t\t\t\tMath.cos( p1 ), Math.sin( p1 ), 1,\n\t\t\t\tMath.cos( p2 ), Math.sin( p2 ), 1\n\t\t\t);\n\n\t\t}\n\n\t\tgeometry.addAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );\n\n\t\tvar material = new LineBasicMaterial( { fog: false } );\n\n\t\tthis.cone = new LineSegments( geometry, material );\n\t\tthis.add( this.cone );\n\n\t\tthis.update();\n\n\t}\n\n\tSpotLightHelper.prototype = Object.create( Object3D.prototype );\n\tSpotLightHelper.prototype.constructor = SpotLightHelper;\n\n\tSpotLightHelper.prototype.dispose = function () {\n\n\t\tthis.cone.geometry.dispose();\n\t\tthis.cone.material.dispose();\n\n\t};\n\n\tSpotLightHelper.prototype.update = function () {\n\n\t\tvar vector = new Vector3();\n\n\t\treturn function update() {\n\n\t\t\tthis.light.updateMatrixWorld();\n\n\t\t\tvar coneLength = this.light.distance ? this.light.distance : 1000;\n\t\t\tvar coneWidth = coneLength * Math.tan( this.light.angle );\n\n\t\t\tthis.cone.scale.set( coneWidth, coneWidth, coneLength );\n\n\t\t\tvector.setFromMatrixPosition( this.light.target.matrixWorld );\n\n\t\t\tthis.cone.lookAt( vector );\n\n\t\t\tif ( this.color !== undefined ) {\n\n\t\t\t\tthis.cone.material.color.set( this.color );\n\n\t\t\t} else {\n\n\t\t\t\tthis.cone.material.color.copy( this.light.color );\n\n\t\t\t}\n\n\t\t};\n\n\t}();\n\n\t/**\n\t * @author Sean Griffin / http://twitter.com/sgrif\n\t * @author Michael Guerrero / http://realitymeltdown.com\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author ikerr / http://verold.com\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\tfunction getBoneList( object ) {\n\n\t\tvar boneList = [];\n\n\t\tif ( object && object.isBone ) {\n\n\t\t\tboneList.push( object );\n\n\t\t}\n\n\t\tfor ( var i = 0; i < object.children.length; i ++ ) {\n\n\t\t\tboneList.push.apply( boneList, getBoneList( object.children[ i ] ) );\n\n\t\t}\n\n\t\treturn boneList;\n\n\t}\n\n\tfunction SkeletonHelper( object ) {\n\n\t\tvar bones = getBoneList( object );\n\n\t\tvar geometry = new BufferGeometry();\n\n\t\tvar vertices = [];\n\t\tvar colors = [];\n\n\t\tvar color1 = new Color( 0, 0, 1 );\n\t\tvar color2 = new Color( 0, 1, 0 );\n\n\t\tfor ( var i = 0; i < bones.length; i ++ ) {\n\n\t\t\tvar bone = bones[ i ];\n\n\t\t\tif ( bone.parent && bone.parent.isBone ) {\n\n\t\t\t\tvertices.push( 0, 0, 0 );\n\t\t\t\tvertices.push( 0, 0, 0 );\n\t\t\t\tcolors.push( color1.r, color1.g, color1.b );\n\t\t\t\tcolors.push( color2.r, color2.g, color2.b );\n\n\t\t\t}\n\n\t\t}\n\n\t\tgeometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tgeometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );\n\n\t\tvar material = new LineBasicMaterial( { vertexColors: VertexColors, depthTest: false, depthWrite: false, transparent: true } );\n\n\t\tLineSegments.call( this, geometry, material );\n\n\t\tthis.root = object;\n\t\tthis.bones = bones;\n\n\t\tthis.matrix = object.matrixWorld;\n\t\tthis.matrixAutoUpdate = false;\n\n\t}\n\n\tSkeletonHelper.prototype = Object.create( LineSegments.prototype );\n\tSkeletonHelper.prototype.constructor = SkeletonHelper;\n\n\tSkeletonHelper.prototype.updateMatrixWorld = function () {\n\n\t\tvar vector = new Vector3();\n\n\t\tvar boneMatrix = new Matrix4();\n\t\tvar matrixWorldInv = new Matrix4();\n\n\t\treturn function updateMatrixWorld( force ) {\n\n\t\t\tvar bones = this.bones;\n\n\t\t\tvar geometry = this.geometry;\n\t\t\tvar position = geometry.getAttribute( 'position' );\n\n\t\t\tmatrixWorldInv.getInverse( this.root.matrixWorld );\n\n\t\t\tfor ( var i = 0, j = 0; i < bones.length; i ++ ) {\n\n\t\t\t\tvar bone = bones[ i ];\n\n\t\t\t\tif ( bone.parent && bone.parent.isBone ) {\n\n\t\t\t\t\tboneMatrix.multiplyMatrices( matrixWorldInv, bone.matrixWorld );\n\t\t\t\t\tvector.setFromMatrixPosition( boneMatrix );\n\t\t\t\t\tposition.setXYZ( j, vector.x, vector.y, vector.z );\n\n\t\t\t\t\tboneMatrix.multiplyMatrices( matrixWorldInv, bone.parent.matrixWorld );\n\t\t\t\t\tvector.setFromMatrixPosition( boneMatrix );\n\t\t\t\t\tposition.setXYZ( j + 1, vector.x, vector.y, vector.z );\n\n\t\t\t\t\tj += 2;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tgeometry.getAttribute( 'position' ).needsUpdate = true;\n\n\t\t\tObject3D.prototype.updateMatrixWorld.call( this, force );\n\n\t\t};\n\n\t}();\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction PointLightHelper( light, sphereSize, color ) {\n\n\t\tthis.light = light;\n\t\tthis.light.updateMatrixWorld();\n\n\t\tthis.color = color;\n\n\t\tvar geometry = new SphereBufferGeometry( sphereSize, 4, 2 );\n\t\tvar material = new MeshBasicMaterial( { wireframe: true, fog: false } );\n\n\t\tMesh.call( this, geometry, material );\n\n\t\tthis.matrix = this.light.matrixWorld;\n\t\tthis.matrixAutoUpdate = false;\n\n\t\tthis.update();\n\n\n\t\t/*\n\t\tvar distanceGeometry = new THREE.IcosahedronBufferGeometry( 1, 2 );\n\t\tvar distanceMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false, wireframe: true, opacity: 0.1, transparent: true } );\n\n\t\tthis.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial );\n\t\tthis.lightDistance = new THREE.Mesh( distanceGeometry, distanceMaterial );\n\n\t\tvar d = light.distance;\n\n\t\tif ( d === 0.0 ) {\n\n\t\t\tthis.lightDistance.visible = false;\n\n\t\t} else {\n\n\t\t\tthis.lightDistance.scale.set( d, d, d );\n\n\t\t}\n\n\t\tthis.add( this.lightDistance );\n\t\t*/\n\n\t}\n\n\tPointLightHelper.prototype = Object.create( Mesh.prototype );\n\tPointLightHelper.prototype.constructor = PointLightHelper;\n\n\tPointLightHelper.prototype.dispose = function () {\n\n\t\tthis.geometry.dispose();\n\t\tthis.material.dispose();\n\n\t};\n\n\tPointLightHelper.prototype.update = function () {\n\n\t\tif ( this.color !== undefined ) {\n\n\t\t\tthis.material.color.set( this.color );\n\n\t\t} else {\n\n\t\t\tthis.material.color.copy( this.light.color );\n\n\t\t}\n\n\t\t/*\n\t\tvar d = this.light.distance;\n\n\t\tif ( d === 0.0 ) {\n\n\t\t\tthis.lightDistance.visible = false;\n\n\t\t} else {\n\n\t\t\tthis.lightDistance.visible = true;\n\t\t\tthis.lightDistance.scale.set( d, d, d );\n\n\t\t}\n\t\t*/\n\n\t};\n\n\t/**\n\t * @author abelnation / http://github.com/abelnation\n\t * @author Mugen87 / http://github.com/Mugen87\n\t * @author WestLangley / http://github.com/WestLangley\n\t *\n\t *  This helper must be added as a child of the light\n\t */\n\n\tfunction RectAreaLightHelper( light, color ) {\n\n\t\tthis.type = 'RectAreaLightHelper';\n\n\t\tthis.light = light;\n\n\t\tthis.color = color; // optional hardwired color for the helper\n\n\t\tvar positions = [ 1, 1, 0, - 1, 1, 0, - 1, - 1, 0, 1, - 1, 0, 1, 1, 0 ];\n\n\t\tvar geometry = new BufferGeometry();\n\t\tgeometry.addAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );\n\t\tgeometry.computeBoundingSphere();\n\n\t\tvar material = new LineBasicMaterial( { fog: false } );\n\n\t\tLine.call( this, geometry, material );\n\n\t\t//\n\n\t\tvar positions2 = [ 1, 1, 0, - 1, 1, 0, - 1, - 1, 0, 1, 1, 0, - 1, - 1, 0, 1, - 1, 0 ];\n\n\t\tvar geometry2 = new BufferGeometry();\n\t\tgeometry2.addAttribute( 'position', new Float32BufferAttribute( positions2, 3 ) );\n\t\tgeometry2.computeBoundingSphere();\n\n\t\tthis.add( new Mesh( geometry2, new MeshBasicMaterial( { side: THREE.BackSide, fog: false } ) ) );\n\n\t\tthis.update();\n\n\t}\n\n\tRectAreaLightHelper.prototype = Object.create( Line.prototype );\n\tRectAreaLightHelper.prototype.constructor = RectAreaLightHelper;\n\n\tRectAreaLightHelper.prototype.update = function () {\n\n\t\tthis.scale.set( 0.5 * this.light.width, 0.5 * this.light.height, 1 );\n\n\t\tif ( this.color !== undefined ) {\n\n\t\t\tthis.material.color.set( this.color );\n\t\t\tthis.children[ 0 ].material.color.set( this.color );\n\n\t\t} else {\n\n\t\t\tthis.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity );\n\n\t\t\t// prevent hue shift\n\t\t\tvar c = this.material.color;\n\t\t\tvar max = Math.max( c.r, c.g, c.b );\n\t\t\tif ( max > 1 ) c.multiplyScalar( 1 / max );\n\n\t\t\tthis.children[ 0 ].material.color.copy( this.material.color );\n\n\t\t}\n\n\t};\n\n\tRectAreaLightHelper.prototype.dispose = function () {\n\n\t\tthis.geometry.dispose();\n\t\tthis.material.dispose();\n\t\tthis.children[ 0 ].geometry.dispose();\n\t\tthis.children[ 0 ].material.dispose();\n\n\t};\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author Mugen87 / https://github.com/Mugen87\n\t */\n\n\tfunction HemisphereLightHelper( light, size, color ) {\n\n\t\tObject3D.call( this );\n\n\t\tthis.light = light;\n\t\tthis.light.updateMatrixWorld();\n\n\t\tthis.matrix = light.matrixWorld;\n\t\tthis.matrixAutoUpdate = false;\n\n\t\tthis.color = color;\n\n\t\tvar geometry = new OctahedronBufferGeometry( size );\n\t\tgeometry.rotateY( Math.PI * 0.5 );\n\n\t\tthis.material = new MeshBasicMaterial( { wireframe: true, fog: false } );\n\t\tif ( this.color === undefined ) this.material.vertexColors = VertexColors;\n\n\t\tvar position = geometry.getAttribute( 'position' );\n\t\tvar colors = new Float32Array( position.count * 3 );\n\n\t\tgeometry.addAttribute( 'color', new BufferAttribute( colors, 3 ) );\n\n\t\tthis.add( new Mesh( geometry, this.material ) );\n\n\t\tthis.update();\n\n\t}\n\n\tHemisphereLightHelper.prototype = Object.create( Object3D.prototype );\n\tHemisphereLightHelper.prototype.constructor = HemisphereLightHelper;\n\n\tHemisphereLightHelper.prototype.dispose = function () {\n\n\t\tthis.children[ 0 ].geometry.dispose();\n\t\tthis.children[ 0 ].material.dispose();\n\n\t};\n\n\tHemisphereLightHelper.prototype.update = function () {\n\n\t\tvar vector = new Vector3();\n\n\t\tvar color1 = new Color();\n\t\tvar color2 = new Color();\n\n\t\treturn function update() {\n\n\t\t\tvar mesh = this.children[ 0 ];\n\n\t\t\tif ( this.color !== undefined ) {\n\n\t\t\t\tthis.material.color.set( this.color );\n\n\t\t\t} else {\n\n\t\t\t\tvar colors = mesh.geometry.getAttribute( 'color' );\n\n\t\t\t\tcolor1.copy( this.light.color );\n\t\t\t\tcolor2.copy( this.light.groundColor );\n\n\t\t\t\tfor ( var i = 0, l = colors.count; i < l; i ++ ) {\n\n\t\t\t\t\tvar color = ( i < ( l / 2 ) ) ? color1 : color2;\n\n\t\t\t\t\tcolors.setXYZ( i, color.r, color.g, color.b );\n\n\t\t\t\t}\n\n\t\t\t\tcolors.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tmesh.lookAt( vector.setFromMatrixPosition( this.light.matrixWorld ).negate() );\n\n\t\t};\n\n\t}();\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction GridHelper( size, divisions, color1, color2 ) {\n\n\t\tsize = size || 10;\n\t\tdivisions = divisions || 10;\n\t\tcolor1 = new Color( color1 !== undefined ? color1 : 0x444444 );\n\t\tcolor2 = new Color( color2 !== undefined ? color2 : 0x888888 );\n\n\t\tvar center = divisions / 2;\n\t\tvar step = size / divisions;\n\t\tvar halfSize = size / 2;\n\n\t\tvar vertices = [], colors = [];\n\n\t\tfor ( var i = 0, j = 0, k = - halfSize; i <= divisions; i ++, k += step ) {\n\n\t\t\tvertices.push( - halfSize, 0, k, halfSize, 0, k );\n\t\t\tvertices.push( k, 0, - halfSize, k, 0, halfSize );\n\n\t\t\tvar color = i === center ? color1 : color2;\n\n\t\t\tcolor.toArray( colors, j ); j += 3;\n\t\t\tcolor.toArray( colors, j ); j += 3;\n\t\t\tcolor.toArray( colors, j ); j += 3;\n\t\t\tcolor.toArray( colors, j ); j += 3;\n\n\t\t}\n\n\t\tvar geometry = new BufferGeometry();\n\t\tgeometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tgeometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );\n\n\t\tvar material = new LineBasicMaterial( { vertexColors: VertexColors } );\n\n\t\tLineSegments.call( this, geometry, material );\n\n\t}\n\n\tGridHelper.prototype = Object.create( LineSegments.prototype );\n\tGridHelper.prototype.constructor = GridHelper;\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author Mugen87 / http://github.com/Mugen87\n\t * @author Hectate / http://www.github.com/Hectate\n\t */\n\n\tfunction PolarGridHelper( radius, radials, circles, divisions, color1, color2 ) {\n\n\t\tradius = radius || 10;\n\t\tradials = radials || 16;\n\t\tcircles = circles || 8;\n\t\tdivisions = divisions || 64;\n\t\tcolor1 = new Color( color1 !== undefined ? color1 : 0x444444 );\n\t\tcolor2 = new Color( color2 !== undefined ? color2 : 0x888888 );\n\n\t\tvar vertices = [];\n\t\tvar colors = [];\n\n\t\tvar x, z;\n\t\tvar v, i, j, r, color;\n\n\t\t// create the radials\n\n\t\tfor ( i = 0; i <= radials; i ++ ) {\n\n\t\t\tv = ( i / radials ) * ( Math.PI * 2 );\n\n\t\t\tx = Math.sin( v ) * radius;\n\t\t\tz = Math.cos( v ) * radius;\n\n\t\t\tvertices.push( 0, 0, 0 );\n\t\t\tvertices.push( x, 0, z );\n\n\t\t\tcolor = ( i & 1 ) ? color1 : color2;\n\n\t\t\tcolors.push( color.r, color.g, color.b );\n\t\t\tcolors.push( color.r, color.g, color.b );\n\n\t\t}\n\n\t\t// create the circles\n\n\t\tfor ( i = 0; i <= circles; i ++ ) {\n\n\t\t\tcolor = ( i & 1 ) ? color1 : color2;\n\n\t\t\tr = radius - ( radius / circles * i );\n\n\t\t\tfor ( j = 0; j < divisions; j ++ ) {\n\n\t\t\t\t// first vertex\n\n\t\t\t\tv = ( j / divisions ) * ( Math.PI * 2 );\n\n\t\t\t\tx = Math.sin( v ) * r;\n\t\t\t\tz = Math.cos( v ) * r;\n\n\t\t\t\tvertices.push( x, 0, z );\n\t\t\t\tcolors.push( color.r, color.g, color.b );\n\n\t\t\t\t// second vertex\n\n\t\t\t\tv = ( ( j + 1 ) / divisions ) * ( Math.PI * 2 );\n\n\t\t\t\tx = Math.sin( v ) * r;\n\t\t\t\tz = Math.cos( v ) * r;\n\n\t\t\t\tvertices.push( x, 0, z );\n\t\t\t\tcolors.push( color.r, color.g, color.b );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvar geometry = new BufferGeometry();\n\t\tgeometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tgeometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );\n\n\t\tvar material = new LineBasicMaterial( { vertexColors: VertexColors } );\n\n\t\tLineSegments.call( this, geometry, material );\n\n\t}\n\n\tPolarGridHelper.prototype = Object.create( LineSegments.prototype );\n\tPolarGridHelper.prototype.constructor = PolarGridHelper;\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author WestLangley / http://github.com/WestLangley\n\t */\n\n\tfunction FaceNormalsHelper( object, size, hex, linewidth ) {\n\n\t\t// FaceNormalsHelper only supports THREE.Geometry\n\n\t\tthis.object = object;\n\n\t\tthis.size = ( size !== undefined ) ? size : 1;\n\n\t\tvar color = ( hex !== undefined ) ? hex : 0xffff00;\n\n\t\tvar width = ( linewidth !== undefined ) ? linewidth : 1;\n\n\t\t//\n\n\t\tvar nNormals = 0;\n\n\t\tvar objGeometry = this.object.geometry;\n\n\t\tif ( objGeometry && objGeometry.isGeometry ) {\n\n\t\t\tnNormals = objGeometry.faces.length;\n\n\t\t} else {\n\n\t\t\tconsole.warn( 'THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead.' );\n\n\t\t}\n\n\t\t//\n\n\t\tvar geometry = new BufferGeometry();\n\n\t\tvar positions = new Float32BufferAttribute( nNormals * 2 * 3, 3 );\n\n\t\tgeometry.addAttribute( 'position', positions );\n\n\t\tLineSegments.call( this, geometry, new LineBasicMaterial( { color: color, linewidth: width } ) );\n\n\t\t//\n\n\t\tthis.matrixAutoUpdate = false;\n\t\tthis.update();\n\n\t}\n\n\tFaceNormalsHelper.prototype = Object.create( LineSegments.prototype );\n\tFaceNormalsHelper.prototype.constructor = FaceNormalsHelper;\n\n\tFaceNormalsHelper.prototype.update = ( function () {\n\n\t\tvar v1 = new Vector3();\n\t\tvar v2 = new Vector3();\n\t\tvar normalMatrix = new Matrix3();\n\n\t\treturn function update() {\n\n\t\t\tthis.object.updateMatrixWorld( true );\n\n\t\t\tnormalMatrix.getNormalMatrix( this.object.matrixWorld );\n\n\t\t\tvar matrixWorld = this.object.matrixWorld;\n\n\t\t\tvar position = this.geometry.attributes.position;\n\n\t\t\t//\n\n\t\t\tvar objGeometry = this.object.geometry;\n\n\t\t\tvar vertices = objGeometry.vertices;\n\n\t\t\tvar faces = objGeometry.faces;\n\n\t\t\tvar idx = 0;\n\n\t\t\tfor ( var i = 0, l = faces.length; i < l; i ++ ) {\n\n\t\t\t\tvar face = faces[ i ];\n\n\t\t\t\tvar normal = face.normal;\n\n\t\t\t\tv1.copy( vertices[ face.a ] )\n\t\t\t\t\t.add( vertices[ face.b ] )\n\t\t\t\t\t.add( vertices[ face.c ] )\n\t\t\t\t\t.divideScalar( 3 )\n\t\t\t\t\t.applyMatrix4( matrixWorld );\n\n\t\t\t\tv2.copy( normal ).applyMatrix3( normalMatrix ).normalize().multiplyScalar( this.size ).add( v1 );\n\n\t\t\t\tposition.setXYZ( idx, v1.x, v1.y, v1.z );\n\n\t\t\t\tidx = idx + 1;\n\n\t\t\t\tposition.setXYZ( idx, v2.x, v2.y, v2.z );\n\n\t\t\t\tidx = idx + 1;\n\n\t\t\t}\n\n\t\t\tposition.needsUpdate = true;\n\n\t\t};\n\n\t}() );\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author WestLangley / http://github.com/WestLangley\n\t */\n\n\tfunction DirectionalLightHelper( light, size, color ) {\n\n\t\tObject3D.call( this );\n\n\t\tthis.light = light;\n\t\tthis.light.updateMatrixWorld();\n\n\t\tthis.matrix = light.matrixWorld;\n\t\tthis.matrixAutoUpdate = false;\n\n\t\tthis.color = color;\n\n\t\tif ( size === undefined ) size = 1;\n\n\t\tvar geometry = new BufferGeometry();\n\t\tgeometry.addAttribute( 'position', new Float32BufferAttribute( [\n\t\t\t- size, size, 0,\n\t\t\tsize, size, 0,\n\t\t\tsize, - size, 0,\n\t\t\t- size, - size, 0,\n\t\t\t- size, size, 0\n\t\t], 3 ) );\n\n\t\tvar material = new LineBasicMaterial( { fog: false } );\n\n\t\tthis.lightPlane = new Line( geometry, material );\n\t\tthis.add( this.lightPlane );\n\n\t\tgeometry = new BufferGeometry();\n\t\tgeometry.addAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 0, 0, 1 ], 3 ) );\n\n\t\tthis.targetLine = new Line( geometry, material );\n\t\tthis.add( this.targetLine );\n\n\t\tthis.update();\n\n\t}\n\n\tDirectionalLightHelper.prototype = Object.create( Object3D.prototype );\n\tDirectionalLightHelper.prototype.constructor = DirectionalLightHelper;\n\n\tDirectionalLightHelper.prototype.dispose = function () {\n\n\t\tthis.lightPlane.geometry.dispose();\n\t\tthis.lightPlane.material.dispose();\n\t\tthis.targetLine.geometry.dispose();\n\t\tthis.targetLine.material.dispose();\n\n\t};\n\n\tDirectionalLightHelper.prototype.update = function () {\n\n\t\tvar v1 = new Vector3();\n\t\tvar v2 = new Vector3();\n\t\tvar v3 = new Vector3();\n\n\t\treturn function update() {\n\n\t\t\tv1.setFromMatrixPosition( this.light.matrixWorld );\n\t\t\tv2.setFromMatrixPosition( this.light.target.matrixWorld );\n\t\t\tv3.subVectors( v2, v1 );\n\n\t\t\tthis.lightPlane.lookAt( v2 );\n\n\t\t\tif ( this.color !== undefined ) {\n\n\t\t\t\tthis.lightPlane.material.color.set( this.color );\n\t\t\t\tthis.targetLine.material.color.set( this.color );\n\n\t\t\t} else {\n\n\t\t\t\tthis.lightPlane.material.color.copy( this.light.color );\n\t\t\t\tthis.targetLine.material.color.copy( this.light.color );\n\n\t\t\t}\n\n\t\t\tthis.targetLine.lookAt( v2 );\n\t\t\tthis.targetLine.scale.z = v3.length();\n\n\t\t};\n\n\t}();\n\n\t/**\n\t * @author alteredq / http://alteredqualia.com/\n\t * @author Mugen87 / https://github.com/Mugen87\n\t *\n\t *\t- shows frustum, line of sight and up of the camera\n\t *\t- suitable for fast updates\n\t * \t- based on frustum visualization in lightgl.js shadowmap example\n\t *\t\thttp://evanw.github.com/lightgl.js/tests/shadowmap.html\n\t */\n\n\tfunction CameraHelper( camera ) {\n\n\t\tvar geometry = new BufferGeometry();\n\t\tvar material = new LineBasicMaterial( { color: 0xffffff, vertexColors: FaceColors } );\n\n\t\tvar vertices = [];\n\t\tvar colors = [];\n\n\t\tvar pointMap = {};\n\n\t\t// colors\n\n\t\tvar colorFrustum = new Color( 0xffaa00 );\n\t\tvar colorCone = new Color( 0xff0000 );\n\t\tvar colorUp = new Color( 0x00aaff );\n\t\tvar colorTarget = new Color( 0xffffff );\n\t\tvar colorCross = new Color( 0x333333 );\n\n\t\t// near\n\n\t\taddLine( 'n1', 'n2', colorFrustum );\n\t\taddLine( 'n2', 'n4', colorFrustum );\n\t\taddLine( 'n4', 'n3', colorFrustum );\n\t\taddLine( 'n3', 'n1', colorFrustum );\n\n\t\t// far\n\n\t\taddLine( 'f1', 'f2', colorFrustum );\n\t\taddLine( 'f2', 'f4', colorFrustum );\n\t\taddLine( 'f4', 'f3', colorFrustum );\n\t\taddLine( 'f3', 'f1', colorFrustum );\n\n\t\t// sides\n\n\t\taddLine( 'n1', 'f1', colorFrustum );\n\t\taddLine( 'n2', 'f2', colorFrustum );\n\t\taddLine( 'n3', 'f3', colorFrustum );\n\t\taddLine( 'n4', 'f4', colorFrustum );\n\n\t\t// cone\n\n\t\taddLine( 'p', 'n1', colorCone );\n\t\taddLine( 'p', 'n2', colorCone );\n\t\taddLine( 'p', 'n3', colorCone );\n\t\taddLine( 'p', 'n4', colorCone );\n\n\t\t// up\n\n\t\taddLine( 'u1', 'u2', colorUp );\n\t\taddLine( 'u2', 'u3', colorUp );\n\t\taddLine( 'u3', 'u1', colorUp );\n\n\t\t// target\n\n\t\taddLine( 'c', 't', colorTarget );\n\t\taddLine( 'p', 'c', colorCross );\n\n\t\t// cross\n\n\t\taddLine( 'cn1', 'cn2', colorCross );\n\t\taddLine( 'cn3', 'cn4', colorCross );\n\n\t\taddLine( 'cf1', 'cf2', colorCross );\n\t\taddLine( 'cf3', 'cf4', colorCross );\n\n\t\tfunction addLine( a, b, color ) {\n\n\t\t\taddPoint( a, color );\n\t\t\taddPoint( b, color );\n\n\t\t}\n\n\t\tfunction addPoint( id, color ) {\n\n\t\t\tvertices.push( 0, 0, 0 );\n\t\t\tcolors.push( color.r, color.g, color.b );\n\n\t\t\tif ( pointMap[ id ] === undefined ) {\n\n\t\t\t\tpointMap[ id ] = [];\n\n\t\t\t}\n\n\t\t\tpointMap[ id ].push( ( vertices.length / 3 ) - 1 );\n\n\t\t}\n\n\t\tgeometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tgeometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );\n\n\t\tLineSegments.call( this, geometry, material );\n\n\t\tthis.camera = camera;\n\t\tif ( this.camera.updateProjectionMatrix ) this.camera.updateProjectionMatrix();\n\n\t\tthis.matrix = camera.matrixWorld;\n\t\tthis.matrixAutoUpdate = false;\n\n\t\tthis.pointMap = pointMap;\n\n\t\tthis.update();\n\n\t}\n\n\tCameraHelper.prototype = Object.create( LineSegments.prototype );\n\tCameraHelper.prototype.constructor = CameraHelper;\n\n\tCameraHelper.prototype.update = function () {\n\n\t\tvar geometry, pointMap;\n\n\t\tvar vector = new Vector3();\n\t\tvar camera = new Camera();\n\n\t\tfunction setPoint( point, x, y, z ) {\n\n\t\t\tvector.set( x, y, z ).unproject( camera );\n\n\t\t\tvar points = pointMap[ point ];\n\n\t\t\tif ( points !== undefined ) {\n\n\t\t\t\tvar position = geometry.getAttribute( 'position' );\n\n\t\t\t\tfor ( var i = 0, l = points.length; i < l; i ++ ) {\n\n\t\t\t\t\tposition.setXYZ( points[ i ], vector.x, vector.y, vector.z );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn function update() {\n\n\t\t\tgeometry = this.geometry;\n\t\t\tpointMap = this.pointMap;\n\n\t\t\tvar w = 1, h = 1;\n\n\t\t\t// we need just camera projection matrix\n\t\t\t// world matrix must be identity\n\n\t\t\tcamera.projectionMatrix.copy( this.camera.projectionMatrix );\n\n\t\t\t// center / target\n\n\t\t\tsetPoint( 'c', 0, 0, - 1 );\n\t\t\tsetPoint( 't', 0, 0, 1 );\n\n\t\t\t// near\n\n\t\t\tsetPoint( 'n1', - w, - h, - 1 );\n\t\t\tsetPoint( 'n2', w, - h, - 1 );\n\t\t\tsetPoint( 'n3', - w, h, - 1 );\n\t\t\tsetPoint( 'n4', w, h, - 1 );\n\n\t\t\t// far\n\n\t\t\tsetPoint( 'f1', - w, - h, 1 );\n\t\t\tsetPoint( 'f2', w, - h, 1 );\n\t\t\tsetPoint( 'f3', - w, h, 1 );\n\t\t\tsetPoint( 'f4', w, h, 1 );\n\n\t\t\t// up\n\n\t\t\tsetPoint( 'u1', w * 0.7, h * 1.1, - 1 );\n\t\t\tsetPoint( 'u2', - w * 0.7, h * 1.1, - 1 );\n\t\t\tsetPoint( 'u3', 0, h * 2, - 1 );\n\n\t\t\t// cross\n\n\t\t\tsetPoint( 'cf1', - w, 0, 1 );\n\t\t\tsetPoint( 'cf2', w, 0, 1 );\n\t\t\tsetPoint( 'cf3', 0, - h, 1 );\n\t\t\tsetPoint( 'cf4', 0, h, 1 );\n\n\t\t\tsetPoint( 'cn1', - w, 0, - 1 );\n\t\t\tsetPoint( 'cn2', w, 0, - 1 );\n\t\t\tsetPoint( 'cn3', 0, - h, - 1 );\n\t\t\tsetPoint( 'cn4', 0, h, - 1 );\n\n\t\t\tgeometry.getAttribute( 'position' ).needsUpdate = true;\n\n\t\t};\n\n\t}();\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t * @author Mugen87 / http://github.com/Mugen87\n\t */\n\n\tfunction BoxHelper( object, color ) {\n\n\t\tthis.object = object;\n\n\t\tif ( color === undefined ) color = 0xffff00;\n\n\t\tvar indices = new Uint16Array( [ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 ] );\n\t\tvar positions = new Float32Array( 8 * 3 );\n\n\t\tvar geometry = new BufferGeometry();\n\t\tgeometry.setIndex( new BufferAttribute( indices, 1 ) );\n\t\tgeometry.addAttribute( 'position', new BufferAttribute( positions, 3 ) );\n\n\t\tLineSegments.call( this, geometry, new LineBasicMaterial( { color: color } ) );\n\n\t\tthis.matrixAutoUpdate = false;\n\n\t\tthis.update();\n\n\t}\n\n\tBoxHelper.prototype = Object.create( LineSegments.prototype );\n\tBoxHelper.prototype.constructor = BoxHelper;\n\n\tBoxHelper.prototype.update = ( function () {\n\n\t\tvar box = new Box3();\n\n\t\treturn function update( object ) {\n\n\t\t\tif ( object !== undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BoxHelper: .update() has no longer arguments.' );\n\n\t\t\t}\n\n\t\t\tif ( this.object !== undefined ) {\n\n\t\t\t\tbox.setFromObject( this.object );\n\n\t\t\t}\n\n\t\t\tif ( box.isEmpty() ) return;\n\n\t\t\tvar min = box.min;\n\t\t\tvar max = box.max;\n\n\t\t\t/*\n\t\t\t  5____4\n\t\t\t1/___0/|\n\t\t\t| 6__|_7\n\t\t\t2/___3/\n\n\t\t\t0: max.x, max.y, max.z\n\t\t\t1: min.x, max.y, max.z\n\t\t\t2: min.x, min.y, max.z\n\t\t\t3: max.x, min.y, max.z\n\t\t\t4: max.x, max.y, min.z\n\t\t\t5: min.x, max.y, min.z\n\t\t\t6: min.x, min.y, min.z\n\t\t\t7: max.x, min.y, min.z\n\t\t\t*/\n\n\t\t\tvar position = this.geometry.attributes.position;\n\t\t\tvar array = position.array;\n\n\t\t\tarray[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z;\n\t\t\tarray[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z;\n\t\t\tarray[ 6 ] = min.x; array[ 7 ] = min.y; array[ 8 ] = max.z;\n\t\t\tarray[ 9 ] = max.x; array[ 10 ] = min.y; array[ 11 ] = max.z;\n\t\t\tarray[ 12 ] = max.x; array[ 13 ] = max.y; array[ 14 ] = min.z;\n\t\t\tarray[ 15 ] = min.x; array[ 16 ] = max.y; array[ 17 ] = min.z;\n\t\t\tarray[ 18 ] = min.x; array[ 19 ] = min.y; array[ 20 ] = min.z;\n\t\t\tarray[ 21 ] = max.x; array[ 22 ] = min.y; array[ 23 ] = min.z;\n\n\t\t\tposition.needsUpdate = true;\n\n\t\t\tthis.geometry.computeBoundingSphere();\n\n\t\t};\n\n\t} )();\n\n\tBoxHelper.prototype.setFromObject = function ( object ) {\n\n\t\tthis.object = object;\n\t\tthis.update();\n\n\t\treturn this;\n\n\t};\n\n\tBoxHelper.prototype.copy = function ( source ) {\n\n\t\tLineSegments.prototype.copy.call( this, source );\n\n\t\tthis.object = source.object;\n\n\t\treturn this;\n\n\t};\n\n\tBoxHelper.prototype.clone = function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t};\n\n\t/**\n\t * @author WestLangley / http://github.com/WestLangley\n\t */\n\n\tfunction Box3Helper( box, hex ) {\n\n\t\tthis.type = 'Box3Helper';\n\n\t\tthis.box = box;\n\n\t\tvar color = ( hex !== undefined ) ? hex : 0xffff00;\n\n\t\tvar indices = new Uint16Array( [ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 ] );\n\n\t\tvar positions = [ 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 1, - 1, 1, - 1, - 1 ];\n\n\t\tvar geometry = new BufferGeometry();\n\n\t\tgeometry.setIndex( new BufferAttribute( indices, 1 ) );\n\n\t\tgeometry.addAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );\n\n\t\tLineSegments.call( this, geometry, new LineBasicMaterial( { color: color } ) );\n\n\t\tthis.geometry.computeBoundingSphere();\n\n\t}\n\n\tBox3Helper.prototype = Object.create( LineSegments.prototype );\n\tBox3Helper.prototype.constructor = Box3Helper;\n\n\tBox3Helper.prototype.updateMatrixWorld = function ( force ) {\n\n\t\tvar box = this.box;\n\n\t\tif ( box.isEmpty() ) return;\n\n\t\tbox.getCenter( this.position );\n\n\t\tbox.getSize( this.scale );\n\n\t\tthis.scale.multiplyScalar( 0.5 );\n\n\t\tObject3D.prototype.updateMatrixWorld.call( this, force );\n\n\t};\n\n\t/**\n\t * @author WestLangley / http://github.com/WestLangley\n\t */\n\n\tfunction PlaneHelper( plane, size, hex ) {\n\n\t\tthis.type = 'PlaneHelper';\n\n\t\tthis.plane = plane;\n\n\t\tthis.size = ( size === undefined ) ? 1 : size;\n\n\t\tvar color = ( hex !== undefined ) ? hex : 0xffff00;\n\n\t\tvar positions = [ 1, - 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, - 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0 ];\n\n\t\tvar geometry = new BufferGeometry();\n\t\tgeometry.addAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );\n\t\tgeometry.computeBoundingSphere();\n\n\t\tLine.call( this, geometry, new LineBasicMaterial( { color: color } ) );\n\n\t\t//\n\n\t\tvar positions2 = [ 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, 1, 1, - 1, - 1, 1, 1, - 1, 1 ];\n\n\t\tvar geometry2 = new BufferGeometry();\n\t\tgeometry2.addAttribute( 'position', new Float32BufferAttribute( positions2, 3 ) );\n\t\tgeometry2.computeBoundingSphere();\n\n\t\tthis.add( new Mesh( geometry2, new MeshBasicMaterial( { color: color, opacity: 0.2, transparent: true, depthWrite: false } ) ) );\n\n\t}\n\n\tPlaneHelper.prototype = Object.create( Line.prototype );\n\tPlaneHelper.prototype.constructor = PlaneHelper;\n\n\tPlaneHelper.prototype.updateMatrixWorld = function ( force ) {\n\n\t\tvar scale = - this.plane.constant;\n\n\t\tif ( Math.abs( scale ) < 1e-8 ) scale = 1e-8; // sign does not matter\n\n\t\tthis.scale.set( 0.5 * this.size, 0.5 * this.size, scale );\n\n\t\tthis.children[ 0 ].material.side = ( scale < 0 ) ? BackSide : FrontSide; // renderer flips side when determinant < 0; flipping not wanted here\n\n\t\tthis.lookAt( this.plane.normal );\n\n\t\tObject3D.prototype.updateMatrixWorld.call( this, force );\n\n\t};\n\n\t/**\n\t * @author WestLangley / http://github.com/WestLangley\n\t * @author zz85 / http://github.com/zz85\n\t * @author bhouston / http://clara.io\n\t *\n\t * Creates an arrow for visualizing directions\n\t *\n\t * Parameters:\n\t *  dir - Vector3\n\t *  origin - Vector3\n\t *  length - Number\n\t *  color - color in hex value\n\t *  headLength - Number\n\t *  headWidth - Number\n\t */\n\n\tvar lineGeometry, coneGeometry;\n\n\tfunction ArrowHelper( dir, origin, length, color, headLength, headWidth ) {\n\n\t\t// dir is assumed to be normalized\n\n\t\tObject3D.call( this );\n\n\t\tif ( dir === undefined ) dir = new THREE.Vector3( 0, 0, 1 );\n\t\tif ( origin === undefined ) origin = new THREE.Vector3( 0, 0, 0 );\n\t\tif ( length === undefined ) length = 1;\n\t\tif ( color === undefined ) color = 0xffff00;\n\t\tif ( headLength === undefined ) headLength = 0.2 * length;\n\t\tif ( headWidth === undefined ) headWidth = 0.2 * headLength;\n\n\t\tif ( lineGeometry === undefined ) {\n\n\t\t\tlineGeometry = new BufferGeometry();\n\t\t\tlineGeometry.addAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 0, 1, 0 ], 3 ) );\n\n\t\t\tconeGeometry = new CylinderBufferGeometry( 0, 0.5, 1, 5, 1 );\n\t\t\tconeGeometry.translate( 0, - 0.5, 0 );\n\n\t\t}\n\n\t\tthis.position.copy( origin );\n\n\t\tthis.line = new Line( lineGeometry, new LineBasicMaterial( { color: color } ) );\n\t\tthis.line.matrixAutoUpdate = false;\n\t\tthis.add( this.line );\n\n\t\tthis.cone = new Mesh( coneGeometry, new MeshBasicMaterial( { color: color } ) );\n\t\tthis.cone.matrixAutoUpdate = false;\n\t\tthis.add( this.cone );\n\n\t\tthis.setDirection( dir );\n\t\tthis.setLength( length, headLength, headWidth );\n\n\t}\n\n\tArrowHelper.prototype = Object.create( Object3D.prototype );\n\tArrowHelper.prototype.constructor = ArrowHelper;\n\n\tArrowHelper.prototype.setDirection = ( function () {\n\n\t\tvar axis = new Vector3();\n\t\tvar radians;\n\n\t\treturn function setDirection( dir ) {\n\n\t\t\t// dir is assumed to be normalized\n\n\t\t\tif ( dir.y > 0.99999 ) {\n\n\t\t\t\tthis.quaternion.set( 0, 0, 0, 1 );\n\n\t\t\t} else if ( dir.y < - 0.99999 ) {\n\n\t\t\t\tthis.quaternion.set( 1, 0, 0, 0 );\n\n\t\t\t} else {\n\n\t\t\t\taxis.set( dir.z, 0, - dir.x ).normalize();\n\n\t\t\t\tradians = Math.acos( dir.y );\n\n\t\t\t\tthis.quaternion.setFromAxisAngle( axis, radians );\n\n\t\t\t}\n\n\t\t};\n\n\t}() );\n\n\tArrowHelper.prototype.setLength = function ( length, headLength, headWidth ) {\n\n\t\tif ( headLength === undefined ) headLength = 0.2 * length;\n\t\tif ( headWidth === undefined ) headWidth = 0.2 * headLength;\n\n\t\tthis.line.scale.set( 1, Math.max( 0, length - headLength ), 1 );\n\t\tthis.line.updateMatrix();\n\n\t\tthis.cone.scale.set( headWidth, headLength, headWidth );\n\t\tthis.cone.position.y = length;\n\t\tthis.cone.updateMatrix();\n\n\t};\n\n\tArrowHelper.prototype.setColor = function ( color ) {\n\n\t\tthis.line.material.color.copy( color );\n\t\tthis.cone.material.color.copy( color );\n\n\t};\n\n\tArrowHelper.prototype.copy = function ( source ) {\n\n\t\tObject3D.prototype.copy.call( this, source, false );\n\n\t\tthis.line.copy( source.line );\n\t\tthis.cone.copy( source.cone );\n\n\t\treturn this;\n\n\t};\n\n\tArrowHelper.prototype.clone = function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t};\n\n\t/**\n\t * @author sroucheray / http://sroucheray.org/\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction AxesHelper( size ) {\n\n\t\tsize = size || 1;\n\n\t\tvar vertices = [\n\t\t\t0, 0, 0,\tsize, 0, 0,\n\t\t\t0, 0, 0,\t0, size, 0,\n\t\t\t0, 0, 0,\t0, 0, size\n\t\t];\n\n\t\tvar colors = [\n\t\t\t1, 0, 0,\t1, 0.6, 0,\n\t\t\t0, 1, 0,\t0.6, 1, 0,\n\t\t\t0, 0, 1,\t0, 0.6, 1\n\t\t];\n\n\t\tvar geometry = new BufferGeometry();\n\t\tgeometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tgeometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );\n\n\t\tvar material = new LineBasicMaterial( { vertexColors: VertexColors } );\n\n\t\tLineSegments.call( this, geometry, material );\n\n\t}\n\n\tAxesHelper.prototype = Object.create( LineSegments.prototype );\n\tAxesHelper.prototype.constructor = AxesHelper;\n\n\t/**\n\t * @author mrdoob / http://mrdoob.com/\n\t */\n\n\tfunction Face4( a, b, c, d, normal, color, materialIndex ) {\n\n\t\tconsole.warn( 'THREE.Face4 has been removed. A THREE.Face3 will be created instead.' );\n\t\treturn new Face3( a, b, c, normal, color, materialIndex );\n\n\t}\n\n\tvar LineStrip = 0;\n\n\tvar LinePieces = 1;\n\n\tfunction MeshFaceMaterial( materials ) {\n\n\t\tconsole.warn( 'THREE.MeshFaceMaterial has been removed. Use an Array instead.' );\n\t\treturn materials;\n\n\t}\n\n\tfunction MultiMaterial( materials ) {\n\n\t\tif ( materials === undefined ) materials = [];\n\n\t\tconsole.warn( 'THREE.MultiMaterial has been removed. Use an Array instead.' );\n\t\tmaterials.isMultiMaterial = true;\n\t\tmaterials.materials = materials;\n\t\tmaterials.clone = function () {\n\n\t\t\treturn materials.slice();\n\n\t\t};\n\t\treturn materials;\n\n\t}\n\n\tfunction PointCloud( geometry, material ) {\n\n\t\tconsole.warn( 'THREE.PointCloud has been renamed to THREE.Points.' );\n\t\treturn new Points( geometry, material );\n\n\t}\n\n\tfunction Particle( material ) {\n\n\t\tconsole.warn( 'THREE.Particle has been renamed to THREE.Sprite.' );\n\t\treturn new Sprite( material );\n\n\t}\n\n\tfunction ParticleSystem( geometry, material ) {\n\n\t\tconsole.warn( 'THREE.ParticleSystem has been renamed to THREE.Points.' );\n\t\treturn new Points( geometry, material );\n\n\t}\n\n\tfunction PointCloudMaterial( parameters ) {\n\n\t\tconsole.warn( 'THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial.' );\n\t\treturn new PointsMaterial( parameters );\n\n\t}\n\n\tfunction ParticleBasicMaterial( parameters ) {\n\n\t\tconsole.warn( 'THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial.' );\n\t\treturn new PointsMaterial( parameters );\n\n\t}\n\n\tfunction ParticleSystemMaterial( parameters ) {\n\n\t\tconsole.warn( 'THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial.' );\n\t\treturn new PointsMaterial( parameters );\n\n\t}\n\n\tfunction Vertex( x, y, z ) {\n\n\t\tconsole.warn( 'THREE.Vertex has been removed. Use THREE.Vector3 instead.' );\n\t\treturn new Vector3( x, y, z );\n\n\t}\n\n\t//\n\n\tfunction DynamicBufferAttribute( array, itemSize ) {\n\n\t\tconsole.warn( 'THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.' );\n\t\treturn new BufferAttribute( array, itemSize ).setDynamic( true );\n\n\t}\n\n\tfunction Int8Attribute( array, itemSize ) {\n\n\t\tconsole.warn( 'THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead.' );\n\t\treturn new Int8BufferAttribute( array, itemSize );\n\n\t}\n\n\tfunction Uint8Attribute( array, itemSize ) {\n\n\t\tconsole.warn( 'THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead.' );\n\t\treturn new Uint8BufferAttribute( array, itemSize );\n\n\t}\n\n\tfunction Uint8ClampedAttribute( array, itemSize ) {\n\n\t\tconsole.warn( 'THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead.' );\n\t\treturn new Uint8ClampedBufferAttribute( array, itemSize );\n\n\t}\n\n\tfunction Int16Attribute( array, itemSize ) {\n\n\t\tconsole.warn( 'THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead.' );\n\t\treturn new Int16BufferAttribute( array, itemSize );\n\n\t}\n\n\tfunction Uint16Attribute( array, itemSize ) {\n\n\t\tconsole.warn( 'THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead.' );\n\t\treturn new Uint16BufferAttribute( array, itemSize );\n\n\t}\n\n\tfunction Int32Attribute( array, itemSize ) {\n\n\t\tconsole.warn( 'THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead.' );\n\t\treturn new Int32BufferAttribute( array, itemSize );\n\n\t}\n\n\tfunction Uint32Attribute( array, itemSize ) {\n\n\t\tconsole.warn( 'THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead.' );\n\t\treturn new Uint32BufferAttribute( array, itemSize );\n\n\t}\n\n\tfunction Float32Attribute( array, itemSize ) {\n\n\t\tconsole.warn( 'THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead.' );\n\t\treturn new Float32BufferAttribute( array, itemSize );\n\n\t}\n\n\tfunction Float64Attribute( array, itemSize ) {\n\n\t\tconsole.warn( 'THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead.' );\n\t\treturn new Float64BufferAttribute( array, itemSize );\n\n\t}\n\n\t//\n\n\tCurve.create = function ( construct, getPoint ) {\n\n\t\tconsole.log( 'THREE.Curve.create() has been deprecated' );\n\n\t\tconstruct.prototype = Object.create( Curve.prototype );\n\t\tconstruct.prototype.constructor = construct;\n\t\tconstruct.prototype.getPoint = getPoint;\n\n\t\treturn construct;\n\n\t};\n\n\t//\n\n\tObject.assign( CurvePath.prototype, {\n\n\t\tcreatePointsGeometry: function ( divisions ) {\n\n\t\t\tconsole.warn( 'THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.' );\n\n\t\t\t// generate geometry from path points (for Line or Points objects)\n\n\t\t\tvar pts = this.getPoints( divisions );\n\t\t\treturn this.createGeometry( pts );\n\n\t\t},\n\n\t\tcreateSpacedPointsGeometry: function ( divisions ) {\n\n\t\t\tconsole.warn( 'THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.' );\n\n\t\t\t// generate geometry from equidistant sampling along the path\n\n\t\t\tvar pts = this.getSpacedPoints( divisions );\n\t\t\treturn this.createGeometry( pts );\n\n\t\t},\n\n\t\tcreateGeometry: function ( points ) {\n\n\t\t\tconsole.warn( 'THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.' );\n\n\t\t\tvar geometry = new Geometry();\n\n\t\t\tfor ( var i = 0, l = points.length; i < l; i ++ ) {\n\n\t\t\t\tvar point = points[ i ];\n\t\t\t\tgeometry.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );\n\n\t\t\t}\n\n\t\t\treturn geometry;\n\n\t\t}\n\n\t} );\n\n\t//\n\n\tObject.assign( Path.prototype, {\n\n\t\tfromPoints: function ( points ) {\n\n\t\t\tconsole.warn( 'THREE.Path: .fromPoints() has been renamed to .setFromPoints().' );\n\t\t\tthis.setFromPoints( points );\n\n\t\t}\n\n\t} );\n\n\t//\n\n\tfunction ClosedSplineCurve3( points ) {\n\n\t\tconsole.warn( 'THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.' );\n\n\t\tCatmullRomCurve3.call( this, points );\n\t\tthis.type = 'catmullrom';\n\t\tthis.closed = true;\n\n\t}\n\n\tClosedSplineCurve3.prototype = Object.create( CatmullRomCurve3.prototype );\n\n\t//\n\n\tfunction SplineCurve3( points ) {\n\n\t\tconsole.warn( 'THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.' );\n\n\t\tCatmullRomCurve3.call( this, points );\n\t\tthis.type = 'catmullrom';\n\n\t}\n\n\tSplineCurve3.prototype = Object.create( CatmullRomCurve3.prototype );\n\n\t//\n\n\tfunction Spline( points ) {\n\n\t\tconsole.warn( 'THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead.' );\n\n\t\tCatmullRomCurve3.call( this, points );\n\t\tthis.type = 'catmullrom';\n\n\t}\n\n\tSpline.prototype = Object.create( CatmullRomCurve3.prototype );\n\n\tObject.assign( Spline.prototype, {\n\n\t\tinitFromArray: function ( /* a */ ) {\n\n\t\t\tconsole.error( 'THREE.Spline: .initFromArray() has been removed.' );\n\n\t\t},\n\t\tgetControlPointsArray: function ( /* optionalTarget */ ) {\n\n\t\t\tconsole.error( 'THREE.Spline: .getControlPointsArray() has been removed.' );\n\n\t\t},\n\t\treparametrizeByArcLength: function ( /* samplingCoef */ ) {\n\n\t\t\tconsole.error( 'THREE.Spline: .reparametrizeByArcLength() has been removed.' );\n\n\t\t}\n\n\t} );\n\n\t//\n\n\tfunction AxisHelper( size ) {\n\n\t\tconsole.warn( 'THREE.AxisHelper has been renamed to THREE.AxesHelper.' );\n\t\treturn new AxesHelper( size );\n\n\t}\n\n\tfunction BoundingBoxHelper( object, color ) {\n\n\t\tconsole.warn( 'THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead.' );\n\t\treturn new BoxHelper( object, color );\n\n\t}\n\n\tfunction EdgesHelper( object, hex ) {\n\n\t\tconsole.warn( 'THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead.' );\n\t\treturn new LineSegments( new EdgesGeometry( object.geometry ), new LineBasicMaterial( { color: hex !== undefined ? hex : 0xffffff } ) );\n\n\t}\n\n\tGridHelper.prototype.setColors = function () {\n\n\t\tconsole.error( 'THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.' );\n\n\t};\n\n\tSkeletonHelper.prototype.update = function () {\n\n\t\tconsole.error( 'THREE.SkeletonHelper: update() no longer needs to be called.' );\n\n\t};\n\n\tfunction WireframeHelper( object, hex ) {\n\n\t\tconsole.warn( 'THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead.' );\n\t\treturn new LineSegments( new WireframeGeometry( object.geometry ), new LineBasicMaterial( { color: hex !== undefined ? hex : 0xffffff } ) );\n\n\t}\n\n\t//\n\n\tObject.assign( Loader.prototype, {\n\n\t\textractUrlBase: function ( url ) {\n\n\t\t\tconsole.warn( 'THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead.' );\n\t\t\treturn LoaderUtils.extractUrlBase( url );\n\n\t\t}\n\n\t} );\n\n\tfunction XHRLoader( manager ) {\n\n\t\tconsole.warn( 'THREE.XHRLoader has been renamed to THREE.FileLoader.' );\n\t\treturn new FileLoader( manager );\n\n\t}\n\n\tfunction BinaryTextureLoader( manager ) {\n\n\t\tconsole.warn( 'THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader.' );\n\t\treturn new DataTextureLoader( manager );\n\n\t}\n\n\tObject.assign( ObjectLoader.prototype, {\n\n\t\tsetTexturePath: function ( value ) {\n\n\t\t\tconsole.warn( 'THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath().' );\n\t\t\treturn this.setResourcePath( value );\n\n\t\t}\n\n\t} );\n\n\t//\n\n\tObject.assign( Box2.prototype, {\n\n\t\tcenter: function ( optionalTarget ) {\n\n\t\t\tconsole.warn( 'THREE.Box2: .center() has been renamed to .getCenter().' );\n\t\t\treturn this.getCenter( optionalTarget );\n\n\t\t},\n\t\tempty: function () {\n\n\t\t\tconsole.warn( 'THREE.Box2: .empty() has been renamed to .isEmpty().' );\n\t\t\treturn this.isEmpty();\n\n\t\t},\n\t\tisIntersectionBox: function ( box ) {\n\n\t\t\tconsole.warn( 'THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().' );\n\t\t\treturn this.intersectsBox( box );\n\n\t\t},\n\t\tsize: function ( optionalTarget ) {\n\n\t\t\tconsole.warn( 'THREE.Box2: .size() has been renamed to .getSize().' );\n\t\t\treturn this.getSize( optionalTarget );\n\n\t\t}\n\t} );\n\n\tObject.assign( Box3.prototype, {\n\n\t\tcenter: function ( optionalTarget ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .center() has been renamed to .getCenter().' );\n\t\t\treturn this.getCenter( optionalTarget );\n\n\t\t},\n\t\tempty: function () {\n\n\t\t\tconsole.warn( 'THREE.Box3: .empty() has been renamed to .isEmpty().' );\n\t\t\treturn this.isEmpty();\n\n\t\t},\n\t\tisIntersectionBox: function ( box ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().' );\n\t\t\treturn this.intersectsBox( box );\n\n\t\t},\n\t\tisIntersectionSphere: function ( sphere ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().' );\n\t\t\treturn this.intersectsSphere( sphere );\n\n\t\t},\n\t\tsize: function ( optionalTarget ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .size() has been renamed to .getSize().' );\n\t\t\treturn this.getSize( optionalTarget );\n\n\t\t}\n\t} );\n\n\tLine3.prototype.center = function ( optionalTarget ) {\n\n\t\tconsole.warn( 'THREE.Line3: .center() has been renamed to .getCenter().' );\n\t\treturn this.getCenter( optionalTarget );\n\n\t};\n\n\tObject.assign( _Math, {\n\n\t\trandom16: function () {\n\n\t\t\tconsole.warn( 'THREE.Math: .random16() has been deprecated. Use Math.random() instead.' );\n\t\t\treturn Math.random();\n\n\t\t},\n\n\t\tnearestPowerOfTwo: function ( value ) {\n\n\t\t\tconsole.warn( 'THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo().' );\n\t\t\treturn _Math.floorPowerOfTwo( value );\n\n\t\t},\n\n\t\tnextPowerOfTwo: function ( value ) {\n\n\t\t\tconsole.warn( 'THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo().' );\n\t\t\treturn _Math.ceilPowerOfTwo( value );\n\n\t\t}\n\n\t} );\n\n\tObject.assign( Matrix3.prototype, {\n\n\t\tflattenToArrayOffset: function ( array, offset ) {\n\n\t\t\tconsole.warn( \"THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.\" );\n\t\t\treturn this.toArray( array, offset );\n\n\t\t},\n\t\tmultiplyVector3: function ( vector ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.' );\n\t\t\treturn vector.applyMatrix3( this );\n\n\t\t},\n\t\tmultiplyVector3Array: function ( /* a */ ) {\n\n\t\t\tconsole.error( 'THREE.Matrix3: .multiplyVector3Array() has been removed.' );\n\n\t\t},\n\t\tapplyToBuffer: function ( buffer /*, offset, length */ ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.' );\n\t\t\treturn this.applyToBufferAttribute( buffer );\n\n\t\t},\n\t\tapplyToVector3Array: function ( /* array, offset, length */ ) {\n\n\t\t\tconsole.error( 'THREE.Matrix3: .applyToVector3Array() has been removed.' );\n\n\t\t}\n\n\t} );\n\n\tObject.assign( Matrix4.prototype, {\n\n\t\textractPosition: function ( m ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().' );\n\t\t\treturn this.copyPosition( m );\n\n\t\t},\n\t\tflattenToArrayOffset: function ( array, offset ) {\n\n\t\t\tconsole.warn( \"THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.\" );\n\t\t\treturn this.toArray( array, offset );\n\n\t\t},\n\t\tgetPosition: function () {\n\n\t\t\tvar v1;\n\n\t\t\treturn function getPosition() {\n\n\t\t\t\tif ( v1 === undefined ) v1 = new Vector3();\n\t\t\t\tconsole.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' );\n\t\t\t\treturn v1.setFromMatrixColumn( this, 3 );\n\n\t\t\t};\n\n\t\t}(),\n\t\tsetRotationFromQuaternion: function ( q ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().' );\n\t\t\treturn this.makeRotationFromQuaternion( q );\n\n\t\t},\n\t\tmultiplyToArray: function () {\n\n\t\t\tconsole.warn( 'THREE.Matrix4: .multiplyToArray() has been removed.' );\n\n\t\t},\n\t\tmultiplyVector3: function ( vector ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead.' );\n\t\t\treturn vector.applyMatrix4( this );\n\n\t\t},\n\t\tmultiplyVector4: function ( vector ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.' );\n\t\t\treturn vector.applyMatrix4( this );\n\n\t\t},\n\t\tmultiplyVector3Array: function ( /* a */ ) {\n\n\t\t\tconsole.error( 'THREE.Matrix4: .multiplyVector3Array() has been removed.' );\n\n\t\t},\n\t\trotateAxis: function ( v ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.' );\n\t\t\tv.transformDirection( this );\n\n\t\t},\n\t\tcrossVector: function ( vector ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.' );\n\t\t\treturn vector.applyMatrix4( this );\n\n\t\t},\n\t\ttranslate: function () {\n\n\t\t\tconsole.error( 'THREE.Matrix4: .translate() has been removed.' );\n\n\t\t},\n\t\trotateX: function () {\n\n\t\t\tconsole.error( 'THREE.Matrix4: .rotateX() has been removed.' );\n\n\t\t},\n\t\trotateY: function () {\n\n\t\t\tconsole.error( 'THREE.Matrix4: .rotateY() has been removed.' );\n\n\t\t},\n\t\trotateZ: function () {\n\n\t\t\tconsole.error( 'THREE.Matrix4: .rotateZ() has been removed.' );\n\n\t\t},\n\t\trotateByAxis: function () {\n\n\t\t\tconsole.error( 'THREE.Matrix4: .rotateByAxis() has been removed.' );\n\n\t\t},\n\t\tapplyToBuffer: function ( buffer /*, offset, length */ ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.' );\n\t\t\treturn this.applyToBufferAttribute( buffer );\n\n\t\t},\n\t\tapplyToVector3Array: function ( /* array, offset, length */ ) {\n\n\t\t\tconsole.error( 'THREE.Matrix4: .applyToVector3Array() has been removed.' );\n\n\t\t},\n\t\tmakeFrustum: function ( left, right, bottom, top, near, far ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead.' );\n\t\t\treturn this.makePerspective( left, right, top, bottom, near, far );\n\n\t\t}\n\n\t} );\n\n\tPlane.prototype.isIntersectionLine = function ( line ) {\n\n\t\tconsole.warn( 'THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().' );\n\t\treturn this.intersectsLine( line );\n\n\t};\n\n\tQuaternion.prototype.multiplyVector3 = function ( vector ) {\n\n\t\tconsole.warn( 'THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.' );\n\t\treturn vector.applyQuaternion( this );\n\n\t};\n\n\tObject.assign( Ray.prototype, {\n\n\t\tisIntersectionBox: function ( box ) {\n\n\t\t\tconsole.warn( 'THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().' );\n\t\t\treturn this.intersectsBox( box );\n\n\t\t},\n\t\tisIntersectionPlane: function ( plane ) {\n\n\t\t\tconsole.warn( 'THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().' );\n\t\t\treturn this.intersectsPlane( plane );\n\n\t\t},\n\t\tisIntersectionSphere: function ( sphere ) {\n\n\t\t\tconsole.warn( 'THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().' );\n\t\t\treturn this.intersectsSphere( sphere );\n\n\t\t}\n\n\t} );\n\n\tObject.assign( Triangle.prototype, {\n\n\t\tarea: function () {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .area() has been renamed to .getArea().' );\n\t\t\treturn this.getArea();\n\n\t\t},\n\t\tbarycoordFromPoint: function ( point, target ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().' );\n\t\t\treturn this.getBarycoord( point, target );\n\n\t\t},\n\t\tmidpoint: function ( target ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .midpoint() has been renamed to .getMidpoint().' );\n\t\t\treturn this.getMidpoint( target );\n\n\t\t},\n\t\tnormal: function ( target ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .normal() has been renamed to .getNormal().' );\n\t\t\treturn this.getNormal( target );\n\n\t\t},\n\t\tplane: function ( target ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .plane() has been renamed to .getPlane().' );\n\t\t\treturn this.getPlane( target );\n\n\t\t}\n\n\t} );\n\n\tObject.assign( Triangle, {\n\n\t\tbarycoordFromPoint: function ( point, a, b, c, target ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().' );\n\t\t\treturn Triangle.getBarycoord( point, a, b, c, target );\n\n\t\t},\n\t\tnormal: function ( a, b, c, target ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .normal() has been renamed to .getNormal().' );\n\t\t\treturn Triangle.getNormal( a, b, c, target );\n\n\t\t}\n\n\t} );\n\n\tObject.assign( Shape.prototype, {\n\n\t\textractAllPoints: function ( divisions ) {\n\n\t\t\tconsole.warn( 'THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead.' );\n\t\t\treturn this.extractPoints( divisions );\n\n\t\t},\n\t\textrude: function ( options ) {\n\n\t\t\tconsole.warn( 'THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.' );\n\t\t\treturn new ExtrudeGeometry( this, options );\n\n\t\t},\n\t\tmakeGeometry: function ( options ) {\n\n\t\t\tconsole.warn( 'THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.' );\n\t\t\treturn new ShapeGeometry( this, options );\n\n\t\t}\n\n\t} );\n\n\tObject.assign( Vector2.prototype, {\n\n\t\tfromAttribute: function ( attribute, index, offset ) {\n\n\t\t\tconsole.warn( 'THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute().' );\n\t\t\treturn this.fromBufferAttribute( attribute, index, offset );\n\n\t\t},\n\t\tdistanceToManhattan: function ( v ) {\n\n\t\t\tconsole.warn( 'THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo().' );\n\t\t\treturn this.manhattanDistanceTo( v );\n\n\t\t},\n\t\tlengthManhattan: function () {\n\n\t\t\tconsole.warn( 'THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength().' );\n\t\t\treturn this.manhattanLength();\n\n\t\t}\n\n\t} );\n\n\tObject.assign( Vector3.prototype, {\n\n\t\tsetEulerFromRotationMatrix: function () {\n\n\t\t\tconsole.error( 'THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.' );\n\n\t\t},\n\t\tsetEulerFromQuaternion: function () {\n\n\t\t\tconsole.error( 'THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.' );\n\n\t\t},\n\t\tgetPositionFromMatrix: function ( m ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().' );\n\t\t\treturn this.setFromMatrixPosition( m );\n\n\t\t},\n\t\tgetScaleFromMatrix: function ( m ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().' );\n\t\t\treturn this.setFromMatrixScale( m );\n\n\t\t},\n\t\tgetColumnFromMatrix: function ( index, matrix ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().' );\n\t\t\treturn this.setFromMatrixColumn( matrix, index );\n\n\t\t},\n\t\tapplyProjection: function ( m ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead.' );\n\t\t\treturn this.applyMatrix4( m );\n\n\t\t},\n\t\tfromAttribute: function ( attribute, index, offset ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute().' );\n\t\t\treturn this.fromBufferAttribute( attribute, index, offset );\n\n\t\t},\n\t\tdistanceToManhattan: function ( v ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo().' );\n\t\t\treturn this.manhattanDistanceTo( v );\n\n\t\t},\n\t\tlengthManhattan: function () {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength().' );\n\t\t\treturn this.manhattanLength();\n\n\t\t}\n\n\t} );\n\n\tObject.assign( Vector4.prototype, {\n\n\t\tfromAttribute: function ( attribute, index, offset ) {\n\n\t\t\tconsole.warn( 'THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().' );\n\t\t\treturn this.fromBufferAttribute( attribute, index, offset );\n\n\t\t},\n\t\tlengthManhattan: function () {\n\n\t\t\tconsole.warn( 'THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength().' );\n\t\t\treturn this.manhattanLength();\n\n\t\t}\n\n\t} );\n\n\t//\n\n\tObject.assign( Geometry.prototype, {\n\n\t\tcomputeTangents: function () {\n\n\t\t\tconsole.error( 'THREE.Geometry: .computeTangents() has been removed.' );\n\n\t\t},\n\t\tcomputeLineDistances: function () {\n\n\t\t\tconsole.error( 'THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.' );\n\n\t\t}\n\n\t} );\n\n\tObject.assign( Object3D.prototype, {\n\n\t\tgetChildByName: function ( name ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().' );\n\t\t\treturn this.getObjectByName( name );\n\n\t\t},\n\t\trenderDepth: function () {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.' );\n\n\t\t},\n\t\ttranslate: function ( distance, axis ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.' );\n\t\t\treturn this.translateOnAxis( axis, distance );\n\n\t\t},\n\t\tgetWorldRotation: function () {\n\n\t\t\tconsole.error( 'THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.' );\n\n\t\t}\n\n\t} );\n\n\tObject.defineProperties( Object3D.prototype, {\n\n\t\teulerOrder: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.Object3D: .eulerOrder is now .rotation.order.' );\n\t\t\t\treturn this.rotation.order;\n\n\t\t\t},\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.Object3D: .eulerOrder is now .rotation.order.' );\n\t\t\t\tthis.rotation.order = value;\n\n\t\t\t}\n\t\t},\n\t\tuseQuaternion: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.' );\n\n\t\t\t},\n\t\t\tset: function () {\n\n\t\t\t\tconsole.warn( 'THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.' );\n\n\t\t\t}\n\t\t}\n\n\t} );\n\n\tObject.defineProperties( LOD.prototype, {\n\n\t\tobjects: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.LOD: .objects has been renamed to .levels.' );\n\t\t\t\treturn this.levels;\n\n\t\t\t}\n\t\t}\n\n\t} );\n\n\tObject.defineProperty( Skeleton.prototype, 'useVertexTexture', {\n\n\t\tget: function () {\n\n\t\t\tconsole.warn( 'THREE.Skeleton: useVertexTexture has been removed.' );\n\n\t\t},\n\t\tset: function () {\n\n\t\t\tconsole.warn( 'THREE.Skeleton: useVertexTexture has been removed.' );\n\n\t\t}\n\n\t} );\n\n\tSkinnedMesh.prototype.initBones = function () {\n\n\t\tconsole.error( 'THREE.SkinnedMesh: initBones() has been removed.' );\n\n\t};\n\n\tObject.defineProperty( Curve.prototype, '__arcLengthDivisions', {\n\n\t\tget: function () {\n\n\t\t\tconsole.warn( 'THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.' );\n\t\t\treturn this.arcLengthDivisions;\n\n\t\t},\n\t\tset: function ( value ) {\n\n\t\t\tconsole.warn( 'THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.' );\n\t\t\tthis.arcLengthDivisions = value;\n\n\t\t}\n\n\t} );\n\n\t//\n\n\tPerspectiveCamera.prototype.setLens = function ( focalLength, filmGauge ) {\n\n\t\tconsole.warn( \"THREE.PerspectiveCamera.setLens is deprecated. \" +\n\t\t\t\t\"Use .setFocalLength and .filmGauge for a photographic setup.\" );\n\n\t\tif ( filmGauge !== undefined ) this.filmGauge = filmGauge;\n\t\tthis.setFocalLength( focalLength );\n\n\t};\n\n\t//\n\n\tObject.defineProperties( Light.prototype, {\n\t\tonlyShadow: {\n\t\t\tset: function () {\n\n\t\t\t\tconsole.warn( 'THREE.Light: .onlyShadow has been removed.' );\n\n\t\t\t}\n\t\t},\n\t\tshadowCameraFov: {\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.Light: .shadowCameraFov is now .shadow.camera.fov.' );\n\t\t\t\tthis.shadow.camera.fov = value;\n\n\t\t\t}\n\t\t},\n\t\tshadowCameraLeft: {\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.Light: .shadowCameraLeft is now .shadow.camera.left.' );\n\t\t\t\tthis.shadow.camera.left = value;\n\n\t\t\t}\n\t\t},\n\t\tshadowCameraRight: {\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.Light: .shadowCameraRight is now .shadow.camera.right.' );\n\t\t\t\tthis.shadow.camera.right = value;\n\n\t\t\t}\n\t\t},\n\t\tshadowCameraTop: {\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.Light: .shadowCameraTop is now .shadow.camera.top.' );\n\t\t\t\tthis.shadow.camera.top = value;\n\n\t\t\t}\n\t\t},\n\t\tshadowCameraBottom: {\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.' );\n\t\t\t\tthis.shadow.camera.bottom = value;\n\n\t\t\t}\n\t\t},\n\t\tshadowCameraNear: {\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.Light: .shadowCameraNear is now .shadow.camera.near.' );\n\t\t\t\tthis.shadow.camera.near = value;\n\n\t\t\t}\n\t\t},\n\t\tshadowCameraFar: {\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.Light: .shadowCameraFar is now .shadow.camera.far.' );\n\t\t\t\tthis.shadow.camera.far = value;\n\n\t\t\t}\n\t\t},\n\t\tshadowCameraVisible: {\n\t\t\tset: function () {\n\n\t\t\t\tconsole.warn( 'THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.' );\n\n\t\t\t}\n\t\t},\n\t\tshadowBias: {\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.Light: .shadowBias is now .shadow.bias.' );\n\t\t\t\tthis.shadow.bias = value;\n\n\t\t\t}\n\t\t},\n\t\tshadowDarkness: {\n\t\t\tset: function () {\n\n\t\t\t\tconsole.warn( 'THREE.Light: .shadowDarkness has been removed.' );\n\n\t\t\t}\n\t\t},\n\t\tshadowMapWidth: {\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.' );\n\t\t\t\tthis.shadow.mapSize.width = value;\n\n\t\t\t}\n\t\t},\n\t\tshadowMapHeight: {\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.' );\n\t\t\t\tthis.shadow.mapSize.height = value;\n\n\t\t\t}\n\t\t}\n\t} );\n\n\t//\n\n\tObject.defineProperties( BufferAttribute.prototype, {\n\n\t\tlength: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.BufferAttribute: .length has been deprecated. Use .count instead.' );\n\t\t\t\treturn this.array.length;\n\n\t\t\t}\n\t\t},\n\t\tcopyIndicesArray: function ( /* indices */ ) {\n\n\t\t\tconsole.error( 'THREE.BufferAttribute: .copyIndicesArray() has been removed.' );\n\n\t\t}\n\n\t} );\n\n\tObject.assign( BufferGeometry.prototype, {\n\n\t\taddIndex: function ( index ) {\n\n\t\t\tconsole.warn( 'THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().' );\n\t\t\tthis.setIndex( index );\n\n\t\t},\n\t\taddDrawCall: function ( start, count, indexOffset ) {\n\n\t\t\tif ( indexOffset !== undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.' );\n\n\t\t\t}\n\t\t\tconsole.warn( 'THREE.BufferGeometry: .addDrawCall() is now .addGroup().' );\n\t\t\tthis.addGroup( start, count );\n\n\t\t},\n\t\tclearDrawCalls: function () {\n\n\t\t\tconsole.warn( 'THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().' );\n\t\t\tthis.clearGroups();\n\n\t\t},\n\t\tcomputeTangents: function () {\n\n\t\t\tconsole.warn( 'THREE.BufferGeometry: .computeTangents() has been removed.' );\n\n\t\t},\n\t\tcomputeOffsets: function () {\n\n\t\t\tconsole.warn( 'THREE.BufferGeometry: .computeOffsets() has been removed.' );\n\n\t\t}\n\n\t} );\n\n\tObject.defineProperties( BufferGeometry.prototype, {\n\n\t\tdrawcalls: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.error( 'THREE.BufferGeometry: .drawcalls has been renamed to .groups.' );\n\t\t\t\treturn this.groups;\n\n\t\t\t}\n\t\t},\n\t\toffsets: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.BufferGeometry: .offsets has been renamed to .groups.' );\n\t\t\t\treturn this.groups;\n\n\t\t\t}\n\t\t}\n\n\t} );\n\n\t//\n\n\tObject.assign( ExtrudeBufferGeometry.prototype, {\n\n\t\tgetArrays: function () {\n\n\t\t\tconsole.error( 'THREE.ExtrudeBufferGeometry: .getArrays() has been removed.' );\n\n\t\t},\n\n\t\taddShapeList: function () {\n\n\t\t\tconsole.error( 'THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.' );\n\n\t\t},\n\n\t\taddShape: function () {\n\n\t\t\tconsole.error( 'THREE.ExtrudeBufferGeometry: .addShape() has been removed.' );\n\n\t\t}\n\n\t} );\n\n\t//\n\n\tObject.defineProperties( Uniform.prototype, {\n\n\t\tdynamic: {\n\t\t\tset: function () {\n\n\t\t\t\tconsole.warn( 'THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.' );\n\n\t\t\t}\n\t\t},\n\t\tonUpdate: {\n\t\t\tvalue: function () {\n\n\t\t\t\tconsole.warn( 'THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.' );\n\t\t\t\treturn this;\n\n\t\t\t}\n\t\t}\n\n\t} );\n\n\t//\n\n\tObject.defineProperties( Material.prototype, {\n\n\t\twrapAround: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.Material: .wrapAround has been removed.' );\n\n\t\t\t},\n\t\t\tset: function () {\n\n\t\t\t\tconsole.warn( 'THREE.Material: .wrapAround has been removed.' );\n\n\t\t\t}\n\t\t},\n\n\t\toverdraw: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.Material: .overdraw has been removed.' );\n\n\t\t\t},\n\t\t\tset: function () {\n\n\t\t\t\tconsole.warn( 'THREE.Material: .overdraw has been removed.' );\n\n\t\t\t}\n\t\t},\n\n\t\twrapRGB: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.Material: .wrapRGB has been removed.' );\n\t\t\t\treturn new Color();\n\n\t\t\t}\n\t\t},\n\n\t\tshading: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.error( 'THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.' );\n\n\t\t\t},\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.' );\n\t\t\t\tthis.flatShading = ( value === FlatShading );\n\n\t\t\t}\n\t\t}\n\n\t} );\n\n\tObject.defineProperties( MeshPhongMaterial.prototype, {\n\n\t\tmetal: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.' );\n\t\t\t\treturn false;\n\n\t\t\t},\n\t\t\tset: function () {\n\n\t\t\t\tconsole.warn( 'THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead' );\n\n\t\t\t}\n\t\t}\n\n\t} );\n\n\tObject.defineProperties( ShaderMaterial.prototype, {\n\n\t\tderivatives: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.' );\n\t\t\t\treturn this.extensions.derivatives;\n\n\t\t\t},\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.' );\n\t\t\t\tthis.extensions.derivatives = value;\n\n\t\t\t}\n\t\t}\n\n\t} );\n\n\t//\n\n\tObject.assign( WebGLRenderer.prototype, {\n\n\t\tclearTarget: function ( renderTarget, color, depth, stencil ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead.' );\n\t\t\tthis.setRenderTarget( renderTarget );\n\t\t\tthis.clear( color, depth, stencil );\n\n\t\t},\n\n\t\tanimate: function ( callback ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .animate() is now .setAnimationLoop().' );\n\t\t\tthis.setAnimationLoop( callback );\n\n\t\t},\n\n\t\tgetCurrentRenderTarget: function () {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget().' );\n\t\t\treturn this.getRenderTarget();\n\n\t\t},\n\n\t\tgetMaxAnisotropy: function () {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy().' );\n\t\t\treturn this.capabilities.getMaxAnisotropy();\n\n\t\t},\n\n\t\tgetPrecision: function () {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision.' );\n\t\t\treturn this.capabilities.precision;\n\n\t\t},\n\n\t\tresetGLState: function () {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .resetGLState() is now .state.reset().' );\n\t\t\treturn this.state.reset();\n\n\t\t},\n\n\t\tsupportsFloatTextures: function () {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( \\'OES_texture_float\\' ).' );\n\t\t\treturn this.extensions.get( 'OES_texture_float' );\n\n\t\t},\n\t\tsupportsHalfFloatTextures: function () {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( \\'OES_texture_half_float\\' ).' );\n\t\t\treturn this.extensions.get( 'OES_texture_half_float' );\n\n\t\t},\n\t\tsupportsStandardDerivatives: function () {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( \\'OES_standard_derivatives\\' ).' );\n\t\t\treturn this.extensions.get( 'OES_standard_derivatives' );\n\n\t\t},\n\t\tsupportsCompressedTextureS3TC: function () {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( \\'WEBGL_compressed_texture_s3tc\\' ).' );\n\t\t\treturn this.extensions.get( 'WEBGL_compressed_texture_s3tc' );\n\n\t\t},\n\t\tsupportsCompressedTexturePVRTC: function () {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( \\'WEBGL_compressed_texture_pvrtc\\' ).' );\n\t\t\treturn this.extensions.get( 'WEBGL_compressed_texture_pvrtc' );\n\n\t\t},\n\t\tsupportsBlendMinMax: function () {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( \\'EXT_blend_minmax\\' ).' );\n\t\t\treturn this.extensions.get( 'EXT_blend_minmax' );\n\n\t\t},\n\t\tsupportsVertexTextures: function () {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures.' );\n\t\t\treturn this.capabilities.vertexTextures;\n\n\t\t},\n\t\tsupportsInstancedArrays: function () {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( \\'ANGLE_instanced_arrays\\' ).' );\n\t\t\treturn this.extensions.get( 'ANGLE_instanced_arrays' );\n\n\t\t},\n\t\tenableScissorTest: function ( boolean ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().' );\n\t\t\tthis.setScissorTest( boolean );\n\n\t\t},\n\t\tinitMaterial: function () {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .initMaterial() has been removed.' );\n\n\t\t},\n\t\taddPrePlugin: function () {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .addPrePlugin() has been removed.' );\n\n\t\t},\n\t\taddPostPlugin: function () {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .addPostPlugin() has been removed.' );\n\n\t\t},\n\t\tupdateShadowMap: function () {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .updateShadowMap() has been removed.' );\n\n\t\t},\n\t\tsetFaceCulling: function () {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: .setFaceCulling() has been removed.' );\n\n\t\t}\n\n\t} );\n\n\tObject.defineProperties( WebGLRenderer.prototype, {\n\n\t\tshadowMapEnabled: {\n\t\t\tget: function () {\n\n\t\t\t\treturn this.shadowMap.enabled;\n\n\t\t\t},\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.' );\n\t\t\t\tthis.shadowMap.enabled = value;\n\n\t\t\t}\n\t\t},\n\t\tshadowMapType: {\n\t\t\tget: function () {\n\n\t\t\t\treturn this.shadowMap.type;\n\n\t\t\t},\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.' );\n\t\t\t\tthis.shadowMap.type = value;\n\n\t\t\t}\n\t\t},\n\t\tshadowMapCullFace: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.' );\n\t\t\t\treturn undefined;\n\n\t\t\t},\n\t\t\tset: function ( /* value */ ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.' );\n\n\t\t\t}\n\t\t}\n\t} );\n\n\tObject.defineProperties( WebGLShadowMap.prototype, {\n\n\t\tcullFace: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.' );\n\t\t\t\treturn undefined;\n\n\t\t\t},\n\t\t\tset: function ( /* cullFace */ ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.' );\n\n\t\t\t}\n\t\t},\n\t\trenderReverseSided: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.' );\n\t\t\t\treturn undefined;\n\n\t\t\t},\n\t\t\tset: function () {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.' );\n\n\t\t\t}\n\t\t},\n\t\trenderSingleSided: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.' );\n\t\t\t\treturn undefined;\n\n\t\t\t},\n\t\t\tset: function () {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.' );\n\n\t\t\t}\n\t\t}\n\n\t} );\n\n\t//\n\n\tObject.defineProperties( WebGLRenderTarget.prototype, {\n\n\t\twrapS: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.' );\n\t\t\t\treturn this.texture.wrapS;\n\n\t\t\t},\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.' );\n\t\t\t\tthis.texture.wrapS = value;\n\n\t\t\t}\n\t\t},\n\t\twrapT: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.' );\n\t\t\t\treturn this.texture.wrapT;\n\n\t\t\t},\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.' );\n\t\t\t\tthis.texture.wrapT = value;\n\n\t\t\t}\n\t\t},\n\t\tmagFilter: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.' );\n\t\t\t\treturn this.texture.magFilter;\n\n\t\t\t},\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.' );\n\t\t\t\tthis.texture.magFilter = value;\n\n\t\t\t}\n\t\t},\n\t\tminFilter: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.' );\n\t\t\t\treturn this.texture.minFilter;\n\n\t\t\t},\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.' );\n\t\t\t\tthis.texture.minFilter = value;\n\n\t\t\t}\n\t\t},\n\t\tanisotropy: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.' );\n\t\t\t\treturn this.texture.anisotropy;\n\n\t\t\t},\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.' );\n\t\t\t\tthis.texture.anisotropy = value;\n\n\t\t\t}\n\t\t},\n\t\toffset: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .offset is now .texture.offset.' );\n\t\t\t\treturn this.texture.offset;\n\n\t\t\t},\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .offset is now .texture.offset.' );\n\t\t\t\tthis.texture.offset = value;\n\n\t\t\t}\n\t\t},\n\t\trepeat: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .repeat is now .texture.repeat.' );\n\t\t\t\treturn this.texture.repeat;\n\n\t\t\t},\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .repeat is now .texture.repeat.' );\n\t\t\t\tthis.texture.repeat = value;\n\n\t\t\t}\n\t\t},\n\t\tformat: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .format is now .texture.format.' );\n\t\t\t\treturn this.texture.format;\n\n\t\t\t},\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .format is now .texture.format.' );\n\t\t\t\tthis.texture.format = value;\n\n\t\t\t}\n\t\t},\n\t\ttype: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .type is now .texture.type.' );\n\t\t\t\treturn this.texture.type;\n\n\t\t\t},\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .type is now .texture.type.' );\n\t\t\t\tthis.texture.type = value;\n\n\t\t\t}\n\t\t},\n\t\tgenerateMipmaps: {\n\t\t\tget: function () {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.' );\n\t\t\t\treturn this.texture.generateMipmaps;\n\n\t\t\t},\n\t\t\tset: function ( value ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.' );\n\t\t\t\tthis.texture.generateMipmaps = value;\n\n\t\t\t}\n\t\t}\n\n\t} );\n\n\t//\n\n\tObject.defineProperties( WebVRManager.prototype, {\n\n\t\tstanding: {\n\t\t\tset: function ( /* value */ ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebVRManager: .standing has been removed.' );\n\n\t\t\t}\n\t\t},\n\t\tuserHeight: {\n\t\t\tset: function ( /* value */ ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebVRManager: .userHeight has been removed.' );\n\n\t\t\t}\n\t\t}\n\n\t} );\n\n\t//\n\n\tAudio.prototype.load = function ( file ) {\n\n\t\tconsole.warn( 'THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.' );\n\t\tvar scope = this;\n\t\tvar audioLoader = new AudioLoader();\n\t\taudioLoader.load( file, function ( buffer ) {\n\n\t\t\tscope.setBuffer( buffer );\n\n\t\t} );\n\t\treturn this;\n\n\t};\n\n\tAudioAnalyser.prototype.getData = function () {\n\n\t\tconsole.warn( 'THREE.AudioAnalyser: .getData() is now .getFrequencyData().' );\n\t\treturn this.getFrequencyData();\n\n\t};\n\n\t//\n\n\tCubeCamera.prototype.updateCubeMap = function ( renderer, scene ) {\n\n\t\tconsole.warn( 'THREE.CubeCamera: .updateCubeMap() is now .update().' );\n\t\treturn this.update( renderer, scene );\n\n\t};\n\n\t//\n\n\tvar GeometryUtils = {\n\n\t\tmerge: function ( geometry1, geometry2, materialIndexOffset ) {\n\n\t\t\tconsole.warn( 'THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.' );\n\t\t\tvar matrix;\n\n\t\t\tif ( geometry2.isMesh ) {\n\n\t\t\t\tgeometry2.matrixAutoUpdate && geometry2.updateMatrix();\n\n\t\t\t\tmatrix = geometry2.matrix;\n\t\t\t\tgeometry2 = geometry2.geometry;\n\n\t\t\t}\n\n\t\t\tgeometry1.merge( geometry2, matrix, materialIndexOffset );\n\n\t\t},\n\n\t\tcenter: function ( geometry ) {\n\n\t\t\tconsole.warn( 'THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead.' );\n\t\t\treturn geometry.center();\n\n\t\t}\n\n\t};\n\n\tImageUtils.crossOrigin = undefined;\n\n\tImageUtils.loadTexture = function ( url, mapping, onLoad, onError ) {\n\n\t\tconsole.warn( 'THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.' );\n\n\t\tvar loader = new TextureLoader();\n\t\tloader.setCrossOrigin( this.crossOrigin );\n\n\t\tvar texture = loader.load( url, onLoad, undefined, onError );\n\n\t\tif ( mapping ) texture.mapping = mapping;\n\n\t\treturn texture;\n\n\t};\n\n\tImageUtils.loadTextureCube = function ( urls, mapping, onLoad, onError ) {\n\n\t\tconsole.warn( 'THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.' );\n\n\t\tvar loader = new CubeTextureLoader();\n\t\tloader.setCrossOrigin( this.crossOrigin );\n\n\t\tvar texture = loader.load( urls, onLoad, undefined, onError );\n\n\t\tif ( mapping ) texture.mapping = mapping;\n\n\t\treturn texture;\n\n\t};\n\n\tImageUtils.loadCompressedTexture = function () {\n\n\t\tconsole.error( 'THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.' );\n\n\t};\n\n\tImageUtils.loadCompressedTextureCube = function () {\n\n\t\tconsole.error( 'THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.' );\n\n\t};\n\n\t//\n\n\tfunction Projector() {\n\n\t\tconsole.error( 'THREE.Projector has been moved to /examples/js/renderers/Projector.js.' );\n\n\t\tthis.projectVector = function ( vector, camera ) {\n\n\t\t\tconsole.warn( 'THREE.Projector: .projectVector() is now vector.project().' );\n\t\t\tvector.project( camera );\n\n\t\t};\n\n\t\tthis.unprojectVector = function ( vector, camera ) {\n\n\t\t\tconsole.warn( 'THREE.Projector: .unprojectVector() is now vector.unproject().' );\n\t\t\tvector.unproject( camera );\n\n\t\t};\n\n\t\tthis.pickingRay = function () {\n\n\t\t\tconsole.error( 'THREE.Projector: .pickingRay() is now raycaster.setFromCamera().' );\n\n\t\t};\n\n\t}\n\n\t//\n\n\tfunction CanvasRenderer() {\n\n\t\tconsole.error( 'THREE.CanvasRenderer has been removed' );\n\n\t}\n\n\t//\n\n\tfunction JSONLoader() {\n\n\t\tconsole.error( 'THREE.JSONLoader has been removed.' );\n\n\t}\n\n\t//\n\n\tvar SceneUtils = {\n\n\t\tcreateMultiMaterialObject: function ( /* geometry, materials */ ) {\n\n\t\t\tconsole.error( 'THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js' );\n\n\t\t},\n\n\t\tdetach: function ( /* child, parent, scene */ ) {\n\n\t\t\tconsole.error( 'THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js' );\n\n\t\t},\n\n\t\tattach: function ( /* child, scene, parent */ ) {\n\n\t\t\tconsole.error( 'THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js' );\n\n\t\t}\n\n\t};\n\n\t//\n\n\tfunction LensFlare() {\n\n\t\tconsole.error( 'THREE.LensFlare has been moved to /examples/js/objects/Lensflare.js' );\n\n\t}\n\n\texports.WebGLRenderTargetCube = WebGLRenderTargetCube;\n\texports.WebGLRenderTarget = WebGLRenderTarget;\n\texports.WebGLRenderer = WebGLRenderer;\n\texports.ShaderLib = ShaderLib;\n\texports.UniformsLib = UniformsLib;\n\texports.UniformsUtils = UniformsUtils;\n\texports.ShaderChunk = ShaderChunk;\n\texports.FogExp2 = FogExp2;\n\texports.Fog = Fog;\n\texports.Scene = Scene;\n\texports.Sprite = Sprite;\n\texports.LOD = LOD;\n\texports.SkinnedMesh = SkinnedMesh;\n\texports.Skeleton = Skeleton;\n\texports.Bone = Bone;\n\texports.Mesh = Mesh;\n\texports.LineSegments = LineSegments;\n\texports.LineLoop = LineLoop;\n\texports.Line = Line;\n\texports.Points = Points;\n\texports.Group = Group;\n\texports.VideoTexture = VideoTexture;\n\texports.DataTexture = DataTexture;\n\texports.DataTexture3D = DataTexture3D;\n\texports.CompressedTexture = CompressedTexture;\n\texports.CubeTexture = CubeTexture;\n\texports.CanvasTexture = CanvasTexture;\n\texports.DepthTexture = DepthTexture;\n\texports.Texture = Texture;\n\texports.AnimationLoader = AnimationLoader;\n\texports.CompressedTextureLoader = CompressedTextureLoader;\n\texports.DataTextureLoader = DataTextureLoader;\n\texports.CubeTextureLoader = CubeTextureLoader;\n\texports.TextureLoader = TextureLoader;\n\texports.ObjectLoader = ObjectLoader;\n\texports.MaterialLoader = MaterialLoader;\n\texports.BufferGeometryLoader = BufferGeometryLoader;\n\texports.DefaultLoadingManager = DefaultLoadingManager;\n\texports.LoadingManager = LoadingManager;\n\texports.ImageLoader = ImageLoader;\n\texports.ImageBitmapLoader = ImageBitmapLoader;\n\texports.FontLoader = FontLoader;\n\texports.FileLoader = FileLoader;\n\texports.Loader = Loader;\n\texports.LoaderUtils = LoaderUtils;\n\texports.Cache = Cache;\n\texports.AudioLoader = AudioLoader;\n\texports.SpotLightShadow = SpotLightShadow;\n\texports.SpotLight = SpotLight;\n\texports.PointLight = PointLight;\n\texports.RectAreaLight = RectAreaLight;\n\texports.HemisphereLight = HemisphereLight;\n\texports.DirectionalLightShadow = DirectionalLightShadow;\n\texports.DirectionalLight = DirectionalLight;\n\texports.AmbientLight = AmbientLight;\n\texports.LightShadow = LightShadow;\n\texports.Light = Light;\n\texports.StereoCamera = StereoCamera;\n\texports.PerspectiveCamera = PerspectiveCamera;\n\texports.OrthographicCamera = OrthographicCamera;\n\texports.CubeCamera = CubeCamera;\n\texports.ArrayCamera = ArrayCamera;\n\texports.Camera = Camera;\n\texports.AudioListener = AudioListener;\n\texports.PositionalAudio = PositionalAudio;\n\texports.AudioContext = AudioContext;\n\texports.AudioAnalyser = AudioAnalyser;\n\texports.Audio = Audio;\n\texports.VectorKeyframeTrack = VectorKeyframeTrack;\n\texports.StringKeyframeTrack = StringKeyframeTrack;\n\texports.QuaternionKeyframeTrack = QuaternionKeyframeTrack;\n\texports.NumberKeyframeTrack = NumberKeyframeTrack;\n\texports.ColorKeyframeTrack = ColorKeyframeTrack;\n\texports.BooleanKeyframeTrack = BooleanKeyframeTrack;\n\texports.PropertyMixer = PropertyMixer;\n\texports.PropertyBinding = PropertyBinding;\n\texports.KeyframeTrack = KeyframeTrack;\n\texports.AnimationUtils = AnimationUtils;\n\texports.AnimationObjectGroup = AnimationObjectGroup;\n\texports.AnimationMixer = AnimationMixer;\n\texports.AnimationClip = AnimationClip;\n\texports.Uniform = Uniform;\n\texports.InstancedBufferGeometry = InstancedBufferGeometry;\n\texports.BufferGeometry = BufferGeometry;\n\texports.Geometry = Geometry;\n\texports.InterleavedBufferAttribute = InterleavedBufferAttribute;\n\texports.InstancedInterleavedBuffer = InstancedInterleavedBuffer;\n\texports.InterleavedBuffer = InterleavedBuffer;\n\texports.InstancedBufferAttribute = InstancedBufferAttribute;\n\texports.Face3 = Face3;\n\texports.Object3D = Object3D;\n\texports.Raycaster = Raycaster;\n\texports.Layers = Layers;\n\texports.EventDispatcher = EventDispatcher;\n\texports.Clock = Clock;\n\texports.QuaternionLinearInterpolant = QuaternionLinearInterpolant;\n\texports.LinearInterpolant = LinearInterpolant;\n\texports.DiscreteInterpolant = DiscreteInterpolant;\n\texports.CubicInterpolant = CubicInterpolant;\n\texports.Interpolant = Interpolant;\n\texports.Triangle = Triangle;\n\texports.Math = _Math;\n\texports.Spherical = Spherical;\n\texports.Cylindrical = Cylindrical;\n\texports.Plane = Plane;\n\texports.Frustum = Frustum;\n\texports.Sphere = Sphere;\n\texports.Ray = Ray;\n\texports.Matrix4 = Matrix4;\n\texports.Matrix3 = Matrix3;\n\texports.Box3 = Box3;\n\texports.Box2 = Box2;\n\texports.Line3 = Line3;\n\texports.Euler = Euler;\n\texports.Vector4 = Vector4;\n\texports.Vector3 = Vector3;\n\texports.Vector2 = Vector2;\n\texports.Quaternion = Quaternion;\n\texports.Color = Color;\n\texports.ImmediateRenderObject = ImmediateRenderObject;\n\texports.VertexNormalsHelper = VertexNormalsHelper;\n\texports.SpotLightHelper = SpotLightHelper;\n\texports.SkeletonHelper = SkeletonHelper;\n\texports.PointLightHelper = PointLightHelper;\n\texports.RectAreaLightHelper = RectAreaLightHelper;\n\texports.HemisphereLightHelper = HemisphereLightHelper;\n\texports.GridHelper = GridHelper;\n\texports.PolarGridHelper = PolarGridHelper;\n\texports.FaceNormalsHelper = FaceNormalsHelper;\n\texports.DirectionalLightHelper = DirectionalLightHelper;\n\texports.CameraHelper = CameraHelper;\n\texports.BoxHelper = BoxHelper;\n\texports.Box3Helper = Box3Helper;\n\texports.PlaneHelper = PlaneHelper;\n\texports.ArrowHelper = ArrowHelper;\n\texports.AxesHelper = AxesHelper;\n\texports.Shape = Shape;\n\texports.Path = Path;\n\texports.ShapePath = ShapePath;\n\texports.Font = Font;\n\texports.CurvePath = CurvePath;\n\texports.Curve = Curve;\n\texports.ImageUtils = ImageUtils;\n\texports.ShapeUtils = ShapeUtils;\n\texports.WebGLUtils = WebGLUtils;\n\texports.WireframeGeometry = WireframeGeometry;\n\texports.ParametricGeometry = ParametricGeometry;\n\texports.ParametricBufferGeometry = ParametricBufferGeometry;\n\texports.TetrahedronGeometry = TetrahedronGeometry;\n\texports.TetrahedronBufferGeometry = TetrahedronBufferGeometry;\n\texports.OctahedronGeometry = OctahedronGeometry;\n\texports.OctahedronBufferGeometry = OctahedronBufferGeometry;\n\texports.IcosahedronGeometry = IcosahedronGeometry;\n\texports.IcosahedronBufferGeometry = IcosahedronBufferGeometry;\n\texports.DodecahedronGeometry = DodecahedronGeometry;\n\texports.DodecahedronBufferGeometry = DodecahedronBufferGeometry;\n\texports.PolyhedronGeometry = PolyhedronGeometry;\n\texports.PolyhedronBufferGeometry = PolyhedronBufferGeometry;\n\texports.TubeGeometry = TubeGeometry;\n\texports.TubeBufferGeometry = TubeBufferGeometry;\n\texports.TorusKnotGeometry = TorusKnotGeometry;\n\texports.TorusKnotBufferGeometry = TorusKnotBufferGeometry;\n\texports.TorusGeometry = TorusGeometry;\n\texports.TorusBufferGeometry = TorusBufferGeometry;\n\texports.TextGeometry = TextGeometry;\n\texports.TextBufferGeometry = TextBufferGeometry;\n\texports.SphereGeometry = SphereGeometry;\n\texports.SphereBufferGeometry = SphereBufferGeometry;\n\texports.RingGeometry = RingGeometry;\n\texports.RingBufferGeometry = RingBufferGeometry;\n\texports.PlaneGeometry = PlaneGeometry;\n\texports.PlaneBufferGeometry = PlaneBufferGeometry;\n\texports.LatheGeometry = LatheGeometry;\n\texports.LatheBufferGeometry = LatheBufferGeometry;\n\texports.ShapeGeometry = ShapeGeometry;\n\texports.ShapeBufferGeometry = ShapeBufferGeometry;\n\texports.ExtrudeGeometry = ExtrudeGeometry;\n\texports.ExtrudeBufferGeometry = ExtrudeBufferGeometry;\n\texports.EdgesGeometry = EdgesGeometry;\n\texports.ConeGeometry = ConeGeometry;\n\texports.ConeBufferGeometry = ConeBufferGeometry;\n\texports.CylinderGeometry = CylinderGeometry;\n\texports.CylinderBufferGeometry = CylinderBufferGeometry;\n\texports.CircleGeometry = CircleGeometry;\n\texports.CircleBufferGeometry = CircleBufferGeometry;\n\texports.BoxGeometry = BoxGeometry;\n\texports.BoxBufferGeometry = BoxBufferGeometry;\n\texports.ShadowMaterial = ShadowMaterial;\n\texports.SpriteMaterial = SpriteMaterial;\n\texports.RawShaderMaterial = RawShaderMaterial;\n\texports.ShaderMaterial = ShaderMaterial;\n\texports.PointsMaterial = PointsMaterial;\n\texports.MeshPhysicalMaterial = MeshPhysicalMaterial;\n\texports.MeshStandardMaterial = MeshStandardMaterial;\n\texports.MeshPhongMaterial = MeshPhongMaterial;\n\texports.MeshToonMaterial = MeshToonMaterial;\n\texports.MeshNormalMaterial = MeshNormalMaterial;\n\texports.MeshLambertMaterial = MeshLambertMaterial;\n\texports.MeshDepthMaterial = MeshDepthMaterial;\n\texports.MeshDistanceMaterial = MeshDistanceMaterial;\n\texports.MeshBasicMaterial = MeshBasicMaterial;\n\texports.MeshMatcapMaterial = MeshMatcapMaterial;\n\texports.LineDashedMaterial = LineDashedMaterial;\n\texports.LineBasicMaterial = LineBasicMaterial;\n\texports.Material = Material;\n\texports.Float64BufferAttribute = Float64BufferAttribute;\n\texports.Float32BufferAttribute = Float32BufferAttribute;\n\texports.Uint32BufferAttribute = Uint32BufferAttribute;\n\texports.Int32BufferAttribute = Int32BufferAttribute;\n\texports.Uint16BufferAttribute = Uint16BufferAttribute;\n\texports.Int16BufferAttribute = Int16BufferAttribute;\n\texports.Uint8ClampedBufferAttribute = Uint8ClampedBufferAttribute;\n\texports.Uint8BufferAttribute = Uint8BufferAttribute;\n\texports.Int8BufferAttribute = Int8BufferAttribute;\n\texports.BufferAttribute = BufferAttribute;\n\texports.ArcCurve = ArcCurve;\n\texports.CatmullRomCurve3 = CatmullRomCurve3;\n\texports.CubicBezierCurve = CubicBezierCurve;\n\texports.CubicBezierCurve3 = CubicBezierCurve3;\n\texports.EllipseCurve = EllipseCurve;\n\texports.LineCurve = LineCurve;\n\texports.LineCurve3 = LineCurve3;\n\texports.QuadraticBezierCurve = QuadraticBezierCurve;\n\texports.QuadraticBezierCurve3 = QuadraticBezierCurve3;\n\texports.SplineCurve = SplineCurve;\n\texports.REVISION = REVISION;\n\texports.MOUSE = MOUSE;\n\texports.CullFaceNone = CullFaceNone;\n\texports.CullFaceBack = CullFaceBack;\n\texports.CullFaceFront = CullFaceFront;\n\texports.CullFaceFrontBack = CullFaceFrontBack;\n\texports.FrontFaceDirectionCW = FrontFaceDirectionCW;\n\texports.FrontFaceDirectionCCW = FrontFaceDirectionCCW;\n\texports.BasicShadowMap = BasicShadowMap;\n\texports.PCFShadowMap = PCFShadowMap;\n\texports.PCFSoftShadowMap = PCFSoftShadowMap;\n\texports.FrontSide = FrontSide;\n\texports.BackSide = BackSide;\n\texports.DoubleSide = DoubleSide;\n\texports.FlatShading = FlatShading;\n\texports.SmoothShading = SmoothShading;\n\texports.NoColors = NoColors;\n\texports.FaceColors = FaceColors;\n\texports.VertexColors = VertexColors;\n\texports.NoBlending = NoBlending;\n\texports.NormalBlending = NormalBlending;\n\texports.AdditiveBlending = AdditiveBlending;\n\texports.SubtractiveBlending = SubtractiveBlending;\n\texports.MultiplyBlending = MultiplyBlending;\n\texports.CustomBlending = CustomBlending;\n\texports.AddEquation = AddEquation;\n\texports.SubtractEquation = SubtractEquation;\n\texports.ReverseSubtractEquation = ReverseSubtractEquation;\n\texports.MinEquation = MinEquation;\n\texports.MaxEquation = MaxEquation;\n\texports.ZeroFactor = ZeroFactor;\n\texports.OneFactor = OneFactor;\n\texports.SrcColorFactor = SrcColorFactor;\n\texports.OneMinusSrcColorFactor = OneMinusSrcColorFactor;\n\texports.SrcAlphaFactor = SrcAlphaFactor;\n\texports.OneMinusSrcAlphaFactor = OneMinusSrcAlphaFactor;\n\texports.DstAlphaFactor = DstAlphaFactor;\n\texports.OneMinusDstAlphaFactor = OneMinusDstAlphaFactor;\n\texports.DstColorFactor = DstColorFactor;\n\texports.OneMinusDstColorFactor = OneMinusDstColorFactor;\n\texports.SrcAlphaSaturateFactor = SrcAlphaSaturateFactor;\n\texports.NeverDepth = NeverDepth;\n\texports.AlwaysDepth = AlwaysDepth;\n\texports.LessDepth = LessDepth;\n\texports.LessEqualDepth = LessEqualDepth;\n\texports.EqualDepth = EqualDepth;\n\texports.GreaterEqualDepth = GreaterEqualDepth;\n\texports.GreaterDepth = GreaterDepth;\n\texports.NotEqualDepth = NotEqualDepth;\n\texports.MultiplyOperation = MultiplyOperation;\n\texports.MixOperation = MixOperation;\n\texports.AddOperation = AddOperation;\n\texports.NoToneMapping = NoToneMapping;\n\texports.LinearToneMapping = LinearToneMapping;\n\texports.ReinhardToneMapping = ReinhardToneMapping;\n\texports.Uncharted2ToneMapping = Uncharted2ToneMapping;\n\texports.CineonToneMapping = CineonToneMapping;\n\texports.ACESFilmicToneMapping = ACESFilmicToneMapping;\n\texports.UVMapping = UVMapping;\n\texports.CubeReflectionMapping = CubeReflectionMapping;\n\texports.CubeRefractionMapping = CubeRefractionMapping;\n\texports.EquirectangularReflectionMapping = EquirectangularReflectionMapping;\n\texports.EquirectangularRefractionMapping = EquirectangularRefractionMapping;\n\texports.SphericalReflectionMapping = SphericalReflectionMapping;\n\texports.CubeUVReflectionMapping = CubeUVReflectionMapping;\n\texports.CubeUVRefractionMapping = CubeUVRefractionMapping;\n\texports.RepeatWrapping = RepeatWrapping;\n\texports.ClampToEdgeWrapping = ClampToEdgeWrapping;\n\texports.MirroredRepeatWrapping = MirroredRepeatWrapping;\n\texports.NearestFilter = NearestFilter;\n\texports.NearestMipMapNearestFilter = NearestMipMapNearestFilter;\n\texports.NearestMipMapLinearFilter = NearestMipMapLinearFilter;\n\texports.LinearFilter = LinearFilter;\n\texports.LinearMipMapNearestFilter = LinearMipMapNearestFilter;\n\texports.LinearMipMapLinearFilter = LinearMipMapLinearFilter;\n\texports.UnsignedByteType = UnsignedByteType;\n\texports.ByteType = ByteType;\n\texports.ShortType = ShortType;\n\texports.UnsignedShortType = UnsignedShortType;\n\texports.IntType = IntType;\n\texports.UnsignedIntType = UnsignedIntType;\n\texports.FloatType = FloatType;\n\texports.HalfFloatType = HalfFloatType;\n\texports.UnsignedShort4444Type = UnsignedShort4444Type;\n\texports.UnsignedShort5551Type = UnsignedShort5551Type;\n\texports.UnsignedShort565Type = UnsignedShort565Type;\n\texports.UnsignedInt248Type = UnsignedInt248Type;\n\texports.AlphaFormat = AlphaFormat;\n\texports.RGBFormat = RGBFormat;\n\texports.RGBAFormat = RGBAFormat;\n\texports.LuminanceFormat = LuminanceFormat;\n\texports.LuminanceAlphaFormat = LuminanceAlphaFormat;\n\texports.RGBEFormat = RGBEFormat;\n\texports.DepthFormat = DepthFormat;\n\texports.DepthStencilFormat = DepthStencilFormat;\n\texports.RedFormat = RedFormat;\n\texports.RGB_S3TC_DXT1_Format = RGB_S3TC_DXT1_Format;\n\texports.RGBA_S3TC_DXT1_Format = RGBA_S3TC_DXT1_Format;\n\texports.RGBA_S3TC_DXT3_Format = RGBA_S3TC_DXT3_Format;\n\texports.RGBA_S3TC_DXT5_Format = RGBA_S3TC_DXT5_Format;\n\texports.RGB_PVRTC_4BPPV1_Format = RGB_PVRTC_4BPPV1_Format;\n\texports.RGB_PVRTC_2BPPV1_Format = RGB_PVRTC_2BPPV1_Format;\n\texports.RGBA_PVRTC_4BPPV1_Format = RGBA_PVRTC_4BPPV1_Format;\n\texports.RGBA_PVRTC_2BPPV1_Format = RGBA_PVRTC_2BPPV1_Format;\n\texports.RGB_ETC1_Format = RGB_ETC1_Format;\n\texports.RGBA_ASTC_4x4_Format = RGBA_ASTC_4x4_Format;\n\texports.RGBA_ASTC_5x4_Format = RGBA_ASTC_5x4_Format;\n\texports.RGBA_ASTC_5x5_Format = RGBA_ASTC_5x5_Format;\n\texports.RGBA_ASTC_6x5_Format = RGBA_ASTC_6x5_Format;\n\texports.RGBA_ASTC_6x6_Format = RGBA_ASTC_6x6_Format;\n\texports.RGBA_ASTC_8x5_Format = RGBA_ASTC_8x5_Format;\n\texports.RGBA_ASTC_8x6_Format = RGBA_ASTC_8x6_Format;\n\texports.RGBA_ASTC_8x8_Format = RGBA_ASTC_8x8_Format;\n\texports.RGBA_ASTC_10x5_Format = RGBA_ASTC_10x5_Format;\n\texports.RGBA_ASTC_10x6_Format = RGBA_ASTC_10x6_Format;\n\texports.RGBA_ASTC_10x8_Format = RGBA_ASTC_10x8_Format;\n\texports.RGBA_ASTC_10x10_Format = RGBA_ASTC_10x10_Format;\n\texports.RGBA_ASTC_12x10_Format = RGBA_ASTC_12x10_Format;\n\texports.RGBA_ASTC_12x12_Format = RGBA_ASTC_12x12_Format;\n\texports.LoopOnce = LoopOnce;\n\texports.LoopRepeat = LoopRepeat;\n\texports.LoopPingPong = LoopPingPong;\n\texports.InterpolateDiscrete = InterpolateDiscrete;\n\texports.InterpolateLinear = InterpolateLinear;\n\texports.InterpolateSmooth = InterpolateSmooth;\n\texports.ZeroCurvatureEnding = ZeroCurvatureEnding;\n\texports.ZeroSlopeEnding = ZeroSlopeEnding;\n\texports.WrapAroundEnding = WrapAroundEnding;\n\texports.TrianglesDrawMode = TrianglesDrawMode;\n\texports.TriangleStripDrawMode = TriangleStripDrawMode;\n\texports.TriangleFanDrawMode = TriangleFanDrawMode;\n\texports.LinearEncoding = LinearEncoding;\n\texports.sRGBEncoding = sRGBEncoding;\n\texports.GammaEncoding = GammaEncoding;\n\texports.RGBEEncoding = RGBEEncoding;\n\texports.LogLuvEncoding = LogLuvEncoding;\n\texports.RGBM7Encoding = RGBM7Encoding;\n\texports.RGBM16Encoding = RGBM16Encoding;\n\texports.RGBDEncoding = RGBDEncoding;\n\texports.BasicDepthPacking = BasicDepthPacking;\n\texports.RGBADepthPacking = RGBADepthPacking;\n\texports.TangentSpaceNormalMap = TangentSpaceNormalMap;\n\texports.ObjectSpaceNormalMap = ObjectSpaceNormalMap;\n\texports.CubeGeometry = BoxGeometry;\n\texports.Face4 = Face4;\n\texports.LineStrip = LineStrip;\n\texports.LinePieces = LinePieces;\n\texports.MeshFaceMaterial = MeshFaceMaterial;\n\texports.MultiMaterial = MultiMaterial;\n\texports.PointCloud = PointCloud;\n\texports.Particle = Particle;\n\texports.ParticleSystem = ParticleSystem;\n\texports.PointCloudMaterial = PointCloudMaterial;\n\texports.ParticleBasicMaterial = ParticleBasicMaterial;\n\texports.ParticleSystemMaterial = ParticleSystemMaterial;\n\texports.Vertex = Vertex;\n\texports.DynamicBufferAttribute = DynamicBufferAttribute;\n\texports.Int8Attribute = Int8Attribute;\n\texports.Uint8Attribute = Uint8Attribute;\n\texports.Uint8ClampedAttribute = Uint8ClampedAttribute;\n\texports.Int16Attribute = Int16Attribute;\n\texports.Uint16Attribute = Uint16Attribute;\n\texports.Int32Attribute = Int32Attribute;\n\texports.Uint32Attribute = Uint32Attribute;\n\texports.Float32Attribute = Float32Attribute;\n\texports.Float64Attribute = Float64Attribute;\n\texports.ClosedSplineCurve3 = ClosedSplineCurve3;\n\texports.SplineCurve3 = SplineCurve3;\n\texports.Spline = Spline;\n\texports.AxisHelper = AxisHelper;\n\texports.BoundingBoxHelper = BoundingBoxHelper;\n\texports.EdgesHelper = EdgesHelper;\n\texports.WireframeHelper = WireframeHelper;\n\texports.XHRLoader = XHRLoader;\n\texports.BinaryTextureLoader = BinaryTextureLoader;\n\texports.GeometryUtils = GeometryUtils;\n\texports.Projector = Projector;\n\texports.CanvasRenderer = CanvasRenderer;\n\texports.JSONLoader = JSONLoader;\n\texports.SceneUtils = SceneUtils;\n\texports.LensFlare = LensFlare;\n\n\tObject.defineProperty(exports, '__esModule', { value: true });\n\n})));\n"
  },
  {
    "path": "WebContent/js/shader-example-2d.js",
    "content": "window.onload = function() {\n\trunSketch();\n};\n\nfunction runSketch() {\n\tvar renderer, scene, camera, clock, stats, uniforms;\n\n\tinit();\n\tanimate();\n\n\t/*\n\t * Initializes the sketch\n\t */\n\tfunction init() {\n\t\t// Initialize the WebGL renderer\n\t\trenderer = new THREE.WebGLRenderer();\n\t\trenderer.setPixelRatio(window.devicePixelRatio);\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\n\t\t// Add the renderer to the sketch container\n\t\tvar container = document.getElementById(\"sketch-container\");\n\t\tcontainer.appendChild(renderer.domElement);\n\n\t\t// Initialize the scene\n\t\tscene = new THREE.Scene();\n\n\t\t// Initialize the camera\n\t\tcamera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);\n\n\t\t// Initialize the clock\n\t\tclock = new THREE.Clock(true);\n\n\t\t// Initialize the statistics monitor and add it to the sketch container\n\t\tstats = new Stats();\n\t\tstats.dom.style.cssText = \"\";\n\t\tdocument.getElementById(\"sketch-stats\").appendChild(stats.dom);\n\n\t\t// Create the plane geometry\n\t\tvar geometry = new THREE.PlaneBufferGeometry(2, 2);\n\n\t\t// Define the shader uniforms\n\t\tuniforms = {\n\t\t\tu_time : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 0.0\n\t\t\t},\n\t\t\tu_frame : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 0.0\n\t\t\t},\n\t\t\tu_resolution : {\n\t\t\t\ttype : \"v2\",\n\t\t\t\tvalue : new THREE.Vector2(window.innerWidth, window.innerHeight)\n\t\t\t\t\t\t.multiplyScalar(window.devicePixelRatio)\n\t\t\t},\n\t\t\tu_mouse : {\n\t\t\t\ttype : \"v2\",\n\t\t\t\tvalue : new THREE.Vector2(0.7 * window.innerWidth, window.innerHeight)\n\t\t\t\t\t\t.multiplyScalar(window.devicePixelRatio)\n\t\t\t}\n\t\t};\n\n\t\t// Create the shader material\n\t\tvar material = new THREE.ShaderMaterial({\n\t\t\tuniforms : uniforms,\n\t\t\tvertexShader : document.getElementById(\"vertexShader\").textContent,\n\t\t\tfragmentShader : document.getElementById(\"fragmentShader\").textContent\n\t\t});\n\n\t\t// Create the mesh and add it to the scene\n\t\tvar mesh = new THREE.Mesh(geometry, material);\n\t\tscene.add(mesh);\n\n\t\t// Add the event listeners\n\t\twindow.addEventListener(\"resize\", onWindowResize, false);\n\t\trenderer.domElement.addEventListener(\"mousemove\", onMouseMove, false);\n\t\trenderer.domElement.addEventListener(\"touchstart\", onTouchMove, false);\n\t\trenderer.domElement.addEventListener(\"touchmove\", onTouchMove, false);\n\t}\n\n\t/*\n\t * Animates the sketch\n\t */\n\tfunction animate() {\n\t\trequestAnimationFrame(animate);\n\t\trender();\n\t\tstats.update();\n\t}\n\n\t/*\n\t * Renders the sketch\n\t */\n\tfunction render() {\n\t\tuniforms.u_time.value = clock.getElapsedTime();\n\t\tuniforms.u_frame.value += 1.0;\n\t\trenderer.render(scene, camera);\n\t}\n\n\t/*\n\t * Updates the renderer size and the uniforms when the window is resized\n\t */\n\tfunction onWindowResize(event) {\n\t\t// Update the renderer\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\n\t\t// Update the resolution uniform\n\t\tuniforms.u_resolution.value.set(window.innerWidth, window.innerHeight).multiplyScalar(window.devicePixelRatio);\n\t}\n\n\t/*\n\t * Updates the uniforms when the mouse moves\n\t */\n\tfunction onMouseMove(event) {\n\t\t// Update the mouse uniform\n\t\tuniforms.u_mouse.value.set(event.pageX, window.innerHeight - event.pageY).multiplyScalar(\n\t\t\t\twindow.devicePixelRatio);\n\t}\n\n\t/*\n\t * Updates the uniforms when the touch moves\n\t */\n\tfunction onTouchMove(event) {\n\t\tevent.preventDefault();\n\n\t\t// Update the mouse uniform\n\t\tuniforms.u_mouse.value.set(event.touches[0].pageX, window.innerHeight - event.touches[0].pageY).multiplyScalar(\n\t\t\t\twindow.devicePixelRatio);\n\t}\n}"
  },
  {
    "path": "WebContent/js/shader-example-3d.js",
    "content": "window.onload = function() {\n\trunSketch();\n};\n\nfunction runSketch() {\n\tvar renderer, scene, camera, clock, stats, controlParameters, uniforms, material, mesh;\n\n\tinit();\n\tanimate();\n\n\t/*\n\t * Initializes the sketch\n\t */\n\tfunction init() {\n\t\t// Initialize the WebGL renderer\n\t\trenderer = new THREE.WebGLRenderer({\n\t\t\tantialias : true\n\t\t});\n\t\trenderer.setPixelRatio(window.devicePixelRatio);\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\t\trenderer.setClearColor(new THREE.Color(0, 0, 0));\n\n\t\t// Add the renderer to the sketch container\n\t\tvar container = document.getElementById(\"sketch-container\");\n\t\tcontainer.appendChild(renderer.domElement);\n\n\t\t// Initialize the scene\n\t\tscene = new THREE.Scene();\n\n\t\t// Initialize the camera\n\t\tcamera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 5000);\n\t\tcamera.position.z = 30;\n\n\t\t// Initialize the camera controls\n\t\tvar controls = new THREE.OrbitControls(camera, renderer.domElement);\n\t\tcontrols.enablePan = false;\n\n\t\t// Initialize the clock\n\t\tclock = new THREE.Clock(true);\n\n\t\t// Initialize the statistics monitor and add it to the sketch container\n\t\tstats = new Stats();\n\t\tstats.dom.style.cssText = \"\";\n\t\tdocument.getElementById(\"sketch-stats\").appendChild(stats.dom);\n\n\t\t// Initialize the control parameters\n\t\tcontrolParameters = {\n\t\t\t\"Geometry\" : \"Torus knot\"\n\t\t};\n\n\t\t// Add the control panel to the sketch\n\t\taddControlPanel();\n\n\t\t// Define the shader uniforms\n\t\tuniforms = {\n\t\t\tu_time : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 0.0\n\t\t\t},\n\t\t\tu_frame : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 0.0\n\t\t\t},\n\t\t\tu_resolution : {\n\t\t\t\ttype : \"v2\",\n\t\t\t\tvalue : new THREE.Vector2(window.innerWidth, window.innerHeight)\n\t\t\t\t\t\t.multiplyScalar(window.devicePixelRatio)\n\t\t\t},\n\t\t\tu_mouse : {\n\t\t\t\ttype : \"v2\",\n\t\t\t\tvalue : new THREE.Vector2(0.7 * window.innerWidth, window.innerHeight)\n\t\t\t\t\t\t.multiplyScalar(window.devicePixelRatio)\n\t\t\t}\n\t\t};\n\n\t\t// Create the shader material\n\t\tmaterial = new THREE.ShaderMaterial({\n\t\t\tuniforms : uniforms,\n\t\t\tvertexShader : document.getElementById(\"vertexShader\").textContent,\n\t\t\tfragmentShader : document.getElementById(\"fragmentShader\").textContent,\n\t\t\tside : THREE.DoubleSide,\n\t\t\ttransparent : true,\n\t\t\textensions : {\n\t\t\t\tderivatives : true\n\t\t\t}\n\t\t});\n\n\t\t// Create the mesh and add it to the scene\n\t\taddMeshToScene();\n\n\t\t// Add the event listeners\n\t\twindow.addEventListener(\"resize\", onWindowResize, false);\n\t\trenderer.domElement.addEventListener(\"mousemove\", onMouseMove, false);\n\t\trenderer.domElement.addEventListener(\"touchstart\", onTouchMove, false);\n\t\trenderer.domElement.addEventListener(\"touchmove\", onTouchMove, false);\n\t}\n\n\t/*\n\t * Adds the control panel to the sketch\n\t */\n\tfunction addControlPanel() {\n\t\t// Create the control panel\n\t\tvar controlPanel = new dat.GUI({\n\t\t\tautoPlace : false\n\t\t});\n\n\t\t// Add the controllers\n\t\tcontrolPanel.add(controlParameters, \"Geometry\", [ \"Torus knot\", \"Sphere\", \"Icosahedron\", \"Suzanne\" ])\n\t\t\t\t.onFinishChange(addMeshToScene);\n\n\t\t// Add the GUI to the correct DOM element\n\t\tdocument.getElementById(\"sketch-gui\").appendChild(controlPanel.domElement);\n\t}\n\n\t/*\n\t * Adds the mesh to the scene\n\t */\n\tfunction addMeshToScene() {\n\t\t// Remove any previous mesh from the scene\n\t\tif (mesh) {\n\t\t\tscene.remove(mesh);\n\t\t}\n\n\t\t// Handle all the different options\n\t\tif (controlParameters.Geometry == \"Suzanne\") {\n\t\t\t// Load the json file that contains the geometry\n\t\t\tvar loader = new THREE.BufferGeometryLoader();\n\t\t\tloader.load(\"/objects/suzanne_buffergeometry.json\", function(geometry) {\n\t\t\t\t// Scale the geometry\n\t\t\t\tgeometry.scale(10, 10, 10);\n\n\t\t\t\t// Calculate the vertex normals\n\t\t\t\tgeometry.computeVertexNormals();\n\n\t\t\t\t// Create the mesh and add it to the scene\n\t\t\t\tmesh = new THREE.Mesh(geometry, material);\n\t\t\t\tscene.add(mesh);\n\t\t\t});\n\t\t} else {\n\t\t\t// Create the desired geometry\n\t\t\tvar geometry;\n\n\t\t\tif (controlParameters.Geometry == \"Torus knot\") {\n\t\t\t\tgeometry = new THREE.TorusKnotGeometry(6.5, 2.3, 256, 32);\n\t\t\t} else if (controlParameters.Geometry == \"Sphere\") {\n\t\t\t\tgeometry = new THREE.SphereGeometry(10, 64, 64);\n\t\t\t} else if (controlParameters.Geometry == \"Icosahedron\") {\n\t\t\t\tgeometry = new THREE.IcosahedronGeometry(10, 0);\n\t\t\t}\n\n\t\t\t// Create the mesh and add it to the scene\n\t\t\tmesh = new THREE.Mesh(geometry, material);\n\t\t\tscene.add(mesh);\n\t\t}\n\t}\n\n\t/*\n\t * Animates the sketch\n\t */\n\tfunction animate() {\n\t\trequestAnimationFrame(animate);\n\t\trender();\n\t\tstats.update();\n\t}\n\n\t/*\n\t * Renders the sketch\n\t */\n\tfunction render() {\n\t\tuniforms.u_time.value = clock.getElapsedTime();\n\t\tuniforms.u_frame.value += 1.0;\n\t\trenderer.render(scene, camera);\n\t}\n\n\t/*\n\t * Updates the renderer size, the camera aspect ratio and the uniforms when the window is resized\n\t */\n\tfunction onWindowResize(event) {\n\t\t// Update the renderer\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\n\t\t// Update the camera\n\t\tcamera.aspect = window.innerWidth / window.innerHeight;\n\t\tcamera.updateProjectionMatrix();\n\n\t\t// Update the resolution uniform\n\t\tuniforms.u_resolution.value.set(window.innerWidth, window.innerHeight).multiplyScalar(window.devicePixelRatio);\n\t}\n\n\t/*\n\t * Updates the uniforms when the mouse moves\n\t */\n\tfunction onMouseMove(event) {\n\t\t// Update the mouse uniform\n\t\tuniforms.u_mouse.value.set(event.pageX, window.innerHeight - event.pageY).multiplyScalar(\n\t\t\t\twindow.devicePixelRatio);\n\t}\n\n\t/*\n\t * Updates the uniforms when the touch moves\n\t */\n\tfunction onTouchMove(event) {\n\t\t// Update the mouse uniform\n\t\tuniforms.u_mouse.value.set(event.touches[0].pageX, window.innerHeight - event.touches[0].pageY).multiplyScalar(\n\t\t\t\twindow.devicePixelRatio);\n\t}\n}\n"
  },
  {
    "path": "WebContent/js/shader-example-debug.js",
    "content": "window.onload = function() {\n\trunSketch();\n};\n\nfunction runSketch() {\n\tvar renderer, scene, camera, gpuSimulator, positionVariable, velocityVariable, uniforms;\n\n\tinit();\n\tanimate();\n\n\tfunction init() {\n\t\t// Initialize the WebGL renderer\n\t\trenderer = new THREE.WebGLRenderer({\n\t\t\tantialias : true\n\t\t});\n\t\trenderer.setPixelRatio(window.devicePixelRatio);\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\t\trenderer.setClearColor(new THREE.Color(0, 0, 0));\n\n\t\t// Add the renderer to the sketch container\n\t\tvar container = document.getElementById(\"sketch-container\");\n\t\tcontainer.appendChild(renderer.domElement);\n\n\t\t// Initialize the scene\n\t\tscene = new THREE.Scene();\n\n\t\t// Initialize the camera\n\t\tcamera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 5000);\n\t\tcamera.position.z = 20;\n\n\t\t// Initialize the simulator\n\t\tvar simSizeX = 64;\n\t\tvar simSizeY = 64;\n\t\tvar nParticles = simSizeX * simSizeY;\n\t\tgpuSimulator = new GPUComputationRenderer(simSizeX, simSizeY, renderer);\n\n\t\t// Create the position and the velocity textures\n\t\tvar positionTexture = gpuSimulator.createTexture();\n\t\tvar velocityTexture = gpuSimulator.createTexture();\n\n\t\t// Fill the texture data arrays with the simulation initial conditions\n\t\tvar position = positionTexture.image.data;\n\t\tvar velocity = velocityTexture.image.data;\n\n\t\tfor (var i = 0; i < nParticles; i++) {\n\t\t\tvar particleIndex = 4 * i;\n\t\t\tvar distance = 3 * Math.sqrt(Math.random());\n\t\t\tvar ang = 2 * Math.PI * Math.random();\n\t\t\tposition[particleIndex] = distance * Math.cos(ang);\n\t\t\tposition[particleIndex + 1] = distance * Math.sin(ang);\n\t\t\tposition[particleIndex + 2] = 0;\n\t\t\tposition[particleIndex + 3] = 1;\n\t\t\tvelocity[particleIndex] = -0.01 * Math.sin(ang);\n\t\t\tvelocity[particleIndex + 1] = 0.01 * Math.cos(ang);\n\t\t\tvelocity[particleIndex + 2] = 0;\n\t\t\tvelocity[particleIndex + 3] = 1;\n\t\t}\n\n\t\t// Add the position and velocity variables to the simulator\n\t\tpositionVariable = gpuSimulator.addVariable(\"u_positionTexture\",\n\t\t\t\tdocument.getElementById(\"positionShader\").textContent, positionTexture);\n\t\tvelocityVariable = gpuSimulator.addVariable(\"u_velocityTexture\",\n\t\t\t\tdocument.getElementById(\"velocityShader\").textContent, velocityTexture);\n\n\t\t// Specify the variable dependencies\n\t\tgpuSimulator.setVariableDependencies(positionVariable, [ positionVariable, velocityVariable ]);\n\t\tgpuSimulator.setVariableDependencies(velocityVariable, [ positionVariable, velocityVariable ]);\n\n\t\t// Initialize the GPU simulator\n\t\tvar error = gpuSimulator.init();\n\n\t\tif (error !== null) {\n\t\t\tconsole.error(error);\n\t\t}\n\n\t\t// Create the particles geometry\n\t\tvar geometry = new THREE.BufferGeometry();\n\n\t\t// Add the particle attributes to the geometry\n\t\tvar indices = new Float32Array(nParticles);\n\t\tvar positions = new Float32Array(3 * nParticles);\n\t\tgeometry.addAttribute(\"a_index\", new THREE.BufferAttribute(indices, 1));\n\t\tgeometry.addAttribute(\"position\", new THREE.BufferAttribute(positions, 3));\n\n\t\tfor (i = 0; i < nParticles; i++) {\n\t\t\tindices[i] = i;\n\t\t\tpositions[3 * i] = 0;\n\t\t\tpositions[3 * i + 1] = 0;\n\t\t\tpositions[3 * i + 2] = 0;\n\t\t}\n\n\t\t// Define the particle shader uniforms\n\t\tuniforms = {\n\t\t\tu_width : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : simSizeX\n\t\t\t},\n\t\t\tu_height : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : simSizeY\n\t\t\t},\n\t\t\tu_positionTexture : {\n\t\t\t\ttype : \"t\",\n\t\t\t\tvalue : null\n\t\t\t}\n\t\t};\n\n\t\t// Create the particles shader material\n\t\tvar material = new THREE.ShaderMaterial({\n\t\t\tuniforms : uniforms,\n\t\t\tvertexShader : document.getElementById(\"vertexShader\").textContent,\n\t\t\tfragmentShader : document.getElementById(\"fragmentShader\").textContent\n\t\t});\n\n\t\t// Create the particles and add them to the scene\n\t\tvar particles = new THREE.Points(geometry, material);\n\t\tscene.add(particles);\n\t}\n\n\tfunction animate() {\n\t\trequestAnimationFrame(animate);\n\t\trender();\n\t}\n\n\tfunction render() {\n\t\tgpuSimulator.compute();\n\t\tuniforms.u_positionTexture.value = gpuSimulator.getCurrentRenderTarget(positionVariable).texture;\n\t\trenderer.render(scene, camera);\n\t}\n}\n"
  },
  {
    "path": "WebContent/js/shader-example-dla.js",
    "content": "window.onload = function() {\n\trunSketch();\n};\n\nfunction runSketch() {\n\tvar renderer, scene, camera, clock, stats, simulator, positionVariable, uniforms;\n\n\tinit();\n\tanimate();\n\n\t/*\n\t * Initializes the sketch\n\t */\n\tfunction init() {\n\t\t// Initialize the WebGL renderer\n\t\trenderer = new THREE.WebGLRenderer({\n\t\t\tantialias : true\n\t\t});\n\t\trenderer.setPixelRatio(window.devicePixelRatio);\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\t\trenderer.setClearColor(new THREE.Color(0, 0, 0));\n\n\t\t// Add the renderer to the sketch container\n\t\tvar container = document.getElementById(\"sketch-container\");\n\t\tcontainer.appendChild(renderer.domElement);\n\n\t\t// Initialize the scene\n\t\tscene = new THREE.Scene();\n\n\t\t// Initialize the camera\n\t\tcamera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 5000);\n\t\tcamera.position.z = 10;\n\n\t\t// Initialize the camera controls\n\t\tvar controls = new THREE.OrbitControls(camera, renderer.domElement);\n\t\tcontrols.enableRotate = false;\n\t\tcontrols.enablePan = false;\n\n\t\t// Initialize the clock\n\t\tclock = new THREE.Clock(true);\n\n\t\t// Initialize the statistics monitor and add it to the sketch container\n\t\tstats = new Stats();\n\t\tstats.dom.style.cssText = \"\";\n\t\tdocument.getElementById(\"sketch-stats\").appendChild(stats.dom);\n\n\t\t// Initialize the simulator\n\t\tvar isDesktop = Math.min(window.innerWidth, window.innerHeight) > 450;\n\t\tvar simSizeX = isDesktop ? 2 * 64 : 64;\n\t\tvar simSizeY = isDesktop ? 64 : 64;\n\t\tsimulator = getSimulator(simSizeX, simSizeY, renderer);\n\t\tpositionVariable = getSimulationVariable(\"u_positionTexture\", simulator);\n\n\t\t// Create the particles geometry\n\t\tvar geometry = new THREE.BufferGeometry();\n\n\t\t// Add the particle attributes to the geometry\n\t\tvar nParticles = simSizeX * simSizeY;\n\t\tvar indices = new Float32Array(nParticles);\n\t\tvar positions = new Float32Array(3 * nParticles);\n\t\tgeometry.addAttribute(\"a_index\", new THREE.BufferAttribute(indices, 1));\n\t\tgeometry.addAttribute(\"position\", new THREE.BufferAttribute(positions, 3));\n\n\t\t// Fill the indices attribute. It's not necessary to fill the positions\n\t\t// attribute because it's not used in the shaders (the position texture is\n\t\t// used instead)\n\t\tfor (var i = 0; i < nParticles; i++) {\n\t\t\tindices[i] = i;\n\t\t}\n\n\t\t// Define the particle shader uniforms\n\t\tuniforms = {\n\t\t\tu_width : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : simSizeX\n\t\t\t},\n\t\t\tu_height : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : simSizeY\n\t\t\t},\n\t\t\tu_particleSize : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 40 * Math.min(window.devicePixelRatio, 2)\n\t\t\t},\n\t\t\tu_positionTexture : {\n\t\t\t\ttype : \"t\",\n\t\t\t\tvalue : null\n\t\t\t},\n\t\t\tu_texture : {\n\t\t\t\ttype : \"t\",\n\t\t\t\tvalue : new THREE.TextureLoader().load(\"img/particle2.png\")\n\t\t\t}\n\t\t};\n\n\t\t// Create the particles shader material\n\t\tvar material = new THREE.ShaderMaterial({\n\t\t\tuniforms : uniforms,\n\t\t\tvertexShader : document.getElementById(\"vertexShader\").textContent,\n\t\t\tfragmentShader : document.getElementById(\"fragmentShader\").textContent,\n\t\t\tdepthTest : false,\n\t\t\tlights : false,\n\t\t\ttransparent : false,\n\t\t\tblending : THREE.AdditiveBlending\n\t\t});\n\n\t\t// Create the particles and add them to the scene\n\t\tvar particles = new THREE.Points(geometry, material);\n\t\tscene.add(particles);\n\n\t\t// Add the event listeners\n\t\twindow.addEventListener(\"resize\", onWindowResize, false);\n\t}\n\n\t/*\n\t * Initializes and returns the GPU simulator\n\t */\n\tfunction getSimulator(simSizeX, simSizeY, renderer) {\n\t\t// Create a new GPU simulator instance\n\t\tvar gpuSimulator = new GPUComputationRenderer(simSizeX, simSizeY, renderer);\n\n\t\t// Create the position texture\n\t\tvar positionTexture = gpuSimulator.createTexture();\n\n\t\t// Fill the texture data array with the simulation initial conditions\n\t\tvar maxDistance = 6;\n\t\tsetInitialConditions(positionTexture, maxDistance);\n\n\t\t// Add the position variable to the simulator\n\t\tvar positionVariable = gpuSimulator.addVariable(\"u_positionTexture\",\n\t\t\t\tdocument.getElementById(\"positionShader\").textContent, positionTexture);\n\n\t\t// Specify the variable dependencies\n\t\tgpuSimulator.setVariableDependencies(positionVariable, [ positionVariable ]);\n\n\t\t// Add the position uniforms\n\t\tvar positionUniforms = positionVariable.material.uniforms;\n\t\tpositionUniforms.u_minDistance = {\n\t\t\ttype : \"f\",\n\t\t\tvalue : 0.07\n\t\t};\n\t\tpositionUniforms.u_maxDistance = {\n\t\t\ttype : \"f\",\n\t\t\tvalue : maxDistance\n\t\t};\n\t\tpositionUniforms.u_time = {\n\t\t\ttype : \"f\",\n\t\t\tvalue : 0\n\t\t};\n\n\t\t// Initialize the GPU simulator\n\t\tvar error = gpuSimulator.init();\n\n\t\tif (error !== null) {\n\t\t\tconsole.error(error);\n\t\t}\n\n\t\treturn gpuSimulator;\n\t}\n\n\t/*\n\t * Sets the simulation initial conditions\n\t */\n\tfunction setInitialConditions(positionTexture, maxDistance) {\n\t\t// Get the position array\n\t\tvar position = positionTexture.image.data;\n\n\t\t// The first particle will be the aggregation seed\n\t\tposition[0] = 0;\n\t\tposition[1] = 0;\n\t\tposition[2] = 0;\n\t\tposition[3] = -1;\n\n\t\t// Fill the rest of the position array\n\t\tvar nParticles = position.length / 4;\n\n\t\tfor (var i = 1; i < nParticles; i++) {\n\t\t\t// Get a random position inside a disk\n\t\t\tvar distance = maxDistance * Math.sqrt(Math.random());\n\t\t\tvar ang = 2 * Math.PI * Math.random();\n\n\t\t\t// Calculate the particle x,y,z coordinates\n\t\t\tvar particleIndex = 4 * i;\n\t\t\tposition[particleIndex] = distance * Math.cos(ang);\n\t\t\tposition[particleIndex + 1] = distance * Math.sin(ang);\n\t\t\tposition[particleIndex + 2] = 0;\n\t\t\tposition[particleIndex + 3] = 1;\n\t\t}\n\t}\n\n\t/*\n\t * Returns the requested simulation variable\n\t */\n\tfunction getSimulationVariable(variableName, gpuSimulator) {\n\t\tfor (var i = 0; i < gpuSimulator.variables.length; i++) {\n\t\t\tif (gpuSimulator.variables[i].name === variableName) {\n\t\t\t\treturn gpuSimulator.variables[i];\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/*\n\t * Animates the sketch\n\t */\n\tfunction animate() {\n\t\trequestAnimationFrame(animate);\n\t\trender();\n\t\tstats.update();\n\t}\n\n\t/*\n\t * Renders the sketch\n\t */\n\tfunction render() {\n\t\t// Run several iterations per frame\n\t\tfor (var i = 0; i < 1; i++) {\n\t\t\t// Update the position variable uniforms\n\t\t\tpositionVariable.material.uniforms.u_time.value = clock.getElapsedTime();\n\n\t\t\t// Compute the next simulation step\n\t\t\tsimulator.compute();\n\t\t}\n\n\t\t// Update the uniforms\n\t\tuniforms.u_positionTexture.value = simulator.getCurrentRenderTarget(positionVariable).texture;\n\n\t\t// Render the particles on the screen\n\t\trenderer.render(scene, camera);\n\t}\n\n\t/*\n\t * Updates the renderer size and the camera aspect ratio when the window is resized\n\t */\n\tfunction onWindowResize(event) {\n\t\t// Update the renderer\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\n\t\t// Update the camera\n\t\tcamera.aspect = window.innerWidth / window.innerHeight;\n\t\tcamera.updateProjectionMatrix();\n\t}\n}\n"
  },
  {
    "path": "WebContent/js/shader-example-evolve.js",
    "content": "window.onload = function() {\n\trunSketch();\n};\n\nfunction runSketch() {\n\tvar renderer, renderTarget1, renderTarget2, sceneShader, sceneScreen, camera, clock, stats, uniforms, materialScreen;\n\n\tinit();\n\tanimate();\n\n\t/*\n\t * Initializes the sketch\n\t */\n\tfunction init() {\n\t\t// Initialize the WebGL renderer\n\t\trenderer = new THREE.WebGLRenderer();\n\t\trenderer.setPixelRatio(window.devicePixelRatio);\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\t\trenderer.setClearColor(new THREE.Color(0, 0, 0));\n\n\t\t// Add the renderer to the sketch container\n\t\tvar container = document.getElementById(\"sketch-container\");\n\t\tcontainer.appendChild(renderer.domElement);\n\n\t\t// Initialize the render targets\n\t\tvar size = renderer.getDrawingBufferSize();\n\t\tvar options = {\n\t\t\tminFilter : THREE.NearestFilter,\n\t\t\tmagFilter : THREE.NearestFilter,\n\t\t\tformat : THREE.RGBAFormat,\n\t\t\ttype : /(iPad|iPhone|iPod)/g.test(navigator.userAgent) ? THREE.HalfFloatType : THREE.FloatType\n\t\t};\n\t\trenderTarget1 = new THREE.WebGLRenderTarget(size.width, size.height, options);\n\t\trenderTarget2 = new THREE.WebGLRenderTarget(size.width, size.height, options);\n\n\t\t// Initialize the scenes\n\t\tsceneShader = new THREE.Scene();\n\t\tsceneScreen = new THREE.Scene();\n\n\t\t// Initialize the camera\n\t\tcamera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);\n\n\t\t// Initialize the clock\n\t\tclock = new THREE.Clock(true);\n\n\t\t// Initialize the statistics monitor and add it to the sketch container\n\t\tstats = new Stats();\n\t\tstats.dom.style.cssText = \"\";\n\t\tdocument.getElementById(\"sketch-stats\").appendChild(stats.dom);\n\n\t\t// Create the plane geometry\n\t\tvar geometry = new THREE.PlaneBufferGeometry(2, 2);\n\n\t\t// Define the shader uniforms\n\t\tuniforms = {\n\t\t\tu_time : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 0.0\n\t\t\t},\n\t\t\tu_frame : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 0.0\n\t\t\t},\n\t\t\tu_resolution : {\n\t\t\t\ttype : \"v2\",\n\t\t\t\tvalue : new THREE.Vector2(window.innerWidth, window.innerHeight)\n\t\t\t\t\t\t.multiplyScalar(window.devicePixelRatio)\n\t\t\t},\n\t\t\tu_mouse : {\n\t\t\t\ttype : \"v2\",\n\t\t\t\tvalue : new THREE.Vector2(0.7 * window.innerWidth, window.innerHeight)\n\t\t\t\t\t\t.multiplyScalar(window.devicePixelRatio)\n\t\t\t},\n\t\t\tu_texture : {\n\t\t\t\ttype : \"t\",\n\t\t\t\tvalue : null\n\t\t\t}\n\t\t};\n\n\t\t// Create the shader material\n\t\tvar materialShader = new THREE.ShaderMaterial({\n\t\t\tuniforms : uniforms,\n\t\t\tvertexShader : document.getElementById(\"vertexShader\").textContent,\n\t\t\tfragmentShader : document.getElementById(\"fragmentShader\").textContent\n\t\t});\n\n\t\t// Create the screen material\n\t\tmaterialScreen = new THREE.MeshBasicMaterial();\n\n\t\t// Create the meshes and add them to the scenes\n\t\tvar meshShader = new THREE.Mesh(geometry, materialShader);\n\t\tvar meshScreen = new THREE.Mesh(geometry, materialScreen);\n\t\tsceneShader.add(meshShader);\n\t\tsceneScreen.add(meshScreen);\n\n\t\t// Add the event listeners\n\t\twindow.addEventListener(\"resize\", onWindowResize, false);\n\t\trenderer.domElement.addEventListener(\"mousemove\", onMouseMove, false);\n\t\trenderer.domElement.addEventListener(\"touchstart\", onTouchMove, false);\n\t\trenderer.domElement.addEventListener(\"touchmove\", onTouchMove, false);\n\t}\n\n\t/*\n\t * Animates the sketch\n\t */\n\tfunction animate() {\n\t\trequestAnimationFrame(animate);\n\t\trender();\n\t\tstats.update();\n\t}\n\n\t/*\n\t * Renders the sketch\n\t */\n\tfunction render() {\n\t\t// Start rendering an empty screen scene on the first render target\n\t\tif (!uniforms.u_texture.value) {\n\t\t\tmaterialScreen.visible = false;\n\t\t\trenderer.render(sceneScreen, camera, renderTarget1);\n\t\t\tmaterialScreen.visible = true;\n\t\t}\n\n\t\t// Update the uniforms\n\t\tuniforms.u_time.value = clock.getElapsedTime();\n\t\tuniforms.u_frame.value += 1.0;\n\t\tuniforms.u_texture.value = renderTarget1.texture;\n\n\t\t// Render the shader scene\n\t\trenderer.render(sceneShader, camera, renderTarget2);\n\n\t\t// Update the screen material texture\n\t\tmaterialScreen.map = renderTarget2.texture;\n\t\tmaterialScreen.needsUpdate = true;\n\n\t\t// Render the screen scene\n\t\trenderer.render(sceneScreen, camera);\n\n\t\t// Swap the render targets\n\t\tvar tmp = renderTarget1;\n\t\trenderTarget1 = renderTarget2;\n\t\trenderTarget2 = tmp;\n\t}\n\n\t/*\n\t * Updates the renderer size and the uniforms when the window is resized\n\t */\n\tfunction onWindowResize(event) {\n\t\t// Update the renderer\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\n\t\t// Update the render targets\n\t\tvar size = renderer.getDrawingBufferSize();\n\t\trenderTarget1.setSize(size.width, size.height);\n\t\trenderTarget2.setSize(size.width, size.height);\n\n\t\t// Update the uniforms\n\t\tuniforms.u_resolution.value.set(window.innerWidth, window.innerHeight).multiplyScalar(window.devicePixelRatio);\n\t\tuniforms.u_texture.value = null;\n\n\t\t// Update the screen material texture\n\t\tmaterialScreen.map = null;\n\t\tmaterialScreen.needsUpdate = true;\n\t}\n\n\t/*\n\t * Updates the uniforms when the mouse moves\n\t */\n\tfunction onMouseMove(event) {\n\t\t// Update the mouse uniform\n\t\tuniforms.u_mouse.value.set(event.pageX, window.innerHeight - event.pageY).multiplyScalar(\n\t\t\t\twindow.devicePixelRatio);\n\t}\n\n\t/*\n\t * Updates the uniforms when the touch moves\n\t */\n\tfunction onTouchMove(event) {\n\t\tevent.preventDefault();\n\n\t\t// Update the mouse uniform\n\t\tuniforms.u_mouse.value.set(event.touches[0].pageX, window.innerHeight - event.touches[0].pageY).multiplyScalar(\n\t\t\t\twindow.devicePixelRatio);\n\t}\n}"
  },
  {
    "path": "WebContent/js/shader-example-evolveImage.js",
    "content": "window.onload = function() {\n\trunSketch();\n};\n\nfunction runSketch() {\n\tvar renderer, renderTarget1, renderTarget2, sceneShader, sceneScreen, camera, clock, stats, uniforms, materialScreen, imgTexture;\n\n\tinit();\n\tanimate();\n\n\t/*\n\t * Initializes the sketch\n\t */\n\tfunction init() {\n\t\t// Initialize the WebGL renderer\n\t\trenderer = new THREE.WebGLRenderer();\n\t\trenderer.setPixelRatio(window.devicePixelRatio);\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\t\trenderer.setClearColor(new THREE.Color(0, 0, 0));\n\n\t\t// Add the renderer to the sketch container\n\t\tvar container = document.getElementById(\"sketch-container\");\n\t\tcontainer.appendChild(renderer.domElement);\n\n\t\t// Initialize the render targets\n\t\tvar size = renderer.getDrawingBufferSize();\n\t\tvar options = {\n\t\t\tminFilter : THREE.NearestFilter,\n\t\t\tmagFilter : THREE.NearestFilter,\n\t\t\tformat : THREE.RGBAFormat,\n\t\t\ttype : /(iPad|iPhone|iPod)/g.test(navigator.userAgent) ? THREE.HalfFloatType : THREE.FloatType\n\t\t};\n\t\trenderTarget1 = new THREE.WebGLRenderTarget(size.width, size.height, options);\n\t\trenderTarget2 = new THREE.WebGLRenderTarget(size.width, size.height, options);\n\n\t\t// Initialize the scenes\n\t\tsceneShader = new THREE.Scene();\n\t\tsceneScreen = new THREE.Scene();\n\n\t\t// Initialize the camera\n\t\tcamera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);\n\n\t\t// Initialize the clock\n\t\tclock = new THREE.Clock(true);\n\n\t\t// Initialize the statistics monitor and add it to the sketch container\n\t\tstats = new Stats();\n\t\tstats.dom.style.cssText = \"\";\n\t\tdocument.getElementById(\"sketch-stats\").appendChild(stats.dom);\n\n\t\t// Create the plane geometry\n\t\tvar geometry = new THREE.PlaneBufferGeometry(2, 2);\n\n\t\t// Define the shader uniforms\n\t\tuniforms = {\n\t\t\tu_time : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 0.0\n\t\t\t},\n\t\t\tu_frame : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 0.0\n\t\t\t},\n\t\t\tu_resolution : {\n\t\t\t\ttype : \"v2\",\n\t\t\t\tvalue : new THREE.Vector2(window.innerWidth, window.innerHeight)\n\t\t\t\t\t\t.multiplyScalar(window.devicePixelRatio)\n\t\t\t},\n\t\t\tu_mouse : {\n\t\t\t\ttype : \"v2\",\n\t\t\t\tvalue : new THREE.Vector2(0.7 * window.innerWidth, window.innerHeight)\n\t\t\t\t\t\t.multiplyScalar(window.devicePixelRatio)\n\t\t\t},\n\t\t\tu_texture : {\n\t\t\t\ttype : \"t\",\n\t\t\t\tvalue : null\n\t\t\t}\n\t\t};\n\n\t\t// Create the shader material\n\t\tvar materialShader = new THREE.ShaderMaterial({\n\t\t\tuniforms : uniforms,\n\t\t\tvertexShader : document.getElementById(\"vertexShader\").textContent,\n\t\t\tfragmentShader : document.getElementById(\"fragmentShader\").textContent\n\t\t});\n\n\t\t// Create the screen material\n\t\tmaterialScreen = new THREE.MeshBasicMaterial();\n\n\t\t// Create the meshes and add them to the scenes\n\t\tvar meshShader = new THREE.Mesh(geometry, materialShader);\n\t\tvar meshScreen = new THREE.Mesh(geometry, materialScreen);\n\t\tsceneShader.add(meshShader);\n\t\tsceneScreen.add(meshScreen);\n\n\t\t// Load the image texture\n\t\tloadTextrure(\"img/portrait.jpg\");\n\n\t\t// Add the event listeners\n\t\twindow.addEventListener(\"resize\", onWindowResize, false);\n\t\trenderer.domElement.addEventListener(\"mousemove\", onMouseMove, false);\n\t\trenderer.domElement.addEventListener(\"touchstart\", onTouchMove, false);\n\t\trenderer.domElement.addEventListener(\"touchmove\", onTouchMove, false);\n\t}\n\n\t/*\n\t * Loads a texture and updates the screen material texture uniform\n\t */\n\tfunction loadTextrure(imageFileName) {\n\t\tvar loader = new THREE.TextureLoader();\n\n\t\tloader.load(imageFileName, function(texture) {\n\t\t\ttexture.minFilter = THREE.LinearFilter;\n\t\t\ttexture.magFilter = THREE.LinearFilter;\n\t\t\timgTexture = texture;\n\t\t\tmaterialScreen.map = imgTexture;\n\t\t\tmaterialScreen.needsUpdate = true;\n\t\t});\n\t}\n\n\t/*\n\t * Animates the sketch\n\t */\n\tfunction animate() {\n\t\trequestAnimationFrame(animate);\n\t\trender();\n\t\tstats.update();\n\t}\n\n\t/*\n\t * Renders the sketch\n\t */\n\tfunction render() {\n\t\t// Wait until the image texture is loaded\n\t\tif (materialScreen.map) {\n\t\t\t// Start rendering the screen scene on the first render target\n\t\t\tif (!uniforms.u_texture.value) {\n\t\t\t\trenderer.render(sceneScreen, camera, renderTarget1);\n\t\t\t}\n\n\t\t\t// Update the uniforms\n\t\t\tuniforms.u_time.value = clock.getElapsedTime();\n\t\t\tuniforms.u_frame.value += 1.0;\n\t\t\tuniforms.u_texture.value = renderTarget1.texture;\n\n\t\t\t// Render the shader scene\n\t\t\trenderer.render(sceneShader, camera, renderTarget2);\n\n\t\t\t// Update the screen material texture\n\t\t\tmaterialScreen.map = renderTarget2.texture;\n\t\t\tmaterialScreen.needsUpdate = true;\n\n\t\t\t// Render the screen scene\n\t\t\trenderer.render(sceneScreen, camera);\n\n\t\t\t// Swap the render targets\n\t\t\tvar tmp = renderTarget1;\n\t\t\trenderTarget1 = renderTarget2;\n\t\t\trenderTarget2 = tmp;\n\t\t}\n\t}\n\n\t/*\n\t * Updates the renderer size and the uniforms when the window is resized\n\t */\n\tfunction onWindowResize(event) {\n\t\t// Update the renderer\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\n\t\t// Update the render targets\n\t\tvar size = renderer.getDrawingBufferSize();\n\t\trenderTarget1.setSize(size.width, size.height);\n\t\trenderTarget2.setSize(size.width, size.height);\n\n\t\t// Update the uniforms\n\t\tuniforms.u_resolution.value.set(window.innerWidth, window.innerHeight).multiplyScalar(window.devicePixelRatio);\n\t\tuniforms.u_texture.value = null;\n\n\t\t// Start again from the original image texture\n\t\tmaterialScreen.map = imgTexture;\n\t}\n\n\t/*\n\t * Updates the uniforms when the mouse moves\n\t */\n\tfunction onMouseMove(event) {\n\t\t// Update the mouse uniform\n\t\tuniforms.u_mouse.value.set(event.pageX, window.innerHeight - event.pageY).multiplyScalar(\n\t\t\t\twindow.devicePixelRatio);\n\t}\n\n\t/*\n\t * Updates the uniforms when the touch moves\n\t */\n\tfunction onTouchMove(event) {\n\t\tevent.preventDefault();\n\n\t\t// Update the mouse uniform\n\t\tuniforms.u_mouse.value.set(event.touches[0].pageX, window.innerHeight - event.touches[0].pageY).multiplyScalar(\n\t\t\t\twindow.devicePixelRatio);\n\t}\n}"
  },
  {
    "path": "WebContent/js/shader-example-filters.js",
    "content": "window.onload = function() {\n\trunSketch();\n};\n\nfunction runSketch() {\n\tvar renderer, scene, camera, clock, stats, controlParameters, uniforms, videoElement;\n\n\tinit();\n\tanimate();\n\n\t/*\n\t * Initializes the sketch\n\t */\n\tfunction init() {\n\t\t// Initialize the WebGL renderer\n\t\trenderer = new THREE.WebGLRenderer();\n\t\trenderer.setPixelRatio(window.devicePixelRatio);\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\n\t\t// Add the renderer to the sketch container\n\t\tvar container = document.getElementById(\"sketch-container\");\n\t\tcontainer.appendChild(renderer.domElement);\n\n\t\t// Initialize the scene\n\t\tscene = new THREE.Scene();\n\n\t\t// Initialize the camera\n\t\tcamera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);\n\n\t\t// Initialize the clock\n\t\tclock = new THREE.Clock(true);\n\n\t\t// Initialize the statistics monitor and add it to the sketch container\n\t\tstats = new Stats();\n\t\tstats.dom.style.cssText = \"\";\n\t\tdocument.getElementById(\"sketch-stats\").appendChild(stats.dom);\n\n\t\t// Initialize the control parameters\n\t\tcontrolParameters = {\n\t\t\t\"Input\" : \"Webcam\"\n\t\t};\n\n\t\t// Add the control panel to the sketch\n\t\taddControlPanel();\n\n\t\t// Create the plane geometry\n\t\tvar geometry = new THREE.PlaneBufferGeometry(2, 2);\n\n\t\t// Define the shader uniforms\n\t\tuniforms = {\n\t\t\tu_time : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 0.0\n\t\t\t},\n\t\t\tu_frame : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 0.0\n\t\t\t},\n\t\t\tu_resolution : {\n\t\t\t\ttype : \"v2\",\n\t\t\t\tvalue : new THREE.Vector2(window.innerWidth, window.innerHeight)\n\t\t\t\t\t\t.multiplyScalar(window.devicePixelRatio)\n\t\t\t},\n\t\t\tu_mouse : {\n\t\t\t\ttype : \"v2\",\n\t\t\t\tvalue : new THREE.Vector2(0.5 * window.innerWidth, window.innerHeight)\n\t\t\t\t\t\t.multiplyScalar(window.devicePixelRatio)\n\t\t\t},\n\t\t\tu_texture : {\n\t\t\t\ttype : \"t\",\n\t\t\t\tvalue : null\n\t\t\t}\n\t\t};\n\n\t\t// Create the shader material\n\t\tvar material = new THREE.ShaderMaterial({\n\t\t\tuniforms : uniforms,\n\t\t\tvertexShader : document.getElementById(\"vertexShader\").textContent,\n\t\t\tfragmentShader : document.getElementById(\"fragmentShader\").textContent\n\t\t});\n\n\t\t// Create the mesh and add it to the scene\n\t\tvar mesh = new THREE.Mesh(geometry, material);\n\t\tscene.add(mesh);\n\n\t\t// Set the input texture\n\t\tsetInputTexture();\n\n\t\t// Add the event listeners\n\t\twindow.addEventListener(\"resize\", onWindowResize, false);\n\t\trenderer.domElement.addEventListener(\"mousemove\", onMouseMove, false);\n\t\trenderer.domElement.addEventListener(\"touchstart\", onTouchMove, false);\n\t\trenderer.domElement.addEventListener(\"touchmove\", onTouchMove, false);\n\t}\n\n\t/*\n\t * Adds the control panel to the sketch\n\t */\n\tfunction addControlPanel() {\n\t\t// Create the control panel\n\t\tvar controlPanel = new dat.GUI({\n\t\t\tautoPlace : false\n\t\t});\n\n\t\t// Add the controllers\n\t\tcontrolPanel.add(controlParameters, \"Input\", [ \"Webcam\", \"Image\" ]).onFinishChange(setInputTexture);\n\n\t\t// Add the GUI to the correct DOM element\n\t\tdocument.getElementById(\"sketch-gui\").appendChild(controlPanel.domElement);\n\t}\n\n\t/*\n\t * Sets the input texture\n\t */\n\tfunction setInputTexture() {\n\t\t// Handle all the different options\n\t\tif (controlParameters.Input == \"Webcam\") {\n\t\t\t// Create the video element if it was not done before\n\t\t\tif (!videoElement) {\n\t\t\t\tvideoElement = document.createElement(\"video\");\n\t\t\t\tvideoElement.autoplay = true;\n\t\t\t}\n\n\t\t\t// Start the user's webcam\n\t\t\tstartWebcam();\n\t\t} else if (controlParameters.Input == \"Image\") {\n\t\t\t// Stop the webcam if it's active\n\t\t\tif (videoElement && videoElement.srcObject) {\n\t\t\t\tvideoElement.srcObject.getVideoTracks()[0].stop();\n\t\t\t}\n\n\t\t\t// Load the image texture\n\t\t\tloadTextrure(\"img/portrait.jpg\");\n\t\t}\n\t}\n\n\t/*\n\t * Starts the user's webcam and updates the texture uniform\n\t */\n\tfunction startWebcam() {\n\t\t// Try to access the webcam stream using the MediadDevices interface\n\t\tif (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {\n\t\t\t// Set the video constraints\n\t\t\tvar constraints = {\n\t\t\t\tvideo : {\n\t\t\t\t\twidth : {\n\t\t\t\t\t\tideal : window.innerWidth * window.devicePixelRatio\n\t\t\t\t\t},\n\t\t\t\t\theight : {\n\t\t\t\t\t\tideal : window.innerHeight * window.devicePixelRatio\n\t\t\t\t\t},\n\t\t\t\t\tfacingMode : \"user\"\n\t\t\t\t}\n\t\t\t};\n\n\t\t\t// Request the user media\n\t\t\tvar promise = navigator.mediaDevices.getUserMedia(constraints);\n\n\t\t\t// Add the handlers\n\t\t\tpromise.then(function(stream) {\n\t\t\t\t// Add the stream to the video element\n\t\t\t\tvideoElement.srcObject = stream;\n\n\t\t\t\t// Create the texture that will contain the webcam video output\n\t\t\t\tvar texture = new THREE.VideoTexture(videoElement);\n\t\t\t\ttexture.format = THREE.RGBFormat;\n\t\t\t\ttexture.generateMipmaps = false;\n\t\t\t\ttexture.minFilter = THREE.LinearFilter;\n\t\t\t\ttexture.magFilter = THREE.LinearFilter;\n\t\t\t\tuniforms.u_texture.value = texture;\n\t\t\t});\n\n\t\t\tpromise.catch(function(error) {\n\t\t\t\tconsole.error(\"Unable to access the camera/webcam.\", error);\n\t\t\t});\n\t\t} else {\n\t\t\tconsole.error(\"MediaDevices interface not available.\");\n\t\t}\n\t}\n\n\t/*\n\t * Loads a texture and updates the texture uniform\n\t */\n\tfunction loadTextrure(imageFileName) {\n\t\tvar loader = new THREE.TextureLoader();\n\n\t\tloader.load(imageFileName, function(texture) {\n\t\t\ttexture.minFilter = THREE.LinearFilter;\n\t\t\ttexture.magFilter = THREE.LinearFilter;\n\t\t\tuniforms.u_texture.value = texture;\n\t\t});\n\t}\n\n\t/*\n\t * Animates the sketch\n\t */\n\tfunction animate() {\n\t\trequestAnimationFrame(animate);\n\t\trender();\n\t\tstats.update();\n\t}\n\n\t/*\n\t * Renders the sketch\n\t */\n\tfunction render() {\n\t\tuniforms.u_time.value = clock.getElapsedTime();\n\t\tuniforms.u_frame.value += 1.0;\n\t\trenderer.render(scene, camera);\n\t}\n\n\t/*\n\t * Updates the renderer size and the uniforms when the window is resized\n\t */\n\tfunction onWindowResize(event) {\n\t\t// Update the renderer\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\n\t\t// Restart the user's webcam if necessary\n\t\tif (controlParameters.Input == \"Webcam\") {\n\t\t\tstartWebcam();\n\t\t}\n\n\t\t// Update the resolution uniform\n\t\tuniforms.u_resolution.value.set(window.innerWidth, window.innerHeight).multiplyScalar(window.devicePixelRatio);\n\t}\n\n\t/*\n\t * Updates the uniforms when the mouse moves\n\t */\n\tfunction onMouseMove(event) {\n\t\t// Update the mouse uniform\n\t\tuniforms.u_mouse.value.set(event.pageX, window.innerHeight - event.pageY).multiplyScalar(\n\t\t\t\twindow.devicePixelRatio);\n\t}\n\n\t/*\n\t * Updates the uniforms when the touch moves\n\t */\n\tfunction onTouchMove(event) {\n\t\tevent.preventDefault();\n\n\t\t// Update the mouse uniform\n\t\tuniforms.u_mouse.value.set(event.touches[0].pageX, window.innerHeight - event.touches[0].pageY).multiplyScalar(\n\t\t\t\twindow.devicePixelRatio);\n\t}\n}"
  },
  {
    "path": "WebContent/js/shader-example-galaxies.js",
    "content": "window.onload = function() {\n\trunSketch();\n};\n\nfunction runSketch() {\n\tvar renderer, scene, camera, stats, simulator, positionVariable, uniforms;\n\n\tinit();\n\tanimate();\n\n\t/*\n\t * Initializes the sketch\n\t */\n\tfunction init() {\n\t\t// Initialize the WebGL renderer\n\t\trenderer = new THREE.WebGLRenderer({\n\t\t\tantialias : true\n\t\t});\n\t\trenderer.setPixelRatio(window.devicePixelRatio);\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\t\trenderer.setClearColor(new THREE.Color(0, 0, 0));\n\n\t\t// Add the renderer to the sketch container\n\t\tvar container = document.getElementById(\"sketch-container\");\n\t\tcontainer.appendChild(renderer.domElement);\n\n\t\t// Initialize the scene\n\t\tscene = new THREE.Scene();\n\n\t\t// Initialize the camera\n\t\tcamera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 5000);\n\t\tcamera.position.x = 8;\n\t\tcamera.position.y = 5;\n\t\tcamera.position.z = 10;\n\n\t\t// Initialize the camera controls\n\t\tvar controls = new THREE.OrbitControls(camera, renderer.domElement);\n\t\tcontrols.enablePan = false;\n\n\t\t// Initialize the statistics monitor and add it to the sketch container\n\t\tstats = new Stats();\n\t\tstats.dom.style.cssText = \"\";\n\t\tdocument.getElementById(\"sketch-stats\").appendChild(stats.dom);\n\n\t\t// Initialize the simulator\n\t\tvar isDesktop = Math.min(window.innerWidth, window.innerHeight) > 450;\n\t\tvar simSizeX = isDesktop ? 128 : 64;\n\t\tvar simSizeY = isDesktop ? 128 : 64;\n\t\tsimulator = getSimulator(simSizeX, simSizeY, renderer);\n\t\tpositionVariable = getSimulationVariable(\"u_positionTexture\", simulator);\n\n\t\t// Create the particles geometry\n\t\tvar geometry = new THREE.BufferGeometry();\n\n\t\t// Add the particle attributes to the geometry\n\t\tvar nParticles = simSizeX * simSizeY;\n\t\tvar indices = new Float32Array(nParticles);\n\t\tvar positions = new Float32Array(3 * nParticles);\n\t\tgeometry.addAttribute(\"a_index\", new THREE.BufferAttribute(indices, 1));\n\t\tgeometry.addAttribute(\"position\", new THREE.BufferAttribute(positions, 3));\n\n\t\t// Fill the indices attribute. It's not necessary to fill the positions\n\t\t// attribute because it's not used in the shaders (the position texture is\n\t\t// used instead)\n\t\tfor (var i = 0; i < nParticles; i++) {\n\t\t\tindices[i] = i;\n\t\t}\n\n\t\t// Define the particle shader uniforms\n\t\tuniforms = {\n\t\t\tu_width : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : simSizeX\n\t\t\t},\n\t\t\tu_height : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : simSizeY\n\t\t\t},\n\t\t\tu_particleSize : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 50 * window.devicePixelRatio\n\t\t\t},\n\t\t\tu_positionTexture : {\n\t\t\t\ttype : \"t\",\n\t\t\t\tvalue : null\n\t\t\t},\n\t\t\tu_texture : {\n\t\t\t\ttype : \"t\",\n\t\t\t\tvalue : new THREE.TextureLoader().load(\"img/particle.png\")\n\t\t\t}\n\t\t};\n\n\t\t// Create the particles shader material\n\t\tvar material = new THREE.ShaderMaterial({\n\t\t\tuniforms : uniforms,\n\t\t\tvertexShader : document.getElementById(\"vertexShader\").textContent,\n\t\t\tfragmentShader : document.getElementById(\"fragmentShader\").textContent,\n\t\t\tdepthTest : false,\n\t\t\tlights : false,\n\t\t\ttransparent : true,\n\t\t\tblending : THREE.AdditiveBlending\n\t\t});\n\n\t\t// Create the particles and add them to the scene\n\t\tvar particles = new THREE.Points(geometry, material);\n\t\tscene.add(particles);\n\n\t\t// Add the event listeners\n\t\twindow.addEventListener(\"resize\", onWindowResize, false);\n\t}\n\n\t/*\n\t * Initializes and returns the GPU simulator\n\t */\n\tfunction getSimulator(simSizeX, simSizeY, renderer) {\n\t\t// Create a new GPU simulator instance\n\t\tvar gpuSimulator = new GPUComputationRenderer(simSizeX, simSizeY, renderer);\n\n\t\t// Create the position and the velocity textures\n\t\tvar positionTexture = gpuSimulator.createTexture();\n\t\tvar velocityTexture = gpuSimulator.createTexture();\n\n\t\t// Fill the texture data arrays with the simulation initial conditions\n\t\tvar galaxyMass = 0.00015;\n\t\tvar galaxyHaloSize = 6;\n\t\tsetInitialConditions(positionTexture, velocityTexture, galaxyMass, galaxyHaloSize);\n\n\t\t// Add the position and velocity variables to the simulator\n\t\tvar positionVariable = gpuSimulator.addVariable(\"u_positionTexture\",\n\t\t\t\tdocument.getElementById(\"positionShader\").textContent, positionTexture);\n\t\tvar velocityVariable = gpuSimulator.addVariable(\"u_velocityTexture\",\n\t\t\t\tdocument.getElementById(\"velocityShader\").textContent, velocityTexture);\n\n\t\t// Specify the variable dependencies\n\t\tgpuSimulator.setVariableDependencies(positionVariable, [ positionVariable, velocityVariable ]);\n\t\tgpuSimulator.setVariableDependencies(velocityVariable, [ positionVariable, velocityVariable ]);\n\n\t\t// Add the velocity defines\n\t\tvelocityVariable.material.defines.nGalaxies = \"2.0\";\n\n\t\t// Add the position uniforms\n\t\tvar positionUniforms = positionVariable.material.uniforms;\n\t\tpositionUniforms.u_dt = {\n\t\t\ttype : \"f\",\n\t\t\tvalue : 0.2\n\t\t};\n\n\t\t// Add the velocity uniforms\n\t\tvar velocityUniforms = velocityVariable.material.uniforms;\n\t\tvelocityUniforms.u_dt = {\n\t\t\ttype : \"f\",\n\t\t\tvalue : positionUniforms.u_dt.value\n\t\t};\n\t\tvelocityUniforms.u_mass = {\n\t\t\ttype : \"f\",\n\t\t\tvalue : galaxyMass\n\t\t};\n\t\tvelocityUniforms.u_haloSize = {\n\t\t\ttype : \"f\",\n\t\t\tvalue : galaxyHaloSize\n\t\t};\n\n\t\t// Initialize the GPU simulator\n\t\tvar error = gpuSimulator.init();\n\n\t\tif (error !== null) {\n\t\t\tconsole.error(error);\n\t\t}\n\n\t\treturn gpuSimulator;\n\t}\n\n\t/*\n\t * Sets the simulation initial conditions\n\t */\n\tfunction setInitialConditions(positionTexture, velocityTexture, galaxyMass, galaxyHaloSize) {\n\t\t// Get the position and velocity arrays\n\t\tvar position = positionTexture.image.data;\n\t\tvar velocity = velocityTexture.image.data;\n\n\t\t// Set the galaxy properties\n\t\tvar nGalaxies = 2;\n\t\tvar nParticles = (position.length / 4) - nGalaxies;\n\t\tvar galaxyParticles = [ Math.round(nParticles / 2), nParticles - Math.round(nParticles / 2) ];\n\t\tvar galaxySizes = [ 0.7 * galaxyHaloSize, 0.7 * galaxyHaloSize ];\n\t\tvar galaxyInclinations = [ 0.35 * Math.PI, Math.PI * Math.random() ];\n\t\tvar galaxyPositions = [ new THREE.Vector3(-galaxyHaloSize, 0, 0), new THREE.Vector3(galaxyHaloSize, 0, 0) ];\n\t\tvar galaxyVelocities = [ new THREE.Vector3(0.0005, 0.0001, 0.001), new THREE.Vector3(-0.0005, -0.0001, -0.001) ];\n\n\t\t// Fill the position and velocity arrays\n\t\tvar startIndex = nGalaxies;\n\n\t\tfor (var i = 0; i < nGalaxies; i++) {\n\t\t\t// Use the first indices for the galaxy centers\n\t\t\tvar galaxyIndex = 4 * i;\n\t\t\tposition[galaxyIndex] = galaxyPositions[i].x;\n\t\t\tposition[galaxyIndex + 1] = galaxyPositions[i].y;\n\t\t\tposition[galaxyIndex + 2] = galaxyPositions[i].z;\n\t\t\tposition[galaxyIndex + 3] = 1;\n\t\t\tvelocity[galaxyIndex] = galaxyVelocities[i].x;\n\t\t\tvelocity[galaxyIndex + 1] = galaxyVelocities[i].y;\n\t\t\tvelocity[galaxyIndex + 2] = galaxyVelocities[i].z;\n\t\t\tvelocity[galaxyIndex + 3] = 1;\n\n\t\t\t// Loop over the galaxy particles\n\t\t\tvar sin = Math.sin(galaxyInclinations[i]);\n\t\t\tvar cos = Math.cos(galaxyInclinations[i]);\n\n\t\t\tfor (var j = startIndex; j < startIndex + galaxyParticles[i]; j++) {\n\t\t\t\t// Get a random point inside the galaxy disk\n\t\t\t\tvar distance = galaxySizes[i] * Math.sqrt(Math.random());\n\t\t\t\tvar ang = 2 * Math.PI * Math.random();\n\n\t\t\t\t// Get the expected velocity at the point distance\n\t\t\t\tvar massAtPosition = galaxyMass * Math.min(distance, galaxyHaloSize) / galaxyHaloSize;\n\t\t\t\tvar vel = Math.sqrt(massAtPosition / distance);\n\n\t\t\t\t// Calculate the particle position and velocity before applying the galaxy inclination\n\t\t\t\tvar x = distance * Math.cos(ang);\n\t\t\t\tvar y = distance * Math.sin(ang);\n\t\t\t\tvar velx = -vel * Math.sin(ang);\n\t\t\t\tvar vely = vel * Math.cos(ang);\n\n\t\t\t\t// Calculate the particle position and velocity\n\t\t\t\tvar particleIndex = 4 * j;\n\t\t\t\tposition[particleIndex] = x + galaxyPositions[i].x;\n\t\t\t\tposition[particleIndex + 1] = cos * y + galaxyPositions[i].y;\n\t\t\t\tposition[particleIndex + 2] = -sin * y + galaxyPositions[i].z;\n\t\t\t\tposition[particleIndex + 3] = 1;\n\t\t\t\tvelocity[particleIndex] = velx + galaxyVelocities[i].x;\n\t\t\t\tvelocity[particleIndex + 1] = cos * vely + galaxyVelocities[i].y;\n\t\t\t\tvelocity[particleIndex + 2] = -sin * vely + galaxyVelocities[i].z;\n\t\t\t\tvelocity[particleIndex + 3] = 1;\n\t\t\t}\n\n\t\t\t// Increase the starting index\n\t\t\tstartIndex += galaxyParticles[i];\n\t\t}\n\t}\n\n\t/*\n\t * Returns the requested simulation variable\n\t */\n\tfunction getSimulationVariable(variableName, gpuSimulator) {\n\t\tfor (var i = 0; i < gpuSimulator.variables.length; i++) {\n\t\t\tif (gpuSimulator.variables[i].name === variableName) {\n\t\t\t\treturn gpuSimulator.variables[i];\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/*\n\t * Animates the sketch\n\t */\n\tfunction animate() {\n\t\trequestAnimationFrame(animate);\n\t\trender();\n\t\tstats.update();\n\t}\n\n\t/*\n\t * Renders the sketch\n\t */\n\tfunction render() {\n\t\t// Run several iterations per frame\n\t\tfor (var i = 0; i < 20; i++) {\n\t\t\tsimulator.compute();\n\t\t}\n\n\t\t// Update the uniforms\n\t\tuniforms.u_positionTexture.value = simulator.getCurrentRenderTarget(positionVariable).texture;\n\n\t\t// Render the particles on the screen\n\t\trenderer.render(scene, camera);\n\t}\n\n\t/*\n\t * Updates the renderer size and the camera aspect ratio when the window is resized\n\t */\n\tfunction onWindowResize(event) {\n\t\t// Update the renderer\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\n\t\t// Update the camera\n\t\tcamera.aspect = window.innerWidth / window.innerHeight;\n\t\tcamera.updateProjectionMatrix();\n\t}\n}\n"
  },
  {
    "path": "WebContent/js/shader-example-gravity.js",
    "content": "window.onload = function() {\n\trunSketch();\n};\n\nfunction runSketch() {\n\tvar renderer, scene, camera, stats, simulator, positionVariable, uniforms;\n\n\tinit();\n\tanimate();\n\n\t/*\n\t * Initializes the sketch\n\t */\n\tfunction init() {\n\t\t// Initialize the WebGL renderer\n\t\trenderer = new THREE.WebGLRenderer({\n\t\t\tantialias : true\n\t\t});\n\t\trenderer.setPixelRatio(window.devicePixelRatio);\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\t\trenderer.setClearColor(new THREE.Color(0, 0, 0));\n\n\t\t// Add the renderer to the sketch container\n\t\tvar container = document.getElementById(\"sketch-container\");\n\t\tcontainer.appendChild(renderer.domElement);\n\n\t\t// Initialize the scene\n\t\tscene = new THREE.Scene();\n\n\t\t// Initialize the camera\n\t\tcamera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 5000);\n\t\tcamera.position.z = 10;\n\n\t\t// Initialize the camera controls\n\t\tvar controls = new THREE.OrbitControls(camera, renderer.domElement);\n\t\tcontrols.enablePan = false;\n\n\t\t// Initialize the statistics monitor and add it to the sketch container\n\t\tstats = new Stats();\n\t\tstats.dom.style.cssText = \"\";\n\t\tdocument.getElementById(\"sketch-stats\").appendChild(stats.dom);\n\n\t\t// Initialize the simulator\n\t\tvar isDesktop = Math.min(window.innerWidth, window.innerHeight) > 450;\n\t\tvar simSizeX = isDesktop ? 64 : 32;\n\t\tvar simSizeY = isDesktop ? 64 : 32;\n\t\tsimulator = getSimulator(simSizeX, simSizeY, renderer);\n\t\tpositionVariable = getSimulationVariable(\"u_positionTexture\", simulator);\n\n\t\t// Create the particles geometry\n\t\tvar geometry = new THREE.BufferGeometry();\n\n\t\t// Add the particle attributes to the geometry\n\t\tvar nParticles = simSizeX * simSizeY;\n\t\tvar indices = new Float32Array(nParticles);\n\t\tvar positions = new Float32Array(3 * nParticles);\n\t\tgeometry.addAttribute(\"a_index\", new THREE.BufferAttribute(indices, 1));\n\t\tgeometry.addAttribute(\"position\", new THREE.BufferAttribute(positions, 3));\n\n\t\t// Fill the indices attribute. It's not necessary to fill the positions\n\t\t// attribute because it's not used in the shaders (the position texture is\n\t\t// used instead)\n\t\tfor (var i = 0; i < nParticles; i++) {\n\t\t\tindices[i] = i;\n\t\t}\n\n\t\t// Define the particle shader uniforms\n\t\tuniforms = {\n\t\t\tu_width : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : simSizeX\n\t\t\t},\n\t\t\tu_height : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : simSizeY\n\t\t\t},\n\t\t\tu_particleSize : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 50 * window.devicePixelRatio\n\t\t\t},\n\t\t\tu_positionTexture : {\n\t\t\t\ttype : \"t\",\n\t\t\t\tvalue : null\n\t\t\t},\n\t\t\tu_texture : {\n\t\t\t\ttype : \"t\",\n\t\t\t\tvalue : new THREE.TextureLoader().load(\"img/particle.png\")\n\t\t\t}\n\t\t};\n\n\t\t// Create the particles shader material\n\t\tvar material = new THREE.ShaderMaterial({\n\t\t\tuniforms : uniforms,\n\t\t\tvertexShader : document.getElementById(\"vertexShader\").textContent,\n\t\t\tfragmentShader : document.getElementById(\"fragmentShader\").textContent,\n\t\t\tdepthTest : false,\n\t\t\tlights : false,\n\t\t\ttransparent : true,\n\t\t\tblending : THREE.AdditiveBlending\n\t\t});\n\n\t\t// Create the particles and add them to the scene\n\t\tvar particles = new THREE.Points(geometry, material);\n\t\tscene.add(particles);\n\n\t\t// Add the event listeners\n\t\twindow.addEventListener(\"resize\", onWindowResize, false);\n\t}\n\n\t/*\n\t * Initializes and returns the GPU simulator\n\t */\n\tfunction getSimulator(simSizeX, simSizeY, renderer) {\n\t\t// Create a new GPU simulator instance\n\t\tvar gpuSimulator = new GPUComputationRenderer(simSizeX, simSizeY, renderer);\n\n\t\t// Create the position and the velocity textures\n\t\tvar positionTexture = gpuSimulator.createTexture();\n\t\tvar velocityTexture = gpuSimulator.createTexture();\n\n\t\t// Fill the texture data arrays with the simulation initial conditions\n\t\tsetInitialConditions(positionTexture, velocityTexture);\n\n\t\t// Add the position and velocity variables to the simulator\n\t\tvar positionVariable = gpuSimulator.addVariable(\"u_positionTexture\",\n\t\t\t\tdocument.getElementById(\"positionShader\").textContent, positionTexture);\n\t\tvar velocityVariable = gpuSimulator.addVariable(\"u_velocityTexture\",\n\t\t\t\tdocument.getElementById(\"velocityShader\").textContent, velocityTexture);\n\n\t\t// Specify the variable dependencies\n\t\tgpuSimulator.setVariableDependencies(positionVariable, [ positionVariable, velocityVariable ]);\n\t\tgpuSimulator.setVariableDependencies(velocityVariable, [ positionVariable, velocityVariable ]);\n\n\t\t// Add the position uniforms\n\t\tvar positionUniforms = positionVariable.material.uniforms;\n\t\tpositionUniforms.u_dt = {\n\t\t\ttype : \"f\",\n\t\t\tvalue : 1.0\n\t\t};\n\n\t\t// Add the velocity uniforms\n\t\tvar velocityUniforms = velocityVariable.material.uniforms;\n\t\tvelocityUniforms.u_dt = {\n\t\t\ttype : \"f\",\n\t\t\tvalue : positionUniforms.u_dt.value\n\t\t};\n\n\t\t// Initialize the GPU simulator\n\t\tvar error = gpuSimulator.init();\n\n\t\tif (error !== null) {\n\t\t\tconsole.error(error);\n\t\t}\n\n\t\treturn gpuSimulator;\n\t}\n\n\t/*\n\t * Sets the simulation initial conditions\n\t */\n\tfunction setInitialConditions(positionTexture, velocityTexture) {\n\t\t// Get the position and velocity arrays\n\t\tvar position = positionTexture.image.data;\n\t\tvar velocity = velocityTexture.image.data;\n\n\t\t// Fill the position and velocity arrays\n\t\tvar nParticles = position.length / 4;\n\n\t\tfor (var i = 0; i < nParticles; i++) {\n\t\t\t// Get a random point inside a sphere\n\t\t\tvar distance = 10 * Math.pow(Math.random(), 1 / 3);\n\t\t\tvar cos = 2 * Math.random() - 1;\n\t\t\tvar sin = Math.sqrt(1 - cos * cos);\n\t\t\tvar ang = 2 * Math.PI * Math.random();\n\n\t\t\t// Calculate the point x,y,z coordinates\n\t\t\tvar particleIndex = 4 * i;\n\t\t\tposition[particleIndex] = distance * sin * Math.cos(ang);\n\t\t\tposition[particleIndex + 1] = distance * sin * Math.sin(ang);\n\t\t\tposition[particleIndex + 2] = distance * cos;\n\t\t\tposition[particleIndex + 3] = 1;\n\n\t\t\t// Start with zero initial velocity\n\t\t\tvelocity[particleIndex] = 0;\n\t\t\tvelocity[particleIndex + 1] = 0;\n\t\t\tvelocity[particleIndex + 2] = 0;\n\t\t\tvelocity[particleIndex + 3] = 1;\n\t\t}\n\t}\n\n\t/*\n\t * Returns the requested simulation variable\n\t */\n\tfunction getSimulationVariable(variableName, gpuSimulator) {\n\t\tfor (var i = 0; i < gpuSimulator.variables.length; i++) {\n\t\t\tif (gpuSimulator.variables[i].name === variableName) {\n\t\t\t\treturn gpuSimulator.variables[i];\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/*\n\t * Animates the sketch\n\t */\n\tfunction animate() {\n\t\trequestAnimationFrame(animate);\n\t\trender();\n\t\tstats.update();\n\t}\n\n\t/*\n\t * Renders the sketch\n\t */\n\tfunction render() {\n\t\t// Run several iterations per frame\n\t\tfor (var i = 0; i < 1; i++) {\n\t\t\tsimulator.compute();\n\t\t}\n\n\t\t// Update the uniforms\n\t\tuniforms.u_positionTexture.value = simulator.getCurrentRenderTarget(positionVariable).texture;\n\n\t\t// Render the particles on the screen\n\t\trenderer.render(scene, camera);\n\t}\n\n\t/*\n\t * Updates the renderer size and the camera aspect ratio when the window is resized\n\t */\n\tfunction onWindowResize(event) {\n\t\t// Update the renderer\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\n\t\t// Update the camera\n\t\tcamera.aspect = window.innerWidth / window.innerHeight;\n\t\tcamera.updateProjectionMatrix();\n\t}\n}\n"
  },
  {
    "path": "WebContent/js/shader-example-mountains.js",
    "content": "window.onload = function() {\n\trunSketch();\n};\n\nfunction runSketch() {\n\tvar renderer, scene, camera, clock, stats, skyColor, uniforms;\n\n\tinit();\n\tanimate();\n\n\t/*\n\t * Initializes the sketch\n\t */\n\tfunction init() {\n\t\t// Initialize the WebGL renderer\n\t\trenderer = new THREE.WebGLRenderer({\n\t\t\tantialias : true\n\t\t});\n\t\trenderer.setPixelRatio(window.devicePixelRatio);\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\n\t\t// Add the renderer to the sketch container\n\t\tvar container = document.getElementById(\"sketch-container\");\n\t\tcontainer.appendChild(renderer.domElement);\n\n\t\t// Initialize the scene\n\t\tscene = new THREE.Scene();\n\n\t\t// Initialize the camera\n\t\tcamera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 5000);\n\t\tcamera.position.z = 30;\n\n\t\t// Initialize the camera controls\n\t\tvar controls = new THREE.OrbitControls(camera, renderer.domElement);\n\t\tcontrols.enablePan = false;\n\n\t\t// Initialize the clock\n\t\tclock = new THREE.Clock(true);\n\n\t\t// Initialize the statistics monitor and add it to the sketch container\n\t\tstats = new Stats();\n\t\tstats.dom.style.cssText = \"\";\n\t\tdocument.getElementById(\"sketch-stats\").appendChild(stats.dom);\n\n\t\t// Set the sky color\n\t\tskyColor = new THREE.Color(0.1, 0.8, 0.9);\n\t\trenderer.setClearColor(skyColor);\n\n\t\t// Create the plane geometry\n\t\tvar planeSize = 320;\n\t\tvar planeSegments = 32;\n\t\tvar geometry = new THREE.PlaneGeometry(planeSize, planeSize, planeSegments, planeSegments);\n\t\tgeometry.rotateX(-Math.PI / 2);\n\n\t\t// Define the shader uniforms\n\t\tuniforms = {\n\t\t\tu_time : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 0.0\n\t\t\t},\n\t\t\tu_frame : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 0.0\n\t\t\t},\n\t\t\tu_resolution : {\n\t\t\t\ttype : \"v2\",\n\t\t\t\tvalue : new THREE.Vector2(window.innerWidth, window.innerHeight)\n\t\t\t\t\t\t.multiplyScalar(window.devicePixelRatio)\n\t\t\t},\n\t\t\tu_mouse : {\n\t\t\t\ttype : \"v2\",\n\t\t\t\tvalue : new THREE.Vector2(0.7 * window.innerWidth, window.innerHeight)\n\t\t\t\t\t\t.multiplyScalar(window.devicePixelRatio)\n\t\t\t},\n\t\t\tu_tileSize : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : planeSize / planeSegments\n\t\t\t},\n\t\t\tu_speed : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 30.0\n\t\t\t},\n\t\t\tu_maxHeight : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 20.0\n\t\t\t},\n\t\t\tu_skyColor : {\n\t\t\t\ttype : \"v3\",\n\t\t\t\tvalue : skyColor\n\t\t\t}\n\t\t};\n\n\t\t// Create the shader material\n\t\tvar material = new THREE.ShaderMaterial({\n\t\t\tuniforms : uniforms,\n\t\t\tvertexShader : document.getElementById(\"vertexShader\").textContent,\n\t\t\tfragmentShader : document.getElementById(\"fragmentShader\").textContent,\n\t\t\tside : THREE.FrontSide,\n\t\t\ttransparent : true,\n\t\t\textensions : {\n\t\t\t\tderivatives : true\n\t\t\t}\n\t\t});\n\n\t\t// Create the mesh and add it to the scene\n\t\tvar mesh = new THREE.Mesh(geometry, material);\n\t\tmesh.rotateX(Math.PI / 9);\n\t\tscene.add(mesh);\n\n\t\t// Add the event listeners\n\t\twindow.addEventListener(\"resize\", onWindowResize, false);\n\t\trenderer.domElement.addEventListener(\"mousemove\", onMouseMove, false);\n\t\trenderer.domElement.addEventListener(\"touchstart\", onTouchMove, false);\n\t\trenderer.domElement.addEventListener(\"touchmove\", onTouchMove, false);\n\t}\n\n\t/*\n\t * Animates the sketch\n\t */\n\tfunction animate() {\n\t\trequestAnimationFrame(animate);\n\t\trender();\n\t\tstats.update();\n\t}\n\n\t/*\n\t * Renders the sketch\n\t */\n\tfunction render() {\n\t\tuniforms.u_time.value = clock.getElapsedTime();\n\t\tuniforms.u_frame.value += 1.0;\n\t\trenderer.render(scene, camera);\n\t}\n\n\t/*\n\t * Updates the renderer size, the camera aspect ratio and the uniforms when the window is resized\n\t */\n\tfunction onWindowResize(event) {\n\t\t// Update the renderer\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\n\t\t// Update the camera\n\t\tcamera.aspect = window.innerWidth / window.innerHeight;\n\t\tcamera.updateProjectionMatrix();\n\n\t\t// Update the resolution uniform\n\t\tuniforms.u_resolution.value.set(window.innerWidth, window.innerHeight).multiplyScalar(window.devicePixelRatio);\n\t}\n\n\t/*\n\t * Updates the uniforms when the mouse moves\n\t */\n\tfunction onMouseMove(event) {\n\t\t// Calculate the new sky color and update the renderer\n\t\tvar sunset = event.pageY / window.innerHeight;\n\t\tvar newSkyColor = new THREE.Color(skyColor.r + sunset, skyColor.g - 0.2 * sunset, skyColor.b - 0.2 * sunset);\n\t\trenderer.setClearColor(newSkyColor);\n\n\t\t// Update the uniforms\n\t\tuniforms.u_mouse.value.set(event.pageX, window.innerHeight - event.pageY).multiplyScalar(\n\t\t\t\twindow.devicePixelRatio);\n\t\tuniforms.u_skyColor.value = newSkyColor;\n\t}\n\n\t/*\n\t * Updates the uniforms when the touch moves\n\t */\n\tfunction onTouchMove(event) {\n\t\t// Calculate the new sky color and update the renderer\n\t\tvar sunset = event.touches[0].pageY / window.innerHeight;\n\t\tvar newSkyColor = new THREE.Color(skyColor.r + sunset, skyColor.g - 0.2 * sunset, skyColor.b - 0.2 * sunset);\n\t\trenderer.setClearColor(newSkyColor);\n\n\t\t// Update the uniforms\n\t\tuniforms.u_mouse.value.set(event.touches[0].pageX, window.innerHeight - event.touches[0].pageY).multiplyScalar(\n\t\t\t\twindow.devicePixelRatio);\n\t\tuniforms.u_skyColor.value = newSkyColor;\n\t}\n}"
  },
  {
    "path": "WebContent/js/shader-example-postprocessing.js",
    "content": "window.onload = function() {\n\trunSketch();\n};\n\nfunction runSketch() {\n\tvar renderer, scene, camera, clock, stats, controlParameters, mesh, uniforms, composer;\n\n\tinit();\n\tanimate();\n\n\t/*\n\t * Initializes the sketch\n\t */\n\tfunction init() {\n\t\t// Initialize the WebGL renderer\n\t\trenderer = new THREE.WebGLRenderer({\n\t\t\tantialias : true\n\t\t});\n\t\trenderer.setPixelRatio(window.devicePixelRatio);\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\t\trenderer.setClearColor(new THREE.Color(0, 0, 0));\n\n\t\t// Add the renderer to the sketch container\n\t\tvar container = document.getElementById(\"sketch-container\");\n\t\tcontainer.appendChild(renderer.domElement);\n\n\t\t// Initialize the scene\n\t\tscene = new THREE.Scene();\n\n\t\t// Initialize the camera\n\t\tcamera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 5000);\n\t\tcamera.position.z = 30;\n\n\t\t// Initialize the camera controls\n\t\tvar controls = new THREE.OrbitControls(camera, renderer.domElement);\n\t\tcontrols.enablePan = false;\n\n\t\t// Initialize the clock\n\t\tclock = new THREE.Clock(true);\n\n\t\t// Initialize the statistics monitor and add it to the sketch container\n\t\tstats = new Stats();\n\t\tstats.dom.style.cssText = \"\";\n\t\tdocument.getElementById(\"sketch-stats\").appendChild(stats.dom);\n\n\t\t// Initialize the control parameters\n\t\tcontrolParameters = {\n\t\t\t\"Geometry\" : \"Torus knot\"\n\t\t};\n\n\t\t// Add the control panel to the sketch\n\t\taddControlPanel();\n\n\t\t// Create the mesh and add it to the scene\n\t\taddMeshToScene();\n\n\t\t// Add some lights to the scene\n\t\tscene.add(new THREE.AmbientLight(0x222222));\n\t\tvar light = new THREE.DirectionalLight(0xffffff);\n\t\tlight.position.set(1, 1, 1);\n\t\tscene.add(light);\n\n\t\t// Define the shader uniforms\n\t\tuniforms = {\n\t\t\tu_time : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 0.0\n\t\t\t},\n\t\t\tu_frame : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 0.0\n\t\t\t},\n\t\t\tu_resolution : {\n\t\t\t\ttype : \"v2\",\n\t\t\t\tvalue : new THREE.Vector2(window.innerWidth, window.innerHeight)\n\t\t\t\t\t\t.multiplyScalar(window.devicePixelRatio)\n\t\t\t},\n\t\t\tu_mouse : {\n\t\t\t\ttype : \"v2\",\n\t\t\t\tvalue : new THREE.Vector2(0.5 * window.innerWidth, window.innerHeight)\n\t\t\t\t\t\t.multiplyScalar(window.devicePixelRatio)\n\t\t\t},\n\t\t\tu_texture : {\n\t\t\t\ttype : \"t\",\n\t\t\t\tvalue : null\n\t\t\t}\n\t\t};\n\n\t\t// Create the shader material\n\t\tvar material = new THREE.ShaderMaterial({\n\t\t\tuniforms : uniforms,\n\t\t\tvertexShader : document.getElementById(\"vertexShader\").textContent,\n\t\t\tfragmentShader : document.getElementById(\"fragmentShader\").textContent\n\t\t});\n\n\t\t// Initialize the effect composer\n\t\tcomposer = new THREE.EffectComposer(renderer);\n\t\tcomposer.addPass(new THREE.RenderPass(scene, camera));\n\n\t\t// Add the post-processing effect\n\t\tvar effect = new THREE.ShaderPass(material, \"u_texture\");\n\t\teffect.renderToScreen = true;\n\t\tcomposer.addPass(effect);\n\n\t\t// Add the event listeners\n\t\twindow.addEventListener(\"resize\", onWindowResize, false);\n\t\trenderer.domElement.addEventListener(\"mousemove\", onMouseMove, false);\n\t\trenderer.domElement.addEventListener(\"touchstart\", onTouchMove, false);\n\t\trenderer.domElement.addEventListener(\"touchmove\", onTouchMove, false);\n\t}\n\n\t/*\n\t * Adds the control panel to the sketch\n\t */\n\tfunction addControlPanel() {\n\t\t// Create the control panel\n\t\tvar controlPanel = new dat.GUI({\n\t\t\tautoPlace : false\n\t\t});\n\n\t\t// Add the controllers\n\t\tcontrolPanel.add(controlParameters, \"Geometry\", [ \"Torus knot\", \"Sphere\", \"Icosahedron\", \"Suzanne\" ])\n\t\t\t\t.onFinishChange(addMeshToScene);\n\n\t\t// Add the GUI to the correct DOM element\n\t\tdocument.getElementById(\"sketch-gui\").appendChild(controlPanel.domElement);\n\t}\n\n\t/*\n\t * Adds the mesh to the scene\n\t */\n\tfunction addMeshToScene() {\n\t\t// Remove any previous mesh from the scene\n\t\tif (mesh) {\n\t\t\tscene.remove(mesh);\n\t\t}\n\n\t\t// Create the mesh material\n\t\tvar material = new THREE.MeshPhongMaterial({\n\t\t\tcolor : 0xffffff,\n\t\t\tprecision: \"mediump\"\n\t\t});\n\n\t\t// Handle all the different options\n\t\tif (controlParameters.Geometry == \"Suzanne\") {\n\t\t\t// Load the json file that contains the geometry\n\t\t\tvar loader = new THREE.BufferGeometryLoader();\n\t\t\tloader.load(\"/objects/suzanne_buffergeometry.json\", function(geometry) {\n\t\t\t\t// Scale the geometry\n\t\t\t\tgeometry.scale(10, 10, 10);\n\n\t\t\t\t// Calculate the vertex normals\n\t\t\t\tgeometry.computeVertexNormals();\n\n\t\t\t\t// Create the mesh and add it to the scene\n\t\t\t\tmesh = new THREE.Mesh(geometry, material);\n\t\t\t\tscene.add(mesh);\n\t\t\t});\n\t\t} else {\n\t\t\t// Create the desired geometry\n\t\t\tvar geometry;\n\n\t\t\tif (controlParameters.Geometry == \"Torus knot\") {\n\t\t\t\tgeometry = new THREE.TorusKnotGeometry(6.5, 2.3, 256, 32);\n\t\t\t} else if (controlParameters.Geometry == \"Sphere\") {\n\t\t\t\tgeometry = new THREE.SphereGeometry(10, 64, 64);\n\t\t\t} else if (controlParameters.Geometry == \"Icosahedron\") {\n\t\t\t\tgeometry = new THREE.IcosahedronGeometry(10, 0);\n\t\t\t}\n\n\t\t\t// Create the mesh and add it to the scene\n\t\t\tmesh = new THREE.Mesh(geometry, material);\n\t\t\tscene.add(mesh);\n\t\t}\n\t}\n\n\t/*\n\t * Animates the sketch\n\t */\n\tfunction animate() {\n\t\trequestAnimationFrame(animate);\n\t\trender();\n\t\tstats.update();\n\t}\n\n\t/*\n\t * Renders the sketch\n\t */\n\tfunction render() {\n\t\tuniforms.u_time.value = clock.getElapsedTime();\n\t\tuniforms.u_frame.value += 1.0;\n\t\tcomposer.render();\n\t}\n\n\t/*\n\t * Updates the renderer size, the camera aspect ratio and the uniforms when the window is resized\n\t */\n\tfunction onWindowResize(event) {\n\t\t// Update the renderer and the effect composer\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\t\tcomposer.setSize(window.innerWidth, window.innerHeight);\n\n\t\t// Update the camera\n\t\tcamera.aspect = window.innerWidth / window.innerHeight;\n\t\tcamera.updateProjectionMatrix();\n\n\t\t// Update the resolution uniform\n\t\tuniforms.u_resolution.value.set(window.innerWidth, window.innerHeight).multiplyScalar(window.devicePixelRatio);\n\t}\n\n\t/*\n\t * Updates the uniforms when the mouse moves\n\t */\n\tfunction onMouseMove(event) {\n\t\t// Update the mouse uniform\n\t\tuniforms.u_mouse.value.set(event.pageX, window.innerHeight - event.pageY).multiplyScalar(\n\t\t\t\twindow.devicePixelRatio);\n\t}\n\n\t/*\n\t * Updates the uniforms when the touch moves\n\t */\n\tfunction onTouchMove(event) {\n\t\t// Update the mouse uniform\n\t\tuniforms.u_mouse.value.set(event.touches[0].pageX, window.innerHeight - event.touches[0].pageY).multiplyScalar(\n\t\t\t\twindow.devicePixelRatio);\n\t}\n}\n"
  },
  {
    "path": "WebContent/js/shader-example-repulsion.js",
    "content": "window.onload = function() {\n\trunSketch();\n};\n\nfunction runSketch() {\n\tvar renderer, scene, camera, stats, simulator, positionVariable, velocityVariable, uniforms, frames;\n\n\tinit();\n\tanimate();\n\n\t/*\n\t * Initializes the sketch\n\t */\n\tfunction init() {\n\t\t// Initialize the WebGL renderer\n\t\trenderer = new THREE.WebGLRenderer({\n\t\t\tantialias : true\n\t\t});\n\t\trenderer.setPixelRatio(window.devicePixelRatio);\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\t\trenderer.setClearColor(new THREE.Color(0.15, 0.15, 0.15));\n\n\t\t// Add the renderer to the sketch container\n\t\tvar container = document.getElementById(\"sketch-container\");\n\t\tcontainer.appendChild(renderer.domElement);\n\n\t\t// Initialize the scene\n\t\tscene = new THREE.Scene();\n\n\t\t// Initialize the camera\n\t\tcamera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 5000);\n\t\tcamera.position.z = 10;\n\n\t\t// Initialize the camera controls\n\t\tvar controls = new THREE.OrbitControls(camera, renderer.domElement);\n\t\tcontrols.enablePan = false;\n\n\t\t// Initialize the statistics monitor and add it to the sketch container\n\t\tstats = new Stats();\n\t\tstats.dom.style.cssText = \"\";\n\t\tdocument.getElementById(\"sketch-stats\").appendChild(stats.dom);\n\n\t\t// Initialize the simulator\n\t\tvar isDesktop = Math.min(window.innerWidth, window.innerHeight) > 450;\n\t\tvar simSizeX = isDesktop ? 64 : 64;\n\t\tvar simSizeY = isDesktop ? 64 : 64;\n\t\tsimulator = getSimulator(simSizeX, simSizeY, renderer);\n\t\tpositionVariable = getSimulationVariable(\"u_positionTexture\", simulator);\n\t\tvelocityVariable = getSimulationVariable(\"u_velocityTexture\", simulator);\n\n\t\t// Create the particles geometry\n\t\tvar geometry = new THREE.BufferGeometry();\n\n\t\t// Add the particle attributes to the geometry\n\t\tvar nParticles = simSizeX * simSizeY;\n\t\tvar indices = new Float32Array(nParticles);\n\t\tvar positions = new Float32Array(3 * nParticles);\n\t\tgeometry.addAttribute(\"a_index\", new THREE.BufferAttribute(indices, 1));\n\t\tgeometry.addAttribute(\"position\", new THREE.BufferAttribute(positions, 3));\n\n\t\t// Fill the indices attribute. It's not necessary to fill the positions\n\t\t// attribute because it's not used in the shaders (the position texture is\n\t\t// used instead)\n\t\tfor (var i = 0; i < nParticles; i++) {\n\t\t\tindices[i] = i;\n\t\t}\n\n\t\t// Define the particle shader uniforms\n\t\tuniforms = {\n\t\t\tu_width : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : simSizeX\n\t\t\t},\n\t\t\tu_height : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : simSizeY\n\t\t\t},\n\t\t\tu_particleSize : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 50 * Math.min(window.devicePixelRatio, 2)\n\t\t\t},\n\t\t\tu_nActiveParticles : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 1\n\t\t\t},\n\t\t\tu_positionTexture : {\n\t\t\t\ttype : \"t\",\n\t\t\t\tvalue : null\n\t\t\t},\n\t\t\tu_velocityTexture : {\n\t\t\t\ttype : \"t\",\n\t\t\t\tvalue : null\n\t\t\t},\n\t\t\tu_texture : {\n\t\t\t\ttype : \"t\",\n\t\t\t\tvalue : new THREE.TextureLoader().load(\"img/particle2.png\")\n\t\t\t}\n\t\t};\n\n\t\t// Create the particles shader material\n\t\tvar material = new THREE.ShaderMaterial({\n\t\t\tuniforms : uniforms,\n\t\t\tvertexShader : document.getElementById(\"vertexShader\").textContent,\n\t\t\tfragmentShader : document.getElementById(\"fragmentShader\").textContent,\n\t\t\tdepthTest : false,\n\t\t\tlights : false,\n\t\t\ttransparent : true,\n\t\t\tblending : THREE.AdditiveBlending\n\t\t});\n\n\t\t// Create the particles and add them to the scene\n\t\tvar particles = new THREE.Points(geometry, material);\n\t\tscene.add(particles);\n\n\t\t// Add the event listeners\n\t\twindow.addEventListener(\"resize\", onWindowResize, false);\n\n\t\t// Initialize the frames counter\n\t\tframes = 0;\n\t}\n\n\t/*\n\t * Initializes and returns the GPU simulator\n\t */\n\tfunction getSimulator(simSizeX, simSizeY, renderer) {\n\t\t// Create a new GPU simulator instance\n\t\tvar gpuSimulator = new GPUComputationRenderer(simSizeX, simSizeY, renderer);\n\n\t\t// Create the position and the velocity textures\n\t\tvar positionTexture = gpuSimulator.createTexture();\n\t\tvar velocityTexture = gpuSimulator.createTexture();\n\n\t\t// Fill the texture data arrays with the simulation initial conditions\n\t\tsetInitialConditions(positionTexture, velocityTexture);\n\n\t\t// Add the position and velocity variables to the simulator\n\t\tvar positionVariable = gpuSimulator.addVariable(\"u_positionTexture\",\n\t\t\t\tdocument.getElementById(\"positionShader\").textContent, positionTexture);\n\t\tvar velocityVariable = gpuSimulator.addVariable(\"u_velocityTexture\",\n\t\t\t\tdocument.getElementById(\"velocityShader\").textContent, velocityTexture);\n\n\t\t// Specify the variable dependencies\n\t\tgpuSimulator.setVariableDependencies(positionVariable, [ positionVariable, velocityVariable ]);\n\t\tgpuSimulator.setVariableDependencies(velocityVariable, [ positionVariable, velocityVariable ]);\n\n\t\t// Add the position uniforms\n\t\tvar positionUniforms = positionVariable.material.uniforms;\n\t\tpositionUniforms.u_dt = {\n\t\t\ttype : \"f\",\n\t\t\tvalue : 0.2\n\t\t};\n\t\tpositionUniforms.u_nActiveParticles = {\n\t\t\ttype : \"f\",\n\t\t\tvalue : 1\n\t\t};\n\n\t\t// Add the velocity uniforms\n\t\tvar velocityUniforms = velocityVariable.material.uniforms;\n\t\tvelocityUniforms.u_dt = {\n\t\t\ttype : \"f\",\n\t\t\tvalue : positionUniforms.u_dt.value\n\t\t};\n\t\tvelocityUniforms.u_nActiveParticles = {\n\t\t\ttype : \"f\",\n\t\t\tvalue : positionUniforms.u_nActiveParticles.value\n\t\t};\n\n\t\t// Initialize the GPU simulator\n\t\tvar error = gpuSimulator.init();\n\n\t\tif (error !== null) {\n\t\t\tconsole.error(error);\n\t\t}\n\n\t\treturn gpuSimulator;\n\t}\n\n\t/*\n\t * Sets the simulation initial conditions\n\t */\n\tfunction setInitialConditions(positionTexture, velocityTexture) {\n\t\t// Get the position and velocity arrays\n\t\tvar position = positionTexture.image.data;\n\t\tvar velocity = velocityTexture.image.data;\n\n\t\t// Fill the position and velocity arrays\n\t\tvar nParticles = position.length / 4;\n\n\t\tfor (var i = 0; i < nParticles; i++) {\n\t\t\t// Get a random point inside a disk\n\t\t\tvar distance = 0.2 * Math.pow(Math.random(), 1 / 2);\n\t\t\tvar ang = 2 * Math.PI * Math.random();\n\n\t\t\t// Calculate the point x,y,z coordinates\n\t\t\tvar particleIndex = 4 * i;\n\t\t\tposition[particleIndex] = distance * Math.cos(ang);\n\t\t\tposition[particleIndex + 1] = distance * Math.sin(ang);\n\t\t\tposition[particleIndex + 2] = 0;\n\t\t\tposition[particleIndex + 3] = 1;\n\n\t\t\t// Start with zero initial velocity\n\t\t\tvelocity[particleIndex] = 0;\n\t\t\tvelocity[particleIndex + 1] = 0;\n\t\t\tvelocity[particleIndex + 2] = 0;\n\t\t\tvelocity[particleIndex + 3] = 1;\n\t\t}\n\t}\n\n\t/*\n\t * Returns the requested simulation variable\n\t */\n\tfunction getSimulationVariable(variableName, gpuSimulator) {\n\t\tfor (var i = 0; i < gpuSimulator.variables.length; i++) {\n\t\t\tif (gpuSimulator.variables[i].name === variableName) {\n\t\t\t\treturn gpuSimulator.variables[i];\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/*\n\t * Animates the sketch\n\t */\n\tfunction animate() {\n\t\trequestAnimationFrame(animate);\n\t\trender();\n\t\tstats.update();\n\t}\n\n\t/*\n\t * Renders the sketch\n\t */\n\tfunction render() {\n\t\t// Run several iterations per frame\n\t\tfor (var i = 0; i < 1; i++) {\n\t\t\tsimulator.compute();\n\t\t}\n\n\t\t// Update the uniforms\n\t\tvar nActiveParticles = Math.ceil(0.4 * frames);\n\t\tpositionVariable.material.uniforms.u_nActiveParticles.value = nActiveParticles;\n\t\tvelocityVariable.material.uniforms.u_nActiveParticles.value = nActiveParticles;\n\t\tuniforms.u_nActiveParticles.value = nActiveParticles;\n\t\tuniforms.u_positionTexture.value = simulator.getCurrentRenderTarget(positionVariable).texture;\n\t\tuniforms.u_velocityTexture.value = simulator.getCurrentRenderTarget(velocityVariable).texture;\n\t\tframes++;\n\n\t\t// Render the particles on the screen\n\t\trenderer.render(scene, camera);\n\n\t}\n\n\t/*\n\t * Updates the renderer size and the camera aspect ratio when the window is resized\n\t */\n\tfunction onWindowResize(event) {\n\t\t// Update the renderer\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\n\t\t// Update the camera\n\t\tcamera.aspect = window.innerWidth / window.innerHeight;\n\t\tcamera.updateProjectionMatrix();\n\t}\n}\n"
  },
  {
    "path": "WebContent/js/shader-example-sphere.js",
    "content": "window.onload = function() {\n\trunSketch();\n};\n\nfunction runSketch() {\n\tvar renderer, scene, camera, clock, stats, uniforms;\n\n\tinit();\n\tanimate();\n\n\t/*\n\t * Initializes the sketch\n\t */\n\tfunction init() {\n\t\t// Initialize the WebGL renderer\n\t\trenderer = new THREE.WebGLRenderer({\n\t\t\tantialias : true\n\t\t});\n\t\trenderer.setPixelRatio(window.devicePixelRatio);\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\t\trenderer.setClearColor(new THREE.Color(0, 0, 0));\n\n\t\t// Add the renderer to the sketch container\n\t\tvar container = document.getElementById(\"sketch-container\");\n\t\tcontainer.appendChild(renderer.domElement);\n\n\t\t// Initialize the scene\n\t\tscene = new THREE.Scene();\n\n\t\t// Initialize the camera\n\t\tcamera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 5000);\n\t\tcamera.position.z = 30;\n\n\t\t// Initialize the camera controls\n\t\tvar controls = new THREE.OrbitControls(camera, renderer.domElement);\n\t\tcontrols.enablePan = false;\n\n\t\t// Initialize the clock\n\t\tclock = new THREE.Clock(true);\n\n\t\t// Initialize the statistics monitor and add it to the sketch container\n\t\tstats = new Stats();\n\t\tstats.dom.style.cssText = \"\";\n\t\tdocument.getElementById(\"sketch-stats\").appendChild(stats.dom);\n\n\t\t// Create the sphere geometry\n\t\tvar sphereRadius = 10;\n\t\tvar geometry = new THREE.SphereGeometry(sphereRadius, 2*128, 2*128);\n\n\t\t// Define the shader uniforms\n\t\tuniforms = {\n\t\t\tu_time : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 0.0\n\t\t\t},\n\t\t\tu_frame : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 0.0\n\t\t\t},\n\t\t\tu_resolution : {\n\t\t\t\ttype : \"v2\",\n\t\t\t\tvalue : new THREE.Vector2(window.innerWidth, window.innerHeight)\n\t\t\t\t\t\t.multiplyScalar(window.devicePixelRatio)\n\t\t\t},\n\t\t\tu_mouse : {\n\t\t\t\ttype : \"v2\",\n\t\t\t\tvalue : new THREE.Vector2(0.7 * window.innerWidth, window.innerHeight)\n\t\t\t\t\t\t.multiplyScalar(window.devicePixelRatio)\n\t\t\t},\n\t\t\tu_radius : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : sphereRadius\n\t\t\t}\n\t\t};\n\n\t\t// Create the shader material\n\t\tvar material = new THREE.ShaderMaterial({\n\t\t\tuniforms : uniforms,\n\t\t\tvertexShader : document.getElementById(\"vertexShader\").textContent,\n\t\t\tfragmentShader : document.getElementById(\"fragmentShader\").textContent,\n\t\t\tside : THREE.FrontSide,\n\t\t\ttransparent : true,\n\t\t\textensions : {\n\t\t\t\tderivatives : true\n\t\t\t}\n\t\t});\n\n\t\t// Create the mesh and add it to the scene\n\t\tvar mesh = new THREE.Mesh(geometry, material);\n\t\tscene.add(mesh);\n\n\t\t// Add the event listeners\n\t\twindow.addEventListener(\"resize\", onWindowResize, false);\n\t\trenderer.domElement.addEventListener(\"mousemove\", onMouseMove, false);\n\t\trenderer.domElement.addEventListener(\"touchstart\", onTouchMove, false);\n\t\trenderer.domElement.addEventListener(\"touchmove\", onTouchMove, false);\n\t}\n\n\t/*\n\t * Animates the sketch\n\t */\n\tfunction animate() {\n\t\trequestAnimationFrame(animate);\n\t\trender();\n\t\tstats.update();\n\t}\n\n\t/*\n\t * Renders the sketch\n\t */\n\tfunction render() {\n\t\tuniforms.u_time.value = clock.getElapsedTime();\n\t\tuniforms.u_frame.value += 1.0;\n\t\trenderer.render(scene, camera);\n\t}\n\n\t/*\n\t * Updates the renderer size, the camera aspect ratio and the uniforms when the window is resized\n\t */\n\tfunction onWindowResize(event) {\n\t\t// Update the renderer\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\n\t\t// Update the camera\n\t\tcamera.aspect = window.innerWidth / window.innerHeight;\n\t\tcamera.updateProjectionMatrix();\n\n\t\t// Update the resolution uniform\n\t\tuniforms.u_resolution.value.set(window.innerWidth, window.innerHeight).multiplyScalar(window.devicePixelRatio);\n\t}\n\n\t/*\n\t * Updates the uniforms when the mouse moves\n\t */\n\tfunction onMouseMove(event) {\n\t\t// Update the uniforms\n\t\tuniforms.u_mouse.value.set(event.pageX, window.innerHeight - event.pageY).multiplyScalar(\n\t\t\t\twindow.devicePixelRatio);\n\t}\n\n\t/*\n\t * Updates the uniforms when the touch moves\n\t */\n\tfunction onTouchMove(event) {\n\t\t// Update the uniforms\n\t\tuniforms.u_mouse.value.set(event.touches[0].pageX, window.innerHeight - event.touches[0].pageY).multiplyScalar(\n\t\t\t\twindow.devicePixelRatio);\n\t}\n}"
  },
  {
    "path": "WebContent/js/shader-example-stippling.js",
    "content": "window.onload = function() {\n\trunSketch();\n};\n\nfunction runSketch() {\n\tvar renderer, scene, camera, stats, simulator, positionVariable, velocityVariable, uniforms, frames;\n\n\tinit();\n\tanimate();\n\n\t/*\n\t * Initializes the sketch\n\t */\n\tfunction init() {\n\t\t// Initialize the WebGL renderer\n\t\trenderer = new THREE.WebGLRenderer({\n\t\t\tantialias : true\n\t\t});\n\t\trenderer.setPixelRatio(window.devicePixelRatio);\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\t\trenderer.setClearColor(new THREE.Color(0.95, 0.95, 0.95));\n\n\t\t// Add the renderer to the sketch container\n\t\tvar container = document.getElementById(\"sketch-container\");\n\t\tcontainer.appendChild(renderer.domElement);\n\n\t\t// Initialize the scene\n\t\tscene = new THREE.Scene();\n\n\t\t// Initialize the camera\n\t\tcamera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 5000);\n\t\tcamera.position.z = 20;\n\n\t\t// Initialize the camera controls\n\t\tvar controls = new THREE.OrbitControls(camera, renderer.domElement);\n\t\tcontrols.enablePan = false;\n\n\t\t// Initialize the statistics monitor and add it to the sketch container\n\t\tstats = new Stats();\n\t\tstats.dom.style.cssText = \"\";\n\t\tdocument.getElementById(\"sketch-stats\").appendChild(stats.dom);\n\n\t\t// Initialize the simulator\n\t\tvar isDesktop = Math.min(window.innerWidth, window.innerHeight) > 450;\n\t\tvar simSizeX = isDesktop ? 64 : 64;\n\t\tvar simSizeY = isDesktop ? 64 : 64;\n\t\tsimulator = getSimulator(simSizeX, simSizeY, renderer);\n\t\tpositionVariable = getSimulationVariable(\"u_positionTexture\", simulator);\n\t\tvelocityVariable = getSimulationVariable(\"u_velocityTexture\", simulator);\n\n\t\t// Create the particles geometry\n\t\tvar geometry = new THREE.BufferGeometry();\n\n\t\t// Add the particle attributes to the geometry\n\t\tvar nParticles = simSizeX * simSizeY;\n\t\tvar indices = new Float32Array(nParticles);\n\t\tvar positions = new Float32Array(3 * nParticles);\n\t\tgeometry.addAttribute(\"a_index\", new THREE.BufferAttribute(indices, 1));\n\t\tgeometry.addAttribute(\"position\", new THREE.BufferAttribute(positions, 3));\n\n\t\t// Fill the indices attribute. It's not necessary to fill the positions\n\t\t// attribute because it's not used in the shaders (the position texture is\n\t\t// used instead)\n\t\tfor (var i = 0; i < nParticles; i++) {\n\t\t\tindices[i] = i;\n\t\t}\n\n\t\t// Define the particle shader uniforms\n\t\tuniforms = {\n\t\t\tu_width : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : simSizeX\n\t\t\t},\n\t\t\tu_height : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : simSizeY\n\t\t\t},\n\t\t\tu_particleSize : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 80 * Math.min(window.devicePixelRatio, 2)\n\t\t\t},\n\t\t\tu_nActiveParticles : {\n\t\t\t\ttype : \"f\",\n\t\t\t\tvalue : 1\n\t\t\t},\n\t\t\tu_positionTexture : {\n\t\t\t\ttype : \"t\",\n\t\t\t\tvalue : null\n\t\t\t},\n\t\t\tu_bgTexture : {\n\t\t\t\ttype : \"t\",\n\t\t\t\tvalue : velocityVariable.material.uniforms.u_bgTexture.value\n\t\t\t},\n\t\t\tu_textureOffset : {\n\t\t\t\ttype : \"v2\",\n\t\t\t\tvalue : velocityVariable.material.uniforms.u_textureOffset.value\n\t\t\t},\n\t\t\tu_texture : {\n\t\t\t\ttype : \"t\",\n\t\t\t\tvalue : new THREE.TextureLoader().load(\"img/particle2.png\")\n\t\t\t}\n\t\t};\n\n\t\t// Create the particles shader material\n\t\tvar material = new THREE.ShaderMaterial({\n\t\t\tuniforms : uniforms,\n\t\t\tvertexShader : document.getElementById(\"vertexShader\").textContent,\n\t\t\tfragmentShader : document.getElementById(\"fragmentShader\").textContent,\n\t\t\tdepthTest : false,\n\t\t\tlights : false,\n\t\t\ttransparent : true\n\t\t});\n\n\t\t// Create the particles and add them to the scene\n\t\tvar particles = new THREE.Points(geometry, material);\n\t\tscene.add(particles);\n\n\t\t// Add the event listeners\n\t\twindow.addEventListener(\"resize\", onWindowResize, false);\n\n\t\t// Initialize the frames counter\n\t\tframes = 0;\n\t}\n\n\t/*\n\t * Initializes and returns the GPU simulator\n\t */\n\tfunction getSimulator(simSizeX, simSizeY, renderer) {\n\t\t// Create a new GPU simulator instance\n\t\tvar gpuSimulator = new GPUComputationRenderer(simSizeX, simSizeY, renderer);\n\n\t\t// Create the position and the velocity textures\n\t\tvar positionTexture = gpuSimulator.createTexture();\n\t\tvar velocityTexture = gpuSimulator.createTexture();\n\n\t\t// Fill the texture data arrays with the simulation initial conditions\n\t\tsetInitialConditions(positionTexture, velocityTexture);\n\n\t\t// Add the position and velocity variables to the simulator\n\t\tvar positionVariable = gpuSimulator.addVariable(\"u_positionTexture\",\n\t\t\t\tdocument.getElementById(\"positionShader\").textContent, positionTexture);\n\t\tvar velocityVariable = gpuSimulator.addVariable(\"u_velocityTexture\",\n\t\t\t\tdocument.getElementById(\"velocityShader\").textContent, velocityTexture);\n\n\t\t// Specify the variable dependencies\n\t\tgpuSimulator.setVariableDependencies(positionVariable, [ positionVariable, velocityVariable ]);\n\t\tgpuSimulator.setVariableDependencies(velocityVariable, [ positionVariable, velocityVariable ]);\n\n\t\t// Add the position uniforms\n\t\tvar positionUniforms = positionVariable.material.uniforms;\n\t\tpositionUniforms.u_dt = {\n\t\t\ttype : \"f\",\n\t\t\tvalue : 0.2\n\t\t};\n\t\tpositionUniforms.u_nActiveParticles = {\n\t\t\ttype : \"f\",\n\t\t\tvalue : 1\n\t\t};\n\n\t\t// Add the velocity uniforms\n\t\tvar velocityUniforms = velocityVariable.material.uniforms;\n\t\tvelocityUniforms.u_dt = {\n\t\t\ttype : \"f\",\n\t\t\tvalue : positionUniforms.u_dt.value\n\t\t};\n\t\tvelocityUniforms.u_nActiveParticles = {\n\t\t\ttype : \"f\",\n\t\t\tvalue : positionUniforms.u_nActiveParticles.value\n\t\t};\n\t\tvelocityUniforms.u_bgTexture = {\n\t\t\ttype : \"t\",\n\t\t\tvalue : new THREE.TextureLoader().load(\"img/dali.jpg\")\n\t\t};\n\t\tvelocityUniforms.u_textureOffset = {\n\t\t\ttype : \"v2\",\n\t\t\tvalue : new THREE.Vector2(15, 15)\n\t\t};\n\n\t\t// Initialize the GPU simulator\n\t\tvar error = gpuSimulator.init();\n\n\t\tif (error !== null) {\n\t\t\tconsole.error(error);\n\t\t}\n\n\t\treturn gpuSimulator;\n\t}\n\n\t/*\n\t * Sets the simulation initial conditions\n\t */\n\tfunction setInitialConditions(positionTexture, velocityTexture) {\n\t\t// Get the position and velocity arrays\n\t\tvar position = positionTexture.image.data;\n\t\tvar velocity = velocityTexture.image.data;\n\n\t\t// Fill the position and velocity arrays\n\t\tvar nParticles = position.length / 4;\n\n\t\tfor (var i = 0; i < nParticles; i++) {\n\t\t\t// Get a random point inside a disk\n\t\t\tvar distance = 4 * Math.pow(Math.random(), 1 / 2);\n\t\t\tvar ang = 2 * Math.PI * Math.random();\n\n\t\t\t// Calculate the point x,y,z coordinates\n\t\t\tvar particleIndex = 4 * i;\n\t\t\tposition[particleIndex] = distance * Math.cos(ang);\n\t\t\tposition[particleIndex + 1] = distance * Math.sin(ang);\n\t\t\tposition[particleIndex + 2] = 0;\n\t\t\tposition[particleIndex + 3] = 1;\n\n\t\t\t// Start with zero initial velocity\n\t\t\tvelocity[particleIndex] = 0;\n\t\t\tvelocity[particleIndex + 1] = 0;\n\t\t\tvelocity[particleIndex + 2] = 0;\n\t\t\tvelocity[particleIndex + 3] = 1;\n\t\t}\n\t}\n\n\t/*\n\t * Returns the requested simulation variable\n\t */\n\tfunction getSimulationVariable(variableName, gpuSimulator) {\n\t\tfor (var i = 0; i < gpuSimulator.variables.length; i++) {\n\t\t\tif (gpuSimulator.variables[i].name === variableName) {\n\t\t\t\treturn gpuSimulator.variables[i];\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/*\n\t * Animates the sketch\n\t */\n\tfunction animate() {\n\t\trequestAnimationFrame(animate);\n\t\trender();\n\t\tstats.update();\n\t}\n\n\t/*\n\t * Renders the sketch\n\t */\n\tfunction render() {\n\t\t// Run several iterations per frame\n\t\tfor (var i = 0; i < 1; i++) {\n\t\t\tsimulator.compute();\n\t\t}\n\n\t\t// Update the uniforms\n\t\tvar nActiveParticles = Math.ceil(10 * frames);\n\t\tpositionVariable.material.uniforms.u_nActiveParticles.value = nActiveParticles;\n\t\tvelocityVariable.material.uniforms.u_nActiveParticles.value = nActiveParticles;\n\t\tuniforms.u_nActiveParticles.value = nActiveParticles;\n\t\tuniforms.u_positionTexture.value = simulator.getCurrentRenderTarget(positionVariable).texture;\n\t\tframes++;\n\n\t\t// Render the particles on the screen\n\t\trenderer.render(scene, camera);\n\n\t}\n\n\t/*\n\t * Updates the renderer size and the camera aspect ratio when the window is resized\n\t */\n\tfunction onWindowResize(event) {\n\t\t// Update the renderer\n\t\trenderer.setSize(window.innerWidth, window.innerHeight);\n\n\t\t// Update the camera\n\t\tcamera.aspect = window.innerWidth / window.innerHeight;\n\t\tcamera.updateProjectionMatrix();\n\t}\n}\n"
  },
  {
    "path": "WebContent/lens-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 2D\">\n<meta name=\"description\" content=\"lens shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>lens shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-filters.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-filters.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-lens.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the varyings\n    v_uv = uv;\n\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n\t// Set the lens radius\n\tfloat lens_radius = min(0.3 * u_resolution.x, 250.0);\n\n\t// Calculate the direction to the mouse position and the distance\n\tvec2 mouse_direction = u_mouse - gl_FragCoord.xy;\n\tfloat mouse_distance = length(mouse_direction);\n\n\t// Calculate the pixel color based on the mouse position\n\tvec3 pixel_color;\n\n\tif (mouse_distance < lens_radius) {\n\t\t// Calculate the pixel offset\n\t\tfloat exp = 1.0;\n\t\tvec2 offset = (1.0 - pow(mouse_distance / lens_radius, exp)) * mouse_direction;\n\n\t\t// Get the pixel color at the offset position\n\t\tpixel_color = texture2D(u_texture, v_uv + offset / u_resolution).rgb;\n\t} else {\n\t\t// Use the original image pixel color\n\t\tpixel_color = texture2D(u_texture, v_uv).rgb;\n\t}\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(pixel_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-filters.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/mountains-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 3D\">\n<meta name=\"description\" content=\"mountains shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>mountains shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-mountains.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-mountains.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-mountains.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * GLSL textureless classic 2D noise \"cnoise\",\n * with an RSL-style periodic variant \"pnoise\".\n * Author:  Stefan Gustavson (stefan.gustavson@liu.se)\n * Version: 2011-08-22\n *\n * Many thanks to Ian McEwan of Ashima Arts for the\n * ideas for permutation and gradient selection.\n *\n * Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n * Distributed under the MIT license. See LICENSE file.\n * https://github.com/stegu/webgl-noise\n */\n\nvec4 mod289(vec4 x) {\n    return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x) {\n    return mod289(((x * 34.0) + 1.0) * x);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n    return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nvec2 fade(vec2 t) {\n    return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n\nfloat cnoise(vec2 P) {\n    vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n    vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n    Pi = mod289(Pi);\n    vec4 ix = Pi.xzxz;\n    vec4 iy = Pi.yyww;\n    vec4 fx = Pf.xzxz;\n    vec4 fy = Pf.yyww;\n\n    vec4 i = permute(permute(ix) + iy);\n\n    vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0;\n    vec4 gy = abs(gx) - 0.5;\n    vec4 tx = floor(gx + 0.5);\n    gx = gx - tx;\n\n    vec2 g00 = vec2(gx.x, gy.x);\n    vec2 g10 = vec2(gx.y, gy.y);\n    vec2 g01 = vec2(gx.z, gy.z);\n    vec2 g11 = vec2(gx.w, gy.w);\n\n    vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n    g00 *= norm.x;\n    g01 *= norm.y;\n    g10 *= norm.z;\n    g11 *= norm.w;\n\n    float n00 = dot(g00, vec2(fx.x, fy.x));\n    float n10 = dot(g10, vec2(fx.y, fy.y));\n    float n01 = dot(g01, vec2(fx.z, fy.z));\n    float n11 = dot(g11, vec2(fx.w, fy.w));\n\n    vec2 fade_xy = fade(Pf.xy);\n    vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n    float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n    return 2.3 * n_xy;\n}\n\n// The plane tile size, the flying speed and the maximum mountain height\nuniform float u_tileSize;\nuniform float u_speed;\nuniform float u_maxHeight;\n\n// Varying containing the terrain elevation\nvarying float v_elevation;\n\n// Calculates the vertex displaced position\nvec3 getDisplacedPosition(vec3 position) {\n\t// Calculate the total flying distance\n\tfloat distance = u_speed * u_time;\n\n\t// Calculate the vertex horizontal shift\n\tfloat h_shift = mod(distance, u_tileSize);\n\n\t// Calculate the vertex vertical shift\n\tfloat v_shift = u_maxHeight * cnoise(0.4 * floor(vec2(position.x, position.z - distance) / u_tileSize));\n\n\t// Flatten the bottom to simulate the lakes\n\tv_shift = max(-0.8 * u_maxHeight, v_shift);\n\n\treturn position + vec3(0.0, v_shift, h_shift);\n}\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new vertex position\n\tvec3 new_position = getDisplacedPosition(position);\n\n\t// Calculate the modelview position\n\tvec4 mv_position = modelViewMatrix * vec4(new_position, 1.0);\n\n\t// Save the varyings\n\tv_position = mv_position.xyz;\n\tv_elevation = 0.5 * (u_maxHeight + new_position.y);\n\n\t// Vertex shader output\n\tgl_Position = projectionMatrix * mv_position;\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n *  Calculates the normal vector at the given position\n *\n *  Uses this fix for some mobiles:\n *  https://stackoverflow.com/questions/20272272/standard-derivatives-from-fragment-shader-dfdx-dfdy-dont-run-correctly-in-a\n */\nvec3 calculateNormal(vec3 position) {\n    vec3 fdx = vec3(dFdx(position.x), dFdx(position.y), dFdx(position.z));\n    vec3 fdy = vec3(dFdy(position.x), dFdy(position.y), dFdy(position.z));\n    vec3 normal = normalize(cross(fdx, fdy));\n\n    if (!gl_FrontFacing) {\n        normal = -normal;\n    }\n\n    return normal;\n}\n\n/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n// The plane tile size, the maximum mountain height and the sky color\nuniform float u_tileSize;\nuniform float u_maxHeight;\nuniform vec3 u_skyColor;\n\n// Varying containing the terrain elevation\nvarying float v_elevation;\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new normal vector\n\tvec3 new_normal = calculateNormal(v_position);\n\n\t// Use the mouse position to define the light direction\n\tfloat min_resolution = min(u_resolution.x, u_resolution.y);\n\tvec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.25);\n\n\t// Set the default surface color\n\tvec3 surface_color = vec3(0.3, 0.65, 0.0);\n\n\t// Change the color for the snow peaks and the lakes\n\tif (v_elevation > 0.85 * u_maxHeight) {\n\t\tsurface_color = vec3(1.0, 1.0, 1.0);\n\t} else if (v_elevation < 0.2 * u_maxHeight) {\n\t\tsurface_color = vec3(0.3, 0.7, 0.9);\n\t}\n\n\t// Apply the light diffusion factor\n\tsurface_color *= diffuseFactor(new_normal, light_direction);\n\n\t// Add a fog effect\n\tfloat fog_factor = clamp(0.0, 1.0, -(1.0 - u_mouse.y / u_resolution.y) * v_position.z / (15.0 * u_tileSize));\n\tsurface_color = mix(surface_color, u_skyColor, fog_factor);\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(surface_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-mountains.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/noise-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 2D\">\n<meta name=\"description\" content=\"noise shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>noise shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-2d.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-2d.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-noise.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n/*\n * The main program\n */\nvoid main() {\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n/*\n * GLSL textureless classic 2D noise \"cnoise\",\n * with an RSL-style periodic variant \"pnoise\".\n * Author:  Stefan Gustavson (stefan.gustavson@liu.se)\n * Version: 2011-08-22\n *\n * Many thanks to Ian McEwan of Ashima Arts for the\n * ideas for permutation and gradient selection.\n *\n * Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n * Distributed under the MIT license. See LICENSE file.\n * https://github.com/stegu/webgl-noise\n */\n\nvec4 mod289(vec4 x) {\n    return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x) {\n    return mod289(((x * 34.0) + 1.0) * x);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n    return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nvec2 fade(vec2 t) {\n    return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n\nfloat cnoise(vec2 P) {\n    vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n    vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n    Pi = mod289(Pi);\n    vec4 ix = Pi.xzxz;\n    vec4 iy = Pi.yyww;\n    vec4 fx = Pf.xzxz;\n    vec4 fy = Pf.yyww;\n\n    vec4 i = permute(permute(ix) + iy);\n\n    vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0;\n    vec4 gy = abs(gx) - 0.5;\n    vec4 tx = floor(gx + 0.5);\n    gx = gx - tx;\n\n    vec2 g00 = vec2(gx.x, gy.x);\n    vec2 g10 = vec2(gx.y, gy.y);\n    vec2 g01 = vec2(gx.z, gy.z);\n    vec2 g11 = vec2(gx.w, gy.w);\n\n    vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n    g00 *= norm.x;\n    g01 *= norm.y;\n    g10 *= norm.z;\n    g11 *= norm.w;\n\n    float n00 = dot(g00, vec2(fx.x, fy.x));\n    float n10 = dot(g10, vec2(fx.y, fy.y));\n    float n01 = dot(g01, vec2(fx.z, fy.z));\n    float n11 = dot(g11, vec2(fx.w, fy.w));\n\n    vec2 fade_xy = fade(Pf.xy);\n    vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n    float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n    return 2.3 * n_xy;\n}\n\n/*\n * Combines the 2d noise function at three different scales\n */\nfloat multy_scale_noise(vec2 p, vec2 rel_mouse_pos) {\n    return 0.8 * cnoise(5.0 * p) + rel_mouse_pos.x * cnoise(15.0 * p) + rel_mouse_pos.y * cnoise(60.0 * p);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Normalize the pixel and mouse positions to the maximum scale dimension\n    float max_dim = max(u_resolution.x, u_resolution.y);\n    vec2 rel_pixel_pos = gl_FragCoord.xy / max_dim;\n    vec2 rel_mouse_pos = u_mouse / max_dim;\n\n    // Use a slightly shifted noise value for each color\n    float r = multy_scale_noise(rel_pixel_pos + 0.05 * rel_mouse_pos, rel_mouse_pos);\n    float g = multy_scale_noise(rel_pixel_pos + 0.05 * rel_mouse_pos.yx, rel_mouse_pos);\n    float b = multy_scale_noise(rel_pixel_pos - 0.05 * rel_mouse_pos, rel_mouse_pos);\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(r, g, b), 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-2d.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/objects/suzanne_buffergeometry.json",
    "content": "{\n    \"metadata\":{\n        \"position\":505,\n        \"type\":\"BufferGeometry\",\n        \"generator\":\"io_three\",\n        \"version\":3\n    },\n    \"data\":{\n        \"attributes\":{\n            \"position\":{\n                \"itemSize\":3,\n                \"type\":\"Float32Array\",\n                \"array\":[0.46875,0.242188,0.757812,0.5,0.09375,0.6875,0.5625,0.242188,0.671875,-0.5,0.09375,0.6875,-0.46875,0.242188,0.757812,-0.5625,0.242188,0.671875,0.546875,0.0546875,0.578125,0.625,0.242188,0.5625,-0.546875,0.0546875,0.578125,-0.625,0.242188,0.5625,0.351562,-0.0234375,0.617188,-0.351562,-0.0234375,0.617188,0.4375,0.164063,0.765625,0.351562,0.03125,0.71875,-0.351562,0.03125,0.71875,-0.4375,0.164063,0.765625,0.351562,0.132813,0.78125,0.203125,0.09375,0.742188,-0.203125,0.09375,0.742188,-0.351562,0.132813,0.78125,0.15625,0.0546875,0.648438,-0.15625,0.0546875,0.648438,0.140625,0.242188,0.742188,-0.140625,0.242188,0.742188,-0.078125,0.242188,0.65625,0.242188,0.242188,0.796875,0.273438,0.164063,0.796875,-0.242188,0.242188,0.796875,0.203125,0.390625,0.742188,-0.203125,0.390625,0.742188,0.078125,0.242188,0.65625,-0.15625,0.4375,0.648438,0.351562,0.453125,0.71875,0.15625,0.4375,0.648438,-0.351562,0.453125,0.71875,-0.351562,0.515625,0.617188,0.351562,0.359375,0.78125,0.273438,0.328125,0.796875,-0.351562,0.359375,0.78125,0.4375,0.328125,0.765625,-0.4375,0.328125,0.765625,-0.5,0.390625,0.6875,0.5,0.390625,0.6875,0.351562,0.515625,0.617188,-0.546875,0.4375,0.578125,0.546875,0.4375,0.578125,0.476562,0.242188,0.773438,-0.476562,0.242188,0.773438,-0.445312,0.335938,0.78125,0.445312,0.335938,0.78125,-0.351562,0.375,0.804688,0.351562,0.375,0.804688,-0.273438,0.328125,0.796875,-0.265625,0.335938,0.820312,0.265625,0.335938,0.820312,-0.226562,0.242188,0.820312,0.265625,0.15625,0.820312,0.226562,0.242188,0.820312,-0.265625,0.15625,0.820312,0.351562,0.117188,0.804688,-0.351562,0.117188,0.804688,-0.273438,0.164063,0.796875,0.445312,0.15625,0.78125,-0.445312,0.15625,0.78125,0.351562,0.242188,0.828125,-0.351562,0.242188,0.828125,0.164062,-0.929688,0.632813,0,-0.984375,0.578125,0.179688,-0.96875,0.554688,-0.164062,-0.929688,0.632813,0,-0.945312,0.640625,0.234375,-0.914062,0.632813,0.328125,-0.945312,0.523438,-0.234375,-0.914062,0.632813,-0.179688,-0.96875,0.554688,0.367188,-0.890625,0.53125,-0.367188,-0.890625,0.53125,-0.328125,-0.945312,0.523438,0.351562,-0.695312,0.570313,0.265625,-0.820312,0.664063,-0.265625,-0.820312,0.664063,-0.351562,-0.695312,0.570313,0.3125,-0.4375,0.570312,0.25,-0.703125,0.6875,-0.25,-0.703125,0.6875,-0.3125,-0.4375,0.570312,0.203125,-0.1875,0.5625,0.398438,-0.046875,0.671875,0.125,-0.101562,0.8125,-0.398438,-0.046875,0.671875,-0.203125,-0.1875,0.5625,-0.125,-0.101562,0.8125,0.632812,-0.0390625,0.539062,0.4375,-0.140625,0.53125,-0.632812,-0.0390625,0.539062,-0.617188,0.0546875,0.625,0.726562,0.203125,0.601562,0.617188,0.0546875,0.625,-0.726562,0.203125,0.601562,0.859375,0.429688,0.59375,0.828125,0.148438,0.445312,-0.859375,0.429688,0.59375,-0.742188,0.375,0.65625,0.710938,0.484375,0.625,0.742188,0.375,0.65625,-0.710938,0.484375,0.625,-0.6875,0.414063,0.726562,0.492188,0.601563,0.6875,0.6875,0.414063,0.726562,-0.492188,0.601563,0.6875,-0.4375,0.546875,0.796875,0.3125,0.640625,0.835938,0.4375,0.546875,0.796875,-0.3125,0.640625,0.835938,0.15625,0.71875,0.757812,0.320312,0.757813,0.734375,-0.15625,0.71875,0.757812,-0.203125,0.617188,0.851562,0.0625,0.492188,0.75,0.203125,0.617188,0.851562,-0.0625,0.492188,0.75,-0.101562,0.429688,0.84375,0,0.429688,0.742188,0.101562,0.429688,0.84375,0,0.351563,0.820312,0.25,0.46875,0.757812,0.164062,0.414063,0.773438,-0.25,0.46875,0.757812,0.328125,0.476563,0.742188,0.429688,0.4375,0.71875,-0.328125,0.476563,0.742188,0.601562,0.375,0.664062,-0.429688,0.4375,0.71875,0.640625,0.296875,0.648438,-0.601562,0.375,0.664062,0.625,0.1875,0.648438,-0.640625,0.296875,0.648438,0.492188,0.0625,0.671875,-0.625,0.1875,0.648438,0.375,0.015625,0.703125,-0.492188,0.0625,0.671875,-0.375,0.015625,0.703125,0,0.046875,0.726562,0.125,0.304688,0.765625,-0.125,0.304688,0.765625,0,0.210938,0.765625,0.132812,0.210938,0.757812,-0.132812,0.210938,0.757812,0.164062,0.140625,0.75,-0.164062,0.140625,0.75,0.0625,-0.882812,0.695313,-0.0625,-0.882812,0.695313,0.117188,-0.835937,0.710938,-0.117188,-0.835937,0.710938,0.109375,-0.71875,0.734375,0.210938,-0.445312,0.710938,0.117188,-0.6875,0.734375,-0.117188,-0.6875,0.734375,-0.210938,-0.445312,0.710938,-0.109375,-0.71875,0.734375,0,-0.328125,0.742188,0.078125,-0.445312,0.75,0.0859375,-0.289062,0.742188,-0.078125,-0.445312,0.75,0,-0.445312,0.75,0,-0.679687,0.734375,0,-0.765625,0.734375,0.125,-0.226562,0.75,0.09375,-0.273437,0.78125,-0.09375,-0.273437,0.78125,-0.125,-0.226562,0.75,-0.0859375,-0.289062,0.742188,0.109375,-0.132812,0.78125,0.101562,-0.148437,0.742188,-0.109375,-0.132812,0.78125,-0.132812,-0.226562,0.796875,0.0390625,-0.125,0.78125,0,-0.140625,0.742188,-0.0390625,-0.125,0.78125,-0.101562,-0.148437,0.742188,0,-0.1875,0.796875,0,-0.195312,0.75,0,-0.320312,0.78125,0,-0.289062,0.804688,-0.078125,-0.25,0.804688,0.046875,-0.148437,0.8125,-0.046875,-0.148437,0.8125,0.09375,-0.15625,0.8125,-0.09375,-0.15625,0.8125,0.132812,-0.226562,0.796875,-0.109375,-0.226562,0.828125,0.078125,-0.25,0.804688,0.109375,-0.226562,0.828125,0,-0.203125,0.828125,0.164062,-0.242187,0.710938,-0.164062,-0.242187,0.710938,-0.179688,-0.3125,0.710938,0.179688,-0.3125,0.710938,0.257812,-0.3125,0.554688,-0.257812,-0.3125,0.554688,0.234375,-0.25,0.554688,-0.234375,-0.25,0.554688,0.09375,-0.742187,0.726563,-0.09375,-0.742187,0.726563,0,-0.773437,0.71875,0.09375,-0.820312,0.710938,-0.09375,-0.820312,0.710938,0.046875,-0.867187,0.6875,-0.046875,-0.867187,0.6875,0,-0.890625,0.6875,0,-0.875,0.6875,0,-0.859375,0.632813,-0.046875,-0.851562,0.632813,0.09375,-0.8125,0.640625,0.046875,-0.851562,0.632813,-0.09375,-0.8125,0.640625,0.09375,-0.75,0.664063,-0.09375,-0.75,0.664063,0,-0.78125,0.65625,0.1875,0.15625,0.773438,0.171875,0.21875,0.78125,-0.1875,0.15625,0.773438,-0.171875,0.21875,0.78125,0.179688,0.296875,0.78125,-0.179688,0.296875,0.78125,0.210938,0.375,0.78125,-0.210938,0.375,0.78125,-0.226562,0.109375,0.78125,0.375,0.0625,0.742188,0.226562,0.109375,0.78125,-0.375,0.0625,0.742188,0.476562,0.101563,0.71875,-0.476562,0.101563,0.71875,0.578125,0.195313,0.679688,-0.578125,0.195313,0.679688,0.585938,0.289063,0.6875,-0.585938,0.289063,0.6875,-0.5625,0.351563,0.695312,0.5625,0.351563,0.695312,-0.421875,0.398438,0.773438,0.335938,0.429688,0.757812,0.421875,0.398438,0.773438,-0.335938,0.429688,0.757812,0.273438,0.421875,0.773438,-0.273438,0.421875,0.773438,0.234375,0.359375,0.757812,0.28125,0.398438,0.765625,-0.234375,0.359375,0.757812,-0.28125,0.398438,0.765625,0.335938,0.40625,0.75,-0.335938,0.40625,0.75,0.414062,0.390625,0.75,-0.414062,0.390625,0.75,0.53125,0.335938,0.679688,-0.53125,0.335938,0.679688,0.554688,0.28125,0.671875,-0.554688,0.28125,0.671875,0.546875,0.210938,0.671875,-0.546875,0.210938,0.671875,0.460938,0.117188,0.703125,-0.460938,0.117188,0.703125,0.375,0.0859375,0.726562,-0.375,0.0859375,0.726562,0.242188,0.125,0.757812,-0.242188,0.125,0.757812,0.203125,0.171875,0.75,-0.203125,0.171875,0.75,0.195312,0.296875,0.757812,-0.195312,0.296875,0.757812,0.195312,0.226563,0.75,-0.195312,0.226563,0.75,0.109375,0.460938,0.609375,0,0.40625,0.601562,-0.109375,0.460938,0.609375,0.195312,0.664062,0.617188,-0.195312,0.664062,0.617188,-0.320312,0.757813,0.734375,-0.335938,0.6875,0.59375,0.335938,0.6875,0.59375,-0.484375,0.554688,0.554688,0.484375,0.554688,0.554688,-0.679688,0.453125,0.492187,0.796875,0.40625,0.460937,0.679688,0.453125,0.492187,-0.796875,0.40625,0.460937,-0.828125,0.148438,0.445312,-0.773438,0.164063,0.375,0.601562,1.80992e-08,0.414062,0.773438,0.164063,0.375,-0.601562,1.80992e-08,0.414062,0.4375,-0.09375,0.46875,-0.4375,-0.09375,0.46875,0,-0.484375,0.28125,0.125,-0.539062,0.359375,0,-0.570312,0.320313,-0.125,-0.539062,0.359375,-0.179688,-0.414062,0.257813,0.140625,-0.757812,0.367188,0,-0.804688,0.34375,-0.140625,-0.757812,0.367188,0.164062,-0.945312,0.4375,0,-0.976562,0.460938,-0.164062,-0.945312,0.4375,0.328125,-0.914062,0.398438,-0.328125,-0.914062,0.398438,0.289062,-0.710938,0.382813,-0.289062,-0.710938,0.382813,0.25,-0.5,0.390625,-0.25,-0.5,0.390625,0.179688,-0.414062,0.257813,0.234375,-0.351562,0.40625,-0.234375,-0.351562,0.40625,0.21875,-0.28125,0.429688,-0.21875,-0.28125,0.429688,-0.210938,-0.226562,0.46875,0.203125,-0.171875,0.5,-0.203125,-0.171875,0.5,-0.4375,-0.140625,0.53125,0.335938,0.0546875,-0.664062,0,-0.195313,-0.671875,0,0.0703125,-0.828125,-0.335938,0.0546875,-0.664062,-0.34375,-0.148438,-0.539062,0.34375,-0.148438,-0.539062,0,-0.382813,-0.351562,-0.296875,-0.3125,-0.265625,0.210938,-0.390625,0.164063,0,-0.460938,0.1875,-0.210938,-0.390625,0.164063,0.734375,-0.046875,0.0703125,0.851562,0.234375,0.0546875,-0.734375,-0.046875,0.0703125,-0.851562,0.234375,0.0546875,0.460938,0.4375,-0.703125,0,0.5625,-0.851562,-0.460938,0.4375,-0.703125,0.453125,0.851562,0.234375,0,0.984375,-0.078125,0,0.898438,0.289062,-0.453125,0.851562,0.234375,-0.453125,0.929688,-0.0703125,0.453125,0.867188,-0.382813,0,0.898438,-0.546875,-0.453125,0.867188,-0.382813,0.726562,0.40625,0.335937,0.632812,0.453125,0.28125,-0.726562,0.40625,0.335937,-0.632812,0.453125,0.28125,0.796875,0.5625,0.125,0.640625,0.703125,0.0546875,-0.796875,0.5625,0.125,-0.640625,0.703125,0.0546875,0.796875,0.617188,-0.117188,0.640625,0.75,-0.195313,-0.796875,0.617188,-0.117188,-0.640625,0.75,-0.195313,0.796875,0.539062,-0.359375,0.640625,0.679688,-0.445313,-0.796875,0.539062,-0.359375,-0.640625,0.679688,-0.445313,0.617188,0.328125,-0.585938,0.773438,0.265625,-0.4375,-0.617188,0.328125,-0.585938,0.453125,0.929688,-0.0703125,0.460938,0.523438,0.429687,-0.460938,0.523438,0.429687,0,0.570312,0.570312,0.859375,0.320312,-0.046875,-0.859375,0.320312,-0.046875,0.820312,0.328125,-0.203125,-0.820312,0.328125,-0.203125,0.296875,-0.3125,-0.265625,0.40625,-0.171875,0.148438,-0.40625,-0.171875,0.148438,-0.429688,-0.195313,-0.210937,0.59375,-0.125,-0.164062,-0.59375,-0.125,-0.164062,0.210938,-0.226562,0.46875,0.640625,-0.00781252,-0.429688,-0.640625,-0.00781252,-0.429688,-0.484375,0.0234375,-0.546875,0.429688,-0.195313,-0.210937,0.484375,0.0234375,-0.546875,0.890625,0.40625,-0.234375,1.01562,0.414062,-0.289063,1.02344,0.476562,-0.3125,-0.890625,0.40625,-0.234375,-1.01562,0.414062,-0.289063,-0.921875,0.359375,-0.21875,1.1875,0.4375,-0.390625,1.23438,0.507812,-0.421875,-1.1875,0.4375,-0.390625,-1.02344,0.476562,-0.3125,-1.23438,0.507812,-0.421875,1.35156,0.320312,-0.421875,-1.35156,0.320312,-0.421875,-1.26562,0.289062,-0.40625,1.26562,0.289062,-0.40625,1.28125,0.0546875,-0.429688,-1.28125,0.0546875,-0.429688,-1.21094,0.078125,-0.40625,1.21094,0.078125,-0.40625,1.03906,-0.101563,-0.328125,-1.03906,-0.101563,-0.328125,-1.03125,-0.0390625,-0.304688,0.828125,-0.0703125,-0.132812,0.773438,-0.140625,-0.125,-0.828125,-0.0703125,-0.132812,-0.773438,-0.140625,-0.125,1.03125,-0.0390625,-0.304688,0.882812,-0.0234375,-0.210938,-0.882812,-0.0234375,-0.210938,1.03906,-1.60503e-08,-0.367188,-1.03906,-1.60503e-08,-0.367188,1.23438,0.25,-0.445312,-1.23438,0.25,-0.445312,-1.1875,0.09375,-0.445312,1.17188,0.359375,-0.4375,-1.17188,0.359375,-0.4375,1.02344,0.34375,-0.359375,-1.02344,0.34375,-0.359375,0.945312,0.304688,-0.289062,-0.945312,0.304688,-0.289062,0.726562,-3.07346e-09,-0.0703125,-0.726562,-3.07346e-09,-0.0703125,-0.71875,-0.0234375,-0.171875,0.71875,-0.0234375,-0.171875,0.921875,0.359375,-0.21875,0.8125,-0.015625,-0.273438,-0.8125,-0.015625,-0.273438,0.71875,0.0390625,-0.1875,0.84375,0.015625,-0.273438,-0.71875,0.0390625,-0.1875,0.757812,0.09375,-0.273438,0.820312,0.0859375,-0.273438,-0.84375,0.015625,-0.273438,-0.757812,0.09375,-0.273438,-0.820312,0.0859375,-0.273438,0.796875,0.203125,-0.210938,0.835938,0.171875,-0.273438,-0.796875,0.203125,-0.210938,0.890625,0.242187,-0.265625,0.84375,0.289062,-0.210938,-0.890625,0.242187,-0.265625,-0.835938,0.171875,-0.273438,-0.84375,0.289062,-0.210938,0.890625,0.234375,-0.320312,0.953125,0.289062,-0.34375,-0.890625,0.234375,-0.320312,-0.953125,0.289062,-0.34375,-0.84375,0.171875,-0.320312,0.765625,0.09375,-0.320312,0.84375,0.171875,-0.320312,-0.765625,0.09375,-0.320312,-0.828125,0.078125,-0.320312,0.828125,0.078125,-0.320312,-0.851562,0.015625,-0.320312,0.8125,-0.015625,-0.320312,0.851562,0.015625,-0.320312,-0.8125,-0.015625,-0.320312,0.882812,-0.015625,-0.265625,-0.882812,-0.015625,-0.265625,1.03906,0.328125,-0.414062,-1.03906,0.328125,-0.414062,1.1875,0.34375,-0.484375,-1.1875,0.34375,-0.484375,1.25781,0.242187,-0.492188,-1.25781,0.242187,-0.492188,1.21094,0.0859375,-0.484375,1.1875,0.09375,-0.445312,-1.21094,0.0859375,-0.484375,1.04688,-1.84407e-08,-0.421875,-1.04688,-1.84407e-08,-0.421875,0.890625,0.109375,-0.328125,-0.890625,0.109375,-0.328125,-0.9375,0.0625,-0.335938,0.9375,0.0625,-0.335938,0.960938,0.171875,-0.351562,-0.960938,0.171875,-0.351562,-1,0.125,-0.367188,1.05469,0.1875,-0.382812,1.01562,0.234375,-0.375,-1.05469,0.1875,-0.382812,-1.01562,0.234375,-0.375,1.08594,0.273437,-0.390625,-1.08594,0.273437,-0.390625,-1.10938,0.210937,-0.390625,1.10938,0.210937,-0.390625,0.789062,-0.125,-0.328125,1.03906,-0.0859375,-0.492188,-0.789062,-0.125,-0.328125,-1.03906,-0.0859375,-0.492188,1.3125,0.0546875,-0.53125,-1.3125,0.0546875,-0.53125,1.36719,0.296875,-0.5,-1.36719,0.296875,-0.5,1.25,0.46875,-0.546875,-1.25,0.46875,-0.546875,1.02344,0.4375,-0.484375,-1.02344,0.4375,-0.484375,0.859375,0.382812,-0.382813,-0.859375,0.382812,-0.382813,-0.773438,0.265625,-0.4375,-0.164062,0.414063,0.773438,1,0.125,-0.367188]\n            }\n        },\n        \"index\":{\n            \"itemSize\":1,\n            \"type\":\"Uint16Array\",\n            \"array\":[0,1,2,3,4,5,2,6,7,8,5,9,1,10,6,11,3,8,12,13,1,14,15,3,16,17,13,18,19,14,13,20,10,21,14,11,22,20,17,23,21,24,25,17,26,27,18,23,25,28,22,29,27,23,28,30,22,29,24,31,32,33,28,34,31,35,36,28,37,38,29,34,39,32,36,40,34,41,42,43,32,41,35,44,2,45,42,5,44,9,0,42,39,4,41,5,39,46,0,40,47,48,36,49,39,38,48,50,37,51,36,52,50,53,25,54,37,27,53,55,25,56,57,58,27,55,26,59,56,60,61,58,16,62,59,63,19,60,12,46,62,47,15,63,64,62,46,47,63,65,59,62,64,65,63,60,64,56,59,60,58,65,64,57,56,58,55,65,64,54,57,55,53,65,64,51,54,53,50,65,64,49,51,50,48,65,64,46,49,48,47,65,66,67,68,69,67,70,71,68,72,73,74,69,75,71,72,73,76,77,78,79,75,80,81,76,82,83,78,84,85,81,86,87,88,89,90,91,92,87,93,94,89,95,92,96,97,98,94,95,99,96,100,101,98,102,103,104,99,105,102,106,107,108,103,109,106,110,107,111,112,113,109,110,114,111,115,116,113,117,118,119,114,120,117,121,122,123,118,122,121,124,125,123,126,127,121,117,125,111,119,113,127,117,112,128,129,110,130,113,108,129,131,106,132,110,104,131,133,102,134,106,96,133,135,98,136,102,97,135,137,95,138,98,87,137,139,89,140,95,17,87,139,89,18,141,17,142,88,142,18,91,123,143,126,121,144,124,143,145,146,145,144,147,148,145,142,149,145,147,150,70,66,70,151,69,152,66,71,69,153,73,152,79,154,153,80,73,155,156,83,157,158,84,154,83,156,84,159,157,160,161,162,160,163,164,161,165,156,163,165,164,154,165,166,159,165,157,167,168,162,169,170,171,172,167,173,174,170,175,176,173,177,178,179,174,180,177,181,180,177,178,162,182,160,171,182,169,168,183,182,169,183,184,180,185,176,186,180,178,176,187,172,188,178,174,187,189,172,188,175,190,189,191,168,184,175,169,192,185,193,190,186,188,193,191,192,184,193,190,177,88,142,91,177,142,173,194,88,195,179,91,162,194,167,171,195,196,161,197,162,163,196,158,198,155,82,199,158,196,200,197,198,201,196,195,86,194,200,195,90,201,166,202,154,166,203,204,152,202,205,203,153,206,150,205,207,206,151,208,209,207,210,208,209,210,207,211,210,208,211,212,207,213,214,215,208,212,205,216,213,217,206,215,204,216,202,204,217,218,218,214,216,212,218,217,216,214,213,215,212,217,146,219,220,221,147,222,143,220,223,222,144,224,143,225,126,144,226,224,17,219,148,18,221,227,17,228,229,230,18,227,139,231,228,232,141,230,137,233,231,234,140,232,135,235,233,236,138,234,131,235,133,134,236,237,129,238,131,132,237,239,129,240,241,242,132,239,128,243,240,244,130,242,125,225,243,226,127,244,243,245,246,247,244,248,240,246,249,248,242,250,240,251,241,242,252,250,241,253,238,239,254,252,235,253,255,254,236,256,235,257,233,236,258,256,231,257,259,258,232,260,231,261,228,232,262,260,228,263,229,230,264,262,219,263,265,264,221,266,225,267,245,268,226,247,223,269,267,270,224,268,220,265,269,266,222,270,122,271,272,273,122,272,118,274,271,275,120,273,115,274,114,276,275,277,107,278,115,109,277,279,103,280,107,105,279,281,103,282,283,284,105,281,100,282,99,285,284,286,100,287,288,289,285,286,92,290,287,291,94,289,292,293,294,292,295,296,294,297,298,294,299,295,298,300,301,298,302,299,68,301,300,301,74,302,72,300,303,302,77,304,75,303,305,304,76,306,78,305,307,306,81,308,305,293,307,295,306,308,303,297,305,304,299,302,307,309,310,308,296,295,82,307,310,308,85,311,312,200,198,313,201,314,310,198,82,311,199,313,200,315,86,201,316,314,315,93,86,316,317,291,318,319,320,321,319,322,323,324,319,322,324,325,324,326,327,328,324,327,327,309,292,296,327,292,309,312,310,296,313,328,288,329,330,331,286,332,333,320,334,335,320,321,336,337,338,339,337,340,337,341,342,343,337,342,342,333,334,335,342,334,283,344,345,346,281,347,345,348,349,350,347,351,349,352,353,354,351,355,353,356,357,358,355,359,360,356,361,362,358,359,333,357,360,359,335,362,341,353,357,355,343,359,363,349,353,351,340,355,336,345,349,347,339,351,283,364,280,281,365,347,364,338,366,365,338,339,274,280,271,275,279,277,271,364,366,365,273,366,272,271,366,366,273,272,288,344,282,286,346,332,330,348,344,350,332,346,367,352,348,354,368,350,356,369,361,358,370,354,371,372,326,325,373,374,372,375,329,373,376,374,287,372,329,373,289,331,290,312,372,313,291,373,312,326,372,373,328,313,290,315,377,314,316,291,378,360,361,379,362,380,360,318,333,362,321,380,381,378,375,374,379,380,323,381,371,322,374,380,318,382,323,322,380,321,383,384,385,386,387,388,385,389,390,391,392,393,389,394,390,391,395,396,397,398,394,396,399,400,401,402,398,400,403,404,402,405,406,407,403,408,409,410,405,411,404,407,401,412,409,413,400,404,414,401,397,415,400,416,417,397,389,418,396,415,419,389,384,420,391,418,384,421,419,422,387,420,375,423,329,376,424,425,406,426,375,408,425,407,330,423,367,424,332,368,369,427,383,388,370,386,405,428,426,429,407,425,430,428,431,432,429,425,433,431,434,435,436,437,438,433,439,440,436,432,438,441,442,440,443,444,442,421,427,445,422,443,438,369,367,440,370,445,423,438,367,424,440,432,423,426,430,432,425,424,421,446,447,448,422,449,439,446,441,444,448,450,439,451,452,453,444,450,434,451,433,437,453,454,431,455,434,435,454,456,431,457,458,459,435,456,428,460,457,461,429,459,419,447,462,449,420,463,417,462,464,463,418,465,414,464,466,465,415,467,414,468,469,415,470,467,469,471,412,416,472,470,412,460,410,413,461,472,458,473,455,456,474,475,476,477,473,475,478,479,477,480,481,482,478,483,480,484,481,482,485,486,462,481,484,483,463,485,477,447,446,478,449,483,452,477,446,450,478,474,455,452,451,450,454,453,460,458,457,461,456,475,471,476,460,475,472,461,480,471,468,482,472,479,487,468,466,486,470,482,464,487,466,486,465,467,462,484,464,465,485,463,402,488,489,490,403,491,398,489,492,491,399,493,398,494,394,399,495,493,394,496,390,395,497,495,390,498,385,393,499,497,385,500,383,392,501,499,489,500,498,491,501,490,498,492,489,493,499,491,496,494,492,493,495,497,369,500,361,370,501,386,361,488,378,490,502,379,375,488,406,490,376,408,0,12,1,3,15,4,2,1,6,8,3,5,1,13,10,11,14,3,12,16,13,14,19,15,16,26,17,18,61,19,13,17,20,21,18,14,22,30,20,23,18,21,25,22,17,27,61,18,25,37,28,29,52,27,28,33,30,29,23,24,32,43,33,34,29,31,36,32,28,38,52,29,39,42,32,40,38,34,42,45,43,41,34,35,2,7,45,5,41,44,0,2,42,4,40,41,39,49,46,40,4,47,36,51,49,38,40,48,37,54,51,52,38,50,25,57,54,27,52,53,25,26,56,58,61,27,26,16,59,60,19,61,16,12,62,63,15,19,12,0,46,47,4,15,66,70,67,69,74,67,71,66,68,73,77,74,75,79,71,73,80,76,78,83,79,80,84,81,82,155,83,84,158,85,86,93,87,89,317,90,92,97,87,94,317,89,92,100,96,98,285,94,99,104,96,101,285,98,103,108,104,105,101,102,107,112,108,109,105,106,107,115,111,113,276,109,114,119,111,116,276,113,118,123,119,120,116,117,122,124,123,122,120,121,125,119,123,127,503,121,125,128,111,113,130,127,112,111,128,110,132,130,108,112,129,106,134,132,104,108,131,102,136,134,96,104,133,98,138,136,97,96,135,95,140,138,87,97,137,89,141,140,17,88,87,89,91,18,17,148,142,142,149,18,123,124,143,121,503,144,143,124,145,145,124,144,148,146,145,149,142,145,150,209,70,70,209,151,152,150,66,69,151,153,152,71,79,153,159,80,155,161,156,157,163,158,154,79,83,84,80,159,160,164,161,160,171,163,161,164,165,163,157,165,154,156,165,159,166,165,167,189,168,169,175,170,172,189,167,174,179,170,176,172,173,178,177,179,180,176,177,162,168,182,171,160,182,168,191,183,169,182,183,180,193,185,186,193,180,176,185,187,188,186,178,187,192,189,188,174,175,189,192,191,184,190,175,192,187,185,190,193,186,193,183,191,184,183,193,177,173,88,91,179,177,173,167,194,195,170,179,162,197,194,171,170,195,161,155,197,163,171,196,198,197,155,199,85,158,200,194,197,201,199,196,86,88,194,195,91,90,166,204,202,166,159,203,152,154,202,203,159,153,150,152,205,206,153,151,209,150,207,208,151,209,207,214,211,208,210,211,207,205,213,215,206,208,205,202,216,217,203,206,204,218,216,204,203,217,218,211,214,212,211,218,146,148,219,221,149,147,143,146,220,222,147,144,143,223,225,144,503,226,17,229,219,18,149,221,17,139,228,230,141,18,139,137,231,232,140,141,137,135,233,234,138,140,135,133,235,236,136,138,131,238,235,134,136,236,129,241,238,132,134,237,129,128,240,242,130,132,128,125,243,244,127,130,125,126,225,226,503,127,243,225,245,247,226,244,240,243,246,248,244,242,240,249,251,242,239,252,241,251,253,239,237,254,235,238,253,254,237,236,235,255,257,236,234,258,231,233,257,258,234,232,231,259,261,232,230,262,228,261,263,230,227,264,219,229,263,264,227,221,225,223,267,268,224,226,223,220,269,270,222,224,220,219,265,266,221,222,122,118,271,273,120,122,118,114,274,275,116,120,115,278,274,276,116,275,107,280,278,109,276,277,103,283,280,105,109,279,103,99,282,284,101,105,100,288,282,285,101,284,100,92,287,289,94,285,92,93,290,291,317,94,292,309,293,292,294,295,294,293,297,294,298,299,298,297,300,298,301,302,68,67,301,301,67,74,72,68,300,302,74,77,75,72,303,304,77,76,78,75,305,306,76,81,305,297,293,295,299,306,303,300,297,304,306,299,307,293,309,308,311,296,82,78,307,308,81,85,312,377,200,313,199,201,310,312,198,311,85,199,200,377,315,201,90,316,315,290,93,316,90,317,318,323,319,321,320,319,323,371,324,322,319,324,324,371,326,328,325,324,327,326,309,296,328,327,309,326,312,296,311,313,288,287,329,331,289,286,333,318,320,335,334,320,336,363,337,339,338,337,337,363,341,343,340,337,342,341,333,335,343,342,283,282,344,346,284,281,345,344,348,350,346,347,349,348,352,354,350,351,353,352,356,358,354,355,360,357,356,362,502,358,333,341,357,359,343,335,341,363,353,355,340,343,363,336,349,351,339,340,336,364,345,347,365,339,283,345,364,281,279,365,364,336,338,365,366,338,274,278,280,275,273,279,271,280,364,365,279,273,288,330,344,286,284,346,330,367,348,350,368,332,367,369,352,354,370,368,356,352,369,358,502,370,371,381,372,325,328,373,372,381,375,373,331,376,287,290,372,373,291,289,290,377,312,313,314,291,378,382,360,379,502,362,360,382,318,362,335,321,381,382,378,374,376,379,323,382,381,322,325,374,383,427,384,386,392,387,385,384,389,391,387,392,389,397,394,391,393,395,397,401,398,396,395,399,401,409,402,400,399,403,402,409,405,407,404,403,409,412,410,411,413,404,401,469,412,413,416,400,414,469,401,415,396,400,417,414,397,418,391,396,419,417,389,420,387,391,384,427,421,422,388,387,375,426,423,376,331,424,406,405,426,408,376,425,330,329,423,424,331,332,369,442,427,388,445,370,405,410,428,429,411,407,430,426,428,432,435,429,433,430,431,435,432,436,438,430,433,440,444,436,438,439,441,440,445,443,442,441,421,445,388,422,438,442,369,440,368,370,423,430,438,424,368,440,421,441,446,448,443,422,439,452,446,444,443,448,439,433,451,453,436,444,434,455,451,437,436,453,431,458,455,435,437,454,431,428,457,459,429,435,428,410,460,461,411,429,419,421,447,449,422,420,417,419,462,463,420,418,414,417,464,465,418,415,414,466,468,415,416,470,469,468,471,416,413,472,412,471,460,413,411,461,458,476,473,456,454,474,476,504,477,475,474,478,477,504,480,482,479,478,480,487,484,482,483,485,462,447,481,483,449,463,477,481,447,478,448,449,452,473,477,450,448,478,455,473,452,450,474,454,460,476,458,461,459,456,471,504,476,475,479,472,480,504,471,482,470,472,487,480,468,486,467,470,464,484,487,486,485,465,402,406,488,490,408,403,398,402,489,491,403,399,398,492,494,399,395,495,394,494,496,395,393,497,390,496,498,393,392,499,385,498,500,392,386,501,489,488,500,491,499,501,498,496,492,493,497,499,369,383,500,370,502,501,361,500,488,490,501,502,375,378,488,490,379,376]\n        }\n    }\n}"
  },
  {
    "path": "WebContent/pencil-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 3D\">\n<meta name=\"description\" content=\"pencil shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>pencil shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-3d.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-3d.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-pencil.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * The main program\n */\nvoid main() {\n    // Save the varyings\n    v_position = position;\n    v_normal = normalize(normalMatrix * normal);\n\n    // Vertex shader output\n    gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * Returns a rotation matrix for the given angle\n */\nmat2 rotate(float angle) {\n    return mat2(cos(angle), -sin(angle), sin(angle), cos(angle));\n}\n\n/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the horizontal line\n */\nfloat horizontalLine(vec2 pixel, float y_pos, float width) {\n    return 1.0 - smoothstep(-1.0, 1.0, abs(pixel.y - y_pos) - 0.5 * width);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Use the mouse position to define the light direction\n    float min_resolution = min(u_resolution.x, u_resolution.y);\n    vec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.5);\n\n    // Calculate the light diffusion factor\n    float df = diffuseFactor(v_normal, light_direction);\n\n    // Move the pixel coordinates origin to the center of the screen\n    vec2 pos = gl_FragCoord.xy - 0.5 * u_resolution;\n\n    // Rotate the coordinates 20 degrees\n    pos = rotate(radians(20.0)) * pos;\n\n    // Define the first group of pencil lines\n    float line_width = 7.0 * (1.0 - smoothstep(0.0, 0.3, df)) + 0.5;\n    float lines_sep = 16.0;\n    vec2 grid_pos = vec2(pos.x, mod(pos.y, lines_sep));\n    float line_1 = horizontalLine(grid_pos, lines_sep / 2.0, line_width);\n    grid_pos.y = mod(pos.y + lines_sep / 2.0, lines_sep);\n    float line_2 = horizontalLine(grid_pos, lines_sep / 2.0, line_width);\n\n    // Rotate the coordinates 50 degrees\n    pos = rotate(radians(-50.0)) * pos;\n\n    // Define the second group of pencil lines\n    lines_sep = 12.0;\n    grid_pos = vec2(pos.x, mod(pos.y, lines_sep));\n    float line_3 = horizontalLine(grid_pos, lines_sep / 2.0, line_width);\n    grid_pos.y = mod(pos.y + lines_sep / 2.0, lines_sep);\n    float line_4 = horizontalLine(grid_pos, lines_sep / 2.0, line_width);\n\n    // Calculate the surface color\n    float surface_color = 1.0;\n    surface_color -= 0.8 * line_1 * (1.0 - smoothstep(0.5, 0.75, df));\n    surface_color -= 0.8 * line_2 * (1.0 - smoothstep(0.4, 0.5, df));\n    surface_color -= 0.8 * line_3 * (1.0 - smoothstep(0.4, 0.65, df));\n    surface_color -= 0.8 * line_4 * (1.0 - smoothstep(0.2, 0.4, df));\n    surface_color = clamp(surface_color, 0.05, 1.0);\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(surface_color), 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-3d.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/pixelated-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, postprocessin\">\n<meta name=\"description\" content=\"pixelated shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>pixelated shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/CopyShader.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/EffectComposer.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/RenderPass.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/ShaderPass.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-postprocessing.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-filters.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-pixelated.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the varyings\n    v_uv = uv;\n\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the square size in pixel units based on the mouse position\n\tfloat square_size = floor(2.0 + 30.0 * (u_mouse.x / u_resolution.x));\n\n\t// Calculate the square center and corners\n\tvec2 center = square_size * floor(v_uv * u_resolution / square_size) + square_size * vec2(0.5, 0.5);\n\tvec2 corner1 = center + square_size * vec2(-0.5, -0.5);\n\tvec2 corner2 = center + square_size * vec2(+0.5, -0.5);\n\tvec2 corner3 = center + square_size * vec2(+0.5, +0.5);\n\tvec2 corner4 = center + square_size * vec2(-0.5, +0.5);\n\n\t// Calculate the average pixel color\n\tvec3 pixel_color = 0.4 * texture2D(u_texture, center / u_resolution).rgb;\n\tpixel_color += 0.15 * texture2D(u_texture, corner1 / u_resolution).rgb;\n\tpixel_color += 0.15 * texture2D(u_texture, corner2 / u_resolution).rgb;\n\tpixel_color += 0.15 * texture2D(u_texture, corner3 / u_resolution).rgb;\n\tpixel_color += 0.15 * texture2D(u_texture, corner4 / u_resolution).rgb;\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(pixel_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-postprocessing.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/pixels-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 2D\">\n<meta name=\"description\" content=\"pixels shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>pixels shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-filters.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-filters.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-pixelated.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the varyings\n    v_uv = uv;\n\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the square size in pixel units based on the mouse position\n\tfloat square_size = floor(2.0 + 30.0 * (u_mouse.x / u_resolution.x));\n\n\t// Calculate the square center and corners\n\tvec2 center = square_size * floor(v_uv * u_resolution / square_size) + square_size * vec2(0.5, 0.5);\n\tvec2 corner1 = center + square_size * vec2(-0.5, -0.5);\n\tvec2 corner2 = center + square_size * vec2(+0.5, -0.5);\n\tvec2 corner3 = center + square_size * vec2(+0.5, +0.5);\n\tvec2 corner4 = center + square_size * vec2(-0.5, +0.5);\n\n\t// Calculate the average pixel color\n\tvec3 pixel_color = 0.4 * texture2D(u_texture, center / u_resolution).rgb;\n\tpixel_color += 0.15 * texture2D(u_texture, corner1 / u_resolution).rgb;\n\tpixel_color += 0.15 * texture2D(u_texture, corner2 / u_resolution).rgb;\n\tpixel_color += 0.15 * texture2D(u_texture, corner3 / u_resolution).rgb;\n\tpixel_color += 0.15 * texture2D(u_texture, corner4 / u_resolution).rgb;\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(pixel_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-filters.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/rain-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 2D\">\n<meta name=\"description\" content=\"rain shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>rain shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-2d.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-2d.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-rain.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n/*\n * The main program\n */\nvoid main() {\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n#define PI 3.14159265\n\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n/*\n * Random number generator with a float seed\n *\n * Credits:\n * http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0\n */\nhighp float random1d(float dt) {\n    highp float c = 43758.5453;\n    highp float sn = mod(dt, 3.14);\n    return fract(sin(sn) * c);\n}\n\n/*\n *  Returns a random drop position for the given seed value\n */\nvec2 random_drop_pos(float val, vec2 screen_dim, vec2 velocity) {\n    float max_x_move = velocity.x * abs(screen_dim.y / velocity.y);\n    float x = -max_x_move * step(0.0, max_x_move) + (screen_dim.x + abs(max_x_move)) * random1d(val);\n    float y = (1.0 + 0.05 * random1d(1.234 * val)) * screen_dim.y;\n\n    return vec2(x, y);\n}\n\n/*\n * Calculates the drop trail color at the given pixel position\n */\nvec3 trail_color(vec2 pixel, vec2 pos, vec2 velocity_dir, float width, float size) {\n    vec2 pixel_dir = pixel - pos;\n    float projected_dist = dot(pixel_dir, -velocity_dir);\n    float tanjential_dist_sq = dot(pixel_dir, pixel_dir) - pow(projected_dist, 2.0);\n    float width_sq = pow(width, 2.0);\n\n    float line = step(0.0, projected_dist) * (1.0 - smoothstep(width_sq / 2.0, width_sq, tanjential_dist_sq));\n    float dashed_line = line * step(0.5, cos(0.3 * projected_dist - PI / 3.0));\n    float fading_dashed_line = dashed_line * (1.0 - smoothstep(size / 5.0, size, projected_dist));\n\n    return vec3(fading_dashed_line);\n}\n\n/*\n * Calculates the drop wave color at the given pixel position\n */\nvec3 wave_color(vec2 pixel, vec2 pos, float size, float time) {\n    vec2 pixel_dir = pixel - pos;\n    float distorted_dist = length(pixel_dir * vec2(1.0, 3.5));\n\n    float inner_radius = (0.05 + 0.8 * time) * size;\n    float outer_radius = inner_radius + 0.25 * size;\n\n    float ring = smoothstep(inner_radius, inner_radius + 5.0, distorted_dist)\n            * (1.0 - smoothstep(outer_radius, outer_radius + 5.0, distorted_dist));\n    float fading_ring = ring * (1.0 - smoothstep(0.0, 0.7, time));\n\n    return vec3(fading_ring);\n}\n\n/*\n * Calculates the background color at the given pixel position\n */\nvec3 background_color(vec2 pixel, vec2 screen_dim, float time) {\n    return vec3(0.0, 0.0, 1.0 - smoothstep(-1.0, 0.8 + 0.2 * cos(0.5 * time), pixel.y / screen_dim.y));\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Set the total number of rain drops that are visible at a given time\n    const float n_drops = 20.0;\n\n    // Set the drop trail radius\n    float trail_width = 2.0;\n\n    // Set the drop trail size\n    float trail_size = 70.0;\n\n    // Set the drop wave size\n    float wave_size = 20.0;\n\n    // Set the drop fall time in seconds\n    float fall_time = 0.7;\n\n    // Set the drop total life time\n    float life_time = fall_time + 0.5;\n\n    // Set the drop velocity in pixels per second\n    vec2 velocity = vec2(u_mouse.x - 0.5 * u_resolution.x, -0.9 * u_resolution.y) / fall_time;\n    vec2 velocity_dir = normalize(velocity);\n\n    // Iterate over the drops to calculate the pixel color\n    vec3 pixel_color = vec3(0.0);\n\n    for (float i = 0.0; i < n_drops; ++i) {\n        // Offset the running time for each drop\n        float time = u_time + life_time * (i + i / n_drops);\n\n        // Calculate the time since the drop appeared on the screen\n        float ellapsed_time = mod(time, life_time);\n\n        // Calculate the drop initial position\n        vec2 initial_pos = random_drop_pos(i + floor(time / life_time - i) * n_drops, u_resolution, velocity);\n\n        // Add the drop to the pixel color\n        if (ellapsed_time < fall_time) {\n            // Calculate the drop current position\n            vec2 current_pos = initial_pos + ellapsed_time * velocity;\n\n            // Add the trail color to the pixel color\n            pixel_color += trail_color(gl_FragCoord.xy, current_pos, velocity_dir, trail_width, trail_size);\n        } else {\n            // Calculate the drop final position\n            vec2 final_pos = initial_pos + fall_time * velocity;\n\n            // Add the wave color to the pixel color\n            pixel_color += wave_color(gl_FragCoord.xy, final_pos, wave_size, ellapsed_time - fall_time);\n        }\n    }\n\n    // Add the background color to the pixel color\n    pixel_color += background_color(gl_FragCoord.xy, u_resolution, u_time);\n\n    // Fragment shader output\n    gl_FragColor = vec4(pixel_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-2d.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/random-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 2D\">\n<meta name=\"description\" content=\"random shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>random shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-2d.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-2d.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-random.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n/*\n * The main program\n */\nvoid main() {\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n/*\n * Random number generator with a vec2 seed\n *\n * Credits:\n * http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0\n * https://github.com/mattdesl/glsl-random\n */\nhighp float random2d(vec2 co) {\n    highp float a = 12.9898;\n    highp float b = 78.233;\n    highp float c = 43758.5453;\n    highp float dt = dot(co.xy, vec2(a, b));\n    highp float sn = mod(dt, 3.14);\n    return fract(sin(sn) * c);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Create a grid of squares that depends on the mouse position\n    vec2 square = floor((gl_FragCoord.xy - u_mouse) / 30.0);\n\n    // Give a random color to each square\n    vec3 square_color = vec3(random2d(square), random2d(1.234 * square), 1.0);\n\n    // Fragment shader output\n    gl_FragColor = vec4(square_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-2d.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/reaction-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 2D\">\n<meta name=\"description\" content=\"reaction shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>reaction shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-evolve.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-filters.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-reaction.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the varyings\n    v_uv = uv;\n\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n *  Calculates the Laplacian at a given texture position\n */\nvec4 laplacian(vec2 uv, sampler2D texture, vec2 texture_size) {\n    // Calculate the texture steps\n    float du = 1.0 / texture_size.x;\n    float dv = 1.0 / texture_size.y;\n\n    // Calculate the laplacian\n    vec4 lap = -texture2D(texture, uv);\n    lap += 0.2 * texture2D(texture, uv + vec2(-du, 0.0));\n    lap += 0.2 * texture2D(texture, uv + vec2(du, 0.0));\n    lap += 0.2 * texture2D(texture, uv + vec2(0.0, -dv));\n    lap += 0.2 * texture2D(texture, uv + vec2(0.0, dv));\n    lap += 0.05 * texture2D(texture, uv + vec2(-du, -dv));\n    lap += 0.05 * texture2D(texture, uv + vec2(du, -dv));\n    lap += 0.05 * texture2D(texture, uv + vec2(du, dv));\n    lap += 0.05 * texture2D(texture, uv + vec2(-du, dv));\n\n    return lap;\n}\n\n// Calculates the pixel color from the pixel chemical concentrations\nvec4 calculate_color(vec2 concentrations) {\n    return vec4(concentrations * vec2(0.05, 1.0), 0.0, 1.0);\n}\n\n// Calculates the pixel chemical concentrations from the pixel color\nvec2 calculate_concentrations(vec4 color) {\n    return color.rg / vec2(0.05, 1.0);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Set the Gray-Scott reaction-diffusion simulation parameters\n    float D_A = 0.8;\n    float D_B = 0.4;\n    float feed = 0.06 * v_uv.x;\n    float kill = 0.035 + 0.03 * v_uv.x + (0.022 - 0.015 * v_uv.x) * v_uv.y;\n    float dt = 1.0;\n\n    // Calculate the chemical concentrations from the pixel color\n    vec4 pixel_color = texture2D(u_texture, v_uv);\n    vec2 concentrations = calculate_concentrations(pixel_color);\n    float A = concentrations.x;\n    float B = concentrations.y;\n\n    // Calculate the laplacian\n    vec2 lap = calculate_concentrations(laplacian(v_uv, u_texture, u_resolution));\n\n    // Calculate the new chemical concentration values\n    float dA = (D_A * lap.r - A * B * B + feed * (1.0 - A)) * dt;\n    float dB = (D_B * lap.g + A * B * B - (kill + feed) * B) * dt;\n    concentrations += vec2(dA, dB);\n\n    // Modify the concentrations in the pixels under the mouse position\n    if (length(gl_FragCoord.xy - u_mouse) < 5.0) {\n        concentrations = vec2(0.0, 0.9);\n    }\n\n    // Fragment shader output\n    gl_FragColor = calculate_color(concentrations);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-evolve.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/repulsion-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 3D, simulation\">\n<meta name=\"description\" content=\"repulsion shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>repulsion shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/GPUComputationRenderer.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-repulsion.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-repulsion-pos.glsl\" class=\"nav-item\">Position shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-repulsion-vel.glsl\" class=\"nav-item\">Velocity shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-repulsion.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-repulsion.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"positionShader\">\n#define GLSLIFY 1\n// Simulation uniforms\nuniform float u_dt;\nuniform float u_nActiveParticles;\n\n// Simulation constants\nconst float width = resolution.x;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Check if the particle is one of the active particles\n    if ((gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * width < u_nActiveParticles) {\n        // Return the updated particle position\n        gl_FragColor = vec4(position + u_dt * velocity, 1.0);\n    } else {\n        // Return the original particle position\n        gl_FragColor = vec4(position, 1.0);\n    }\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"velocityShader\">\n#define GLSLIFY 1\n// Simulation uniforms\nuniform float u_dt;\nuniform float u_nActiveParticles;\n\n// Simulation constants\nconst float width = resolution.x;\nconst float height = resolution.y;\nconst float nParticles = width * height;\n\n// Softening factor. This is required to avoid high acceleration values\n// when two particles get too close\nconst float softening = 0.005;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Check if the particle is one of the active particles\n    if ((gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * width < u_nActiveParticles) {\n        // Loop over all the particles and calculate the total repulsion force\n        vec3 totalForce = vec3(0.0);\n        float forceScalingFactor = 0.0001;\n\n        for (float i = 0.0; i < nParticles; i++) {\n            // Consider only active particles\n            if (i >= u_nActiveParticles) {\n                break;\n            }\n\n            // Get the position of the repulsing particle\n            vec2 particleUv = vec2(mod(i, width) + 0.5, floor(i / width) + 0.5) / resolution;\n            vec3 particlePosition = texture2D(u_positionTexture, particleUv).xyz;\n\n            // Calculate the force direction\n            vec3 forceDirection = -(particlePosition - position);\n\n            // Calculate the particle distance\n            float distance = length(forceDirection);\n\n            // Move to the next particle if the distance is exactly zero, which\n            // indicates that we are comparing the particle with itself\n            if (distance == 0.0) {\n                continue;\n            }\n\n            // Add the particle repulsion force\n            float distanceDumping = 1.0 - smoothstep(0.45, 0.5, distance);\n            totalForce += forceScalingFactor * distanceDumping * (forceDirection / distance)\n                    / pow(distance + softening, 2.0);\n        }\n\n        // Return the updated particle velocity\n        gl_FragColor = vec4(velocity * (1.0 - 0.1 * u_dt) + u_dt * totalForce, 1.0);\n    } else {\n        // Return the original particle velocity\n        gl_FragColor = vec4(velocity, 1.0);\n    }\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Particle index attribute\nattribute float a_index;\n\n// Simulation uniforms\nuniform float u_width;\nuniform float u_height;\nuniform float u_particleSize;\nuniform float u_nActiveParticles;\nuniform sampler2D u_positionTexture;\nuniform sampler2D u_velocityTexture;\n\n// Particle color varying\nvarying vec3 v_color;\n\n/*\n * The main program\n */\nvoid main() {\n    // Check if the particle is one of the active particles\n    if (a_index < u_nActiveParticles) {\n        // Get the particle position and velocity\n        vec2 uv = vec2((mod(a_index, u_width) + 0.5) / u_width, (floor(a_index / u_width) + 0.5) / u_height);\n        vec3 position = texture2D(u_positionTexture, uv).xyz;\n        vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n        // Calculate the model view position\n        vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n\n        // Calculate the particle color based on its velocity\n        v_color = mix(vec3(1.0, 0.0, 0.0), vec3(1.0, 1.0, 0.0), 20.0 * length(velocity));\n\n        // Vertex shader output\n        gl_PointSize = -u_particleSize / mvPosition.z;\n        gl_Position = projectionMatrix * mvPosition;\n    } else {\n        // Vertex shader output\n        gl_PointSize = 0.0;\n        gl_Position = vec4(-1000000.0);\n    }\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Texture with the particle profile\nuniform sampler2D u_texture;\n\n// Particle color varying\nvarying vec3 v_color;\n\n/*\n * The main program\n */\nvoid main() {\n    // Fragment shader output\n    gl_FragColor = vec4(v_color, texture2D(u_texture, gl_PointCoord).a);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-repulsion.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/rgb-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, postprocessin\">\n<meta name=\"description\" content=\"rgb shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>rgb shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/CopyShader.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/EffectComposer.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/RenderPass.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/ShaderPass.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-postprocessing.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-filters.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-rgb.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the varyings\n    v_uv = uv;\n\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the color offset directions\n    float angle = u_time;\n    vec2 red_offset = vec2(cos(angle), sin(angle));\n    angle += radians(120.0);\n    vec2 green_offset = vec2(cos(angle), sin(angle));\n    angle += radians(120.0);\n    vec2 blue_offset = vec2(cos(angle), sin(angle));\n\n    // Calculate the offset size as a function of the pixel distance to the center\n    float offset_size = 0.1 * length(gl_FragCoord.xy - 0.5 * u_resolution);\n\n    // Scale the offset size by the relative mouse position\n    offset_size *= u_mouse.x / u_resolution.x;\n\n    // Extract the pixel color values from the input texture\n    float red = texture2D(u_texture, v_uv - offset_size * red_offset / u_resolution).r;\n    float green = texture2D(u_texture, v_uv - offset_size * green_offset / u_resolution).g;\n    float blue = texture2D(u_texture, v_uv - offset_size * blue_offset / u_resolution).b;\n\n    // Fragment shader output\n    gl_FragColor = vec4(red, green, blue, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-postprocessing.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/shaders/frag-badtv.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * Random number generator with a float seed\n *\n * Credits:\n * http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0\n */\nhighp float random1d(float dt) {\n    highp float c = 43758.5453;\n    highp float sn = mod(dt, 3.14);\n    return fract(sin(sn) * c);\n}\n\n/*\n * Pseudo-noise generator\n *\n * Credits:\n * https://thebookofshaders.com/11/\n */\nhighp float noise1d(float value) {\n\thighp float i = floor(value);\n\thighp float f = fract(value);\n\treturn mix(random1d(i), random1d(i + 1.0), smoothstep(0.0, 1.0, f));\n}\n\n/*\n * Random number generator with a vec2 seed\n *\n * Credits:\n * http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0\n * https://github.com/mattdesl/glsl-random\n */\nhighp float random2d(vec2 co) {\n    highp float a = 12.9898;\n    highp float b = 78.233;\n    highp float c = 43758.5453;\n    highp float dt = dot(co.xy, vec2(a, b));\n    highp float sn = mod(dt, 3.14);\n    return fract(sin(sn) * c);\n}\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the effect relative strength\n\tfloat strength = (0.3 + 0.7 * noise1d(0.3 * u_time)) * u_mouse.x / u_resolution.x;\n\n\t// Calculate the effect jump at the current time interval\n\tfloat jump = 500.0 * floor(0.3 * (u_mouse.x / u_resolution.x) * (u_time + noise1d(u_time)));\n\n\t// Shift the texture coordinates\n\tvec2 uv = v_uv;\n\tuv.y += 0.2 * strength * (noise1d(5.0 * v_uv.y + 2.0 * u_time + jump) - 0.5);\n\tuv.x += 0.1 * strength * (noise1d(100.0 * strength * uv.y + 3.0 * u_time + jump) - 0.5);\n\n\t// Get the texture pixel color\n\tvec3 pixel_color = texture2D(u_texture, uv).rgb;\n\n\t// Add some white noise\n\tpixel_color += vec3(5.0 * strength * (random2d(v_uv + 1.133001 * vec2(u_time, 1.13)) - 0.5));\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-blur.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the pixel color based on the mouse position\n    vec3 pixel_color;\n\n    if (gl_FragCoord.x > u_mouse.x) {\n        // Apply the gaussian kernel\n        float step = 1.0 + 2.0 * u_mouse.y / u_resolution.y;\n        pixel_color += (1.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-2, -2) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-2, -1) / u_resolution).rgb;\n        pixel_color += (6.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-2, 0) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-2, 1) / u_resolution).rgb;\n        pixel_color += (1.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-2, 2) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-1, -2) / u_resolution).rgb;\n        pixel_color += (16.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-1, -1) / u_resolution).rgb;\n        pixel_color += (24.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-1, 0) / u_resolution).rgb;\n        pixel_color += (16.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-1, 1) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-1, 2) / u_resolution).rgb;\n        pixel_color += (6.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(0, -2) / u_resolution).rgb;\n        pixel_color += (24.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(0, -1) / u_resolution).rgb;\n        pixel_color += (36.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(0, 0) / u_resolution).rgb;\n        pixel_color += (24.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(0, 1) / u_resolution).rgb;\n        pixel_color += (6.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(0, 2) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(1, -2) / u_resolution).rgb;\n        pixel_color += (16.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(1, -1) / u_resolution).rgb;\n        pixel_color += (24.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(1, 0) / u_resolution).rgb;\n        pixel_color += (16.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(1, 1) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(1, 2) / u_resolution).rgb;\n        pixel_color += (1.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(2, -2) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(2, -1) / u_resolution).rgb;\n        pixel_color += (6.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(2, 0) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(2, 1) / u_resolution).rgb;\n        pixel_color += (1.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(2, 2) / u_resolution).rgb;\n    } else if (gl_FragCoord.x > u_mouse.x - 1.0) {\n        // Draw a line indicating the transition\n        pixel_color = vec3(0.0);\n    } else {\n        // Use the original image pixel color\n        pixel_color = texture2D(u_texture, v_uv).rgb;\n    }\n\n// Fragment shader output\n    gl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-cursor.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the circle\n */\nfloat circle(vec2 pixel, vec2 center, float radius) {\n    return 1.0 - smoothstep(radius - 1.0, radius + 1.0, length(pixel - center));\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the pixel color\n    vec3 pixel_color = texture2D(u_texture, v_uv).rgb;\n\n\t// Draw a circle at the mouse position\n    float circle_radius = 50.0;\n    vec3 circle_color = vec3(0.5, 0.5, 0.8) + vec3(0.3 * cos(u_time), 0.3 * sin(1.3 *u_time), 0.2 * cos(2.7 *u_time));\n    float mix_factor = 0.8 * circle(gl_FragCoord.xy, u_mouse, circle_radius);\n    pixel_color = mix(pixel_color, circle_color, mix_factor);\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-cuts.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * Returns a rotation matrix for the given angle\n */\nmat2 rotate(float angle) {\n    return mat2(cos(angle), -sin(angle), sin(angle), cos(angle));\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Change the cuts pixel size as a function of the mouse relative position\n    float cuts_size = 150.0 * (1.1 - u_mouse.x / u_resolution.x);\n\n    // Calculate the cuts offset\n    float angle = 0.4 * u_time;\n    vec2 offset = 30.0 * sin(angle) * vec2(cos(angle), sin(angle));\n\n    // Change the offset direction between cuts\n    vec2 rotated_pos = rotate(angle) * (gl_FragCoord.xy - 0.5 * u_resolution) + 0.5 * u_resolution;\n    offset *= 2.0 * floor(mod(rotated_pos.y / cuts_size, 2.0)) - 1.0;\n\n    // Fragment shader output\n    gl_FragColor = texture2D(u_texture, v_uv + offset / u_resolution);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-debug-pos.glsl",
    "content": "#define GLSLIFY 1\nvoid main() {\n    vec2 uv = gl_FragCoord.xy / resolution;\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    gl_FragColor = vec4(position + velocity, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-debug-vel.glsl",
    "content": "#define GLSLIFY 1\nvoid main() {\n    vec2 uv = gl_FragCoord.xy / resolution;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    gl_FragColor = vec4(velocity, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-debug.glsl",
    "content": "#define GLSLIFY 1\nvoid main() {\n    gl_FragColor = vec4(vec3(1.0), 1);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-dla-pos.glsl",
    "content": "#define GLSLIFY 1\n/*\n * Random number generator with a vec2 seed\n *\n * Credits:\n * http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0\n * https://github.com/mattdesl/glsl-random\n */\nhighp float random2d(vec2 co) {\n    highp float a = 12.9898;\n    highp float b = 78.233;\n    highp float c = 43758.5453;\n    highp float dt = dot(co.xy, vec2(a, b));\n    highp float sn = mod(dt, 3.14);\n    return fract(sin(sn) * c);\n}\n\n// Simulation uniforms\nuniform float u_minDistance;\nuniform float u_maxDistance;\nuniform float u_time;\n\n// Simulation constants\nconst float width = resolution.x;\nconst float height = resolution.y;\nconst float nParticles = width * height;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position\n    vec4 position = texture2D(u_positionTexture, uv);\n\n    // Update the particle position if it has not been aggregated\n    if (position.w > 0.0) {\n        // Move the particle to a new random position\n        float ang = 2.0 * 3.141593 * random2d(123.456 * position.xy + u_time);\n        position.xy += 0.9 * u_minDistance * vec2(cos(ang), sin(ang));\n\n        // Loop over all the particles in the simulation\n        for (float i = 0.0; i < nParticles; i++) {\n            // Get the particle position and velocity\n            vec2 particleUv = vec2(mod(i, width) + 0.5, floor(i / width) + 0.5) / resolution;\n            vec4 particlePosition = texture2D(u_positionTexture, particleUv);\n\n            // Check if it's an aggregated particle\n            if (position.w > 0.0 && particlePosition.w < 0.0) {\n                // Calculate the distance between the two particles\n                float distance = length(particlePosition.xy - position.xy);\n\n                // Set the particle as aggregated if the distance is small\n                // enough and we are not comparing the particle with itself\n                if (distance != 0.0 && distance < u_minDistance) {\n                    position.w = -1.0;\n                    position.xy = particlePosition.xy + u_minDistance * (position.xy - particlePosition.xy) / distance;\n                    break;\n                }\n            }\n        }\n\n        // Make sure that the particle distance to the center is smaller than\n        // the maximum allowed distance\n        float distanceToCenter = length(position.xy);\n\n        if (distanceToCenter > u_maxDistance) {\n            position.xy -= 2.0 * u_maxDistance * position.xy / distanceToCenter;\n        }\n    }\n\n    // Return the updated particle position\n    gl_FragColor = position;\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-dla-vel.glsl",
    "content": "#define GLSLIFY 1\n"
  },
  {
    "path": "WebContent/shaders/frag-dla.glsl",
    "content": "#define GLSLIFY 1\n// Texture with the particle profile\nuniform sampler2D u_texture;\n\n// Varying with the aggregation information\nvarying float v_aggregation;\n\n/*\n * The main program\n */\nvoid main() {\n    // Use a different color for aggregated and non-aggregated particles\n    vec3 particleColor = v_aggregation < 0.0 ? vec3(1.0) : vec3(0.5);\n\n    // Fragment shader output\n    gl_FragColor = vec4(particleColor, texture2D(u_texture, gl_PointCoord).a);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-dots.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the circle\n */\nfloat circle(vec2 pixel, vec2 center, float radius) {\n    return 1.0 - smoothstep(radius - 1.0, radius + 1.0, length(pixel - center));\n}\n\n/*\n * Returns a rotation matrix for the given angle\n */\nmat2 rotate(float angle) {\n    return mat2(cos(angle), -sin(angle), sin(angle), cos(angle));\n}\n\n/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Use the mouse position to define the light direction\n    float min_resolution = min(u_resolution.x, u_resolution.y);\n    vec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.5);\n\n    // Calculate the light diffusion factor\n    float df = diffuseFactor(v_normal, light_direction);\n\n    // Move the pixel coordinates origin to the center of the screen\n    vec2 pos = gl_FragCoord.xy - 0.5 * u_resolution;\n\n    // Rotate the coordinates 20 degrees\n    pos = rotate(radians(20.0)) * pos;\n\n    // Define the grid\n    float grid_step = 12.0;\n    vec2 grid_pos = mod(pos, grid_step);\n\n    // Calculate the surface color\n    float surface_color = 1.0;\n    surface_color -= circle(grid_pos, vec2(grid_step / 2.0), 0.8 * grid_step * pow(1.0 - df, 2.0));\n    surface_color = clamp(surface_color, 0.05, 1.0);\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(surface_color), 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-edge.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the pixel color based on the mouse position\n    vec3 pixel_color;\n\n    if (gl_FragCoord.x > u_mouse.x) {\n        // Apply the edge detection kernel\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(-1, -1) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(-1, 0) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(-1, 1) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(0, -1) / u_resolution).rgb;\n        pixel_color += 8.0 * texture2D(u_texture, v_uv + vec2(0, 0) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(0, 1) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(1, -1) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(1, 0) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(1, 1) / u_resolution).rgb;\n\n        // Use the most extreme color value\n        float min_value = min(pixel_color.r, min(pixel_color.g, pixel_color.b));\n        float max_value = max(pixel_color.r, max(pixel_color.g, pixel_color.b));\n\n        if (abs(min_value) > abs(max_value)) {\n            pixel_color = vec3(min_value);\n        } else {\n            pixel_color = vec3(max_value);\n        }\n\n        // Rescale the pixel color using the mouse y position\n        float scale = 0.2 + 2.5 * u_mouse.y / u_resolution.y;\n        pixel_color = 0.5 + scale * pixel_color;\n    } else if (gl_FragCoord.x > u_mouse.x - 1.0) {\n        // Draw a line indicating the transition\n        pixel_color = vec3(0.0);\n    } else {\n        // Use the original image pixel color\n        pixel_color = texture2D(u_texture, v_uv).rgb;\n    }\n\n    // Fragment shader output\n    gl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-fire.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * GLSL textureless classic 2D noise \"cnoise\",\n * with an RSL-style periodic variant \"pnoise\".\n * Author:  Stefan Gustavson (stefan.gustavson@liu.se)\n * Version: 2011-08-22\n *\n * Many thanks to Ian McEwan of Ashima Arts for the\n * ideas for permutation and gradient selection.\n *\n * Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n * Distributed under the MIT license. See LICENSE file.\n * https://github.com/stegu/webgl-noise\n */\n\nvec4 mod289(vec4 x) {\n    return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x) {\n    return mod289(((x * 34.0) + 1.0) * x);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n    return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nvec2 fade(vec2 t) {\n    return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n\nfloat cnoise(vec2 P) {\n    vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n    vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n    Pi = mod289(Pi);\n    vec4 ix = Pi.xzxz;\n    vec4 iy = Pi.yyww;\n    vec4 fx = Pf.xzxz;\n    vec4 fy = Pf.yyww;\n\n    vec4 i = permute(permute(ix) + iy);\n\n    vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0;\n    vec4 gy = abs(gx) - 0.5;\n    vec4 tx = floor(gx + 0.5);\n    gx = gx - tx;\n\n    vec2 g00 = vec2(gx.x, gy.x);\n    vec2 g10 = vec2(gx.y, gy.y);\n    vec2 g01 = vec2(gx.z, gy.z);\n    vec2 g11 = vec2(gx.w, gy.w);\n\n    vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n    g00 *= norm.x;\n    g01 *= norm.y;\n    g10 *= norm.z;\n    g11 *= norm.w;\n\n    float n00 = dot(g00, vec2(fx.x, fy.x));\n    float n10 = dot(g10, vec2(fx.y, fy.y));\n    float n01 = dot(g01, vec2(fx.z, fy.z));\n    float n11 = dot(g11, vec2(fx.w, fy.w));\n\n    vec2 fade_xy = fade(Pf.xy);\n    vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n    float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n    return 2.3 * n_xy;\n}\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the pixel color depending of the distance from the floor\n\tvec3 pixel_color = vec3(0.0);\n\tfloat floor = 2.0;\n\n\tif (gl_FragCoord.y <= floor) {\n\t\t// Use some 2D noise to simulate the fire change in position and time\n\t\tpixel_color.rg = vec2(cnoise(vec2(0.01 * gl_FragCoord.x, -0.2 * u_time)));\n\t} else {\n\t\t// Get a smoothed value of the pixels bellow\n\t    vec2 delta =  1.0 / u_resolution;\n\t    pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(2.0 * delta.x, -delta.y)).rgb;\n\t\tpixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(1.0 * delta.x, -delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(0.0 * delta.x, -delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(-1.0 * delta.x, -delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(-2.0 * delta.x, -delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(2.0 * delta.x, -2.0 * delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(1.0 * delta.x, -2.0 * delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(0.0 * delta.x, -2.0 * delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(-1.0 * delta.x, -2.0 * delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(-2.0 * delta.x, -2.0 * delta.y)).rgb;\n\n        // Decrease the intensity with the distance to the floor\n        float fade_factor = 1.0 - smoothstep(0.0, u_resolution.x, (gl_FragCoord.y - floor) / 3.0);\n        pixel_color.r *= fade_factor;\n        pixel_color.g *= 0.99 * fade_factor;\n        pixel_color.b = 0.0;\n\t}\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-flare.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * GLSL textureless classic 2D noise \"cnoise\",\n * with an RSL-style periodic variant \"pnoise\".\n * Author:  Stefan Gustavson (stefan.gustavson@liu.se)\n * Version: 2011-08-22\n *\n * Many thanks to Ian McEwan of Ashima Arts for the\n * ideas for permutation and gradient selection.\n *\n * Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n * Distributed under the MIT license. See LICENSE file.\n * https://github.com/stegu/webgl-noise\n */\n\nvec4 mod289(vec4 x) {\n    return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x) {\n    return mod289(((x * 34.0) + 1.0) * x);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n    return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nvec2 fade(vec2 t) {\n    return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n\nfloat cnoise(vec2 P) {\n    vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n    vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n    Pi = mod289(Pi);\n    vec4 ix = Pi.xzxz;\n    vec4 iy = Pi.yyww;\n    vec4 fx = Pf.xzxz;\n    vec4 fy = Pf.yyww;\n\n    vec4 i = permute(permute(ix) + iy);\n\n    vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0;\n    vec4 gy = abs(gx) - 0.5;\n    vec4 tx = floor(gx + 0.5);\n    gx = gx - tx;\n\n    vec2 g00 = vec2(gx.x, gy.x);\n    vec2 g10 = vec2(gx.y, gy.y);\n    vec2 g01 = vec2(gx.z, gy.z);\n    vec2 g11 = vec2(gx.w, gy.w);\n\n    vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n    g00 *= norm.x;\n    g01 *= norm.y;\n    g10 *= norm.z;\n    g11 *= norm.w;\n\n    float n00 = dot(g00, vec2(fx.x, fy.x));\n    float n10 = dot(g10, vec2(fx.y, fy.y));\n    float n01 = dot(g01, vec2(fx.z, fy.z));\n    float n11 = dot(g11, vec2(fx.w, fy.w));\n\n    vec2 fade_xy = fade(Pf.xy);\n    vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n    float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n    return 2.3 * n_xy;\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Set the star radius\n    float star_radius = 90.0;\n\n    // Get the pixel position relative to the screen center\n    vec2 position = gl_FragCoord.xy - 0.5 * u_resolution;\n\n    // Calculate the pixel distance from the center\n    float radial_distance = length(position);\n\n    // Calculate the star color\n    vec3 star_color = vec3(0.0);\n\n    if (radial_distance < star_radius) {\n        // Calculate the pixel polar angle\n        float angle = atan(position.y, position.x) + radians(180.0);\n\n        // Calculate the radial noise position\n        float r = 0.05 * (radial_distance - u_frame);\n\n        // Calculate the noise value\n        float noise_value = cnoise(vec2(r, 1.5 * angle));\n\n        // Smooth the noise discontinuity between 0 and 360 degrees\n        float smooth_step = radians(20.0);\n        float limit_angle = radians(360.0) - smooth_step;\n\n        if (angle > limit_angle) {\n            noise_value = mix(noise_value, cnoise(vec2(r, 0.0)), (angle - limit_angle) / smooth_step);\n        }\n\n        // The final star color is the combination of a radially constant\n        // declining intensity plus the noise\n        float f = pow(radial_distance / star_radius, 2.0);\n        star_color = vec3((1.0 - f) + f * (0.1 + 0.4 * u_mouse.x / u_resolution.x) * (0.5 + 0.5 * noise_value));\n    }\n\n    // Calculate the average color of the pixels that are radially bellow the\n    // current pixel\n    vec3 average_color = vec3(0.0);\n    float counter = 0.0;\n\n    for (float i = -2.0; i <= 2.0; i++) {\n        for (float j = -2.0; j <= 2.0; j++) {\n            // Get the pixel color at the offset position\n            vec2 offset = vec2(i, j);\n            vec3 color = texture2D(u_texture, v_uv + offset / u_resolution).rgb;\n\n            // Add the color to the average if the pixel is above the offset\n            // position and is not a pixel inside the star\n            if (radial_distance > length(position + offset) && radial_distance >= star_radius) {\n                average_color += color;\n                counter++;\n            }\n        }\n    }\n\n    if (counter > 0.0) {\n        average_color /= counter;\n    }\n\n    // Set the distance decrement factor for the average color\n    float decrement_factor = 0.1 * (u_resolution.y - u_mouse.y) / u_resolution.y;\n\n    // Fragment shader output\n    gl_FragColor = vec4(star_color + (1.0 - decrement_factor) * average_color, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-galaxies-pos.glsl",
    "content": "#define GLSLIFY 1\n// Simulation uniforms\nuniform float u_dt;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Return the updated particle position\n    gl_FragColor = vec4(position + u_dt * velocity, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-galaxies-vel.glsl",
    "content": "#define GLSLIFY 1\n// Simulation uniforms\nuniform float u_dt;\nuniform float u_mass;\nuniform float u_haloSize;\n\n// Simulation constants\nconst float width = resolution.x;\nconst float height = resolution.y;\n\n// Softening factor. This is required to avoid high acceleration values\n// when two particles get too close\nconst float softening = 0.001;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Loop over all the particles and calculate the total gravitational force\n    vec3 totalForce = vec3(0.0);\n\n    for (float i = 0.0; i < nGalaxies; i++) {\n        // Get the position of the attracting particle\n        vec2 particleUv = vec2(mod(i, width) + 0.5, floor(i / width) + 0.5) / resolution;\n        vec3 particlePosition = texture2D(u_positionTexture, particleUv).xyz;\n\n        // Calculate the force direction\n        vec3 forceDirection = particlePosition - position;\n\n        // Calculate the particle distance\n        float distance = length(forceDirection);\n\n        // Move to the next particle if the distance is exactly zero, which\n        // indicates that we are comparing the particle with itself\n        if (distance == 0.0) {\n            continue;\n        }\n\n        // Add the particle gravitational force\n        float massAtPosition = u_mass * min(distance, u_haloSize) / u_haloSize;\n        totalForce += massAtPosition * (forceDirection / distance) / pow(distance + softening, 2.0);\n    }\n\n    // Return the updated particle velocity\n    gl_FragColor = vec4(velocity + u_dt * totalForce, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-grav-pos.glsl",
    "content": "#define GLSLIFY 1\n// Simulation uniforms\nuniform float u_dt;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Return the updated particle position\n    gl_FragColor = vec4(position + u_dt * velocity, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-grav-vel.glsl",
    "content": "#define GLSLIFY 1\n// Simulation uniforms\nuniform float u_dt;\n\n// Simulation constants\nconst float width = resolution.x;\nconst float height = resolution.y;\nconst float nParticles = width * height;\n\n// Softening factor. This is required to avoid high acceleration values\n// when two particles get too close\nconst float softening = 0.1;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Loop over all the particles and calculate the total gravitational force\n    vec3 totalForce = vec3(0.0);\n    float forceScalingFactor = 1.0 / (2.0 * pow(nParticles, 1.5));\n\n    for (float i = 0.0; i < nParticles; i++) {\n        // Get the position of the attracting particle\n        vec2 particleUv = vec2(mod(i, width) + 0.5, floor(i / width) + 0.5) / resolution;\n        vec3 particlePosition = texture2D(u_positionTexture, particleUv).xyz;\n\n        // Calculate the force direction\n        vec3 forceDirection = particlePosition - position;\n\n        // Calculate the particle distance\n        float distance = length(forceDirection);\n\n        // Move to the next particle if the distance is exactly zero, which\n        // indicates that we are comparing the particle with itself\n        if (distance == 0.0) {\n            continue;\n        }\n\n        // Add the particle gravitational force\n        totalForce += forceScalingFactor * (forceDirection / distance) / pow(distance + softening, 2.0);\n    }\n\n    // Return the updated particle velocity\n    gl_FragColor = vec4(velocity + u_dt * totalForce, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-lens.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n\t// Set the lens radius\n\tfloat lens_radius = min(0.3 * u_resolution.x, 250.0);\n\n\t// Calculate the direction to the mouse position and the distance\n\tvec2 mouse_direction = u_mouse - gl_FragCoord.xy;\n\tfloat mouse_distance = length(mouse_direction);\n\n\t// Calculate the pixel color based on the mouse position\n\tvec3 pixel_color;\n\n\tif (mouse_distance < lens_radius) {\n\t\t// Calculate the pixel offset\n\t\tfloat exp = 1.0;\n\t\tvec2 offset = (1.0 - pow(mouse_distance / lens_radius, exp)) * mouse_direction;\n\n\t\t// Get the pixel color at the offset position\n\t\tpixel_color = texture2D(u_texture, v_uv + offset / u_resolution).rgb;\n\t} else {\n\t\t// Use the original image pixel color\n\t\tpixel_color = texture2D(u_texture, v_uv).rgb;\n\t}\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-mountains.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n *  Calculates the normal vector at the given position\n *\n *  Uses this fix for some mobiles:\n *  https://stackoverflow.com/questions/20272272/standard-derivatives-from-fragment-shader-dfdx-dfdy-dont-run-correctly-in-a\n */\nvec3 calculateNormal(vec3 position) {\n    vec3 fdx = vec3(dFdx(position.x), dFdx(position.y), dFdx(position.z));\n    vec3 fdy = vec3(dFdy(position.x), dFdy(position.y), dFdy(position.z));\n    vec3 normal = normalize(cross(fdx, fdy));\n\n    if (!gl_FrontFacing) {\n        normal = -normal;\n    }\n\n    return normal;\n}\n\n/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n// The plane tile size, the maximum mountain height and the sky color\nuniform float u_tileSize;\nuniform float u_maxHeight;\nuniform vec3 u_skyColor;\n\n// Varying containing the terrain elevation\nvarying float v_elevation;\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new normal vector\n\tvec3 new_normal = calculateNormal(v_position);\n\n\t// Use the mouse position to define the light direction\n\tfloat min_resolution = min(u_resolution.x, u_resolution.y);\n\tvec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.25);\n\n\t// Set the default surface color\n\tvec3 surface_color = vec3(0.3, 0.65, 0.0);\n\n\t// Change the color for the snow peaks and the lakes\n\tif (v_elevation > 0.85 * u_maxHeight) {\n\t\tsurface_color = vec3(1.0, 1.0, 1.0);\n\t} else if (v_elevation < 0.2 * u_maxHeight) {\n\t\tsurface_color = vec3(0.3, 0.7, 0.9);\n\t}\n\n\t// Apply the light diffusion factor\n\tsurface_color *= diffuseFactor(new_normal, light_direction);\n\n\t// Add a fog effect\n\tfloat fog_factor = clamp(0.0, 1.0, -(1.0 - u_mouse.y / u_resolution.y) * v_position.z / (15.0 * u_tileSize));\n\tsurface_color = mix(surface_color, u_skyColor, fog_factor);\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(surface_color, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-noise.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n/*\n * GLSL textureless classic 2D noise \"cnoise\",\n * with an RSL-style periodic variant \"pnoise\".\n * Author:  Stefan Gustavson (stefan.gustavson@liu.se)\n * Version: 2011-08-22\n *\n * Many thanks to Ian McEwan of Ashima Arts for the\n * ideas for permutation and gradient selection.\n *\n * Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n * Distributed under the MIT license. See LICENSE file.\n * https://github.com/stegu/webgl-noise\n */\n\nvec4 mod289(vec4 x) {\n    return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x) {\n    return mod289(((x * 34.0) + 1.0) * x);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n    return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nvec2 fade(vec2 t) {\n    return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n\nfloat cnoise(vec2 P) {\n    vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n    vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n    Pi = mod289(Pi);\n    vec4 ix = Pi.xzxz;\n    vec4 iy = Pi.yyww;\n    vec4 fx = Pf.xzxz;\n    vec4 fy = Pf.yyww;\n\n    vec4 i = permute(permute(ix) + iy);\n\n    vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0;\n    vec4 gy = abs(gx) - 0.5;\n    vec4 tx = floor(gx + 0.5);\n    gx = gx - tx;\n\n    vec2 g00 = vec2(gx.x, gy.x);\n    vec2 g10 = vec2(gx.y, gy.y);\n    vec2 g01 = vec2(gx.z, gy.z);\n    vec2 g11 = vec2(gx.w, gy.w);\n\n    vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n    g00 *= norm.x;\n    g01 *= norm.y;\n    g10 *= norm.z;\n    g11 *= norm.w;\n\n    float n00 = dot(g00, vec2(fx.x, fy.x));\n    float n10 = dot(g10, vec2(fx.y, fy.y));\n    float n01 = dot(g01, vec2(fx.z, fy.z));\n    float n11 = dot(g11, vec2(fx.w, fy.w));\n\n    vec2 fade_xy = fade(Pf.xy);\n    vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n    float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n    return 2.3 * n_xy;\n}\n\n/*\n * Combines the 2d noise function at three different scales\n */\nfloat multy_scale_noise(vec2 p, vec2 rel_mouse_pos) {\n    return 0.8 * cnoise(5.0 * p) + rel_mouse_pos.x * cnoise(15.0 * p) + rel_mouse_pos.y * cnoise(60.0 * p);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Normalize the pixel and mouse positions to the maximum scale dimension\n    float max_dim = max(u_resolution.x, u_resolution.y);\n    vec2 rel_pixel_pos = gl_FragCoord.xy / max_dim;\n    vec2 rel_mouse_pos = u_mouse / max_dim;\n\n    // Use a slightly shifted noise value for each color\n    float r = multy_scale_noise(rel_pixel_pos + 0.05 * rel_mouse_pos, rel_mouse_pos);\n    float g = multy_scale_noise(rel_pixel_pos + 0.05 * rel_mouse_pos.yx, rel_mouse_pos);\n    float b = multy_scale_noise(rel_pixel_pos - 0.05 * rel_mouse_pos, rel_mouse_pos);\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(r, g, b), 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-normals.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n *  Calculates the normal vector at the given position\n *\n *  Uses this fix for some mobiles:\n *  https://stackoverflow.com/questions/20272272/standard-derivatives-from-fragment-shader-dfdx-dfdy-dont-run-correctly-in-a\n */\nvec3 calculateNormal(vec3 position) {\n    vec3 fdx = vec3(dFdx(position.x), dFdx(position.y), dFdx(position.z));\n    vec3 fdy = vec3(dFdy(position.x), dFdy(position.y), dFdy(position.z));\n    vec3 normal = normalize(cross(fdx, fdy));\n\n    if (!gl_FrontFacing) {\n        normal = -normal;\n    }\n\n    return normal;\n}\n\n/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new normal vector\n\tvec3 new_normal = calculateNormal(v_position);\n\n\t// Use the mouse position to define the light direction\n\tfloat min_resolution = min(u_resolution.x, u_resolution.y);\n\tvec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.25);\n\n\t// Set the surface color\n\tvec3 surface_color = vec3(1.0);\n\n\t// Apply the light diffusion factor\n\tsurface_color *= diffuseFactor(new_normal, light_direction);\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(surface_color, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-pencil.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * Returns a rotation matrix for the given angle\n */\nmat2 rotate(float angle) {\n    return mat2(cos(angle), -sin(angle), sin(angle), cos(angle));\n}\n\n/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the horizontal line\n */\nfloat horizontalLine(vec2 pixel, float y_pos, float width) {\n    return 1.0 - smoothstep(-1.0, 1.0, abs(pixel.y - y_pos) - 0.5 * width);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Use the mouse position to define the light direction\n    float min_resolution = min(u_resolution.x, u_resolution.y);\n    vec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.5);\n\n    // Calculate the light diffusion factor\n    float df = diffuseFactor(v_normal, light_direction);\n\n    // Move the pixel coordinates origin to the center of the screen\n    vec2 pos = gl_FragCoord.xy - 0.5 * u_resolution;\n\n    // Rotate the coordinates 20 degrees\n    pos = rotate(radians(20.0)) * pos;\n\n    // Define the first group of pencil lines\n    float line_width = 7.0 * (1.0 - smoothstep(0.0, 0.3, df)) + 0.5;\n    float lines_sep = 16.0;\n    vec2 grid_pos = vec2(pos.x, mod(pos.y, lines_sep));\n    float line_1 = horizontalLine(grid_pos, lines_sep / 2.0, line_width);\n    grid_pos.y = mod(pos.y + lines_sep / 2.0, lines_sep);\n    float line_2 = horizontalLine(grid_pos, lines_sep / 2.0, line_width);\n\n    // Rotate the coordinates 50 degrees\n    pos = rotate(radians(-50.0)) * pos;\n\n    // Define the second group of pencil lines\n    lines_sep = 12.0;\n    grid_pos = vec2(pos.x, mod(pos.y, lines_sep));\n    float line_3 = horizontalLine(grid_pos, lines_sep / 2.0, line_width);\n    grid_pos.y = mod(pos.y + lines_sep / 2.0, lines_sep);\n    float line_4 = horizontalLine(grid_pos, lines_sep / 2.0, line_width);\n\n    // Calculate the surface color\n    float surface_color = 1.0;\n    surface_color -= 0.8 * line_1 * (1.0 - smoothstep(0.5, 0.75, df));\n    surface_color -= 0.8 * line_2 * (1.0 - smoothstep(0.4, 0.5, df));\n    surface_color -= 0.8 * line_3 * (1.0 - smoothstep(0.4, 0.65, df));\n    surface_color -= 0.8 * line_4 * (1.0 - smoothstep(0.2, 0.4, df));\n    surface_color = clamp(surface_color, 0.05, 1.0);\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(surface_color), 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-pixelated.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the square size in pixel units based on the mouse position\n\tfloat square_size = floor(2.0 + 30.0 * (u_mouse.x / u_resolution.x));\n\n\t// Calculate the square center and corners\n\tvec2 center = square_size * floor(v_uv * u_resolution / square_size) + square_size * vec2(0.5, 0.5);\n\tvec2 corner1 = center + square_size * vec2(-0.5, -0.5);\n\tvec2 corner2 = center + square_size * vec2(+0.5, -0.5);\n\tvec2 corner3 = center + square_size * vec2(+0.5, +0.5);\n\tvec2 corner4 = center + square_size * vec2(-0.5, +0.5);\n\n\t// Calculate the average pixel color\n\tvec3 pixel_color = 0.4 * texture2D(u_texture, center / u_resolution).rgb;\n\tpixel_color += 0.15 * texture2D(u_texture, corner1 / u_resolution).rgb;\n\tpixel_color += 0.15 * texture2D(u_texture, corner2 / u_resolution).rgb;\n\tpixel_color += 0.15 * texture2D(u_texture, corner3 / u_resolution).rgb;\n\tpixel_color += 0.15 * texture2D(u_texture, corner4 / u_resolution).rgb;\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-rain.glsl",
    "content": "#define GLSLIFY 1\n#define PI 3.14159265\n\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n/*\n * Random number generator with a float seed\n *\n * Credits:\n * http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0\n */\nhighp float random1d(float dt) {\n    highp float c = 43758.5453;\n    highp float sn = mod(dt, 3.14);\n    return fract(sin(sn) * c);\n}\n\n/*\n *  Returns a random drop position for the given seed value\n */\nvec2 random_drop_pos(float val, vec2 screen_dim, vec2 velocity) {\n    float max_x_move = velocity.x * abs(screen_dim.y / velocity.y);\n    float x = -max_x_move * step(0.0, max_x_move) + (screen_dim.x + abs(max_x_move)) * random1d(val);\n    float y = (1.0 + 0.05 * random1d(1.234 * val)) * screen_dim.y;\n\n    return vec2(x, y);\n}\n\n/*\n * Calculates the drop trail color at the given pixel position\n */\nvec3 trail_color(vec2 pixel, vec2 pos, vec2 velocity_dir, float width, float size) {\n    vec2 pixel_dir = pixel - pos;\n    float projected_dist = dot(pixel_dir, -velocity_dir);\n    float tanjential_dist_sq = dot(pixel_dir, pixel_dir) - pow(projected_dist, 2.0);\n    float width_sq = pow(width, 2.0);\n\n    float line = step(0.0, projected_dist) * (1.0 - smoothstep(width_sq / 2.0, width_sq, tanjential_dist_sq));\n    float dashed_line = line * step(0.5, cos(0.3 * projected_dist - PI / 3.0));\n    float fading_dashed_line = dashed_line * (1.0 - smoothstep(size / 5.0, size, projected_dist));\n\n    return vec3(fading_dashed_line);\n}\n\n/*\n * Calculates the drop wave color at the given pixel position\n */\nvec3 wave_color(vec2 pixel, vec2 pos, float size, float time) {\n    vec2 pixel_dir = pixel - pos;\n    float distorted_dist = length(pixel_dir * vec2(1.0, 3.5));\n\n    float inner_radius = (0.05 + 0.8 * time) * size;\n    float outer_radius = inner_radius + 0.25 * size;\n\n    float ring = smoothstep(inner_radius, inner_radius + 5.0, distorted_dist)\n            * (1.0 - smoothstep(outer_radius, outer_radius + 5.0, distorted_dist));\n    float fading_ring = ring * (1.0 - smoothstep(0.0, 0.7, time));\n\n    return vec3(fading_ring);\n}\n\n/*\n * Calculates the background color at the given pixel position\n */\nvec3 background_color(vec2 pixel, vec2 screen_dim, float time) {\n    return vec3(0.0, 0.0, 1.0 - smoothstep(-1.0, 0.8 + 0.2 * cos(0.5 * time), pixel.y / screen_dim.y));\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Set the total number of rain drops that are visible at a given time\n    const float n_drops = 20.0;\n\n    // Set the drop trail radius\n    float trail_width = 2.0;\n\n    // Set the drop trail size\n    float trail_size = 70.0;\n\n    // Set the drop wave size\n    float wave_size = 20.0;\n\n    // Set the drop fall time in seconds\n    float fall_time = 0.7;\n\n    // Set the drop total life time\n    float life_time = fall_time + 0.5;\n\n    // Set the drop velocity in pixels per second\n    vec2 velocity = vec2(u_mouse.x - 0.5 * u_resolution.x, -0.9 * u_resolution.y) / fall_time;\n    vec2 velocity_dir = normalize(velocity);\n\n    // Iterate over the drops to calculate the pixel color\n    vec3 pixel_color = vec3(0.0);\n\n    for (float i = 0.0; i < n_drops; ++i) {\n        // Offset the running time for each drop\n        float time = u_time + life_time * (i + i / n_drops);\n\n        // Calculate the time since the drop appeared on the screen\n        float ellapsed_time = mod(time, life_time);\n\n        // Calculate the drop initial position\n        vec2 initial_pos = random_drop_pos(i + floor(time / life_time - i) * n_drops, u_resolution, velocity);\n\n        // Add the drop to the pixel color\n        if (ellapsed_time < fall_time) {\n            // Calculate the drop current position\n            vec2 current_pos = initial_pos + ellapsed_time * velocity;\n\n            // Add the trail color to the pixel color\n            pixel_color += trail_color(gl_FragCoord.xy, current_pos, velocity_dir, trail_width, trail_size);\n        } else {\n            // Calculate the drop final position\n            vec2 final_pos = initial_pos + fall_time * velocity;\n\n            // Add the wave color to the pixel color\n            pixel_color += wave_color(gl_FragCoord.xy, final_pos, wave_size, ellapsed_time - fall_time);\n        }\n    }\n\n    // Add the background color to the pixel color\n    pixel_color += background_color(gl_FragCoord.xy, u_resolution, u_time);\n\n    // Fragment shader output\n    gl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-random.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n/*\n * Random number generator with a vec2 seed\n *\n * Credits:\n * http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0\n * https://github.com/mattdesl/glsl-random\n */\nhighp float random2d(vec2 co) {\n    highp float a = 12.9898;\n    highp float b = 78.233;\n    highp float c = 43758.5453;\n    highp float dt = dot(co.xy, vec2(a, b));\n    highp float sn = mod(dt, 3.14);\n    return fract(sin(sn) * c);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Create a grid of squares that depends on the mouse position\n    vec2 square = floor((gl_FragCoord.xy - u_mouse) / 30.0);\n\n    // Give a random color to each square\n    vec3 square_color = vec3(random2d(square), random2d(1.234 * square), 1.0);\n\n    // Fragment shader output\n    gl_FragColor = vec4(square_color, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-reaction.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n *  Calculates the Laplacian at a given texture position\n */\nvec4 laplacian(vec2 uv, sampler2D texture, vec2 texture_size) {\n    // Calculate the texture steps\n    float du = 1.0 / texture_size.x;\n    float dv = 1.0 / texture_size.y;\n\n    // Calculate the laplacian\n    vec4 lap = -texture2D(texture, uv);\n    lap += 0.2 * texture2D(texture, uv + vec2(-du, 0.0));\n    lap += 0.2 * texture2D(texture, uv + vec2(du, 0.0));\n    lap += 0.2 * texture2D(texture, uv + vec2(0.0, -dv));\n    lap += 0.2 * texture2D(texture, uv + vec2(0.0, dv));\n    lap += 0.05 * texture2D(texture, uv + vec2(-du, -dv));\n    lap += 0.05 * texture2D(texture, uv + vec2(du, -dv));\n    lap += 0.05 * texture2D(texture, uv + vec2(du, dv));\n    lap += 0.05 * texture2D(texture, uv + vec2(-du, dv));\n\n    return lap;\n}\n\n// Calculates the pixel color from the pixel chemical concentrations\nvec4 calculate_color(vec2 concentrations) {\n    return vec4(concentrations * vec2(0.05, 1.0), 0.0, 1.0);\n}\n\n// Calculates the pixel chemical concentrations from the pixel color\nvec2 calculate_concentrations(vec4 color) {\n    return color.rg / vec2(0.05, 1.0);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Set the Gray-Scott reaction-diffusion simulation parameters\n    float D_A = 0.8;\n    float D_B = 0.4;\n    float feed = 0.06 * v_uv.x;\n    float kill = 0.035 + 0.03 * v_uv.x + (0.022 - 0.015 * v_uv.x) * v_uv.y;\n    float dt = 1.0;\n\n    // Calculate the chemical concentrations from the pixel color\n    vec4 pixel_color = texture2D(u_texture, v_uv);\n    vec2 concentrations = calculate_concentrations(pixel_color);\n    float A = concentrations.x;\n    float B = concentrations.y;\n\n    // Calculate the laplacian\n    vec2 lap = calculate_concentrations(laplacian(v_uv, u_texture, u_resolution));\n\n    // Calculate the new chemical concentration values\n    float dA = (D_A * lap.r - A * B * B + feed * (1.0 - A)) * dt;\n    float dB = (D_B * lap.g + A * B * B - (kill + feed) * B) * dt;\n    concentrations += vec2(dA, dB);\n\n    // Modify the concentrations in the pixels under the mouse position\n    if (length(gl_FragCoord.xy - u_mouse) < 5.0) {\n        concentrations = vec2(0.0, 0.9);\n    }\n\n    // Fragment shader output\n    gl_FragColor = calculate_color(concentrations);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-repulsion-pos.glsl",
    "content": "#define GLSLIFY 1\n// Simulation uniforms\nuniform float u_dt;\nuniform float u_nActiveParticles;\n\n// Simulation constants\nconst float width = resolution.x;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Check if the particle is one of the active particles\n    if ((gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * width < u_nActiveParticles) {\n        // Return the updated particle position\n        gl_FragColor = vec4(position + u_dt * velocity, 1.0);\n    } else {\n        // Return the original particle position\n        gl_FragColor = vec4(position, 1.0);\n    }\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-repulsion-vel.glsl",
    "content": "#define GLSLIFY 1\n// Simulation uniforms\nuniform float u_dt;\nuniform float u_nActiveParticles;\n\n// Simulation constants\nconst float width = resolution.x;\nconst float height = resolution.y;\nconst float nParticles = width * height;\n\n// Softening factor. This is required to avoid high acceleration values\n// when two particles get too close\nconst float softening = 0.005;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Check if the particle is one of the active particles\n    if ((gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * width < u_nActiveParticles) {\n        // Loop over all the particles and calculate the total repulsion force\n        vec3 totalForce = vec3(0.0);\n        float forceScalingFactor = 0.0001;\n\n        for (float i = 0.0; i < nParticles; i++) {\n            // Consider only active particles\n            if (i >= u_nActiveParticles) {\n                break;\n            }\n\n            // Get the position of the repulsing particle\n            vec2 particleUv = vec2(mod(i, width) + 0.5, floor(i / width) + 0.5) / resolution;\n            vec3 particlePosition = texture2D(u_positionTexture, particleUv).xyz;\n\n            // Calculate the force direction\n            vec3 forceDirection = -(particlePosition - position);\n\n            // Calculate the particle distance\n            float distance = length(forceDirection);\n\n            // Move to the next particle if the distance is exactly zero, which\n            // indicates that we are comparing the particle with itself\n            if (distance == 0.0) {\n                continue;\n            }\n\n            // Add the particle repulsion force\n            float distanceDumping = 1.0 - smoothstep(0.45, 0.5, distance);\n            totalForce += forceScalingFactor * distanceDumping * (forceDirection / distance)\n                    / pow(distance + softening, 2.0);\n        }\n\n        // Return the updated particle velocity\n        gl_FragColor = vec4(velocity * (1.0 - 0.1 * u_dt) + u_dt * totalForce, 1.0);\n    } else {\n        // Return the original particle velocity\n        gl_FragColor = vec4(velocity, 1.0);\n    }\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-repulsion.glsl",
    "content": "#define GLSLIFY 1\n// Texture with the particle profile\nuniform sampler2D u_texture;\n\n// Particle color varying\nvarying vec3 v_color;\n\n/*\n * The main program\n */\nvoid main() {\n    // Fragment shader output\n    gl_FragColor = vec4(v_color, texture2D(u_texture, gl_PointCoord).a);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-rgb.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the color offset directions\n    float angle = u_time;\n    vec2 red_offset = vec2(cos(angle), sin(angle));\n    angle += radians(120.0);\n    vec2 green_offset = vec2(cos(angle), sin(angle));\n    angle += radians(120.0);\n    vec2 blue_offset = vec2(cos(angle), sin(angle));\n\n    // Calculate the offset size as a function of the pixel distance to the center\n    float offset_size = 0.1 * length(gl_FragCoord.xy - 0.5 * u_resolution);\n\n    // Scale the offset size by the relative mouse position\n    offset_size *= u_mouse.x / u_resolution.x;\n\n    // Extract the pixel color values from the input texture\n    float red = texture2D(u_texture, v_uv - offset_size * red_offset / u_resolution).r;\n    float green = texture2D(u_texture, v_uv - offset_size * green_offset / u_resolution).g;\n    float blue = texture2D(u_texture, v_uv - offset_size * blue_offset / u_resolution).b;\n\n    // Fragment shader output\n    gl_FragColor = vec4(red, green, blue, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-sim.glsl",
    "content": "#define GLSLIFY 1\n// Texture with the particle profile\nuniform sampler2D u_texture;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle alpha value from the texture\n    float alpha = texture2D(u_texture, gl_PointCoord).a;\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(1.0), alpha);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-sort.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * Calculates the pixel resistance based on the pixel color\n */\nfloat calculage_pixel_resistance(vec3 pixel_color) {\n    return min(min(pixel_color.r, pixel_color.g), pixel_color.b);\n}\n\n/*\n * Calculates the pixel weight based on the pixel color\n */\nfloat calculage_pixel_weight(vec3 pixel_color) {\n    return dot(pixel_color, vec3(1.0, -1.0, -1.0));\n}\n\n/*\n * Swaps the current pixel color with the color bellow if the pixel bellow is\n * lighter\n */\nvec3 swap_color_bellow(vec2 uv, float uv_min, float uv_max, float stop_value) {\n    // Get the texture uv coordinates of the pixel bellow\n    vec2 uv_bellow = uv + vec2(0.0, -1.0 / u_resolution.y);\n\n    // Make sure we stay inside the texture block limits\n    if (uv_bellow.y < uv_min || uv.y >= uv_max) {\n        uv_bellow = uv;\n    }\n\n    // Get the pixel colors\n    vec3 color = texture2D(u_texture, uv).rgb;\n    vec3 color_bellow = texture2D(u_texture, uv_bellow).rgb;\n\n    // Get the pixel resistances\n    float resistance = calculage_pixel_resistance(color);\n    float resistance_bellow = calculage_pixel_resistance(color_bellow);\n\n    // Swap the colors only if the resistances are lower than the stop value\n    if (resistance < stop_value && resistance_bellow < stop_value) {\n        // Get the pixel weights\n        float weight = calculage_pixel_weight(color);\n        float weight_bellow = calculage_pixel_weight(color_bellow);\n\n        // Swap the color if the pixel bellow is lighter\n        if (weight > weight_bellow) {\n            color = color_bellow;\n        }\n    }\n\n    return color;\n}\n\n/*\n * Swaps the current pixel color with the color above if the pixel above is\n * heavier\n */\nvec3 swap_color_above(vec2 uv, float uv_min, float uv_max, float stop_value) {\n    // Get the texture uv coordinates of the pixel above\n    vec2 uv_above = uv + vec2(0.0, 1.0 / u_resolution.y);\n\n    // Make sure we stay inside the texture block limits\n    if (uv.y < uv_min || uv_above.y >= uv_max) {\n        uv_above = uv;\n    }\n\n    // Get the pixel colors\n    vec3 color = texture2D(u_texture, uv).rgb;\n    vec3 color_above = texture2D(u_texture, uv_above).rgb;\n\n    // Get the pixel resistances\n    float resistance = calculage_pixel_resistance(color);\n    float resistance_above = calculage_pixel_resistance(color_above);\n\n    // Swap the colors only if the resistances are lower than the stop value\n    if (resistance < stop_value && resistance_above < stop_value) {\n        // Get the pixel weights\n        float weight = calculage_pixel_weight(color);\n        float weight_above = calculage_pixel_weight(color_above);\n\n        // Swap the color if the pixel above is heavier\n        if (weight < weight_above) {\n            color = color_above;\n        }\n    }\n\n    return color;\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Set the sorting parameters using the mouse relative position\n    float n_steps = floor(10.0 * u_mouse.y / u_resolution.y);\n    float uv_min = floor(n_steps * v_uv.y) / n_steps;\n    float uv_max = min(uv_min + 1.0 / n_steps, 1.0);\n    float stop_value = u_mouse.x / u_resolution.x;\n\n    // Check if we are in an even pixel row\n    bool even_row = mod(floor(gl_FragCoord.y), 2.0) == 0.0;\n\n    // Calculate the new pixel color\n    vec3 pixel_color;\n\n    if (mod(u_frame, 2.0) == 0.0) {\n        if (even_row) {\n            pixel_color = swap_color_bellow(v_uv, uv_min, uv_max, stop_value);\n        } else {\n            pixel_color = swap_color_above(v_uv, uv_min, uv_max, stop_value);\n        }\n    } else {\n        if (even_row) {\n            pixel_color = swap_color_above(v_uv, uv_min, uv_max, stop_value);\n        } else {\n            pixel_color = swap_color_bellow(v_uv, uv_min, uv_max, stop_value);\n        }\n    }\n\n    // Fragment shader output\n    gl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-sphere.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n *  Calculates the normal vector at the given position\n *\n *  Uses this fix for some mobiles:\n *  https://stackoverflow.com/questions/20272272/standard-derivatives-from-fragment-shader-dfdx-dfdy-dont-run-correctly-in-a\n */\nvec3 calculateNormal(vec3 position) {\n    vec3 fdx = vec3(dFdx(position.x), dFdx(position.y), dFdx(position.z));\n    vec3 fdy = vec3(dFdy(position.x), dFdy(position.y), dFdy(position.z));\n    vec3 normal = normalize(cross(fdx, fdy));\n\n    if (!gl_FrontFacing) {\n        normal = -normal;\n    }\n\n    return normal;\n}\n\n/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n// The sphere radius\nuniform float u_radius;\n\n// Varying containing the sphere elevation\nvarying float v_elevation;\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new normal vector\n\tvec3 new_normal = calculateNormal(v_position);\n\n\t// Use the mouse position to define the light direction\n\tfloat min_resolution = min(u_resolution.x, u_resolution.y);\n\tvec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.25);\n\n\t// Set the default surface color\n\tvec3 surface_color = vec3(clamp(0.0, 1.0, 5.0*(v_elevation - u_radius)/u_radius), 0.3, 0.3);\n\n\t// Apply the light diffusion factor\n\tsurface_color *= diffuseFactor(new_normal, light_direction);\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(surface_color, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-stippling-pos.glsl",
    "content": "#define GLSLIFY 1\n// Simulation uniforms\nuniform float u_dt;\nuniform float u_nActiveParticles;\n\n// Simulation constants\nconst float width = resolution.x;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Check if the particle is one of the active particles\n    if ((gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * width < u_nActiveParticles) {\n        // Return the updated particle position\n        gl_FragColor = vec4(position + u_dt * velocity, 1.0);\n    } else {\n        // Return the original particle position\n        gl_FragColor = vec4(position, 1.0);\n    }\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-stippling-vel.glsl",
    "content": "#define GLSLIFY 1\n// Simulation uniforms\nuniform float u_dt;\nuniform float u_nActiveParticles;\nuniform sampler2D u_bgTexture;\nuniform vec2 u_textureOffset;\n\n// Simulation constants\nconst float width = resolution.x;\nconst float height = resolution.y;\nconst float nParticles = width * height;\n\n// Softening factor. This is required to avoid high acceleration values when\n// two particles get too close\nconst float softening = 0.03;\n\n/*\n * Returns the texture background color at the given position\n */\nvec3 get_background_color(vec3 position) {\n    return texture2D(u_bgTexture, (position.xy + u_textureOffset) / (2.0 * u_textureOffset)).rgb;\n}\n\n/*\n * Calculates the charge size for the given background color\n */\nfloat calculate_charge_size(vec3 bgColor) {\n    return 0.045 + 0.03 * pow(dot(bgColor, vec3(1.0)), 2.0);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Check if the particle is one of the active particles\n    if ((gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * width < u_nActiveParticles) {\n        // Get the particle current position\n        vec3 position = texture2D(u_positionTexture, uv).xyz;\n\n        // Get the particle charge size based on the background color\n        vec3 bgColor = get_background_color(position);\n        float chargeSize = calculate_charge_size(bgColor);\n\n        // Loop over all the particles and calculate the total repulsion force\n        vec3 totalForce = vec3(0.0);\n\n        for (float i = 0.0; i < nParticles; i++) {\n            // Consider only active particles\n            if (i >= u_nActiveParticles) {\n                break;\n            }\n\n            // Get the position of the repulsing particle\n            vec2 particleUv = vec2(mod(i, width) + 0.5, floor(i / width) + 0.5) / resolution;\n            vec3 particlePosition = texture2D(u_positionTexture, particleUv).xyz;\n\n            // Get the repulsing particle charge size based on the background color\n            vec3 particleBgColor = get_background_color(particlePosition);\n            float particleChargeSize = calculate_charge_size(particleBgColor);\n\n            // Calculate the total charge size\n            float totalChargeSize = chargeSize + particleChargeSize;\n\n            // Calculate the force direction\n            vec3 forceDirection = -(particlePosition - position);\n\n            // Calculate the particle distance\n            float distance = length(forceDirection);\n\n            // Check that we are not comparing the particle with itself (zero\n            // distance) and that the distance is smaller than the total\n            // charge size\n            if (distance != 0.0 && distance < totalChargeSize) {\n                // Add the particle repulsion force\n                totalForce += 0.03 * pow(totalChargeSize / (distance + softening), 2.0) * (forceDirection / distance);\n            }\n        }\n\n        // Return the new particle velocity\n        gl_FragColor = vec4(u_dt * totalForce, 1.0);\n    } else {\n        // Return the original particle velocity\n        gl_FragColor = texture2D(u_velocityTexture, uv);\n    }\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-stippling.glsl",
    "content": "#define GLSLIFY 1\n// Texture with the particle profile\nuniform sampler2D u_texture;\n\n/*\n * The main program\n */\nvoid main() {\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(0.0), texture2D(u_texture, gl_PointCoord).a);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-stripes.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Use the mouse position to define the light direction\n    float min_resolution = min(u_resolution.x, u_resolution.y);\n    vec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.5);\n\n    // Calculate the light diffusion factor\n    float df = diffuseFactor(v_normal, light_direction);\n\n    // Calculate the surface color\n    float surface_color = df;\n\n    // Don't paint the pixels between the stripes\n    if (cos(2.0 * v_position.y + 3.0 * u_time) < 0.0) {\n        discard;\n    }\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(surface_color), 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-tile.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the square\n */\nfloat square(vec2 pixel, vec2 bottom_left, float side) {\n    vec2 top_right = bottom_left + side;\n\n    return smoothstep(-1.0, 1.0, pixel.x - bottom_left.x) * smoothstep(-1.0, 1.0, pixel.y - bottom_left.y)\n            * smoothstep(-1.0, 1.0, top_right.x - pixel.x) * smoothstep(-1.0, 1.0, top_right.y - pixel.y);\n}\n\n/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the rectangle\n */\nfloat rectangle(vec2 pixel, vec2 bottom_left, vec2 sides) {\n    vec2 top_right = bottom_left + sides;\n\n    return smoothstep(-1.0, 1.0, pixel.x - bottom_left.x) * smoothstep(-1.0, 1.0, pixel.y - bottom_left.y)\n            * smoothstep(-1.0, 1.0, top_right.x - pixel.x) * smoothstep(-1.0, 1.0, top_right.y - pixel.y);\n}\n\n/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the circle\n */\nfloat circle(vec2 pixel, vec2 center, float radius) {\n    return 1.0 - smoothstep(radius - 1.0, radius + 1.0, length(pixel - center));\n}\n\n/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the ellipse\n */\nfloat ellipse(vec2 pixel, vec2 center, vec2 radii) {\n    vec2 relative_pos = pixel - center;\n    float dist = length(relative_pos);\n    float r = radii.x * radii.y * dist / length(radii.yx * relative_pos);\n\n    return 1.0 - smoothstep(r - 1.0, r + 1.0, dist);\n}\n\n/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the line segment\n */\nfloat lineSegment(vec2 pixel, vec2 start, vec2 end, float width) {\n    vec2 pixel_dir = pixel - start;\n    vec2 line_dir = end - start;\n    float line_length = length(line_dir);\n    float projected_dist = dot(pixel_dir, line_dir) / line_length;\n    float tanjential_dist = sqrt(dot(pixel_dir, pixel_dir) - projected_dist * projected_dist);\n\n    return smoothstep(-1.0, 1.0, projected_dist) * smoothstep(-1.0, 1.0, line_length - projected_dist)\n            * (1.0 - smoothstep(-1.0, 1.0, tanjential_dist - 0.5 * width));\n}\n\n/*\n * Returns a rotation matrix for the given angle\n */\nmat2 rotate(float angle) {\n    return mat2(cos(angle), -sin(angle), sin(angle), cos(angle));\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Set the background color\n    vec3 pixel_color = vec3(0.0);\n\n    // Divide the screen in a grid\n    vec2 grid1_pos = mod(gl_FragCoord.xy, 250.0);\n\n    // Add a blue square to each grid element\n    pixel_color = mix(pixel_color, vec3(0.3, 0.4, 1.0), square(grid1_pos, vec2(5.0, 5.0), 150.0));\n\n    // Add a red circle to each grid element\n    pixel_color = mix(pixel_color, vec3(1.0, 0.4, 0.3), circle(grid1_pos, vec2(0.0, 0.0), 80.0));\n\n    // Add ten grey lines to each grid element\n    for (float i = 0.0; i < 10.0; ++i) {\n        pixel_color = mix(pixel_color, vec3(0.8),\n                lineSegment(grid1_pos, vec2(10.0, -10.0 * i), vec2(150.0, 100.0 - 10.0 * i), 4.0));\n    }\n\n    // Apply some rotations to the grid\n    grid1_pos -= 100.0;\n    grid1_pos = rotate(u_time) * grid1_pos;\n    grid1_pos += 100.0;\n    grid1_pos -= 60.0;\n    grid1_pos = rotate(0.66 * u_time) * grid1_pos;\n    grid1_pos += 60.0;\n\n    // Draw a green rectangle to each grid element\n    pixel_color = mix(pixel_color, vec3(0.3, 0.9, 0.3), rectangle(grid1_pos, vec2(60.0, 50.0), vec2(40.0, 20)));\n\n    // Define a second rotated grid\n    vec2 grid2_pos = mod(rotate(radians(45.0)) * gl_FragCoord.xy, 100.0);\n\n    // Add a white circle to each grid element\n    pixel_color = mix(pixel_color, vec3(1.0), circle(grid2_pos, vec2(50.0, 50.0), 20.0));\n\n    // Fragment shader output\n    gl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-toon.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Use the mouse position to define the light direction\n    float min_resolution = min(u_resolution.x, u_resolution.y);\n    vec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.5);\n\n    // Calculate the light diffusion factor\n    float df = diffuseFactor(v_normal, light_direction);\n\n    // Define the toon shading steps\n    float nSteps = 4.0;\n    float step = sqrt(df) * nSteps;\n    step = (floor(step) + smoothstep(0.48, 0.52, fract(step))) / nSteps;\n\n    // Calculate the surface color\n    float surface_color = step * step;\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(surface_color), 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/frag-wave.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Use the mouse position to define the light direction\n    float min_resolution = min(u_resolution.x, u_resolution.y);\n    vec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.25);\n\n    // Set the surface color\n    vec3 surface_color = vec3(0.5 + 0.5 * cos(2.0 * v_position.y + 3.0 * u_time));\n\n    // Apply the light diffusion factor\n    surface_color *= diffuseFactor(v_normal, light_direction);\n\n    // Fragment shader output\n    gl_FragColor = vec4(surface_color, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/vert-2d.glsl",
    "content": "#define GLSLIFY 1\n/*\n * The main program\n */\nvoid main() {\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/vert-3d.glsl",
    "content": "#define GLSLIFY 1\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * The main program\n */\nvoid main() {\n    // Save the varyings\n    v_position = position;\n    v_normal = normalize(normalMatrix * normal);\n\n    // Vertex shader output\n    gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/vert-attraction.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * The main program\n */\nvoid main() {\n\t// Define the attractor position using spherical coordinates\n\tfloat r = 15.0;\n\tfloat theta = 0.87 * u_time;\n\tfloat phi = 0.63 * u_time;\n\tvec3 attractor_position = r * vec3(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));\n\n\t// Calculate the new vertex position to simulate attraction effect\n\tvec3 effect_direction = attractor_position - position;\n\tfloat effect_intensity = min(30.0 * pow(length(effect_direction), -2.0), 1.0);\n\tvec3 new_position = position + effect_intensity * effect_direction;\n\n\t// Calculate the modelview position\n\tvec4 mv_position = modelViewMatrix * vec4(new_position, 1.0);\n\n\t// Save the varyings\n\tv_position = mv_position.xyz;\n\tv_normal = normalize(normalMatrix * normal);\n\n\t// Vertex shader output\n\tgl_Position = projectionMatrix * mv_position;\n}\n"
  },
  {
    "path": "WebContent/shaders/vert-debug.glsl",
    "content": "#define GLSLIFY 1\nattribute float a_index;\n\nuniform float u_width;\nuniform float u_height;\nuniform sampler2D u_positionTexture;\n\nvoid main() {\n    vec2 uv = vec2((mod(a_index, u_width) + 0.5) / u_width, (floor(a_index / u_width) + 0.5) / u_height);\n    gl_PointSize = 2.0;\n    gl_Position = projectionMatrix * modelViewMatrix * texture2D(u_positionTexture, uv);\n}\n"
  },
  {
    "path": "WebContent/shaders/vert-deform.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new vertex position to simulate a wave effect\n\tfloat effect_intensity = 2.0 * u_mouse.x / u_resolution.x;\n\tvec3 new_position = position + effect_intensity * (0.5 + 0.5 * cos(position.x + 4.0 * u_time)) * normal;\n\n\t// Calculate the modelview position\n\tvec4 mv_position = modelViewMatrix * vec4(new_position, 1.0);\n\n\t// Save the varyings\n\tv_position = mv_position.xyz;\n\tv_normal = normalize(normalMatrix * normal);\n\n\t// Vertex shader output\n\tgl_Position = projectionMatrix * mv_position;\n}\n"
  },
  {
    "path": "WebContent/shaders/vert-dla.glsl",
    "content": "#define GLSLIFY 1\n// Particle index attribute\nattribute float a_index;\n\n// Simulation uniforms\nuniform float u_width;\nuniform float u_height;\nuniform float u_particleSize;\nuniform sampler2D u_positionTexture;\n\n// Varying with the aggregation information\nvarying float v_aggregation;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle model view position\n    vec2 uv = vec2((mod(a_index, u_width) + 0.5) / u_width, (floor(a_index / u_width) + 0.5) / u_height);\n    vec4 position = texture2D(u_positionTexture, uv);\n    vec4 mvPosition = modelViewMatrix * vec4(position.xyz, 1.0);\n\n    // Pass the aggregation information to the fragment shader\n    v_aggregation = position.w;\n\n    // Vertex shader output\n    gl_PointSize = v_aggregation < 0.0 ? -u_particleSize / mvPosition.z : -0.5 * u_particleSize / mvPosition.z;\n    gl_Position = projectionMatrix * mvPosition;\n}\n"
  },
  {
    "path": "WebContent/shaders/vert-filters.glsl",
    "content": "#define GLSLIFY 1\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the varyings\n    v_uv = uv;\n\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n"
  },
  {
    "path": "WebContent/shaders/vert-mountains.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * GLSL textureless classic 2D noise \"cnoise\",\n * with an RSL-style periodic variant \"pnoise\".\n * Author:  Stefan Gustavson (stefan.gustavson@liu.se)\n * Version: 2011-08-22\n *\n * Many thanks to Ian McEwan of Ashima Arts for the\n * ideas for permutation and gradient selection.\n *\n * Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n * Distributed under the MIT license. See LICENSE file.\n * https://github.com/stegu/webgl-noise\n */\n\nvec4 mod289(vec4 x) {\n    return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x) {\n    return mod289(((x * 34.0) + 1.0) * x);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n    return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nvec2 fade(vec2 t) {\n    return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n\nfloat cnoise(vec2 P) {\n    vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n    vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n    Pi = mod289(Pi);\n    vec4 ix = Pi.xzxz;\n    vec4 iy = Pi.yyww;\n    vec4 fx = Pf.xzxz;\n    vec4 fy = Pf.yyww;\n\n    vec4 i = permute(permute(ix) + iy);\n\n    vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0;\n    vec4 gy = abs(gx) - 0.5;\n    vec4 tx = floor(gx + 0.5);\n    gx = gx - tx;\n\n    vec2 g00 = vec2(gx.x, gy.x);\n    vec2 g10 = vec2(gx.y, gy.y);\n    vec2 g01 = vec2(gx.z, gy.z);\n    vec2 g11 = vec2(gx.w, gy.w);\n\n    vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n    g00 *= norm.x;\n    g01 *= norm.y;\n    g10 *= norm.z;\n    g11 *= norm.w;\n\n    float n00 = dot(g00, vec2(fx.x, fy.x));\n    float n10 = dot(g10, vec2(fx.y, fy.y));\n    float n01 = dot(g01, vec2(fx.z, fy.z));\n    float n11 = dot(g11, vec2(fx.w, fy.w));\n\n    vec2 fade_xy = fade(Pf.xy);\n    vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n    float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n    return 2.3 * n_xy;\n}\n\n// The plane tile size, the flying speed and the maximum mountain height\nuniform float u_tileSize;\nuniform float u_speed;\nuniform float u_maxHeight;\n\n// Varying containing the terrain elevation\nvarying float v_elevation;\n\n// Calculates the vertex displaced position\nvec3 getDisplacedPosition(vec3 position) {\n\t// Calculate the total flying distance\n\tfloat distance = u_speed * u_time;\n\n\t// Calculate the vertex horizontal shift\n\tfloat h_shift = mod(distance, u_tileSize);\n\n\t// Calculate the vertex vertical shift\n\tfloat v_shift = u_maxHeight * cnoise(0.4 * floor(vec2(position.x, position.z - distance) / u_tileSize));\n\n\t// Flatten the bottom to simulate the lakes\n\tv_shift = max(-0.8 * u_maxHeight, v_shift);\n\n\treturn position + vec3(0.0, v_shift, h_shift);\n}\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new vertex position\n\tvec3 new_position = getDisplacedPosition(position);\n\n\t// Calculate the modelview position\n\tvec4 mv_position = modelViewMatrix * vec4(new_position, 1.0);\n\n\t// Save the varyings\n\tv_position = mv_position.xyz;\n\tv_elevation = 0.5 * (u_maxHeight + new_position.y);\n\n\t// Vertex shader output\n\tgl_Position = projectionMatrix * mv_position;\n}\n"
  },
  {
    "path": "WebContent/shaders/vert-repulsion.glsl",
    "content": "#define GLSLIFY 1\n// Particle index attribute\nattribute float a_index;\n\n// Simulation uniforms\nuniform float u_width;\nuniform float u_height;\nuniform float u_particleSize;\nuniform float u_nActiveParticles;\nuniform sampler2D u_positionTexture;\nuniform sampler2D u_velocityTexture;\n\n// Particle color varying\nvarying vec3 v_color;\n\n/*\n * The main program\n */\nvoid main() {\n    // Check if the particle is one of the active particles\n    if (a_index < u_nActiveParticles) {\n        // Get the particle position and velocity\n        vec2 uv = vec2((mod(a_index, u_width) + 0.5) / u_width, (floor(a_index / u_width) + 0.5) / u_height);\n        vec3 position = texture2D(u_positionTexture, uv).xyz;\n        vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n        // Calculate the model view position\n        vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n\n        // Calculate the particle color based on its velocity\n        v_color = mix(vec3(1.0, 0.0, 0.0), vec3(1.0, 1.0, 0.0), 20.0 * length(velocity));\n\n        // Vertex shader output\n        gl_PointSize = -u_particleSize / mvPosition.z;\n        gl_Position = projectionMatrix * mvPosition;\n    } else {\n        // Vertex shader output\n        gl_PointSize = 0.0;\n        gl_Position = vec4(-1000000.0);\n    }\n}\n"
  },
  {
    "path": "WebContent/shaders/vert-sim.glsl",
    "content": "#define GLSLIFY 1\n// Particle index attribute\nattribute float a_index;\n\n// Simulation uniforms\nuniform float u_width;\nuniform float u_height;\nuniform float u_particleSize;\nuniform sampler2D u_positionTexture;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle model view position\n    vec2 uv = vec2((mod(a_index, u_width) + 0.5) / u_width, (floor(a_index / u_width) + 0.5) / u_height);\n    vec4 mvPosition = modelViewMatrix * texture2D(u_positionTexture, uv);\n\n    // Vertex shader output\n    gl_PointSize = -u_particleSize / mvPosition.z;\n    gl_Position = projectionMatrix * mvPosition;\n}\n"
  },
  {
    "path": "WebContent/shaders/vert-sphere.glsl",
    "content": "#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * GLSL textureless classic 2D noise \"cnoise\",\n * with an RSL-style periodic variant \"pnoise\".\n * Author:  Stefan Gustavson (stefan.gustavson@liu.se)\n * Version: 2011-08-22\n *\n * Many thanks to Ian McEwan of Ashima Arts for the\n * ideas for permutation and gradient selection.\n *\n * Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n * Distributed under the MIT license. See LICENSE file.\n * https://github.com/stegu/webgl-noise\n */\n\nvec4 mod289(vec4 x) {\n    return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x) {\n    return mod289(((x * 34.0) + 1.0) * x);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n    return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nvec2 fade(vec2 t) {\n    return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n\nfloat cnoise(vec2 P) {\n    vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n    vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n    Pi = mod289(Pi);\n    vec4 ix = Pi.xzxz;\n    vec4 iy = Pi.yyww;\n    vec4 fx = Pf.xzxz;\n    vec4 fy = Pf.yyww;\n\n    vec4 i = permute(permute(ix) + iy);\n\n    vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0;\n    vec4 gy = abs(gx) - 0.5;\n    vec4 tx = floor(gx + 0.5);\n    gx = gx - tx;\n\n    vec2 g00 = vec2(gx.x, gy.x);\n    vec2 g10 = vec2(gx.y, gy.y);\n    vec2 g01 = vec2(gx.z, gy.z);\n    vec2 g11 = vec2(gx.w, gy.w);\n\n    vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n    g00 *= norm.x;\n    g01 *= norm.y;\n    g10 *= norm.z;\n    g11 *= norm.w;\n\n    float n00 = dot(g00, vec2(fx.x, fy.x));\n    float n10 = dot(g10, vec2(fx.y, fy.y));\n    float n01 = dot(g01, vec2(fx.z, fy.z));\n    float n11 = dot(g11, vec2(fx.w, fy.w));\n\n    vec2 fade_xy = fade(Pf.xy);\n    vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n    float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n    return 2.3 * n_xy;\n}\n\n// The sphere radius\nuniform float u_radius;\n\n// Varying containing the sphere elevation\nvarying float v_elevation;\n\n// Calculates the vertex displaced position\nvec3 getDisplacedPosition(vec3 position) {\n\t// Calculate the vertex shift\n\tfloat shift = 2.0\n\t\t\t* cnoise(vec2(3.0 * cos(atan(position.z, position.x)), 2.0 * u_time + 3.0 * acos(position.y / u_radius)));\n\n\treturn position + normal * shift;\n}\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new vertex position\n\tvec3 new_position = getDisplacedPosition(position);\n\n\t// Calculate the modelview position\n\tvec4 mv_position = modelViewMatrix * vec4(new_position, 1.0);\n\n\t// Save the varyings\n\tv_position = mv_position.xyz;\n\tv_elevation = length(new_position);\n\n\t// Vertex shader output\n\tgl_Position = projectionMatrix * mv_position;\n}\n"
  },
  {
    "path": "WebContent/shaders/vert-stippling.glsl",
    "content": "#define GLSLIFY 1\n// Particle index attribute\nattribute float a_index;\n\n// Simulation uniforms\nuniform float u_width;\nuniform float u_height;\nuniform float u_particleSize;\nuniform float u_nActiveParticles;\nuniform sampler2D u_positionTexture;\nuniform sampler2D u_bgTexture;\nuniform vec2 u_textureOffset;\n\n/*\n * Returns the texture background color at the given position\n */\nvec3 get_background_color(vec3 position) {\n    return texture2D(u_bgTexture, (position.xy + u_textureOffset) / (2.0 * u_textureOffset)).rgb;\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Check if the particle is one of the active particles\n    if (a_index < u_nActiveParticles) {\n        // Get the particle position\n        vec2 uv = vec2((mod(a_index, u_width) + 0.5) / u_width, (floor(a_index / u_width) + 0.5) / u_height);\n        vec3 position = texture2D(u_positionTexture, uv).xyz;\n\n        // Calculate the model view position\n        vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n\n        // Calculate the particle relative size based on the background texture color\n        vec3 bgColor = get_background_color(position);\n        float relativeSize = 1.0 - 0.3 * dot(bgColor, vec3(1.0));\n\n        // Vertex shader output\n        gl_PointSize = -u_particleSize * relativeSize / mvPosition.z;\n        gl_Position = projectionMatrix * mvPosition;\n    } else {\n        // Vertex shader output\n        gl_PointSize = 0.0;\n        gl_Position = vec4(-1000000.0);\n    }\n}\n"
  },
  {
    "path": "WebContent/sort-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 2D\">\n<meta name=\"description\" content=\"sort shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>sort shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-evolveImage.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-filters.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-sort.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the varyings\n    v_uv = uv;\n\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Texture uniforms\nuniform sampler2D u_texture;\n\n// Texture varyings\nvarying vec2 v_uv;\n\n/*\n * Calculates the pixel resistance based on the pixel color\n */\nfloat calculage_pixel_resistance(vec3 pixel_color) {\n    return min(min(pixel_color.r, pixel_color.g), pixel_color.b);\n}\n\n/*\n * Calculates the pixel weight based on the pixel color\n */\nfloat calculage_pixel_weight(vec3 pixel_color) {\n    return dot(pixel_color, vec3(1.0, -1.0, -1.0));\n}\n\n/*\n * Swaps the current pixel color with the color bellow if the pixel bellow is\n * lighter\n */\nvec3 swap_color_bellow(vec2 uv, float uv_min, float uv_max, float stop_value) {\n    // Get the texture uv coordinates of the pixel bellow\n    vec2 uv_bellow = uv + vec2(0.0, -1.0 / u_resolution.y);\n\n    // Make sure we stay inside the texture block limits\n    if (uv_bellow.y < uv_min || uv.y >= uv_max) {\n        uv_bellow = uv;\n    }\n\n    // Get the pixel colors\n    vec3 color = texture2D(u_texture, uv).rgb;\n    vec3 color_bellow = texture2D(u_texture, uv_bellow).rgb;\n\n    // Get the pixel resistances\n    float resistance = calculage_pixel_resistance(color);\n    float resistance_bellow = calculage_pixel_resistance(color_bellow);\n\n    // Swap the colors only if the resistances are lower than the stop value\n    if (resistance < stop_value && resistance_bellow < stop_value) {\n        // Get the pixel weights\n        float weight = calculage_pixel_weight(color);\n        float weight_bellow = calculage_pixel_weight(color_bellow);\n\n        // Swap the color if the pixel bellow is lighter\n        if (weight > weight_bellow) {\n            color = color_bellow;\n        }\n    }\n\n    return color;\n}\n\n/*\n * Swaps the current pixel color with the color above if the pixel above is\n * heavier\n */\nvec3 swap_color_above(vec2 uv, float uv_min, float uv_max, float stop_value) {\n    // Get the texture uv coordinates of the pixel above\n    vec2 uv_above = uv + vec2(0.0, 1.0 / u_resolution.y);\n\n    // Make sure we stay inside the texture block limits\n    if (uv.y < uv_min || uv_above.y >= uv_max) {\n        uv_above = uv;\n    }\n\n    // Get the pixel colors\n    vec3 color = texture2D(u_texture, uv).rgb;\n    vec3 color_above = texture2D(u_texture, uv_above).rgb;\n\n    // Get the pixel resistances\n    float resistance = calculage_pixel_resistance(color);\n    float resistance_above = calculage_pixel_resistance(color_above);\n\n    // Swap the colors only if the resistances are lower than the stop value\n    if (resistance < stop_value && resistance_above < stop_value) {\n        // Get the pixel weights\n        float weight = calculage_pixel_weight(color);\n        float weight_above = calculage_pixel_weight(color_above);\n\n        // Swap the color if the pixel above is heavier\n        if (weight < weight_above) {\n            color = color_above;\n        }\n    }\n\n    return color;\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Set the sorting parameters using the mouse relative position\n    float n_steps = floor(10.0 * u_mouse.y / u_resolution.y);\n    float uv_min = floor(n_steps * v_uv.y) / n_steps;\n    float uv_max = min(uv_min + 1.0 / n_steps, 1.0);\n    float stop_value = u_mouse.x / u_resolution.x;\n\n    // Check if we are in an even pixel row\n    bool even_row = mod(floor(gl_FragCoord.y), 2.0) == 0.0;\n\n    // Calculate the new pixel color\n    vec3 pixel_color;\n\n    if (mod(u_frame, 2.0) == 0.0) {\n        if (even_row) {\n            pixel_color = swap_color_bellow(v_uv, uv_min, uv_max, stop_value);\n        } else {\n            pixel_color = swap_color_above(v_uv, uv_min, uv_max, stop_value);\n        }\n    } else {\n        if (even_row) {\n            pixel_color = swap_color_above(v_uv, uv_min, uv_max, stop_value);\n        } else {\n            pixel_color = swap_color_bellow(v_uv, uv_min, uv_max, stop_value);\n        }\n    }\n\n    // Fragment shader output\n    gl_FragColor = vec4(pixel_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-evolveImage.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/sphere-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 3D\">\n<meta name=\"description\" content=\"sphere shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>sphere shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-sphere.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-sphere.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-sphere.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * GLSL textureless classic 2D noise \"cnoise\",\n * with an RSL-style periodic variant \"pnoise\".\n * Author:  Stefan Gustavson (stefan.gustavson@liu.se)\n * Version: 2011-08-22\n *\n * Many thanks to Ian McEwan of Ashima Arts for the\n * ideas for permutation and gradient selection.\n *\n * Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n * Distributed under the MIT license. See LICENSE file.\n * https://github.com/stegu/webgl-noise\n */\n\nvec4 mod289(vec4 x) {\n    return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x) {\n    return mod289(((x * 34.0) + 1.0) * x);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n    return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nvec2 fade(vec2 t) {\n    return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n\nfloat cnoise(vec2 P) {\n    vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n    vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n    Pi = mod289(Pi);\n    vec4 ix = Pi.xzxz;\n    vec4 iy = Pi.yyww;\n    vec4 fx = Pf.xzxz;\n    vec4 fy = Pf.yyww;\n\n    vec4 i = permute(permute(ix) + iy);\n\n    vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0;\n    vec4 gy = abs(gx) - 0.5;\n    vec4 tx = floor(gx + 0.5);\n    gx = gx - tx;\n\n    vec2 g00 = vec2(gx.x, gy.x);\n    vec2 g10 = vec2(gx.y, gy.y);\n    vec2 g01 = vec2(gx.z, gy.z);\n    vec2 g11 = vec2(gx.w, gy.w);\n\n    vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n    g00 *= norm.x;\n    g01 *= norm.y;\n    g10 *= norm.z;\n    g11 *= norm.w;\n\n    float n00 = dot(g00, vec2(fx.x, fy.x));\n    float n10 = dot(g10, vec2(fx.y, fy.y));\n    float n01 = dot(g01, vec2(fx.z, fy.z));\n    float n11 = dot(g11, vec2(fx.w, fy.w));\n\n    vec2 fade_xy = fade(Pf.xy);\n    vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n    float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n    return 2.3 * n_xy;\n}\n\n// The sphere radius\nuniform float u_radius;\n\n// Varying containing the sphere elevation\nvarying float v_elevation;\n\n// Calculates the vertex displaced position\nvec3 getDisplacedPosition(vec3 position) {\n\t// Calculate the vertex shift\n\tfloat shift = 2.0\n\t\t\t* cnoise(vec2(3.0 * cos(atan(position.z, position.x)), 2.0 * u_time + 3.0 * acos(position.y / u_radius)));\n\n\treturn position + normal * shift;\n}\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new vertex position\n\tvec3 new_position = getDisplacedPosition(position);\n\n\t// Calculate the modelview position\n\tvec4 mv_position = modelViewMatrix * vec4(new_position, 1.0);\n\n\t// Save the varyings\n\tv_position = mv_position.xyz;\n\tv_elevation = length(new_position);\n\n\t// Vertex shader output\n\tgl_Position = projectionMatrix * mv_position;\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n *  Calculates the normal vector at the given position\n *\n *  Uses this fix for some mobiles:\n *  https://stackoverflow.com/questions/20272272/standard-derivatives-from-fragment-shader-dfdx-dfdy-dont-run-correctly-in-a\n */\nvec3 calculateNormal(vec3 position) {\n    vec3 fdx = vec3(dFdx(position.x), dFdx(position.y), dFdx(position.z));\n    vec3 fdy = vec3(dFdy(position.x), dFdy(position.y), dFdy(position.z));\n    vec3 normal = normalize(cross(fdx, fdy));\n\n    if (!gl_FrontFacing) {\n        normal = -normal;\n    }\n\n    return normal;\n}\n\n/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n// The sphere radius\nuniform float u_radius;\n\n// Varying containing the sphere elevation\nvarying float v_elevation;\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new normal vector\n\tvec3 new_normal = calculateNormal(v_position);\n\n\t// Use the mouse position to define the light direction\n\tfloat min_resolution = min(u_resolution.x, u_resolution.y);\n\tvec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.25);\n\n\t// Set the default surface color\n\tvec3 surface_color = vec3(clamp(0.0, 1.0, 5.0*(v_elevation - u_radius)/u_radius), 0.3, 0.3);\n\n\t// Apply the light diffusion factor\n\tsurface_color *= diffuseFactor(new_normal, light_direction);\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(surface_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-sphere.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/stippling-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 3D, simulation\">\n<meta name=\"description\" content=\"stippling shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>stippling shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/GPUComputationRenderer.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-stippling.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-stippling-pos.glsl\" class=\"nav-item\">Position shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-stippling-vel.glsl\" class=\"nav-item\">Velocity shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-stippling.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-stippling.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"positionShader\">\n#define GLSLIFY 1\n// Simulation uniforms\nuniform float u_dt;\nuniform float u_nActiveParticles;\n\n// Simulation constants\nconst float width = resolution.x;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Check if the particle is one of the active particles\n    if ((gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * width < u_nActiveParticles) {\n        // Return the updated particle position\n        gl_FragColor = vec4(position + u_dt * velocity, 1.0);\n    } else {\n        // Return the original particle position\n        gl_FragColor = vec4(position, 1.0);\n    }\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"velocityShader\">\n#define GLSLIFY 1\n// Simulation uniforms\nuniform float u_dt;\nuniform float u_nActiveParticles;\nuniform sampler2D u_bgTexture;\nuniform vec2 u_textureOffset;\n\n// Simulation constants\nconst float width = resolution.x;\nconst float height = resolution.y;\nconst float nParticles = width * height;\n\n// Softening factor. This is required to avoid high acceleration values when\n// two particles get too close\nconst float softening = 0.03;\n\n/*\n * Returns the texture background color at the given position\n */\nvec3 get_background_color(vec3 position) {\n    return texture2D(u_bgTexture, (position.xy + u_textureOffset) / (2.0 * u_textureOffset)).rgb;\n}\n\n/*\n * Calculates the charge size for the given background color\n */\nfloat calculate_charge_size(vec3 bgColor) {\n    return 0.045 + 0.03 * pow(dot(bgColor, vec3(1.0)), 2.0);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Check if the particle is one of the active particles\n    if ((gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * width < u_nActiveParticles) {\n        // Get the particle current position\n        vec3 position = texture2D(u_positionTexture, uv).xyz;\n\n        // Get the particle charge size based on the background color\n        vec3 bgColor = get_background_color(position);\n        float chargeSize = calculate_charge_size(bgColor);\n\n        // Loop over all the particles and calculate the total repulsion force\n        vec3 totalForce = vec3(0.0);\n\n        for (float i = 0.0; i < nParticles; i++) {\n            // Consider only active particles\n            if (i >= u_nActiveParticles) {\n                break;\n            }\n\n            // Get the position of the repulsing particle\n            vec2 particleUv = vec2(mod(i, width) + 0.5, floor(i / width) + 0.5) / resolution;\n            vec3 particlePosition = texture2D(u_positionTexture, particleUv).xyz;\n\n            // Get the repulsing particle charge size based on the background color\n            vec3 particleBgColor = get_background_color(particlePosition);\n            float particleChargeSize = calculate_charge_size(particleBgColor);\n\n            // Calculate the total charge size\n            float totalChargeSize = chargeSize + particleChargeSize;\n\n            // Calculate the force direction\n            vec3 forceDirection = -(particlePosition - position);\n\n            // Calculate the particle distance\n            float distance = length(forceDirection);\n\n            // Check that we are not comparing the particle with itself (zero\n            // distance) and that the distance is smaller than the total\n            // charge size\n            if (distance != 0.0 && distance < totalChargeSize) {\n                // Add the particle repulsion force\n                totalForce += 0.03 * pow(totalChargeSize / (distance + softening), 2.0) * (forceDirection / distance);\n            }\n        }\n\n        // Return the new particle velocity\n        gl_FragColor = vec4(u_dt * totalForce, 1.0);\n    } else {\n        // Return the original particle velocity\n        gl_FragColor = texture2D(u_velocityTexture, uv);\n    }\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Particle index attribute\nattribute float a_index;\n\n// Simulation uniforms\nuniform float u_width;\nuniform float u_height;\nuniform float u_particleSize;\nuniform float u_nActiveParticles;\nuniform sampler2D u_positionTexture;\nuniform sampler2D u_bgTexture;\nuniform vec2 u_textureOffset;\n\n/*\n * Returns the texture background color at the given position\n */\nvec3 get_background_color(vec3 position) {\n    return texture2D(u_bgTexture, (position.xy + u_textureOffset) / (2.0 * u_textureOffset)).rgb;\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Check if the particle is one of the active particles\n    if (a_index < u_nActiveParticles) {\n        // Get the particle position\n        vec2 uv = vec2((mod(a_index, u_width) + 0.5) / u_width, (floor(a_index / u_width) + 0.5) / u_height);\n        vec3 position = texture2D(u_positionTexture, uv).xyz;\n\n        // Calculate the model view position\n        vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n\n        // Calculate the particle relative size based on the background texture color\n        vec3 bgColor = get_background_color(position);\n        float relativeSize = 1.0 - 0.3 * dot(bgColor, vec3(1.0));\n\n        // Vertex shader output\n        gl_PointSize = -u_particleSize * relativeSize / mvPosition.z;\n        gl_Position = projectionMatrix * mvPosition;\n    } else {\n        // Vertex shader output\n        gl_PointSize = 0.0;\n        gl_Position = vec4(-1000000.0);\n    }\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Texture with the particle profile\nuniform sampler2D u_texture;\n\n/*\n * The main program\n */\nvoid main() {\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(0.0), texture2D(u_texture, gl_PointCoord).a);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-stippling.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/stripes-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 3D\">\n<meta name=\"description\" content=\"stripes shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>stripes shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-3d.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-3d.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-stripes.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * The main program\n */\nvoid main() {\n    // Save the varyings\n    v_position = position;\n    v_normal = normalize(normalMatrix * normal);\n\n    // Vertex shader output\n    gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Use the mouse position to define the light direction\n    float min_resolution = min(u_resolution.x, u_resolution.y);\n    vec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.5);\n\n    // Calculate the light diffusion factor\n    float df = diffuseFactor(v_normal, light_direction);\n\n    // Calculate the surface color\n    float surface_color = df;\n\n    // Don't paint the pixels between the stripes\n    if (cos(2.0 * v_position.y + 3.0 * u_time) < 0.0) {\n        discard;\n    }\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(surface_color), 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-3d.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/tile-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 2D\">\n<meta name=\"description\" content=\"tile shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>tile shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-2d.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-2d.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-tile.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n/*\n * The main program\n */\nvoid main() {\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the square\n */\nfloat square(vec2 pixel, vec2 bottom_left, float side) {\n    vec2 top_right = bottom_left + side;\n\n    return smoothstep(-1.0, 1.0, pixel.x - bottom_left.x) * smoothstep(-1.0, 1.0, pixel.y - bottom_left.y)\n            * smoothstep(-1.0, 1.0, top_right.x - pixel.x) * smoothstep(-1.0, 1.0, top_right.y - pixel.y);\n}\n\n/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the rectangle\n */\nfloat rectangle(vec2 pixel, vec2 bottom_left, vec2 sides) {\n    vec2 top_right = bottom_left + sides;\n\n    return smoothstep(-1.0, 1.0, pixel.x - bottom_left.x) * smoothstep(-1.0, 1.0, pixel.y - bottom_left.y)\n            * smoothstep(-1.0, 1.0, top_right.x - pixel.x) * smoothstep(-1.0, 1.0, top_right.y - pixel.y);\n}\n\n/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the circle\n */\nfloat circle(vec2 pixel, vec2 center, float radius) {\n    return 1.0 - smoothstep(radius - 1.0, radius + 1.0, length(pixel - center));\n}\n\n/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the ellipse\n */\nfloat ellipse(vec2 pixel, vec2 center, vec2 radii) {\n    vec2 relative_pos = pixel - center;\n    float dist = length(relative_pos);\n    float r = radii.x * radii.y * dist / length(radii.yx * relative_pos);\n\n    return 1.0 - smoothstep(r - 1.0, r + 1.0, dist);\n}\n\n/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the line segment\n */\nfloat lineSegment(vec2 pixel, vec2 start, vec2 end, float width) {\n    vec2 pixel_dir = pixel - start;\n    vec2 line_dir = end - start;\n    float line_length = length(line_dir);\n    float projected_dist = dot(pixel_dir, line_dir) / line_length;\n    float tanjential_dist = sqrt(dot(pixel_dir, pixel_dir) - projected_dist * projected_dist);\n\n    return smoothstep(-1.0, 1.0, projected_dist) * smoothstep(-1.0, 1.0, line_length - projected_dist)\n            * (1.0 - smoothstep(-1.0, 1.0, tanjential_dist - 0.5 * width));\n}\n\n/*\n * Returns a rotation matrix for the given angle\n */\nmat2 rotate(float angle) {\n    return mat2(cos(angle), -sin(angle), sin(angle), cos(angle));\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Set the background color\n    vec3 pixel_color = vec3(0.0);\n\n    // Divide the screen in a grid\n    vec2 grid1_pos = mod(gl_FragCoord.xy, 250.0);\n\n    // Add a blue square to each grid element\n    pixel_color = mix(pixel_color, vec3(0.3, 0.4, 1.0), square(grid1_pos, vec2(5.0, 5.0), 150.0));\n\n    // Add a red circle to each grid element\n    pixel_color = mix(pixel_color, vec3(1.0, 0.4, 0.3), circle(grid1_pos, vec2(0.0, 0.0), 80.0));\n\n    // Add ten grey lines to each grid element\n    for (float i = 0.0; i < 10.0; ++i) {\n        pixel_color = mix(pixel_color, vec3(0.8),\n                lineSegment(grid1_pos, vec2(10.0, -10.0 * i), vec2(150.0, 100.0 - 10.0 * i), 4.0));\n    }\n\n    // Apply some rotations to the grid\n    grid1_pos -= 100.0;\n    grid1_pos = rotate(u_time) * grid1_pos;\n    grid1_pos += 100.0;\n    grid1_pos -= 60.0;\n    grid1_pos = rotate(0.66 * u_time) * grid1_pos;\n    grid1_pos += 60.0;\n\n    // Draw a green rectangle to each grid element\n    pixel_color = mix(pixel_color, vec3(0.3, 0.9, 0.3), rectangle(grid1_pos, vec2(60.0, 50.0), vec2(40.0, 20)));\n\n    // Define a second rotated grid\n    vec2 grid2_pos = mod(rotate(radians(45.0)) * gl_FragCoord.xy, 100.0);\n\n    // Add a white circle to each grid element\n    pixel_color = mix(pixel_color, vec3(1.0), circle(grid2_pos, vec2(50.0, 50.0), 20.0));\n\n    // Fragment shader output\n    gl_FragColor = vec4(pixel_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-2d.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/toon-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 3D\">\n<meta name=\"description\" content=\"toon shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>toon shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-3d.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-3d.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-toon.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * The main program\n */\nvoid main() {\n    // Save the varyings\n    v_position = position;\n    v_normal = normalize(normalMatrix * normal);\n\n    // Vertex shader output\n    gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Use the mouse position to define the light direction\n    float min_resolution = min(u_resolution.x, u_resolution.y);\n    vec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.5);\n\n    // Calculate the light diffusion factor\n    float df = diffuseFactor(v_normal, light_direction);\n\n    // Define the toon shading steps\n    float nSteps = 4.0;\n    float step = sqrt(df) * nSteps;\n    step = (floor(step) + smoothstep(0.48, 0.52, fract(step))) / nSteps;\n\n    // Calculate the surface color\n    float surface_color = step * step;\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(surface_color), 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-3d.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "WebContent/wave-example.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 3D\">\n<meta name=\"description\" content=\"wave shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>wave shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"/js/shader-example-3d.js\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"/shaders/vert-3d.glsl\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"/shaders/frag-wave.glsl\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n#define GLSLIFY 1\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n * The main program\n */\nvoid main() {\n    // Save the varyings\n    v_position = position;\n    v_normal = normalize(normalMatrix * normal);\n\n    // Vertex shader output\n    gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n#define GLSLIFY 1\n// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n\n// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n\n/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Use the mouse position to define the light direction\n    float min_resolution = min(u_resolution.x, u_resolution.y);\n    vec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.25);\n\n    // Set the surface color\n    vec3 surface_color = vec3(0.5 + 0.5 * cos(2.0 * v_position.y + 3.0 * u_time));\n\n    // Apply the light diffusion factor\n    surface_color *= diffuseFactor(v_normal, light_direction);\n\n    // Fragment shader output\n    gl_FragColor = vec4(surface_color, 1.0);\n}\n\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"/js/shader-example-3d.js\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "html/about.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, examples, about\">\n<meta name=\"description\" content=\"About the WebGL shader examples project\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>About this project</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item is-active-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<header>\n\t\t\t<h2>About WebGL-shaders.com</h2>\n\t\t</header>\n\n\t\t<p>\n\t\t\tThe main intention of this site is to teach <a href=\"https://jagracar.com\">myself</a> to program WebGL shaders, but I\n\t\t\thope it will also be useful to oder people that are trying to do the same.\n\t\t</p>\n\n\t\t<p>Bellow is a non-complete list of references that have helped me to learn the basics:</p>\n\t\t<ul>\n\t\t\t<li><a href=\"https://thebookofshaders.com/\">The Book of shaders</a>.</li>\n\t\t\t<li><a href=\"https://webglfundamentals.org/\">WebGL fundamentals</a>.</li>\n\t\t\t<li><a href=\"http://pixelshaders.com/\">Pixel shaders</a>.</li>\n\t\t\t<li><a href=\"https://www.clicktorelease.com/blog/\">Clicktorelease blog</a>.</li>\n\t\t\t<li><a href=\"http://madebyevan.com/shaders/\">Shader tricks</a>.</li>\n\t\t\t<li><a href=\"https://www.airtightinteractive.com/2013/02/intro-to-pixel-shaders-in-three-js/\">Intro to pixel\n\t\t\t\t\tshaders in Three.js</a>.</li>\n\t\t\t<li><a href=\"http://www.iquilezles.org/www/index.htm\">List of articles by Íñigo Quílez</a>.</li>\n\t\t\t<li><a href=\"https://www.taylorpetrick.com/blog/post/convolution-part1\">Image convolution tutorial</a>.</li>\n\t\t\t<li><a href=\"https://developer.nvidia.com/gpugems/GPUGems/gpugems_pref01.html\">GPU gems</a>.</li>\n\t\t\t<li><a href=\"http://codeflow.org/tags/howto.html\">Codeflow howtos</a>.</li>\n\t\t\t<li><a href=\"https://processing.org/tutorials/pshader/\">Processing shaders tutorial</a>.</li>\n\t\t\t<li><a href=\"https://openframeworks.cc/ofBook/chapters/shaders.html\">OpenFrameworks shaders tutorial</a>.</li>\n\t\t\t<li><a href=\"https://threejs.org/examples/\">Three.js examples</a>.</li>\n\t\t</ul>\n\n\t\t<p>Some inspiration:</p>\n\t\t<ul>\n\t\t\t<li><a href=\"https://www.shadertoy.com/\">Shadertoy</a>.</li>\n\t\t\t<li><a href=\"http://glslsandbox.com/\">GLSL sandbox</a>.</li>\n\t\t</ul>\n\t</article>\n\t</main>\n\n\t<!-- Footer -->\n\t<footer class=\"footer-container\">\n\t\t<div class=\"footer-content\">\n\t\t\t<p>\n\t\t\t\tHand made in Munich. <span class=\"separator\">///</span> Unless otherwise stated, all the content in this site is\n\t\t\t\tlicensed under a Creative Commons Attribution-ShareAlike <a href=\"https://creativecommons.org/licenses/by-sa/4.0/\">license</a>.\n\t\t\t</p>\n\t\t</div>\n\t</footer>\n</body>\n</html>"
  },
  {
    "path": "html/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, examples\">\n<meta name=\"description\" content=\"WebGL shader examples\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>WebGL shader examples</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<header>\n\t\t\t<h2>\n\t\t\t\tWebGL shader examples<br /> <small>by <a href=\"https://jagracar.com\">Javier Gracia Carpio</a></small>\n\t\t\t</h2>\n\t\t</header>\n\n\t\t<div class=\"example-list\">\n\t\t\t<nav>\n\t\t\t\t<header>\n\t\t\t\t\t<h3>2D examples:</h3>\n\t\t\t\t</header>\n\n\t\t\t\t<ul>\n\t\t\t\t\t<li><a href=\"/random-example.html\">Random pixels</a></li>\n\t\t\t\t\t<li><a href=\"/noise-example.html\">Classic 2D noise</a></li>\n\t\t\t\t\t<li><a href=\"/rain-example.html\">Rain drops</a></li>\n\t\t\t\t\t<li><a href=\"/tile-example.html\">Geometric tile</a></li>\n\t\t\t\t</ul>\n\t\t\t</nav>\n\n\t\t\t<nav>\n\t\t\t\t<header>\n\t\t\t\t\t<h3>3D examples:</h3>\n\t\t\t\t</header>\n\n\t\t\t\t<ul>\n\t\t\t\t\t<li><a href=\"/wave-example.html\">Cosine wave</a></li>\n\t\t\t\t\t<li><a href=\"/pencil-example.html\">Pencil shading</a></li>\n\t\t\t\t\t<li><a href=\"/dots-example.html\">Dot shading</a></li>\n\t\t\t\t\t<li><a href=\"/toon-example.html\">Toon shading</a></li>\n\t\t\t\t\t<li><a href=\"/stripes-example.html\">Stripes</a></li>\n\t\t\t\t</ul>\n\t\t\t</nav>\n\n\t\t\t<nav>\n\t\t\t\t<header>\n\t\t\t\t\t<h3>Image manipulation examples:</h3>\n\t\t\t\t</header>\n\n\t\t\t\t<ul>\n\t\t\t\t\t<li><a href=\"/edge-example.html\">Edge detection</a></li>\n\t\t\t\t\t<li><a href=\"/blur-example.html\">Gaussian blur</a></li>\n\t\t\t\t\t<li><a href=\"/pixels-example.html\">Pixelated</a></li>\n\t\t\t\t\t<li><a href=\"/lens-example.html\">Lens effect</a></li>\n\t\t\t\t</ul>\n\t\t\t</nav>\n\n\t\t\t<nav>\n\t\t\t\t<header>\n\t\t\t\t\t<h3>Simulation examples:</h3>\n\t\t\t\t</header>\n\n\t\t\t\t<ul>\n\t\t\t\t\t<li><a href=\"/gravity-example.html\">Gravity</a></li>\n\t\t\t\t\t<li><a href=\"/galaxies-example.html\">Interacting galaxies</a></li>\n\t\t\t\t\t<li><a href=\"/repulsion-example.html\">Repulsion</a></li>\n\t\t\t\t\t<li><a href=\"/stippling-example.html\">Stippling</a></li>\n\t\t\t\t\t<li><a href=\"/dla-example.html\">Diffusion-limited aggregation</a></li>\n\t\t\t\t</ul>\n\t\t\t</nav>\n\n\t\t\t<nav>\n\t\t\t\t<header>\n\t\t\t\t\t<h3>Post-processing examples:</h3>\n\t\t\t\t</header>\n\n\t\t\t\t<ul>\n\t\t\t\t\t<li><a href=\"/badtv-example.html\">Bad TV</a></li>\n\t\t\t\t\t<li><a href=\"/pixelated-example.html\">Pixelated</a></li>\n\t\t\t\t\t<li><a href=\"/cuts-example.html\">Cuts</a></li>\n\t\t\t\t\t<li><a href=\"/rgb-example.html\">RGB shift</a></li>\n\t\t\t\t</ul>\n\t\t\t</nav>\n\n\t\t\t<nav>\n\t\t\t\t<header>\n\t\t\t\t\t<h3>Evolution examples:</h3>\n\t\t\t\t</header>\n\n\t\t\t\t<ul>\n\t\t\t\t\t<li><a href=\"/fire-example.html\">Fire</a></li>\n\t\t\t\t\t<li><a href=\"/flare-example.html\">Flaring star</a></li>\n\t\t\t\t\t<li><a href=\"/cursor-example.html\">Cursor draw</a></li>\n\t\t\t\t\t<li><a href=\"/reaction-example.html\">Reaction-diffusion</a></li>\n\t\t\t\t\t<li><a href=\"/sort-example.html\">Pixel sorting</a></li>\n\t\t\t\t</ul>\n\t\t\t</nav>\n\n\t\t\t<nav>\n\t\t\t\t<header>\n\t\t\t\t\t<h3>Vertex manipulation examples:</h3>\n\t\t\t\t</header>\n\n\t\t\t\t<ul>\n\t\t\t\t\t<li><a href=\"/deform-example.html\">Deformation</a></li>\n\t\t\t\t\t<li><a href=\"/attraction-example.html\">Attraction</a></li>\n\t\t\t\t\t<li><a href=\"/mountains-example.html\">Infinite landscape</a></li>\n\t\t\t\t\t<li><a href=\"/sphere-example.html\">Alien sphere</a></li>\n\t\t\t\t</ul>\n\t\t\t</nav>\n\t\t</div>\n\t</article>\n\t</main>\n\n\t<!-- Footer -->\n\t<footer class=\"footer-container\">\n\t\t<div class=\"footer-content\">\n\t\t\t<p>\n\t\t\t\tHand made in Munich. <span class=\"separator\">///</span> Unless otherwise stated, all the content in this site is\n\t\t\t\tlicensed under a Creative Commons Attribution-ShareAlike <a href=\"https://creativecommons.org/licenses/by-sa/4.0/\">license</a>.\n\t\t\t</p>\n\t\t</div>\n\t</footer>\n</body>\n</html>"
  },
  {
    "path": "html/template-example-2d.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 2D\">\n<meta name=\"description\" content=\"@@name shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>@@name shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"@@jsFile\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"@@vertexShaderFile\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"@@fragmentShaderFile\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n@@vertexShaderContent\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n@@fragmentShaderContent\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"@@jsFile\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "html/template-example-3d.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 3D\">\n<meta name=\"description\" content=\"@@name shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>@@name shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"@@jsFile\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"@@vertexShaderFile\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"@@fragmentShaderFile\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n@@vertexShaderContent\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n@@fragmentShaderContent\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"@@jsFile\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "html/template-example-post.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, postprocessin\">\n<meta name=\"description\" content=\"@@name shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>@@name shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/CopyShader.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/EffectComposer.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/RenderPass.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/ShaderPass.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"@@jsFile\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"@@vertexShaderFile\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"@@fragmentShaderFile\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n@@vertexShaderContent\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n@@fragmentShaderContent\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"@@jsFile\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "html/template-example-sim.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<meta name=\"keywords\" content=\"WebGL, shader, three.js, javaScript, example, 3D, simulation\">\n<meta name=\"description\" content=\"@@name shader example\">\n<meta name=\"author\" content=\"Javier Gracia Carpio\">\n\n<title>@@name shader example</title>\n\n<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">\n\n<!-- CSS files -->\n<link rel=\"stylesheet\" href=\"/css/styles.css\">\n\n<!-- JavaScript files -->\n<script type=\"text/javascript\" src=\"/js/libs/three.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/stats.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/dat.gui.min.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/OrbitControls.js\"></script>\n<script type=\"text/javascript\" src=\"/js/libs/GPUComputationRenderer.js\"></script>\n</head>\n\n<body>\n\t<!-- Navigation bar -->\n\t<header class=\"nav-container\">\n\t\t<h1 class=\"nav-header\">\n\t\t\t<a href=\"/index.html\" class=\"nav-item is-header-item\">WebGL-shaders</a>\n\t\t</h1>\n\n\t\t<nav class=\"nav-menu-wrapper\">\n\t\t\t<span class=\"nav-item is-menu-item menu-icon\" onclick=\"return false;\"></span>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/index.html\" class=\"nav-item\">Back to list</a></li>\n\t\t\t\t<li><a href=\"@@jsFile\" class=\"nav-item\">JavaScript file</a></li>\n\t\t\t\t<li><a href=\"@@positionShaderFile\" class=\"nav-item\">Position shader</a></li>\n\t\t\t\t<li><a href=\"@@velocityShaderFile\" class=\"nav-item\">Velocity shader</a></li>\n\t\t\t\t<li><a href=\"@@vertexShaderFile\" class=\"nav-item\">Vertex shader</a></li>\n\t\t\t\t<li><a href=\"@@fragmentShaderFile\" class=\"nav-item\">Fragment shader</a></li>\n\t\t\t</ul>\n\n\t\t\t<ul class=\"nav-menu-list\">\n\t\t\t\t<li><a href=\"/about.html\" class=\"nav-item\">About</a></li>\n\t\t\t\t<li><a href=\"https://github.com/jagracar/webgl-shader-examples\" class=\"nav-item\"><span class=\"github-icon\"></span>\n\t\t\t\t\t\tGithub</a></li>\n\t\t\t</ul>\n\t\t</nav>\n\t</header>\n\n\t<!-- Main content -->\n\t<main class=\"main-container\">\n\t<article class=\"content\">\n\t\t<div class=\"sketch-container\" id=\"sketch-container\">\n\t\t\t<div class=\"sketch-gui\" id=\"sketch-gui\"></div>\n\t\t\t<div class=\"sketch-stats\" id=\"sketch-stats\"></div>\n\t\t</div>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"positionShader\">\n@@positionShaderContent\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"velocityShader\">\n@@velocityShaderContent\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-vertex\" id=\"vertexShader\">\n@@vertexShaderContent\n\t\t</script>\n\n\t\t<script type=\"x-shader/x-fragment\" id=\"fragmentShader\">\n@@fragmentShaderContent\n\t\t</script>\n\n\t\t<script type=\"text/javascript\" src=\"@@jsFile\"></script>\n\t</article>\n\t</main>\n</body>\n</html>"
  },
  {
    "path": "package.json",
    "content": "{\n\t\"name\": \"webgl-shader-examples\",\n\t\"version\": \"0.1.0\",\n\t\"description\": \"Some simple examples of WebGL shaders\",\n\t\"main\": \"WebContent/index.html\",\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git://github.com/jagracar/webgl-shader-examples.git\"\n\t},\n\t\"keywords\": [\n\t\t\"math\",\n\t\t\"WebGL\",\n\t\t\"shader\"\n\t],\n\t\"author\": \"Javier Graciá Carpio\",\n\t\"license\": \"LGPL-3.0\",\n\t\"bugs\": {\n\t\t\"url\": \"https://github.com/jagracar/webgl-shader-examples/issues\"\n\t},\n\t\"homepage\": \"https://webgl-shaders.com\",\n\t\"devDependencies\": {\n\t\t\"glslify\": \"^6.3.1\",\n\t\t\"glslify-import\": \"^3.1.0\",\n\t\t\"grunt\": \"^1.0.3\",\n\t\t\"grunt-autoprefixer\": \"^3.0.4\",\n\t\t\"grunt-contrib-clean\": \"^1.1.0\",\n\t\t\"grunt-contrib-copy\": \"^1.0.0\",\n\t\t\"grunt-contrib-jshint\": \"^1.1.0\",\n\t\t\"grunt-contrib-sass\": \"^1.0.0\",\n\t\t\"grunt-contrib-watch\": \"^1.1.0\",\n\t\t\"grunt-exec\": \"^3.0.0\",\n\t\t\"grunt-replace\": \"^1.0.1\"\n\t},\n\t\"glslify\": {\n\t\t\"transform\": [\n\t\t\t\"glslify-import\"\n\t\t]\n\t},\n\t\"dependencies\": {}\n}\n"
  },
  {
    "path": "sass/originals/_normalize.scss",
    "content": "/*! normalize.css v8.0.0 | MIT License | github.com/necolas/normalize.css */\n\n/* Document\n   ========================================================================== */\n\n/**\n * 1. Correct the line height in all browsers.\n * 2. Prevent adjustments of font size after orientation changes in iOS.\n */\n\nhtml {\n  line-height: 1.15; /* 1 */\n  -webkit-text-size-adjust: 100%; /* 2 */\n}\n\n/* Sections\n   ========================================================================== */\n\n/**\n * Remove the margin in all browsers.\n */\n\nbody {\n  margin: 0;\n}\n\n/**\n * Correct the font size and margin on `h1` elements within `section` and\n * `article` contexts in Chrome, Firefox, and Safari.\n */\n\nh1 {\n  font-size: 2em;\n  margin: 0.67em 0;\n}\n\n/* Grouping content\n   ========================================================================== */\n\n/**\n * 1. Add the correct box sizing in Firefox.\n * 2. Show the overflow in Edge and IE.\n */\n\nhr {\n  box-sizing: content-box; /* 1 */\n  height: 0; /* 1 */\n  overflow: visible; /* 2 */\n}\n\n/**\n * 1. Correct the inheritance and scaling of font size in all browsers.\n * 2. Correct the odd `em` font sizing in all browsers.\n */\n\npre {\n  font-family: monospace, monospace; /* 1 */\n  font-size: 1em; /* 2 */\n}\n\n/* Text-level semantics\n   ========================================================================== */\n\n/**\n * Remove the gray background on active links in IE 10.\n */\n\na {\n  background-color: transparent;\n}\n\n/**\n * 1. Remove the bottom border in Chrome 57-\n * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.\n */\n\nabbr[title] {\n  border-bottom: none; /* 1 */\n  text-decoration: underline; /* 2 */\n  text-decoration: underline dotted; /* 2 */\n}\n\n/**\n * Add the correct font weight in Chrome, Edge, and Safari.\n */\n\nb,\nstrong {\n  font-weight: bolder;\n}\n\n/**\n * 1. Correct the inheritance and scaling of font size in all browsers.\n * 2. Correct the odd `em` font sizing in all browsers.\n */\n\ncode,\nkbd,\nsamp {\n  font-family: monospace, monospace; /* 1 */\n  font-size: 1em; /* 2 */\n}\n\n/**\n * Add the correct font size in all browsers.\n */\n\nsmall {\n  font-size: 80%;\n}\n\n/**\n * Prevent `sub` and `sup` elements from affecting the line height in\n * all browsers.\n */\n\nsub,\nsup {\n  font-size: 75%;\n  line-height: 0;\n  position: relative;\n  vertical-align: baseline;\n}\n\nsub {\n  bottom: -0.25em;\n}\n\nsup {\n  top: -0.5em;\n}\n\n/* Embedded content\n   ========================================================================== */\n\n/**\n * Remove the border on images inside links in IE 10.\n */\n\nimg {\n  border-style: none;\n}\n\n/* Forms\n   ========================================================================== */\n\n/**\n * 1. Change the font styles in all browsers.\n * 2. Remove the margin in Firefox and Safari.\n */\n\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n  font-family: inherit; /* 1 */\n  font-size: 100%; /* 1 */\n  line-height: 1.15; /* 1 */\n  margin: 0; /* 2 */\n}\n\n/**\n * Show the overflow in IE.\n * 1. Show the overflow in Edge.\n */\n\nbutton,\ninput { /* 1 */\n  overflow: visible;\n}\n\n/**\n * Remove the inheritance of text transform in Edge, Firefox, and IE.\n * 1. Remove the inheritance of text transform in Firefox.\n */\n\nbutton,\nselect { /* 1 */\n  text-transform: none;\n}\n\n/**\n * Correct the inability to style clickable types in iOS and Safari.\n */\n\nbutton,\n[type=\"button\"],\n[type=\"reset\"],\n[type=\"submit\"] {\n  -webkit-appearance: button;\n}\n\n/**\n * Remove the inner border and padding in Firefox.\n */\n\nbutton::-moz-focus-inner,\n[type=\"button\"]::-moz-focus-inner,\n[type=\"reset\"]::-moz-focus-inner,\n[type=\"submit\"]::-moz-focus-inner {\n  border-style: none;\n  padding: 0;\n}\n\n/**\n * Restore the focus styles unset by the previous rule.\n */\n\nbutton:-moz-focusring,\n[type=\"button\"]:-moz-focusring,\n[type=\"reset\"]:-moz-focusring,\n[type=\"submit\"]:-moz-focusring {\n  outline: 1px dotted ButtonText;\n}\n\n/**\n * Correct the padding in Firefox.\n */\n\nfieldset {\n  padding: 0.35em 0.75em 0.625em;\n}\n\n/**\n * 1. Correct the text wrapping in Edge and IE.\n * 2. Correct the color inheritance from `fieldset` elements in IE.\n * 3. Remove the padding so developers are not caught out when they zero out\n *    `fieldset` elements in all browsers.\n */\n\nlegend {\n  box-sizing: border-box; /* 1 */\n  color: inherit; /* 2 */\n  display: table; /* 1 */\n  max-width: 100%; /* 1 */\n  padding: 0; /* 3 */\n  white-space: normal; /* 1 */\n}\n\n/**\n * Add the correct vertical alignment in Chrome, Firefox, and Opera.\n */\n\nprogress {\n  vertical-align: baseline;\n}\n\n/**\n * Remove the default vertical scrollbar in IE 10+.\n */\n\ntextarea {\n  overflow: auto;\n}\n\n/**\n * 1. Add the correct box sizing in IE 10.\n * 2. Remove the padding in IE 10.\n */\n\n[type=\"checkbox\"],\n[type=\"radio\"] {\n  box-sizing: border-box; /* 1 */\n  padding: 0; /* 2 */\n}\n\n/**\n * Correct the cursor style of increment and decrement buttons in Chrome.\n */\n\n[type=\"number\"]::-webkit-inner-spin-button,\n[type=\"number\"]::-webkit-outer-spin-button {\n  height: auto;\n}\n\n/**\n * 1. Correct the odd appearance in Chrome and Safari.\n * 2. Correct the outline style in Safari.\n */\n\n[type=\"search\"] {\n  -webkit-appearance: textfield; /* 1 */\n  outline-offset: -2px; /* 2 */\n}\n\n/**\n * Remove the inner padding in Chrome and Safari on macOS.\n */\n\n[type=\"search\"]::-webkit-search-decoration {\n  -webkit-appearance: none;\n}\n\n/**\n * 1. Correct the inability to style clickable types in iOS and Safari.\n * 2. Change font properties to `inherit` in Safari.\n */\n\n::-webkit-file-upload-button {\n  -webkit-appearance: button; /* 1 */\n  font: inherit; /* 2 */\n}\n\n/* Interactive\n   ========================================================================== */\n\n/*\n * Add the correct display in Edge, IE 10+, and Firefox.\n */\n\ndetails {\n  display: block;\n}\n\n/*\n * Add the correct display in all browsers.\n */\n\nsummary {\n  display: list-item;\n}\n\n/* Misc\n   ========================================================================== */\n\n/**\n * Add the correct display in IE 10+.\n */\n\ntemplate {\n  display: none;\n}\n\n/**\n * Add the correct display in IE 10.\n */\n\n[hidden] {\n  display: none;\n}\n"
  },
  {
    "path": "sass/partials/_base.scss",
    "content": "/*\n * General styling\n */\n\n*, *:before, *:after {\n\tbox-sizing: border-box;\n}\n\nbody {\n\tfont-family: \"HelveticaNeue-Light\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n\tfont-size: 0.9em;\n\tline-height: 1.4;\n\tcolor: $general-text-color;\n}\n\na {\n\ttext-decoration: none;\n\tcolor: $link-color;\n\n\t&:hover, &:focus {\n\t\ttext-decoration: underline;\n\t}\n\n\th1 &, h2 &, h3 &, h4 &, h5 &, h6 & {\n\t\tcolor: inherit;\n\n\t\t&:hover, &:focus {\n\t\t\ttext-decoration: none;\n\t\t}\n\t}\n}\n\nh1, h2, h3, h4, h5, h6 {\n\tfont-weight: normal;\n\tcolor: $header-color;\n\n\tsmall {\n\t\tfont-size: 60%;\n\t}\n}\n\nh2 {\n\tfont-size: 2.6em;\n\n\t@media (max-width: $M) {\n\t\tfont-size: 2.2em;\n\t}\n}\n\nh3 {\n\tfont-size: 1.5em;\n}\n\nh4 {\n\tfont-size: 1.2em;\n}\n\np {\n\tmax-width: 0.8 * $L;\n}\n\nfigure {\n\tmargin: 0;\n}\n"
  },
  {
    "path": "sass/partials/_content.scss",
    "content": "/*\n * Content components\n */\n\n.main-container {\n\tpadding: $main-container-top-padding $container-sides-padding 0 $container-sides-padding;\n}\n\n.content {\n\tpadding-bottom: 2em;\n}\n\n.example-list {\n\tdisplay: flex;\n\tflex-flow: row wrap;\n\tjustify-content: space-between;\n\n\tnav {\n\t\tflex: 0 0 48%;\n\t}\n\n\tul {\n\t\tpadding: 0;\n\t\tmargin: 0;\n\t}\n\n\tli {\n\t\tlist-style-type: none;\n\t}\n\n\ta {\n\t\tdisplay: block;\n\t\tpadding: $examples-list-item-padding;\n\t\tmargin-bottom: $examples-list-item-margin;\n\t\tborder-radius: $examples-list-item-border-radius;\n\t\ttext-align: center;\n\t\twhite-space: nowrap;\n\t\tcolor: $examples-list-item-color;\n\t\tbackground-color: $examples-list-item-bg-color;\n\t\ttransition: background-color $speed;\n\n\t\t&:hover, &:focus, &.active-sketch {\n\t\t\ttext-decoration: none;\n\t\t\tcolor: $examples-list-item-hover-color;\n\t\t\tbackground-color: $examples-list-item-hover-bg-color;\n\t\t}\n\t}\n}\n\n\n// Style for small, medium and large devices\n\n@media (max-width: $L) {\n\t.main-container {\n\t\tpadding: $main-container-top-padding $container-sides-padding-lowres 0 $container-sides-padding-lowres;\n\t}\n}\n\n\n// Style for small and medium devices\n\n@media (max-width: $M) {\n\t.example-list {\n\t\tdisplay: block;\n\t}\n}\n"
  },
  {
    "path": "sass/partials/_fonts.scss",
    "content": "/*\n * Fonts declarations\n */\n\n@font-face {\n\tfont-family: \"Font Awesome 4.7\";\n\tfont-style: normal;\n\tfont-weight: normal;\n\tsrc: url(\"../fonts/fontAwesome-4.7.0/fontawesome-webfont.eot?v=4.7.0\");\n\tsrc: url(\"../fonts/fontAwesome-4.7.0/fontawesome-webfont.eot?#iefix&v=4.7.0\") format(\"embedded-opentype\"),\n\t\t url(\"../fonts/fontAwesome-4.7.0/fontawesome-webfont.woff2?v=4.7.0\") format(\"woff2\"),\n\t\t url(\"../fonts/fontAwesome-4.7.0/fonts/fontawesome-webfont.woff?v=4.7.0\") format(\"woff\"),\n\t\t url(\"../fonts/fontAwesome-4.7.0/fonts/fontawesome-webfont.ttf?v=4.7.0\") format(\"truetype\"),\n\t\t url(\"../fonts/fontAwesome-4.7.0/fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular\") format(\"svg\");\n}\n\n@font-face {\n\tfont-family: 'Font Awesome 5 Brands';\n\tfont-style: normal;\n\tfont-weight: normal;\n\tsrc: url(\"../fonts/fontAwesome-5.2.0/fa-brands-400.eot\");\n\tsrc: url(\"../fonts/fontAwesome-5.2.0/fa-brands-400.eot?#iefix\") format(\"embedded-opentype\"),\n\t\t url(\"../fonts/fontAwesome-5.2.0/fa-brands-400.woff2\") format(\"woff2\"),\n\t\t url(\"../fonts/fontAwesome-5.2.0/fa-brands-400.woff\") format(\"woff\"),\n\t\t url(\"../fonts/fontAwesome-5.2.0/fa-brands-400.ttf\") format(\"truetype\"),\n\t\t url(\"../fonts/fontAwesome-5.2.0/fa-brands-400.svg#fontawesome\") format(\"svg\");\n}\n\n@font-face {\n\tfont-family: 'Font Awesome 5 Regular';\n\tfont-style: normal;\n\tfont-weight: 400;\n\tsrc: url(\"../fonts/fontAwesome-5.2.0/fa-regular-400.eot\");\n\tsrc: url(\"../fonts/fontAwesome-5.2.0/fa-regular-400.eot?#iefix\") format(\"embedded-opentype\"),\n\t\t url(\"../fonts/fontAwesome-5.2.0/fa-regular-400.woff2\") format(\"woff2\"),\n\t\t url(\"../fonts/fontAwesome-5.2.0/fa-regular-400.woff\") format(\"woff\"),\n\t\t url(\"../fonts/fontAwesome-5.2.0/fa-regular-400.ttf\") format(\"truetype\"),\n\t\t url(\"../fonts/fontAwesome-5.2.0/fa-regular-400.svg#fontawesome\") format(\"svg\");\n}\n\n@font-face {\n\tfont-family: 'Font Awesome 5 Solid';\n\tfont-style: normal;\n\tfont-weight: 900;\n\tsrc: url(\"../fonts/fontAwesome-5.2.0/fa-solid-900.eot\");\n\tsrc: url(\"../fonts/fontAwesome-5.2.0/fa-solid-900.eot?#iefix\") format(\"embedded-opentype\"),\n\t\t url(\"../fonts/fontAwesome-5.2.0/fa-solid-900.woff2\") format(\"woff2\"),\n\t\t url(\"../fonts/fontAwesome-5.2.0/fa-solid-900.woff\") format(\"woff\"),\n\t\t url(\"../fonts/fontAwesome-5.2.0/fa-solid-900.ttf\") format(\"truetype\"),\n\t\t url(\"../fonts/fontAwesome-5.2.0/fa-solid-900.svg#fontawesome\") format(\"svg\");\n}\n\n.fab, .far, .fas {\n\t-moz-osx-font-smoothing: grayscale;\n\t-webkit-font-smoothing: antialiased;\n\tdisplay: inline-block;\n\tfont-style: normal;\n\tfont-variant: normal;\n\ttext-rendering: auto;\n\tline-height: 1;\n}\n\n.fab {\n\tfont-family: 'Font Awesome 5 Brands';\n}\n\n.far {\n\tfont-family: 'Font Awesome 5 Regular';\n\tfont-weight: 400;\n}\n\n.fas {\n\tfont-family: 'Font Awesome 5 Solid';\n\tfont-weight: 900;\n}\n\n\n/*\n * Icons\n */\n\n.menu-icon:before {\n\tfont-family: \"Font Awesome 5 Solid\";\n\tfont-weight: 900;\n\tcontent: \"\\f0c9\";\n}\n\n.back-icon:before {\n\tfont-family: \"Font Awesome 5 Solid\";\n\tfont-weight: 900;\n\tcontent: \"\\f52b\";\n}\n\n.love-icon:before {\n\tfont-family: \"Font Awesome 5 Regular\";\n\tcontent: \"\\f004\";\n}\n\n.envelope-icon:before {\n\tfont-family: \"Font Awesome 5 Regular\";\n\tcontent: \"\\f0e0\";\n}\n\n.phone-icon:before {\n\tfont-family: \"Font Awesome 5 Solid\";\n\tfont-weight: 900;\n\tcontent: \"\\f095\";\n}\n\n.noSpam-icon:before {\n\tfont-family: \"Font Awesome 4.7\";\n\tcontent: \"\\f1fa\";\n}\n\n.handMade-icon:before {\n\tfont-family: \"Font Awesome 5 Solid\";\n\tfont-weight: 900;\n\tcontent: \"\\f1b0\";\n}\n\n.up-icon:before {\n\tfont-family: \"Font Awesome 5 Solid\";\n\tfont-weight: 900;\n\tcontent: \"\\f106\";\n}\n\n.down-icon:before {\n\tfont-family: \"Font Awesome 5 Solid\";\n\tfont-weight: 900;\n\tcontent: \"\\f107\";\n}\n\n.js-icon:before {\n\tfont-family: \"Font Awesome 5 Brands\";\n\tcontent: \"\\f3b8\";\n}\n\n.code-icon:before {\n\tfont-family: \"Font Awesome 5 Solid\";\n\tfont-weight: 900;\n\tcontent: \"\\f121\";\n}\n\n.github-icon:before {\n\tfont-family: \"Font Awesome 5 Brands\";\n\tcontent: \"\\f09b\";\n}\n"
  },
  {
    "path": "sass/partials/_footer.scss",
    "content": "/*\n * Footer components\n */\n\n.footer-container {\n\tpadding: 0 $container-sides-padding;\n}\n\n.footer-content {\n\tborder-top: 1px dotted $footer-border-color;\n\tcolor: $footer-color;\n}\n\n.separator {\n\tpadding: 0 0.5em;\n}\n\n\n// Style for small, medium and large devices\n\n@media (max-width: $L) {\n\t.footer-container {\n\t\tpadding: 0 $container-sides-padding-lowres;\n\t}\n}\n"
  },
  {
    "path": "sass/partials/_layout.scss",
    "content": "/*\n * General layout\n */\n\nhtml, body {\n\theight: 100%;\n}\n\n\n// First flexbox group\n\nbody {\n\tdisplay: flex;\n\tflex-direction: column;\n}\n\n.nav-container {\n\tposition: fixed;\n\ttop: 0;\n\tleft: 0;\n\tz-index: 5000;\n}\n\n.main-container {\n\tflex: 1 1 auto;\n}\n\n.footer-container {\n\tflex: 0 0 auto;\n}\n\n\n// Second flexbox group\n\n.nav-container {\n\tdisplay: flex;\n\tflex-direction: row;\n}\n\n.nav-header {\n\tflex: 0 0 auto;\n}\n\n.nav-menu-wrapper {\n\tflex: 1 1 auto;\n}\n\n\n// Third flexbox group\n\n.nav-menu-wrapper {\n\tdisplay: flex;\n\tflex-direction: row;\n\tjustify-content: space-between;\n}\n\n\n// Layout for small and medium devices\n\n@media (max-width: $M) {\n\t.nav-header {\n\t\tflex: 1 1 auto;\n\t}\n\n\t.nav-menu-wrapper {\n\t\tposition: absolute;\n\t\ttop: $nav-padding + $nav-margin;\n\t\tleft: 0;\n\t}\n\n\t.nav-menu-wrapper {\n\t\tdisplay: block;\n\t}\n}\n"
  },
  {
    "path": "sass/partials/_navbar.scss",
    "content": "/*\n * Navigation bar components\n */\n\n.nav-container {\n\twidth: 100%;\n\tpadding: $nav-padding;\n\tborder-bottom: $nav-border solid $nav-border-color;\n\tmargin: $nav-margin;\n\tbackground: linear-gradient(to right, $nav-bg-color, $nav-middle-bg-color 30%, $nav-middle-bg-color 70%, $nav-bg-color);\n\n\ta:hover, a:focus {\n\t\ttext-decoration: none;\n\t}\n\n\tul {\n\t\tpadding: 0;\n\t\tmargin: 0;\n\t}\n\n\tli {\n\t\tdisplay: inline-block;\n\t\tlist-style-type: none;\n\t}\n}\n\n.nav-header {\n\twidth: $nav-header-width;\n\tmargin: 0;\n\tfont-size: 1.0em;\n}\n\n.nav-item {\n\tdisplay: block;\n\tmin-width: $nav-item-min-width;\n\tpadding: $nav-item-padding-with-border;\n\tborder: $nav-item-border solid $border-color;\n\tborder-radius: $nav-border-radius;\n\tfont-size: 1.0em;\n\ttext-align: center;\n\twhite-space: nowrap;\n\tcolor: $nav-item-color;\n\tbackground-color: $nav-item-bg-color;\n\ttransition: color $speed, background-color $speed;\n\n\t&:hover {\n\t\tcolor: $nav-item-hover-color;\n\t\tbackground-color: $nav-item-hover-bg-color;\n\t}\n}\n\n.is-header-item {\n\tpadding: $nav-item-padding;\n\tborder: 0;\n\tbackground-color: transparent;\n\t\n\t&:hover {\n\t\tbackground-color: transparent;\n\t}\n}\n\n.is-menu-item {\n\tdisplay: none;\n\tmin-width: 0;\n}\n\n.is-active-item {\n\tbackground-color: $nav-active-item-bg-color;\n\n\t&:hover {\n\t\tbackground-color: $nav-active-item-hover-bg-color;\n\t}\n}\n\n\n// Style for small and medium devices\n\n@media (max-width: $M) {\n\t.nav-menu-wrapper:hover {\n\t\twidth: 100%;\n\t}\n\n\t.is-menu-item {\n\t\tdisplay: inline-block;\n\t\tpadding: $nav-item-padding-with-border;\n\t\tborder: $nav-item-border solid $border-color;\n\t\tmargin-left: $nav-padding + $nav-margin;\n\n\t\t.nav-menu-wrapper:hover & {\n\t\t\tbackground-color: $nav-item-hover-bg-color;\n\t\t}\n\t}\n\n\t.nav-menu-list {\n\t\tdisplay: none;\n\n\t\t&:first-of-type {\n\t\t\tmargin-top: $nav-padding + $nav-margin;\n\t\t}\n\t\t\n\t\t.nav-menu-wrapper:hover & {\n\t\t\tdisplay: block;\n\t\t\tbackground: linear-gradient(to right, $nav-bg-color, $nav-middle-bg-color 30%, $nav-middle-bg-color 70%, $nav-bg-color);\n\t\t}\n\n\t\tli {\n\t\t\tdisplay: list-item;\n\t\t\tborder-top: $nav-item-border solid $border-color;\n\t\t}\n\n\t\t.nav-item {\n\t\t\tpadding: $nav-item-padding;\n\t\t\tborder: 0;\n\t\t\tborder-radius: 0;\n\t\t\ttext-align: left\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "sass/partials/_normalize.scss",
    "content": "/*\n * Normalize\n *\n * v8.0.0 | MIT License | github.com/necolas/normalize.css\n */\nhtml {\n\tline-height: 1.15;\n\t-webkit-text-size-adjust: 100%;\n}\n\nbody {\n\tmargin: 0;\n}\n\nh1 {\n\tfont-size: 2em;\n\tmargin: 0.67em 0;\n}\n\nhr {\n\tbox-sizing: content-box;\n\theight: 0;\n\toverflow: visible;\n}\n\npre {\n\tfont-family: monospace, monospace;\n\tfont-size: 1em;\n}\n\na {\n\tbackground-color: transparent;\n}\n\nabbr[title] {\n\tborder-bottom: none;\n\ttext-decoration: underline;\n\ttext-decoration: underline dotted;\n}\n\nb, strong {\n\tfont-weight: bolder;\n}\n\ncode, kbd, samp {\n\tfont-family: monospace, monospace;\n\tfont-size: 1em;\n}\n\nsmall {\n\tfont-size: 80%;\n}\n\nsub, sup {\n\tfont-size: 75%;\n\tline-height: 0;\n\tposition: relative;\n\tvertical-align: baseline;\n}\n\nsub {\n\tbottom: -0.25em;\n}\n\nsup {\n\ttop: -0.5em;\n}\n\nimg {\n\tborder-style: none;\n}\n\nbutton, input, optgroup, select, textarea {\n\tfont-family: inherit;\n\tfont-size: 100%;\n\tline-height: 1.15;\n\tmargin: 0;\n}\n\nbutton, input {\n\toverflow: visible;\n}\n\nbutton, select {\n\ttext-transform: none;\n}\n\nbutton, [type=\"button\"], [type=\"reset\"], [type=\"submit\"] {\n\t-webkit-appearance: button;\n}\n\nbutton::-moz-focus-inner, [type=\"button\"]::-moz-focus-inner, [type=\"reset\"]::-moz-focus-inner,\n\t[type=\"submit\"]::-moz-focus-inner {\n\tborder-style: none;\n\tpadding: 0;\n}\n\nbutton:-moz-focusring, [type=\"button\"]:-moz-focusring, [type=\"reset\"]:-moz-focusring,\n\t[type=\"submit\"]:-moz-focusring {\n\toutline: 1px dotted ButtonText;\n}\n\nfieldset {\n\tpadding: 0.35em 0.75em 0.625em;\n}\n\nlegend {\n\tbox-sizing: border-box;\n\tcolor: inherit;\n\tdisplay: table;\n\tmax-width: 100%;\n\tpadding: 0;\n\twhite-space: normal;\n}\n\nprogress {\n\tvertical-align: baseline;\n}\n\ntextarea {\n\toverflow: auto;\n}\n\n[type=\"checkbox\"], [type=\"radio\"] {\n\tbox-sizing: border-box;\n\tpadding: 0;\n}\n\n[type=\"number\"]::-webkit-inner-spin-button, [type=\"number\"]::-webkit-outer-spin-button\n\t{\n\theight: auto;\n}\n\n[type=\"search\"] {\n\t-webkit-appearance: textfield;\n\toutline-offset: -2px;\n}\n\n[type=\"search\"]::-webkit-search-decoration {\n\t-webkit-appearance: none;\n}\n\n::-webkit-file-upload-button {\n\t-webkit-appearance: button;\n\tfont: inherit;\n}\n\ndetails {\n\tdisplay: block;\n}\n\nsummary {\n\tdisplay: list-item;\n}\n\ntemplate {\n\tdisplay: none;\n}\n\n[hidden] {\n\tdisplay: none;\n}"
  },
  {
    "path": "sass/partials/_sketch.scss",
    "content": "/*\n * Sketch components\n */\n\n.sketch-container {\n\tposition: absolute;\n\tright: 0;\n\ttop: 0;\n\t\n\tcanvas {\n\t\tdisplay: block;\n\t}\n}\n\n.sketch-gui {\n\tposition: absolute;\n\tright: 0;\n\tbottom: 20px;\n\n\tselect {\n\t\tcolor: $general-text-color;\n\t}\n}\n\n.sketch-stats {\n\tposition: absolute;\n\tleft: 0;\n\tbottom: 0;\n\tz-index:10000;\n\tcursor:pointer;\n\topacity:0.9;\n}\n"
  },
  {
    "path": "sass/partials/_variables.scss",
    "content": "// Media queries breakpoint variables\n$S:  480px; // 30em for 16px body font\n$M:  816px; // 51em for 16px body font\n$L: 1440px; // 90em for 16px body font\n\n// Size variables\n$nav-padding: 0.3em;\n$nav-border: 0.0625em;\n$nav-margin: 0;\n$nav-header-width: 14em;\n$nav-border-radius: 3px;\n$nav-item-min-width: 4em;\n$nav-item-border: 0.0625em;\n$nav-item-padding: 0.4em 0.7em;\n$nav-item-padding-with-border: 0.3375em 0.6375em;\n$container-sides-padding: 10%;\n$container-sides-padding-lowres: 5%;\n$main-container-top-padding: 2.5em;\n$examples-list-width: 20%;\n$examples-list-margin: 3em;\n$examples-list-margin-lowres: 1em;\n$examples-list-item-margin: 0.3em;\n$examples-list-item-padding: 0.4em;\n$examples-list-item-border-radius: $nav-border-radius;\n\n// Color variables\n$alpha: 0.96;\n$general-text-color: lighten(black, 20%);\n$shadow-color: lighten(black, 60%);\n$header-color: lighten(black, 40%);\n$link-color: lighten(blue, 20%);\n$border-color: rgba(white, 0.1);\n$nav-bg-color: rgba(lighten(black, 10%), $alpha);\n$nav-middle-bg-color: rgba(lighten(black, 25%), $alpha);\n$nav-border-color: rgba(lighten(black, 40%), $alpha);\n$nav-shadow-color: rgba(darken($shadow-color, 20%), $alpha);\n$nav-item-color: darken(white, 10%);\n$nav-item-hover-color: lighten($nav-item-color, 20%);\n$nav-item-bg-color: rgba(white, 0.1);\n$nav-item-hover-bg-color: rgba(white, 0.3);\n$nav-active-item-bg-color: rgba(0, 150, 255, 0.7);\n$nav-active-item-hover-bg-color: rgba(0, 150, 255, 1.0);\n$examples-list-item-color: $general-text-color;\n$examples-list-item-hover-color: lighten($examples-list-item-color, 80%);\n$examples-list-item-bg-color: darken(white, 5%);\n$examples-list-item-hover-bg-color: darken($examples-list-item-bg-color, 20%);\n$footer-color: lighten($general-text-color, 20%);\n$footer-border-color: darken(white, 20%);\n\n// Other variables\n$speed: 0.6s;"
  },
  {
    "path": "sass/styles.scss",
    "content": "\n@import \"partials/variables\";\n@import \"partials/normalize\";\n@import \"partials/fonts\";\n@import \"partials/base\";\n@import \"partials/layout\";\n@import \"partials/navbar\";\n@import \"partials/content\";\n@import \"partials/sketch\";\n@import \"partials/footer\";\n"
  },
  {
    "path": "shaders/frag-badtv.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureVaryings.glsl\")\n#pragma glslify: noise1d = require(\"./requires/noise1d\")\n#pragma glslify: random2d = require(\"./requires/random2d\")\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the effect relative strength\n\tfloat strength = (0.3 + 0.7 * noise1d(0.3 * u_time)) * u_mouse.x / u_resolution.x;\n\n\t// Calculate the effect jump at the current time interval\n\tfloat jump = 500.0 * floor(0.3 * (u_mouse.x / u_resolution.x) * (u_time + noise1d(u_time)));\n\n\t// Shift the texture coordinates\n\tvec2 uv = v_uv;\n\tuv.y += 0.2 * strength * (noise1d(5.0 * v_uv.y + 2.0 * u_time + jump) - 0.5);\n\tuv.x += 0.1 * strength * (noise1d(100.0 * strength * uv.y + 3.0 * u_time + jump) - 0.5);\n\n\t// Get the texture pixel color\n\tvec3 pixel_color = texture2D(u_texture, uv).rgb;\n\n\t// Add some white noise\n\tpixel_color += vec3(5.0 * strength * (random2d(v_uv + 1.133001 * vec2(u_time, 1.13)) - 0.5));\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-blur.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureVaryings.glsl\")\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the pixel color based on the mouse position\n    vec3 pixel_color;\n\n    if (gl_FragCoord.x > u_mouse.x) {\n        // Apply the gaussian kernel\n        float step = 1.0 + 2.0 * u_mouse.y / u_resolution.y;\n        pixel_color += (1.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-2, -2) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-2, -1) / u_resolution).rgb;\n        pixel_color += (6.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-2, 0) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-2, 1) / u_resolution).rgb;\n        pixel_color += (1.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-2, 2) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-1, -2) / u_resolution).rgb;\n        pixel_color += (16.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-1, -1) / u_resolution).rgb;\n        pixel_color += (24.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-1, 0) / u_resolution).rgb;\n        pixel_color += (16.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-1, 1) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(-1, 2) / u_resolution).rgb;\n        pixel_color += (6.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(0, -2) / u_resolution).rgb;\n        pixel_color += (24.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(0, -1) / u_resolution).rgb;\n        pixel_color += (36.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(0, 0) / u_resolution).rgb;\n        pixel_color += (24.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(0, 1) / u_resolution).rgb;\n        pixel_color += (6.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(0, 2) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(1, -2) / u_resolution).rgb;\n        pixel_color += (16.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(1, -1) / u_resolution).rgb;\n        pixel_color += (24.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(1, 0) / u_resolution).rgb;\n        pixel_color += (16.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(1, 1) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(1, 2) / u_resolution).rgb;\n        pixel_color += (1.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(2, -2) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(2, -1) / u_resolution).rgb;\n        pixel_color += (6.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(2, 0) / u_resolution).rgb;\n        pixel_color += (4.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(2, 1) / u_resolution).rgb;\n        pixel_color += (1.0 / 256.0) * texture2D(u_texture, v_uv + step * vec2(2, 2) / u_resolution).rgb;\n    } else if (gl_FragCoord.x > u_mouse.x - 1.0) {\n        // Draw a line indicating the transition\n        pixel_color = vec3(0.0);\n    } else {\n        // Use the original image pixel color\n        pixel_color = texture2D(u_texture, v_uv).rgb;\n    }\n\n// Fragment shader output\n    gl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-cursor.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureVaryings.glsl\")\n#pragma glslify: circle = require(\"./requires/shapes/circle\")\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the pixel color\n    vec3 pixel_color = texture2D(u_texture, v_uv).rgb;\n\n\t// Draw a circle at the mouse position\n    float circle_radius = 50.0;\n    vec3 circle_color = vec3(0.5, 0.5, 0.8) + vec3(0.3 * cos(u_time), 0.3 * sin(1.3 *u_time), 0.2 * cos(2.7 *u_time));\n    float mix_factor = 0.8 * circle(gl_FragCoord.xy, u_mouse, circle_radius);\n    pixel_color = mix(pixel_color, circle_color, mix_factor);\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-cuts.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureVaryings.glsl\")\n#pragma glslify: rotate = require(\"./requires/rotate2d\")\n\n/*\n * The main program\n */\nvoid main() {\n    // Change the cuts pixel size as a function of the mouse relative position\n    float cuts_size = 150.0 * (1.1 - u_mouse.x / u_resolution.x);\n\n    // Calculate the cuts offset\n    float angle = 0.4 * u_time;\n    vec2 offset = 30.0 * sin(angle) * vec2(cos(angle), sin(angle));\n\n    // Change the offset direction between cuts\n    vec2 rotated_pos = rotate(angle) * (gl_FragCoord.xy - 0.5 * u_resolution) + 0.5 * u_resolution;\n    offset *= 2.0 * floor(mod(rotated_pos.y / cuts_size, 2.0)) - 1.0;\n\n    // Fragment shader output\n    gl_FragColor = texture2D(u_texture, v_uv + offset / u_resolution);\n}\n"
  },
  {
    "path": "shaders/frag-debug-pos.glsl",
    "content": "void main() {\n    vec2 uv = gl_FragCoord.xy / resolution;\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    gl_FragColor = vec4(position + velocity, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-debug-vel.glsl",
    "content": "void main() {\n    vec2 uv = gl_FragCoord.xy / resolution;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    gl_FragColor = vec4(velocity, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-debug.glsl",
    "content": "void main() {\n    gl_FragColor = vec4(vec3(1.0), 1);\n}\n"
  },
  {
    "path": "shaders/frag-dla-pos.glsl",
    "content": "#pragma glslify: random = require(\"./requires/random2d\")\n\n// Simulation uniforms\nuniform float u_minDistance;\nuniform float u_maxDistance;\nuniform float u_time;\n\n// Simulation constants\nconst float width = resolution.x;\nconst float height = resolution.y;\nconst float nParticles = width * height;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position\n    vec4 position = texture2D(u_positionTexture, uv);\n\n    // Update the particle position if it has not been aggregated\n    if (position.w > 0.0) {\n        // Move the particle to a new random position\n        float ang = 2.0 * 3.141593 * random(123.456 * position.xy + u_time);\n        position.xy += 0.9 * u_minDistance * vec2(cos(ang), sin(ang));\n\n        // Loop over all the particles in the simulation\n        for (float i = 0.0; i < nParticles; i++) {\n            // Get the particle position and velocity\n            vec2 particleUv = vec2(mod(i, width) + 0.5, floor(i / width) + 0.5) / resolution;\n            vec4 particlePosition = texture2D(u_positionTexture, particleUv);\n\n            // Check if it's an aggregated particle\n            if (position.w > 0.0 && particlePosition.w < 0.0) {\n                // Calculate the distance between the two particles\n                float distance = length(particlePosition.xy - position.xy);\n\n                // Set the particle as aggregated if the distance is small\n                // enough and we are not comparing the particle with itself\n                if (distance != 0.0 && distance < u_minDistance) {\n                    position.w = -1.0;\n                    position.xy = particlePosition.xy + u_minDistance * (position.xy - particlePosition.xy) / distance;\n                    break;\n                }\n            }\n        }\n\n        // Make sure that the particle distance to the center is smaller than\n        // the maximum allowed distance\n        float distanceToCenter = length(position.xy);\n\n        if (distanceToCenter > u_maxDistance) {\n            position.xy -= 2.0 * u_maxDistance * position.xy / distanceToCenter;\n        }\n    }\n\n    // Return the updated particle position\n    gl_FragColor = position;\n}\n"
  },
  {
    "path": "shaders/frag-dla-vel.glsl",
    "content": ""
  },
  {
    "path": "shaders/frag-dla.glsl",
    "content": "// Texture with the particle profile\nuniform sampler2D u_texture;\n\n// Varying with the aggregation information\nvarying float v_aggregation;\n\n/*\n * The main program\n */\nvoid main() {\n    // Use a different color for aggregated and non-aggregated particles\n    vec3 particleColor = v_aggregation < 0.0 ? vec3(1.0) : vec3(0.5);\n\n    // Fragment shader output\n    gl_FragColor = vec4(particleColor, texture2D(u_texture, gl_PointCoord).a);\n}\n"
  },
  {
    "path": "shaders/frag-dots.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/commonVaryings3d.glsl\")\n#pragma glslify: circle = require(\"./requires/shapes/circle\")\n#pragma glslify: rotate = require(\"./requires/rotate2d\")\n#pragma glslify: diffuseFactor = require(\"./requires/diffuseFactor\")\n\n/*\n * The main program\n */\nvoid main() {\n    // Use the mouse position to define the light direction\n    float min_resolution = min(u_resolution.x, u_resolution.y);\n    vec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.5);\n\n    // Calculate the light diffusion factor\n    float df = diffuseFactor(v_normal, light_direction);\n\n    // Move the pixel coordinates origin to the center of the screen\n    vec2 pos = gl_FragCoord.xy - 0.5 * u_resolution;\n\n    // Rotate the coordinates 20 degrees\n    pos = rotate(radians(20.0)) * pos;\n\n    // Define the grid\n    float grid_step = 12.0;\n    vec2 grid_pos = mod(pos, grid_step);\n\n    // Calculate the surface color\n    float surface_color = 1.0;\n    surface_color -= circle(grid_pos, vec2(grid_step / 2.0), 0.8 * grid_step * pow(1.0 - df, 2.0));\n    surface_color = clamp(surface_color, 0.05, 1.0);\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(surface_color), 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-edge.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureVaryings.glsl\")\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the pixel color based on the mouse position\n    vec3 pixel_color;\n\n    if (gl_FragCoord.x > u_mouse.x) {\n        // Apply the edge detection kernel\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(-1, -1) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(-1, 0) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(-1, 1) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(0, -1) / u_resolution).rgb;\n        pixel_color += 8.0 * texture2D(u_texture, v_uv + vec2(0, 0) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(0, 1) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(1, -1) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(1, 0) / u_resolution).rgb;\n        pixel_color += -1.0 * texture2D(u_texture, v_uv + vec2(1, 1) / u_resolution).rgb;\n\n        // Use the most extreme color value\n        float min_value = min(pixel_color.r, min(pixel_color.g, pixel_color.b));\n        float max_value = max(pixel_color.r, max(pixel_color.g, pixel_color.b));\n\n        if (abs(min_value) > abs(max_value)) {\n            pixel_color = vec3(min_value);\n        } else {\n            pixel_color = vec3(max_value);\n        }\n\n        // Rescale the pixel color using the mouse y position\n        float scale = 0.2 + 2.5 * u_mouse.y / u_resolution.y;\n        pixel_color = 0.5 + scale * pixel_color;\n    } else if (gl_FragCoord.x > u_mouse.x - 1.0) {\n        // Draw a line indicating the transition\n        pixel_color = vec3(0.0);\n    } else {\n        // Use the original image pixel color\n        pixel_color = texture2D(u_texture, v_uv).rgb;\n    }\n\n    // Fragment shader output\n    gl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-fire.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureVaryings.glsl\")\n#pragma glslify: noise = require(\"./requires/classicNoise2d\")\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the pixel color depending of the distance from the floor\n\tvec3 pixel_color = vec3(0.0);\n\tfloat floor = 2.0;\n\n\tif (gl_FragCoord.y <= floor) {\n\t\t// Use some 2D noise to simulate the fire change in position and time\n\t\tpixel_color.rg = vec2(noise(vec2(0.01 * gl_FragCoord.x, -0.2 * u_time)));\n\t} else {\n\t\t// Get a smoothed value of the pixels bellow\n\t    vec2 delta =  1.0 / u_resolution;\n\t    pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(2.0 * delta.x, -delta.y)).rgb;\n\t\tpixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(1.0 * delta.x, -delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(0.0 * delta.x, -delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(-1.0 * delta.x, -delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(-2.0 * delta.x, -delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(2.0 * delta.x, -2.0 * delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(1.0 * delta.x, -2.0 * delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(0.0 * delta.x, -2.0 * delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(-1.0 * delta.x, -2.0 * delta.y)).rgb;\n        pixel_color += 0.1 * texture2D(u_texture, v_uv + vec2(-2.0 * delta.x, -2.0 * delta.y)).rgb;\n\n        // Decrease the intensity with the distance to the floor\n        float fade_factor = 1.0 - smoothstep(0.0, u_resolution.x, (gl_FragCoord.y - floor) / 3.0);\n        pixel_color.r *= fade_factor;\n        pixel_color.g *= 0.99 * fade_factor;\n        pixel_color.b = 0.0;\n\t}\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-flare.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureVaryings.glsl\")\n#pragma glslify: noise = require(\"./requires/classicNoise2d\")\n\n/*\n * The main program\n */\nvoid main() {\n    // Set the star radius\n    float star_radius = 90.0;\n\n    // Get the pixel position relative to the screen center\n    vec2 position = gl_FragCoord.xy - 0.5 * u_resolution;\n\n    // Calculate the pixel distance from the center\n    float radial_distance = length(position);\n\n    // Calculate the star color\n    vec3 star_color = vec3(0.0);\n\n    if (radial_distance < star_radius) {\n        // Calculate the pixel polar angle\n        float angle = atan(position.y, position.x) + radians(180.0);\n\n        // Calculate the radial noise position\n        float r = 0.05 * (radial_distance - u_frame);\n\n        // Calculate the noise value\n        float noise_value = noise(vec2(r, 1.5 * angle));\n\n        // Smooth the noise discontinuity between 0 and 360 degrees\n        float smooth_step = radians(20.0);\n        float limit_angle = radians(360.0) - smooth_step;\n\n        if (angle > limit_angle) {\n            noise_value = mix(noise_value, noise(vec2(r, 0.0)), (angle - limit_angle) / smooth_step);\n        }\n\n        // The final star color is the combination of a radially constant\n        // declining intensity plus the noise\n        float f = pow(radial_distance / star_radius, 2.0);\n        star_color = vec3((1.0 - f) + f * (0.1 + 0.4 * u_mouse.x / u_resolution.x) * (0.5 + 0.5 * noise_value));\n    }\n\n    // Calculate the average color of the pixels that are radially bellow the\n    // current pixel\n    vec3 average_color = vec3(0.0);\n    float counter = 0.0;\n\n    for (float i = -2.0; i <= 2.0; i++) {\n        for (float j = -2.0; j <= 2.0; j++) {\n            // Get the pixel color at the offset position\n            vec2 offset = vec2(i, j);\n            vec3 color = texture2D(u_texture, v_uv + offset / u_resolution).rgb;\n\n            // Add the color to the average if the pixel is above the offset\n            // position and is not a pixel inside the star\n            if (radial_distance > length(position + offset) && radial_distance >= star_radius) {\n                average_color += color;\n                counter++;\n            }\n        }\n    }\n\n    if (counter > 0.0) {\n        average_color /= counter;\n    }\n\n    // Set the distance decrement factor for the average color\n    float decrement_factor = 0.1 * (u_resolution.y - u_mouse.y) / u_resolution.y;\n\n    // Fragment shader output\n    gl_FragColor = vec4(star_color + (1.0 - decrement_factor) * average_color, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-galaxies-pos.glsl",
    "content": "// Simulation uniforms\nuniform float u_dt;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Return the updated particle position\n    gl_FragColor = vec4(position + u_dt * velocity, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-galaxies-vel.glsl",
    "content": "// Simulation uniforms\nuniform float u_dt;\nuniform float u_mass;\nuniform float u_haloSize;\n\n// Simulation constants\nconst float width = resolution.x;\nconst float height = resolution.y;\n\n// Softening factor. This is required to avoid high acceleration values\n// when two particles get too close\nconst float softening = 0.001;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Loop over all the particles and calculate the total gravitational force\n    vec3 totalForce = vec3(0.0);\n\n    for (float i = 0.0; i < nGalaxies; i++) {\n        // Get the position of the attracting particle\n        vec2 particleUv = vec2(mod(i, width) + 0.5, floor(i / width) + 0.5) / resolution;\n        vec3 particlePosition = texture2D(u_positionTexture, particleUv).xyz;\n\n        // Calculate the force direction\n        vec3 forceDirection = particlePosition - position;\n\n        // Calculate the particle distance\n        float distance = length(forceDirection);\n\n        // Move to the next particle if the distance is exactly zero, which\n        // indicates that we are comparing the particle with itself\n        if (distance == 0.0) {\n            continue;\n        }\n\n        // Add the particle gravitational force\n        float massAtPosition = u_mass * min(distance, u_haloSize) / u_haloSize;\n        totalForce += massAtPosition * (forceDirection / distance) / pow(distance + softening, 2.0);\n    }\n\n    // Return the updated particle velocity\n    gl_FragColor = vec4(velocity + u_dt * totalForce, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-grav-pos.glsl",
    "content": "// Simulation uniforms\nuniform float u_dt;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Return the updated particle position\n    gl_FragColor = vec4(position + u_dt * velocity, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-grav-vel.glsl",
    "content": "// Simulation uniforms\nuniform float u_dt;\n\n// Simulation constants\nconst float width = resolution.x;\nconst float height = resolution.y;\nconst float nParticles = width * height;\n\n// Softening factor. This is required to avoid high acceleration values\n// when two particles get too close\nconst float softening = 0.1;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Loop over all the particles and calculate the total gravitational force\n    vec3 totalForce = vec3(0.0);\n    float forceScalingFactor = 1.0 / (2.0 * pow(nParticles, 1.5));\n\n    for (float i = 0.0; i < nParticles; i++) {\n        // Get the position of the attracting particle\n        vec2 particleUv = vec2(mod(i, width) + 0.5, floor(i / width) + 0.5) / resolution;\n        vec3 particlePosition = texture2D(u_positionTexture, particleUv).xyz;\n\n        // Calculate the force direction\n        vec3 forceDirection = particlePosition - position;\n\n        // Calculate the particle distance\n        float distance = length(forceDirection);\n\n        // Move to the next particle if the distance is exactly zero, which\n        // indicates that we are comparing the particle with itself\n        if (distance == 0.0) {\n            continue;\n        }\n\n        // Add the particle gravitational force\n        totalForce += forceScalingFactor * (forceDirection / distance) / pow(distance + softening, 2.0);\n    }\n\n    // Return the updated particle velocity\n    gl_FragColor = vec4(velocity + u_dt * totalForce, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-lens.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureVaryings.glsl\")\n\n/*\n * The main program\n */\nvoid main() {\n\t// Set the lens radius\n\tfloat lens_radius = min(0.3 * u_resolution.x, 250.0);\n\n\t// Calculate the direction to the mouse position and the distance\n\tvec2 mouse_direction = u_mouse - gl_FragCoord.xy;\n\tfloat mouse_distance = length(mouse_direction);\n\n\t// Calculate the pixel color based on the mouse position\n\tvec3 pixel_color;\n\n\tif (mouse_distance < lens_radius) {\n\t\t// Calculate the pixel offset\n\t\tfloat exp = 1.0;\n\t\tvec2 offset = (1.0 - pow(mouse_distance / lens_radius, exp)) * mouse_direction;\n\n\t\t// Get the pixel color at the offset position\n\t\tpixel_color = texture2D(u_texture, v_uv + offset / u_resolution).rgb;\n\t} else {\n\t\t// Use the original image pixel color\n\t\tpixel_color = texture2D(u_texture, v_uv).rgb;\n\t}\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-mountains.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/commonVaryings3d.glsl\")\n#pragma glslify: calculateNormal = require(\"./requires/calculateNormal\")\n#pragma glslify: diffuseFactor = require(\"./requires/diffuseFactor\")\n\n// The plane tile size, the maximum mountain height and the sky color\nuniform float u_tileSize;\nuniform float u_maxHeight;\nuniform vec3 u_skyColor;\n\n// Varying containing the terrain elevation\nvarying float v_elevation;\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new normal vector\n\tvec3 new_normal = calculateNormal(v_position);\n\n\t// Use the mouse position to define the light direction\n\tfloat min_resolution = min(u_resolution.x, u_resolution.y);\n\tvec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.25);\n\n\t// Set the default surface color\n\tvec3 surface_color = vec3(0.3, 0.65, 0.0);\n\n\t// Change the color for the snow peaks and the lakes\n\tif (v_elevation > 0.85 * u_maxHeight) {\n\t\tsurface_color = vec3(1.0, 1.0, 1.0);\n\t} else if (v_elevation < 0.2 * u_maxHeight) {\n\t\tsurface_color = vec3(0.3, 0.7, 0.9);\n\t}\n\n\t// Apply the light diffusion factor\n\tsurface_color *= diffuseFactor(new_normal, light_direction);\n\n\t// Add a fog effect\n\tfloat fog_factor = clamp(0.0, 1.0, -(1.0 - u_mouse.y / u_resolution.y) * v_position.z / (15.0 * u_tileSize));\n\tsurface_color = mix(surface_color, u_skyColor, fog_factor);\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(surface_color, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-noise.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: noise = require(\"./requires/classicNoise2d\")\n\n/*\n * Combines the 2d noise function at three different scales\n */\nfloat multy_scale_noise(vec2 p, vec2 rel_mouse_pos) {\n    return 0.8 * noise(5.0 * p) + rel_mouse_pos.x * noise(15.0 * p) + rel_mouse_pos.y * noise(60.0 * p);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Normalize the pixel and mouse positions to the maximum scale dimension\n    float max_dim = max(u_resolution.x, u_resolution.y);\n    vec2 rel_pixel_pos = gl_FragCoord.xy / max_dim;\n    vec2 rel_mouse_pos = u_mouse / max_dim;\n\n    // Use a slightly shifted noise value for each color\n    float r = multy_scale_noise(rel_pixel_pos + 0.05 * rel_mouse_pos, rel_mouse_pos);\n    float g = multy_scale_noise(rel_pixel_pos + 0.05 * rel_mouse_pos.yx, rel_mouse_pos);\n    float b = multy_scale_noise(rel_pixel_pos - 0.05 * rel_mouse_pos, rel_mouse_pos);\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(r, g, b), 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-normals.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/commonVaryings3d.glsl\")\n#pragma glslify: calculateNormal = require(\"./requires/calculateNormal\")\n#pragma glslify: diffuseFactor = require(\"./requires/diffuseFactor\")\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new normal vector\n\tvec3 new_normal = calculateNormal(v_position);\n\n\t// Use the mouse position to define the light direction\n\tfloat min_resolution = min(u_resolution.x, u_resolution.y);\n\tvec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.25);\n\n\t// Set the surface color\n\tvec3 surface_color = vec3(1.0);\n\n\t// Apply the light diffusion factor\n\tsurface_color *= diffuseFactor(new_normal, light_direction);\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(surface_color, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-pencil.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/commonVaryings3d.glsl\")\n#pragma glslify: rotate = require(\"./requires/rotate2d\")\n#pragma glslify: diffuseFactor = require(\"./requires/diffuseFactor\")\n#pragma glslify: horizontalLine = require(\"./requires/shapes/horizontalLine\")\n\n/*\n * The main program\n */\nvoid main() {\n    // Use the mouse position to define the light direction\n    float min_resolution = min(u_resolution.x, u_resolution.y);\n    vec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.5);\n\n    // Calculate the light diffusion factor\n    float df = diffuseFactor(v_normal, light_direction);\n\n    // Move the pixel coordinates origin to the center of the screen\n    vec2 pos = gl_FragCoord.xy - 0.5 * u_resolution;\n\n    // Rotate the coordinates 20 degrees\n    pos = rotate(radians(20.0)) * pos;\n\n    // Define the first group of pencil lines\n    float line_width = 7.0 * (1.0 - smoothstep(0.0, 0.3, df)) + 0.5;\n    float lines_sep = 16.0;\n    vec2 grid_pos = vec2(pos.x, mod(pos.y, lines_sep));\n    float line_1 = horizontalLine(grid_pos, lines_sep / 2.0, line_width);\n    grid_pos.y = mod(pos.y + lines_sep / 2.0, lines_sep);\n    float line_2 = horizontalLine(grid_pos, lines_sep / 2.0, line_width);\n\n    // Rotate the coordinates 50 degrees\n    pos = rotate(radians(-50.0)) * pos;\n\n    // Define the second group of pencil lines\n    lines_sep = 12.0;\n    grid_pos = vec2(pos.x, mod(pos.y, lines_sep));\n    float line_3 = horizontalLine(grid_pos, lines_sep / 2.0, line_width);\n    grid_pos.y = mod(pos.y + lines_sep / 2.0, lines_sep);\n    float line_4 = horizontalLine(grid_pos, lines_sep / 2.0, line_width);\n\n    // Calculate the surface color\n    float surface_color = 1.0;\n    surface_color -= 0.8 * line_1 * (1.0 - smoothstep(0.5, 0.75, df));\n    surface_color -= 0.8 * line_2 * (1.0 - smoothstep(0.4, 0.5, df));\n    surface_color -= 0.8 * line_3 * (1.0 - smoothstep(0.4, 0.65, df));\n    surface_color -= 0.8 * line_4 * (1.0 - smoothstep(0.2, 0.4, df));\n    surface_color = clamp(surface_color, 0.05, 1.0);\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(surface_color), 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-pixelated.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureVaryings.glsl\")\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the square size in pixel units based on the mouse position\n\tfloat square_size = floor(2.0 + 30.0 * (u_mouse.x / u_resolution.x));\n\n\t// Calculate the square center and corners\n\tvec2 center = square_size * floor(v_uv * u_resolution / square_size) + square_size * vec2(0.5, 0.5);\n\tvec2 corner1 = center + square_size * vec2(-0.5, -0.5);\n\tvec2 corner2 = center + square_size * vec2(+0.5, -0.5);\n\tvec2 corner3 = center + square_size * vec2(+0.5, +0.5);\n\tvec2 corner4 = center + square_size * vec2(-0.5, +0.5);\n\n\t// Calculate the average pixel color\n\tvec3 pixel_color = 0.4 * texture2D(u_texture, center / u_resolution).rgb;\n\tpixel_color += 0.15 * texture2D(u_texture, corner1 / u_resolution).rgb;\n\tpixel_color += 0.15 * texture2D(u_texture, corner2 / u_resolution).rgb;\n\tpixel_color += 0.15 * texture2D(u_texture, corner3 / u_resolution).rgb;\n\tpixel_color += 0.15 * texture2D(u_texture, corner4 / u_resolution).rgb;\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-rain.glsl",
    "content": "#define PI 3.14159265\n\n#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: random = require(\"./requires/random1d\")\n\n/*\n *  Returns a random drop position for the given seed value\n */\nvec2 random_drop_pos(float val, vec2 screen_dim, vec2 velocity) {\n    float max_x_move = velocity.x * abs(screen_dim.y / velocity.y);\n    float x = -max_x_move * step(0.0, max_x_move) + (screen_dim.x + abs(max_x_move)) * random(val);\n    float y = (1.0 + 0.05 * random(1.234 * val)) * screen_dim.y;\n\n    return vec2(x, y);\n}\n\n/*\n * Calculates the drop trail color at the given pixel position\n */\nvec3 trail_color(vec2 pixel, vec2 pos, vec2 velocity_dir, float width, float size) {\n    vec2 pixel_dir = pixel - pos;\n    float projected_dist = dot(pixel_dir, -velocity_dir);\n    float tanjential_dist_sq = dot(pixel_dir, pixel_dir) - pow(projected_dist, 2.0);\n    float width_sq = pow(width, 2.0);\n\n    float line = step(0.0, projected_dist) * (1.0 - smoothstep(width_sq / 2.0, width_sq, tanjential_dist_sq));\n    float dashed_line = line * step(0.5, cos(0.3 * projected_dist - PI / 3.0));\n    float fading_dashed_line = dashed_line * (1.0 - smoothstep(size / 5.0, size, projected_dist));\n\n    return vec3(fading_dashed_line);\n}\n\n/*\n * Calculates the drop wave color at the given pixel position\n */\nvec3 wave_color(vec2 pixel, vec2 pos, float size, float time) {\n    vec2 pixel_dir = pixel - pos;\n    float distorted_dist = length(pixel_dir * vec2(1.0, 3.5));\n\n    float inner_radius = (0.05 + 0.8 * time) * size;\n    float outer_radius = inner_radius + 0.25 * size;\n\n    float ring = smoothstep(inner_radius, inner_radius + 5.0, distorted_dist)\n            * (1.0 - smoothstep(outer_radius, outer_radius + 5.0, distorted_dist));\n    float fading_ring = ring * (1.0 - smoothstep(0.0, 0.7, time));\n\n    return vec3(fading_ring);\n}\n\n/*\n * Calculates the background color at the given pixel position\n */\nvec3 background_color(vec2 pixel, vec2 screen_dim, float time) {\n    return vec3(0.0, 0.0, 1.0 - smoothstep(-1.0, 0.8 + 0.2 * cos(0.5 * time), pixel.y / screen_dim.y));\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Set the total number of rain drops that are visible at a given time\n    const float n_drops = 20.0;\n\n    // Set the drop trail radius\n    float trail_width = 2.0;\n\n    // Set the drop trail size\n    float trail_size = 70.0;\n\n    // Set the drop wave size\n    float wave_size = 20.0;\n\n    // Set the drop fall time in seconds\n    float fall_time = 0.7;\n\n    // Set the drop total life time\n    float life_time = fall_time + 0.5;\n\n    // Set the drop velocity in pixels per second\n    vec2 velocity = vec2(u_mouse.x - 0.5 * u_resolution.x, -0.9 * u_resolution.y) / fall_time;\n    vec2 velocity_dir = normalize(velocity);\n\n    // Iterate over the drops to calculate the pixel color\n    vec3 pixel_color = vec3(0.0);\n\n    for (float i = 0.0; i < n_drops; ++i) {\n        // Offset the running time for each drop\n        float time = u_time + life_time * (i + i / n_drops);\n\n        // Calculate the time since the drop appeared on the screen\n        float ellapsed_time = mod(time, life_time);\n\n        // Calculate the drop initial position\n        vec2 initial_pos = random_drop_pos(i + floor(time / life_time - i) * n_drops, u_resolution, velocity);\n\n        // Add the drop to the pixel color\n        if (ellapsed_time < fall_time) {\n            // Calculate the drop current position\n            vec2 current_pos = initial_pos + ellapsed_time * velocity;\n\n            // Add the trail color to the pixel color\n            pixel_color += trail_color(gl_FragCoord.xy, current_pos, velocity_dir, trail_width, trail_size);\n        } else {\n            // Calculate the drop final position\n            vec2 final_pos = initial_pos + fall_time * velocity;\n\n            // Add the wave color to the pixel color\n            pixel_color += wave_color(gl_FragCoord.xy, final_pos, wave_size, ellapsed_time - fall_time);\n        }\n    }\n\n    // Add the background color to the pixel color\n    pixel_color += background_color(gl_FragCoord.xy, u_resolution, u_time);\n\n    // Fragment shader output\n    gl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-random.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: random = require(\"./requires/random2d\")\n\n/*\n * The main program\n */\nvoid main() {\n    // Create a grid of squares that depends on the mouse position\n    vec2 square = floor((gl_FragCoord.xy - u_mouse) / 30.0);\n\n    // Give a random color to each square\n    vec3 square_color = vec3(random(square), random(1.234 * square), 1.0);\n\n    // Fragment shader output\n    gl_FragColor = vec4(square_color, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-reaction.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureVaryings.glsl\")\n#pragma glslify: laplacian = require(\"./requires/laplacian\")\n\n// Calculates the pixel color from the pixel chemical concentrations\nvec4 calculate_color(vec2 concentrations) {\n    return vec4(concentrations * vec2(0.05, 1.0), 0.0, 1.0);\n}\n\n// Calculates the pixel chemical concentrations from the pixel color\nvec2 calculate_concentrations(vec4 color) {\n    return color.rg / vec2(0.05, 1.0);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Set the Gray-Scott reaction-diffusion simulation parameters\n    float D_A = 0.8;\n    float D_B = 0.4;\n    float feed = 0.06 * v_uv.x;\n    float kill = 0.035 + 0.03 * v_uv.x + (0.022 - 0.015 * v_uv.x) * v_uv.y;\n    float dt = 1.0;\n\n    // Calculate the chemical concentrations from the pixel color\n    vec4 pixel_color = texture2D(u_texture, v_uv);\n    vec2 concentrations = calculate_concentrations(pixel_color);\n    float A = concentrations.x;\n    float B = concentrations.y;\n\n    // Calculate the laplacian\n    vec2 lap = calculate_concentrations(laplacian(v_uv, u_texture, u_resolution));\n\n    // Calculate the new chemical concentration values\n    float dA = (D_A * lap.r - A * B * B + feed * (1.0 - A)) * dt;\n    float dB = (D_B * lap.g + A * B * B - (kill + feed) * B) * dt;\n    concentrations += vec2(dA, dB);\n\n    // Modify the concentrations in the pixels under the mouse position\n    if (length(gl_FragCoord.xy - u_mouse) < 5.0) {\n        concentrations = vec2(0.0, 0.9);\n    }\n\n    // Fragment shader output\n    gl_FragColor = calculate_color(concentrations);\n}\n"
  },
  {
    "path": "shaders/frag-repulsion-pos.glsl",
    "content": "// Simulation uniforms\nuniform float u_dt;\nuniform float u_nActiveParticles;\n\n// Simulation constants\nconst float width = resolution.x;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Check if the particle is one of the active particles\n    if ((gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * width < u_nActiveParticles) {\n        // Return the updated particle position\n        gl_FragColor = vec4(position + u_dt * velocity, 1.0);\n    } else {\n        // Return the original particle position\n        gl_FragColor = vec4(position, 1.0);\n    }\n}\n"
  },
  {
    "path": "shaders/frag-repulsion-vel.glsl",
    "content": "// Simulation uniforms\nuniform float u_dt;\nuniform float u_nActiveParticles;\n\n// Simulation constants\nconst float width = resolution.x;\nconst float height = resolution.y;\nconst float nParticles = width * height;\n\n// Softening factor. This is required to avoid high acceleration values\n// when two particles get too close\nconst float softening = 0.005;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Check if the particle is one of the active particles\n    if ((gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * width < u_nActiveParticles) {\n        // Loop over all the particles and calculate the total repulsion force\n        vec3 totalForce = vec3(0.0);\n        float forceScalingFactor = 0.0001;\n\n        for (float i = 0.0; i < nParticles; i++) {\n            // Consider only active particles\n            if (i >= u_nActiveParticles) {\n                break;\n            }\n\n            // Get the position of the repulsing particle\n            vec2 particleUv = vec2(mod(i, width) + 0.5, floor(i / width) + 0.5) / resolution;\n            vec3 particlePosition = texture2D(u_positionTexture, particleUv).xyz;\n\n            // Calculate the force direction\n            vec3 forceDirection = -(particlePosition - position);\n\n            // Calculate the particle distance\n            float distance = length(forceDirection);\n\n            // Move to the next particle if the distance is exactly zero, which\n            // indicates that we are comparing the particle with itself\n            if (distance == 0.0) {\n                continue;\n            }\n\n            // Add the particle repulsion force\n            float distanceDumping = 1.0 - smoothstep(0.45, 0.5, distance);\n            totalForce += forceScalingFactor * distanceDumping * (forceDirection / distance)\n                    / pow(distance + softening, 2.0);\n        }\n\n        // Return the updated particle velocity\n        gl_FragColor = vec4(velocity * (1.0 - 0.1 * u_dt) + u_dt * totalForce, 1.0);\n    } else {\n        // Return the original particle velocity\n        gl_FragColor = vec4(velocity, 1.0);\n    }\n}\n"
  },
  {
    "path": "shaders/frag-repulsion.glsl",
    "content": "// Texture with the particle profile\nuniform sampler2D u_texture;\n\n// Particle color varying\nvarying vec3 v_color;\n\n/*\n * The main program\n */\nvoid main() {\n    // Fragment shader output\n    gl_FragColor = vec4(v_color, texture2D(u_texture, gl_PointCoord).a);\n}\n"
  },
  {
    "path": "shaders/frag-rgb.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureVaryings.glsl\")\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the color offset directions\n    float angle = u_time;\n    vec2 red_offset = vec2(cos(angle), sin(angle));\n    angle += radians(120.0);\n    vec2 green_offset = vec2(cos(angle), sin(angle));\n    angle += radians(120.0);\n    vec2 blue_offset = vec2(cos(angle), sin(angle));\n\n    // Calculate the offset size as a function of the pixel distance to the center\n    float offset_size = 0.1 * length(gl_FragCoord.xy - 0.5 * u_resolution);\n\n    // Scale the offset size by the relative mouse position\n    offset_size *= u_mouse.x / u_resolution.x;\n\n    // Extract the pixel color values from the input texture\n    float red = texture2D(u_texture, v_uv - offset_size * red_offset / u_resolution).r;\n    float green = texture2D(u_texture, v_uv - offset_size * green_offset / u_resolution).g;\n    float blue = texture2D(u_texture, v_uv - offset_size * blue_offset / u_resolution).b;\n\n    // Fragment shader output\n    gl_FragColor = vec4(red, green, blue, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-sim.glsl",
    "content": "// Texture with the particle profile\nuniform sampler2D u_texture;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle alpha value from the texture\n    float alpha = texture2D(u_texture, gl_PointCoord).a;\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(1.0), alpha);\n}\n"
  },
  {
    "path": "shaders/frag-sort.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureUniforms.glsl\")\n#pragma glslify: import(\"./imports/textureVaryings.glsl\")\n\n/*\n * Calculates the pixel resistance based on the pixel color\n */\nfloat calculage_pixel_resistance(vec3 pixel_color) {\n    return min(min(pixel_color.r, pixel_color.g), pixel_color.b);\n}\n\n/*\n * Calculates the pixel weight based on the pixel color\n */\nfloat calculage_pixel_weight(vec3 pixel_color) {\n    return dot(pixel_color, vec3(1.0, -1.0, -1.0));\n}\n\n/*\n * Swaps the current pixel color with the color bellow if the pixel bellow is\n * lighter\n */\nvec3 swap_color_bellow(vec2 uv, float uv_min, float uv_max, float stop_value) {\n    // Get the texture uv coordinates of the pixel bellow\n    vec2 uv_bellow = uv + vec2(0.0, -1.0 / u_resolution.y);\n\n    // Make sure we stay inside the texture block limits\n    if (uv_bellow.y < uv_min || uv.y >= uv_max) {\n        uv_bellow = uv;\n    }\n\n    // Get the pixel colors\n    vec3 color = texture2D(u_texture, uv).rgb;\n    vec3 color_bellow = texture2D(u_texture, uv_bellow).rgb;\n\n    // Get the pixel resistances\n    float resistance = calculage_pixel_resistance(color);\n    float resistance_bellow = calculage_pixel_resistance(color_bellow);\n\n    // Swap the colors only if the resistances are lower than the stop value\n    if (resistance < stop_value && resistance_bellow < stop_value) {\n        // Get the pixel weights\n        float weight = calculage_pixel_weight(color);\n        float weight_bellow = calculage_pixel_weight(color_bellow);\n\n        // Swap the color if the pixel bellow is lighter\n        if (weight > weight_bellow) {\n            color = color_bellow;\n        }\n    }\n\n    return color;\n}\n\n/*\n * Swaps the current pixel color with the color above if the pixel above is\n * heavier\n */\nvec3 swap_color_above(vec2 uv, float uv_min, float uv_max, float stop_value) {\n    // Get the texture uv coordinates of the pixel above\n    vec2 uv_above = uv + vec2(0.0, 1.0 / u_resolution.y);\n\n    // Make sure we stay inside the texture block limits\n    if (uv.y < uv_min || uv_above.y >= uv_max) {\n        uv_above = uv;\n    }\n\n    // Get the pixel colors\n    vec3 color = texture2D(u_texture, uv).rgb;\n    vec3 color_above = texture2D(u_texture, uv_above).rgb;\n\n    // Get the pixel resistances\n    float resistance = calculage_pixel_resistance(color);\n    float resistance_above = calculage_pixel_resistance(color_above);\n\n    // Swap the colors only if the resistances are lower than the stop value\n    if (resistance < stop_value && resistance_above < stop_value) {\n        // Get the pixel weights\n        float weight = calculage_pixel_weight(color);\n        float weight_above = calculage_pixel_weight(color_above);\n\n        // Swap the color if the pixel above is heavier\n        if (weight < weight_above) {\n            color = color_above;\n        }\n    }\n\n    return color;\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Set the sorting parameters using the mouse relative position\n    float n_steps = floor(10.0 * u_mouse.y / u_resolution.y);\n    float uv_min = floor(n_steps * v_uv.y) / n_steps;\n    float uv_max = min(uv_min + 1.0 / n_steps, 1.0);\n    float stop_value = u_mouse.x / u_resolution.x;\n\n    // Check if we are in an even pixel row\n    bool even_row = mod(floor(gl_FragCoord.y), 2.0) == 0.0;\n\n    // Calculate the new pixel color\n    vec3 pixel_color;\n\n    if (mod(u_frame, 2.0) == 0.0) {\n        if (even_row) {\n            pixel_color = swap_color_bellow(v_uv, uv_min, uv_max, stop_value);\n        } else {\n            pixel_color = swap_color_above(v_uv, uv_min, uv_max, stop_value);\n        }\n    } else {\n        if (even_row) {\n            pixel_color = swap_color_above(v_uv, uv_min, uv_max, stop_value);\n        } else {\n            pixel_color = swap_color_bellow(v_uv, uv_min, uv_max, stop_value);\n        }\n    }\n\n    // Fragment shader output\n    gl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-sphere.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/commonVaryings3d.glsl\")\n#pragma glslify: calculateNormal = require(\"./requires/calculateNormal\")\n#pragma glslify: diffuseFactor = require(\"./requires/diffuseFactor\")\n\n// The sphere radius\nuniform float u_radius;\n\n// Varying containing the sphere elevation\nvarying float v_elevation;\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new normal vector\n\tvec3 new_normal = calculateNormal(v_position);\n\n\t// Use the mouse position to define the light direction\n\tfloat min_resolution = min(u_resolution.x, u_resolution.y);\n\tvec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.25);\n\n\t// Set the default surface color\n\tvec3 surface_color = vec3(clamp(0.0, 1.0, 5.0*(v_elevation - u_radius)/u_radius), 0.3, 0.3);\n\n\t// Apply the light diffusion factor\n\tsurface_color *= diffuseFactor(new_normal, light_direction);\n\n\t// Fragment shader output\n\tgl_FragColor = vec4(surface_color, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-stippling-pos.glsl",
    "content": "// Simulation uniforms\nuniform float u_dt;\nuniform float u_nActiveParticles;\n\n// Simulation constants\nconst float width = resolution.x;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Get the particle current position and velocity\n    vec3 position = texture2D(u_positionTexture, uv).xyz;\n    vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n    // Check if the particle is one of the active particles\n    if ((gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * width < u_nActiveParticles) {\n        // Return the updated particle position\n        gl_FragColor = vec4(position + u_dt * velocity, 1.0);\n    } else {\n        // Return the original particle position\n        gl_FragColor = vec4(position, 1.0);\n    }\n}\n"
  },
  {
    "path": "shaders/frag-stippling-vel.glsl",
    "content": "// Simulation uniforms\nuniform float u_dt;\nuniform float u_nActiveParticles;\nuniform sampler2D u_bgTexture;\nuniform vec2 u_textureOffset;\n\n// Simulation constants\nconst float width = resolution.x;\nconst float height = resolution.y;\nconst float nParticles = width * height;\n\n// Softening factor. This is required to avoid high acceleration values when\n// two particles get too close\nconst float softening = 0.03;\n\n/*\n * Returns the texture background color at the given position\n */\nvec3 get_background_color(vec3 position) {\n    return texture2D(u_bgTexture, (position.xy + u_textureOffset) / (2.0 * u_textureOffset)).rgb;\n}\n\n/*\n * Calculates the charge size for the given background color\n */\nfloat calculate_charge_size(vec3 bgColor) {\n    return 0.045 + 0.03 * pow(dot(bgColor, vec3(1.0)), 2.0);\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle texture position\n    vec2 uv = gl_FragCoord.xy / resolution;\n\n    // Check if the particle is one of the active particles\n    if ((gl_FragCoord.x - 0.5) + (gl_FragCoord.y - 0.5) * width < u_nActiveParticles) {\n        // Get the particle current position\n        vec3 position = texture2D(u_positionTexture, uv).xyz;\n\n        // Get the particle charge size based on the background color\n        vec3 bgColor = get_background_color(position);\n        float chargeSize = calculate_charge_size(bgColor);\n\n        // Loop over all the particles and calculate the total repulsion force\n        vec3 totalForce = vec3(0.0);\n\n        for (float i = 0.0; i < nParticles; i++) {\n            // Consider only active particles\n            if (i >= u_nActiveParticles) {\n                break;\n            }\n\n            // Get the position of the repulsing particle\n            vec2 particleUv = vec2(mod(i, width) + 0.5, floor(i / width) + 0.5) / resolution;\n            vec3 particlePosition = texture2D(u_positionTexture, particleUv).xyz;\n\n            // Get the repulsing particle charge size based on the background color\n            vec3 particleBgColor = get_background_color(particlePosition);\n            float particleChargeSize = calculate_charge_size(particleBgColor);\n\n            // Calculate the total charge size\n            float totalChargeSize = chargeSize + particleChargeSize;\n\n            // Calculate the force direction\n            vec3 forceDirection = -(particlePosition - position);\n\n            // Calculate the particle distance\n            float distance = length(forceDirection);\n\n            // Check that we are not comparing the particle with itself (zero\n            // distance) and that the distance is smaller than the total\n            // charge size\n            if (distance != 0.0 && distance < totalChargeSize) {\n                // Add the particle repulsion force\n                totalForce += 0.03 * pow(totalChargeSize / (distance + softening), 2.0) * (forceDirection / distance);\n            }\n        }\n\n        // Return the new particle velocity\n        gl_FragColor = vec4(u_dt * totalForce, 1.0);\n    } else {\n        // Return the original particle velocity\n        gl_FragColor = texture2D(u_velocityTexture, uv);\n    }\n}\n"
  },
  {
    "path": "shaders/frag-stippling.glsl",
    "content": "// Texture with the particle profile\nuniform sampler2D u_texture;\n\n/*\n * The main program\n */\nvoid main() {\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(0.0), texture2D(u_texture, gl_PointCoord).a);\n}\n"
  },
  {
    "path": "shaders/frag-stripes.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/commonVaryings3d.glsl\")\n#pragma glslify: diffuseFactor = require(\"./requires/diffuseFactor\")\n\n/*\n * The main program\n */\nvoid main() {\n    // Use the mouse position to define the light direction\n    float min_resolution = min(u_resolution.x, u_resolution.y);\n    vec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.5);\n\n    // Calculate the light diffusion factor\n    float df = diffuseFactor(v_normal, light_direction);\n\n    // Calculate the surface color\n    float surface_color = df;\n\n    // Don't paint the pixels between the stripes\n    if (cos(2.0 * v_position.y + 3.0 * u_time) < 0.0) {\n        discard;\n    }\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(surface_color), 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-tile.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: square = require(\"./requires/shapes/square\")\n#pragma glslify: rectangle = require(\"./requires/shapes/rectangle\")\n#pragma glslify: circle = require(\"./requires/shapes/circle\")\n#pragma glslify: ellipse = require(\"./requires/shapes/ellipse\")\n#pragma glslify: lineSegment = require(\"./requires/shapes/lineSegment\")\n#pragma glslify: rotate = require(\"./requires/rotate2d\")\n\n/*\n * The main program\n */\nvoid main() {\n    // Set the background color\n    vec3 pixel_color = vec3(0.0);\n\n    // Divide the screen in a grid\n    vec2 grid1_pos = mod(gl_FragCoord.xy, 250.0);\n\n    // Add a blue square to each grid element\n    pixel_color = mix(pixel_color, vec3(0.3, 0.4, 1.0), square(grid1_pos, vec2(5.0, 5.0), 150.0));\n\n    // Add a red circle to each grid element\n    pixel_color = mix(pixel_color, vec3(1.0, 0.4, 0.3), circle(grid1_pos, vec2(0.0, 0.0), 80.0));\n\n    // Add ten grey lines to each grid element\n    for (float i = 0.0; i < 10.0; ++i) {\n        pixel_color = mix(pixel_color, vec3(0.8),\n                lineSegment(grid1_pos, vec2(10.0, -10.0 * i), vec2(150.0, 100.0 - 10.0 * i), 4.0));\n    }\n\n    // Apply some rotations to the grid\n    grid1_pos -= 100.0;\n    grid1_pos = rotate(u_time) * grid1_pos;\n    grid1_pos += 100.0;\n    grid1_pos -= 60.0;\n    grid1_pos = rotate(0.66 * u_time) * grid1_pos;\n    grid1_pos += 60.0;\n\n    // Draw a green rectangle to each grid element\n    pixel_color = mix(pixel_color, vec3(0.3, 0.9, 0.3), rectangle(grid1_pos, vec2(60.0, 50.0), vec2(40.0, 20)));\n\n    // Define a second rotated grid\n    vec2 grid2_pos = mod(rotate(radians(45.0)) * gl_FragCoord.xy, 100.0);\n\n    // Add a white circle to each grid element\n    pixel_color = mix(pixel_color, vec3(1.0), circle(grid2_pos, vec2(50.0, 50.0), 20.0));\n\n    // Fragment shader output\n    gl_FragColor = vec4(pixel_color, 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-toon.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/commonVaryings3d.glsl\")\n#pragma glslify: diffuseFactor = require(\"./requires/diffuseFactor\")\n\n/*\n * The main program\n */\nvoid main() {\n    // Use the mouse position to define the light direction\n    float min_resolution = min(u_resolution.x, u_resolution.y);\n    vec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.5);\n\n    // Calculate the light diffusion factor\n    float df = diffuseFactor(v_normal, light_direction);\n\n    // Define the toon shading steps\n    float nSteps = 4.0;\n    float step = sqrt(df) * nSteps;\n    step = (floor(step) + smoothstep(0.48, 0.52, fract(step))) / nSteps;\n\n    // Calculate the surface color\n    float surface_color = step * step;\n\n    // Fragment shader output\n    gl_FragColor = vec4(vec3(surface_color), 1.0);\n}\n"
  },
  {
    "path": "shaders/frag-wave.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/commonVaryings3d.glsl\")\n#pragma glslify: diffuseFactor = require(\"./requires/diffuseFactor\")\n\n/*\n * The main program\n */\nvoid main() {\n    // Use the mouse position to define the light direction\n    float min_resolution = min(u_resolution.x, u_resolution.y);\n    vec3 light_direction = -vec3((u_mouse - 0.5 * u_resolution) / min_resolution, 0.25);\n\n    // Set the surface color\n    vec3 surface_color = vec3(0.5 + 0.5 * cos(2.0 * v_position.y + 3.0 * u_time));\n\n    // Apply the light diffusion factor\n    surface_color *= diffuseFactor(v_normal, light_direction);\n\n    // Fragment shader output\n    gl_FragColor = vec4(surface_color, 1.0);\n}\n"
  },
  {
    "path": "shaders/imports/commonUniforms.glsl",
    "content": "// Common uniforms\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\nuniform float u_frame;\n"
  },
  {
    "path": "shaders/imports/commonVaryings3d.glsl",
    "content": "// Common varyings\nvarying vec3 v_position;\nvarying vec3 v_normal;\n"
  },
  {
    "path": "shaders/imports/textureUniforms.glsl",
    "content": "// Texture uniforms\nuniform sampler2D u_texture;\n"
  },
  {
    "path": "shaders/imports/textureVaryings.glsl",
    "content": "// Texture varyings\nvarying vec2 v_uv;\n"
  },
  {
    "path": "shaders/requires/calculateNormal.glsl",
    "content": "/*\n *  Calculates the normal vector at the given position\n *\n *  Uses this fix for some mobiles:\n *  https://stackoverflow.com/questions/20272272/standard-derivatives-from-fragment-shader-dfdx-dfdy-dont-run-correctly-in-a\n */\nvec3 calculateNormal(vec3 position) {\n    vec3 fdx = vec3(dFdx(position.x), dFdx(position.y), dFdx(position.z));\n    vec3 fdy = vec3(dFdy(position.x), dFdy(position.y), dFdy(position.z));\n    vec3 normal = normalize(cross(fdx, fdy));\n\n    if (!gl_FrontFacing) {\n        normal = -normal;\n    }\n\n    return normal;\n}\n\n#pragma glslify: export(calculateNormal)\n"
  },
  {
    "path": "shaders/requires/classicNoise2d.glsl",
    "content": "/*\n * GLSL textureless classic 2D noise \"cnoise\",\n * with an RSL-style periodic variant \"pnoise\".\n * Author:  Stefan Gustavson (stefan.gustavson@liu.se)\n * Version: 2011-08-22\n *\n * Many thanks to Ian McEwan of Ashima Arts for the\n * ideas for permutation and gradient selection.\n *\n * Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n * Distributed under the MIT license. See LICENSE file.\n * https://github.com/stegu/webgl-noise\n */\n\nvec4 mod289(vec4 x) {\n    return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x) {\n    return mod289(((x * 34.0) + 1.0) * x);\n}\n\nvec4 taylorInvSqrt(vec4 r) {\n    return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nvec2 fade(vec2 t) {\n    return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\n\nfloat cnoise(vec2 P) {\n    vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n    vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n    Pi = mod289(Pi);\n    vec4 ix = Pi.xzxz;\n    vec4 iy = Pi.yyww;\n    vec4 fx = Pf.xzxz;\n    vec4 fy = Pf.yyww;\n\n    vec4 i = permute(permute(ix) + iy);\n\n    vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0;\n    vec4 gy = abs(gx) - 0.5;\n    vec4 tx = floor(gx + 0.5);\n    gx = gx - tx;\n\n    vec2 g00 = vec2(gx.x, gy.x);\n    vec2 g10 = vec2(gx.y, gy.y);\n    vec2 g01 = vec2(gx.z, gy.z);\n    vec2 g11 = vec2(gx.w, gy.w);\n\n    vec4 norm = taylorInvSqrt(vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n    g00 *= norm.x;\n    g01 *= norm.y;\n    g10 *= norm.z;\n    g11 *= norm.w;\n\n    float n00 = dot(g00, vec2(fx.x, fy.x));\n    float n10 = dot(g10, vec2(fx.y, fy.y));\n    float n01 = dot(g01, vec2(fx.z, fy.z));\n    float n11 = dot(g11, vec2(fx.w, fy.w));\n\n    vec2 fade_xy = fade(Pf.xy);\n    vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n    float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n    return 2.3 * n_xy;\n}\n\n#pragma glslify: export(cnoise)\n"
  },
  {
    "path": "shaders/requires/diffuseFactor.glsl",
    "content": "/*\n *  Calculates the diffuse factor produced by the light illumination\n */\nfloat diffuseFactor(vec3 normal, vec3 light_direction) {\n    float df = dot(normalize(normal), normalize(light_direction));\n\n    if (gl_FrontFacing) {\n        df = -df;\n    }\n\n    return max(0.0, df);\n}\n\n#pragma glslify: export(diffuseFactor)\n"
  },
  {
    "path": "shaders/requires/kernels/edgeKernel.glsl",
    "content": "// Edge detection kernel\nconst mat3 kernel = mat3(-1.0, -1.0, -1.0,\n                         -1.0, +8.0, -1.0,\n                         -1.0, -1.0, -1.0);\n\n#pragma glslify: export(kernel)\n"
  },
  {
    "path": "shaders/requires/kernels/gaussianKernel.glsl",
    "content": "// Approximate gaussian kernel\nconst mat3 kernel = mat3(1.0 / 16.0, 2.0 / 16.0, 1.0 / 16.0,\n                         2.0 / 16.0, 4.0 / 16.0, 2.0 / 16.0,\n                         1.0 / 16.0, 2.0 / 16.0, 1.0 / 16.0);\n\n#pragma glslify: export(kernel)\n"
  },
  {
    "path": "shaders/requires/laplacian.glsl",
    "content": "/*\n *  Calculates the Laplacian at a given texture position\n */\nvec4 laplacian(vec2 uv, sampler2D texture, vec2 texture_size) {\n    // Calculate the texture steps\n    float du = 1.0 / texture_size.x;\n    float dv = 1.0 / texture_size.y;\n\n    // Calculate the laplacian\n    vec4 lap = -texture2D(texture, uv);\n    lap += 0.2 * texture2D(texture, uv + vec2(-du, 0.0));\n    lap += 0.2 * texture2D(texture, uv + vec2(du, 0.0));\n    lap += 0.2 * texture2D(texture, uv + vec2(0.0, -dv));\n    lap += 0.2 * texture2D(texture, uv + vec2(0.0, dv));\n    lap += 0.05 * texture2D(texture, uv + vec2(-du, -dv));\n    lap += 0.05 * texture2D(texture, uv + vec2(du, -dv));\n    lap += 0.05 * texture2D(texture, uv + vec2(du, dv));\n    lap += 0.05 * texture2D(texture, uv + vec2(-du, dv));\n\n    return lap;\n}\n\n#pragma glslify: export(laplacian)\n"
  },
  {
    "path": "shaders/requires/noise1d.glsl",
    "content": "#pragma glslify: random1d = require(\"./random1d\")\n\n/*\n * Pseudo-noise generator\n *\n * Credits:\n * https://thebookofshaders.com/11/\n */\nhighp float noise1d(float value) {\n\thighp float i = floor(value);\n\thighp float f = fract(value);\n\treturn mix(random1d(i), random1d(i + 1.0), smoothstep(0.0, 1.0, f));\n}\n\n#pragma glslify: export(noise1d)\n"
  },
  {
    "path": "shaders/requires/random1d.glsl",
    "content": "/*\n * Random number generator with a float seed\n *\n * Credits:\n * http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0\n */\nhighp float random1d(float dt) {\n    highp float c = 43758.5453;\n    highp float sn = mod(dt, 3.14);\n    return fract(sin(sn) * c);\n}\n\n#pragma glslify: export(random1d)\n"
  },
  {
    "path": "shaders/requires/random2d.glsl",
    "content": "/*\n * Random number generator with a vec2 seed\n *\n * Credits:\n * http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0\n * https://github.com/mattdesl/glsl-random\n */\nhighp float random2d(vec2 co) {\n    highp float a = 12.9898;\n    highp float b = 78.233;\n    highp float c = 43758.5453;\n    highp float dt = dot(co.xy, vec2(a, b));\n    highp float sn = mod(dt, 3.14);\n    return fract(sin(sn) * c);\n}\n\n#pragma glslify: export(random2d)\n"
  },
  {
    "path": "shaders/requires/rotate2d.glsl",
    "content": "/*\n * Returns a rotation matrix for the given angle\n */\nmat2 rotate(float angle) {\n    return mat2(cos(angle), -sin(angle), sin(angle), cos(angle));\n}\n\n#pragma glslify: export(rotate)\n"
  },
  {
    "path": "shaders/requires/shapes/circle.glsl",
    "content": "/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the circle\n */\nfloat circle(vec2 pixel, vec2 center, float radius) {\n    return 1.0 - smoothstep(radius - 1.0, radius + 1.0, length(pixel - center));\n}\n\n#pragma glslify: export(circle)\n"
  },
  {
    "path": "shaders/requires/shapes/ellipse.glsl",
    "content": "/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the ellipse\n */\nfloat ellipse(vec2 pixel, vec2 center, vec2 radii) {\n    vec2 relative_pos = pixel - center;\n    float dist = length(relative_pos);\n    float r = radii.x * radii.y * dist / length(radii.yx * relative_pos);\n\n    return 1.0 - smoothstep(r - 1.0, r + 1.0, dist);\n}\n\n#pragma glslify: export(ellipse)\n"
  },
  {
    "path": "shaders/requires/shapes/horizontalLine.glsl",
    "content": "/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the horizontal line\n */\nfloat horizontalLine(vec2 pixel, float y_pos, float width) {\n    return 1.0 - smoothstep(-1.0, 1.0, abs(pixel.y - y_pos) - 0.5 * width);\n}\n\n#pragma glslify: export(horizontalLine)\n"
  },
  {
    "path": "shaders/requires/shapes/line.glsl",
    "content": "/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the line\n */\nfloat line(vec2 pixel, vec2 point, vec2 line_dir, float width) {\n    vec2 pixel_dir = pixel - point;\n    float projected_dist = dot(pixel_dir, normalize(line_dir));\n    float tanjential_dist = sqrt(dot(pixel_dir, pixel_dir) - projected_dist * projected_dist);\n\n    return 1.0 - smoothstep(-1.0, 1.0, tanjential_dist - 0.5 * width);\n}\n\n#pragma glslify: export(line)\n"
  },
  {
    "path": "shaders/requires/shapes/lineSegment.glsl",
    "content": "/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the line segment\n */\nfloat lineSegment(vec2 pixel, vec2 start, vec2 end, float width) {\n    vec2 pixel_dir = pixel - start;\n    vec2 line_dir = end - start;\n    float line_length = length(line_dir);\n    float projected_dist = dot(pixel_dir, line_dir) / line_length;\n    float tanjential_dist = sqrt(dot(pixel_dir, pixel_dir) - projected_dist * projected_dist);\n\n    return smoothstep(-1.0, 1.0, projected_dist) * smoothstep(-1.0, 1.0, line_length - projected_dist)\n            * (1.0 - smoothstep(-1.0, 1.0, tanjential_dist - 0.5 * width));\n}\n\n#pragma glslify: export(lineSegment)\n"
  },
  {
    "path": "shaders/requires/shapes/rectangle.glsl",
    "content": "/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the rectangle\n */\nfloat rectangle(vec2 pixel, vec2 bottom_left, vec2 sides) {\n    vec2 top_right = bottom_left + sides;\n\n    return smoothstep(-1.0, 1.0, pixel.x - bottom_left.x) * smoothstep(-1.0, 1.0, pixel.y - bottom_left.y)\n            * smoothstep(-1.0, 1.0, top_right.x - pixel.x) * smoothstep(-1.0, 1.0, top_right.y - pixel.y);\n}\n\n#pragma glslify: export(rectangle)\n"
  },
  {
    "path": "shaders/requires/shapes/square.glsl",
    "content": "/*\n * Returns a value between 1 and 0 that indicates if the pixel is inside the square\n */\nfloat square(vec2 pixel, vec2 bottom_left, float side) {\n    vec2 top_right = bottom_left + side;\n\n    return smoothstep(-1.0, 1.0, pixel.x - bottom_left.x) * smoothstep(-1.0, 1.0, pixel.y - bottom_left.y)\n            * smoothstep(-1.0, 1.0, top_right.x - pixel.x) * smoothstep(-1.0, 1.0, top_right.y - pixel.y);\n}\n\n#pragma glslify: export(square)\n"
  },
  {
    "path": "shaders/requires/simplexNoise2d.glsl",
    "content": "/*\n * Description : Array and textureless GLSL 2D simplex noise function.\n *      Author : Ian McEwan, Ashima Arts.\n *  Maintainer : stegu\n *     Lastmod : 20110822 (ijm)\n *     License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n *               Distributed under the MIT License. See LICENSE file.\n *               https://github.com/ashima/webgl-noise\n *               https://github.com/stegu/webgl-noise\n */\n\nvec3 mod289(vec3 x) {\n    return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec2 mod289(vec2 x) {\n    return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec3 permute(vec3 x) {\n    return mod289(((x * 34.0) + 1.0) * x);\n}\n\nfloat snoise(vec2 v) {\n    const vec4 C = vec4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439);\n\n    // First corner\n    vec2 i = floor(v + dot(v, C.yy));\n    vec2 x0 = v - i + dot(i, C.xx);\n\n    // Other corners\n    vec2 i1;\n    i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n    vec4 x12 = x0.xyxy + C.xxzz;\n    x12.xy -= i1;\n\n    // Permutations\n    i = mod289(i);\n    vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0)) + i.x + vec3(0.0, i1.x, 1.0));\n    vec3 m = max(0.5 - vec3(dot(x0, x0), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), 0.0);\n    m = m * m;\n    m = m * m;\n\n    // Gradients: 41 points uniformly over a line, mapped onto a diamond.\n    vec3 x = 2.0 * fract(p * C.www) - 1.0;\n    vec3 h = abs(x) - 0.5;\n    vec3 ox = floor(x + 0.5);\n    vec3 a0 = x - ox;\n\n    // Normalise gradients implicitly by scaling m\n    m *= 1.79284291400159 - 0.85373472095314 * (a0 * a0 + h * h);\n\n    // Compute final noise value at P\n    vec3 g;\n    g.x = a0.x * x0.x + h.x * x0.y;\n    g.yz = a0.yz * x12.xz + h.yz * x12.yw;\n    return 130.0 * dot(m, g);\n}\n\n#pragma glslify: export(snoise)\n"
  },
  {
    "path": "shaders/vert-2d.glsl",
    "content": "/*\n * The main program\n */\nvoid main() {\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n"
  },
  {
    "path": "shaders/vert-3d.glsl",
    "content": "#pragma glslify: import(\"./imports/commonVaryings3d.glsl\")\n\n/*\n * The main program\n */\nvoid main() {\n    // Save the varyings\n    v_position = position;\n    v_normal = normalize(normalMatrix * normal);\n\n    // Vertex shader output\n    gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"
  },
  {
    "path": "shaders/vert-attraction.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/commonVaryings3d.glsl\")\n\n/*\n * The main program\n */\nvoid main() {\n\t// Define the attractor position using spherical coordinates\n\tfloat r = 15.0;\n\tfloat theta = 0.87 * u_time;\n\tfloat phi = 0.63 * u_time;\n\tvec3 attractor_position = r * vec3(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));\n\n\t// Calculate the new vertex position to simulate attraction effect\n\tvec3 effect_direction = attractor_position - position;\n\tfloat effect_intensity = min(30.0 * pow(length(effect_direction), -2.0), 1.0);\n\tvec3 new_position = position + effect_intensity * effect_direction;\n\n\t// Calculate the modelview position\n\tvec4 mv_position = modelViewMatrix * vec4(new_position, 1.0);\n\n\t// Save the varyings\n\tv_position = mv_position.xyz;\n\tv_normal = normalize(normalMatrix * normal);\n\n\t// Vertex shader output\n\tgl_Position = projectionMatrix * mv_position;\n}\n"
  },
  {
    "path": "shaders/vert-debug.glsl",
    "content": "attribute float a_index;\n\nuniform float u_width;\nuniform float u_height;\nuniform sampler2D u_positionTexture;\n\nvoid main() {\n    vec2 uv = vec2((mod(a_index, u_width) + 0.5) / u_width, (floor(a_index / u_width) + 0.5) / u_height);\n    gl_PointSize = 2.0;\n    gl_Position = projectionMatrix * modelViewMatrix * texture2D(u_positionTexture, uv);\n}\n"
  },
  {
    "path": "shaders/vert-deform.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/commonVaryings3d.glsl\")\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new vertex position to simulate a wave effect\n\tfloat effect_intensity = 2.0 * u_mouse.x / u_resolution.x;\n\tvec3 new_position = position + effect_intensity * (0.5 + 0.5 * cos(position.x + 4.0 * u_time)) * normal;\n\n\t// Calculate the modelview position\n\tvec4 mv_position = modelViewMatrix * vec4(new_position, 1.0);\n\n\t// Save the varyings\n\tv_position = mv_position.xyz;\n\tv_normal = normalize(normalMatrix * normal);\n\n\t// Vertex shader output\n\tgl_Position = projectionMatrix * mv_position;\n}\n"
  },
  {
    "path": "shaders/vert-dla.glsl",
    "content": "// Particle index attribute\nattribute float a_index;\n\n// Simulation uniforms\nuniform float u_width;\nuniform float u_height;\nuniform float u_particleSize;\nuniform sampler2D u_positionTexture;\n\n// Varying with the aggregation information\nvarying float v_aggregation;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle model view position\n    vec2 uv = vec2((mod(a_index, u_width) + 0.5) / u_width, (floor(a_index / u_width) + 0.5) / u_height);\n    vec4 position = texture2D(u_positionTexture, uv);\n    vec4 mvPosition = modelViewMatrix * vec4(position.xyz, 1.0);\n\n    // Pass the aggregation information to the fragment shader\n    v_aggregation = position.w;\n\n    // Vertex shader output\n    gl_PointSize = v_aggregation < 0.0 ? -u_particleSize / mvPosition.z : -0.5 * u_particleSize / mvPosition.z;\n    gl_Position = projectionMatrix * mvPosition;\n}\n"
  },
  {
    "path": "shaders/vert-filters.glsl",
    "content": "#pragma glslify: import(\"./imports/textureVaryings.glsl\")\n\n/*\n * The main program\n */\nvoid main() {\n    // Calculate the varyings\n    v_uv = uv;\n\n    // Vertex shader output\n    gl_Position = vec4(position, 1.0);\n}\n"
  },
  {
    "path": "shaders/vert-mountains.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/commonVaryings3d.glsl\")\n#pragma glslify: noise = require(\"./requires/classicNoise2d\")\n\n// The plane tile size, the flying speed and the maximum mountain height\nuniform float u_tileSize;\nuniform float u_speed;\nuniform float u_maxHeight;\n\n// Varying containing the terrain elevation\nvarying float v_elevation;\n\n// Calculates the vertex displaced position\nvec3 getDisplacedPosition(vec3 position) {\n\t// Calculate the total flying distance\n\tfloat distance = u_speed * u_time;\n\n\t// Calculate the vertex horizontal shift\n\tfloat h_shift = mod(distance, u_tileSize);\n\n\t// Calculate the vertex vertical shift\n\tfloat v_shift = u_maxHeight * noise(0.4 * floor(vec2(position.x, position.z - distance) / u_tileSize));\n\n\t// Flatten the bottom to simulate the lakes\n\tv_shift = max(-0.8 * u_maxHeight, v_shift);\n\n\treturn position + vec3(0.0, v_shift, h_shift);\n}\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new vertex position\n\tvec3 new_position = getDisplacedPosition(position);\n\n\t// Calculate the modelview position\n\tvec4 mv_position = modelViewMatrix * vec4(new_position, 1.0);\n\n\t// Save the varyings\n\tv_position = mv_position.xyz;\n\tv_elevation = 0.5 * (u_maxHeight + new_position.y);\n\n\t// Vertex shader output\n\tgl_Position = projectionMatrix * mv_position;\n}\n"
  },
  {
    "path": "shaders/vert-repulsion.glsl",
    "content": "// Particle index attribute\nattribute float a_index;\n\n// Simulation uniforms\nuniform float u_width;\nuniform float u_height;\nuniform float u_particleSize;\nuniform float u_nActiveParticles;\nuniform sampler2D u_positionTexture;\nuniform sampler2D u_velocityTexture;\n\n// Particle color varying\nvarying vec3 v_color;\n\n/*\n * The main program\n */\nvoid main() {\n    // Check if the particle is one of the active particles\n    if (a_index < u_nActiveParticles) {\n        // Get the particle position and velocity\n        vec2 uv = vec2((mod(a_index, u_width) + 0.5) / u_width, (floor(a_index / u_width) + 0.5) / u_height);\n        vec3 position = texture2D(u_positionTexture, uv).xyz;\n        vec3 velocity = texture2D(u_velocityTexture, uv).xyz;\n\n        // Calculate the model view position\n        vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n\n        // Calculate the particle color based on its velocity\n        v_color = mix(vec3(1.0, 0.0, 0.0), vec3(1.0, 1.0, 0.0), 20.0 * length(velocity));\n\n        // Vertex shader output\n        gl_PointSize = -u_particleSize / mvPosition.z;\n        gl_Position = projectionMatrix * mvPosition;\n    } else {\n        // Vertex shader output\n        gl_PointSize = 0.0;\n        gl_Position = vec4(-1000000.0);\n    }\n}\n"
  },
  {
    "path": "shaders/vert-sim.glsl",
    "content": "// Particle index attribute\nattribute float a_index;\n\n// Simulation uniforms\nuniform float u_width;\nuniform float u_height;\nuniform float u_particleSize;\nuniform sampler2D u_positionTexture;\n\n/*\n * The main program\n */\nvoid main() {\n    // Get the particle model view position\n    vec2 uv = vec2((mod(a_index, u_width) + 0.5) / u_width, (floor(a_index / u_width) + 0.5) / u_height);\n    vec4 mvPosition = modelViewMatrix * texture2D(u_positionTexture, uv);\n\n    // Vertex shader output\n    gl_PointSize = -u_particleSize / mvPosition.z;\n    gl_Position = projectionMatrix * mvPosition;\n}\n"
  },
  {
    "path": "shaders/vert-sphere.glsl",
    "content": "#pragma glslify: import(\"./imports/commonUniforms.glsl\")\n#pragma glslify: import(\"./imports/commonVaryings3d.glsl\")\n#pragma glslify: noise = require(\"./requires/classicNoise2d\")\n\n// The sphere radius\nuniform float u_radius;\n\n// Varying containing the sphere elevation\nvarying float v_elevation;\n\n// Calculates the vertex displaced position\nvec3 getDisplacedPosition(vec3 position) {\n\t// Calculate the vertex shift\n\tfloat shift = 2.0\n\t\t\t* noise(vec2(3.0 * cos(atan(position.z, position.x)), 2.0 * u_time + 3.0 * acos(position.y / u_radius)));\n\n\treturn position + normal * shift;\n}\n\n/*\n * The main program\n */\nvoid main() {\n\t// Calculate the new vertex position\n\tvec3 new_position = getDisplacedPosition(position);\n\n\t// Calculate the modelview position\n\tvec4 mv_position = modelViewMatrix * vec4(new_position, 1.0);\n\n\t// Save the varyings\n\tv_position = mv_position.xyz;\n\tv_elevation = length(new_position);\n\n\t// Vertex shader output\n\tgl_Position = projectionMatrix * mv_position;\n}\n"
  },
  {
    "path": "shaders/vert-stippling.glsl",
    "content": "// Particle index attribute\nattribute float a_index;\n\n// Simulation uniforms\nuniform float u_width;\nuniform float u_height;\nuniform float u_particleSize;\nuniform float u_nActiveParticles;\nuniform sampler2D u_positionTexture;\nuniform sampler2D u_bgTexture;\nuniform vec2 u_textureOffset;\n\n/*\n * Returns the texture background color at the given position\n */\nvec3 get_background_color(vec3 position) {\n    return texture2D(u_bgTexture, (position.xy + u_textureOffset) / (2.0 * u_textureOffset)).rgb;\n}\n\n/*\n * The main program\n */\nvoid main() {\n    // Check if the particle is one of the active particles\n    if (a_index < u_nActiveParticles) {\n        // Get the particle position\n        vec2 uv = vec2((mod(a_index, u_width) + 0.5) / u_width, (floor(a_index / u_width) + 0.5) / u_height);\n        vec3 position = texture2D(u_positionTexture, uv).xyz;\n\n        // Calculate the model view position\n        vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n\n        // Calculate the particle relative size based on the background texture color\n        vec3 bgColor = get_background_color(position);\n        float relativeSize = 1.0 - 0.3 * dot(bgColor, vec3(1.0));\n\n        // Vertex shader output\n        gl_PointSize = -u_particleSize * relativeSize / mvPosition.z;\n        gl_Position = projectionMatrix * mvPosition;\n    } else {\n        // Vertex shader output\n        gl_PointSize = 0.0;\n        gl_Position = vec4(-1000000.0);\n    }\n}\n"
  }
]