From e0ac7286a722a18bd29febaf2cd61fce7582116c Mon Sep 17 00:00:00 2001 From: Srinivasan Ramachandran Date: Thu, 13 Jun 2019 19:01:56 -0400 Subject: [PATCH] Adding free movements to items, and couple of updates to the docs --- .jshintrc | 125 + .npmignore | 2 + .project | 8 +- .settings/.jsdtscope | 7 + .settings/com.eclipsesource.jshint.ui.prefs | 4 + .settings/org.eclipse.wst.jsdt.core.prefs | 2 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + build/index.html | 2 +- build/js/bp3djs.js | 273 +- build/js/bp3djs.min.js | 2 +- docs/ast/source/blueprint.js.json | 286 +- .../source/floorplanner/floorplanner.js.json | 43323 ++++++++------ docs/ast/source/model/corner.js.json | 10234 ++-- docs/ast/source/model/floorplan.js.json | 47602 ++++++++-------- docs/ast/source/model/half_edge.js.json | 27212 +++++---- docs/badge.svg | 4 +- .../scripts/blueprint.js~BlueprintJS.html | 6 +- .../floorplanner.js~Floorplanner2D.html | 28 +- .../class/scripts/model/corner.js~Corner.html | 4 +- .../scripts/model/floorplan.js~Floorplan.html | 60 +- .../scripts/model/half_edge.js~HalfEdge.html | 879 +- docs/coverage.json | 43 +- docs/file/scripts/blueprint.js.html | 4 +- .../scripts/floorplanner/floorplanner.js.html | 35 +- docs/file/scripts/model/corner.js.html | 4 +- docs/file/scripts/model/floorplan.js.html | 11 +- docs/file/scripts/model/half_edge.js.html | 231 +- docs/index.json | 894 +- docs/lint.json | 52 +- docs/source.html | 34 +- package-lock.json | 35 +- package.json | 1 + src/scripts/blueprint.js | 4 +- src/scripts/items/floor_item.js | 1 + src/scripts/items/item.js | 7 +- src/scripts/items/wall_item.js | 1 + src/scripts/model/corner.js | 4 +- src/scripts/model/floorplan.js | 11 +- src/scripts/model/half_edge.js | 231 +- src/scripts/model/model.js | 2 +- src/scripts/model/scene.js | 6 +- src/scripts/three/controller.js | 15 + 43 files changed, 70321 insertions(+), 61370 deletions(-) create mode 100644 .jshintrc create mode 100644 .npmignore create mode 100644 .settings/.jsdtscope create mode 100644 .settings/com.eclipsesource.jshint.ui.prefs create mode 100644 .settings/org.eclipse.wst.jsdt.core.prefs create mode 100644 .settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 .settings/org.eclipse.wst.jsdt.ui.superType.name diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..6c1b23a --- /dev/null +++ b/.jshintrc @@ -0,0 +1,125 @@ +{ + // -------------------------------------------------------------------- + // JSHint Nodeclipse Configuration v0.18 + // Strict Edition with some relaxations and switch to Node.js, no `use strict` + // by Ory Band, Michael Haschke, Paul Verest + // https://github.com/Nodeclipse/nodeclipse-1/blob/master/org.nodeclipse.ui/templates/common-templates/.jshintrc + // JSHint Documentation is at http://www.jshint.com/docs/options/ + // JSHint Integration v0.9.10 comes with JSHInt 2.5.6 , see https://github.com/eclipsesource/jshint-eclipse + // -------------------------------------------------------------------- + // from https://gist.github.com/haschek/2595796 + // + // This is a options template for [JSHint][1], using [JSHint example][2] + // and [Ory Band's example][3] as basis and setting config values to + // be most strict: + // + // * set all enforcing options to true + // * set all relaxing options to false + // * set all environment options to false, except the node value + // * set all JSLint legacy options to false + // + // [1]: http://www.jshint.com/ + // [2]: https://github.com/jshint/node-jshint/blob/master/example/config.json //404 + // [3]: https://github.com/oryband/dotfiles/blob/master/jshintrc + // [4]: http://www.jshint.com/options/ + // + // @author http://michael.haschke.biz/ + // @license http://unlicense.org/ + + // == Enforcing Options =============================================== + // + // These options tell JSHint to be more strict towards your code. Use + // them if you want to allow only a safe subset of JavaScript, very + // useful when your codebase is shared with a big number of developers + // with different skill levels. Was all true. + + "bitwise" : true, // Prohibit bitwise operators (&, |, ^, etc.). + "curly" : true, // Require {} for every new block or scope. + "eqeqeq" : true, // Require triple equals i.e. `===`. + "forin" : true, // Tolerate `for in` loops without `hasOwnPrototype`. + "immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );` + "latedef" : true, // Prohibit variable use before definition. + "newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`. + "noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`. + "noempty" : true, // Prohibit use of empty blocks. + "nonew" : true, // Prohibit use of constructors for side-effects. + "plusplus" : false, // Prohibit use of `++` & `--`. //coding style related only + "regexp" : true, // Prohibit `.` and `[^...]` in regular expressions. + "undef" : true, // Require all non-global variables be declared before they are used. + "strict" : false, // Require `use strict` pragma in every file. + "trailing" : true, // Prohibit trailing whitespaces. + + // == Relaxing Options ================================================ + // + // These options allow you to suppress certain types of warnings. Use + // them only if you are absolutely positive that you know what you are + // doing. Was all false. + "asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons). + "boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments. + "debug" : false, // Allow debugger statements e.g. browser breakpoints. + "eqnull" : false, // Tolerate use of `== null`. + //"es5" : true, // Allow EcmaScript 5 syntax. // es5 is default https://github.com/jshint/jshint/issues/1411 + "esnext" : false, // Allow ES.next (ECMAScript 6) specific features such as `const` and `let`. + "evil" : false, // Tolerate use of `eval`. + "expr" : false, // Tolerate `ExpressionStatement` as Programs. + "funcscope" : false, // Tolerate declarations of variables inside of control structures while accessing them later from the outside. + "globalstrict" : false, // Allow global "use strict" (also enables 'strict'). + "iterator" : false, // Allow usage of __iterator__ property. + "lastsemic" : false, // Tolerat missing semicolons when the it is omitted for the last statement in a one-line block. + "laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons. + "laxcomma" : true, // Suppress warnings about comma-first coding style. + "loopfunc" : false, // Allow functions to be defined within loops. + "maxerr" : 100, // This options allows you to set the maximum amount of warnings JSHint will produce before giving up. Default is 50. + "multistr" : false, // Tolerate multi-line strings. + "onecase" : false, // Tolerate switches with just one case. + "proto" : false, // Tolerate __proto__ property. This property is deprecated. + "regexdash" : false, // Tolerate unescaped last dash i.e. `[-...]`. + "scripturl" : false, // Tolerate script-targeted URLs. + "smarttabs" : false, // Tolerate mixed tabs and spaces when the latter are used for alignmnent only. + "shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`. + "sub" : false, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`. + "supernew" : false, // Tolerate `new function () { ... };` and `new Object;`. + "validthis" : false, // Tolerate strict violations when the code is running in strict mode and you use this in a non-constructor function. + + // == Environments ==================================================== + // + // These options pre-define global variables that are exposed by + // popular JavaScript libraries and runtime environments—such as + // browser or node.js. TODO JSHint Documentation has more, but it is not clear since what JSHint version they appeared + "browser" : false, // Standard browser globals e.g. `window`, `document`. + "couch" : false, // Enable globals exposed by CouchDB. + "devel" : false, // Allow development statements e.g. `console.log();`. + "dojo" : false, // Enable globals exposed by Dojo Toolkit. + "jquery" : false, // Enable globals exposed by jQuery JavaScript library. + "mootools" : false, // Enable globals exposed by MooTools JavaScript framework. + "node" : true, // Enable globals available when code is running inside of the NodeJS runtime environment. + "nonstandard" : false, // Define non-standard but widely adopted globals such as escape and unescape. + "phantom" : false, //?since version? This option defines globals available when your core is running inside of the PhantomJS runtime environment. + "prototypejs" : false, // Enable globals exposed by Prototype JavaScript framework. + "rhino" : false, // Enable globals available when your code is running inside of the Rhino runtime environment. + "worker" : false, //?since version? This option defines globals available when your code is running inside of a Web Worker. + "wsh" : false, // Enable globals available when your code is running as a script for the Windows Script Host. + "yui" : false, //?since version? This option defines globals exposed by the YUI JavaScript framework. + + // == JSLint Legacy =================================================== + // + // These options are legacy from JSLint. Aside from bug fixes they will + // not be improved in any way and might be removed at any point. + "nomen" : false, // Prohibit use of initial or trailing underbars in names. + "onevar" : false, // Allow only one `var` statement per function. + "passfail" : false, // Stop on first error. + "white" : false, // Check against strict whitespace and indentation rules. + + // == Undocumented Options ============================================ + // + // While Michael have found these options in [example1][2] and [example2][3] (already gone 404) + // they are not described in the [JSHint Options documentation][4]. + + "predef" : [ // Extra globals. + //"exampleVar", + //"anotherCoolGlobal", + //"iLoveDouglas" + "Java", "JavaFX", "$ARG" //no effect + ] + //, "indent" : 2 // Specify indentation spacing +} diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..8ce442d --- /dev/null +++ b/.npmignore @@ -0,0 +1,2 @@ +.DS_Store +.*.md.html diff --git a/.project b/.project index e2d3760..9d955ee 100644 --- a/.project +++ b/.project @@ -5,16 +5,13 @@ - - org.python.pydev.PyDevBuilder - - - + com.eclipsesource.jshint.ui.builder + org.eclipse.wst.jsdt.core.javascriptValidator @@ -25,6 +22,5 @@ org.nodeclipse.ui.NodeNature org.eclipse.wst.jsdt.core.jsNature tern.eclipse.ide.core.ternnature - org.python.pydev.pythonNature diff --git a/.settings/.jsdtscope b/.settings/.jsdtscope new file mode 100644 index 0000000..ae607b1 --- /dev/null +++ b/.settings/.jsdtscope @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.settings/com.eclipsesource.jshint.ui.prefs b/.settings/com.eclipsesource.jshint.ui.prefs new file mode 100644 index 0000000..c0a3138 --- /dev/null +++ b/.settings/com.eclipsesource.jshint.ui.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +excluded=//*.json\:bower_components//*\:node_lib//*\:node_modules//* +included=//*.jjs\://*.js\://*.jshintrc\://*.mjs\://*.njs\://*.pjs\://*.vjs +projectSpecificOptions=true diff --git a/.settings/org.eclipse.wst.jsdt.core.prefs b/.settings/org.eclipse.wst.jsdt.core.prefs new file mode 100644 index 0000000..3beff51 --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +semanticValidation=disabled diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.container b/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..49c8cd4 --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.JRE_CONTAINER \ No newline at end of file diff --git a/.settings/org.eclipse.wst.jsdt.ui.superType.name b/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..11006e2 --- /dev/null +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Global \ No newline at end of file diff --git a/build/index.html b/build/index.html index 499832f..8845a70 100644 --- a/build/index.html +++ b/build/index.html @@ -190,7 +190,7 @@

diff --git a/build/js/bp3djs.js b/build/js/bp3djs.js index 94d8f64..a05fbce 100644 --- a/build/js/bp3djs.js +++ b/build/js/bp3djs.js @@ -49197,32 +49197,131 @@ var BP3DJS = (function (exports) { /** * Constructs a half edge. - * @param room The associated room. Instance of Room - * @param wall The corresponding wall. Instance of Wall - * @param front True if front side. Boolean value + * @param {Room} room The associated room. Instance of Room + * @param {Wall} wall The corresponding wall. Instance of Wall + * @param {boolean} front True if front side. Boolean value */ function HalfEdge(room, wall, front) { classCallCheck(this, HalfEdge); + /** The minimum point in space calculated from the bounds + * @property {Vector3} min The minimum point in space calculated from the bounds + * @type {Vector3} + * @see https://threejs.org/docs/#api/en/math/Vector3 + **/ var _this = possibleConstructorReturn(this, (HalfEdge.__proto__ || Object.getPrototypeOf(HalfEdge)).call(this)); _this.min = null; + + /** + * The maximum point in space calculated from the bounds + * @property {Vector3} max The maximum point in space calculated from the bounds + * @type {Vector3} + * @see https://threejs.org/docs/#api/en/math/Vector3 + **/ _this.max = null; + + /** + * The center of this half edge + * @property {Vector3} center The center of this half edge + * @type {Vector3} + * @see https://threejs.org/docs/#api/en/math/Vector3 + **/ _this.center = null; + /** + * Reference to a Room instance + * @property {Room} room Reference to a Room instance + * @type {Room} + **/ _this.room = room; + + /** + * Reference to a Wall instance + * @property {Wall} room Reference to a Wall instance + * @type {Wall} + **/ _this.wall = wall; + + /** + * Reference to the next halfedge instance connected to this + * @property {HalfEdge} next Reference to the next halfedge instance connected to this + * @type {HalfEdge} + **/ _this.next = null; + + /** + * Reference to the previous halfedge instance connected to this + * @property {HalfEdge} prev Reference to the previous halfedge instance connected to this + * @type {HalfEdge} + **/ _this.prev = null; + + /** + * The offset to maintain for the front and back walls from the midline of a wall + * @property {Number} offset The offset to maintain for the front and back walls from the midline of a wall + * @type {Number} + **/ _this.offset = 0.0; + + /** + * The height of a wall + * @property {Number} height The height of a wall + * @type {Number} + **/ _this.height = 0.0; + + /** + * The plane mesh that will be used for checking intersections of wall items + * @property {Mesh} plane The plane mesh that will be used for checking intersections of wall items + * @type {Mesh} + * @see https://threejs.org/docs/#api/en/objects/Mesh + */ _this.plane = null; + + /** + * The interior transformation matrix that contains the homogeneous transformation of the plane based on the two corner positions of the wall + * @property {Matrix4} interiorTransform The interior transformation matrix that contains the homogeneous transformation of the plane based on the two corner positions of the wall + * @type {Matrix4} + * @see https://threejs.org/docs/#api/en/math/Matrix4 + */ _this.interiorTransform = new Matrix4(); + + /** + * The inverse of the interior transformation matrix that contains the homogeneous transformation of the plane based on the two corner positions of the wall + * @property {Matrix4} invInteriorTransform The inverse of the interior transformation matrix that contains the homogeneous transformation of the plane based on the two corner positions of the wall + * @type {Matrix4} + * @see https://threejs.org/docs/#api/en/math/Matrix4 + */ _this.invInteriorTransform = new Matrix4(); + + /** + * The exterior transformation matrix that contains the homogeneous transformation of the plane based on the two corner positions of the wall + * @property {Matrix4} exteriorTransform The exterior transformation matrix that contains the homogeneous transformation of the plane based on the two corner positions of the wall + * @type {Matrix4} + * @see https://threejs.org/docs/#api/en/math/Matrix4 + */ _this.exteriorTransform = new Matrix4(); + + /** + * The inverse of the exterior transformation matrix that contains the homogeneous transformation of the plane based on the two corner positions of the wall + * @property {Matrix4} invExteriorTransform The inverse of the exterior transformation matrix that contains the homogeneous transformation of the plane based on the two corner positions of the wall + * @type {Matrix4} + * @see https://threejs.org/docs/#api/en/math/Matrix4 + */ _this.invExteriorTransform = new Matrix4(); + + /** + * This is an array of callbacks to be call when redraw happens + * @depreceated + */ _this.redrawCallbacks = null; + /** + * Is this is the front edge or the back edge + * @property {boolean} front Is this is the front edge or the back edge + * @type {boolean} + */ _this.front = front || false; _this.offset = wall.thickness / 2.0; @@ -49238,7 +49337,8 @@ var BP3DJS = (function (exports) { } /** - * + * Two separate textures are used for the walls. Based on which side of the wall this {HalfEdge} refers the texture is returned + * @return {Object} front/back Two separate textures are used for the walls. Based on which side of the wall this {@link HalfEdge} refers the texture is returned */ @@ -49253,7 +49353,11 @@ var BP3DJS = (function (exports) { } /** - * + * Set a Texture to the wall. Based on the edge side as front or back the texture is applied appropriately to the wall + * @param {String} textureUrl The path to the texture image + * @param {boolean} textureStretch Can the texture stretch? If not it will be repeated + * @param {Number} textureScale The scale value using which the number of repetitions of the texture image is calculated + * @emits {EVENT_REDRAW} */ }, { @@ -49269,11 +49373,25 @@ var BP3DJS = (function (exports) { //this.redrawCallbacks.fire(); this.dispatchEvent({ type: EVENT_REDRAW, item: this }); } + + /** + * Emit the redraw event + * @emits {EVENT_REDRAW} + */ + }, { key: 'dispatchRedrawEvent', value: function dispatchRedrawEvent() { this.dispatchEvent({ type: EVENT_REDRAW, item: this }); } + + /** + * Transform the {@link Corner} instance to a Vector3 instance using the x and y position returned as x and z + * @param {Corner} corner + * @return {Vector3} + * @see https://threejs.org/docs/#api/en/math/Vector3 + */ + }, { key: 'transformCorner', value: function transformCorner(corner) { @@ -49281,7 +49399,7 @@ var BP3DJS = (function (exports) { } /** - * this feels hacky, but need wall items + * This generates the invisible planes in the scene that are used for interesection testing for the wall items */ }, { @@ -49322,6 +49440,17 @@ var BP3DJS = (function (exports) { this.max = b3.max.clone(); this.center = this.max.clone().sub(this.min).multiplyScalar(0.5).add(this.min); } + + /** + * Calculate the transformation matrix for the edge (front/back) baesd on the parameters. + * @param {Matrix4} transform The matrix reference in which the transformation is stored + * @param {Matrix4} invTransform The inverse of the transform that is stored in the invTransform + * @param {Vector2} start The starting point location + * @param {Vector2} end The ending point location + * @see https://threejs.org/docs/#api/en/math/Matrix4 + * @see https://threejs.org/docs/#api/en/math/Vector2 + */ + }, { key: 'computeTransforms', value: function computeTransforms(transform, invTransform, start, end) { @@ -49340,9 +49469,9 @@ var BP3DJS = (function (exports) { } /** Gets the distance from specified point. - * @param x X coordinate of the point. - * @param y Y coordinate of the point. - * @returns The distance. + * @param {Number} x X coordinate of the point. + * @param {Number} y Y coordinate of the point. + * @returns {Number} The distance. */ }, { @@ -49351,6 +49480,12 @@ var BP3DJS = (function (exports) { // x, y, x1, y1, x2, y2 return Utils.pointDistanceFromLine(new Vector2(x, y), this.interiorStart(), this.interiorEnd()); } + + /** + * Get the starting corner of the wall this instance represents + * @return {Corner} The starting corner + */ + }, { key: 'getStart', value: function getStart() { @@ -49360,6 +49495,12 @@ var BP3DJS = (function (exports) { return this.wall.getEnd(); } } + + /** + * Get the ending corner of the wall this instance represents + * @return {Corner} The ending corner + */ + }, { key: 'getEnd', value: function getEnd() { @@ -49369,6 +49510,13 @@ var BP3DJS = (function (exports) { return this.wall.getStart(); } } + + /** + * If this is the front edge then return the back edge. + * For example in a wall there are two halfedges, i.e one for front and one back. Based on which side this halfedge lies return the opposite {@link HalfEdge} + * @return {HalfEdge} The other HalfEdge + */ + }, { key: 'getOppositeEdge', value: function getOppositeEdge() { @@ -49379,7 +49527,12 @@ var BP3DJS = (function (exports) { } } - // these return an object with attributes x, y + /** + * Return the 2D interior location that is at the end. + * @return {Vector2} Return an object with attributes x, y + * @see https://threejs.org/docs/#api/en/math/Vector2 + */ + // }, { key: 'interiorEnd', @@ -49388,6 +49541,13 @@ var BP3DJS = (function (exports) { return new Vector2(this.getEnd().x + vec.x, this.getEnd().y + vec.y); // return {x:this.getEnd().x + vec.x, y:this.getEnd().y + vec.y}; } + + /** + * Return the 2D interior location that is at the start. + * @return {Vector2} Return an object with attributes x, y + * @see https://threejs.org/docs/#api/en/math/Vector2 + */ + }, { key: 'interiorStart', value: function interiorStart() { @@ -49395,11 +49555,24 @@ var BP3DJS = (function (exports) { return new Vector2(this.getStart().x + vec.x, this.getStart().y + vec.y); // return {x:this.getStart().x + vec.x, y:this.getStart().y + vec.y}; } + + /** + * Return the 2D interior location that is at the center/middle. + * @return {Vector2} Return an object with attributes x, y + * @see https://threejs.org/docs/#api/en/math/Vector2 + */ + }, { key: 'interiorCenter', value: function interiorCenter() { return new Vector2((this.interiorStart().x + this.interiorEnd().x) / 2.0, (this.interiorStart().y + this.interiorEnd().y) / 2.0); } + + /** + * Return the interior distance of the interior wall + * @return {Number} The distance + */ + }, { key: 'interiorDistance', value: function interiorDistance() { @@ -49407,23 +49580,50 @@ var BP3DJS = (function (exports) { var end = this.interiorEnd(); return Utils.distance(start, end); } + + /** + * Return the 2D exterior location that is at the end. + * @return {Vector2} Return an object with attributes x, y + * @see https://threejs.org/docs/#api/en/math/Vector2 + */ + }, { key: 'exteriorEnd', value: function exteriorEnd() { var vec = this.halfAngleVector(this, this.next); return new Vector2(this.getEnd().x - vec.x, this.getEnd().y - vec.y); } + + /** + * Return the 2D exterior location that is at the start. + * @return {Vector2} Return an object with attributes x, y + * @see https://threejs.org/docs/#api/en/math/Vector2 + */ + }, { key: 'exteriorStart', value: function exteriorStart() { var vec = this.halfAngleVector(this.prev, this); return new Vector2(this.getStart().x - vec.x, this.getStart().y - vec.y); } + + /** + * Return the 2D exterior location that is at the center/middle. + * @return {Vector2} Return an object with attributes x, y + * @see https://threejs.org/docs/#api/en/math/Vector2 + */ + }, { key: 'exteriorCenter', value: function exteriorCenter() { return new Vector2((this.exteriorStart().x + this.exteriorEnd().x) / 2.0, (this.exteriorStart().y + this.exteriorEnd().y) / 2.0); } + + /** + * Return the exterior distance of the exterior wall + * @return {Number} The distance + */ + }, { key: 'exteriorDistance', value: function exteriorDistance() { @@ -49433,7 +49633,7 @@ var BP3DJS = (function (exports) { } /** Get the corners of the half edge. - * @returns An array of x,y pairs. + * @returns {Corner[]} An array of x,y pairs. */ }, { @@ -49444,6 +49644,9 @@ var BP3DJS = (function (exports) { /** * Gets CCW angle from v1 to v2 + * @param {Vector2} v1 The point a + * @param {Vector2} v1 The point b + * @return {Object} contains keys x and y with number representing the halfAngles */ }, { @@ -49680,7 +49883,7 @@ var BP3DJS = (function (exports) { /** * @param {Number} tolerance - The tolerance value within which it will snap to adjacent corners - * @return {Object} snapped + * @return {Object} snapped Contains keys x and y with true/false values * @description The object with x and y that are boolean values to indicate if the snap happens in x and y */ @@ -49836,7 +50039,7 @@ var BP3DJS = (function (exports) { * Returns the distance between this corner and a point in 2d space * @param {Vector2} point * @see https://threejs.org/docs/#api/en/math/Vector2 - * @return {Number} distance + * @return {Number} distance The distance **/ }, { @@ -50691,7 +50894,7 @@ var BP3DJS = (function (exports) { /** - * @return {HalfEdge[]} edges + * @return {HalfEdge[]} edges The array of {@link HalfEdge} **/ value: function wallEdges() { var edges = []; @@ -50780,9 +50983,10 @@ var BP3DJS = (function (exports) { // other walls. If two walls are intersecting then the intersection point // has to create a new wall. /** - * @param {Corner} start - * @param {Corner} end - * @return {boolean} intersects + * Checks existing walls for any intersections they would make. If there are intersections then introduce new corners and new walls as required at places + * @param {Corner} start + * @param {Corner} end + * @return {boolean} intersects **/ }, { @@ -51470,7 +51674,7 @@ var BP3DJS = (function (exports) { } /** - * @return {CarbonSheet} _carbonSheet + * @return {CarbonSheet} _carbonSheet reference to the instance of {@link CarbonSheet} **/ , get: function get() { @@ -102927,6 +103131,7 @@ var BP3DJS = (function (exports) { _this.bhelper = null; _this.scene = _this.model.scene; + _this._freePosition = true; if (!isgltf) { _this.geometry = geometry; @@ -103487,6 +103692,11 @@ var BP3DJS = (function (exports) { scale_x: this.scale.x, scale_y: this.scale.y, scale_z: this.scale.z, fixed: this.fixed, material_colors: matattribs }; } + }, { + key: 'freePosition', + get: function get() { + return this._freePosition; + } }]); return Item; }(Mesh); @@ -103500,7 +103710,11 @@ var BP3DJS = (function (exports) { function FloorItem(model, metadata, geometry, material, position, rotation, scale) { var isgltf = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false; classCallCheck(this, FloorItem); - return possibleConstructorReturn(this, (FloorItem.__proto__ || Object.getPrototypeOf(FloorItem)).call(this, model, metadata, geometry, material, position, rotation, scale, isgltf)); + + var _this = possibleConstructorReturn(this, (FloorItem.__proto__ || Object.getPrototypeOf(FloorItem)).call(this, model, metadata, geometry, material, position, rotation, scale, isgltf)); + + _this._freePosition = false; + return _this; } /** */ @@ -103622,6 +103836,7 @@ var BP3DJS = (function (exports) { /** */ _this.backVisible = false; _this.allowRotate = false; + _this._freePosition = false; return _this; } @@ -106481,7 +106696,7 @@ var BP3DJS = (function (exports) { var threeGltfExporter = _GLTFExporter; /** - * A Model connects a Floorplan and a Scene. + * A Model is an abstract concept the has the data structuring a floorplan. It connects a {@link Floorplan} and a {@link Scene} */ var Model = function (_EventDispatcher) { inherits(Model, _EventDispatcher); @@ -118609,6 +118824,9 @@ var BP3DJS = (function (exports) { key: 'itemIntersection', value: function itemIntersection(vec2, item) { var customIntersections = item.customIntersectionPlanes(); + if (item.freePosition) { + return this.freeMouse3D(vec2); + } var intersections = null; if (customIntersections && customIntersections.length > 0) { intersections = this.getIntersections(vec2, customIntersections, true); @@ -118643,6 +118861,17 @@ var BP3DJS = (function (exports) { vector.unproject(this.camera); return vector; } + }, { + key: 'freeMouse3D', + value: function freeMouse3D(vec2) { + var distance; + var pos = new Vector3(); + var vector = this.mouseToVec3(vec2); + vector.sub(this.camera.position).normalize(); + distance = -this.camera.position.z / vector.z; + pos.copy(this.camera.position).add(vector.multiplyScalar(distance)); + return { point: pos, distance: distance }; + } // filter by normals will only return objects facing the camera // objects can be an array of objects or a single object @@ -169602,8 +169831,8 @@ var BP3DJS = (function (exports) { if (!options.widget) { /** - * @property {Floorplanner} floorplanner - * @type {Floorplanner} + * @property {Floorplanner2D} floorplanner + * @type {Floorplanner2D} **/ this.floorplanner = new Floorplanner2D(options.floorplannerElement, this.model.floorplan); } else { diff --git a/build/js/bp3djs.min.js b/build/js/bp3djs.min.js index 89f3660..d9a9fe5 100644 --- a/build/js/bp3djs.min.js +++ b/build/js/bp3djs.min.js @@ -1 +1 @@ -var BP3DJS=function(e){"use strict";function t(){}function n(e,t){this.x=e||0,this.y=t||0}function i(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function r(e,t,n,i){this._x=e||0,this._y=t||0,this._z=n||0,this._w=void 0!==i?i:1}function a(e,t,n){this.x=e||0,this.y=t||0,this.z=n||0}function o(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function s(e,t,i,r,a,c,l,h,u,p){Object.defineProperty(this,"id",{value:h_++}),this.uuid=c_.generateUUID(),this.name="",this.image=void 0!==e?e:s.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:s.DEFAULT_MAPPING,this.wrapS=void 0!==i?i:Yw,this.wrapT=void 0!==r?r:Yw,this.magFilter=void 0!==a?a:$w,this.minFilter=void 0!==c?c:tb,this.anisotropy=void 0!==u?u:1,this.format=void 0!==l?l:vb,this.type=void 0!==h?h:nb,this.offset=new n(0,0),this.repeat=new n(1,1),this.center=new n(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new o,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==p?p:Kb,this.version=0,this.onUpdate=null}function c(e,t,n,i){this.x=e||0,this.y=t||0,this.z=n||0,this.w=void 0!==i?i:1}function l(e,t,n){this.width=e,this.height=t,this.scissor=new c(0,0,e,t),this.scissorTest=!1,this.viewport=new c(0,0,e,t),void 0===(n=n||{}).minFilter&&(n.minFilter=$w),this.texture=new s(void 0,void 0,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.generateMipmaps=void 0===n.generateMipmaps||n.generateMipmaps,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0===n.stencilBuffer||n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null}function h(e,t,n){l.call(this,e,t,n),this.activeCubeFace=0,this.activeMipMapLevel=0}function u(e,t,n,i,r,a,o,c,l,h,u,p){s.call(this,null,a,o,c,l,h,i,r,u,p),this.image={data:e,width:t,height:n},this.magFilter=void 0!==l?l:Jw,this.minFilter=void 0!==h?h:Jw,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function p(e,t){this.min=void 0!==e?e:new a(1/0,1/0,1/0),this.max=void 0!==t?t:new a(-1/0,-1/0,-1/0)}function d(e,t){this.center=void 0!==e?e:new a,this.radius=void 0!==t?t:0}function f(e,t){this.normal=void 0!==e?e:new a(1,0,0),this.constant=void 0!==t?t:0}function m(e,t,n,i,r,a){this.planes=[void 0!==e?e:new f,void 0!==t?t:new f,void 0!==n?n:new f,void 0!==i?i:new f,void 0!==r?r:new f,void 0!==a?a:new f]}function v(e,t,n){return void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}function g(){function e(r,a){!1!==n&&(i(r,a),t.requestAnimationFrame(e))}var t=null,n=!1,i=null;return{start:function(){!0!==n&&null!==i&&(t.requestAnimationFrame(e),n=!0)},stop:function(){n=!1},setAnimationLoop:function(e){i=e},setContext:function(e){t=e}}}function y(e){function t(t,n){var i=t.array,r=t.dynamic?35048:35044,a=e.createBuffer();e.bindBuffer(n,a),e.bufferData(n,i,r),t.onUploadCallback();var o=5126;return i instanceof Float32Array?o=5126:i instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):i instanceof Uint16Array?o=5123:i instanceof Int16Array?o=5122:i instanceof Uint32Array?o=5125:i instanceof Int32Array?o=5124:i instanceof Int8Array?o=5120:i instanceof Uint8Array&&(o=5121),{buffer:a,type:o,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version}}function n(t,n,i){var r=n.array,a=n.updateRange;e.bindBuffer(i,t),!1===n.dynamic?e.bufferData(i,r,35044):-1===a.count?e.bufferSubData(i,0,r):0===a.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(e.bufferSubData(i,a.offset*r.BYTES_PER_ELEMENT,r.subarray(a.offset,a.offset+a.count)),a.count=-1)}function i(e){return e.isInterleavedBufferAttribute&&(e=e.data),o.get(e)}function r(t){t.isInterleavedBufferAttribute&&(t=t.data);var n=o.get(t);n&&(e.deleteBuffer(n.buffer),o.delete(t))}function a(e,i){e.isInterleavedBufferAttribute&&(e=e.data);var r=o.get(e);void 0===r?o.set(e,t(e,i)):r.versiont&&(t=e[n]);return t}function U(){Object.defineProperty(this,"id",{value:y_+=2}),this.uuid=c_.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}function B(e,t,n,i,r,a){M.call(this),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a},this.fromBufferGeometry(new F(e,t,n,i,r,a)),this.mergeVertices()}function F(e,t,n,i,r,o){function s(e,t,n,i,r,o,s,m,v,g,y){var x,w,b=o/v,_=s/g,M=o/2,E=s/2,T=m/2,S=v+1,A=g+1,L=0,R=0,C=new a;for(w=0;w0?1:-1,u.push(C.x,C.y,C.z),p.push(x/v),p.push(1-w/g),L+=1}}for(w=0;w0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}var a,o="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext,s=void 0!==n.precision?n.precision:"highp",c=r(s);c!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",c,"instead."),s=c);var l=!0===n.logarithmicDepthBuffer,h=e.getParameter(34930),u=e.getParameter(35660),p=e.getParameter(3379),d=e.getParameter(34076),f=e.getParameter(34921),m=e.getParameter(36347),v=e.getParameter(36348),g=e.getParameter(36349),y=u>0,x=o||!!t.get("OES_texture_float");return{isWebGL2:o,getMaxAnisotropy:i,getMaxPrecision:r,precision:s,logarithmicDepthBuffer:l,maxTextures:h,maxVertexTextures:u,maxTextureSize:p,maxCubemapSize:d,maxAttributes:f,maxVertexUniforms:m,maxVaryings:v,maxFragmentUniforms:g,vertexTextures:y,floatFragmentTextures:x,floatVertexTextures:y&&x}}function J(){function e(){h.value!==i&&(h.value=i,h.needsUpdate=r>0),n.numPlanes=r,n.numIntersection=0}function t(e,t,i,r){var a=null!==e?e.length:0,o=null;if(0!==a){if(o=h.value,!0!==r||null===o){var s=i+4*a,u=t.matrixWorldInverse;l.getNormalMatrix(u),(null===o||o.length65535?P:R)(i,1),t.update(n,34963),c[e.id]=n,n}var s={},c={};return{get:r,update:a,getWireframeAttribute:o}}function $(e,t,n,i){function r(e){c=e}function a(e){l=e.type,h=e.bytesPerElement}function o(t,i){e.drawElements(c,i,l,t*h),n.update(i,c)}function s(r,a,o){var s;if(i.isWebGL2)s=e;else if(null===(s=t.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");s[i.isWebGL2?"drawElementsInstanced":"drawElementsInstancedANGLE"](c,o,l,a*h,r.maxInstancedCount),n.update(o,c,r.maxInstancedCount)}var c,l,h;this.setMode=r,this.setIndex=a,this.render=o,this.renderInstances=s}function ee(e){function t(e,t,n){switch(n=n||1,i.calls++,t){case 4:i.triangles+=n*(e/3);break;case 5:case 6:i.triangles+=n*(e-2);break;case 1:i.lines+=n*(e/2);break;case 3:i.lines+=n*(e-1);break;case 2:i.lines+=n*e;break;case 0:i.points+=n*e;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",t)}}function n(){i.frame++,i.calls=0,i.triangles=0,i.points=0,i.lines=0}var i={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:i,programs:null,autoReset:!0,reset:n,update:t}}function te(e,t){return Math.abs(t[1])-Math.abs(e[1])}function ne(e){function t(t,r,a,o){var s=t.morphTargetInfluences,c=s.length,l=n[r.id];if(void 0===l){l=[];for(p=0;p0)return e;var r=t*n,a=M_[r];if(void 0===a&&(a=new Float32Array(r),M_[r]=a),0!==t){i.toArray(a,0);for(var o=1,s=0;o!==t;++o)s+=n,e[o].toArray(a,s)}return a}function ce(e,t){if(e.length!==t.length)return!1;for(var n=0,i=e.length;n");return tt(n)}return e.replace(/^[ \t]*#include +<([\w\d.\/]+)>/gm,t)}function nt(e){function t(e,t,n,i){for(var r="",a=parseInt(t);a0?e.gammaFactor:1,y=o.isWebGL2?"":Ze(i.extensions,a,t),x=Je(c),w=s.createProgram();if(i.isRawShaderMaterial?((m=[x].filter(Qe).join("\n")).length>0&&(m+="\n"),(v=[y,x].filter(Qe).join("\n")).length>0&&(v+="\n")):(m=["precision "+a.precision+" float;","precision "+a.precision+" int;","#define SHADER_NAME "+r.name,x,a.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+a.maxBones,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+d:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.displacementMap&&a.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.vertexColors?"#define USE_COLOR":"",a.flatShading?"#define FLAT_SHADED":"",a.skinning?"#define USE_SKINNING":"",a.useVertexTexture?"#define BONE_TEXTURE":"",a.morphTargets?"#define USE_MORPHTARGETS":"",a.morphNormals&&!1===a.flatShading?"#define USE_MORPHNORMALS":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+u:"",a.sizeAttenuation?"#define USE_SIZEATTENUATION":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(o.isWebGL2||t.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Qe).join("\n"),v=[y,"precision "+a.precision+" float;","precision "+a.precision+" int;","#define SHADER_NAME "+r.name,x,a.alphaTest?"#define ALPHATEST "+a.alphaTest+(a.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+g,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+p:"",a.envMap?"#define "+d:"",a.envMap?"#define "+f:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.vertexColors?"#define USE_COLOR":"",a.gradientMap?"#define USE_GRADIENTMAP":"",a.flatShading?"#define FLAT_SHADED":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+u:"",a.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",a.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(o.isWebGL2||t.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",a.envMap&&(o.isWebGL2||t.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",a.toneMapping!==Dw?"#define TONE_MAPPING":"",a.toneMapping!==Dw?u_.tonemapping_pars_fragment:"",a.toneMapping!==Dw?Ye("toneMapping",a.toneMapping):"",a.dithering?"#define DITHERING":"",a.outputEncoding||a.mapEncoding||a.matcapEncoding||a.envMapEncoding||a.emissiveMapEncoding?u_.encodings_pars_fragment:"",a.mapEncoding?Xe("mapTexelToLinear",a.mapEncoding):"",a.matcapEncoding?Xe("matcapTexelToLinear",a.matcapEncoding):"",a.envMapEncoding?Xe("envMapTexelToLinear",a.envMapEncoding):"",a.emissiveMapEncoding?Xe("emissiveMapTexelToLinear",a.emissiveMapEncoding):"",a.outputEncoding?qe("linearToOutputTexel",a.outputEncoding):"",a.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(Qe).join("\n")),l=tt(l),l=$e(l,a),l=et(l,a),h=tt(h),h=$e(h,a),h=et(h,a),l=nt(l),h=nt(h),o.isWebGL2&&!i.isRawShaderMaterial){var b=!1,_=/^\s*#version\s+300\s+es\s*\n/;i.isShaderMaterial&&null!==l.match(_)&&null!==h.match(_)&&(b=!0,l=l.replace(_,""),h=h.replace(_,"")),m=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+m,v=["#version 300 es\n","#define varying in",b?"":"out highp vec4 pc_fragColor;",b?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v}var M=v+h,E=je(s,35633,m+l),T=je(s,35632,M);s.attachShader(w,E),s.attachShader(w,T),void 0!==i.index0AttributeName?s.bindAttribLocation(w,0,i.index0AttributeName):!0===a.morphTargets&&s.bindAttribLocation(w,0,"position"),s.linkProgram(w);var S=s.getProgramInfoLog(w).trim(),A=s.getShaderInfoLog(E).trim(),L=s.getShaderInfoLog(T).trim(),R=!0,C=!0;!1===s.getProgramParameter(w,35714)?(R=!1,console.error("THREE.WebGLProgram: shader error: ",s.getError(),"35715",s.getProgramParameter(w,35715),"gl.getProgramInfoLog",S,A,L)):""!==S?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",S):""!==A&&""!==L||(C=!1),C&&(this.diagnostics={runnable:R,material:i,programLog:S,vertexShader:{log:A,prefix:m},fragmentShader:{log:L,prefix:v}}),s.deleteShader(E),s.deleteShader(T);var P;this.getUniforms=function(){return void 0===P&&(P=new He(s,w,e)),P};var O;return this.getAttributes=function(){return void 0===O&&(O=Ke(s,w)),O},this.destroy=function(){s.deleteProgram(w),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms()."),this.getUniforms()}},attributes:{get:function(){return console.warn("THREE.WebGLProgram: .attributes is now .getAttributes()."),this.getAttributes()}}}),this.name=r.name,this.id=R_++,this.code=n,this.usedTimes=1,this.program=w,this.vertexShader=E,this.fragmentShader=T,this}function rt(e,t,n){function i(e){var t=e.skeleton.bones;if(n.floatVertexTextures)return 1024;var i=n.maxVertexUniforms,r=Math.floor((i-20)/4),a=Math.min(r,t.length);return a0,maxBones:d,useVertexTexture:n.floatVertexTextures,morphTargets:t.morphTargets,morphNormals:t.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numClippingPlanes:l,numClipIntersection:h,dithering:t.dithering,shadowMapEnabled:e.shadowMap.enabled&&u.receiveShadow&&s.length>0,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:t.premultipliedAlpha,alphaTest:t.alphaTest,doubleSided:t.side===Qx,flipSided:t.side===Kx,depthPacking:void 0!==t.depthPacking&&t.depthPacking}},this.getProgramCode=function(t,n){var i=[];if(n.shaderID?i.push(n.shaderID):(i.push(t.fragmentShader),i.push(t.vertexShader)),void 0!==t.defines)for(var r in t.defines)i.push(r),i.push(t.defines[r]);for(var a=0;a1&&a.sort(ot),o.length>1&&o.sort(st)}var i=[],r=0,a=[],o=[];return{opaque:a,transparent:o,init:e,push:t,sort:n}}function lt(){function e(e,t){var i=e.id+","+t.id,r=n[i];return void 0===r&&(r=new ct,n[i]=r),r}function t(){n={}}var n={};return{get:e,dispose:t}}function ht(){var e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];var i;switch(t.type){case"DirectionalLight":i={direction:new a,color:new v,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new n};break;case"SpotLight":i={position:new a,direction:new a,color:new v,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new n};break;case"PointLight":i={position:new a,color:new v,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new n,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":i={direction:new a,skyColor:new v,groundColor:new v};break;case"RectAreaLight":i={color:new v,position:new a,halfWidth:new a,halfHeight:new a}}return e[t.id]=i,i}}}function ut(){function e(e,i,a){for(var c=0,l=0,h=0,u=0,p=0,d=0,f=0,m=0,v=a.matrixWorldInverse,g=0,y=e.length;g0:s&&s.isGeometry&&(u=s.morphTargets&&s.morphTargets.length>0)),t.isSkinnedMesh&&!1===n.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",t);var p=t.isSkinnedMesh&&n.skinning,d=0;u&&(d|=g),p&&(d|=y),c=l[d]}if(e.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var f=c.uuid,m=n.uuid,v=_[f];void 0===v&&(v={},_[f]=v);var x=v[m];void 0===x&&(x=c.clone(),v[m]=x),c=x}return c.visible=n.visible,c.wireframe=n.wireframe,c.side=null!=n.shadowSide?n.shadowSide:M[n.side],c.clipShadows=n.clipShadows,c.clippingPlanes=n.clippingPlanes,c.clipIntersection=n.clipIntersection,c.wireframeLinewidth=n.wireframeLinewidth,c.linewidth=n.linewidth,i&&c.isMeshDistanceMaterial&&(c.referencePosition.copy(r),c.nearDistance=a,c.farDistance=o),c}function s(n,i,r,a){if(!1!==n.visible){if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&n.castShadow&&(!n.frustumCulled||h.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,n.matrixWorld);var c=t.update(n),l=n.material;if(Array.isArray(l))for(var u=c.groups,p=0,d=u.length;p=1):-1!==ae.indexOf("OpenGL ES")&&(re=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(ae)[1]),ie=re>=2);var oe=null,se={},ce=new c,le=new c,he={};return he[3553]=s(3553,3553,1),he[34067]=s(34067,34069,6),O.setClear(0,0,0,1),I.setClear(1),N.setClear(0),d(2929),I.setFunc(Aw),x(!1),w(Xx),d(2884),g(nw),{buffers:{color:O,depth:I,stencil:N},initAttributes:l,enableAttribute:h,enableAttributeAndDivisor:u,disableUnusedAttributes:p,enable:d,disable:f,getCompressedTextureFormats:m,useProgram:v,setBlending:g,setMaterial:y,setFlipSided:x,setCullFace:w,setLineWidth:b,setPolygonOffset:_,setScissorTest:M,activeTexture:E,bindTexture:T,compressedTexImage2D:S,texImage2D:A,texImage3D:L,scissor:R,viewport:C,reset:P}}function yt(e,t,n,i,r,a,o){function s(e,t){if(e.width>t||e.height>t){if("data"in e)return void console.warn("THREE.WebGLRenderer: image in DataTexture is too big ("+e.width+"x"+e.height+").");var n=t/Math.max(e.width,e.height),i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return i.width=Math.floor(e.width*n),i.height=Math.floor(e.height*n),i.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,i.width,i.height),console.warn("THREE.WebGLRenderer: image is too big ("+e.width+"x"+e.height+"). Resized to "+i.width+"x"+i.height),i}return e}function c(e){return c_.isPowerOfTwo(e.width)&&c_.isPowerOfTwo(e.height)}function l(e){return e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof ImageBitmap?(void 0===O&&(O=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),O.width=c_.floorPowerOfTwo(e.width),O.height=c_.floorPowerOfTwo(e.height),O.getContext("2d").drawImage(e,0,0,O.width,O.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+e.width+"x"+e.height+"). Resized to "+O.width+"x"+O.height),O):e}function h(e){return!r.isWebGL2&&(e.wrapS!==Yw||e.wrapT!==Yw||e.minFilter!==Jw&&e.minFilter!==$w)}function u(e,t){return e.generateMipmaps&&t&&e.minFilter!==Jw&&e.minFilter!==$w}function p(t,n,r,a){e.generateMipmap(t),i.get(n).__maxMipLevel=Math.log(Math.max(r,a))*Math.LOG2E}function d(e,t){if(!r.isWebGL2)return e;if(6403===e){if(5126===t)return 33326;if(5131===t)return 33325;if(5121===t)return 33321}if(6407===e){if(5126===t)return 34837;if(5131===t)return 34843;if(5121===t)return 32849}if(6408===e){if(5126===t)return 34836;if(5131===t)return 34842;if(5121===t)return 32856}return e}function f(e){return e===Jw||e===Kw||e===Qw?9728:9729}function m(e){var t=e.target;t.removeEventListener("dispose",m),g(t),t.isVideoTexture&&delete I[t.id],o.memory.textures--}function v(e){var t=e.target;t.removeEventListener("dispose",v),y(t),o.memory.textures--}function g(t){var n=i.get(t);if(t.image&&n.__image__webglTextureCube)e.deleteTexture(n.__image__webglTextureCube);else{if(void 0===n.__webglInit)return;e.deleteTexture(n.__webglTexture)}i.remove(t)}function y(t){var n=i.get(t),r=i.get(t.texture);if(t){if(void 0!==r.__webglTexture&&e.deleteTexture(r.__webglTexture),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLRenderTargetCube)for(var a=0;a<6;a++)e.deleteFramebuffer(n.__webglFramebuffer[a]),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[a]);else e.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer);i.remove(t.texture),i.remove(t)}}function x(e,t){var r=i.get(e);if(e.isVideoTexture&&P(e),e.version>0&&r.__version!==e.version){var a=e.image;if(void 0===a)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==a.complete)return void E(r,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+t),n.bindTexture(3553,r.__webglTexture)}function w(e,t){var r=i.get(e);if(e.version>0&&r.__version!==e.version)return void E(r,e,t);n.activeTexture(33984+t),n.bindTexture(32879,r.__webglTexture)}function b(t,l){var h=i.get(t);if(6===t.image.length)if(t.version>0&&h.__version!==t.version){h.__image__webglTextureCube||(t.addEventListener("dispose",m),h.__image__webglTextureCube=e.createTexture(),o.memory.textures++),n.activeTexture(33984+l),n.bindTexture(34067,h.__image__webglTextureCube),e.pixelStorei(37440,t.flipY);for(var f=t&&t.isCompressedTexture,v=t.image[0]&&t.image[0].isDataTexture,g=[],y=0;y<6;y++)g[y]=f||v?v?t.image[y].image:t.image[y]:s(t.image[y],r.maxCubemapSize);var x=g[0],w=c(x),b=a.convert(t.format),_=a.convert(t.type),E=d(b,_);M(34067,t,w);for(y=0;y<6;y++)if(f)for(var T,S=g[y].mipmaps,A=0,L=S.length;A-1?n.compressedTexImage2D(34069+y,A,E,T.width,T.height,0,T.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(34069+y,A,E,T.width,T.height,0,b,_,T.data);else v?n.texImage2D(34069+y,0,E,g[y].width,g[y].height,0,b,_,g[y].data):n.texImage2D(34069+y,0,E,b,_,g[y]);h.__maxMipLevel=f?S.length-1:0,u(t,w)&&p(34067,t,x.width,x.height),h.__version=t.version,t.onUpdate&&t.onUpdate(t)}else n.activeTexture(33984+l),n.bindTexture(34067,h.__image__webglTextureCube)}function _(e,t){n.activeTexture(33984+t),n.bindTexture(34067,i.get(e).__webglTexture)}function M(n,o,s){var c;if(s?(e.texParameteri(n,10242,a.convert(o.wrapS)),e.texParameteri(n,10243,a.convert(o.wrapT)),e.texParameteri(n,10240,a.convert(o.magFilter)),e.texParameteri(n,10241,a.convert(o.minFilter))):(e.texParameteri(n,10242,33071),e.texParameteri(n,10243,33071),o.wrapS===Yw&&o.wrapT===Yw||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,10240,f(o.magFilter)),e.texParameteri(n,10241,f(o.minFilter)),o.minFilter!==Jw&&o.minFilter!==$w&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),c=t.get("EXT_texture_filter_anisotropic")){if(o.type===cb&&null===t.get("OES_texture_float_linear"))return;if(o.type===lb&&null===(r.isWebGL2||t.get("OES_texture_half_float_linear")))return;(o.anisotropy>1||i.get(o).__currentAnisotropy)&&(e.texParameterf(n,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,r.getMaxAnisotropy())),i.get(o).__currentAnisotropy=o.anisotropy)}}function E(t,i,f){var v;v=i.isDataTexture3D?32879:3553,void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",m),t.__webglTexture=e.createTexture(),o.memory.textures++),n.activeTexture(33984+f),n.bindTexture(v,t.__webglTexture),e.pixelStorei(37440,i.flipY),e.pixelStorei(37441,i.premultiplyAlpha),e.pixelStorei(3317,i.unpackAlignment);var g=s(i.image,r.maxTextureSize);h(i)&&!1===c(g)&&(g=l(g));var y=c(g),x=a.convert(i.format),w=a.convert(i.type),b=d(x,w);M(v,i,y);var _,E=i.mipmaps;if(i.isDepthTexture){if(b=6402,i.type===cb){if(!r.isWebGL2)throw new Error("Float Depth Texture only supported in WebGL2.0");b=36012}else r.isWebGL2&&(b=33189);i.format===wb&&6402===b&&i.type!==ab&&i.type!==sb&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=ab,w=a.convert(i.type)),i.format===bb&&(b=34041,i.type!==db&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=db,w=a.convert(i.type))),n.texImage2D(3553,0,b,g.width,g.height,0,x,w,null)}else if(i.isDataTexture)if(E.length>0&&y){for(var T=0,S=E.length;T-1?n.compressedTexImage2D(3553,T,b,_.width,_.height,0,_.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(3553,T,b,_.width,_.height,0,x,w,_.data);t.__maxMipLevel=E.length-1}else if(i.isDataTexture3D)n.texImage3D(32879,0,b,g.width,g.height,g.depth,0,x,w,g.data),t.__maxMipLevel=0;else if(E.length>0&&y){for(var T=0,S=E.length;T=0){var c=i[o];if(void 0!==c){var l=c.normalized,h=c.itemSize,u=ke.get(c);if(void 0===u)continue;var p=u.buffer,d=u.type,f=u.bytesPerElement;if(c.isInterleavedBufferAttribute){var m=c.data,v=m.stride,g=c.offset;m&&m.isInstancedInterleavedBuffer?(Ue.enableAttributeAndDivisor(s,m.meshPerAttribute),void 0===n.maxInstancedCount&&(n.maxInstancedCount=m.meshPerAttribute*m.count)):Ue.enableAttribute(s),se.bindBuffer(34962,p),se.vertexAttribPointer(s,h,d,l,v*f,g*f)}else c.isInstancedBufferAttribute?(Ue.enableAttributeAndDivisor(s,c.meshPerAttribute),void 0===n.maxInstancedCount&&(n.maxInstancedCount=c.meshPerAttribute*c.count)):Ue.enableAttribute(s),se.bindBuffer(34962,p),se.vertexAttribPointer(s,h,d,l,0,0)}else if(void 0!==a){var y=a[o];if(void 0!==y)switch(y.length){case 2:se.vertexAttrib2fv(s,y);break;case 3:se.vertexAttrib3fv(s,y);break;case 4:se.vertexAttrib4fv(s,y);break;default:se.vertexAttrib1fv(s,y)}}}}Ue.disableUnusedAttributes()}function f(e){Qe.isPresenting()||et&&et(e)}function v(e,t,n){if(!1!==e.visible){if(e.layers.test(t.layers))if(e.isLight)oe.pushLight(e),e.castShadow&&oe.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||Ae.intersectsSprite(e)){n&&Oe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Pe);var i=Ve.update(e),r=e.material;ae.push(e,i,r,Oe.z,null)}}else if(e.isImmediateRenderObject)n&&Oe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Pe),ae.push(e,null,e.material,Oe.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.update(),!e.frustumCulled||Ae.intersectsObject(e))){n&&Oe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Pe);var i=Ve.update(e),r=e.material;if(Array.isArray(r))for(var a=i.groups,o=0,s=a.length;o=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(var v=0;v=0&&e.numSupportedMorphNormals++}var g=i.shader.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(i.numClippingPlanes=Le.numPlanes,i.numIntersection=Le.numIntersection,g.clippingPlanes=Le.uniform),i.fog=t,void 0===o&&(i.lightsHash=o={}),o.stateID=c.stateID,o.directionalLength=c.directionalLength,o.pointLength=c.pointLength,o.spotLength=c.spotLength,o.rectAreaLength=c.rectAreaLength,o.hemiLength=c.hemiLength,o.shadowsLength=c.shadowsLength,e.lights&&(g.ambientLightColor.value=r.state.ambient,g.directionalLights.value=r.state.directional,g.spotLights.value=r.state.spot,g.rectAreaLights.value=r.state.rectArea,g.pointLights.value=r.state.point,g.hemisphereLights.value=r.state.hemi,g.directionalShadowMap.value=r.state.directionalShadowMap,g.directionalShadowMatrix.value=r.state.directionalShadowMatrix,g.spotShadowMap.value=r.state.spotShadowMap,g.spotShadowMatrix.value=r.state.spotShadowMatrix,g.pointShadowMap.value=r.state.pointShadowMap,g.pointShadowMatrix.value=r.state.pointShadowMatrix);var y=i.program.getUniforms(),x=He.seqWithValue(y.seq,g);i.uniformsList=x}function _(e,t,n,i){we=0;var r=Fe.get(n),a=oe.state.lights,o=r.lightsHash,s=a.state.hash;if(Re&&(Ce||e!==me)){var c=e===me&&n.id===de;Le.setState(n.clippingPlanes,n.clipIntersection,n.clipShadows,e,r,c)}!1===n.needsUpdate&&(void 0===r.program?n.needsUpdate=!0:n.fog&&r.fog!==t?n.needsUpdate=!0:!n.lights||o.stateID===s.stateID&&o.directionalLength===s.directionalLength&&o.pointLength===s.pointLength&&o.spotLength===s.spotLength&&o.rectAreaLength===s.rectAreaLength&&o.hemiLength===s.hemiLength&&o.shadowsLength===s.shadowsLength?void 0===r.numClippingPlanes||r.numClippingPlanes===Le.numPlanes&&r.numIntersection===Le.numIntersection||(n.needsUpdate=!0):n.needsUpdate=!0),n.needsUpdate&&(b(n,t,i),n.needsUpdate=!1);var l=!1,h=!1,p=!1,d=r.program,f=d.getUniforms(),m=r.shader.uniforms;if(Ue.useProgram(d.program)&&(l=!0,h=!0,p=!0),n.id!==de&&(de=n.id,h=!0),l||me!==e){if(f.setValue(se,"projectionMatrix",e.projectionMatrix),De.logarithmicDepthBuffer&&f.setValue(se,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),me!==e&&(me=e,h=!0,p=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.envMap){var v=f.map.cameraPosition;void 0!==v&&v.setValue(se,Oe.setFromMatrixPosition(e.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.skinning)&&f.setValue(se,"viewMatrix",e.matrixWorldInverse)}if(n.skinning){f.setOptional(se,i,"bindMatrix"),f.setOptional(se,i,"bindMatrixInverse");var g=i.skeleton;if(g){var y=g.bones;if(De.floatVertexTextures){if(void 0===g.boneTexture){var x=Math.sqrt(4*y.length);x=c_.ceilPowerOfTwo(x),x=Math.max(x,4);var w=new Float32Array(x*x*4);w.set(g.boneMatrices);var _=new u(w,x,x,vb,cb);_.needsUpdate=!0,g.boneMatrices=w,g.boneTexture=_,g.boneTextureSize=x}f.setValue(se,"boneTexture",g.boneTexture),f.setValue(se,"boneTextureSize",g.boneTextureSize)}else f.setOptional(se,g,"boneMatrices")}}return h&&(f.setValue(se,"toneMappingExposure",ce.toneMappingExposure),f.setValue(se,"toneMappingWhitePoint",ce.toneMappingWhitePoint),n.lights&&F(m,p),t&&n.fog&&L(m,t),n.isMeshBasicMaterial?M(m,n):n.isMeshLambertMaterial?(M(m,n),R(m,n)):n.isMeshPhongMaterial?(M(m,n),n.isMeshToonMaterial?P(m,n):C(m,n)):n.isMeshStandardMaterial?(M(m,n),n.isMeshPhysicalMaterial?I(m,n):O(m,n)):n.isMeshMatcapMaterial?(M(m,n),N(m,n)):n.isMeshDepthMaterial?(M(m,n),D(m,n)):n.isMeshDistanceMaterial?(M(m,n),U(m,n)):n.isMeshNormalMaterial?(M(m,n),B(m,n)):n.isLineBasicMaterial?(E(m,n),n.isLineDashedMaterial&&T(m,n)):n.isPointsMaterial?S(m,n):n.isSpriteMaterial?A(m,n):n.isShadowMaterial&&(m.color.value=n.color,m.opacity.value=n.opacity),void 0!==m.ltc_1&&(m.ltc_1.value=f_.LTC_1),void 0!==m.ltc_2&&(m.ltc_2.value=f_.LTC_2),He.upload(se,r.uniformsList,m,ce)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(He.upload(se,r.uniformsList,m,ce),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&f.setValue(se,"center",i.center),f.setValue(se,"modelViewMatrix",i.modelViewMatrix),f.setValue(se,"normalMatrix",i.normalMatrix),f.setValue(se,"modelMatrix",i.matrixWorld),d}function M(e,t){e.opacity.value=t.opacity,t.color&&(e.diffuse.value=t.color),t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.specularMap&&(e.specularMap.value=t.specularMap),t.envMap&&(e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap&&t.envMap.isCubeTexture?-1:1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio,e.maxMipLevel.value=Fe.get(t.envMap).__maxMipLevel),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity);var n;t.map?n=t.map:t.specularMap?n=t.specularMap:t.displacementMap?n=t.displacementMap:t.normalMap?n=t.normalMap:t.bumpMap?n=t.bumpMap:t.roughnessMap?n=t.roughnessMap:t.metalnessMap?n=t.metalnessMap:t.alphaMap?n=t.alphaMap:t.emissiveMap&&(n=t.emissiveMap),void 0!==n&&(n.isWebGLRenderTarget&&(n=n.texture),!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}function E(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}function T(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function S(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size*Me,e.scale.value=.5*_e,e.map.value=t.map,null!==t.map&&(!0===t.map.matrixAutoUpdate&&t.map.updateMatrix(),e.uvTransform.value.copy(t.map.matrix))}function A(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity,e.rotation.value=t.rotation,e.map.value=t.map,null!==t.map&&(!0===t.map.matrixAutoUpdate&&t.map.updateMatrix(),e.uvTransform.value.copy(t.map.matrix))}function L(e,t){e.fogColor.value=t.color,t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)}function R(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}function C(e,t){e.specular.value=t.specular,e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Kx&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Kx&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function P(e,t){C(e,t),t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function O(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Kx&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Kx&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function I(e,t){O(e,t),e.reflectivity.value=t.reflectivity,e.clearCoat.value=t.clearCoat,e.clearCoatRoughness.value=t.clearCoatRoughness}function N(e,t){t.matcap&&(e.matcap.value=t.matcap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Kx&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Kx&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function D(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function U(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}function B(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===Kx&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===Kx&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function F(e,t){e.ambientLightColor.needsUpdate=t,e.directionalLights.needsUpdate=t,e.pointLights.needsUpdate=t,e.spotLights.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function z(){var e=we;return e>=De.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+e+" texture units while this GPU supports only "+De.maxTextures),we+=1,e}console.log("THREE.WebGLRenderer",Vx);var k=void 0!==(e=e||{}).canvas?e.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),G=void 0!==e.context?e.context:null,H=void 0!==e.alpha&&e.alpha,V=void 0===e.depth||e.depth,j=void 0===e.stencil||e.stencil,W=void 0!==e.antialias&&e.antialias,X=void 0===e.premultipliedAlpha||e.premultipliedAlpha,te=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,re=void 0!==e.powerPreference?e.powerPreference:"default",ae=null,oe=null;this.domElement=k,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=Uw,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var se,ce=this,le=!1,he=null,ue=null,pe=null,de=-1,fe={geometry:null,program:null,wireframe:!1},me=null,ve=null,ge=new c,ye=new c,xe=null,we=0,be=k.width,_e=k.height,Me=1,Ee=new c(0,0,be,_e),Te=new c(0,0,be,_e),Se=!1,Ae=new m,Le=new J,Re=!1,Ce=!1,Pe=new i,Oe=new a;try{var Ie={alpha:H,depth:V,stencil:j,antialias:W,premultipliedAlpha:X,preserveDrawingBuffer:te,powerPreference:re};if(k.addEventListener("webglcontextlost",r,!1),k.addEventListener("webglcontextrestored",o,!1),null===(se=G||k.getContext("webgl",Ie)||k.getContext("experimental-webgl",Ie)))throw null!==k.getContext("webgl")?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.");void 0===se.getShaderPrecisionFormat&&(se.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){console.error("THREE.WebGLRenderer: "+e.message)}var Ne,De,Ue,Be,Fe,ze,ke,Ge,Ve,je,We,Xe,qe,Ye,Ze,Je,Ke;n();var Qe=null;"undefined"!=typeof navigator&&(Qe="xr"in navigator?new St(ce):new Tt(ce)),this.vr=Qe;var $e=new vt(ce,Ve,De.maxTextureSize);this.shadowMap=$e,this.getContext=function(){return se},this.getContextAttributes=function(){return se.getContextAttributes()},this.forceContextLoss=function(){var e=Ne.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){var e=Ne.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return Me},this.setPixelRatio=function(e){void 0!==e&&(Me=e,this.setSize(be,_e,!1))},this.getSize=function(){return{width:be,height:_e}},this.setSize=function(e,t,n){if(Qe.isPresenting())return void console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");be=e,_e=t,k.width=e*Me,k.height=t*Me,!1!==n&&(k.style.width=e+"px",k.style.height=t+"px"),this.setViewport(0,0,e,t)},this.getDrawingBufferSize=function(){return{width:be*Me,height:_e*Me}},this.setDrawingBufferSize=function(e,t,n){be=e,_e=t,Me=n,k.width=e*n,k.height=t*n,this.setViewport(0,0,e,t)},this.getCurrentViewport=function(){return ge},this.setViewport=function(e,t,n,i){Ee.set(e,_e-t-i,n,i),Ue.viewport(ge.copy(Ee).multiplyScalar(Me))},this.setScissor=function(e,t,n,i){Te.set(e,_e-t-i,n,i),Ue.scissor(ye.copy(Te).multiplyScalar(Me))},this.setScissorTest=function(e){Ue.setScissorTest(Se=e)},this.getClearColor=function(){return qe.getClearColor()},this.setClearColor=function(){qe.setClearColor.apply(qe,arguments)},this.getClearAlpha=function(){return qe.getClearAlpha()},this.setClearAlpha=function(){qe.setClearAlpha.apply(qe,arguments)},this.clear=function(e,t,n){var i=0;(void 0===e||e)&&(i|=16384),(void 0===t||t)&&(i|=256),(void 0===n||n)&&(i|=1024),se.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){k.removeEventListener("webglcontextlost",r,!1),k.removeEventListener("webglcontextrestored",o,!1),We.dispose(),Xe.dispose(),Fe.dispose(),Ve.dispose(),Qe.dispose(),tt.stop()},this.renderBufferImmediate=function(e,t){Ue.initAttributes();var n=Fe.get(e);e.hasPositions&&!n.position&&(n.position=se.createBuffer()),e.hasNormals&&!n.normal&&(n.normal=se.createBuffer()),e.hasUvs&&!n.uv&&(n.uv=se.createBuffer()),e.hasColors&&!n.color&&(n.color=se.createBuffer());var i=t.getAttributes();e.hasPositions&&(se.bindBuffer(34962,n.position),se.bufferData(34962,e.positionArray,35048),Ue.enableAttribute(i.position),se.vertexAttribPointer(i.position,3,5126,!1,0,0)),e.hasNormals&&(se.bindBuffer(34962,n.normal),se.bufferData(34962,e.normalArray,35048),Ue.enableAttribute(i.normal),se.vertexAttribPointer(i.normal,3,5126,!1,0,0)),e.hasUvs&&(se.bindBuffer(34962,n.uv),se.bufferData(34962,e.uvArray,35048),Ue.enableAttribute(i.uv),se.vertexAttribPointer(i.uv,2,5126,!1,0,0)),e.hasColors&&(se.bindBuffer(34962,n.color),se.bufferData(34962,e.colorArray,35048),Ue.enableAttribute(i.color),se.vertexAttribPointer(i.color,3,5126,!1,0,0)),Ue.disableUnusedAttributes(),se.drawArrays(4,0,e.count),e.count=0},this.renderBufferDirect=function(e,n,i,r,a,o){var s=a.isMesh&&a.normalMatrix.determinant()<0;Ue.setMaterial(r,s);var c=_(e,n,r,a),l=!1;fe.geometry===i.id&&fe.program===c.id&&fe.wireframe===(!0===r.wireframe)||(fe.geometry=i.id,fe.program=c.id,fe.wireframe=!0===r.wireframe,l=!0),a.morphTargetInfluences&&(Ye.update(a,i,r,c),l=!0);var h=i.index,u=i.attributes.position,p=1;!0===r.wireframe&&(h=Ge.getWireframeAttribute(i),p=2);var f,m=Ze;null!==h&&(f=ke.get(h),(m=Je).setIndex(f)),l&&(d(r,c,i),null!==h&&se.bindBuffer(34963,f.buffer));var v=1/0;null!==h?v=h.count:void 0!==u&&(v=u.count);var g=i.drawRange.start*p,y=i.drawRange.count*p,x=null!==o?o.start*p:0,w=null!==o?o.count*p:1/0,b=Math.max(g,x),M=Math.min(v,g+y,x+w)-1,E=Math.max(0,M-b+1);if(0!==E){if(a.isMesh)if(!0===r.wireframe)Ue.setLineWidth(r.wireframeLinewidth*t()),m.setMode(1);else switch(a.drawMode){case Yb:m.setMode(4);break;case Zb:m.setMode(5);break;case Jb:m.setMode(6)}else if(a.isLine){var T=r.linewidth;void 0===T&&(T=1),Ue.setLineWidth(T*t()),a.isLineSegments?m.setMode(1):a.isLineLoop?m.setMode(2):m.setMode(3)}else a.isPoints?m.setMode(0):a.isSprite&&m.setMode(4);i&&i.isInstancedBufferGeometry?i.maxInstancedCount>0&&m.renderInstances(i,b,E):m.render(b,E)}},this.compile=function(e,t){(oe=Xe.get(e,t)).init(),e.traverse(function(e){e.isLight&&(oe.pushLight(e),e.castShadow&&oe.pushShadow(e))}),oe.setupLights(t),e.traverse(function(t){if(t.material)if(Array.isArray(t.material))for(var n=0;n=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&se.readPixels(t,n,i,r,Ke.convert(l),Ke.convert(h),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&se.bindFramebuffer(36160,pe)}}},this.copyFramebufferToTexture=function(e,t,n){var i=t.image.width,r=t.image.height,a=Ke.convert(t.format);this.setTexture2D(t,0),se.copyTexImage2D(3553,n||0,a,e.x,e.y,i,r,0)},this.copyTextureToTexture=function(e,t,n,i){var r=t.image.width,a=t.image.height,o=Ke.convert(n.format),s=Ke.convert(n.type);this.setTexture2D(n,0),t.isDataTexture?se.texSubImage2D(3553,i||0,e.x,e.y,r,a,o,s,t.image.data):se.texSubImage2D(3553,i||0,e.x,e.y,o,s,t.image)}}function Lt(e,t){this.name="",this.color=new v(e),this.density=void 0!==t?t:25e-5}function Rt(e,t,n){this.name="",this.color=new v(e),this.near=void 0!==t?t:1,this.far=void 0!==n?n:1e3}function Ct(){_.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function Pt(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}function Ot(e,t,n,i){this.data=e,this.itemSize=t,this.offset=n,this.normalized=!0===i}function It(e){G.call(this),this.type="SpriteMaterial",this.color=new v(16777215),this.map=null,this.rotation=0,this.sizeAttenuation=!0,this.lights=!1,this.transparent=!0,this.setValues(e)}function Nt(e){if(_.call(this),this.type="Sprite",void 0===I_){I_=new U;var t=new Pt(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);I_.setIndex([0,1,2,0,2,3]),I_.addAttribute("position",new Ot(t,3,0,!1)),I_.addAttribute("uv",new Ot(t,2,3,!1))}this.geometry=I_,this.material=void 0!==e?e:new It,this.center=new n(.5,.5)}function Dt(){_.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function Ut(e,t){if(e=e||[],this.bones=e.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===t)this.calculateInverses();else if(this.bones.length===t.length)this.boneInverses=t.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var n=0,r=this.bones.length;n=0?(e(g-1e-5,v,p),d.subVectors(u,p)):(e(g+1e-5,v,p),d.subVectors(p,u)),v-1e-5>=0?(e(g,v-1e-5,p),f.subVectors(u,p)):(e(g,v+1e-5,p),f.subVectors(p,u)),h.crossVectors(d,f).normalize(),c.push(h.x,h.y,h.z),l.push(g,v)}}for(i=0;i.9&&a<.1&&(t<.2&&(m[e+0]+=1),n<.2&&(m[e+2]+=1),i<.2&&(m[e+4]+=1))}}function c(e){f.push(e.x,e.y,e.z)}function l(t,n){var i=3*t;n.x=e[i+0],n.y=e[i+1],n.z=e[i+2]}function h(){for(var e=new a,t=new a,i=new a,r=new a,o=new n,s=new n,c=new n,l=0,h=0;l0)for(a=t;a=t;a-=i)o=zn(a,e[a],e[a+1],o);return o&&In(o,o.next)&&(kn(o),o=o.next),o}function vn(e,t){if(!e)return e;t||(t=e);var n,i=e;do{if(n=!1,i.steiner||!In(i,i.next)&&0!==On(i.prev,i,i.next))i=i.next;else{if(kn(i),(i=t=i.prev)===i.next)break;n=!0}}while(n||i!==t);return t}function gn(e,t,n,i,r,a,o){if(e){!o&&a&&Sn(e,i,r,a);for(var s,c,l=e;e.prev!==e.next;)if(s=e.prev,c=e.next,a?xn(e,i,r,a):yn(e))t.push(s.i/n),t.push(e.i/n),t.push(c.i/n),kn(e),e=c.next,l=c.next;else if((e=c)===l){o?1===o?gn(e=wn(e,t,n),t,n,i,r,a,2):2===o&&bn(e,t,n,i,r,a):gn(vn(e),t,n,i,r,a,1);break}}}function yn(e){var t=e.prev,n=e,i=e.next;if(On(t,n,i)>=0)return!1;for(var r=e.next.next;r!==e.prev;){if(Cn(t.x,t.y,n.x,n.y,i.x,i.y,r.x,r.y)&&On(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function xn(e,t,n,i){var r=e.prev,a=e,o=e.next;if(On(r,a,o)>=0)return!1;for(var s=r.xa.x?r.x>o.x?r.x:o.x:a.x>o.x?a.x:o.x,h=r.y>a.y?r.y>o.y?r.y:o.y:a.y>o.y?a.y:o.y,u=Ln(s,c,t,n,i),p=Ln(l,h,t,n,i),d=e.nextZ;d&&d.z<=p;){if(d!==e.prev&&d!==e.next&&Cn(r.x,r.y,a.x,a.y,o.x,o.y,d.x,d.y)&&On(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(d=e.prevZ;d&&d.z>=u;){if(d!==e.prev&&d!==e.next&&Cn(r.x,r.y,a.x,a.y,o.x,o.y,d.x,d.y)&&On(d.prev,d,d.next)>=0)return!1;d=d.prevZ}return!0}function wn(e,t,n){var i=e;do{var r=i.prev,a=i.next.next;!In(r,a)&&Nn(r,i,i.next,a)&&Un(r,a)&&Un(a,r)&&(t.push(r.i/n),t.push(i.i/n),t.push(a.i/n),kn(i),kn(i.next),i=e=a),i=i.next}while(i!==e);return i}function bn(e,t,n,i,r,a){var o=e;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&Pn(o,s)){var c=Fn(o,s);return o=vn(o,o.next),c=vn(c,c.next),gn(o,t,n,i,r,a),void gn(c,t,n,i,r,a)}s=s.next}o=o.next}while(o!==e)}function _n(e,t,n,i){var r,a,o,s=[];for(r=0,a=t.length;r=i.next.y&&i.next.y!==i.y){var s=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=r&&s>o){if(o=s,s===r){if(a===i.y)return i;if(a===i.next.y)return i.next}n=i.x=i.x&&i.x>=h&&r!==i.x&&Cn(an.x)&&Un(i,e)&&(n=i,p=c),i=i.next;return n}function Sn(e,t,n,i){var r=e;do{null===r.z&&(r.z=Ln(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,An(r)}function An(e){var t,n,i,r,a,o,s,c,l=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,i=n,s=0,t=0;t0||c>0&&i;)0!==s&&(0===c||!i||n.z<=i.z)?(r=n,n=n.nextZ,s--):(r=i,i=i.nextZ,c--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,l*=2}while(o>1);return e}function Ln(e,t,n,i,r){return e=32767*(e-n)*r,t=32767*(t-i)*r,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1}function Rn(e){var t=e,n=e;do{t.x=0&&(e-o)*(i-s)-(n-o)*(t-s)>=0&&(n-o)*(a-s)-(r-o)*(i-s)>=0}function Pn(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Dn(e,t)&&Un(e,t)&&Un(t,e)&&Bn(e,t)}function On(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function In(e,t){return e.x===t.x&&e.y===t.y}function Nn(e,t,n,i){return!!(In(e,t)&&In(n,i)||In(e,i)&&In(n,t))||On(e,t,n)>0!=On(e,t,i)>0&&On(n,i,e)>0!=On(n,i,t)>0}function Dn(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Nn(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Un(e,t){return On(e.prev,e,e.next)<0?On(e,t,e.next)>=0&&On(e,e.prev,t)>=0:On(e,t,e.prev)<0||On(e,e.next,t)<0}function Bn(e,t){var n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}function Fn(e,t){var n=new Gn(e.i,e.x,e.y),i=new Gn(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function zn(e,t,n,i){var r=new Gn(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function kn(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Gn(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Hn(e,t,n,i){for(var r=0,a=t,o=n-i;a2&&e[t-1].equals(e[0])&&e.pop()}function jn(e,t){for(var n=0;nNumber.EPSILON){var d=Math.sqrt(u),f=Math.sqrt(l*l+h*h),m=t.x-c/d,v=t.y+s/d,g=((i.x-h/f-m)*h-(i.y+l/f-v)*l)/(s*h-c*l),y=(r=m+s*g-e.x)*r+(a=v+c*g-e.y)*a;if(y<=2)return new n(r,a);o=Math.sqrt(y/2)}else{var x=!1;s>Number.EPSILON?l>Number.EPSILON&&(x=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(x=!0):Math.sign(c)===Math.sign(h)&&(x=!0),x?(r=-c,a=s,o=Math.sqrt(u)):(r=s,a=c,o=Math.sqrt(u/2))}return new n(r/o,a/o)}function l(e,t){var n,i;for(Y=e.length;--Y>=0;){n=Y,(i=Y-1)<0&&(i=e.length-1);var r=0,a=g+2*_;for(r=0;r=0;z--){for(G=z/_,H=w*Math.cos(G*Math.PI/2),k=b*Math.sin(G*Math.PI/2),Y=0,Z=F.length;Y0)&&m.push(_,M,T),(l!==n-1||h0&&h(!0),t>0&&h(!1)),this.setIndex(p),this.addAttribute("position",new O(d,3)),this.addAttribute("normal",new O(f,3)),this.addAttribute("uv",new O(m,2))}function ci(e,t,n,i,r,a,o){oi.call(this,0,e,t,n,i,r,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}function li(e,t,n,i,r,a,o){si.call(this,0,e,t,n,i,r,a,o),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}function hi(e,t,n,i){M.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},this.fromBufferGeometry(new ui(e,t,n,i)),this.mergeVertices()}function ui(e,t,i,r){U.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},e=e||1,t=void 0!==t?Math.max(3,t):8,i=void 0!==i?i:0,r=void 0!==r?r:2*Math.PI;var o,s,c=[],l=[],h=[],u=[],p=new a,d=new n;for(l.push(0,0,0),h.push(0,0,1),u.push(.5,.5),s=0,o=3;s<=t;s++,o+=3){var f=i+s/t*r;p.x=e*Math.cos(f),p.y=e*Math.sin(f),l.push(p.x,p.y,p.z),h.push(0,0,1),d.x=(l[o]/e+1)/2,d.y=(l[o+1]/e+1)/2,u.push(d.x,d.y)}for(o=1;o<=t;o++)c.push(o,o+1,0);this.setIndex(c),this.addAttribute("position",new O(l,3)),this.addAttribute("normal",new O(h,3)),this.addAttribute("uv",new O(u,2))}function pi(e){G.call(this),this.type="ShadowMaterial",this.color=new v(0),this.transparent=!0,this.setValues(e)}function di(e){H.call(this,e),this.type="RawShaderMaterial"}function fi(e){G.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new v(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new v(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=o_,this.normalScale=new n(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function mi(e){fi.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(e)}function vi(e){G.call(this),this.type="MeshPhongMaterial",this.color=new v(16777215),this.specular=new v(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new v(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=o_,this.normalScale=new n(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Ow,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function gi(e){vi.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(e)}function yi(e){G.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=o_,this.normalScale=new n(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function xi(e){G.call(this),this.type="MeshLambertMaterial",this.color=new v(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new v(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Ow,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function wi(e){if(G.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new v(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=o_,this.normalScale=new n(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.lights=!1,this.setValues(e),null===this.matcap){var t=document.createElement("canvas");t.width=1,t.height=1;var i=t.getContext("2d");i.fillStyle="#fff",i.fillRect(0,0,1,1),this.matcap=new THREE.CanvasTexture(t)}}function bi(e){zt.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}function _i(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n}function Mi(e,t,n,i){_i.call(this,e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Ei(e,t,n,i){_i.call(this,e,t,n,i)}function Ti(e,t,n,i){_i.call(this,e,t,n,i)}function Si(e,t,n,i){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=z_.convertArray(t,this.TimeBufferType),this.values=z_.convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}function Ai(e,t,n){Si.call(this,e,t,n)}function Li(e,t,n,i){Si.call(this,e,t,n,i)}function Ri(e,t,n,i){Si.call(this,e,t,n,i)}function Ci(e,t,n,i){_i.call(this,e,t,n,i)}function Pi(e,t,n,i){Si.call(this,e,t,n,i)}function Oi(e,t,n,i){Si.call(this,e,t,n,i)}function Ii(e,t,n,i){Si.call(this,e,t,n,i)}function Ni(e,t,n){this.name=e,this.tracks=n,this.duration=void 0!==t?t:-1,this.uuid=c_.generateUUID(),this.duration<0&&this.resetDuration()}function Di(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ri;case"vector":case"vector2":case"vector3":case"vector4":return Ii;case"color":return Li;case"quaternion":return Pi;case"bool":case"boolean":return Ai;case"string":return Oi}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function Ui(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");var t=Di(e.type);if(void 0===e.times){var n=[],i=[];z_.flattenJSON(e.keys,n,i,"value"),e.times=n,e.values=i}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}function Bi(e,t,n){var i=this,r=!1,a=0,o=0,s=void 0;this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,!1===r&&void 0!==i.onStart&&i.onStart(e,a,o),r=!0},this.itemEnd=function(e){a++,void 0!==i.onProgress&&i.onProgress(e,a,o),a===o&&(r=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(e){void 0!==i.onError&&i.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this}}function Fi(e){this.manager=void 0!==e?e:G_}function zi(e){this.manager=void 0!==e?e:G_}function ki(e){this.manager=void 0!==e?e:G_,this._parser=null}function Gi(e){this.manager=void 0!==e?e:G_,this._parser=null}function Hi(e){this.manager=void 0!==e?e:G_}function Vi(e){this.manager=void 0!==e?e:G_}function ji(e){this.manager=void 0!==e?e:G_}function Wi(){this.type="Curve",this.arcLengthDivisions=200}function Xi(e,t,n,i,r,a,o,s){Wi.call(this),this.type="EllipseCurve",this.aX=e||0,this.aY=t||0,this.xRadius=n||1,this.yRadius=i||1,this.aStartAngle=r||0,this.aEndAngle=a||2*Math.PI,this.aClockwise=o||!1,this.aRotation=s||0}function qi(e,t,n,i,r,a){Xi.call(this,e,t,n,n,i,r,a),this.type="ArcCurve"}function Yi(){function e(e,a,o,s){t=e,n=o,i=-3*e+3*a-2*o-s,r=2*e-2*a+o+s}var t=0,n=0,i=0,r=0;return{initCatmullRom:function(t,n,i,r,a){e(n,i,a*(i-t),a*(r-n))},initNonuniformCatmullRom:function(t,n,i,r,a,o,s){var c=(n-t)/a-(i-t)/(a+o)+(i-n)/o,l=(i-n)/o-(r-n)/(o+s)+(r-i)/s;e(n,i,c*=o,l*=o)},calc:function(e){var a=e*e;return t+n*e+i*a+r*(a*e)}}}function Zi(e,t,n,i){Wi.call(this),this.type="CatmullRomCurve3",this.points=e||[],this.closed=t||!1,this.curveType=n||"centripetal",this.tension=i||.5}function Ji(e,t,n,i,r){var a=.5*(i-t),o=.5*(r-n),s=e*e;return(2*n-2*i+a+o)*(e*s)+(-3*n+3*i-2*a-o)*s+a*e+n}function Ki(e,t){var n=1-e;return n*n*t}function Qi(e,t){return 2*(1-e)*e*t}function $i(e,t){return e*e*t}function er(e,t,n,i){return Ki(e,t)+Qi(e,n)+$i(e,i)}function tr(e,t){var n=1-e;return n*n*n*t}function nr(e,t){var n=1-e;return 3*n*n*e*t}function ir(e,t){return 3*(1-e)*e*e*t}function rr(e,t){return e*e*e*t}function ar(e,t,n,i,r){return tr(e,t)+nr(e,n)+ir(e,i)+rr(e,r)}function or(e,t,i,r){Wi.call(this),this.type="CubicBezierCurve",this.v0=e||new n,this.v1=t||new n,this.v2=i||new n,this.v3=r||new n}function sr(e,t,n,i){Wi.call(this),this.type="CubicBezierCurve3",this.v0=e||new a,this.v1=t||new a,this.v2=n||new a,this.v3=i||new a}function cr(e,t){Wi.call(this),this.type="LineCurve",this.v1=e||new n,this.v2=t||new n}function lr(e,t){Wi.call(this),this.type="LineCurve3",this.v1=e||new a,this.v2=t||new a}function hr(e,t,i){Wi.call(this),this.type="QuadraticBezierCurve",this.v0=e||new n,this.v1=t||new n,this.v2=i||new n}function ur(e,t,n){Wi.call(this),this.type="QuadraticBezierCurve3",this.v0=e||new a,this.v1=t||new a,this.v2=n||new a}function pr(e){Wi.call(this),this.type="SplineCurve",this.points=e||[]}function dr(){Wi.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}function fr(e){dr.call(this),this.type="Path",this.currentPoint=new n,e&&this.setFromPoints(e)}function mr(e){fr.call(this,e),this.uuid=c_.generateUUID(),this.type="Shape",this.holes=[]}function vr(e,t){_.call(this),this.type="Light",this.color=new v(e),this.intensity=void 0!==t?t:1,this.receiveShadow=void 0}function gr(e,t,n){vr.call(this,e,n),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(_.DefaultUp),this.updateMatrix(),this.groundColor=new v(t)}function yr(e){this.camera=e,this.bias=0,this.radius=1,this.mapSize=new n(512,512),this.map=null,this.matrix=new i}function xr(){yr.call(this,new _t(50,1,.5,500))}function wr(e,t,n,i,r,a){vr.call(this,e,t),this.type="SpotLight",this.position.copy(_.DefaultUp),this.updateMatrix(),this.target=new _,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(e){this.intensity=e/Math.PI}}),this.distance=void 0!==n?n:0,this.angle=void 0!==i?i:Math.PI/3,this.penumbra=void 0!==r?r:0,this.decay=void 0!==a?a:1,this.shadow=new xr}function br(e,t,n,i){vr.call(this,e,t),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(e){this.intensity=e/(4*Math.PI)}}),this.distance=void 0!==n?n:0,this.decay=void 0!==i?i:1,this.shadow=new yr(new _t(90,1,.5,500))}function _r(e,t,n,i,r,a){bt.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=void 0!==e?e:-1,this.right=void 0!==t?t:1,this.top=void 0!==n?n:1,this.bottom=void 0!==i?i:-1,this.near=void 0!==r?r:.1,this.far=void 0!==a?a:2e3,this.updateProjectionMatrix()}function Mr(){yr.call(this,new _r(-5,5,5,-5,.5,500))}function Er(e,t){vr.call(this,e,t),this.type="DirectionalLight",this.position.copy(_.DefaultUp),this.updateMatrix(),this.target=new _,this.shadow=new Mr}function Tr(e,t){vr.call(this,e,t),this.type="AmbientLight",this.castShadow=void 0}function Sr(e,t,n,i){vr.call(this,e,t),this.type="RectAreaLight",this.width=void 0!==n?n:10,this.height=void 0!==i?i:10}function Ar(e){this.manager=void 0!==e?e:G_,this.textures={}}function Lr(e){this.manager=void 0!==e?e:G_}function Rr(){}function Cr(e){"boolean"==typeof e&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),e=void 0),this.manager=void 0!==e?e:G_,this.withCredentials=!1}function Pr(e){this.manager=void 0!==e?e:G_,this.resourcePath=""}function Or(e){"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.manager=void 0!==e?e:G_,this.options=void 0}function Ir(){this.type="ShapePath",this.color=new v,this.subPaths=[],this.currentPath=null}function Nr(e){this.type="Font",this.data=e}function Dr(e,t,n){for(var i=Array.from?Array.from(e):String(e).split(""),r=t/n.resolution,a=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*r,o=[],s=0,c=0,l=0;l=0&&u<=1&&p>=0&&p<=1?oo({x:e+u*(n-e),y:t+u*(i-t)}):cM}function oo(e){var t=so("intersecting");return t.point=e,t}function so(e){return{type:e}}function co(){var e=this;if(!(this instanceof co))return new(Function.prototype.bind.apply(co,[null].concat(Array.prototype.slice.call(arguments))));Array.from(arguments).forEach(function(t){e[t]=Symbol(t)})}function lo(e,t){return dM===uM.All||dM==e||t===pM.Warning||t===pM.Error||t===pM.Fatal}function ho(e,t,n){if(!1!==lo(e,t)){var i="";switch(t){case pM.Information:i="[INFO_] ";break;case pM.Warning:i="[WARNG] ";break;case pM.Error:i="[ERROR] ";break;case pM.Fatal:i="[FATAL] ";break;case pM.Debug:i="[DEBUG] "}console.log(i+n)}}function uo(e,t){return t={exports:{}},e(t,t.exports),t.exports}function po(){}function fo(e,t){this.x=e||0,this.y=t||0}function mo(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function vo(e,t,n,i){this._x=e||0,this._y=t||0,this._z=n||0,this._w=void 0!==i?i:1}function go(e,t,n){this.x=e||0,this.y=t||0,this.z=n||0}function yo(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function xo(e,t,n,i,r,a,o,s,c,l){Object.defineProperty(this,"id",{value:KT++}),this.uuid=JT.generateUUID(),this.name="",this.image=void 0!==e?e:xo.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:xo.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:BE,this.wrapT=void 0!==i?i:BE,this.magFilter=void 0!==r?r:HE,this.minFilter=void 0!==a?a:jE,this.anisotropy=void 0!==c?c:1,this.format=void 0!==o?o:aT,this.type=void 0!==s?s:WE,this.offset=new fo(0,0),this.repeat=new fo(1,1),this.center=new fo(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new yo,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==l?l:zT,this.version=0,this.onUpdate=null}function wo(e,t,n,i){this.x=e||0,this.y=t||0,this.z=n||0,this.w=void 0!==i?i:1}function bo(e,t,n){this.width=e,this.height=t,this.scissor=new wo(0,0,e,t),this.scissorTest=!1,this.viewport=new wo(0,0,e,t),void 0===(n=n||{}).minFilter&&(n.minFilter=HE),this.texture=new xo(void 0,void 0,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.generateMipmaps=void 0===n.generateMipmaps||n.generateMipmaps,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0===n.stencilBuffer||n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null}function _o(e,t,n){bo.call(this,e,t,n),this.activeCubeFace=0,this.activeMipMapLevel=0}function Mo(e,t,n,i,r,a,o,s,c,l,h,u){xo.call(this,null,a,o,s,c,l,i,r,h,u),this.image={data:e,width:t,height:n},this.magFilter=void 0!==c?c:zE,this.minFilter=void 0!==l?l:zE,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function Eo(e,t){this.min=void 0!==e?e:new go(1/0,1/0,1/0),this.max=void 0!==t?t:new go(-1/0,-1/0,-1/0)}function To(e,t){this.center=void 0!==e?e:new go,this.radius=void 0!==t?t:0}function So(e,t){this.normal=void 0!==e?e:new go(1,0,0),this.constant=void 0!==t?t:0}function Ao(e,t,n,i,r,a){this.planes=[void 0!==e?e:new So,void 0!==t?t:new So,void 0!==n?n:new So,void 0!==i?i:new So,void 0!==r?r:new So,void 0!==a?a:new So]}function Lo(e,t,n){return void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}function Ro(){function e(r,a){!1!==n&&(i(r,a),t.requestAnimationFrame(e))}var t=null,n=!1,i=null;return{start:function(){!0!==n&&null!==i&&(t.requestAnimationFrame(e),n=!0)},stop:function(){n=!1},setAnimationLoop:function(e){i=e},setContext:function(e){t=e}}}function Co(e){function t(t,n){var i=t.array,r=t.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW,a=e.createBuffer();e.bindBuffer(n,a),e.bufferData(n,i,r),t.onUploadCallback();var o=e.FLOAT;return i instanceof Float32Array?o=e.FLOAT:i instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):i instanceof Uint16Array?o=e.UNSIGNED_SHORT:i instanceof Int16Array?o=e.SHORT:i instanceof Uint32Array?o=e.UNSIGNED_INT:i instanceof Int32Array?o=e.INT:i instanceof Int8Array?o=e.BYTE:i instanceof Uint8Array&&(o=e.UNSIGNED_BYTE),{buffer:a,type:o,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version}}function n(t,n,i){var r=n.array,a=n.updateRange;e.bindBuffer(i,t),!1===n.dynamic?e.bufferData(i,r,e.STATIC_DRAW):-1===a.count?e.bufferSubData(i,0,r):0===a.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(e.bufferSubData(i,a.offset*r.BYTES_PER_ELEMENT,r.subarray(a.offset,a.offset+a.count)),a.count=-1)}function i(e){return e.isInterleavedBufferAttribute&&(e=e.data),o.get(e)}function r(t){t.isInterleavedBufferAttribute&&(t=t.data);var n=o.get(t);n&&(e.deleteBuffer(n.buffer),o.delete(t))}function a(e,i){e.isInterleavedBufferAttribute&&(e=e.data);var r=o.get(e);void 0===r?o.set(e,t(e,i)):r.versiont&&(t=e[n]);return t}function Jo(){Object.defineProperty(this,"id",{value:aS+=2}),this.uuid=JT.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}function Ko(e,t,n,i,r,a){Bo.call(this),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a},this.fromBufferGeometry(new Qo(e,t,n,i,r,a)),this.mergeVertices()}function Qo(e,t,n,i,r,a){function o(e,t,n,i,r,a,o,f,m,v,g){var y,x,w=a/m,b=o/v,_=a/2,M=o/2,E=f/2,T=m+1,S=v+1,A=0,L=0,R=new go;for(x=0;x0?1:-1,h.push(R.x,R.y,R.z),u.push(y/m),u.push(1-x/v),A+=1}}for(x=0;x0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var a,o=void 0!==n.precision?n.precision:"highp",s=r(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);var c=!0===n.logarithmicDepthBuffer,l=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),h=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),d=e.getParameter(e.MAX_VERTEX_ATTRIBS),f=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),m=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),g=h>0,y=!!t.get("OES_texture_float");return{getMaxAnisotropy:i,getMaxPrecision:r,precision:o,logarithmicDepthBuffer:c,maxTextures:l,maxVertexTextures:h,maxTextureSize:u,maxCubemapSize:p,maxAttributes:d,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:v,vertexTextures:g,floatFragmentTextures:y,floatVertexTextures:g&&y}}function us(){function e(){l.value!==i&&(l.value=i,l.needsUpdate=r>0),n.numPlanes=r,n.numIntersection=0}function t(e,t,i,r){var a=null!==e?e.length:0,o=null;if(0!==a){if(o=l.value,!0!==r||null===o){var h=i+4*a,u=t.matrixWorldInverse;c.getNormalMatrix(u),(null===o||o.length65535?Wo:Vo)(r,1),t.update(i,e.ELEMENT_ARRAY_BUFFER),c[n.id]=i,i}var s={},c={};return{get:r,update:a,getWireframeAttribute:o}}function fs(e,t,n){function i(e){s=e}function r(e){c=e.type,l=e.bytesPerElement}function a(t,i){e.drawElements(s,i,c,t*l),n.update(i,s)}function o(e,i,r){var a=t.get("ANGLE_instanced_arrays");if(null===a)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");a.drawElementsInstancedANGLE(s,r,c,i*l,e.maxInstancedCount),n.update(r,s,e.maxInstancedCount)}var s,c,l;this.setMode=i,this.setIndex=r,this.render=a,this.renderInstances=o}function ms(e){function t(t,n,r){switch(r=r||1,i.calls++,n){case e.TRIANGLES:i.triangles+=r*(t/3);break;case e.TRIANGLE_STRIP:case e.TRIANGLE_FAN:i.triangles+=r*(t-2);break;case e.LINES:i.lines+=r*(t/2);break;case e.LINE_STRIP:i.lines+=r*(t-1);break;case e.LINE_LOOP:i.lines+=r*t;break;case e.POINTS:i.points+=r*t;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}function n(){i.frame++,i.calls=0,i.triangles=0,i.points=0,i.lines=0}var i={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:i,programs:null,autoReset:!0,reset:n,update:t}}function vs(e,t){return Math.abs(t[1])-Math.abs(e[1])}function gs(e){function t(t,r,a,o){var s=t.morphTargetInfluences,c=s.length,l=n[r.id];if(void 0===l){l=[];for(p=0;p0)return e;var r=t*n,a=lS[r];if(void 0===a&&(a=new Float32Array(r),lS[r]=a),0!==t){i.toArray(a,0);for(var o=1,s=0;o!==t;++o)s+=n,e[o].toArray(a,s)}return a}function _s(e,t){if(e.length!==t.length)return!1;for(var n=0,i=e.length;n");return fc(n)}return e.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,t)}function mc(e){function t(e,t,n,i){for(var r="",a=parseInt(t);a0?e.gammaFactor:1,g=cc(i.extensions,a,t),y=lc(s),x=o.createProgram();i.isRawShaderMaterial?((f=[y].filter(uc).join("\n")).length>0&&(f+="\n"),(m=[g,y].filter(uc).join("\n")).length>0&&(m+="\n")):(f=["precision "+a.precision+" float;","precision "+a.precision+" int;","#define SHADER_NAME "+r.name,y,a.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+v,"#define MAX_BONES "+a.maxBones,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+p:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.displacementMap&&a.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.vertexColors?"#define USE_COLOR":"",a.flatShading?"#define FLAT_SHADED":"",a.skinning?"#define USE_SKINNING":"",a.useVertexTexture?"#define BONE_TEXTURE":"",a.morphTargets?"#define USE_MORPHTARGETS":"",a.morphNormals&&!1===a.flatShading?"#define USE_MORPHNORMALS":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+h:"",a.sizeAttenuation?"#define USE_SIZEATTENUATION":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&t.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(uc).join("\n"),m=[g,"precision "+a.precision+" float;","precision "+a.precision+" int;","#define SHADER_NAME "+r.name,y,a.alphaTest?"#define ALPHATEST "+a.alphaTest+(a.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+v,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+u:"",a.envMap?"#define "+p:"",a.envMap?"#define "+d:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.vertexColors?"#define USE_COLOR":"",a.gradientMap?"#define USE_GRADIENTMAP":"",a.flatShading?"#define FLAT_SHADED":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+h:"",a.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",a.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&t.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",a.envMap&&t.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",a.toneMapping!==EE?"#define TONE_MAPPING":"",a.toneMapping!==EE?QT.tonemapping_pars_fragment:"",a.toneMapping!==EE?sc("toneMapping",a.toneMapping):"",a.dithering?"#define DITHERING":"",a.outputEncoding||a.mapEncoding||a.envMapEncoding||a.emissiveMapEncoding?QT.encodings_pars_fragment:"",a.mapEncoding?ac("mapTexelToLinear",a.mapEncoding):"",a.envMapEncoding?ac("envMapTexelToLinear",a.envMapEncoding):"",a.emissiveMapEncoding?ac("emissiveMapTexelToLinear",a.emissiveMapEncoding):"",a.outputEncoding?oc("linearToOutputTexel",a.outputEncoding):"",a.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(uc).join("\n")),c=dc(c=pc(c=fc(c),a),a),l=dc(l=pc(l=fc(l),a),a);var w=f+(c=mc(c)),b=m+(l=mc(l)),_=ic(o,o.VERTEX_SHADER,w),M=ic(o,o.FRAGMENT_SHADER,b);o.attachShader(x,_),o.attachShader(x,M),void 0!==i.index0AttributeName?o.bindAttribLocation(x,0,i.index0AttributeName):!0===a.morphTargets&&o.bindAttribLocation(x,0,"position"),o.linkProgram(x);var E=o.getProgramInfoLog(x).trim(),T=o.getShaderInfoLog(_).trim(),S=o.getShaderInfoLog(M).trim(),A=!0,L=!0;!1===o.getProgramParameter(x,o.LINK_STATUS)?(A=!1,console.error("THREE.WebGLProgram: shader error: ",o.getError(),"gl.VALIDATE_STATUS",o.getProgramParameter(x,o.VALIDATE_STATUS),"gl.getProgramInfoLog",E,T,S)):""!==E?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",E):""!==T&&""!==S||(L=!1),L&&(this.diagnostics={runnable:A,material:i,programLog:E,vertexShader:{log:T,prefix:f},fragmentShader:{log:S,prefix:m}}),o.deleteShader(_),o.deleteShader(M);var R;this.getUniforms=function(){return void 0===R&&(R=new tc(o,x,e)),R};var C;return this.getAttributes=function(){return void 0===C&&(C=hc(o,x)),C},this.destroy=function(){o.deleteProgram(x),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms()."),this.getUniforms()}},attributes:{get:function(){return console.warn("THREE.WebGLProgram: .attributes is now .getAttributes()."),this.getAttributes()}}}),this.name=r.name,this.id=mS++,this.code=n,this.usedTimes=1,this.program=x,this.vertexShader=_,this.fragmentShader=M,this}function gc(e,t,n){function i(e){var t=e.skeleton.bones;if(n.floatVertexTextures)return 1024;var i=n.maxVertexUniforms,r=Math.floor((i-20)/4),a=Math.min(r,t.length);return a0,maxBones:d,useVertexTexture:n.floatVertexTextures,morphTargets:t.morphTargets,morphNormals:t.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numClippingPlanes:l,numClipIntersection:h,dithering:t.dithering,shadowMapEnabled:e.shadowMap.enabled&&u.receiveShadow&&s.length>0,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:t.premultipliedAlpha,alphaTest:t.alphaTest,doubleSided:t.side===GM,flipSided:t.side===kM,depthPacking:void 0!==t.depthPacking&&t.depthPacking}},this.getProgramCode=function(t,n){var i=[];if(n.shaderID?i.push(n.shaderID):(i.push(t.fragmentShader),i.push(t.vertexShader)),void 0!==t.defines)for(var r in t.defines)i.push(r),i.push(t.defines[r]);for(var a=0;a1&&a.sort(xc),o.length>1&&o.sort(wc)}var i=[],r=0,a=[],o=[];return{opaque:a,transparent:o,init:e,push:t,sort:n}}function _c(){function e(e,t){var i=e.id+","+t.id,r=n[i];return void 0===r&&(r=new bc,n[i]=r),r}function t(){n={}}var n={};return{get:e,dispose:t}}function Mc(){var e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];var n;switch(t.type){case"DirectionalLight":n={direction:new go,color:new Lo,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new fo};break;case"SpotLight":n={position:new go,direction:new go,color:new Lo,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new fo};break;case"PointLight":n={position:new go,color:new Lo,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new fo,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":n={direction:new go,skyColor:new Lo,groundColor:new Lo};break;case"RectAreaLight":n={color:new Lo,position:new go,halfWidth:new go,halfHeight:new go}}return e[t.id]=n,n}}}function Ec(){function e(e,o,s){for(var c=0,l=0,h=0,u=0,p=0,d=0,f=0,m=0,v=s.matrixWorldInverse,g=0,y=e.length;g0:s&&s.isGeometry&&(d=s.morphTargets&&s.morphTargets.length>0)),t.isSkinnedMesh&&!1===n.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",t);var y=t.isSkinnedMesh&&n.skinning,x=0;d&&(x|=u),y&&(x|=p),c=l[x]}if(e.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var w=c.uuid,b=n.uuid,_=v[w];void 0===_&&(_={},v[w]=_);var M=_[b];void 0===M&&(M=c.clone(),_[b]=M),c=M}return c.visible=n.visible,c.wireframe=n.wireframe,c.side=null!=n.shadowSide?n.shadowSide:g[n.side],c.clipShadows=n.clipShadows,c.clippingPlanes=n.clippingPlanes,c.clipIntersection=n.clipIntersection,c.wireframeLinewidth=n.wireframeLinewidth,c.linewidth=n.linewidth,i&&c.isMeshDistanceMaterial&&(c.referencePosition.copy(r),c.nearDistance=a,c.farDistance=o),c}function r(n,o,s,c){if(!1!==n.visible){if(n.layers.test(o.layers)&&(n.isMesh||n.isLine||n.isPoints)&&n.castShadow&&(!n.frustumCulled||a.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);var l=t.update(n),u=n.material;if(Array.isArray(u))for(var p=l.groups,d=0,f=p.length;d 0 ) {","\t\tfloat fogFactor = 0.0;","\t\tif ( fogType == 1 ) {","\t\t\tfogFactor = smoothstep( fogNear, fogFar, fogDepth );","\t\t} else {","\t\t\tconst float LOG2 = 1.442695;","\t\t\tfogFactor = exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 );","\t\t\tfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","\t\t}","\t\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );","\t}","}"].join("\n")),t.compileShader(n),t.compileShader(i),t.attachShader(e,n),t.attachShader(e,i),t.linkProgram(e),e}function s(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:t.id-e.id}var c,l,h,u,p,d,f=new go,m=new vo,v=new go;this.render=function(r,o,g){if(0!==r.length){void 0===h&&a(),n.useProgram(h),n.initAttributes(),n.enableAttribute(u.position),n.enableAttribute(u.uv),n.disableUnusedAttributes(),n.disable(t.CULL_FACE),n.enable(t.BLEND),t.bindBuffer(t.ARRAY_BUFFER,c),t.vertexAttribPointer(u.position,2,t.FLOAT,!1,16,0),t.vertexAttribPointer(u.uv,2,t.FLOAT,!1,16,8),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,l),t.uniformMatrix4fv(p.projectionMatrix,!1,g.projectionMatrix.elements),n.activeTexture(t.TEXTURE0),t.uniform1i(p.map,0);var y=0,x=0,w=o.fog;w?(t.uniform3f(p.fogColor,w.color.r,w.color.g,w.color.b),w.isFog?(t.uniform1f(p.fogNear,w.near),t.uniform1f(p.fogFar,w.far),t.uniform1i(p.fogType,1),y=1,x=1):w.isFogExp2&&(t.uniform1f(p.fogDensity,w.density),t.uniform1i(p.fogType,2),y=2,x=2)):(t.uniform1i(p.fogType,0),y=0,x=0);for(var b=0,_=r.length;b<_;b++)(T=r[b]).modelViewMatrix.multiplyMatrices(g.matrixWorldInverse,T.matrixWorld),T.z=-T.modelViewMatrix.elements[14];r.sort(s);for(var M=[],E=[],b=0,_=r.length;b<_;b++){var T=r[b],S=T.material;if(!1!==S.visible){T.onBeforeRender(e,o,g,void 0,S,void 0),t.uniform1f(p.alphaTest,S.alphaTest),t.uniformMatrix4fv(p.modelViewMatrix,!1,T.modelViewMatrix.elements),T.matrixWorld.decompose(f,m,v),M[0]=v.x,M[1]=v.y,E[0]=T.center.x-.5,E[1]=T.center.y-.5;var A=0;o.fog&&S.fog&&(A=x),y!==A&&(t.uniform1i(p.fogType,A),y=A),null!==S.map?(t.uniform2f(p.uvOffset,S.map.offset.x,S.map.offset.y),t.uniform2f(p.uvScale,S.map.repeat.x,S.map.repeat.y)):(t.uniform2f(p.uvOffset,0,0),t.uniform2f(p.uvScale,1,1)),t.uniform1f(p.opacity,S.opacity),t.uniform3f(p.color,S.color.r,S.color.g,S.color.b),t.uniform1f(p.rotation,S.rotation),t.uniform2fv(p.center,E),t.uniform2fv(p.scale,M),n.setBlending(S.blending,S.blendEquation,S.blendSrc,S.blendDst,S.blendEquationAlpha,S.blendSrcAlpha,S.blendDstAlpha,S.premultipliedAlpha),n.buffers.depth.setTest(S.depthTest),n.buffers.depth.setMask(S.depthWrite),n.buffers.color.setMask(S.colorWrite),i.setTexture2D(S.map||d,0),t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0),T.onAfterRender(e,o,g,void 0,S,void 0)}}n.enable(t.CULL_FACE),n.reset()}}}function Oc(e,t,n){function i(){var t=!1,n=new wo,i=null,r=new wo(0,0,0,0);return{setMask:function(n){i===n||t||(e.colorMask(n,n,n,n),i=n)},setLocked:function(e){t=e},setClear:function(t,i,a,o,s){!0===s&&(t*=o,i*=o,a*=o),n.set(t,i,a,o),!1===r.equals(n)&&(e.clearColor(t,i,a,o),r.copy(n))},reset:function(){t=!1,i=null,r.set(-1,0,0,0)}}}function r(){var t=!1,n=null,i=null,r=null;return{setTest:function(t){t?u(e.DEPTH_TEST):p(e.DEPTH_TEST)},setMask:function(i){n===i||t||(e.depthMask(i),n=i)},setFunc:function(t){if(i!==t){if(t)switch(t){case dE:e.depthFunc(e.NEVER);break;case fE:e.depthFunc(e.ALWAYS);break;case mE:e.depthFunc(e.LESS);break;case vE:e.depthFunc(e.LEQUAL);break;case gE:e.depthFunc(e.EQUAL);break;case yE:e.depthFunc(e.GEQUAL);break;case xE:e.depthFunc(e.GREATER);break;case wE:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}else e.depthFunc(e.LEQUAL);i=t}},setLocked:function(e){t=e},setClear:function(t){r!==t&&(e.clearDepth(t),r=t)},reset:function(){t=!1,n=null,i=null,r=null}}}function a(){var t=!1,n=null,i=null,r=null,a=null,o=null,s=null,c=null,l=null;return{setTest:function(t){t?u(e.STENCIL_TEST):p(e.STENCIL_TEST)},setMask:function(i){n===i||t||(e.stencilMask(i),n=i)},setFunc:function(t,n,o){i===t&&r===n&&a===o||(e.stencilFunc(t,n,o),i=t,r=n,a=o)},setOp:function(t,n,i){o===t&&s===n&&c===i||(e.stencilOp(t,n,i),o=t,s=n,c=i)},setLocked:function(e){t=e},setClear:function(t){l!==t&&(e.clearStencil(t),l=t)},reset:function(){t=!1,n=null,i=null,r=null,a=null,o=null,s=null,c=null,l=null}}}function o(t,n,i){var r=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(var o=0;o=1):-1!==te.indexOf("OpenGL ES")&&(ee=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(te)[1]),$=ee>=2);var ne=null,ie={},re=new wo,ae=new wo,oe={};return oe[e.TEXTURE_2D]=o(e.TEXTURE_2D,e.TEXTURE_2D,1),oe[e.TEXTURE_CUBE_MAP]=o(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),R.setClear(0,0,0,1),C.setClear(1),P.setClear(0),u(e.DEPTH_TEST),C.setFunc(vE),g(!1),y(DM),u(e.CULL_FACE),u(e.BLEND),m(XM),{buffers:{color:R,depth:C,stencil:P},initAttributes:s,enableAttribute:c,enableAttributeAndDivisor:l,disableUnusedAttributes:h,enable:u,disable:p,getCompressedTextureFormats:d,useProgram:f,setBlending:m,setMaterial:v,setFlipSided:g,setCullFace:y,setLineWidth:x,setPolygonOffset:w,setScissorTest:b,activeTexture:_,bindTexture:M,compressedTexImage2D:E,texImage2D:T,scissor:S,viewport:A,reset:L}}function Ic(e,t,n,i,r,a,o){function s(e,t){if(e.width>t||e.height>t){if("data"in e)return void console.warn("THREE.WebGLRenderer: image in DataTexture is too big ("+e.width+"x"+e.height+").");var n=t/Math.max(e.width,e.height),i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return i.width=Math.floor(e.width*n),i.height=Math.floor(e.height*n),i.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,i.width,i.height),console.warn("THREE.WebGLRenderer: image is too big ("+e.width+"x"+e.height+"). Resized to "+i.width+"x"+i.height,e),i}return e}function c(e){return JT.isPowerOfTwo(e.width)&&JT.isPowerOfTwo(e.height)}function l(e){return e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof ImageBitmap?(void 0===C&&(C=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),C.width=JT.floorPowerOfTwo(e.width),C.height=JT.floorPowerOfTwo(e.height),C.getContext("2d").drawImage(e,0,0,C.width,C.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+e.width+"x"+e.height+"). Resized to "+C.width+"x"+C.height,e),C):e}function h(e){return e.wrapS!==BE||e.wrapT!==BE||e.minFilter!==zE&&e.minFilter!==HE}function u(e,t){return e.generateMipmaps&&t&&e.minFilter!==zE&&e.minFilter!==HE}function p(t,n,r,a){e.generateMipmap(t),i.get(n).__maxMipLevel=Math.log(Math.max(r,a))*Math.LOG2E}function d(t){return t===zE||t===kE||t===GE?e.NEAREST:e.LINEAR}function f(e){var t=e.target;t.removeEventListener("dispose",f),v(t),t.isVideoTexture&&delete O[t.id],o.memory.textures--}function m(e){var t=e.target;t.removeEventListener("dispose",m),g(t),o.memory.textures--}function v(t){var n=i.get(t);if(t.image&&n.__image__webglTextureCube)e.deleteTexture(n.__image__webglTextureCube);else{if(void 0===n.__webglInit)return;e.deleteTexture(n.__webglTexture)}i.remove(t)}function g(t){var n=i.get(t),r=i.get(t.texture);if(t){if(void 0!==r.__webglTexture&&e.deleteTexture(r.__webglTexture),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLRenderTargetCube)for(var a=0;a<6;a++)e.deleteFramebuffer(n.__webglFramebuffer[a]),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[a]);else e.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer);i.remove(t.texture),i.remove(t)}}function y(t,r){var a=i.get(t);if(t.isVideoTexture&&R(t),t.version>0&&a.__version!==t.version){var o=t.image;if(void 0===o)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",t);else{if(!1!==o.complete)return void _(a,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",t)}}n.activeTexture(e.TEXTURE0+r),n.bindTexture(e.TEXTURE_2D,a.__webglTexture)}function x(t,l){var h=i.get(t);if(6===t.image.length)if(t.version>0&&h.__version!==t.version){h.__image__webglTextureCube||(t.addEventListener("dispose",f),h.__image__webglTextureCube=e.createTexture(),o.memory.textures++),n.activeTexture(e.TEXTURE0+l),n.bindTexture(e.TEXTURE_CUBE_MAP,h.__image__webglTextureCube),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t.flipY);for(var d=t&&t.isCompressedTexture,m=t.image[0]&&t.image[0].isDataTexture,v=[],g=0;g<6;g++)v[g]=d||m?m?t.image[g].image:t.image[g]:s(t.image[g],r.maxCubemapSize);var y=v[0],x=c(y),w=a.convert(t.format),_=a.convert(t.type);b(e.TEXTURE_CUBE_MAP,t,x);for(g=0;g<6;g++)if(d)for(var M,E=v[g].mipmaps,T=0,S=E.length;T-1?n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,T,w,M.width,M.height,0,M.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,T,w,M.width,M.height,0,w,_,M.data);else m?n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,w,v[g].width,v[g].height,0,w,_,v[g].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,w,w,_,v[g]);h.__maxMipLevel=d?E.length-1:0,u(t,x)&&p(e.TEXTURE_CUBE_MAP,t,y.width,y.height),h.__version=t.version,t.onUpdate&&t.onUpdate(t)}else n.activeTexture(e.TEXTURE0+l),n.bindTexture(e.TEXTURE_CUBE_MAP,h.__image__webglTextureCube)}function w(t,r){n.activeTexture(e.TEXTURE0+r),n.bindTexture(e.TEXTURE_CUBE_MAP,i.get(t).__webglTexture)}function b(n,o,s){var c;if(s?(e.texParameteri(n,e.TEXTURE_WRAP_S,a.convert(o.wrapS)),e.texParameteri(n,e.TEXTURE_WRAP_T,a.convert(o.wrapT)),e.texParameteri(n,e.TEXTURE_MAG_FILTER,a.convert(o.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,a.convert(o.minFilter))):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),o.wrapS===BE&&o.wrapT===BE||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",o),e.texParameteri(n,e.TEXTURE_MAG_FILTER,d(o.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,d(o.minFilter)),o.minFilter!==zE&&o.minFilter!==HE&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",o)),c=t.get("EXT_texture_filter_anisotropic")){if(o.type===KE&&null===t.get("OES_texture_float_linear"))return;if(o.type===QE&&null===t.get("OES_texture_half_float_linear"))return;(o.anisotropy>1||i.get(o).__currentAnisotropy)&&(e.texParameterf(n,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,r.getMaxAnisotropy())),i.get(o).__currentAnisotropy=o.anisotropy)}}function _(t,i,d){void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",f),t.__webglTexture=e.createTexture(),o.memory.textures++),n.activeTexture(e.TEXTURE0+d),n.bindTexture(e.TEXTURE_2D,t.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,i.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,i.unpackAlignment);var m=s(i.image,r.maxTextureSize);h(i)&&!1===c(m)&&(m=l(m));var v=c(m),g=a.convert(i.format),y=a.convert(i.type);b(e.TEXTURE_2D,i,v);var x,w=i.mipmaps;if(i.isDepthTexture){var _=e.DEPTH_COMPONENT;if(i.type===KE){if(!P)throw new Error("Float Depth Texture only supported in WebGL2.0");_=e.DEPTH_COMPONENT32F}else P&&(_=e.DEPTH_COMPONENT16);i.format===lT&&_===e.DEPTH_COMPONENT&&i.type!==YE&&i.type!==JE&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=YE,y=a.convert(i.type)),i.format===hT&&(_=e.DEPTH_STENCIL,i.type!==nT&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=nT,y=a.convert(i.type))),n.texImage2D(e.TEXTURE_2D,0,_,m.width,m.height,0,g,y,null)}else if(i.isDataTexture)if(w.length>0&&v){for(var M=0,E=w.length;M-1?n.compressedTexImage2D(e.TEXTURE_2D,M,g,x.width,x.height,0,x.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(e.TEXTURE_2D,M,g,x.width,x.height,0,g,y,x.data);t.__maxMipLevel=w.length-1}else if(w.length>0&&v){for(var M=0,E=w.length;M=0){var c=i[o];if(void 0!==c){var l=c.normalized,h=c.itemSize,u=be.get(c);if(void 0===u)continue;var p=u.buffer,d=u.type,f=u.bytesPerElement;if(c.isInterleavedBufferAttribute){var m=c.data,v=m.stride,g=c.offset;m&&m.isInstancedInterleavedBuffer?(ge.enableAttributeAndDivisor(s,m.meshPerAttribute),void 0===n.maxInstancedCount&&(n.maxInstancedCount=m.meshPerAttribute*m.count)):ge.enableAttribute(s),H.bindBuffer(H.ARRAY_BUFFER,p),H.vertexAttribPointer(s,h,d,l,v*f,g*f)}else c.isInstancedBufferAttribute?(ge.enableAttributeAndDivisor(s,c.meshPerAttribute),void 0===n.maxInstancedCount&&(n.maxInstancedCount=c.meshPerAttribute*c.count)):ge.enableAttribute(s),H.bindBuffer(H.ARRAY_BUFFER,p),H.vertexAttribPointer(s,h,d,l,0,0)}else if(void 0!==a){var y=a[o];if(void 0!==y)switch(y.length){case 2:H.vertexAttrib2fv(s,y);break;case 3:H.vertexAttrib3fv(s,y);break;case 4:H.vertexAttrib4fv(s,y);break;default:H.vertexAttrib1fv(s,y)}}}}ge.disableUnusedAttributes()}function h(e){Ie.isPresenting()||De&&De(e)}function u(e,t,n){if(!1!==e.visible){if(e.layers.test(t.layers))if(e.isLight)G.pushLight(e),e.castShadow&&G.pushShadow(e);else if(e.isSprite)e.frustumCulled&&!ce.intersectsSprite(e)||G.pushSprite(e);else if(e.isImmediateRenderObject)n&&de.setFromMatrixPosition(e.matrixWorld).applyMatrix4(pe),k.push(e,null,e.material,de.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.update(),!e.frustumCulled||ce.intersectsObject(e))){n&&de.setFromMatrixPosition(e.matrixWorld).applyMatrix4(pe);var i=Me.update(e),r=e.material;if(Array.isArray(r))for(var a=i.groups,o=0,s=a.length;o=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(var f=0;f=0&&e.numSupportedMorphNormals++}var m=i.shader.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(i.numClippingPlanes=le.numPlanes,i.numIntersection=le.numIntersection,m.clippingPlanes=le.uniform),i.fog=t,i.lightsHash=r.state.hash,e.lights&&(m.ambientLightColor.value=r.state.ambient,m.directionalLights.value=r.state.directional,m.spotLights.value=r.state.spot,m.rectAreaLights.value=r.state.rectArea,m.pointLights.value=r.state.point,m.hemisphereLights.value=r.state.hemi,m.directionalShadowMap.value=r.state.directionalShadowMap,m.directionalShadowMatrix.value=r.state.directionalShadowMatrix,m.spotShadowMap.value=r.state.spotShadowMap,m.spotShadowMatrix.value=r.state.spotShadowMatrix,m.pointShadowMap.value=r.state.pointShadowMap,m.pointShadowMatrix.value=r.state.pointShadowMatrix);var v=i.program.getUniforms(),g=tc.seqWithValue(v.seq,m);i.uniformsList=g}function m(e,t,n,i){te=0;var r=xe.get(n),a=G.state.lights;if(he&&(ue||e!==J)){var o=e===J&&n.id===Y;le.setState(n.clippingPlanes,n.clipIntersection,n.clipShadows,e,r,o)}!1===n.needsUpdate&&(void 0===r.program?n.needsUpdate=!0:n.fog&&r.fog!==t?n.needsUpdate=!0:n.lights&&r.lightsHash!==a.state.hash?n.needsUpdate=!0:void 0===r.numClippingPlanes||r.numClippingPlanes===le.numPlanes&&r.numIntersection===le.numIntersection||(n.needsUpdate=!0)),n.needsUpdate&&(f(n,t,i),n.needsUpdate=!1);var s=!1,c=!1,l=!1,h=r.program,u=h.getUniforms(),p=r.shader.uniforms;if(ge.useProgram(h.program)&&(s=!0,c=!0,l=!0),n.id!==Y&&(Y=n.id,c=!0),s||e!==J){if(u.setValue(H,"projectionMatrix",e.projectionMatrix),ve.logarithmicDepthBuffer&&u.setValue(H,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),J!==(K||e)&&(J=K||e,c=!0,l=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.envMap){var d=u.map.cameraPosition;void 0!==d&&d.setValue(H,de.setFromMatrixPosition(e.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.skinning)&&u.setValue(H,"viewMatrix",e.matrixWorldInverse)}if(n.skinning){u.setOptional(H,i,"bindMatrix"),u.setOptional(H,i,"bindMatrixInverse");var m=i.skeleton;if(m){var C=m.bones;if(ve.floatVertexTextures){if(void 0===m.boneTexture){var P=Math.sqrt(4*C.length);P=JT.ceilPowerOfTwo(P),P=Math.max(P,4);var O=new Float32Array(P*P*4);O.set(m.boneMatrices);var I=new Mo(O,P,P,aT,KE);I.needsUpdate=!0,m.boneMatrices=O,m.boneTexture=I,m.boneTextureSize=P}u.setValue(H,"boneTexture",m.boneTexture),u.setValue(H,"boneTextureSize",m.boneTextureSize)}else u.setOptional(H,m,"boneMatrices")}}return c&&(u.setValue(H,"toneMappingExposure",V.toneMappingExposure),u.setValue(H,"toneMappingWhitePoint",V.toneMappingWhitePoint),n.lights&&R(p,l),t&&n.fog&&w(p,t),n.isMeshBasicMaterial?v(p,n):n.isMeshLambertMaterial?(v(p,n),b(p,n)):n.isMeshPhongMaterial?(v(p,n),n.isMeshToonMaterial?M(p,n):_(p,n)):n.isMeshStandardMaterial?(v(p,n),n.isMeshPhysicalMaterial?T(p,n):E(p,n)):n.isMeshDepthMaterial?(v(p,n),S(p,n)):n.isMeshDistanceMaterial?(v(p,n),A(p,n)):n.isMeshNormalMaterial?(v(p,n),L(p,n)):n.isLineBasicMaterial?(g(p,n),n.isLineDashedMaterial&&y(p,n)):n.isPointsMaterial?x(p,n):n.isShadowMaterial&&(p.color.value=n.color,p.opacity.value=n.opacity),void 0!==p.ltc_1&&(p.ltc_1.value=tS.LTC_1),void 0!==p.ltc_2&&(p.ltc_2.value=tS.LTC_2),tc.upload(H,r.uniformsList,p,V)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(tc.upload(H,r.uniformsList,p,V),n.uniformsNeedUpdate=!1),u.setValue(H,"modelViewMatrix",i.modelViewMatrix),u.setValue(H,"normalMatrix",i.normalMatrix),u.setValue(H,"modelMatrix",i.matrixWorld),h}function v(e,t){e.opacity.value=t.opacity,t.color&&(e.diffuse.value=t.color),t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.specularMap&&(e.specularMap.value=t.specularMap),t.envMap&&(e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap&&t.envMap.isCubeTexture?-1:1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio,e.maxMipLevel.value=xe.get(t.envMap).__maxMipLevel),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity);var n;t.map?n=t.map:t.specularMap?n=t.specularMap:t.displacementMap?n=t.displacementMap:t.normalMap?n=t.normalMap:t.bumpMap?n=t.bumpMap:t.roughnessMap?n=t.roughnessMap:t.metalnessMap?n=t.metalnessMap:t.alphaMap?n=t.alphaMap:t.emissiveMap&&(n=t.emissiveMap),void 0!==n&&(n.isWebGLRenderTarget&&(n=n.texture),!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}function g(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}function y(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function x(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size*re,e.scale.value=.5*ie,e.map.value=t.map,null!==t.map&&(!0===t.map.matrixAutoUpdate&&t.map.updateMatrix(),e.uvTransform.value.copy(t.map.matrix))}function w(e,t){e.fogColor.value=t.color,t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)}function b(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}function _(e,t){e.specular.value=t.specular,e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===kM&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===kM&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function M(e,t){_(e,t),t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function E(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===kM&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===kM&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function T(e,t){E(e,t),e.reflectivity.value=t.reflectivity,e.clearCoat.value=t.clearCoat,e.clearCoatRoughness.value=t.clearCoatRoughness}function S(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function A(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}function L(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===kM&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===kM&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function R(e,t){e.ambientLightColor.needsUpdate=t,e.directionalLights.needsUpdate=t,e.pointLights.needsUpdate=t,e.spotLights.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function C(){var e=te;return e>=ve.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+e+" texture units while this GPU supports only "+ve.maxTextures),te+=1,e}console.log("THREE.WebGLRenderer",OM);var P=void 0!==(e=e||{}).canvas?e.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),O=void 0!==e.context?e.context:null,I=void 0!==e.alpha&&e.alpha,N=void 0===e.depth||e.depth,D=void 0===e.stencil||e.stencil,U=void 0!==e.antialias&&e.antialias,B=void 0===e.premultipliedAlpha||e.premultipliedAlpha,F=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,z=void 0!==e.powerPreference?e.powerPreference:"default",k=null,G=null;this.domElement=P,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=TE,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var H,V=this,j=!1,W=null,X=null,q=null,Y=-1,Z="",J=null,K=null,Q=new wo,$=new wo,ee=null,te=0,ne=P.width,ie=P.height,re=1,ae=new wo(0,0,ne,ie),oe=new wo(0,0,ne,ie),se=!1,ce=new Ao,le=new us,he=!1,ue=!1,pe=new mo,de=new go;try{var fe={alpha:I,depth:N,stencil:D,antialias:U,premultipliedAlpha:B,preserveDrawingBuffer:F,powerPreference:z};if(P.addEventListener("webglcontextlost",i,!1),P.addEventListener("webglcontextrestored",r,!1),null===(H=O||P.getContext("webgl",fe)||P.getContext("experimental-webgl",fe)))throw null!==P.getContext("webgl")?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.");void 0===H.getShaderPrecisionFormat&&(H.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){console.error("THREE.WebGLRenderer: "+e.message)}var me,ve,ge,ye,xe,we,be,_e,Me,Ee,Te,Se,Ae,Le,Re,Ce,Pe,Oe;n();var Ie="xr"in navigator?new zc(V):new Fc(V);this.vr=Ie;var Ne=new Rc(V,Me,ve.maxTextureSize);this.shadowMap=Ne,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){var e=me.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){var e=me.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(e){void 0!==e&&(re=e,this.setSize(ne,ie,!1))},this.getSize=function(){return{width:ne,height:ie}},this.setSize=function(e,t,n){if(Ie.isPresenting())return void console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");ne=e,ie=t,P.width=e*re,P.height=t*re,!1!==n&&(P.style.width=e+"px",P.style.height=t+"px"),this.setViewport(0,0,e,t)},this.getDrawingBufferSize=function(){return{width:ne*re,height:ie*re}},this.setDrawingBufferSize=function(e,t,n){ne=e,ie=t,re=n,P.width=e*n,P.height=t*n,this.setViewport(0,0,e,t)},this.getCurrentViewport=function(){return Q},this.setViewport=function(e,t,n,i){ae.set(e,ie-t-i,n,i),ge.viewport(Q.copy(ae).multiplyScalar(re))},this.setScissor=function(e,t,n,i){oe.set(e,ie-t-i,n,i),ge.scissor($.copy(oe).multiplyScalar(re))},this.setScissorTest=function(e){ge.setScissorTest(se=e)},this.getClearColor=function(){return Ae.getClearColor()},this.setClearColor=function(){Ae.setClearColor.apply(Ae,arguments)},this.getClearAlpha=function(){return Ae.getClearAlpha()},this.setClearAlpha=function(){Ae.setClearAlpha.apply(Ae,arguments)},this.clear=function(e,t,n){var i=0;(void 0===e||e)&&(i|=H.COLOR_BUFFER_BIT),(void 0===t||t)&&(i|=H.DEPTH_BUFFER_BIT),(void 0===n||n)&&(i|=H.STENCIL_BUFFER_BIT),H.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.clearTarget=function(e,t,n,i){this.setRenderTarget(e),this.clear(t,n,i)},this.dispose=function(){P.removeEventListener("webglcontextlost",i,!1),P.removeEventListener("webglcontextrestored",r,!1),Te.dispose(),Se.dispose(),xe.dispose(),Me.dispose(),Ie.dispose(),Ue.stop()},this.renderBufferImmediate=function(e,t,n){ge.initAttributes();var i=xe.get(e);e.hasPositions&&!i.position&&(i.position=H.createBuffer()),e.hasNormals&&!i.normal&&(i.normal=H.createBuffer()),e.hasUvs&&!i.uv&&(i.uv=H.createBuffer()),e.hasColors&&!i.color&&(i.color=H.createBuffer());var r=t.getAttributes();if(e.hasPositions&&(H.bindBuffer(H.ARRAY_BUFFER,i.position),H.bufferData(H.ARRAY_BUFFER,e.positionArray,H.DYNAMIC_DRAW),ge.enableAttribute(r.position),H.vertexAttribPointer(r.position,3,H.FLOAT,!1,0,0)),e.hasNormals){if(H.bindBuffer(H.ARRAY_BUFFER,i.normal),!n.isMeshPhongMaterial&&!n.isMeshStandardMaterial&&!n.isMeshNormalMaterial&&!0===n.flatShading)for(var a=0,o=3*e.count;a0&&g.renderInstances(i,M,T):g.render(M,T)}},this.compile=function(e,t){(G=Se.get(e,t)).init(),e.traverse(function(e){e.isLight&&(G.pushLight(e),e.castShadow&&G.pushShadow(e))}),G.setupLights(t),e.traverse(function(t){if(t.material)if(Array.isArray(t.material))for(var n=0;n=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&H.readPixels(t,n,i,r,Oe.convert(l),Oe.convert(h),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&H.bindFramebuffer(H.FRAMEBUFFER,q)}}},this.copyFramebufferToTexture=function(e,t,n){var i=t.image.width,r=t.image.height,a=Oe.convert(t.format);this.setTexture2D(t,0),H.copyTexImage2D(H.TEXTURE_2D,n||0,a,e.x,e.y,i,r,0)},this.copyTextureToTexture=function(e,t,n,i){var r=t.image.width,a=t.image.height,o=Oe.convert(n.format),s=Oe.convert(n.type);this.setTexture2D(n,0),t.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,i||0,e.x,e.y,r,a,o,s,t.image.data):H.texSubImage2D(H.TEXTURE_2D,i||0,e.x,e.y,o,s,t.image)}}function Gc(e,t){this.name="",this.color=new Lo(e),this.density=void 0!==t?t:25e-5}function Hc(e,t,n){this.name="",this.color=new Lo(e),this.near=void 0!==t?t:1,this.far=void 0!==n?n:1e3}function Vc(){Io.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function jc(e){ts.call(this),this.type="SpriteMaterial",this.color=new Lo(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(e)}function Wc(e){Io.call(this),this.type="Sprite",this.material=void 0!==e?e:new jc,this.center=new fo(.5,.5)}function Xc(){Io.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function qc(e,t){if(e=e||[],this.bones=e.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===t)this.calculateInverses();else if(this.bones.length===t.length)this.boneInverses=t.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var n=0,i=this.bones.length;n=0?(e(v-1e-5,m,u),p.subVectors(h,u)):(e(v+1e-5,m,u),p.subVectors(u,h)),m-1e-5>=0?(e(v,m-1e-5,u),d.subVectors(h,u)):(e(v,m+1e-5,u),d.subVectors(u,h)),l.crossVectors(p,d).normalize(),s.push(l.x,l.y,l.z),c.push(v,m)}}for(i=0;i.9&&a<.1&&(t<.2&&(d[e+0]+=1),n<.2&&(d[e+2]+=1),i<.2&&(d[e+4]+=1))}}function o(e){p.push(e.x,e.y,e.z)}function s(t,n){var i=3*t;n.x=e[i+0],n.y=e[i+1],n.z=e[i+2]}function c(){for(var e=new go,t=new go,n=new go,i=new go,r=new fo,a=new fo,o=new fo,s=0,c=0;s0)for(a=t;a=t;a-=i)o=Yl(a,e[a],e[a+1],o);return o&&Hl(o,o.next)&&(Zl(o),o=o.next),o}function Tl(e,t){if(!e)return e;t||(t=e);var n,i=e;do{if(n=!1,i.steiner||!Hl(i,i.next)&&0!==Gl(i.prev,i,i.next))i=i.next;else{if(Zl(i),(i=t=i.prev)===i.next)break;n=!0}}while(n||i!==t);return t}function Sl(e,t,n,i,r,a,o){if(e){!o&&a&&Dl(e,i,r,a);for(var s,c,l=e;e.prev!==e.next;)if(s=e.prev,c=e.next,a?Ll(e,i,r,a):Al(e))t.push(s.i/n),t.push(e.i/n),t.push(c.i/n),Zl(e),e=c.next,l=c.next;else if((e=c)===l){o?1===o?Sl(e=Rl(e,t,n),t,n,i,r,a,2):2===o&&Cl(e,t,n,i,r,a):Sl(Tl(e),t,n,i,r,a,1);break}}}function Al(e){var t=e.prev,n=e,i=e.next;if(Gl(t,n,i)>=0)return!1;for(var r=e.next.next;r!==e.prev;){if(zl(t.x,t.y,n.x,n.y,i.x,i.y,r.x,r.y)&&Gl(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Ll(e,t,n,i){var r=e.prev,a=e,o=e.next;if(Gl(r,a,o)>=0)return!1;for(var s=r.xa.x?r.x>o.x?r.x:o.x:a.x>o.x?a.x:o.x,h=r.y>a.y?r.y>o.y?r.y:o.y:a.y>o.y?a.y:o.y,u=Bl(s,c,t,n,i),p=Bl(l,h,t,n,i),d=e.nextZ;d&&d.z<=p;){if(d!==e.prev&&d!==e.next&&zl(r.x,r.y,a.x,a.y,o.x,o.y,d.x,d.y)&&Gl(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(d=e.prevZ;d&&d.z>=u;){if(d!==e.prev&&d!==e.next&&zl(r.x,r.y,a.x,a.y,o.x,o.y,d.x,d.y)&&Gl(d.prev,d,d.next)>=0)return!1;d=d.prevZ}return!0}function Rl(e,t,n){var i=e;do{var r=i.prev,a=i.next.next;!Hl(r,a)&&Vl(r,i,i.next,a)&&Wl(r,a)&&Wl(a,r)&&(t.push(r.i/n),t.push(i.i/n),t.push(a.i/n),Zl(i),Zl(i.next),i=e=a),i=i.next}while(i!==e);return i}function Cl(e,t,n,i,r,a){var o=e;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&kl(o,s)){var c=ql(o,s);return o=Tl(o,o.next),c=Tl(c,c.next),Sl(o,t,n,i,r,a),void Sl(c,t,n,i,r,a)}s=s.next}o=o.next}while(o!==e)}function Pl(e,t,n,i){var r,a,o,s=[];for(r=0,a=t.length;r=i.next.y&&i.next.y!==i.y){var s=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=r&&s>o){if(o=s,s===r){if(a===i.y)return i;if(a===i.next.y)return i.next}n=i.x=i.x&&i.x>=h&&r!==i.x&&zl(an.x)&&Wl(i,e)&&(n=i,p=c),i=i.next;return n}function Dl(e,t,n,i){var r=e;do{null===r.z&&(r.z=Bl(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,Ul(r)}function Ul(e){var t,n,i,r,a,o,s,c,l=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,i=n,s=0,t=0;t0||c>0&&i;)0!==s&&(0===c||!i||n.z<=i.z)?(r=n,n=n.nextZ,s--):(r=i,i=i.nextZ,c--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,l*=2}while(o>1);return e}function Bl(e,t,n,i,r){return e=32767*(e-n)*r,t=32767*(t-i)*r,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1}function Fl(e){var t=e,n=e;do{t.x=0&&(e-o)*(i-s)-(n-o)*(t-s)>=0&&(n-o)*(a-s)-(r-o)*(i-s)>=0}function kl(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!jl(e,t)&&Wl(e,t)&&Wl(t,e)&&Xl(e,t)}function Gl(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Hl(e,t){return e.x===t.x&&e.y===t.y}function Vl(e,t,n,i){return!!(Hl(e,t)&&Hl(n,i)||Hl(e,i)&&Hl(n,t))||Gl(e,t,n)>0!=Gl(e,t,i)>0&&Gl(n,i,e)>0!=Gl(n,i,t)>0}function jl(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Vl(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Wl(e,t){return Gl(e.prev,e,e.next)<0?Gl(e,t,e.next)>=0&&Gl(e,e.prev,t)>=0:Gl(e,t,e.prev)<0||Gl(e,e.next,t)<0}function Xl(e,t){var n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}function ql(e,t){var n=new Jl(e.i,e.x,e.y),i=new Jl(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function Yl(e,t,n,i){var r=new Jl(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Zl(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Jl(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Kl(e,t,n,i){for(var r=0,a=t,o=n-i;a2&&e[t-1].equals(e[0])&&e.pop()}function $l(e,t){for(var n=0;nNumber.EPSILON){var p=Math.sqrt(h),d=Math.sqrt(c*c+l*l),f=t.x-s/p,m=t.y+o/p,v=((n.x-l/d-f)*l-(n.y+c/d-m)*c)/(o*l-s*c),g=(i=f+o*v-e.x)*i+(r=m+s*v-e.y)*r;if(g<=2)return new fo(i,r);a=Math.sqrt(g/2)}else{var y=!1;o>Number.EPSILON?c>Number.EPSILON&&(y=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(l)&&(y=!0),y?(i=-s,r=o,a=Math.sqrt(h)):(i=o,r=s,a=Math.sqrt(h/2))}return new fo(i/a,r/a)}function s(e,t){var n,i;for(X=e.length;--X>=0;){n=X,(i=X-1)<0&&(i=e.length-1);var r=0,a=m+2*w;for(r=0;r=0;B--){for(z=B/w,k=y*Math.cos(z*Math.PI/2),F=x*Math.sin(z*Math.PI/2),X=0,q=U.length;X0)&&f.push(b,_,E),(c!==n-1||l0&&c(!0),t>0&&c(!1)),this.setIndex(h),this.addAttribute("position",new Xo(u,3)),this.addAttribute("normal",new Xo(p,3)),this.addAttribute("uv",new Xo(d,2))}function gh(e,t,n,i,r,a,o){mh.call(this,0,e,t,n,i,r,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}function yh(e,t,n,i,r,a,o){vh.call(this,0,e,t,n,i,r,a,o),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}function xh(e,t,n,i){Bo.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},this.fromBufferGeometry(new wh(e,t,n,i)),this.mergeVertices()}function wh(e,t,n,i){Jo.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},e=e||1,t=void 0!==t?Math.max(3,t):8,n=void 0!==n?n:0,i=void 0!==i?i:2*Math.PI;var r,a,o=[],s=[],c=[],l=[],h=new go,u=new fo;for(s.push(0,0,0),c.push(0,0,1),l.push(.5,.5),a=0,r=3;a<=t;a++,r+=3){var p=n+a/t*i;h.x=e*Math.cos(p),h.y=e*Math.sin(p),s.push(h.x,h.y,h.z),c.push(0,0,1),u.x=(s[r]/e+1)/2,u.y=(s[r+1]/e+1)/2,l.push(u.x,u.y)}for(r=1;r<=t;r++)o.push(r,r+1,0);this.setIndex(o),this.addAttribute("position",new Xo(s,3)),this.addAttribute("normal",new Xo(c,3)),this.addAttribute("uv",new Xo(l,2))}function bh(e){ts.call(this),this.type="ShadowMaterial",this.color=new Lo(0),this.transparent=!0,this.setValues(e)}function _h(e){is.call(this,e),this.type="RawShaderMaterial"}function Mh(e){ts.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Lo(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Lo(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=YT,this.normalScale=new fo(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Eh(e){Mh.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(e)}function Th(e){ts.call(this),this.type="MeshPhongMaterial",this.color=new Lo(16777215),this.specular=new Lo(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Lo(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=YT,this.normalScale=new fo(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=bE,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Sh(e){Th.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(e)}function Ah(e){ts.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=YT,this.normalScale=new fo(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Lh(e){ts.call(this),this.type="MeshLambertMaterial",this.color=new Lo(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Lo(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=bE,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Rh(e){Jc.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}function Ch(e,t,n){var i=this,r=!1,a=0,o=0,s=void 0;this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,!1===r&&void 0!==i.onStart&&i.onStart(e,a,o),r=!0},this.itemEnd=function(e){a++,void 0!==i.onProgress&&i.onProgress(e,a,o),a===o&&(r=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(e){void 0!==i.onError&&i.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this}}function Ph(e){this.manager=void 0!==e?e:MS}function Oh(e){this.manager=void 0!==e?e:MS,this._parser=null}function Ih(e){this.manager=void 0!==e?e:MS,this._parser=null}function Nh(e){this.manager=void 0!==e?e:MS}function Dh(e){this.manager=void 0!==e?e:MS}function Uh(e){this.manager=void 0!==e?e:MS}function Bh(){this.type="Curve",this.arcLengthDivisions=200}function Fh(e,t,n,i,r,a,o,s){Bh.call(this),this.type="EllipseCurve",this.aX=e||0,this.aY=t||0,this.xRadius=n||1,this.yRadius=i||1,this.aStartAngle=r||0,this.aEndAngle=a||2*Math.PI,this.aClockwise=o||!1,this.aRotation=s||0}function zh(e,t,n,i,r,a){Fh.call(this,e,t,n,n,i,r,a),this.type="ArcCurve"}function kh(){function e(e,a,o,s){t=e,n=o,i=-3*e+3*a-2*o-s,r=2*e-2*a+o+s}var t=0,n=0,i=0,r=0;return{initCatmullRom:function(t,n,i,r,a){e(n,i,a*(i-t),a*(r-n))},initNonuniformCatmullRom:function(t,n,i,r,a,o,s){var c=(n-t)/a-(i-t)/(a+o)+(i-n)/o,l=(i-n)/o-(r-n)/(o+s)+(r-i)/s;e(n,i,c*=o,l*=o)},calc:function(e){var a=e*e;return t+n*e+i*a+r*(a*e)}}}function Gh(e,t,n,i){Bh.call(this),this.type="CatmullRomCurve3",this.points=e||[],this.closed=t||!1,this.curveType=n||"centripetal",this.tension=i||.5}function Hh(e,t,n,i,r){var a=.5*(i-t),o=.5*(r-n),s=e*e;return(2*n-2*i+a+o)*(e*s)+(-3*n+3*i-2*a-o)*s+a*e+n}function Vh(e,t){var n=1-e;return n*n*t}function jh(e,t){return 2*(1-e)*e*t}function Wh(e,t){return e*e*t}function Xh(e,t,n,i){return Vh(e,t)+jh(e,n)+Wh(e,i)}function qh(e,t){var n=1-e;return n*n*n*t}function Yh(e,t){var n=1-e;return 3*n*n*e*t}function Zh(e,t){return 3*(1-e)*e*e*t}function Jh(e,t){return e*e*e*t}function Kh(e,t,n,i,r){return qh(e,t)+Yh(e,n)+Zh(e,i)+Jh(e,r)}function Qh(e,t,n,i){Bh.call(this),this.type="CubicBezierCurve",this.v0=e||new fo,this.v1=t||new fo,this.v2=n||new fo,this.v3=i||new fo}function $h(e,t,n,i){Bh.call(this),this.type="CubicBezierCurve3",this.v0=e||new go,this.v1=t||new go,this.v2=n||new go,this.v3=i||new go}function eu(e,t){Bh.call(this),this.type="LineCurve",this.v1=e||new fo,this.v2=t||new fo}function tu(e,t){Bh.call(this),this.type="LineCurve3",this.v1=e||new go,this.v2=t||new go}function nu(e,t,n){Bh.call(this),this.type="QuadraticBezierCurve",this.v0=e||new fo,this.v1=t||new fo,this.v2=n||new fo}function iu(e,t,n){Bh.call(this),this.type="QuadraticBezierCurve3",this.v0=e||new go,this.v1=t||new go,this.v2=n||new go}function ru(e){Bh.call(this),this.type="SplineCurve",this.points=e||[]}function au(){Bh.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}function ou(e){au.call(this),this.type="Path",this.currentPoint=new fo,e&&this.setFromPoints(e)}function su(e){ou.call(this,e),this.uuid=JT.generateUUID(),this.type="Shape",this.holes=[]}function cu(e,t){Io.call(this),this.type="Light",this.color=new Lo(e),this.intensity=void 0!==t?t:1,this.receiveShadow=void 0}function lu(e,t,n){cu.call(this,e,n),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(Io.DefaultUp),this.updateMatrix(),this.groundColor=new Lo(t)}function hu(e){this.camera=e,this.bias=0,this.radius=1,this.mapSize=new fo(512,512),this.map=null,this.matrix=new mo}function uu(){hu.call(this,new Uc(50,1,.5,500))}function pu(e,t,n,i,r,a){cu.call(this,e,t),this.type="SpotLight",this.position.copy(Io.DefaultUp),this.updateMatrix(),this.target=new Io,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(e){this.intensity=e/Math.PI}}),this.distance=void 0!==n?n:0,this.angle=void 0!==i?i:Math.PI/3,this.penumbra=void 0!==r?r:0,this.decay=void 0!==a?a:1,this.shadow=new uu}function du(e,t,n,i){cu.call(this,e,t),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(e){this.intensity=e/(4*Math.PI)}}),this.distance=void 0!==n?n:0,this.decay=void 0!==i?i:1,this.shadow=new hu(new Uc(90,1,.5,500))}function fu(){hu.call(this,new Do(-5,5,5,-5,.5,500))}function mu(e,t){cu.call(this,e,t),this.type="DirectionalLight",this.position.copy(Io.DefaultUp),this.updateMatrix(),this.target=new Io,this.shadow=new fu}function vu(e,t){cu.call(this,e,t),this.type="AmbientLight",this.castShadow=void 0}function gu(e,t,n,i){cu.call(this,e,t),this.type="RectAreaLight",this.width=void 0!==n?n:10,this.height=void 0!==i?i:10}function yu(e,t,n,i){Lu.call(this,e,t,n,i)}function xu(e,t,n){Lu.call(this,e,t,n)}function wu(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n}function bu(e,t,n,i){wu.call(this,e,t,n,i)}function _u(e,t,n,i){Lu.call(this,e,t,n,i)}function Mu(e,t,n,i){Lu.call(this,e,t,n,i)}function Eu(e,t,n,i){Lu.call(this,e,t,n,i)}function Tu(e,t,n,i){wu.call(this,e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Su(e,t,n,i){wu.call(this,e,t,n,i)}function Au(e,t,n,i){wu.call(this,e,t,n,i)}function Lu(e,t,n,i){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=CS.convertArray(t,this.TimeBufferType),this.values=CS.convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation),this.validate(),this.optimize()}function Ru(e,t,n,i){Lu.call(this,e,t,n,i)}function Cu(e,t,n){this.name=e,this.tracks=n,this.duration=void 0!==t?t:-1,this.uuid=JT.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function Pu(e){this.manager=void 0!==e?e:MS,this.textures={}}function Ou(e){this.manager=void 0!==e?e:MS}function Iu(){}function Nu(e){"boolean"==typeof e&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),e=void 0),this.manager=void 0!==e?e:MS,this.withCredentials=!1}function Du(e){this.manager=void 0!==e?e:MS,this.texturePath=""}function Uu(e){"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.manager=void 0!==e?e:MS,this.options=void 0}function Bu(){this.type="ShapePath",this.color=new Lo,this.subPaths=[],this.currentPath=null}function Fu(e){this.type="Font",this.data=e}function zu(e,t,n){for(var i=Array.from?Array.from(e):String(e).split(""),r=t/n.resolution,a=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*r,o=[],s=0,c=0,l=0;l0?l(o()):Q.y<0&&h(o()),J.copy(K),O.update()}function v(e){Y.set(e.clientX,e.clientY),Z.subVectors(Y,q).multiplyScalar(O.panSpeed),te(Z.x,Z.y),q.copy(Y),O.update()}function g(e){e.deltaY<0?h(o()):e.deltaY>0&&l(o()),O.update()}function y(e){switch(e.keyCode){case O.keys.UP:te(0,O.keyPanSpeed),O.update();break;case O.keys.BOTTOM:te(0,-O.keyPanSpeed),O.update();break;case O.keys.LEFT:te(O.keyPanSpeed,0),O.update();break;case O.keys.RIGHT:te(-O.keyPanSpeed,0),O.update()}}function x(e){j.set(e.touches[0].pageX,e.touches[0].pageY)}function w(e){if(O.enableZoom){var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+n*n);J.set(0,i)}if(O.enablePan){var r=.5*(e.touches[0].pageX+e.touches[1].pageX),a=.5*(e.touches[0].pageY+e.touches[1].pageY);q.set(r,a)}}function b(e){W.set(e.touches[0].pageX,e.touches[0].pageY),X.subVectors(W,j).multiplyScalar(O.rotateSpeed);var t=O.domElement===document?O.domElement.body:O.domElement;s(2*Math.PI*X.x/t.clientHeight),c(2*Math.PI*X.y/t.clientHeight),j.copy(W),O.update()}function _(e){if(O.enableZoom){var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+n*n);K.set(0,i),Q.set(0,Math.pow(K.y/J.y,O.zoomSpeed)),l(Q.y),J.copy(K)}if(O.enablePan){var r=.5*(e.touches[0].pageX+e.touches[1].pageX),a=.5*(e.touches[0].pageY+e.touches[1].pageY);Y.set(r,a),Z.subVectors(Y,q).multiplyScalar(O.panSpeed),te(Z.x,Z.y),q.copy(Y)}O.update()}function M(e){if(!1!==O.enabled){switch(e.preventDefault(),e.button){case O.mouseButtons.LEFT:if(e.ctrlKey||e.metaKey){if(!1===O.enablePan)return;d(e),B=U.PAN}else{if(!1===O.enableRotate)return;u(e),B=U.ROTATE}break;case O.mouseButtons.MIDDLE:if(!1===O.enableZoom)return;p(e),B=U.DOLLY;break;case O.mouseButtons.RIGHT:if(!1===O.enablePan)return;d(e),B=U.PAN}B!==U.NONE&&(document.addEventListener("mousemove",E,!1),document.addEventListener("mouseup",T,!1),O.dispatchEvent(N))}}function E(e){if(!1!==O.enabled)switch(e.preventDefault(),B){case U.ROTATE:if(!1===O.enableRotate)return;f(e);break;case U.DOLLY:if(!1===O.enableZoom)return;m(e);break;case U.PAN:if(!1===O.enablePan)return;v(e)}}function T(e){!1!==O.enabled&&(document.removeEventListener("mousemove",E,!1),document.removeEventListener("mouseup",T,!1),O.dispatchEvent(D),B=U.NONE)}function S(e){!1===O.enabled||!1===O.enableZoom||B!==U.NONE&&B!==U.ROTATE||(e.preventDefault(),e.stopPropagation(),O.dispatchEvent(N),g(e),O.dispatchEvent(D))}function A(e){!1!==O.enabled&&!1!==O.enableKeys&&!1!==O.enablePan&&y(e)}function L(e){if(!1!==O.enabled){switch(e.preventDefault(),e.touches.length){case 1:if(!1===O.enableRotate)return;x(e),B=U.TOUCH_ROTATE;break;case 2:if(!1===O.enableZoom&&!1===O.enablePan)return;w(e),B=U.TOUCH_DOLLY_PAN;break;default:B=U.NONE}B!==U.NONE&&O.dispatchEvent(N)}}function R(e){if(!1!==O.enabled)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:if(!1===O.enableRotate)return;if(B!==U.TOUCH_ROTATE)return;b(e);break;case 2:if(!1===O.enableZoom&&!1===O.enablePan)return;if(B!==U.TOUCH_DOLLY_PAN)return;_(e);break;default:B=U.NONE}}function C(e){!1!==O.enabled&&(O.dispatchEvent(D),B=U.NONE)}function P(e){!1!==O.enabled&&e.preventDefault()}this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.needsUpdate=!0,this.target=new a,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.25,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={LEFT:jx.LEFT,MIDDLE:jx.MIDDLE,RIGHT:jx.RIGHT},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return z.phi},this.getAzimuthalAngle=function(){return z.theta},this.saveState=function(){O.target0.copy(O.target),O.position0.copy(O.object.position),O.zoom0=O.object.zoom},this.reset=function(){O.target.copy(O.target0),O.object.position.copy(O.position0),O.object.zoom=O.zoom0,O.object.updateProjectionMatrix(),O.dispatchEvent(I),O.dispatchEvent({type:Hx}),O.update(),B=U.NONE},this.update=function(){var t=new a,n=(new r).setFromUnitVectors(e.up,new a(0,1,0)),o=n.clone().inverse(),c=new a,l=new r;return function(){var e=O.object.position;return t.copy(e).sub(O.target),t.applyQuaternion(n),z.setFromVector3(t),O.autoRotate&&B===U.NONE&&s(i()),z.theta+=k.theta,z.phi+=k.phi,z.theta=Math.max(O.minAzimuthAngle,Math.min(O.maxAzimuthAngle,z.theta)),z.phi=Math.max(O.minPolarAngle,Math.min(O.maxPolarAngle,z.phi)),z.makeSafe(),z.radius*=G,z.radius=Math.max(O.minDistance,Math.min(O.maxDistance,z.radius)),O.target.add(H),t.setFromSpherical(z),t.applyQuaternion(o),e.copy(O.target).add(t),O.object.lookAt(O.target),!0===O.enableDamping?(k.theta*=1-O.dampingFactor,k.phi*=1-O.dampingFactor,H.multiplyScalar(1-O.dampingFactor)):(k.set(0,0,0),H.set(0,0,0)),G=1,V||c.distanceToSquared(O.object.position)>F||8*(1-l.dot(O.object.quaternion))>F?(O.dispatchEvent(I),O.dispatchEvent({type:Hx}),c.copy(O.object.position),l.copy(O.object.quaternion),V=!1,this.needsUpdate=!0,!0):(this.needsUpdate=!1,!1)}}(),this.dispose=function(){O.domElement.removeEventListener("contextmenu",P,!1),O.domElement.removeEventListener("mousedown",M,!1),O.domElement.removeEventListener("wheel",S,!1),O.domElement.removeEventListener("touchstart",L,!1),O.domElement.removeEventListener("touchend",C,!1),O.domElement.removeEventListener("touchmove",R,!1),document.removeEventListener("mousemove",E,!1),document.removeEventListener("mouseup",T,!1),window.removeEventListener("keydown",A,!1)};var O=this,I={type:"change"},N={type:"start"},D={type:"end"},U={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY_PAN:4},B=U.NONE,F=1e-6,z=new aa,k=new aa,G=1,H=new a,V=!1,j=new n,W=new n,X=new n,q=new n,Y=new n,Z=new n,J=new n,K=new n,Q=new n,$=function(){var e=new a;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),H.add(e)}}(),ee=function(){var e=new a;return function(t,n){!0===O.screenSpacePanning?e.setFromMatrixColumn(n,1):(e.setFromMatrixColumn(n,0),e.crossVectors(O.object.up,e)),e.multiplyScalar(t),H.add(e)}}(),te=function(){var e=new a;return function(t,n){var i=O.domElement===document?O.domElement.body:O.domElement;if(O.object.isPerspectiveCamera){var r=O.object.position;e.copy(r).sub(O.target);var a=e.length();a*=Math.tan(O.object.fov/2*Math.PI/180),$(2*t*a/i.clientHeight,O.object.matrix),ee(2*n*a/i.clientHeight,O.object.matrix)}else O.object.isOrthographicCamera?($(t*(O.object.right-O.object.left)/O.object.zoom/i.clientWidth,O.object.matrix),ee(n*(O.object.top-O.object.bottom)/O.object.zoom/i.clientHeight,O.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),O.enablePan=!1)}}();O.domElement.addEventListener("contextmenu",P,!1),O.domElement.addEventListener("mousedown",M,!1),O.domElement.addEventListener("wheel",S,!1),O.domElement.addEventListener("touchstart",L,!1),O.domElement.addEventListener("touchend",C,!1),O.domElement.addEventListener("touchmove",R,!1),window.addEventListener("keydown",A,!1),this.update()}function pd(e,t){function n(){l.enabled&&l.isLocked}function i(e){if(!1!==l.enabled){var t=e.movementX||e.mozMovementX||e.webkitMovementX||0,n=e.movementY||e.mozMovementY||e.webkitMovementY||0;u.rotation.y-=t*l.lookspeed,h.rotation.x-=n*l.lookspeed,h.rotation.x=Math.max(-p,Math.min(p,h.rotation.x))}}function r(e){if(!1!==l.enabled)switch(e.keyCode){case 38:case 87:d=!0;break;case 37:case 65:m=!0;break;case 40:case 83:f=!0;break;case 39:case 68:v=!0;break;case 32:!0===g&&(y.y+=350),g=!1}}function o(e){if(!1!==l.enabled)switch(e.keyCode){case 38:case 87:d=!1;break;case 37:case 65:m=!1;break;case 40:case 83:f=!1;break;case 39:case 68:v=!1}}function s(){document.pointerLockElement===l.domElement?(l.dispatchEvent({type:"lock"}),l.isLocked=!0):(l.dispatchEvent({type:"unlock"}),l.isLocked=!1)}function c(){console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}var l=this;this.domElement=t||document.body,this.enabled=!1,this.isLocked=!0,this.walkspeed=3e3,this.lookspeed=.002,this.characterHeight=125,e.rotation.set(0,0,0);var h=new _;h.add(e);var u=new _;u.position.y=this.characterHeight,u.add(h);var p=Math.PI/2,d=!1,f=!1,m=!1,v=!1,g=!1,y=new a,x=new a;this.update=function(e){var t=e;y.x-=10*y.x*t,y.z-=10*y.z*t,y.y-=9.8*100*t,x.z=Number(d)-Number(f),x.x=Number(m)-Number(v),x.normalize(),(d||f)&&(y.z-=x.z*this.walkspeed*t),(m||v)&&(y.x-=x.x*this.walkspeed*t),l.getObject().translateX(y.x*t),l.getObject().translateY(y.y*t),l.getObject().translateZ(y.z*t),l.getObject().position.y0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function vd(e,t,n,i){this._x=e||0,this._y=t||0,this._z=n||0,this._w=void 0!==i?i:1}function gd(e,t,n){this.x=e||0,this.y=t||0,this.z=n||0}function yd(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function xd(e,t,n,i,r,a,o,s,c,l){Object.defineProperty(this,"id",{value:FR++}),this.uuid=UR.generateUUID(),this.name="",this.image=void 0!==e?e:xd.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:xd.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:EL,this.wrapT=void 0!==i?i:EL,this.magFilter=void 0!==r?r:RL,this.minFilter=void 0!==a?a:PL,this.anisotropy=void 0!==c?c:1,this.format=void 0!==o?o:XL,this.type=void 0!==s?s:OL,this.offset=new fd(0,0),this.repeat=new fd(1,1),this.center=new fd(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new yd,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==l?l:TR,this.version=0,this.onUpdate=null}function wd(e,t,n,i){this.x=e||0,this.y=t||0,this.z=n||0,this.w=void 0!==i?i:1}function bd(e,t,n){this.width=e,this.height=t,this.scissor=new wd(0,0,e,t),this.scissorTest=!1,this.viewport=new wd(0,0,e,t),void 0===(n=n||{}).minFilter&&(n.minFilter=RL),this.texture=new xd(void 0,void 0,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.generateMipmaps=void 0===n.generateMipmaps||n.generateMipmaps,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0===n.stencilBuffer||n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null}function _d(e,t,n){bd.call(this,e,t,n),this.activeCubeFace=0,this.activeMipMapLevel=0}function Md(e,t,n,i,r,a,o,s,c,l,h,u){xd.call(this,null,a,o,s,c,l,i,r,h,u),this.image={data:e,width:t,height:n},this.magFilter=void 0!==c?c:SL,this.minFilter=void 0!==l?l:SL,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function Ed(e,t){this.min=void 0!==e?e:new gd(1/0,1/0,1/0),this.max=void 0!==t?t:new gd(-1/0,-1/0,-1/0)}function Td(e,t){this.center=void 0!==e?e:new gd,this.radius=void 0!==t?t:0}function Sd(e,t){this.normal=void 0!==e?e:new gd(1,0,0),this.constant=void 0!==t?t:0}function Ad(e,t,n,i,r,a){this.planes=[void 0!==e?e:new Sd,void 0!==t?t:new Sd,void 0!==n?n:new Sd,void 0!==i?i:new Sd,void 0!==r?r:new Sd,void 0!==a?a:new Sd]}function Ld(e,t,n){return void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}function Rd(){function e(r,a){!1!==n&&(i(r,a),t.requestAnimationFrame(e))}var t=null,n=!1,i=null;return{start:function(){!0!==n&&null!==i&&(t.requestAnimationFrame(e),n=!0)},stop:function(){n=!1},setAnimationLoop:function(e){i=e},setContext:function(e){t=e}}}function Cd(e){function t(t,n){var i=t.array,r=t.dynamic?e.DYNAMIC_DRAW:e.STATIC_DRAW,a=e.createBuffer();e.bindBuffer(n,a),e.bufferData(n,i,r),t.onUploadCallback();var o=e.FLOAT;return i instanceof Float32Array?o=e.FLOAT:i instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):i instanceof Uint16Array?o=e.UNSIGNED_SHORT:i instanceof Int16Array?o=e.SHORT:i instanceof Uint32Array?o=e.UNSIGNED_INT:i instanceof Int32Array?o=e.INT:i instanceof Int8Array?o=e.BYTE:i instanceof Uint8Array&&(o=e.UNSIGNED_BYTE),{buffer:a,type:o,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version}}function n(t,n,i){var r=n.array,a=n.updateRange;e.bindBuffer(i,t),!1===n.dynamic?e.bufferData(i,r,e.STATIC_DRAW):-1===a.count?e.bufferSubData(i,0,r):0===a.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(e.bufferSubData(i,a.offset*r.BYTES_PER_ELEMENT,r.subarray(a.offset,a.offset+a.count)),a.count=-1)}function i(e){return e.isInterleavedBufferAttribute&&(e=e.data),o.get(e)}function r(t){t.isInterleavedBufferAttribute&&(t=t.data);var n=o.get(t);n&&(e.deleteBuffer(n.buffer),o.delete(t))}function a(e,i){e.isInterleavedBufferAttribute&&(e=e.data);var r=o.get(e);void 0===r?o.set(e,t(e,i)):r.versiont&&(t=e[n]);return t}function Jd(){Object.defineProperty(this,"id",{value:XR+=2}),this.uuid=UR.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}function Kd(e,t,n,i,r,a){Bd.call(this),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a},this.fromBufferGeometry(new Qd(e,t,n,i,r,a)),this.mergeVertices()}function Qd(e,t,n,i,r,a){function o(e,t,n,i,r,a,o,f,m,v,g){var y,x,w=a/m,b=o/v,_=a/2,M=o/2,E=f/2,T=m+1,S=v+1,A=0,L=0,R=new gd;for(x=0;x0?1:-1,h.push(R.x,R.y,R.z),u.push(y/m),u.push(1-x/v),A+=1}}for(x=0;x0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var a,o="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext,s=void 0!==n.precision?n.precision:"highp",c=r(s);c!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",c,"instead."),s=c);var l=!0===n.logarithmicDepthBuffer,h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=e.getParameter(e.MAX_TEXTURE_SIZE),d=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),f=e.getParameter(e.MAX_VERTEX_ATTRIBS),m=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),v=e.getParameter(e.MAX_VARYING_VECTORS),g=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),y=u>0,x=o||!!t.get("OES_texture_float");return{isWebGL2:o,getMaxAnisotropy:i,getMaxPrecision:r,precision:s,logarithmicDepthBuffer:l,maxTextures:h,maxVertexTextures:u,maxTextureSize:p,maxCubemapSize:d,maxAttributes:f,maxVertexUniforms:m,maxVaryings:v,maxFragmentUniforms:g,vertexTextures:y,floatFragmentTextures:x,floatVertexTextures:y&&x}}function uf(){function e(){l.value!==i&&(l.value=i,l.needsUpdate=r>0),n.numPlanes=r,n.numIntersection=0}function t(e,t,i,r){var a=null!==e?e.length:0,o=null;if(0!==a){if(o=l.value,!0!==r||null===o){var h=i+4*a,u=t.matrixWorldInverse;c.getNormalMatrix(u),(null===o||o.length65535?Wd:Vd)(r,1),t.update(i,e.ELEMENT_ARRAY_BUFFER),c[n.id]=i,i}var s={},c={};return{get:r,update:a,getWireframeAttribute:o}}function ff(e,t,n,i){function r(e){c=e}function a(e){l=e.type,h=e.bytesPerElement}function o(t,i){e.drawElements(c,i,l,t*h),n.update(i,c)}function s(r,a,o){var s;if(i.isWebGL2)s=e;else if(null===(s=t.get("ANGLE_instanced_arrays")))return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");s[i.isWebGL2?"drawElementsInstanced":"drawElementsInstancedANGLE"](c,o,l,a*h,r.maxInstancedCount),n.update(o,c,r.maxInstancedCount)}var c,l,h;this.setMode=r,this.setIndex=a,this.render=o,this.renderInstances=s}function mf(e){function t(t,n,r){switch(r=r||1,i.calls++,n){case e.TRIANGLES:i.triangles+=r*(t/3);break;case e.TRIANGLE_STRIP:case e.TRIANGLE_FAN:i.triangles+=r*(t-2);break;case e.LINES:i.lines+=r*(t/2);break;case e.LINE_STRIP:i.lines+=r*(t-1);break;case e.LINE_LOOP:i.lines+=r*t;break;case e.POINTS:i.points+=r*t;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}function n(){i.frame++,i.calls=0,i.triangles=0,i.points=0,i.lines=0}var i={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:i,programs:null,autoReset:!0,reset:n,update:t}}function vf(e,t){return Math.abs(t[1])-Math.abs(e[1])}function gf(e){function t(t,r,a,o){var s=t.morphTargetInfluences,c=s.length,l=n[r.id];if(void 0===l){l=[];for(p=0;p0)return e;var r=t*n,a=JR[r];if(void 0===a&&(a=new Float32Array(r),JR[r]=a),0!==t){i.toArray(a,0);for(var o=1,s=0;o!==t;++o)s+=n,e[o].toArray(a,s)}return a}function _f(e,t){if(e.length!==t.length)return!1;for(var n=0,i=e.length;n");return fm(n)}return e.replace(/^[ \t]*#include +<([\w\d.\/]+)>/gm,t)}function mm(e){function t(e,t,n,i){for(var r="",a=parseInt(t);a0?e.gammaFactor:1,y=o.isWebGL2?"":cm(i.extensions,a,t),x=lm(c),w=s.createProgram();if(i.isRawShaderMaterial?((m=[x].filter(um).join("\n")).length>0&&(m+="\n"),(v=[y,x].filter(um).join("\n")).length>0&&(v+="\n")):(m=["precision "+a.precision+" float;","precision "+a.precision+" int;","#define SHADER_NAME "+r.name,x,a.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+a.maxBones,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+d:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.displacementMap&&a.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.vertexColors?"#define USE_COLOR":"",a.flatShading?"#define FLAT_SHADED":"",a.skinning?"#define USE_SKINNING":"",a.useVertexTexture?"#define BONE_TEXTURE":"",a.morphTargets?"#define USE_MORPHTARGETS":"",a.morphNormals&&!1===a.flatShading?"#define USE_MORPHNORMALS":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+u:"",a.sizeAttenuation?"#define USE_SIZEATTENUATION":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(o.isWebGL2||t.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(um).join("\n"),v=[y,"precision "+a.precision+" float;","precision "+a.precision+" int;","#define SHADER_NAME "+r.name,x,a.alphaTest?"#define ALPHATEST "+a.alphaTest+(a.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+g,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+p:"",a.envMap?"#define "+d:"",a.envMap?"#define "+f:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.vertexColors?"#define USE_COLOR":"",a.gradientMap?"#define USE_GRADIENTMAP":"",a.flatShading?"#define FLAT_SHADED":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+u:"",a.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",a.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(o.isWebGL2||t.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",a.envMap&&(o.isWebGL2||t.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",a.toneMapping!==uL?"#define TONE_MAPPING":"",a.toneMapping!==uL?zR.tonemapping_pars_fragment:"",a.toneMapping!==uL?sm("toneMapping",a.toneMapping):"",a.dithering?"#define DITHERING":"",a.outputEncoding||a.mapEncoding||a.envMapEncoding||a.emissiveMapEncoding?zR.encodings_pars_fragment:"",a.mapEncoding?am("mapTexelToLinear",a.mapEncoding):"",a.envMapEncoding?am("envMapTexelToLinear",a.envMapEncoding):"",a.emissiveMapEncoding?am("emissiveMapTexelToLinear",a.emissiveMapEncoding):"",a.outputEncoding?om("linearToOutputTexel",a.outputEncoding):"",a.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(um).join("\n")),l=fm(l),l=pm(l,a),l=dm(l,a),h=fm(h),h=pm(h,a),h=dm(h,a),l=mm(l),h=mm(h),o.isWebGL2&&!i.isRawShaderMaterial){var b=!1,_=/^\s*#version\s+300\s+es\s*\n/;i.isShaderMaterial&&null!==l.match(_)&&null!==h.match(_)&&(b=!0,l=l.replace(_,""),h=h.replace(_,"")),m=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+m,v=["#version 300 es\n","#define varying in",b?"":"out highp vec4 pc_fragColor;",b?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+v}var M=m+l,E=v+h,T=im(s,s.VERTEX_SHADER,M),S=im(s,s.FRAGMENT_SHADER,E);s.attachShader(w,T),s.attachShader(w,S),void 0!==i.index0AttributeName?s.bindAttribLocation(w,0,i.index0AttributeName):!0===a.morphTargets&&s.bindAttribLocation(w,0,"position"),s.linkProgram(w);var A=s.getProgramInfoLog(w).trim(),L=s.getShaderInfoLog(T).trim(),R=s.getShaderInfoLog(S).trim(),C=!0,P=!0;!1===s.getProgramParameter(w,s.LINK_STATUS)?(C=!1,console.error("THREE.WebGLProgram: shader error: ",s.getError(),"gl.VALIDATE_STATUS",s.getProgramParameter(w,s.VALIDATE_STATUS),"gl.getProgramInfoLog",A,L,R)):""!==A?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",A):""!==L&&""!==R||(P=!1),P&&(this.diagnostics={runnable:C,material:i,programLog:A,vertexShader:{log:L,prefix:m},fragmentShader:{log:R,prefix:v}}),s.deleteShader(T),s.deleteShader(S);var O;this.getUniforms=function(){return void 0===O&&(O=new tm(s,w,e)),O};var I;return this.getAttributes=function(){return void 0===I&&(I=hm(s,w)),I},this.destroy=function(){s.deleteProgram(w),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms()."),this.getUniforms()}},attributes:{get:function(){return console.warn("THREE.WebGLProgram: .attributes is now .getAttributes()."),this.getAttributes()}}}),this.name=r.name,this.id=nC++,this.code=n,this.usedTimes=1,this.program=w,this.vertexShader=T,this.fragmentShader=S,this}function gm(e,t,n){function i(e){var t=e.skeleton.bones;if(n.floatVertexTextures)return 1024;var i=n.maxVertexUniforms,r=Math.floor((i-20)/4),a=Math.min(r,t.length);return a0,maxBones:d,useVertexTexture:n.floatVertexTextures,morphTargets:t.morphTargets,morphNormals:t.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numClippingPlanes:l,numClipIntersection:h,dithering:t.dithering,shadowMapEnabled:e.shadowMap.enabled&&u.receiveShadow&&s.length>0,shadowMapType:e.shadowMap.type,toneMapping:e.toneMapping,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:t.premultipliedAlpha,alphaTest:t.alphaTest,doubleSided:t.side===LA,flipSided:t.side===AA,depthPacking:void 0!==t.depthPacking&&t.depthPacking}},this.getProgramCode=function(t,n){var i=[];if(n.shaderID?i.push(n.shaderID):(i.push(t.fragmentShader),i.push(t.vertexShader)),void 0!==t.defines)for(var r in t.defines)i.push(r),i.push(t.defines[r]);for(var a=0;a1&&a.sort(xm),o.length>1&&o.sort(wm)}var i=[],r=0,a=[],o=[];return{opaque:a,transparent:o,init:e,push:t,sort:n}}function _m(){function e(e,t){var i=e.id+","+t.id,r=n[i];return void 0===r&&(r=new bm,n[i]=r),r}function t(){n={}}var n={};return{get:e,dispose:t}}function Mm(){var e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];var n;switch(t.type){case"DirectionalLight":n={direction:new gd,color:new Ld,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new fd};break;case"SpotLight":n={position:new gd,direction:new gd,color:new Ld,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new fd};break;case"PointLight":n={position:new gd,color:new Ld,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new fd,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":n={direction:new gd,skyColor:new Ld,groundColor:new Ld};break;case"RectAreaLight":n={color:new Ld,position:new gd,halfWidth:new gd,halfHeight:new gd}}return e[t.id]=n,n}}}function Em(){function e(e,o,s){for(var c=0,l=0,h=0,u=0,p=0,d=0,f=0,m=0,v=s.matrixWorldInverse,g=0,y=e.length;g0:s&&s.isGeometry&&(d=s.morphTargets&&s.morphTargets.length>0)),t.isSkinnedMesh&&!1===n.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",t);var y=t.isSkinnedMesh&&n.skinning,x=0;d&&(x|=u),y&&(x|=p),c=l[x]}if(e.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var w=c.uuid,b=n.uuid,_=v[w];void 0===_&&(_={},v[w]=_);var M=_[b];void 0===M&&(M=c.clone(),_[b]=M),c=M}return c.visible=n.visible,c.wireframe=n.wireframe,c.side=null!=n.shadowSide?n.shadowSide:g[n.side],c.clipShadows=n.clipShadows,c.clippingPlanes=n.clippingPlanes,c.clipIntersection=n.clipIntersection,c.wireframeLinewidth=n.wireframeLinewidth,c.linewidth=n.linewidth,i&&c.isMeshDistanceMaterial&&(c.referencePosition.copy(r),c.nearDistance=a,c.farDistance=o),c}function r(n,o,s,c){if(!1!==n.visible){if(n.layers.test(o.layers)&&(n.isMesh||n.isLine||n.isPoints)&&n.castShadow&&(!n.frustumCulled||a.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);var l=t.update(n),u=n.material;if(Array.isArray(u))for(var p=l.groups,d=0,f=p.length;d=1):-1!==ie.indexOf("OpenGL ES")&&(ne=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(ie)[1]),te=ne>=2);var re=null,ae={},oe=new wd,se=new wd,ce={};return ce[e.TEXTURE_2D]=s(e.TEXTURE_2D,e.TEXTURE_2D,1),ce[e.TEXTURE_CUBE_MAP]=s(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),C.setClear(0,0,0,1),P.setClear(1),O.setClear(0),p(e.DEPTH_TEST),P.setFunc(iL),y(!1),x(_A),p(e.CULL_FACE),v(OA),{buffers:{color:C,depth:P,stencil:O},initAttributes:c,enableAttribute:l,enableAttributeAndDivisor:h,disableUnusedAttributes:u,enable:p,disable:d,getCompressedTextureFormats:f,useProgram:m,setBlending:v,setMaterial:g,setFlipSided:y,setCullFace:x,setLineWidth:w,setPolygonOffset:b,setScissorTest:_,activeTexture:M,bindTexture:E,compressedTexImage2D:T,texImage2D:S,scissor:A,viewport:L,reset:R}}function Pm(e,t,n,i,r,a,o){function s(e,t){if(e.width>t||e.height>t){if("data"in e)return void console.warn("THREE.WebGLRenderer: image in DataTexture is too big ("+e.width+"x"+e.height+").");var n=t/Math.max(e.width,e.height),i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return i.width=Math.floor(e.width*n),i.height=Math.floor(e.height*n),i.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,i.width,i.height),console.warn("THREE.WebGLRenderer: image is too big ("+e.width+"x"+e.height+"). Resized to "+i.width+"x"+i.height),i}return e}function c(e){return UR.isPowerOfTwo(e.width)&&UR.isPowerOfTwo(e.height)}function l(e){return e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof ImageBitmap?(void 0===P&&(P=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),P.width=UR.floorPowerOfTwo(e.width),P.height=UR.floorPowerOfTwo(e.height),P.getContext("2d").drawImage(e,0,0,P.width,P.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+e.width+"x"+e.height+"). Resized to "+P.width+"x"+P.height),P):e}function h(e){return!r.isWebGL2&&(e.wrapS!==EL||e.wrapT!==EL||e.minFilter!==SL&&e.minFilter!==RL)}function u(e,t){return e.generateMipmaps&&t&&e.minFilter!==SL&&e.minFilter!==RL}function p(t,n,r,a){e.generateMipmap(t),i.get(n).__maxMipLevel=Math.log(Math.max(r,a))*Math.LOG2E}function d(t,n){if(!r.isWebGL2)return t;if(t===e.RGB){if(n===e.FLOAT)return e.RGB32F;if(n===e.HALF_FLOAT)return e.RGB16F;if(n===e.UNSIGNED_BYTE)return e.RGB8}if(t===e.RGBA){if(n===e.FLOAT)return e.RGBA32F;if(n===e.HALF_FLOAT)return e.RGBA16F;if(n===e.UNSIGNED_BYTE)return e.RGBA8}return t}function f(t){return t===SL||t===AL||t===LL?e.NEAREST:e.LINEAR}function m(e){var t=e.target;t.removeEventListener("dispose",m),g(t),t.isVideoTexture&&delete O[t.id],o.memory.textures--}function v(e){var t=e.target;t.removeEventListener("dispose",v),y(t),o.memory.textures--}function g(t){var n=i.get(t);if(t.image&&n.__image__webglTextureCube)e.deleteTexture(n.__image__webglTextureCube);else{if(void 0===n.__webglInit)return;e.deleteTexture(n.__webglTexture)}i.remove(t)}function y(t){var n=i.get(t),r=i.get(t.texture);if(t){if(void 0!==r.__webglTexture&&e.deleteTexture(r.__webglTexture),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLRenderTargetCube)for(var a=0;a<6;a++)e.deleteFramebuffer(n.__webglFramebuffer[a]),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[a]);else e.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer);i.remove(t.texture),i.remove(t)}}function x(t,r){var a=i.get(t);if(t.isVideoTexture&&C(t),t.version>0&&a.__version!==t.version){var o=t.image;if(void 0===o)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==o.complete)return void M(a,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(e.TEXTURE0+r),n.bindTexture(e.TEXTURE_2D,a.__webglTexture)}function w(t,l){var h=i.get(t);if(6===t.image.length)if(t.version>0&&h.__version!==t.version){h.__image__webglTextureCube||(t.addEventListener("dispose",m),h.__image__webglTextureCube=e.createTexture(),o.memory.textures++),n.activeTexture(e.TEXTURE0+l),n.bindTexture(e.TEXTURE_CUBE_MAP,h.__image__webglTextureCube),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t.flipY);for(var f=t&&t.isCompressedTexture,v=t.image[0]&&t.image[0].isDataTexture,g=[],y=0;y<6;y++)g[y]=f||v?v?t.image[y].image:t.image[y]:s(t.image[y],r.maxCubemapSize);var x=g[0],w=c(x),b=a.convert(t.format),M=a.convert(t.type),E=d(b,M);_(e.TEXTURE_CUBE_MAP,t,w);for(y=0;y<6;y++)if(f)for(var T,S=g[y].mipmaps,A=0,L=S.length;A-1?n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+y,A,E,T.width,T.height,0,T.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+y,A,E,T.width,T.height,0,b,M,T.data);else v?n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+y,0,E,g[y].width,g[y].height,0,b,M,g[y].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+y,0,E,b,M,g[y]);h.__maxMipLevel=f?S.length-1:0,u(t,w)&&p(e.TEXTURE_CUBE_MAP,t,x.width,x.height),h.__version=t.version,t.onUpdate&&t.onUpdate(t)}else n.activeTexture(e.TEXTURE0+l),n.bindTexture(e.TEXTURE_CUBE_MAP,h.__image__webglTextureCube)}function b(t,r){n.activeTexture(e.TEXTURE0+r),n.bindTexture(e.TEXTURE_CUBE_MAP,i.get(t).__webglTexture)}function _(n,o,s){var c;if(s?(e.texParameteri(n,e.TEXTURE_WRAP_S,a.convert(o.wrapS)),e.texParameteri(n,e.TEXTURE_WRAP_T,a.convert(o.wrapT)),e.texParameteri(n,e.TEXTURE_MAG_FILTER,a.convert(o.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,a.convert(o.minFilter))):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),o.wrapS===EL&&o.wrapT===EL||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,e.TEXTURE_MAG_FILTER,f(o.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,f(o.minFilter)),o.minFilter!==SL&&o.minFilter!==RL&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),c=t.get("EXT_texture_filter_anisotropic")){if(o.type===FL&&null===t.get("OES_texture_float_linear"))return;if(o.type===zL&&null===(r.isWebGL2||t.get("OES_texture_half_float_linear")))return;(o.anisotropy>1||i.get(o).__currentAnisotropy)&&(e.texParameterf(n,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,r.getMaxAnisotropy())),i.get(o).__currentAnisotropy=o.anisotropy)}}function M(t,i,f){void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",m),t.__webglTexture=e.createTexture(),o.memory.textures++),n.activeTexture(e.TEXTURE0+f),n.bindTexture(e.TEXTURE_2D,t.__webglTexture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,i.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,i.unpackAlignment);var v=s(i.image,r.maxTextureSize);h(i)&&!1===c(v)&&(v=l(v));var g=c(v),y=a.convert(i.format),x=a.convert(i.type),w=d(y,x);_(e.TEXTURE_2D,i,g);var b,M=i.mipmaps;if(i.isDepthTexture){if(w=e.DEPTH_COMPONENT,i.type===FL){if(!r.isWebGL2)throw new Error("Float Depth Texture only supported in WebGL2.0");w=e.DEPTH_COMPONENT32F}else r.isWebGL2&&(w=e.DEPTH_COMPONENT16);i.format===ZL&&w===e.DEPTH_COMPONENT&&i.type!==DL&&i.type!==BL&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=DL,x=a.convert(i.type)),i.format===JL&&(w=e.DEPTH_STENCIL,i.type!==VL&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=VL,x=a.convert(i.type))),n.texImage2D(e.TEXTURE_2D,0,w,v.width,v.height,0,y,x,null)}else if(i.isDataTexture)if(M.length>0&&g){for(var E=0,T=M.length;E-1?n.compressedTexImage2D(e.TEXTURE_2D,E,w,b.width,b.height,0,b.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(e.TEXTURE_2D,E,w,b.width,b.height,0,y,x,b.data);t.__maxMipLevel=M.length-1}else if(M.length>0&&g){for(var E=0,T=M.length;E=0){var c=i[o];if(void 0!==c){var l=c.normalized,h=c.itemSize,u=_e.get(c);if(void 0===u)continue;var p=u.buffer,d=u.type,f=u.bytesPerElement;if(c.isInterleavedBufferAttribute){var m=c.data,v=m.stride,g=c.offset;m&&m.isInstancedInterleavedBuffer?(ye.enableAttributeAndDivisor(s,m.meshPerAttribute),void 0===n.maxInstancedCount&&(n.maxInstancedCount=m.meshPerAttribute*m.count)):ye.enableAttribute(s),V.bindBuffer(V.ARRAY_BUFFER,p),V.vertexAttribPointer(s,h,d,l,v*f,g*f)}else c.isInstancedBufferAttribute?(ye.enableAttributeAndDivisor(s,c.meshPerAttribute),void 0===n.maxInstancedCount&&(n.maxInstancedCount=c.meshPerAttribute*c.count)):ye.enableAttribute(s),V.bindBuffer(V.ARRAY_BUFFER,p),V.vertexAttribPointer(s,h,d,l,0,0)}else if(void 0!==a){var y=a[o];if(void 0!==y)switch(y.length){case 2:V.vertexAttrib2fv(s,y);break;case 3:V.vertexAttrib3fv(s,y);break;case 4:V.vertexAttrib4fv(s,y);break;default:V.vertexAttrib1fv(s,y)}}}}ye.disableUnusedAttributes()}function h(e){Ie.isPresenting()||De&&De(e)}function u(e,t,n){if(!1!==e.visible){if(e.layers.test(t.layers))if(e.isLight)H.pushLight(e),e.castShadow&&H.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||le.intersectsSprite(e)){n&&fe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(de);var i=Ee.update(e),r=e.material;G.push(e,i,r,fe.z,null)}}else if(e.isImmediateRenderObject)n&&fe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(de),G.push(e,null,e.material,fe.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.update(),!e.frustumCulled||le.intersectsObject(e))){n&&fe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(de);var i=Ee.update(e),r=e.material;if(Array.isArray(r))for(var a=i.groups,o=0,s=a.length;o=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(var v=0;v=0&&e.numSupportedMorphNormals++}var g=i.shader.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(i.numClippingPlanes=he.numPlanes,i.numIntersection=he.numIntersection,g.clippingPlanes=he.uniform),i.fog=t,void 0===c&&(i.lightsHash=c={}),c.stateID=l.stateID,c.directionalLength=l.directionalLength,c.pointLength=l.pointLength,c.spotLength=l.spotLength,c.rectAreaLength=l.rectAreaLength,c.hemiLength=l.hemiLength,c.shadowsLength=l.shadowsLength,e.lights&&(g.ambientLightColor.value=r.state.ambient,g.directionalLights.value=r.state.directional,g.spotLights.value=r.state.spot,g.rectAreaLights.value=r.state.rectArea,g.pointLights.value=r.state.point,g.hemisphereLights.value=r.state.hemi,g.directionalShadowMap.value=r.state.directionalShadowMap,g.directionalShadowMatrix.value=r.state.directionalShadowMatrix,g.spotShadowMap.value=r.state.spotShadowMap,g.spotShadowMatrix.value=r.state.spotShadowMatrix,g.pointShadowMap.value=r.state.pointShadowMap,g.pointShadowMatrix.value=r.state.pointShadowMatrix);var y=i.program.getUniforms(),x=tm.seqWithValue(y.seq,g);i.uniformsList=x}function m(e,t,n,i){ne=0;var r=we.get(n),a=H.state.lights,o=r.lightsHash,s=a.state.hash;if(ue&&(pe||e!==K)){var c=e===K&&n.id===Z;he.setState(n.clippingPlanes,n.clipIntersection,n.clipShadows,e,r,c)}!1===n.needsUpdate&&(void 0===r.program?n.needsUpdate=!0:n.fog&&r.fog!==t?n.needsUpdate=!0:!n.lights||o.stateID===s.stateID&&o.directionalLength===s.directionalLength&&o.pointLength===s.pointLength&&o.spotLength===s.spotLength&&o.rectAreaLength===s.rectAreaLength&&o.hemiLength===s.hemiLength&&o.shadowsLength===s.shadowsLength?void 0===r.numClippingPlanes||r.numClippingPlanes===he.numPlanes&&r.numIntersection===he.numIntersection||(n.needsUpdate=!0):n.needsUpdate=!0),n.needsUpdate&&(f(n,t,i),n.needsUpdate=!1);var l=!1,h=!1,u=!1,p=r.program,d=p.getUniforms(),m=r.shader.uniforms;if(ye.useProgram(p.program)&&(l=!0,h=!0,u=!0),n.id!==Z&&(Z=n.id,h=!0),l||K!==e){if(d.setValue(V,"projectionMatrix",e.projectionMatrix),ge.logarithmicDepthBuffer&&d.setValue(V,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),K!==e&&(K=e,h=!0,u=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.envMap){var P=d.map.cameraPosition;void 0!==P&&P.setValue(V,fe.setFromMatrixPosition(e.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.skinning)&&d.setValue(V,"viewMatrix",e.matrixWorldInverse)}if(n.skinning){d.setOptional(V,i,"bindMatrix"),d.setOptional(V,i,"bindMatrixInverse");var O=i.skeleton;if(O){var I=O.bones;if(ge.floatVertexTextures){if(void 0===O.boneTexture){var N=Math.sqrt(4*I.length);N=UR.ceilPowerOfTwo(N),N=Math.max(N,4);var D=new Float32Array(N*N*4);D.set(O.boneMatrices);var U=new Md(D,N,N,XL,FL);U.needsUpdate=!0,O.boneMatrices=D,O.boneTexture=U,O.boneTextureSize=N}d.setValue(V,"boneTexture",O.boneTexture),d.setValue(V,"boneTextureSize",O.boneTextureSize)}else d.setOptional(V,O,"boneMatrices")}}return h&&(d.setValue(V,"toneMappingExposure",j.toneMappingExposure),d.setValue(V,"toneMappingWhitePoint",j.toneMappingWhitePoint),n.lights&&C(m,u),t&&n.fog&&b(m,t),n.isMeshBasicMaterial?v(m,n):n.isMeshLambertMaterial?(v(m,n),_(m,n)):n.isMeshPhongMaterial?(v(m,n),n.isMeshToonMaterial?E(m,n):M(m,n)):n.isMeshStandardMaterial?(v(m,n),n.isMeshPhysicalMaterial?S(m,n):T(m,n)):n.isMeshDepthMaterial?(v(m,n),A(m,n)):n.isMeshDistanceMaterial?(v(m,n),L(m,n)):n.isMeshNormalMaterial?(v(m,n),R(m,n)):n.isLineBasicMaterial?(g(m,n),n.isLineDashedMaterial&&y(m,n)):n.isPointsMaterial?x(m,n):n.isSpriteMaterial?w(m,n):n.isShadowMaterial&&(m.color.value=n.color,m.opacity.value=n.opacity),void 0!==m.ltc_1&&(m.ltc_1.value=HR.LTC_1),void 0!==m.ltc_2&&(m.ltc_2.value=HR.LTC_2),tm.upload(V,r.uniformsList,m,j)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(tm.upload(V,r.uniformsList,m,j),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&d.setValue(V,"center",i.center),d.setValue(V,"modelViewMatrix",i.modelViewMatrix),d.setValue(V,"normalMatrix",i.normalMatrix),d.setValue(V,"modelMatrix",i.matrixWorld),p}function v(e,t){e.opacity.value=t.opacity,t.color&&(e.diffuse.value=t.color),t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.specularMap&&(e.specularMap.value=t.specularMap),t.envMap&&(e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap&&t.envMap.isCubeTexture?-1:1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio,e.maxMipLevel.value=we.get(t.envMap).__maxMipLevel),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity);var n;t.map?n=t.map:t.specularMap?n=t.specularMap:t.displacementMap?n=t.displacementMap:t.normalMap?n=t.normalMap:t.bumpMap?n=t.bumpMap:t.roughnessMap?n=t.roughnessMap:t.metalnessMap?n=t.metalnessMap:t.alphaMap?n=t.alphaMap:t.emissiveMap&&(n=t.emissiveMap),void 0!==n&&(n.isWebGLRenderTarget&&(n=n.texture),!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}function g(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity}function y(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function x(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity,e.size.value=t.size*ae,e.scale.value=.5*re,e.map.value=t.map,null!==t.map&&(!0===t.map.matrixAutoUpdate&&t.map.updateMatrix(),e.uvTransform.value.copy(t.map.matrix))}function w(e,t){e.diffuse.value=t.color,e.opacity.value=t.opacity,e.rotation.value=t.rotation,e.map.value=t.map,null!==t.map&&(!0===t.map.matrixAutoUpdate&&t.map.updateMatrix(),e.uvTransform.value.copy(t.map.matrix))}function b(e,t){e.fogColor.value=t.color,t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)}function _(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}function M(e,t){e.specular.value=t.specular,e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===AA&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===AA&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function E(e,t){M(e,t),t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function T(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===AA&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===AA&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function S(e,t){T(e,t),e.reflectivity.value=t.reflectivity,e.clearCoat.value=t.clearCoat,e.clearCoatRoughness.value=t.clearCoatRoughness}function A(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function L(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}function R(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===AA&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===AA&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function C(e,t){e.ambientLightColor.needsUpdate=t,e.directionalLights.needsUpdate=t,e.pointLights.needsUpdate=t,e.spotLights.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function P(){var e=ne;return e>=ge.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+e+" texture units while this GPU supports only "+ge.maxTextures),ne+=1,e}console.log("THREE.WebGLRenderer",wA);var O=void 0!==(e=e||{}).canvas?e.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),I=void 0!==e.context?e.context:null,N=void 0!==e.alpha&&e.alpha,D=void 0===e.depth||e.depth,U=void 0===e.stencil||e.stencil,B=void 0!==e.antialias&&e.antialias,F=void 0===e.premultipliedAlpha||e.premultipliedAlpha,z=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,k=void 0!==e.powerPreference?e.powerPreference:"default",G=null,H=null;this.domElement=O,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=pL,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var V,j=this,W=!1,X=null,q=null,Y=null,Z=-1,J={geometry:null,program:null,wireframe:!1},K=null,Q=null,$=new wd,ee=new wd,te=null,ne=0,ie=O.width,re=O.height,ae=1,oe=new wd(0,0,ie,re),se=new wd(0,0,ie,re),ce=!1,le=new Ad,he=new uf,ue=!1,pe=!1,de=new md,fe=new gd;try{var me={alpha:N,depth:D,stencil:U,antialias:B,premultipliedAlpha:F,preserveDrawingBuffer:z,powerPreference:k};if(O.addEventListener("webglcontextlost",i,!1),O.addEventListener("webglcontextrestored",r,!1),null===(V=I||O.getContext("webgl",me)||O.getContext("experimental-webgl",me)))throw null!==O.getContext("webgl")?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.");void 0===V.getShaderPrecisionFormat&&(V.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){console.error("THREE.WebGLRenderer: "+e.message)}var ve,ge,ye,xe,we,be,_e,Me,Ee,Te,Se,Ae,Le,Re,Ce,Pe,Oe;n();var Ie="xr"in navigator?new Bm(j):new Um(j);this.vr=Ie;var Ne=new Rm(j,Ee,ge.maxTextureSize);this.shadowMap=Ne,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){var e=ve.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){var e=ve.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return ae},this.setPixelRatio=function(e){void 0!==e&&(ae=e,this.setSize(ie,re,!1))},this.getSize=function(){return{width:ie,height:re}},this.setSize=function(e,t,n){if(Ie.isPresenting())return void console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");ie=e,re=t,O.width=e*ae,O.height=t*ae,!1!==n&&(O.style.width=e+"px",O.style.height=t+"px"),this.setViewport(0,0,e,t)},this.getDrawingBufferSize=function(){return{width:ie*ae,height:re*ae}},this.setDrawingBufferSize=function(e,t,n){ie=e,re=t,ae=n,O.width=e*n,O.height=t*n,this.setViewport(0,0,e,t)},this.getCurrentViewport=function(){return $},this.setViewport=function(e,t,n,i){oe.set(e,re-t-i,n,i),ye.viewport($.copy(oe).multiplyScalar(ae))},this.setScissor=function(e,t,n,i){se.set(e,re-t-i,n,i),ye.scissor(ee.copy(se).multiplyScalar(ae))},this.setScissorTest=function(e){ye.setScissorTest(ce=e)},this.getClearColor=function(){return Le.getClearColor()},this.setClearColor=function(){Le.setClearColor.apply(Le,arguments)},this.getClearAlpha=function(){return Le.getClearAlpha()},this.setClearAlpha=function(){Le.setClearAlpha.apply(Le,arguments)},this.clear=function(e,t,n){var i=0;(void 0===e||e)&&(i|=V.COLOR_BUFFER_BIT),(void 0===t||t)&&(i|=V.DEPTH_BUFFER_BIT),(void 0===n||n)&&(i|=V.STENCIL_BUFFER_BIT),V.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.clearTarget=function(e,t,n,i){this.setRenderTarget(e),this.clear(t,n,i)},this.dispose=function(){O.removeEventListener("webglcontextlost",i,!1),O.removeEventListener("webglcontextrestored",r,!1),Se.dispose(),Ae.dispose(),we.dispose(),Ee.dispose(),Ie.dispose(),Ue.stop()},this.renderBufferImmediate=function(e,t){ye.initAttributes();var n=we.get(e);e.hasPositions&&!n.position&&(n.position=V.createBuffer()),e.hasNormals&&!n.normal&&(n.normal=V.createBuffer()),e.hasUvs&&!n.uv&&(n.uv=V.createBuffer()),e.hasColors&&!n.color&&(n.color=V.createBuffer());var i=t.getAttributes();e.hasPositions&&(V.bindBuffer(V.ARRAY_BUFFER,n.position),V.bufferData(V.ARRAY_BUFFER,e.positionArray,V.DYNAMIC_DRAW),ye.enableAttribute(i.position),V.vertexAttribPointer(i.position,3,V.FLOAT,!1,0,0)),e.hasNormals&&(V.bindBuffer(V.ARRAY_BUFFER,n.normal),V.bufferData(V.ARRAY_BUFFER,e.normalArray,V.DYNAMIC_DRAW),ye.enableAttribute(i.normal),V.vertexAttribPointer(i.normal,3,V.FLOAT,!1,0,0)),e.hasUvs&&(V.bindBuffer(V.ARRAY_BUFFER,n.uv),V.bufferData(V.ARRAY_BUFFER,e.uvArray,V.DYNAMIC_DRAW),ye.enableAttribute(i.uv),V.vertexAttribPointer(i.uv,2,V.FLOAT,!1,0,0)),e.hasColors&&(V.bindBuffer(V.ARRAY_BUFFER,n.color),V.bufferData(V.ARRAY_BUFFER,e.colorArray,V.DYNAMIC_DRAW),ye.enableAttribute(i.color),V.vertexAttribPointer(i.color,3,V.FLOAT,!1,0,0)),ye.disableUnusedAttributes(),V.drawArrays(V.TRIANGLES,0,e.count),e.count=0},this.renderBufferDirect=function(e,n,i,r,a,o){var s=a.isMesh&&a.normalMatrix.determinant()<0;ye.setMaterial(r,s);var c=m(e,n,r,a),h=!1;J.geometry===i.id&&J.program===c.id&&J.wireframe===(!0===r.wireframe)||(J.geometry=i.id,J.program=c.id,J.wireframe=!0===r.wireframe,h=!0),a.morphTargetInfluences&&(Re.update(a,i,r,c),h=!0);var u=i.index,p=i.attributes.position,d=1;!0===r.wireframe&&(u=Me.getWireframeAttribute(i),d=2);var f,v=Ce;null!==u&&(f=_e.get(u),(v=Pe).setIndex(f)),h&&(l(r,c,i),null!==u&&V.bindBuffer(V.ELEMENT_ARRAY_BUFFER,f.buffer));var g=1/0;null!==u?g=u.count:void 0!==p&&(g=p.count);var y=i.drawRange.start*d,x=i.drawRange.count*d,w=null!==o?o.start*d:0,b=null!==o?o.count*d:1/0,_=Math.max(y,w),M=Math.min(g,y+x,w+b)-1,E=Math.max(0,M-_+1);if(0!==E){if(a.isMesh)if(!0===r.wireframe)ye.setLineWidth(r.wireframeLinewidth*t()),v.setMode(V.LINES);else switch(a.drawMode){case _R:v.setMode(V.TRIANGLES);break;case MR:v.setMode(V.TRIANGLE_STRIP);break;case ER:v.setMode(V.TRIANGLE_FAN)}else if(a.isLine){var T=r.linewidth;void 0===T&&(T=1),ye.setLineWidth(T*t()),a.isLineSegments?v.setMode(V.LINES):a.isLineLoop?v.setMode(V.LINE_LOOP):v.setMode(V.LINE_STRIP)}else a.isPoints?v.setMode(V.POINTS):a.isSprite&&v.setMode(V.TRIANGLES);i&&i.isInstancedBufferGeometry?i.maxInstancedCount>0&&v.renderInstances(i,_,E):v.render(_,E)}},this.compile=function(e,t){(H=Ae.get(e,t)).init(),e.traverse(function(e){e.isLight&&(H.pushLight(e),e.castShadow&&H.pushShadow(e))}),H.setupLights(t),e.traverse(function(t){if(t.material)if(Array.isArray(t.material))for(var n=0;n=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&V.readPixels(t,n,i,r,Oe.convert(l),Oe.convert(h),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&V.bindFramebuffer(V.FRAMEBUFFER,Y)}}},this.copyFramebufferToTexture=function(e,t,n){var i=t.image.width,r=t.image.height,a=Oe.convert(t.format);this.setTexture2D(t,0),V.copyTexImage2D(V.TEXTURE_2D,n||0,a,e.x,e.y,i,r,0)},this.copyTextureToTexture=function(e,t,n,i){var r=t.image.width,a=t.image.height,o=Oe.convert(n.format),s=Oe.convert(n.type);this.setTexture2D(n,0),t.isDataTexture?V.texSubImage2D(V.TEXTURE_2D,i||0,e.x,e.y,r,a,o,s,t.image.data):V.texSubImage2D(V.TEXTURE_2D,i||0,e.x,e.y,o,s,t.image)}}function zm(e,t){this.name="",this.color=new Ld(e),this.density=void 0!==t?t:25e-5}function km(e,t,n){this.name="",this.color=new Ld(e),this.near=void 0!==t?t:1,this.far=void 0!==n?n:1e3}function Gm(){Id.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function Hm(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}function Vm(e,t,n,i){this.data=e,this.itemSize=t,this.offset=n,this.normalized=!0===i}function jm(e){tf.call(this),this.type="SpriteMaterial",this.color=new Ld(16777215),this.map=null,this.rotation=0,this.sizeAttenuation=!0,this.lights=!1,this.transparent=!0,this.setValues(e)}function Wm(e){if(Id.call(this),this.type="Sprite",void 0===rC){rC=new Jd;var t=new Hm(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);rC.setIndex([0,1,2,0,2,3]),rC.addAttribute("position",new Vm(t,3,0,!1)),rC.addAttribute("uv",new Vm(t,2,3,!1))}this.geometry=rC,this.material=void 0!==e?e:new jm,this.center=new fd(.5,.5)}function Xm(){Id.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function qm(e,t){if(e=e||[],this.bones=e.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===t)this.calculateInverses();else if(this.bones.length===t.length)this.boneInverses=t.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var n=0,i=this.bones.length;n=0?(e(v-1e-5,m,u),p.subVectors(h,u)):(e(v+1e-5,m,u),p.subVectors(u,h)),m-1e-5>=0?(e(v,m-1e-5,u),d.subVectors(h,u)):(e(v,m+1e-5,u),d.subVectors(u,h)),l.crossVectors(p,d).normalize(),s.push(l.x,l.y,l.z),c.push(v,m)}}for(i=0;i.9&&a<.1&&(t<.2&&(d[e+0]+=1),n<.2&&(d[e+2]+=1),i<.2&&(d[e+4]+=1))}}function o(e){p.push(e.x,e.y,e.z)}function s(t,n){var i=3*t;n.x=e[i+0],n.y=e[i+1],n.z=e[i+2]}function c(){for(var e=new gd,t=new gd,n=new gd,i=new gd,r=new fd,a=new fd,o=new fd,s=0,c=0;s0)for(a=t;a=t;a-=i)o=Zv(a,e[a],e[a+1],o);return o&&Vv(o,o.next)&&(Jv(o),o=o.next),o}function Sv(e,t){if(!e)return e;t||(t=e);var n,i=e;do{if(n=!1,i.steiner||!Vv(i,i.next)&&0!==Hv(i.prev,i,i.next))i=i.next;else{if(Jv(i),(i=t=i.prev)===i.next)break;n=!0}}while(n||i!==t);return t}function Av(e,t,n,i,r,a,o){if(e){!o&&a&&Uv(e,i,r,a);for(var s,c,l=e;e.prev!==e.next;)if(s=e.prev,c=e.next,a?Rv(e,i,r,a):Lv(e))t.push(s.i/n),t.push(e.i/n),t.push(c.i/n),Jv(e),e=c.next,l=c.next;else if((e=c)===l){o?1===o?Av(e=Cv(e,t,n),t,n,i,r,a,2):2===o&&Pv(e,t,n,i,r,a):Av(Sv(e),t,n,i,r,a,1);break}}}function Lv(e){var t=e.prev,n=e,i=e.next;if(Hv(t,n,i)>=0)return!1;for(var r=e.next.next;r!==e.prev;){if(kv(t.x,t.y,n.x,n.y,i.x,i.y,r.x,r.y)&&Hv(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Rv(e,t,n,i){var r=e.prev,a=e,o=e.next;if(Hv(r,a,o)>=0)return!1;for(var s=r.xa.x?r.x>o.x?r.x:o.x:a.x>o.x?a.x:o.x,h=r.y>a.y?r.y>o.y?r.y:o.y:a.y>o.y?a.y:o.y,u=Fv(s,c,t,n,i),p=Fv(l,h,t,n,i),d=e.nextZ;d&&d.z<=p;){if(d!==e.prev&&d!==e.next&&kv(r.x,r.y,a.x,a.y,o.x,o.y,d.x,d.y)&&Hv(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(d=e.prevZ;d&&d.z>=u;){if(d!==e.prev&&d!==e.next&&kv(r.x,r.y,a.x,a.y,o.x,o.y,d.x,d.y)&&Hv(d.prev,d,d.next)>=0)return!1;d=d.prevZ}return!0}function Cv(e,t,n){var i=e;do{var r=i.prev,a=i.next.next;!Vv(r,a)&&jv(r,i,i.next,a)&&Xv(r,a)&&Xv(a,r)&&(t.push(r.i/n),t.push(i.i/n),t.push(a.i/n),Jv(i),Jv(i.next),i=e=a),i=i.next}while(i!==e);return i}function Pv(e,t,n,i,r,a){var o=e;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&Gv(o,s)){var c=Yv(o,s);return o=Sv(o,o.next),c=Sv(c,c.next),Av(o,t,n,i,r,a),void Av(c,t,n,i,r,a)}s=s.next}o=o.next}while(o!==e)}function Ov(e,t,n,i){var r,a,o,s=[];for(r=0,a=t.length;r=i.next.y&&i.next.y!==i.y){var s=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=r&&s>o){if(o=s,s===r){if(a===i.y)return i;if(a===i.next.y)return i.next}n=i.x=i.x&&i.x>=h&&r!==i.x&&kv(an.x)&&Xv(i,e)&&(n=i,p=c),i=i.next;return n}function Uv(e,t,n,i){var r=e;do{null===r.z&&(r.z=Fv(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,Bv(r)}function Bv(e){var t,n,i,r,a,o,s,c,l=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,i=n,s=0,t=0;t0||c>0&&i;)0!==s&&(0===c||!i||n.z<=i.z)?(r=n,n=n.nextZ,s--):(r=i,i=i.nextZ,c--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,l*=2}while(o>1);return e}function Fv(e,t,n,i,r){return e=32767*(e-n)*r,t=32767*(t-i)*r,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1}function zv(e){var t=e,n=e;do{t.x=0&&(e-o)*(i-s)-(n-o)*(t-s)>=0&&(n-o)*(a-s)-(r-o)*(i-s)>=0}function Gv(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Wv(e,t)&&Xv(e,t)&&Xv(t,e)&&qv(e,t)}function Hv(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Vv(e,t){return e.x===t.x&&e.y===t.y}function jv(e,t,n,i){return!!(Vv(e,t)&&Vv(n,i)||Vv(e,i)&&Vv(n,t))||Hv(e,t,n)>0!=Hv(e,t,i)>0&&Hv(n,i,e)>0!=Hv(n,i,t)>0}function Wv(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&jv(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Xv(e,t){return Hv(e.prev,e,e.next)<0?Hv(e,t,e.next)>=0&&Hv(e,e.prev,t)>=0:Hv(e,t,e.prev)<0||Hv(e,e.next,t)<0}function qv(e,t){var n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}function Yv(e,t){var n=new Kv(e.i,e.x,e.y),i=new Kv(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function Zv(e,t,n,i){var r=new Kv(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Jv(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Kv(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Qv(e,t,n,i){for(var r=0,a=t,o=n-i;a2&&e[t-1].equals(e[0])&&e.pop()}function eg(e,t){for(var n=0;nNumber.EPSILON){var p=Math.sqrt(h),d=Math.sqrt(c*c+l*l),f=t.x-s/p,m=t.y+o/p,v=((n.x-l/d-f)*l-(n.y+c/d-m)*c)/(o*l-s*c),g=(i=f+o*v-e.x)*i+(r=m+s*v-e.y)*r;if(g<=2)return new fd(i,r);a=Math.sqrt(g/2)}else{var y=!1;o>Number.EPSILON?c>Number.EPSILON&&(y=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(l)&&(y=!0),y?(i=-s,r=o,a=Math.sqrt(h)):(i=o,r=s,a=Math.sqrt(h/2))}return new fd(i/a,r/a)}function s(e,t){var n,i;for(X=e.length;--X>=0;){n=X,(i=X-1)<0&&(i=e.length-1);var r=0,a=m+2*w;for(r=0;r=0;B--){for(z=B/w,k=y*Math.cos(z*Math.PI/2),F=x*Math.sin(z*Math.PI/2),X=0,q=U.length;X0)&&f.push(b,_,E),(c!==n-1||l0&&c(!0),t>0&&c(!1)),this.setIndex(h),this.addAttribute("position",new Xd(u,3)),this.addAttribute("normal",new Xd(p,3)),this.addAttribute("uv",new Xd(d,2))}function yg(e,t,n,i,r,a,o){vg.call(this,0,e,t,n,i,r,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}function xg(e,t,n,i,r,a,o){gg.call(this,0,e,t,n,i,r,a,o),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}function wg(e,t,n,i){Bd.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},this.fromBufferGeometry(new bg(e,t,n,i)),this.mergeVertices()}function bg(e,t,n,i){Jd.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},e=e||1,t=void 0!==t?Math.max(3,t):8,n=void 0!==n?n:0,i=void 0!==i?i:2*Math.PI;var r,a,o=[],s=[],c=[],l=[],h=new gd,u=new fd;for(s.push(0,0,0),c.push(0,0,1),l.push(.5,.5),a=0,r=3;a<=t;a++,r+=3){var p=n+a/t*i;h.x=e*Math.cos(p),h.y=e*Math.sin(p),s.push(h.x,h.y,h.z),c.push(0,0,1),u.x=(s[r]/e+1)/2,u.y=(s[r+1]/e+1)/2,l.push(u.x,u.y)}for(r=1;r<=t;r++)o.push(r,r+1,0);this.setIndex(o),this.addAttribute("position",new Xd(s,3)),this.addAttribute("normal",new Xd(c,3)),this.addAttribute("uv",new Xd(l,2))}function _g(e){tf.call(this),this.type="ShadowMaterial",this.color=new Ld(0),this.transparent=!0,this.setValues(e)}function Mg(e){rf.call(this,e),this.type="RawShaderMaterial"}function Eg(e){tf.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ld(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ld(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=NR,this.normalScale=new fd(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Tg(e){Eg.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(e)}function Sg(e){tf.call(this),this.type="MeshPhongMaterial",this.color=new Ld(16777215),this.specular=new Ld(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ld(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=NR,this.normalScale=new fd(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=cL,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Ag(e){Sg.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(e)}function Lg(e){tf.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=NR,this.normalScale=new fd(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Rg(e){tf.call(this),this.type="MeshLambertMaterial",this.color=new Ld(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ld(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=cL,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Cg(e){Jm.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}function Pg(e,t,n){var i=this,r=!1,a=0,o=0,s=void 0;this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,!1===r&&void 0!==i.onStart&&i.onStart(e,a,o),r=!0},this.itemEnd=function(e){a++,void 0!==i.onProgress&&i.onProgress(e,a,o),a===o&&(r=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(e){void 0!==i.onError&&i.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this}}function Og(e){this.manager=void 0!==e?e:uC}function Ig(e){this.manager=void 0!==e?e:uC,this._parser=null}function Ng(e){this.manager=void 0!==e?e:uC,this._parser=null}function Dg(e){this.manager=void 0!==e?e:uC}function Ug(e){this.manager=void 0!==e?e:uC}function Bg(e){this.manager=void 0!==e?e:uC}function Fg(){this.type="Curve",this.arcLengthDivisions=200}function zg(e,t,n,i,r,a,o,s){Fg.call(this),this.type="EllipseCurve",this.aX=e||0,this.aY=t||0,this.xRadius=n||1,this.yRadius=i||1,this.aStartAngle=r||0,this.aEndAngle=a||2*Math.PI,this.aClockwise=o||!1,this.aRotation=s||0}function kg(e,t,n,i,r,a){zg.call(this,e,t,n,n,i,r,a),this.type="ArcCurve"}function Gg(){function e(e,a,o,s){t=e,n=o,i=-3*e+3*a-2*o-s,r=2*e-2*a+o+s}var t=0,n=0,i=0,r=0;return{initCatmullRom:function(t,n,i,r,a){e(n,i,a*(i-t),a*(r-n))},initNonuniformCatmullRom:function(t,n,i,r,a,o,s){var c=(n-t)/a-(i-t)/(a+o)+(i-n)/o,l=(i-n)/o-(r-n)/(o+s)+(r-i)/s;e(n,i,c*=o,l*=o)},calc:function(e){var a=e*e;return t+n*e+i*a+r*(a*e)}}}function Hg(e,t,n,i){Fg.call(this),this.type="CatmullRomCurve3",this.points=e||[],this.closed=t||!1,this.curveType=n||"centripetal",this.tension=i||.5}function Vg(e,t,n,i,r){var a=.5*(i-t),o=.5*(r-n),s=e*e;return(2*n-2*i+a+o)*(e*s)+(-3*n+3*i-2*a-o)*s+a*e+n}function jg(e,t){var n=1-e;return n*n*t}function Wg(e,t){return 2*(1-e)*e*t}function Xg(e,t){return e*e*t}function qg(e,t,n,i){return jg(e,t)+Wg(e,n)+Xg(e,i)}function Yg(e,t){var n=1-e;return n*n*n*t}function Zg(e,t){var n=1-e;return 3*n*n*e*t}function Jg(e,t){return 3*(1-e)*e*e*t}function Kg(e,t){return e*e*e*t}function Qg(e,t,n,i,r){return Yg(e,t)+Zg(e,n)+Jg(e,i)+Kg(e,r)}function $g(e,t,n,i){Fg.call(this),this.type="CubicBezierCurve",this.v0=e||new fd,this.v1=t||new fd,this.v2=n||new fd,this.v3=i||new fd}function ey(e,t,n,i){Fg.call(this),this.type="CubicBezierCurve3",this.v0=e||new gd,this.v1=t||new gd,this.v2=n||new gd,this.v3=i||new gd}function ty(e,t){Fg.call(this),this.type="LineCurve",this.v1=e||new fd,this.v2=t||new fd}function ny(e,t){Fg.call(this),this.type="LineCurve3",this.v1=e||new gd,this.v2=t||new gd}function iy(e,t,n){Fg.call(this),this.type="QuadraticBezierCurve",this.v0=e||new fd,this.v1=t||new fd,this.v2=n||new fd}function ry(e,t,n){Fg.call(this),this.type="QuadraticBezierCurve3",this.v0=e||new gd,this.v1=t||new gd,this.v2=n||new gd}function ay(e){Fg.call(this),this.type="SplineCurve",this.points=e||[]}function oy(){Fg.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}function sy(e){oy.call(this),this.type="Path",this.currentPoint=new fd,e&&this.setFromPoints(e)}function cy(e){sy.call(this,e),this.uuid=UR.generateUUID(),this.type="Shape",this.holes=[]}function ly(e,t){Id.call(this),this.type="Light",this.color=new Ld(e),this.intensity=void 0!==t?t:1,this.receiveShadow=void 0}function hy(e,t,n){ly.call(this,e,n),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(Id.DefaultUp),this.updateMatrix(),this.groundColor=new Ld(t)}function uy(e){this.camera=e,this.bias=0,this.radius=1,this.mapSize=new fd(512,512),this.map=null,this.matrix=new md}function py(){uy.call(this,new Nm(50,1,.5,500))}function dy(e,t,n,i,r,a){ly.call(this,e,t),this.type="SpotLight",this.position.copy(Id.DefaultUp),this.updateMatrix(),this.target=new Id,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(e){this.intensity=e/Math.PI}}),this.distance=void 0!==n?n:0,this.angle=void 0!==i?i:Math.PI/3,this.penumbra=void 0!==r?r:0,this.decay=void 0!==a?a:1,this.shadow=new py}function fy(e,t,n,i){ly.call(this,e,t),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(e){this.intensity=e/(4*Math.PI)}}),this.distance=void 0!==n?n:0,this.decay=void 0!==i?i:1,this.shadow=new uy(new Nm(90,1,.5,500))}function my(){uy.call(this,new Dd(-5,5,5,-5,.5,500))}function vy(e,t){ly.call(this,e,t),this.type="DirectionalLight",this.position.copy(Id.DefaultUp),this.updateMatrix(),this.target=new Id,this.shadow=new my}function gy(e,t){ly.call(this,e,t),this.type="AmbientLight",this.castShadow=void 0}function yy(e,t,n,i){ly.call(this,e,t),this.type="RectAreaLight",this.width=void 0!==n?n:10,this.height=void 0!==i?i:10}function xy(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n}function wy(e,t,n,i){xy.call(this,e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function by(e,t,n,i){xy.call(this,e,t,n,i)}function _y(e,t,n,i){xy.call(this,e,t,n,i)}function My(e,t,n,i){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=yC.convertArray(t,this.TimeBufferType),this.values=yC.convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}function Ey(e,t,n){My.call(this,e,t,n)}function Ty(e,t,n,i){My.call(this,e,t,n,i)}function Sy(e,t,n,i){My.call(this,e,t,n,i)}function Ay(e,t,n,i){xy.call(this,e,t,n,i)}function Ly(e,t,n,i){My.call(this,e,t,n,i)}function Ry(e,t,n,i){My.call(this,e,t,n,i)}function Cy(e,t,n,i){My.call(this,e,t,n,i)}function Py(e,t,n){this.name=e,this.tracks=n,this.duration=void 0!==t?t:-1,this.uuid=UR.generateUUID(),this.duration<0&&this.resetDuration()}function Oy(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Sy;case"vector":case"vector2":case"vector3":case"vector4":return Cy;case"color":return Ty;case"quaternion":return Ly;case"bool":case"boolean":return Ey;case"string":return Ry}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function Iy(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");var t=Oy(e.type);if(void 0===e.times){var n=[],i=[];yC.flattenJSON(e.keys,n,i,"value"),e.times=n,e.values=i}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}function Ny(e){this.manager=void 0!==e?e:uC,this.textures={}}function Dy(e){this.manager=void 0!==e?e:uC}function Uy(){}function By(e){"boolean"==typeof e&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),e=void 0),this.manager=void 0!==e?e:uC,this.withCredentials=!1}function Fy(e){this.manager=void 0!==e?e:uC,this.texturePath=""}function zy(){this.type="ShapePath",this.color=new Ld,this.subPaths=[],this.currentPath=null}function ky(e){this.type="Font",this.data=e}function Gy(e,t,n){for(var i=Array.from?Array.from(e):String(e).split(""),r=t/n.resolution,a=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*r,o=[],s=0,c=0,l=0;l0?1:+e}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&function(){Object.assign=function(e){if(void 0===e||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=1;n>8&255]+e[t>>16&255]+e[t>>24&255]+"-"+e[255&n]+e[n>>8&255]+"-"+e[n>>16&15|64]+e[n>>24&255]+"-"+e[63&i|128]+e[i>>8&255]+"-"+e[i>>16&255]+e[i>>24&255]+e[255&r]+e[r>>8&255]+e[r>>16&255]+e[r>>24&255]).toUpperCase()}}(),clamp:function(e,t,n){return Math.max(t,Math.min(n,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},lerp:function(e,t,n){return(1-n)*e+n*t},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*c_.DEG2RAD},radToDeg:function(e){return e*c_.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}};Object.defineProperties(n.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(n.prototype,{isVector2:!0,set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},applyMatrix3:function(e){var t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:function(){var e=new n,t=new n;return function(n,i){return e.set(n,n),t.set(i,i),this.clamp(e,t)}}(),clampLength:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},cross:function(e){return this.x*e.y-this.y*e.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var e=Math.atan2(this.y,this.x);return e<0&&(e+=2*Math.PI),e},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,n=this.y-e.y;return t*t+n*n},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromBufferAttribute:function(e,t,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){var n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}}),Object.assign(i.prototype,{isMatrix4:!0,set:function(e,t,n,i,r,a,o,s,c,l,h,u,p,d,f,m){var v=this.elements;return v[0]=e,v[4]=t,v[8]=n,v[12]=i,v[1]=r,v[5]=a,v[9]=o,v[13]=s,v[2]=c,v[6]=l,v[10]=h,v[14]=u,v[3]=p,v[7]=d,v[11]=f,v[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new i).fromArray(this.elements)},copy:function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this},copyPosition:function(e){var t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this},extractBasis:function(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this},extractRotation:function(){var e=new a;return function(t){var n=this.elements,i=t.elements,r=1/e.setFromMatrixColumn(t,0).length(),a=1/e.setFromMatrixColumn(t,1).length(),o=1/e.setFromMatrixColumn(t,2).length();return n[0]=i[0]*r,n[1]=i[1]*r,n[2]=i[2]*r,n[3]=0,n[4]=i[4]*a,n[5]=i[5]*a,n[6]=i[6]*a,n[7]=0,n[8]=i[8]*o,n[9]=i[9]*o,n[10]=i[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}}(),makeRotationFromEuler:function(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(i),c=Math.sin(i),l=Math.cos(r),h=Math.sin(r);if("XYZ"===e.order){var u=a*l,p=a*h,d=o*l,f=o*h;t[0]=s*l,t[4]=-s*h,t[8]=c,t[1]=p+d*c,t[5]=u-f*c,t[9]=-o*s,t[2]=f-u*c,t[6]=d+p*c,t[10]=a*s}else if("YXZ"===e.order){var m=s*l,v=s*h,g=c*l,y=c*h;t[0]=m+y*o,t[4]=g*o-v,t[8]=a*c,t[1]=a*h,t[5]=a*l,t[9]=-o,t[2]=v*o-g,t[6]=y+m*o,t[10]=a*s}else if("ZXY"===e.order){var m=s*l,v=s*h,g=c*l,y=c*h;t[0]=m-y*o,t[4]=-a*h,t[8]=g+v*o,t[1]=v+g*o,t[5]=a*l,t[9]=y-m*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if("ZYX"===e.order){var u=a*l,p=a*h,d=o*l,f=o*h;t[0]=s*l,t[4]=d*c-p,t[8]=u*c+f,t[1]=s*h,t[5]=f*c+u,t[9]=p*c-d,t[2]=-c,t[6]=o*s,t[10]=a*s}else if("YZX"===e.order){var x=a*s,w=a*c,b=o*s,_=o*c;t[0]=s*l,t[4]=_-x*h,t[8]=b*h+w,t[1]=h,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=w*h+b,t[10]=x-_*h}else if("XZY"===e.order){var x=a*s,w=a*c,b=o*s,_=o*c;t[0]=s*l,t[4]=-h,t[8]=c*l,t[1]=x*h+_,t[5]=a*l,t[9]=w*h-b,t[2]=b*h-w,t[6]=o*l,t[10]=_*h+x}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(){var e=new a(0,0,0),t=new a(1,1,1);return function(n){return this.compose(e,n,t)}}(),lookAt:function(){var e=new a,t=new a,n=new a;return function(i,r,a){var o=this.elements;return n.subVectors(i,r),0===n.lengthSq()&&(n.z=1),n.normalize(),e.crossVectors(a,n),0===e.lengthSq()&&(1===Math.abs(a.z)?n.x+=1e-4:n.z+=1e-4,n.normalize(),e.crossVectors(a,n)),e.normalize(),t.crossVectors(n,e),o[0]=e.x,o[4]=t.x,o[8]=n.x,o[1]=e.y,o[5]=t.y,o[9]=n.y,o[2]=e.z,o[6]=t.z,o[10]=n.z,this}}(),multiply:function(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],h=n[5],u=n[9],p=n[13],d=n[2],f=n[6],m=n[10],v=n[14],g=n[3],y=n[7],x=n[11],w=n[15],b=i[0],_=i[4],M=i[8],E=i[12],T=i[1],S=i[5],A=i[9],L=i[13],R=i[2],C=i[6],P=i[10],O=i[14],I=i[3],N=i[7],D=i[11],U=i[15];return r[0]=a*b+o*T+s*R+c*I,r[4]=a*_+o*S+s*C+c*N,r[8]=a*M+o*A+s*P+c*D,r[12]=a*E+o*L+s*O+c*U,r[1]=l*b+h*T+u*R+p*I,r[5]=l*_+h*S+u*C+p*N,r[9]=l*M+h*A+u*P+p*D,r[13]=l*E+h*L+u*O+p*U,r[2]=d*b+f*T+m*R+v*I,r[6]=d*_+f*S+m*C+v*N,r[10]=d*M+f*A+m*P+v*D,r[14]=d*E+f*L+m*O+v*U,r[3]=g*b+y*T+x*R+w*I,r[7]=g*_+y*S+x*C+w*N,r[11]=g*M+y*A+x*P+w*D,r[15]=g*E+y*L+x*O+w*U,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},applyToBufferAttribute:function(){var e=new a;return function(t){for(var n=0,i=t.count;n=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var x=Math.sqrt(y),w=Math.atan2(x,v*g);m=Math.sin(m*w)/x,o=Math.sin(o*w)/x}var b=o*g;if(s=s*m+u*b,c=c*m+p*b,l=l*m+d*b,h=h*m+f*b,m===1-o){var _=1/Math.sqrt(s*s+c*c+l*l+h*h);s*=_,c*=_,l*=_,h*=_}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=h}}),Object.defineProperties(r.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this.onChangeCallback()}}}),Object.assign(r.prototype,{isQuaternion:!0,set:function(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this.onChangeCallback(),this},setFromEuler:function(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=e._x,i=e._y,r=e._z,a=e.order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(i/2),h=o(r/2),u=s(n/2),p=s(i/2),d=s(r/2);return"XYZ"===a?(this._x=u*l*h+c*p*d,this._y=c*p*h-u*l*d,this._z=c*l*d+u*p*h,this._w=c*l*h-u*p*d):"YXZ"===a?(this._x=u*l*h+c*p*d,this._y=c*p*h-u*l*d,this._z=c*l*d-u*p*h,this._w=c*l*h+u*p*d):"ZXY"===a?(this._x=u*l*h-c*p*d,this._y=c*p*h+u*l*d,this._z=c*l*d+u*p*h,this._w=c*l*h-u*p*d):"ZYX"===a?(this._x=u*l*h-c*p*d,this._y=c*p*h+u*l*d,this._z=c*l*d-u*p*h,this._w=c*l*h+u*p*d):"YZX"===a?(this._x=u*l*h+c*p*d,this._y=c*p*h+u*l*d,this._z=c*l*d-u*p*h,this._w=c*l*h-u*p*d):"XZY"===a&&(this._x=u*l*h-c*p*d,this._y=c*p*h-u*l*d,this._z=c*l*d+u*p*h,this._w=c*l*h+u*p*d),!1!==t&&this.onChangeCallback(),this},setFromAxisAngle:function(e,t){var n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this.onChangeCallback(),this},setFromRotationMatrix:function(e){var t,n=e.elements,i=n[0],r=n[4],a=n[8],o=n[1],s=n[5],c=n[9],l=n[2],h=n[6],u=n[10],p=i+s+u;return p>0?(t=.5/Math.sqrt(p+1),this._w=.25/t,this._x=(h-c)*t,this._y=(a-l)*t,this._z=(o-r)*t):i>s&&i>u?(t=2*Math.sqrt(1+i-s-u),this._w=(h-c)/t,this._x=.25*t,this._y=(r+o)/t,this._z=(a+l)/t):s>u?(t=2*Math.sqrt(1+s-i-u),this._w=(a-l)/t,this._x=(r+o)/t,this._y=.25*t,this._z=(c+h)/t):(t=2*Math.sqrt(1+u-i-s),this._w=(o-r)/t,this._x=(a+l)/t,this._y=(c+h)/t,this._z=.25*t),this.onChangeCallback(),this},setFromUnitVectors:function(){var e,t=new a;return function(n,i){return void 0===t&&(t=new a),e=n.dot(i)+1,e<1e-6?(e=0,Math.abs(n.x)>Math.abs(n.z)?t.set(-n.y,n.x,0):t.set(0,-n.z,n.y)):t.crossVectors(n,i),this._x=t.x,this._y=t.y,this._z=t.z,this._w=e,this.normalize()}}(),angleTo:function(e){return 2*Math.acos(Math.abs(c_.clamp(this.dot(e),-1,1)))},rotateTowards:function(e,t){var n=this.angleTo(e);if(0===n)return this;var i=Math.min(1,t/n);return this.slerp(e,i),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this.onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var n=e._x,i=e._y,r=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+i*c-r*s,this._y=i*l+a*s+r*o-n*c,this._z=r*l+a*c+n*s-i*o,this._w=a*l-n*o-i*s-r*c,this.onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var n=this._x,i=this._y,r=this._z,a=this._w,o=a*e._w+n*e._x+i*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;var s=1-o*o;if(s<=Number.EPSILON){var c=1-t;return this._w=c*a+t*this._w,this._x=c*n+t*this._x,this._y=c*i+t*this._y,this._z=c*r+t*this._z,this.normalize()}var l=Math.sqrt(s),h=Math.atan2(l,o),u=Math.sin((1-t)*h)/l,p=Math.sin(t*h)/l;return this._w=a*u+this._w*p,this._x=n*u+this._x*p,this._y=i*u+this._y*p,this._z=r*u+this._z*p,this.onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}}),Object.assign(a.prototype,{isVector3:!0,set:function(e,t,n){return this.x=e,this.y=t,this.z=n,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:function(){var e=new r;return function(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(e.setFromEuler(t))}}(),applyAxisAngle:function(){var e=new r;return function(t,n){return this.applyQuaternion(e.setFromAxisAngle(t,n))}}(),applyMatrix3:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this},applyMatrix4:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this},applyQuaternion:function(e){var t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,o=e.z,s=e.w,c=s*t+a*i-o*n,l=s*n+o*t-r*i,h=s*i+r*n-a*t,u=-r*t-a*n-o*i;return this.x=c*s+u*-r+l*-o-h*-a,this.y=l*s+u*-a+h*-r-c*-o,this.z=h*s+u*-o+c*-a-l*-r,this},project:function(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)},unproject:function(){var e=new i;return function(t){return this.applyMatrix4(e.getInverse(t.projectionMatrix)).applyMatrix4(t.matrixWorld)}}(),transformDirection:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(){var e=new a,t=new a;return function(n,i){return e.set(n,n,n),t.set(i,i,i),this.clamp(e,t)}}(),clampLength:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},cross:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)},crossVectors:function(e,t){var n=e.x,i=e.y,r=e.z,a=t.x,o=t.y,s=t.z;return this.x=i*s-r*o,this.y=r*a-n*s,this.z=n*o-i*a,this},projectOnVector:function(e){var t=e.dot(this)/e.lengthSq();return this.copy(e).multiplyScalar(t)},projectOnPlane:function(){var e=new a;return function(t){return e.copy(this).projectOnVector(t),this.sub(e)}}(),reflect:function(){var e=new a;return function(t){return this.sub(e.copy(t).multiplyScalar(2*this.dot(t)))}}(),angleTo:function(e){var t=this.dot(e)/Math.sqrt(this.lengthSq()*e.lengthSq());return Math.acos(c_.clamp(t,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)},setFromSphericalCoords:function(e,t,n){var i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this},setFromCylindrical:function(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)},setFromCylindricalCoords:function(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this},setFromMatrixPosition:function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,4*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromBufferAttribute:function(e,t,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}}),Object.assign(o.prototype,{isMatrix3:!0,set:function(e,t,n,i,r,a,o,s,c){var l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},applyToBufferAttribute:function(){var e=new a;return function(t){for(var n=0,i=t.count;n2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}},h_=0;s.DEFAULT_IMAGE=void 0,s.DEFAULT_MAPPING=300,s.prototype=Object.assign(Object.create(t.prototype),{constructor:s,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this},toJSON:function(e){var t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];var n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var i=this.image;if(void 0===i.uuid&&(i.uuid=c_.generateUUID()),!t&&void 0===e.images[i.uuid]){var r;if(Array.isArray(i)){r=[];for(var a=0,o=i.length;a1)switch(this.wrapS){case qw:e.x=e.x-Math.floor(e.x);break;case Yw:e.x=e.x<0?0:1;break;case Zw:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case qw:e.y=e.y-Math.floor(e.y);break;case Yw:e.y=e.y<0?0:1;break;case Zw:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}}),Object.defineProperty(s.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(c.prototype,{isVector4:!0,set:function(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,n,i,r,a=e.elements,o=a[0],s=a[4],c=a[8],l=a[1],h=a[5],u=a[9],p=a[2],d=a[6],f=a[10];if(Math.abs(s-l)<.01&&Math.abs(c-p)<.01&&Math.abs(u-d)<.01){if(Math.abs(s+l)<.1&&Math.abs(c+p)<.1&&Math.abs(u+d)<.1&&Math.abs(o+h+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;var m=(o+1)/2,v=(h+1)/2,g=(f+1)/2,y=(s+l)/4,x=(c+p)/4,w=(u+d)/4;return m>v&&m>g?m<.01?(n=0,i=.707106781,r=.707106781):(i=y/(n=Math.sqrt(m)),r=x/n):v>g?v<.01?(n=.707106781,i=0,r=.707106781):(n=y/(i=Math.sqrt(v)),r=w/i):g<.01?(n=.707106781,i=.707106781,r=0):(n=x/(r=Math.sqrt(g)),i=w/r),this.set(n,i,r,t),this}var b=Math.sqrt((d-u)*(d-u)+(c-p)*(c-p)+(l-s)*(l-s));return Math.abs(b)<.001&&(b=1),this.x=(d-u)/b,this.y=(c-p)/b,this.z=(l-s)/b,this.w=Math.acos((o+h+f-1)/2),this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this},clampScalar:function(){var e,t;return function(n,i){return void 0===e&&(e=new c,t=new c),e.set(n,n,n,n),t.set(i,i,i,i),this.clamp(e,t)}}(),clampLength:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this},lerpVectors:function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e},fromBufferAttribute:function(e,t,n){return void 0!==n&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}}),l.prototype=Object.assign(Object.create(t.prototype),{constructor:l,isWebGLRenderTarget:!0,setSize:function(e,t){this.width===e&&this.height===t||(this.width=e,this.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),h.prototype=Object.create(l.prototype),h.prototype.constructor=h,h.prototype.isWebGLRenderTargetCube=!0,u.prototype=Object.create(s.prototype),u.prototype.constructor=u,u.prototype.isDataTexture=!0,Object.assign(p.prototype,{isBox3:!0,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){for(var t=1/0,n=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0,s=0,c=e.length;sr&&(r=l),h>a&&(a=h),u>o&&(o=u)}return this.min.set(t,n,i),this.max.set(r,a,o),this},setFromBufferAttribute:function(e){for(var t=1/0,n=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0,s=0,c=e.count;sr&&(r=l),h>a&&(a=h),u>o&&(o=u)}return this.min.set(t,n,i),this.max.set(r,a,o),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},getParameter:function(e,t){return void 0===t&&(console.warn("THREE.Box3: .getParameter() target is now required"),t=new a),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},intersectsSphere:function(){var e=new a;return function(t){return this.clampPoint(t.center,e),e.distanceToSquared(t.center)<=t.radius*t.radius}}(),intersectsPlane:function(e){var t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant},intersectsTriangle:function(){function e(e){var r,a;for(r=0,a=e.length-3;r<=a;r+=3){c.fromArray(e,r);var o=h.x*Math.abs(c.x)+h.y*Math.abs(c.y)+h.z*Math.abs(c.z),s=t.dot(c),l=n.dot(c),u=i.dot(c);if(Math.max(-Math.max(s,l,u),Math.min(s,l,u))>o)return!1}return!0}var t=new a,n=new a,i=new a,r=new a,o=new a,s=new a,c=new a,l=new a,h=new a,u=new a;return function(a){if(this.isEmpty())return!1;this.getCenter(l),h.subVectors(this.max,l),t.subVectors(a.a,l),n.subVectors(a.b,l),i.subVectors(a.c,l),r.subVectors(n,t),o.subVectors(i,n),s.subVectors(t,i);var c=[0,-r.z,r.y,0,-o.z,o.y,0,-s.z,s.y,r.z,0,-r.x,o.z,0,-o.x,s.z,0,-s.x,-r.y,r.x,0,-o.y,o.x,0,-s.y,s.x,0];return!!e(c)&&(c=[1,0,0,0,1,0,0,0,1],!!e(c)&&(u.crossVectors(r,o),c=[u.x,u.y,u.z],e(c)))}}(),clampPoint:function(e,t){return void 0===t&&(console.warn("THREE.Box3: .clampPoint() target is now required"),t=new a),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new a;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),getBoundingSphere:function(){var e=new a;return function(t){return void 0===t&&(console.warn("THREE.Box3: .getBoundingSphere() target is now required"),t=new d),this.getCenter(t.center),t.radius=.5*this.getSize(e).length(),t}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(){var e=[new a,new a,new a,new a,new a,new a,new a,new a];return function(t){return this.isEmpty()?this:(e[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),e[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),e[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),e[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),e[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),e[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),e[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),e[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(e),this)}}(),translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),Object.assign(d.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(){var e=new p;return function(t,n){var i=this.center;void 0!==n?i.copy(n):e.setFromPoints(t).getCenter(i);for(var r=0,a=0,o=t.length;athis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t},getBoundingBox:function(e){return void 0===e&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),e=new p),e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}}),Object.assign(f.prototype,{set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(){var e=new a,t=new a;return function(n,i,r){var a=e.subVectors(r,i).cross(t.subVectors(n,i)).normalize();return this.setFromNormalAndCoplanarPoint(a,n),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return void 0===t&&(console.warn("THREE.Plane: .projectPoint() target is now required"),t=new a),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(){var e=new a;return function(t,n){void 0===n&&(console.warn("THREE.Plane: .intersectLine() target is now required"),n=new a);var i=t.delta(e),r=this.normal.dot(i);if(0!==r){var o=-(t.start.dot(this.normal)+this.constant)/r;if(!(o<0||o>1))return n.copy(i).multiplyScalar(o).add(t.start)}else if(0===this.distanceToPoint(t.start))return n.copy(t.start)}}(),intersectsLine:function(e){var t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return void 0===e&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),e=new a),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new a,t=new o;return function(n,i){var r=i||t.getNormalMatrix(n),a=this.coplanarPoint(e).applyMatrix4(n),o=this.normal.applyMatrix3(r).normalize();return this.constant=-a.dot(o),this}}(),translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}}),Object.assign(m.prototype,{set:function(e,t,n,i,r,a){var o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,n=0;n<6;n++)t[n].copy(e.planes[n]);return this},setFromMatrix:function(e){var t=this.planes,n=e.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],h=n[7],u=n[8],p=n[9],d=n[10],f=n[11],m=n[12],v=n[13],g=n[14],y=n[15];return t[0].setComponents(o-i,h-s,f-u,y-m).normalize(),t[1].setComponents(o+i,h+s,f+u,y+m).normalize(),t[2].setComponents(o+r,h+c,f+p,y+v).normalize(),t[3].setComponents(o-r,h-c,f-p,y-v).normalize(),t[4].setComponents(o-a,h-l,f-d,y-g).normalize(),t[5].setComponents(o+a,h+l,f+d,y+g).normalize(),this},intersectsObject:function(){var e=new d;return function(t){var n=t.geometry;return null===n.boundingSphere&&n.computeBoundingSphere(),e.copy(n.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSprite:function(){var e=new d;return function(t){return e.center.set(0,0,0),e.radius=.7071067811865476,e.applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSphere:function(e){for(var t=this.planes,n=e.center,i=-e.radius,r=0;r<6;r++)if(t[r].distanceToPoint(n)0?t.max.x:t.min.x,e.y=r.normal.y>0?t.max.y:t.min.y,e.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(e)<0)return!1}return!0}}(),containsPoint:function(e){for(var t=this.planes,n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}});var u_={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n",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",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"\nvec3 transformed = vec3( position );\n",beginnormal_vertex:"\nvec3 objectNormal = vec3( normal );\n",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",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",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",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",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",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",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",defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",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",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",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",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",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",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",fog_vertex:"#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif\n",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif\n",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",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",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",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",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",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",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",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",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",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",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",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",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",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n#endif\n",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",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",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",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",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",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",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",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",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",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",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",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",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",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",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",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",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",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",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",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",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",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",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",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",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",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}\n",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",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",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",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tgl_FragColor = texture2D( t2D, vUv );\n}\n",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position, 1.0 );\n\tgl_Position.z = 1.0;\n}\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \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",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \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\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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 \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",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 \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \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 \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",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 \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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\tvec4 matcapColor = texture2D( matcap, uv );\n\tmatcapColor = matcapTexelToLinear( matcapColor );\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",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 \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",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 \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",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 \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \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 \n\t#include \n\t#include \n\t#include \n}\n",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}\n",shadow_vert:"#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}\n",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n}\n"},p_={merge:function(e){for(var t={},n=0;n>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,n){return this.r=e,this.g=t,this.b=n,this},setHSL:function(){function e(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}return function(t,n,i){if(t=c_.euclideanModulo(t,1),n=c_.clamp(n,0,1),i=c_.clamp(i,0,1),0===n)this.r=this.g=this.b=i;else{var r=i<=.5?i*(1+n):i+n-i*n,a=2*i-r;this.r=e(a,r,t+1/3),this.g=e(a,r,t),this.b=e(a,r,t-1/3)}return this}}(),setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var n;if(n=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var i,r=n[1],a=n[2];switch(r){case"rgb":case"rgba":if(i=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(i[1],10))/255,this.g=Math.min(255,parseInt(i[2],10))/255,this.b=Math.min(255,parseInt(i[3],10))/255,t(i[5]),this;if(i=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(i[1],10))/100,this.g=Math.min(100,parseInt(i[2],10))/100,this.b=Math.min(100,parseInt(i[3],10))/100,t(i[5]),this;break;case"hsl":case"hsla":if(i=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(i[1])/360,s=parseInt(i[2],10)/100,c=parseInt(i[3],10)/100;return t(i[5]),this.setHSL(o,s,c)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(e)){var l=(h=n[1]).length;if(3===l)return this.r=parseInt(h.charAt(0)+h.charAt(0),16)/255,this.g=parseInt(h.charAt(1)+h.charAt(1),16)/255,this.b=parseInt(h.charAt(2)+h.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(h.charAt(0)+h.charAt(1),16)/255,this.g=parseInt(h.charAt(2)+h.charAt(3),16)/255,this.b=parseInt(h.charAt(4)+h.charAt(5),16)/255,this}if(e&&e.length>0){var h=d_[e];void 0!==h?this.setHex(h):console.warn("THREE.Color: Unknown color "+e)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);var n=t>0?1/t:1;return this.r=Math.pow(e.r,n),this.g=Math.pow(e.g,n),this.b=Math.pow(e.b,n),this},convertGammaToLinear:function(e){return this.copyGammaToLinear(this,e),this},convertLinearToGamma:function(e){return this.copyLinearToGamma(this,e),this},copySRGBToLinear:function(){function e(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}return function(t){return this.r=e(t.r),this.g=e(t.g),this.b=e(t.b),this}}(),copyLinearToSRGB:function(){function e(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}return function(t){return this.r=e(t.r),this.g=e(t.g),this.b=e(t.b),this}}(),convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){void 0===e&&(console.warn("THREE.Color: .getHSL() target is now required"),e={h:0,s:0,l:0});var t,n,i=this.r,r=this.g,a=this.b,o=Math.max(i,r,a),s=Math.min(i,r,a),c=(s+o)/2;if(s===o)t=0,n=0;else{var l=o-s;switch(n=c<=.5?l/(o+s):l/(2-o-s),o){case i:t=(r-a)/l+(r1){for(var t=0;t1){for(var t=0;t0){a.children=[];for(s=0;s0&&(r.geometries=u),p.length>0&&(r.materials=p),d.length>0&&(r.textures=d),f.length>0&&(r.images=f),m.length>0&&(r.shapes=m)}return r.object=a,r},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(var n=0;n0)for(p=0;p0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,t,n;for(this.computeFaceNormals(),e=0,t=this.faces.length;e0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,n,i,r;for(n=0,i=this.faces.length;n=0;n--){var f=p[n];for(this.faces.splice(f,1),o=0,s=this.faceVertexUvs.length;o0,w=g.vertexNormals.length>0,b=1!==g.color.r||1!==g.color.g||1!==g.color.b,_=g.vertexColors.length>0,M=0;if(M=e(M,0,0),M=e(M,1,!0),M=e(M,2,!1),M=e(M,3,y),M=e(M,4,x),M=e(M,5,w),M=e(M,6,b),M=e(M,7,_),h.push(M),h.push(g.a,g.b,g.c),h.push(g.materialIndex),y){var E=this.faceVertexUvs[0][c];h.push(i(E[0]),i(E[1]),i(E[2]))}if(x&&h.push(t(g.normal)),w){var T=g.vertexNormals;h.push(t(T[0]),t(T[1]),t(T[2]))}if(b&&h.push(n(g.color)),_){var S=g.vertexColors;h.push(n(S[0]),n(S[1]),n(S[2]))}}return r.data={},r.data.vertices=s,r.data.normals=u,d.length>0&&(r.data.colors=d),m.length>0&&(r.data.uvs=[m]),r.data.faces=h,r},clone:function(){return(new M).copy(this)},copy:function(e){var t,n,i,r,a,o;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var s=e.vertices;for(t=0,n=s.length;t0,s=a[1]&&a[1].length>0,c=e.morphTargets,l=c.length;if(l>0){t=[];for(g=0;g0){h=[];for(g=0;g0&&0===i.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(var g=0;g65535?P:R)(e,1):this.index=e},addAttribute:function(e,t){return t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):(this.attributes[e]=t,this):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.addAttribute(e,new E(arguments[1],arguments[2])))},getAttribute:function(e){return this.attributes[e]},removeAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,n){this.groups.push({start:e,count:t,materialIndex:void 0!==n?n:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix:function(e){var t=this.attributes.position;void 0!==t&&(e.applyToBufferAttribute(t),t.needsUpdate=!0);var n=this.attributes.normal;return void 0!==n&&((new o).getNormalMatrix(e).applyToBufferAttribute(n),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var e=new i;return function(t){return e.makeRotationX(t),this.applyMatrix(e),this}}(),rotateY:function(){var e=new i;return function(t){return e.makeRotationY(t),this.applyMatrix(e),this}}(),rotateZ:function(){var e=new i;return function(t){return e.makeRotationZ(t),this.applyMatrix(e),this}}(),translate:function(){var e=new i;return function(t,n,i){return e.makeTranslation(t,n,i),this.applyMatrix(e),this}}(),scale:function(){var e=new i;return function(t,n,i){return e.makeScale(t,n,i),this.applyMatrix(e),this}}(),lookAt:function(){var e=new _;return function(t){e.lookAt(t),e.updateMatrix(),this.applyMatrix(e.matrix)}}(),center:function(){var e=new a;return function(){return this.computeBoundingBox(),this.boundingBox.getCenter(e).negate(),this.translate(e.x,e.y,e.z),this}}(),setFromObject:function(e){var t=e.geometry;if(e.isPoints||e.isLine){var n=new O(3*t.vertices.length,3),i=new O(3*t.colors.length,3);if(this.addAttribute("position",n.copyVector3sArray(t.vertices)),this.addAttribute("color",i.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var r=new O(t.lineDistances.length,1);this.addAttribute("lineDistance",r.copyArray(t.lineDistances))}null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone())}else e.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},setFromPoints:function(e){for(var t=[],n=0,i=e.length;n0){var n=new Float32Array(3*e.normals.length);this.addAttribute("normal",new E(n,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var i=new Float32Array(3*e.colors.length);this.addAttribute("color",new E(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var r=new Float32Array(2*e.uvs.length);this.addAttribute("uv",new E(r,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var a=new Float32Array(2*e.uvs2.length);this.addAttribute("uv2",new E(a,2).copyVector2sArray(e.uvs2))}this.groups=e.groups;for(var o in e.morphTargets){for(var s=[],c=e.morphTargets[o],l=0,h=c.length;l0){var d=new O(4*e.skinIndices.length,4);this.addAttribute("skinIndex",d.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var f=new O(4*e.skinWeights.length,4);this.addAttribute("skinWeight",f.copyVector4sArray(e.skinWeights))}return null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new p);var e=this.attributes.position;void 0!==e?this.boundingBox.setFromBufferAttribute(e):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var e=new p,t=new a;return function(){null===this.boundingSphere&&(this.boundingSphere=new d);var n=this.attributes.position;if(n){var i=this.boundingSphere.center;e.setFromBufferAttribute(n),e.getCenter(i);for(var r=0,a=0,o=n.count;a0&&(e.userData=this.userData),void 0!==this.parameters){var t=this.parameters;for(var n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};var i=this.index;if(null!==i){o=Array.prototype.slice.call(i.array);e.data.index={type:i.array.constructor.name,array:o}}var r=this.attributes;for(var n in r){var a=r[n],o=Array.prototype.slice.call(a.array);e.data.attributes[n]={itemSize:a.itemSize,type:a.array.constructor.name,array:o,normalized:a.normalized}}var s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(e.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),e},clone:function(){return(new U).copy(this)},copy:function(e){var t,n,i;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var r=e.index;null!==r&&this.setIndex(r.clone());var a=e.attributes;for(t in a){var o=a[t];this.addAttribute(t,o.clone())}var s=e.morphAttributes;for(t in s){var c=[],l=s[t];for(n=0,i=l.length;n0&&(i.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(i.morphTargets=!0),!0===this.skinning&&(i.skinning=!0),!1===this.visible&&(i.visible=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),n){var r=t(e.textures),a=t(e.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.lights=e.lights,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.userData=JSON.parse(JSON.stringify(e.userData)),this.clipShadows=e.clipShadows,this.clipIntersection=e.clipIntersection;var t=e.clippingPlanes,n=null;if(null!==t){var i=t.length;n=new Array(i);for(var r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.shadowSide=e.shadowSide,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),H.prototype=Object.create(G.prototype),H.prototype.constructor=H,H.prototype.isShaderMaterial=!0,H.prototype.copy=function(e){return G.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=p_.clone(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.extensions=e.extensions,this},H.prototype.toJSON=function(e){var t=G.prototype.toJSON.call(this,e);t.uniforms={};for(var n in this.uniforms){var i=this.uniforms[n].value;i.isTexture?t.uniforms[n]={type:"t",value:i.toJSON(e).uuid}:i.isColor?t.uniforms[n]={type:"c",value:i.getHex()}:i.isVector2?t.uniforms[n]={type:"v2",value:i.toArray()}:i.isVector3?t.uniforms[n]={type:"v3",value:i.toArray()}:i.isVector4?t.uniforms[n]={type:"v4",value:i.toArray()}:i.isMatrix4?t.uniforms[n]={type:"m4",value:i.toArray()}:t.uniforms[n]={value:i}}return Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t},Object.assign(V.prototype,{set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){return void 0===t&&(console.warn("THREE.Ray: .at() target is now required"),t=new a),t.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(){var e=new a;return function(t){return this.origin.copy(this.at(t,e)),this}}(),closestPointToPoint:function(e,t){void 0===t&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),t=new a),t.subVectors(e,this.origin);var n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(){var e=new a;return function(t){var n=e.subVectors(t,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(t):(e.copy(this.direction).multiplyScalar(n).add(this.origin),e.distanceToSquared(t))}}(),distanceSqToSegment:function(){var e=new a,t=new a,n=new a;return function(i,r,a,o){e.copy(i).add(r).multiplyScalar(.5),t.copy(r).sub(i).normalize(),n.copy(this.origin).sub(e);var s,c,l,h,u=.5*i.distanceTo(r),p=-this.direction.dot(t),d=n.dot(this.direction),f=-n.dot(t),m=n.lengthSq(),v=Math.abs(1-p*p);if(v>0)if(s=p*f-d,c=p*d-f,h=u*v,s>=0)if(c>=-h)if(c<=h){var g=1/v;l=(s*=g)*(s+p*(c*=g)+2*d)+c*(p*s+c+2*f)+m}else c=u,l=-(s=Math.max(0,-(p*c+d)))*s+c*(c+2*f)+m;else c=-u,l=-(s=Math.max(0,-(p*c+d)))*s+c*(c+2*f)+m;else c<=-h?l=-(s=Math.max(0,-(-p*u+d)))*s+(c=s>0?-u:Math.min(Math.max(-u,-f),u))*(c+2*f)+m:c<=h?(s=0,l=(c=Math.min(Math.max(-u,-f),u))*(c+2*f)+m):l=-(s=Math.max(0,-(p*u+d)))*s+(c=s>0?u:Math.min(Math.max(-u,-f),u))*(c+2*f)+m;else c=p>0?-u:u,l=-(s=Math.max(0,-(p*c+d)))*s+c*(c+2*f)+m;return a&&a.copy(this.direction).multiplyScalar(s).add(this.origin),o&&o.copy(t).multiplyScalar(c).add(e),l}}(),intersectSphere:function(){var e=new a;return function(t,n){e.subVectors(t.center,this.origin);var i=e.dot(this.direction),r=e.dot(e)-i*i,a=t.radius*t.radius;if(r>a)return null;var o=Math.sqrt(a-r),s=i-o,c=i+o;return s<0&&c<0?null:s<0?this.at(c,n):this.at(s,n)}}(),intersectsSphere:function(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null},intersectPlane:function(e,t){var n=this.distanceToPlane(e);return null===n?null:this.at(n,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0},intersectBox:function(e,t){var n,i,r,a,o,s,c=1/this.direction.x,l=1/this.direction.y,h=1/this.direction.z,u=this.origin;return c>=0?(n=(e.min.x-u.x)*c,i=(e.max.x-u.x)*c):(n=(e.max.x-u.x)*c,i=(e.min.x-u.x)*c),l>=0?(r=(e.min.y-u.y)*l,a=(e.max.y-u.y)*l):(r=(e.max.y-u.y)*l,a=(e.min.y-u.y)*l),n>a||r>i?null:((r>n||n!==n)&&(n=r),(a=0?(o=(e.min.z-u.z)*h,s=(e.max.z-u.z)*h):(o=(e.max.z-u.z)*h,s=(e.min.z-u.z)*h),n>s||o>i?null:((o>n||n!==n)&&(n=o),(s=0?n:i,t)))},intersectsBox:function(){var e=new a;return function(t){return null!==this.intersectBox(t,e)}}(),intersectTriangle:function(){var e=new a,t=new a,n=new a,i=new a;return function(r,a,o,s,c){t.subVectors(a,r),n.subVectors(o,r),i.crossVectors(t,n);var l,h=this.direction.dot(i);if(h>0){if(s)return null;l=1}else{if(!(h<0))return null;l=-1,h=-h}e.subVectors(this.origin,r);var u=l*this.direction.dot(n.crossVectors(e,n));if(u<0)return null;var p=l*this.direction.dot(t.cross(e));if(p<0)return null;if(u+p>h)return null;var d=-l*e.dot(i);return d<0?null:this.at(d/h,c)}}(),applyMatrix4:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}}),Object.assign(j,{getNormal:function(){var e=new a;return function(t,n,i,r){void 0===r&&(console.warn("THREE.Triangle: .getNormal() target is now required"),r=new a),r.subVectors(i,n),e.subVectors(t,n),r.cross(e);var o=r.lengthSq();return o>0?r.multiplyScalar(1/Math.sqrt(o)):r.set(0,0,0)}}(),getBarycoord:function(){var e=new a,t=new a,n=new a;return function(i,r,o,s,c){e.subVectors(s,r),t.subVectors(o,r),n.subVectors(i,r);var l=e.dot(e),h=e.dot(t),u=e.dot(n),p=t.dot(t),d=t.dot(n),f=l*p-h*h;if(void 0===c&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),c=new a),0===f)return c.set(-2,-1,-1);var m=1/f,v=(p*u-h*d)*m,g=(l*d-h*u)*m;return c.set(1-v-g,g,v)}}(),containsPoint:function(){var e=new a;return function(t,n,i,r){return j.getBarycoord(t,n,i,r,e),e.x>=0&&e.y>=0&&e.x+e.y<=1}}(),getUV:function(){var e=new a;return function(t,n,i,r,a,o,s,c){return this.getBarycoord(t,n,i,r,e),c.set(0,0),c.addScaledVector(a,e.x),c.addScaledVector(o,e.y),c.addScaledVector(s,e.z),c}}()}),Object.assign(j.prototype,{set:function(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this},setFromPointsAndIndices:function(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},getArea:function(){var e=new a,t=new a;return function(){return e.subVectors(this.c,this.b),t.subVectors(this.a,this.b),.5*e.cross(t).length()}}(),getMidpoint:function(e){return void 0===e&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),e=new a),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(e){return j.getNormal(this.a,this.b,this.c,e)},getPlane:function(e){return void 0===e&&(console.warn("THREE.Triangle: .getPlane() target is now required"),e=new a),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,t){return j.getBarycoord(e,this.a,this.b,this.c,t)},containsPoint:function(e){return j.containsPoint(e,this.a,this.b,this.c)},getUV:function(e,t,n,i,r){return j.getUV(e,this.a,this.b,this.c,t,n,i,r)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:function(){var e=new a,t=new a,n=new a,i=new a,r=new a,o=new a;return function(s,c){void 0===c&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),c=new a);var l,h,u=this.a,p=this.b,d=this.c;e.subVectors(p,u),t.subVectors(d,u),i.subVectors(s,u);var f=e.dot(i),m=t.dot(i);if(f<=0&&m<=0)return c.copy(u);r.subVectors(s,p);var v=e.dot(r),g=t.dot(r);if(v>=0&&g<=v)return c.copy(p);var y=f*g-v*m;if(y<=0&&f>=0&&v<=0)return l=f/(f-v),c.copy(u).addScaledVector(e,l);o.subVectors(s,d);var x=e.dot(o),w=t.dot(o);if(w>=0&&x<=w)return c.copy(d);var b=x*m-f*w;if(b<=0&&m>=0&&w<=0)return h=m/(m-w),c.copy(u).addScaledVector(t,h);var _=v*w-x*g;if(_<=0&&g-v>=0&&x-w>=0)return n.subVectors(d,p),h=(g-v)/(g-v+(x-w)),c.copy(p).addScaledVector(n,h);var M=1/(_+b+y);return l=b*M,h=y*M,c.copy(u).addScaledVector(e,l).addScaledVector(t,h)}}(),equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}),W.prototype=Object.create(G.prototype),W.prototype.constructor=W,W.prototype.isMeshBasicMaterial=!0,W.prototype.copy=function(e){return G.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this},X.prototype=Object.assign(Object.create(_.prototype),{constructor:X,isMesh:!0,setDrawMode:function(e){this.drawMode=e},copy:function(e){return _.prototype.copy.call(this,e),this.drawMode=e.drawMode,void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this},updateMorphTargets:function(){var e,t,n,i=this.geometry;if(i.isBufferGeometry){var r=i.morphAttributes,a=Object.keys(r);if(a.length>0){var o=r[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=o.length;e0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=s.length;en.far?null:{distance:c,point:w.clone(),object:e}}function t(t,i,r,a,o,s,u,p,d){c.fromBufferAttribute(o,u),l.fromBufferAttribute(o,p),h.fromBufferAttribute(o,d);var f=e(t,i,r,a,c,l,h,y);if(f){s&&(m.fromBufferAttribute(s,u),v.fromBufferAttribute(s,p),g.fromBufferAttribute(s,d),f.uv=j.getUV(y,c,l,h,m,v,g,new n));var w=new x(u,p,d);j.getNormal(c,l,h,w.normal),f.face=w}return f}var r=new i,o=new V,s=new d,c=new a,l=new a,h=new a,u=new a,p=new a,f=new a,m=new n,v=new n,g=new n,y=new a,w=new a;return function(i,a){var d=this.geometry,x=this.material,w=this.matrixWorld;if(void 0!==x&&(null===d.boundingSphere&&d.computeBoundingSphere(),s.copy(d.boundingSphere),s.applyMatrix4(w),!1!==i.ray.intersectsSphere(s)&&(r.getInverse(w),o.copy(i.ray).applyMatrix4(r),null===d.boundingBox||!1!==o.intersectsBox(d.boundingBox)))){var b;if(d.isBufferGeometry){var _,M,E,T,S,A,L,R,C,P=d.index,O=d.attributes.position,I=d.attributes.uv,N=d.groups,D=d.drawRange;if(null!==P)if(Array.isArray(x))for(T=0,A=N.length;T0&&(z=V);for(var W=0,X=H.length;Wi.far||a.push({distance:x,point:t.clone(),uv:j.getUV(t,h,u,p,d,f,m,new n),face:null,object:this})}}}(),clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return _.prototype.copy.call(this,e),void 0!==e.center&&this.center.copy(e.center),this}}),Dt.prototype=Object.assign(Object.create(_.prototype),{constructor:Dt,copy:function(e){_.prototype.copy.call(this,e,!1);for(var t=e.levels,n=0,i=t.length;n1){e.setFromMatrixPosition(n.matrixWorld),t.setFromMatrixPosition(this.matrixWorld);var r=e.distanceTo(t);i[0].object.visible=!0;for(var a=1,o=i.length;a=i[a].distance;a++)i[a-1].object.visible=!1,i[a].object.visible=!0;for(;ah||(f.applyMatrix4(this.matrixWorld),(S=i.ray.origin.distanceTo(f))i.far||r.push({distance:S,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this}))}else for(var x=0,w=g.length/3-1;xh||(f.applyMatrix4(this.matrixWorld),(S=i.ray.origin.distanceTo(f))i.far||r.push({distance:S,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this}))}else if(s.isGeometry)for(var M=s.vertices,E=M.length,x=0;xh)){f.applyMatrix4(this.matrixWorld);var S=i.ray.origin.distanceTo(f);Si.far||r.push({distance:S,point:d.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}}}(),copy:function(e){return _.prototype.copy.call(this,e),this.geometry.copy(e.geometry),this.material.copy(e.material),this},clone:function(){return(new this.constructor).copy(this)}}),Gt.prototype=Object.assign(Object.create(kt.prototype),{constructor:Gt,isLineSegments:!0,computeLineDistances:function(){var e=new a,t=new a;return function(){var n=this.geometry;if(n.isBufferGeometry)if(null===n.index){for(var i=n.attributes.position,r=[],a=0,o=i.count;ai.far)return;r.push({distance:o,distanceToRay:Math.sqrt(a),point:f.clone(),index:n,face:null,object:s})}}var s=this,c=this.geometry,l=this.matrixWorld,h=i.params.Points.threshold;if(null===c.boundingSphere&&c.computeBoundingSphere(),n.copy(c.boundingSphere),n.applyMatrix4(l),n.radius+=h,!1!==i.ray.intersectsSphere(n)){e.getInverse(l),t.copy(i.ray).applyMatrix4(e);var u=h/((this.scale.x+this.scale.y+this.scale.z)/3),p=u*u,d=new a,f=new a;if(c.isBufferGeometry){var m=c.index,v=c.attributes.position.array;if(null!==m)for(var g=m.array,y=0,x=g.length;y=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),Xt.prototype=Object.create(s.prototype),Xt.prototype.constructor=Xt,Xt.prototype.isCompressedTexture=!0,qt.prototype=Object.create(s.prototype),qt.prototype.constructor=qt,qt.prototype.isCanvasTexture=!0,Yt.prototype=Object.create(s.prototype),Yt.prototype.constructor=Yt,Yt.prototype.isDepthTexture=!0,Zt.prototype=Object.create(U.prototype),Zt.prototype.constructor=Zt,Jt.prototype=Object.create(M.prototype),Jt.prototype.constructor=Jt,Kt.prototype=Object.create(U.prototype),Kt.prototype.constructor=Kt,Qt.prototype=Object.create(M.prototype),Qt.prototype.constructor=Qt,$t.prototype=Object.create(U.prototype),$t.prototype.constructor=$t,en.prototype=Object.create(M.prototype),en.prototype.constructor=en,tn.prototype=Object.create($t.prototype),tn.prototype.constructor=tn,nn.prototype=Object.create(M.prototype),nn.prototype.constructor=nn,rn.prototype=Object.create($t.prototype),rn.prototype.constructor=rn,an.prototype=Object.create(M.prototype),an.prototype.constructor=an,on.prototype=Object.create($t.prototype),on.prototype.constructor=on,sn.prototype=Object.create(M.prototype),sn.prototype.constructor=sn,cn.prototype=Object.create($t.prototype),cn.prototype.constructor=cn,ln.prototype=Object.create(M.prototype),ln.prototype.constructor=ln,hn.prototype=Object.create(U.prototype),hn.prototype.constructor=hn,un.prototype=Object.create(M.prototype),un.prototype.constructor=un,pn.prototype=Object.create(U.prototype),pn.prototype.constructor=pn,dn.prototype=Object.create(M.prototype),dn.prototype.constructor=dn,fn.prototype=Object.create(U.prototype),fn.prototype.constructor=fn;var N_={triangulate:function(e,t,n){n=n||2;var i=t&&t.length,r=i?t[0]*n:e.length,a=mn(e,0,r,n,!0),o=[];if(!a)return o;var s,c,l,h,u,p,d;if(i&&(a=_n(e,t,a,n)),e.length>80*n){s=l=e[0],c=h=e[1];for(var f=n;fl&&(l=u),p>h&&(h=p);d=0!==(d=Math.max(l-s,h-c))?1/d:0}return gn(a,o,n,s,c,d),o}},D_={area:function(e){for(var t=e.length,n=0,i=t-1,r=0;r=r)break e;var o=t[1];e=r)break t}a=n,n=0}for(;n>>1;et;)--a;if(++a,0!==r||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);var o=this.getValueSize();this.times=z_.arraySlice(n,r,a),this.values=z_.arraySlice(this.values,r*o,a*o)}return this},validate:function(){var e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);var n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);for(var a=null,o=0;o!==r;o++){var s=n[o];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,s),e=!1;break}if(null!==a&&a>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,s,a),e=!1;break}a=s}if(void 0!==i&&z_.isTypedArray(i))for(var o=0,c=i.length;o!==c;++o){var l=i[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e},optimize:function(){for(var e=this.times,t=this.values,n=this.getValueSize(),i=2302===this.getInterpolation(),r=1,a=e.length-1,o=1;o0){e[r]=e[a];for(var f=a*n,m=r*n,p=0;p!==n;++p)t[m+p]=t[f+p];++r}return r!==e.length&&(this.times=z_.arraySlice(e,0,r),this.values=z_.arraySlice(t,0,r*n)),this}}),Ai.prototype=Object.assign(Object.create(Si.prototype),{constructor:Ai,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Li.prototype=Object.assign(Object.create(Si.prototype),{constructor:Li,ValueTypeName:"color"}),Ri.prototype=Object.assign(Object.create(Si.prototype),{constructor:Ri,ValueTypeName:"number"}),Ci.prototype=Object.assign(Object.create(_i.prototype),{constructor:Ci,interpolate_:function(e,t,n,i){for(var a=this.resultBuffer,o=this.sampleValues,s=this.valueSize,c=e*s,l=(n-t)/(i-t),h=c+s;c!==h;c+=4)r.slerpFlat(a,0,o,c-s,o,c,l);return a}}),Pi.prototype=Object.assign(Object.create(Si.prototype),{constructor:Pi,ValueTypeName:"quaternion",DefaultInterpolation:2301,InterpolantFactoryMethodLinear:function(e){return new Ci(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0}),Oi.prototype=Object.assign(Object.create(Si.prototype),{constructor:Oi,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Ii.prototype=Object.assign(Object.create(Si.prototype),{constructor:Ii,ValueTypeName:"vector"}),Object.assign(Ni,{parse:function(e){for(var t=[],n=e.tracks,i=1/(e.fps||1),r=0,a=n.length;r!==a;++r)t.push(Ui(n[r]).scale(i));return new Ni(e.name,e.duration,t)},toJSON:function(e){for(var t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid},r=0,a=n.length;r!==a;++r)t.push(Si.toJSON(n[r]));return i},CreateFromMorphTargetSequence:function(e,t,n,i){for(var r=t.length,a=[],o=0;o1){var c=i[h=s[1]];c||(i[h]=c=[]),c.push(o)}}var l=[];for(var h in i)l.push(Ni.CreateFromMorphTargetSequence(h,i[h],t,n));return l},parseAnimation:function(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var n=function(e,t,n,i,r){if(0!==n.length){var a=[],o=[];z_.flattenJSON(n,a,o,i),0!==a.length&&r.push(new e(t,a,o))}},i=[],r=e.name||"default",a=e.length||-1,o=e.fps||30,s=e.hierarchy||[],c=0;c0||0===e.search(/^data\:image\/jpeg/);r.format=i?mb:vb,r.needsUpdate=!0,void 0!==t&&t(r)},n,i),r},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),Object.assign(Wi.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(e,t){var n=this.getUtoTmapping(e);return this.getPoint(n,t)},getPoints:function(e){void 0===e&&(e=5);for(var t=[],n=0;n<=e;n++)t.push(this.getPoint(n/e));return t},getSpacedPoints:function(e){void 0===e&&(e=5);for(var t=[],n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t},getLength:function(){var e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(void 0===e&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,n,i=[],r=this.getPoint(0),a=0;for(i.push(0),n=1;n<=e;n++)a+=(t=this.getPoint(n/e)).distanceTo(r),i.push(a),r=t;return this.cacheArcLengths=i,i},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){var n,i=this.getLengths(),r=0,a=i.length;n=t||e*i[a-1];for(var o,s=0,c=a-1;s<=c;)if(r=Math.floor(s+(c-s)/2),(o=i[r]-n)<0)s=r+1;else{if(!(o>0)){c=r;break}c=r-1}if(r=c,i[r]===n)return r/(a-1);var l=i[r];return(r+(n-l)/(i[r+1]-l))/(a-1)},getTangent:function(e){var t=e-1e-4,n=e+1e-4;t<0&&(t=0),n>1&&(n=1);var i=this.getPoint(t);return this.getPoint(n).clone().sub(i).normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},computeFrenetFrames:function(e,t){var n,r,o,s=new a,c=[],l=[],h=[],u=new a,p=new i;for(n=0;n<=e;n++)r=n/e,c[n]=this.getTangentAt(r),c[n].normalize();l[0]=new a,h[0]=new a;var d=Number.MAX_VALUE,f=Math.abs(c[0].x),m=Math.abs(c[0].y),v=Math.abs(c[0].z);for(f<=d&&(d=f,s.set(1,0,0)),m<=d&&(d=m,s.set(0,1,0)),v<=d&&s.set(0,0,1),u.crossVectors(c[0],s).normalize(),l[0].crossVectors(c[0],u),h[0].crossVectors(c[0],l[0]),n=1;n<=e;n++)l[n]=l[n-1].clone(),h[n]=h[n-1].clone(),u.crossVectors(c[n-1],c[n]),u.length()>Number.EPSILON&&(u.normalize(),o=Math.acos(c_.clamp(c[n-1].dot(c[n]),-1,1)),l[n].applyMatrix4(p.makeRotationAxis(u,o))),h[n].crossVectors(c[n],l[n]);if(!0===t)for(o=Math.acos(c_.clamp(l[0].dot(l[e]),-1,1)),o/=e,c[0].dot(u.crossVectors(l[0],l[e]))>0&&(o=-o),n=1;n<=e;n++)l[n].applyMatrix4(p.makeRotationAxis(c[n],o*n)),h[n].crossVectors(c[n],l[n]);return{tangents:c,normals:l,binormals:h}},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){var e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}),Xi.prototype=Object.create(Wi.prototype),Xi.prototype.constructor=Xi,Xi.prototype.isEllipseCurve=!0,Xi.prototype.getPoint=function(e,t){for(var i=t||new n,r=2*Math.PI,a=this.aEndAngle-this.aStartAngle,o=Math.abs(a)r;)a-=r;a0?0:(Math.floor(Math.abs(s)/r)+1)*r:0===c&&s===r-1&&(s=r-2,c=1);var l,h,u,p;if(this.closed||s>0?l=i[(s-1)%r]:(V_.subVectors(i[0],i[1]).add(i[0]),l=V_),h=i[s%r],u=i[(s+1)%r],this.closed||s+2r.length-2?r.length-1:o+1],u=r[o>r.length-3?r.length-1:o+2];return i.set(Ji(s,c.x,l.x,h.x,u.x),Ji(s,c.y,l.y,h.y,u.y)),i},pr.prototype.copy=function(e){Wi.prototype.copy.call(this,e),this.points=[];for(var t=0,n=e.points.length;t=t){var r=n[i]-t,a=this.curves[i],o=a.getLength(),s=0===o?0:1-r/o;return a.getPointAt(s)}i++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],t=0,n=0,i=this.curves.length;n1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},copy:function(e){Wi.prototype.copy.call(this,e),this.curves=[];for(var t=0,n=e.curves.length;t0){var l=c.getPoint(0);l.equals(this.currentPoint)||this.lineTo(l.x,l.y)}this.curves.push(c);var h=c.getPoint(1);this.currentPoint.copy(h)},copy:function(e){return dr.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){var e=dr.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return dr.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}}),mr.prototype=Object.assign(Object.create(fr.prototype),{constructor:mr,getPointsHoles:function(e){for(var t=[],n=0,i=this.holes.length;n1?e.skinWeights[i+1]:0,s=n>2?e.skinWeights[i+2]:0,l=n>3?e.skinWeights[i+3]:0;t.skinWeights.push(new c(a,o,s,l))}if(e.skinIndices)for(var i=0,r=e.skinIndices.length;i1?e.skinIndices[i+1]:0,p=n>2?e.skinIndices[i+2]:0,d=n>3?e.skinIndices[i+3]:0;t.skinIndices.push(new c(h,u,p,d))}t.bones=e.bones,t.bones&&t.bones.length>0&&(t.skinWeights.length!==t.skinIndices.length||t.skinIndices.length!==t.vertices.length)&&console.warn("When skinning, number of vertices ("+t.vertices.length+"), skinIndices ("+t.skinIndices.length+"), and skinWeights ("+t.skinWeights.length+") should match.")}function i(e,t){var n=e.scale;if(void 0!==e.morphTargets)for(var i=0,r=e.morphTargets.length;i0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');for(var u=t.faces,p=e.morphColors[0].colors,i=0,r=u.length;i0&&(t.animations=n)}return function(n,a){void 0!==n.data&&(n=n.data),void 0!==n.scale?n.scale=1/n.scale:n.scale=1;var o=new M;return e(n,o),t(n,o),i(n,o),r(n,o),o.computeFaceNormals(),o.computeBoundingSphere(),void 0===n.materials||0===n.materials.length?{geometry:o}:{geometry:o,materials:Rr.prototype.initMaterials(n.materials,this.resourcePath||a,this.crossOrigin)}}}()}),Object.assign(Pr.prototype,{crossOrigin:"anonymous",load:function(e,t,n,i){var r=this,a=void 0===this.path?Y_.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;var o=new Fi(r.manager);o.setPath(this.path),o.load(e,function(n){var a=null;try{a=JSON.parse(n)}catch(t){return void 0!==i&&i(t),void console.error("THREE:ObjectLoader: Can't parse "+e+".",t.message)}var o=a.metadata;if(void 0===o||void 0===o.type||"geometry"===o.type.toLowerCase())return void console.error("THREE.ObjectLoader: Can't load "+e+". Use THREE.JSONLoader instead.");r.parse(a,t)},n,i)},setPath:function(e){return this.path=e,this},setResourcePath:function(e){return this.resourcePath=e,this},setCrossOrigin:function(e){return this.crossOrigin=e,this},parse:function(e,t){var n=this.parseShape(e.shapes),i=this.parseGeometries(e.geometries,n),r=this.parseImages(e.images,function(){void 0!==t&&t(s)}),a=this.parseTextures(e.textures,r),o=this.parseMaterials(e.materials,a),s=this.parseObject(e.object,i,o);return e.animations&&(s.animations=this.parseAnimations(e.animations)),void 0!==e.images&&0!==e.images.length||void 0!==t&&t(s),s},parseShape:function(e){var t={};if(void 0!==e)for(var n=0,i=e.length;n0){var a=new Hi(new Bi(t));a.setCrossOrigin(this.crossOrigin);for(var o=0,s=e.length;o0?new Ft(o,s):new X(o,s);break;case"LOD":a=new Dt;break;case"Line":a=new kt(i(e.geometry),r(e.material),e.mode);break;case"LineLoop":a=new Ht(i(e.geometry),r(e.material));break;case"LineSegments":a=new Gt(i(e.geometry),r(e.material));break;case"PointCloud":case"Points":a=new jt(i(e.geometry),r(e.material));break;case"Sprite":a=new Nt(r(e.material));break;case"Group":a=new wt;break;default:a=new _}if(a.uuid=e.uuid,void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(a.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.quaternion&&a.quaternion.fromArray(e.quaternion),void 0!==e.scale&&a.scale.fromArray(e.scale)),void 0!==e.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(a.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&a.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(a.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.frustumCulled&&(a.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(a.renderOrder=e.renderOrder),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.layers&&(a.layers.mask=e.layers),void 0!==e.children)for(var c=e.children,l=0;l1){for(var g=!1,y=[],x=0,w=p.length;xNumber.EPSILON){if(l<0&&(o=t[a],c=-c,s=t[r],l=-l),e.ys.y)continue;if(e.y===o.y){if(e.x===o.x)return!0}else{var h=l*(e.x-o.x)-c*(e.y-o.y);if(0===h)return!0;if(h<0)continue;i=!i}}else{if(e.y!==o.y)continue;if(s.x<=e.x&&e.x<=o.x||o.x<=e.x&&e.x<=s.x)return!0}}return i})(M.p,p[T].p)&&(x!==T&&y.push({froms:x,tos:T,hole:_}),E?(E=!1,u[T].push(M)):g=!0);E&&u[x].push(M)}y.length>0&&(g||(d=u))}for(var S,m=0,A=p.length;m0){this.source.connect(this.filters[0]);for(var e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(var e=1,t=this.filters.length;e=.5)for(var a=0;a!==r;++a)e[t+a]=e[n+a]},_slerp:function(e,t,n,i){r.slerpFlat(e,t,e,t,e,n,i)},_lerp:function(e,t,n,i,r){for(var a=1-i,o=0;o!==r;++o){var s=t+o;e[s]=e[s]*a+e[n+o]*i}}});Object.assign(qr.prototype,{getValue:function(e,t){this.bind();var n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(e,t)},setValue:function(e,t){for(var n=this._bindings,i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)},bind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()},unbind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}),Object.assign(Yr,{Composite:qr,create:function(e,t,n){return e&&e.isAnimationObjectGroup?new Yr.Composite(e,t,n):new Yr(e,t,n)},sanitizeNodeName:function(){var e=new RegExp("[\\[\\]\\.:\\/]","g");return function(t){return t.replace(/\s/g,"_").replace(e,"")}}(),parseTrackName:function(){var e="[^\\[\\]\\.:\\/]",t="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",n=/((?:WC+[\/:])*)/.source.replace("WC",e),i=/(WCOD+)?/.source.replace("WCOD",t),r=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",e),a=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",e),o=new RegExp("^"+n+i+r+a+"$"),s=["material","materials","bones"];return function(e){var t=o.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);var n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){var r=n.nodeName.substring(i+1);-1!==s.indexOf(r)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}}(),findNode:function(e,t){if(!t||""===t||"root"===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){var n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){var i=function(e){for(var n=0;n=t){var h=t++,u=e[h];n[u.uuid]=l,e[l]=u,n[c]=h,e[h]=s;for(var p=0,d=r;p!==d;++p){var f=i[p],m=f[h],v=f[l];f[l]=m,f[h]=v}}}this.nCachedObjects_=t},uncache:function(){for(var e=this._objects,t=e.length,n=this.nCachedObjects_,i=this._indicesByUUID,r=this._bindings,a=r.length,o=0,s=arguments.length;o!==s;++o){var c=arguments[o].uuid,l=i[c];if(void 0!==l)if(delete i[c],l0)for(var c=this._interpolants,l=this._propertyBindings,h=0,u=c.length;h!==u;++h)c[h].evaluate(o),l[h].accumulate(i,s)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var n=this._weightInterpolant;if(null!==n){var i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var n=this._timeScaleInterpolant;null!==n&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t},_updateTime:function(e){var t=this.time+e,n=this._clip.duration,i=this.loop,r=this._loopCount,a=2202===i;if(0===e)return-1===r?t:a&&1==(1&r)?n-t:t;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(t>=n)t=n;else{if(!(t<0))break e;t=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),t>=n||t<0){var o=Math.floor(t/n);t-=n*o,r+=Math.abs(o);var s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=e>0?n:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===s){var c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}if(a&&1==(1&r))return this.time=t,n-t}return this.time=t,t},_setEndings:function(e,t,n){var i=this._interpolantSettings;n?(i.endingStart=2401,i.endingEnd=2401):(i.endingStart=e?this.zeroSlopeAtStart?2401:qb:2402,i.endingEnd=t?this.zeroSlopeAtEnd?2401:qb:2402)},_scheduleFading:function(e,t,n){var i=this._mixer,r=i.time,a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=r,s[0]=t,o[1]=r+e,s[1]=n,this}}),Kr.prototype=Object.assign(Object.create(t.prototype),{constructor:Kr,_bindAction:function(e,t){var n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,c=this._bindingsByRootAndName,l=c[s];void 0===l&&(l={},c[s]=l);for(var h=0;h!==r;++h){var u=i[h],p=u.name,d=l[p];if(void 0!==d)a[h]=d;else{if(void 0!==(d=a[h])){null===d._cacheIndex&&(++d.referenceCount,this._addInactiveBinding(d,s,p));continue}var f=t&&t._propertyBindings[h].binding.parsedPath;++(d=new Xr(Yr.create(n,p,f),u.ValueTypeName,u.getValueSize())).referenceCount,this._addInactiveBinding(d,s,p),a[h]=d}o[h].resultBuffer=d.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}for(var r=e._propertyBindings,a=0,o=r.length;a!==o;++a){var s=r[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,n=0,i=t.length;n!==i;++n){var r=t[n];0==--r.useCount&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){var t=e._cacheIndex;return null!==t&&tthis.max.x||e.ythis.max.y)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y},getParameter:function(e,t){return void 0===t&&(console.warn("THREE.Box2: .getParameter() target is now required"),t=new n),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)},clampPoint:function(e,t){return void 0===t&&(console.warn("THREE.Box2: .clampPoint() target is now required"),t=new n),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new n;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),Object.assign(ca.prototype,{set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},getCenter:function(e){return void 0===e&&(console.warn("THREE.Line3: .getCenter() target is now required"),e=new a),e.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return void 0===e&&(console.warn("THREE.Line3: .delta() target is now required"),e=new a),e.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){return void 0===t&&(console.warn("THREE.Line3: .at() target is now required"),t=new a),this.delta(t).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(){var e=new a,t=new a;return function(n,i){e.subVectors(n,this.start),t.subVectors(this.end,this.start);var r=t.dot(t),a=t.dot(e)/r;return i&&(a=c_.clamp(a,0,1)),a}}(),closestPointToPoint:function(e,t,n){var i=this.closestPointToPointParameter(e,t);return void 0===n&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),n=new a),this.delta(n).multiplyScalar(i).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}}),la.prototype=Object.create(_.prototype),la.prototype.constructor=la,la.prototype.isImmediateRenderObject=!0,ha.prototype=Object.create(Gt.prototype),ha.prototype.constructor=ha,ha.prototype.update=function(){var e=new a,t=new a,n=new o;return function(){var i=["a","b","c"];this.object.updateMatrixWorld(!0),n.getNormalMatrix(this.object.matrixWorld);var r=this.object.matrixWorld,a=this.geometry.attributes.position,o=this.object.geometry;if(o&&o.isGeometry)for(var s=o.vertices,c=o.faces,l=0,h=0,u=c.length;h.99999?this.quaternion.set(0,0,0,1):n.y<-.99999?this.quaternion.set(1,0,0,0):(t.set(n.z,0,-n.x).normalize(),e=Math.acos(n.y),this.quaternion.setFromAxisAngle(t,e))}}(),Ta.prototype.setLength=function(e,t,n){void 0===t&&(t=.2*e),void 0===n&&(n=.2*t),this.line.scale.set(1,Math.max(0,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()},Ta.prototype.setColor=function(e){this.line.material.color.copy(e),this.cone.material.color.copy(e)},Ta.prototype.copy=function(e){return _.prototype.copy.call(this,e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this},Ta.prototype.clone=function(){return(new this.constructor).copy(this)},Sa.prototype=Object.create(Gt.prototype),Sa.prototype.constructor=Sa;Wi.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(Wi.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Object.assign(dr.prototype,{createPointsGeometry:function(e){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var t=this.getPoints(e);return this.createGeometry(t)},createSpacedPointsGeometry:function(e){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var t=this.getSpacedPoints(e);return this.createGeometry(t)},createGeometry:function(e){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var t=new M,n=0,i=e.length;n1?(r=i.x,a=i.y):(r=t.x+h*c,a=t.y+h*l),new n(r,a)}},{key:"distance",value:function(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}},{key:"angle",value:function(e,t){var n=e.x*t.x+e.y*t.y,i=e.x*t.y-e.y*t.x;return-Math.atan2(i,n)}},{key:"angle2pi",value:function(t,n){var i=e.angle(t,n);return i<0&&(i+=2*Math.PI),i}},{key:"isClockwise",value:function(t){for(var n=Math.min(0,Math.min.apply(null,e.map(t,function(e){return e.x}))),i=Math.min(0,Math.min.apply(null,e.map(t,function(e){return e.x}))),r=e.map(t,function(e){return{x:e.x-n,y:e.y-i}}),a=0,o=0;o=0}},{key:"guide",value:function(){var e=function(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)};return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()}},{key:"polygonPolygonIntersect",value:function(t,n){for(var i=0;i(o-r)*(s-i)}var a=e,o=t,s=n,c=i;return r(a,s,c)!=r(o,s,c)&&r(a,o,s)!=r(a,o,c)}},{key:"pointInPolygon2",value:function(e,t){for(var n=e.x,i=e.y,r=!1,a=0,o=t.length-1;a=0;n--)e[n]===t&&e.splice(n,1)}},{key:"hasValue",value:function(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:1;switch(gM.getStringValue("dimUnit")){case"feetAndInch":return e*Math.pow(.03280841666667,t);case"inch":return Math.round(e*Math.pow(.3937,t)*1e3)/1e3;case"mm":return Math.round(e*Math.pow(10,t)*1e3)/1e3;case yM:return Math.round(1e3*e)/1e3;case"m":default:return Math.round(e*Math.pow(.01,t)*1e3)/1e3}}},{key:"cmToMeasure",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;switch(gM.getStringValue("dimUnit")){case"feetAndInch":var n=e*Math.pow(.03280841666667,t),i=Math.floor(n),r=n-i;return i+"'"+Math.round(12*r)+'"';case"inch":return Math.round(e*Math.pow(.3937,t)*1e3)/1e3+"'";case"mm":return Math.round(e*Math.pow(10,t)*1e3)/1e3+"mm";case yM:return Math.round(1e3*e)/1e3+"cm";case"m":default:return Math.round(e*Math.pow(.01,t)*1e3)/1e3+"m"}}}]),e}(),MM=function(e){function t(e,n,r){Nx(this,t);var a=Fx(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return a.min=null,a.max=null,a.center=null,a.room=e,a.wall=n,a.next=null,a.prev=null,a.offset=0,a.height=0,a.plane=null,a.interiorTransform=new i,a.invInteriorTransform=new i,a.exteriorTransform=new i,a.invExteriorTransform=new i,a.redrawCallbacks=null,a.front=r||!1,a.offset=n.thickness/2,a.height=n.height,a.front?a.wall.frontEdge=a:a.wall.backEdge=a,a}return Bx(t,e),Dx(t,[{key:"getTexture",value:function(){return this.front?this.wall.frontTexture:this.wall.backTexture}},{key:"setTexture",value:function(e,t,n){var i={url:e,stretch:t,scale:n};this.front?this.wall.frontTexture=i:this.wall.backTexture=i,this.dispatchEvent({type:"REDRAW_EVENT",item:this})}},{key:"dispatchRedrawEvent",value:function(){this.dispatchEvent({type:"REDRAW_EVENT",item:this})}},{key:"transformCorner",value:function(e){return new a(e.x,0,e.y)}},{key:"generatePlane",value:function(){var e=new M,t=this.transformCorner(this.interiorStart()),n=this.transformCorner(this.interiorEnd()),i=n.clone(),r=t.clone();i.y=this.wall.getStart().elevation,r.y=this.wall.getEnd().elevation,e.vertices=[t,n,i,r],e.faces.push(new x(0,1,2)),e.faces.push(new x(0,2,3)),e.computeFaceNormals(),e.computeBoundingBox(),this.plane=new X(e,new W({visible:!1})),this.plane.visible=!0,this.plane.edge=this,this.computeTransforms(this.interiorTransform,this.invInteriorTransform,this.interiorStart(),this.interiorEnd()),this.computeTransforms(this.exteriorTransform,this.invExteriorTransform,this.exteriorStart(),this.exteriorEnd());var a=new p;a.setFromObject(this.plane),this.min=a.min.clone(),this.max=a.max.clone(),this.center=this.max.clone().sub(this.min).multiplyScalar(.5).add(this.min)}},{key:"computeTransforms",value:function(e,t,r,a){var o=r,s=a,c=lM.angle(new n(1,0),new n(s.x-o.x,s.y-o.y)),l=new i,h=new i;l.makeTranslation(-o.x,0,-o.y),h.makeRotationY(-c),e.multiplyMatrices(h,l),t.getInverse(e)}},{key:"distanceTo",value:function(e,t){return lM.pointDistanceFromLine(new n(e,t),this.interiorStart(),this.interiorEnd())}},{key:"getStart",value:function(){return this.front?this.wall.getStart():this.wall.getEnd()}},{key:"getEnd",value:function(){return this.front?this.wall.getEnd():this.wall.getStart()}},{key:"getOppositeEdge",value:function(){return this.front?this.wall.backEdge:this.wall.frontEdge}},{key:"interiorEnd",value:function(){var e=this.halfAngleVector(this,this.next);return new n(this.getEnd().x+e.x,this.getEnd().y+e.y)}},{key:"interiorStart",value:function(){var e=this.halfAngleVector(this.prev,this);return new n(this.getStart().x+e.x,this.getStart().y+e.y)}},{key:"interiorCenter",value:function(){return new n((this.interiorStart().x+this.interiorEnd().x)/2,(this.interiorStart().y+this.interiorEnd().y)/2)}},{key:"interiorDistance",value:function(){var e=this.interiorStart(),t=this.interiorEnd();return lM.distance(e,t)}},{key:"exteriorEnd",value:function(){var e=this.halfAngleVector(this,this.next);return new n(this.getEnd().x-e.x,this.getEnd().y-e.y)}},{key:"exteriorStart",value:function(){var e=this.halfAngleVector(this.prev,this);return new n(this.getStart().x-e.x,this.getStart().y-e.y)}},{key:"exteriorCenter",value:function(){return new n((this.exteriorStart().x+this.exteriorEnd().x)/2,(this.exteriorStart().y+this.exteriorEnd().y)/2)}},{key:"exteriorDistance",value:function(){var e=this.exteriorStart(),t=this.exteriorEnd();return lM.distance(e,t)}},{key:"corners",value:function(){return[this.interiorStart(),this.interiorEnd(),this.exteriorEnd(),this.exteriorStart()]}},{key:"halfAngleVector",value:function(e,t){var i=0,r=0,a=0,o=0,s=0,c=0,l=0,h=0;e?(i=e.getStart().x,r=e.getStart().y,a=e.getEnd().x,o=e.getEnd().y):(i=t.getStart().x-(t.getEnd().x-t.getStart().x),r=t.getStart().y-(t.getEnd().y-t.getStart().y),a=t.getStart().x,o=t.getStart().y),t?(s=t.getStart().x,c=t.getStart().y,l=t.getEnd().x,h=t.getEnd().y):(s=e.getEnd().x,c=e.getEnd().y,l=e.getEnd().x+(e.getEnd().x-e.getStart().x),h=e.getEnd().y+(e.getEnd().y-e.getStart().y));var u=lM.angle2pi(new n(i-a,r-o),new n(l-a,h-o)),p=Math.cos(u/2),d=Math.sin(u/2),f=l-s,m=h-c,v=f*p-m*d,g=f*d+m*p,y=lM.distance(new n(0,0),new n(v,g)),x=this.offset/d/y,w={x:v*x,y:g*x};return w}}]),t}(t),EM=function(e){function t(e,n,i,r){Nx(this,t);var a=Fx(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return a.wallStarts=[],a.wallEnds=[],a.moved_callbacks=null,a.deleted_callbacks=null,a.action_callbacks=null,a.floorplan=e,a.x=n,a.y=i,a._elevation=gM.getNumericValue(fM),a.id=r||lM.guide(),a.attachedRooms=[],a}return Bx(t,e),Dx(t,[{key:"attachRoom",value:function(e){e&&this.attachedRooms.push(e)}},{key:"getAttachedRooms",value:function(){return this.attachedRooms}},{key:"clearAttachedRooms",value:function(){this.attachedRooms=[]}},{key:"fireOnMove",value:function(e){this.moved_callbacks.add(e)}},{key:"fireOnDelete",value:function(e){this.deleted_callbacks.add(e)}},{key:"fireOnAction",value:function(e){this.action_callbacks.add(e)}},{key:"fireAction",value:function(e){this.dispatchEvent({type:"ACTION_EVENT",item:this,action:e})}},{key:"getX",value:function(){return this.x}},{key:"getY",value:function(){return this.y}},{key:"snapToAxis",value:function(e){var t={x:!1,y:!1},n=this;return this.adjacentCorners().forEach(function(i){Math.abs(i.x-n.x)=0;t--)e.wallStarts[t].setStart(this);for(t=e.wallEnds.length-1;t>=0;t--)e.wallEnds[t].setEnd(this);e.removeAll(),this.removeDuplicateWalls(),this.floorplan.update()}},{key:"mergeWithIntersected",value:function(){var e=0;for(e=0;e=0;e--)this.wallStarts[e].getEnd()===this?this.wallStarts[e].remove():this.wallStarts[e].getEnd().id in t?this.wallStarts[e].remove():t[this.wallStarts[e].getEnd().id]=!0;for(e=this.wallEnds.length-1;e>=0;e--)this.wallEnds[e].getStart()===this?this.wallEnds[e].remove():this.wallEnds[e].getStart().id in n?this.wallEnds[e].remove():n[this.wallEnds[e].getStart().id]=!0}},{key:"elevation",set:function(e){this._elevation=_M.cmFromMeasureRaw(Number(e))},get:function(){return this._elevation}}]),t}(t),TM={url:"rooms/textures/wallmap.png",stretch:!0,scale:0},SM=function(e){function t(e,n){Nx(this,t);var i=Fx(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return i.start=e,i.end=n,i.name="wall",i.id=i.getUuid(),i.start.attachStart(i),i.end.attachEnd(i),i.frontEdge=null,i.backEdge=null,i.orphan=!1,i.items=[],i.onItems=[],i.frontTexture=TM,i.backTexture=TM,i.thickness=gM.getNumericValue(mM),i.height=gM.getNumericValue(fM),i.moved_callbacks=null,i.deleted_callbacks=null,i.action_callbacks=null,i}return Bx(t,e),Dx(t,[{key:"getUuid",value:function(){return[this.start.id,this.end.id].join()}},{key:"resetFrontBack",value:function(){this.frontEdge=null,this.backEdge=null,this.orphan=!1}},{key:"snapToAxis",value:function(e){this.start.snapToAxis(e),this.end.snapToAxis(e)}},{key:"fireOnMove",value:function(e){this.moved_callbacks.add(e)}},{key:"fireOnDelete",value:function(e){this.deleted_callbacks.add(e)}},{key:"dontFireOnDelete",value:function(e){this.deleted_callbacks.remove(e)}},{key:"fireOnAction",value:function(e){this.action_callbacks.add(e)}},{key:"fireAction",value:function(e){this.dispatchEvent({type:"ACTION_EVENT",action:e})}},{key:"relativeMove",value:function(e,t){this.start.relativeMove(e,t),this.end.relativeMove(e,t)}},{key:"fireMoved",value:function(){this.dispatchEvent({type:"MOVED_EVENT",position:null})}},{key:"fireRedraw",value:function(){this.frontEdge&&this.frontEdge.dispatchRedrawEvent(),this.backEdge&&this.backEdge.dispatchRedrawEvent()}},{key:"getStart",value:function(){return this.start}},{key:"getEnd",value:function(){return this.end}},{key:"getStartX",value:function(){return this.start.getX()}},{key:"getEndX",value:function(){return this.end.getX()}},{key:"getStartY",value:function(){return this.start.getY()}},{key:"getEndY",value:function(){return this.end.getY()}},{key:"wallLength",value:function(){var e=this.getStart(),t=this.getEnd();return lM.distance(e,t)}},{key:"wallCenter",value:function(){return new n((this.getStart().x+this.getEnd().x)/2,(this.getStart().y+this.getEnd().y)/2)}},{key:"remove",value:function(){this.start.detachWall(this),this.end.detachWall(this),this.dispatchEvent({type:"DELETED_EVENT",item:this})}},{key:"setStart",value:function(e){this.start.detachWall(this),e.attachStart(this),this.start=e,this.fireMoved()}},{key:"setEnd",value:function(e){this.end.detachWall(this),e.attachEnd(this),this.end=e,this.fireMoved()}},{key:"distanceFrom",value:function(e){return lM.pointDistanceFromLine(e,new n(this.getStartX(),this.getStartY()),new n(this.getEndX(),this.getEndY()))}},{key:"oppositeCorner",value:function(e){return this.start===e?this.end:this.end===e?this.start:(console.log("Wall does not connect to corner"),null)}},{key:"getClosestCorner",value:function(e){var t=new n(this.start.x,this.start.y),i=new n(this.end.x,this.end.y);return e.distanceTo(t)<10?this.start:e.distanceTo(i)<10?this.end:null}},{key:"updateAttachedRooms",value:function(){null!=this.start&&this.start.updateAttachedRooms(),this.end&&this.end.updateAttachedRooms()}}]),t}(t),AM={url:"rooms/textures/hardwood.png",scale:400},LM=function(e){function t(e,n){Nx(this,t);var i=Fx(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));i._name="A New Room",i.min=null,i.max=null,i.center=null,i.area=0,i.areaCenter=null,i.floorplan=e,i.corners=n,i.interiorCorners=[],i.edgePointer=null,i.floorPlane=null,i.roofPlane=null,i.customTexture=!1,i.floorChangeCallbacks=null,i.updateWalls(),i.updateInteriorCorners(),i.generatePlane(),i.generateRoofPlane();var r=[];return i.corners.forEach(function(e){e.attachRoom(i),r.push(e.id)}),i._roomByCornersId=r.join(","),i}return Bx(t,e),Dx(t,[{key:"roomIdentifier",value:function(){var e=[];return this.corners.forEach(function(t){e.push(t.id)}),e.join(",")}},{key:"getUuid",value:function(){var e=lM.map(this.corners,function(e){return e.id});return e.sort(),e.join()}},{key:"fireOnFloorChange",value:function(e){this.floorChangeCallbacks.add(e)}},{key:"getTexture",value:function(){var e=this.getUuid();return this.floorplan.getFloorTexture(e)||AM}},{key:"setRoomWallsTexture",value:function(e,t,n){var i=this.edgePointer;for(i.setTexture(e,t,n);;){if(i.next===this.edgePointer)break;(i=i.next).setTexture(e,t,n)}}},{key:"setTexture",value:function(e,t,n){var i=this.getUuid();this.floorplan.setFloorTexture(i,e,n),this.dispatchEvent({type:"CHANGED_EVENT",item:this})}},{key:"generateRoofPlane",value:function(){this.roofPlane&&null!=this.roofPlane&&null!=this.roofPlane.parent&&this.roofPlane.parent.remove(this.roofPlane);var e=new M;this.corners.forEach(function(t){var n=new a(t.x,t.elevation,t.y);e.vertices.push(n)});for(var t=2;tn&&(n=e.x),e.yr&&(r=e.y)});return t==1/0||n==-1/0||i==1/0||r==-1/0?new a:e?new a(.5*(t+n),0,.5*(i+r)):new a(n-t,0,r-i)}},{key:"assignOrphanEdges",value:function(){this.walls.forEach(function(e){if(!e.backEdge&&!e.frontEdge){e.orphan=!0;var t=new MM(null,e,!1),n=new MM(null,e,!0);t.generatePlane(),n.generatePlane()}})}},{key:"findRooms",value:function(e){function t(e,t,i){return lM.angle2pi(new n(e.x-t.x,e.y-t.y),new n(i.x-t.x,i.y-t.y))}function i(e,n){var i=[],r={corner:n,previousCorners:[e]},a={};for(a[e.id]=!0;r;){var o=r.corner;if(a[o.id]=!0,r.corner===e&&o!==n)return r.previousCorners;for(var s=[],c=r.corner.adjacentCorners(),l=0;l1){var p=r.previousCorners[r.previousCorners.length-1];s.sort(function(e,n){return t(p,o,n)-t(p,o,e)})}s.length>0&&s.forEach(function(e){i.push({corner:e,previousCorners:u})}),r=i.pop()}return[]}var r=[];e.forEach(function(e){e.adjacentCorners().forEach(function(t){r.push(i(e,t))})});var a=function(e){for(var t=[],n={},i=function(e){return e.id},r=0;r",o).replace("#include ",s).replace("#include ",c).replace("#include ",l).replace("#include ",h);delete a.roughness,delete a.metalness,delete a.roughnessMap,delete a.metalnessMap,a.specular={value:(new aM.Color).setHex(1118481)},a.glossiness={value:.5},a.specularMap={value:null},a.glossinessMap={value:null},e.vertexShader=r.vertexShader,e.fragmentShader=u,e.uniforms=a,e.defines={STANDARD:""},e.color=new aM.Color(1,1,1),e.opacity=1;var p=[];if(Array.isArray(i.diffuseFactor)){var d=i.diffuseFactor;e.color.fromArray(d),e.opacity=d[3]}if(void 0!==i.diffuseTexture&&p.push(n.assignTexture(e,"map",i.diffuseTexture)),e.emissive=new aM.Color(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new aM.Color(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){var f=i.specularGlossinessTexture;p.push(n.assignTexture(e,"glossinessMap",f)),p.push(n.assignTexture(e,"specularMap",f))}return Promise.all(p)},createMaterial:function(e){var t=new aM.ShaderMaterial({defines:e.defines,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,uniforms:e.uniforms,fog:!0,lights:!0,opacity:e.opacity,transparent:e.transparent});return t.isGLTFSpecularGlossinessMaterial=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t.refractionRatio=.98,t.extensions.derivatives=!0,t},cloneMaterial:function(e){var t=e.clone();t.isGLTFSpecularGlossinessMaterial=!0;for(var n=this.specularGlossinessParams,i=0,r=n.length;i=2&&(i[a++]=e.getY(r)),n>=3&&(i[a++]=e.getZ(r)),n>=4&&(i[a++]=e.getW(r));return new aM.BufferAttribute(i,n,e.normalized)}return e.clone()}function x(e,n,i){this.json=e||{},this.extensions=n||{},this.options=i||{},this.cache=new t,this.primitiveCache={},this.textureLoader=new aM.TextureLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.fileLoader=new aM.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer")}function w(e,t,n){var i=t.attributes,r=[];for(var a in i){var o=P[a]||a.toLowerCase();o in e.attributes||r.push(function(t,i){return n.getDependency("accessor",t).then(function(t){e.addAttribute(i,t)})}(i[a],o))}if(void 0!==t.indices&&!e.index){var s=n.getDependency("accessor",t.indices).then(function(t){e.setIndex(t)});r.push(s)}return d(e,t),Promise.all(r).then(function(){return void 0!==t.targets?f(e,t.targets,n):e})}e.prototype={constructor:e,crossOrigin:"anonymous",load:function(e,t,n,i){var r,a=this;r=void 0!==this.resourcePath?this.resourcePath:void 0!==this.path?this.path:aM.LoaderUtils.extractUrlBase(e),a.manager.itemStart(e);var o=function(t){i?i(t):console.error(t),a.manager.itemError(e),a.manager.itemEnd(e)},s=new aM.FileLoader(a.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.load(e,function(n){try{a.parse(n,r,function(n){t(n),a.manager.itemEnd(e)},o)}catch(e){o(e)}},n,o)},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this},setResourcePath:function(e){return this.resourcePath=e,this},setDRACOLoader:function(e){return this.dracoLoader=e,this},parse:function(e,t,l,h){var u,p={};if("string"==typeof e)u=e;else if(aM.LoaderUtils.decodeText(new Uint8Array(e,0,4))===_){try{p[b.KHR_BINARY_GLTF]=new a(e)}catch(e){return void(h&&h(e))}u=p[b.KHR_BINARY_GLTF].content}else u=aM.LoaderUtils.decodeText(new Uint8Array(e));var d=JSON.parse(u);if(void 0===d.asset||d.asset.version[0]<2)return void(h&&h(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported. Use LegacyGLTFLoader instead.")));if(d.extensionsUsed)for(var f=0;f=0&&console.warn('THREE.GLTFLoader: Unknown extension "'+m+'".')}}new x(d,p,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,manager:this.manager}).parse(l,h)}};var b={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",MSFT_TEXTURE_DDS:"MSFT_texture_dds"};i.prototype.loadLight=function(e){var t,n=this.lightDefs[e],i=new aM.Color(16777215);void 0!==n.color&&i.fromArray(n.color);var r=void 0!==n.range?n.range:0;switch(n.type){case"directional":(t=new aM.DirectionalLight(i)).target.position.set(0,0,-1),t.add(t.target);break;case"point":(t=new aM.PointLight(i)).distance=r;break;case"spot":(t=new aM.SpotLight(i)).distance=r,n.spot=n.spot||{},n.spot.innerConeAngle=void 0!==n.spot.innerConeAngle?n.spot.innerConeAngle:0,n.spot.outerConeAngle=void 0!==n.spot.outerConeAngle?n.spot.outerConeAngle:Math.PI/4,t.angle=n.spot.outerConeAngle,t.penumbra=1-n.spot.innerConeAngle/n.spot.outerConeAngle,t.target.position.set(0,0,-1),t.add(t.target);break;default:throw new Error('THREE.GLTFLoader: Unexpected light type, "'+n.type+'".')}return t.position.set(0,0,0),t.decay=2,void 0!==n.intensity&&(t.intensity=n.intensity),t.name=n.name||"light_"+e,Promise.resolve(t)},r.prototype.getMaterialType=function(){return aM.MeshBasicMaterial},r.prototype.extendParams=function(e,t,n){var i=[];e.color=new aM.Color(1,1,1),e.opacity=1;var r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){var a=r.baseColorFactor;e.color.fromArray(a),e.opacity=a[3]}void 0!==r.baseColorTexture&&i.push(n.assignTexture(e,"map",r.baseColorTexture))}return Promise.all(i)};var _="glTF",M=12,E={JSON:1313821514,BIN:5130562};o.prototype.decodePrimitive=function(e,t){var n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,o={},s={},c={};for(var l in a){h=P[l]||l.toLowerCase();o[h]=a[l]}for(l in e.attributes){var h=P[l]||l.toLowerCase();if(void 0!==a[l]){var u=n.accessors[e.attributes[l]],p=A[u.componentType];c[h]=p,s[h]=!0===u.normalized}}return t.getDependency("bufferView",r).then(function(e){return new Promise(function(t){i.decodeDracoFile(e,function(e){for(var n in e.attributes){var i=e.attributes[n],r=s[n];void 0!==r&&(i.normalized=r)}t(e)},o,c)})})},s.prototype.extendTexture=function(e,t){return e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),e.needsUpdate=!0,e},l.prototype=Object.create(aM.Interpolant.prototype),l.prototype.constructor=l,l.prototype.copySampleValue_=function(e){for(var t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i,a=0;a!==i;a++)t[a]=n[r+a];return t},l.prototype.beforeStart_=l.prototype.copySampleValue_,l.prototype.afterEnd_=l.prototype.copySampleValue_,l.prototype.interpolate_=function(e,t,n,i){for(var r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=2*o,c=3*o,l=i-t,h=(n-t)/l,u=h*h,p=u*h,d=e*c,f=d-c,m=-2*p+3*u,v=p-u,g=1-m,y=v-u+h,x=0;x!==o;x++){var w=a[f+x+o],b=a[f+x+s]*l,_=a[d+x+o],M=a[d+x]*l;r[x]=g*w+y*b+m*_+v*M}return r};var T,S={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},A=(Number,aM.Matrix3,aM.Matrix4,aM.Vector2,aM.Vector3,aM.Vector4,aM.Texture,{5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array}),L={9728:aM.NearestFilter,9729:aM.LinearFilter,9984:aM.NearestMipMapNearestFilter,9985:aM.LinearMipMapNearestFilter,9986:aM.NearestMipMapLinearFilter,9987:aM.LinearMipMapLinearFilter},R={33071:aM.ClampToEdgeWrapping,33648:aM.MirroredRepeatWrapping,10497:aM.RepeatWrapping},C=(aM.BackSide,aM.FrontSide,aM.NeverDepth,aM.LessDepth,aM.EqualDepth,aM.LessEqualDepth,aM.GreaterEqualDepth,aM.NotEqualDepth,aM.GreaterEqualDepth,aM.AlwaysDepth,aM.AddEquation,aM.SubtractEquation,aM.ReverseSubtractEquation,aM.ZeroFactor,aM.OneFactor,aM.SrcColorFactor,aM.OneMinusSrcColorFactor,aM.SrcAlphaFactor,aM.OneMinusSrcAlphaFactor,aM.DstAlphaFactor,aM.OneMinusDstAlphaFactor,aM.DstColorFactor,aM.OneMinusDstColorFactor,aM.SrcAlphaSaturateFactor,{SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16}),P={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},O={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},I={CUBICSPLINE:void 0,LINEAR:aM.InterpolateLinear,STEP:aM.InterpolateDiscrete},N={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"},D={"image/png":aM.RGBAFormat,"image/jpeg":aM.RGBFormat};return x.prototype.parse=function(e,t){var n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.markDefs(),Promise.all([this.getDependencies("scene"),this.getDependencies("animation"),this.getDependencies("camera")]).then(function(t){var a={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};p(r,a,i),e(a)}).catch(t)},x.prototype.markDefs=function(){for(var e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[],i={},r={},a=0,o=t.length;a=2&&a.setY(E,b[_*s+1]),s>=3&&a.setZ(E,b[_*s+2]),s>=4&&a.setW(E,b[_*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return a})},x.prototype.loadTexture=function(e){var t,n=this,i=this.json,r=this.options,a=this.textureLoader,o=window.URL||window.webkitURL,s=i.textures[e],c=s.extensions||{},l=(t=c[b.MSFT_TEXTURE_DDS]?i.images[c[b.MSFT_TEXTURE_DDS].source]:i.images[s.source]).uri,u=!1;return void 0!==t.bufferView&&(l=n.getDependency("bufferView",t.bufferView).then(function(e){u=!0;var n=new Blob([e],{type:t.mimeType});return l=o.createObjectURL(n)})),Promise.resolve(l).then(function(e){var t=aM.Loader.Handlers.get(e);return t||(t=c[b.MSFT_TEXTURE_DDS]?n.extensions[b.MSFT_TEXTURE_DDS].ddsLoader:a),new Promise(function(n,i){t.load(h(e,r.path),n,void 0,i)})}).then(function(e){!0===u&&o.revokeObjectURL(l),e.flipY=!1,void 0!==s.name&&(e.name=s.name),t.mimeType in D&&(e.format=D[t.mimeType]);var n=(i.samplers||{})[s.sampler]||{};return e.magFilter=L[n.magFilter]||aM.LinearFilter,e.minFilter=L[n.minFilter]||aM.LinearMipMapLinearFilter,e.wrapS=R[n.wrapS]||aM.RepeatWrapping,e.wrapT=R[n.wrapT]||aM.RepeatWrapping,e})},x.prototype.assignTexture=function(e,t,n){var i=this;return this.getDependency("texture",n.index).then(function(r){if(!r.isCompressedTexture)switch(t){case"aoMap":case"emissiveMap":case"metalnessMap":case"normalMap":case"roughnessMap":r.format=aM.RGBFormat}if(i.extensions[b.KHR_TEXTURE_TRANSFORM]){var a=void 0!==n.extensions?n.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;a&&(r=i.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(r,a))}e[t]=r})},x.prototype.assignFinalMaterial=function(e){var t=e.geometry,n=e.material,i=this.extensions,r=void 0!==t.attributes.tangent,a=void 0!==t.attributes.color,o=void 0===t.attributes.normal,s=!0===e.isSkinnedMesh,c=Object.keys(t.morphAttributes).length>0,l=c&&void 0!==t.morphAttributes.normal;if(e.isPoints){var h="PointsMaterial:"+n.uuid,u=this.cache.get(h);u||(u=new aM.PointsMaterial,aM.Material.prototype.copy.call(u,n),u.color.copy(n.color),u.map=n.map,u.lights=!1,this.cache.add(h,u)),n=u}else if(e.isLine){var h="LineBasicMaterial:"+n.uuid,p=this.cache.get(h);p||(p=new aM.LineBasicMaterial,aM.Material.prototype.copy.call(p,n),p.color.copy(n.color),p.lights=!1,this.cache.add(h,p)),n=p}if(r||a||o||s||c){h="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(h+="specular-glossiness:"),s&&(h+="skinning:"),r&&(h+="vertex-tangents:"),a&&(h+="vertex-colors:"),o&&(h+="flat-shading:"),c&&(h+="morph-targets:"),l&&(h+="morph-normals:");var d=this.cache.get(h);d||(d=n.isGLTFSpecularGlossinessMaterial?i[b.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].cloneMaterial(n):n.clone(),s&&(d.skinning=!0),r&&(d.vertexTangents=!0),a&&(d.vertexColors=aM.VertexColors),o&&(d.flatShading=!0),c&&(d.morphTargets=!0),l&&(d.morphNormals=!0),this.cache.add(h,d)),n=d}n.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&(console.log("THREE.GLTFLoader: Duplicating UVs to support aoMap."),t.addAttribute("uv2",new aM.BufferAttribute(t.attributes.uv.array,2))),n.isGLTFSpecularGlossinessMaterial&&(e.onBeforeRender=i[b.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].refreshUniforms),e.material=n},x.prototype.loadMaterial=function(e){var t,n=this,i=this.json,r=this.extensions,a=i.materials[e],o={},s=a.extensions||{},c=[];if(s[b.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){var l=r[b.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];t=l.getMaterialType(),c.push(l.extendParams(o,a,n))}else if(s[b.KHR_MATERIALS_UNLIT]){var h=r[b.KHR_MATERIALS_UNLIT];t=h.getMaterialType(),c.push(h.extendParams(o,a,n))}else{t=aM.MeshStandardMaterial;var u=a.pbrMetallicRoughness||{};if(o.color=new aM.Color(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){var f=u.baseColorFactor;o.color.fromArray(f),o.opacity=f[3]}void 0!==u.baseColorTexture&&c.push(n.assignTexture(o,"map",u.baseColorTexture)),o.metalness=void 0!==u.metallicFactor?u.metallicFactor:1,o.roughness=void 0!==u.roughnessFactor?u.roughnessFactor:1,void 0!==u.metallicRoughnessTexture&&(c.push(n.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(n.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture)))}!0===a.doubleSided&&(o.side=aM.DoubleSide);var m=a.alphaMode||N.OPAQUE;return m===N.BLEND?o.transparent=!0:(o.transparent=!1,m===N.MASK&&(o.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&t!==aM.MeshBasicMaterial&&(c.push(n.assignTexture(o,"normalMap",a.normalTexture)),o.normalScale=new aM.Vector2(1,1),void 0!==a.normalTexture.scale&&o.normalScale.set(a.normalTexture.scale,a.normalTexture.scale)),void 0!==a.occlusionTexture&&t!==aM.MeshBasicMaterial&&(c.push(n.assignTexture(o,"aoMap",a.occlusionTexture)),void 0!==a.occlusionTexture.strength&&(o.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&t!==aM.MeshBasicMaterial&&(o.emissive=(new aM.Color).fromArray(a.emissiveFactor)),void 0!==a.emissiveTexture&&t!==aM.MeshBasicMaterial&&c.push(n.assignTexture(o,"emissiveMap",a.emissiveTexture)),Promise.all(c).then(function(){var e;return e=t===aM.ShaderMaterial?r[b.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):new t(o),void 0!==a.name&&(e.name=a.name),e.map&&(e.map.encoding=aM.sRGBEncoding),e.emissiveMap&&(e.emissiveMap.encoding=aM.sRGBEncoding),e.specularMap&&(e.specularMap.encoding=aM.sRGBEncoding),d(e,a),a.extensions&&p(r,e,a),e})},x.prototype.loadGeometries=function(e){for(var t=this,n=this.extensions,i=this.primitiveCache,r=[],a=0,o=e.length;a0&&m(l,i),l.name=i.name||"mesh_"+e,a.length>1&&(l.name+="_"+s),d(l,i),t.assignFinalMaterial(l),o.push(l)}if(1===o.length)return o[0];for(var f=new aM.Group,s=0,c=o.length;s1){var n=a[o.mesh]++;(t=e.clone()).name+="_instance_"+n,t.onBeforeRender=e.onBeforeRender;for(var i=0,s=t.children.length;i0?1:+e}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&function(){Object.assign=function(e){if(void 0===e||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=1;n>8&255]+e[t>>16&255]+e[t>>24&255]+"-"+e[255&n]+e[n>>8&255]+"-"+e[n>>16&15|64]+e[n>>24&255]+"-"+e[63&i|128]+e[i>>8&255]+"-"+e[i>>16&255]+e[i>>24&255]+e[255&r]+e[r>>8&255]+e[r>>16&255]+e[r>>24&255]).toUpperCase()}}(),clamp:function(e,t,n){return Math.max(t,Math.min(n,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},lerp:function(e,t,n){return(1-n)*e+n*t},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*JT.DEG2RAD},radToDeg:function(e){return e*JT.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}};Object.defineProperties(fo.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(fo.prototype,{isVector2:!0,set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},applyMatrix3:function(e){var t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:function(){var e=new fo,t=new fo;return function(n,i){return e.set(n,n),t.set(i,i),this.clamp(e,t)}}(),clampLength:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var e=Math.atan2(this.y,this.x);return e<0&&(e+=2*Math.PI),e},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,n=this.y-e.y;return t*t+n*n},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromBufferAttribute:function(e,t,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){var n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}}),Object.assign(mo.prototype,{isMatrix4:!0,set:function(e,t,n,i,r,a,o,s,c,l,h,u,p,d,f,m){var v=this.elements;return v[0]=e,v[4]=t,v[8]=n,v[12]=i,v[1]=r,v[5]=a,v[9]=o,v[13]=s,v[2]=c,v[6]=l,v[10]=h,v[14]=u,v[3]=p,v[7]=d,v[11]=f,v[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new mo).fromArray(this.elements)},copy:function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this},copyPosition:function(e){var t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this},extractBasis:function(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this},extractRotation:function(){var e=new go;return function(t){var n=this.elements,i=t.elements,r=1/e.setFromMatrixColumn(t,0).length(),a=1/e.setFromMatrixColumn(t,1).length(),o=1/e.setFromMatrixColumn(t,2).length();return n[0]=i[0]*r,n[1]=i[1]*r,n[2]=i[2]*r,n[3]=0,n[4]=i[4]*a,n[5]=i[5]*a,n[6]=i[6]*a,n[7]=0,n[8]=i[8]*o,n[9]=i[9]*o,n[10]=i[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}}(),makeRotationFromEuler:function(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(i),c=Math.sin(i),l=Math.cos(r),h=Math.sin(r);if("XYZ"===e.order){var u=a*l,p=a*h,d=o*l,f=o*h;t[0]=s*l,t[4]=-s*h,t[8]=c,t[1]=p+d*c,t[5]=u-f*c,t[9]=-o*s,t[2]=f-u*c,t[6]=d+p*c,t[10]=a*s}else if("YXZ"===e.order){var m=s*l,v=s*h,g=c*l,y=c*h;t[0]=m+y*o,t[4]=g*o-v,t[8]=a*c,t[1]=a*h,t[5]=a*l,t[9]=-o,t[2]=v*o-g,t[6]=y+m*o,t[10]=a*s}else if("ZXY"===e.order){var m=s*l,v=s*h,g=c*l,y=c*h;t[0]=m-y*o,t[4]=-a*h,t[8]=g+v*o,t[1]=v+g*o,t[5]=a*l,t[9]=y-m*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if("ZYX"===e.order){var u=a*l,p=a*h,d=o*l,f=o*h;t[0]=s*l,t[4]=d*c-p,t[8]=u*c+f,t[1]=s*h,t[5]=f*c+u,t[9]=p*c-d,t[2]=-c,t[6]=o*s,t[10]=a*s}else if("YZX"===e.order){var x=a*s,w=a*c,b=o*s,_=o*c;t[0]=s*l,t[4]=_-x*h,t[8]=b*h+w,t[1]=h,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=w*h+b,t[10]=x-_*h}else if("XZY"===e.order){var x=a*s,w=a*c,b=o*s,_=o*c;t[0]=s*l,t[4]=-h,t[8]=c*l,t[1]=x*h+_,t[5]=a*l,t[9]=w*h-b,t[2]=b*h-w,t[6]=o*l,t[10]=_*h+x}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(){var e=new go(0,0,0),t=new go(1,1,1);return function(n){return this.compose(e,n,t)}}(),lookAt:function(){var e=new go,t=new go,n=new go;return function(i,r,a){var o=this.elements;return n.subVectors(i,r),0===n.lengthSq()&&(n.z=1),n.normalize(),e.crossVectors(a,n),0===e.lengthSq()&&(1===Math.abs(a.z)?n.x+=1e-4:n.z+=1e-4,n.normalize(),e.crossVectors(a,n)),e.normalize(),t.crossVectors(n,e),o[0]=e.x,o[4]=t.x,o[8]=n.x,o[1]=e.y,o[5]=t.y,o[9]=n.y,o[2]=e.z,o[6]=t.z,o[10]=n.z,this}}(),multiply:function(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var n=e.elements,i=t.elements,r=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],h=n[5],u=n[9],p=n[13],d=n[2],f=n[6],m=n[10],v=n[14],g=n[3],y=n[7],x=n[11],w=n[15],b=i[0],_=i[4],M=i[8],E=i[12],T=i[1],S=i[5],A=i[9],L=i[13],R=i[2],C=i[6],P=i[10],O=i[14],I=i[3],N=i[7],D=i[11],U=i[15];return r[0]=a*b+o*T+s*R+c*I,r[4]=a*_+o*S+s*C+c*N,r[8]=a*M+o*A+s*P+c*D,r[12]=a*E+o*L+s*O+c*U,r[1]=l*b+h*T+u*R+p*I,r[5]=l*_+h*S+u*C+p*N,r[9]=l*M+h*A+u*P+p*D,r[13]=l*E+h*L+u*O+p*U,r[2]=d*b+f*T+m*R+v*I,r[6]=d*_+f*S+m*C+v*N,r[10]=d*M+f*A+m*P+v*D,r[14]=d*E+f*L+m*O+v*U,r[3]=g*b+y*T+x*R+w*I,r[7]=g*_+y*S+x*C+w*N,r[11]=g*M+y*A+x*P+w*D,r[15]=g*E+y*L+x*O+w*U,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},applyToBufferAttribute:function(){var e=new go;return function(t){for(var n=0,i=t.count;n=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var x=Math.sqrt(y),w=Math.atan2(x,v*g);m=Math.sin(m*w)/x,o=Math.sin(o*w)/x}var b=o*g;if(s=s*m+u*b,c=c*m+p*b,l=l*m+d*b,h=h*m+f*b,m===1-o){var _=1/Math.sqrt(s*s+c*c+l*l+h*h);s*=_,c*=_,l*=_,h*=_}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=h}}),Object.defineProperties(vo.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this.onChangeCallback()}}}),Object.assign(vo.prototype,{set:function(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this.onChangeCallback(),this},setFromEuler:function(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=e._x,i=e._y,r=e._z,a=e.order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(i/2),h=o(r/2),u=s(n/2),p=s(i/2),d=s(r/2);return"XYZ"===a?(this._x=u*l*h+c*p*d,this._y=c*p*h-u*l*d,this._z=c*l*d+u*p*h,this._w=c*l*h-u*p*d):"YXZ"===a?(this._x=u*l*h+c*p*d,this._y=c*p*h-u*l*d,this._z=c*l*d-u*p*h,this._w=c*l*h+u*p*d):"ZXY"===a?(this._x=u*l*h-c*p*d,this._y=c*p*h+u*l*d,this._z=c*l*d+u*p*h,this._w=c*l*h-u*p*d):"ZYX"===a?(this._x=u*l*h-c*p*d,this._y=c*p*h+u*l*d,this._z=c*l*d-u*p*h,this._w=c*l*h+u*p*d):"YZX"===a?(this._x=u*l*h+c*p*d,this._y=c*p*h+u*l*d,this._z=c*l*d-u*p*h,this._w=c*l*h-u*p*d):"XZY"===a&&(this._x=u*l*h-c*p*d,this._y=c*p*h-u*l*d,this._z=c*l*d+u*p*h,this._w=c*l*h+u*p*d),!1!==t&&this.onChangeCallback(),this},setFromAxisAngle:function(e,t){var n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this.onChangeCallback(),this},setFromRotationMatrix:function(e){var t,n=e.elements,i=n[0],r=n[4],a=n[8],o=n[1],s=n[5],c=n[9],l=n[2],h=n[6],u=n[10],p=i+s+u;return p>0?(t=.5/Math.sqrt(p+1),this._w=.25/t,this._x=(h-c)*t,this._y=(a-l)*t,this._z=(o-r)*t):i>s&&i>u?(t=2*Math.sqrt(1+i-s-u),this._w=(h-c)/t,this._x=.25*t,this._y=(r+o)/t,this._z=(a+l)/t):s>u?(t=2*Math.sqrt(1+s-i-u),this._w=(a-l)/t,this._x=(r+o)/t,this._y=.25*t,this._z=(c+h)/t):(t=2*Math.sqrt(1+u-i-s),this._w=(o-r)/t,this._x=(a+l)/t,this._y=(c+h)/t,this._z=.25*t),this.onChangeCallback(),this},setFromUnitVectors:function(){var e,t=new go;return function(n,i){return void 0===t&&(t=new go),e=n.dot(i)+1,e<1e-6?(e=0,Math.abs(n.x)>Math.abs(n.z)?t.set(-n.y,n.x,0):t.set(0,-n.z,n.y)):t.crossVectors(n,i),this._x=t.x,this._y=t.y,this._z=t.z,this._w=e,this.normalize()}}(),inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this.onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var n=e._x,i=e._y,r=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+i*c-r*s,this._y=i*l+a*s+r*o-n*c,this._z=r*l+a*c+n*s-i*o,this._w=a*l-n*o-i*s-r*c,this.onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var n=this._x,i=this._y,r=this._z,a=this._w,o=a*e._w+n*e._x+i*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;var s=1-o*o;if(s<=Number.EPSILON){var c=1-t;return this._w=c*a+t*this._w,this._x=c*n+t*this._x,this._y=c*i+t*this._y,this._z=c*r+t*this._z,this.normalize()}var l=Math.sqrt(s),h=Math.atan2(l,o),u=Math.sin((1-t)*h)/l,p=Math.sin(t*h)/l;return this._w=a*u+this._w*p,this._x=n*u+this._x*p,this._y=i*u+this._y*p,this._z=r*u+this._z*p,this.onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}}),Object.assign(go.prototype,{isVector3:!0,set:function(e,t,n){return this.x=e,this.y=t,this.z=n,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:function(){var e=new vo;return function(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(e.setFromEuler(t))}}(),applyAxisAngle:function(){var e=new vo;return function(t,n){return this.applyQuaternion(e.setFromAxisAngle(t,n))}}(),applyMatrix3:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this},applyMatrix4:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this},applyQuaternion:function(e){var t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,o=e.z,s=e.w,c=s*t+a*i-o*n,l=s*n+o*t-r*i,h=s*i+r*n-a*t,u=-r*t-a*n-o*i;return this.x=c*s+u*-r+l*-o-h*-a,this.y=l*s+u*-a+h*-r-c*-o,this.z=h*s+u*-o+c*-a-l*-r,this},project:function(){var e=new mo;return function(t){return e.multiplyMatrices(t.projectionMatrix,e.getInverse(t.matrixWorld)),this.applyMatrix4(e)}}(),unproject:function(){var e=new mo;return function(t){return e.multiplyMatrices(t.matrixWorld,e.getInverse(t.projectionMatrix)),this.applyMatrix4(e)}}(),transformDirection:function(e){var t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(){var e=new go,t=new go;return function(n,i){return e.set(n,n,n),t.set(i,i,i),this.clamp(e,t)}}(),clampLength:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},cross:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)},crossVectors:function(e,t){var n=e.x,i=e.y,r=e.z,a=t.x,o=t.y,s=t.z;return this.x=i*s-r*o,this.y=r*a-n*s,this.z=n*o-i*a,this},projectOnVector:function(e){var t=e.dot(this)/e.lengthSq();return this.copy(e).multiplyScalar(t)},projectOnPlane:function(){var e=new go;return function(t){return e.copy(this).projectOnVector(t),this.sub(e)}}(),reflect:function(){var e=new go;return function(t){return this.sub(e.copy(t).multiplyScalar(2*this.dot(t)))}}(),angleTo:function(e){var t=this.dot(e)/Math.sqrt(this.lengthSq()*e.lengthSq());return Math.acos(JT.clamp(t,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){var t=Math.sin(e.phi)*e.radius;return this.x=t*Math.sin(e.theta),this.y=Math.cos(e.phi)*e.radius,this.z=t*Math.cos(e.theta),this},setFromCylindrical:function(e){return this.x=e.radius*Math.sin(e.theta),this.y=e.y,this.z=e.radius*Math.cos(e.theta),this},setFromMatrixPosition:function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,4*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromBufferAttribute:function(e,t,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}}),Object.assign(yo.prototype,{isMatrix3:!0,set:function(e,t,n,i,r,a,o,s,c){var l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},applyToBufferAttribute:function(){var e=new go;return function(t){for(var n=0,i=t.count;n2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}var n=void 0===e||"string"==typeof e;if(!n&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];var i={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var r=this.image;if(void 0===r.uuid&&(r.uuid=JT.generateUUID()),!n&&void 0===e.images[r.uuid]){var a;if(Array.isArray(r)){a=[];for(var o=0,s=r.length;o1)switch(this.wrapS){case UE:e.x=e.x-Math.floor(e.x);break;case BE:e.x=e.x<0?0:1;break;case FE:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case UE:e.y=e.y-Math.floor(e.y);break;case BE:e.y=e.y<0?0:1;break;case FE:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}this.flipY&&(e.y=1-e.y)}}}),Object.defineProperty(xo.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(wo.prototype,{isVector4:!0,set:function(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,n,i,r,a=e.elements,o=a[0],s=a[4],c=a[8],l=a[1],h=a[5],u=a[9],p=a[2],d=a[6],f=a[10];if(Math.abs(s-l)<.01&&Math.abs(c-p)<.01&&Math.abs(u-d)<.01){if(Math.abs(s+l)<.1&&Math.abs(c+p)<.1&&Math.abs(u+d)<.1&&Math.abs(o+h+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;var m=(o+1)/2,v=(h+1)/2,g=(f+1)/2,y=(s+l)/4,x=(c+p)/4,w=(u+d)/4;return m>v&&m>g?m<.01?(n=0,i=.707106781,r=.707106781):(i=y/(n=Math.sqrt(m)),r=x/n):v>g?v<.01?(n=.707106781,i=0,r=.707106781):(n=y/(i=Math.sqrt(v)),r=w/i):g<.01?(n=.707106781,i=.707106781,r=0):(n=x/(r=Math.sqrt(g)),i=w/r),this.set(n,i,r,t),this}var b=Math.sqrt((d-u)*(d-u)+(c-p)*(c-p)+(l-s)*(l-s));return Math.abs(b)<.001&&(b=1),this.x=(d-u)/b,this.y=(c-p)/b,this.z=(l-s)/b,this.w=Math.acos((o+h+f-1)/2),this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this},clampScalar:function(){var e,t;return function(n,i){return void 0===e&&(e=new wo,t=new wo),e.set(n,n,n,n),t.set(i,i,i,i),this.clamp(e,t)}}(),clampLength:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this},lerpVectors:function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e},fromBufferAttribute:function(e,t,n){return void 0!==n&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}}),bo.prototype=Object.assign(Object.create(po.prototype),{constructor:bo,isWebGLRenderTarget:!0,setSize:function(e,t){this.width===e&&this.height===t||(this.width=e,this.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),_o.prototype=Object.create(bo.prototype),_o.prototype.constructor=_o,_o.prototype.isWebGLRenderTargetCube=!0,Mo.prototype=Object.create(xo.prototype),Mo.prototype.constructor=Mo,Mo.prototype.isDataTexture=!0,Object.assign(Eo.prototype,{isBox3:!0,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){for(var t=1/0,n=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0,s=0,c=e.length;sr&&(r=l),h>a&&(a=h),u>o&&(o=u)}return this.min.set(t,n,i),this.max.set(r,a,o),this},setFromBufferAttribute:function(e){for(var t=1/0,n=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0,s=0,c=e.count;sr&&(r=l),h>a&&(a=h),u>o&&(o=u)}return this.min.set(t,n,i),this.max.set(r,a,o),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},getParameter:function(e,t){return void 0===t&&(console.warn("THREE.Box3: .getParameter() target is now required"),t=new go),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},intersectsSphere:function(){var e=new go;return function(t){return this.clampPoint(t.center,e),e.distanceToSquared(t.center)<=t.radius*t.radius}}(),intersectsPlane:function(e){var t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=e.constant&&n>=e.constant},intersectsTriangle:function(){function e(e){var r,a;for(r=0,a=e.length-3;r<=a;r+=3){s.fromArray(e,r);var o=l.x*Math.abs(s.x)+l.y*Math.abs(s.y)+l.z*Math.abs(s.z),c=t.dot(s),h=n.dot(s),u=i.dot(s);if(Math.max(-Math.max(c,h,u),Math.min(c,h,u))>o)return!1}return!0}var t=new go,n=new go,i=new go,r=new go,a=new go,o=new go,s=new go,c=new go,l=new go,h=new go;return function(s){if(this.isEmpty())return!1;this.getCenter(c),l.subVectors(this.max,c),t.subVectors(s.a,c),n.subVectors(s.b,c),i.subVectors(s.c,c),r.subVectors(n,t),a.subVectors(i,n),o.subVectors(t,i);var u=[0,-r.z,r.y,0,-a.z,a.y,0,-o.z,o.y,r.z,0,-r.x,a.z,0,-a.x,o.z,0,-o.x,-r.y,r.x,0,-a.y,a.x,0,-o.y,o.x,0];return!!e(u)&&(u=[1,0,0,0,1,0,0,0,1],!!e(u)&&(h.crossVectors(r,a),u=[h.x,h.y,h.z],e(u)))}}(),clampPoint:function(e,t){return void 0===t&&(console.warn("THREE.Box3: .clampPoint() target is now required"),t=new go),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new go;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),getBoundingSphere:function(){var e=new go;return function(t){return void 0===t&&(console.warn("THREE.Box3: .getBoundingSphere() target is now required"),t=new To),this.getCenter(t.center),t.radius=.5*this.getSize(e).length(),t}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(e){if(this.isEmpty())return this;var t=e.elements,n=t[0]*this.min.x,i=t[1]*this.min.x,r=t[2]*this.min.x,a=t[0]*this.max.x,o=t[1]*this.max.x,s=t[2]*this.max.x,c=t[4]*this.min.y,l=t[5]*this.min.y,h=t[6]*this.min.y,u=t[4]*this.max.y,p=t[5]*this.max.y,d=t[6]*this.max.y,f=t[8]*this.min.z,m=t[9]*this.min.z,v=t[10]*this.min.z,g=t[8]*this.max.z,y=t[9]*this.max.z,x=t[10]*this.max.z;return this.min.x=Math.min(n,a)+Math.min(c,u)+Math.min(f,g)+t[12],this.min.y=Math.min(i,o)+Math.min(l,p)+Math.min(m,y)+t[13],this.min.z=Math.min(r,s)+Math.min(h,d)+Math.min(v,x)+t[14],this.max.x=Math.max(n,a)+Math.max(c,u)+Math.max(f,g)+t[12],this.max.y=Math.max(i,o)+Math.max(l,p)+Math.max(m,y)+t[13],this.max.z=Math.max(r,s)+Math.max(h,d)+Math.max(v,x)+t[14],this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),Object.assign(To.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(){var e=new Eo;return function(t,n){var i=this.center;void 0!==n?i.copy(n):e.setFromPoints(t).getCenter(i);for(var r=0,a=0,o=t.length;athis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t},getBoundingBox:function(e){return void 0===e&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),e=new Eo),e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}}),Object.assign(So.prototype,{set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(){var e=new go,t=new go;return function(n,i,r){var a=e.subVectors(r,i).cross(t.subVectors(n,i)).normalize();return this.setFromNormalAndCoplanarPoint(a,n),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return void 0===t&&(console.warn("THREE.Plane: .projectPoint() target is now required"),t=new go),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(){var e=new go;return function(t,n){void 0===n&&(console.warn("THREE.Plane: .intersectLine() target is now required"),n=new go);var i=t.delta(e),r=this.normal.dot(i);if(0!==r){var a=-(t.start.dot(this.normal)+this.constant)/r;if(!(a<0||a>1))return n.copy(i).multiplyScalar(a).add(t.start)}else if(0===this.distanceToPoint(t.start))return n.copy(t.start)}}(),intersectsLine:function(e){var t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return void 0===e&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),e=new go),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new go,t=new yo;return function(n,i){var r=i||t.getNormalMatrix(n),a=this.coplanarPoint(e).applyMatrix4(n),o=this.normal.applyMatrix3(r).normalize();return this.constant=-a.dot(o),this}}(),translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}}),Object.assign(Ao.prototype,{set:function(e,t,n,i,r,a){var o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,n=0;n<6;n++)t[n].copy(e.planes[n]);return this},setFromMatrix:function(e){var t=this.planes,n=e.elements,i=n[0],r=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],h=n[7],u=n[8],p=n[9],d=n[10],f=n[11],m=n[12],v=n[13],g=n[14],y=n[15];return t[0].setComponents(o-i,h-s,f-u,y-m).normalize(),t[1].setComponents(o+i,h+s,f+u,y+m).normalize(),t[2].setComponents(o+r,h+c,f+p,y+v).normalize(),t[3].setComponents(o-r,h-c,f-p,y-v).normalize(),t[4].setComponents(o-a,h-l,f-d,y-g).normalize(),t[5].setComponents(o+a,h+l,f+d,y+g).normalize(),this},intersectsObject:function(){var e=new To;return function(t){var n=t.geometry;return null===n.boundingSphere&&n.computeBoundingSphere(),e.copy(n.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSprite:function(){var e=new To;return function(t){return e.center.set(0,0,0),e.radius=.7071067811865476,e.applyMatrix4(t.matrixWorld),this.intersectsSphere(e)}}(),intersectsSphere:function(e){for(var t=this.planes,n=e.center,i=-e.radius,r=0;r<6;r++)if(t[r].distanceToPoint(n)0?n.min.x:n.max.x,t.x=a.normal.x>0?n.max.x:n.min.x,e.y=a.normal.y>0?n.min.y:n.max.y,t.y=a.normal.y>0?n.max.y:n.min.y,e.z=a.normal.z>0?n.min.z:n.max.z,t.z=a.normal.z>0?n.max.z:n.min.z;var o=a.distanceToPoint(e),s=a.distanceToPoint(t);if(o<0&&s<0)return!1}return!0}}(),containsPoint:function(e){for(var t=this.planes,n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}});var QT={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n",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",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"\nvec3 transformed = vec3( position );\n",beginnormal_vertex:"\nvec3 objectNormal = vec3( normal );\n",bsdfs:"float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\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",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",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",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",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",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(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",defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",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.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\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.w );\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.w );\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.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, 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.x, 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",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",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",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",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",fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",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",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",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",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",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",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",lights_pars_maps:"#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( 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(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",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",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",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",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",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",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",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",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",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",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",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",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",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",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",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",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",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",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",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",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",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",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",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",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",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",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",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",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",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",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",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",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",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}\n",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",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",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",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \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",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\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\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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 \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",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 \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \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 \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",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 \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",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 \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",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 \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}\n",shadow_vert:"#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n"},$T={merge:function(e){for(var t={},n=0;n>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,n){return this.r=e,this.g=t,this.b=n,this},setHSL:function(){function e(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}return function(t,n,i){if(t=JT.euclideanModulo(t,1),n=JT.clamp(n,0,1),i=JT.clamp(i,0,1),0===n)this.r=this.g=this.b=i;else{var r=i<=.5?i*(1+n):i+n-i*n,a=2*i-r;this.r=e(a,r,t+1/3),this.g=e(a,r,t),this.b=e(a,r,t-1/3)}return this}}(),setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var n;if(n=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var i,r=n[1],a=n[2];switch(r){case"rgb":case"rgba":if(i=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(i[1],10))/255,this.g=Math.min(255,parseInt(i[2],10))/255,this.b=Math.min(255,parseInt(i[3],10))/255,t(i[5]),this;if(i=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(i[1],10))/100,this.g=Math.min(100,parseInt(i[2],10))/100,this.b=Math.min(100,parseInt(i[3],10))/100,t(i[5]),this;break;case"hsl":case"hsla":if(i=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(i[1])/360,s=parseInt(i[2],10)/100,c=parseInt(i[3],10)/100;return t(i[5]),this.setHSL(o,s,c)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(e)){var l=(h=n[1]).length;if(3===l)return this.r=parseInt(h.charAt(0)+h.charAt(0),16)/255,this.g=parseInt(h.charAt(1)+h.charAt(1),16)/255,this.b=parseInt(h.charAt(2)+h.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(h.charAt(0)+h.charAt(1),16)/255,this.g=parseInt(h.charAt(2)+h.charAt(3),16)/255,this.b=parseInt(h.charAt(4)+h.charAt(5),16)/255,this}if(e&&e.length>0){var h=eS[e];void 0!==h?this.setHex(h):console.warn("THREE.Color: Unknown color "+e)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);var n=t>0?1/t:1;return this.r=Math.pow(e.r,n),this.g=Math.pow(e.g,n),this.b=Math.pow(e.b,n),this},convertGammaToLinear:function(e){return this.copyGammaToLinear(this,e),this},convertLinearToGamma:function(e){return this.copyLinearToGamma(this,e),this},copySRGBToLinear:function(){function e(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}return function(t){return this.r=e(t.r),this.g=e(t.g),this.b=e(t.b),this}}(),copyLinearToSRGB:function(){function e(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}return function(t){return this.r=e(t.r),this.g=e(t.g),this.b=e(t.b),this}}(),convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){void 0===e&&(console.warn("THREE.Color: .getHSL() target is now required"),e={h:0,s:0,l:0});var t,n,i=this.r,r=this.g,a=this.b,o=Math.max(i,r,a),s=Math.min(i,r,a),c=(s+o)/2;if(s===o)t=0,n=0;else{var l=o-s;switch(n=c<=.5?l/(o+s):l/(2-o-s),o){case i:t=(r-a)/l+(r1){for(var t=0;t1){for(var t=0;t0){a.children=[];for(s=0;s0&&(r.geometries=u),p.length>0&&(r.materials=p),d.length>0&&(r.textures=d),f.length>0&&(r.images=f),m.length>0&&(r.shapes=m)}return r.object=a,r},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(var n=0;n0)for(d=0;d0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,t,n;for(this.computeFaceNormals(),e=0,t=this.faces.length;e0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,n,i,r;for(n=0,i=this.faces.length;n=0;n--){var f=p[n];for(this.faces.splice(f,1),o=0,s=this.faceVertexUvs.length;o0,w=g.vertexNormals.length>0,b=1!==g.color.r||1!==g.color.g||1!==g.color.b,_=g.vertexColors.length>0,M=0;if(M=e(M,0,0),M=e(M,1,!0),M=e(M,2,!1),M=e(M,3,y),M=e(M,4,x),M=e(M,5,w),M=e(M,6,b),M=e(M,7,_),h.push(M),h.push(g.a,g.b,g.c),h.push(g.materialIndex),y){var E=this.faceVertexUvs[0][c];h.push(i(E[0]),i(E[1]),i(E[2]))}if(x&&h.push(t(g.normal)),w){var T=g.vertexNormals;h.push(t(T[0]),t(T[1]),t(T[2]))}if(b&&h.push(n(g.color)),_){var S=g.vertexColors;h.push(n(S[0]),n(S[1]),n(S[2]))}}return r.data={},r.data.vertices=s,r.data.normals=u,d.length>0&&(r.data.colors=d),m.length>0&&(r.data.uvs=[m]),r.data.faces=h,r},clone:function(){return(new Bo).copy(this)},copy:function(e){var t,n,i,r,a,o;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var s=e.vertices;for(t=0,n=s.length;t0,o=r[1]&&r[1].length>0,s=e.morphTargets,c=s.length;if(c>0){t=[];for(v=0;v0){l=[];for(v=0;v0&&0===n.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(var v=0;v65535?Wo:Vo)(e,1):this.index=e},addAttribute:function(e,t){return t&&t.isBufferAttribute||t&&t.isInterleavedBufferAttribute?"index"===e?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(t),this):(this.attributes[e]=t,this):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.addAttribute(e,new Fo(arguments[1],arguments[2])))},getAttribute:function(e){return this.attributes[e]},removeAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,n){this.groups.push({start:e,count:t,materialIndex:void 0!==n?n:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix:function(e){var t=this.attributes.position;void 0!==t&&(e.applyToBufferAttribute(t),t.needsUpdate=!0);var n=this.attributes.normal;return void 0!==n&&((new yo).getNormalMatrix(e).applyToBufferAttribute(n),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var e=new mo;return function(t){return e.makeRotationX(t),this.applyMatrix(e),this}}(),rotateY:function(){var e=new mo;return function(t){return e.makeRotationY(t),this.applyMatrix(e),this}}(),rotateZ:function(){var e=new mo;return function(t){return e.makeRotationZ(t),this.applyMatrix(e),this}}(),translate:function(){var e=new mo;return function(t,n,i){return e.makeTranslation(t,n,i),this.applyMatrix(e),this}}(),scale:function(){var e=new mo;return function(t,n,i){return e.makeScale(t,n,i),this.applyMatrix(e),this}}(),lookAt:function(){var e=new Io;return function(t){e.lookAt(t),e.updateMatrix(),this.applyMatrix(e.matrix)}}(),center:function(){var e=new go;return function(){return this.computeBoundingBox(),this.boundingBox.getCenter(e).negate(),this.translate(e.x,e.y,e.z),this}}(),setFromObject:function(e){var t=e.geometry;if(e.isPoints||e.isLine){var n=new Xo(3*t.vertices.length,3),i=new Xo(3*t.colors.length,3);if(this.addAttribute("position",n.copyVector3sArray(t.vertices)),this.addAttribute("color",i.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var r=new Xo(t.lineDistances.length,1);this.addAttribute("lineDistance",r.copyArray(t.lineDistances))}null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone())}else e.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},setFromPoints:function(e){for(var t=[],n=0,i=e.length;n0){var n=new Float32Array(3*e.normals.length);this.addAttribute("normal",new Fo(n,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var i=new Float32Array(3*e.colors.length);this.addAttribute("color",new Fo(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var r=new Float32Array(2*e.uvs.length);this.addAttribute("uv",new Fo(r,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var a=new Float32Array(2*e.uvs2.length);this.addAttribute("uv2",new Fo(a,2).copyVector2sArray(e.uvs2))}this.groups=e.groups;for(var o in e.morphTargets){for(var s=[],c=e.morphTargets[o],l=0,h=c.length;l0){var d=new Xo(4*e.skinIndices.length,4);this.addAttribute("skinIndex",d.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var f=new Xo(4*e.skinWeights.length,4);this.addAttribute("skinWeight",f.copyVector4sArray(e.skinWeights))}return null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Eo);var e=this.attributes.position;void 0!==e?this.boundingBox.setFromBufferAttribute(e):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var e=new Eo,t=new go;return function(){null===this.boundingSphere&&(this.boundingSphere=new To);var n=this.attributes.position;if(n){var i=this.boundingSphere.center;e.setFromBufferAttribute(n),e.getCenter(i);for(var r=0,a=0,o=n.count;a0&&(e.userData=this.userData),void 0!==this.parameters){var t=this.parameters;for(var n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};var i=this.index;if(null!==i){o=Array.prototype.slice.call(i.array);e.data.index={type:i.array.constructor.name,array:o}}var r=this.attributes;for(var n in r){var a=r[n],o=Array.prototype.slice.call(a.array);e.data.attributes[n]={itemSize:a.itemSize,type:a.array.constructor.name,array:o,normalized:a.normalized}}var s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(e.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),e},clone:function(){return(new Jo).copy(this)},copy:function(e){var t,n,i;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var r=e.index;null!==r&&this.setIndex(r.clone());var a=e.attributes;for(t in a){var o=a[t];this.addAttribute(t,o.clone())}var s=e.morphAttributes;for(t in s){var c=[],l=s[t];for(n=0,i=l.length;n0&&(i.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(i.morphTargets=!0),!0===this.skinning&&(i.skinning=!0),!1===this.visible&&(i.visible=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),n){var r=t(e.textures),a=t(e.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}return i},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.lights=e.lights,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.overdraw=e.overdraw,this.visible=e.visible,this.userData=JSON.parse(JSON.stringify(e.userData)),this.clipShadows=e.clipShadows,this.clipIntersection=e.clipIntersection;var t=e.clippingPlanes,n=null;if(null!==t){var i=t.length;n=new Array(i);for(var r=0;r!==i;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.shadowSide=e.shadowSide,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),ns.prototype=Object.create(ts.prototype),ns.prototype.constructor=ns,ns.prototype.isMeshBasicMaterial=!0,ns.prototype.copy=function(e){return ts.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this},is.prototype=Object.create(ts.prototype),is.prototype.constructor=is,is.prototype.isShaderMaterial=!0,is.prototype.copy=function(e){return ts.prototype.copy.call(this,e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=$T.clone(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this.extensions=e.extensions,this},is.prototype.toJSON=function(e){var t=ts.prototype.toJSON.call(this,e);return t.uniforms=this.uniforms,t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t},Object.assign(rs.prototype,{set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){return void 0===t&&(console.warn("THREE.Ray: .at() target is now required"),t=new go),t.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(){var e=new go;return function(t){return this.origin.copy(this.at(t,e)),this}}(),closestPointToPoint:function(e,t){void 0===t&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),t=new go),t.subVectors(e,this.origin);var n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(){var e=new go;return function(t){var n=e.subVectors(t,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(t):(e.copy(this.direction).multiplyScalar(n).add(this.origin),e.distanceToSquared(t))}}(),distanceSqToSegment:function(){var e=new go,t=new go,n=new go;return function(i,r,a,o){e.copy(i).add(r).multiplyScalar(.5),t.copy(r).sub(i).normalize(),n.copy(this.origin).sub(e);var s,c,l,h,u=.5*i.distanceTo(r),p=-this.direction.dot(t),d=n.dot(this.direction),f=-n.dot(t),m=n.lengthSq(),v=Math.abs(1-p*p);if(v>0)if(s=p*f-d,c=p*d-f,h=u*v,s>=0)if(c>=-h)if(c<=h){var g=1/v;l=(s*=g)*(s+p*(c*=g)+2*d)+c*(p*s+c+2*f)+m}else c=u,l=-(s=Math.max(0,-(p*c+d)))*s+c*(c+2*f)+m;else c=-u,l=-(s=Math.max(0,-(p*c+d)))*s+c*(c+2*f)+m;else c<=-h?l=-(s=Math.max(0,-(-p*u+d)))*s+(c=s>0?-u:Math.min(Math.max(-u,-f),u))*(c+2*f)+m:c<=h?(s=0,l=(c=Math.min(Math.max(-u,-f),u))*(c+2*f)+m):l=-(s=Math.max(0,-(p*u+d)))*s+(c=s>0?u:Math.min(Math.max(-u,-f),u))*(c+2*f)+m;else c=p>0?-u:u,l=-(s=Math.max(0,-(p*c+d)))*s+c*(c+2*f)+m;return a&&a.copy(this.direction).multiplyScalar(s).add(this.origin),o&&o.copy(t).multiplyScalar(c).add(e),l}}(),intersectSphere:function(){var e=new go;return function(t,n){e.subVectors(t.center,this.origin);var i=e.dot(this.direction),r=e.dot(e)-i*i,a=t.radius*t.radius;if(r>a)return null;var o=Math.sqrt(a-r),s=i-o,c=i+o;return s<0&&c<0?null:s<0?this.at(c,n):this.at(s,n)}}(),intersectsSphere:function(e){return this.distanceToPoint(e.center)<=e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null},intersectPlane:function(e,t){var n=this.distanceToPlane(e);return null===n?null:this.at(n,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0},intersectBox:function(e,t){var n,i,r,a,o,s,c=1/this.direction.x,l=1/this.direction.y,h=1/this.direction.z,u=this.origin;return c>=0?(n=(e.min.x-u.x)*c,i=(e.max.x-u.x)*c):(n=(e.max.x-u.x)*c,i=(e.min.x-u.x)*c),l>=0?(r=(e.min.y-u.y)*l,a=(e.max.y-u.y)*l):(r=(e.max.y-u.y)*l,a=(e.min.y-u.y)*l),n>a||r>i?null:((r>n||n!==n)&&(n=r),(a=0?(o=(e.min.z-u.z)*h,s=(e.max.z-u.z)*h):(o=(e.max.z-u.z)*h,s=(e.min.z-u.z)*h),n>s||o>i?null:((o>n||n!==n)&&(n=o),(s=0?n:i,t)))},intersectsBox:function(){var e=new go;return function(t){return null!==this.intersectBox(t,e)}}(),intersectTriangle:function(){var e=new go,t=new go,n=new go,i=new go;return function(r,a,o,s,c){t.subVectors(a,r),n.subVectors(o,r),i.crossVectors(t,n);var l,h=this.direction.dot(i);if(h>0){if(s)return null;l=1}else{if(!(h<0))return null;l=-1,h=-h}e.subVectors(this.origin,r);var u=l*this.direction.dot(n.crossVectors(e,n));if(u<0)return null;var p=l*this.direction.dot(t.cross(e));if(p<0)return null;if(u+p>h)return null;var d=-l*e.dot(i);return d<0?null:this.at(d/h,c)}}(),applyMatrix4:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}}),Object.assign(as.prototype,{set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},getCenter:function(e){return void 0===e&&(console.warn("THREE.Line3: .getCenter() target is now required"),e=new go),e.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return void 0===e&&(console.warn("THREE.Line3: .delta() target is now required"),e=new go),e.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){return void 0===t&&(console.warn("THREE.Line3: .at() target is now required"),t=new go),this.delta(t).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(){var e=new go,t=new go;return function(n,i){e.subVectors(n,this.start),t.subVectors(this.end,this.start);var r=t.dot(t),a=t.dot(e)/r;return i&&(a=JT.clamp(a,0,1)),a}}(),closestPointToPoint:function(e,t,n){var i=this.closestPointToPointParameter(e,t);return void 0===n&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),n=new go),this.delta(n).multiplyScalar(i).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}}),Object.assign(os,{getNormal:function(){var e=new go;return function(t,n,i,r){void 0===r&&(console.warn("THREE.Triangle: .getNormal() target is now required"),r=new go),r.subVectors(i,n),e.subVectors(t,n),r.cross(e);var a=r.lengthSq();return a>0?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)}}(),getBarycoord:function(){var e=new go,t=new go,n=new go;return function(i,r,a,o,s){e.subVectors(o,r),t.subVectors(a,r),n.subVectors(i,r);var c=e.dot(e),l=e.dot(t),h=e.dot(n),u=t.dot(t),p=t.dot(n),d=c*u-l*l;if(void 0===s&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),s=new go),0===d)return s.set(-2,-1,-1);var f=1/d,m=(u*h-l*p)*f,v=(c*p-l*h)*f;return s.set(1-m-v,v,m)}}(),containsPoint:function(){var e=new go;return function(t,n,i,r){return os.getBarycoord(t,n,i,r,e),e.x>=0&&e.y>=0&&e.x+e.y<=1}}()}),Object.assign(os.prototype,{set:function(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this},setFromPointsAndIndices:function(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},getArea:function(){var e=new go,t=new go;return function(){return e.subVectors(this.c,this.b),t.subVectors(this.a,this.b),.5*e.cross(t).length()}}(),getMidpoint:function(e){return void 0===e&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),e=new go),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(e){return os.getNormal(this.a,this.b,this.c,e)},getPlane:function(e){return void 0===e&&(console.warn("THREE.Triangle: .getPlane() target is now required"),e=new go),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,t){return os.getBarycoord(e,this.a,this.b,this.c,t)},containsPoint:function(e){return os.containsPoint(e,this.a,this.b,this.c)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:function(){var e=new So,t=[new as,new as,new as],n=new go,i=new go;return function(r,a){void 0===a&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),a=new go);var o=1/0;if(e.setFromCoplanarPoints(this.a,this.b,this.c),e.projectPoint(r,n),!0===this.containsPoint(n))a.copy(n);else{t[0].set(this.a,this.b),t[1].set(this.b,this.c),t[2].set(this.c,this.a);for(var s=0;s0){var o=r[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=o.length;e0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=s.length;en.far?null:{distance:c,point:g.clone(),object:e}}function n(n,i,r,a,l,h,u,m,g){o.fromBufferAttribute(l,u),s.fromBufferAttribute(l,m),c.fromBufferAttribute(l,g);var y=t(n,i,r,a,o,s,c,v);if(y){h&&(p.fromBufferAttribute(h,u),d.fromBufferAttribute(h,m),f.fromBufferAttribute(h,g),y.uv=e(v,o,s,c,p,d,f));var x=new Uo(u,m,g);os.getNormal(o,s,c,x.normal),y.face=x}return y}var i=new mo,r=new rs,a=new To,o=new go,s=new go,c=new go,l=new go,h=new go,u=new go,p=new fo,d=new fo,f=new fo,m=new go,v=new go,g=new go;return function(m,g){var y=this.geometry,x=this.material,w=this.matrixWorld;if(void 0!==x&&(null===y.boundingSphere&&y.computeBoundingSphere(),a.copy(y.boundingSphere),a.applyMatrix4(w),!1!==m.ray.intersectsSphere(a)&&(i.getInverse(w),r.copy(m.ray).applyMatrix4(i),null===y.boundingBox||!1!==r.intersectsBox(y.boundingBox)))){var b;if(y.isBufferGeometry){var _,M,E,T,S,A,L,R,C,P=y.index,O=y.attributes.position,I=y.attributes.uv,N=y.groups,D=y.drawRange;if(null!==P)if(Array.isArray(x))for(T=0,A=N.length;T0&&(z=V);for(var j=0,W=H.length;jr.far||a.push({distance:m,point:t.clone(),face:null,object:this})}}}(),clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return Io.prototype.copy.call(this,e),void 0!==e.center&&this.center.copy(e.center),this}}),Xc.prototype=Object.assign(Object.create(Io.prototype),{constructor:Xc,copy:function(e){Io.prototype.copy.call(this,e,!1);for(var t=e.levels,n=0,i=t.length;n1){e.setFromMatrixPosition(n.matrixWorld),t.setFromMatrixPosition(this.matrixWorld);var r=e.distanceTo(t);i[0].object.visible=!0;for(var a=1,o=i.length;a=i[a].distance;a++)i[a-1].object.visible=!1,i[a].object.visible=!0;for(;ao||(p.applyMatrix4(this.matrixWorld),(E=i.ray.origin.distanceTo(p))i.far||r.push({distance:E,point:u.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else for(var g=0,y=m.length/3-1;go||(p.applyMatrix4(this.matrixWorld),(E=i.ray.origin.distanceTo(p))i.far||r.push({distance:E,point:u.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else if(s.isGeometry)for(var b=s.vertices,_=b.length,g=0;g<_-1;g+=d){var M=t.distanceSqToSegment(b[g],b[g+1],p,u);if(!(M>o)){p.applyMatrix4(this.matrixWorld);var E=i.ray.origin.distanceTo(p);Ei.far||r.push({distance:E,point:u.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Qc.prototype=Object.assign(Object.create(Kc.prototype),{constructor:Qc,isLineSegments:!0,computeLineDistances:function(){var e=new go,t=new go;return function(){var n=this.geometry;if(n.isBufferGeometry)if(null===n.index){for(var i=n.attributes.position,r=[],a=0,o=i.count;ai.far)return;r.push({distance:s,distanceToRay:Math.sqrt(a),point:d.clone(),index:n,face:null,object:o})}}var o=this,s=this.geometry,c=this.matrixWorld,l=i.params.Points.threshold;if(null===s.boundingSphere&&s.computeBoundingSphere(),n.copy(s.boundingSphere),n.applyMatrix4(c),n.radius+=l,!1!==i.ray.intersectsSphere(n)){e.getInverse(c),t.copy(i.ray).applyMatrix4(e);var h=l/((this.scale.x+this.scale.y+this.scale.z)/3),u=h*h,p=new go,d=new go;if(s.isBufferGeometry){var f=s.index,m=s.attributes.position.array;if(null!==f)for(var v=f.array,g=0,y=v.length;g=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),il.prototype=Object.create(xo.prototype),il.prototype.constructor=il,il.prototype.isCompressedTexture=!0,rl.prototype=Object.create(xo.prototype),rl.prototype.constructor=rl,rl.prototype.isDepthTexture=!0,al.prototype=Object.create(Jo.prototype),al.prototype.constructor=al,ol.prototype=Object.create(Bo.prototype),ol.prototype.constructor=ol,sl.prototype=Object.create(Jo.prototype),sl.prototype.constructor=sl,cl.prototype=Object.create(Bo.prototype),cl.prototype.constructor=cl,ll.prototype=Object.create(Jo.prototype),ll.prototype.constructor=ll,hl.prototype=Object.create(Bo.prototype),hl.prototype.constructor=hl,ul.prototype=Object.create(ll.prototype),ul.prototype.constructor=ul,pl.prototype=Object.create(Bo.prototype),pl.prototype.constructor=pl,dl.prototype=Object.create(ll.prototype),dl.prototype.constructor=dl,fl.prototype=Object.create(Bo.prototype),fl.prototype.constructor=fl,ml.prototype=Object.create(ll.prototype),ml.prototype.constructor=ml,vl.prototype=Object.create(Bo.prototype),vl.prototype.constructor=vl,gl.prototype=Object.create(ll.prototype),gl.prototype.constructor=gl,yl.prototype=Object.create(Bo.prototype),yl.prototype.constructor=yl,xl.prototype=Object.create(Jo.prototype),xl.prototype.constructor=xl,wl.prototype=Object.create(Bo.prototype),wl.prototype.constructor=wl,bl.prototype=Object.create(Jo.prototype),bl.prototype.constructor=bl,_l.prototype=Object.create(Bo.prototype),_l.prototype.constructor=_l,Ml.prototype=Object.create(Jo.prototype),Ml.prototype.constructor=Ml;var gS={triangulate:function(e,t,n){n=n||2;var i=t&&t.length,r=i?t[0]*n:e.length,a=El(e,0,r,n,!0),o=[];if(!a)return o;var s,c,l,h,u,p,d;if(i&&(a=Pl(e,t,a,n)),e.length>80*n){s=l=e[0],c=h=e[1];for(var f=n;fl&&(l=u),p>h&&(h=p);d=0!==(d=Math.max(l-s,h-c))?1/d:0}return Sl(a,o,n,s,c,d),o}},yS={area:function(e){for(var t=e.length,n=0,i=t-1,r=0;r0||0===e.search(/^data\:image\/jpeg/);r.format=i?rT:aT,r.needsUpdate=!0,void 0!==t&&t(r)},n,i),r},setCrossOrigin:function(e){return this.crossOrigin=e,this},setPath:function(e){return this.path=e,this}}),Object.assign(Bh.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(e,t){var n=this.getUtoTmapping(e);return this.getPoint(n,t)},getPoints:function(e){void 0===e&&(e=5);for(var t=[],n=0;n<=e;n++)t.push(this.getPoint(n/e));return t},getSpacedPoints:function(e){void 0===e&&(e=5);for(var t=[],n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t},getLength:function(){var e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(void 0===e&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,n,i=[],r=this.getPoint(0),a=0;for(i.push(0),n=1;n<=e;n++)a+=(t=this.getPoint(n/e)).distanceTo(r),i.push(a),r=t;return this.cacheArcLengths=i,i},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){var n,i=this.getLengths(),r=0,a=i.length;n=t||e*i[a-1];for(var o,s=0,c=a-1;s<=c;)if(r=Math.floor(s+(c-s)/2),(o=i[r]-n)<0)s=r+1;else{if(!(o>0)){c=r;break}c=r-1}if(r=c,i[r]===n)return r/(a-1);var l=i[r];return(r+(n-l)/(i[r+1]-l))/(a-1)},getTangent:function(e){var t=e-1e-4,n=e+1e-4;t<0&&(t=0),n>1&&(n=1);var i=this.getPoint(t);return this.getPoint(n).clone().sub(i).normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},computeFrenetFrames:function(e,t){var n,i,r,a=new go,o=[],s=[],c=[],l=new go,h=new mo;for(n=0;n<=e;n++)i=n/e,o[n]=this.getTangentAt(i),o[n].normalize();s[0]=new go,c[0]=new go;var u=Number.MAX_VALUE,p=Math.abs(o[0].x),d=Math.abs(o[0].y),f=Math.abs(o[0].z);for(p<=u&&(u=p,a.set(1,0,0)),d<=u&&(u=d,a.set(0,1,0)),f<=u&&a.set(0,0,1),l.crossVectors(o[0],a).normalize(),s[0].crossVectors(o[0],l),c[0].crossVectors(o[0],s[0]),n=1;n<=e;n++)s[n]=s[n-1].clone(),c[n]=c[n-1].clone(),l.crossVectors(o[n-1],o[n]),l.length()>Number.EPSILON&&(l.normalize(),r=Math.acos(JT.clamp(o[n-1].dot(o[n]),-1,1)),s[n].applyMatrix4(h.makeRotationAxis(l,r))),c[n].crossVectors(o[n],s[n]);if(!0===t)for(r=Math.acos(JT.clamp(s[0].dot(s[e]),-1,1)),r/=e,o[0].dot(l.crossVectors(s[0],s[e]))>0&&(r=-r),n=1;n<=e;n++)s[n].applyMatrix4(h.makeRotationAxis(o[n],r*n)),c[n].crossVectors(o[n],s[n]);return{tangents:o,normals:s,binormals:c}},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){var e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}),Fh.prototype=Object.create(Bh.prototype),Fh.prototype.constructor=Fh,Fh.prototype.isEllipseCurve=!0,Fh.prototype.getPoint=function(e,t){for(var n=t||new fo,i=2*Math.PI,r=this.aEndAngle-this.aStartAngle,a=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(o)/r)+1)*r:0===s&&o===r-1&&(o=r-2,s=1);var c,l,h,u;if(this.closed||o>0?c=i[(o-1)%r]:(TS.subVectors(i[0],i[1]).add(i[0]),c=TS),l=i[o%r],h=i[(o+1)%r],this.closed||o+2i.length-2?i.length-1:a+1],h=i[a>i.length-3?i.length-1:a+2];return n.set(Hh(o,s.x,c.x,l.x,h.x),Hh(o,s.y,c.y,l.y,h.y)),n},ru.prototype.copy=function(e){Bh.prototype.copy.call(this,e),this.points=[];for(var t=0,n=e.points.length;t=t){var r=n[i]-t,a=this.curves[i],o=a.getLength(),s=0===o?0:1-r/o;return a.getPointAt(s)}i++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],t=0,n=0,i=this.curves.length;n1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},copy:function(e){Bh.prototype.copy.call(this,e),this.curves=[];for(var t=0,n=e.curves.length;t0){var l=c.getPoint(0);l.equals(this.currentPoint)||this.lineTo(l.x,l.y)}this.curves.push(c);var h=c.getPoint(1);this.currentPoint.copy(h)},copy:function(e){return au.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){var e=au.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return au.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}}),su.prototype=Object.assign(Object.create(ou.prototype),{constructor:su,getPointsHoles:function(e){for(var t=[],n=0,i=this.holes.length;n=r)break e;var o=t[1];e=r)break t}a=n,n=0}for(;n>>1;et;)--a;if(++a,0!==r||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);var o=this.getValueSize();this.times=CS.arraySlice(n,r,a),this.values=CS.arraySlice(this.values,r*o,a*o)}return this},validate:function(){var e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);var n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);for(var a=null,o=0;o!==r;o++){var s=n[o];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,s),e=!1;break}if(null!==a&&a>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,s,a),e=!1;break}a=s}if(void 0!==i&&CS.isTypedArray(i))for(var o=0,c=i.length;o!==c;++o){var l=i[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}return e},optimize:function(){for(var e=this.times,t=this.values,n=this.getValueSize(),i=2302===this.getInterpolation(),r=1,a=e.length-1,o=1;o0){e[r]=e[a];for(var f=a*n,m=r*n,p=0;p!==n;++p)t[m+p]=t[f+p];++r}return r!==e.length&&(this.times=CS.arraySlice(e,0,r),this.values=CS.arraySlice(t,0,r*n)),this}}),Ru.prototype=Object.assign(Object.create(Lu.prototype),{constructor:Ru,ValueTypeName:"vector"}),Object.assign(Cu,{parse:function(e){for(var t=[],n=e.tracks,i=1/(e.fps||1),r=0,a=n.length;r!==a;++r)t.push(Lu.parse(n[r]).scale(i));return new Cu(e.name,e.duration,t)},toJSON:function(e){for(var t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid},r=0,a=n.length;r!==a;++r)t.push(Lu.toJSON(n[r]));return i},CreateFromMorphTargetSequence:function(e,t,n,i){for(var r=t.length,a=[],o=0;o1){var c=i[h=s[1]];c||(i[h]=c=[]),c.push(o)}}var l=[];for(var h in i)l.push(Cu.CreateFromMorphTargetSequence(h,i[h],t,n));return l},parseAnimation:function(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var n=function(e,t,n,i,r){if(0!==n.length){var a=[],o=[];CS.flattenJSON(n,a,o,i),0!==a.length&&r.push(new e(t,a,o))}},i=[],r=e.name||"default",a=e.length||-1,o=e.fps||30,s=e.hierarchy||[],c=0;c1?e.skinWeights[i+1]:0,s=n>2?e.skinWeights[i+2]:0,c=n>3?e.skinWeights[i+3]:0;t.skinWeights.push(new wo(a,o,s,c))}if(e.skinIndices)for(var i=0,r=e.skinIndices.length;i1?e.skinIndices[i+1]:0,u=n>2?e.skinIndices[i+2]:0,p=n>3?e.skinIndices[i+3]:0;t.skinIndices.push(new wo(l,h,u,p))}t.bones=e.bones,t.bones&&t.bones.length>0&&(t.skinWeights.length!==t.skinIndices.length||t.skinIndices.length!==t.vertices.length)&&console.warn("When skinning, number of vertices ("+t.vertices.length+"), skinIndices ("+t.skinIndices.length+"), and skinWeights ("+t.skinWeights.length+") should match.")}function n(e,t){var n=e.scale;if(void 0!==e.morphTargets)for(var i=0,r=e.morphTargets.length;i0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');for(var h=t.faces,u=e.morphColors[0].colors,i=0,r=h.length;i0&&(t.animations=n)}return function(r,a){void 0!==r.data&&(r=r.data),void 0!==r.scale?r.scale=1/r.scale:r.scale=1;var o=new Bo;return e(r,o),t(r,o),n(r,o),i(r,o),o.computeFaceNormals(),o.computeBoundingSphere(),void 0===r.materials||0===r.materials.length?{geometry:o}:{geometry:o,materials:Iu.prototype.initMaterials(r.materials,a,this.crossOrigin)}}}()}),Object.assign(Du.prototype,{crossOrigin:"anonymous",load:function(e,t,n,i){""===this.texturePath&&(this.texturePath=e.substring(0,e.lastIndexOf("/")+1));var r=this;new Ph(r.manager).load(e,function(n){var a=null;try{a=JSON.parse(n)}catch(t){return void 0!==i&&i(t),void console.error("THREE:ObjectLoader: Can't parse "+e+".",t.message)}var o=a.metadata;if(void 0===o||void 0===o.type||"geometry"===o.type.toLowerCase())return void console.error("THREE.ObjectLoader: Can't load "+e+". Use THREE.JSONLoader instead.");r.parse(a,t)},n,i)},setTexturePath:function(e){return this.texturePath=e,this},setCrossOrigin:function(e){return this.crossOrigin=e,this},parse:function(e,t){var n=this.parseShape(e.shapes),i=this.parseGeometries(e.geometries,n),r=this.parseImages(e.images,function(){void 0!==t&&t(s)}),a=this.parseTextures(e.textures,r),o=this.parseMaterials(e.materials,a),s=this.parseObject(e.object,i,o);return e.animations&&(s.animations=this.parseAnimations(e.animations)),void 0!==e.images&&0!==e.images.length||void 0!==t&&t(s),s},parseShape:function(e){var t={};if(void 0!==e)for(var n=0,i=e.length;n0){var a=new Nh(new Ch(t));a.setCrossOrigin(this.crossOrigin);for(var o=0,s=e.length;o0?new Zc(o,s):new ss(o,s);break;case"LOD":a=new Xc;break;case"Line":a=new Kc(i(e.geometry),r(e.material),e.mode);break;case"LineLoop":a=new $c(i(e.geometry),r(e.material));break;case"LineSegments":a=new Qc(i(e.geometry),r(e.material));break;case"PointCloud":case"Points":a=new tl(i(e.geometry),r(e.material));break;case"Sprite":a=new Wc(r(e.material));break;case"Group":a=new Dc;break;default:a=new Io}if(a.uuid=e.uuid,void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(a.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.quaternion&&a.quaternion.fromArray(e.quaternion),void 0!==e.scale&&a.scale.fromArray(e.scale)),void 0!==e.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(a.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&a.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(a.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.frustumCulled&&(a.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(a.renderOrder=e.renderOrder),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.layers&&(a.layers.mask=e.layers),void 0!==e.children)for(var c=e.children,l=0;l1){for(var g=!1,y=[],x=0,w=p.length;xNumber.EPSILON){if(l<0&&(o=t[a],c=-c,s=t[r],l=-l),e.ys.y)continue;if(e.y===o.y){if(e.x===o.x)return!0}else{var h=l*(e.x-o.x)-c*(e.y-o.y);if(0===h)return!0;if(h<0)continue;i=!i}}else{if(e.y!==o.y)continue;if(s.x<=e.x&&e.x<=o.x||o.x<=e.x&&e.x<=s.x)return!0}}return i})(M.p,p[T].p)&&(x!==T&&y.push({froms:x,tos:T,hole:_}),E?(E=!1,u[T].push(M)):g=!0);E&&u[x].push(M)}y.length>0&&(g||(d=u))}for(var S,m=0,A=p.length;m0){this.source.connect(this.filters[0]);for(var e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(var e=1,t=this.filters.length;e=.5)for(var a=0;a!==r;++a)e[t+a]=e[n+a]},_slerp:function(e,t,n,i){vo.slerpFlat(e,t,e,t,e,n,i)},_lerp:function(e,t,n,i,r){for(var a=1-i,o=0;o!==r;++o){var s=t+o;e[s]=e[s]*a+e[n+o]*i}}});Object.assign(Ju.prototype,{getValue:function(e,t){this.bind();var n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(e,t)},setValue:function(e,t){for(var n=this._bindings,i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)},bind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()},unbind:function(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}),Object.assign(Ku,{Composite:Ju,create:function(e,t,n){return e&&e.isAnimationObjectGroup?new Ku.Composite(e,t,n):new Ku(e,t,n)},sanitizeNodeName:function(){var e=new RegExp("[\\[\\]\\.:\\/]","g");return function(t){return t.replace(/\s/g,"_").replace(e,"")}}(),parseTrackName:function(){var e="[^\\[\\]\\.:\\/]",t="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",n=/((?:WC+[\/:])*)/.source.replace("WC",e),i=/(WCOD+)?/.source.replace("WCOD",t),r=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",e),a=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",e),o=new RegExp("^"+n+i+r+a+"$"),s=["material","materials","bones"];return function(e){var t=o.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);var n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){var r=n.nodeName.substring(i+1);-1!==s.indexOf(r)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}}(),findNode:function(e,t){if(!t||""===t||"root"===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){var n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){var i=function(e){for(var n=0;n=t){var h=t++,u=e[h];n[u.uuid]=l,e[l]=u,n[c]=h,e[h]=s;for(var p=0,d=r;p!==d;++p){var f=i[p],m=f[h],v=f[l];f[l]=m,f[h]=v}}}this.nCachedObjects_=t},uncache:function(){for(var e=this._objects,t=e.length,n=this.nCachedObjects_,i=this._indicesByUUID,r=this._bindings,a=r.length,o=0,s=arguments.length;o!==s;++o){var c=arguments[o].uuid,l=i[c];if(void 0!==l)if(delete i[c],l0)for(var c=this._interpolants,l=this._propertyBindings,h=0,u=c.length;h!==u;++h)c[h].evaluate(o),l[h].accumulate(i,s)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var n=this._weightInterpolant;if(null!==n){var i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var n=this._timeScaleInterpolant;null!==n&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t},_updateTime:function(e){var t=this.time+e;if(0===e)return t;var n=this._clip.duration,i=this.loop,r=this._loopCount;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(t>=n)t=n;else{if(!(t<0))break e;t=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{var a=2202===i;if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),t>=n||t<0){var o=Math.floor(t/n);t-=n*o,r+=Math.abs(o);var s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=e>0?n:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===s){var c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}if(a&&1==(1&r))return this.time=t,n-t}return this.time=t,t},_setEndings:function(e,t,n){var i=this._interpolantSettings;n?(i.endingStart=2401,i.endingEnd=2401):(i.endingStart=e?this.zeroSlopeAtStart?2401:DT:2402,i.endingEnd=t?this.zeroSlopeAtEnd?2401:DT:2402)},_scheduleFading:function(e,t,n){var i=this._mixer,r=i.time,a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=r,s[0]=t,o[1]=r+e,s[1]=n,this}}),ep.prototype=Object.assign(Object.create(po.prototype),{constructor:ep,_bindAction:function(e,t){var n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,c=this._bindingsByRootAndName,l=c[s];void 0===l&&(l={},c[s]=l);for(var h=0;h!==r;++h){var u=i[h],p=u.name,d=l[p];if(void 0!==d)a[h]=d;else{if(void 0!==(d=a[h])){null===d._cacheIndex&&(++d.referenceCount,this._addInactiveBinding(d,s,p));continue}var f=t&&t._propertyBindings[h].binding.parsedPath;++(d=new Zu(Ku.create(n,p,f),u.ValueTypeName,u.getValueSize())).referenceCount,this._addInactiveBinding(d,s,p),a[h]=d}o[h].resultBuffer=d.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}for(var r=e._propertyBindings,a=0,o=r.length;a!==o;++a){var s=r[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,n=0,i=t.length;n!==i;++n){var r=t[n];0==--r.useCount&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){var t=e._cacheIndex;return null!==t&&tthis.max.x||e.ythis.max.y)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y},getParameter:function(e,t){return void 0===t&&(console.warn("THREE.Box2: .getParameter() target is now required"),t=new fo),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)},clampPoint:function(e,t){return void 0===t&&(console.warn("THREE.Box2: .clampPoint() target is now required"),t=new fo),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new fo;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}),fp.prototype=Object.create(Io.prototype),fp.prototype.constructor=fp,fp.prototype.isImmediateRenderObject=!0,mp.prototype=Object.create(Qc.prototype),mp.prototype.constructor=mp,mp.prototype.update=function(){var e=new go,t=new go,n=new yo;return function(){var i=["a","b","c"];this.object.updateMatrixWorld(!0),n.getNormalMatrix(this.object.matrixWorld);var r=this.object.matrixWorld,a=this.geometry.attributes.position,o=this.object.geometry;if(o&&o.isGeometry)for(var s=o.vertices,c=o.faces,l=0,h=0,u=c.length;h.99999?this.quaternion.set(0,0,0,1):n.y<-.99999?this.quaternion.set(1,0,0,0):(t.set(n.z,0,-n.x).normalize(),e=Math.acos(n.y),this.quaternion.setFromAxisAngle(t,e))}}(),Cp.prototype.setLength=function(e,t,n){void 0===t&&(t=.2*e),void 0===n&&(n=.2*t),this.line.scale.set(1,Math.max(0,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()},Cp.prototype.setColor=function(e){this.line.material.color.copy(e),this.cone.material.color.copy(e)},Pp.prototype=Object.create(Qc.prototype),Pp.prototype.constructor=Pp;Bh.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(Bh.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Object.assign(au.prototype,{createPointsGeometry:function(e){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var t=this.getPoints(e);return this.createGeometry(t)},createSpacedPointsGeometry:function(e){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var t=this.getSpacedPoints(e);return this.createGeometry(t)},createGeometry:function(e){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var t=new Bo,n=0,i=e.length;n0?t[t.length-1]:"",smooth:void 0!==n?n.smooth:this.smooth,groupStart:void 0!==n?n.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){var t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(i),i},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){var t=this.currentMaterial();if(t&&-1===t.groupEnd&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(var n=this.materials.length-1;n>=0;n--)this.materials[n].groupCount<=0&&this.materials.splice(n,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},n&&n.name&&"function"==typeof n.clone){var i=n.clone(0);i.inherited=!0,this.object.materials.push(i)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){var n=parseInt(e,10);return 3*(n>=0?n-1:n+t/3)},parseNormalIndex:function(e,t){var n=parseInt(e,10);return 3*(n>=0?n-1:n+t/3)},parseUVIndex:function(e,t){var n=parseInt(e,10);return 2*(n>=0?n-1:n+t/2)},addVertex:function(e,t,n){var i=this.vertices,r=this.object.geometry.vertices;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addVertexPoint:function(e){var t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){var t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){var i=this.normals,r=this.object.geometry.normals;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addColor:function(e,t,n){var i=this.colors,r=this.object.geometry.colors;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addUV:function(e,t,n){var i=this.uvs,r=this.object.geometry.uvs;r.push(i[e+0],i[e+1]),r.push(i[t+0],i[t+1]),r.push(i[n+0],i[n+1])},addUVLine:function(e){var t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,i,r,a,o,s,c){var l=this.vertices.length,h=this.parseVertexIndex(e,l),u=this.parseVertexIndex(t,l),p=this.parseVertexIndex(n,l);if(this.addVertex(h,u,p),void 0!==i&&""!==i){var d=this.uvs.length;h=this.parseUVIndex(i,d),u=this.parseUVIndex(r,d),p=this.parseUVIndex(a,d),this.addUV(h,u,p)}if(void 0!==o&&""!==o){var f=this.normals.length;h=this.parseNormalIndex(o,f),u=o===s?h:this.parseNormalIndex(s,f),p=o===c?h:this.parseNormalIndex(c,f),this.addNormal(h,u,p)}this.colors.length>0&&this.addColor(h,u,p)},addPointGeometry:function(e){this.object.geometry.type="Points";for(var t=this.vertices.length,n=0,i=e.length;n0){var x=y.split("/");m.push(x)}}for(var w=m[0],v=1,g=m.length-1;v1){var O=l[1].trim().toLowerCase();a.object.smooth="0"!==O&&"off"!==O}else a.object.smooth=!0;(W=a.object.currentMaterial())&&(W.smooth=a.object.smooth)}a.finalize();var I=new VS.Group;I.materialLibraries=[].concat(a.materialLibraries);for(var u=0,p=a.objects.length;u0?k.addAttribute("normal",new VS.Float32BufferAttribute(D.normals,3)):k.computeVertexNormals(),D.colors.length>0&&(z=!0,k.addAttribute("color",new VS.Float32BufferAttribute(D.colors,3))),D.uvs.length>0&&k.addAttribute("uv",new VS.Float32BufferAttribute(D.uvs,2));for(var G=[],H=0,V=U.length;H1){for(var H=0,V=U.length;H7&&void 0!==arguments[7]&&arguments[7];Nx(this,t);var u=Fx(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));if(u.model=e,u.metadata=n,u.errorGlow=new X,u.hover=!1,u.selected=!1,u.highlighted=!1,u.error=!1,u.emissiveColor=4473924,u.obstructFloorMoves=!0,u.position_set=!1,u.allowRotate=!0,u.fixed=!1,u.dragOffset=new a,u.halfSize=new a(0,0,0),u.bhelper=null,u.scene=u.model.scene,h){var d=new p;d.setFromObject(r);var f=d.max.clone().sub(d.min).multiplyScalar(.5);u.geometry=new B(.5*f.x,.5*f.y,.5*f.z),u.material=new fi({color:0,wireframe:!0,visible:!1}),u.geometry.computeBoundingBox(),u.add(r)}else u.geometry=r,u.material=o,u.geometry.computeBoundingBox(),u.geometry.applyMatrix((new i).makeTranslation(-.5*(u.geometry.boundingBox.max.x+u.geometry.boundingBox.min.x),-.5*(u.geometry.boundingBox.max.y+u.geometry.boundingBox.min.y),-.5*(u.geometry.boundingBox.max.z+u.geometry.boundingBox.min.z))),u.geometry.computeBoundingBox();if(u.material.color||(u.material.color=new v("#FFFFFF")),u.wirematerial=new W({color:0,wireframe:!0}),u.errorColor=16711680,u.resizable=n.resizable,u.castShadow=!0,u.receiveShadow=!1,u.originalmaterial=o,u.texture=u.material.texture,u.position_set=!1,s&&(u.position.copy(s),u.position_set=!0),u.halfSize=u.objectHalfSize(),u.canvasWH=document.createElement("canvas"),u.canvasWH.width=u.getWidth()+1,u.canvasWH.height=u.getHeight()+1,u.canvascontextWH=u.canvasWH.getContext("2d"),u.canvasTextureWH=new qt(u.canvasWH),u.canvasMaterialWH=new W({map:u.canvasTextureWH,side:Qx,transparent:!0}),u.canvasPlaneWH=new X(new z(u.getWidth(),u.getHeight(),1,1),u.canvasMaterialWH),u.canvasPlaneWH.scale.set(1,1,1),u.canvasPlaneWH.position.set(0,0,.5*u.getDepth()+.3),u.canvasWD=document.createElement("canvas"),u.canvasWD.width=u.getWidth()+1,u.canvasWD.height=u.getDepth()+1,u.canvascontextWD=u.canvasWD.getContext("2d"),u.canvasTextureWD=new qt(u.canvasWD),u.canvasMaterialWD=new W({map:u.canvasTextureWD,side:Qx,transparent:!0}),u.canvasPlaneWD=new X(new z(u.getWidth(),u.getDepth(),1,1),u.canvasMaterialWD),u.canvasPlaneWD.rotateX(.5*-Math.PI),u.canvasPlaneWD.scale.set(1,1,1),u.canvasPlaneWD.position.set(0,.5*u.getHeight()+.3,0),u.canvasPlaneWH.visible=u.canvasPlaneWD.visible=!1,u.add(u.canvasPlaneWH),u.add(u.canvasPlaneWD),u.resizeProportionally=!0,c&&(u.rotation.y=c),null!=l&&u.setScale(l.x,l.y,l.z),u.metadata.materialColors&&u.metadata.materialColors.length)if(u.material.length)for(var m=0;m.1?this.setScale(i,i,i):Math.abs(e-this.getHeight())>.1?this.setScale(r,r,r):this.setScale(a,a,a));this.setScale(i,r,a)}},{key:"getMaterial",value:function(){return this.material}},{key:"getMaterialColor",value:function(e){return e=e||0,this.material.length?"#"+this.material[e].color.getHexString():"#"+this.material.color.getHexString()}},{key:"setMaterialColor",value:function(e,t){var n=new v(e);if(this.material.length)return t=t||0,void(this.material[t].color=n);this.material.color=n}},{key:"setScale",value:function(e,t,n){var i=new a(e,t,n);this.halfSize.multiply(i),i.multiply(this.scale),this.scale.set(i.x,i.y,i.z),this.resized(),this.bhelper&&this.bhelper.update(),this.updateCanvasTexture(this.canvasWH,this.canvascontextWH,this.canvasMaterialWH,this.getWidth(),this.getHeight(),"w:","h:"),this.updateCanvasTexture(this.canvasWD,this.canvascontextWD,this.canvasMaterialWD,this.getWidth(),this.getDepth(),"w:","d:"),this.scene.needsUpdate=!0}},{key:"getProportionalResize",value:function(){return this.resizeProportionally}},{key:"setProportionalResize",value:function(e){this.resizeProportionally=e}},{key:"setFixed",value:function(e){this.fixed=e}},{key:"resized",value:function(){}},{key:"getHeight",value:function(){return 2*this.halfSize.y}},{key:"getWidth",value:function(){return 2*this.halfSize.x}},{key:"getDepth",value:function(){return 2*this.halfSize.z}},{key:"placeInRoom",value:function(){}},{key:"initObject",value:function(){this.placeInRoom(),this.halfSize.x<1&&this.resize(300*this.getHeight(),300*this.getWidth(),300*this.getDepth()),this.bhelper=new _a(this),this.scene.add(this.bhelper),this.bhelper.visible=!1,this.scene.needsUpdate=!0}},{key:"removed",value:function(){}},{key:"updateHighlight",value:function(){var e=this,t=this.hover||this.selected;this.highlighted=t;var n=t?this.emissiveColor:0;this.material&&(this.material.length?this.material.forEach(function(t){t.emissive.setHex(n),e.material.emissive=new v(n)}):(this.material.emissive.setHex(n),this.material.emissive=new v(n)))}},{key:"mouseOver",value:function(){this.hover=!0,this.updateHighlight()}},{key:"mouseOff",value:function(){this.hover=!1,this.updateHighlight()}},{key:"setSelected",value:function(){this.setScale(1,1,1),this.selected=!0,this.bhelper.visible=!0,this.canvasPlaneWH.visible=this.canvasPlaneWD.visible=!0,this.updateHighlight()}},{key:"setUnselected",value:function(){this.selected=!1,this.bhelper.visible=!1,this.canvasPlaneWH.visible=this.canvasPlaneWD.visible=!1,this.updateHighlight()}},{key:"clickPressed",value:function(e){this.dragOffset.copy(e.point).sub(this.position)}},{key:"clickDragged",value:function(e){e&&this.moveToPosition(e.point.sub(this.dragOffset),e)}},{key:"rotate",value:function(e){if(e){for(var t=lM.angle(new n(0,1),new n(e.point.x-this.position.x,e.point.z-this.position.z)),i=Math.PI/16,r=-4;r<=4;r++)if(Math.abs(t-r*(Math.PI/2))7&&void 0!==arguments[7]&&arguments[7];return Nx(this,t),Fx(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,i,r,a,o,s,c))}return Bx(t,e),Dx(t,[{key:"placeInRoom",value:function(){if(!this.position_set){var e=this.model.floorplan.getCenter();this.position.x=e.x,this.position.z=e.z,this.position.y=.5*(this.geometry.boundingBox.max.y-this.geometry.boundingBox.min.y)}}},{key:"resized",value:function(){this.position.y=this.halfSize.y}},{key:"moveToPosition",value:function(e){if(!this.isValidPosition(e))return void this.showError(e);this.hideError(),e.y=this.position.y,Ux(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"moveToPosition",this).call(this,e)}},{key:"isValidPosition",value:function(e){for(var t=this.getCorners("x","z",e),i=this.model.floorplan.getRooms(),r=0;r7&&void 0!==arguments[7]&&arguments[7];Nx(this,t);var h=Fx(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i,r,a,o,s,c,l));return h.currentWallEdge=null,h.refVec=new n(0,1),h.wallOffsetScalar=0,h.sizeX=0,h.sizeY=0,h.addToWall=!1,h.boundToFloor=!1,h.frontVisible=!1,h.backVisible=!1,h.allowRotate=!1,h}return Bx(t,e),Dx(t,[{key:"closestWallEdge",value:function(){var e=this.model.floorplan.wallEdges(),t=null,n=null,i=this.position.x,r=this.position.z;return e.forEach(function(e){var a=e.distanceTo(i,r);(null===n||at.interiorDistance()-this.sizeX/2-1&&(e.x=t.interiorDistance()-this.sizeX/2-1),this.boundToFloor?e.y=.5*(this.geometry.boundingBox.max.y-this.geometry.boundingBox.min.y)*this.scale.y+.01:e.yt.height-this.sizeY/2-1&&(e.y=t.height-this.sizeY/2-1),e.z=this.getWallOffset(),e.applyMatrix4(t.invInteriorTransform)}}]),t}(WS),YS=function(e){function t(e,n,i,r,a,o,s){var c=arguments.length>7&&void 0!==arguments[7]&&arguments[7];Nx(this,t);var l=Fx(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,i,r,a,o,s,c));return l.addToWall=!0,l}return Bx(t,e),Dx(t,[{key:"getWallOffset",value:function(){return.5-this.currentWallEdge.offset}}]),t}(qS),ZS=function(e){function t(e,n,i,r,a,o,s){var c=arguments.length>7&&void 0!==arguments[7]&&arguments[7];Nx(this,t);var l=Fx(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,i,r,a,o,s,c));return l.boundToFloor=!0,l}return Bx(t,e),t}(YS),JS=function(e){function t(e,n,i,r,a,o,s){var c=arguments.length>7&&void 0!==arguments[7]&&arguments[7];Nx(this,t);var l=Fx(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,i,r,a,o,s,c));return l.obstructFloorMoves=!1,l.receiveShadow=!0,l}return Bx(t,e),t}(XS),KS=function(e){function t(e,n,i,r,a,o,s){var c=arguments.length>7&&void 0!==arguments[7]&&arguments[7];Nx(this,t);var l=Fx(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,i,r,a,o,s,c));return l.boundToFloor=!0,l}return Bx(t,e),t}(qS),QS=function(e){function t(e,n,r,a,o,s,c){var l=arguments.length>7&&void 0!==arguments[7]&&arguments[7];Nx(this,t);var h=Fx(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,r,a,o,s,c,l));h.allowRotate=!1,h.boundToFloor=!1,h.geometry&&(h.geometry.applyMatrix((new i).makeTranslation(-.5*(h.geometry.boundingBox.max.x+h.geometry.boundingBox.min.x),-.5*(h.geometry.boundingBox.max.y-h.geometry.boundingBox.min.y),-.5*(h.geometry.boundingBox.max.z+h.geometry.boundingBox.min.z))),h.geometry.computeBoundingBox()),h.halfSize=h.objectHalfSize(),h.canvasPlaneWH.position.set(0,-.5*h.getHeight(),.5*h.getDepth()),h.canvasPlaneWD.position.set(0,-h.getHeight(),0);var u=h.closestCeilingPoint();return h.moveToPosition(u),h}return Bx(t,e),Dx(t,[{key:"customIntersectionPlanes",value:function(){return this.model.floorplan.roofPlanes()}},{key:"roofContainsPoint",value:function(e,t){for(var n=e.geometry,i={distance:Number.MAX_VALUE,contains:!1,point:null,closestPoint:null},r=null,o=0;o2&&void 0!==arguments[2]&&arguments[2],u=new(eA.getClass(e))(l.model,n,t,c,i,r,a,h);u.fixed=o||!1,l.items.push(u),l.add(u),u.initObject(),l.dispatchEvent({type:"ITEM_LOADED_EVENT",item:u}),s&&(u.moveToPosition(s.position,s.edge),u.placeInRoom())},u=function(e){var t=[],n=new M;e.scene.traverse(function(e){if("Mesh"==e.type){var i=[];if(e.material.length)for(var r=0;r255?32:r}return t.buffer}function c(e,t,n){for(var i={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)},r=t;r5e-4)return!1;return!0}function u(e){if(z.attributes.has(e))return z.attributes.get(e);for(var t=e.clone(),n=new aM.Vector3,i=0,r=t.count;i0)&&(t.alphaMode=e.opacity<1?"BLEND":"MASK",e.alphaTest>0&&.5!==e.alphaTest&&(t.alphaCutoff=e.alphaTest)),e.side===aM.DoubleSide&&(t.doubleSided=!0),""!==e.name&&(t.name=e.name),Object.keys(e.userData).length>0&&(t.extras=f(e)),O.materials.push(t);var r=O.materials.length-1;return z.materials.set(e,r),r}function M(e){var n,i=e.geometry;if(e.isLineSegments)n=t.LINES;else if(e.isLineLoop)n=t.LINE_LOOP;else if(e.isLine)n=t.LINE_STRIP;else if(e.isPoints)n=t.POINTS;else{if(!i.isBufferGeometry){var r=new aM.BufferGeometry;r.fromGeometry(i),i=r}e.drawMode===aM.TriangleFanDrawMode?(console.warn("GLTFExporter: TriangleFanDrawMode and wireframe incompatible."),n=t.TRIANGLE_FAN):n=e.drawMode===aM.TriangleStripDrawMode?e.material.wireframe?t.LINE_STRIP:t.TRIANGLE_STRIP:e.material.wireframe?t.LINES:t.TRIANGLES}var o={},s={},c=[],l=[],p={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},d=i.getAttribute("normal");void 0===d||h(d)||(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),i.addAttribute("normal",u(d)));for(var m in i.attributes){S=i.attributes[m];m=p[m]||m.toUpperCase();var v=S.array;if("JOINTS_0"!==m||v instanceof Uint16Array||v instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),S=new aM.BufferAttribute(new Uint16Array(v),S.itemSize,S.normalized)),"MORPH"!==m.substr(0,5)){var g=y(S,i);null!==g&&(s[m]=g)}}if(void 0!==d&&i.addAttribute("normal",d),0===Object.keys(s).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){var x=[],w=[],b={};if(void 0!==e.morphTargetDictionary)for(var M in e.morphTargetDictionary)b[e.morphTargetDictionary[M]]=M;for(B=0;B0&&(o.extras={},o.extras.targetNames=w)}var P=Object.keys(i.userData).length>0?f(i):void 0,I=a.forceIndices,N=Array.isArray(e.material);if(N&&0===i.groups.length)return null;!I&&null===i.index&&N&&(console.warn("THREE.GLTFExporter: Creating index for non-indexed multi-material mesh."),I=!0);var D=!1;if(null===i.index&&I){for(var U=[],B=0,F=i.attributes.position.count;B0&&(G.targets=l),null!==i.index&&(G.indices=y(i.index,i,k[B].start,k[B].count));var H=_(z[k[B].materialIndex]);null!==H&&(G.material=H),c.push(G)}return D&&i.setIndex(null),o.primitives=c,O.meshes||(O.meshes=[]),O.meshes.push(o),O.meshes.length-1}function E(e){O.cameras||(O.cameras=[]);var t=e.isOrthographicCamera,n={type:t?"orthographic":"perspective"};return t?n.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:n.perspective={aspectRatio:e.aspect,yfov:aM.Math.degToRad(e.fov)/e.aspect,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(n.name=e.type),O.cameras.push(n),O.cameras.length-1}function T(e,t){O.animations||(O.animations=[]);for(var n=[],r=[],a=0;a0&&(t.extras=f(e)),e.isMesh||e.isLine||e.isPoints){var s=M(e);null!==s&&(t.mesh=s)}else e.isCamera&&(t.camera=E(e));if(e.isSkinnedMesh&&B.push(e),e.children.length>0){for(var c=[],l=0,h=e.children.length;l0&&(t.children=c)}O.nodes.push(t);var d=O.nodes.length-1;return U.set(e,d),d}function L(e){O.scenes||(O.scenes=[],O.scene=0);var t={nodes:[]};""!==e.name&&(t.name=e.name),O.scenes.push(t);for(var n=[],i=0,r=e.children.length;i0&&(t.nodes=n)}function R(e){var t=new aM.Scene;t.name="AuxScene";for(var n=0;n0&&(a.trs=!0);var P,O={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},I=0,N=[],D=[],U=new Map,B=[],F={},z={attributes:new Map,materials:new Map,textures:new Map,images:new Map};!function(e){e=e instanceof Array?e:[e];for(var t=[],n=0;n0&&R(t),n=0;n0&&(O.extensionsUsed=t),O.buffers&&O.buffers.length>0){O.buffers[0].byteLength=e.size;var n=new window.FileReader;if(!0===a.binary){n.readAsArrayBuffer(e),n.onloadend=function(){var e=d(n.result),t=new DataView(new ArrayBuffer(8));t.setUint32(0,e.byteLength,!0),t.setUint32(4,5130562,!0);var i=d(s(JSON.stringify(O)),32),a=new DataView(new ArrayBuffer(8));a.setUint32(0,i.byteLength,!0),a.setUint32(4,1313821514,!0);var o=new ArrayBuffer(12),c=new DataView(o);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0);var l=12+a.byteLength+i.byteLength+t.byteLength+e.byteLength;c.setUint32(8,l,!0);var h=new Blob([o,a,i,t,e],{type:"application/octet-stream"}),u=new window.FileReader;u.readAsArrayBuffer(h),u.onloadend=function(){r(u.result)}}}else n.readAsDataURL(e),n.onloadend=function(){var e=n.result;O.buffers[0].uri=e,r(O)}}else r(O)})}},e}(),iA=function(e){function t(e){Nx(this,t);var n=Fx(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.floorplan=new RM,n.scene=new tA(n,e),n.roomLoadingCallbacks=null,n.roomLoadedCallbacks=null,n.roomSavedCallbacks=null,n.roomDeletedCallbacks=null,n}return Bx(t,e),Dx(t,[{key:"switchWireframe",value:function(e){this.scene.switchWireframe(e)}},{key:"loadSerialized",value:function(e){this.dispatchEvent({type:"LOADING_EVENT",item:this});var t=JSON.parse(e);this.newRoom(t.floorplan,t.items),this.dispatchEvent({type:kx,item:this})}},{key:"exportMeshAsObj",value:function(){return(new hd).parse(this.scene.getScene())}},{key:"exportForBlender",value:function(){var e=this,t=new nA,n=[];this.scene.getScene().traverse(function(e){if(e instanceof X&&e.material&&(e.material.length||e.material.visible)){var t=e.material.transparent?e.material.opacity:void 0;n.push(e),t&&(e.material.opacity=t)}}),t.parse(n,function(t){var n=JSON.stringify(t,null,2);e.dispatchEvent({type:"GLTF_READY_EVENT",item:this,gltf:n})})}},{key:"exportSerialized",value:function(){for(var e=[],t=this.scene.getItems(),n=0;n0&&t-1 in e)}function a(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}function o(e,t,n){return we(t)?Me.grep(e,function(e,i){return!!t.call(e,i,e)!==n}):t.nodeType?Me.grep(e,function(e){return e===t!==n}):"string"!=typeof t?Me.grep(e,function(e){return de.call(t,e)>-1!==n}):Me.filter(t,e,n)}function s(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}function c(e){var t={};return Me.each(e.match(Ie)||[],function(e,n){t[n]=!0}),t}function l(e){return e}function h(e){throw e}function u(e,t,n,i){var r;try{e&&we(r=e.promise)?r.call(e).done(t).fail(n):e&&we(r=e.then)?r.call(e,t,n):t.apply(void 0,[e].slice(i))}catch(e){n.apply(void 0,[e])}}function p(){ce.removeEventListener("DOMContentLoaded",p),e.removeEventListener("load",p),Me.ready()}function d(e,t){return t.toUpperCase()}function f(e){return e.replace(Be,"ms-").replace(Fe,d)}function m(){this.expando=Me.expando+m.uid++}function v(e){return"true"===e||"false"!==e&&("null"===e?null:e===+e+""?+e:He.test(e)?JSON.parse(e):e)}function g(e,t,n){var i;if(void 0===n&&1===e.nodeType)if(i="data-"+t.replace(Ve,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(i))){try{n=v(n)}catch(e){}Ge.set(e,t,n)}else n=void 0;return n}function y(e,t,n,i){var r,a,o=20,s=i?function(){return i.cur()}:function(){return Me.css(e,t,"")},c=s(),l=n&&n[3]||(Me.cssNumber[t]?"":"px"),h=e.nodeType&&(Me.cssNumber[t]||"px"!==l&&+c)&&We.exec(Me.css(e,t));if(h&&h[3]!==l){for(c/=2,l=l||h[3],h=+c||1;o--;)Me.style(e,t,h+l),(1-a)*(1-(a=s()/c||.5))<=0&&(o=0),h/=a;h*=2,Me.style(e,t,h+l),n=n||[]}return n&&(h=+h||+c||0,r=n[1]?h+(n[1]+1)*n[2]:+n[2],i&&(i.unit=l,i.start=h,i.end=r)),r}function x(e){var t,n=e.ownerDocument,i=e.nodeName,r=Qe[i];return r||(t=n.body.appendChild(n.createElement(i)),r=Me.css(t,"display"),t.parentNode.removeChild(t),"none"===r&&(r="block"),Qe[i]=r,r)}function w(e,t){for(var n,i,r=[],a=0,o=e.length;a-1)a&&a.push(o);else if(h=Ye(o),s=b(p.appendChild(o),"script"),h&&_(s),n)for(u=0;o=s[u++];)tt.test(o.type||"")&&n.push(o);return p}function E(){return!0}function T(){return!1}function S(e,t){return e===A()==("focus"===t)}function A(){try{return ce.activeElement}catch(e){}}function L(e,t,n,i,r,a){var o,s;if("object"==typeof t){"string"!=typeof n&&(i=i||n,n=void 0);for(s in t)L(e,s,n,i,t[s],a);return e}if(null==i&&null==r?(r=n,i=n=void 0):null==r&&("string"==typeof n?(r=i,i=void 0):(r=i,i=n,n=void 0)),!1===r)r=T;else if(!r)return e;return 1===a&&(o=r,(r=function(e){return Me().off(e),o.apply(this,arguments)}).guid=o.guid||(o.guid=Me.guid++)),e.each(function(){Me.event.add(this,t,r,i,n)})}function R(e,t,n){if(!n)return void(void 0===ke.get(e,t)&&Me.event.add(e,t,E));ke.set(e,t,!1),Me.event.add(e,t,{namespace:!1,handler:function(e){var i,r,a=ke.get(this,t);if(1&e.isTrigger&&this[t]){if(a.length)(Me.event.special[t]||{}).delegateType&&e.stopPropagation();else if(a=he.call(arguments),ke.set(this,t,a),i=n(this,t),this[t](),r=ke.get(this,t),a!==r||i?ke.set(this,t,!1):r={},a!==r)return e.stopImmediatePropagation(),e.preventDefault(),r.value}else a.length&&(ke.set(this,t,{value:Me.event.trigger(Me.extend(a[0],Me.Event.prototype),a.slice(1),this)}),e.stopImmediatePropagation())}})}function C(e,t){return a(e,"table")&&a(11!==t.nodeType?t:t.firstChild,"tr")?Me(e).children("tbody")[0]||e:e}function P(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function O(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function I(e,t){var n,i,r,a,o,s,c,l;if(1===t.nodeType){if(ke.hasData(e)&&(a=ke.access(e),o=ke.set(t,a),l=a.events)){delete o.handle,o.events={};for(r in l)for(n=0,i=l[r].length;n1&&"string"==typeof f&&!xe.checkClone&&ct.test(f))return e.each(function(n){var a=e.eq(n);m&&(t[0]=f.call(this,n,a.html())),D(a,t,i,r)});if(p&&(a=M(t,e[0].ownerDocument,!1,e,r),o=a.firstChild,1===a.childNodes.length&&(a=o),o||r)){for(c=(s=Me.map(b(a,"script"),P)).length;u=0&&(c+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-a-c-s-.5))||0),c}function V(e,t,n){var i=ut(e),r=(!xe.boxSizingReliable()||n)&&"border-box"===Me.css(e,"boxSizing",!1,i),a=r,o=B(e,t,i),s="offset"+t[0].toUpperCase()+t.slice(1);if(ht.test(o)){if(!n)return o;o="auto"}return(!xe.boxSizingReliable()&&r||"auto"===o||!parseFloat(o)&&"inline"===Me.css(e,"display",!1,i))&&e.getClientRects().length&&(r="border-box"===Me.css(e,"boxSizing",!1,i),(a=s in e)&&(o=e[s])),(o=parseFloat(o)||0)+H(e,t,n||(r?"border":"content"),a,i,o)+"px"}function j(e,t,n,i,r){return new j.prototype.init(e,t,n,i,r)}function W(){bt&&(!1===ce.hidden&&e.requestAnimationFrame?e.requestAnimationFrame(W):e.setTimeout(W,Me.fx.interval),Me.fx.tick())}function X(){return e.setTimeout(function(){wt=void 0}),wt=Date.now()}function q(e,t){var n,i=0,r={height:e};for(t=t?1:0;i<4;i+=2-t)r["margin"+(n=Xe[i])]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}function Y(e,t,n){for(var i,r=(K.tweeners[t]||[]).concat(K.tweeners["*"]),a=0,o=r.length;a=0&&nb.cacheLength&&delete e[t.shift()],e[n+" "]=i}var t=[];return e}function i(e){return e[F]=!0,e}function r(e){var t=P.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function a(e,t){for(var n=e.split("|"),i=n.length;i--;)b.attrHandle[n[i]]=t}function o(e,t){var n=t&&e,i=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(i)return i;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function s(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&Ee(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function c(e){return i(function(t){return t=+t,i(function(n,i){for(var r,a=e([],n.length,t),o=a.length;o--;)n[r=a[o]]&&(n[r]=!(i[r]=n[r]))})})}function l(e){return e&&void 0!==e.getElementsByTagName&&e}function h(){}function u(e){for(var t=0,n=e.length,i="";t1?function(t,n,i){for(var r=e.length;r--;)if(!e[r](t,n,i))return!1;return!0}:e[0]}function f(e,n,i){for(var r=0,a=n.length;r-1&&(i[l]=!(o[l]=u))}}else x=m(x===o?x.splice(v,x.length):x),a?a(null,o,x,c):K.apply(o,x)})}function g(e){for(var t,n,i,r=e.length,a=b.relative[e[0].type],o=a||b.relative[" "],s=a?1:0,c=p(function(e){return e===t},o,!0),l=p(function(e){return $(t,e)>-1},o,!0),h=[function(e,n,i){var r=!a&&(i||n!==A)||((t=n).nodeType?c(e,n,i):l(e,n,i));return t=null,r}];s1&&d(h),s>1&&u(e.slice(0,s-1).concat({value:" "===e[s-2].type?"*":""})).replace(oe,"$1"),n,s0,a=e.length>0,o=function(i,o,s,c,l){var h,u,p,d=0,f="0",v=i&&[],g=[],y=A,x=i||a&&b.find.TAG("*",l),w=k+=null==y?1:Math.random()||.1,_=x.length;for(l&&(A=o===P||o||l);f!==_&&null!=(h=x[f]);f++){if(a&&h){for(u=0,o||h.ownerDocument===P||(C(h),s=!I);p=e[u++];)if(p(h,o||P,s)){c.push(h);break}l&&(k=w)}r&&((h=!p&&h)&&d--,i&&v.push(h))}if(d+=f,r&&f!==d){for(u=0;p=n[u++];)p(v,g,o,s);if(i){if(d>0)for(;f--;)v[f]||g[f]||(g[f]=Z.call(c));g=m(g)}K.apply(c,g),l&&!i&&g.length>0&&d+n.length>1&&t.uniqueSort(c)}return l&&(k=w,A=y),v};return r?i(o):o}var x,w,b,_,M,E,T,S,A,L,R,C,P,O,I,N,D,U,B,F="sizzle"+1*new Date,z=e.document,k=0,G=0,H=n(),V=n(),j=n(),W=n(),X=function(e,t){return e===t&&(R=!0),0},q={}.hasOwnProperty,Y=[],Z=Y.pop,J=Y.push,K=Y.push,Q=Y.slice,$=function(e,t){for(var n=0,i=e.length;n+~]|"+te+")"+te+"*"),le=new RegExp(te+"|>"),he=new RegExp(re),ue=new RegExp("^"+ne+"$"),pe={ID:new RegExp("^#("+ne+")"),CLASS:new RegExp("^\\.("+ne+")"),TAG:new RegExp("^("+ne+"|[*])"),ATTR:new RegExp("^"+ie),PSEUDO:new RegExp("^"+re),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+te+"*(even|odd|(([+-]|)(\\d*)n|)"+te+"*(?:([+-]|)"+te+"*(\\d+)|))"+te+"*\\)|)","i"),bool:new RegExp("^(?:"+ee+")$","i"),needsContext:new RegExp("^"+te+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+te+"*((?:-\\d)?\\d*)"+te+"*\\)|)(?=[^-]|$)","i")},de=/HTML$/i,fe=/^(?:input|select|textarea|button)$/i,me=/^h\d$/i,ve=/^[^{]+\{\s*\[native \w/,ge=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ye=/[+~]/,xe=new RegExp("\\\\([\\da-f]{1,6}"+te+"?|("+te+")|.)","ig"),we=function(e,t,n){var i="0x"+t-65536;return i!==i||n?t:i<0?String.fromCharCode(i+65536):String.fromCharCode(i>>10|55296,1023&i|56320)},be=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,_e=function(e,t){return t?"\0"===e?"ďż˝":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},Me=function(){C()},Ee=p(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{K.apply(Y=Q.call(z.childNodes),z.childNodes),Y[z.childNodes.length].nodeType}catch(e){K={apply:Y.length?function(e,t){J.apply(e,Q.call(t))}:function(e,t){for(var n=e.length,i=0;e[n++]=t[i++];);e.length=n-1}}}w=t.support={},M=t.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return!de.test(t||n&&n.nodeName||"HTML")},C=t.setDocument=function(e){var t,n,i=e?e.ownerDocument||e:z;return i!==P&&9===i.nodeType&&i.documentElement?(P=i,O=P.documentElement,I=!M(P),z!==P&&(n=P.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",Me,!1):n.attachEvent&&n.attachEvent("onunload",Me)),w.attributes=r(function(e){return e.className="i",!e.getAttribute("className")}),w.getElementsByTagName=r(function(e){return e.appendChild(P.createComment("")),!e.getElementsByTagName("*").length}),w.getElementsByClassName=ve.test(P.getElementsByClassName),w.getById=r(function(e){return O.appendChild(e).id=F,!P.getElementsByName||!P.getElementsByName(F).length}),w.getById?(b.filter.ID=function(e){var t=e.replace(xe,we);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if(void 0!==t.getElementById&&I){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var t=e.replace(xe,we);return function(e){var n=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},b.find.ID=function(e,t){if(void 0!==t.getElementById&&I){var n,i,r,a=t.getElementById(e);if(a){if((n=a.getAttributeNode("id"))&&n.value===e)return[a];for(r=t.getElementsByName(e),i=0;a=r[i++];)if((n=a.getAttributeNode("id"))&&n.value===e)return[a]}return[]}}),b.find.TAG=w.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):w.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,i=[],r=0,a=t.getElementsByTagName(e);if("*"===e){for(;n=a[r++];)1===n.nodeType&&i.push(n);return i}return a},b.find.CLASS=w.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&I)return t.getElementsByClassName(e)},D=[],N=[],(w.qsa=ve.test(P.querySelectorAll))&&(r(function(e){O.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&N.push("[*^$]="+te+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||N.push("\\["+te+"*(?:value|"+ee+")"),e.querySelectorAll("[id~="+F+"-]").length||N.push("~="),e.querySelectorAll(":checked").length||N.push(":checked"),e.querySelectorAll("a#"+F+"+*").length||N.push(".#.+[+~]")}),r(function(e){e.innerHTML="";var t=P.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&N.push("name"+te+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&N.push(":enabled",":disabled"),O.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&N.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),N.push(",.*:")})),(w.matchesSelector=ve.test(U=O.matches||O.webkitMatchesSelector||O.mozMatchesSelector||O.oMatchesSelector||O.msMatchesSelector))&&r(function(e){w.disconnectedMatch=U.call(e,"*"),U.call(e,"[s!='']:x"),D.push("!=",re)}),N=N.length&&new RegExp(N.join("|")),D=D.length&&new RegExp(D.join("|")),t=ve.test(O.compareDocumentPosition),B=t||ve.test(O.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,i=t&&t.parentNode;return e===i||!(!i||1!==i.nodeType||!(n.contains?n.contains(i):e.compareDocumentPosition&&16&e.compareDocumentPosition(i)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},X=t?function(e,t){if(e===t)return R=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1,1&n||!w.sortDetached&&t.compareDocumentPosition(e)===n?e===P||e.ownerDocument===z&&B(z,e)?-1:t===P||t.ownerDocument===z&&B(z,t)?1:L?$(L,e)-$(L,t):0:4&n?-1:1)}:function(e,t){if(e===t)return R=!0,0;var n,i=0,r=e.parentNode,a=t.parentNode,s=[e],c=[t];if(!r||!a)return e===P?-1:t===P?1:r?-1:a?1:L?$(L,e)-$(L,t):0;if(r===a)return o(e,t);for(n=e;n=n.parentNode;)s.unshift(n);for(n=t;n=n.parentNode;)c.unshift(n);for(;s[i]===c[i];)i++;return i?o(s[i],c[i]):s[i]===z?-1:c[i]===z?1:0},P):P},t.matches=function(e,n){return t(e,null,null,n)},t.matchesSelector=function(e,n){if((e.ownerDocument||e)!==P&&C(e),w.matchesSelector&&I&&!W[n+" "]&&(!D||!D.test(n))&&(!N||!N.test(n)))try{var i=U.call(e,n);if(i||w.disconnectedMatch||e.document&&11!==e.document.nodeType)return i}catch(e){W(n,!0)}return t(n,P,null,[e]).length>0},t.contains=function(e,t){return(e.ownerDocument||e)!==P&&C(e),B(e,t)},t.attr=function(e,t){(e.ownerDocument||e)!==P&&C(e);var n=b.attrHandle[t.toLowerCase()],i=n&&q.call(b.attrHandle,t.toLowerCase())?n(e,t,!I):void 0;return void 0!==i?i:w.attributes||!I?e.getAttribute(t):(i=e.getAttributeNode(t))&&i.specified?i.value:null},t.escape=function(e){return(e+"").replace(be,_e)},t.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},t.uniqueSort=function(e){var t,n=[],i=0,r=0;if(R=!w.detectDuplicates,L=!w.sortStable&&e.slice(0),e.sort(X),R){for(;t=e[r++];)t===e[r]&&(i=n.push(r));for(;i--;)e.splice(n[i],1)}return L=null,e},_=t.getText=function(e){var t,n="",i=0,r=e.nodeType;if(r){if(1===r||9===r||11===r){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=_(e)}else if(3===r||4===r)return e.nodeValue}else for(;t=e[i++];)n+=_(t);return n},(b=t.selectors={cacheLength:50,createPseudo:i,match:pe,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(xe,we),e[3]=(e[3]||e[4]||e[5]||"").replace(xe,we),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||t.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&t.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return pe.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&he.test(n)&&(t=E(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(xe,we).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=H[e+" "];return t||(t=new RegExp("(^|"+te+")"+e+"("+te+"|$)"))&&H(e,function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,n,i){return function(r){var a=t.attr(r,e);return null==a?"!="===n:!n||(a+="","="===n?a===i:"!="===n?a!==i:"^="===n?i&&0===a.indexOf(i):"*="===n?i&&a.indexOf(i)>-1:"$="===n?i&&a.slice(-i.length)===i:"~="===n?(" "+a.replace(ae," ")+" ").indexOf(i)>-1:"|="===n&&(a===i||a.slice(0,i.length+1)===i+"-"))}},CHILD:function(e,t,n,i,r){var a="nth"!==e.slice(0,3),o="last"!==e.slice(-4),s="of-type"===t;return 1===i&&0===r?function(e){return!!e.parentNode}:function(t,n,c){var l,h,u,p,d,f,m=a!==o?"nextSibling":"previousSibling",v=t.parentNode,g=s&&t.nodeName.toLowerCase(),y=!c&&!s,x=!1;if(v){if(a){for(;m;){for(p=t;p=p[m];)if(s?p.nodeName.toLowerCase()===g:1===p.nodeType)return!1;f=m="only"===e&&!f&&"nextSibling"}return!0}if(f=[o?v.firstChild:v.lastChild],o&&y){for(x=(d=(l=(h=(u=(p=v)[F]||(p[F]={}))[p.uniqueID]||(u[p.uniqueID]={}))[e]||[])[0]===k&&l[1])&&l[2],p=d&&v.childNodes[d];p=++d&&p&&p[m]||(x=d=0)||f.pop();)if(1===p.nodeType&&++x&&p===t){h[e]=[k,d,x];break}}else if(y&&(x=d=(l=(h=(u=(p=t)[F]||(p[F]={}))[p.uniqueID]||(u[p.uniqueID]={}))[e]||[])[0]===k&&l[1]),!1===x)for(;(p=++d&&p&&p[m]||(x=d=0)||f.pop())&&((s?p.nodeName.toLowerCase()!==g:1!==p.nodeType)||!++x||(y&&((h=(u=p[F]||(p[F]={}))[p.uniqueID]||(u[p.uniqueID]={}))[e]=[k,x]),p!==t)););return(x-=r)===i||x%i==0&&x/i>=0}}},PSEUDO:function(e,n){var r,a=b.pseudos[e]||b.setFilters[e.toLowerCase()]||t.error("unsupported pseudo: "+e);return a[F]?a(n):a.length>1?(r=[e,e,"",n],b.setFilters.hasOwnProperty(e.toLowerCase())?i(function(e,t){for(var i,r=a(e,n),o=r.length;o--;)e[i=$(e,r[o])]=!(t[i]=r[o])}):function(e){return a(e,0,r)}):a}},pseudos:{not:i(function(e){var t=[],n=[],r=T(e.replace(oe,"$1"));return r[F]?i(function(e,t,n,i){for(var a,o=r(e,null,i,[]),s=e.length;s--;)(a=o[s])&&(e[s]=!(t[s]=a))}):function(e,i,a){return t[0]=e,r(t,null,a,n),t[0]=null,!n.pop()}}),has:i(function(e){return function(n){return t(e,n).length>0}}),contains:i(function(e){return e=e.replace(xe,we),function(t){return(t.textContent||_(t)).indexOf(e)>-1}}),lang:i(function(e){return ue.test(e||"")||t.error("unsupported lang: "+e),e=e.replace(xe,we).toLowerCase(),function(t){var n;do{if(n=I?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===O},focus:function(e){return e===P.activeElement&&(!P.hasFocus||P.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:s(!1),disabled:s(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!b.pseudos.empty(e)},header:function(e){return me.test(e.nodeName)},input:function(e){return fe.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:c(function(){return[0]}),last:c(function(e,t){return[t-1]}),eq:c(function(e,t,n){return[n<0?n+t:n]}),even:c(function(e,t){for(var n=0;nt?t:n;--i>=0;)e.push(i);return e}),gt:c(function(e,t,n){for(var i=n<0?n+t:n;++i2&&"ID"===(o=a[0]).type&&9===t.nodeType&&I&&b.relative[a[1].type]){if(!(t=(b.find.ID(o.matches[0].replace(xe,we),t)||[])[0]))return n;h&&(t=t.parentNode),e=e.slice(a.shift().value.length)}for(r=pe.needsContext.test(e)?0:a.length;r--&&(o=a[r],!b.relative[s=o.type]);)if((c=b.find[s])&&(i=c(o.matches[0].replace(xe,we),ye.test(a[0].type)&&l(t.parentNode)||t))){if(a.splice(r,1),!(e=i.length&&u(a)))return K.apply(n,i),n;break}}return(h||T(e,p))(i,t,!I,n,!t||ye.test(e)&&l(t.parentNode)||t),n},w.sortStable=F.split("").sort(X).join("")===F,w.detectDuplicates=!!R,C(),w.sortDetached=r(function(e){return 1&e.compareDocumentPosition(P.createElement("fieldset"))}),r(function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")})||a("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),w.attributes&&r(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||a("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),r(function(e){return null==e.getAttribute("disabled")})||a(ee,function(e,t,n){var i;if(!n)return!0===e[t]?t.toLowerCase():(i=e.getAttributeNode(t))&&i.specified?i.value:null}),t}(e);Me.find=Ee,Me.expr=Ee.selectors,Me.expr[":"]=Me.expr.pseudos,Me.uniqueSort=Me.unique=Ee.uniqueSort,Me.text=Ee.getText,Me.isXMLDoc=Ee.isXML,Me.contains=Ee.contains,Me.escapeSelector=Ee.escape;var Te=function(e,t,n){for(var i=[],r=void 0!==n;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(r&&Me(e).is(n))break;i.push(e)}return i},Se=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},Ae=Me.expr.match.needsContext,Le=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;Me.filter=function(e,t,n){var i=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===i.nodeType?Me.find.matchesSelector(i,e)?[i]:[]:Me.find.matches(e,Me.grep(t,function(e){return 1===e.nodeType}))},Me.fn.extend({find:function(e){var t,n,i=this.length,r=this;if("string"!=typeof e)return this.pushStack(Me(e).filter(function(){for(t=0;t1?Me.uniqueSort(n):n},filter:function(e){return this.pushStack(o(this,e||[],!1))},not:function(e){return this.pushStack(o(this,e||[],!0))},is:function(e){return!!o(this,"string"==typeof e&&Ae.test(e)?Me(e):e||[],!1).length}});var Re,Ce=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(Me.fn.init=function(e,t,n){var i,r;if(!e)return this;if(n=n||Re,"string"==typeof e){if(!(i="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:Ce.exec(e))||!i[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(i[1]){if(t=t instanceof Me?t[0]:t,Me.merge(this,Me.parseHTML(i[1],t&&t.nodeType?t.ownerDocument||t:ce,!0)),Le.test(i[1])&&Me.isPlainObject(t))for(i in t)we(this[i])?this[i](t[i]):this.attr(i,t[i]);return this}return(r=ce.getElementById(i[2]))&&(this[0]=r,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):we(e)?void 0!==n.ready?n.ready(e):e(Me):Me.makeArray(e,this)}).prototype=Me.fn,Re=Me(ce);var Pe=/^(?:parents|prev(?:Until|All))/,Oe={children:!0,contents:!0,next:!0,prev:!0};Me.fn.extend({has:function(e){var t=Me(e,this),n=t.length;return this.filter(function(){for(var e=0;e-1:1===n.nodeType&&Me.find.matchesSelector(n,e))){a.push(n);break}return this.pushStack(a.length>1?Me.uniqueSort(a):a)},index:function(e){return e?"string"==typeof e?de.call(Me(e),this[0]):de.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(Me.uniqueSort(Me.merge(this.get(),Me(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),Me.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return Te(e,"parentNode")},parentsUntil:function(e,t,n){return Te(e,"parentNode",n)},next:function(e){return s(e,"nextSibling")},prev:function(e){return s(e,"previousSibling")},nextAll:function(e){return Te(e,"nextSibling")},prevAll:function(e){return Te(e,"previousSibling")},nextUntil:function(e,t,n){return Te(e,"nextSibling",n)},prevUntil:function(e,t,n){return Te(e,"previousSibling",n)},siblings:function(e){return Se((e.parentNode||{}).firstChild,e)},children:function(e){return Se(e.firstChild)},contents:function(e){return void 0!==e.contentDocument?e.contentDocument:(a(e,"template")&&(e=e.content||e),Me.merge([],e.childNodes))}},function(e,t){Me.fn[e]=function(n,i){var r=Me.map(this,t,n);return"Until"!==e.slice(-5)&&(i=n),i&&"string"==typeof i&&(r=Me.filter(i,r)),this.length>1&&(Oe[e]||Me.uniqueSort(r),Pe.test(e)&&r.reverse()),this.pushStack(r)}});var Ie=/[^\x20\t\r\n\f]+/g;Me.Callbacks=function(e){e="string"==typeof e?c(e):Me.extend({},e);var t,n,r,a,o=[],s=[],l=-1,h=function(){for(a=a||e.once,r=t=!0;s.length;l=-1)for(n=s.shift();++l-1;)o.splice(n,1),n<=l&&l--}),this},has:function(e){return e?Me.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return a=s=[],o=n="",this},disabled:function(){return!o},lock:function(){return a=s=[],n||t||(o=n=""),this},locked:function(){return!!a},fireWith:function(e,n){return a||(n=[e,(n=n||[]).slice?n.slice():n],s.push(n),t||h()),this},fire:function(){return u.fireWith(this,arguments),this},fired:function(){return!!r}};return u},Me.extend({Deferred:function(t){var n=[["notify","progress",Me.Callbacks("memory"),Me.Callbacks("memory"),2],["resolve","done",Me.Callbacks("once memory"),Me.Callbacks("once memory"),0,"resolved"],["reject","fail",Me.Callbacks("once memory"),Me.Callbacks("once memory"),1,"rejected"]],i="pending",r={state:function(){return i},always:function(){return a.done(arguments).fail(arguments),this},catch:function(e){return r.then(null,e)},pipe:function(){var e=arguments;return Me.Deferred(function(t){Me.each(n,function(n,i){var r=we(e[i[4]])&&e[i[4]];a[i[1]](function(){var e=r&&r.apply(this,arguments);e&&we(e.promise)?e.promise().progress(t.notify).done(t.resolve).fail(t.reject):t[i[0]+"With"](this,r?[e]:arguments)})}),e=null}).promise()},then:function(t,i,r){function a(t,n,i,r){return function(){var s=this,c=arguments,u=function(){var e,u;if(!(t=o&&(i!==h&&(s=void 0,c=[e]),n.rejectWith(s,c))}};t?p():(Me.Deferred.getStackHook&&(p.stackTrace=Me.Deferred.getStackHook()),e.setTimeout(p))}}var o=0;return Me.Deferred(function(e){n[0][3].add(a(0,e,we(r)?r:l,e.notifyWith)),n[1][3].add(a(0,e,we(t)?t:l)),n[2][3].add(a(0,e,we(i)?i:h))}).promise()},promise:function(e){return null!=e?Me.extend(e,r):r}},a={};return Me.each(n,function(e,t){var o=t[2],s=t[5];r[t[1]]=o.add,s&&o.add(function(){i=s},n[3-e][2].disable,n[3-e][3].disable,n[0][2].lock,n[0][3].lock),o.add(t[3].fire),a[t[0]]=function(){return a[t[0]+"With"](this===a?void 0:this,arguments),this},a[t[0]+"With"]=o.fireWith}),r.promise(a),t&&t.call(a,a),a},when:function(e){var t=arguments.length,n=t,i=Array(n),r=he.call(arguments),a=Me.Deferred(),o=function(e){return function(n){i[e]=this,r[e]=arguments.length>1?he.call(arguments):n,--t||a.resolveWith(i,r)}};if(t<=1&&(u(e,a.done(o(n)).resolve,a.reject,!t),"pending"===a.state()||we(r[n]&&r[n].then)))return a.then();for(;n--;)u(r[n],o(n),a.reject);return a.promise()}});var Ne=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;Me.Deferred.exceptionHook=function(t,n){e.console&&e.console.warn&&t&&Ne.test(t.name)&&e.console.warn("jQuery.Deferred exception: "+t.message,t.stack,n)},Me.readyException=function(t){e.setTimeout(function(){throw t})};var De=Me.Deferred();Me.fn.ready=function(e){return De.then(e).catch(function(e){Me.readyException(e)}),this},Me.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--Me.readyWait:Me.isReady)||(Me.isReady=!0,!0!==e&&--Me.readyWait>0||De.resolveWith(ce,[Me]))}}),Me.ready.then=De.then,"complete"===ce.readyState||"loading"!==ce.readyState&&!ce.documentElement.doScroll?e.setTimeout(Me.ready):(ce.addEventListener("DOMContentLoaded",p),e.addEventListener("load",p));var Ue=function(e,t,n,r,a,o,s){var c=0,l=e.length,h=null==n;if("object"===i(n)){a=!0;for(c in n)Ue(e,t,c,n[c],!0,o,s)}else if(void 0!==r&&(a=!0,we(r)||(s=!0),h&&(s?(t.call(e,r),t=null):(h=t,t=function(e,t,n){return h.call(Me(e),n)})),t))for(;c1,null,!0)},removeData:function(e){return this.each(function(){Ge.remove(this,e)})}}),Me.extend({queue:function(e,t,n){var i;if(e)return t=(t||"fx")+"queue",i=ke.get(e,t),n&&(!i||Array.isArray(n)?i=ke.access(e,t,Me.makeArray(n)):i.push(n)),i||[]},dequeue:function(e,t){t=t||"fx";var n=Me.queue(e,t),i=n.length,r=n.shift(),a=Me._queueHooks(e,t),o=function(){Me.dequeue(e,t)};"inprogress"===r&&(r=n.shift(),i--),r&&("fx"===t&&n.unshift("inprogress"),delete a.stop,r.call(e,o,a)),!i&&a&&a.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return ke.get(e,n)||ke.access(e,n,{empty:Me.Callbacks("once memory").add(function(){ke.remove(e,[t+"queue",n])})})}}),Me.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length\x20\t\r\n\f]*)/i,tt=/^$|^module$|\/(?:java|ecma)script/i,nt={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};nt.optgroup=nt.option,nt.tbody=nt.tfoot=nt.colgroup=nt.caption=nt.thead,nt.th=nt.td;var it=/<|&#?\w+;/;!function(){var e=ce.createDocumentFragment().appendChild(ce.createElement("div")),t=ce.createElement("input");t.setAttribute("type","radio"),t.setAttribute("checked","checked"),t.setAttribute("name","t"),e.appendChild(t),xe.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,e.innerHTML="",xe.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var rt=/^key/,at=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,ot=/^([^.]*)(?:\.(.+)|)/;Me.event={global:{},add:function(e,t,n,i,r){var a,o,s,c,l,h,u,p,d,f,m,v=ke.get(e);if(v)for(n.handler&&(n=(a=n).handler,r=a.selector),r&&Me.find.matchesSelector(qe,r),n.guid||(n.guid=Me.guid++),(c=v.events)||(c=v.events={}),(o=v.handle)||(o=v.handle=function(t){return void 0!==Me&&Me.event.triggered!==t.type?Me.event.dispatch.apply(e,arguments):void 0}),l=(t=(t||"").match(Ie)||[""]).length;l--;)d=m=(s=ot.exec(t[l])||[])[1],f=(s[2]||"").split(".").sort(),d&&(u=Me.event.special[d]||{},d=(r?u.delegateType:u.bindType)||d,u=Me.event.special[d]||{},h=Me.extend({type:d,origType:m,data:i,handler:n,guid:n.guid,selector:r,needsContext:r&&Me.expr.match.needsContext.test(r),namespace:f.join(".")},a),(p=c[d])||((p=c[d]=[]).delegateCount=0,u.setup&&!1!==u.setup.call(e,i,f,o)||e.addEventListener&&e.addEventListener(d,o)),u.add&&(u.add.call(e,h),h.handler.guid||(h.handler.guid=n.guid)),r?p.splice(p.delegateCount++,0,h):p.push(h),Me.event.global[d]=!0)},remove:function(e,t,n,i,r){var a,o,s,c,l,h,u,p,d,f,m,v=ke.hasData(e)&&ke.get(e);if(v&&(c=v.events)){for(l=(t=(t||"").match(Ie)||[""]).length;l--;)if(s=ot.exec(t[l])||[],d=m=s[1],f=(s[2]||"").split(".").sort(),d){for(u=Me.event.special[d]||{},p=c[d=(i?u.delegateType:u.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+f.join("\\.(?:.*\\.|)")+"(\\.|$)"),o=a=p.length;a--;)h=p[a],!r&&m!==h.origType||n&&n.guid!==h.guid||s&&!s.test(h.namespace)||i&&i!==h.selector&&("**"!==i||!h.selector)||(p.splice(a,1),h.selector&&p.delegateCount--,u.remove&&u.remove.call(e,h));o&&!p.length&&(u.teardown&&!1!==u.teardown.call(e,f,v.handle)||Me.removeEvent(e,d,v.handle),delete c[d])}else for(d in c)Me.event.remove(e,d+t[l],n,i,!0);Me.isEmptyObject(c)&&ke.remove(e,"handle events")}},dispatch:function(e){var t,n,i,r,a,o,s=Me.event.fix(e),c=new Array(arguments.length),l=(ke.get(this,"events")||{})[s.type]||[],h=Me.event.special[s.type]||{};for(c[0]=s,t=1;t=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(a=[],o={},n=0;n-1:Me.find(r,this,null,[l]).length),o[r]&&a.push(i);a.length&&s.push({elem:l,handlers:a})}return l=this,c\s*$/g;Me.extend({htmlPrefilter:function(e){return e.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,"<$1>")},clone:function(e,t,n){var i,r,a,o,s=e.cloneNode(!0),c=Ye(e);if(!(xe.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||Me.isXMLDoc(e)))for(o=b(s),i=0,r=(a=b(e)).length;i0&&_(o,!c&&b(e,"script")),s},cleanData:function(e){for(var t,n,i,r=Me.event.special,a=0;void 0!==(n=e[a]);a++)if(ze(n)){if(t=n[ke.expando]){if(t.events)for(i in t.events)r[i]?Me.event.remove(n,i):Me.removeEvent(n,i,t.handle);n[ke.expando]=void 0}n[Ge.expando]&&(n[Ge.expando]=void 0)}}}),Me.fn.extend({detach:function(e){return U(this,e,!0)},remove:function(e){return U(this,e)},text:function(e){return Ue(this,function(e){return void 0===e?Me.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return D(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||C(this,e).appendChild(e)})},prepend:function(){return D(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=C(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return D(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return D(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(Me.cleanData(b(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return Me.clone(this,e,t)})},html:function(e){return Ue(this,function(e){var t=this[0]||{},n=0,i=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!st.test(e)&&!nt[(et.exec(e)||["",""])[1].toLowerCase()]){e=Me.htmlPrefilter(e);try{for(;n1)}}),Me.Tween=j,j.prototype={constructor:j,init:function(e,t,n,i,r,a){this.elem=e,this.prop=n,this.easing=r||Me.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=i,this.unit=a||(Me.cssNumber[n]?"":"px")},cur:function(){var e=j.propHooks[this.prop];return e&&e.get?e.get(this):j.propHooks._default.get(this)},run:function(e){var t,n=j.propHooks[this.prop];return this.options.duration?this.pos=t=Me.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):j.propHooks._default.set(this),this}},j.prototype.init.prototype=j.prototype,j.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=Me.css(e.elem,e.prop,""),t&&"auto"!==t?t:0)},set:function(e){Me.fx.step[e.prop]?Me.fx.step[e.prop](e):1!==e.elem.nodeType||!Me.cssHooks[e.prop]&&null==e.elem.style[k(e.prop)]?e.elem[e.prop]=e.now:Me.style(e.elem,e.prop,e.now+e.unit)}}},j.propHooks.scrollTop=j.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},Me.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},Me.fx=j.prototype.init,Me.fx.step={};var wt,bt,_t=/^(?:toggle|show|hide)$/,Mt=/queueHooks$/;Me.Animation=Me.extend(K,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return y(n.elem,e,We.exec(t),n),n}]},tweener:function(e,t){we(e)?(t=e,e=["*"]):e=e.match(Ie);for(var n,i=0,r=e.length;i1)},removeAttr:function(e){return this.each(function(){Me.removeAttr(this,e)})}}),Me.extend({attr:function(e,t,n){var i,r,a=e.nodeType;if(3!==a&&8!==a&&2!==a)return void 0===e.getAttribute?Me.prop(e,t,n):(1===a&&Me.isXMLDoc(e)||(r=Me.attrHooks[t.toLowerCase()]||(Me.expr.match.bool.test(t)?Et:void 0)),void 0!==n?null===n?void Me.removeAttr(e,t):r&&"set"in r&&void 0!==(i=r.set(e,n,t))?i:(e.setAttribute(t,n+""),n):r&&"get"in r&&null!==(i=r.get(e,t))?i:(i=Me.find.attr(e,t),null==i?void 0:i))},attrHooks:{type:{set:function(e,t){if(!xe.radioValue&&"radio"===t&&a(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,i=0,r=t&&t.match(Ie);if(r&&1===e.nodeType)for(;n=r[i++];)e.removeAttribute(n)}}),Et={set:function(e,t,n){return!1===t?Me.removeAttr(e,n):e.setAttribute(n,n),n}},Me.each(Me.expr.match.bool.source.match(/\w+/g),function(e,t){var n=Tt[t]||Me.find.attr;Tt[t]=function(e,t,i){var r,a,o=t.toLowerCase();return i||(a=Tt[o],Tt[o]=r,r=null!=n(e,t,i)?o:null,Tt[o]=a),r}});var St=/^(?:input|select|textarea|button)$/i,At=/^(?:a|area)$/i;Me.fn.extend({prop:function(e,t){return Ue(this,Me.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[Me.propFix[e]||e]})}}),Me.extend({prop:function(e,t,n){var i,r,a=e.nodeType;if(3!==a&&8!==a&&2!==a)return 1===a&&Me.isXMLDoc(e)||(t=Me.propFix[t]||t,r=Me.propHooks[t]),void 0!==n?r&&"set"in r&&void 0!==(i=r.set(e,n,t))?i:e[t]=n:r&&"get"in r&&null!==(i=r.get(e,t))?i:e[t]},propHooks:{tabIndex:{get:function(e){var t=Me.find.attr(e,"tabindex");return t?parseInt(t,10):St.test(e.nodeName)||At.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),xe.optSelected||(Me.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),Me.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){Me.propFix[this.toLowerCase()]=this}),Me.fn.extend({addClass:function(e){var t,n,i,r,a,o,s,c=0;if(we(e))return this.each(function(t){Me(this).addClass(e.call(this,t,$(this)))});if((t=ee(e)).length)for(;n=this[c++];)if(r=$(n),i=1===n.nodeType&&" "+Q(r)+" "){for(o=0;a=t[o++];)i.indexOf(" "+a+" ")<0&&(i+=a+" ");r!==(s=Q(i))&&n.setAttribute("class",s)}return this},removeClass:function(e){var t,n,i,r,a,o,s,c=0;if(we(e))return this.each(function(t){Me(this).removeClass(e.call(this,t,$(this)))});if(!arguments.length)return this.attr("class","");if((t=ee(e)).length)for(;n=this[c++];)if(r=$(n),i=1===n.nodeType&&" "+Q(r)+" "){for(o=0;a=t[o++];)for(;i.indexOf(" "+a+" ")>-1;)i=i.replace(" "+a+" "," ");r!==(s=Q(i))&&n.setAttribute("class",s)}return this},toggleClass:function(e,t){var n=typeof e,i="string"===n||Array.isArray(e);return"boolean"==typeof t&&i?t?this.addClass(e):this.removeClass(e):we(e)?this.each(function(n){Me(this).toggleClass(e.call(this,n,$(this),t),t)}):this.each(function(){var t,r,a,o;if(i)for(r=0,a=Me(this),o=ee(e);t=o[r++];)a.hasClass(t)?a.removeClass(t):a.addClass(t);else void 0!==e&&"boolean"!==n||((t=$(this))&&ke.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":ke.get(this,"__className__")||""))})},hasClass:function(e){var t,n,i=0;for(t=" "+e+" ";n=this[i++];)if(1===n.nodeType&&(" "+Q($(n))+" ").indexOf(t)>-1)return!0;return!1}});Me.fn.extend({val:function(e){var t,n,i,r=this[0];if(arguments.length)return i=we(e),this.each(function(n){var r;1===this.nodeType&&(null==(r=i?e.call(this,n,Me(this).val()):e)?r="":"number"==typeof r?r+="":Array.isArray(r)&&(r=Me.map(r,function(e){return null==e?"":e+""})),(t=Me.valHooks[this.type]||Me.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,r,"value")||(this.value=r))});if(r)return(t=Me.valHooks[r.type]||Me.valHooks[r.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(r,"value"))?n:(n=r.value,"string"==typeof n?n.replace(/\r/g,""):null==n?"":n)}}),Me.extend({valHooks:{option:{get:function(e){var t=Me.find.attr(e,"value");return null!=t?t:Q(Me.text(e))}},select:{get:function(e){var t,n,i,r=e.options,o=e.selectedIndex,s="select-one"===e.type,c=s?null:[],l=s?o+1:r.length;for(i=o<0?l:s?o:0;i-1)&&(n=!0);return n||(e.selectedIndex=-1),a}}}}),Me.each(["radio","checkbox"],function(){Me.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=Me.inArray(Me(e).val(),t)>-1}},xe.checkOn||(Me.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),xe.focusin="onfocusin"in e;var Lt=/^(?:focusinfocus|focusoutblur)$/,Rt=function(e){e.stopPropagation()};Me.extend(Me.event,{trigger:function(t,n,i,r){var a,o,s,c,l,h,u,p,d=[i||ce],f=ve.call(t,"type")?t.type:t,m=ve.call(t,"namespace")?t.namespace.split("."):[];if(o=p=s=i=i||ce,3!==i.nodeType&&8!==i.nodeType&&!Lt.test(f+Me.event.triggered)&&(f.indexOf(".")>-1&&(f=(m=f.split(".")).shift(),m.sort()),l=f.indexOf(":")<0&&"on"+f,t=t[Me.expando]?t:new Me.Event(f,"object"==typeof t&&t),t.isTrigger=r?2:3,t.namespace=m.join("."),t.rnamespace=t.namespace?new RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=i),n=null==n?[t]:Me.makeArray(n,[t]),u=Me.event.special[f]||{},r||!u.trigger||!1!==u.trigger.apply(i,n))){if(!r&&!u.noBubble&&!be(i)){for(c=u.delegateType||f,Lt.test(c+f)||(o=o.parentNode);o;o=o.parentNode)d.push(o),s=o;s===(i.ownerDocument||ce)&&d.push(s.defaultView||s.parentWindow||e)}for(a=0;(o=d[a++])&&!t.isPropagationStopped();)p=o,t.type=a>1?c:u.bindType||f,(h=(ke.get(o,"events")||{})[t.type]&&ke.get(o,"handle"))&&h.apply(o,n),(h=l&&o[l])&&h.apply&&ze(o)&&(t.result=h.apply(o,n),!1===t.result&&t.preventDefault());return t.type=f,r||t.isDefaultPrevented()||u._default&&!1!==u._default.apply(d.pop(),n)||!ze(i)||l&&we(i[f])&&!be(i)&&((s=i[l])&&(i[l]=null),Me.event.triggered=f,t.isPropagationStopped()&&p.addEventListener(f,Rt),i[f](),t.isPropagationStopped()&&p.removeEventListener(f,Rt),Me.event.triggered=void 0,s&&(i[l]=s)),t.result}},simulate:function(e,t,n){var i=Me.extend(new Me.Event,n,{type:e,isSimulated:!0});Me.event.trigger(i,null,t)}}),Me.fn.extend({trigger:function(e,t){return this.each(function(){Me.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return Me.event.trigger(e,t,n,!0)}}),xe.focusin||Me.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){Me.event.simulate(t,e.target,Me.event.fix(e))};Me.event.special[t]={setup:function(){var i=this.ownerDocument||this,r=ke.access(i,t);r||i.addEventListener(e,n,!0),ke.access(i,t,(r||0)+1)},teardown:function(){var i=this.ownerDocument||this,r=ke.access(i,t)-1;r?ke.access(i,t,r):(i.removeEventListener(e,n,!0),ke.remove(i,t))}}});var Ct=e.location,Pt=Date.now(),Ot=/\?/;Me.parseXML=function(t){var n;if(!t||"string"!=typeof t)return null;try{n=(new e.DOMParser).parseFromString(t,"text/xml")}catch(e){n=void 0}return n&&!n.getElementsByTagName("parsererror").length||Me.error("Invalid XML: "+t),n};var It=/\[\]$/,Nt=/^(?:submit|button|image|reset|file)$/i,Dt=/^(?:input|select|textarea|keygen)/i;Me.param=function(e,t){var n,i=[],r=function(e,t){var n=we(t)?t():t;i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(null==e)return"";if(Array.isArray(e)||e.jquery&&!Me.isPlainObject(e))Me.each(e,function(){r(this.name,this.value)});else for(n in e)te(n,e[n],t,r);return i.join("&")},Me.fn.extend({serialize:function(){return Me.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=Me.prop(this,"elements");return e?Me.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!Me(this).is(":disabled")&&Dt.test(this.nodeName)&&!Nt.test(e)&&(this.checked||!$e.test(e))}).map(function(e,t){var n=Me(this).val();return null==n?null:Array.isArray(n)?Me.map(n,function(e){return{name:t.name,value:e.replace(/\r?\n/g,"\r\n")}}):{name:t.name,value:n.replace(/\r?\n/g,"\r\n")}}).get()}});var Ut=/^(.*?):[ \t]*([^\r\n]*)$/gm,Bt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Ft=/^(?:GET|HEAD)$/,zt={},kt={},Gt="*/".concat("*"),Ht=ce.createElement("a");Ht.href=Ct.href,Me.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Ct.href,type:"GET",isLocal:Bt.test(Ct.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Gt,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":Me.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?re(re(e,Me.ajaxSettings),t):re(Me.ajaxSettings,e)},ajaxPrefilter:ne(zt),ajaxTransport:ne(kt),ajax:function(t,n){function i(t,n,i,s){var l,p,d,w,b,_=n;h||(h=!0,c&&e.clearTimeout(c),r=void 0,o=s||"",M.readyState=t>0?4:0,l=t>=200&&t<300||304===t,i&&(w=ae(f,M,i)),w=oe(f,w,M,l),l?(f.ifModified&&((b=M.getResponseHeader("Last-Modified"))&&(Me.lastModified[a]=b),(b=M.getResponseHeader("etag"))&&(Me.etag[a]=b)),204===t||"HEAD"===f.type?_="nocontent":304===t?_="notmodified":(_=w.state,p=w.data,l=!(d=w.error))):(d=_,!t&&_||(_="error",t<0&&(t=0))),M.status=t,M.statusText=(n||_)+"",l?g.resolveWith(m,[p,_,M]):g.rejectWith(m,[M,_,d]),M.statusCode(x),x=void 0,u&&v.trigger(l?"ajaxSuccess":"ajaxError",[M,f,l?p:d]),y.fireWith(m,[M,_]),u&&(v.trigger("ajaxComplete",[M,f]),--Me.active||Me.event.trigger("ajaxStop")))}"object"==typeof t&&(n=t,t=void 0),n=n||{};var r,a,o,s,c,l,h,u,p,d,f=Me.ajaxSetup({},n),m=f.context||f,v=f.context&&(m.nodeType||m.jquery)?Me(m):Me.event,g=Me.Deferred(),y=Me.Callbacks("once memory"),x=f.statusCode||{},w={},b={},_="canceled",M={readyState:0,getResponseHeader:function(e){var t;if(h){if(!s)for(s={};t=Ut.exec(o);)s[t[1].toLowerCase()+" "]=(s[t[1].toLowerCase()+" "]||[]).concat(t[2]);t=s[e.toLowerCase()+" "]}return null==t?null:t.join(", ")},getAllResponseHeaders:function(){return h?o:null},setRequestHeader:function(e,t){return null==h&&(e=b[e.toLowerCase()]=b[e.toLowerCase()]||e,w[e]=t),this},overrideMimeType:function(e){return null==h&&(f.mimeType=e),this},statusCode:function(e){var t;if(e)if(h)M.always(e[M.status]);else for(t in e)x[t]=[x[t],e[t]];return this},abort:function(e){var t=e||_;return r&&r.abort(t),i(0,t),this}};if(g.promise(M),f.url=((t||f.url||Ct.href)+"").replace(/^\/\//,Ct.protocol+"//"),f.type=n.method||n.type||f.method||f.type,f.dataTypes=(f.dataType||"*").toLowerCase().match(Ie)||[""],null==f.crossDomain){l=ce.createElement("a");try{l.href=f.url,l.href=l.href,f.crossDomain=Ht.protocol+"//"+Ht.host!=l.protocol+"//"+l.host}catch(e){f.crossDomain=!0}}if(f.data&&f.processData&&"string"!=typeof f.data&&(f.data=Me.param(f.data,f.traditional)),ie(zt,f,n,M),h)return M;(u=Me.event&&f.global)&&0==Me.active++&&Me.event.trigger("ajaxStart"),f.type=f.type.toUpperCase(),f.hasContent=!Ft.test(f.type),a=f.url.replace(/#.*$/,""),f.hasContent?f.data&&f.processData&&0===(f.contentType||"").indexOf("application/x-www-form-urlencoded")&&(f.data=f.data.replace(/%20/g,"+")):(d=f.url.slice(a.length),f.data&&(f.processData||"string"==typeof f.data)&&(a+=(Ot.test(a)?"&":"?")+f.data,delete f.data),!1===f.cache&&(a=a.replace(/([?&])_=[^&]*/,"$1"),d=(Ot.test(a)?"&":"?")+"_="+Pt+++d),f.url=a+d),f.ifModified&&(Me.lastModified[a]&&M.setRequestHeader("If-Modified-Since",Me.lastModified[a]),Me.etag[a]&&M.setRequestHeader("If-None-Match",Me.etag[a])),(f.data&&f.hasContent&&!1!==f.contentType||n.contentType)&&M.setRequestHeader("Content-Type",f.contentType),M.setRequestHeader("Accept",f.dataTypes[0]&&f.accepts[f.dataTypes[0]]?f.accepts[f.dataTypes[0]]+("*"!==f.dataTypes[0]?", "+Gt+"; q=0.01":""):f.accepts["*"]);for(p in f.headers)M.setRequestHeader(p,f.headers[p]);if(f.beforeSend&&(!1===f.beforeSend.call(m,M,f)||h))return M.abort();if(_="abort",y.add(f.complete),M.done(f.success),M.fail(f.error),r=ie(kt,f,n,M)){if(M.readyState=1,u&&v.trigger("ajaxSend",[M,f]),h)return M;f.async&&f.timeout>0&&(c=e.setTimeout(function(){M.abort("timeout")},f.timeout));try{h=!1,r.send(w,i)}catch(e){if(h)throw e;i(-1,e)}}else i(-1,"No Transport");return M},getJSON:function(e,t,n){return Me.get(e,t,n,"json")},getScript:function(e,t){return Me.get(e,void 0,t,"script")}}),Me.each(["get","post"],function(e,t){Me[t]=function(e,n,i,r){return we(n)&&(r=r||i,i=n,n=void 0),Me.ajax(Me.extend({url:e,type:t,dataType:r,data:n,success:i},Me.isPlainObject(e)&&e))}}),Me._evalUrl=function(e,t){return Me.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,converters:{"text script":function(){}},dataFilter:function(e){Me.globalEval(e,t)}})},Me.fn.extend({wrapAll:function(e){var t;return this[0]&&(we(e)&&(e=e.call(this[0])),t=Me(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return we(e)?this.each(function(t){Me(this).wrapInner(e.call(this,t))}):this.each(function(){var t=Me(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=we(e);return this.each(function(n){Me(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){Me(this).replaceWith(this.childNodes)}),this}}),Me.expr.pseudos.hidden=function(e){return!Me.expr.pseudos.visible(e)},Me.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},Me.ajaxSettings.xhr=function(){try{return new e.XMLHttpRequest}catch(e){}};var Vt={0:200,1223:204},jt=Me.ajaxSettings.xhr();xe.cors=!!jt&&"withCredentials"in jt,xe.ajax=jt=!!jt,Me.ajaxTransport(function(t){var n,i;if(xe.cors||jt&&!t.crossDomain)return{send:function(r,a){var o,s=t.xhr();if(s.open(t.type,t.url,t.async,t.username,t.password),t.xhrFields)for(o in t.xhrFields)s[o]=t.xhrFields[o];t.mimeType&&s.overrideMimeType&&s.overrideMimeType(t.mimeType),t.crossDomain||r["X-Requested-With"]||(r["X-Requested-With"]="XMLHttpRequest");for(o in r)s.setRequestHeader(o,r[o]);n=function(e){return function(){n&&(n=i=s.onload=s.onerror=s.onabort=s.ontimeout=s.onreadystatechange=null,"abort"===e?s.abort():"error"===e?"number"!=typeof s.status?a(0,"error"):a(s.status,s.statusText):a(Vt[s.status]||s.status,s.statusText,"text"!==(s.responseType||"text")||"string"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=n(),i=s.onerror=s.ontimeout=n("error"),void 0!==s.onabort?s.onabort=i:s.onreadystatechange=function(){4===s.readyState&&e.setTimeout(function(){n&&i()})},n=n("abort");try{s.send(t.hasContent&&t.data||null)}catch(e){if(n)throw e}},abort:function(){n&&n()}}}),Me.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),Me.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return Me.globalEval(e),e}}}),Me.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),Me.ajaxTransport("script",function(e){if(e.crossDomain||e.scriptAttrs){var t,n;return{send:function(i,r){t=Me("