1import t,{isWebCodecsSupported as n}from"https://unpkg.com/[email protected]";import{H as e,n as r,c as a,S as i,i as o,s,h as l,e as c,a as u,b as p,d,f,g as m,t as h,j as g,u as v,k as _,l as x,o as y,m as b,p as S,q as T,r as E,v as w,w as A,x as M,y as L,z as C,A as R,B as P,C as B,D as I,E as F,F as G,G as D,I as N,J as O,K as k,L as j,M as U,N as V,O as z}from"./vendor.ce9a259e.js";window.MP4EncoderReady({isWebCodecsSupported:n,loadMP4Module:t});const H="https://api.thegraph.com/subgraphs/name/artblocks/art-blocks",W=JSON.stringify(["0x99a9b7c1116f9ceeb1652de04d5969cce509b069","0x059edd72cd353df5106d2b9cc5ab83a52287ac3a","0xa7d8d9ef8d8ce8992df33d8b8cf4aebabd5bd270"]);async function $(t,n){const e=await fetch(t,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:n})}),r=await e.json();if(r.errors)throw new Error(r.errors[0].message);return r.data}var q={js:'<html>\n <head>\n {{prelude}}\n {{tokenData}}\n <style type="text/css">\n body {\n margin: 0;\n padding: 0;\n }\n canvas {\n padding: 0;\n margin: auto;\n display: block;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n }\n </style>\n </head>\n <body>\n <canvas></canvas>\n {{script}}\n </body>\n</html>',p5js:'<html>\n <head>\n <meta charset="utf-8" />\n {{prelude}}\n {{tokenData}}\n <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/{{version}}/p5.min.js"><\/script>\n {{script}}\n <style type="text/css">\n body {\n margin: 0;\n padding: 0;\n }\n canvas {\n padding: 0;\n margin: auto;\n display: block;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n }\n </style>\n </head>\n</html>',threejs:"<html>\n <head>\n {{prelude}}\n <script>\n // threejs.org/license\n(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\n\ttypeof define === 'function' && define.amd ? define(['exports'], factory) :\n\t(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.THREE = {}));\n}(this, (function (exports) { 'use strict';\n\n\t// Polyfills\n\tif (Number.EPSILON === undefined) {\n\t\tNumber.EPSILON = Math.pow(2, -52);\n\t}\n\n\tif (Number.isInteger === undefined) {\n\t\t// Missing in IE\n\t\t// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger\n\t\tNumber.isInteger = function (value) {\n\t\t\treturn typeof value === 'number' && isFinite(value) && Math.floor(value) === value;\n\t\t};\n\t} //\n\n\n\tif (Math.sign === undefined) {\n\t\t// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign\n\t\tMath.sign = function (x) {\n\t\t\treturn x < 0 ? -1 : x > 0 ? 1 : +x;\n\t\t};\n\t}\n\n\tif ('name' in Function.prototype === false) {\n\t\t// Missing in IE\n\t\t// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name\n\t\tObject.defineProperty(Function.prototype, 'name', {\n\t\t\tget: function get() {\n\t\t\t\treturn this.toString().match(/^\\s*function\\s*([^\\(\\s]*)/)[1];\n\t\t\t}\n\t\t});\n\t}\n\n\tif (Object.assign === undefined) {\n\t\t// Missing in IE\n\t\t// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\n\t\tObject.assign = function (target) {\n\n\t\t\tif (target === undefined || target === null) {\n\t\t\t\tthrow new TypeError('Cannot convert undefined or null to object');\n\t\t\t}\n\n\t\t\tvar output = Object(target);\n\n\t\t\tfor (var index = 1; index < arguments.length; index++) {\n\t\t\t\tvar source = arguments[index];\n\n\t\t\t\tif (source !== undefined && source !== null) {\n\t\t\t\t\tfor (var nextKey in source) {\n\t\t\t\t\t\tif (Object.prototype.hasOwnProperty.call(source, nextKey)) {\n\t\t\t\t\t\t\toutput[nextKey] = source[nextKey];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn output;\n\t\t};\n\t}\n\n\tvar REVISION = '124';\n\tvar MOUSE = {\n\t\tLEFT: 0,\n\t\tMIDDLE: 1,\n\t\tRIGHT: 2,\n\t\tROTATE: 0,\n\t\tDOLLY: 1,\n\t\tPAN: 2\n\t};\n\tvar TOUCH = {\n\t\tROTATE: 0,\n\t\tPAN: 1,\n\t\tDOLLY_PAN: 2,\n\t\tDOLLY_ROTATE: 3\n\t};\n\tvar CullFaceNone = 0;\n\tvar CullFaceBack = 1;\n\tvar CullFaceFront = 2;\n\tvar CullFaceFrontBack = 3;\n\tvar BasicShadowMap = 0;\n\tvar PCFShadowMap = 1;\n\tvar PCFSoftShadowMap = 2;\n\tvar VSMShadowMap = 3;
1\n\tvar FrontSide = 0;\n\tvar BackSide = 1;\n\tvar DoubleSide = 2;\n\tvar FlatShading = 1;\n\tvar SmoothShading = 2;\n\tvar NoBlending = 0;\n\tvar NormalBlending = 1;\n\tvar AdditiveBlending = 2;\n\tvar SubtractiveBlending = 3;\n\tvar MultiplyBlending = 4;\n\tvar CustomBlending = 5;\n\tvar AddEquation = 100;\n\tvar SubtractEquation = 101;\n\tvar ReverseSubtractEquation = 102;\n\tvar MinEquation = 103;\n\tvar MaxEquation = 104;\n\tvar ZeroFactor = 200;\n\tvar OneFactor = 201;\n\tvar SrcColorFactor = 202;\n\tvar OneMinusSrcColorFactor = 203;\n\tvar SrcAlphaFactor = 204;\n\tvar OneMinusSrcAlphaFactor = 205;\n\tvar DstAlphaFactor = 206;\n\tvar OneMinusDstAlphaFactor = 207;\n\tvar DstColorFactor = 208;\n\tvar OneMinusDstColorFactor = 209;\n\tvar SrcAlphaSaturateFactor = 210;\n\tvar NeverDepth = 0;\n\tvar AlwaysDepth = 1;\n\tvar LessDepth = 2;\n\tvar LessEqualDepth = 3;\n\tvar EqualDepth = 4;\n\tvar GreaterEqualDepth = 5;\n\tvar GreaterDepth = 6;\n\tvar NotEqualDepth = 7;\n\tvar MultiplyOperation = 0;\n\tvar MixOperation = 1;\n\tvar AddOperation = 2;\n\tvar NoToneMapping = 0;\n\tvar LinearToneMapping = 1;\n\tvar ReinhardToneMapping = 2;\n\tvar CineonToneMapping = 3;\n\tvar ACESFilmicToneMapping = 4;\n\tvar CustomToneMapping = 5;\n\tvar UVMapping = 300;\n\tvar CubeReflectionMapping = 301;\n\tvar CubeRefractionMapping = 302;\n\tvar EquirectangularReflectionMapping = 303;\n\tvar EquirectangularRefractionMapping = 304;\n\tvar CubeUVReflectionMapping = 306;\n\tvar CubeUVRefractionMapping = 307;\n\tvar RepeatWrapping = 1000;\n\tvar ClampToEdgeWrapping = 1001;\n\tvar MirroredRepeatWrapping = 1002;\n\tvar NearestFilter = 1003;\n\tvar NearestMipmapNearestFilter = 1004;\n\tvar NearestMipMapNearestFilter = 1004;\n\tvar NearestMipmapLinearFilter = 1005;\n\tvar NearestMipMapLinearFilter = 1005;\n\tvar LinearFilter = 1006;\n\tvar LinearMipmapNearestFilter = 1007;\n\tvar LinearMipMapNearestFilter = 1007;\n\tvar LinearMipmapLinearFilter = 1008;\n\tvar LinearMipMapLinearFilter = 1008;\n\tvar UnsignedByteType = 1009;\n\tvar ByteType = 1010;\n\tvar ShortType = 1011;\n\tvar UnsignedShortType = 1012;\n\tvar IntType = 1013;\n\tvar UnsignedIntType = 1014;\n\tvar FloatType = 1015;\n\tvar HalfFloatType = 1016;\n\tvar UnsignedShort4444Type = 1017;\n\tvar UnsignedShort5551Type = 1018;\n\tvar UnsignedShort565Type = 1019;\n\tvar UnsignedInt248Type = 1020;\n\tvar AlphaFormat = 1021;\n\tvar RGBFormat = 1022;\n\tvar RGBAFormat = 1023;\n\tvar LuminanceFormat = 1024;\n\tvar LuminanceAlphaFormat = 1025;\n\tvar RGBEFormat = RGBAFormat;\n\tvar DepthFormat = 1026;\n\tvar DepthStencilFormat = 1027;\n\tvar RedFormat = 1028;\n\tvar RedIntegerFormat = 1029;\n\tvar RGFormat = 1030;\n\tvar RGIntegerFormat = 1031;\n\tvar RGBIntegerFormat = 1032;\n\tvar RGBAIntegerFormat = 1033;\n\tvar RGB_S3TC_DXT1_Format = 33776;\n\tvar RGBA_S3TC_DXT1_Format = 33777;\n\tvar RGBA_S3TC_DXT3_Format = 33778;\n\tvar RGBA_S3TC_DXT5_Format = 33779;\n\tvar RGB_PVRTC_4BPPV1_Format = 35840;\n\tvar RGB_PVRTC_2BPPV1_Format = 35841;\n\tvar RGBA_PVRTC_4BPPV1_Format = 35842;\n\tvar RGBA_PVRTC_2BPPV1_Format = 35843;\n\tvar RGB_ETC1_Format = 36196;\n\tvar RGB_ETC2_Format = 37492;\n\tvar RGBA_ETC2_EAC_Format = 37496;\n\tvar RGBA_ASTC_4x4_Format = 37808;\n\tvar RGBA_ASTC_5x4_Format = 37809;\n\tvar RGBA_ASTC_5x5_Format = 37810;\n\tvar RGBA_ASTC_6x5_Format = 37811;\n\tvar RGBA_ASTC_6x6_Format = 37812;\n\tvar RGBA_ASTC_8x5_Format = 37813;\n\tvar RGBA_ASTC_8x6_Format = 37814;\n\tvar RGBA_ASTC_8x8_Format = 37815;\n\tvar RGBA_ASTC_10x5_Format = 37816;\n\tvar RGBA_ASTC_10x6_Format = 37817;\n\tvar RGBA_ASTC_10x8_Format = 37818;\n\tvar RGBA_ASTC_10x10_Format = 37819;\n\tvar RGBA_ASTC_12x10_Format = 37820;\n\tvar RGBA_ASTC_12x12_Format = 37821;\n\tvar RGBA_BPTC_Format = 36492;\n\tvar SRGB8_ALPHA8_ASTC_4x4_Format = 37840;\n\tvar SRGB8_ALPHA8_ASTC_5x4_Format = 37841;\n\tvar SRGB8_ALPHA8_ASTC_5x5_Format = 37842;\n\tvar SRGB8_ALPHA8_ASTC_6x5_Format = 37843;\n\tvar SRGB8_ALPHA8_ASTC_6x6_Format = 37844;\n\tvar SRGB8_ALPHA8_ASTC_8x5_Format = 37845;\n\tvar SRGB8_ALPHA8_ASTC_8x6_Format = 37846;\n\tvar SRGB8_ALPHA8_ASTC_8x8_Format = 37847;\n\tvar SRGB8_ALPHA8_ASTC_10x5_Format = 37848;\n\tvar SRGB8_ALPHA8_ASTC_10x6_Format = 37849;\n\tvar SRGB8_ALPHA8_ASTC_10x8_Format = 37850;\n\tvar SRGB8_ALPHA8_ASTC_10x10_Format = 37851;\n\tvar SRGB8_ALPHA8_ASTC_12x10_Format = 37852;\n\tvar SRGB8_ALPHA8_ASTC_12x12_Format = 37853;\n\tvar LoopOnce = 2200;\n\tvar LoopRepeat = 2201;\n\tvar LoopPingPong = 2202;\n\tvar InterpolateDiscrete = 2300;\n\tvar InterpolateLinear = 2301;\n\tvar InterpolateSmooth = 2302;\n\tvar ZeroCurvatureEnding = 2400;\n\tvar ZeroSlopeEnding = 2401;\n\tvar WrapAroundEnding = 2402;\n\tvar NormalAnimationBlendMode = 2500;\n\tvar AdditiveAnimationBlendMode = 2501;\n\tvar TrianglesDrawMode = 0;\n\tvar TriangleStripDrawMode = 1;\n\tvar TriangleFanDrawMode = 2;\n\tvar LinearEncoding = 3000;\n\tvar sRGBEncoding = 3001;\n\tvar GammaEncoding = 3007;\n\tvar RGBEEncoding = 3002;\n\tvar LogLuvEncoding = 3003;\n\tvar RGBM7Encoding = 3004;\n\tvar RGBM16Encoding = 3005;\n\tvar RGBDEncoding = 3006;\n\tvar BasicDepthPacking = 3200;\n\tvar RGBADepthPacking = 3201;\n\tvar TangentSpaceNormalMap = 0;\n\tvar ObjectSpaceNormalMap = 1;\n\tvar ZeroStencilOp = 0;\n\tvar KeepStencilOp = 7680;\n\tvar ReplaceStencilOp = 7681;\n\tvar IncrementStencilOp = 7682;\n\tvar DecrementStencilOp = 7683;\n\tvar IncrementWrapStencilOp = 34055;\n\tvar DecrementWrapStencilOp = 34056;\n\tvar InvertStencilOp = 5386;\n\tvar NeverStencilFunc = 512;\n\tvar LessStencilFunc = 513;\n\tvar EqualStencilFunc = 514;\n\tvar LessEqualStencilFunc = 515;\n\tvar GreaterStencilFunc = 516;\n\tvar NotEqualStencilFunc = 517;\n\tvar GreaterEqualStencilFunc = 518;\n\tvar AlwaysStencilFunc = 519;\n\tvar StaticDrawUsage = 35044;\n\tvar DynamicDrawUsage = 35048;\n\tvar StreamDrawUsage = 35040;\n\tvar StaticReadUsage = 35045;\n\tvar DynamicReadUsage = 35049;\n\tvar StreamReadUsage = 35041;\n\tvar StaticCopyUsage = 35046;\n\tvar DynamicCopyUsage = 35050;\n\tvar StreamCopyUsage = 35042;\n\tvar GLSL1 = '100';\n\tvar GLSL3 = '300 es';\n\n\t/**\n\t * https://github.com/mrdoob/eventdispatcher.js/\n\t */\n\tfunction EventDispatcher() {}\n\n\tObject.assign(EventDispatcher.prototype, {\n\t\taddEventListener: function addEventListener(type, listener) {\n\t\t\tif (this._listeners === undefined) this._listeners = {};\n\t\t\tvar listeners = this._listeners;\n\n\t\t\tif (listeners[type] === undefined) {\n\t\t\t\tlisteners[type] = [];\n\t\t\t}\n\n\t\t\tif (listeners[type].indexOf(listener) === -1) {\n\t\t\t\tlisteners[type].push(listener);\n\t\t\t}\n\t\t},\n\t\thasEventListener: function hasEventListener(type, listener) {\n\t\t\tif (this._listeners === undefined) return false;\n\t\t\tvar listeners = this._listeners;\n\t\t\treturn listeners[type] !== undefined && listeners[type].indexOf(listener) !== -1;\n\t\t},\n\t\tremoveEventListener: function removeEventListener(type, listener) {\n\t\t\tif (this._listeners === undefined) return;\n\t\t\tvar listeners = this._listeners;\n\t\t\tvar listenerArray = listeners[type];\n\n\t\t\tif (listenerArray !== undefined) {\n\t\t\t\tvar index = listenerArray.indexOf(listener);\n\n\t\t\t\tif (index !== -1) {\n\t\t\t\t\tlistenerArray.splice(index, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tdispatchEvent: function dispatchEvent(event) {\n\t\t\tif (this._listeners === undefined) return;\n\t\t\tvar listeners = this._listeners;\n\t\t\tvar listenerArray = listeners[event.type];\n\n\t\t\tif (listenerArray !== undefined) {\n\t\t\t\tevent.target = this; // Make a copy, in case listeners are removed while iterating.\n\n\t\t\t\tvar array = listenerArray.slice(0);\n\n\t\t\t\tfor (var i = 0, l = array.length; i < l;
1 i++) {\n\t\t\t\t\tarray[i].call(this, event);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\tvar _lut = [];\n\n\tfor (var i = 0; i < 256; i++) {\n\t\t_lut[i] = (i < 16 ? '0' : '') + i.toString(16);\n\t}\n\n\tvar _seed = 1234567;\n\tvar MathUtils = {\n\t\tDEG2RAD: Math.PI / 180,\n\t\tRAD2DEG: 180 / Math.PI,\n\t\tgenerateUUID: function generateUUID() {\n\t\t\t// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136\n\t\t\tvar d0 = Math.random() * 0xffffffff | 0;\n\t\t\tvar d1 = Math.random() * 0xffffffff | 0;\n\t\t\tvar d2 = Math.random() * 0xffffffff | 0;\n\t\t\tvar d3 = Math.random() * 0xffffffff | 0;\n\t\t\tvar uuid = _lut[d0 & 0xff] + _lut[d0 >> 8 & 0xff] + _lut[d0 >> 16 & 0xff] + _lut[d0 >> 24 & 0xff] + '-' + _lut[d1 & 0xff] + _lut[d1 >> 8 & 0xff] + '-' + _lut[d1 >> 16 & 0x0f | 0x40] + _lut[d1 >> 24 & 0xff] + '-' + _lut[d2 & 0x3f | 0x80] + _lut[d2 >> 8 & 0xff] + '-' + _lut[d2 >> 16 & 0xff] + _lut[d2 >> 24 & 0xff] + _lut[d3 & 0xff] + _lut[d3 >> 8 & 0xff] + _lut[d3 >> 16 & 0xff] + _lut[d3 >> 24 & 0xff]; // .toUpperCase() here flattens concatenated strings to save heap memory space.\n\n\t\t\treturn uuid.toUpperCase();\n\t\t},\n\t\tclamp: function clamp(value, min, max) {\n\t\t\treturn Math.max(min, Math.min(max, value));\n\t\t},\n\t\t// compute euclidian modulo of m % n\n\t\t// https://en.wikipedia.org/wiki/Modulo_operation\n\t\teuclideanModulo: function euclideanModulo(n, m) {\n\t\t\treturn (n % m + m) % m;\n\t\t},\n\t\t// Linear mapping from range <a1, a2> to range <b1, b2>\n\t\tmapLinear: function mapLinear(x, a1, a2, b1, b2) {\n\t\t\treturn b1 + (x - a1) * (b2 - b1) / (a2 - a1);\n\t\t},\n\t\t// https://en.wikipedia.org/wiki/Linear_interpolation\n\t\tlerp: function lerp(x, y, t) {\n\t\t\treturn (1 - t) * x + t * y;\n\t\t},\n\t\t// http://en.wikipedia.org/wiki/Smoothstep\n\t\tsmoothstep: function smoothstep(x, min, max) {\n\t\t\tif (x <= min) return 0;\n\t\t\tif (x >= max) return 1;\n\t\t\tx = (x - min) / (max - min);\n\t\t\treturn x * x * (3 - 2 * x);\n\t\t},\n\t\tsmootherstep: function smootherstep(x, min, max) {\n\t\t\tif (x <= min) return 0;\n\t\t\tif (x >= max) return 1;\n\t\t\tx = (x - min) / (max - min);\n\t\t\treturn x * x * x * (x * (x * 6 - 15) + 10);\n\t\t},\n\t\t// Random integer from <low, high> interval\n\t\trandInt: function randInt(low, high) {\n\t\t\treturn low + Math.floor(Math.random() * (high - low + 1));\n\t\t},\n\t\t// Random float from <low, high> interval\n\t\trandFloat: function randFloat(low, high) {\n\t\t\treturn low + Math.random() * (high - low);\n\t\t},\n\t\t// Random float from <-range/2, range/2> interval\n\t\trandFloatSpread: function randFloatSpread(range) {\n\t\t\treturn range * (0.5 - Math.random());\n\t\t},\n\t\t// Deterministic pseudo-random float in the interval [ 0, 1 ]\n\t\tseededRandom: function seededRandom(s) {\n\t\t\tif (s !== undefined) _seed = s % 2147483647; // Park-Miller algorithm\n\n\t\t\t_seed = _seed * 16807 % 2147483647;\n\t\t\treturn (_seed - 1) / 2147483646;\n\t\t},\n\t\tdegToRad: function degToRad(degrees) {\n\t\t\treturn degrees * MathUtils.DEG2RAD;\n\t\t},\n\t\tradToDeg: function radToDeg(radians) {\n\t\t\treturn radians * MathUtils.RAD2DEG;\n\t\t},\n\t\tisPowerOfTwo: function isPowerOfTwo(value) {\n\t\t\treturn (value & value - 1) === 0 && value !== 0;\n\t\t},\n\t\tceilPowerOfTwo: function ceilPowerOfTwo(value) {\n\t\t\treturn Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));\n\t\t},\n\t\tfloorPowerOfTwo: function floorPowerOfTwo(value) {\n\t\t\treturn Math.pow(2, Math.floor(Math.log(value) / Math.LN2));\n\t\t},\n\t\tsetQuaternionFromProperEuler: function setQuaternionFromProperEuler(q, a, b, c, order) {\n\t\t\t// Intrinsic Proper Euler Angles - see https://en.wikipedia.org/wiki/Euler_angles\n\t\t\t// rotations are applied to the axes in the order specified by 'order'\n\t\t\t// rotation by angle 'a' is applied first, then by angle 'b', then by angle 'c'\n\t\t\t// angles are in radians\n\t\t\tvar cos = Math.cos;\n\t\t\tvar sin = Math.sin;\n\t\t\tvar c2 = cos(b / 2);\n\t\t\tvar s2 = sin(b / 2);\n\t\t\tvar c13 = cos((a + c) / 2);\n\t\t\tvar s13 = sin((a + c) / 2);\n\t\t\tvar c1_3 = cos((a - c) / 2);\n\t\t\tvar s1_3 = sin((a - c) / 2);\n\t\t\tvar c3_1 = cos((c - a) / 2);\n\t\t\tvar s3_1 = sin((c - a) / 2);\n\n\t\t\tswitch (order) {\n\t\t\t\tcase 'XYX':\n\t\t\t\t\tq.set(c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'YZY':\n\t\t\t\t\tq.set(s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'ZXZ':\n\t\t\t\t\tq.set(s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'XZX':\n\t\t\t\t\tq.set(c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'YXY':\n\t\t\t\t\tq.set(s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'ZYZ':\n\t\t\t\t\tq.set(s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13);\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tconsole.warn('THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order);\n\t\t\t}\n\t\t}\n\t};\n\n\tfunction _defineProperties(target, props) {\n\t\tfor (var i = 0; i < props.length;
1 i++) {\n\t\t\tvar descriptor = props[i];\n\t\t\tdescriptor.enumerable = descriptor.enumerable || false;\n\t\t\tdescriptor.configurable = true;\n\t\t\tif (\"value\" in descriptor) descriptor.writable = true;\n\t\t\tObject.defineProperty(target, descriptor.key, descriptor);\n\t\t}\n\t}\n\n\tfunction _createClass(Constructor, protoProps, staticProps) {\n\t\tif (protoProps) _defineProperties(Constructor.prototype, protoProps);\n\t\tif (staticProps) _defineProperties(Constructor, staticProps);\n\t\treturn Constructor;\n\t}\n\n\tfunction _inheritsLoose(subClass, superClass) {\n\t\tsubClass.prototype = Object.create(superClass.prototype);\n\t\tsubClass.prototype.constructor = subClass;\n\t\tsubClass.__proto__ = superClass;\n\t}\n\n\tfunction _assertThisInitialized(self) {\n\t\tif (self === void 0) {\n\t\t\tthrow new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n\t\t}\n\n\t\treturn self;\n\t}\n\n\tvar Vector2 = /*#__PURE__*/function () {\n\t\tfunction Vector2(x, y) {\n\t\t\tif (x === void 0) {\n\t\t\t\tx = 0;\n\t\t\t}\n\n\t\t\tif (y === void 0) {\n\t\t\t\ty = 0;\n\t\t\t}\n\n\t\t\tObject.defineProperty(this, 'isVector2', {\n\t\t\t\tvalue: true\n\t\t\t});\n\t\t\tthis.x = x;\n\t\t\tthis.y = y;\n\t\t}\n\n\t\tvar _proto = Vector2.prototype;\n\n\t\t_proto.set = function set(x, y) {\n\t\t\tthis.x = x;\n\t\t\tthis.y = y;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setScalar = function setScalar(scalar) {\n\t\t\tthis.x = scalar;\n\t\t\tthis.y = scalar;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setX = function setX(x) {\n\t\t\tthis.x = x;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setY = function setY(y) {\n\t\t\tthis.y = y;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setComponent = function setComponent(index, value) {\n\t\t\tswitch (index) {\n\t\t\t\tcase 0:\n\t\t\t\t\tthis.x = value;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 1:\n\t\t\t\t\tthis.y = value;\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error('index is out of range: ' + index);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.getComponent = function getComponent(index) {\n\t\t\tswitch (index) {\n\t\t\t\tcase 0:\n\t\t\t\t\treturn this.x;\n\n\t\t\t\tcase 1:\n\t\t\t\t\treturn this.y;\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error('index is out of range: ' + index);\n\t\t\t}\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor(this.x, this.y);\n\t\t};\n\n\t\t_proto.copy = function copy(v) {\n\t\t\tthis.x = v.x;\n\t\t\tthis.y = v.y;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.add = function add(v, w) {\n\t\t\tif (w !== undefined) {\n\t\t\t\tconsole.warn('THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.');\n\t\t\t\treturn this.addVectors(v, w);\n\t\t\t}\n\n\t\t\tthis.x += v.x;\n\t\t\tthis.y += v.y;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.addScalar = function addScalar(s) {\n\t\t\tthis.x += s;\n\t\t\tthis.y += s;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.addVectors = function addVectors(a, b) {\n\t\t\tthis.x = a.x + b.x;\n\t\t\tthis.y = a.y + b.y;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.addScaledVector = function addScaledVector(v, s) {\n\t\t\tthis.x += v.x * s;\n\t\t\tthis.y += v.y * s;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.sub = function sub(v, w) {\n\t\t\tif (w !== undefined) {\n\t\t\t\tconsole.warn('THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.');\n\t\t\t\treturn this.subVectors(v, w);\n\t\t\t}\n\n\t\t\tthis.x -= v.x;\n\t\t\tthis.y -= v.y;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.subScalar = function subScalar(s) {\n\t\t\tthis.x -= s;\n\t\t\tthis.y -= s;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.subVectors = function subVectors(a, b) {\n\t\t\tthis.x = a.x - b.x;\n\t\t\tthis.y = a.y - b.y;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.multiply = function multiply(v) {\n\t\t\tthis.x *= v.x;\n\t\t\tthis.y *= v.y;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.multiplyScalar = function multiplyScalar(scalar) {\n\t\t\tthis.x *= scalar;\n\t\t\tthis.y *= scalar;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.divide = function divide(v) {\n\t\t\tthis.x /= v.x;\n\t\t\tthis.y /= v.y;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.divideScalar = function divideScalar(scalar) {\n\t\t\treturn this.multiplyScalar(1 / scalar);\n\t\t};\n\n\t\t_proto.applyMatrix3 = function applyMatrix3(m) {\n\t\t\tvar x = this.x,\n\t\t\t\t\ty = this.y;\n\t\t\tvar e = m.elements;\n\t\t\tthis.x = e[0] * x + e[3] * y + e[6];\n\t\t\tthis.y = e[1] * x + e[4] * y + e[7];\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.min = function min(v) {\n\t\t\tthis.x = Math.min(this.x, v.x);\n\t\t\tthis.y = Math.min(this.y, v.y);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.max = function max(v) {\n\t\t\tthis.x = Math.max(this.x, v.x);\n\t\t\tthis.y = Math.max(this.y, v.y);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clamp = function clamp(min, max) {\n\t\t\t// assumes min < max, componentwise\n\t\t\tthis.x = Math.max(min.x, Math.min(max.x, this.x));\n\t\t\tthis.y = Math.max(min.y, Math.min(max.y, this.y));\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clampScalar = function clampScalar(minVal, maxVal) {\n\t\t\tthis.x = Math.max(minVal, Math.min(maxVal, this.x));\n\t\t\tthis.y = Math.max(minVal, Math.min(maxVal, this.y));\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clampLength = function clampLength(min, max) {\n\t\t\tvar length = this.length();\n\t\t\treturn this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));\n\t\t};\n\n\t\t_proto.floor = function floor() {\n\t\t\tthis.x = Math.floor(this.x);\n\t\t\tthis.y = Math.floor(this.y);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.ceil = function ceil() {\n\t\t\tthis.x = Math.ceil(this.x);\n\t\t\tthis.y = Math.ceil(this.y);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.round = function round() {\n\t\t\tthis.x = Math.round(this.x);\n\t\t\tthis.y = Math.round(this.y);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.roundToZero = function roundToZero() {\n\t\t\tthis.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);\n\t\t\tthis.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.negate = function negate() {\n\t\t\tthis.x = -this.x;\n\t\t\tthis.y = -this.y;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.dot = function dot(v) {\n\t\t\treturn this.x * v.x + this.y * v.y;\n\t\t};\n\n\t\t_proto.cross = function cross(v) {\n\t\t\treturn this.x * v.y - this.y * v.x;\n\t\t};\n\n\t\t_proto.lengthSq = function lengthSq() {\n\t\t\treturn this.x * this.x + this.y * this.y;\n\t\t};\n\n\t\t_proto.length = function length() {\n\t\t\treturn Math.sqrt(this.x * this.x + this.y * this.y);\n\t\t};\n\n\t\t_proto.manhattanLength = function manhattanLength() {\n\t\t\treturn Math.abs(this.x) + Math.abs(this.y);\n\t\t};\n\n\t\t_proto.normalize = function normalize() {\n\t\t\treturn this.divideScalar(this.length() || 1);\n\t\t};\n\n\t\t_proto.angle = function angle() {\n\t\t\t// computes the angle in radians with respect to the positive x-axis\n\t\t\tvar angle = Math.atan2(-this.y, -this.x) + Math.PI;\n\t\t\treturn angle;\n\t\t};\n\n\t\t_proto.distanceTo = function distanceTo(v) {\n\t\t\treturn Math.sqrt(this.distanceToSquared(v));\n\t\t};\n\n\t\t_proto.distanceToSquared = function distanceToSquared(v) {\n\t\t\tvar dx = this.x - v.x,\n\t\t\t\t\tdy = this.y - v.y;\n\t\t\treturn dx * dx + dy * dy;\n\t\t};\n\n\t\t_proto.manhattanDistanceTo = function manhattanDistanceTo(v) {\n\t\t\treturn Math.abs(this.x - v.x) + Math.abs(this.y - v.y);\n\t\t};\n\n\t\t_proto.setLength = function setLength(length) {\n\t\t\treturn this.normalize().multiplyScalar(length);\n\t\t};\n\n\t\t_proto.lerp = function lerp(v, alpha) {\n\t\t\tthis.x += (v.x - this.x) * alpha;\n\t\t\tthis.y += (v.y - this.y) * alpha;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.lerpVectors = function lerpVectors(v1, v2, alpha) {\n\t\t\tthis.x = v1.x + (v2.x - v1.x) * alpha;\n\t\t\tthis.y = v1.y + (v2.y - v1.y) * alpha;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.equals = function equals(v) {\n\t\t\treturn v.x === this.x && v.y === this.y;\n\t\t};\n\n\t\t_proto.fromArray = function fromArray(array, offset) {\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tthis.x = array[offset];\n\t\t\tthis.y = array[offset + 1];\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.toArray = function toArray(array, offset) {\n\t\t\tif (array === void 0) {\n\t\t\t\tarray = [];\n\t\t\t}\n\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tarray[offset] = this.x;\n\t\t\tarray[offset + 1] = this.y;\n\t\t\treturn array;\n\t\t};\n\n\t\t_proto.fromBufferAttribute = function fromBufferAttribute(attribute, index, offset) {\n\t\t\tif (offset !== undefined) {\n\t\t\t\tconsole.warn('THREE.Vector2: offset has been removed from .fromBufferAttribute().');\n\t\t\t}\n\n\t\t\tthis.x = attribute.getX(index);\n\t\t\tthis.y = attribute.getY(index);\n\t\t\treturn this;\n\t\t};
1\n\n\t\t_proto.rotateAround = function rotateAround(center, angle) {\n\t\t\tvar c = Math.cos(angle),\n\t\t\t\t\ts = Math.sin(angle);\n\t\t\tvar x = this.x - center.x;\n\t\t\tvar y = this.y - center.y;\n\t\t\tthis.x = x * c - y * s + center.x;\n\t\t\tthis.y = x * s + y * c + center.y;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.random = function random() {\n\t\t\tthis.x = Math.random();\n\t\t\tthis.y = Math.random();\n\t\t\treturn this;\n\t\t};\n\n\t\t_createClass(Vector2, [{\n\t\t\tkey: \"width\",\n\t\t\tget: function get() {\n\t\t\t\treturn this.x;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tthis.x = value;\n\t\t\t}\n\t\t}, {\n\t\t\tkey: \"height\",\n\t\t\tget: function get() {\n\t\t\t\treturn this.y;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tthis.y = value;\n\t\t\t}\n\t\t}]);\n\n\t\treturn Vector2;\n\t}();\n\n\tvar Matrix3 = /*#__PURE__*/function () {\n\t\tfunction Matrix3() {\n\t\t\tObject.defineProperty(this, 'isMatrix3', {\n\t\t\t\tvalue: true\n\t\t\t});\n\t\t\tthis.elements = [1, 0, 0, 0, 1, 0, 0, 0, 1];\n\n\t\t\tif (arguments.length > 0) {\n\t\t\t\tconsole.error('THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.');\n\t\t\t}\n\t\t}\n\n\t\tvar _proto = Matrix3.prototype;\n\n\t\t_proto.set = function set(n11, n12, n13, n21, n22, n23, n31, n32, n33) {\n\t\t\tvar te = this.elements;\n\t\t\tte[0] = n11;\n\t\t\tte[1] = n21;\n\t\t\tte[2] = n31;\n\t\t\tte[3] = n12;\n\t\t\tte[4] = n22;\n\t\t\tte[5] = n32;\n\t\t\tte[6] = n13;\n\t\t\tte[7] = n23;\n\t\t\tte[8] = n33;
1\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.identity = function identity() {\n\t\t\tthis.set(1, 0, 0, 0, 1, 0, 0, 0, 1);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor().fromArray(this.elements);\n\t\t};\n\n\t\t_proto.copy = function copy(m) {\n\t\t\tvar te = this.elements;\n\t\t\tvar me = m.elements;\n\t\t\tte[0] = me[0];\n\t\t\tte[1] = me[1];\n\t\t\tte[2] = me[2];\n\t\t\tte[3] = me[3];\n\t\t\tte[4] = me[4];\n\t\t\tte[5] = me[5];\n\t\t\tte[6] = me[6];\n\t\t\tte[7] = me[7];\n\t\t\tte[8] = me[8];\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.extractBasis = function extractBasis(xAxis, yAxis, zAxis) {\n\t\t\txAxis.setFromMatrix3Column(this, 0);\n\t\t\tyAxis.setFromMatrix3Column(this, 1);\n\t\t\tzAxis.setFromMatrix3Column(this, 2);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromMatrix4 = function setFromMatrix4(m) {\n\t\t\tvar me = m.elements;\n\t\t\tthis.set(me[0], me[4], me[8], me[1], me[5], me[9], me[2], me[6], me[10]);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.multiply = function multiply(m) {\n\t\t\treturn this.multiplyMatrices(this, m);\n\t\t};\n\n\t\t_proto.premultiply = function premultiply(m) {\n\t\t\treturn this.multiplyMatrices(m, this);\n\t\t};\n\n\t\t_proto.multiplyMatrices = function multiplyMatrices(a, b) {\n\t\t\tvar ae = a.elements;\n\t\t\tvar be = b.elements;\n\t\t\tvar te = this.elements;\n\t\t\tvar a11 = ae[0],\n\t\t\t\t\ta12 = ae[3],\n\t\t\t\t\ta13 = ae[6];\n\t\t\tvar a21 = ae[1],\n\t\t\t\t\ta22 = ae[4],\n\t\t\t\t\ta23 = ae[7];\n\t\t\tvar a31 = ae[2],\n\t\t\t\t\ta32 = ae[5],\n\t\t\t\t\ta33 = ae[8];\n\t\t\tvar b11 = be[0],\n\t\t\t\t\tb12 = be[3],\n\t\t\t\t\tb13 = be[6];\n\t\t\tvar b21 = be[1],\n\t\t\t\t\tb22 = be[4],\n\t\t\t\t\tb23 = be[7];\n\t\t\tvar b31 = be[2],\n\t\t\t\t\tb32 = be[5],\n\t\t\t\t\tb33 = be[8];\n\t\t\tte[0] = a11 * b11 + a12 * b21 + a13 * b31;\n\t\t\tte[3] = a11 * b12 + a12 * b22 + a13 * b32;\n\t\t\tte[6] = a11 * b13 + a12 * b23 + a13 * b33;\n\t\t\tte[1] = a21 * b11 + a22 * b21 + a23 * b31;\n\t\t\tte[4] = a21 * b12 + a22 * b22 + a23 * b32;\n\t\t\tte[7] = a21 * b13 + a22 * b23 + a23 * b33;\n\t\t\tte[2] = a31 * b11 + a32 * b21 + a33 * b31;\n\t\t\tte[5] = a31 * b12 + a32 * b22 + a33 * b32;\n\t\t\tte[8] = a31 * b13 + a32 * b23 + a33 * b33;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.multiplyScalar = function multiplyScalar(s) {\n\t\t\tvar te = this.elements;\n\t\t\tte[0] *= s;\n\t\t\tte[3] *= s;\n\t\t\tte[6] *= s;\n\t\t\tte[1] *= s;\n\t\t\tte[4] *= s;\n\t\t\tte[7] *= s;\n\t\t\tte[2] *= s;\n\t\t\tte[5] *= s;\n\t\t\tte[8] *= s;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.determinant = function determinant() {\n\t\t\tvar te = this.elements;\n\t\t\tvar a = te[0],\n\t\t\t\t\tb = te[1],\n\t\t\t\t\tc = te[2],\n\t\t\t\t\td = te[3],\n\t\t\t\t\te = te[4],\n\t\t\t\t\tf = te[5],\n\t\t\t\t\tg = te[6],\n\t\t\t\t\th = te[7],\n\t\t\t\t\ti = te[8];\n\t\t\treturn a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;\n\t\t};\n\n\t\t_proto.invert = function invert() {\n\t\t\tvar te = this.elements,\n\t\t\t\t\tn11 = te[0],\n\t\t\t\t\tn21 = te[1],\n\t\t\t\t\tn31 = te[2],\n\t\t\t\t\tn12 = te[3],\n\t\t\t\t\tn22 = te[4],\n\t\t\t\t\tn32 = te[5],\n\t\t\t\t\tn13 = te[6],\n\t\t\t\t\tn23 = te[7],\n\t\t\t\t\tn33 = te[8],\n\t\t\t\t\tt11 = n33 * n22 - n32 * n23,\n\t\t\t\t\tt12 = n32 * n13 - n33 * n12,\n\t\t\t\t\tt13 = n23 * n12 - n22 * n13,\n\t\t\t\t\tdet = n11 * t11 + n21 * t12 + n31 * t13;\n\t\t\tif (det === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);\n\t\t\tvar detInv = 1 / det;\n\t\t\tte[0] = t11 * detInv;\n\t\t\tte[1] = (n31 * n23 - n33 * n21) * detInv;\n\t\t\tte[2] = (n32 * n21 - n31 * n22) * detInv;\n\t\t\tte[3] = t12 * detInv;\n\t\t\tte[4] = (n33 * n11 - n31 * n13) * detInv;\n\t\t\tte[5] = (n31 * n12 - n32 * n11) * detInv;\n\t\t\tte[6] = t13 * detInv;\n\t\t\tte[7] = (n21 * n13 - n23 * n11) * detInv;\n\t\t\tte[8] = (n22 * n11 - n21 * n12) * detInv;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.transpose = function transpose() {\n\t\t\tvar tmp;\n\t\t\tvar m = this.elements;\n\t\t\ttmp = m[1];\n\t\t\tm[1] = m[3];\n\t\t\tm[3] = tmp;\n\t\t\ttmp = m[2];\n\t\t\tm[2] = m[6];\n\t\t\tm[6] = tmp;\n\t\t\ttmp = m[5];\n\t\t\tm[5] = m[7];\n\t\t\tm[7] = tmp;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.getNormalMatrix = function getNormalMatrix(matrix4) {\n\t\t\treturn this.setFromMatrix4(matrix4).copy(this).invert().transpose();\n\t\t};\n\n\t\t_proto.transposeIntoArray = function transposeIntoArray(r) {\n\t\t\tvar m = this.elements;\n\t\t\tr[0] = m[0];\n\t\t\tr[1] = m[3];\n\t\t\tr[2] = m[6];\n\t\t\tr[3] = m[1];\n\t\t\tr[4] = m[4];\n\t\t\tr[5] = m[7];\n\t\t\tr[6] = m[2];\n\t\t\tr[7] = m[5];\n\t\t\tr[8] = m[8];\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setUvTransform = function setUvTransform(tx, ty, sx, sy, rotation, cx, cy) {\n\t\t\tvar c = Math.cos(rotation);\n\t\t\tvar s = Math.sin(rotation);
1\n\t\t\tthis.set(sx * c, sx * s, -sx * (c * cx + s * cy) + cx + tx, -sy * s, sy * c, -sy * (-s * cx + c * cy) + cy + ty, 0, 0, 1);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.scale = function scale(sx, sy) {\n\t\t\tvar te = this.elements;\n\t\t\tte[0] *= sx;\n\t\t\tte[3] *= sx;\n\t\t\tte[6] *= sx;\n\t\t\tte[1] *= sy;\n\t\t\tte[4] *= sy;\n\t\t\tte[7] *= sy;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.rotate = function rotate(theta) {\n\t\t\tvar c = Math.cos(theta);\n\t\t\tvar s = Math.sin(theta);\n\t\t\tvar te = this.elements;\n\t\t\tvar a11 = te[0],\n\t\t\t\t\ta12 = te[3],\n\t\t\t\t\ta13 = te[6];\n\t\t\tvar a21 = te[1],\n\t\t\t\t\ta22 = te[4],\n\t\t\t\t\ta23 = te[7];\n\t\t\tte[0] = c * a11 + s * a21;\n\t\t\tte[3] = c * a12 + s * a22;\n\t\t\tte[6] = c * a13 + s * a23;\n\t\t\tte[1] = -s * a11 + c * a21;\n\t\t\tte[4] = -s * a12 + c * a22;\n\t\t\tte[7] = -s * a13 + c * a23;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.translate = function translate(tx, ty) {\n\t\t\tvar te = this.elements;\n\t\t\tte[0] += tx * te[2];\n\t\t\tte[3] += tx * te[5];\n\t\t\tte[6] += tx * te[8];\n\t\t\tte[1] += ty * te[2];\n\t\t\tte[4] += ty * te[5];\n\t\t\tte[7] += ty * te[8];\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.equals = function equals(matrix) {\n\t\t\tvar te = this.elements;\n\t\t\tvar me = matrix.elements;\n\n\t\t\tfor (var i = 0; i < 9; i++) {\n\t\t\t\tif (te[i] !== me[i]) return false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t};\n\n\t\t_proto.fromArray = function fromArray(array, offset) {\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tfor (var i = 0; i < 9; i++) {\n\t\t\t\tthis.elements[i] = array[i + offset];\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.toArray = function toArray(array, offset) {\n\t\t\tif (array === void 0) {\n\t\t\t\tarray = [];\n\t\t\t}\n\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tvar te = this.elements;\n\t\t\tarray[offset] = te[0];\n\t\t\tarray[offset + 1] = te[1];\n\t\t\tarray[offset + 2] = te[2];\n\t\t\tarray[offset + 3] = te[3];\n\t\t\tarray[offset + 4] = te[4];\n\t\t\tarray[offset + 5] = te[5];\n\t\t\tarray[offset + 6] = te[6];\n\t\t\tarray[offset + 7] = te[7];\n\t\t\tarray[offset + 8] = te[8];\n\t\t\treturn array;\n\t\t};\n\n\t\treturn Matrix3;\n\t}();\n\n\tvar _canvas;\n\n\tvar ImageUtils = {\n\t\tgetDataURL: function getDataURL(image) {\n\t\t\tif (/^data:/i.test(image.src)) {\n\t\t\t\treturn image.src;\n\t\t\t}\n\n\t\t\tif (typeof HTMLCanvasElement == 'undefined') {\n\t\t\t\treturn image.src;\n\t\t\t}\n\n\t\t\tvar canvas;\n\n\t\t\tif (image instanceof HTMLCanvasElement) {\n\t\t\t\tcanvas = image;\n\t\t\t} else {\n\t\t\t\tif (_canvas === undefined) _canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');\n\t\t\t\t_canvas.width = image.width;\n\t\t\t\t_canvas.height = image.height;\n\n\t\t\t\tvar context = _canvas.getContext('2d');\n\n\t\t\t\tif (image instanceof ImageData) {\n\t\t\t\t\tcontext.putImageData(image, 0, 0);\n\t\t\t\t} else {\n\t\t\t\t\tcontext.drawImage(image, 0, 0, image.width, image.height);\n\t\t\t\t}\n\n\t\t\t\tcanvas = _canvas;\n\t\t\t}\n\n\t\t\tif (canvas.width > 2048 || canvas.height > 2048) {\n\t\t\t\treturn canvas.toDataURL('image/jpeg', 0.6);\n\t\t\t} else {\n\t\t\t\treturn canvas.toDataURL('image/png');\n\t\t\t}\n\t\t}\n\t};\n\n\tvar textureId = 0;\n\n\tfunction Texture(image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding) {\n\t\tif (image === void 0) {\n\t\t\timage = Texture.DEFAULT_IMAGE;\n\t\t}\n\n\t\tif (mapping === void 0) {\n\t\t\tmapping = Texture.DEFAULT_MAPPING;\n\t\t}\n\n\t\tif (wrapS === void 0) {\n\t\t\twrapS = ClampToEdgeWrapping;\n\t\t}\n\n\t\tif (wrapT === void 0) {\n\t\t\twrapT = ClampToEdgeWrapping;\n\t\t}\n\n\t\tif (magFilter === void 0) {\n\t\t\tmagFilter = LinearFilter;\n\t\t}\n\n\t\tif (minFilter === void 0) {\n\t\t\tminFilter = LinearMipmapLinearFilter;\n\t\t}\n\n\t\tif (format === void 0) {\n\t\t\tformat = RGBAFormat;\n\t\t}\n\n\t\tif (type === void 0) {\n\t\t\ttype = UnsignedByteType;\n\t\t}\n\n\t\tif (anisotropy === void 0) {\n\t\t\tanisotropy = 1;\n\t\t}\n\n\t\tif (encoding === void 0) {\n\t\t\tencoding = LinearEncoding;\n\t\t}\n\n\t\tObject.defineProperty(this, 'id', {\n\t\t\tvalue: textureId++\n\t\t});\n\t\tthis.uuid = MathUtils.generateUUID();\n\t\tthis.name = '';\n\t\tthis.image = image;\n\t\tthis.mipmaps = [];\n\t\tthis.mapping = mapping;\n\t\tthis.wrapS = wrapS;\n\t\tthis.wrapT = wrapT;\n\t\tthis.magFilter = magFilter;\n\t\tthis.minFilter = minFilter;\n\t\tthis.anisotropy = anisotropy;\n\t\tthis.format = format;\n\t\tthis.internalFormat = null;\n\t\tthis.type = type;\n\t\tthis.offset = new Vector2(0, 0);\n\t\tthis.repeat = new Vector2(1, 1);\n\t\tthis.center = new Vector2(0, 0);\n\t\tthis.rotation = 0;\n\t\tthis.matrixAutoUpdate = true;\n\t\tthis.matrix = new Matrix3();\n\t\tthis.generateMipmaps = true;\n\t\tthis.premultiplyAlpha = false;\n\t\tthis.flipY = true;\n\t\tthis.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)\n\t\t// Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap.\n\t\t//\n\t\t// Also changing the encoding after already used by a Material will not automatically make the Material\n\t\t// update. You need to explicitly call Material.needsUpdate to trigger it to recompile.\n\n\t\tthis.encoding = encoding;\n\t\tthis.version = 0;\n\t\tthis.onUpdate = null;\n\t}\n\n\tTexture.DEFAULT_IMAGE = undefined;\n\tTexture.DEFAULT_MAPPING = UVMapping;\n\tTexture.prototype = Object.assign(Object.create(EventDispatcher.prototype), {\n\t\tconstructor: Texture,\n\t\tisTexture: true,\n\t\tupdateMatrix: function updateMatrix() {\n\t\t\tthis.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);\n\t\t},\n\t\tclone: function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t},\n\t\tcopy: function copy(source) {\n\t\t\tthis.name = source.name;\n\t\t\tthis.image = source.image;\n\t\t\tthis.mipmaps = source.mipmaps.slice(0);
1\n\t\t\tthis.mapping = source.mapping;\n\t\t\tthis.wrapS = source.wrapS;\n\t\t\tthis.wrapT = source.wrapT;\n\t\t\tthis.magFilter = source.magFilter;\n\t\t\tthis.minFilter = source.minFilter;\n\t\t\tthis.anisotropy = source.anisotropy;\n\t\t\tthis.format = source.format;\n\t\t\tthis.internalFormat = source.internalFormat;\n\t\t\tthis.type = source.type;\n\t\t\tthis.offset.copy(source.offset);\n\t\t\tthis.repeat.copy(source.repeat);\n\t\t\tthis.center.copy(source.center);\n\t\t\tthis.rotation = source.rotation;\n\t\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\t\t\tthis.matrix.copy(source.matrix);\n\t\t\tthis.generateMipmaps = source.generateMipmaps;\n\t\t\tthis.premultiplyAlpha = source.premultiplyAlpha;\n\t\t\tthis.flipY = source.flipY;\n\t\t\tthis.unpackAlignment = source.unpackAlignment;\n\t\t\tthis.encoding = source.encoding;\n\t\t\treturn this;\n\t\t},\n\t\ttoJSON: function toJSON(meta) {\n\t\t\tvar isRootObject = meta === undefined || typeof meta === 'string';\n\n\t\t\tif (!isRootObject && meta.textures[this.uuid] !== undefined) {\n\t\t\t\treturn meta.textures[this.uuid];\n\t\t\t}\n\n\t\t\tvar output = {\n\t\t\t\tmetadata: {\n\t\t\t\t\tversion: 4.5,\n\t\t\t\t\ttype: 'Texture',\n\t\t\t\t\tgenerator: 'Texture.toJSON'\n\t\t\t\t},\n\t\t\t\tuuid: this.uuid,\n\t\t\t\tname: this.name,\n\t\t\t\tmapping: this.mapping,\n\t\t\t\trepeat: [this.repeat.x, this.repeat.y],\n\t\t\t\toffset: [this.offset.x, this.offset.y],\n\t\t\t\tcenter: [this.center.x, this.center.y],\n\t\t\t\trotation: this.rotation,\n\t\t\t\twrap: [this.wrapS, this.wrapT],\n\t\t\t\tformat: this.format,\n\t\t\t\ttype: this.type,\n\t\t\t\tencoding: this.encoding,\n\t\t\t\tminFilter: this.minFilter,\n\t\t\t\tmagFilter: this.magFilter,\n\t\t\t\tanisotropy: this.anisotropy,\n\t\t\t\tflipY: this.flipY,\n\t\t\t\tpremultiplyAlpha: this.premultiplyAlpha,\n\t\t\t\tunpackAlignment: this.unpackAlignment\n\t\t\t};\n\n\t\t\tif (this.image !== undefined) {\n\t\t\t\t// TODO: Move to THREE.Image\n\t\t\t\tvar image = this.image;\n\n\t\t\t\tif (image.uuid === undefined) {\n\t\t\t\t\timage.uuid = MathUtils.generateUUID(); // UGH\n\t\t\t\t}\n\n\t\t\t\tif (!isRootObject && meta.images[image.uuid] === undefined) {\n\t\t\t\t\tvar url;\n\n\t\t\t\t\tif (Array.isArray(image)) {\n\t\t\t\t\t\t// process array of images e.g. CubeTexture\n\t\t\t\t\t\turl = [];\n\n\t\t\t\t\t\tfor (var i = 0, l = image.length; i < l; i++) {\n\t\t\t\t\t\t\t// check cube texture with data textures\n\t\t\t\t\t\t\tif (image[i].isDataTexture) {\n\t\t\t\t\t\t\t\turl.push(serializeImage(image[i].image));\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\turl.push(serializeImage(image[i]));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// process single image\n\t\t\t\t\t\turl = serializeImage(image);\n\t\t\t\t\t}\n\n\t\t\t\t\tmeta.images[image.uuid] = {\n\t\t\t\t\t\tuuid: image.uuid,\n\t\t\t\t\t\turl: url\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\toutput.image = image.uuid;\n\t\t\t}\n\n\t\t\tif (!isRootObject) {\n\t\t\t\tmeta.textures[this.uuid] = output;\n\t\t\t}\n\n\t\t\treturn output;\n\t\t},\n\t\tdispose: function dispose() {\n\t\t\tthis.dispatchEvent({\n\t\t\t\ttype: 'dispose'\n\t\t\t});\n\t\t},\n\t\ttransformUv: function transformUv(uv) {\n\t\t\tif (this.mapping !== UVMapping) return uv;\n\t\t\tuv.applyMatrix3(this.matrix);\n\n\t\t\tif (uv.x < 0 || uv.x > 1) {\n\t\t\t\tswitch (this.wrapS) {\n\t\t\t\t\tcase RepeatWrapping:\n\t\t\t\t\t\tuv.x = uv.x - Math.floor(uv.x);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase ClampToEdgeWrapping:\n\t\t\t\t\t\tuv.x = uv.x < 0 ? 0 : 1;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase MirroredRepeatWrapping:\n\t\t\t\t\t\tif (Math.abs(Math.floor(uv.x) % 2) === 1) {\n\t\t\t\t\t\t\tuv.x = Math.ceil(uv.x) - uv.x;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tuv.x = uv.x - Math.floor(uv.x);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (uv.y < 0 || uv.y > 1) {\n\t\t\t\tswitch (this.wrapT) {\n\t\t\t\t\tcase RepeatWrapping:\n\t\t\t\t\t\tuv.y = uv.y - Math.floor(uv.y);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase ClampToEdgeWrapping:\n\t\t\t\t\t\tuv.y = uv.y < 0 ? 0 : 1;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase MirroredRepeatWrapping:\n\t\t\t\t\t\tif (Math.abs(Math.floor(uv.y) % 2) === 1) {\n\t\t\t\t\t\t\tuv.y = Math.ceil(uv.y) - uv.y;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tuv.y = uv.y - Math.floor(uv.y);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.flipY) {\n\t\t\t\tuv.y = 1 - uv.y;\n\t\t\t}\n\n\t\t\treturn uv;\n\t\t}\n\t});\n\tObject.defineProperty(Texture.prototype, 'needsUpdate', {\n\t\tset: function set(value) {\n\t\t\tif (value === true) this.version++;\n\t\t}\n\t});\n\n\tfunction serializeImage(image) {\n\t\tif (typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement || typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement || typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap) {\n\t\t\t// default images\n\t\t\treturn ImageUtils.getDataURL(image);\n\t\t} else {\n\t\t\tif (image.data) {\n\t\t\t\t// images of DataTexture\n\t\t\t\treturn {\n\t\t\t\t\tdata: Array.prototype.slice.call(image.data),\n\t\t\t\t\twidth: image.width,\n\t\t\t\t\theight: image.height,\n\t\t\t\t\ttype: image.data.constructor.name\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tconsole.warn('THREE.Texture: Unable to serialize Texture.');\n\t\t\t\treturn {};\n\t\t\t}\n\t\t}\n\t}\n\n\tvar Vector4 = /*#__PURE__*/function () {\n\t\tfunction Vector4(x, y, z, w) {\n\t\t\tif (x === void 0) {\n\t\t\t\tx = 0;\n\t\t\t}\n\n\t\t\tif (y === void 0) {\n\t\t\t\ty = 0;\n\t\t\t}\n\n\t\t\tif (z === void 0) {\n\t\t\t\tz = 0;\n\t\t\t}\n\n\t\t\tif (w === void 0) {\n\t\t\t\tw = 1;\n\t\t\t}\n\n\t\t\tObject.defineProperty(this, 'isVector4', {\n\t\t\t\tvalue: true\n\t\t\t});\n\t\t\tthis.x = x;\n\t\t\tthis.y = y;\n\t\t\tthis.z = z;\n\t\t\tthis.w = w;\n\t\t}\n\n\t\tvar _proto = Vector4.prototype;\n\n\t\t_proto.set = function set(x, y, z, w) {\n\t\t\tthis.x = x;\n\t\t\tthis.y = y;\n\t\t\tthis.z = z;\n\t\t\tthis.w = w;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setScalar = function setScalar(scalar) {\n\t\t\tthis.x = scalar;\n\t\t\tthis.y = scalar;\n\t\t\tthis.z = scalar;\n\t\t\tthis.w = scalar;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setX = function setX(x) {\n\t\t\tthis.x = x;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setY = function setY(y) {\n\t\t\tthis.y = y;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setZ = function setZ(z) {\n\t\t\tthis.z = z;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setW = function setW(w) {\n\t\t\tthis.w = w;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setComponent = function setComponent(index, value) {\n\t\t\tswitch (index) {\n\t\t\t\tcase 0:\n\t\t\t\t\tthis.x = value;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 1:\n\t\t\t\t\tthis.y = value;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 2:\n\t\t\t\t\tthis.z = value;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 3:\n\t\t\t\t\tthis.w = value;\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error('index is out of range: ' + index);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.getComponent = function getComponent(index) {\n\t\t\tswitch (index) {\n\t\t\t\tcase 0:\n\t\t\t\t\treturn this.x;\n\n\t\t\t\tcase 1:\n\t\t\t\t\treturn this.y;\n\n\t\t\t\tcase 2:\n\t\t\t\t\treturn this.z;\n\n\t\t\t\tcase 3:\n\t\t\t\t\treturn this.w;\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error('index is out of range: ' + index);\n\t\t\t}\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor(this.x, this.y, this.z, this.w);\n\t\t};\n\n\t\t_proto.copy = function copy(v) {\n\t\t\tthis.x = v.x;\n\t\t\tthis.y = v.y;\n\t\t\tthis.z = v.z;\n\t\t\tthis.w = v.w !== undefined ? v.w : 1;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.add = function add(v, w) {\n\t\t\tif (w !== undefined) {\n\t\t\t\tconsole.warn('THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.');\n\t\t\t\treturn this.addVectors(v, w);\n\t\t\t}\n\n\t\t\tthis.x += v.x;\n\t\t\tthis.y += v.y;\n\t\t\tthis.z += v.z;\n\t\t\tthis.w += v.w;\n\t\t\treturn this;\n\t\t};
1\n\n\t\t_proto.addScalar = function addScalar(s) {\n\t\t\tthis.x += s;\n\t\t\tthis.y += s;\n\t\t\tthis.z += s;\n\t\t\tthis.w += s;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.addVectors = function addVectors(a, b) {\n\t\t\tthis.x = a.x + b.x;\n\t\t\tthis.y = a.y + b.y;\n\t\t\tthis.z = a.z + b.z;\n\t\t\tthis.w = a.w + b.w;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.addScaledVector = function addScaledVector(v, s) {\n\t\t\tthis.x += v.x * s;\n\t\t\tthis.y += v.y * s;\n\t\t\tthis.z += v.z * s;\n\t\t\tthis.w += v.w * s;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.sub = function sub(v, w) {\n\t\t\tif (w !== undefined) {\n\t\t\t\tconsole.warn('THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.');\n\t\t\t\treturn this.subVectors(v, w);\n\t\t\t}\n\n\t\t\tthis.x -= v.x;\n\t\t\tthis.y -= v.y;\n\t\t\tthis.z -= v.z;\n\t\t\tthis.w -= v.w;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.subScalar = function subScalar(s) {\n\t\t\tthis.x -= s;\n\t\t\tthis.y -= s;\n\t\t\tthis.z -= s;\n\t\t\tthis.w -= s;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.subVectors = function subVectors(a, b) {\n\t\t\tthis.x = a.x - b.x;\n\t\t\tthis.y = a.y - b.y;\n\t\t\tthis.z = a.z - b.z;\n\t\t\tthis.w = a.w - b.w;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.multiplyScalar = function multiplyScalar(scalar) {\n\t\t\tthis.x *= scalar;\n\t\t\tthis.y *= scalar;\n\t\t\tthis.z *= scalar;\n\t\t\tthis.w *= scalar;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.applyMatrix4 = function applyMatrix4(m) {\n\t\t\tvar x = this.x,\n\t\t\t\t\ty = this.y,\n\t\t\t\t\tz = this.z,\n\t\t\t\t\tw = this.w;\n\t\t\tvar e = m.elements;\n\t\t\tthis.x = e[0] * x + e[4] * y + e[8] * z + e[12] * w;\n\t\t\tthis.y = e[1] * x + e[5] * y + e[9] * z + e[13] * w;\n\t\t\tthis.z = e[2] * x + e[6] * y + e[10] * z + e[14] * w;\n\t\t\tthis.w = e[3] * x + e[7] * y + e[11] * z + e[15] * w;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.divideScalar = function divideScalar(scalar) {\n\t\t\treturn this.multiplyScalar(1 / scalar);\n\t\t};\n\n\t\t_proto.setAxisAngleFromQuaternion = function setAxisAngleFromQuaternion(q) {\n\t\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm\n\t\t\t// q is assumed to be normalized\n\t\t\tthis.w = 2 * Math.acos(q.w);\n\t\t\tvar s = Math.sqrt(1 - q.w * q.w);\n\n\t\t\tif (s < 0.0001) {\n\t\t\t\tthis.x = 1;\n\t\t\t\tthis.y = 0;\n\t\t\t\tthis.z = 0;\n\t\t\t} else {\n\t\t\t\tthis.x = q.x / s;\n\t\t\t\tthis.y = q.y / s;\n\t\t\t\tthis.z = q.z / s;\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setAxisAngleFromRotationMatrix = function setAxisAngleFromRotationMatrix(m) {\n\t\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm\n\t\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\t\t\tvar angle, x, y, z; // variables for result\n\n\t\t\tvar epsilon = 0.01,\n\t\t\t\t\t// margin to allow for rounding errors\n\t\t\tepsilon2 = 0.1,\n\t\t\t\t\t// margin to distinguish between 0 and 180 degrees\n\t\t\tte = m.elements,\n\t\t\t\t\tm11 = te[0],\n\t\t\t\t\tm12 = te[4],\n\t\t\t\t\tm13 = te[8],\n\t\t\t\t\tm21 = te[1],\n\t\t\t\t\tm22 = te[5],\n\t\t\t\t\tm23 = te[9],\n\t\t\t\t\tm31 = te[2],\n\t\t\t\t\tm32 = te[6],\n\t\t\t\t\tm33 = te[10];\n\n\t\t\tif (Math.abs(m12 - m21) < epsilon && Math.abs(m13 - m31) < epsilon && Math.abs(m23 - m32) < epsilon) {\n\t\t\t\t// singularity found\n\t\t\t\t// first check for identity matrix which must have +1 for all terms\n\t\t\t\t// in leading diagonal and zero in other terms\n\t\t\t\tif (Math.abs(m12 + m21) < epsilon2 && Math.abs(m13 + m31) < epsilon2 && Math.abs(m23 + m32) < epsilon2 && Math.abs(m11 + m22 + m33 - 3) < epsilon2) {\n\t\t\t\t\t// this singularity is identity matrix so angle = 0\n\t\t\t\t\tthis.set(1, 0, 0, 0);\n\t\t\t\t\treturn this; // zero angle, arbitrary axis\n\t\t\t\t} // otherwise this singularity is angle = 180\n\n\n\t\t\t\tangle = Math.PI;\n\t\t\t\tvar xx = (m11 + 1) / 2;\n\t\t\t\tvar yy = (m22 + 1) / 2;\n\t\t\t\tvar zz = (m33 + 1) / 2;\n\t\t\t\tvar xy = (m12 + m21) / 4;\n\t\t\t\tvar xz = (m13 + m31) / 4;\n\t\t\t\tvar yz = (m23 + m32) / 4;\n\n\t\t\t\tif (xx > yy && xx > zz) {\n\t\t\t\t\t// m11 is the largest diagonal term\n\t\t\t\t\tif (xx < epsilon) {\n\t\t\t\t\t\tx = 0;\n\t\t\t\t\t\ty = 0.707106781;\n\t\t\t\t\t\tz = 0.707106781;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tx = Math.sqrt(xx);\n\t\t\t\t\t\ty = xy / x;\n\t\t\t\t\t\tz = xz / x;\n\t\t\t\t\t}\n\t\t\t\t} else if (yy > zz) {\n\t\t\t\t\t// m22 is the largest diagonal term\n\t\t\t\t\tif (yy < epsilon) {\n\t\t\t\t\t\tx = 0.707106781;\n\t\t\t\t\t\ty = 0;\n\t\t\t\t\t\tz = 0.707106781;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ty = Math.sqrt(yy);\n\t\t\t\t\t\tx = xy / y;\n\t\t\t\t\t\tz = yz / y;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// m33 is the largest diagonal term so base result on this\n\t\t\t\t\tif (zz < epsilon) {\n\t\t\t\t\t\tx = 0.707106781;\n\t\t\t\t\t\ty = 0.707106781;\n\t\t\t\t\t\tz = 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tz = Math.sqrt(zz);\n\t\t\t\t\t\tx = xz / z;\n\t\t\t\t\t\ty = yz / z;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.set(x, y, z, angle);\n\t\t\t\treturn this; // return 180 deg rotation\n\t\t\t} // as we have reached here there are no singularities so we can handle normally\n\n\n\t\t\tvar s = Math.sqrt((m32 - m23) * (m32 - m23) + (m13 - m31) * (m13 - m31) + (m21 - m12) * (m21 - m12)); // used to normalize\n\n\t\t\tif (Math.abs(s) < 0.001) s = 1; // prevent divide by zero, should not happen if matrix is orthogonal and should be\n\t\t\t// caught by singularity test above, but I've left it in just in case\n\n\t\t\tthis.x = (m32 - m23) / s;\n\t\t\tthis.y = (m13 - m31) / s;\n\t\t\tthis.z = (m21 - m12) / s;\n\t\t\tthis.w = Math.acos((m11 + m22 + m33 - 1) / 2);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.min = function min(v) {\n\t\t\tthis.x = Math.min(this.x, v.x);\n\t\t\tthis.y = Math.min(this.y, v.y);\n\t\t\tthis.z = Math.min(this.z, v.z);\n\t\t\tthis.w = Math.min(this.w, v.w);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.max = function max(v) {\n\t\t\tthis.x = Math.max(this.x, v.x);\n\t\t\tthis.y = Math.max(this.y, v.y);\n\t\t\tthis.z = Math.max(this.z, v.z);\n\t\t\tthis.w = Math.max(this.w, v.w);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clamp = function clamp(min, max) {\n\t\t\t// assumes min < max, componentwise\n\t\t\tthis.x = Math.max(min.x, Math.min(max.x, this.x));\n\t\t\tthis.y = Math.max(min.y, Math.min(max.y, this.y));\n\t\t\tthis.z = Math.max(min.z, Math.min(max.z, this.z));\n\t\t\tthis.w = Math.max(min.w, Math.min(max.w, this.w));\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clampScalar = function clampScalar(minVal, maxVal) {\n\t\t\tthis.x = Math.max(minVal, Math.min(maxVal, this.x));\n\t\t\tthis.y = Math.max(minVal, Math.min(maxVal, this.y));\n\t\t\tthis.z = Math.max(minVal, Math.min(maxVal, this.z));\n\t\t\tthis.w = Math.max(minVal, Math.min(maxVal, this.w));\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clampLength = function clampLength(min, max) {\n\t\t\tvar length = this.length();\n\t\t\treturn this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));\n\t\t};\n\n\t\t_proto.floor = function floor() {\n\t\t\tthis.x = Math.floor(this.x);\n\t\t\tthis.y = Math.floor(this.y);\n\t\t\tthis.z = Math.floor(this.z);\n\t\t\tthis.w = Math.floor(this.w);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.ceil = function ceil() {\n\t\t\tthis.x = Math.ceil(this.x);\n\t\t\tthis.y = Math.ceil(this.y);
1\n\t\t\tthis.z = Math.ceil(this.z);\n\t\t\tthis.w = Math.ceil(this.w);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.round = function round() {\n\t\t\tthis.x = Math.round(this.x);\n\t\t\tthis.y = Math.round(this.y);\n\t\t\tthis.z = Math.round(this.z);\n\t\t\tthis.w = Math.round(this.w);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.roundToZero = function roundToZero() {\n\t\t\tthis.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);\n\t\t\tthis.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);\n\t\t\tthis.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z);\n\t\t\tthis.w = this.w < 0 ? Math.ceil(this.w) : Math.floor(this.w);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.negate = function negate() {\n\t\t\tthis.x = -this.x;\n\t\t\tthis.y = -this.y;\n\t\t\tthis.z = -this.z;\n\t\t\tthis.w = -this.w;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.dot = function dot(v) {\n\t\t\treturn this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;\n\t\t};\n\n\t\t_proto.lengthSq = function lengthSq() {\n\t\t\treturn this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;\n\t\t};\n\n\t\t_proto.length = function length() {\n\t\t\treturn Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);\n\t\t};\n\n\t\t_proto.manhattanLength = function manhattanLength() {\n\t\t\treturn Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w);\n\t\t};\n\n\t\t_proto.normalize = function normalize() {\n\t\t\treturn this.divideScalar(this.length() || 1);\n\t\t};\n\n\t\t_proto.setLength = function setLength(length) {\n\t\t\treturn this.normalize().multiplyScalar(length);\n\t\t};\n\n\t\t_proto.lerp = function lerp(v, alpha) {\n\t\t\tthis.x += (v.x - this.x) * alpha;\n\t\t\tthis.y += (v.y - this.y) * alpha;\n\t\t\tthis.z += (v.z - this.z) * alpha;\n\t\t\tthis.w += (v.w - this.w) * alpha;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.lerpVectors = function lerpVectors(v1, v2, alpha) {\n\t\t\tthis.x = v1.x + (v2.x - v1.x) * alpha;\n\t\t\tthis.y = v1.y + (v2.y - v1.y) * alpha;\n\t\t\tthis.z = v1.z + (v2.z - v1.z) * alpha;\n\t\t\tthis.w = v1.w + (v2.w - v1.w) * alpha;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.equals = function equals(v) {\n\t\t\treturn v.x === this.x && v.y === this.y && v.z === this.z && v.w === this.w;\n\t\t};\n\n\t\t_proto.fromArray = function fromArray(array, offset) {\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tthis.x = array[offset];\n\t\t\tthis.y = array[offset + 1];\n\t\t\tthis.z = array[offset + 2];\n\t\t\tthis.w = array[offset + 3];\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.toArray = function toArray(array, offset) {\n\t\t\tif (array === void 0) {\n\t\t\t\tarray = [];\n\t\t\t}\n\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tarray[offset] = this.x;\n\t\t\tarray[offset + 1] = this.y;\n\t\t\tarray[offset + 2] = this.z;\n\t\t\tarray[offset + 3] = this.w;\n\t\t\treturn array;\n\t\t};\n\n\t\t_proto.fromBufferAttribute = function fromBufferAttribute(attribute, index, offset) {\n\t\t\tif (offset !== undefined) {\n\t\t\t\tconsole.warn('THREE.Vector4: offset has been removed from .fromBufferAttribute().');\n\t\t\t}\n\n\t\t\tthis.x = attribute.getX(index);\n\t\t\tthis.y = attribute.getY(index);\n\t\t\tthis.z = attribute.getZ(index);\n\t\t\tthis.w = attribute.getW(index);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.random = function random() {\n\t\t\tthis.x = Math.random();\n\t\t\tthis.y = Math.random();\n\t\t\tthis.z = Math.random();\n\t\t\tthis.w = Math.random();\n\t\t\treturn this;\n\t\t};\n\n\t\t_createClass(Vector4, [{\n\t\t\tkey: \"width\",\n\t\t\tget: function get() {\n\t\t\t\treturn this.z;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tthis.z = value;\n\t\t\t}\n\t\t}, {\n\t\t\tkey: \"height\",\n\t\t\tget: function get() {\n\t\t\t\treturn this.w;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tthis.w = value;\n\t\t\t}\n\t\t}]);\n\n\t\treturn Vector4;\n\t}();\n\n\t/*\n\t In options, we can specify:\n\t * Texture parameters for an auto-generated target texture\n\t * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers\n\t*/\n\n\tfunction WebGLRenderTarget(width, height, options) {\n\t\tthis.width = width;\n\t\tthis.height = height;\n\t\tthis.scissor = new Vector4(0, 0, width, height);\n\t\tthis.scissorTest = false;\n\t\tthis.viewport = new Vector4(0, 0, width, height);\n\t\toptions = options || {};\n\t\tthis.texture = new Texture(undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding);\n\t\tthis.texture.image = {};\n\t\tthis.texture.image.width = width;\n\t\tthis.texture.image.height = height;\n\t\tthis.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;\n\t\tthis.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;\n\t\tthis.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;\n\t\tthis.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false;\n\t\tthis.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;\n\t}\n\n\tWebGLRenderTarget.prototype = Object.assign(Object.create(EventDispatcher.prototype), {\n\t\tconstructor: WebGLRenderTarget,\n\t\tisWebGLRenderTarget: true,\n\t\tsetSize: function setSize(width, height) {\n\t\t\tif (this.width !== width || this.height !== height) {\n\t\t\t\tthis.width = width;\n\t\t\t\tthis.height = height;\n\t\t\t\tthis.texture.image.width = width;\n\t\t\t\tthis.texture.image.height = height;\n\t\t\t\tthis.dispose();\n\t\t\t}\n\n\t\t\tthis.viewport.set(0, 0, width, height);\n\t\t\tthis.scissor.set(0, 0, width, height);\n\t\t},\n\t\tclone: function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t},\n\t\tcopy: function copy(source) {\n\t\t\tthis.width = source.width;\n\t\t\tthis.height = source.height;\n\t\t\tthis.viewport.copy(source.viewport);\n\t\t\tthis.texture = source.texture.clone();\n\t\t\tthis.depthBuffer = source.depthBuffer;\n\t\t\tthis.stencilBuffer = source.stencilBuffer;\n\t\t\tthis.depthTexture = source.depthTexture;\n\t\t\treturn this;\n\t\t},\n\t\tdispose: function dispose() {\n\t\t\tthis.dispatchEvent({\n\t\t\t\ttype: 'dispose'\n\t\t\t});\n\t\t}\n\t});\n\n\tfunction WebGLMultisampleRenderTarget(width, height, options) {\n\t\tWebGLRenderTarget.call(this, width, height, options);\n\t\tthis.samples = 4;\n\t}\n\n\tWebGLMultisampleRenderTarget.prototype = Object.assign(Object.create(WebGLRenderTarget.prototype), {\n\t\tconstructor: WebGLMultisampleRenderTarget,\n\t\tisWebGLMultisampleRenderTarget: true,\n\t\tcopy: function copy(source) {\n\t\t\tWebGLRenderTarget.prototype.copy.call(this, source);\n\t\t\tthis.samples = source.samples;\n\t\t\treturn this;\n\t\t}\n\t});\n\n\tvar Quaternion = /*#__PURE__*/function () {\n\t\tfunction Quaternion(x, y, z, w) {\n\t\t\tif (x === void 0) {\n\t\t\t\tx = 0;\n\t\t\t}\n\n\t\t\tif (y === void 0) {\n\t\t\t\ty = 0;\n\t\t\t}\n\n\t\t\tif (z === void 0) {\n\t\t\t\tz = 0;\n\t\t\t}\n\n\t\t\tif (w === void 0) {\n\t\t\t\tw = 1;\n\t\t\t}\n\n\t\t\tObject.defineProperty(this, 'isQuaternion', {\n\t\t\t\tvalue: true\n\t\t\t});\n\t\t\tthis._x = x;\n\t\t\tthis._y = y;\n\t\t\tthis._z = z;\n\t\t\tthis._w = w;\n\t\t}\n\n\t\tQuaternion.slerp = function slerp(qa, qb, qm, t) {\n\t\t\treturn qm.copy(qa).slerp(qb, t);\n\t\t};\n\n\t\tQuaternion.slerpFlat = function slerpFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t) {\n\t\t\t// fuzz-free, array-based Quaternion SLERP operation\n\t\t\tvar x0 = src0[srcOffset0 + 0],\n\t\t\t\t\ty0 = src0[srcOffset0 + 1],\n\t\t\t\t\tz0 = src0[srcOffset0 + 2],\n\t\t\t\t\tw0 = src0[srcOffset0 + 3];\n\t\t\tvar x1 = src1[srcOffset1 + 0],\n\t\t\t\t\ty1 = src1[srcOffset1 + 1],\n\t\t\t\t\tz1 = src1[srcOffset1 + 2],\n\t\t\t\t\tw1 = src1[srcOffset1 + 3];\n\n\t\t\tif (w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1) {\n\t\t\t\tvar s = 1 - t;\n\t\t\t\tvar cos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1,\n\t\t\t\t\t\tdir = cos >= 0 ? 1 : -1,\n\t\t\t\t\t\tsqrSin = 1 - cos * cos; // Skip the Slerp for tiny steps to avoid numeric problems:\n\n\t\t\t\tif (sqrSin > Number.EPSILON) {\n\t\t\t\t\tvar sin = Math.sqrt(sqrSin),\n\t\t\t\t\t\t\tlen = Math.atan2(sin, c
1os * dir);\n\t\t\t\t\ts = Math.sin(s * len) / sin;\n\t\t\t\t\tt = Math.sin(t * len) / sin;\n\t\t\t\t}\n\n\t\t\t\tvar tDir = t * dir;\n\t\t\t\tx0 = x0 * s + x1 * tDir;\n\t\t\t\ty0 = y0 * s + y1 * tDir;\n\t\t\t\tz0 = z0 * s + z1 * tDir;\n\t\t\t\tw0 = w0 * s + w1 * tDir; // Normalize in case we just did a lerp:\n\n\t\t\t\tif (s === 1 - t) {\n\t\t\t\t\tvar f = 1 / Math.sqrt(x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0);\n\t\t\t\t\tx0 *= f;\n\t\t\t\t\ty0 *= f;\n\t\t\t\t\tz0 *= f;\n\t\t\t\t\tw0 *= f;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdst[dstOffset] = x0;\n\t\t\tdst[dstOffset + 1] = y0;\n\t\t\tdst[dstOffset + 2] = z0;\n\t\t\tdst[dstOffset + 3] = w0;\n\t\t};\n\n\t\tQuaternion.multiplyQuaternionsFlat = function multiplyQuaternionsFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1) {\n\t\t\tvar x0 = src0[srcOffset0];\n\t\t\tvar y0 = src0[srcOffset0 + 1];\n\t\t\tvar z0 = src0[srcOffset0 + 2];\n\t\t\tvar w0 = src0[srcOffset0 + 3];\n\t\t\tvar x1 = src1[srcOffset1];\n\t\t\tvar y1 = src1[srcOffset1 + 1];\n\t\t\tvar z1 = src1[srcOffset1 + 2];\n\t\t\tvar w1 = src1[srcOffset1 + 3];\n\t\t\tdst[dstOffset] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;\n\t\t\tdst[dstOffset + 1] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;\n\t\t\tdst[dstOffset + 2] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;\n\t\t\tdst[dstOffset + 3] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;\n\t\t\treturn dst;\n\t\t};\n\n\t\tvar _proto = Quaternion.prototype;\n\n\t\t_proto.set = function set(x, y, z, w) {\n\t\t\tthis._x = x;\n\t\t\tthis._y = y;\n\t\t\tthis._z = z;\n\t\t\tthis._w = w;\n\n\t\t\tthis._onChangeCallback();\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor(this._x, this._y, this._z, this._w);\n\t\t};\n\n\t\t_proto.copy = function copy(quaternion) {\n\t\t\tthis._x = quaternion.x;\n\t\t\tthis._y = quaternion.y;\n\t\t\tthis._z = quaternion.z;\n\t\t\tthis._w = quaternion.w;\n\n\t\t\tthis._onChangeCallback();\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromEuler = function setFromEuler(euler, update) {\n\t\t\tif (!(euler && euler.isEuler)) {\n\t\t\t\tthrow new Error('THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.');\n\t\t\t}\n\n\t\t\tvar x = euler._x,\n\t\t\t\t\ty = euler._y,\n\t\t\t\t\tz = euler._z,\n\t\t\t\t\torder = euler._order; // http://www.mathworks.com/matlabcentral/fileexchange/\n\t\t\t// \t20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/\n\t\t\t//\tcontent/SpinCalc.m\n\n\t\t\tvar cos = Math.cos;\n\t\t\tvar sin = Math.sin;\n\t\t\tvar c1 = cos(x / 2);\n\t\t\tvar c2 = cos(y / 2);\n\t\t\tvar c3 = cos(z / 2);\n\t\t\tvar s1 = sin(x / 2);\n\t\t\tvar s2 = sin(y / 2);\n\t\t\tvar s3 = sin(z / 2);\n\n\t\t\tswitch (order) {\n\t\t\t\tcase 'XYZ':\n\t\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'YXZ':\n\t\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'ZXY':\n\t\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'ZYX':\n\t\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'YZX':\n\t\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'XZY':\n\t\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tconsole.warn('THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + order);\n\t\t\t}\n\n\t\t\tif (update !== false) this._onChangeCallback();\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromAxisAngle = function setFromAxisAngle(axis, angle) {\n\t\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm\n\t\t\t// assumes axis is normalized\n\t\t\tvar halfAngle = angle / 2,\n\t\t\t\t\ts = Math.sin(halfAngle);\n\t\t\tthis._x = axis.x * s;\n\t\t\tthis._y = axis.y * s;\n\t\t\tthis._z = axis.z * s;\n\t\t\tthis._w = Math.cos(halfAngle);\n\n\t\t\tthis._onChangeCallback();\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromRotationMatrix = function setFromRotationMatrix(m) {\n\t\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm\n\t\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\t\t\tvar te = m.elements,\n\t\t\t\t\tm11 = te[0],\n\t\t\t\t\tm12 = te[4],\n\t\t\t\t\tm13 = te[8],\n\t\t\t\t\tm21 = te[1],\n\t\t\t\t\tm22 = te[5],\n\t\t\t\t\tm23 = te[9],\n\t\t\t\t\tm31 = te[2],\n\t\t\t\t\tm32 = te[6],\n\t\t\t\t\tm33 = te[10],\n\t\t\t\t\ttrace = m11 + m22 + m33;\n\n\t\t\tif (trace > 0) {\n\t\t\t\tvar s = 0.5 / Math.sqrt(trace + 1.0);\n\t\t\t\tthis._w = 0.25 / s;\n\t\t\t\tthis._x = (m32 - m23) * s;\n\t\t\t\tthis._y = (m13 - m31) * s;\n\t\t\t\tthis._z = (m21 - m12) * s;\n\t\t\t} else if (m11 > m22 && m11 > m33) {\n\t\t\t\tvar _s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);\n\n\t\t\t\tthis._w = (m32 - m23) / _s;\n\t\t\t\tthis._x = 0.25 * _s;\n\t\t\t\tthis._y = (m12 + m21) / _s;\n\t\t\t\tthis._z = (m13 + m31) / _s;\n\t\t\t} else if (m22 > m33) {\n\t\t\t\tvar _s2 = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);\n\n\t\t\t\tthis._w = (m13 - m31) / _s2;\n\t\t\t\tthis._x = (m12 + m21) / _s2;\n\t\t\t\tthis._y = 0.25 * _s2;\n\t\t\t\tthis._z = (m23 + m32) / _s2;\n\t\t\t} else {\n\t\t\t\tvar _s3 = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);\n\n\t\t\t\tthis._w = (m21 - m12) / _s3;\n\t\t\t\tthis._x = (m13 + m31) / _s3;\n\t\t\t\tthis._y = (m23 + m32) / _s3;\n\t\t\t\tthis._z = 0.25 * _s3;\n\t\t\t}\n\n\t\t\tthis._onChangeCallback();\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromUnitVectors = function setFromUnitVectors(vFrom, vTo) {\n\t\t\t// assumes direction vectors vFrom and vTo are normalized\n\t\t\tvar EPS = 0.000001;\n\t\t\tvar r = vFrom.dot(vTo) + 1;\n\n\t\t\tif (r < EPS) {\n\t\t\t\tr = 0;\n\n\t\t\t\tif (Math.abs(vFrom.x) > Math.abs(vFrom.z)) {\n\t\t\t\t\tthis._x = -vFrom.y;\n\t\t\t\t\tthis._y = vFrom.x;\n\t\t\t\t\tthis._z = 0;\n\t\t\t\t\tthis._w = r;\n\t\t\t\t} else {\n\t\t\t\t\tthis._x = 0;\n\t\t\t\t\tthis._y = -vFrom.z;\n\t\t\t\t\tthis._z = vFrom.y;\n\t\t\t\t\tthis._w = r;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3\n\t\t\t\tthis._x = vFrom.y * vTo.z - vFrom.z * vTo.y;\n\t\t\t\tthis._y = vFrom.z * vTo.x - vFrom.x * vTo.z;\n\t\t\t\tthis._z = vFrom.x * vTo.y - vFrom.y * vTo.x;\n\t\t\t\tthis._w = r;\n\t\t\t}\n\n\t\t\treturn this.normalize();\n\t\t};\n\n\t\t_proto.angleTo = function angleTo(q) {\n\t\t\treturn 2 * Math.acos(Math.abs(MathUtils.clamp(this.dot(q), -1, 1)));\n\t\t};\n\n\t\t_proto.rotateTowards = function rotateTowards(q, step) {\n\t\t\tvar angle = this.angleTo(q);\n\t\t\tif (angle === 0) return this;\n\t\t\tvar t = Math.min(1, step / angle);\n\t\t\tthis.slerp(q, t);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.identity = function identity() {\n\t\t\treturn this.set(0, 0, 0, 1);\n\t\t};\n\n\t\t_proto.invert = function invert() {\n\t\t\t// quaternion is assumed to have unit length\n\t\t\treturn this.conjugate();\n\t\t};\n\n\t\t_proto.conjugate = function conjugate() {\n\t\t\tthis._x *= -1;\n\t\t\tthis._y *= -1;\n\t\t\tthis._z *= -1;\n\n\t\t\tthis._onChangeCallback();\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.dot = function dot(v) {\n\t\t\treturn this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;\n\t\t};\n\n\t\t_proto.lengthSq = function lengthSq() {\n\t\t\treturn this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;\n\t\t};\n\n\t\t_proto.length = function length() {\n\t\t\treturn Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);\n\t\t};\n\n\t\t_proto.normalize = function normalize() {\n\t\t\tvar l = this.length();\n\n\t\t\tif (l === 0) {\n\t\t\t\tthis._x = 0;\n\t\t\t\tthis._y = 0;\n\t\t\t\tthis._z = 0;\n\t\t\t\tthis._w = 1;\n\t\t\t} else {\n\t\t\t\tl = 1 / l;\n\t\t\t\tthis._x = this._x * l;\n\t\t\t\tthis._y = this._y * l;\n\t\t\t\tthis._z = this._z * l;\n\t\t\t\tthis._w = this._w * l;\n\t\t\t}\n\n\t\t\tthis._onChangeCallback();\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.multiply = function multiply(q, p) {\n\t\t\tif (p !== undefined) {\n\t\t\t\tconsole.warn('THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.');\n\t\t\t\treturn this.multiplyQuaternions(q, p);\n\t\t\t}\n\n\t\t\treturn this.multiplyQuaternions(this, q);\n\t\t};\n\n\t\t_proto.premultiply = function premultiply(q) {\n\t\t\treturn this.multiplyQuaternions(q, this);\n\t\t};\n\n\t\t_proto.multiplyQuaternions = function multiplyQuaternions(a, b) {\n\t\t\t// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm\n\t\t\tvar qax = a._x,\n\t\t\t\t\tqay = a._y,\n\t\t\t\t\tqaz = a._z,\n\t\t\t\t\tqaw = a._w;\n\t\t\tvar qbx = b._x,\n\t\t\t\t\tqby = b._y,\n\t\t\t\t\tqbz = b._z,\n\t\t\t\t\tqbw = b._w;\n\t\t\tthis._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;\n\t\t\tthis._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;\n\t\t\tthis._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;\n\t\t\tthis._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;\n\n\t\t\tthis._onChangeCallback();\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.slerp = function slerp(qb, t) {\n\t\t\tif (t === 0) return this;\n\t\t\tif (t === 1) return this.copy(qb);\n\t\t\tvar x = this._x,\n\t\t\t\t\ty = this._y,\n\t\t\t\t\tz = this._z,\n\t\t\t\t\tw = this._w; // http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/\n\n\t\t\tvar cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;\n\n\t\t\tif (cosHalfTheta < 0) {\n\t\t\t\tthis._w = -qb._w;\n\t\t\t\tthis._x = -qb._x;\n\t\t\t\tthis._y = -qb._y;\n\t\t\t\tthis._z = -qb._z;\n\t\t\t\tcosHalfTheta = -cosHalfTheta;\n\t\t\t} else {\n\t\t\t\tthis.copy(qb);\n\t\t\t}\n\n\t\t\tif (cosHalfTheta >= 1.0) {\n\t\t\t\tthis._w = w;\n\t\t\t\tthis._x = x;\n\t\t\t\tthis._y = y;\n\t\t\t\tthis._z = z;\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tvar sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;\n\n\t\t\tif (sqrSinHalfTheta <= Number.EPSILON) {\n\t\t\t\tvar s = 1 - t;\n\t\t\t\tthis._w = s * w + t * this._w;\n\t\t\t\tthis._x = s * x + t * this._x;\n\t\t\t\tthis._y = s * y + t * this._y;\n\t\t\t\tthis._z = s * z + t * this._z;\n\t\t\t\tthis.normalize();\n\n\t\t\t\tthis._onChangeCallback();\n\n\t\t\t\treturn this;\n\t\t\t}
1\n\n\t\t\tvar sinHalfTheta = Math.sqrt(sqrSinHalfTheta);\n\t\t\tvar halfTheta = Math.atan2(sinHalfTheta, cosHalfTheta);\n\t\t\tvar ratioA = Math.sin((1 - t) * halfTheta) / sinHalfTheta,\n\t\t\t\t\tratioB = Math.sin(t * halfTheta) / sinHalfTheta;\n\t\t\tthis._w = w * ratioA + this._w * ratioB;\n\t\t\tthis._x = x * ratioA + this._x * ratioB;\n\t\t\tthis._y = y * ratioA + this._y * ratioB;\n\t\t\tthis._z = z * ratioA + this._z * ratioB;\n\n\t\t\tthis._onChangeCallback();\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.equals = function equals(quaternion) {\n\t\t\treturn quaternion._x === this._x && quaternion._y === this._y && quaternion._z === this._z && quaternion._w === this._w;\n\t\t};\n\n\t\t_proto.fromArray = function fromArray(array, offset) {\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tthis._x = array[offset];\n\t\t\tthis._y = array[offset + 1];\n\t\t\tthis._z = array[offset + 2];\n\t\t\tthis._w = array[offset + 3];\n\n\t\t\tthis._onChangeCallback();\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.toArray = function toArray(array, offset) {\n\t\t\tif (array === void 0) {\n\t\t\t\tarray = [];\n\t\t\t}\n\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tarray[offset] = this._x;\n\t\t\tarray[offset + 1] = this._y;\n\t\t\tarray[offset + 2] = this._z;\n\t\t\tarray[offset + 3] = this._w;\n\t\t\treturn array;\n\t\t};\n\n\t\t_proto.fromBufferAttribute = function fromBufferAttribute(attribute, index) {\n\t\t\tthis._x = attribute.getX(index);\n\t\t\tthis._y = attribute.getY(index);\n\t\t\tthis._z = attribute.getZ(index);\n\t\t\tthis._w = attribute.getW(index);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto._onChange = function _onChange(callback) {\n\t\t\tthis._onChangeCallback = callback;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto._onChangeCallback = function _onChangeCallback() {};\n\n\t\t_createClass(Quaternion, [{\n\t\t\tkey: \"x\",\n\t\t\tget: function get() {\n\t\t\t\treturn this._x;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tthis._x = value;\n\n\t\t\t\tthis._onChangeCallback();\n\t\t\t}\n\t\t}, {\n\t\t\tkey: \"y\",\n\t\t\tget: function get() {\n\t\t\t\treturn this._y;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tthis._y = value;\n\n\t\t\t\tthis._onChangeCallback();\n\t\t\t}\n\t\t}, {\n\t\t\tkey: \"z\",\n\t\t\tget: function get() {\n\t\t\t\treturn this._z;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tthis._z = value;\n\n\t\t\t\tthis._onChangeCallback();\n\t\t\t}\n\t\t}, {\n\t\t\tkey: \"w\",\n\t\t\tget: function get() {\n\t\t\t\treturn this._w;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tthis._w = value;\n\n\t\t\t\tthis._onChangeCallback();\n\t\t\t}\n\t\t}]);\n\n\t\treturn Quaternion;\n\t}();\n\n\tvar Vector3 = /*#__PURE__*/function () {\n\t\tfunction Vector3(x, y, z) {\n\t\t\tif (x === void 0) {\n\t\t\t\tx = 0;\n\t\t\t}\n\n\t\t\tif (y === void 0) {\n\t\t\t\ty = 0;\n\t\t\t}\n\n\t\t\tif (z === void 0) {\n\t\t\t\tz = 0;\n\t\t\t}\n\n\t\t\tObject.defineProperty(this, 'isVector3', {\n\t\t\t\tvalue: true\n\t\t\t});\n\t\t\tthis.x = x;\n\t\t\tthis.y = y;\n\t\t\tthis.z = z;\n\t\t}\n\n\t\tvar _proto = Vector3.prototype;\n\n\t\t_proto.set = function set(x, y, z) {\n\t\t\tif (z === undefined) z = this.z; // sprite.scale.set(x,y)\n\n\t\t\tthis.x = x;\n\t\t\tthis.y = y;\n\t\t\tthis.z = z;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setScalar = function setScalar(scalar) {\n\t\t\tthis.x = scalar;\n\t\t\tthis.y = scalar;\n\t\t\tthis.z = scalar;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setX = function setX(x) {\n\t\t\tthis.x = x;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setY = function setY(y) {\n\t\t\tthis.y = y;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setZ = function setZ(z) {\n\t\t\tthis.z = z;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setComponent = function setComponent(index, value) {\n\t\t\tswitch (index) {\n\t\t\t\tcase 0:\n\t\t\t\t\tthis.x = value;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 1:\n\t\t\t\t\tthis.y = value;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 2:\n\t\t\t\t\tthis.z = value;\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error('index is out of range: ' + index);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.getComponent = function getComponent(index) {\n\t\t\tswitch (index) {\n\t\t\t\tcase 0:\n\t\t\t\t\treturn this.x;\n\n\t\t\t\tcase 1:\n\t\t\t\t\treturn this.y;\n\n\t\t\t\tcase 2:\n\t\t\t\t\treturn this.z;\n\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error('index is out of range: ' + index);\n\t\t\t}\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor(this.x, this.y, this.z);\n\t\t};\n\n\t\t_proto.copy = function copy(v) {\n\t\t\tthis.x = v.x;\n\t\t\tthis.y = v.y;\n\t\t\tthis.z = v.z;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.add = function add(v, w) {\n\t\t\tif (w !== undefined) {\n\t\t\t\tconsole.warn('THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.');\n\t\t\t\treturn this.addVectors(v, w);\n\t\t\t}\n\n\t\t\tthis.x += v.x;\n\t\t\tthis.y += v.y;\n\t\t\tthis.z += v.z;\n\t\t\treturn this;\n\t\t};
1\n\n\t\t_proto.addScalar = function addScalar(s) {\n\t\t\tthis.x += s;\n\t\t\tthis.y += s;\n\t\t\tthis.z += s;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.addVectors = function addVectors(a, b) {\n\t\t\tthis.x = a.x + b.x;\n\t\t\tthis.y = a.y + b.y;\n\t\t\tthis.z = a.z + b.z;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.addScaledVector = function addScaledVector(v, s) {\n\t\t\tthis.x += v.x * s;\n\t\t\tthis.y += v.y * s;\n\t\t\tthis.z += v.z * s;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.sub = function sub(v, w) {\n\t\t\tif (w !== undefined) {\n\t\t\t\tconsole.warn('THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.');\n\t\t\t\treturn this.subVectors(v, w);\n\t\t\t}\n\n\t\t\tthis.x -= v.x;\n\t\t\tthis.y -= v.y;\n\t\t\tthis.z -= v.z;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.subScalar = function subScalar(s) {\n\t\t\tthis.x -= s;\n\t\t\tthis.y -= s;\n\t\t\tthis.z -= s;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.subVectors = function subVectors(a, b) {\n\t\t\tthis.x = a.x - b.x;\n\t\t\tthis.y = a.y - b.y;\n\t\t\tthis.z = a.z - b.z;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.multiply = function multiply(v, w) {\n\t\t\tif (w !== undefined) {\n\t\t\t\tconsole.warn('THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.');\n\t\t\t\treturn this.multiplyVectors(v, w);\n\t\t\t}\n\n\t\t\tthis.x *= v.x;\n\t\t\tthis.y *= v.y;\n\t\t\tthis.z *= v.z;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.multiplyScalar = function multiplyScalar(scalar) {\n\t\t\tthis.x *= scalar;\n\t\t\tthis.y *= scalar;\n\t\t\tthis.z *= scalar;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.multiplyVectors = function multiplyVectors(a, b) {\n\t\t\tthis.x = a.x * b.x;\n\t\t\tthis.y = a.y * b.y;\n\t\t\tthis.z = a.z * b.z;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.applyEuler = function applyEuler(euler) {\n\t\t\tif (!(euler && euler.isEuler)) {\n\t\t\t\tconsole.error('THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.');\n\t\t\t}\n\n\t\t\treturn this.applyQuaternion(_quaternion.setFromEuler(euler));\n\t\t};\n\n\t\t_proto.applyAxisAngle = function applyAxisAngle(axis, angle) {\n\t\t\treturn this.applyQuaternion(_quaternion.setFromAxisAngle(axis, angle));\n\t\t};\n\n\t\t_proto.applyMatrix3 = function applyMatrix3(m) {\n\t\t\tvar x = this.x,\n\t\t\t\t\ty = this.y,\n\t\t\t\t\tz = this.z;\n\t\t\tvar e = m.elements;\n\t\t\tthis.x = e[0] * x + e[3] * y + e[6] * z;\n\t\t\tthis.y = e[1] * x + e[4] * y + e[7] * z;\n\t\t\tthis.z = e[2] * x + e[5] * y + e[8] * z;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.applyNormalMatrix = function applyNormalMatrix(m) {\n\t\t\treturn this.applyMatrix3(m).normalize();\n\t\t};\n\n\t\t_proto.applyMatrix4 = function applyMatrix4(m) {\n\t\t\tvar x = this.x,\n\t\t\t\t\ty = this.y,\n\t\t\t\t\tz = this.z;\n\t\t\tvar e = m.elements;\n\t\t\tvar w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);\n\t\t\tthis.x = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w;\n\t\t\tthis.y = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;\n\t\t\tthis.z = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.applyQuaternion = function applyQuaternion(q) {\n\t\t\tvar x = this.x,\n\t\t\t\t\ty = this.y,\n\t\t\t\t\tz = this.z;\n\t\t\tvar qx = q.x,\n\t\t\t\t\tqy = q.y,\n\t\t\t\t\tqz = q.z,\n\t\t\t\t\tqw = q.w; // calculate quat * vector\n\n\t\t\tvar ix = qw * x + qy * z - qz * y;\n\t\t\tvar iy = qw * y + qz * x - qx * z;\n\t\t\tvar iz = qw * z + qx * y - qy * x;\n\t\t\tvar iw = -qx * x - qy * y - qz * z; // calculate result * inverse quat\n\n\t\t\tthis.x = ix * qw + iw * -qx + iy * -qz - iz * -qy;\n\t\t\tthis.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;\n\t\t\tthis.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.project = function project(camera) {\n\t\t\treturn this.applyMatrix4(camera.matrixWorldInverse).applyMatrix4(camera.projectionMatrix);\n\t\t};\n\n\t\t_proto.unproject = function unproject(camera) {\n\t\t\treturn this.applyMatrix4(camera.projectionMatrixInverse).applyMatrix4(camera.matrixWorld);\n\t\t};\n\n\t\t_proto.transformDirection = function transformDirection(m) {\n\t\t\t// input: THREE.Matrix4 affine matrix\n\t\t\t// vector interpreted as a direction\n\t\t\tvar x = this.x,\n\t\t\t\t\ty = this.y,\n\t\t\t\t\tz = this.z;\n\t\t\tvar e = m.elements;\n\t\t\tthis.x = e[0] * x + e[4] * y + e[8] * z;\n\t\t\tthis.y = e[1] * x + e[5] * y + e[9] * z;\n\t\t\tthis.z = e[2] * x + e[6] * y + e[10] * z;\n\t\t\treturn this.normalize();\n\t\t};\n\n\t\t_proto.divide = function divide(v) {\n\t\t\tthis.x /= v.x;\n\t\t\tthis.y /= v.y;\n\t\t\tthis.z /= v.z;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.divideScalar = function divideScalar(scalar) {\n\t\t\treturn this.multiplyScalar(1 / scalar);\n\t\t};\n\n\t\t_proto.min = function min(v) {\n\t\t\tthis.x = Math.min(this.x, v.x);\n\t\t\tthis.y = Math.min(this.y, v.y);\n\t\t\tthis.z = Math.min(this.z, v.z);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.max = function max(v) {\n\t\t\tthis.x = Math.max(this.x, v.x);\n\t\t\tthis.y = Math.max(this.y, v.y);\n\t\t\tthis.z = Math.max(this.z, v.z);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clamp = function clamp(min, max) {\n\t\t\t// assumes min < max, componentwise\n\t\t\tthis.x = Math.max(min.x, Math.min(max.x, this.x));\n\t\t\tthis.y = Math.max(min.y, Math.min(max.y, this.y));\n\t\t\tthis.z = Math.max(min.z, Math.min(max.z, this.z));\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clampScalar = function clampScalar(minVal, maxVal) {\n\t\t\tthis.x = Math.max(minVal, Math.min(maxVal, this.x));\n\t\t\tthis.y = Math.max(minVal, Math.min(maxVal, this.y));\n\t\t\tthis.z = Math.max(minVal, Math.min(maxVal, this.z));\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clampLength = function clampLength(min, max) {\n\t\t\tvar length = this.length();\n\t\t\treturn this.divideScalar(length || 1).multiplyScalar(Math.max(min, Math.min(max, length)));\n\t\t};\n\n\t\t_proto.floor = function floor() {\n\t\t\tthis.x = Math.floor(this.x);\n\t\t\tthis.y = Math.floor(this.y);\n\t\t\tthis.z = Math.floor(this.z);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.ceil = function ceil() {\n\t\t\tthis.x = Math.ceil(this.x);\n\t\t\tthis.y = Math.ceil(this.y);
1\n\t\t\tthis.z = Math.ceil(this.z);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.round = function round() {\n\t\t\tthis.x = Math.round(this.x);\n\t\t\tthis.y = Math.round(this.y);\n\t\t\tthis.z = Math.round(this.z);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.roundToZero = function roundToZero() {\n\t\t\tthis.x = this.x < 0 ? Math.ceil(this.x) : Math.floor(this.x);\n\t\t\tthis.y = this.y < 0 ? Math.ceil(this.y) : Math.floor(this.y);\n\t\t\tthis.z = this.z < 0 ? Math.ceil(this.z) : Math.floor(this.z);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.negate = function negate() {\n\t\t\tthis.x = -this.x;\n\t\t\tthis.y = -this.y;\n\t\t\tthis.z = -this.z;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.dot = function dot(v) {\n\t\t\treturn this.x * v.x + this.y * v.y + this.z * v.z;\n\t\t} // TODO lengthSquared?\n\t\t;\n\n\t\t_proto.lengthSq = function lengthSq() {\n\t\t\treturn this.x * this.x + this.y * this.y + this.z * this.z;\n\t\t};\n\n\t\t_proto.length = function length() {\n\t\t\treturn Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);\n\t\t};\n\n\t\t_proto.manhattanLength = function manhattanLength() {\n\t\t\treturn Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);\n\t\t};\n\n\t\t_proto.normalize = function normalize() {\n\t\t\treturn this.divideScalar(this.length() || 1);\n\t\t};\n\n\t\t_proto.setLength = function setLength(length) {\n\t\t\treturn this.normalize().multiplyScalar(length);\n\t\t};\n\n\t\t_proto.lerp = function lerp(v, alpha) {\n\t\t\tthis.x += (v.x - this.x) * alpha;\n\t\t\tthis.y += (v.y - this.y) * alpha;\n\t\t\tthis.z += (v.z - this.z) * alpha;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.lerpVectors = function lerpVectors(v1, v2, alpha) {\n\t\t\tthis.x = v1.x + (v2.x - v1.x) * alpha;\n\t\t\tthis.y = v1.y + (v2.y - v1.y) * alpha;\n\t\t\tthis.z = v1.z + (v2.z - v1.z) * alpha;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.cross = function cross(v, w) {\n\t\t\tif (w !== undefined) {\n\t\t\t\tconsole.warn('THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.');\n\t\t\t\treturn this.crossVectors(v, w);\n\t\t\t}\n\n\t\t\treturn this.crossVectors(this, v);\n\t\t};\n\n\t\t_proto.crossVectors = function crossVectors(a, b) {\n\t\t\tvar ax = a.x,\n\t\t\t\t\tay = a.y,\n\t\t\t\t\taz = a.z;\n\t\t\tvar bx = b.x,\n\t\t\t\t\tby = b.y,\n\t\t\t\t\tbz = b.z;\n\t\t\tthis.x = ay * bz - az * by;\n\t\t\tthis.y = az * bx - ax * bz;\n\t\t\tthis.z = ax * by - ay * bx;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.projectOnVector = function projectOnVector(v) {\n\t\t\tvar denominator = v.lengthSq();\n\t\t\tif (denominator === 0) return this.set(0, 0, 0);\n\t\t\tvar scalar = v.dot(this) / denominator;\n\t\t\treturn this.copy(v).multiplyScalar(scalar);\n\t\t};\n\n\t\t_proto.projectOnPlane = function projectOnPlane(planeNormal) {\n\t\t\t_vector.copy(this).projectOnVector(planeNormal);\n\n\t\t\treturn this.sub(_vector);\n\t\t};\n\n\t\t_proto.reflect = function reflect(normal) {\n\t\t\t// reflect incident vector off plane orthogonal to normal\n\t\t\t// normal is assumed to have unit length\n\t\t\treturn this.sub(_vector.copy(normal).multiplyScalar(2 * this.dot(normal)));\n\t\t};\n\n\t\t_proto.angleTo = function angleTo(v) {\n\t\t\tvar denominator = Math.sqrt(this.lengthSq() * v.lengthSq());\n\t\t\tif (denominator === 0) return Math.PI / 2;\n\t\t\tvar theta = this.dot(v) / denominator; // clamp, to handle numerical problems\n\n\t\t\treturn Math.acos(MathUtils.clamp(theta, -1, 1));\n\t\t};\n\n\t\t_proto.distanceTo = function distanceTo(v) {\n\t\t\treturn Math.sqrt(this.distanceToSquared(v));\n\t\t};\n\n\t\t_proto.distanceToSquared = function distanceToSquared(v) {\n\t\t\tvar dx = this.x - v.x,\n\t\t\t\t\tdy = this.y - v.y,\n\t\t\t\t\tdz = this.z - v.z;\n\t\t\treturn dx * dx + dy * dy + dz * dz;\n\t\t};\n\n\t\t_proto.manhattanDistanceTo = function manhattanDistanceTo(v) {\n\t\t\treturn Math.abs(this.x - v.x) + Math.abs(this.y - v.y) + Math.abs(this.z - v.z);\n\t\t};\n\n\t\t_proto.setFromSpherical = function setFromSpherical(s) {\n\t\t\treturn this.setFromSphericalCoords(s.radius, s.phi, s.theta);\n\t\t};\n\n\t\t_proto.setFromSphericalCoords = function setFromSphericalCoords(radius, phi, theta) {\n\t\t\tvar sinPhiRadius = Math.sin(phi) * radius;\n\t\t\tthis.x = sinPhiRadius * Math.sin(theta);\n\t\t\tthis.y = Math.cos(phi) * radius;\n\t\t\tthis.z = sinPhiRadius * Math.cos(theta);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromCylindrical = function setFromCylindrical(c) {\n\t\t\treturn this.setFromCylindricalCoords(c.radius, c.theta, c.y);\n\t\t};\n\n\t\t_proto.setFromCylindricalCoords = function setFromCylindricalCoords(radius, theta, y) {\n\t\t\tthis.x = radiu
1s * Math.sin(theta);\n\t\t\tthis.y = y;\n\t\t\tthis.z = radius * Math.cos(theta);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromMatrixPosition = function setFromMatrixPosition(m) {\n\t\t\tvar e = m.elements;\n\t\t\tthis.x = e[12];\n\t\t\tthis.y = e[13];\n\t\t\tthis.z = e[14];\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromMatrixScale = function setFromMatrixScale(m) {\n\t\t\tvar sx = this.setFromMatrixColumn(m, 0).length();\n\t\t\tvar sy = this.setFromMatrixColumn(m, 1).length();\n\t\t\tvar sz = this.setFromMatrixColumn(m, 2).length();\n\t\t\tthis.x = sx;\n\t\t\tthis.y = sy;\n\t\t\tthis.z = sz;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromMatrixColumn = function setFromMatrixColumn(m, index) {\n\t\t\treturn this.fromArray(m.elements, index * 4);\n\t\t};\n\n\t\t_proto.setFromMatrix3Column = function setFromMatrix3Column(m, index) {\n\t\t\treturn this.fromArray(m.elements, index * 3);\n\t\t};\n\n\t\t_proto.equals = function equals(v) {\n\t\t\treturn v.x === this.x && v.y === this.y && v.z === this.z;\n\t\t};\n\n\t\t_proto.fromArray = function fromArray(array, offset) {\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tthis.x = array[offset];\n\t\t\tthis.y = array[offset + 1];\n\t\t\tthis.z = array[offset + 2];\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.toArray = function toArray(array, offset) {\n\t\t\tif (array === void 0) {\n\t\t\t\tarray = [];\n\t\t\t}\n\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tarray[offset] = this.x;\n\t\t\tarray[offset + 1] = this.y;\n\t\t\tarray[offset + 2] = this.z;\n\t\t\treturn array;\n\t\t};\n\n\t\t_proto.fromBufferAttribute = function fromBufferAttribute(attribute, index, offset) {\n\t\t\tif (offset !== undefined) {\n\t\t\t\tconsole.warn('THREE.Vector3: offset has been removed from .fromBufferAttribute().');\n\t\t\t}\n\n\t\t\tthis.x = attribute.getX(index);\n\t\t\tthis.y = attribute.getY(index);\n\t\t\tthis.z = attribute.getZ(index);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.random = function random() {\n\t\t\tthis.x = Math.random();\n\t\t\tthis.y = Math.random();\n\t\t\tthis.z = Math.random();\n\t\t\treturn this;\n\t\t};\n\n\t\treturn Vector3;\n\t}();\n\n\tvar _vector = /*@__PURE__*/new Vector3();\n\n\tvar _quaternion = /*@__PURE__*/new Quaternion();\n\n\tvar Box3 = /*#__PURE__*/function () {\n\t\tfunction Box3(min, max) {\n\t\t\tObject.defineProperty(this, 'isBox3', {\n\t\t\t\tvalue: true\n\t\t\t});\n\t\t\tthis.min = min !== undefined ? min : new Vector3(+Infinity, +Infinity, +Infinity);\n\t\t\tthis.max = max !== undefined ? max : new Vector3(-Infinity, -Infinity, -Infinity);\n\t\t}\n\n\t\tvar _proto = Box3.prototype;\n\n\t\t_proto.set = function set(min, max) {\n\t\t\tthis.min.copy(min);\n\t\t\tthis.max.copy(max);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromArray = function setFromArray(array) {\n\t\t\tvar minX = +Infinity;\n\t\t\tvar minY = +Infinity;\n\t\t\tvar minZ = +Infinity;\n\t\t\tvar maxX = -Infinity;\n\t\t\tvar maxY = -Infinity;\n\t\t\tvar maxZ = -Infinity;\n\n\t\t\tfor (var i = 0, l = array.length; i < l; i += 3) {\n\t\t\t\tvar x = array[i];\n\t\t\t\tvar y = array[i + 1];\n\t\t\t\tvar z = array[i + 2];\n\t\t\t\tif (x < minX) minX = x;\n\t\t\t\tif (y < minY) minY = y;\n\t\t\t\tif (z < minZ) minZ = z;\n\t\t\t\tif (x > maxX) maxX = x;\n\t\t\t\tif (y > maxY) maxY = y;\n\t\t\t\tif (z > maxZ) maxZ = z;\n\t\t\t}\n\n\t\t\tthis.min.set(minX, minY, minZ);\n\t\t\tthis.max.set(maxX, maxY, maxZ);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromBufferAttribute = function setFromBufferAttribute(attribute) {\n\t\t\tvar minX = +Infinity;\n\t\t\tvar minY = +Infinity;\n\t\t\tvar minZ = +Infinity;\n\t\t\tvar maxX = -Infinity;\n\t\t\tvar maxY = -Infinity;\n\t\t\tvar maxZ = -Infinity;\n\n\t\t\tfor (var i = 0, l = attribute.count; i < l; i++) {\n\t\t\t\tvar x = attribute.getX(i);\n\t\t\t\tvar y = attribute.getY(i);\n\t\t\t\tvar z = attribute.getZ(i);\n\t\t\t\tif (x < minX) minX = x;\n\t\t\t\tif (y < minY) minY = y;\n\t\t\t\tif (z < minZ) minZ = z;\n\t\t\t\tif (x > maxX) maxX = x;\n\t\t\t\tif (y > maxY) maxY = y;\n\t\t\t\tif (z > maxZ) maxZ = z;\n\t\t\t}\n\n\t\t\tthis.min.set(minX, minY, minZ);\n\t\t\tthis.max.set(maxX, maxY, maxZ);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromPoints = function setFromPoints(points) {\n\t\t\tthis.makeEmpty();\n\n\t\t\tfor (var i = 0, il = points.length; i < il;
1 i++) {\n\t\t\t\tthis.expandByPoint(points[i]);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromCenterAndSize = function setFromCenterAndSize(center, size) {\n\t\t\tvar halfSize = _vector$1.copy(size).multiplyScalar(0.5);\n\n\t\t\tthis.min.copy(center).sub(halfSize);\n\t\t\tthis.max.copy(center).add(halfSize);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromObject = function setFromObject(object) {\n\t\t\tthis.makeEmpty();\n\t\t\treturn this.expandByObject(object);\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t};\n\n\t\t_proto.copy = function copy(box) {\n\t\t\tthis.min.copy(box.min);\n\t\t\tthis.max.copy(box.max);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.makeEmpty = function makeEmpty() {\n\t\t\tthis.min.x = this.min.y = this.min.z = +Infinity;\n\t\t\tthis.max.x = this.max.y = this.max.z = -Infinity;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.isEmpty = function isEmpty() {\n\t\t\t// this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes\n\t\t\treturn this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;\n\t\t};\n\n\t\t_proto.getCenter = function getCenter(target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Box3: .getCenter() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\treturn this.isEmpty() ? target.set(0, 0, 0) : target.addVectors(this.min, this.max).multiplyScalar(0.5);\n\t\t};\n\n\t\t_proto.getSize = function getSize(target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Box3: .getSize() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\treturn this.isEmpty() ? target.set(0, 0, 0) : target.subVectors(this.max, this.min);\n\t\t};\n\n\t\t_proto.expandByPoint = function expandByPoint(point) {\n\t\t\tthis.min.min(point);\n\t\t\tthis.max.max(point);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.expandByVector = function expandByVector(vector) {\n\t\t\tthis.min.sub(vector);\n\t\t\tthis.max.add(vector);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.expandByScalar = function expandByScalar(scalar) {\n\t\t\tthis.min.addScalar(-scalar);\n\t\t\tthis.max.addScalar(scalar);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.expandByObject = function expandByObject(object) {\n\t\t\t// Computes the world-axis-aligned bounding box of an object (including its children),\n\t\t\t// accounting for both the object's, and children's, world transforms\n\t\t\tobject.updateWorldMatrix(false, false);\n\t\t\tvar geometry = object.geometry;\n\n\t\t\tif (geometry !== undefined) {\n\t\t\t\tif (geometry.boundingBox === null) {\n\t\t\t\t\tgeometry.computeBoundingBox();\n\t\t\t\t}\n\n\t\t\t\t_box.copy(geometry.boundingBox);\n\n\t\t\t\t_box.applyMatrix4(object.matrixWorld);\n\n\t\t\t\tthis.union(_box);\n\t\t\t}\n\n\t\t\tvar children = object.children;\n\n\t\t\tfor (var i = 0, l = children.length; i < l; i++) {\n\t\t\t\tthis.expandByObject(children[i]);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.containsPoint = function containsPoint(point) {\n\t\t\treturn point.x < this.min.x || point.x > this.max.x || point.y < this.min.y || point.y > this.max.y || point.z < this.min.z || point.z > this.max.z ? false : true;\n\t\t};\n\n\t\t_proto.containsBox = function containsBox(box) {\n\t\t\treturn this.min.x <= box.min.x && box.max.x <= this.max.x && this.min.y <= box.min.y && box.max.y <= this.max.y && this.min.z <= box.min.z && box.max.z <= this.max.z;\n\t\t};\n\n\t\t_proto.getParameter = function getParameter(point, target) {\n\t\t\t// This can potentially have a divide by zero if the box\n\t\t\t// has a size dimension of 0.\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Box3: .getParameter() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\treturn target.set((point.x - this.min.x) / (this.max.x - this.min.x), (point.y - this.min.y) / (this.max.y - this.min.y), (point.z - this.min.z) / (this.max.z - this.min.z));\n\t\t};\n\n\t\t_proto.intersectsBox = function intersectsBox(box) {\n\t\t\t// using 6 splitting planes to rule out intersections.\n\t\t\treturn box.max.x < this.min.x || box.min.x > this.max.x || box.max.y < this.min.y || box.min.y > this.max.y || box.max.z < this.min.z || box.min.z > this.max.z ? false : true;\n\t\t};\n\n\t\t_proto.intersectsSphere = function intersectsSphere(sphere) {\n\t\t\t// Find the point on the AABB closest to the sphere center.\n\t\t\tthis.clampPoint(sphere.center, _vector$1); // If that point is inside the sphere, the AABB and sphere intersect.\n\n\t\t\treturn _vector$1.distanceToSquared(sphere.center) <= sphere.radius * sphere.radius;\n\t\t};\n\n\t\t_proto.intersectsPlane = function intersectsPlane(plane) {\n\t\t\t// We compute the minimum and maximum dot product values. If those values\n\t\t\t// are on the same side (back or front) of the plane, then there is no intersection.\n\t\t\tvar min, max;\n\n\t\t\tif (plane.normal.x > 0) {\n\t\t\t\tmin = plane.normal.x * this.min.x;\n\t\t\t\tmax = plane.normal.x * this.max.x;\n\t\t\t} else {\n\t\t\t\tmin = plane.normal.x * this.max.x;\n\t\t\t\tmax = plane.normal.x * this.min.x;\n\t\t\t}\n\n\t\t\tif (plane.normal.y > 0) {\n\t\t\t\tmin += plane.normal.y * this.min.y;\n\t\t\t\tmax += plane.normal.y * this.max.y;\n\t\t\t} else {\n\t\t\t\tmin += plane.normal.y * this.max.y;\n\t\t\t\tmax += plane.normal.y * this.min.y;\n\t\t\t}\n\n\t\t\tif (plane.normal.z > 0) {\n\t\t\t\tmin += plane.normal.z * this.min.z;\n\t\t\t\tmax += plane.normal.z * this.max.z;\n\t\t\t} else {\n\t\t\t\tmin += plane.normal.z * this.max.z;\n\t\t\t\tmax += plane.normal.z * this.min.z;\n\t\t\t}\n\n\t\t\treturn min <= -plane.constant && max >= -plane.constant;\n\t\t};\n\n\t\t_proto.intersectsTriangle = function intersectsTriangle(triangle) {\n\t\t\tif (this.isEmpty()) {\n\t\t\t\treturn false;\n\t\t\t} // compute box center and extents\n\n\n\t\t\tthis.getCenter(_center);\n\n\t\t\t_extents.subVectors(this.max, _center); // translate triangle to aabb origin\n\n\n\t\t\t_v0.subVectors(triangle.a, _center);\n\n\t\t\t_v1.subVectors(triangle.b, _center);\n\n\t\t\t_v2.subVectors(triangle.c, _center); // compute edge vectors for triangle\n\n\n\t\t\t_f0.subVectors(_v1, _v0);\n\n\t\t\t_f1.subVectors(_v2, _v1);\n\n\t\t\t_f2.subVectors(_v0, _v2); // test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb\n\t\t\t// make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation\n\t\t\t// axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned)\n\n\n\t\t\tvar axes = [0, -_f0.z, _f0.y, 0, -_f1.z, _f1.y, 0, -_f2.z, _f2.y, _f0.z, 0, -_f0.x, _f1.z, 0, -_f1.x, _f2.z, 0, -_f2.x, -_f0.y, _f0.x, 0, -_f1.y, _f1.x, 0, -_f2.y, _f2.x, 0];\n\n\t\t\tif (!satForAxes(axes, _v0, _v1, _v2, _extents)) {\n\t\t\t\treturn false;\n\t\t\t} // test 3 face normals from the aabb\n\n\n\t\t\taxes = [1, 0, 0, 0, 1, 0, 0, 0, 1];\n\n\t\t\tif (!satForAxes(axes, _v0, _v1, _v2, _extents)) {\n\t\t\t\treturn false;\n\t\t\t} // finally testing the face normal of the triangle\n\t\t\t// use already existing triangle edge vectors here\n\n\n\t\t\t_triangleNormal.crossVectors(_f0, _f1);
1\n\n\t\t\taxes = [_triangleNormal.x, _triangleNormal.y, _triangleNormal.z];\n\t\t\treturn satForAxes(axes, _v0, _v1, _v2, _extents);\n\t\t};\n\n\t\t_proto.clampPoint = function clampPoint(point, target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Box3: .clampPoint() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\treturn target.copy(point).clamp(this.min, this.max);\n\t\t};\n\n\t\t_proto.distanceToPoint = function distanceToPoint(point) {\n\t\t\tvar clampedPoint = _vector$1.copy(point).clamp(this.min, this.max);\n\n\t\t\treturn clampedPoint.sub(point).length();\n\t\t};\n\n\t\t_proto.getBoundingSphere = function getBoundingSphere(target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.error('THREE.Box3: .getBoundingSphere() target is now required'); //target = new Sphere(); // removed to avoid cyclic dependency\n\t\t\t}\n\n\t\t\tthis.getCenter(target.center);\n\t\t\ttarget.radius = this.getSize(_vector$1).length() * 0.5;\n\t\t\treturn target;\n\t\t};\n\n\t\t_proto.intersect = function intersect(box) {\n\t\t\tthis.min.max(box.min);\n\t\t\tthis.max.min(box.max); // ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values.\n\n\t\t\tif (this.isEmpty()) this.makeEmpty();\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.union = function union(box) {\n\t\t\tthis.min.min(box.min);\n\t\t\tthis.max.max(box.max);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.applyMatrix4 = function applyMatrix4(matrix) {\n\t\t\t// transform of empty box is an empty box.\n\t\t\tif (this.isEmpty()) return this; // NOTE: I am using a binary pattern to specify all 2^3 combinations below\n\n\t\t\t_points[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(matrix); // 000\n\n\n\t\t\t_points[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(matrix); // 001\n\n\n\t\t\t_points[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(matrix); // 010\n\n\n\t\t\t_points[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(matrix); // 011\n\n\n\t\t\t_points[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(matrix); // 100\n\n\n\t\t\t_points[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(matrix); // 101\n\n\n\t\t\t_points[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(matrix); // 110\n\n\n\t\t\t_points[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(matrix); // 111\n\n\n\t\t\tthis.setFromPoints(_points);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.translate = function translate(offset) {\n\t\t\tthis.min.add(offset);\n\t\t\tthis.max.add(offset);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.equals = function equals(box) {\n\t\t\treturn box.min.equals(this.min) && box.max.equals(this.max);\n\t\t};\n\n\t\treturn Box3;\n\t}();\n\n\tfunction satForAxes(axes, v0, v1, v2, extents) {\n\t\tfor (var i = 0, j = axes.length - 3; i <= j; i += 3) {\n\t\t\t_testAxis.fromArray(axes, i); // project the aabb onto the seperating axis\n\n\n\t\t\tvar r = extents.x * Math.abs(_testAxis.x) + extents.y * Math.abs(_testAxis.y) + extents.z * Math.abs(_testAxis.z); // project all 3 vertices of the triangle onto the seperating axis\n\n\t\t\tvar p0 = v0.dot(_testAxis);\n\t\t\tvar p1 = v1.dot(_testAxis);\n\t\t\tvar p2 = v2.dot(_testAxis); // actual test, basically see if either of the most extreme of the triangle points intersects r\n\n\t\t\tif (Math.max(-Math.max(p0, p1, p2), Math.min(p0, p1, p2)) > r) {\n\t\t\t\t// points of the projected triangle are outside the projected half-length of the aabb\n\t\t\t\t// the axis is seperating and we can exit\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tvar _points = [/*@__PURE__*/new Vector3(), /*@__PURE__*/new Vector3(), /*@__PURE__*/new Vector3(), /*@__PURE__*/new Vector3(), /*@__PURE__*/new Vector3(), /*@__PURE__*/new Vector3(), /*@__PURE__*/new Vector3(), /*@__PURE__*/new Vector3()];\n\n\tvar _vector$1 = /*@__PURE__*/new Vector3();\n\n\tvar _box = /*@__PURE__*/new Box3(); // triangle centered vertices\n\n\n\tvar _v0 = /*@__PURE__*/new Vector3();\n\n\tvar _v1 = /*@__PURE__*/new Vector3();\n\n\tvar _v2 = /*@__PURE__*/new Vector3(); // triangle edge vectors\n\n\n\tvar _f0 = /*@__PURE__*/new Vector3();\n\n\tvar _f1 = /*@__PURE__*/new Vector3();\n\n\tvar _f2 = /*@__PURE__*/new Vector3();\n\n\tvar _center = /*@__PURE__*/new Vector3();\n\n\tvar _extents = /*@__PURE__*/new Vector3();\n\n\tvar _triangleNormal = /*@__PURE__*/new Vector3();\n\n\tvar _testAxis = /*@__PURE__*/new Vector3();\n\n\tvar _box$1 = /*@__PURE__*/new Box3();\n\n\tvar Sphere = /*#__PURE__*/function () {\n\t\tfunction Sphere(center, radius) {\n\t\t\tthis.center = center !== undefined ? center : new Vector3();
1\n\t\t\tthis.radius = radius !== undefined ? radius : -1;\n\t\t}\n\n\t\tvar _proto = Sphere.prototype;\n\n\t\t_proto.set = function set(center, radius) {\n\t\t\tthis.center.copy(center);\n\t\t\tthis.radius = radius;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromPoints = function setFromPoints(points, optionalCenter) {\n\t\t\tvar center = this.center;\n\n\t\t\tif (optionalCenter !== undefined) {\n\t\t\t\tcenter.copy(optionalCenter);\n\t\t\t} else {\n\t\t\t\t_box$1.setFromPoints(points).getCenter(center);\n\t\t\t}\n\n\t\t\tvar maxRadiusSq = 0;\n\n\t\t\tfor (var i = 0, il = points.length; i < il; i++) {\n\t\t\t\tmaxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(points[i]));\n\t\t\t}\n\n\t\t\tthis.radius = Math.sqrt(maxRadiusSq);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t};\n\n\t\t_proto.copy = function copy(sphere) {\n\t\t\tthis.center.copy(sphere.center);\n\t\t\tthis.radius = sphere.radius;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.isEmpty = function isEmpty() {\n\t\t\treturn this.radius < 0;\n\t\t};\n\n\t\t_proto.makeEmpty = function makeEmpty() {\n\t\t\tthis.center.set(0, 0, 0);\n\t\t\tthis.radius = -1;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.containsPoint = function containsPoint(point) {\n\t\t\treturn point.distanceToSquared(this.center) <= this.radius * this.radius;\n\t\t};\n\n\t\t_proto.distanceToPoint = function distanceToPoint(point) {\n\t\t\treturn point.distanceTo(this.center) - this.radius;\n\t\t};\n\n\t\t_proto.intersectsSphere = function intersectsSphere(sphere) {\n\t\t\tvar radiusSum = this.radius + sphere.radius;\n\t\t\treturn sphere.center.distanceToSquared(this.center) <= radiusSum * radiusSum;\n\t\t};\n\n\t\t_proto.intersectsBox = function intersectsBox(box) {\n\t\t\treturn box.intersectsSphere(this);\n\t\t};\n\n\t\t_proto.intersectsPlane = function intersectsPlane(plane) {\n\t\t\treturn Math.abs(plane.distanceToPoint(this.center)) <= this.radius;\n\t\t};\n\n\t\t_proto.clampPoint = function clampPoint(point, target) {\n\t\t\tvar deltaLengthSq = this.center.distanceToSquared(point);\n\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Sphere: .clampPoint() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\ttarget.copy(point);\n\n\t\t\tif (deltaLengthSq > this.radius * this.radius) {\n\t\t\t\ttarget.sub(this.center).normalize();\n\t\t\t\ttarget.multiplyScalar(this.radius).add(this.center);\n\t\t\t}\n\n\t\t\treturn target;\n\t\t};\n\n\t\t_proto.getBoundingBox = function getBoundingBox(target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Sphere: .getBoundingBox() target is now required');\n\t\t\t\ttarget = new Box3();\n\t\t\t}\n\n\t\t\tif (this.isEmpty()) {\n\t\t\t\t// Empty sphere produces empty bounding box\n\t\t\t\ttarget.makeEmpty();\n\t\t\t\treturn target;\n\t\t\t}\n\n\t\t\ttarget.set(this.center, this.center);\n\t\t\ttarget.expandByScalar(this.radius);\n\t\t\treturn target;\n\t\t};\n\n\t\t_proto.applyMatrix4 = function applyMatrix4(matrix) {\n\t\t\tthis.center.applyMatrix4(matrix);\n\t\t\tthis.radius = this.radius * matrix.getMaxScaleOnAxis();\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.translate = function translate(offset) {\n\t\t\tthis.center.add(offset);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.equals = function equals(sphere) {\n\t\t\treturn sphere.center.equals(this.center) && sphere.radius === this.radius;\n\t\t};\n\n\t\treturn Sphere;\n\t}();\n\n\tvar _vector$2 = /*@__PURE__*/new Vector3();\n\n\tvar _segCenter = /*@__PURE__*/new Vector3();\n\n\tvar _segDir = /*@__PURE__*/new Vector3();\n\n\tvar _diff = /*@__PURE__*/new Vector3();\n\n\tvar _edge1 = /*@__PURE__*/new Vector3();\n\n\tvar _edge2 = /*@__PURE__*/new Vector3();\n\n\tvar _normal = /*@__PURE__*/new Vector3();\n\n\tvar Ray = /*#__PURE__*/function () {\n\t\tfunction Ray(origin, direction) {\n\t\t\tthis.origin = origin !== undefined ? origin : new Vector3();\n\t\t\tthis.direction = direction !== undefined ? direction : new Vector3(0, 0, -1);\n\t\t}\n\n\t\tvar _proto = Ray.prototype;\n\n\t\t_proto.set = function set(origin, direction) {\n\t\t\tthis.origin.copy(origin);\n\t\t\tthis.direction.copy(direction);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t};\n\n\t\t_proto.copy = function copy(ray) {\n\t\t\tthis.origin.copy(ray.origin);\n\t\t\tthis.direction.copy(ray.direction);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.at = function at(t, target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Ray: .at() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\treturn target.copy(this.direction).multiplyScalar(t).add(this.origin);\n\t\t};\n\n\t\t_proto.lookAt = function lookAt(v) {\n\t\t\tthis.direction.copy(v).sub(this.origin).normalize();\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.recast = function recast(t) {\n\t\t\tthis.origin.copy(this.at(t, _vector$2));\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.closestPointToPoint = function closestPointToPoint(point, target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Ray: .closestPointToPoint() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\ttarget.subVectors(point, this.origin);
1\n\t\t\tvar directionDistance = target.dot(this.direction);\n\n\t\t\tif (directionDistance < 0) {\n\t\t\t\treturn target.copy(this.origin);\n\t\t\t}\n\n\t\t\treturn target.copy(this.direction).multiplyScalar(directionDistance).add(this.origin);\n\t\t};\n\n\t\t_proto.distanceToPoint = function distanceToPoint(point) {\n\t\t\treturn Math.sqrt(this.distanceSqToPoint(point));\n\t\t};\n\n\t\t_proto.distanceSqToPoint = function distanceSqToPoint(point) {\n\t\t\tvar directionDistance = _vector$2.subVectors(point, this.origin).dot(this.direction); // point behind the ray\n\n\n\t\t\tif (directionDistance < 0) {\n\t\t\t\treturn this.origin.distanceToSquared(point);\n\t\t\t}\n\n\t\t\t_vector$2.copy(this.direction).multiplyScalar(directionDistance).add(this.origin);\n\n\t\t\treturn _vector$2.distanceToSquared(point);\n\t\t};\n\n\t\t_proto.distanceSqToSegment = function distanceSqToSegment(v0, v1, optionalPointOnRay, optionalPointOnSegment) {\n\t\t\t// from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistRaySegment.h\n\t\t\t// It returns the min distance between the ray and the segment\n\t\t\t// defined by v0 and v1\n\t\t\t// It can also set two optional targets :\n\t\t\t// - The closest point on the ray\n\t\t\t// - The closest point on the segment\n\t\t\t_segCenter.copy(v0).add(v1).multiplyScalar(0.5);\n\n\t\t\t_segDir.copy(v1).sub(v0).normalize();\n\n\t\t\t_diff.copy(this.origin).sub(_segCenter);\n\n\t\t\tvar segExtent = v0.distanceTo(v1) * 0.5;\n\t\t\tvar a01 = -this.direction.dot(_segDir);\n\n\t\t\tvar b0 = _diff.dot(this.direction);\n\n\t\t\tvar b1 = -_diff.dot(_segDir);\n\n\t\t\tvar c = _diff.lengthSq();\n\n\t\t\tvar det = Math.abs(1 - a01 * a01);\n\t\t\tvar s0, s1, sqrDist, extDet;\n\n\t\t\tif (det > 0) {\n\t\t\t\t// The ray and segment are not parallel.\n\t\t\t\ts0 = a01 * b1 - b0;\n\t\t\t\ts1 = a01 * b0 - b1;\n\t\t\t\textDet = segExtent * det;\n\n\t\t\t\tif (s0 >= 0) {\n\t\t\t\t\tif (s1 >= -extDet) {\n\t\t\t\t\t\tif (s1 <= extDet) {\n\t\t\t\t\t\t\t// region 0\n\t\t\t\t\t\t\t// Minimum at interior points of ray and segment.\n\t\t\t\t\t\t\tvar invDet = 1 / det;\n\t\t\t\t\t\t\ts0 *= invDet;\n\t\t\t\t\t\t\ts1 *= invDet;\n\t\t\t\t\t\t\tsqrDist = s0 * (s0 + a01 * s1 + 2 * b0) + s1 * (a01 * s0 + s1 + 2 * b1) + c;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// region 1\n\t\t\t\t\t\t\ts1 = segExtent;\n\t\t\t\t\t\t\ts0 = Math.max(0, -(a01 * s1 + b0));\n\t\t\t\t\t\t\tsqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// region 5\n\t\t\t\t\t\ts1 = -segExtent;\n\t\t\t\t\t\ts0 = Math.max(0, -(a01 * s1 + b0));\n\t\t\t\t\t\tsqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (s1 <= -extDet) {\n\t\t\t\t\t\t// region 4\n\t\t\t\t\t\ts0 = Math.max(0, -(-a01 * segExtent + b0));\n\t\t\t\t\t\ts1 = s0 > 0 ? -segExtent : Math.min(Math.max(-segExtent, -b1), segExtent);\n\t\t\t\t\t\tsqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;\n\t\t\t\t\t} else if (s1 <= extDet) {\n\t\t\t\t\t\t// region 3\n\t\t\t\t\t\ts0 = 0;\n\t\t\t\t\t\ts1 = Math.min(Math.max(-segExtent, -b1), segExtent);\n\t\t\t\t\t\tsqrDist = s1 * (s1 + 2 * b1) + c;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// region 2\n\t\t\t\t\t\ts0 = Math.max(0, -(a01 * segExtent + b0));\n\t\t\t\t\t\ts1 = s0 > 0 ? segExtent : Math.min(Math.max(-segExtent, -b1), segExtent);\n\t\t\t\t\t\tsqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Ray and segment are parallel.\n\t\t\t\ts1 = a01 > 0 ? -segExtent : segExtent;\n\t\t\t\ts0 = Math.max(0, -(a01 * s1 + b0));\n\t\t\t\tsqrDist = -s0 * s0 + s1 * (s1 + 2 * b1) + c;\n\t\t\t}\n\n\t\t\tif (optionalPointOnRay) {\n\t\t\t\toptionalPointOnRay.copy(this.direction).multiplyScalar(s0).add(this.origin);\n\t\t\t}\n\n\t\t\tif (optionalPointOnSegment) {\n\t\t\t\toptionalPointOnSegment.copy(_segDir).multiplyScalar(s1).add(_segCenter);\n\t\t\t}\n\n\t\t\treturn sqrDist;\n\t\t};\n\n\t\t_proto.intersectSphere = function intersectSphere(sphere, target) {\n\t\t\t_vector$2.subVectors(sphere.center, this.origin);\n\n\t\t\tvar tca = _vector$2.dot(this.direction);\n\n\t\t\tvar d2 = _vector$2.dot(_vector$2) - tca * tca;\n\t\t\tvar radius2 = sphere.radius * sphere.radius;\n\t\t\tif (d2 > radius2) return null;\n\t\t\tvar thc = Math.sqrt(radius2 - d2); // t0 = first intersect point - entrance on front of sphere\n\n\t\t\tvar t0 = tca - thc; // t1 = second intersect point - exit point on back of sphere\n\n\t\t\tvar t1 = tca + thc; // test to see if both t0 and t1 are behind the ray - if so, return null\n\n\t\t\tif (t0 < 0 && t1 < 0) return null; // test to see if t0 is behind the ray:\n\t\t\t// if it is, the ray is inside the sphere, so return the second exit point scaled by t1,\n\t\t\t// in order to always return an intersect point that is in front of the ray.\n\n\t\t\tif (t0 < 0) return this.at(t1, target); // else t0 is in front of the ray, so return the first collision point scaled by t0\n\n\t\t\treturn this.at(t0, target);\n\t\t};\n\n\t\t_proto.intersectsSphere = function intersectsSphere(sphere) {\n\t\t\treturn this.distanceSqToPoint(sphere.center) <= sphere.radius * sphere.radius;\n\t\t};\n\n\t\t_proto.distanceToPlane = function distanceToPlane(plane) {\n\t\t\tvar denominator = plane.normal.dot(this.direction);\n\n\t\t\tif (denominator === 0) {\n\t\t\t\t// line is coplanar, return origin\n\t\t\t\tif (plane.distanceToPoint(this.origin) === 0) {\n\t\t\t\t\treturn 0;\n\t\t\t\t} // Null is preferable to undefined since undefined means.... it is undefined\n\n\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tvar t = -(this.origin.dot(plane.normal) + plane.constant) / denominator; // Return if the ray never intersects the plane\n\n\t\t\treturn t >= 0 ? t : null;\n\t\t};\n\n\t\t_proto.intersectPlane = function intersectPlane(plane, target) {\n\t\t\tvar t = this.distanceToPlane(plane);\n\n\t\t\tif (t === null) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn this.at(t, target);\n\t\t};\n\n\t\t_proto.intersectsPlane = function intersectsPlane(plane) {\n\t\t\t// check if the ray lies on the plane first\n\t\t\tvar distToPoint = plane.distanceToPoint(this.origin);\n\n\t\t\tif (distToPoint === 0) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tvar denominator = plane.normal.dot(this.direction);\n\n\t\t\tif (denominator * distToPoint < 0) {\n\t\t\t\treturn true;\n\t\t\t} // ray origin is behind the plane (and is pointing behind it)\n\n\n\t\t\treturn false;\n\t\t};\n\n\t\t_proto.intersectBox = function intersectBox(box, target) {\n\t\t\tvar tmin, tmax, tymin, tymax, tzmin, tzmax;\n\t\t\tvar invdirx = 1 / this.direction.x,\n\t\t\t\t\tinvdiry = 1 / this.direction.y,\n\t\t\t\t\tinvdirz = 1 / this.direction.z;\n\t\t\tvar origin = this.origin;\n\n\t\t\tif (invdirx >= 0) {\n\t\t\t\ttmin = (box.min.x - origin.x) * invdirx;\n\t\t\t\ttmax = (box.max.x - origin.x) * invdirx;\n\t\t\t} else {\n\t\t\t\ttmin = (box.max.x - origin.x) * invdirx;\n\t\t\t\ttmax = (box.min.x - origin.x) * invdirx;\n\t\t\t}\n\n\t\t\tif (invdiry >= 0) {\n\t\t\t\ttymin = (box.min.y - origin.y) * invdiry;\n\t\t\t\ttymax = (box.max.y - origin.y) * invdiry;\n\t\t\t} else {\n\t\t\t\ttymin = (box.max.y - origin.y) * invdiry;\n\t\t\t\ttymax = (box.min.y - origin.y) * invdiry;\n\t\t\t}\n\n\t\t\tif (tmin > tymax || tymin > tmax) return null; // These lines also handle the case where tmin or tmax is NaN\n\t\t\t// (result of 0 * Infinity). x !== x returns true if x is N
1aN\n\n\t\t\tif (tymin > tmin || tmin !== tmin) tmin = tymin;\n\t\t\tif (tymax < tmax || tmax !== tmax) tmax = tymax;\n\n\t\t\tif (invdirz >= 0) {\n\t\t\t\ttzmin = (box.min.z - origin.z) * invdirz;\n\t\t\t\ttzmax = (box.max.z - origin.z) * invdirz;\n\t\t\t} else {\n\t\t\t\ttzmin = (box.max.z - origin.z) * invdirz;\n\t\t\t\ttzmax = (box.min.z - origin.z) * invdirz;\n\t\t\t}\n\n\t\t\tif (tmin > tzmax || tzmin > tmax) return null;\n\t\t\tif (tzmin > tmin || tmin !== tmin) tmin = tzmin;\n\t\t\tif (tzmax < tmax || tmax !== tmax) tmax = tzmax; //return point closest to the ray (positive side)\n\n\t\t\tif (tmax < 0) return null;\n\t\t\treturn this.at(tmin >= 0 ? tmin : tmax, target);\n\t\t};\n\n\t\t_proto.intersectsBox = function intersectsBox(box) {\n\t\t\treturn this.intersectBox(box, _vector$2) !== null;\n\t\t};\n\n\t\t_proto.intersectTriangle = function intersectTriangle(a, b, c, backfaceCulling, target) {\n\t\t\t// Compute the offset origin, edges, and normal.\n\t\t\t// from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h\n\t\t\t_edge1.subVectors(b, a);\n\n\t\t\t_edge2.subVectors(c, a);\n\n\t\t\t_normal.crossVectors(_edge1, _edge2); // Solve Q + t*D = b1*E1 + b2*E2 (Q = kDiff, D = ray direction,\n\t\t\t// E1 = kEdge1, E2 = kEdge2, N = Cross(E1,E2)) by\n\t\t\t//\t |Dot(D,N)|*b1 = sign(Dot(D,N))*Dot(D,Cross(Q,E2))\n\t\t\t//\t |Dot(D,N)|*b2 = sign(Dot(D,N))*Dot(D,Cross(E1,Q))\n\t\t\t//\t |Dot(D,N)|*t = -sign(Dot(D,N))*Dot(Q,N)\n\n\n\t\t\tvar DdN = this.direction.dot(_normal);\n\t\t\tvar sign;\n\n\t\t\tif (DdN > 0) {\n\t\t\t\tif (backfaceCulling) return null;\n\t\t\t\tsign = 1;\n\t\t\t} else if (DdN < 0) {\n\t\t\t\tsign = -1;\n\t\t\t\tDdN = -DdN;\n\t\t\t} else {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t_diff.subVectors(this.origin, a);\n\n\t\t\tvar DdQxE2 = sign * this.direction.dot(_edge2.crossVectors(_diff, _edge2)); // b1 < 0, no intersection\n\n\t\t\tif (DdQxE2 < 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tvar DdE1xQ = sign * this.direction.dot(_edge1.cross(_diff)); // b2 < 0, no intersection\n\n\t\t\tif (DdE1xQ < 0) {\n\t\t\t\treturn null;\n\t\t\t} // b1+b2 > 1, no intersection\n\n\n\t\t\tif (DdQxE2 + DdE1xQ > DdN) {\n\t\t\t\treturn null;\n\t\t\t} // Line intersects triangle, check if ray does.\n\n\n\t\t\tvar QdN = -sign * _diff.dot(_normal); // t < 0, no intersection\n\n\n\t\t\tif (QdN < 0) {\n\t\t\t\treturn null;\n\t\t\t} // Ray intersects triangle.\n\n\n\t\t\treturn this.at(QdN / DdN, target);\n\t\t};\n\n\t\t_proto.applyMatrix4 = function applyMatrix4(matrix4) {\n\t\t\tthis.origin.applyMatrix4(matrix4);\n\t\t\tthis.direction.transformDirection(matrix4);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.equals = function equals(ray) {\n\t\t\treturn ray.origin.equals(this.origin) && ray.direction.equals(this.direction);\n\t\t};\n\n\t\treturn Ray;\n\t}();\n\n\tvar Matrix4 = /*#__PURE__*/function () {\n\t\tfunction Matrix4() {\n\t\t\tObject.defineProperty(this, 'isMatrix4', {\n\t\t\t\tvalue: true\n\t\t\t});\n\t\t\tthis.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];\n\n\t\t\tif (arguments.length > 0) {\n\t\t\t\tconsole.error('THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.');\n\t\t\t}\n\t\t}\n\n\t\tvar _proto = Matrix4.prototype;\n\n\t\t_proto.set = function set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {\n\t\t\tvar te = this.elements;\n\t\t\tte[0] = n11;\n\t\t\tte[4] = n12;\n\t\t\tte[8] = n13;\n\t\t\tte[12] = n14;\n\t\t\tte[1] = n21;\n\t\t\tte[5] = n22;\n\t\t\tte[9] = n23;\n\t\t\tte[13] = n24;\n\t\t\tte[2] = n31;\n\t\t\tte[6] = n32;\n\t\t\tte[10] = n33;\n\t\t\tte[14] = n34;\n\t\t\tte[3] = n41;\n\t\t\tte[7] = n42;\n\t\t\tte[11] = n43;\n\t\t\tte[15] = n44;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.identity = function identity() {\n\t\t\tthis.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new Matrix4().fromArray(this.elements);\n\t\t};\n\n\t\t_proto.copy = function copy(m) {\n\t\t\tvar te = this.elements;\n\t\t\tvar me = m.elements;\n\t\t\tte[0] = me[0];\n\t\t\tte[1] = me[1];\n\t\t\tte[2] = me[2];\n\t\t\tte[3] = me[3];\n\t\t\tte[4] = me[4];\n\t\t\tte[5] = me[5];\n\t\t\tte[6] = me[6];\n\t\t\tte[7] = me[7];\n\t\t\tte[8] = me[8];\n\t\t\tte[9] = me[9];\n\t\t\tte[10] = me[10];\n\t\t\tte[11] = me[11];\n\t\t\tte[12] = me[12];\n\t\t\tte[13] = me[13];\n\t\t\tte[14] = me[14];\n\t\t\tte[15] = me[15];\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.copyPosition = function copyPosition(m) {\n\t\t\tvar te = this.elements,\n\t\t\t\t\tme = m.elements;\n\t\t\tte[12] = me[12];\n\t\t\tte[13] = me[13];\n\t\t\tte[14] = me[14];\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.extractBasis = function extractBasis(xAxis, yAxis, zAxis) {\n\t\t\txAxis.setFromMatrixColumn(this, 0);\n\t\t\tyAxis.setFromMatrixColumn(this, 1);\n\t\t\tzAxis.setFromMatrixColumn(this, 2);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.makeBasis = function makeBasis(xAxis, yAxis, zAxis) {\n\t\t\tthis.set(xAxis.x, yAxis.x, zAxis.x, 0, xAxis.y, yAxis.y, zAxis.y, 0, xAxis.z, yAxis.z, zAxis.z,
10, 0, 0, 0, 1);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.extractRotation = function extractRotation(m) {\n\t\t\t// this method does not support reflection matrices\n\t\t\tvar te = this.elements;\n\t\t\tvar me = m.elements;\n\n\t\t\tvar scaleX = 1 / _v1$1.setFromMatrixColumn(m, 0).length();\n\n\t\t\tvar scaleY = 1 / _v1$1.setFromMatrixColumn(m, 1).length();\n\n\t\t\tvar scaleZ = 1 / _v1$1.setFromMatrixColumn(m, 2).length();\n\n\t\t\tte[0] = me[0] * scaleX;\n\t\t\tte[1] = me[1] * scaleX;\n\t\t\tte[2] = me[2] * scaleX;\n\t\t\tte[3] = 0;\n\t\t\tte[4] = me[4] * scaleY;\n\t\t\tte[5] = me[5] * scaleY;\n\t\t\tte[6] = me[6] * scaleY;\n\t\t\tte[7] = 0;\n\t\t\tte[8] = me[8] * scaleZ;\n\t\t\tte[9] = me[9] * scaleZ;\n\t\t\tte[10] = me[10] * scaleZ;\n\t\t\tte[11] = 0;\n\t\t\tte[12] = 0;\n\t\t\tte[13] = 0;\n\t\t\tte[14] = 0;\n\t\t\tte[15] = 1;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.makeRotationFromEuler = function makeRotationFromEuler(euler) {\n\t\t\tif (!(euler && euler.isEuler)) {\n\t\t\t\tconsole.error('THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.');\n\t\t\t}\n\n\t\t\tvar te = this.elements;\n\t\t\tvar x = euler.x,\n\t\t\t\t\ty = euler.y,\n\t\t\t\t\tz = euler.z;\n\t\t\tvar a = Math.cos(x),\n\t\t\t\t\tb = Math.sin(x);\n\t\t\tvar c = Math.cos(y),\n\t\t\t\t\td = Math.sin(y);\n\t\t\tvar e = Math.cos(z),\n\t\t\t\t\tf = Math.sin(z);\n\n\t\t\tif (euler.order === 'XYZ') {\n\t\t\t\tvar ae = a * e,\n\t\t\t\t\t\taf = a * f,\n\t\t\t\t\t\tbe = b * e,\n\t\t\t\t\t\tbf = b * f;\n\t\t\t\tte[0] = c * e;\n\t\t\t\tte[4] = -c * f;\n\t\t\t\tte[8] = d;\n\t\t\t\tte[1] = af + be * d;\n\t\t\t\tte[5] = ae - bf * d;\n\t\t\t\tte[9] = -b * c;\n\t\t\t\tte[2] = bf - ae * d;\n\t\t\t\tte[6] = be + af * d;\n\t\t\t\tte[10] = a * c;\n\t\t\t} else if (euler.order === 'YXZ') {\n\t\t\t\tvar ce = c * e,\n\t\t\t\t\t\tcf = c * f,\n\t\t\t\t\t\tde = d * e,\n\t\t\t\t\t\tdf = d * f;\n\t\t\t\tte[0] = ce + df * b;\n\t\t\t\tte[4] = de * b - cf;\n\t\t\t\tte[8] = a * d;\n\t\t\t\tte[1] = a * f;\n\t\t\t\tte[5] = a * e;\n\t\t\t\tte[9] = -b;\n\t\t\t\tte[2] = cf * b - de;\n\t\t\t\tte[6] = df + ce * b;\n\t\t\t\tte[10] = a * c;\n\t\t\t} else if (euler.order === 'ZXY') {\n\t\t\t\tvar _ce = c * e,\n\t\t\t\t\t\t_cf = c * f,\n\t\t\t\t\t\t_de = d * e,\n\t\t\t\t\t\t_df = d * f;\n\n\t\t\t\tte[0] = _ce - _df * b;\n\t\t\t\tte[4] = -a * f;\n\t\t\t\tte[8] = _de + _cf * b;\n\t\t\t\tte[1] = _cf + _de * b;\n\t\t\t\tte[5] = a * e;\n\t\t\t\tte[9] = _df - _ce * b;\n\t\t\t\tte[2] = -a * d;\n\t\t\t\tte[6] = b;\n\t\t\t\tte[10] = a * c;\n\t\t\t} else if (euler.order === 'ZYX') {\n\t\t\t\tvar _ae = a * e,\n\t\t\t\t\t\t_af = a * f,\n\t\t\t\t\t\t_be = b * e,\n\t\t\t\t\t\t_bf = b * f;\n\n\t\t\t\tte[0] = c * e;\n\t\t\t\tte[4] = _be * d - _af;\n\t\t\t\tte[8] = _ae * d + _bf;\n\t\t\t\tte[1] = c * f;\n\t\t\t\tte[5] = _bf * d + _ae;\n\t\t\t\tte[9] = _af * d - _be;\n\t\t\t\tte[2] = -d;\n\t\t\t\tte[6] = b * c;\n\t\t\t\tte[10] = a * c;\n\t\t\t} else if (euler.order === 'YZX') {\n\t\t\t\tvar ac = a * c,\n\t\t\t\t\t\tad = a * d,\n\t\t\t\t\t\tbc = b * c,\n\t\t\t\t\t\tbd = b * d;\n\t\t\t\tte[0] = c * e;\n\t\t\t\tte[4] = bd - ac * f;\n\t\t\t\tte[8] = bc * f + ad;\n\t\t\t\tte[1] = f;\n\t\t\t\tte[5] = a * e;\n\t\t\t\tte[9] = -b * e;\n\t\t\t\tte[2] = -d * e;\n\t\t\t\tte[6] = ad * f + bc;\n\t\t\t\tte[10] = ac - bd * f;\n\t\t\t} else if (euler.order === 'XZY') {\n\t\t\t\tvar _ac = a * c,\n\t\t\t\t\t\t_ad = a * d,\n\t\t\t\t\t\t_bc = b * c,\n\t\t\t\t\t\t_bd = b * d;\n\n\t\t\t\tte[0] = c * e;\n\t\t\t\tte[4] = -f;\n\t\t\t\tte[8] = d * e;\n\t\t\t\tte[1] = _ac * f + _bd;\n\t\t\t\tte[5] = a * e;\n\t\t\t\tte[9] = _ad * f - _bc;\n\t\t\t\tte[2] = _bc * f - _ad;\n\t\t\t\tte[6] = b * e;\n\t\t\t\tte[10] = _bd * f + _ac;\n\t\t\t} // bottom row\n\n\n\t\t\tte[3] = 0;\n\t\t\tte[7] = 0;\n\t\t\tte[11] = 0; // last column\n\n\t\t\tte[12] = 0;\n\t\t\tte[13] = 0;\n\t\t\tte[14] = 0;\n\t\t\tte[15] = 1;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.makeRotationFromQuaternion = function makeRotationFromQuaternion(q) {\n\t\t\treturn this.compose(_zero, q, _one);\n\t\t};\n\n\t\t_proto.lookAt = function lookAt(eye, target, up) {\n\t\t\tvar te = this.elements;\n\n\t\t\t_z.subVectors(eye, target);\n\n\t\t\tif (_z.lengthSq() === 0) {\n\t\t\t\t// eye and target are in the same position\n\t\t\t\t_z.z = 1;\n\t\t\t}\n\n\t\t\t_z.normalize();\n\n\t\t\t_x.crossVectors(up, _z);\n\n\t\t\tif (_x.lengthSq() === 0) {\n\t\t\t\t// up and z are parallel\n\t\t\t\tif (Math.abs(up.z) === 1) {\n\t\t\t\t\t_z.x += 0.0001;\n\t\t\t\t} else {\n\t\t\t\t\t_z.z += 0.0001;\n\t\t\t\t}\n\n\t\t\t\t_z.normalize();\n\n\t\t\t\t_x.crossVectors(up, _z);\n\t\t\t}\n\n\t\t\t_x.normalize();\n\n\t\t\t_y.crossVectors(_z, _x);\n\n\t\t\tte[0] = _x.x;\n\t\t\tte[4] = _y.x;\n\t\t\tte[8] = _z.x;\n\t\t\tte[1] = _x.y;\n\t\t\tte[5] = _y.y;\n\t\t\tte[9] = _z.y;\n\t\t\tte[2] = _x.z;\n\t\t\tte[6] = _y.z;\n\t\t\tte[10] = _z.z;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.multiply = function multiply(m, n) {\n\t\t\tif (n !== undefined) {\n\t\t\t\tconsole.warn('THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.');\n\t\t\t\treturn this.multiplyMatrices(m, n);\n\t\t\t}\n\n\t\t\treturn this.multiplyMatrices(this, m);\n\t\t};\n\n\t\t_proto.premultiply = function premultiply(m) {\n\t\t\treturn this.multiplyMatrices(m, this);\n\t\t};\n\n\t\t_proto.multiplyMatrices = function multiplyMatrices(a, b) {\n\t\t\tvar ae = a.elements;\n\t\t\tvar be = b.elements;\n\t\t\tvar te = this.elements;\n\t\t\tvar a11 = ae[0],\n\t\t\t\t\ta12 = ae[4],\n\t\t\t\t\ta13 = ae[8],\n\t\t\t\t\ta14 = ae[12];\n\t\t\tvar a21 = ae[1],\n\t\t\t\t\ta22 = ae[5],\n\t\t\t\t\ta23 = ae[9],\n\t\t\t\t\ta24 = ae[13];\n\t\t\tvar a31 = ae[2],\n\t\t\t\t\ta32 = ae[6],\n\t\t\t\t\ta33 = ae[10],\n\t\t\t\t\ta34 = ae[14];\n\t\t\tvar a41 = ae[3],\n\t\t\t\t\ta42 = ae[7],\n\t\t\t\t\ta43 = ae[11],\n\t\t\t\t\ta44 = ae[15];\n\t\t\tvar b11 = be[0],\n\t\t\t\t\tb12 = be[4],\n\t\t\t\t\tb13 = be[8],\n\t\t\t\t\tb14 = be[12];\n\t\t\tvar b21 = be[1],\n\t\t\t\t\tb22 = be[5],\n\t\t\t\t\tb23 = be[9],\n\t\t\t\t\tb24 = be[13];\n\t\t\tvar b31 = be[2],\n\t\t\t\t\tb32 = be[6],\n\t\t\t\t\tb33 = be[10],\n\t\t\t\t\tb34 = be[14];\n\t\t\tvar b41 = be[3],\n\t\t\t\t\tb42 = be[7],\n\t\t\t\t\tb43 = be[11],\
1n\t\t\t\t\tb44 = be[15];\n\t\t\tte[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;\n\t\t\tte[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;\n\t\t\tte[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;\n\t\t\tte[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;\n\t\t\tte[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;\n\t\t\tte[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;\n\t\t\tte[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;\n\t\t\tte[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;\n\t\t\tte[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;\n\t\t\tte[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;\n\t\t\tte[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;\n\t\t\tte[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;\n\t\t\tte[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;\n\t\t\tte[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;\n\t\t\tte[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;\n\t\t\tte[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.multiplyScalar = function multiplyScalar(s) {\n\t\t\tvar te = this.elements;\n\t\t\tte[0] *= s;\n\t\t\tte[4] *= s;\n\t\t\tte[8] *= s;\n\t\t\tte[12] *= s;\n\t\t\tte[1] *= s;\n\t\t\tte[5] *= s;\n\t\t\tte[9] *= s;\n\t\t\tte[13] *= s;\n\t\t\tte[2] *= s;\n\t\t\tte[6] *= s;\n\t\t\tte[10] *= s;\n\t\t\tte[14] *= s;\n\t\t\tte[3] *= s;\n\t\t\tte[7] *= s;\n\t\t\tte[11] *= s;\n\t\t\tte[15] *= s;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.determinant = function determinant() {\n\t\t\tvar te = this.elements;\n\t\t\tvar n11 = te[0],\n\t\t\t\t\tn12 = te[4],\n\t\t\t\t\tn13 = te[8],\n\t\t\t\t\tn14 = te[12];\n\t\t\tvar n21 = te[1],\n\t\t\t\t\tn22 = te[5],\n\t\t\t\t\tn23 = te[9],\n\t\t\t\t\tn24 = te[13];\n\t\t\tvar n31 = te[2],\n\t\t\t\t\tn32 = te[6],\n\t\t\t\t\tn33 = te[10],\n\t\t\t\t\tn34 = te[14];\n\t\t\tvar n41 = te[3],\n\t\t\t\t\tn42 = te[7],\n\t\t\t\t\tn43 = te[11],\
1n\t\t\t\t\tn44 = te[15]; //TODO: make this more efficient\n\t\t\t//( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )\n\n\t\t\treturn n41 * (+n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34) + n42 * (+n11 * n23 * n34 - n11 * n24 * n33 + n14 * n21 * n33 - n13 * n21 * n34 + n13 * n24 * n31 - n14 * n23 * n31) + n43 * (+n11 * n24 * n32 - n11 * n22 * n34 - n14 * n21 * n32 + n12 * n21 * n34 + n14 * n22 * n31 - n12 * n24 * n31) + n44 * (-n13 * n22 * n31 - n11 * n23 * n32 + n11 * n22 * n33 + n13 * n21 * n32 - n12 * n21 * n33 + n12 * n23 * n31);\n\t\t};\n\n\t\t_proto.transpose = function transpose() {\n\t\t\tvar te = this.elements;\n\t\t\tvar tmp;\n\t\t\ttmp = te[1];\n\t\t\tte[1] = te[4];\n\t\t\tte[4] = tmp;\n\t\t\ttmp = te[2];\n\t\t\tte[2] = te[8];\n\t\t\tte[8] = tmp;\n\t\t\ttmp = te[6];\n\t\t\tte[6] = te[9];\n\t\t\tte[9] = tmp;\n\t\t\ttmp = te[3];\n\t\t\tte[3] = te[12];\n\t\t\tte[12] = tmp;\n\t\t\ttmp = te[7];\n\t\t\tte[7] = te[13];\n\t\t\tte[13] = tmp;\n\t\t\ttmp = te[11];\n\t\t\tte[11] = te[14];\n\t\t\tte[14] = tmp;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setPosition = function setPosition(x, y, z) {\n\t\t\tvar te = this.elements;\n\n\t\t\tif (x.isVector3) {\n\t\t\t\tte[12] = x.x;\n\t\t\t\tte[13] = x.y;\n\t\t\t\tte[14] = x.z;\n\t\t\t} else {\n\t\t\t\tte[12] = x;\n\t\t\t\tte[13] = y;\n\t\t\t\tte[14] = z;\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.invert = function invert() {\n\t\t\t// based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm\n\t\t\tvar te = this.elements,\n\t\t\t\t\tn11 = te[0],\n\t\t\t\t\tn21 = te[1],\n\t\t\t\t\tn31 = te[2],\n\t\t\t\t\tn41 = te[3],\n\t\t\t\t\tn12 = te[4],\n\t\t\t\t\tn22 = te[5],\n\t\t\t\t\tn32 = te[6],\n\t\t\t\t\tn42 = te[7],\n\t\t\t\t\tn13 = te[8],\n\t\t\t\t\tn23 = te[9],\n\t\t\t\t\tn33 = te[10],\n\t\t\t\t\tn43 = te[11],\
1n\t\t\t\t\tn14 = te[12],\n\t\t\t\t\tn24 = te[13],\n\t\t\t\t\tn34 = te[14],\n\t\t\t\t\tn44 = te[15],\n\t\t\t\t\tt11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,\n\t\t\t\t\tt12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,\n\t\t\t\t\tt13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,\n\t\t\t\t\tt14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;\n\t\t\tvar det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;\n\t\t\tif (det === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\n\t\t\tvar detInv = 1 / det;\n\t\t\tte[0] = t11 * detInv;\n\t\t\tte[1] = (n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44) * detInv;\n\t\t\tte[2] = (n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44) * detInv;\n\t\t\tte[3] = (n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43) * detInv;\n\t\t\tte[4] = t12 * detInv;\n\t\t\tte[5] = (n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44) * detInv;\n\t\t\tte[6] = (n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44) * detInv;\n\t\t\tte[7] = (n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43) * detInv;\n\t\t\tte[8] = t13 * detInv;\n\t\t\tte[9] = (n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44) * detInv;\n\t\t\tte[10] = (n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44) * detInv;\n\t\t\tte[11] = (n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43) * detInv;\n\t\t\tte[12] = t14 * detInv;\n\t\t\tte[13] = (n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34) * detInv;\n\t\t\tte[14] = (n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34) * detInv;\n\t\t\tte[15] = (n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33) * detInv;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.scale = function scale(v) {\n\t\t\tvar te = this.elements;\n\t\t\tvar x = v.x,\n\t\t\t\t\ty = v.y,\n\t\t\t\t\tz = v.z;\n\t\t\tte[0] *= x;\n\t\t\tte[4] *= y;\n\t\t\tte[8] *= z;\n\t\t\tte[1] *= x;\n\t\t\tte[5] *= y;\n\t\t\tte[9] *= z;\n\t\t\tte[2] *= x;\n\t\t\tte[6] *= y;\n\t\t\tte[10] *= z;\n\t\t\tte[3] *= x;\n\t\t\tte[7] *= y;\n\t\t\tte[11] *= z;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.getMaxScaleOnAxis = function getMaxScaleOnAxis() {\n\t\t\tvar te = this.elements;\n\t\t\tvar scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2];\n\t\t\tvar scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6];\n\t\t\tvar scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10];\n\t\t\treturn Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));\n\t\t};\n\n\t\t_proto.makeTranslation = function makeTranslation(x, y, z) {\n\t\t\tthis.set(1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.makeRotationX = function makeRotationX(theta) {\n\t\t\tvar c = Math.cos(theta),\n\t\t\t\t\ts = Math.sin(theta);\n\t\t\tthis.set(1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.makeRotationY = function makeRotationY(theta) {\n\t\t\tvar c = Math.cos(theta),\n\t\t\t\t\ts = Math.sin(theta);\n\t\t\tthis.set(c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.makeRotationZ = function makeRotationZ(theta) {\n\t\t\tvar c = Math.cos(theta),\n\t\t\t\t\ts = Math.sin(theta);\n\t\t\tthis.set(c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.makeRotationAxis = function makeRotationAxis(axis, angle) {\n\t\t\t// Based on http://www.gamedev.net/reference/articles/article1199.asp\n\t\t\tvar c = Math.cos(angle);\n\t\t\tvar s = Math.sin(angle);\n\t\t\tvar t = 1 - c;\n\t\t\tvar x = axis.x,\n\t\t\t\t\ty = axis.y,\n\t\t\t\t\tz = axis.z;\n\t\t\tvar tx = t * x,\n\t\t\t\t\tty = t * y;\n\t\t\tthis.set(tx * x + c, tx * y - s * z, tx * z + s * y, 0, tx * y + s * z, ty * y + c, ty * z - s * x, 0, tx * z - s * y, ty * z + s * x, t * z * z + c, 0, 0, 0, 0, 1);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.makeScale = function makeScale(x, y, z) {\n\t\t\tthis.set(x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.makeShear = function makeShear(x, y, z) {\n\t\t\tthis.set(1, y, z, 0, x, 1, z, 0, x, y, 1, 0, 0, 0, 0, 1);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.compose = function compose(position, quaternion, scale) {\n\t\t\tvar te = this.elements;\n\t\t\tvar x = quaternion._x,\n\t\t\t\t\ty = quaternion._y,\n\t\t\t\t\tz = quaternion._z,\n\t\t\t\t\tw = quaternion._w;
1\n\t\t\tvar x2 = x + x,\n\t\t\t\t\ty2 = y + y,\n\t\t\t\t\tz2 = z + z;\n\t\t\tvar xx = x * x2,\n\t\t\t\t\txy = x * y2,\n\t\t\t\t\txz = x * z2;\n\t\t\tvar yy = y * y2,\n\t\t\t\t\tyz = y * z2,\n\t\t\t\t\tzz = z * z2;\n\t\t\tvar wx = w * x2,\n\t\t\t\t\twy = w * y2,\n\t\t\t\t\twz = w * z2;\n\t\t\tvar sx = scale.x,\n\t\t\t\t\tsy = scale.y,\n\t\t\t\t\tsz = scale.z;\n\t\t\tte[0] = (1 - (yy + zz)) * sx;\n\t\t\tte[1] = (xy + wz) * sx;\n\t\t\tte[2] = (xz - wy) * sx;\n\t\t\tte[3] = 0;\n\t\t\tte[4] = (xy - wz) * sy;\n\t\t\tte[5] = (1 - (xx + zz)) * sy;\n\t\t\tte[6] = (yz + wx) * sy;\n\t\t\tte[7] = 0;\n\t\t\tte[8] = (xz + wy) * sz;\n\t\t\tte[9] = (yz - wx) * sz;\n\t\t\tte[10] = (1 - (xx + yy)) * sz;\n\t\t\tte[11] = 0;\n\t\t\tte[12] = position.x;\n\t\t\tte[13] = position.y;\n\t\t\tte[14] = position.z;\n\t\t\tte[15] = 1;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.decompose = function decompose(position, quaternion, scale) {\n\t\t\tvar te = this.elements;\n\n\t\t\tvar sx = _v1$1.set(te[0], te[1], te[2]).length();\n\n\t\t\tvar sy = _v1$1.set(te[4], te[5], te[6]).length();\n\n\t\t\tvar sz = _v1$1.set(te[8], te[9], te[10]).length(); // if determine is negative, we need to invert one scale\n\n\n\t\t\tvar det = this.determinant();\n\t\t\tif (det < 0) sx = -sx;\n\t\t\tposition.x = te[12];\n\t\t\tposition.y = te[13];\n\t\t\tposition.z = te[14]; // scale the rotation part\n\n\t\t\t_m1.copy(this);\n\n\t\t\tvar invSX = 1 / sx;\n\t\t\tvar invSY = 1 / sy;\n\t\t\tvar invSZ = 1 / sz;\n\t\t\t_m1.elements[0] *= invSX;\n\t\t\t_m1.elements[1] *= invSX;\n\t\t\t_m1.elements[2] *= invSX;\n\t\t\t_m1.elements[4] *= invSY;\n\t\t\t_m1.elements[5] *= invSY;\n\t\t\t_m1.elements[6] *= invSY;\n\t\t\t_m1.elements[8] *= invSZ;\n\t\t\t_m1.elements[9] *= invSZ;\n\t\t\t_m1.elements[10] *= invSZ;\n\t\t\tquaternion.setFromRotationMatrix(_m1);\n\t\t\tscale.x = sx;\n\t\t\tscale.y = sy;\n\t\t\tscale.z = sz;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.makePerspective = function makePerspective(left, right, top, bottom, near, far) {\n\t\t\tif (far === undefined) {\n\t\t\t\tconsole.warn('THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.');\n\t\t\t}\n\n\t\t\tvar te = this.elements;\n\t\t\tvar x = 2 * near / (right - left);\n\t\t\tvar y = 2 * near / (top - bottom);\n\t\t\tvar a = (right + left) / (right - left);\n\t\t\tvar b = (top + bottom) / (top - bottom);\n\t\t\tvar c = -(far + near) / (far - near);\n\t\t\tvar d = -2 * far * near / (far - near);\n\t\t\tte[0] = x;\n\t\t\tte[4] = 0;\n\t\t\tte[8] = a;\n\t\t\tte[12] = 0;\n\t\t\tte[1] = 0;\n\t\t\tte[5] = y;\n\t\t\tte[9] = b;\n\t\t\tte[13] = 0;\n\t\t\tte[2] = 0;\n\t\t\tte[6] = 0;\n\t\t\tte[10] = c;\n\t\t\tte[14] = d;\n\t\t\tte[3] = 0;\n\t\t\tte[7] = 0;\n\t\t\tte[11] = -1;\n\t\t\tte[15] = 0;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.makeOrthographic = function makeOrthographic(left, right, top, bottom, near, far) {\n\t\t\tvar te = this.elements;\n\t\t\tvar w = 1.0 / (right - left);\n\t\t\tvar h = 1.0 / (top - bottom);\n\t\t\tvar p = 1.0 / (far - near);\n\t\t\tvar x = (right + left) * w;\n\t\t\tvar y = (top + bottom) * h;\n\t\t\tvar z = (far + near) * p;\n\t\t\tte[0] = 2 * w;\n\t\t\tte[4] = 0;\n\t\t\tte[8] = 0;\n\t\t\tte[12] = -x;\n\t\t\tte[1] = 0;\n\t\t\tte[5] = 2 * h;\n\t\t\tte[9] = 0;\n\t\t\tte[13] = -y;\n\t\t\tte[2] = 0;\n\t\t\tte[6] = 0;\n\t\t\tte[10] = -2 * p;\n\t\t\tte[14] = -z;\n\t\t\tte[3] = 0;\n\t\t\tte[7] = 0;\n\t\t\tte[11] = 0;\n\t\t\tte[15] = 1;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.equals = function equals(matrix) {\n\t\t\tvar te = this.elements;\n\t\t\tvar me = matrix.elements;\n\n\t\t\tfor (var i = 0; i < 16; i++) {\n\t\t\t\tif (te[i] !== me[i]) return false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t};\n\n\t\t_proto.fromArray = function fromArray(array, offset) {\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tfor (var i = 0; i < 16; i++) {\n\t\t\t\tthis.elements[i] = array[i + offset];\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.toArray = function toArray(array, offset) {\n\t\t\tif (array === void 0) {\n\t\t\t\tarray = [];\n\t\t\t}\n\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tvar te = this.elements;\n\t\t\tarray[offset] = te[0];\n\t\t\tarray[offset + 1] = te[1];\n\t\t\tarray[offset + 2] = te[2];\n\t\t\tarray[offset + 3] = te[3];\n\t\t\tarray[offset + 4] = te[4];\n\t\t\tarray[offset + 5] = te[5];\n\t\t\tarray[offset + 6] = te[6];\n\t\t\tarray[offset + 7] = te[7];\n\t\t\tarray[offset + 8] = te[8];\n\t\t\tarray[offset + 9] = te[9];\n\t\t\tarray[offset + 10] = te[10];\n\t\t\tarray[offset + 11] = te[11];\n\t\t\tarray[offset + 12] = te[12];\n\t\t\tarray[offset + 13] = te[13];\n\t\t\tarray[offset + 14] = te[14];\n\t\t\tarray[offset + 15] = te[15];\n\t\t\treturn array;\n\t\t};\n\n\t\treturn Matrix4;\n\t}();\n\n\tvar _v1$1 = /*@__PURE__*/new Vector3();\n\n\tvar _m1 = /*@__PURE__*/new Matrix4();\n\n\tvar _zero = /*@__PURE__*/new Vector3(0, 0, 0);\n\n\tvar _one = /*@__PURE__*/new Vector3(1, 1, 1);\n\n\tvar _x = /*@__PURE__*/new Vector3();\n\n\tvar _y = /*@__PURE__*/new Vector3();\n\n\tvar _z = /*@__PURE__*/new Vector3();\n\n\tvar Euler = /*#__PURE__*/function () {\n\t\tfunction Euler(x, y, z, order) {\n\t\t\tif (x === void 0) {\n\t\t\t\tx = 0;\n\t\t\t}\n\n\t\t\tif (y === void 0) {\n\t\t\t\ty = 0;\n\t\t\t}\n\n\t\t\tif (z === void 0) {\n\t\t\t\tz = 0;\n\t\t\t}\n\n\t\t\tif (order === void 0) {\n\t\t\t\torder = Euler.DefaultOrder;\n\t\t\t}\n\n\t\t\tObject.defineProperty(this, 'isEuler', {\n\t\t\t\tvalue: true\n\t\t\t});\n\t\t\tthis._x = x;\n\t\t\tthis._y = y;\n\t\t\tthis._z = z;\n\t\t\tthis._order = order;\n\t\t}\n\n\t\tvar _proto = Euler.prototype;\n\n\t\t_proto.set = function set(x, y, z, order) {\n\t\t\tthis._x = x;\n\t\t\tthis._y = y;\n\t\t\tthis._z = z;\n\t\t\tthis._order = order || this._order;\n\n\t\t\tthis._onChangeCallback();\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor(this._x, this._y, this._z, this._order);\n\t\t};\n\n\t\t_proto.copy = function copy(euler) {\n\t\t\tthis._x = euler._x;\n\t\t\tthis._y = euler._y;\n\t\t\tthis._z = euler._z;\n\t\t\tthis._order = euler._order;\n\n\t\t\tthis._onChangeCallback();\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromRotationMatrix = function setFromRotationMatrix(m, order, update) {\n\t\t\tvar clamp = MathUtils.clamp; // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\t\tvar te = m.elements;\n\t\t\tvar m11 = te[0],\n\t\t\t\t\tm12 = te[4],\n\t\t\t\t\tm13 = te[8];\n\t\t\tvar m21 = te[1],\n\t\t\t\t\tm22 = te[5],\n\t\t\t\t\tm23 = te[9];\n\t\t\tvar m31 = te[2],\n\t\t\t\t\tm32 = te[6],\n\t\t\t\t\tm33 = te[10];\n\t\t\torder = order || this._order;\n\n\t\t\tswitch (order) {\n\t\t\t\tcase 'XYZ':\n\t\t\t\t\tthis._y = Math.asin(clamp(m13, -1, 1));\n\n\t\t\t\t\tif (Math.abs(m13) < 0.9999999) {\n\t\t\t\t\t\tthis._x = Math.atan2(-m23, m33);\n\t\t\t\t\t\tthis._z = Math.atan2(-m12, m11);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._x = Math.atan2(m32, m22);\n\t\t\t\t\t\tthis._z = 0;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'YXZ':\n\t\t\t\t\tthis._x = Math.asin(-clamp(m23, -1, 1));\n\n\t\t\t\t\tif (Math.abs(m23) < 0.9999999) {\n\t\t\t\t\t\tthis._y = Math.atan2(m13, m33);\n\t\t\t\t\t\tthis._z = Math.atan2(m21, m22);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._y = Math.atan2(-m31, m11);\n\t\t\t\t\t\tthis._z = 0;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'ZXY':\n\t\t\t\t\tthis._x = Math.asin(clamp(m32, -1, 1));\n\n\t\t\t\t\tif (Math.abs(m32) < 0.9999999) {\n\t\t\t\t\t\tthis._y = Math.atan2(-m31, m33);\n\t\t\t\t\t\tthis._z = Math.atan2(-m12, m22);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._y = 0;\n\t\t\t\t\t\tthis._z = Math.atan2(m21, m11);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'ZYX':\n\t\t\t\t\tthis._y = Math.asin(-clamp(m31, -1, 1));\n\n\t\t\t\t\tif (Math.abs(m31) < 0.9999999) {\n\t\t\t\t\t\tthis._x = Math.atan2(m32, m33);\n\t\t\t\t\t\tthis._z = Math.atan2(m21, m11);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._x = 0;\n\t\t\t\t\t\tthis._z = Math.atan2(-m12, m22);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'YZX':\n\t\t\t\t\tthis._z = Math.asin(clamp(m21, -1, 1));\n\n\t\t\t\t\tif (Math.abs(m21) < 0.9999999) {\n\t\t\t\t\t\tthis._x = Math.atan2(-m23, m22);\n\t\t\t\t\t\tthis._y = Math.atan2(-m31, m11);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._x = 0;\n\t\t\t\t\t\tthis._y = Math.atan2(m13, m33);\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'XZY':\n\t\t\t\t\tthis._z = Math.asin(-clamp(m12, -1, 1));\n\n\t\t\t\t\tif (Math.abs(m12) < 0.9999999) {\n\t\t\t\t\t\tthis._x = Math.atan2(m32, m22);\n\t\t\t\t\t\tthis._y = Math.atan2(m13, m11);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis._x = Math.atan2(-m23, m33);\n\t\t\t\t\t\tthis._y = 0;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tconsole.warn('THREE.Euler: .setFromRotationMatrix() encountered an unknown order: ' + order);\n\t\t\t}\n\n\t\t\tthis._order = order;\n\t\t\tif (update !== false) this._onChangeCallback();\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromQuaternion = function setFromQuaternion(q, order, update) {\n\t\t\t_matrix.makeRotationFromQuaternion(q);\n\n\t\t\treturn this.setFromRotationMatrix(_matrix, order, update);\n\t\t};\n\n\t\t_proto.setFromVector3 = function setFromVector3(v, order) {\n\t\t\treturn this.set(v.x, v.y, v.z, order || this._order);\n\t\t};\n\n\t\t_proto.reorder = function reorder(newOrder) {\n\t\t\t// WARNING: this discards revolution information -bhouston\n\t\t\t_quaternion$1.setFromEuler(this);\n\n\t\t\treturn this.setFromQuaternion(_quaternion$1, newOrder);\n\t\t};\n\n\t\t_proto.equals = function equals(euler) {\n\t\t\treturn euler._x === this._x && euler._y === this._y && euler._z === this._z && euler._order === this._order;\n\t\t};\n\n\t\t_proto.fromArray = function fromArray(array) {\n\t\t\tthis._x = array[0];\n\t\t\tthis._y = array[1];\n\t\t\tthis._z = array[2];\n\t\t\tif (array[3] !== undefined) this._order = array[3];\n\n\t\t\tthis._onChangeCallback();\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.toArray = function toArray(array, offset) {\n\t\t\tif (array === void 0) {\n\t\t\t\tarray = [];\n\t\t\t}\n\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tarray[offset] = this._x;\n\t\t\tarray[offset + 1] = this._y;\n\t\t\tarray[offset + 2] = this._z;\n\t\t\tarray[offset + 3] = this._order;\n\t\t\treturn array;\n\t\t};\n\n\t\t_proto.toVector3 = function toVector3(optionalResult) {\n\t\t\tif (optionalResult) {\n\t\t\t\treturn optionalResult.set(this._x, this._y, this._z);\n\t\t\t} else {\n\t\t\t\treturn new Vector3(this._x, this._y, this._z);\n\t\t\t}\n\t\t};\n\n\t\t_proto._onChange = function _onChange(callback) {\n\t\t\tthis._onChangeCallback = callback;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto._onChangeCallback = function _onChangeCallback() {};\n\n\t\t_createClass(Euler, [{\n\t\t\tkey: \"x\",\n\t\t\tget: function get() {\n\t\t\t\treturn this._x;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tthis._x = value;\n\n\t\t\t\tthis._onChangeCallback();\n\t\t\t}\n\t\t}, {\n\t\t\tkey: \"y\",\n\t\t\tget: function get() {\n\t\t\t\treturn this._y;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tthis._y = value;\n\n\t\t\t\tthis._onChangeCallback();\n\t\t\t}\n\t\t}, {\n\t\t\tkey: \"z\",\n\t\t\tget: function get() {\n\t\t\t\treturn this._z;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tthis._z = value;\n\n\t\t\t\tthis._onChangeCallback();\n\t\t\t}\n\t\t}, {\n\t\t\tkey: \"order\",\n\t\t\tget: function get() {\n\t\t\t\treturn this._order;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tthis._order = value;\n\n\t\t\t\tthis._onChangeCallback();\n\t\t\t}\n\t\t}]);\n\n\t\treturn Euler;\n\t}();\n\n\tEuler.DefaultOrder = 'XYZ';\n\tEuler.RotationOrders = ['XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX'];\n\n\tvar _matrix = /*@__PURE__*/new Matrix4();\n\n\tvar _quaternion$1 = /*@__PURE__*/new Quaternion();\n\n\tvar Layers = /*#__PURE__*/function () {\n\t\tfunction Layers() {\n\t\t\tthis.mask = 1 | 0;\n\t\t}\n\n\t\tvar _proto = Layers.prototype;\n\n\t\t_proto.set = function set(channel) {\n\t\t\tthis.mask = 1 << channel | 0;\n\t\t};
1\n\n\t\t_proto.enable = function enable(channel) {\n\t\t\tthis.mask |= 1 << channel | 0;\n\t\t};\n\n\t\t_proto.enableAll = function enableAll() {\n\t\t\tthis.mask = 0xffffffff | 0;\n\t\t};\n\n\t\t_proto.toggle = function toggle(channel) {\n\t\t\tthis.mask ^= 1 << channel | 0;\n\t\t};\n\n\t\t_proto.disable = function disable(channel) {\n\t\t\tthis.mask &= ~(1 << channel | 0);\n\t\t};\n\n\t\t_proto.disableAll = function disableAll() {\n\t\t\tthis.mask = 0;\n\t\t};\n\n\t\t_proto.test = function test(layers) {\n\t\t\treturn (this.mask & layers.mask) !== 0;\n\t\t};\n\n\t\treturn Layers;\n\t}();\n\n\tvar _object3DId = 0;\n\n\tvar _v1$2 = new Vector3();\n\n\tvar _q1 = new Quaternion();\n\n\tvar _m1$1 = new Matrix4();\n\n\tvar _target = new Vector3();\n\n\tvar _position = new Vector3();\n\n\tvar _scale = new Vector3();\n\n\tvar _quaternion$2 = new Quaternion();\n\n\tvar _xAxis = new Vector3(1, 0, 0);\n\n\tvar _yAxis = new Vector3(0, 1, 0);\n\n\tvar _zAxis = new Vector3(0, 0, 1);\n\n\tvar _addedEvent = {\n\t\ttype: 'added'\n\t};\n\tvar _removedEvent = {\n\t\ttype: 'removed'\n\t};\n\n\tfunction Object3D() {\n\t\tObject.defineProperty(this, 'id', {\n\t\t\tvalue: _object3DId++\n\t\t});\n\t\tthis.uuid = MathUtils.generateUUID();\n\t\tthis.name = '';\n\t\tthis.type = 'Object3D';\n\t\tthis.parent = null;\n\t\tthis.children = [];\n\t\tthis.up = Object3D.DefaultUp.clone();\n\t\tvar position = new Vector3();\n\t\tvar rotation = new Euler();\n\t\tvar quaternion = new Quaternion();\n\t\tvar scale = new Vector3(1, 1, 1);\n\n\t\tfunction onRotationChange() {\n\t\t\tquaternion.setFromEuler(rotation, false);\n\t\t}\n\n\t\tfunction onQuaternionChange() {\n\t\t\trotation.setFromQuaternion(quaternion, undefined, false);\n\t\t}\n\n\t\trotation._onChange(onRotationChange);\n\n\t\tquaternion._onChange(onQuaternionChange);\n\n\t\tObject.defineProperties(this, {\n\t\t\tposition: {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tvalue: position\n\t\t\t},\n\t\t\trotation: {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tvalue: rotation\n\t\t\t},\n\t\t\tquaternion: {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tvalue: quaternion\n\t\t\t},\n\t\t\tscale: {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tvalue: scale\n\t\t\t},\n\t\t\tmodelViewMatrix: {\n\t\t\t\tvalue: new Matrix4()\n\t\t\t},\n\t\t\tnormalMatrix: {\n\t\t\t\tvalue: new Matrix3()\n\t\t\t}\n\t\t});\n\t\tthis.matrix = new Matrix4();\n\t\tthis.matrixWorld = new Matrix4();\n\t\tthis.matrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate;\n\t\tthis.matrixWorldNeedsUpdate = false;\n\t\tthis.layers = new Layers();\n\t\tthis.visible = true;\n\t\tthis.castShadow = false;\n\t\tthis.receiveShadow = false;\n\t\tthis.frustumCulled = true;\n\t\tthis.renderOrder = 0;\n\t\tthis.animations = [];\n\t\tthis.userData = {};\n\t}\n\n\tObject3D.DefaultUp = new Vector3(0, 1, 0);\n\tObject3D.DefaultMatrixAutoUpdate = true;\n\tObject3D.prototype = Object.assign(Object.create(EventDispatcher.prototype), {\n\t\tconstructor: Object3D,\n\t\tisObject3D: true,\n\t\tonBeforeRender: function onBeforeRender() {},\n\t\tonAfterRender: function onAfterRender() {},\n\t\tapplyMatrix4: function applyMatrix4(matrix) {\n\t\t\tif (this.matrixAutoUpdate) this.updateMatrix();\n\t\t\tthis.matrix.premultiply(matrix);\n\t\t\tthis.matrix.decompose(this.position, this.quaternion, this.scale);\n\t\t},\n\t\tapplyQuaternion: function applyQuaternion(q) {\n\t\t\tthis.quaternion.premultiply(q);\n\t\t\treturn this;\n\t\t},\n\t\tsetRotationFromAxisAngle: function setRotationFromAxisAngle(axis, angle) {\n\t\t\t// assumes axis is normalized\n\t\t\tthis.quaternion.setFromAxisAngle(axis, angle);\n\t\t},\n\t\tsetRotationFromEuler: function setRotationFromEuler(euler) {\n\t\t\tthis.quaternion.setFromEuler(euler, true);\n\t\t},\n\t\tsetRotationFromMatrix: function setRotationFromMatrix(m) {\n\t\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\t\t\tthis.quaternion.setFromRotationMatrix(m);\n\t\t},\n\t\tsetRotationFromQuaternion: function setRotationFromQuaternion(q) {\n\t\t\t// assumes q is normalized\n\t\t\tthis.quaternion.copy(q);\n\t\t},\n\t\trotateOnAxis: function rotateOnAxis(axis, angle) {\n\t\t\t// rotate object on axis in object space\n\t\t\t// axis is assumed to be normalized\n\t\t\t_q1.setFromAxisAngle(axis, angle);
1\n\n\t\t\tthis.quaternion.multiply(_q1);\n\t\t\treturn this;\n\t\t},\n\t\trotateOnWorldAxis: function rotateOnWorldAxis(axis, angle) {\n\t\t\t// rotate object on axis in world space\n\t\t\t// axis is assumed to be normalized\n\t\t\t// method assumes no rotated parent\n\t\t\t_q1.setFromAxisAngle(axis, angle);\n\n\t\t\tthis.quaternion.premultiply(_q1);\n\t\t\treturn this;\n\t\t},\n\t\trotateX: function rotateX(angle) {\n\t\t\treturn this.rotateOnAxis(_xAxis, angle);\n\t\t},\n\t\trotateY: function rotateY(angle) {\n\t\t\treturn this.rotateOnAxis(_yAxis, angle);\n\t\t},\n\t\trotateZ: function rotateZ(angle) {\n\t\t\treturn this.rotateOnAxis(_zAxis, angle);\n\t\t},\n\t\ttranslateOnAxis: function translateOnAxis(axis, distance) {\n\t\t\t// translate object by distance along axis in object space\n\t\t\t// axis is assumed to be normalized\n\t\t\t_v1$2.copy(axis).applyQuaternion(this.quaternion);\n\n\t\t\tthis.position.add(_v1$2.multiplyScalar(distance));\n\t\t\treturn this;\n\t\t},\n\t\ttranslateX: function translateX(distance) {\n\t\t\treturn this.translateOnAxis(_xAxis, distance);\n\t\t},\n\t\ttranslateY: function translateY(distance) {\n\t\t\treturn this.translateOnAxis(_yAxis, distance);\n\t\t},\n\t\ttranslateZ: function translateZ(distance) {\n\t\t\treturn this.translateOnAxis(_zAxis, distance);\n\t\t},\n\t\tlocalToWorld: function localToWorld(vector) {\n\t\t\treturn vector.applyMatrix4(this.matrixWorld);\n\t\t},\n\t\tworldToLocal: function worldToLocal(vector) {\n\t\t\treturn vector.applyMatrix4(_m1$1.copy(this.matrixWorld).invert());\n\t\t},\n\t\tlookAt: function lookAt(x, y, z) {\n\t\t\t// This method does not support objects having non-uniformly-scaled parent(s)\n\t\t\tif (x.isVector3) {\n\t\t\t\t_target.copy(x);\n\t\t\t} else {\n\t\t\t\t_target.set(x, y, z);\n\t\t\t}\n\n\t\t\tvar parent = this.parent;\n\t\t\tthis.updateWorldMatrix(true, false);\n\n\t\t\t_position.setFromMatrixPosition(this.matrixWorld);\n\n\t\t\tif (this.isCamera || this.isLight) {\n\t\t\t\t_m1$1.lookAt(_position, _target, this.up);\n\t\t\t} else {\n\t\t\t\t_m1$1.lookAt(_target, _position, this.up);\n\t\t\t}\n\n\t\t\tthis.quaternion.setFromRotationMatrix(_m1$1);\n\n\t\t\tif (parent) {\n\t\t\t\t_m1$1.extractRotation(parent.matrixWorld);\n\n\t\t\t\t_q1.setFromRotationMatrix(_m1$1);\n\n\t\t\t\tthis.quaternion.premultiply(_q1.invert());\n\t\t\t}\n\t\t},\n\t\tadd: function add(object) {\n\t\t\tif (arguments.length > 1) {\n\t\t\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\t\t\tthis.add(arguments[i]);\n\t\t\t\t}\n\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tif (object === this) {\n\t\t\t\tconsole.error('THREE.Object3D.add: object can\\'t be added as a child of itself.', object);\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tif (object && object.isObject3D) {\n\t\t\t\tif (object.parent !== null) {\n\t\t\t\t\tobject.parent.remove(object);\n\t\t\t\t}\n\n\t\t\t\tobject.parent = this;\n\t\t\t\tthis.children.push(object);\n\t\t\t\tobject.dispatchEvent(_addedEvent);\n\t\t\t} else {\n\t\t\t\tconsole.error('THREE.Object3D.add: object not an instance of THREE.Object3D.', object);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tremove: function remove(object) {\n\t\t\tif (arguments.length > 1) {\n\t\t\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\t\t\tthis.remove(arguments[i]);\n\t\t\t\t}\n\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tvar index = this.children.indexOf(object);\n\n\t\t\tif (index !== -1) {\n\t\t\t\tobject.parent = null;\n\t\t\t\tthis.children.splice(index, 1);\n\t\t\t\tobject.dispatchEvent(_removedEvent);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tclear: function clear() {\n\t\t\tfor (var i = 0; i < this.children.length; i++) {\n\t\t\t\tvar object = this.children[i];\n\t\t\t\tobject.parent = null;\n\t\t\t\tobject.dispatchEvent(_removedEvent);\n\t\t\t}\n\n\t\t\tthis.children.length = 0;\n\t\t\treturn this;\n\t\t},\n\t\tattach: function attach(object) {\n\t\t\t// adds object as a child of this, while maintaining the object's world transform\n\t\t\tthis.updateWorldMatrix(true, false);\n\n\t\t\t_m1$1.copy(this.matrixWorld).invert();\n\n\t\t\tif (object.parent !== null) {\n\t\t\t\tobject.parent.updateWorldMatrix(true, false);\n\n\t\t\t\t_m1$1.multiply(object.parent.matrixWorld);\n\t\t\t}\n\n\t\t\tobject.applyMatrix4(_m1$1);\n\t\t\tobject.updateWorldMatrix(false, false);\n\t\t\tthis.add(object);\n\t\t\treturn this;\n\t\t},\n\t\tgetObjectById: function getObjectById(id) {\n\t\t\treturn this.getObjectByProperty('id', id);\n\t\t},\n\t\tgetObjectByName: function getObjectByName(name) {\n\t\t\treturn this.getObjectByProperty('name', name);\n\t\t},\n\t\tgetObjectByProperty: function getObjectByProperty(name, value) {\n\t\t\tif (this[name] === value) return this;\n\n\t\t\tfor (var i = 0, l = this.children.length; i < l;
1 i++) {\n\t\t\t\tvar child = this.children[i];\n\t\t\t\tvar object = child.getObjectByProperty(name, value);\n\n\t\t\t\tif (object !== undefined) {\n\t\t\t\t\treturn object;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t\tgetWorldPosition: function getWorldPosition(target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Object3D: .getWorldPosition() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\tthis.updateWorldMatrix(true, false);\n\t\t\treturn target.setFromMatrixPosition(this.matrixWorld);\n\t\t},\n\t\tgetWorldQuaternion: function getWorldQuaternion(target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Object3D: .getWorldQuaternion() target is now required');\n\t\t\t\ttarget = new Quaternion();\n\t\t\t}\n\n\t\t\tthis.updateWorldMatrix(true, false);\n\t\t\tthis.matrixWorld.decompose(_position, target, _scale);\n\t\t\treturn target;\n\t\t},\n\t\tgetWorldScale: function getWorldScale(target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Object3D: .getWorldScale() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\tthis.updateWorldMatrix(true, false);\n\t\t\tthis.matrixWorld.decompose(_position, _quaternion$2, target);\n\t\t\treturn target;\n\t\t},\n\t\tgetWorldDirection: function getWorldDirection(target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Object3D: .getWorldDirection() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\tthis.updateWorldMatrix(true, false);\n\t\t\tvar e = this.matrixWorld.elements;\n\t\t\treturn target.set(e[8], e[9], e[10]).normalize();\n\t\t},\n\t\traycast: function raycast() {},\n\t\ttraverse: function traverse(callback) {\n\t\t\tcallback(this);\n\t\t\tvar children = this.children;\n\n\t\t\tfor (var i = 0, l = children.length; i < l; i++) {\n\t\t\t\tchildren[i].traverse(callback);\n\t\t\t}\n\t\t},\n\t\ttraverseVisible: function traverseVisible(callback) {\n\t\t\tif (this.visible === false) return;\n\t\t\tcallback(this);\n\t\t\tvar children = this.children;\n\n\t\t\tfor (var i = 0, l = children.length; i < l; i++) {\n\t\t\t\tchildren[i].traverseVisible(callback);\n\t\t\t}\n\t\t},\n\t\ttraverseAncestors: function traverseAncestors(callback) {\n\t\t\tvar parent = this.parent;\n\n\t\t\tif (parent !== null) {\n\t\t\t\tcallback(parent);\n\t\t\t\tparent.traverseAncestors(callback);\n\t\t\t}\n\t\t},\n\t\tupdateMatrix: function updateMatrix() {\n\t\t\tthis.matrix.compose(this.position, this.quaternion, this.scale);\n\t\t\tthis.matrixWorldNeedsUpdate = true;\n\t\t},\n\t\tupdateMatrixWorld: function updateMatrixWorld(force) {\n\t\t\tif (this.matrixAutoUpdate) this.updateMatrix();\n\n\t\t\tif (this.matrixWorldNeedsUpdate || force) {\n\t\t\t\tif (this.parent === null) {\n\t\t\t\t\tthis.matrixWorld.copy(this.matrix);\n\t\t\t\t} else {\n\t\t\t\t\tthis.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix);\n\t\t\t\t}\n\n\t\t\t\tthis.matrixWorldNeedsUpdate = false;\n\t\t\t\tforce = true;\n\t\t\t} // update children\n\n\n\t\t\tvar children = this.children;\n\n\t\t\tfor (var i = 0, l = children.length; i < l; i++) {\n\t\t\t\tchildren[i].updateMatrixWorld(force);\n\t\t\t}\n\t\t},\n\t\tupdateWorldMatrix: function updateWorldMatrix(updateParents, updateChildren) {\n\t\t\tvar parent = this.parent;\n\n\t\t\tif (updateParents === true && parent !== null) {\n\t\t\t\tparent.updateWorldMatrix(true, false);\n\t\t\t}\n\n\t\t\tif (this.matrixAutoUpdate) this.updateMatrix();\n\n\t\t\tif (this.parent === null) {\n\t\t\t\tthis.matrixWorld.copy(this.matrix);\n\t\t\t} else {\n\t\t\t\tthis.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix);\n\t\t\t} // update children\n\n\n\t\t\tif (updateChildren === true) {\n\t\t\t\tvar children = this.children;\n\n\t\t\t\tfor (var i = 0, l = children.length; i < l; i++) {\n\t\t\t\t\tchildren[i].updateWorldMatrix(false, true);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\ttoJSON: function toJSON(meta) {\n\t\t\t// meta is a string when called from JSON.stringify\n\t\t\tvar isRootObject = meta === undefined || typeof meta === 'string';\n\t\t\tvar output = {}; // meta is a hash used to collect geometries, materials.\n\t\t\t// not providing it implies that this is the root object\n\t\t\t// being serialized.\n\n\t\t\tif (isRootObject) {\n\t\t\t\t// initialize meta obj\n\t\t\t\tmeta = {\n\t\t\t\t\tgeometries: {},\n\t\t\t\t\tmaterials: {},\n\t\t\t\t\ttextures: {},\n\t\t\t\t\timages: {},\n\t\t\t\t\tshapes: {},\n\t\t\t\t\tskeletons: {},\n\t\t\t\t\tanimations: {}\n\t\t\t\t};\n\t\t\t\toutput.metadata = {\n\t\t\t\t\tversion: 4.5,\n\t\t\t\t\ttype: 'Object',\n\t\t\t\t\tgenerator: 'Object3D.toJSON'\n\t\t\t\t};\n\t\t\t} // standard Object3D serialization\n\n\n\t\t\tvar object = {};\n\t\t\tobject.uuid = this.uuid;\n\t\t\tobject.type = this.type;\n\t\t\tif (this.name !== '') object.name = this.name;\n\t\t\tif (this.castShadow === true) object.castShadow = true;\n\t\t\tif (this.receiveShadow === true) object.receiveShadow = true;\n\t\t\tif (this.visible === false) object.visible = false;\n\t\t\tif (this.frustumCulled === false) object.frustumCulled = false;\n\t\t\tif (this.renderOrder !== 0) object.renderOrder = this.renderOrder;\n\t\t\tif (JSON.stringify(this.userData) !== '{}') object.userData = this.userData;\n\t\t\tobject.layers = this.layers.mask;\n\t\t\tobject.matrix = this.matrix.toArray();\n\t\t\tif (this.matrixAutoUpdate === false) object.matrixAutoUpdate = false; // object specific properties\n\n\t\t\tif (this.isInstancedMesh) {\n\t\t\t\tobject.type = 'InstancedMesh';\n\t\t\t\tobject.count = this.count;\n\t\t\t\tobject.instanceMatrix = this.instanceMatrix.toJSON();\n\t\t\t} //\n\n\n\t\t\tfunction serialize(library, element) {\n\t\t\t\tif (library[element.uuid] === undefined) {\n\t\t\t\t\tlibrary[element.uuid] = element.toJSON(meta);\n\t\t\t\t}\n\n\t\t\t\treturn element.uuid;\n\t\t\t}\n\n\t\t\tif (this.isMesh || this.isLine || this.isPoints) {\n\t\t\t\tobject.geometry = serialize(meta.geometries, this.geometry);\n\t\t\t\tvar parameters = this.geometry.parameters;\n\n\t\t\t\tif (parameters !== undefined && parameters.shapes !== undefined) {\n\t\t\t\t\tvar shapes = parameters.shapes;\n\n\t\t\t\t\tif (Array.isArray(shapes)) {\n\t\t\t\t\t\tfor (var i = 0, l = shapes.length; i < l;
1 i++) {\n\t\t\t\t\t\t\tvar shape = shapes[i];\n\t\t\t\t\t\t\tserialize(meta.shapes, shape);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tserialize(meta.shapes, shapes);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.isSkinnedMesh) {\n\t\t\t\tobject.bindMode = this.bindMode;\n\t\t\t\tobject.bindMatrix = this.bindMatrix.toArray();\n\n\t\t\t\tif (this.skeleton !== undefined) {\n\t\t\t\t\tserialize(meta.skeletons, this.skeleton);\n\t\t\t\t\tobject.skeleton = this.skeleton.uuid;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.material !== undefined) {\n\t\t\t\tif (Array.isArray(this.material)) {\n\t\t\t\t\tvar uuids = [];\n\n\t\t\t\t\tfor (var _i = 0, _l = this.material.length; _i < _l; _i++) {\n\t\t\t\t\t\tuuids.push(serialize(meta.materials, this.material[_i]));\n\t\t\t\t\t}\n\n\t\t\t\t\tobject.material = uuids;\n\t\t\t\t} else {\n\t\t\t\t\tobject.material = serialize(meta.materials, this.material);\n\t\t\t\t}\n\t\t\t} //\n\n\n\t\t\tif (this.children.length > 0) {\n\t\t\t\tobject.children = [];\n\n\t\t\t\tfor (var _i2 = 0; _i2 < this.children.length; _i2++) {\n\t\t\t\t\tobject.children.push(this.children[_i2].toJSON(meta).object);\n\t\t\t\t}\n\t\t\t} //\n\n\n\t\t\tif (this.animations.length > 0) {\n\t\t\t\tobject.animations = [];\n\n\t\t\t\tfor (var _i3 = 0; _i3 < this.animations.length; _i3++) {\n\t\t\t\t\tvar animation = this.animations[_i3];\n\t\t\t\t\tobject.animations.push(serialize(meta.animations, animation));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (isRootObject) {\n\t\t\t\tvar geometries = extractFromCache(meta.geometries);\n\t\t\t\tvar materials = extractFromCache(meta.materials);\n\t\t\t\tvar textures = extractFromCache(meta.textures);\n\t\t\t\tvar images = extractFromCache(meta.images);\n\n\t\t\t\tvar _shapes = extractFromCache(meta.shapes);\n\n\t\t\t\tvar skeletons = extractFromCache(meta.skeletons);\n\t\t\t\tvar animations = extractFromCache(meta.animations);\n\t\t\t\tif (geometries.length > 0) output.geometries = geometries;\n\t\t\t\tif (materials.length > 0) output.materials = materials;\n\t\t\t\tif (textures.length > 0) output.textures = textures;\n\t\t\t\tif (images.length > 0) output.images = images;\n\t\t\t\tif (_shapes.length > 0) output.shapes = _shapes;\n\t\t\t\tif (skeletons.length > 0) output.skeletons = skeletons;\n\t\t\t\tif (animations.length > 0) output.animations = animations;\n\t\t\t}\n\n\t\t\toutput.object = object;\n\t\t\treturn output; // extract data from the cache hash\n\t\t\t// remove metadata on each item\n\t\t\t// and return as array\n\n\t\t\tfunction extractFromCache(cache) {\n\t\t\t\tvar values = [];\n\n\t\t\t\tfor (var key in cache) {\n\t\t\t\t\tvar data = cache[key];\n\t\t\t\t\tdelete data.metadata;\n\t\t\t\t\tvalues.push(data);\n\t\t\t\t}\n\n\t\t\t\treturn values;\n\t\t\t}\n\t\t},\n\t\tclone: function clone(recursive) {\n\t\t\treturn new this.constructor().copy(this, recursive);\n\t\t},\n\t\tcopy: function copy(source, recursive) {\n\t\t\tif (recursive === void 0) {\n\t\t\t\trecursive = true;\n\t\t\t}\n\n\t\t\tthis.name = source.name;\n\t\t\tthis.up.copy(source.up);\n\t\t\tthis.position.copy(source.position);\n\t\t\tthis.rotation.order = source.rotation.order;\n\t\t\tthis.quaternion.copy(source.quaternion);\n\t\t\tthis.scale.copy(source.scale);\n\t\t\tthis.matrix.copy(source.matrix);\n\t\t\tthis.matrixWorld.copy(source.matrixWorld);\n\t\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\t\t\tthis.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;\n\t\t\tthis.layers.mask = source.layers.mask;\n\t\t\tthis.visible = source.visible;\n\t\t\tthis.castShadow = source.castShadow;\n\t\t\tthis.receiveShadow = source.receiveShadow;\n\t\t\tthis.frustumCulled = source.frustumCulled;\n\t\t\tthis.renderOrder = source.renderOrder;\n\t\t\tthis.userData = JSON.parse(JSON.stringify(source.userData));\n\n\t\t\tif (recursive === true) {\n\t\t\t\tfor (var i = 0; i < source.children.length; i++) {\n\t\t\t\t\tvar child = source.children[i];\n\t\t\t\t\tthis.add(child.clone());\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this;\n\t\t}\n\t});\n\n\tvar _vector1 = /*@__PURE__*/new Vector3();\n\n\tvar _vector2 = /*@__PURE__*/new Vector3();\n\n\tvar _normalMatrix = /*@__PURE__*/new Matrix3();\n\n\tvar Plane = /*#__PURE__*/function () {\n\t\tfunction Plane(normal, constant) {\n\t\t\tObject.defineProperty(this, 'isPlane', {\n\t\t\t\tvalue: true\n\t\t\t}); // normal is assumed to be normalized\n\n\t\t\tthis.normal = normal !== undefined ? normal : new Vector3(1, 0, 0);\n\t\t\tthis.constant = constant !== undefined ? constant : 0;\n\t\t}\n\n\t\tvar _proto = Plane.prototype;\n\n\t\t_proto.set = function set(normal, constant) {\n\t\t\tthis.normal.copy(normal);\n\t\t\tthis.constant = constant;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setComponents = function setComponents(x, y, z, w) {\n\t\t\tthis.normal.set(x, y, z);\n\t\t\tthis.constant = w;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromNormalAndCoplanarPoint = function setFromNormalAndCoplanarPoint(normal, point) {\n\t\t\tthis.normal.copy(normal);\n\t\t\tthis.constant = -point.dot(this.normal);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromCoplanarPoints = function setFromCoplanarPoints(a, b, c) {\n\t\t\tvar normal = _vector1.subVectors(c, b).cross(_vector2.subVectors(a, b)).normalize(); // Q: should an error be thrown if normal is zero (e.g. degenerate plane)?\n\n\n\t\t\tthis.setFromNormalAndCoplanarPoint(normal, a);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t};\n\n\t\t_proto.copy = function copy(plane) {\n\t\t\tthis.normal.copy(plane.normal);\n\t\t\tthis.constant = plane.constant;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.normalize = function normalize() {\n\t\t\t// Note: will lead to a divide by zero if the plane is invali
1d.\n\t\t\tvar inverseNormalLength = 1.0 / this.normal.length();\n\t\t\tthis.normal.multiplyScalar(inverseNormalLength);\n\t\t\tthis.constant *= inverseNormalLength;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.negate = function negate() {\n\t\t\tthis.constant *= -1;\n\t\t\tthis.normal.negate();\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.distanceToPoint = function distanceToPoint(point) {\n\t\t\treturn this.normal.dot(point) + this.constant;\n\t\t};\n\n\t\t_proto.distanceToSphere = function distanceToSphere(sphere) {\n\t\t\treturn this.distanceToPoint(sphere.center) - sphere.radius;\n\t\t};\n\n\t\t_proto.projectPoint = function projectPoint(point, target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Plane: .projectPoint() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\treturn target.copy(this.normal).multiplyScalar(-this.distanceToPoint(point)).add(point);\n\t\t};\n\n\t\t_proto.intersectLine = function intersectLine(line, target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Plane: .intersectLine() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\tvar direction = line.delta(_vector1);\n\t\t\tvar denominator = this.normal.dot(direction);\n\n\t\t\tif (denominator === 0) {\n\t\t\t\t// line is coplanar, return origin\n\t\t\t\tif (this.distanceToPoint(line.start) === 0) {\n\t\t\t\t\treturn target.copy(line.start);\n\t\t\t\t} // Unsure if this is the correct method to handle this case.\n\n\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tvar t = -(line.start.dot(this.normal) + this.constant) / denominator;\n\n\t\t\tif (t < 0 || t > 1) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn target.copy(direction).multiplyScalar(t).add(line.start);\n\t\t};\n\n\t\t_proto.intersectsLine = function intersectsLine(line) {\n\t\t\t// Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it.\n\t\t\tvar startSign = this.distanceToPoint(line.start);\n\t\t\tvar endSign = this.distanceToPoint(line.end);\n\t\t\treturn startSign < 0 && endSign > 0 || endSign < 0 && startSign > 0;\n\t\t};\n\n\t\t_proto.intersectsBox = function intersectsBox(box) {\n\t\t\treturn box.intersectsPlane(this);\n\t\t};\n\n\t\t_proto.intersectsSphere = function intersectsSphere(sphere) {\n\t\t\treturn sphere.intersectsPlane(this);\n\t\t};\n\n\t\t_proto.coplanarPoint = function coplanarPoint(target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Plane: .coplanarPoint() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\treturn target.copy(this.normal).multiplyScalar(-this.constant);\n\t\t};\n\n\t\t_proto.applyMatrix4 = function applyMatrix4(matrix, optionalNormalMatrix) {\n\t\t\tvar normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix(matrix);\n\n\t\t\tvar referencePoint = this.coplanarPoint(_vector1).applyMatrix4(matrix);\n\t\t\tvar normal = this.normal.applyMatrix3(normalMatrix).normalize();\n\t\t\tthis.constant = -referencePoint.dot(normal);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.translate = function translate(offset) {\n\t\t\tthis.constant -= offset.dot(this.normal);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.equals = function equals(plane) {\n\t\t\treturn plane.normal.equals(this.normal) && plane.constant === this.constant;\n\t\t};\n\n\t\treturn Plane;\n\t}();\n\n\tvar _v0$1 = /*@__PURE__*/new Vector3();\n\n\tvar _v1$3 = /*@__PURE__*/new Vector3();\n\n\tvar _v2$1 = /*@__PURE__*/new Vector3();\n\n\tvar _v3 = /*@__PURE__*/new Vector3();\n\n\tvar _vab = /*@__PURE__*/new Vector3();\n\n\tvar _vac = /*@__PURE__*/new Vector3();\n\n\tvar _vbc = /*@__PURE__*/new Vector3();\n\n\tvar _vap = /*@__PURE__*/new Vector3();\n\n\tvar _vbp = /*@__PURE__*/new Vector3();\n\n\tvar _vcp = /*@__PURE__*/new Vector3();\n\n\tvar Triangle = /*#__PURE__*/function () {\n\t\tfunction Triangle(a, b, c) {\n\t\t\tthis.a = a !== undefined ? a : new Vector3();\n\t\t\tthis.b = b !== undefined ? b : new Vector3();\n\t\t\tthis.c = c !== undefined ? c : new Vector3();\n\t\t}\n\n\t\tTriangle.getNormal = function getNormal(a, b, c, target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Triangle: .getNormal() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\ttarget.subVectors(c, b);\n\n\t\t\t_v0$1.subVectors(a, b);\n\n\t\t\ttarget.cross(_v0$1);\n\t\t\tvar targetLengthSq = target.lengthSq();\n\n\t\t\tif (targetLengthSq > 0) {\n\t\t\t\treturn target.multiplyScalar(1 / Math.sqrt(targetLengthSq));\n\t\t\t}\n\n\t\t\treturn target.set(0, 0, 0);\n\t\t} // static/instance method to calculate barycentric coordinates\n\t\t// based on: http://www.blackpawn.com/texts/pointinpoly/default.html\n\t\t;\n\n\t\tTriangle.getBarycoord = function getBarycoord(point, a, b, c, target) {\n\t\t\t_v0$1.subVectors(c, a);\n\n\t\t\t_v1$3.subVectors(b, a);\n\n\t\t\t_v2$1.subVectors(point, a);
1\n\n\t\t\tvar dot00 = _v0$1.dot(_v0$1);\n\n\t\t\tvar dot01 = _v0$1.dot(_v1$3);\n\n\t\t\tvar dot02 = _v0$1.dot(_v2$1);\n\n\t\t\tvar dot11 = _v1$3.dot(_v1$3);\n\n\t\t\tvar dot12 = _v1$3.dot(_v2$1);\n\n\t\t\tvar denom = dot00 * dot11 - dot01 * dot01;\n\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Triangle: .getBarycoord() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t} // collinear or singular triangle\n\n\n\t\t\tif (denom === 0) {\n\t\t\t\t// arbitrary location outside of triangle?\n\t\t\t\t// not sure if this is the best idea, maybe should be returning undefined\n\t\t\t\treturn target.set(-2, -1, -1);\n\t\t\t}\n\n\t\t\tvar invDenom = 1 / denom;\n\t\t\tvar u = (dot11 * dot02 - dot01 * dot12) * invDenom;\n\t\t\tvar v = (dot00 * dot12 - dot01 * dot02) * invDenom; // barycentric coordinates must always sum to 1\n\n\t\t\treturn target.set(1 - u - v, v, u);\n\t\t};\n\n\t\tTriangle.containsPoint = function containsPoint(point, a, b, c) {\n\t\t\tthis.getBarycoord(point, a, b, c, _v3);\n\t\t\treturn _v3.x >= 0 && _v3.y >= 0 && _v3.x + _v3.y <= 1;\n\t\t};\n\n\t\tTriangle.getUV = function getUV(point, p1, p2, p3, uv1, uv2, uv3, target) {\n\t\t\tthis.getBarycoord(point, p1, p2, p3, _v3);\n\t\t\ttarget.set(0, 0);\n\t\t\ttarget.addScaledVector(uv1, _v3.x);\n\t\t\ttarget.addScaledVector(uv2, _v3.y);\n\t\t\ttarget.addScaledVector(uv3, _v3.z);\n\t\t\treturn target;\n\t\t};\n\n\t\tTriangle.isFrontFacing = function isFrontFacing(a, b, c, direction) {\n\t\t\t_v0$1.subVectors(c, b);\n\n\t\t\t_v1$3.subVectors(a, b); // strictly front facing\n\n\n\t\t\treturn _v0$1.cross(_v1$3).dot(direction) < 0 ? true : false;\n\t\t};\n\n\t\tvar _proto = Triangle.prototype;\n\n\t\t_proto.set = function set(a, b, c) {\n\t\t\tthis.a.copy(a);\n\t\t\tthis.b.copy(b);\n\t\t\tthis.c.copy(c);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromPointsAndIndices = function setFromPointsAndIndices(points, i0, i1, i2) {\n\t\t\tthis.a.copy(points[i0]);\n\t\t\tthis.b.copy(points[i1]);\n\t\t\tthis.c.copy(points[i2]);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t};\n\n\t\t_proto.copy = function copy(triangle) {\n\t\t\tthis.a.copy(triangle.a);\n\t\t\tthis.b.copy(triangle.b);\n\t\t\tthis.c.copy(triangle.c);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.getArea = function getArea() {\n\t\t\t_v0$1.subVectors(this.c, this.b);\n\n\t\t\t_v1$3.subVectors(this.a, this.b);\n\n\t\t\treturn _v0$1.cross(_v1$3).length() * 0.5;\n\t\t};\n\n\t\t_proto.getMidpoint = function getMidpoint(target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Triangle: .getMidpoint() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\treturn target.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3);\n\t\t};\n\n\t\t_proto.getNormal = function getNormal(target) {\n\t\t\treturn Triangle.getNormal(this.a, this.b, this.c, target);\n\t\t};\n\n\t\t_proto.getPlane = function getPlane(target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Triangle: .getPlane() target is now required');\n\t\t\t\ttarget = new Plane();\n\t\t\t}\n\n\t\t\treturn target.setFromCoplanarPoints(this.a, this.b, this.c);\n\t\t};\n\n\t\t_proto.getBarycoord = function getBarycoord(point, target) {\n\t\t\treturn Triangle.getBarycoord(point, this.a, this.b, this.c, target);\n\t\t};\n\n\t\t_proto.getUV = function getUV(point, uv1, uv2, uv3, target) {\n\t\t\treturn Triangle.getUV(point, this.a, this.b, this.c, uv1, uv2, uv3, target);\n\t\t};\n\n\t\t_proto.containsPoint = function containsPoint(point) {\n\t\t\treturn Triangle.containsPoint(point, this.a, this.b, this.c);\n\t\t};\n\n\t\t_proto.isFrontFacing = function isFrontFacing(direction) {\n\t\t\treturn Triangle.isFrontFacing(this.a, this.b, this.c, direction);\n\t\t};\n\n\t\t_proto.intersectsBox = function intersectsBox(box) {\n\t\t\treturn box.intersectsTriangle(this);\n\t\t};\n\n\t\t_proto.closestPointToPoint = function closestPointToPoint(p, target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Triangle: .closestPointToPoint() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\tvar a = this.a,\n\t\t\t\t\tb = this.b,\n\t\t\t\t\tc = this.c;\n\t\t\tvar v, w; // algorithm thanks to Real-Time Collision Detection by Christer Ericson,\n\t\t\t// published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc.,\n\t\t\t// under the accompanying license; see chapter 5.1.5 for detailed explanation.\n\t\t\t// basically, we're distinguishing which of the voronoi regi
1ons of the triangle\n\t\t\t// the point lies in with the minimum amount of redundant computation.\n\n\t\t\t_vab.subVectors(b, a);\n\n\t\t\t_vac.subVectors(c, a);\n\n\t\t\t_vap.subVectors(p, a);\n\n\t\t\tvar d1 = _vab.dot(_vap);\n\n\t\t\tvar d2 = _vac.dot(_vap);\n\n\t\t\tif (d1 <= 0 && d2 <= 0) {\n\t\t\t\t// vertex region of A; barycentric coords (1, 0, 0)\n\t\t\t\treturn target.copy(a);\n\t\t\t}\n\n\t\t\t_vbp.subVectors(p, b);\n\n\t\t\tvar d3 = _vab.dot(_vbp);\n\n\t\t\tvar d4 = _vac.dot(_vbp);\n\n\t\t\tif (d3 >= 0 && d4 <= d3) {\n\t\t\t\t// vertex region of B; barycentric coords (0, 1, 0)\n\t\t\t\treturn target.copy(b);\n\t\t\t}\n\n\t\t\tvar vc = d1 * d4 - d3 * d2;\n\n\t\t\tif (vc <= 0 && d1 >= 0 && d3 <= 0) {\n\t\t\t\tv = d1 / (d1 - d3); // edge region of AB; barycentric coords (1-v, v, 0)\n\n\t\t\t\treturn target.copy(a).addScaledVector(_vab, v);\n\t\t\t}\n\n\t\t\t_vcp.subVectors(p, c);\n\n\t\t\tvar d5 = _vab.dot(_vcp);\n\n\t\t\tvar d6 = _vac.dot(_vcp);\n\n\t\t\tif (d6 >= 0 && d5 <= d6) {\n\t\t\t\t// vertex region of C; barycentric coords (0, 0, 1)\n\t\t\t\treturn target.copy(c);\n\t\t\t}\n\n\t\t\tvar vb = d5 * d2 - d1 * d6;\n\n\t\t\tif (vb <= 0 && d2 >= 0 && d6 <= 0) {\n\t\t\t\tw = d2 / (d2 - d6); // edge region of AC; barycentric coords (1-w, 0, w)\n\n\t\t\t\treturn target.copy(a).addScaledVector(_vac, w);\n\t\t\t}\n\n\t\t\tvar va = d3 * d6 - d5 * d4;\n\n\t\t\tif (va <= 0 && d4 - d3 >= 0 && d5 - d6 >= 0) {\n\t\t\t\t_vbc.subVectors(c, b);\n\n\t\t\t\tw = (d4 - d3) / (d4 - d3 + (d5 - d6)); // edge region of BC; barycentric coords (0, 1-w, w)\n\n\t\t\t\treturn target.copy(b).addScaledVector(_vbc, w); // edge region of BC\n\t\t\t} // face region\n\n\n\t\t\tvar denom = 1 / (va + vb + vc); // u = va * denom\n\n\t\t\tv = vb * denom;\n\t\t\tw = vc * denom;\n\t\t\treturn target.copy(a).addScaledVector(_vab, v).addScaledVector(_vac, w);\n\t\t};\n\n\t\t_proto.equals = function equals(triangle) {\n\t\t\treturn triangle.a.equals(this.a) && triangle.b.equals(this.b) && triangle.c.equals(this.c);\n\t\t};\n\n\t\treturn Triangle;\n\t}();\n\n\tvar _colorKeywords = {\n\t\t'aliceblue': 0xF0F8FF,\n\t\t'antiquewhite': 0xFAEBD7,\n\t\t'aqua': 0x00FFFF,\n\t\t'aquamarine': 0x7FFFD4,\n\t\t'azure': 0xF0FFFF,\n\t\t'beige': 0xF5F5DC,\n\t\t'bisque': 0xFFE4C4,\n\t\t'black': 0x000000,\n\t\t'blanchedalmond': 0xFFEBCD,\n\t\t'blue': 0x0000FF,\n\t\t'blueviolet': 0x8A2BE2,\n\t\t'brown': 0xA52A2A,\n\t\t'burlywood': 0xDEB887,\n\t\t'cadetblue': 0x5F9EA0,\n\t\t'chartreuse': 0x7FFF00,\n\t\t'chocolate': 0xD2691E,\n\t\t'coral': 0xFF7F50,\n\t\t'cornflowerblue': 0x6495ED,\n\t\t'cornsilk': 0xFFF8DC,\n\t\t'crimson': 0xDC143C,\n\t\t'cyan': 0x00FFFF,\n\t\t'darkblue': 0x00008B,\n\t\t'darkcyan': 0x008B8B,\n\t\t'darkgoldenrod': 0xB8860B,\n\t\t'darkgray': 0xA9A9A9,\n\t\t'darkgreen': 0x006400,\n\t\t'darkgrey': 0xA9A9A9,\n\t\t'darkkhaki': 0xBDB76B,\n\t\t'darkmagenta': 0x8B008B,\n\t\t'darkolivegreen': 0x556B2F,\n\t\t'darkorange': 0xFF8C00,\n\t\t'darkorchid': 0x9932CC,\n\t\t'darkred': 0x8B0000,\n\t\t'darksalmon': 0xE9967A,\n\t\t'darkseagreen': 0x8FBC8F,\n\t\t'darkslateblue': 0x483D8B,\n\t\t'darkslategray': 0x2F4F4F,\n\t\t'darkslategrey': 0x2F4F4F,\n\t\t'darkturquoise': 0x00CED1,\n\t\t'darkviolet': 0x9400D3,\n\t\t'deeppink': 0xFF1493,\n\t\t'deepskyblue': 0x00BFFF,\n\t\t'dimgray': 0x696969,\n\t\t'dimgrey': 0x696969,\n\t\t'dodgerblue': 0x1E90FF,\n\t\t'firebrick': 0xB22222,\n\t\t'floralwhite': 0xFFFAF0,\n\t\t'forestgreen': 0x228B22,\n\t\t'fuchsia': 0xFF00FF,\n\t\t'gainsboro': 0xDCDCDC,\n\t\t'ghostwhite': 0xF8F8FF,\n\t\t'gold': 0xFFD700,\n\t\t'goldenrod': 0xDAA520,\n\t\t'gray': 0x808080,\n\t\t'green': 0x008000,\n\t\t'greenyellow': 0xADFF2F,\n\t\t'grey': 0x808080,\n\t\t'honeydew': 0xF0FFF0,\n\t\t'hotpink': 0xFF69B4,\n\t\t'indianred': 0xCD5C5C,\n\t\t'indigo': 0x4B0082,\n\t\t'ivory': 0xFFFFF0,\n\t\t'khaki': 0xF0E68C,\n\t\t'lavender': 0xE6E6FA,\n\t\t'lavenderblush': 0xFFF0F5,\n\t\t'lawngreen': 0x7CFC00,\n\t\t'lemonchiffon': 0xFFFACD,\n\t\t'lightblue': 0xADD8E6,\n\t\t'lightcoral': 0xF08080,\n\t\t'lightcyan': 0xE0FFFF,\n\t\t'lightgoldenrodyellow': 0xFAFAD2,\n\t\t'lightgray': 0xD3D3D3,\n\t\t'lightgreen': 0x90EE90,\n\t\t'lightgrey': 0xD3D3D3,\n\t\t'lightpink': 0xFFB6C1,\n\t\t'lightsalmon': 0xFFA07A,\n\t\t'lightseagreen': 0x20B2AA,\n\t\t'lightskyblue': 0x87CEFA,\n\t\t'lightslategray': 0x778899,\n\t\t'lightslategrey': 0x778899,\n\t\t'lightsteelblue': 0xB0C4DE,\n\t\t'lightyellow': 0xFFFFE0,\n\t\t'lime': 0x00FF00,\n\t\t'limegreen': 0x32CD32,\n\t\t'linen': 0xFAF0E6,\n\t\t'magenta': 0xFF00FF,\n\t\t'maroon': 0x800000,\n\t\t'mediumaquamarine': 0x66CDAA,\n\t\t'mediumblue': 0x0000CD,\n\t\t'mediumorchid': 0xBA55D3,\n\t\t'mediumpurple': 0x9370DB,\n\t\t'mediumseagreen': 0x3CB371,\n\t\t'mediumslateblue': 0x7B68EE,\n\t\t'mediumspringgreen': 0x00FA9A,\n\t\t'mediumturquoise': 0x48D1CC,\n\t\t'mediumvioletred': 0xC71585,\n\t\t'midnightblue': 0x191970,\n\t\t'mintcream': 0xF5FFFA,\n\t\t'mistyrose': 0xFFE4E1,\n\t\t'moccasin': 0xFFE4B5,\n\t\t'navajowhite': 0xFFDEAD,\n\t\t'navy': 0x000080,\n\t\t'oldlace': 0xFDF5E6,\n\t\t'olive': 0x808000,\n\t\t'olivedrab': 0x6B8E23,\n\t\t'orange': 0xFFA500,\n\t\t'orangered': 0xFF4500,\n\t\t'orchid': 0xDA70D6,\n\t\t'palegoldenrod': 0xEEE8AA,\n\t\t'palegreen': 0x98FB98,\n\t\t'paleturquoise': 0xAFEEEE,\n\t\t'palevioletred': 0xDB7093,\n\t\t'papayawhip': 0xFFEFD5,\n\t\t'peachpuff': 0xFFDAB9,\n\t\t'peru': 0xCD853F,\n\t\t'pink': 0xFFC0CB,\n\t\t'plum': 0xDDA0DD,\n\t\t'powderblue': 0xB0E0E6,\n\t\t'purple': 0x800080,\n\t\t'rebeccapurple': 0x663399,\n\t\t'red': 0xFF0000,\n\t\t'rosybrown': 0xBC8F8F,\n\t\t'royalblue': 0x4169E1,\n\t\t'saddlebrown': 0x8B4513,\n\t\t'salmon': 0xFA8072,\n\t\t'sandybrown': 0xF4A460,\n\t\t'seagreen': 0x2E8B57,\n\t\t'seashell': 0xFFF5EE,\n\t\t'sienna': 0xA0522D,\n\t\t'silver': 0xC0C0C0,\n\t\t'skyblue': 0x87CEEB,\n\t\t'slateblue': 0x6A5ACD,\
1n\t\t'slategray': 0x708090,\n\t\t'slategrey': 0x708090,\n\t\t'snow': 0xFFFAFA,\n\t\t'springgreen': 0x00FF7F,\n\t\t'steelblue': 0x4682B4,\n\t\t'tan': 0xD2B48C,\n\t\t'teal': 0x008080,\n\t\t'thistle': 0xD8BFD8,\n\t\t'tomato': 0xFF6347,\n\t\t'turquoise': 0x40E0D0,\n\t\t'violet': 0xEE82EE,\n\t\t'wheat': 0xF5DEB3,\n\t\t'white': 0xFFFFFF,\n\t\t'whitesmoke': 0xF5F5F5,\n\t\t'yellow': 0xFFFF00,\n\t\t'yellowgreen': 0x9ACD32\n\t};\n\tvar _hslA = {\n\t\th: 0,\n\t\ts: 0,\n\t\tl: 0\n\t};\n\tvar _hslB = {\n\t\th: 0,\n\t\ts: 0,\n\t\tl: 0\n\t};\n\n\tfunction hue2rgb(p, q, t) {\n\t\tif (t < 0) t += 1;\n\t\tif (t > 1) t -= 1;\n\t\tif (t < 1 / 6) return p + (q - p) * 6 * t;\n\t\tif (t < 1 / 2) return q;\n\t\tif (t < 2 / 3) return p + (q - p) * 6 * (2 / 3 - t);\n\t\treturn p;\n\t}\n\n\tfunction SRGBToLinear(c) {\n\t\treturn c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);\n\t}\n\n\tfunction LinearToSRGB(c) {\n\t\treturn c < 0.0031308 ? c * 12.92 : 1.055 * Math.pow(c, 0.41666) - 0.055;\n\t}\n\n\tvar Color = /*#__PURE__*/function () {\n\t\tfunction Color(r, g, b) {\n\t\t\tObject.defineProperty(this, 'isColor', {\n\t\t\t\tvalue: true\n\t\t\t});\n\n\t\t\tif (g === undefined && b === undefined) {\n\t\t\t\t// r is THREE.Color, hex or string\n\t\t\t\treturn this.set(r);\n\t\t\t}\n\n\t\t\treturn this.setRGB(r, g, b);\n\t\t}\n\n\t\tvar _proto = Color.prototype;\n\n\t\t_proto.set = function set(value) {\n\t\t\tif (value && value.isColor) {\n\t\t\t\tthis.copy(value);\n\t\t\t} else if (typeof value === 'number') {\n\t\t\t\tthis.setHex(value);\n\t\t\t} else if (typeof value === 'string') {\n\t\t\t\tthis.setStyle(value);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setScalar = function setScalar(scalar) {\n\t\t\tthis.r = scalar;\n\t\t\tthis.g = scalar;\n\t\t\tthis.b = scalar;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setHex = function setHex(hex) {\n\t\t\thex = Math.floor(hex);\n\t\t\tthis.r = (hex >> 16 & 255) / 255;\n\t\t\tthis.g = (hex >> 8 & 255) / 255;\n\t\t\tthis.b = (hex & 255) / 255;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setRGB = function setRGB(r, g, b) {\n\t\t\tthis.r = r;\n\t\t\tthis.g = g;\n\t\t\tthis.b = b;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setHSL = function setHSL(h, s, l) {\n\t\t\t// h,s,l ranges are in 0.0 - 1.0\n\t\t\th = MathUtils.euclideanModulo(h, 1);\n\t\t\ts = MathUtils.clamp(s, 0, 1);\n\t\t\tl = MathUtils.clamp(l, 0, 1);\n\n\t\t\tif (s === 0) {\n\t\t\t\tthis.r = this.g = this.b = l;\n\t\t\t} else {\n\t\t\t\tvar p = l <= 0.5 ? l * (1 + s) : l + s - l * s;\n\t\t\t\tvar q = 2 * l - p;\n\t\t\t\tthis.r = hue2rgb(q, p, h + 1 / 3);\n\t\t\t\tthis.g = hue2rgb(q, p, h);\n\t\t\t\tthis.b = hue2rgb(q, p, h - 1 / 3);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setStyle = function setStyle(style) {\n\t\t\tfunction handleAlpha(string) {\n\t\t\t\tif (string === undefined) return;\n\n\t\t\t\tif (parseFloat(string) < 1) {\n\t\t\t\t\tconsole.warn('THREE.Color: Alpha component of ' + style + ' will be ignored.');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar m;\n\n\t\t\tif (m = /^((?:rgb|hsl)a?)\\(\\s*([^\\)]*)\\)/.exec(style)) {\n\t\t\t\t// rgb / hsl\n\t\t\t\tvar color;\n\t\t\t\tvar name = m[1];\n\t\t\t\tvar components = m[2];\n\n\t\t\t\tswitch (name) {\n\t\t\t\t\tcase 'rgb':\n\t\t\t\t\tcase 'rgba':\n\t\t\t\t\t\tif (color = /^(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(components)) {\n\t\t\t\t\t\t\t// rgb(255,0,0) rgba(255,0,0,0.5)\n\t\t\t\t\t\t\tthis.r = Math.min(255, parseInt(color[1], 10)) / 255;\n\t\t\t\t\t\t\tthis.g = Math.min(255, parseInt(color[2], 10)) / 255;\n\t\t\t\t\t\t\tthis.b = Math.min(255, parseInt(color[3], 10)) / 255;\n\t\t\t\t\t\t\thandleAlpha(color[4]);\n\t\t\t\t\t\t\treturn this;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (color = /^(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(components)) {\n\t\t\t\t\t\t\t// rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)\n\t\t\t\t\t\t\tthis.r = Math.min(100, parseInt(color[1], 10)) / 100;\n\t\t\t\t\t\t\tthis.g = Math.min(100, parseInt(color[2], 10)) / 100;\n\t\t\t\t\t\t\tthis.b = Math.min(100, parseInt(color[3], 10)) / 100;\n\t\t\t\t\t\t\thandleAlpha(color[4]);\n\t\t\t\t\t\t\treturn this;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'hsl':\n\t\t\t\t\tcase 'hsla':\n\t\t\t\t\t\tif (color = /^(\\d*\\.?\\d+)\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(components)) {\n\t\t\t\t\t\t\t// hsl(120,50%,50%) hsla(120,50%,50%,0.5)\n\t\t\t\t\t\t\tvar h = parseFloat(color[1]) / 360;\n\t\t\t\t\t\t\tvar s = parseInt(color[2], 10) / 100;\n\t\t\t\t\t\t\tvar l = parseInt(color[3], 10) / 100;\n\t\t\t\t\t\t\thandleAlpha(color[4]);\n\t\t\t\t\t\t\treturn this.setHSL(h, s, l);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}
1 else if (m = /^\\#([A-Fa-f\\d]+)$/.exec(style)) {\n\t\t\t\t// hex color\n\t\t\t\tvar hex = m[1];\n\t\t\t\tvar size = hex.length;\n\n\t\t\t\tif (size === 3) {\n\t\t\t\t\t// #ff0\n\t\t\t\t\tthis.r = parseInt(hex.charAt(0) + hex.charAt(0), 16) / 255;\n\t\t\t\t\tthis.g = parseInt(hex.charAt(1) + hex.charAt(1), 16) / 255;\n\t\t\t\t\tthis.b = parseInt(hex.charAt(2) + hex.charAt(2), 16) / 255;\n\t\t\t\t\treturn this;\n\t\t\t\t} else if (size === 6) {\n\t\t\t\t\t// #ff0000\n\t\t\t\t\tthis.r = parseInt(hex.charAt(0) + hex.charAt(1), 16) / 255;\n\t\t\t\t\tthis.g = parseInt(hex.charAt(2) + hex.charAt(3), 16) / 255;\n\t\t\t\t\tthis.b = parseInt(hex.charAt(4) + hex.charAt(5), 16) / 255;\n\t\t\t\t\treturn this;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (style && style.length > 0) {\n\t\t\t\treturn this.setColorName(style);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setColorName = function setColorName(style) {\n\t\t\t// color keywords\n\t\t\tvar hex = _colorKeywords[style];\n\n\t\t\tif (hex !== undefined) {\n\t\t\t\t// red\n\t\t\t\tthis.setHex(hex);\n\t\t\t} else {\n\t\t\t\t// unknown color\n\t\t\t\tconsole.warn('THREE.Color: Unknown color ' + style);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor(this.r, this.g, this.b);\n\t\t};\n\n\t\t_proto.copy = function copy(color) {\n\t\t\tthis.r = color.r;\n\t\t\tthis.g = color.g;\n\t\t\tthis.b = color.b;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.copyGammaToLinear = function copyGammaToLinear(color, gammaFactor) {\n\t\t\tif (gammaFactor === void 0) {\n\t\t\t\tgammaFactor = 2.0;\n\t\t\t}\n\n\t\t\tthis.r = Math.pow(color.r, gammaFactor);\n\t\t\tthis.g = Math.pow(color.g, gammaFactor);\n\t\t\tthis.b = Math.pow(color.b, gammaFactor);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.copyLinearToGamma = function copyLinearToGamma(color, gammaFactor) {\n\t\t\tif (gammaFactor === void 0) {\n\t\t\t\tgammaFactor = 2.0;\n\t\t\t}\n\n\t\t\tvar safeInverse = gammaFactor > 0 ? 1.0 / gammaFactor : 1.0;\n\t\t\tthis.r = Math.pow(color.r, safeInverse);\n\t\t\tthis.g = Math.pow(color.g, safeInverse);\n\t\t\tthis.b = Math.pow(color.b, safeInverse);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.convertGammaToLinear = function convertGammaToLinear(gammaFactor) {\n\t\t\tthis.copyGammaToLinear(this, gammaFactor);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.convertLinearToGamma = function convertLinearToGamma(gammaFactor) {\n\t\t\tthis.copyLinearToGamma(this, gammaFactor);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.copySRGBToLinear = function copySRGBToLinear(color) {\n\t\t\tthis.r = SRGBToLinear(color.r);\n\t\t\tthis.g = SRGBToLinear(color.g);\n\t\t\tthis.b = SRGBToLinear(color.b);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.copyLinearToSRGB = function copyLinearToSRGB(color) {\n\t\t\tthis.r = LinearToSRGB(color.r);\n\t\t\tthis.g = LinearToSRGB(color.g);\n\t\t\tthis.b = LinearToSRGB(color.b);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.convertSRGBToLinear = function convertSRGBToLinear() {\n\t\t\tthis.copySRGBToLinear(this);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.convertLinearToSRGB = function convertLinearToSRGB() {\n\t\t\tthis.copyLinearToSRGB(this);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.getHex = function getHex() {\n\t\t\treturn this.r * 255 << 16 ^ this.g * 255 << 8 ^ this.b * 255 << 0;\n\t\t};\n\n\t\t_proto.getHexString = function getHexString() {\n\t\t\treturn ('000000' + this.getHex().toString(16)).slice(-6);\n\t\t};\n\n\t\t_proto.getHSL = function getHSL(target) {\n\t\t\t// h,s,l ranges are in 0.0 - 1.0\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Color: .getHSL() target is now required');\n\t\t\t\ttarget = {\n\t\t\t\t\th: 0,\n\t\t\t\t\ts: 0,\n\t\t\t\t\tl: 0\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tvar r = this.r,\n\t\t\t\t\tg = this.g,\n\t\t\t\t\tb = this.b;\n\t\t\tvar max = Math.max(r, g, b);\n\t\t\tvar min = Math.min(r, g, b);\n\t\t\tvar hue, saturation;\n\t\t\tvar lightness = (min + max) / 2.0;\n\n\t\t\tif (min === max) {\n\t\t\t\thue = 0;\n\t\t\t\tsaturation = 0;\n\t\t\t} else {\n\t\t\t\tvar delta = max - min;\n\t\t\t\tsaturation = lightness <= 0.5 ? delta / (max + min) : delta / (2 - max - min);\n\n\t\t\t\tswitch (max) {\n\t\t\t\t\tcase r:\n\t\t\t\t\t\thue = (g - b) / delta + (g < b ? 6 : 0);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase g:\n\t\t\t\t\t\thue = (b - r) / delta + 2;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase b:\n\t\t\t\t\t\thue = (r - g) / delta + 4;\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\thue /= 6;\n\t\t\t}\n\n\t\t\ttarget.h = hue;\n\t\t\ttarget.s = saturation;\n\t\t\ttarget.l = lightness;\n\t\t\treturn target;\n\t\t};\n\n\t\t_proto.getStyle = function getStyle() {\n\t\t\treturn 'rgb(' + (this.r * 255 | 0) + ',' + (this.g * 255 | 0) + ',' + (this.b * 255 | 0) + ')';\n\t\t};\n\n\t\t_proto.offsetHSL = function offsetHSL(h, s, l) {\n\t\t\tthis.getHSL(_hslA);\n\t\t\t_hslA.h += h;\n\t\t\t_hslA.s += s;\n\t\t\t_hslA.l += l;\n\t\t\tthis.setHSL(_hslA.h, _hslA.s, _hslA.l);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.add = function add(color) {\n\t\t\tthis.r += color.r;\n\t\t\tthis.g += color.g;\n\t\t\tthis.b += color.b;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.addColors = function addColors(color1, color2) {\n\t\t\tthis.r = color1.r + color2.r;\n\t\t\tthis.g = color1.g + color2.g;\n\t\t\tthis.b = color1.b + color2.b;\n\t\t\treturn this;\n\t\t};
1\n\n\t\t_proto.addScalar = function addScalar(s) {\n\t\t\tthis.r += s;\n\t\t\tthis.g += s;\n\t\t\tthis.b += s;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.sub = function sub(color) {\n\t\t\tthis.r = Math.max(0, this.r - color.r);\n\t\t\tthis.g = Math.max(0, this.g - color.g);\n\t\t\tthis.b = Math.max(0, this.b - color.b);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.multiply = function multiply(color) {\n\t\t\tthis.r *= color.r;\n\t\t\tthis.g *= color.g;\n\t\t\tthis.b *= color.b;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.multiplyScalar = function multiplyScalar(s) {\n\t\t\tthis.r *= s;\n\t\t\tthis.g *= s;\n\t\t\tthis.b *= s;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.lerp = function lerp(color, alpha) {\n\t\t\tthis.r += (color.r - this.r) * alpha;\n\t\t\tthis.g += (color.g - this.g) * alpha;\n\t\t\tthis.b += (color.b - this.b) * alpha;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.lerpHSL = function lerpHSL(color, alpha) {\n\t\t\tthis.getHSL(_hslA);\n\t\t\tcolor.getHSL(_hslB);\n\t\t\tvar h = MathUtils.lerp(_hslA.h, _hslB.h, alpha);\n\t\t\tvar s = MathUtils.lerp(_hslA.s, _hslB.s, alpha);\n\t\t\tvar l = MathUtils.lerp(_hslA.l, _hslB.l, alpha);\n\t\t\tthis.setHSL(h, s, l);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.equals = function equals(c) {\n\t\t\treturn c.r === this.r && c.g === this.g && c.b === this.b;\n\t\t};\n\n\t\t_proto.fromArray = function fromArray(array, offset) {\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tthis.r = array[offset];\n\t\t\tthis.g = array[offset + 1];\n\t\t\tthis.b = array[offset + 2];\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.toArray = function toArray(array, offset) {\n\t\t\tif (array === void 0) {\n\t\t\t\tarray = [];\n\t\t\t}\n\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tarray[offset] = this.r;\n\t\t\tarray[offset + 1] = this.g;\n\t\t\tarray[offset + 2] = this.b;\n\t\t\treturn array;\n\t\t};\n\n\t\t_proto.fromBufferAttribute = function fromBufferAttribute(attribute, index) {\n\t\t\tthis.r = attribute.getX(index);\n\t\t\tthis.g = attribute.getY(index);\n\t\t\tthis.b = attribute.getZ(index);\n\n\t\t\tif (attribute.normalized === true) {\n\t\t\t\t// assuming Uint8Array\n\t\t\t\tthis.r /= 255;\n\t\t\t\tthis.g /= 255;\n\t\t\t\tthis.b /= 255;\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.toJSON = function toJSON() {\n\t\t\treturn this.getHex();\n\t\t};\n\n\t\treturn Color;\n\t}();\n\n\tColor.NAMES = _colorKeywords;\n\tColor.prototype.r = 1;\n\tColor.prototype.g = 1;\n\tColor.prototype.b = 1;\n\n\tvar Face3 = /*#__PURE__*/function () {\n\t\tfunction Face3(a, b, c, normal, color, materialIndex) {\n\t\t\tif (materialIndex === void 0) {\n\t\t\t\tmaterialIndex = 0;\n\t\t\t}\n\n\t\t\tthis.a = a;\n\t\t\tthis.b = b;\n\t\t\tthis.c = c;\n\t\t\tthis.normal = normal && normal.isVector3 ? normal : new Vector3();\n\t\t\tthis.vertexNormals = Array.isArray(normal) ? normal : [];\n\t\t\tthis.color = color && color.isColor ? color : new Color();\n\t\t\tthis.vertexColors = Array.isArray(color) ? color : [];\n\t\t\tthis.materialIndex = materialIndex;\n\t\t}\n\n\t\tvar _proto = Face3.prototype;\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t};\n\n\t\t_proto.copy = function copy(source) {\n\t\t\tthis.a = source.a;\n\t\t\tthis.b = source.b;\n\t\t\tthis.c = source.c;\n\t\t\tthis.normal.copy(source.normal);\n\t\t\tthis.color.copy(source.color);\n\t\t\tthis.materialIndex = source.materialIndex;\n\n\t\t\tfor (var i = 0, il = source.vertexNormals.length; i < il; i++) {\n\t\t\t\tthis.vertexNormals[i] = source.vertexNormals[i].clone();\n\t\t\t}\n\n\t\t\tfor (var _i = 0, _il = source.vertexColors.length; _i < _il; _i++) {\n\t\t\t\tthis.vertexColors[_i] = source.vertexColors[_i].clone();\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\treturn Face3;\n\t}();\n\n\tvar materialId = 0;\n\n\tfunction Material() {\n\t\tObject.defineProperty(this, 'id', {\n\t\t\tvalue: materialId++\n\t\t});\n\t\tthis.uuid = MathUtils.generateUUID();\n\t\tthis.name = '';\n\t\tthis.type = 'Material';\n\t\tthis.fog = true;\n\t\tthis.blending = NormalBlending;\n\t\tthis.side = FrontSide;\n\t\tthis.flatShading = false;\n\t\tthis.vertexColors = false;\n\t\tthis.opacity = 1;\n\t\tthis.transparent = false;\n\t\tthis.blendSrc = SrcAlphaFactor;\n\t\tthis.blendDst = OneMinusSrcAlphaFactor;\n\t\tthis.blendEquation = AddEquation;\n\t\tthis.blendSrcAlpha = null;\n\t\tthis.blendDstAlpha = null;\n\t\tthis.blendEquationAlpha = null;\n\t\tthis.depthFunc = LessEqualDepth;\n\t\tthis.depthTest = true;\n\t\tthis.depthWrite = true;\n\t\tthis.stencilWriteMask = 0xff;\n\t\tthis.stencilFunc = AlwaysStencilFunc;\n\t\tthis.stencilRef = 0;\n\t\tthis.stencilFuncMask = 0xff;\n\t\tthis.stencilFail = KeepStencilOp;\n\t\tthis.stencilZFail = KeepStencilOp;\n\t\tthis.stencilZPass = KeepStencilOp;\n\t\tthis.stencilWrite = false;\n\t\tthis.clippingPlanes = null;\n\t\tthis.clipIntersection = false;\n\t\tthis.clipShadows = false;\n\t\tthis.shadowSide = null;\n\t\tthis.colorWrite = true;\n\t\tthis.precision = null; // override the renderer's default precision for this material\n\n\t\tthis.polygonOffset = false;\n\t\tthis.polygonOffsetFactor = 0;\n\t\tthis.polygonOffsetUnits = 0;\n\t\tthis.dithering = false;\n\t\tthis.alphaTest = 0;\n\t\tthis.premultipliedAlpha = false;\n\t\tthis.visible = true;\n\t\tthis.toneMapped = true;\n\t\tthis.userData = {};\n\t\tthis.version = 0;\n\t}\n\n\tMaterial.prototype = Object.assign(Object.create(EventDispatcher.prototype), {\n\t\tconstructor: Material,\n\t\tisMaterial: true,\n\t\tonBeforeCompile: function onBeforeCompile()\n\t\t/* shaderobject, renderer */\n\t\t{},\n\t\tcustomProgramCacheKey: function customProgramCacheKey() {\n\t\t\treturn this.onBeforeCompile.toString();\n\t\t},\n\t\tsetValues: function setValues(values) {\n\t\t\tif (values === undefined) return;\n\n\t\t\tfor (var key in values) {\n\t\t\t\tvar newValue = values[key];\n\n\t\t\t\tif (newValue === undefined) {\n\t\t\t\t\tconsole.warn('THREE.Material: \\'' + key + '\\' parameter is undefined.');\n\t\t\t\t\tcontinue;\n\t\t\t\t} // for backward compatability if shading is set in the constructor\n\n\n\t\t\t\tif (key === 'shading') {\n\t\t\t\t\tconsole.warn('THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.');\n\t\t\t\t\tthis.flatShading = newValue === FlatShading ? true : false;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tvar currentValue = this[key];\n\n\t\t\t\tif (currentValue === undefined) {\n\t\t\t\t\tconsole.warn('THREE.' + this.type + ': \\'' + key + '\\' is not a property of this material.');\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (currentValue && currentValue.isColor) {\n\t\t\t\t\tcurrentValue.set(newValue);\n\t\t\t\t} else if (currentValue && currentValue.isVector3 && newValue && newValue.isVector3) {\n\t\t\t\t\tcurrentValue.copy(newValue);\n\t\t\t\t} else {\n\t\t\t\t\tthis[key] = newValue;\n\t\t\t\t}\n\t\t\t}\n\t\t}
1,\n\t\ttoJSON: function toJSON(meta) {\n\t\t\tvar isRoot = meta === undefined || typeof meta === 'string';\n\n\t\t\tif (isRoot) {\n\t\t\t\tmeta = {\n\t\t\t\t\ttextures: {},\n\t\t\t\t\timages: {}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tvar data = {\n\t\t\t\tmetadata: {\n\t\t\t\t\tversion: 4.5,\n\t\t\t\t\ttype: 'Material',\n\t\t\t\t\tgenerator: 'Material.toJSON'\n\t\t\t\t}\n\t\t\t}; // standard Material serialization\n\n\t\t\tdata.uuid = this.uuid;\n\t\t\tdata.type = this.type;\n\t\t\tif (this.name !== '') data.name = this.name;\n\t\t\tif (this.color && this.color.isColor) data.color = this.color.getHex();\n\t\t\tif (this.roughness !== undefined) data.roughness = this.roughness;\n\t\t\tif (this.metalness !== undefined) data.metalness = this.metalness;\n\t\t\tif (this.sheen && this.sheen.isColor) data.sheen = this.sheen.getHex();\n\t\t\tif (this.emissive && this.emissive.isColor) data.emissive = this.emissive.getHex();\n\t\t\tif (this.emissiveIntensity && this.emissiveIntensity !== 1) data.emissiveIntensity = this.emissiveIntensity;\n\t\t\tif (this.specular && this.specular.isColor) data.specular = this.specular.getHex();\n\t\t\tif (this.shininess !== undefined) data.shininess = this.shininess;\n\t\t\tif (this.clearcoat !== undefined) data.clearcoat = this.clearcoat;\n\t\t\tif (this.clearcoatRoughness !== undefined) data.clearcoatRoughness = this.clearcoatRoughness;\n\n\t\t\tif (this.clearcoatMap && this.clearcoatMap.isTexture) {\n\t\t\t\tdata.clearcoatMap = this.clearcoatMap.toJSON(meta).uuid;\n\t\t\t}\n\n\t\t\tif (this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture) {\n\t\t\t\tdata.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(meta).uuid;\n\t\t\t}\n\n\t\t\tif (this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture) {\n\t\t\t\tdata.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(meta).uuid;\n\t\t\t\tdata.clearcoatNormalScale = this.clearcoatNormalScale.toArray();\n\t\t\t}\n\n\t\t\tif (this.map && this.map.isTexture) data.map = this.map.toJSON(meta).uuid;\n\t\t\tif (this.matcap && this.matcap.isTexture) data.matcap = this.matcap.toJSON(meta).uuid;\n\t\t\tif (this.alphaMap && this.alphaMap.isTexture) data.alphaMap = this.alphaMap.toJSON(meta).uuid;\n\t\t\tif (this.lightMap && this.lightMap.isTexture) data.lightMap = this.lightMap.toJSON(meta).uuid;\n\n\t\t\tif (this.aoMap && this.aoMap.isTexture) {\n\t\t\t\tdata.aoMap = this.aoMap.toJSON(meta).uuid;\n\t\t\t\tdata.aoMapIntensity = this.aoMapIntensity;\n\t\t\t}\n\n\t\t\tif (this.bumpMap && this.bumpMap.isTexture) {\n\t\t\t\tdata.bumpMap = this.bumpMap.toJSON(meta).uuid;\n\t\t\t\tdata.bumpScale = this.bumpScale;\n\t\t\t}\n\n\t\t\tif (this.normalMap && this.normalMap.isTexture) {\n\t\t\t\tdata.normalMap = this.normalMap.toJSON(meta).uuid;\n\t\t\t\tdata.normalMapType = this.normalMapType;\n\t\t\t\tdata.normalScale = this.normalScale.toArray();\n\t\t\t}\n\n\t\t\tif (this.displacementMap && this.displacementMap.isTexture) {\n\t\t\t\tdata.displacementMap = this.displacementMap.toJSON(meta).uuid;\n\t\t\t\tdata.displacementScale = this.displacementScale;\n\t\t\t\tdata.displacementBias = this.displacementBias;\n\t\t\t}\n\n\t\t\tif (this.roughnessMap && this.roughnessMap.isTexture) data.roughnessMap = this.roughnessMap.toJSON(meta).uuid;\n\t\t\tif (this.metalnessMap && this.metalnessMap.isTexture) data.metalnessMap = this.metalnessMap.toJSON(meta).uuid;\n\t\t\tif (this.emissiveMap && this.emissiveMap.isTexture) data.emissiveMap = this.emissiveMap.toJSON(meta).uuid;\n\t\t\tif (this.specularMap && this.specularMap.isTexture) data.specularMap = this.specularMap.toJSON(meta).uuid;\n\n\t\t\tif (this.envMap && this.envMap.isTexture) {\n\t\t\t\tdata.envMap = this.envMap.toJSON(meta).uuid;\n\t\t\t\tdata.reflectivity = this.reflectivity; // Scale behind envMap\n\n\t\t\t\tdata.refractionRatio = this.refractionRatio;\n\t\t\t\tif (this.combine !== undefined) data.combine = this.combine;\n\t\t\t\tif (this.envMapIntensity !== undefined) data.envMapIntensity = this.envMapIntensity;\n\t\t\t}\n\n\t\t\tif (this.gradientMap && this.gradientMap.isTexture) {\n\t\t\t\tdata.gradientMap = this.gradientMap.toJSON(meta).uuid;\n\t\t\t}\n\n\t\t\tif (this.size !== undefined) data.size = this.size;\n\t\t\tif (this.sizeAttenuation !== undefined) data.sizeAttenuation = this.sizeAttenuation;\n\t\t\tif (this.blending !== NormalBlending) data.blending = this.blending;\n\t\t\tif (this.flatShading === true) data.flatShading = this.flatShading;\n\t\t\tif (this.side !== FrontSide) data.side = this.side;\n\t\t\tif (this.vertexColors) data.vertexColors = true;\n\t\t\tif (this.opacity < 1) data.opacity = this.opacity;\n\t\t\tif (this.transparent === true) data.transparent = this.transparent;\n\t\t\tdata.depthFunc = this.depthFunc;\n\t\t\tdata.depthTest = this.depthTest;\n\t\t\tdata.depthWrite = this.depthWrite;\n\t\t\tdata.stencilWrite = this.stencilWrite;\n\t\t\tdata.stencilWriteMask = this.stencilWriteMask;\n\t\t\tdata.stencilFunc = this.stencilFunc;\n\t\t\tdata.stencilRef = this.stencilRef;\n\t\t\tdata.stencilFuncMask = this.stencilFuncMask;\n\t\t\tdata.stencilFail = this.stencilFail;\n\t\t\tdata.stencilZFail = this.stencilZFail;\n\t\t\tdata.stencilZPass = this.stencilZPass; // rotation (SpriteMaterial)\n\n\t\t\tif (this.rotation && this.rotation !== 0) data.rotation = this.rotation;\n\t\t\tif (this.polygonOffset === true) data.polygonOffset = true;\n\t\t\tif (this.polygonOffsetFactor !== 0) data.polygonOffsetFactor = this.polygonOffsetFactor;
1\n\t\t\tif (this.polygonOffsetUnits !== 0) data.polygonOffsetUnits = this.polygonOffsetUnits;\n\t\t\tif (this.linewidth && this.linewidth !== 1) data.linewidth = this.linewidth;\n\t\t\tif (this.dashSize !== undefined) data.dashSize = this.dashSize;\n\t\t\tif (this.gapSize !== undefined) data.gapSize = this.gapSize;\n\t\t\tif (this.scale !== undefined) data.scale = this.scale;\n\t\t\tif (this.dithering === true) data.dithering = true;\n\t\t\tif (this.alphaTest > 0) data.alphaTest = this.alphaTest;\n\t\t\tif (this.premultipliedAlpha === true) data.premultipliedAlpha = this.premultipliedAlpha;\n\t\t\tif (this.wireframe === true) data.wireframe = this.wireframe;\n\t\t\tif (this.wireframeLinewidth > 1) data.wireframeLinewidth = this.wireframeLinewidth;\n\t\t\tif (this.wireframeLinecap !== 'round') data.wireframeLinecap = this.wireframeLinecap;\n\t\t\tif (this.wireframeLinejoin !== 'round') data.wireframeLinejoin = this.wireframeLinejoin;\n\t\t\tif (this.morphTargets === true) data.morphTargets = true;\n\t\t\tif (this.morphNormals === true) data.morphNormals = true;\n\t\t\tif (this.skinning === true) data.skinning = true;\n\t\t\tif (this.visible === false) data.visible = false;\n\t\t\tif (this.toneMapped === false) data.toneMapped = false;\n\t\t\tif (JSON.stringify(this.userData) !== '{}') data.userData = this.userData; // TODO: Copied from Object3D.toJSON\n\n\t\t\tfunction extractFromCache(cache) {\n\t\t\t\tvar values = [];\n\n\t\t\t\tfor (var key in cache) {\n\t\t\t\t\tvar _data = cache[key];\n\t\t\t\t\tdelete _data.metadata;\n\t\t\t\t\tvalues.push(_data);\n\t\t\t\t}\n\n\t\t\t\treturn values;\n\t\t\t}\n\n\t\t\tif (isRoot) {\n\t\t\t\tvar textures = extractFromCache(meta.textures);\n\t\t\t\tvar images = extractFromCache(meta.images);\n\t\t\t\tif (textures.length > 0) data.textures = textures;\n\t\t\t\tif (images.length > 0) data.images = images;\n\t\t\t}\n\n\t\t\treturn data;\n\t\t},\n\t\tclone: function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t},\n\t\tcopy: function copy(source) {\n\t\t\tthis.name = source.name;\n\t\t\tthis.fog = source.fog;\n\t\t\tthis.blending = source.blending;\n\t\t\tthis.side = source.side;\n\t\t\tthis.flatShading = source.flatShading;\n\t\t\tthis.vertexColors = source.vertexColors;\n\t\t\tthis.opacity = source.opacity;\n\t\t\tthis.transparent = source.transparent;\n\t\t\tthis.blendSrc = source.blendSrc;\n\t\t\tthis.blendDst = source.blendDst;\n\t\t\tthis.blendEquation = source.blendEquation;\n\t\t\tthis.blendSrcAlpha = source.blendSrcAlpha;\n\t\t\tthis.blendDstAlpha = source.blendDstAlpha;\n\t\t\tthis.blendEquationAlpha = source.blendEquationAlpha;\n\t\t\tthis.depthFunc = source.depthFunc;\n\t\t\tthis.depthTest = source.depthTest;\n\t\t\tthis.depthWrite = source.depthWrite;\n\t\t\tthis.stencilWriteMask = source.stencilWriteMask;\n\t\t\tthis.stencilFunc = source.stencilFunc;\n\t\t\tthis.stencilRef = source.stencilRef;\n\t\t\tthis.stencilFuncMask = source.stencilFuncMask;\n\t\t\tthis.stencilFail = source.stencilFail;\n\t\t\tthis.stencilZFail = source.stencilZFail;\n\t\t\tthis.stencilZPass = source.stencilZPass;\n\t\t\tthis.stencilWrite = source.stencilWrite;\n\t\t\tvar srcPlanes = source.clippingPlanes;\n\t\t\tvar dstPlanes = null;\n\n\t\t\tif (srcPlanes !== null) {\n\t\t\t\tvar n = srcPlanes.length;\n\t\t\t\tdstPlanes = new Array(n);\n\n\t\t\t\tfor (var i = 0; i !== n; ++i) {\n\t\t\t\t\tdstPlanes[i] = srcPlanes[i].clone();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.clippingPlanes = dstPlanes;\n\t\t\tthis.clipIntersection = source.clipIntersection;\n\t\t\tthis.clipShadows = source.clipShadows;\n\t\t\tthis.shadowSide = source.shadowSide;\n\t\t\tthis.colorWrite = source.colorWrite;\n\t\t\tthis.precision = source.precision;\n\t\t\tthis.polygonOffset = source.polygonOffset;\n\t\t\tthis.polygonOffsetFactor = source.polygonOffsetFactor;\n\t\t\tthis.polygonOffsetUnits = source.polygonOffsetUnits;\n\t\t\tthis.dithering = source.dithering;\n\t\t\tthis.alphaTest = source.alphaTest;\n\t\t\tthis.premultipliedAlpha = source.premultipliedAlpha;\n\t\t\tthis.visible = source.visible;\n\t\t\tthis.toneMapped = source.toneMapped;\n\t\t\tthis.userData = JSON.parse(JSON.stringify(source.userData));\n\t\t\treturn this;\n\t\t},\n\t\tdispose: function dispose() {\n\t\t\tthis.dispatchEvent({\n\t\t\t\ttype: 'dispose'\n\t\t\t});\n\t\t}\n\t});\n\tObject.defineProperty(Material.prototype, 'needsUpdate', {\n\t\tset: function set(value) {\n\t\t\tif (value === true) this.version++;\n\t\t}\n\t});\n\n\t/**\n\t * parameters = {\n\t *\tcolor: <hex>,\n\t *\topacity: <float>,\n\t *\tmap: new THREE.Texture( <Image> ),\n\t *\n\t *\tlightMap: new THREE.Texture( <Image> ),\n\t *\tlightMapIntensity: <float>\n\t *\n\t *\taoMap: new THREE.Texture( <Image> ),\n\t *\taoMapIntensity: <float>\n\t *\n\t *\tspecularMap: new THREE.Texture( <Image> ),\n\t *\n\t *\talphaMap: new THREE.Texture( <Image> ),\n\t *\n\t *\tenvMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ),\n\t *\tcombine: THREE.Multiply,\n\t *\treflectivity: <float>,\n\t *\trefractionRatio: <float>,\n\t *\n\t *\tdepthTest: <bool>,\n\t *\tdepthWrite: <bool>,\n\t *\n\t *\twireframe: <boolean>,\n\t *\twireframeLinewidth: <float>,\n\t *\n\t *\tskinning: <bool>,\n\t *\tmorphTargets: <bool>\n\t * }\n\t */\n\n\tfunction MeshBasicMaterial(parameters) {\n\t\tMaterial.call(this);\n\t\tthis.type = 'MeshBasicMaterial';\n\t\tthis.color = new Color(0xffffff); // emissive\n\n\t\tthis.map = null;\n\t\tthis.lightMap = null;\n\t\tthis.lightMapIntensity = 1.0;\n\t\tthis.aoMap = null;\n\t\tthis.aoMapIntensity = 1.0;\n\t\tthis.specularMap = null;\n\t\tthis.alphaMap = null;\n\t\tthis.envMap = null;\n\t\tthis.combine = MultiplyOperation;\n\t\tthis.reflectivity = 1;\n\t\tthis.refractionRatio = 0.98;\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.wireframeLinecap = 'round';\n\t\tthis.wireframeLinejoin = 'round';\n\t\tthis.skinning = false;\n\t\tthis.morphTargets = false;\n\t\tthis.setValues(parameters);\n\t}\n\n\tMeshBasicMaterial.prototype = Object.create(Material.prototype);\n\tMeshBasicMaterial.prototype.constructor = MeshBasicMaterial;\n\tMeshBasicMaterial.prototype.isMeshBasicMaterial = true;\n\n\tMeshBasicMaterial.prototype.copy = function (source) {\n\t\tMaterial.prototype.copy.call(this, source);\n\t\tthis.color.copy(source.color);\n\t\tthis.map = source.map;\n\t\tthis.lightMap = source.lightMap;\n\t\tthis.lightMapIntensity = source.lightMapIntensity;\n\t\tthis.aoMap = source.aoMap;\n\t\tthis.aoMapIntensity = source.aoMapIntensity;\n\t\tthis.specularMap = source.specularMap;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.envMap = source.envMap;\n\t\tthis.combine = source.combine;\n\t\tthis.reflectivity = source.reflectivity;\n\t\tthis.refractionRatio = source.refractionRatio;\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.wireframeLinecap = source.wireframeLinecap;\n\t\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\t\treturn this;\n\t};\n\n\tvar _vector$3 = new Vector3();\n\n\tvar _vector2$1 = new Vector2();\n\n\tfunction BufferAttribute(array, itemSize, normalized) {\n\t\tif (Array.isArray(array)) {\n\t\t\tthrow new TypeError('THREE.BufferAttribute: array should be a Typed Array.');\n\t\t}\n\n\t\tthis.name = '';\n\t\tthis.array = array;\n\t\tthis.itemSize = itemSize;\n\t\tthis.count = array !== undefined ? array.length / itemSize : 0;\n\t\tthis.normalized = normalized === true;\n\t\tthis.usage = StaticDrawUsage;\n\t\tthis.updateRange = {\n\t\t\toffset: 0,\n\t\t\tcount: -1\n\t\t};\n\t\tthis.version = 0;\n\t}\n\n\tObject.defineProperty(BufferAttribute.prototype, 'needsUpdate', {\n\t\tset: function set(value) {\n\t\t\tif (value === true) this.version++;\n\t\t}\n\t});\n\tObject.assign(BufferAttribute.prototype, {\n\t\tisBufferAttribute: true,\n\t\tonUploadCallback: function onUploadCallback() {},\n\t\tsetUsage: function setUsage(value) {\n\t\t\tthis.usage = value;\n\t\t\treturn this;\n\t\t},\n\t\tcopy: function copy(source) {\n\t\t\tthis.name = source.name;\n\t\t\tthis.array = new source.array.constructor(source.array);
1\n\t\t\tthis.itemSize = source.itemSize;\n\t\t\tthis.count = source.count;\n\t\t\tthis.normalized = source.normalized;\n\t\t\tthis.usage = source.usage;\n\t\t\treturn this;\n\t\t},\n\t\tcopyAt: function copyAt(index1, attribute, index2) {\n\t\t\tindex1 *= this.itemSize;\n\t\t\tindex2 *= attribute.itemSize;\n\n\t\t\tfor (var i = 0, l = this.itemSize; i < l; i++) {\n\t\t\t\tthis.array[index1 + i] = attribute.array[index2 + i];\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tcopyArray: function copyArray(array) {\n\t\t\tthis.array.set(array);\n\t\t\treturn this;\n\t\t},\n\t\tcopyColorsArray: function copyColorsArray(colors) {\n\t\t\tvar array = this.array;\n\t\t\tvar offset = 0;\n\n\t\t\tfor (var i = 0, l = colors.length; i < l; i++) {\n\t\t\t\tvar color = colors[i];\n\n\t\t\t\tif (color === undefined) {\n\t\t\t\t\tconsole.warn('THREE.BufferAttribute.copyColorsArray(): color is undefined', i);\n\t\t\t\t\tcolor = new Color();\n\t\t\t\t}\n\n\t\t\t\tarray[offset++] = color.r;\n\t\t\t\tarray[offset++] = color.g;\n\t\t\t\tarray[offset++] = color.b;\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tcopyVector2sArray: function copyVector2sArray(vectors) {\n\t\t\tvar array = this.array;\n\t\t\tvar offset = 0;\n\n\t\t\tfor (var i = 0, l = vectors.length; i < l; i++) {\n\t\t\t\tvar vector = vectors[i];\n\n\t\t\t\tif (vector === undefined) {\n\t\t\t\t\tconsole.warn('THREE.BufferAttribute.copyVector2sArray(): vector is undefined', i);\n\t\t\t\t\tvector = new Vector2();\n\t\t\t\t}\n\n\t\t\t\tarray[offset++] = vector.x;\n\t\t\t\tarray[offset++] = vector.y;\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tcopyVector3sArray: function copyVector3sArray(vectors) {\n\t\t\tvar array = this.array;\n\t\t\tvar offset = 0;\n\n\t\t\tfor (var i = 0, l = vectors.length; i < l; i++) {\n\t\t\t\tvar vector = vectors[i];\n\n\t\t\t\tif (vector === undefined) {\n\t\t\t\t\tconsole.warn('THREE.BufferAttribute.copyVector3sArray(): vector is undefined', i);\n\t\t\t\t\tvector = new Vector3();\n\t\t\t\t}\n\n\t\t\t\tarray[offset++] = vector.x;\n\t\t\t\tarray[offset++] = vector.y;\n\t\t\t\tarray[offset++] = vector.z;\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tcopyVector4sArray: function copyVector4sArray(vectors) {\n\t\t\tvar array = this.array;\n\t\t\tvar offset = 0;\n\n\t\t\tfor (var i = 0, l = vectors.length; i < l; i++) {\n\t\t\t\tvar vector = vectors[i];\n\n\t\t\t\tif (vector === undefined) {\n\t\t\t\t\tconsole.warn('THREE.BufferAttribute.copyVector4sArray(): vector is undefined', i);\n\t\t\t\t\tvector = new Vector4();\n\t\t\t\t}\n\n\t\t\t\tarray[offset++] = vector.x;\n\t\t\t\tarray[offset++] = vector.y;\n\t\t\t\tarray[offset++] = vector.z;\n\t\t\t\tarray[offset++] = vector.w;\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tapplyMatrix3: function applyMatrix3(m) {\n\t\t\tif (this.itemSize === 2) {\n\t\t\t\tfor (var i = 0, l = this.count; i < l; i++) {\n\t\t\t\t\t_vector2$1.fromBufferAttribute(this, i);\n\n\t\t\t\t\t_vector2$1.applyMatrix3(m);\n\n\t\t\t\t\tthis.setXY(i, _vector2$1.x, _vector2$1.y);\n\t\t\t\t}\n\t\t\t} else if (this.itemSize === 3) {\n\t\t\t\tfor (var _i = 0, _l = this.count; _i < _l; _i++) {\n\t\t\t\t\t_vector$3.fromBufferAttribute(this, _i);\n\n\t\t\t\t\t_vector$3.applyMatrix3(m);\n\n\t\t\t\t\tthis.setXYZ(_i, _vector$3.x, _vector$3.y, _vector$3.z);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tapplyMatrix4: function applyMatrix4(m) {\n\t\t\tfor (var i = 0, l = this.count; i < l; i++) {\n\t\t\t\t_vector$3.x = this.getX(i);\n\t\t\t\t_vector$3.y = this.getY(i);\n\t\t\t\t_vector$3.z = this.getZ(i);\n\n\t\t\t\t_vector$3.applyMatrix4(m);\n\n\t\t\t\tthis.setXYZ(i, _vector$3.x, _vector$3.y, _vector$3.z);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tapplyNormalMatrix: function applyNormalMatrix(m) {\n\t\t\tfor (var i = 0, l = this.count; i < l; i++) {\n\t\t\t\t_vector$3.x = this.getX(i);\n\t\t\t\t_vector$3.y = this.getY(i);\n\t\t\t\t_vector$3.z = this.getZ(i);\n\n\t\t\t\t_vector$3.applyNormalMatrix(m);\n\n\t\t\t\tthis.setXYZ(i, _vector$3.x, _vector$3.y, _vector$3.z);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\ttransformDirection: function transformDirection(m) {\n\t\t\tfor (var i = 0, l = this.count; i < l;
1 i++) {\n\t\t\t\t_vector$3.x = this.getX(i);\n\t\t\t\t_vector$3.y = this.getY(i);\n\t\t\t\t_vector$3.z = this.getZ(i);\n\n\t\t\t\t_vector$3.transformDirection(m);\n\n\t\t\t\tthis.setXYZ(i, _vector$3.x, _vector$3.y, _vector$3.z);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tset: function set(value, offset) {\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tthis.array.set(value, offset);\n\t\t\treturn this;\n\t\t},\n\t\tgetX: function getX(index) {\n\t\t\treturn this.array[index * this.itemSize];\n\t\t},\n\t\tsetX: function setX(index, x) {\n\t\t\tthis.array[index * this.itemSize] = x;\n\t\t\treturn this;\n\t\t},\n\t\tgetY: function getY(index) {\n\t\t\treturn this.array[index * this.itemSize + 1];\n\t\t},\n\t\tsetY: function setY(index, y) {\n\t\t\tthis.array[index * this.itemSize + 1] = y;\n\t\t\treturn this;\n\t\t},\n\t\tgetZ: function getZ(index) {\n\t\t\treturn this.array[index * this.itemSize + 2];\n\t\t},\n\t\tsetZ: function setZ(index, z) {\n\t\t\tthis.array[index * this.itemSize + 2] = z;\n\t\t\treturn this;\n\t\t},\n\t\tgetW: function getW(index) {\n\t\t\treturn this.array[index * this.itemSize + 3];\n\t\t},\n\t\tsetW: function setW(index, w) {\n\t\t\tthis.array[index * this.itemSize + 3] = w;\n\t\t\treturn this;\n\t\t},\n\t\tsetXY: function setXY(index, x, y) {\n\t\t\tindex *= this.itemSize;\n\t\t\tthis.array[index + 0] = x;\n\t\t\tthis.array[index + 1] = y;\n\t\t\treturn this;\n\t\t},\n\t\tsetXYZ: function setXYZ(index, x, y, z) {\n\t\t\tindex *= this.itemSize;\n\t\t\tthis.array[index + 0] = x;\n\t\t\tthis.array[index + 1] = y;\n\t\t\tthis.array[index + 2] = z;\n\t\t\treturn this;\n\t\t},\n\t\tsetXYZW: function setXYZW(index, x, y, z, w) {\n\t\t\tindex *= this.itemSize;\n\t\t\tthis.array[index + 0] = x;\n\t\t\tthis.array[index + 1] = y;\n\t\t\tthis.array[index + 2] = z;\n\t\t\tthis.array[index + 3] = w;\n\t\t\treturn this;\n\t\t},\n\t\tonUpload: function onUpload(callback) {\n\t\t\tthis.onUploadCallback = callback;\n\t\t\treturn this;\n\t\t},\n\t\tclone: function clone() {\n\t\t\treturn new this.constructor(this.array, this.itemSize).copy(this);\n\t\t},\n\t\ttoJSON: function toJSON() {\n\t\t\treturn {\n\t\t\t\titemSize: this.itemSize,\n\t\t\t\ttype: this.array.constructor.name,\n\t\t\t\tarray: Array.prototype.slice.call(this.array),\n\t\t\t\tnormalized: this.normalized\n\t\t\t};\n\t\t}\n\t}); //\n\n\tfunction Int8BufferAttribute(array, itemSize, normalized) {\n\t\tBufferAttribute.call(this, new Int8Array(array), itemSize, normalized);\n\t}\n\n\tInt8BufferAttribute.prototype = Object.create(BufferAttribute.prototype);\n\tInt8BufferAttribute.prototype.constructor = Int8BufferAttribute;\n\n\tfunction Uint8BufferAttribute(array, itemSize, normalized) {\n\t\tBufferAttribute.call(this, new Uint8Array(array), itemSize, normalized);\n\t}\n\n\tUint8BufferAttribute.prototype = Object.create(BufferAttribute.prototype);\n\tUint8BufferAttribute.prototype.constructor = Uint8BufferAttribute;\n\n\tfunction Uint8ClampedBufferAttribute(array, itemSize, normalized) {\n\t\tBufferAttribute.call(this, new Uint8ClampedArray(array), itemSize, normalized);\n\t}\n\n\tUint8ClampedBufferAttribute.prototype = Object.create(BufferAttribute.prototype);\n\tUint8ClampedBufferAttribute.prototype.constructor = Uint8ClampedBufferAttribute;\n\n\tfunction Int16BufferAttribute(array, itemSize, normalized) {\n\t\tBufferAttribute.call(this, new Int16Array(array), itemSize, normalized);\n\t}\n\n\tInt16BufferAttribute.prototype = Object.create(BufferAttribute.prototype);\n\tInt16BufferAttribute.prototype.constructor = Int16BufferAttribute;\n\n\tfunction Uint16BufferAttribute(array, itemSize, normalized) {\n\t\tBufferAttribute.call(this, new Uint16Array(array), itemSize, normalized);\n\t}\n\n\tUint16BufferAttribute.prototype = Object.create(BufferAttribute.prototype);\n\tUint16BufferAttribute.prototype.constructor = Uint16BufferAttribute;\n\n\tfunction Int32BufferAttribute(array, itemSize, normalized) {\n\t\tBufferAttribute.call(this, new Int32Array(array), itemSize, normalized);\n\t}\n\n\tInt32BufferAttribute.prototype = Object.create(BufferAttribute.prototype);\n\tInt32BufferAttribute.prototype.constructor = Int32BufferAttribute;\n\n\tfunction Uint32BufferAttribute(array, itemSize, normalized) {\n\t\tBufferAttribute.call(this, new Uint32Array(array), itemSize, normalized);\n\t}\n\n\tUint32BufferAttribute.prototype = Object.create(BufferAttribute.prototype);\n\tUint32BufferAttribute.prototype.constructor = Uint32BufferAttribute;\n\n\tfunction Float16BufferAttribute(array, itemSize, normalized) {\n\t\tBufferAttribute.call(this, new Uint16Array(array), itemSize, normalized);\n\t}\n\n\tFloat16BufferAttribute.prototype = Object.create(BufferAttribute.prototype);\n\tFloat16BufferAttribute.prototype.constructor = Float16BufferAttribute;\n\tFloat16BufferAttribute.prototype.isFloat16BufferAttribute = true;\n\n\tfunction Float32BufferAttribute(array, itemSize, normalized) {\n\t\tBufferAttribute.call(this, new Float32Array(array), itemSize, normalized);\n\t}\n\n\tFloat32BufferAttribute.prototype = Object.create(BufferAttribute.prototype);\n\tFloat32BufferAttribute.prototype.constructor = Float32BufferAttribute;\n\n\tfunction Float64BufferAttribute(array, itemSize, normalized) {\n\t\tBufferAttribute.call(this, new Float64Array(array), itemSize, normalized);\n\t}\n\n\tFloat64BufferAttribute.prototype = Object.create(BufferAttribute.prototype);\n\tFloat64BufferAttribute.prototype.constructor = Float64BufferAttribute; //\n\n\tvar DirectGeometry = /*#__PURE__*/function () {\n\t\tfunction DirectGeometry() {\n\t\t\tthis.vertices = [];\n\t\t\tthis.normals = [];\n\t\t\tthis.colors = [];\n\t\t\tthis.uvs = [];\n\t\t\tthis.uvs2 = [];\n\t\t\tthis.groups = [];\n\t\t\tthis.morphTargets = {};\n\t\t\tthis.skinWeights = [];\n\t\t\tthis.skinIndices = []; // this.lineDistances = [];\n\n\t\t\tthis.boundingBox = null;\n\t\t\tthis.boundingSphere = null; // update flags\n\n\t\t\tthis.verticesNeedUpdate = false;\n\t\t\tthis.normalsNeedUpdate = false;\n\t\t\tthis.colorsNeedUpdate = false;\n\t\t\tthis.uvsNeedUpdate = false;\n\t\t\tthis.groupsNeedUpdate = false;\n\t\t}\n\n\t\tvar _proto = DirectGeometry.prototype;\n\n\t\t_proto.computeGroups = function computeGroups(geometry) {\n\t\t\tvar groups = [];\n\t\t\tvar group, i;\n\t\t\tvar materialIndex = undefined;\n\t\t\tvar faces = geometry.faces;\n\n\t\t\tfor (i = 0; i < faces.length;
1 i++) {\n\t\t\t\tvar face = faces[i]; // materials\n\n\t\t\t\tif (face.materialIndex !== materialIndex) {\n\t\t\t\t\tmaterialIndex = face.materialIndex;\n\n\t\t\t\t\tif (group !== undefined) {\n\t\t\t\t\t\tgroup.count = i * 3 - group.start;\n\t\t\t\t\t\tgroups.push(group);\n\t\t\t\t\t}\n\n\t\t\t\t\tgroup = {\n\t\t\t\t\t\tstart: i * 3,\n\t\t\t\t\t\tmaterialIndex: materialIndex\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (group !== undefined) {\n\t\t\t\tgroup.count = i * 3 - group.start;\n\t\t\t\tgroups.push(group);\n\t\t\t}\n\n\t\t\tthis.groups = groups;\n\t\t};\n\n\t\t_proto.fromGeometry = function fromGeometry(geometry) {\n\t\t\tvar faces = geometry.faces;\n\t\t\tvar vertices = geometry.vertices;\n\t\t\tvar faceVertexUvs = geometry.faceVertexUvs;\n\t\t\tvar hasFaceVertexUv = faceVertexUvs[0] && faceVertexUvs[0].length > 0;\n\t\t\tvar hasFaceVertexUv2 = faceVertexUvs[1] && faceVertexUvs[1].length > 0; // morphs\n\n\t\t\tvar morphTargets = geometry.morphTargets;\n\t\t\tvar morphTargetsLength = morphTargets.length;\n\t\t\tvar morphTargetsPosition;\n\n\t\t\tif (morphTargetsLength > 0) {\n\t\t\t\tmorphTargetsPosition = [];\n\n\t\t\t\tfor (var i = 0; i < morphTargetsLength; i++) {\n\t\t\t\t\tmorphTargetsPosition[i] = {\n\t\t\t\t\t\tname: morphTargets[i].name,\n\t\t\t\t\t\tdata: []\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tthis.morphTargets.position = morphTargetsPosition;\n\t\t\t}\n\n\t\t\tvar morphNormals = geometry.morphNormals;\n\t\t\tvar morphNormalsLength = morphNormals.length;\n\t\t\tvar morphTargetsNormal;\n\n\t\t\tif (morphNormalsLength > 0) {\n\t\t\t\tmorphTargetsNormal = [];\n\n\t\t\t\tfor (var _i = 0; _i < morphNormalsLength;
1 _i++) {\n\t\t\t\t\tmorphTargetsNormal[_i] = {\n\t\t\t\t\t\tname: morphNormals[_i].name,\n\t\t\t\t\t\tdata: []\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tthis.morphTargets.normal = morphTargetsNormal;\n\t\t\t} // skins\n\n\n\t\t\tvar skinIndices = geometry.skinIndices;\n\t\t\tvar skinWeights = geometry.skinWeights;\n\t\t\tvar hasSkinIndices = skinIndices.length === vertices.length;\n\t\t\tvar hasSkinWeights = skinWeights.length === vertices.length; //\n\n\t\t\tif (vertices.length > 0 && faces.length === 0) {\n\t\t\t\tconsole.error('THREE.DirectGeometry: Faceless geometries are not supported.');\n\t\t\t}\n\n\t\t\tfor (var _i2 = 0; _i2 < faces.length; _i2++) {\n\t\t\t\tvar face = faces[_i2];\n\t\t\t\tthis.vertices.push(vertices[face.a], vertices[face.b], vertices[face.c]);\n\t\t\t\tvar vertexNormals = face.vertexNormals;\n\n\t\t\t\tif (vertexNormals.length === 3) {\n\t\t\t\t\tthis.normals.push(vertexNormals[0], vertexNormals[1], vertexNormals[2]);\n\t\t\t\t} else {\n\t\t\t\t\tvar normal = face.normal;\n\t\t\t\t\tthis.normals.push(normal, normal, normal);\n\t\t\t\t}\n\n\t\t\t\tvar vertexColors = face.vertexColors;\n\n\t\t\t\tif (vertexColors.length === 3) {\n\t\t\t\t\tthis.colors.push(vertexColors[0], vertexColors[1], vertexColors[2]);\n\t\t\t\t} else {\n\t\t\t\t\tvar color = face.color;\n\t\t\t\t\tthis.colors.push(color, color, color);\n\t\t\t\t}\n\n\t\t\t\tif (hasFaceVertexUv === true) {\n\t\t\t\t\tvar vertexUvs = faceVertexUvs[0][_i2];\n\n\t\t\t\t\tif (vertexUvs !== undefined) {\n\t\t\t\t\t\tthis.uvs.push(vertexUvs[0], vertexUvs[1], vertexUvs[2]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.warn('THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', _i2);\n\t\t\t\t\t\tthis.uvs.push(new Vector2(), new Vector2(), new Vector2());\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (hasFaceVertexUv2 === true) {\n\t\t\t\t\tvar _vertexUvs = faceVertexUvs[1][_i2];\n\n\t\t\t\t\tif (_vertexUvs !== undefined) {\n\t\t\t\t\t\tthis.uvs2.push(_vertexUvs[0], _vertexUvs[1], _vertexUvs[2]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.warn('THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', _i2);\n\t\t\t\t\t\tthis.uvs2.push(new Vector2(), new Vector2(), new Vector2());\n\t\t\t\t\t}\n\t\t\t\t} // morphs\n\n\n\t\t\t\tfor (var j = 0; j < morphTargetsLength; j++) {\n\t\t\t\t\tvar morphTarget = morphTargets[j].vertices;\n\t\t\t\t\tmorphTargetsPosition[j].data.push(morphTarget[face.a], morphTarget[face.b], morphTarget[face.c]);\n\t\t\t\t}\n\n\t\t\t\tfor (var _j = 0; _j < morphNormalsLength; _j++) {\n\t\t\t\t\tvar morphNormal = morphNormals[_j].vertexNormals[_i2];\n\n\t\t\t\t\tmorphTargetsNormal[_j].data.push(morphNormal.a, morphNormal.b, morphNormal.c);\n\t\t\t\t} // skins\n\n\n\t\t\t\tif (hasSkinIndices) {\n\t\t\t\t\tthis.skinIndices.push(skinIndices[face.a], skinIndices[face.b], skinIndices[face.c]);\n\t\t\t\t}\n\n\t\t\t\tif (hasSkinWeights) {\n\t\t\t\t\tthis.skinWeights.push(skinWeights[face.a], skinWeights[face.b], skinWeights[face.c]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.computeGroups(geometry);\n\t\t\tthis.verticesNeedUpdate = geometry.verticesNeedUpdate;\n\t\t\tthis.normalsNeedUpdate = geometry.normalsNeedUpdate;\n\t\t\tthis.colorsNeedUpdate = geometry.colorsNeedUpdate;\n\t\t\tthis.uvsNeedUpdate = geometry.uvsNeedUpdate;\n\t\t\tthis.groupsNeedUpdate = geometry.groupsNeedUpdate;\n\n\t\t\tif (geometry.boundingSphere !== null) {\n\t\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\t\t\t}\n\n\t\t\tif (geometry.boundingBox !== null) {\n\t\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\treturn DirectGeometry;\n\t}();\n\n\tfunction arrayMax(array) {\n\t\tif (array.length === 0) return -Infinity;\n\t\tvar max = array[0];\n\n\t\tfor (var i = 1, l = array.length; i < l; ++i) {\n\t\t\tif (array[i] > max) max = array[i];\n\t\t}\n\n\t\treturn max;\n\t}\n\n\tvar TYPED_ARRAYS = {\n\t\tInt8Array: Int8Array,\n\t\tUint8Array: Uint8Array,\n\t\t// Workaround for IE11 pre KB2929437. See #11440\n\t\tUint8ClampedArray: typeof Uint8ClampedArray !== 'undefined' ? Uint8ClampedArray : Uint8Array,\n\t\tInt16Array: Int16Array,\n\t\tUint16Array: Uint16Array,\n\t\tInt32Array: Int32Array,\n\t\tUint32Array: Uint32Array,\n\t\tFloat32Array: Float32Array,\n\t\tFloat64Array: Float64Array\n\t};\n\n\tfunction getTypedArray(type, buffer) {\n\t\treturn new TYPED_ARRAYS[type](buffer);\n\t}\n\n\tvar _bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id\n\n\tvar _m1$2 = new Matrix4();\n\n\tvar _obj = new Object3D();\n\n\tvar _offset = new Vector3();\n\n\tvar _box$2 = new Box3();\n\n\tvar _boxMorphTargets = new Box3();\n\n\tvar _vector$4 = new Vector3();\n\n\tfunction BufferGeometry() {\n\t\tObject.defineProperty(this, 'id', {\n\t\t\tvalue: _bufferGeometryId += 2\n\t\t});\n\t\tthis.uuid = MathUtils.generateUUID();\n\t\tthis.name = '';\n\t\tthis.type = 'BufferGeometry';\n\t\tthis.index = null;\n\t\tthis.attributes = {};\n\t\tthis.morphAttributes = {};\n\t\tthis.morphTargetsRelative = false;\n\t\tthis.groups = [];\n\t\tthis.boundingBox = null;\n\t\tthis.boundingSphere = null;\n\t\tthis.drawRange = {\n\t\t\tstart: 0,\n\t\t\tcount: Infinity\n\t\t};\n\t\tthis.userData = {};\n\t}\n\n\tBufferGeometry.prototype = Object.assign(Object.create(EventDispatcher.prototype), {\n\t\tconstructor: BufferGeometry,\n\t\tisBufferGeometry: true,\n\t\tgetIndex: function getIndex() {\n\t\t\treturn this.index;\n\t\t},\n\t\tsetIndex: function setIndex(index) {\n\t\t\tif (Array.isArray(index)) {\n\t\t\t\tthis.index = new (arrayMax(index) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute)(index, 1);\n\t\t\t} else {\n\t\t\t\tthis.index = index;\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tgetAttribute: function getAttribute(name) {\n\t\t\treturn this.attributes[name];\n\t\t},\n\t\tsetAttribute: function setAttribute(name, attribute) {\n\t\t\tthis.attributes[name] = attribute;\n\t\t\treturn this;\n\t\t},\n\t\tdeleteAttribute: function deleteAttribute(name) {\n\t\t\tdelete this.attributes[name];\n\t\t\treturn this;\n\t\t},\n\t\thasAttribute: function hasAttribute(name) {\n\t\t\treturn this.attributes[name] !== undefined;\n\t\t},\n\t\taddGroup: function addGroup(start, count, materialIndex) {\n\t\t\tif (materialIndex === void 0) {\n\t\t\t\tmaterialIndex = 0;\n\t\t\t}\n\n\t\t\tthis.groups.push({\n\t\t\t\tstart: start,\n\t\t\t\tcount: count,\n\t\t\t\tmaterialIndex: materialIndex\n\t\t\t});\n\t\t},\n\t\tclearGroups: function clearGroups() {\n\t\t\tthis.groups = [];\n\t\t},\n\t\tsetDrawRange: function setDrawRange(start, count) {\n\t\t\tthis.drawRange.start = start;\n\t\t\tthis.drawRange.count = count;\n\t\t},\n\t\tapplyMatrix4: function applyMatrix4(matrix) {\n\t\t\tvar position = this.attributes.position;\n\n\t\t\tif (position !== undefined) {\n\t\t\t\tposition.applyMatrix4(matrix);\n\t\t\t\tposition.needsUpdate = true;\n\t\t\t}\n\n\t\t\tvar normal = this.attributes.normal;
1\n\n\t\t\tif (normal !== undefined) {\n\t\t\t\tvar normalMatrix = new Matrix3().getNormalMatrix(matrix);\n\t\t\t\tnormal.applyNormalMatrix(normalMatrix);\n\t\t\t\tnormal.needsUpdate = true;\n\t\t\t}\n\n\t\t\tvar tangent = this.attributes.tangent;\n\n\t\t\tif (tangent !== undefined) {\n\t\t\t\ttangent.transformDirection(matrix);\n\t\t\t\ttangent.needsUpdate = true;\n\t\t\t}\n\n\t\t\tif (this.boundingBox !== null) {\n\t\t\t\tthis.computeBoundingBox();\n\t\t\t}\n\n\t\t\tif (this.boundingSphere !== null) {\n\t\t\t\tthis.computeBoundingSphere();\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\trotateX: function rotateX(angle) {\n\t\t\t// rotate geometry around world x-axis\n\t\t\t_m1$2.makeRotationX(angle);\n\n\t\t\tthis.applyMatrix4(_m1$2);\n\t\t\treturn this;\n\t\t},\n\t\trotateY: function rotateY(angle) {\n\t\t\t// rotate geometry around world y-axis\n\t\t\t_m1$2.makeRotationY(angle);\n\n\t\t\tthis.applyMatrix4(_m1$2);\n\t\t\treturn this;\n\t\t},\n\t\trotateZ: function rotateZ(angle) {\n\t\t\t// rotate geometry around world z-axis\n\t\t\t_m1$2.makeRotationZ(angle);\n\n\t\t\tthis.applyMatrix4(_m1$2);\n\t\t\treturn this;\n\t\t},\n\t\ttranslate: function translate(x, y, z) {\n\t\t\t// translate geometry\n\t\t\t_m1$2.makeTranslation(x, y, z);\n\n\t\t\tthis.applyMatrix4(_m1$2);\n\t\t\treturn this;\n\t\t},\n\t\tscale: function scale(x, y, z) {\n\t\t\t// scale geometry\n\t\t\t_m1$2.makeScale(x, y, z);\n\n\t\t\tthis.applyMatrix4(_m1$2);\n\t\t\treturn this;\n\t\t},\n\t\tlookAt: function lookAt(vector) {\n\t\t\t_obj.lookAt(vector);\n\n\t\t\t_obj.updateMatrix();\n\n\t\t\tthis.applyMatrix4(_obj.matrix);\n\t\t\treturn this;\n\t\t},\n\t\tcenter: function center() {\n\t\t\tthis.computeBoundingBox();\n\t\t\tthis.boundingBox.getCenter(_offset).negate();\n\t\t\tthis.translate(_offset.x, _offset.y, _offset.z);\n\t\t\treturn this;\n\t\t},\n\t\tsetFromObject: function setFromObject(object) {\n\t\t\t// console.log( 'THREE.BufferGeometry.setFromObject(). Converting', object, this );\n\t\t\tvar geometry = object.geometry;\n\n\t\t\tif (object.isPoints || object.isLine) {\n\t\t\t\tvar positions = new Float32BufferAttribute(geometry.vertices.length * 3, 3);\n\t\t\t\tvar colors = new Float32BufferAttribute(geometry.colors.length * 3, 3);\n\t\t\t\tthis.setAttribute('position', positions.copyVector3sArray(geometry.vertices));\n\t\t\t\tthis.setAttribute('color', colors.copyColorsArray(geometry.colors));\n\n\t\t\t\tif (geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length) {\n\t\t\t\t\tvar lineDistances = new Float32BufferAttribute(geometry.lineDistances.length, 1);\n\t\t\t\t\tthis.setAttribute('lineDistance', lineDistances.copyArray(geometry.lineDistances));\n\t\t\t\t}\n\n\t\t\t\tif (geometry.boundingSphere !== null) {\n\t\t\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\t\t\t\t}\n\n\t\t\t\tif (geometry.boundingBox !== null) {\n\t\t\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\t\t\t\t}\n\t\t\t} else if (object.isMesh) {\n\t\t\t\tif (geometry && geometry.isGeometry) {\n\t\t\t\t\tthis.fromGeometry(geometry);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tsetFromPoints: function setFromPoints(points) {\n\t\t\tvar position = [];\n\n\t\t\tfor (var i = 0, l = points.length; i < l; i++) {\n\t\t\t\tvar point = points[i];\n\t\t\t\tposition.push(point.x, point.y, point.z || 0);\n\t\t\t}\n\n\t\t\tthis.setAttribute('position', new Float32BufferAttribute(position, 3));\n\t\t\treturn this;\n\t\t},\n\t\tupdateFromObject: function updateFromObject(object) {\n\t\t\tvar geometry = object.geometry;\n\n\t\t\tif (object.isMesh) {\n\t\t\t\tvar direct = geometry.__directGeometry;\n\n\t\t\t\tif (geometry.elementsNeedUpdate === true) {\n\t\t\t\t\tdirect = undefined;\n\t\t\t\t\tgeometry.elementsNeedUpdate = false;\n\t\t\t\t}\n\n\t\t\t\tif (direct === undefined) {\n\t\t\t\t\treturn this.fromGeometry(geometry);\n\t\t\t\t}\n\n\t\t\t\tdirect.verticesNeedUpdate = geometry.verticesNeedUpdate;\n\t\t\t\tdirect.normalsNeedUpdate = geometry.normalsNeedUpdate;\n\t\t\t\tdirect.colorsNeedUpdate = geometry.colorsNeedUpdate;\n\t\t\t\tdirect.uvsNeedUpdate = geometry.uvsNeedUpdate;\n\t\t\t\tdirect.groupsNeedUpdate = geometry.groupsNeedUpdate;\n\t\t\t\tgeometry.verticesNeedUpdate = false;\n\t\t\t\tgeometry.normalsNeedUpdate = false;\n\t\t\t\tgeometry.colorsNeedUpdate = false;\n\t\t\t\tgeometry.uvsNeedUpdate = false;\n\t\t\t\tgeometry.groupsNeedUpdate = false;\n\t\t\t\tgeometry = direct;\n\t\t\t}\n\n\t\t\tif (geometry.verticesNeedUpdate === true) {\n\t\t\t\tvar attribute = this.attributes.position;\n\n\t\t\t\tif (attribute !== undefined) {\n\t\t\t\t\tattribute.copyVector3sArray(geometry.vertices);\n\t\t\t\t\tattribute.needsUpdate = true;\n\t\t\t\t}\n\n\t\t\t\tgeometry.verticesNeedUpdate = false;\n\t\t\t}\n\n\t\t\tif (geometry.normalsNeedUpdate === true) {\n\t\t\t\tvar _attribute = this.attributes.normal;\n\n\t\t\t\tif (_attribute !== undefined) {\n\t\t\t\t\t_attribute.copyVector3sArray(geometry.normals);\n\n\t\t\t\t\t_attribute.needsUpdate = true;\n\t\t\t\t}\n\n\t\t\t\tgeometry.normalsNeedUpdate = false;\n\t\t\t}\n\n\t\t\tif (geometry.colorsNeedUpdate === true) {\n\t\t\t\tvar _attribute2 = this.attributes.color;\n\n\t\t\t\tif (_attribute2 !== undefined) {\n\t\t\t\t\t_attribute2.copyColorsArray(geometry.colors);\n\n\t\t\t\t\t_attribute2.needsUpdate = true;\n\t\t\t\t}\n\n\t\t\t\tgeometry.colorsNeedUpdate = false;\n\t\t\t}\n\n\t\t\tif (geometry.uvsNeedUpdate) {\n\t\t\t\tvar _attribute3 = this.attributes.uv;\n\n\t\t\t\tif (_attribute3 !== undefined) {\n\t\t\t\t\t_attribute3.copyVector2sArray(geometry.uvs);\n\n\t\t\t\t\t_attribute3.needsUpdate = true;\n\t\t\t\t}\n\n\t\t\t\tgeometry.uvsNeedUpdate = false;\n\t\t\t}\n\n\t\t\tif (geometry.lineDistancesNeedUpdate) {\n\t\t\t\tvar _attribute4 = this.attributes.lineDistance;\n\n\t\t\t\tif (_attribute4 !== undefined) {\n\t\t\t\t\t_attribute4.copyArray(geometry.lineDistances);\n\n\t\t\t\t\t_attribute4.needsUpdate = true;\n\t\t\t\t}\n\n\t\t\t\tgeometry.lineDistancesNeedUpdate = false;\n\t\t\t}\n\n\t\t\tif (geometry.groupsNeedUpdate) {\n\t\t\t\tgeometry.computeGroups(object.geometry);\n\t\t\t\tthis.groups = geometry.groups;\n\t\t\t\tgeometry.groupsNeedUpdate = false;\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tfromGeometry: function fromGeometry(geometry) {\n\t\t\tgeometry.__directGeometry = new DirectGeometry().fromGeometry(geometry);\n\t\t\treturn this.fromDirectGeometry(geometry.__directGeometry);\n\t\t},\n\t\tfromDirectGeometry: function fromDirectGeometry(geometry) {\n\t\t\tvar positions = new Float32Array(geometry.vertices.length * 3);\n\t\t\tthis.setAttribute('position', new BufferAttribute(positions, 3).copyVector3sArray(geometry.vertices));\n\n\t\t\tif (geometry.normals.length > 0) {\n\t\t\t\tvar normals = new Float32Array(geometry.normals.length * 3);\n\t\t\t\tthis.setAttribute('normal', new BufferAttribute(normals, 3).copyVector3sArray(geometry.normals));\n\t\t\t}\n\n\t\t\tif (geometry.colors.length > 0) {\n\t\t\t\tvar colors = new Float32Array(geometry.colors.length * 3);\n\t\t\t\tthis.setAttribute('color', new BufferAttribute(colors, 3).copyColorsArray(geometry.colors));\n\t\t\t}\n\n\t\t\tif (geometry.uvs.length > 0) {\n\t\t\t\tvar uvs = new Float32Array(geometry.uvs.length * 2);\n\t\t\t\tthis.setAttribute('uv', new BufferAttribute(uvs, 2).copyVector2sArray(geometry.uvs)
1);\n\t\t\t}\n\n\t\t\tif (geometry.uvs2.length > 0) {\n\t\t\t\tvar uvs2 = new Float32Array(geometry.uvs2.length * 2);\n\t\t\t\tthis.setAttribute('uv2', new BufferAttribute(uvs2, 2).copyVector2sArray(geometry.uvs2));\n\t\t\t} // groups\n\n\n\t\t\tthis.groups = geometry.groups; // morphs\n\n\t\t\tfor (var name in geometry.morphTargets) {\n\t\t\t\tvar array = [];\n\t\t\t\tvar morphTargets = geometry.morphTargets[name];\n\n\t\t\t\tfor (var i = 0, l = morphTargets.length; i < l; i++) {\n\t\t\t\t\tvar morphTarget = morphTargets[i];\n\t\t\t\t\tvar attribute = new Float32BufferAttribute(morphTarget.data.length * 3, 3);\n\t\t\t\t\tattribute.name = morphTarget.name;\n\t\t\t\t\tarray.push(attribute.copyVector3sArray(morphTarget.data));\n\t\t\t\t}\n\n\t\t\t\tthis.morphAttributes[name] = array;\n\t\t\t} // skinning\n\n\n\t\t\tif (geometry.skinIndices.length > 0) {\n\t\t\t\tvar skinIndices = new Float32BufferAttribute(geometry.skinIndices.length * 4, 4);\n\t\t\t\tthis.setAttribute('skinIndex', skinIndices.copyVector4sArray(geometry.skinIndices));\n\t\t\t}\n\n\t\t\tif (geometry.skinWeights.length > 0) {\n\t\t\t\tvar skinWeights = new Float32BufferAttribute(geometry.skinWeights.length * 4, 4);\n\t\t\t\tthis.setAttribute('skinWeight', skinWeights.copyVector4sArray(geometry.skinWeights));\n\t\t\t} //\n\n\n\t\t\tif (geometry.boundingSphere !== null) {\n\t\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\t\t\t}\n\n\t\t\tif (geometry.boundingBox !== null) {\n\t\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tcomputeBoundingBox: function computeBoundingBox() {\n\t\t\tif (this.boundingBox === null) {\n\t\t\t\tthis.boundingBox = new Box3();\n\t\t\t}\n\n\t\t\tvar position = this.attributes.position;\n\t\t\tvar morphAttributesPosition = this.morphAttributes.position;\n\n\t\t\tif (position && position.isGLBufferAttribute) {\n\t\t\t\tconsole.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set \"mesh.frustumCulled\" to \"false\".', this);\n\t\t\t\tthis.boundingBox.set(new Vector3(-Infinity, -Infinity, -Infinity), new Vector3(+Infinity, +Infinity, +Infinity));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (position !== undefined) {\n\t\t\t\tthis.boundingBox.setFromBufferAttribute(position); // process morph attributes if present\n\n\t\t\t\tif (morphAttributesPosition) {\n\t\t\t\t\tfor (var i = 0, il = morphAttributesPosition.length; i < il; i++) {\n\t\t\t\t\t\tvar morphAttribute = morphAttributesPosition[i];\n\n\t\t\t\t\t\t_box$2.setFromBufferAttribute(morphAttribute);\n\n\t\t\t\t\t\tif (this.morphTargetsRelative) {\n\t\t\t\t\t\t\t_vector$4.addVectors(this.boundingBox.min, _box$2.min);\n\n\t\t\t\t\t\t\tthis.boundingBox.expandByPoint(_vector$4);\n\n\t\t\t\t\t\t\t_vector$4.addVectors(this.boundingBox.max, _box$2.max);\n\n\t\t\t\t\t\t\tthis.boundingBox.expandByPoint(_vector$4);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.boundingBox.expandByPoint(_box$2.min);\n\t\t\t\t\t\t\tthis.boundingBox.expandByPoint(_box$2.max);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.boundingBox.makeEmpty();\n\t\t\t}\n\n\t\t\tif (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) {\n\t\t\t\tconsole.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The \"position\" attribute is likely to have NaN values.', this);\n\t\t\t}\n\t\t},\n\t\tcomputeBoundingSphere: function computeBoundingSphere() {\n\t\t\tif (this.boundingSphere === null) {\n\t\t\t\tthis.boundingSphere = new Sphere();\n\t\t\t}\n\n\t\t\tvar position = this.attributes.position;\n\t\t\tvar morphAttributesPosition = this.morphAttributes.position;\n\n\t\t\tif (position && position.isGLBufferAttribute) {\n\t\t\t\tconsole.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set \"mesh.frustumCulled\" to \"false\".', this);\n\t\t\t\tthis.boundingSphere.set(new Vector3(), Infinity);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (position) {\n\t\t\t\t// first, find the center of the bounding sphere\n\t\t\t\tvar center = this.boundingSphere.center;\n\n\t\t\t\t_box$2.setFromBufferAttribute(position); // process morph attributes if present\n\n\n\t\t\t\tif (morphAttributesPosition) {\n\t\t\t\t\tfor (var i = 0, il = morphAttributesPosition.length; i < il;
1 i++) {\n\t\t\t\t\t\tvar morphAttribute = morphAttributesPosition[i];\n\n\t\t\t\t\t\t_boxMorphTargets.setFromBufferAttribute(morphAttribute);\n\n\t\t\t\t\t\tif (this.morphTargetsRelative) {\n\t\t\t\t\t\t\t_vector$4.addVectors(_box$2.min, _boxMorphTargets.min);\n\n\t\t\t\t\t\t\t_box$2.expandByPoint(_vector$4);\n\n\t\t\t\t\t\t\t_vector$4.addVectors(_box$2.max, _boxMorphTargets.max);\n\n\t\t\t\t\t\t\t_box$2.expandByPoint(_vector$4);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t_box$2.expandByPoint(_boxMorphTargets.min);\n\n\t\t\t\t\t\t\t_box$2.expandByPoint(_boxMorphTargets.max);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t_box$2.getCenter(center); // second, try to find a boundingSphere with a radius smaller than the\n\t\t\t\t// boundingSphere of the boundingBox: sqrt(3) smaller in the best case\n\n\n\t\t\t\tvar maxRadiusSq = 0;\n\n\t\t\t\tfor (var _i = 0, _il = position.count; _i < _il; _i++) {\n\t\t\t\t\t_vector$4.fromBufferAttribute(position, _i);\n\n\t\t\t\t\tmaxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector$4));\n\t\t\t\t} // process morph attributes if present\n\n\n\t\t\t\tif (morphAttributesPosition) {\n\t\t\t\t\tfor (var _i2 = 0, _il2 = morphAttributesPosition.length; _i2 < _il2; _i2++) {\n\t\t\t\t\t\tvar _morphAttribute = morphAttributesPosition[_i2];\n\t\t\t\t\t\tvar morphTargetsRelative = this.morphTargetsRelative;\n\n\t\t\t\t\t\tfor (var j = 0, jl = _morphAttribute.count; j < jl; j++) {\n\t\t\t\t\t\t\t_vector$4.fromBufferAttribute(_morphAttribute, j);\n\n\t\t\t\t\t\t\tif (morphTargetsRelative) {\n\t\t\t\t\t\t\t\t_offset.fromBufferAttribute(position, j);\n\n\t\t\t\t\t\t\t\t_vector$4.add(_offset);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tmaxRadiusSq = Math.max(maxRadiusSq, center.distanceToSquared(_vector$4));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.boundingSphere.radius = Math.sqrt(maxRadiusSq);\n\n\t\t\t\tif (isNaN(this.boundingSphere.radius)) {\n\t\t\t\t\tconsole.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The \"position\" attribute is likely to have NaN values.', this);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tcomputeFaceNormals: function computeFaceNormals() {// backwards compatibility\n\t\t},\n\t\tcomputeVertexNormals: function computeVertexNormals() {\n\t\t\tvar index = this.index;\n\t\t\tvar positionAttribute = this.getAttribute('position');\n\n\t\t\tif (positionAttribute !== undefined) {\n\t\t\t\tvar normalAttribute = this.getAttribute('normal');\n\n\t\t\t\tif (normalAttribute === undefined) {\n\t\t\t\t\tnormalAttribute = new BufferAttribute(new Float32Array(positionAttribute.count * 3), 3);\n\t\t\t\t\tthis.setAttribute('normal', normalAttribute);\n\t\t\t\t} else {\n\t\t\t\t\t// reset existing normals to zero\n\t\t\t\t\tfor (var i = 0, il = normalAttribute.count; i < il; i++) {\n\t\t\t\t\t\tnormalAttribute.setXYZ(i, 0, 0, 0);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvar pA = new Vector3(),\n\t\t\t\t\t\tpB = new Vector3(),\n\t\t\t\t\t\tpC = new Vector3();\n\t\t\t\tvar nA = new Vector3(),\n\t\t\t\t\t\tnB = new Vector3(),\n\t\t\t\t\t\tnC = new Vector3();\n\t\t\t\tvar cb = new Vector3(),\n\t\t\t\t\t\tab = new Vector3(); // indexed elements\n\n\t\t\t\tif (index) {\n\t\t\t\t\tfor (var _i3 = 0, _il3 = index.count; _i3 < _il3; _i3 += 3) {\n\t\t\t\t\t\tvar vA = index.getX(_i3 + 0);\n\t\t\t\t\t\tvar vB = index.getX(_i3 + 1);\n\t\t\t\t\t\tvar vC = index.getX(_i3 + 2);\n\t\t\t\t\t\tpA.fromBufferAttribute(positionAttribute, vA);\n\t\t\t\t\t\tpB.fromBufferAttribute(positionAttribute, vB);\n\t\t\t\t\t\tpC.fromBufferAttribute(positionAttribute, vC);\n\t\t\t\t\t\tcb.subVectors(pC, pB);\n\t\t\t\t\t\tab.subVectors(pA, pB);\n\t\t\t\t\t\tcb.cross(ab);\n\t\t\t\t\t\tnA.fromBufferAttribute(normalAttribute, vA);\n\t\t\t\t\t\tnB.fromBufferAttribute(normalAttribute, vB);\n\t\t\t\t\t\tnC.fromBufferAttribute(normalAttribute, vC);\n\t\t\t\t\t\tnA.add(cb);\n\t\t\t\t\t\tnB.add(cb);\n\t\t\t\t\t\tnC.add(cb);\n\t\t\t\t\t\tnormalAttribute.setXYZ(vA, nA.x, nA.y, nA.z);\n\t\t\t\t\t\tnormalAttribute.setXYZ(vB, nB.x, nB.y, nB.z);\n\t\t\t\t\t\tnormalAttribute.setXYZ(vC, nC.x, nC.y, nC.z);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// non-indexed elements (unconnected triangle soup)\n\t\t\t\t\tfor (var _i4 = 0, _il4 = positionAttribute.count; _i4 < _il4; _i4 += 3) {\n\t\t\t\t\t\tpA.fromBufferAttribute(positionAttribute, _i4 + 0);\n\t\t\t\t\t\tpB.fromBufferAttribute(positionAttribute, _i4 + 1);\n\t\t\t\t\t\tpC.fromBufferAttribute(positionAttribute, _i4 + 2);\n\t\t\t\t\t\tcb.subVectors(pC, pB);\n\t\t\t\t\t\tab.subVectors(pA, pB);\n\t\t\t\t\t\tcb.cross(ab);\n\t\t\t\t\t\tnormalAttribute.setXYZ(_i4 + 0, cb.x, cb.y, cb.z);\n\t\t\t\t\t\tnormalAttribute.setXYZ(_i4 + 1, cb.x, cb.y, cb.z);\n\t\t\t\t\t\tnormalAttribute.setXYZ(_i4 + 2, cb.x, cb.y, cb.z);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.normalizeNormals();\n\t\t\t\tnormalAttribute.needsUpdate = true;\n\t\t\t}\n\t\t},\n\t\tmerge: function merge(geometry, offset) {\n\t\t\tif (!(geometry && geometry.isBufferGeometry)) {\n\t\t\t\tconsole.error('THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.', geometry);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (offset === undefined) {\n\t\t\t\toffset = 0;\n\t\t\t\tconsole.warn('THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. ' + 'Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge.');\n\t\t\t}\n\n\t\t\tvar attributes = this.attributes;\n\n\t\t\tfor (var key in attributes) {\n\t\t\t\tif (geometry.attributes[key] === undefined) continue;\n\t\t\t\tvar attribute1 = attributes[key];\n\t\t\t\tvar attributeArray1 = attribute1.array;\n\t\t\t\tvar attribute2 = geometry.attributes[key];\n\t\t\t\tvar attributeArray2 = attribute2.array;\n\t\t\t\tvar attributeOffset = attribute2.itemSize * offset;\n\t\t\t\tvar length = Math.min(attributeArray2.length, attributeArray1.length - attributeOffset);\n\n\t\t\t\tfor (var i = 0, j = attributeOffset; i < length;
1 i++, j++) {\n\t\t\t\t\tattributeArray1[j] = attributeArray2[i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tnormalizeNormals: function normalizeNormals() {\n\t\t\tvar normals = this.attributes.normal;\n\n\t\t\tfor (var i = 0, il = normals.count; i < il; i++) {\n\t\t\t\t_vector$4.fromBufferAttribute(normals, i);\n\n\t\t\t\t_vector$4.normalize();\n\n\t\t\t\tnormals.setXYZ(i, _vector$4.x, _vector$4.y, _vector$4.z);\n\t\t\t}\n\t\t},\n\t\ttoNonIndexed: function toNonIndexed() {\n\t\t\tfunction convertBufferAttribute(attribute, indices) {\n\t\t\t\tvar array = attribute.array;\n\t\t\t\tvar itemSize = attribute.itemSize;\n\t\t\t\tvar normalized = attribute.normalized;\n\t\t\t\tvar array2 = new array.constructor(indices.length * itemSize);\n\t\t\t\tvar index = 0,\n\t\t\t\t\t\tindex2 = 0;\n\n\t\t\t\tfor (var i = 0, l = indices.length; i < l; i++) {\n\t\t\t\t\tindex = indices[i] * itemSize;\n\n\t\t\t\t\tfor (var j = 0; j < itemSize; j++) {\n\t\t\t\t\t\tarray2[index2++] = array[index++];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new BufferAttribute(array2, itemSize, normalized);\n\t\t\t} //\n\n\n\t\t\tif (this.index === null) {\n\t\t\t\tconsole.warn('THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed.');\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tvar geometry2 = new BufferGeometry();\n\t\t\tvar indices = this.index.array;\n\t\t\tvar attributes = this.attributes; // attributes\n\n\t\t\tfor (var name in attributes) {\n\t\t\t\tvar attribute = attributes[name];\n\t\t\t\tvar newAttribute = convertBufferAttribute(attribute, indices);\n\t\t\t\tgeometry2.setAttribute(name, newAttribute);\n\t\t\t} // morph attributes\n\n\n\t\t\tvar morphAttributes = this.morphAttributes;\n\n\t\t\tfor (var _name in morphAttributes) {\n\t\t\t\tvar morphArray = [];\n\t\t\t\tvar morphAttribute = morphAttributes[_name]; // morphAttribute: array of Float32BufferAttributes\n\n\t\t\t\tfor (var i = 0, il = morphAttribute.length; i < il; i++) {\n\t\t\t\t\tvar _attribute5 = morphAttribute[i];\n\n\t\t\t\t\tvar _newAttribute = convertBufferAttribute(_attribute5, indices);\n\n\t\t\t\t\tmorphArray.push(_newAttribute);\n\t\t\t\t}\n\n\t\t\t\tgeometry2.morphAttributes[_name] = morphArray;\n\t\t\t}\n\n\t\t\tgeometry2.morphTargetsRelative = this.morphTargetsRelative; // groups\n\n\t\t\tvar groups = this.groups;\n\n\t\t\tfor (var _i5 = 0, l = groups.length; _i5 < l; _i5++) {\n\t\t\t\tvar group = groups[_i5];\n\t\t\t\tgeometry2.addGroup(group.start, group.count, group.materialIndex);\n\t\t\t}\n\n\t\t\treturn geometry2;\n\t\t},\n\t\ttoJSON: function toJSON() {\n\t\t\tvar data = {\n\t\t\t\tmetadata: {\n\t\t\t\t\tversion: 4.5,\n\t\t\t\t\ttype: 'BufferGeometry',\n\t\t\t\t\tgenerator: 'BufferGeometry.toJSON'\n\t\t\t\t}\n\t\t\t}; // standard BufferGeometry serialization\n\n\t\t\tdata.uuid = this.uuid;\n\t\t\tdata.type = this.type;\n\t\t\tif (this.name !== '') data.name = this.name;\n\t\t\tif (Object.keys(this.userData).length > 0) data.userData = this.userData;\n\n\t\t\tif (this.parameters !== undefined) {\n\t\t\t\tvar parameters = this.parameters;\n\n\t\t\t\tfor (var key in parameters) {\n\t\t\t\t\tif (parameters[key] !== undefined) data[key] = parameters[key];\n\t\t\t\t}\n\n\t\t\t\treturn data;\n\t\t\t}\n\n\t\t\tdata.data = {\n\t\t\t\tattributes: {}\n\t\t\t};\n\t\t\tvar index = this.index;\n\n\t\t\tif (index !== null) {\n\t\t\t\tdata.data.index = {\n\t\t\t\t\ttype: index.array.constructor.name,\n\t\t\t\t\tarray: Array.prototype.slice.call(index.array)\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tvar attributes = this.attributes;\n\n\t\t\tfor (var _key in attributes) {\n\t\t\t\tvar attribute = attributes[_key];\n\t\t\t\tvar attributeData = attribute.toJSON(data.data);\n\t\t\t\tif (attribute.name !== '') attributeData.name = attribute.name;\n\t\t\t\tdata.data.attributes[_key] = attributeData;\n\t\t\t}\n\n\t\t\tvar morphAttributes = {};\n\t\t\tvar hasMorphAttributes = false;\n\n\t\t\tfor (var _key2 in this.morphAttributes) {\n\t\t\t\tvar attributeArray = this.morphAttributes[_key2];\n\t\t\t\tvar array = [];\n\n\t\t\t\tfor (var i = 0, il = attributeArray.length; i < il;
1 i++) {\n\t\t\t\t\tvar _attribute6 = attributeArray[i];\n\n\t\t\t\t\tvar _attributeData = _attribute6.toJSON(data.data);\n\n\t\t\t\t\tif (_attribute6.name !== '') _attributeData.name = _attribute6.name;\n\t\t\t\t\tarray.push(_attributeData);\n\t\t\t\t}\n\n\t\t\t\tif (array.length > 0) {\n\t\t\t\t\tmorphAttributes[_key2] = array;\n\t\t\t\t\thasMorphAttributes = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (hasMorphAttributes) {\n\t\t\t\tdata.data.morphAttributes = morphAttributes;\n\t\t\t\tdata.data.morphTargetsRelative = this.morphTargetsRelative;\n\t\t\t}\n\n\t\t\tvar groups = this.groups;\n\n\t\t\tif (groups.length > 0) {\n\t\t\t\tdata.data.groups = JSON.parse(JSON.stringify(groups));\n\t\t\t}\n\n\t\t\tvar boundingSphere = this.boundingSphere;\n\n\t\t\tif (boundingSphere !== null) {\n\t\t\t\tdata.data.boundingSphere = {\n\t\t\t\t\tcenter: boundingSphere.center.toArray(),\n\t\t\t\t\tradius: boundingSphere.radius\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn data;\n\t\t},\n\t\tclone: function clone() {\n\t\t\t/*\n\t\t\t // Handle primitives\n\t\t\t\t const parameters = this.parameters;\n\t\t\t\t if ( parameters !== undefined ) {\n\t\t\t\t const values = [];\n\t\t\t\t for ( const key in parameters ) {\n\t\t\t\t values.push( parameters[ key ] );\n\t\t\t\t }\n\t\t\t\t const geometry = Object.create( this.constructor.prototype );\n\t\t\t this.constructor.apply( geometry, values );\n\t\t\t return geometry;\n\t\t\t\t }\n\t\t\t\t return new this.constructor().copy( this );\n\t\t\t */\n\t\t\treturn new BufferGeometry().copy(this);\n\t\t},\n\t\tcopy: function copy(source) {\n\t\t\t// reset\n\t\t\tthis.index = null;\n\t\t\tthis.attributes = {};\n\t\t\tthis.morphAttributes = {};\n\t\t\tthis.groups = [];\n\t\t\tthis.boundingBox = null;\n\t\t\tthis.boundingSphere = null; // used for storing cloned, shared data\n\n\t\t\tvar data = {}; // name\n\n\t\t\tthis.name = source.name; // index\n\n\t\t\tvar index = source.index;\n\n\t\t\tif (index !== null) {\n\t\t\t\tthis.setIndex(index.clone(data));\n\t\t\t} // attributes\n\n\n\t\t\tvar attributes = source.attributes;\n\n\t\t\tfor (var name in attributes) {\n\t\t\t\tvar attribute = attributes[name];\n\t\t\t\tthis.setAttribute(name, attribute.clone(data));\n\t\t\t} // morph attributes\n\n\n\t\t\tvar morphAttributes = source.morphAttributes;\n\n\t\t\tfor (var _name2 in morphAttributes) {\n\t\t\t\tvar array = [];\n\t\t\t\tvar morphAttribute = morphAttributes[_name2]; // morphAttribute: array of Float32BufferAttributes\n\n\t\t\t\tfor (var i = 0, l = morphAttribute.length; i < l; i++) {\n\t\t\t\t\tarray.push(morphAttribute[i].clone(data));\n\t\t\t\t}\n\n\t\t\t\tthis.morphAttributes[_name2] = array;\n\t\t\t}\n\n\t\t\tthis.morphTargetsRelative = source.morphTargetsRelative; // groups\n\n\t\t\tvar groups = source.groups;\n\n\t\t\tfor (var _i6 = 0, _l = groups.length; _i6 < _l; _i6++) {\n\t\t\t\tvar group = groups[_i6];\n\t\t\t\tthis.addGroup(group.start, group.count, group.materialIndex);\n\t\t\t} // bounding box\n\n\n\t\t\tvar boundingBox = source.boundingBox;\n\n\t\t\tif (boundingBox !== null) {\n\t\t\t\tthis.boundingBox = boundingBox.clone();\n\t\t\t} // bounding sphere\n\n\n\t\t\tvar boundingSphere = source.boundingSphere;\n\n\t\t\tif (boundingSphere !== null) {\n\t\t\t\tthis.boundingSphere = boundingSphere.clone();\n\t\t\t} // draw range\n\n\n\t\t\tthis.drawRange.start = source.drawRange.start;\n\t\t\tthis.drawRange.count = source.drawRange.count; // user data\n\n\t\t\tthis.userData = source.userData;\n\t\t\treturn this;\n\t\t},\n\t\tdispose: function dispose() {\n\t\t\tthis.dispatchEvent({\n\t\t\t\ttype: 'dispose'\n\t\t\t});\n\t\t}\n\t});\n\n\tvar _inverseMatrix = new Matrix4();\n\n\tvar _ray = new Ray();\n\n\tvar _sphere = new Sphere();\n\n\tvar _vA = new Vector3();\n\n\tvar _vB = new Vector3();\n\n\tvar _vC = new Vector3();\n\n\tvar _tempA = new Vector3();\n\n\tvar _tempB = new Vector3();\n\n\tvar _tempC = new Vector3();\n\n\tvar _morphA = new Vector3();\n\n\tvar _morphB = new Vector3();\n\n\tvar _morphC = new Vector3();\n\n\tvar _uvA = new Vector2();\n\n\tvar _uvB = new Vector2();\n\n\tvar _uvC = new Vector2();\n\n\tvar _intersectionPoint = new Vector3();\n\n\tvar _intersectionPointWorld = new Vector3();\n\n\tfunction Mesh(geometry, material) {\n\t\tif (geometry === void 0) {\n\t\t\tgeometry = new BufferGeometry();\n\t\t}\n\n\t\tif (material === void 0) {\n\t\t\tmaterial = new MeshBasicMaterial();\n\t\t}\n\n\t\tObject3D.call(this);\n\t\tthis.type = 'Mesh';\n\t\tthis.geometry = geometry;\n\t\tthis.material = material;\n\t\tthis.updateMorphTargets();\n\t}\n\n\tMesh.prototype = Object.assign(Object.create(Object3D.prototype), {\n\t\tconstructor: Mesh,\n\t\tisMesh: true,\n\t\tcopy: function copy(source) {\n\t\t\tObject3D.prototype.copy.call(this, source);\n\n\t\t\tif (source.morphTargetInfluences !== undefined) {\n\t\t\t\tthis.morphTargetInfluences = source.morphTargetInfluences.slice();\n\t\t\t}\n\n\t\t\tif (source.morphTargetDictionary !== undefined) {\n\t\t\t\tthis.morphTargetDictionary = Object.assign({}, source.morphTargetDictionary);\n\t\t\t}\n\n\t\t\tthis.material = source.material;\n\t\t\tthis.geometry = source.geometry;\n\t\t\treturn this;\n\t\t},\n\t\tupdateMorphTargets: function updateMorphTargets() {\n\t\t\tvar geometry = this.geometry;\n\n\t\t\tif (geometry.isBufferGeometry) {\n\t\t\t\tvar morphAttributes = geometry.morphAttributes;\n\t\t\t\tvar keys = Object.keys(morphAttributes);\n\n\t\t\t\tif (keys.length > 0) {\n\t\t\t\t\tvar morphAttribute = morphAttributes[keys[0]];\n\n\t\t\t\t\tif (morphAttribute !== undefined) {\n\t\t\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\t\t\tfor (var m = 0, ml = morphAttribute.length; m < ml; m++) {\n\t\t\t\t\t\t\tvar name = morphAttribute[m].name || String(m);\n\t\t\t\t\t\t\tthis.morphTargetInfluences.push(0);\n\t\t\t\t\t\t\tthis.morphTargetDictionary[name] = m;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tvar morphTargets = geometry.morphTargets;\n\n\t\t\t\tif (morphTargets !== undefined && morphTargets.length > 0) {\n\t\t\t\t\tconsole.error('THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.');\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\traycast: function raycast(raycaster, intersects) {\n\t\t\tvar geometry = this.geometry;\n\t\t\tvar material = this.material;\n\t\t\tvar matrixWorld = this.matrixWorld;\n\t\t\tif (material === undefined) return; // Checking boundingSphere distance to ray\n\n\t\t\tif (geometry.boundingSphere === null) geometry.computeBoundingSphere();\n\n\t\t\t_sphere.copy(geometry.boundingSphere);\n\n\t\t\t_sphere.applyMatrix4(matrixWorld);\n\n\t\t\tif (raycaster.ray.intersectsSphere(_sphere) === false) return; //\n\n\t\t\t_inverseMatrix.copy(matrixWorld).invert();\n\n\t\t\t_ray.copy(raycaster.ray).applyMatrix4(_inverseMatrix); // Check boundingBox before continuing\n\n\n\t\t\tif (geometry.boundingBox !== null) {\n\t\t\t\tif (_ray.intersectsBox(geometry.boundingBox) === false) return;\n\t\t\t}\n\n\t\t\tvar intersection;\n\n\t\t\tif (geometry.isBufferGeometry) {\n\t\t\t\tvar index = geometry.index;\n\t\t\t\tvar position = geometry.attributes.position;\n\t\t\t\tvar morphPosition = geometry.morphAttributes.position;\n\t\t\t\tvar morphTargetsRelative = geometry.morphTargetsRelative;\n\t\t\t\tvar uv = geometry.attributes.uv;\n\t\t\t\tvar uv2 = geometry.attributes.uv2;\n\t\t\t\tvar groups = geometry.groups;\n\t\t\t\tvar drawRange = geometry.drawRange;\n\n\t\t\t\tif (index !== null) {\n\t\t\t\t\t// indexed buffer geometry\n\t\t\t\t\tif (Array.isArray(material)) {\n\t\t\t\t\t\tfor (var i = 0, il = groups.length; i < il;
1 i++) {\n\t\t\t\t\t\t\tvar group = groups[i];\n\t\t\t\t\t\t\tvar groupMaterial = material[group.materialIndex];\n\t\t\t\t\t\t\tvar start = Math.max(group.start, drawRange.start);\n\t\t\t\t\t\t\tvar end = Math.min(group.start + group.count, drawRange.start + drawRange.count);\n\n\t\t\t\t\t\t\tfor (var j = start, jl = end; j < jl; j += 3) {\n\t\t\t\t\t\t\t\tvar a = index.getX(j);\n\t\t\t\t\t\t\t\tvar b = index.getX(j + 1);\n\t\t\t\t\t\t\t\tvar c = index.getX(j + 2);\n\t\t\t\t\t\t\t\tintersection = checkBufferGeometryIntersection(this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c);\n\n\t\t\t\t\t\t\t\tif (intersection) {\n\t\t\t\t\t\t\t\t\tintersection.faceIndex = Math.floor(j / 3); // triangle number in indexed buffer semantics\n\n\t\t\t\t\t\t\t\t\tintersection.face.materialIndex = group.materialIndex;\n\t\t\t\t\t\t\t\t\tintersects.push(intersection);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvar _start = Math.max(0, drawRange.start);\n\n\t\t\t\t\t\tvar _end = Math.min(index.count, drawRange.start + drawRange.count);\n\n\t\t\t\t\t\tfor (var _i = _start, _il = _end; _i < _il; _i += 3) {\n\t\t\t\t\t\t\tvar _a = index.getX(_i);\n\n\t\t\t\t\t\t\tvar _b = index.getX(_i + 1);\n\n\t\t\t\t\t\t\tvar _c = index.getX(_i + 2);\n\n\t\t\t\t\t\t\tintersection = checkBufferGeometryIntersection(this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, _a, _b, _c);\n\n\t\t\t\t\t\t\tif (intersection) {\n\t\t\t\t\t\t\t\tintersection.faceIndex = Math.floor(_i / 3); // triangle number in indexed buffer semantics\n\n\t\t\t\t\t\t\t\tintersects.push(intersection);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (position !== undefined) {\n\t\t\t\t\t// non-indexed buffer geometry\n\t\t\t\t\tif (Array.isArray(material)) {\n\t\t\t\t\t\tfor (var _i2 = 0, _il2 = groups.length; _i2 < _il2; _i2++) {\n\t\t\t\t\t\t\tvar _group = groups[_i2];\n\t\t\t\t\t\t\tvar _groupMaterial = material[_group.materialIndex];\n\n\t\t\t\t\t\t\tvar _start2 = Math.max(_group.start, drawRange.start);\n\n\t\t\t\t\t\t\tvar _end2 = Math.min(_group.start + _group.count, drawRange.start + drawRange.count);\n\n\t\t\t\t\t\t\tfor (var _j = _start2, _jl = _end2; _j < _jl; _j += 3) {\n\t\t\t\t\t\t\t\tvar _a2 = _j;\n\n\t\t\t\t\t\t\t\tvar _b2 = _j + 1;\n\n\t\t\t\t\t\t\t\tvar _c2 = _j + 2;\n\n\t\t\t\t\t\t\t\tintersection = checkBufferGeometryIntersection(this, _groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, _a2, _b2, _c2);\n\n\t\t\t\t\t\t\t\tif (intersection) {\n\t\t\t\t\t\t\t\t\tintersection.faceIndex = Math.floor(_j / 3); // triangle number in non-indexed buffer semantics\n\n\t\t\t\t\t\t\t\t\tintersection.face.materialIndex = _group.materialIndex;\n\t\t\t\t\t\t\t\t\tintersects.push(intersection);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvar _start3 = Math.max(0, drawRange.start);\n\n\t\t\t\t\t\tvar _end3 = Math.min(position.count, drawRange.start + drawRange.count);\n\n\t\t\t\t\t\tfor (var _i3 = _start3, _il3 = _end3; _i3 < _il3; _i3 += 3) {\n\t\t\t\t\t\t\tvar _a3 = _i3;\n\n\t\t\t\t\t\t\tvar _b3 = _i3 + 1;\n\n\t\t\t\t\t\t\tvar _c3 = _i3 + 2;\n\n\t\t\t\t\t\t\tintersection = checkBufferGeometryIntersection(this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, _a3, _b3, _c3);\n\n\t\t\t\t\t\t\tif (intersection) {\n\t\t\t\t\t\t\t\tintersection.faceIndex = Math.floor(_i3 / 3); // triangle number in non-indexed buffer semantics\n\n\t\t\t\t\t\t\t\tintersects.push(intersection);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (geometry.isGeometry) {\n\t\t\t\tvar isMultiMaterial = Array.isArray(material);\n\t\t\t\tvar vertices = geometry.vertices;\n\t\t\t\tvar faces = geometry.faces;\n\t\t\t\tvar uvs;\n\t\t\t\tvar faceVertexUvs = geometry.faceVertexUvs[0];\n\t\t\t\tif (faceVertexUvs.length > 0) uvs = faceVertexUvs;\n\n\t\t\t\tfor (var f = 0, fl = faces.length; f < fl; f++) {\n\t\t\t\t\tvar face = faces[f];\n\t\t\t\t\tvar faceMaterial = isMultiMaterial ? material[face.materialIndex] : material;\n\t\t\t\t\tif (faceMaterial === undefined) continue;\n\t\t\t\t\tvar fvA = vertices[face.a];\n\t\t\t\t\tvar fvB = vertices[face.b];\n\t\t\t\t\tvar fvC = vertices[face.c];\n\t\t\t\t\tintersection = checkIntersection(this, faceMaterial, raycaster, _ray, fvA, fvB, fvC, _intersectionPoint);\n\n\t\t\t\t\tif (intersection) {\n\t\t\t\t\t\tif (uvs && uvs[f]) {\n\t\t\t\t\t\t\tvar uvs_f = uvs[f];\n\n\t\t\t\t\t\t\t_uvA.copy(uvs_f[0]);\n\n\t\t\t\t\t\t\t_uvB.copy(uvs_f[1]);\n\n\t\t\t\t\t\t\t_uvC.copy(uvs_f[2]);\n\n\t\t\t\t\t\t\tintersection.uv = Triangle.getUV(_intersectionPoint, fvA, fvB, fvC, _uvA, _uvB, _uvC, new Vector2());\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tintersection.face = face;\n\t\t\t\t\t\tintersection.faceIndex = f;\n\t\t\t\t\t\tintersects.push(intersection);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\tfunction checkIntersection(object, material, raycaster, ray, pA, pB, pC, point) {\n\t\tvar intersect;\n\n\t\tif (material.side === BackSide) {\n\t\t\tintersect = ray.intersectTriangle(pC, pB, pA, true, point);\n\t\t} else {\n\t\t\tintersect = ray.intersectTriangle(pA, pB, pC, material.side !== DoubleSide, point);\n\t\t}\n\n\t\tif (intersect === null) return null;\n\n\t\t_intersectionPointWorld.copy(point);\n\n\t\t_intersectionPointWorld.applyMatrix4(object.matrixWorld);\n\n\t\tvar distance = raycaster.ray.origin.distanceTo(_intersectionPointWorld);\n\t\tif (distance < raycaster.near || distance > raycaster.far) return null;\n\t\treturn {\n\t\t\tdistance: distance,\n\t\t\tpoint: _intersectionPointWorld.clone(),\n\t\t\tobject: object\n\t\t};\n\t}\n\n\tfunction checkBufferGeometryIntersection(object, material, raycaster, ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c) {\n\t\t_vA.fromBufferAttribute(position, a);\n\n\t\t_vB.fromBufferAttribute(position, b);\n\n\t\t_vC.fromBufferAttribute(position, c);\n\n\t\tvar morphInfluences = object.morphTargetInfluences;\n\n\t\tif (material.morphTargets && morphPosition && morphInfluences) {\n\t\t\t_morphA.set(0, 0, 0);\n\n\t\t\t_morphB.set(0, 0, 0);\n\n\t\t\t_morphC.set(0, 0, 0);\n\n\t\t\tfor (var i = 0, il = morphPosition.length; i < il;
1 i++) {\n\t\t\t\tvar influence = morphInfluences[i];\n\t\t\t\tvar morphAttribute = morphPosition[i];\n\t\t\t\tif (influence === 0) continue;\n\n\t\t\t\t_tempA.fromBufferAttribute(morphAttribute, a);\n\n\t\t\t\t_tempB.fromBufferAttribute(morphAttribute, b);\n\n\t\t\t\t_tempC.fromBufferAttribute(morphAttribute, c);\n\n\t\t\t\tif (morphTargetsRelative) {\n\t\t\t\t\t_morphA.addScaledVector(_tempA, influence);\n\n\t\t\t\t\t_morphB.addScaledVector(_tempB, influence);\n\n\t\t\t\t\t_morphC.addScaledVector(_tempC, influence);\n\t\t\t\t} else {\n\t\t\t\t\t_morphA.addScaledVector(_tempA.sub(_vA), influence);\n\n\t\t\t\t\t_morphB.addScaledVector(_tempB.sub(_vB), influence);\n\n\t\t\t\t\t_morphC.addScaledVector(_tempC.sub(_vC), influence);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t_vA.add(_morphA);\n\n\t\t\t_vB.add(_morphB);\n\n\t\t\t_vC.add(_morphC);\n\t\t}\n\n\t\tif (object.isSkinnedMesh) {\n\t\t\tobject.boneTransform(a, _vA);\n\t\t\tobject.boneTransform(b, _vB);\n\t\t\tobject.boneTransform(c, _vC);\n\t\t}\n\n\t\tvar intersection = checkIntersection(object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint);\n\n\t\tif (intersection) {\n\t\t\tif (uv) {\n\t\t\t\t_uvA.fromBufferAttribute(uv, a);\n\n\t\t\t\t_uvB.fromBufferAttribute(uv, b);\n\n\t\t\t\t_uvC.fromBufferAttribute(uv, c);\n\n\t\t\t\tintersection.uv = Triangle.getUV(_intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2());\n\t\t\t}\n\n\t\t\tif (uv2) {\n\t\t\t\t_uvA.fromBufferAttribute(uv2, a);\n\n\t\t\t\t_uvB.fromBufferAttribute(uv2, b);\n\n\t\t\t\t_uvC.fromBufferAttribute(uv2, c);\n\n\t\t\t\tintersection.uv2 = Triangle.getUV(_intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2());\n\t\t\t}\n\n\t\t\tvar face = new Face3(a, b, c);\n\t\t\tTriangle.getNormal(_vA, _vB, _vC, face.normal);\n\t\t\tintersection.face = face;\n\t\t}\n\n\t\treturn intersection;\n\t}\n\n\tvar BoxBufferGeometry = /*#__PURE__*/function (_BufferGeometry) {\n\t\t_inheritsLoose(BoxBufferGeometry, _BufferGeometry);\n\n\t\tfunction BoxBufferGeometry(width, height, depth, widthSegments, heightSegments, depthSegments) {\n\t\t\tvar _this;\n\n\t\t\tif (width === void 0) {\n\t\t\t\twidth = 1;\n\t\t\t}\n\n\t\t\tif (height === void 0) {\n\t\t\t\theight = 1;\n\t\t\t}\n\n\t\t\tif (depth === void 0) {\n\t\t\t\tdepth = 1;\n\t\t\t}\n\n\t\t\tif (widthSegments === void 0) {\n\t\t\t\twidthSegments = 1;\n\t\t\t}\n\n\t\t\tif (heightSegments === void 0) {\n\t\t\t\theightSegments = 1;\n\t\t\t}\n\n\t\t\tif (depthSegments === void 0) {\n\t\t\t\tdepthSegments = 1;\n\t\t\t}\n\n\t\t\t_this = _BufferGeometry.call(this) || this;\n\t\t\t_this.type = 'BoxBufferGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\twidth: width,\n\t\t\t\theight: height,\n\t\t\t\tdepth: depth,\n\t\t\t\twidthSegments: widthSegments,\n\t\t\t\theightSegments: heightSegments,\n\t\t\t\tdepthSegments: depthSegments\n\t\t\t};\n\n\t\t\tvar scope = _assertThisInitialized(_this); // segments\n\n\n\t\t\twidthSegments = Math.floor(widthSegments);\n\t\t\theightSegments = Math.floor(heightSegments);\n\t\t\tdepthSegments = Math.floor(depthSegments); // buffers\n\n\t\t\tvar indices = [];\n\t\t\tvar vertices = [];\n\t\t\tvar normals = [];\n\t\t\tvar uvs = []; // helper variables\n\n\t\t\tvar numberOfVertices = 0;\n\t\t\tvar groupStart = 0; // build each side of the box geometry\n\n\t\t\tbuildPlane('z', 'y', 'x', -1, -1, depth, height, width, depthSegments, heightSegments, 0); // px\n\n\t\t\tbuildPlane('z', 'y', 'x', 1, -1, depth, height, -width, depthSegments, heightSegments, 1); // nx\n\n\t\t\tbuildPlane('x', 'z', 'y', 1, 1, width, depth, height, widthSegments, depthSegments, 2); // py\n\n\t\t\tbuildPlane('x', 'z', 'y', 1, -1, width, depth, -height, widthSegments, depthSegments, 3); // ny\n\n\t\t\tbuildPlane('x', 'y', 'z', 1, -1, width, height, depth, widthSegments, heightSegments, 4); // pz\n\n\t\t\tbuildPlane('x', 'y', 'z', -1, -1, width, height, -depth, widthSegments, heightSegments, 5); // nz\n\t\t\t// build geometry\n\n\t\t\t_this.setIndex(indices);\n\n\t\t\t_this.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\n\t\t\t_this.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\n\t\t\t_this.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\n\t\t\tfunction buildPlane(u, v, w, udir, vdir, width, height, depth, gridX, gridY, materialIndex) {\n\t\t\t\tvar segmentWidth = width / gridX;\n\t\t\t\tvar segmentHeight = height / gridY;\n\t\t\t\tvar widthHalf = width / 2;\n\t\t\t\tvar heightHalf = height / 2;\n\t\t\t\tvar depthHalf = depth / 2;\n\t\t\t\tvar gridX1 = gridX + 1;\n\t\t\t\tvar gridY1 = gridY + 1;\n\t\t\t\tvar vertexCounter = 0;\n\t\t\t\tvar groupCount = 0;\n\t\t\t\tvar vector = new Vector3(); // generate vertices, normals and uvs\n\n\t\t\t\tfor (var iy = 0; iy < gridY1; iy++) {\n\t\t\t\t\tvar y = iy * segmentHeight - heightHalf;\n\n\t\t\t\t\tfor (var ix = 0; ix < gridX1; ix++) {\n\t\t\t\t\t\tvar x = ix * segmentWidth - widthHalf; // set values to correct vector component\n\n\t\t\t\t\t\tvector[u] = x * udir;\n\t\t\t\t\t\tvector[v] = y * vdir;\n\t\t\t\t\t\tvector[w] = depthHalf; // now apply vector to vertex buffer\n\n\t\t\t\t\t\tvertices.push(vector.x, vector.y, vector.z); // set values to correct vector component\n\n\t\t\t\t\t\tvector[u] = 0;\n\t\t\t\t\t\tvector[v] = 0;\n\t\t\t\t\t\tvector[w] = depth > 0 ? 1 : -1; // now apply vector to normal buffer\n\n\t\t\t\t\t\tnormals.push(vector.x, vector.y, vector.z); // uvs\n\n\t\t\t\t\t\tuvs.push(ix / gridX);\n\t\t\t\t\t\tuvs.push(1 - iy / gridY); // counters\n\n\t\t\t\t\t\tvertexCounter += 1;\n\t\t\t\t\t}\n\t\t\t\t} // indices\n\t\t\t\t// 1. you need three indices to draw a single face\n\t\t\t\t// 2. a single segment consists of two faces\n\t\t\t\t// 3. so we need to generate six (2*3) indices per segment\n\n\n\t\t\t\tfor (var _iy = 0; _iy < gridY; _iy++) {\n\t\t\t\t\tfor (var _ix = 0; _ix < gridX; _ix++) {\n\t\t\t\t\t\tvar a = numberOfVertices + _ix + gridX1 * _iy;\n\t\t\t\t\t\tvar b = numberOfVertices + _ix + gridX1 * (_iy + 1);\n\t\t\t\t\t\tvar c = numberOfVertices + (_ix + 1) + gridX1 * (_iy + 1);\n\t\t\t\t\t\tvar d = numberOfVertices + (_ix + 1) + gridX1 * _iy; // faces\n\n\t\t\t\t\t\tindices.push(a, b, d);\n\t\t\t\t\t\tindices.push(b, c, d); // increase counter\n\n\t\t\t\t\t\tgroupCount += 6;\n\t\t\t\t\t}\n\t\t\t\t} // add a group to the geometry. this will ensure multi material support\n\n\n\t\t\t\tscope.addGroup(groupStart, groupCount, materialIndex); // calculate new start value for groups\n\n\t\t\t\tgroupStart += groupCount; // update total number of vertices\n\n\t\t\t\tnumberOfVertices += vertexCounter;\n\t\t\t}\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn BoxBufferGeometry;\n\t}(BufferGeometry);\n\n\t/**\n\t * Uniform Utilities\n\t */\n\tfunction cloneUniforms(src) {\n\t\tvar dst = {};\n\n\t\tfor (var u in src) {\n\t\t\tdst[u] = {};\n\n\t\t\tfor (var p in src[u]) {\n\t\t\t\tvar property = src[u][p];\n\n\t\t\t\tif (property && (property.isColor || property.isMatrix3 || property.isMatrix4 || property.isVector2 || property.isVector3 || property.isVector4 || property.isTexture)) {\n\t\t\t\t\tdst[u][p] = property.clone();\n\t\t\t\t} else if (Array.isArray(property)) {\n\t\t\t\t\tdst[u][p] = property.slice();\n\t\t\t\t} else {\n\t\t\t\t\tdst[u][p] = property;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn dst;\n\t}\n\tfunction mergeUniforms(uniforms) {\n\t\tvar merged = {};\n\n\t\tfor (var u = 0; u < uniforms.length; u++) {\n\t\t\tvar tmp = cloneUniforms(uniforms[u]);\n\n\t\t\tfor (var p in tmp) {\n\t\t\t\tmerged[p] = tmp[p];\n\t\t\t}\n\t\t}\n\n\t\treturn merged;\n\t} // Legacy\n\n\tvar UniformsUtils = {\n\t\tclone: cloneUniforms,\n\t\tmerge: mergeUniforms\n\t};\n\n\tvar default_vertex = \"void main() {\\n\\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\\n}\";\n\n\tvar default_fragment = \"void main() {\\n\\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\\n}\";\n\n\t/**\n\t * parameters = {\n\t *\tdefines: { \"label\" : \"value\" },\n\t *\tuniforms: { \"parameter1\": { value: 1.0 }, \"parameter2\": { value2: 2 } },\n\t *\n\t *\tfragmentShader: <string>,\n\t *\tvertexShader: <string>,\n\t *\n\t *\twireframe: <boolean>,\n\t *\twireframeLinewidth: <float>,\n\t *\n\t *\tlights: <bool>,\n\t *\n\t *\tskinning: <bool>,\n\t *\tmorphTargets: <bool>,\n\t *\tmorphNormals: <bool>\n\t * }\n\t */\n\n\tfunction ShaderMaterial(parameters) {\n\t\tMaterial.call(this);\n\t\tthis.type = 'ShaderMaterial';\n\t\tthis.defines = {};\n\t\tthis.uniforms = {};\n\t\tthis.vertexShader = default_vertex;\n\t\tthis.fragmentShader = default_fragment;\n\t\tthis.linewidth = 1;\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.fog = false; // set to use scene fog\n\n\t\tthis.lights = false; // set to use scene lights\n\n\t\tthis.clipping = false; // set to use user-defined clipping planes\n\n\t\tthis.skinning = false; // set to use skinning attribute streams\n\n\t\tthis.morphTargets = false; // set to use morph targets\n\n\t\tthis.morphNormals = false; // set to use morph normals\n\n\t\tthis.extensions = {\n\t\t\tderivatives: false,\n\t\t\t// set to use derivatives\n\t\t\tfragDepth: fal
1se,\n\t\t\t// set to use fragment depth values\n\t\t\tdrawBuffers: false,\n\t\t\t// set to use draw buffers\n\t\t\tshaderTextureLOD: false // set to use shader texture LOD\n\n\t\t}; // When rendered geometry doesn't include these attributes but the material does,\n\t\t// use these default values in WebGL. This avoids errors when buffer data is missing.\n\n\t\tthis.defaultAttributeValues = {\n\t\t\t'color': [1, 1, 1],\n\t\t\t'uv': [0, 0],\n\t\t\t'uv2': [0, 0]\n\t\t};\n\t\tthis.index0AttributeName = undefined;\n\t\tthis.uniformsNeedUpdate = false;\n\t\tthis.glslVersion = null;\n\n\t\tif (parameters !== undefined) {\n\t\t\tif (parameters.attributes !== undefined) {\n\t\t\t\tconsole.error('THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead.');\n\t\t\t}\n\n\t\t\tthis.setValues(parameters);\n\t\t}\n\t}\n\n\tShaderMaterial.prototype = Object.create(Material.prototype);\n\tShaderMaterial.prototype.constructor = ShaderMaterial;\n\tShaderMaterial.prototype.isShaderMaterial = true;\n\n\tShaderMaterial.prototype.copy = function (source) {\n\t\tMaterial.prototype.copy.call(this, source);\n\t\tthis.fragmentShader = source.fragmentShader;\n\t\tthis.vertexShader = source.vertexShader;\n\t\tthis.uniforms = cloneUniforms(source.uniforms);\n\t\tthis.defines = Object.assign({}, source.defines);\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.lights = source.lights;\n\t\tthis.clipping = source.clipping;\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\t\tthis.morphNormals = source.morphNormals;\n\t\tthis.extensions = Object.assign({}, source.extensions);\n\t\tthis.glslVersion = source.glslVersion;\n\t\treturn this;\n\t};\n\n\tShaderMaterial.prototype.toJSON = function (meta) {\n\t\tvar data = Material.prototype.toJSON.call(this, meta);\n\t\tdata.glslVersion = this.glslVersion;\n\t\tdata.uniforms = {};\n\n\t\tfor (var name in this.uniforms) {\n\t\t\tvar uniform = this.uniforms[name];\n\t\t\tvar value = uniform.value;\n\n\t\t\tif (value && value.isTexture) {\n\t\t\t\tdata.uniforms[name] = {\n\t\t\t\t\ttype: 't',\n\t\t\t\t\tvalue: value.toJSON(meta).uuid\n\t\t\t\t};\n\t\t\t} else if (value && value.isColor) {\n\t\t\t\tdata.uniforms[name] = {\n\t\t\t\t\ttype: 'c',\n\t\t\t\t\tvalue: value.getHex()\n\t\t\t\t};\n\t\t\t} else if (value && value.isVector2) {\n\t\t\t\tdata.uniforms[name] = {\n\t\t\t\t\ttype: 'v2',\n\t\t\t\t\tvalue: value.toArray()\n\t\t\t\t};\n\t\t\t} else if (value && value.isVector3) {\n\t\t\t\tdata.uniforms[name] = {\n\t\t\t\t\ttype: 'v3',\n\t\t\t\t\tvalue: value.toArray()\n\t\t\t\t};\n\t\t\t} else if (value && value.isVector4) {\n\t\t\t\tdata.uniforms[name] = {\n\t\t\t\t\ttype: 'v4',\n\t\t\t\t\tvalue: value.toArray()\n\t\t\t\t};\n\t\t\t} else if (value && value.isMatrix3) {\n\t\t\t\tdata.uniforms[name] = {\n\t\t\t\t\ttype: 'm3',\n\t\t\t\t\tvalue: value.toArray()\n\t\t\t\t};\n\t\t\t} else if (value && value.isMatrix4) {\n\t\t\t\tdata.uniforms[name] = {\n\t\t\t\t\ttype: 'm4',\n\t\t\t\t\tvalue: value.toArray()\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tdata.uniforms[name] = {\n\t\t\t\t\tvalue: value\n\t\t\t\t}; // note: the array variants v2v, v3v, v4v, m4v and tv are not supported so far\n\t\t\t}\n\t\t}\n\n\t\tif (Object.keys(this.defines).length > 0) data.defines = this.defines;\n\t\tdata.vertexShader = this.vertexShader;\n\t\tdata.fragmentShader = this.fragmentShader;\n\t\tvar extensions = {};\n\n\t\tfor (var key in this.extensions) {\n\t\t\tif (this.extensions[key] === true) extensions[key] = true;\n\t\t}\n\n\t\tif (Object.keys(extensions).length > 0) data.extensions = extensions;\n\t\treturn data;\n\t};\n\n\tfunction Camera() {\n\t\tObject3D.call(this);\n\t\tthis.type = 'Camera';\n\t\tthis.matrixWorldInverse = new Matrix4();\n\t\tthis.projectionMatrix = new Matrix4();\n\t\tthis.projectionMatrixInverse = new Matrix4();\n\t}\n\n\tCamera.prototype = Object.assign(Object.create(Object3D.prototype), {\n\t\tconstructor: Camera,\n\t\tisCamera: true,\n\t\tcopy: function copy(source, recursive) {\n\t\t\tObject3D.prototype.copy.call(this, source, recursive);\n\t\t\tthis.matrixWorldInverse.copy(source.matrixWorldInverse);\n\t\t\tthis.projectionMatrix.copy(source.projectionMatrix);\n\t\t\tthis.projectionMatrixInverse.copy(source.projectionMatrixInverse);\n\t\t\treturn this;\n\t\t},\n\t\tgetWorldDirection: function getWorldDirection(target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Camera: .getWorldDirection() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\tthis.updateWorldMatrix(true, false);\n\t\t\tvar e = this.matrixWorld.elements;\n\t\t\treturn target.set(-e[8], -e[9], -e[10]).normalize();\n\t\t},\n\t\tupdateMatrixWorld: function updateMatrixWorld(force) {\n\t\t\tObject3D.prototype.updateMatrixWorld.call(this, force);\n\t\t\tthis.matrixWorldInverse.copy(this.matrixWorld).invert();\n\t\t},\n\t\tupdateWorldMatrix: function updateWorldMatrix(updateParents, updateChildren) {\n\t\t\tObject3D.prototype.updateWorldMatrix.call(this, updateParents, updateChildren);\n\t\t\tthis.matrixWorldInverse.copy(this.matrixWorld).invert();\n\t\t},\n\t\tclone: function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t}\n\t});\n\n\tfunction PerspectiveCamera(fov, aspect, near, far) {\n\t\tif (fov === void 0) {\n\t\t\tfov = 50;\n\t\t}\n\n\t\tif (aspect === void 0) {\n\t\t\taspect = 1;\n\t\t}\n\n\t\tif (near === void 0) {\n\t\t\tnear = 0.1;\n\t\t}\n\n\t\tif (far === void 0) {\n\t\t\tfar = 2000;\n\t\t}\n\n\t\tCamera.call(this);\n\t\tthis.type = 'PerspectiveCamera';\n\t\tthis.fov = fov;\n\t\tthis.zoom = 1;\n\t\tthis.near = near;\n\t\tthis.far = far;\n\t\tthis.focus = 10;\n\t\tthis.aspect = aspect;\n\t\tthis.view = null;\n\t\tthis.filmGauge = 35; // width of the film (default in millimeters)\n\n\t\tthis.filmOffset = 0; // horizontal film offset (same unit as gauge)\n\n\t\tthis.updateProjectionMatrix();\n\t}\n\n\tPerspectiveCamera.prototype = Object.assign(Object.create(Camera.prototype), {\n\t\tconstructor: PerspectiveCamera,\n\t\tisPerspectiveCamera: true,\n\t\tcopy: function copy(source, recursive) {\n\t\t\tCamera.prototype.copy.call(this, source, recursive);\n\t\t\tthis.fov = source.fov;\n\t\t\tthis.zoom = source.zoom;\n\t\t\tthis.near = source.near;\n\t\t\tthis.far = source.far;
1\n\t\t\tthis.focus = source.focus;\n\t\t\tthis.aspect = source.aspect;\n\t\t\tthis.view = source.view === null ? null : Object.assign({}, source.view);\n\t\t\tthis.filmGauge = source.filmGauge;\n\t\t\tthis.filmOffset = source.filmOffset;\n\t\t\treturn this;\n\t\t},\n\n\t\t/**\n\t\t * Sets the FOV by focal length in respect to the current .filmGauge.\n\t\t *\n\t\t * The default film gauge is 35, so that the focal length can be specified for\n\t\t * a 35mm (full frame) camera.\n\t\t *\n\t\t * Values for focal length and film gauge must have the same unit.\n\t\t */\n\t\tsetFocalLength: function setFocalLength(focalLength) {\n\t\t\t// see http://www.bobatkins.com/photography/technical/field_of_view.html\n\t\t\tvar vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;\n\t\t\tthis.fov = MathUtils.RAD2DEG * 2 * Math.atan(vExtentSlope);\n\t\t\tthis.updateProjectionMatrix();\n\t\t},\n\n\t\t/**\n\t\t * Calculates the focal length from the current .fov and .filmGauge.\n\t\t */\n\t\tgetFocalLength: function getFocalLength() {\n\t\t\tvar vExtentSlope = Math.tan(MathUtils.DEG2RAD * 0.5 * this.fov);\n\t\t\treturn 0.5 * this.getFilmHeight() / vExtentSlope;\n\t\t},\n\t\tgetEffectiveFOV: function getEffectiveFOV() {\n\t\t\treturn MathUtils.RAD2DEG * 2 * Math.atan(Math.tan(MathUtils.DEG2RAD * 0.5 * this.fov) / this.zoom);\n\t\t},\n\t\tgetFilmWidth: function getFilmWidth() {\n\t\t\t// film not completely covered in portrait format (aspect < 1)\n\t\t\treturn this.filmGauge * Math.min(this.aspect, 1);\n\t\t},\n\t\tgetFilmHeight: function getFilmHeight() {\n\t\t\t// film not completely covered in landscape format (aspect > 1)\n\t\t\treturn this.filmGauge / Math.max(this.aspect, 1);\n\t\t},\n\n\t\t/**\n\t\t * Sets an offset in a larger frustum. This is useful for multi-window or\n\t\t * multi-monitor/multi-machine setups.\n\t\t *\n\t\t * For example, if you have 3x2 monitors and each monitor is 1920x1080 and\n\t\t * the monitors are in grid like this\n\t\t *\n\t\t *\t +---+---+---+\n\t\t *\t | A | B | C |\n\t\t *\t +---+---+---+\n\t\t *\t | D | E | F |\n\t\t *\t +---+---+---+\n\t\t *\n\t\t * then for each monitor you would call it like this\n\t\t *\n\t\t *\t const w = 1920;\n\t\t *\t const h = 1080;\n\t\t *\t const fullWidth = w * 3;\n\t\t *\t const fullHeight = h * 2;\n\t\t *\n\t\t *\t --A--\n\t\t *\t camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );\n\t\t *\t --B--\n\t\t *\t camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );\n\t\t *\t --C--\n\t\t *\t camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );\n\t\t *\t --D--\n\t\t *\t camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );\n\t\t *\t --E--\n\t\t *\t camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );\n\t\t *\t --F--\n\t\t *\t camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );\n\t\t *\n\t\t *\t Note there is no reason monitors have to be the same size or in a grid.\n\t\t */\n\t\tsetViewOffset: function setViewOffset(fullWidth, fullHeight, x, y, width, height) {\n\t\t\tthis.aspect = fullWidth / fullHeight;\n\n\t\t\tif (this.view === null) {\n\t\t\t\tthis.view = {\n\t\t\t\t\tenabled: true,\n\t\t\t\t\tfullWidth: 1,\n\t\t\t\t\tfullHeight: 1,\n\t\t\t\t\toffsetX: 0,\n\t\t\t\t\toffsetY: 0,\n\t\t\t\t\twidth: 1,\n\t\t\t\t\theight: 1\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tthis.view.enabled = true;\n\t\t\tthis.view.fullWidth = fullWidth;\n\t\t\tthis.view.fullHeight = fullHeight;\n\t\t\tthis.view.offsetX = x;\n\t\t\tthis.view.offsetY = y;\n\t\t\tthis.view.width = width;\n\t\t\tthis.view.height = height;\n\t\t\tthis.updateProjectionMatrix();\n\t\t},\n\t\tclearViewOffset: function clearViewOffset() {\n\t\t\tif (this.view !== null) {\n\t\t\t\tthis.view.enabled = false;\n\t\t\t}\n\n\t\t\tthis.updateProjectionMatrix();\n\t\t},\n\t\tupdateProjectionMatrix: function updateProjectionMatrix() {\n\t\t\tvar near = this.near;\n\t\t\tvar top = near * Math.tan(MathUtils.DEG2RAD * 0.5 * this.fov) / this.zoom;\n\t\t\tvar height = 2 * top;\n\t\t\tvar width = this.aspect * height;\n\t\t\tvar left = -0.5 * width;\n\t\t\tvar view = this.view;\n\n\t\t\tif (this.view !== null && this.view.enabled) {\n\t\t\t\tvar fullWidth = view.fullWidth,\n\t\t\t\t\t\tfullHeight = view.fullHeight;\n\t\t\t\tleft += view.offsetX * width / fullWidth;\n\t\t\t\ttop -= view.offsetY * height / fullHeight;\n\t\t\t\twidth *= view.width / fullWidth;\n\t\t\t\theight *= view.height / fullHeight;\n\t\t\t}\n\n\t\t\tvar skew = this.filmOffset;\n\t\t\tif (skew !== 0) left += near * skew / this.getFilmWidth();\n\t\t\tthis.projectionMatrix.makePerspective(left, left + width, top, top - height, near, this.far);\n\t\t\tthis.projectionMatrixInverse.copy(this.projectionMatrix).invert();\n\t\t},\n\t\ttoJSON: function toJSON(meta) {\n\t\t\tvar data = Object3D.prototype.toJSON.call(this, meta);\n\t\t\tdata.object.fov = this.fov;\n\t\t\tdata.object.zoom = this.zoom;\n\t\t\tdata.object.near = this.near;\n\t\t\tdata.object.far = this.far;\n\t\t\tdata.object.focus = this.focus;\n\t\t\tdata.object.aspect = this.aspect;\n\t\t\tif (this.view !== null) data.object.view = Object.assign({}, this.view);\n\t\t\tdata.object.filmGauge = this.filmGauge;\n\t\t\tdata.object.filmOffset = this.filmOffset;\n\t\t\treturn data;\n\t\t}\n\t});\n\n\tvar fov = 90,\n\t\t\taspect = 1;\n\n\tfunction CubeCamera(near, far, renderTarget) {\n\t\tObject3D.call(this);\n\t\tthis.type = 'CubeCamera';
1\n\n\t\tif (renderTarget.isWebGLCubeRenderTarget !== true) {\n\t\t\tconsole.error('THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.');\n\t\t\treturn;\n\t\t}\n\n\t\tthis.renderTarget = renderTarget;\n\t\tvar cameraPX = new PerspectiveCamera(fov, aspect, near, far);\n\t\tcameraPX.layers = this.layers;\n\t\tcameraPX.up.set(0, -1, 0);\n\t\tcameraPX.lookAt(new Vector3(1, 0, 0));\n\t\tthis.add(cameraPX);\n\t\tvar cameraNX = new PerspectiveCamera(fov, aspect, near, far);\n\t\tcameraNX.layers = this.layers;\n\t\tcameraNX.up.set(0, -1, 0);\n\t\tcameraNX.lookAt(new Vector3(-1, 0, 0));\n\t\tthis.add(cameraNX);\n\t\tvar cameraPY = new PerspectiveCamera(fov, aspect, near, far);\n\t\tcameraPY.layers = this.layers;\n\t\tcameraPY.up.set(0, 0, 1);\n\t\tcameraPY.lookAt(new Vector3(0, 1, 0));\n\t\tthis.add(cameraPY);\n\t\tvar cameraNY = new PerspectiveCamera(fov, aspect, near, far);\n\t\tcameraNY.layers = this.layers;\n\t\tcameraNY.up.set(0, 0, -1);\n\t\tcameraNY.lookAt(new Vector3(0, -1, 0));\n\t\tthis.add(cameraNY);\n\t\tvar cameraPZ = new PerspectiveCamera(fov, aspect, near, far);\n\t\tcameraPZ.layers = this.layers;\n\t\tcameraPZ.up.set(0, -1, 0);\n\t\tcameraPZ.lookAt(new Vector3(0, 0, 1));\n\t\tthis.add(cameraPZ);\n\t\tvar cameraNZ = new PerspectiveCamera(fov, aspect, near, far);\n\t\tcameraNZ.layers = this.layers;\n\t\tcameraNZ.up.set(0, -1, 0);\n\t\tcameraNZ.lookAt(new Vector3(0, 0, -1));\n\t\tthis.add(cameraNZ);\n\n\t\tthis.update = function (renderer, scene) {\n\t\t\tif (this.parent === null) this.updateMatrixWorld();\n\t\t\tvar currentXrEnabled = renderer.xr.enabled;\n\t\t\tvar currentRenderTarget = renderer.getRenderTarget();\n\t\t\trenderer.xr.enabled = false;\n\t\t\tvar generateMipmaps = renderTarget.texture.generateMipmaps;\n\t\t\trenderTarget.texture.generateMipmaps = false;\n\t\t\trenderer.setRenderTarget(renderTarget, 0);\n\t\t\trenderer.render(scene, cameraPX);\n\t\t\trenderer.setRenderTarget(renderTarget, 1);\n\t\t\trenderer.render(scene, cameraNX);\n\t\t\trenderer.setRenderTarget(renderTarget, 2);\n\t\t\trenderer.render(scene, cameraPY);\n\t\t\trenderer.setRenderTarget(renderTarget, 3);\n\t\t\trenderer.render(scene, cameraNY);\n\t\t\trenderer.setRenderTarget(renderTarget, 4);\n\t\t\trenderer.render(scene, cameraPZ);\n\t\t\trenderTarget.texture.generateMipmaps = generateMipmaps;\n\t\t\trenderer.setRenderTarget(renderTarget, 5);\n\t\t\trenderer.render(scene, cameraNZ);\n\t\t\trenderer.setRenderTarget(currentRenderTarget);\n\t\t\trenderer.xr.enabled = currentXrEnabled;\n\t\t};\n\t}\n\n\tCubeCamera.prototype = Object.create(Object3D.prototype);\n\tCubeCamera.prototype.constructor = CubeCamera;\n\n\tfunction CubeTexture(images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding) {\n\t\timages = images !== undefined ? images : [];\n\t\tmapping = mapping !== undefined ? mapping : CubeReflectionMapping;\n\t\tformat = format !== undefined ? format : RGBFormat;\n\t\tTexture.call(this, images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);\n\t\tthis.flipY = false; // Why CubeTexture._needsFlipEnvMap is necessary:\n\t\t//\n\t\t// By convention -- likely based on the RenderMan spec from the 1990's -- cube maps are specified by WebGL (and three.js)\n\t\t// in a coordinate system in which positive-x is to the right when looking up the positive-z axis -- in other words,\n\t\t// in a left-handed coordinate system. By continuing this convention, preexisting cube maps continued to render correctly.\n\t\t// three.js uses a right-handed coordinate system. So environment maps used in three.js appear to have px and nx swapped\n\t\t// and the flag _needsFlipEnvMap controls this conversion. The flip is not required (and thus _needsFlipEnvMap is set to false)\n\t\t// when using WebGLCubeRenderTarget.texture as a cube texture.\n\n\t\tthis._needsFlipEnvMap = true;\n\t}\n\n\tCubeTexture.prototype = Object.create(Texture.prototype);\n\tCubeTexture.prototype.constructor = CubeTexture;\n\tCubeTexture.prototype.isCubeTexture = true;\n\tObject.defineProperty(CubeTexture.prototype, 'images', {\n\t\tget: function get() {\n\t\t\treturn this.image;\n\t\t},\n\t\tset: function set(value) {\n\t\t\tthis.image = value;\n\t\t}\n\t});
1\n\n\tfunction WebGLCubeRenderTarget(size, options, dummy) {\n\t\tif (Number.isInteger(options)) {\n\t\t\tconsole.warn('THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )');\n\t\t\toptions = dummy;\n\t\t}\n\n\t\tWebGLRenderTarget.call(this, size, size, options);\n\t\toptions = options || {};\n\t\tthis.texture = new CubeTexture(undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding);\n\t\tthis.texture._needsFlipEnvMap = false;\n\t}\n\n\tWebGLCubeRenderTarget.prototype = Object.create(WebGLRenderTarget.prototype);\n\tWebGLCubeRenderTarget.prototype.constructor = WebGLCubeRenderTarget;\n\tWebGLCubeRenderTarget.prototype.isWebGLCubeRenderTarget = true;\n\n\tWebGLCubeRenderTarget.prototype.fromEquirectangularTexture = function (renderer, texture) {\n\t\tthis.texture.type = texture.type;\n\t\tthis.texture.format = RGBAFormat; // see #18859\n\n\t\tthis.texture.encoding = texture.encoding;\n\t\tthis.texture.generateMipmaps = texture.generateMipmaps;\n\t\tthis.texture.minFilter = texture.minFilter;\n\t\tthis.texture.magFilter = texture.magFilter;\n\t\tvar shader = {\n\t\t\tuniforms: {\n\t\t\t\ttEquirect: {\n\t\t\t\t\tvalue: null\n\t\t\t\t}\n\t\t\t},\n\t\t\tvertexShader:\n\t\t\t/* glsl */\n\t\t\t\"\\n\\n\\t\\t\\tvarying vec3 vWorldDirection;\\n\\n\\t\\t\\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\\n\\n\\t\\t\\t\\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\\n\\n\\t\\t\\t}\\n\\n\\t\\t\\tvoid main() {\\n\\n\\t\\t\\t\\tvWorldDirection = transformDirection( position, modelMatrix );\\n\\n\\t\\t\\t\\t#include <begin_vertex>\\n\\t\\t\\t\\t#include <project_vertex>\\n\\n\\t\\t\\t}\\n\\t\\t\",\n\t\t\tfragmentShader:\n\t\t\t/* glsl */\n\t\t\t\"\\n\\n\\t\\t\\tuniform sampler2D tEquirect;\\n\\n\\t\\t\\tvarying vec3 vWorldDirection;\\n\\n\\t\\t\\t#include <common>\\n\\n\\t\\t\\tvoid main() {\\n\\n\\t\\t\\t\\tvec3 direction = normalize( vWorldDirection );\\n\\n\\t\\t\\t\\tvec2 sampleUV = equirectUv( direction );\\n\\n\\t\\t\\t\\tgl_FragColor = texture2D( tEquirect, sampleUV );\\n\\n\\t\\t\\t}\\n\\t\\t\"\n\t\t};\n\t\tvar geometry = new BoxBufferGeometry(5, 5, 5);\n\t\tvar material = new ShaderMaterial({\n\t\t\tname: 'CubemapFromEquirect',\n\t\t\tuniforms: cloneUniforms(shader.uniforms),\n\t\t\tvertexShader: shader.vertexShader,\n\t\t\tfragmentShader: shader.fragmentShader,\n\t\t\tside: BackSide,\n\t\t\tblending: NoBlending\n\t\t});\n\t\tmaterial.uniforms.tEquirect.value = texture;\n\t\tvar mesh = new Mesh(geometry, material);\n\t\tvar currentMinFilter = texture.minFilter; // Avoid blurred poles\n\n\t\tif (texture.minFilter === LinearMipmapLinearFilter) texture.minFilter = LinearFilter;\n\t\tvar camera = new CubeCamera(1, 10, this);\n\t\tcamera.update(renderer, mesh);\n\t\ttexture.minFilter = currentMinFilter;\n\t\tmesh.geometry.dispose();\n\t\tmesh.material.dispose();\n\t\treturn this;\n\t};\n\n\tWebGLCubeRenderTarget.prototype.clear = function (renderer, color, depth, stencil) {\n\t\tvar currentRenderTarget = renderer.getRenderTarget();\n\n\t\tfor (var i = 0; i < 6; i++) {\n\t\t\trenderer.setRenderTarget(this, i);\n\t\t\trenderer.clear(color, depth, stencil);\n\t\t}\n\n\t\trenderer.setRenderTarget(currentRenderTarget);\n\t};\n\n\tfunction DataTexture(data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding) {\n\t\tTexture.call(this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);\n\t\tthis.image = {\n\t\t\tdata: data || null,\n\t\t\twidth: width || 1,\n\t\t\theight: height || 1\n\t\t};\n\t\tthis.magFilter = magFilter !== undefined ? magFilter : NearestFilter;\n\t\tthis.minFilter = minFilter !== undefined ? minFilter : NearestFilter;\n\t\tthis.generateMipmaps = false;\n\t\tthis.flipY = false;\n\t\tthis.unpackAlignment = 1;\n\t\tthis.needsUpdate = true;\n\t}\n\n\tDataTexture.prototype = Object.create(Texture.prototype);\n\tDataTexture.prototype.constructor = DataTexture;\n\tDataTexture.prototype.isDataTexture = true;\n\n\tvar _sphere$1 = /*@__PURE__*/new Sphere();\n\n\tvar _vector$5 = /*@__PURE__*/new Vector3();\n\n\tvar Frustum = /*#__PURE__*/function () {\n\t\tfunction Frustum(p0, p1, p2, p3, p4, p5) {\n\t\t\tthis.planes = [p0 !== undefined ? p0 : new Plane(), p1 !== undefined ? p1 : new Plane(), p2 !== undefined ? p2 : new Plane(), p3 !== undefined ? p3 : new Plane(), p4 !== undefined ? p4 : new Plane(), p5 !== undefined ? p5 : new Plane()];\n\t\t}\n\n\t\tvar _proto = Frustum.prototype;\n\n\t\t_proto.set = function set(p0, p1, p2, p3, p4, p5) {\n\t\t\tvar planes = this.planes;\n\t\t\tplanes[0].copy(p0);
1\n\t\t\tplanes[1].copy(p1);\n\t\t\tplanes[2].copy(p2);\n\t\t\tplanes[3].copy(p3);\n\t\t\tplanes[4].copy(p4);\n\t\t\tplanes[5].copy(p5);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t};\n\n\t\t_proto.copy = function copy(frustum) {\n\t\t\tvar planes = this.planes;\n\n\t\t\tfor (var i = 0; i < 6; i++) {\n\t\t\t\tplanes[i].copy(frustum.planes[i]);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromProjectionMatrix = function setFromProjectionMatrix(m) {\n\t\t\tvar planes = this.planes;\n\t\t\tvar me = m.elements;\n\t\t\tvar me0 = me[0],\n\t\t\t\t\tme1 = me[1],\n\t\t\t\t\tme2 = me[2],\n\t\t\t\t\tme3 = me[3];\n\t\t\tvar me4 = me[4],\n\t\t\t\t\tme5 = me[5],\n\t\t\t\t\tme6 = me[6],\n\t\t\t\t\tme7 = me[7];\n\t\t\tvar me8 = me[8],\n\t\t\t\t\tme9 = me[9],\n\t\t\t\t\tme10 = me[10],\n\t\t\t\t\tme11 = me[11];\n\t\t\tvar me12 = me[12],\n\t\t\t\t\tme13 = me[13],\n\t\t\t\t\tme14 = me[14],\n\t\t\t\t\tme15 = me[15];\n\t\t\tplanes[0].setComponents(me3 - me0, me7 - me4, me11 - me8, me15 - me12).normalize();\n\t\t\tplanes[1].setComponents(me3 + me0, me7 + me4, me11 + me8, me15 + me12).normalize();\n\t\t\tplanes[2].setComponents(me3 + me1, me7 + me5, me11 + me9, me15 + me13).normalize();\n\t\t\tplanes[3].setComponents(me3 - me1, me7 - me5, me11 - me9, me15 - me13).normalize();\n\t\t\tplanes[4].setComponents(me3 - me2, me7 - me6, me11 - me10, me15 - me14).normalize();\n\t\t\tplanes[5].setComponents(me3 + me2, me7 + me6, me11 + me10, me15 + me14).normalize();\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.intersectsObject = function intersectsObject(object) {\n\t\t\tvar geometry = object.geometry;\n\t\t\tif (geometry.boundingSphere === null) geometry.computeBoundingSphere();\n\n\t\t\t_sphere$1.copy(geometry.boundingSphere).applyMatrix4(object.matrixWorld);\n\n\t\t\treturn this.intersectsSphere(_sphere$1);\n\t\t};\n\n\t\t_proto.intersectsSprite = function intersectsSprite(sprite) {\n\t\t\t_sphere$1.center.set(0, 0, 0);\n\n\t\t\t_sphere$1.radius = 0.7071067811865476;\n\n\t\t\t_sphere$1.applyMatrix4(sprite.matrixWorld);\n\n\t\t\treturn this.intersectsSphere(_sphere$1);\n\t\t};\n\n\t\t_proto.intersectsSphere = function intersectsSphere(sphere) {\n\t\t\tvar planes = this.planes;\n\t\t\tvar center = sphere.center;\n\t\t\tvar negRadius = -sphere.radius;\n\n\t\t\tfor (var i = 0; i < 6; i++) {\n\t\t\t\tvar distance = planes[i].distanceToPoint(center);\n\n\t\t\t\tif (distance < negRadius) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn true;\n\t\t};\n\n\t\t_proto.intersectsBox = function intersectsBox(box) {\n\t\t\tvar planes = this.planes;\n\n\t\t\tfor (var i = 0; i < 6; i++) {\n\t\t\t\tvar plane = planes[i]; // corner at max distance\n\n\t\t\t\t_vector$5.x = plane.normal.x > 0 ? box.max.x : box.min.x;\n\t\t\t\t_vector$5.y = plane.normal.y > 0 ? box.max.y : box.min.y;\n\t\t\t\t_vector$5.z = plane.normal.z > 0 ? box.max.z : box.min.z;\n\n\t\t\t\tif (plane.distanceToPoint(_vector$5) < 0) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn true;\n\t\t};\n\n\t\t_proto.containsPoint = function containsPoint(point) {\n\t\t\tvar planes = this.planes;\n\n\t\t\tfor (var i = 0; i < 6; i++) {\n\t\t\t\tif (planes[i].distanceToPoint(point) < 0) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn true;\n\t\t};\n\n\t\treturn Frustum;\n\t}();\n\n\tfunction WebGLAnimation() {\n\t\tvar context = null;\n\t\tvar isAnimating = false;\n\t\tvar animationLoop = null;\n\t\tvar requestId = null;\n\n\t\tfunction onAnimationFrame(time, frame) {\n\t\t\tanimationLoop(time, frame);\n\t\t\trequestId = context.requestAnimationFrame(onAnimationFrame);\n\t\t}\n\n\t\treturn {\n\t\t\tstart: function start() {\n\t\t\t\tif (isAnimating === true) return;\n\t\t\t\tif (animationLoop === null) return;\n\t\t\t\trequestId = context.requestAnimationFrame(onAnimationFrame);\n\t\t\t\tisAnimating = true;\n\t\t\t},\n\t\t\tstop: function stop() {\n\t\t\t\tcontext.cancelAnimationFrame(requestId);\n\t\t\t\tisAnimating = false;\n\t\t\t},\n\t\t\tsetAnimationLoop: function setAnimationLoop(callback) {\n\t\t\t\tanimationLoop = callback;\n\t\t\t},\n\t\t\tsetContext: function setContext(value) {\n\t\t\t\tcontext = value;\n\t\t\t}\n\t\t};\n\t}\n\n\tfunction WebGLAttributes(gl, capabilities) {\n\t\tvar isWebGL2 = capabilities.isWebGL2;\n\t\tvar buffers = new WeakMap();\n\n\t\tfunction createBuffer(attribute, bufferType) {\n\t\t\tvar array = attribute.array;\n\t\t\tvar usage = attribute.usage;\n\t\t\tvar buffer = gl.createBuffer();\n\t\t\tgl.bindBuffer(bufferType, buffer);\n\t\t\tgl.bufferData(bufferType, array, usage);\n\t\t\tattribute.onUploadCallback();\n\t\t\tvar type = 5126;\n\n\t\t\tif (array instanceof Float32Array) {\n\t\t\t\ttype = 5126;\n\t\t\t} else if (array instanceof Float64Array) {\n\t\t\t\tconsole.warn('THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.');\n\t\t\t} else if (array instanceof Uint16Array) {\n\t\t\t\tif (attribute.isFloat16BufferAttribute) {\n\t\t\t\t\tif (isWebGL2) {\n\t\t\t\t\t\ttype = 5131;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.warn('THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.');\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttype = 5123;\n\t\t\t\t}\n\t\t\t} else if (array instanceof Int16Array) {\n\t\t\t\ttype = 5122;\n\t\t\t} else if (array instanceof Uint32Array) {\n\t\t\t\ttype = 5125;\n\t\t\t} else if (array instanceof Int32Array) {\n\t\t\t\ttype = 5124;\n\t\t\t} else if (array instanceof Int8Array) {\n\t\t\t\ttype = 5120;\n\t\t\t} else if (array instanceof Uint8Array) {\n\t\t\t\ttype = 5121;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tbuffer: buffer,\n\t\t\t\ttype: type,\n\t\t\t\tbytesPerElement: array.BYTES_PER_ELEMENT,\n\t\t\t\tversion: attribute.version\n\t\t\t};\n\t\t}\n\n\t\tfunction updateBuffer(buffer, attribute, bufferType) {\n\t\t\tvar array = attribute.array;\n\t\t\tvar updateRange = attribute.updateRange;\n\t\t\tgl.bindBuffer(bufferType, buffer);\n\n\t\t\tif (updateRange.count === -1) {\n\t\t\t\t// Not using update ranges\n\t\t\t\tgl.bufferSubData(bufferType, 0, array);\n\t\t\t} else {\n\t\t\t\tif (isWebGL2) {\n\t\t\t\t\tgl.bufferSubData(bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, array, updateRange.offset, updateRange.count);\n\t\t\t\t} else {\n\t\t\t\t\tgl.bufferSubData(bufferType, updateRange.offset * array.BYTES_PER_ELEMENT, array.subarray(updateRange.offset, updateRange.offset + updateRange.count));\n\t\t\t\t}\n\n\t\t\t\tupdateRange.count = -1; // reset range\n\t\t\t}\n\t\t} //\n\n\n\t\tfunction get(attribute) {\n\t\t\tif (attribute.isInterleavedBufferAttribute) attribute = attribute.data;\n\t\t\treturn buffers.get(attribute);\n\t\t}\n\n\t\tfunction remove(attribute) {\n\t\t\tif (attribute.isInterleavedBufferAttribute) attribute = attribute.data;\n\t\t\tvar data = buffers.get(attribute);
1\n\n\t\t\tif (data) {\n\t\t\t\tgl.deleteBuffer(data.buffer);\n\t\t\t\tbuffers.delete(attribute);\n\t\t\t}\n\t\t}\n\n\t\tfunction update(attribute, bufferType) {\n\t\t\tif (attribute.isGLBufferAttribute) {\n\t\t\t\tvar cached = buffers.get(attribute);\n\n\t\t\t\tif (!cached || cached.version < attribute.version) {\n\t\t\t\t\tbuffers.set(attribute, {\n\t\t\t\t\t\tbuffer: attribute.buffer,\n\t\t\t\t\t\ttype: attribute.type,\n\t\t\t\t\t\tbytesPerElement: attribute.elementSize,\n\t\t\t\t\t\tversion: attribute.version\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (attribute.isInterleavedBufferAttribute) attribute = attribute.data;\n\t\t\tvar data = buffers.get(attribute);\n\n\t\t\tif (data === undefined) {\n\t\t\t\tbuffers.set(attribute, createBuffer(attribute, bufferType));\n\t\t\t} else if (data.version < attribute.version) {\n\t\t\t\tupdateBuffer(data.buffer, attribute, bufferType);\n\t\t\t\tdata.version = attribute.version;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tget: get,\n\t\t\tremove: remove,\n\t\t\tupdate: update\n\t\t};\n\t}\n\n\tvar PlaneBufferGeometry = /*#__PURE__*/function (_BufferGeometry) {\n\t\t_inheritsLoose(PlaneBufferGeometry, _BufferGeometry);\n\n\t\tfunction PlaneBufferGeometry(width, height, widthSegments, heightSegments) {\n\t\t\tvar _this;\n\n\t\t\tif (width === void 0) {\n\t\t\t\twidth = 1;\n\t\t\t}\n\n\t\t\tif (height === void 0) {\n\t\t\t\theight = 1;\n\t\t\t}\n\n\t\t\tif (widthSegments === void 0) {\n\t\t\t\twidthSegments = 1;\n\t\t\t}\n\n\t\t\tif (heightSegments === void 0) {\n\t\t\t\theightSegments = 1;\n\t\t\t}\n\n\t\t\t_this = _BufferGeometry.call(this) || this;\n\t\t\t_this.type = 'PlaneBufferGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\twidth: width,\n\t\t\t\theight: height,\n\t\t\t\twidthSegments: widthSegments,\n\t\t\t\theightSegments: heightSegments\n\t\t\t};\n\t\t\tvar width_half = width / 2;\n\t\t\tvar height_half = height / 2;\n\t\t\tvar gridX = Math.floor(widthSegments);\n\t\t\tvar gridY = Math.floor(heightSegments);\n\t\t\tvar gridX1 = gridX + 1;\n\t\t\tvar gridY1 = gridY + 1;\n\t\t\tvar segment_width = width / gridX;\n\t\t\tvar segment_height = height / gridY; //\n\n\t\t\tvar indices = [];\n\t\t\tvar vertices = [];\n\t\t\tvar normals = [];\n\t\t\tvar uvs = [];\n\n\t\t\tfor (var iy = 0; iy < gridY1; iy++) {\n\t\t\t\tvar y = iy * segment_height - height_half;\n\n\t\t\t\tfor (var ix = 0; ix < gridX1; ix++) {\n\t\t\t\t\tvar x = ix * segment_width - width_half;\n\t\t\t\t\tvertices.push(x, -y, 0);\n\t\t\t\t\tnormals.push(0, 0, 1);\n\t\t\t\t\tuvs.push(ix / gridX);\n\t\t\t\t\tuvs.push(1 - iy / gridY);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (var _iy = 0; _iy < gridY; _iy++) {\n\t\t\t\tfor (var _ix = 0; _ix < gridX; _ix++) {\n\t\t\t\t\tvar a = _ix + gridX1 * _iy;\n\t\t\t\t\tvar b = _ix + gridX1 * (_iy + 1);\n\t\t\t\t\tvar c = _ix + 1 + gridX1 * (_iy + 1);\n\t\t\t\t\tvar d = _ix + 1 + gridX1 * _iy;\n\t\t\t\t\tindices.push(a, b, d);\n\t\t\t\t\tindices.push(b, c, d);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t_this.setIndex(indices);\n\n\t\t\t_this.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\n\t\t\t_this.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\n\t\t\t_this.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn PlaneBufferGeometry;\n\t}(BufferGeometry);\n\n\tvar alphamap_fragment = \"#ifdef USE_ALPHAMAP\\n\\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\\n#endif\";\n\n\tvar alphamap_pars_fragment = \"#ifdef USE_ALPHAMAP\\n\\tuniform sampler2D alphaMap;\\n#endif\";\n\n\tvar alphatest_fragment = \"#ifdef ALPHATEST\\n\\tif ( diffuseColor.a < ALPHATEST ) discard;\\n#endif\";\n\n\tvar aomap_fragment = \"#ifdef USE_AOMAP\\n\\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\\n\\treflectedLight.indirectDiffuse *= ambientOcclusion;\\n\\t#if defined( USE_ENVMAP ) && defined( STANDARD )\\n\\t\\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\\n\\t\\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\\n\\t#endif\\n#endif\";\n\n\tvar aomap_pars_fragment = \"#ifdef USE_AOMAP\\n\\tuniform sampler2D aoMap;\\n\\tuniform float aoMapIntensity;\\n#endif\";\n\n\tvar begin_vertex = \"vec3 transformed = vec3( position );\";\n\n\tvar beginnormal_vertex = \"vec3 objectNormal = vec3( normal );\\n#ifdef USE_TANGENT\\n\\tvec3 objectTangent = vec3( tangent.xyz );\\n#endif\";\n\n\tvar bsdfs = \"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\\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\\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\\n}\\nfloat 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}\\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\\n\\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\\n\\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\\n\\treturn Fr * fresnel + F0;\\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 vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\\n\\tfloat alpha = pow2( roughness );\\n\\tvec3 halfDir = normalize( incidentLight.direction + viewDir );
1\\n\\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\\n\\tfloat dotNV = saturate( dot( normal, viewDir ) );\\n\\tfloat dotNH = saturate( dot( 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 >
1 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 vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\\n\\tfloat dotNV = saturate( dot( normal, viewDir ) );\\n\\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\\n\\treturn specularColor * brdf.x + brdf.y;\\n}\\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\\n\\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\\n\\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\\n\\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\\n\\tvec3 FssEss = F * brdf.x + brdf.y;\\n\\tfloat Ess = brdf.x + brdf.y;\\n\\tfloat Ems = 1.0 - Ess;\\n\\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\\n\\tsingleScatter += FssEss;\\n\\tmultiScatter += Fms * Ems;\\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#if defined( USE_SHEEN )\\nfloat D_Charlie(float roughness, float NoH) {\\n\\tfloat invAlpha = 1.0 / roughness;\\n\\tfloat cos2h = NoH * NoH;\\n\\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\\n}\\nfloat V_Neubelt(float NoV, float NoL) {\\n\\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\\n}\\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\\n\\tvec3 N = geometry.normal;\\n\\tvec3 V = geometry.viewDir;\\n\\tvec3 H = normalize( V + L );
1\\n\\tfloat dotNH = saturate( dot( N, H ) );\\n\\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\\n}\\n#endif\";\n\n\tvar bumpmap_pars_fragment = \"#ifdef USE_BUMPMAP\\n\\tuniform sampler2D bumpMap;\\n\\tuniform float bumpScale;\\n\\tvec2 dHdxy_fwd() {\\n\\t\\tvec2 dSTdx = dFdx( vUv );\\n\\t\\tvec2 dSTdy = dFdy( vUv );\\n\\t\\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\\n\\t\\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\\n\\t\\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\\n\\t\\treturn vec2( dBx, dBy );\\n\\t}\\n\\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\\n\\t\\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\\n\\t\\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\\n\\t\\tvec3 vN = surf_norm;\\n\\t\\tvec3 R1 = cross( vSigmaY, vN );\\n\\t\\tvec3 R2 = cross( vN, vSigmaX );\\n\\t\\tfloat fDet = dot( vSigmaX, R1 );\\n\\t\\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\\n\\t\\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\\n\\t\\treturn normalize( abs( fDet ) * surf_norm - vGrad );\\n\\t}\\n#endif\";\n\n\tvar clipping_planes_fragment = \"#if NUM_CLIPPING_PLANES > 0\\n\\tvec4 plane;\\n\\t#pragma unroll_loop_start\\n\\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\\n\\t\\tplane = clippingPlanes[ i ];\\n\\t\\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\\n\\t}\\n\\t#pragma unroll_loop_end\\n\\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\\n\\t\\tbool clipped = true;\\n\\t\\t#pragma unroll_loop_start\\n\\t\\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\\n\\t\\t\\tplane = clippingPlanes[ i ];\\n\\t\\t\\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\\n\\t\\t}\\n\\t\\t#pragma unroll_loop_end\\n\\t\\tif ( clipped ) discard;\\n\\t#endif\\n#endif\";\n\n\tvar clipping_planes_pars_fragment = \"#if NUM_CLIPPING_PLANES > 0\\n\\tvarying vec3 vClipPosition;\\n\\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\\n#endif\";\n\n\tvar clipping_planes_pars_vertex = \"#if NUM_CLIPPING_PLANES > 0\\n\\tvarying vec3 vClipPosition;\\n#endif\";\n\n\tvar clipping_planes_vertex = \"#if NUM_CLIPPING_PLANES > 0\\n\\tvClipPosition = - mvPosition.xyz;\\n#endif\";\n\n\tvar color_fragment = \"#ifdef USE_COLOR\\n\\tdiffuseColor.rgb *= vColor;\\n#endif\";\n\n\tvar color_pars_fragment = \"#ifdef USE_COLOR\\n\\tvarying vec3 vColor;\\n#endif\";\n\n\tvar color_pars_vertex = \"#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\\n\\tvarying vec3 vColor;\\n#endif\";\n\n\tvar color_vertex = \"#if defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\\n\\tvColor = vec3( 1.0 );\\n#endif\\n#ifdef USE_COLOR\\n\\tvColor.xyz *= color.xyz;\\n#endif\\n#ifdef USE_INSTANCING_COLOR\\n\\tvColor.xyz *= instanceColor.xyz;\\n#endif\";\n\n\tvar common = \"#define PI 3.141592653589793\\n#define PI2 6.283185307179586\\n#define PI_HALF 1.5707963267948966\\n#define RECIPROCAL_PI 0.3183098861837907\\n#define RECIPROCAL_PI2 0.15915494309189535\\n#define EPSILON 1e-6\\n#ifndef saturate\\n#define saturate(a) clamp( a, 0.0, 1.0 )\\n#endif\\n#define whiteComplement(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}\\n#ifdef HIGH_PRECISION\\n\\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\\n#else\\n\\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\\n\\tfloat precisionSafeLength( vec3 v ) {\\n\\t\\tfloat maxComponent = max3( abs( v ) );\\n\\t\\treturn length( v / maxComponent ) * maxComponent;\\n\\t}\\n#endif\\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#ifdef CLEARCOAT\\n\\tvec3 clearcoatNormal;\\n#endif\\n};
1\\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}\\nbool isPerspectiveMatrix( mat4 m ) {\\n\\treturn m[ 2 ][ 3 ] == - 1.0;\\n}\\nvec2 equirectUv( in vec3 dir ) {\\n\\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\\n\\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\\n\\treturn vec2( u, v );\\n}\";\n\n\tvar cube_uv_reflection_fragment = \"#ifdef ENVMAP_TYPE_CUBE_UV\\n\\t#define cubeUV_maxMipLevel 8.0\\n\\t#define cubeUV_minMipLevel 4.0\\n\\t#define cubeUV_maxTileSize 256.0\\n\\t#define cubeUV_minTileSize 16.0\\n\\tfloat getFace( vec3 direction ) {\\n\\t\\tvec3 absDirection = abs( direction );\\n\\t\\tfloat face = - 1.0;\\n\\t\\tif ( absDirection.x > absDirection.z ) {\\n\\t\\t\\tif ( absDirection.x > absDirection.y )\\n\\t\\t\\t\\tface = direction.x > 0.0 ? 0.0 : 3.0;\\n\\t\\t\\telse\\n\\t\\t\\t\\tface = direction.y > 0.0 ? 1.0 : 4.0;\\n\\t\\t} else {\\n\\t\\t\\tif ( absDirection.z > absDirection.y )\\n\\t\\t\\t\\tface = direction.z > 0.0 ? 2.0 : 5.0;\\n\\t\\t\\telse\\n\\t\\t\\t\\tface = direction.y > 0.0 ? 1.0 : 4.0;\\n\\t\\t}\\n\\t\\treturn face;\\n\\t}\\n\\tvec2 getUV( vec3 direction, float face ) {\\n\\t\\tvec2 uv;\\n\\t\\tif ( face == 0.0 ) {\\n\\t\\t\\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\\n\\t\\t} else if ( face == 1.0 ) {\\n\\t\\t\\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\\n\\t\\t} else if ( face == 2.0 ) {\\n\\t\\t\\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\\n\\t\\t} else if ( face == 3.0 ) {\\n\\t\\t\\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\\n\\t\\t} else if ( face == 4.0 ) {\\n\\t\\t\\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\\n\\t\\t} else {\\n\\t\\t\\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\\n\\t\\t}\\n\\t\\treturn 0.5 * ( uv + 1.0 );\\n\\t}\\n\\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\\n\\t\\tfloat face = getFace( direction );\\n\\t\\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\\n\\t\\tmipInt = max( mipInt, cubeUV_minMipLevel );\\n\\t\\tfloat faceSize = exp2( mipInt );\\n\\t\\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\\n\\t\\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 );\\n\\t\\tvec2 f = fract( uv );\\n\\t\\tuv += 0.5 - f;\\n\\t\\tif ( face > 2.0 ) {\\n\\t\\t\\tuv.y += faceSize;\\n\\t\\t\\tface -= 3.0;\\n\\t\\t}\\n\\t\\tuv.x += face * faceSize;\\n\\t\\tif ( mipInt < cubeUV_maxMipLevel ) {\\n\\t\\t\\tuv.y += 2.0 * cubeUV_maxTileSize;\\n\\t\\t}\\n\\t\\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\\n\\t\\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\\n\\t\\tuv *= texelSize;\\n\\t\\tvec3 tl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\\n\\t\\tuv.x += texelSize;\\n\\t\\tvec3 tr = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\\n\\t\\tuv.y += texelSize;\\n\\t\\tvec3 br = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\\n\\t\\tuv.x -= texelSize;\\n\\t\\tvec3 bl = envMapTexelToLinear( texture2D( envMap, uv ) ).rgb;\\n\\t\\tvec3 tm = mix( tl, tr, f.x );\\n\\t\\tvec3 bm = mix( bl, br, f.x );\\n\\t\\treturn mix( tm, bm, f.y );\\n\\t}\\n\\t#define r0 1.0\\n\\t#define v0 0.339\\n\\t#define m0 - 2.0\\n\\t#define r1 0.8\\n\\t#define v1 0.276\\n\\t#define m1 - 1.0\\n\\t#define r4 0.4\\n\\t#define v4 0.046\\n\\t#define m4 2.0\\n\\t#define r5 0.305\\n\\t#define v5 0.016\\n\\t#define m5 3.0\\n\\t#define r6 0.21\\n\\t#define v6 0.0038\\n\\t#define m6 4.0\\n\\tfloat roughnessToMip( float roughness ) {\\n\\t\\tfloat mip = 0.0;\\n\\t\\tif ( roughness >= r1 ) {\\n\\t\\t\\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\\n\\t\\t} else if ( roughness >= r4 ) {\\n\\t\\t\\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\\n\\t\\t} else if ( roughness >= r5 ) {\\n\\t\\t\\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\\n\\t\\t} else if ( roughness >= r6 ) {\\n\\t\\t\\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\\n\\t\\t} else {\\n\\t\\t\\tmip = - 2.0 * log2( 1.16 * roughness );\\t\\t}\\n\\t\\treturn mip;\\n\\t}\\n\\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\\n\\t\\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\\n\\t\\tfloat mipF = fract( mip );\\n\\t\\tfloat mipInt = floor( mip );\\n\\t\\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\\n\\t\\tif ( mipF == 0.0 ) {\\n\\t\\t\\treturn vec4( color0, 1.0 );\\n\\t\\t} else {\\n\\t\\t\\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\\n\\t\\t\\treturn vec4( mix( color0, color1, mipF ), 1.0 );\\n\\t\\t}\\n\\t}\\n#endif\";\n\n\tvar defaultnormal_vertex = \"vec3 transformedNormal = objectNormal;\\n#ifdef USE_INSTANCING\\n\\tmat3 m = mat3( instanceMatrix );\\n\\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\\n\\ttransformedNormal = m * transformedNormal;\\n#endif\\ntransformedNormal = normalMatrix * transformedNormal;\\n#ifdef FLIP_SIDED\\n\\ttransformedNormal = - transformedNormal;\\n#endif\\n#ifdef USE_TANGENT\\n\\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\\n\\t#ifdef FLIP_SIDED\\n\\t\\ttransformedTangent = - transformedTangent;\\n\\t#endif\\n#endif\";\n\n\tvar displacementmap_pars_vertex = \"#ifdef USE_DISPLACEMENTMAP\\n\\tuniform sampler2D displacementMap;\\n\\tuniform float displacementScale;\\n\\tuniform float displacementBias;\\n#endif\";\n\n\tvar displacementmap_vertex = \"#ifdef USE_DISPLACEMENTMAP\\n\\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + dis
1placementBias );\\n#endif\";\n\n\tvar emissivemap_fragment = \"#ifdef USE_EMISSIVEMAP\\n\\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\\n\\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\\n\\ttotalEmissiveRadiance *= emissiveColor.rgb;\\n#endif\";\n\n\tvar emissivemap_pars_fragment = \"#ifdef USE_EMISSIVEMAP\\n\\tuniform sampler2D emissiveMap;\\n#endif\";\n\n\tvar encodings_fragment = \"gl_FragColor = linearToOutputTexel( gl_FragColor );\";\n\n\tvar encodings_pars_fragment = \"\\nvec4 LinearToLinear( in vec4 value ) {\\n\\treturn value;\\n}\\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\\n\\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\\n}\\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\\n\\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\\n}\\nvec4 sRGBToLinear( in vec4 value ) {\\n\\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\\n}\\nvec4 LinearTosRGB( in vec4 value ) {\\n\\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\\n}\\nvec4 RGBEToLinear( in vec4 value ) {\\n\\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\\n}\\nvec4 LinearToRGBE( in vec4 value ) {\\n\\tfloat maxComponent = max( max( value.r, value.g ), value.b );\\n\\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\\n\\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\\n}\\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\\n\\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\\n}\\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\\n\\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\\n\\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\\n\\tM = ceil( M * 255.0 ) / 255.0;\\n\\treturn vec4( value.rgb / ( M * maxRange ), M );\\n}\\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\\n\\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\\n}\\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\\n\\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\\n\\tfloat D = max( maxRange / maxRGB, 1.0 );\\n\\tD = clamp( floor( D ) / 255.0, 0.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 = cLogLuvM * value.rgb;\\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 = cLogLuvInverseM * Xp_Y_XYZp.rgb;\\n\\treturn vec4( max( vRGB, 0.0 ), 1.0 );\\n}\";\n\n\tvar envmap_fragment = \"#ifdef USE_ENVMAP\\n\\t#ifdef ENV_WORLDPOS\\n\\t\\tvec3 cameraToFrag;\\n\\t\\tif ( isOrthographic ) {\\n\\t\\t\\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\\n\\t\\t} else {\\n\\t\\t\\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\\n\\t\\t}\\n\\t\\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\\n\\t\\t#ifdef ENVMAP_MODE_REFLECTION\\n\\t\\t\\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\\n\\t\\t#else\\n\\t\\t\\tvec3 reflectVec = refract( cameraToFrag, 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_CUBE_UV )\\n\\t\\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\\n\\t#else\\n\\t\\tvec4 envColor = vec4( 0.0 );\\n\\t#endif\\n\\t#ifndef ENVMAP_TYPE_CUBE_UV\\n\\t\\tenvColor = envMapTexelToLinear( envColor );\\n\\t#endif\\n\\t#ifdef ENVMAP_BLENDING_MULTIPLY\\n\\t\\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\\n\\t#elif defined( ENVMAP_BLENDING_MIX )\\n\\t\\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\\n\\t#elif defined( ENVMAP_BLENDING_ADD )\\n\\t\\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\\n\\t#endif\\n#endif\";\n\n\tvar envmap_common_pars_fragment = \"#ifdef USE_ENVMAP\\n\\tuniform float envMapIntensity;\\n\\tuniform float flipEnvMap;\\n\\tuniform int maxMipLevel;\\n\\t#ifdef ENVMAP_TYPE_CUBE\\n\\t\\tuniform samplerCube envMap;\\n\\t#else\\n\\t\\tuniform sampler2D envMap;\\n\\t#endif\\n\\t\\n#endif\";\n\n\tvar envmap_pars_fragment = \"#ifdef USE_ENVMAP\\n\\tuniform float reflectivity;\\n\\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\\n\\t\\t#define ENV_WORLDPOS\\n\\t#endif\\n\\t#ifdef ENV_WORLDPOS\\n\\t\\tvarying vec3 vWorldPosition;\\n\\t\\tuniform float refractionRatio;\\n\\t#else\\n\\t\\tvarying vec3 vReflect;\\n\\t#endif\\n#endif\";\n\n\tvar envmap_pars_vertex = \"#ifdef USE_ENVMAP\\n\\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\\n\\t\\t#define ENV_WORLDPOS\\n\\t#endif\\n\\t#ifdef ENV_WORLDPOS\\n\\t\\t\\n\\t\\tvarying vec3 vWorldPosition;\\n\\t#else\\n\\t\\tvarying vec3 vReflect;\\n\\t\\tuniform float refractionRatio;\\n\\t#endif\\n#endif\";\n\n\tvar envmap_vertex = \"#ifdef USE_ENVMAP\\n\\t#ifdef ENV_WORLDPOS\\n\\t\\tvWorldPosition = worldPosition.xyz;\\n\\t#else\\n\\t\\tvec3 cameraToVertex;\\n\\t\\tif ( isOrthographic ) {\\n\\t\\t\\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\\n\\t\\t}
1 else {\\n\\t\\t\\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\\n\\t\\t}\\n\\t\\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\\n\\t\\t#ifdef ENVMAP_MODE_REFLECTION\\n\\t\\t\\tvReflect = reflect( cameraToVertex, worldNormal );\\n\\t\\t#else\\n\\t\\t\\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\\n\\t\\t#endif\\n\\t#endif\\n#endif\";\n\n\tvar fog_vertex = \"#ifdef USE_FOG\\n\\tfogDepth = - mvPosition.z;\\n#endif\";\n\n\tvar fog_pars_vertex = \"#ifdef USE_FOG\\n\\tvarying float fogDepth;\\n#endif\";\n\n\tvar fog_fragment = \"#ifdef USE_FOG\\n\\t#ifdef FOG_EXP2\\n\\t\\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\\n\\t#else\\n\\t\\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\\n\\t#endif\\n\\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\\n#endif\";\n\n\tvar fog_pars_fragment = \"#ifdef USE_FOG\\n\\tuniform vec3 fogColor;\\n\\tvarying float fogDepth;\\n\\t#ifdef FOG_EXP2\\n\\t\\tuniform float fogDensity;\\n\\t#else\\n\\t\\tuniform float fogNear;\\n\\t\\tuniform float fogFar;\\n\\t#endif\\n#endif\";\n\n\tvar gradientmap_pars_fragment = \"#ifdef USE_GRADIENTMAP\\n\\tuniform sampler2D gradientMap;\\n#endif\\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\\n\\tfloat dotNL = dot( normal, lightDirection );\\n\\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\\n\\t#ifdef USE_GRADIENTMAP\\n\\t\\treturn texture2D( gradientMap, coord ).rgb;\\n\\t#else\\n\\t\\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\\n\\t#endif\\n}\";\n\n\tvar lightmap_fragment = \"#ifdef USE_LIGHTMAP\\n\\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\\n\\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\\n#endif\";\n\n\tvar lightmap_pars_fragment = \"#ifdef USE_LIGHTMAP\\n\\tuniform sampler2D lightMap;\\n\\tuniform float lightMapIntensity;\\n#endif\";\n\n\tvar lights_lambert_vertex = \"vec3 diffuse = vec3( 1.0 );\\nGeometricContext geometry;\\ngeometry.position = mvPosition.xyz;\\ngeometry.normal = normalize( transformedNormal );\\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\\nGeometricContext backGeometry;\\nbackGeometry.position = geometry.position;\\nbackGeometry.normal = -geometry.normal;\\nbackGeometry.viewDir = geometry.viewDir;\\nvLightFront = vec3( 0.0 );\\nvIndirectFront = vec3( 0.0 );\\n#ifdef DOUBLE_SIDED\\n\\tvLightBack = vec3( 0.0 );\\n\\tvIndirectBack = vec3( 0.0 );\\n#endif\\nIncidentLight directLight;\\nfloat dotNL;\\nvec3 directLightColor_Diffuse;\\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\\n#ifdef DOUBLE_SIDED\\n\\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\\n\\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\\n#endif\\n#if NUM_POINT_LIGHTS > 0\\n\\t#pragma unroll_loop_start\\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\\t#pragma unroll_loop_end\\n#endif\\n#if NUM_SPOT_LIGHTS > 0\\n\\t#pragma unroll_loop_start\\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\\t#pragma unroll_loop_end\\n#endif\\n#if NUM_DIR_LIGHTS > 0\\n\\t#pragma unroll_loop_start\\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\\t#pragma unroll_loop_end\\n#endif\\n#if NUM_HEMI_LIGHTS > 0\\n\\t#pragma unroll_loop_start\\n\\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\\n\\t\\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\\n\\t\\t#ifdef DOUBLE_SIDED\\n\\t\\t\\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\\n\\t\\t#endif\\n\\t}\\n\\t#pragma unroll_loop_end\\n#endif\";\n\n\tvar lights_pars_begin = \"uniform bool receiveShadow;\\nuniform vec3 ambientLightColor;\\nuniform vec3 lightProbe[ 9 ];\\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\\n\\tfloat x = normal.x, y = normal.y, z = normal.z;\\n\\tvec3 result = shCoefficients[ 0 ] * 0.886227;\\n\\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\\n\\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\\n\\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\\n\\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\\n\\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\\n\\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\\n\\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\\n\\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\\n\\treturn result;\\n}\\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\\n\\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\\n\\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\\n\\treturn irradiance;\\n}\\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};\\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};\\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}
1\\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};\\n\\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\\n\\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\\n\\t\\tvec3 lVector = spotLight.position - geometry.position;\\n\\t\\tdirectLight.direction = normalize( lVector );\\n\\t\\tfloat lightDistance = length( lVector );\\n\\t\\tfloat angleCos = dot( directLight.direction, spotLight.direction );\\n\\t\\tif ( angleCos > spotLight.coneCos ) {\\n\\t\\t\\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\\n\\t\\t\\tdirectLight.color = spotLight.color;\\n\\t\\t\\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\\n\\t\\t\\tdirectLight.visible = true;\\n\\t\\t} else {\\n\\t\\t\\tdirectLight.color = vec3( 0.0 );\\n\\t\\t\\tdirectLight.visible = false;\\n\\t\\t}\\n\\t}\\n#endif\\n#if NUM_RECT_AREA_LIGHTS > 0\\n\\tstruct RectAreaLight {\\n\\t\\tvec3 color;\\n\\t\\tvec3 position;\\n\\t\\tvec3 halfWidth;\\n\\t\\tvec3 halfHeight;\\n\\t};\\n\\tuniform sampler2D ltc_1;\\tuniform sampler2D ltc_2;\\n\\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\\n#endif\\n#if NUM_HEMI_LIGHTS > 0\\n\\tstruct HemisphereLight {\\n\\t\\tvec3 direction;\\n\\t\\tvec3 skyColor;\\n\\t\\tvec3 groundColor;\\n\\t};\\n\\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\\n\\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\\n\\t\\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\\n\\t\\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\\n\\t\\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\\n\\t\\t#ifndef PHYSICALLY_CORRECT_LIGHTS\\n\\t\\t\\tirradiance *= PI;\\n\\t\\t#endif\\n\\t\\treturn irradiance;\\n\\t}\\n#endif\";\n\n\tvar envmap_physical_pars_fragment = \"#if defined( USE_ENVMAP )\\n\\t#ifdef ENVMAP_MODE_REFRACTION\\n\\t\\tuniform float refractionRatio;\\n\\t#endif\\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\\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 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 roughness, const in int maxMIPLevel ) {\\n\\t\\tfloat maxMIPLevelScalar = float( maxMIPLevel );\\n\\t\\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\\n\\t\\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\\n\\t\\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\\n\\t}\\n\\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\\n\\t\\t#ifdef ENVMAP_MODE_REFLECTION\\n\\t\\t\\tvec3 reflectVec = reflect( -viewDir, normal );\\n\\t\\t\\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\\n\\t\\t#else\\n\\t\\t\\tvec3 reflectVec = refract( -viewDir, normal, refractionRatio );\\n\\t\\t#endif\\n\\t\\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\\n\\t\\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, 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\\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\\n\\t\\t#endif\\n\\t\\treturn envMapColor.rgb * envMapIntensity;\\n\\t}\\n#endif\";\n\n\tvar lights_toon_fragment = \"ToonMaterial material;\\nmaterial.diffuseColor = diffuseColor.rgb;\";\n\n\tvar lights_toon_pars_fragment = \"varying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\nstruct ToonMaterial {\\n\\tvec3 diffuseColor;\\n};\\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\\n\\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\\n\\t#ifndef PHYSICALLY_CORRECT_LIGHTS\\n\\t\\tirradiance *= PI;\\n\\t#endif\\n\\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\\n}\\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\\n\\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\\n}\\n#define RE_Direct\\t\\t\\t\\tRE_Direct_Toon\\n#define RE_IndirectDiffuse\\t\\tRE_IndirectDiffuse_Toon\\n#define Material_LightProbeLOD( material )\\t(0)\";\n\n\tvar lights_phong_fragment = \"BlinnPhongMaterial material;\\nmaterial.diffuseColor = diffuseColor.rgb;\\nmaterial.specularColor = specular;\\nmaterial.specularShininess = shininess;\\nmaterial.specularStrength = specularStrength;\";\n\n\tvar lights_phong_pars_fragment = \"varying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\nstruct BlinnPhongMaterial {\\n\\tvec3 diffuseColor;\\n\\tvec3 specularColor;\\n\\tfloat specularShininess;\\n\\tfloat specularStrength;\\n};\\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\\n\\tfloat dotNL = saturate( dot
1( geometry.normal, directLight.direction ) );\\n\\tvec3 irradiance = dotNL * directLight.color;\\n\\t#ifndef PHYSICALLY_CORRECT_LIGHTS\\n\\t\\tirradiance *= PI;\\n\\t#endif\\n\\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\\n\\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\\n}\\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\\n\\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\\n}\\n#define RE_Direct\\t\\t\\t\\tRE_Direct_BlinnPhong\\n#define RE_IndirectDiffuse\\t\\tRE_IndirectDiffuse_BlinnPhong\\n#define Material_LightProbeLOD( material )\\t(0)\";\n\n\tvar lights_physical_fragment = \"PhysicalMaterial material;\\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );material.specularRoughness += geometryRoughness;\\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\\n#ifdef REFLECTIVITY\\n\\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\\n#else\\n\\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\\n#endif\\n#ifdef CLEARCOAT\\n\\tmaterial.clearcoat = clearcoat;\\n\\tmaterial.clearcoatRoughness = clearcoatRoughness;\\n\\t#ifdef USE_CLEARCOATMAP\\n\\t\\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\\n\\t#endif\\n\\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\\n\\t\\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\\n\\t#endif\\n\\tmaterial.clearcoat = saturate( material.clearcoat );\\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\\n\\tmaterial.clearcoatRoughness += geometryRoughness;\\n\\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\\n#endif\\n#ifdef USE_SHEEN\\n\\tmaterial.sheenColor = sheen;\\n#endif\";\n\n\tvar lights_physical_pars_fragment = \"struct PhysicalMaterial {\\n\\tvec3 diffuseColor;\\n\\tfloat specularRoughness;\\n\\tvec3 specularColor;\\n#ifdef CLEARCOAT\\n\\tfloat clearcoat;\\n\\tfloat clearcoatRoughness;\\n#endif\\n#ifdef USE_SHEEN\\n\\tvec3 sheenColor;\\n#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(\t\t0, 1,\t\t0 ),\\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
1( 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#ifdef CLEARCOAT\\n\\t\\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\\n\\t\\tvec3 ccIrradiance = ccDotNL * directLight.color;\\n\\t\\t#ifndef PHYSICALLY_CORRECT_LIGHTS\\n\\t\\t\\tccIrradiance *= PI;\\n\\t\\t#endif\\n\\t\\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\\n\\t\\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\\n\\t#else\\n\\t\\tfloat clearcoatDHR = 0.0;\\n\\t#endif\\n\\t#ifdef USE_SHEEN\\n\\t\\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\\n\\t\\t\\tmaterial.specularRoughness,\\n\\t\\t\\tdirectLight.direction,\\n\\t\\t\\tgeometry,\\n\\t\\t\\tmaterial.sheenColor\\n\\t\\t);\\n\\t#else\\n\\t\\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\\n\\t#endif\\n\\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\\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 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\\n\\t#ifdef CLEARCOAT\\n\\t\\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\\n\\t\\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\\n\\t\\tfloat ccDotNL = ccDotNV;\\n\\t\\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\\n\\t#else\\n\\t\\tfloat clearcoatDHR = 0.0;\\n\\t#endif\\n\\tfloat clearcoatInv = 1.0 - clearcoatDHR;\\n\\tvec3 singleScattering = vec3( 0.0 );\\n\\tvec3 multiScattering = vec3( 0.0 );\\n\\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\\n\\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\\n\\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\\n\\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\\n\\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\\n\\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\\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\\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\\n\\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\\n}\";\n\n\tvar lights_fragment_begin = \"\\nGeometricContext geometry;\\ngeometry.position = - vViewPosition;\\ngeometry.normal = normal;\\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\\n#ifdef CLEARCOAT\\n\\tgeometry.clearcoatNormal = clearcoatNormal;\\n#endif\\nIncidentLight directLight;\\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\\n\\tPointLight pointLight;\\n\\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\\n\\tPointLightShadow pointLightShadow;\\n\\t#endif\\n\\t#pragma unroll_loop_start\\n\\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\\n\\t\\tpointLight = pointLights[ i ];\\n\\t\\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\\n\\t\\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\\n\\t\\tpointLightShadow = pointLightShadows[ i ];\\n\\t\\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\\n\\t\\t#endif\\n\\t\\tRE_Direct( directLight, geometry, material, reflectedLight );\\n\\t}
1\\n\\t#pragma unroll_loop_end\\n#endif\\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\\n\\tSpotLight spotLight;\\n\\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\\n\\tSpotLightShadow spotLightShadow;\\n\\t#endif\\n\\t#pragma unroll_loop_start\\n\\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\\n\\t\\tspotLight = spotLights[ i ];\\n\\t\\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\\n\\t\\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\\n\\t\\tspotLightShadow = spotLightShadows[ i ];\\n\\t\\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\\n\\t\\t#endif\\n\\t\\tRE_Direct( directLight, geometry, material, reflectedLight );\\n\\t}\\n\\t#pragma unroll_loop_end\\n#endif\\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\\n\\tDirectionalLight directionalLight;\\n\\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\\n\\tDirectionalLightShadow directionalLightShadow;\\n\\t#endif\\n\\t#pragma unroll_loop_start\\n\\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\\n\\t\\tdirectionalLight = directionalLights[ i ];\\n\\t\\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\\n\\t\\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\\n\\t\\tdirectionalLightShadow = directionalLightShadows[ i ];\\n\\t\\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\\n\\t\\t#endif\\n\\t\\tRE_Direct( directLight, geometry, material, reflectedLight );\\n\\t}\\n\\t#pragma unroll_loop_end\\n#endif\\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\\n\\tRectAreaLight rectAreaLight;\\n\\t#pragma unroll_loop_start\\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\\t#pragma unroll_loop_end\\n#endif\\n#if defined( RE_IndirectDiffuse )\\n\\tvec3 iblIrradiance = vec3( 0.0 );\\n\\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\\n\\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\\n\\t#if ( NUM_HEMI_LIGHTS > 0 )\\n\\t\\t#pragma unroll_loop_start\\n\\t\\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\\n\\t\\t\\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\\n\\t\\t}\\n\\t\\t#pragma unroll_loop_end\\n\\t#endif\\n#endif\\n#if defined( RE_IndirectSpecular )\\n\\tvec3 radiance = vec3( 0.0 );\\n\\tvec3 clearcoatRadiance = vec3( 0.0 );\\n#endif\";\n\n\tvar lights_fragment_maps = \"#if defined( RE_IndirectDiffuse )\\n\\t#ifdef USE_LIGHTMAP\\n\\t\\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\\n\\t\\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * 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( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\\n\\t\\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\\n\\t#endif\\n#endif\\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\\n\\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\\n\\t#ifdef CLEARCOAT\\n\\t\\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\\n\\t#endif\\n#endif\";\n\n\tvar lights_fragment_end = \"#if defined( RE_IndirectDiffuse )\\n\\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\\n#endif\\n#if defined( RE_IndirectSpecular )\\n\\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\\n#endif\";\n\n\tvar logdepthbuf_fragment = \"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\\n\\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\\n#endif\";\n\n\tvar logdepthbuf_pars_fragment = \"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\\n\\tuniform float logDepthBufFC;\\n\\tvarying float vFragDepth;\\n\\tvarying float vIsPerspective;\\n#endif\";
1\n\n\tvar logdepthbuf_pars_vertex = \"#ifdef USE_LOGDEPTHBUF\\n\\t#ifdef USE_LOGDEPTHBUF_EXT\\n\\t\\tvarying float vFragDepth;\\n\\t\\tvarying float vIsPerspective;\\n\\t#else\\n\\t\\tuniform float logDepthBufFC;\\n\\t#endif\\n#endif\";\n\n\tvar logdepthbuf_vertex = \"#ifdef USE_LOGDEPTHBUF\\n\\t#ifdef USE_LOGDEPTHBUF_EXT\\n\\t\\tvFragDepth = 1.0 + gl_Position.w;\\n\\t\\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\\n\\t#else\\n\\t\\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\\n\\t\\t\\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\\n\\t\\t\\tgl_Position.z *= gl_Position.w;\\n\\t\\t}\\n\\t#endif\\n#endif\";\n\n\tvar map_fragment = \"#ifdef USE_MAP\\n\\tvec4 texelColor = texture2D( map, vUv );\\n\\ttexelColor = mapTexelToLinear( texelColor );\\n\\tdiffuseColor *= texelColor;\\n#endif\";\n\n\tvar map_pars_fragment = \"#ifdef USE_MAP\\n\\tuniform sampler2D map;\\n#endif\";\n\n\tvar map_particle_fragment = \"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\\n\\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\\n#endif\\n#ifdef USE_MAP\\n\\tvec4 mapTexel = texture2D( map, uv );\\n\\tdiffuseColor *= mapTexelToLinear( mapTexel );\\n#endif\\n#ifdef USE_ALPHAMAP\\n\\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\\n#endif\";\n\n\tvar map_particle_pars_fragment = \"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\\n\\tuniform mat3 uvTransform;\\n#endif\\n#ifdef USE_MAP\\n\\tuniform sampler2D map;\\n#endif\\n#ifdef USE_ALPHAMAP\\n\\tuniform sampler2D alphaMap;\\n#endif\";\n\n\tvar metalnessmap_fragment = \"float metalnessFactor = metalness;\\n#ifdef USE_METALNESSMAP\\n\\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\\n\\tmetalnessFactor *= texelMetalness.b;\\n#endif\";\n\n\tvar metalnessmap_pars_fragment = \"#ifdef USE_METALNESSMAP\\n\\tuniform sampler2D metalnessMap;\\n#endif\";\n\n\tvar morphnormal_vertex = \"#ifdef USE_MORPHNORMALS\\n\\tobjectNormal *= morphTargetBaseInfluence;\\n\\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\\n\\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\\n\\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\\n\\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\\n#endif\";\n\n\tvar morphtarget_pars_vertex = \"#ifdef USE_MORPHTARGETS\\n\\tuniform float morphTargetBaseInfluence;\\n\\t#ifndef USE_MORPHNORMALS\\n\\t\\tuniform float morphTargetInfluences[ 8 ];\\n\\t#else\\n\\t\\tuniform float morphTargetInfluences[ 4 ];\\n\\t#endif\\n#endif\";\n\n\tvar morphtarget_vertex = \"#ifdef USE_MORPHTARGETS\\n\\ttransformed *= morphTargetBaseInfluence;\\n\\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\\n\\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\\n\\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\\n\\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\\n\\t#ifndef USE_MORPHNORMALS\\n\\t\\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\\n\\t\\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\\n\\t\\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\\n\\t\\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\\n\\t#endif\\n#endif\";\n\n\tvar normal_fragment_begin = \"#ifdef FLAT_SHADED\\n\\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\\n\\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\\n\\tvec3 normal = normalize( cross( fdx, fdy ) );\\n#else\\n\\tvec3 normal = normalize( vNormal );\\n\\t#ifdef DOUBLE_SIDED\\n\\t\\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\\n\\t#endif\\n\\t#ifdef USE_TANGENT\\n\\t\\tvec3 tangent = normalize( vTangent );\\n\\t\\tvec3 bitangent = normalize( vBitangent );\\n\\t\\t#ifdef DOUBLE_SIDED\\n\\t\\t\\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\\n\\t\\t\\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\\n\\t\\t#endif\\n\\t\\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\\n\\t\\t\\tmat3 vTBN = mat3( tangent, bitangent, normal );\\n\\t\\t#endif\\n\\t#endif\\n#endif\\nvec3 geometryNormal = normal;\";\n\n\tvar normal_fragment_maps = \"#ifdef OBJECTSPACE_NORMALMAP\\n\\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\\n\\t#ifdef FLIP_SIDED\\n\\t\\tnormal = - normal;\\n\\t#endif\\n\\t#ifdef DOUBLE_SIDED\\n\\t\\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\\n\\t#endif\\n\\tnormal = normalize( normalMatrix * normal );\\n#elif defined( TANGENTSPACE_NORMALMAP )\\n\\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\\n\\tmapN.xy *= normalScale;\\n\\t#ifdef USE_TANGENT\\n\\t\\tnormal = normalize( vTBN * mapN );
1\\n\\t#else\\n\\t\\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\\n\\t#endif\\n#elif defined( USE_BUMPMAP )\\n\\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\\n#endif\";\n\n\tvar normalmap_pars_fragment = \"#ifdef USE_NORMALMAP\\n\\tuniform sampler2D normalMap;\\n\\tuniform vec2 normalScale;\\n#endif\\n#ifdef OBJECTSPACE_NORMALMAP\\n\\tuniform mat3 normalMatrix;\\n#endif\\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\\n\\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\\n\\t\\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\\n\\t\\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\\n\\t\\tvec2 st0 = dFdx( vUv.st );\\n\\t\\tvec2 st1 = dFdy( vUv.st );\\n\\t\\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\\n\\t\\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\\n\\t\\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\\n\\t\\tvec3 N = normalize( surf_norm );\\n\\t\\tmat3 tsn = mat3( S, T, N );\\n\\t\\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\\n\\t\\treturn normalize( tsn * mapN );\\n\\t}\\n#endif\";\n\n\tvar clearcoat_normal_fragment_begin = \"#ifdef CLEARCOAT\\n\\tvec3 clearcoatNormal = geometryNormal;\\n#endif\";\n\n\tvar clearcoat_normal_fragment_maps = \"#ifdef USE_CLEARCOAT_NORMALMAP\\n\\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\\n\\tclearcoatMapN.xy *= clearcoatNormalScale;\\n\\t#ifdef USE_TANGENT\\n\\t\\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\\n\\t#else\\n\\t\\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\\n\\t#endif\\n#endif\";\n\n\tvar clearcoat_pars_fragment = \"#ifdef USE_CLEARCOATMAP\\n\\tuniform sampler2D clearcoatMap;\\n#endif\\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\\n\\tuniform sampler2D clearcoatRoughnessMap;\\n#endif\\n#ifdef USE_CLEARCOAT_NORMALMAP\\n\\tuniform sampler2D clearcoatNormalMap;\\n\\tuniform vec2 clearcoatNormalScale;\\n#endif\";\n\n\tvar packing = \"vec3 packNormalToRGB( const in vec3 normal ) {\\n\\treturn normalize( normal ) * 0.5 + 0.5;\\n}\\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\\n\\treturn 2.0 * rgb.xyz - 1.0;\\n}\\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\\nconst float ShiftRight8 = 1. / 256.;\\nvec4 packDepthToRGBA( const in float v ) {\\n\\tvec4 r = vec4( fract( v * PackFactors ), v );\\n\\tr.yzw -= r.xyz * ShiftRight8;\\treturn r * PackUpscale;\\n}\\nfloat unpackRGBAToDepth( const in vec4 v ) {\\n\\treturn dot( v, UnpackFactors );\\n}\\nvec4 pack2HalfToRGBA( vec2 v ) {\\n\\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\\n\\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\\n}\\nvec2 unpackRGBATo2Half( vec4 v ) {\\n\\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\\n}\\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\\n\\treturn ( viewZ + near ) / ( near - far );\\n}\\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\\n\\treturn linearClipZ * ( near - far ) - near;\\n}\\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\\n\\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\\n}\\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\\n\\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\\n}\";\n\n\tvar premultiplied_alpha_fragment = \"#ifdef PREMULTIPLIED_ALPHA\\n\\tgl_FragColor.rgb *= gl_FragColor.a;\\n#endif\";\n\n\tvar project_vertex = \"vec4 mvPosition = vec4( transformed, 1.0 );\\n#ifdef USE_INSTANCING\\n\\tmvPosition = instanceMatrix * mvPosition;\\n#endif\\nmvPosition = modelViewMatrix * mvPosition;\\ngl_Position = projectionMatrix * mvPosition;\";\n\n\tvar dithering_fragment = \"#ifdef DITHERING\\n\\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\\n#endif\";\n\n\tvar dithering_pars_fragment = \"#ifdef DITHERING\\n\\tvec3 dithering( vec3 color ) {\\n\\t\\tfloat grid_position = rand( gl_FragCoord.xy );\\n\\t\\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\\n\\t\\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\\n\\t\\treturn color + dither_shift_RGB;\\n\\t}\\n#endif\";\n\n\tvar roughnessmap_fragment = \"float roughnessFactor = roughness;\\n#ifdef USE_ROUGHNESSMAP\\n\\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\\n\\troughnessFactor *= texelRoughness.g;\\n#endif\";\n\n\tvar roughnessmap_pars_fragment = \"#ifdef USE_ROUGHNESSMAP\\n\\tuniform sampler2D roughnessMap;\\n#endif\";\n\n\tvar shadowmap_pars_fragment = \"#ifdef USE_SHADOWMAP\\n\\t#if NUM_DIR_LIGHT_SHADOWS > 0\\n\\t\\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\\n\\t\\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1\\n\\t\\tstruct DirectionalLightShadow {\\n\\t\\t\\tfloat shadowBias;\\n\\t\\t\\tfloat shadowNormalBias;\\n\\t\\t\\tfloat shadowRadius;\\n\\t\\t\\tvec2 shadowMapSize;\\n\\t\\t};\\n\\t\\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\\n\\t#endif\\n\\t#if NUM_SPOT_LIGHT_SHADOWS > 0\\n\\t\\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\\n\\t\\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\\n\\t\\tstruct SpotLightShadow {\\n\\t\\t\\tfloat shadowBias;\\n\\t\\t\\tfloat shadowNormalBias;\\n\\t\\t\\tfloat shadowRadius;\\n\\t\\t\\tvec2 shadowMapSize;\\n\\t\\t};\\n\\t\\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\\n\\t#endif\\n\\t#if NUM_POINT_LIGHT_SHADOWS > 0\\n\\t\\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\\n\\t\\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\\n\\t\\tstruct PointLightShadow {\\n\\t\\t\\tfloat shadowBias;\\n\\t\\t\\tfloat shadowNormalBias;\\n\\t\\t\\tfloat shadowRadius;\\n\\t\\t\\tvec2 shadowMapSize;\\n\\t\\t\\tfloat shadowCameraNear;\\n\\t\\t\\tfloat shadowCameraFar;\\n\\t\\t};\\n\\t\\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\\n\\t#endif\\n\\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\\n\\t\\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\\n\\t}\\n\\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\\n\\t\\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\\n\\t}\\n\\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\\n\\t\\tfloat occlusion = 1.0;\\n\\t\\tvec2 distribution = texture2DDistribution( shadow, uv );\\n\\t\\tfloat hard_shadow = step( compare , distribution.x );\\n\\t\\tif (hard_shadow != 1.0 ) {\\n\\t\\t\\tfloat distance = compare - distribution.x ;\\n\\t\\t\\tfloat variance = max( 0.00000, distribution.y * distribution.y );\\n\\t\\t\\tfloat softness_probability = variance / (variance + distance * distance );\\t\\t\\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\\t\\t\\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\\n\\t\\t}\\n\\t\\treturn occlusion;\\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;
1\\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\\tfloat dx2 = dx0 / 2.0;\\n\\t\\t\\tfloat dy2 = dy0 / 2.0;\\n\\t\\t\\tfloat dx3 = dx1 / 2.0;\\n\\t\\t\\tfloat dy3 = dy1 / 2.0;\\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( dx2, dy2 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), 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( dx2, dy3 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), 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 / 17.0 );\\n\\t\\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\\n\\t\\t\\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\\n\\t\\t\\tfloat dx = texelSize.x;\\n\\t\\t\\tfloat dy = texelSize.y;\\n\\t\\t\\tvec2 uv = shadowCoord.xy;\\n\\t\\t\\tvec2 f = fract( uv * shadowMapSize + 0.5 );\\n\\t\\t\\tuv -= f * texelSize;\\n\\t\\t\\tshadow = (\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\\n\\t\\t\\t\\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \\n\\t\\t\\t\\t\\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\\n\\t\\t\\t\\t\\t f.x ) +\\n\\t\\t\\t\\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \\n\\t\\t\\t\\t\\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\\n\\t\\t\\t\\t\\t f.x ) +\\n\\t\\t\\t\\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \\n\\t\\t\\t\\t\\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\\n\\t\\t\\t\\t\\t f.y ) +\\n\\t\\t\\t\\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \\n\\t\\t\\t\\t\\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\\n\\t\\t\\t\\t\\t f.y ) +\\n\\t\\t\\t\\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \\n\\t\\t\\t\\t\\t\\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\\n\\t\\t\\t\\t\\t\\t\tf.x ),\\n\\t\\t\\t\\t\\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \\n\\t\\t\\t\\t\\t\\t\ttexture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\\n\\t\\t\\t\\t\\t\\t\tf.x ),\\n\\t\\t\\t\\t\\t f.y )\\n\\t\\t\\t) * ( 1.0 / 9.0 );\\n\\t\\t#elif defined( SHADOWMAP_TYPE_VSM )\\n\\t\\t\\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\\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 ) || defined( SHADOWMAP_TYPE_VSM )\\n\\t\\t\\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\\n\\t\\t\\treturn (\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\\n\\t\\t\\t\\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\\n\\t\\t\\t) * ( 1.0 / 9.0 );\\n\\t\\t#else\\n\\t\\t\\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\\n\\t\\t#endif\\n\\t}\\n#endif\";\n\n\tvar shadowmap_pars_vertex = \"#ifdef USE_SHADOWMAP\\n\\t#if NUM_DIR_LIGHT_SHADOWS > 0\\n\\t\\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\\n\\t\\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
1\\n\\t\\tstruct DirectionalLightShadow {\\n\\t\\t\\tfloat shadowBias;\\n\\t\\t\\tfloat shadowNormalBias;\\n\\t\\t\\tfloat shadowRadius;\\n\\t\\t\\tvec2 shadowMapSize;\\n\\t\\t};\\n\\t\\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\\n\\t#endif\\n\\t#if NUM_SPOT_LIGHT_SHADOWS > 0\\n\\t\\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\\n\\t\\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\\n\\t\\tstruct SpotLightShadow {\\n\\t\\t\\tfloat shadowBias;\\n\\t\\t\\tfloat shadowNormalBias;\\n\\t\\t\\tfloat shadowRadius;\\n\\t\\t\\tvec2 shadowMapSize;\\n\\t\\t};\\n\\t\\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\\n\\t#endif\\n\\t#if NUM_POINT_LIGHT_SHADOWS > 0\\n\\t\\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\\n\\t\\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\\n\\t\\tstruct PointLightShadow {\\n\\t\\t\\tfloat shadowBias;\\n\\t\\t\\tfloat shadowNormalBias;\\n\\t\\t\\tfloat shadowRadius;\\n\\t\\t\\tvec2 shadowMapSize;\\n\\t\\t\\tfloat shadowCameraNear;\\n\\t\\t\\tfloat shadowCameraFar;\\n\\t\\t};\\n\\t\\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\\n\\t#endif\\n#endif\";\n\n\tvar shadowmap_vertex = \"#ifdef USE_SHADOWMAP\\n\\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\\n\\t\\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\\n\\t\\tvec4 shadowWorldPosition;\\n\\t#endif\\n\\t#if NUM_DIR_LIGHT_SHADOWS > 0\\n\\t#pragma unroll_loop_start\\n\\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\\n\\t\\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\\n\\t\\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\\n\\t}\\n\\t#pragma unroll_loop_end\\n\\t#endif\\n\\t#if NUM_SPOT_LIGHT_SHADOWS > 0\\n\\t#pragma unroll_loop_start\\n\\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\\n\\t\\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\\n\\t\\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\\n\\t}\\n\\t#pragma unroll_loop_end\\n\\t#endif\\n\\t#if NUM_POINT_LIGHT_SHADOWS > 0\\n\\t#pragma unroll_loop_start\\n\\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\\n\\t\\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\\n\\t\\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\\n\\t}\\n\\t#pragma unroll_loop_end\\n\\t#endif\\n#endif\";\n\n\tvar shadowmask_pars_fragment = \"float getShadowMask() {\\n\\tfloat shadow = 1.0;\\n\\t#ifdef USE_SHADOWMAP\\n\\t#if NUM_DIR_LIGHT_SHADOWS > 0\\n\\tDirectionalLightShadow directionalLight;\\n\\t#pragma unroll_loop_start\\n\\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\\n\\t\\tdirectionalLight = directionalLightShadows[ i ];\\n\\t\\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\\n\\t}\\n\\t#pragma unroll_loop_end\\n\\t#endif\\n\\t#if NUM_SPOT_LIGHT_SHADOWS > 0\\n\\tSpotLightShadow spotLight;\\n\\t#pragma unroll_loop_start\\n\\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\\n\\t\\tspotLight = spotLightShadows[ i ];\\n\\t\\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\\n\\t}\\n\\t#pragma unroll_loop_end\\n\\t#endif\\n\\t#if NUM_POINT_LIGHT_SHADOWS > 0\\n\\tPointLightShadow pointLight;\\n\\t#pragma unroll_loop_start\\n\\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\\n\\t\\tpointLight = pointLightShadows[ i ];\\n\\t\\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\\n\\t}\\n\\t#pragma unroll_loop_end\\n\\t#endif\\n\\t#endif\\n\\treturn shadow;\\n}\";\n\n\tvar skinbase_vertex = \"#ifdef USE_SKINNING\\n\\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\\n\\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\\n\\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\\n\\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\\n#endif\";\n\n\tvar skinning_pars_vertex = \"#ifdef USE_SKINNING\\n\\tuniform mat4 bindMatrix;\\n\\tuniform mat4 bindMatrixInverse;\\n\\t#ifdef BONE_TEXTURE\\n\\t\\tuniform highp sampler2D boneTexture;\\n\\t\\tuniform int boneTextureSize;\\n\\t\\tmat4 getBoneMatrix( const in float i ) {\\n\\t\\t\\tfloat j = i * 4.0;\\n\\t\\t\\tfloat x = mod( j, float( boneTextureSize ) );\\n\\t\\t\\tfloat y = floor( j / float( boneTextureSize ) );\\n\\t\\t\\tfloat dx = 1.0 / float( boneTextureSize );\\n\\t\\t\\tfloat dy = 1.0 / float( boneTextureSize );\\n\\t\\t\\ty = dy * ( y + 0.5 );\\n\\t\\t\\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\\n\\t\\t\\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\\n\\t\\t\\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\\n\\t\\t\\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\\n\\t\\t\\tmat4 bone = mat4( v1, v2, v3, v4 );\\n\\t\\t\\treturn bone;\\n\\t\\t}\\n\\t#else\\n\\t\\tuniform mat4 boneMatrices[ MAX_BONES ];\\n\\t\\tmat4 getBoneMatrix( const in float i ) {\\n\\t\\t\\tmat4 bone = boneMatrices[ int(i) ];\\n\\t\\t\\treturn bone;\\n\\t\\t}\\n\\t#endif\\n#endif\";\n\n\tvar skinning_vertex = \"#ifdef USE_SKINNING\\n\\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\\n\\tvec4 skinned = vec4( 0.0 );\\n\\tskinned += boneMatX * skinVertex * skinWeight.x;\\n\\tskinned += boneMatY * skinVertex * skinWeight.y;\\n\\tskinned += boneMatZ * skinVertex * skinWeight.z;\\n\\tskinned += boneMatW * skinVertex * skinWeight.w;\\n\\ttransformed = ( bindMatrixInverse * skinned ).xyz;\\n#endif\";\n\n\tvar skinnormal_vertex = \"#ifdef USE_SKINNING\\n\\tmat4 skinMatrix = mat4( 0.0 );\\n\\tskinMatrix += skinWeight.x * boneMatX;\\n\\tskinMatrix += skinWeight.y * boneMatY;\\n\\tskinMatrix += skinWeight.z * boneMatZ;\\n\\tskinMatrix += skinWeight.w * boneMatW;\\n\\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\\n\\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\\n\\t#ifdef USE_TANGENT\\n\\t\\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\\n\\t#endif\\n#endif\";\n\n\tvar specularmap_fragment = \"float specularStrength;\\n#ifdef USE_SPECULARMAP\\n\\tvec4 texelSpecular = texture2D( specularMap, vUv );\\n\\tspecularStrength = texelSpecular.r;\\n#else\\n\\tspecularStrength = 1.0;\\n#endif\";\n\n\tvar specularmap_pars_fragment = \"#ifdef USE_SPECULARMAP\\n\\tuniform sampler2D specularMap;\\n#endif\";\n\n\tvar tonemapping_fragment = \"#if defined( TONE_MAPPING )\\n\\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\\n#endif\";\n\n\tvar tonemapping_pars_fragment = \"#ifndef saturate\\n#define saturate(a) clamp( a, 0.0, 1.0 )\\n#endif\\nuniform float toneMappingExposure;\\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}\\nvec3 OptimizedCineonToneMapping( vec3 color ) {\\n\\tcolor *= toneMappingExposure;\\n\\tcolor = max( vec3( 0.0 ), color - 0.004 );\\n\\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\\n}\\nvec3 RRTAndODTFit( vec3 v ) {\\n\\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\\n\\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\\n\\treturn a / b;\\n}\\nvec3 ACESFilmicToneMapping( vec3 color ) {\\n\\tconst mat3 ACESInputMat = mat3(\\n\\t\\tvec3( 0.59719, 0.07600, 0.02840 ),\\t\\tvec3( 0.35458, 0.90834, 0.13383 ),\\n\\t\\tvec3( 0.04823, 0.01566, 0.83777 )\\n\\t);\\n\\tconst mat3 ACESOutputMat = mat3(\\n\\t\\tvec3(\t1.60475, -0.10208, -0.00327 ),\\t\\tvec3( -0.53108,\t1.10813, -0.07276 ),\\n\\t\\tvec3( -0.07367, -0.00605,\t1.07602 )\\n\\t);\\n\\tcolor *= toneMappingExposure / 0.6;\\n\\tcolor = ACESInputMat * color;\\n\\tcolor = RRTAndODTFit( color );\\n\\tcolor = ACESOutputMat * color;\\n\\treturn saturate( color );\\n}\\nvec3 CustomToneMapping( vec3 color ) { return color; }\";\n\n\tvar transmissionmap_fragment = \"#ifdef USE_TRANSMISSIONMAP\\n\\ttotalTransmission *= texture2D( transmissionMap, vUv ).r;\\n#endif\";\n\n\tvar transmissionmap_pars_fragment = \"#ifdef USE_TRANSMISSIONMAP\\n\\tuniform sampler2D transmissionMap;\\n#endif\";\n\n\tvar uv_pars_fragment = \"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\\n\\tvarying vec2 vUv;\\n#endif\";\n\n\tvar uv_pars_vertex = \"#ifdef USE_UV\\n\\t#ifdef UVS_VERTEX_ONLY\\n\\t\\tvec2 vUv;\\n\\t#else\\n\\t\\tvarying vec2 vUv;\\n\\t#endif\\n\\tuniform mat3 uvTransform;\\n#endif\";\n\n\tvar uv_vertex = \"#ifdef USE_UV\\n\\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\\n#endif\";\n\n\tvar uv2_pars_fragment = \"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\\n\\tvarying vec2 vUv2;\\n#endif\";\n\n\tvar uv2_pars_vertex = \"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\\n\\tattribute vec2 uv2;\\n\\tvarying vec2 vUv2;\\n\\tuniform mat3 uv2Transform;\\n#endif\";\n\n\tvar uv2_vertex = \"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\\n\\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\\n#endif\";\n\n\tvar worldpos_vertex = \"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\\n\\tvec4 worldPosition = vec4( transformed, 1.0 );\\n\\t#ifdef USE_INSTANCING\\n\\t\\tworldPosition = instanceMatrix * worldPosition;\\n\\t#endif\\n\\tworldPosition = modelMatrix * worldPosition;\\n#endif\";\n\n\tvar background_frag = \"uniform sampler2D t2D;\\nvarying vec2 vUv;\\nvoid main() {\\n\\tvec4 texColor = texture2D( t2D, vUv );\\n\\tgl_FragColor = mapTexelToLinear( texColor );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n}\";\n\n\tvar background_vert = \"varying vec2 vUv;\\nuniform mat3 uvTransform;\\nvoid main() {\\n\\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\\n\\tgl_Position = vec4( position.xy, 1.0, 1.0 );\\n}\";\n\n\tvar cube_frag = \"#include <envmap_common_pars_fragment>\\nuniform float opacity;\\nvarying vec3 vWorldDirection;\\n#include <cube_uv_reflection_fragment>\\nvoid main() {\\n\\tvec3 vReflect = vWorldDirection;\\n\\t#include <envmap_fragment>\\n\\tgl_FragColor = envColor;\\n\\tgl_FragColor.a *= opacity;\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n}\";\n\n\tvar cube_vert = \"varying vec3 vWorldDirection;\\n#include <common>\\nvoid main() {\\n\\tvWorldDirection = transformDirection( position, modelMatrix );\\n\\t#include <begin_vertex>\\n\\t#include <project_vertex>\\n\\tgl_Position.z = gl_Position.w;\\n}\";\n\n\tvar depth_frag = \"#if DEPTH_PACKING == 3200\\n\\tuniform float opacity;\\n#endif\\n#include <common>\\n#include <packing>\\n#include <uv_pars_fragment>\\n#include <map_pars_fragment>\\n#include <alphamap_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvarying vec2 vHighPrecisionZW;\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tvec4 diffuseColor = vec4( 1.0 );\\n\\t#if DEPTH_PACKING == 3200\\n\\t\\tdiffuseColor.a = opacity;\\n\\t#endif\\n\\t#include <map_fragment>\\n\\t#include <alphamap_fragment>\\n\\t#include <alphatest_fragment>\\n\\t#include <logdepthbuf_fragment>\\n\\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\\n\\t#if DEPTH_PACKING == 3200\\n\\t\\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\\n\\t#elif DEPTH_PACKING == 3201\\n\\t\\tgl_FragColor = packDepthToRGBA( fragCoordZ );\\n\\t#endif\\n}\";\n\n\tvar depth_vert = \"#include <common>\\n#include <uv_pars_vertex>\\n#include <displacementmap_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <skinning_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvarying vec2 vHighPrecisionZW;\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#ifdef USE_DISPLACEMENTMAP\\n\\t\\t#include <beginnormal_vertex>\\n\\t\\t#include <morphnormal_vertex>\\n\\t\\t#include <skinnormal_vertex>\\n\\t#endif\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <skinning_vertex>\\n\\t#include <displacementmap_vertex>\\n\\t#include <project_vertex>\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\tvHighPrecisionZW = gl_Position.zw;\\n}\";\n\n\tvar distanceRGBA_frag = \"#define DISTANCE\\nuniform vec3 referencePosition;\\nuniform float nearDistance;\\nuniform float farDistance;\\nvarying vec3 vWorldPosition;\\n#include <common>\\n#include <packing>\\n#include <uv_pars_fragment>\\n#include <map_pars_fragment>\\n#include <alphamap_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main () {\\n\\t#include <clipping_planes_fragment>\\n\\tvec4 diffuseColor = vec4( 1.0 );\\n\\t#include <map_fragment>\\n\\t#include <alphamap_fragment>\\n\\t#include <alphatest_fragment>\\n\\tfloat dist = length( vWorldPosition - referencePosition );\\n\\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\\n\\tdist = saturate( dist );\\n\\tgl_FragColor = packDepthToRGBA( dist );\\n}\";\n\n\tvar distanceRGBA_vert = \"#define DISTANCE\\nvarying vec3 vWorldPosition;\\n#include <common>\\n#include <uv_pars_vertex>\\n#include <displacementmap_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <skinning_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#ifdef USE_DISPLACEMENTMAP\\n\\t\\t#include <beginnormal_vertex>\\n\\t\\t#include <morphnormal_vertex>\\n\\t\\t#include <skinnormal_vertex>\\n\\t#endif\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <skinning_vertex>\\n\\t#include <displacementmap_vertex>\\n\\t#include <project_vertex>\\n\\t#include <worldpos_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\tvWorldPosition = worldPosition.xyz;\\n}\";\n\n\tvar equirect_frag = \"uniform sampler2D tEquirect;\\nvarying vec3 vWorldDirection;\\n#include <common>\\nvoid main() {\\n\\tvec3 direction = normalize( vWorldDirection );\\n\\tvec2 sampleUV = equirectUv( direction );\\n\\tvec4 texColor = texture2D( tEquirect, sampleUV );\\n\\tgl_FragColor = mapTexelToLinear( texColor );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n}\";\n\n\tvar equirect_vert = \"varying vec3 vWorldDirection;\\n#include <common>\\nvoid main() {\\n\\tvWorldDirection = transformDirection( position, modelMatrix );\\n\\t#include <begin_vertex>\\n\\t#include <project_vertex>\\n}\";\n\n\tvar linedashed_frag = \"uniform vec3 diffuse;\\nuniform float opacity;\\nuniform float dashSize;\\nuniform float totalSize;\\nvarying float vLineDistance;\\n#include <common>\\n#include <color_pars_fragment>\\n#include <fog_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\\n\\t\\tdiscard;\\n\\t}\\n\\tvec3 outgoingLight = vec3( 0.0 );\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <color_fragment>\\n\\toutgoingLight = diffuseColor.rgb;\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n\\t#include <premultiplied_alpha_fragment>\\n}\";\n\n\tvar linedashed_vert = \"uniform float scale;\\nattribute float lineDistance;\\nvarying float vLineDistance;\\n#include <common>\\n#include <color_pars_vertex>\\n#include <fog_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\tvLineDistance = scale * lineDistance;\\n\\t#include <color_vertex>\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <project_vertex>\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\t#include <fog_vertex>\\n}\";\n\n\tvar meshbasic_fr
1ag = \"uniform vec3 diffuse;\\nuniform float opacity;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include <common>\\n#include <dithering_pars_fragment>\\n#include <color_pars_fragment>\\n#include <uv_pars_fragment>\\n#include <uv2_pars_fragment>\\n#include <map_pars_fragment>\\n#include <alphamap_pars_fragment>\\n#include <aomap_pars_fragment>\\n#include <lightmap_pars_fragment>\\n#include <envmap_common_pars_fragment>\\n#include <envmap_pars_fragment>\\n#include <cube_uv_reflection_fragment>\\n#include <fog_pars_fragment>\\n#include <specularmap_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <map_fragment>\\n\\t#include <color_fragment>\\n\\t#include <alphamap_fragment>\\n\\t#include <alphatest_fragment>\\n\\t#include <specularmap_fragment>\\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\t#ifdef USE_LIGHTMAP\\n\\t\\n\\t\\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\\n\\t\\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\\n\\t#else\\n\\t\\treflectedLight.indirectDiffuse += vec3( 1.0 );\\n\\t#endif\\n\\t#include <aomap_fragment>\\n\\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\\n\\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\\n\\t#include <envmap_fragment>\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n\\t#include <premultiplied_alpha_fragment>\\n\\t#include <dithering_fragment>\\n}\";\n\n\tvar meshbasic_vert = \"#include <common>\\n#include <uv_pars_vertex>\\n#include <uv2_pars_vertex>\\n#include <envmap_pars_vertex>\\n#include <color_pars_vertex>\\n#include <fog_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <skinning_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\t#include <uv2_vertex>\\n\\t#include <color_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#ifdef USE_ENVMAP\\n\\t#include <beginnormal_vertex>\\n\\t#include <morphnormal_vertex>\\n\\t#include <skinnormal_vertex>\\n\\t#include <defaultnormal_vertex>\\n\\t#endif\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <skinning_vertex>\\n\\t#include <project_vertex>\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <worldpos_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\t#include <envmap_vertex>\\n\\t#include <fog_vertex>\\n}\";\n\n\tvar meshlambert_frag = \"uniform vec3 diffuse;\\nuniform vec3 emissive;\\nuniform float opacity;\\nvarying vec3 vLightFront;\\nvarying vec3 vIndirectFront;\\n#ifdef DOUBLE_SIDED\\n\\tvarying vec3 vLightBack;\\n\\tvarying vec3 vIndirectBack;\\n#endif\\n#include <common>\\n#include <packing>\\n#include <dithering_pars_fragment>\\n#include <color_pars_fragment>\\n#include <uv_pars_fragment>\\n#include <uv2_pars_fragment>\\n#include <map_pars_fragment>\\n#include <alphamap_pars_fragment>\\n#include <aomap_pars_fragment>\\n#include <lightmap_pars_fragment>\\n#include <emissivemap_pars_fragment>\\n#include <envmap_common_pars_fragment>\\n#include <envmap_pars_fragment>\\n#include <cube_uv_reflection_fragment>\\n#include <bsdfs>\\n#include <lights_pars_begin>\\n#include <fog_pars_fragment>\\n#include <shadowmap_pars_fragment>\\n#include <shadowmask_pars_fragment>\\n#include <specularmap_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\tvec3 totalEmissiveRadiance = emissive;\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <map_fragment>\\n\\t#include <color_fragment>\\n\\t#include <alphamap_fragment>\\n\\t#include <alphatest_fragment>\\n\\t#include <specularmap_fragment>\\n\\t#include <emissivemap_fragment>\\n\\t#ifdef DOUBLE_SIDED\\n\\t\\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\\n\\t#else\\n\\t\\treflectedLight.indirectDiffuse += vIndirectFront;\\n\\t#endif\\n\\t#include <lightmap_fragment>\\n\\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\\n\\t#ifdef DOUBLE_SIDED\\n\\t\\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\\n\\t#else\\n\\t\\treflectedLight.directDiffuse = vLightFront;\\n\\t#endif\\n\\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\\n\\t#include <aomap_fragment>\\n\\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\\n\\t#include <envmap_fragment>\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n\\t#include <premultiplied_alpha_fragment>\\n\\t#include <dithering_fragment>\\n}\";\n\n\tvar meshlambert_vert = \"#define LAMBERT\\nvarying vec3 vLightFront;\\nvarying vec3 vIndirectFront;\\n#ifdef DOUBLE_SIDED\\n\\tvarying vec3 vLightBack;\\n\\tvarying vec3 vIndirectBack;\\n#endif\\n#include <common>\\n#include <uv_pars_vertex>\\n#include <uv2_pars_vertex>\\n#include <envmap_pars_vertex>\\n#include <bsdfs>\\n#include <lights_pars_begin>\\n#include <color_pars_vertex>\\n#include <fog_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <skinning_pars_vertex>\\n#include <shadowmap_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\t#include <uv2_vertex>\\n\\t#include <color_vertex>\\n\\t#include <beginnormal_vertex>\\n\\t#include <morphnormal_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#include <skinnormal_vertex>\\n\\t#include <defaultnormal_vertex>\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <skinning_vertex>\\n\\t#include <project_vertex>\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\t#include <worldpos_vertex>\\n\\t#include <envmap_vertex>\\n\\t#include <lights_lambert_vertex>\\n\\t#include <shadowmap_vertex>\\n\\t#include <fog_vertex>\\n}\";\n\n\tvar meshmatcap_frag = \"#define MATCAP\\nuniform vec3 diffuse;\\nuniform float opacity;\\nuniform sampler2D matcap;\\nvarying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include <common>\\n#include <dithering_pars_fragment>\\n#include <color_pars_fragment>\\n#include <uv_pars_fragment>\\n#include <map_pars_fragment>\\n#include <alphamap_pars_fragment>\\n#include <fog_pars_fragment>\\n#include <bumpmap_pars_fragment>\\n#include <normalmap_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <map_fragment>\\n\\t#include <color_fragment>\\n\\t#include <alphamap_fragment>\\n\\t#include <alphatest_fragment>\\n\\t#include <normal_fragment_begin>\\n\\t#include <normal_fragment_maps>\\n\\tvec3 viewDir = normalize( vViewPosition );\\n\\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\\n\\tvec3 y = cross( viewDir, x );\\n\\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
1\\n\\t#ifdef USE_MATCAP\\n\\t\\tvec4 matcapColor = texture2D( matcap, uv );\\n\\t\\tmatcapColor = matcapTexelToLinear( matcapColor );\\n\\t#else\\n\\t\\tvec4 matcapColor = vec4( 1.0 );\\n\\t#endif\\n\\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n\\t#include <premultiplied_alpha_fragment>\\n\\t#include <dithering_fragment>\\n}\";\n\n\tvar meshmatcap_vert = \"#define MATCAP\\nvarying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include <common>\\n#include <uv_pars_vertex>\\n#include <color_pars_vertex>\\n#include <displacementmap_pars_vertex>\\n#include <fog_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <skinning_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\t#include <color_vertex>\\n\\t#include <beginnormal_vertex>\\n\\t#include <morphnormal_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#include <skinnormal_vertex>\\n\\t#include <defaultnormal_vertex>\\n\\t#ifndef FLAT_SHADED\\n\\t\\tvNormal = normalize( transformedNormal );\\n\\t#endif\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <skinning_vertex>\\n\\t#include <displacementmap_vertex>\\n\\t#include <project_vertex>\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\t#include <fog_vertex>\\n\\tvViewPosition = - mvPosition.xyz;\\n}\";\n\n\tvar meshtoon_frag = \"#define TOON\\nuniform vec3 diffuse;\\nuniform vec3 emissive;\\nuniform float opacity;\\n#include <common>\\n#include <packing>\\n#include <dithering_pars_fragment>\\n#include <color_pars_fragment>\\n#include <uv_pars_fragment>\\n#include <uv2_pars_fragment>\\n#include <map_pars_fragment>\\n#include <alphamap_pars_fragment>\\n#include <aomap_pars_fragment>\\n#include <lightmap_pars_fragment>\\n#include <emissivemap_pars_fragment>\\n#include <gradientmap_pars_fragment>\\n#include <fog_pars_fragment>\\n#include <bsdfs>\\n#include <lights_pars_begin>\\n#include <lights_toon_pars_fragment>\\n#include <shadowmap_pars_fragment>\\n#include <bumpmap_pars_fragment>\\n#include <normalmap_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\tvec3 totalEmissiveRadiance = emissive;\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <map_fragment>\\n\\t#include <color_fragment>\\n\\t#include <alphamap_fragment>\\n\\t#include <alphatest_fragment>\\n\\t#include <normal_fragment_begin>\\n\\t#include <normal_fragment_maps>\\n\\t#include <emissivemap_fragment>\\n\\t#include <lights_toon_fragment>\\n\\t#include <lights_fragment_begin>\\n\\t#include <lights_fragment_maps>\\n\\t#include <lights_fragment_end>\\n\\t#include <aomap_fragment>\\n\\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n\\t#include <premultiplied_alpha_fragment>\\n\\t#include <dithering_fragment>\\n}\";\n\n\tvar meshtoon_vert = \"#define TOON\\nvarying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include <common>\\n#include <uv_pars_vertex>\\n#include <uv2_pars_vertex>\\n#include <displacementmap_pars_vertex>\\n#include <color_pars_vertex>\\n#include <fog_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <skinning_pars_vertex>\\n#include <shadowmap_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\t#include <uv2_vertex>\\n\\t#include <color_vertex>\\n\\t#include <beginnormal_vertex>\\n\\t#include <morphnormal_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#include <skinnormal_vertex>\\n\\t#include <defaultnormal_vertex>\\n#ifndef FLAT_SHADED\\n\\tvNormal = normalize( transformedNormal );\\n#endif\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <skinning_vertex>\\n\\t#include <displacementmap_vertex>\\n\\t#include <project_vertex>\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\tvViewPosition = - mvPosition.xyz;\\n\\t#include <worldpos_vertex>\\n\\t#include <shadowmap_vertex>\\n\\t#include <fog_vertex>\\n}\";\n\n\tvar meshphong_frag = \"#define PHONG\\nuniform vec3 diffuse;\\nuniform vec3 emissive;\\nuniform vec3 specular;\\nuniform float shininess;\\nuniform float opacity;\\n#include <common>\\n#include <packing>\\n#include <dithering_pars_fragment>\\n#include <color_pars_fragment>\\n#include <uv_pars_fragment>\\n#include <uv2_pars_fragment>\\n#include <map_pars_fragment>\\n#include <alphamap_pars_fragment>\\n#include <aomap_pars_fragment>\\n#include <lightmap_pars_fragment>\\n#include <emissivemap_pars_fragment>\\n#include <envmap_common_pars_fragment>\\n#include <envmap_pars_fragment>\\n#include <cube_uv_reflection_fragment>\\n#include <fog_pars_fragment>\\n#include <bsdfs>\\n#include <lights_pars_begin>\\n#include <lights_phong_pars_fragment>\\n#include <shadowmap_pars_fragment>\\n#include <bumpmap_pars_fragment>\\n#include <normalmap_pars_fragment>\\n#include <specularmap_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\tvec3 totalEmissiveRadiance = emissive;\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <map_fragment>\\n\\t#include <color_fragment>\\n\\t#include <alphamap_fragment>\\n\\t#include <alphatest_fragment>\\n\\t#include <specularmap_fragment>\\n\\t#include <normal_fragment_begin>\\n\\t#include <normal_fragment_maps>\\n\\t#include <emissivemap_fragment>\\n\\t#include <lights_phong_fragment>\\n\\t#include <lights_fragment_begin>\\n\\t#include <lights_fragment_maps>\\n\\t#include <lights_fragment_end>\\n\\t#include <aomap_fragment>\\n\\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\\n\\t#include <envmap_fragment>\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n\\t#include <premultiplied_alpha_fragment>\\n\\t#include <dithering_fragment>\\n}\";\n\n\tvar meshphong_vert = \"#define PHONG\\nvarying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n#endif\\n#include <common>\\n#include <uv_pars_vertex>\\n#include <uv2_pars_vertex>\\n#include <displacementmap_pars_vertex>\\n#include <envmap_pars_vertex>\\n#include <color_pars_vertex>\\n#include <fog_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <skinning_pars_vertex>\\n#include <shadowmap_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\t#include <uv2_vertex>\\n\\t#include <color_vertex>\\n\\t#include <beginnormal_vertex>\\n\\t#include <morphnormal_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#include <skinnormal_vertex>\\n\\t#include <defaultnormal_vertex>\\n#ifndef FLAT_SHADED\\n\\tvNormal = normalize( transformedNormal );\\n#endif\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <skinning_vertex>\\n\\t#include <displacementmap_vertex>\\n\\t#include <project_vertex>\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\tvViewPosition = - mvPosition.xyz;\\n\\t#include <worldpos_vertex>\\n\\t#include <envmap_vertex>\\n\\t#include <shadowmap_vertex>\\n\\t#include <fog_vertex>\\n}\";\n\n\tvar meshphysical_frag = \"#define STANDARD\\n#ifdef PHYSICAL\\n\\t#define REFLECTIVITY\\n\\t#define CLEARCOAT\\n\\t#define TRANSMISSION\\n#endif\\nuniform vec3 diffuse;\\nuniform vec3 emissive;\\nuniform float roughness;\\nuniform float metalness;\\nuniform float opacity;\\n#ifdef TRANSMISSION\\n\\tuniform float transmission;\\n#endif\\n#ifdef REFLECTIVITY\\n\\tuniform float reflectivity;\\n#endif\\n#ifdef CLEARCOAT\\n\\tuniform float clearcoat;\\n\\tuniform float clearcoatRoughness;\\n#endif\\n#ifdef USE_SHEEN\\n\\tuniform vec3 sheen;\\n#endif\\nvarying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n\\t#ifdef USE_TANGENT\\n\\t\\tvarying vec3 vTangent;\\n\\t\\tvarying vec3 vBitangent;\\n\\t#endif\\n#endif\\n#include <common>\\n#include <packing>\\n#include <dithering_pars_fragment>\\n#include <color_pars_fragment>\\n#include <uv_pars_fragment>\\n#include <uv2_pars_fragment>\\n#include <map_pars_fragment>\\n#include <alphamap_pars_fragment>\\n#include <aomap_pars_fragment>\\n#include <lightmap_pars_fragment>\\n#include <emissivemap_pars_fragment>\\n#include <transmissionmap_pars_fragment>\\n#include <bsdfs>\\n#include <cube_uv_reflection_fragment>\\n#include <envmap_common_pars_fragment>\\n#include <envmap_physical_pars_fragment>\\n#include <fog_pars_fragment>\\n#include <lights_pars_begin>\\n#include <lights_physical_pars_fragment>\\n#include <shadowmap_pars_fragment>\\n#include <bumpmap_pars_fragment>\\n#include <normalmap_pars_fragment>\\n#include <clearcoat_pars_fragment>\\n#include <roughnessmap_pars_fragment>\\n#include <metalnessmap_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\\n\\tvec3 totalEmissiveRadiance = emissive;\\n\\t#ifdef TRANSMISSION\\n\\t\\tfloat totalTransmission = transmission;\\n\\t#endif\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <map_fragment>\\n\\t#include <color_fragment>\\n\\t#include <alphamap_fragment>\\n\\t#include <alphatest_fragment>\\n\\t#include <roughnessmap_fragment>\\n\\t#include <metalnessmap_fragment>\\n\\t#include <normal_fragment_begin>\\n\\t#include <normal_fragment_maps>\\n\\t#include <clearcoat_normal_fragment_begin>\\n\\t#include <clearcoat_normal_fragment_maps>\\n\\t#include <emissivemap_fragment>\\n\\t#include <transmissionmap_fragment>\\n\\t#include <lights_physical_fragment>\\n\\t#include <lights_fragment_begin>\\n\\t#include <lights_fragment_maps>\\n\\t#include <lights_fragment_end>\\n\\t#include <aomap_fragment>\\n\\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\\n\\t#ifdef TRANSMISSION\\n\\t\\tdiffuseColor.a *= mix( saturate( 1. - totalTransmission + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) ), 1.0, metalness );\\n\\t#endif\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n\\t#include <premultiplied_alpha_fragment>\\n\\t#include <dithering_fragment>\\n}\";\n\n\tvar meshphysical_vert = \"#define STANDARD\\nvarying vec3 vViewPosition;\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n\\t#ifdef USE_TANGENT\\n\\t\\tvarying vec3 vTangent;\\n\\t\\tvarying vec3 vBitangent;\\n\\t#endif\\n#endif\\n#include <common>\\n#include <uv_pars_vertex>\\n#include <uv2_pars_vertex>\\n#include <displacementmap_pars_vertex>\\n#include <color_pars_vertex>\\n#include <fog_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <skinning_pars_vertex>\\n#include <shadowmap_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\t#include <uv2_vertex>\\n\\t#include <color_vertex>\\n\\t#include <beginnormal_vertex>\\n\\t#include <morphnormal_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#include <skinnormal_vertex>\\n\\t#include <defaultnormal_vertex>\\n#ifndef FLAT_SHADED\\n\\tvNormal = normalize( transformedNormal );\\n\\t#ifdef USE_TANGENT\\n\\t\\tvTangent = normalize( transformedTangent );\\n\\t\\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\\n\\t#endif\\n#endif\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <skinning_vertex>\\n\\t#include <displacementmap_vertex>\\n\\t#include <project_vertex>\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\tvViewPosition = - mvPosition.xyz;\\n\\t#include <worldpos_vertex>\\n\\t#include <shadowmap_vertex>\\n\\t#include <fog_vertex>\\n}\";\n\n\tvar normal_frag = \"#define NORMAL\\nuniform float opacity;\\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\\n\\tvarying vec3 vViewPosition;\\n#endif\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n\\t#ifdef USE_TANGENT\\n\\t\\tvarying vec3 vTangent;\\n\\t\\tvarying vec3 vBitangent;\\n\\t#endif\\n#endif\\n#include <packing>\\n#include <uv_pars_fragment>\\n#include <bumpmap_pars_fragment>\\n#include <normalmap_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <normal_fragment_begin>\\n\\t#include <normal_fragment_maps>\\n\\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\\n}\";\n\n\tvar normal_vert = \"#define NORMAL\\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\\n\\tvarying vec3 vViewPosition;\\n#endif\\n#ifndef FLAT_SHADED\\n\\tvarying vec3 vNormal;\\n\\t#ifdef USE_TANGENT\\n\\t\\tvarying vec3 vTangent;\\n\\t\\tvarying vec3 vBitangent;\\n\\t#endif\\n#endif\\n#include <common>\\n#include <uv_pars_vertex>\\n#include <displacementmap_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <skinning_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\t#include <beginnormal_vertex>\\n\\t#include <morphnormal_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#include <skinnormal_vertex>\\n\\t#include <defaultnormal_vertex>\\n#ifndef FLAT_SHADED\\n\\tvNormal = normalize( transformedNormal );\\n\\t#ifdef USE_TANGENT\\n\\t\\tvTangent = normalize( transformedTangent );\\n\\t\\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\\n\\t#endif\\n#endif\\n\\t#include <begin_vertex>\\n\\t#include <morphtarget_vertex>\\n\\t#include <skinning_vertex>\\n\\t#include <displacementmap_vertex>\\n\\t#include <project_vertex>\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\\n\\tvViewPosition = - mvPosition.xyz;\\n#endif\\n}\";\n\n\tvar points_frag = \"uniform vec3 diffuse;\\nuniform float opacity;\\n#include <common>\\n#include <color_pars_fragment>\\n#include <map_particle_pars_fragment>\\n#include <fog_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tvec3 outgoingLight = vec3( 0.0 );\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <map_particle_fragment>\\n\\t#include <color_fragment>\\n\\t#include <alphatest_fragment>\\n\\toutgoingLight = diffuseColor.rgb;\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n\\t#include <premultiplied_alpha_fragment>\\n}\";\n\n\tvar points_vert = \"uniform float size;\\nuniform float scale;\\n#include <common>\\n#include <color_pars_vertex>\\n#include <fog_pars_vertex>\\n#include <morphtarget_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <color_vertex>\\n\\t#include <begin_vertex>\\n\\t#include <morp
1htarget_vertex>\\n\\t#include <project_vertex>\\n\\tgl_PointSize = size;\\n\\t#ifdef USE_SIZEATTENUATION\\n\\t\\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\\n\\t\\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\\n\\t#endif\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\t#include <worldpos_vertex>\\n\\t#include <fog_vertex>\\n}\";\n\n\tvar shadow_frag = \"uniform vec3 color;\\nuniform float opacity;\\n#include <common>\\n#include <packing>\\n#include <fog_pars_fragment>\\n#include <bsdfs>\\n#include <lights_pars_begin>\\n#include <shadowmap_pars_fragment>\\n#include <shadowmask_pars_fragment>\\nvoid main() {\\n\\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n}\";\n\n\tvar shadow_vert = \"#include <common>\\n#include <fog_pars_vertex>\\n#include <shadowmap_pars_vertex>\\nvoid main() {\\n\\t#include <begin_vertex>\\n\\t#include <project_vertex>\\n\\t#include <worldpos_vertex>\\n\\t#include <beginnormal_vertex>\\n\\t#include <morphnormal_vertex>\\n\\t#include <skinbase_vertex>\\n\\t#include <skinnormal_vertex>\\n\\t#include <defaultnormal_vertex>\\n\\t#include <shadowmap_vertex>\\n\\t#include <fog_vertex>\\n}\";\n\n\tvar sprite_frag = \"uniform vec3 diffuse;\\nuniform float opacity;\\n#include <common>\\n#include <uv_pars_fragment>\\n#include <map_pars_fragment>\\n#include <alphamap_pars_fragment>\\n#include <fog_pars_fragment>\\n#include <logdepthbuf_pars_fragment>\\n#include <clipping_planes_pars_fragment>\\nvoid main() {\\n\\t#include <clipping_planes_fragment>\\n\\tvec3 outgoingLight = vec3( 0.0 );\\n\\tvec4 diffuseColor = vec4( diffuse, opacity );\\n\\t#include <logdepthbuf_fragment>\\n\\t#include <map_fragment>\\n\\t#include <alphamap_fragment>\\n\\t#include <alphatest_fragment>\\n\\toutgoingLight = diffuseColor.rgb;\\n\\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\\n\\t#include <tonemapping_fragment>\\n\\t#include <encodings_fragment>\\n\\t#include <fog_fragment>\\n}\";\n\n\tvar sprite_vert = \"uniform float rotation;\\nuniform vec2 center;\\n#include <common>\\n#include <uv_pars_vertex>\\n#include <fog_pars_vertex>\\n#include <logdepthbuf_pars_vertex>\\n#include <clipping_planes_pars_vertex>\\nvoid main() {\\n\\t#include <uv_vertex>\\n\\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\\n\\tvec2 scale;\\n\\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\\n\\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\\n\\t#ifndef USE_SIZEATTENUATION\\n\\t\\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\\n\\t\\tif ( isPerspective ) scale *= - mvPosition.z;\\n\\t#endif\\n\\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\\n\\tvec2 rotatedPosition;\\n\\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\\n\\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\\n\\tmvPosition.xy += rotatedPosition;\\n\\tgl_Position = projectionMatrix * mvPosition;\\n\\t#include <logdepthbuf_vertex>\\n\\t#include <clipping_planes_vertex>\\n\\t#include <fog_vertex>\\n}\";\n\n\tvar ShaderChunk = {\n\t\talphamap_fragment: alphamap_fragment,\n\t\talphamap_pars_fragment: alphamap_pars_fragment,\n\t\talphatest_fragment: alphatest_fragment,\n\t\taomap_fragment: aomap_fragment,\n\t\taomap_pars_fragment: aomap_pars_fragment,\n\t\tbegin_vertex: begin_vertex,\n\t\tbeginnormal_vertex: beginnormal_vertex,\n\t\tbsdfs: bsdfs,\n\t\tbumpmap_pars_fragment: bumpmap_pars_fragment,\n\t\tclipping_planes_fragment: clipping_planes_fragment,\n\t\tclipping_planes_pars_fragment: clipping_planes_pars_fragment,\n\t\tclipping_planes_pars_vertex: clipping_planes_pars_vertex,\n\t\tclipping_planes_vertex: clipping_planes_vertex,\n\t\tcolor_fragment: color_fragment,\n\t\tcolor_pars_fragment: color_pars_fragment,\n\t\tcolor_pars_vertex: color_pars_vertex,\n\t\tcolor_vertex: color_vertex,\n\t\tcommon: common,\n\t\tcube_uv_reflection_fragment: cube_uv_reflection_fragment,\n\t\tdefaultnormal_vertex: defaultnormal_vertex,\n\t\tdisplacementmap_pars_vertex: displacementmap_pars_vertex,\n\t\tdisplacementmap_vertex: displacementmap_vertex,\n\t\temissivemap_fragment: emissivemap_fragment,\n\t\temissivemap_pars_fragment: emissivemap_pars_fragment,\n\t\tencodings_fragment: encodings_fragment,\n\t\tencodings_pars_fragment: encodings_pars_fragment,\n\t\tenvmap_fragment: envmap_fragment,\n\t\tenvmap_common_pars_fragment: envmap_common_pars_fragment,\n\t\tenvmap_pars_fragment: envmap_pars_fragment,\n\t\tenvmap_pars_vertex: envmap_pars_vertex,\n\t\tenvmap_physical_pars_fragment: envmap_physical_pars_fragment,\n\t\tenvmap_vertex: envmap_vertex,\n\t\tfog_vertex: fog_vertex,\n\t\tfog_pars_vertex: fog_pars_vertex,\n\t\tfog_fragment: fog_fragment,\n\t\tfog_pars_fragment: fog_pars_fragment,\n\t\tgradientmap_pars_fragment: gradientmap_pars_fragment,\n\t\tlightmap_fragment: lightmap_fragment,\n\t\tlightmap_pars_fragment: lightmap_pars_fragment,\n\t\tlights_lambert_vertex: lights_lambert_vertex,\n\t\tlights_pars_begin: lights_pars_begin,\n\t\tlights_toon_fragment: lights_toon_fragment,\n\t\tlights_toon_pars_fragment: lights_toon_pars_fragment,\n\t\tlights_phong_fragment: lights_phong_fragment,\n\t\tlights_phong_pars_fragment: lights_phong_pars_fragment,\n\t\tlights_physical_fragment: lights_physical_fragment,\n\t\tlights_physical_pars_fragment: lights_physical_pars_fragment,\n\t\tlights_fragment_begin: lights_fragment_begin,\n\t\tlights_fragment_maps: lights_fragment_maps,\n\t\tlights_fragment_end: lights_fragment_end,\n\t\tlogdepthbuf_fragment: logdepthbuf_fragment,\n\t\tlogdepthbuf_pars_fragment: logdepthbuf_pars_fragment,\n\t\tlogdepthbuf_pars_vertex: logdepthbuf_pars_vertex,\n\t\tlogdepthbuf_vertex: logdepthbuf_vertex,\n\t\tmap_fragment: map_fragment,\n\t\tmap_pars_fragment: map_pars_fragment,\n\t\tmap_particle_fragment: map_particle_fragment,\n\t\tmap_particle_pars_fragment: map_particle_pars_fragment,\n\t\tmetalnessmap_fragment: metalnessmap_fragment,\n\t\tmetalnessmap_pars_fragment: metalnessmap_pars_fragment,\n\t\tmorphnormal_vertex: morphnormal_vertex,\n\t\tmorphtarget_pars_vertex: morphtarget_pars_vertex,\n\t\tmorphtarget_vertex: morphtarget_vertex,\n\t\tnormal_fragment_begin: normal_fragment_begin,\n\t\tnormal_fragment_maps: normal_fragment_maps,\n\t\tnormalmap_pars_fragment: normalmap_pars_fragment,\n\t\tclearcoat_normal_fragment_begin: clearcoat_normal_fragment_begin,\n\t\tclearcoat_normal_fragment_maps: clearcoat_normal_fragment_maps,\n\t\tclearcoat_pars_fragment: clearcoat_pars_fragment,\n\t\tpacking: packing,\n\t\tpremultiplied_alpha_fragment: premultiplied_alpha_fragment,\n\t\tproject_vertex: project_vertex,\n\t\tdithering_fragment: dithering_fragment,\n\t\tdithering_pars_fragment: dithering_pars_fragment,\n\t\troughnessmap_fragment: roughnessmap_fragment,\n\t\troughnessmap_pars_fragment: roughnessmap_pars_fragment,\n\t\tshadowmap_pars_fragment: shadowmap_pars_fragment,\n\t\tshadowmap_pars_vertex: shadowmap_pars_vertex,\n\t\tshadowmap_vertex: shadowmap_vertex,\n\t\tshadowmask_pars_fragment: shadowmask_pars_fragment,\n\t\tskinbase_vertex: skinbase_vertex,\n\t\tskinning_pars_vertex: skinning_pars_vertex,\n\t\tskinning_vertex: skinning_vertex,\n\t\tskinnormal_vertex: skinnormal_vertex,\n\t\tspecularmap_fragment: specularmap_fragment,\n\t\tspecularmap_pars_fragment: specularmap_pars_fragment,\n\t\ttonemapping_fragment: tonemapping_fragment,\n\t\ttonemapping_pars_fragment: tonemapping_pars_fragment,\n\t\ttransmissionmap_fragment: transmissionmap_fragment,\n\t\ttransmissionmap_pars_fragment: transmissionmap_pars_fragment,\n\t\tuv_pars_fragment: uv_pars_fragment,\n\t\tuv_pars_vertex: uv_pars_vertex,\n\t\tuv_vertex: uv_vertex,\n\t\tuv2_pars_fragment: uv2_pars_fragment,\n\t\tuv2_pars_vertex: uv2_pars_vertex,\n\t\tuv2_vertex: uv2_vertex,\n\t\tworldpos_vertex: worldpos_vertex,\n\t\tbackground_frag: background_frag,\n\t\tbackground_vert: background_vert,\n\t\tcube_frag: cube_frag,\n\t\tcube_vert: cube_vert,\n\t\tdepth_frag: depth_frag,\n\t\tdepth_vert: depth_vert,\n\t\tdistanceRGBA_frag: distanceRGBA_frag,\n\t\tdistanceRGBA_vert: distanceRGBA_vert,\n\t\tequirect_frag: equirect_frag,\n\t\tequirect_vert: equirect_vert,\n\t\tlinedashed_frag: linedashed_frag,\n\t\tlinedashed_vert: linedashed_vert,\n\t\tmeshbasic_frag: meshbasic_frag,\n\t\tmeshbasic_vert: meshbasic_vert,\n\t\tmeshlambert_frag: meshlambert_frag,\n\t\tmeshlambert_vert: meshlambert_vert,\n\t\tmeshmatcap_frag: meshmatcap_frag,\n\t\tmeshmatcap_vert: meshmatcap_vert,\n\t\tmeshtoon_frag: meshtoon_frag,\n\t\tmeshtoon_vert: meshtoon_vert,\n\t\tmeshphong_frag: meshphong_frag,\n\t\tmeshphong_vert: meshphong_vert,\n\t\tmeshphysical_frag: meshphysical_frag,\n\t\tmeshphysical_vert: meshphysical_vert,\n\t\tnormal_frag: normal_frag,\n\t\tnormal_vert: normal_vert,\n\t\tpoints_frag: points_frag,\n\t\tpoints_vert: points_vert,\n\t\tshadow_frag: shadow_frag,\n\t\tshadow_vert: shadow_vert,\n\t\tsprite_frag: sprite_frag,\n\t\tsprite_vert: sprite_vert\n\t};\n\n\t/**\n\t * Uniforms library for shared webgl shaders\n\t */\n\n\tvar UniformsLib = {\n\t\tcommon: {\n\t\t\tdiffuse: {\n\t\t\t\tvalue: new Color(0xeeeeee)\n\t\t\t},\n\t\t\topacity: {\n\t\t\t\tvalue: 1.0\n\t\t\t},\n\t\t\tmap: {\n\t\t\t\tvalue: null\n\t\t\t},\n\t\t\tuvTransform: {\n\t\t\t\tvalue: new Matrix3()\n\t\t\t},\n\t\t\tuv2Transform: {\n\t\t\t\tvalue: new Matrix3()\n\t\t\t},\n\t\t\talphaMap: {\n\t\t\t\tvalue: null\n\t\t\t}\n\t\t},\n\t\tspecularmap: {\n\t\t\tspecularMap: {\n\t\t\t\tvalue: null\n\t\t\t}\n\t\t},\n\t\tenvmap: {\n\t\t\tenvMap: {\n\t\t\t\tvalue: null\n\t\t\t},\n\t\t\tflipEnvMap: {\n\t\t\t\tvalue: -1\n\t\t\t},\n\t\t\treflectivity: {\n\t\t\t\tvalue: 1.0\n\t\t\t},\n\t\t\trefractionRatio: {\n\t\t\t\tvalue: 0.98\n\t\t\t},\n\t\t\tmaxMipLevel: {\n\t\t\t\tvalue: 0\n\t\t\t}\n\t\t},\n\t\taomap: {\n\t\t\taoMap: {\n\t\t\t\tvalue: null\n\t\t\t},\n\t\t\taoMapIntensity: {\n\t\t\t\tvalue: 1\n\t\t\t}\n\t\t},\n\t\tlightmap: {\n\t\t\tlightMap: {\n\t\t\t\tvalue: null\n\t\t\t},\n\t\t\tlightMapIntensity: {\n\t\t\t\tvalue: 1\n\t\t\t}\n\t\t},\n\t\temissivemap: {\n\t\t\temissiveMap: {\n\t\t\t\tvalue: null\n\t\t\t}\n\t\t},\n\t\tbumpmap: {\n\t\t\tbumpMap: {\n\t\t\t\tvalue: null\n\t\t\t}
1,\n\t\t\tbumpScale: {\n\t\t\t\tvalue: 1\n\t\t\t}\n\t\t},\n\t\tnormalmap: {\n\t\t\tnormalMap: {\n\t\t\t\tvalue: null\n\t\t\t},\n\t\t\tnormalScale: {\n\t\t\t\tvalue: new Vector2(1, 1)\n\t\t\t}\n\t\t},\n\t\tdisplacementmap: {\n\t\t\tdisplacementMap: {\n\t\t\t\tvalue: null\n\t\t\t},\n\t\t\tdisplacementScale: {\n\t\t\t\tvalue: 1\n\t\t\t},\n\t\t\tdisplacementBias: {\n\t\t\t\tvalue: 0\n\t\t\t}\n\t\t},\n\t\troughnessmap: {\n\t\t\troughnessMap: {\n\t\t\t\tvalue: null\n\t\t\t}\n\t\t},\n\t\tmetalnessmap: {\n\t\t\tmetalnessMap: {\n\t\t\t\tvalue: null\n\t\t\t}\n\t\t},\n\t\tgradientmap: {\n\t\t\tgradientMap: {\n\t\t\t\tvalue: null\n\t\t\t}\n\t\t},\n\t\tfog: {\n\t\t\tfogDensity: {\n\t\t\t\tvalue: 0.00025\n\t\t\t},\n\t\t\tfogNear: {\n\t\t\t\tvalue: 1\n\t\t\t},\n\t\t\tfogFar: {\n\t\t\t\tvalue: 2000\n\t\t\t},\n\t\t\tfogColor: {\n\t\t\t\tvalue: new Color(0xffffff)\n\t\t\t}\n\t\t},\n\t\tlights: {\n\t\t\tambientLightColor: {\n\t\t\t\tvalue: []\n\t\t\t},\n\t\t\tlightProbe: {\n\t\t\t\tvalue: []\n\t\t\t},\n\t\t\tdirectionalLights: {\n\t\t\t\tvalue: [],\n\t\t\t\tproperties: {\n\t\t\t\t\tdirection: {},\n\t\t\t\t\tcolor: {}\n\t\t\t\t}\n\t\t\t},\n\t\t\tdirectionalLightShadows: {\n\t\t\t\tvalue: [],\n\t\t\t\tproperties: {\n\t\t\t\t\tshadowBias: {},\n\t\t\t\t\tshadowNormalBias: {},\n\t\t\t\t\tshadowRadius: {},\n\t\t\t\t\tshadowMapSize: {}\n\t\t\t\t}\n\t\t\t},\n\t\t\tdirectionalShadowMap: {\n\t\t\t\tvalue: []\n\t\t\t},\n\t\t\tdirectionalShadowMatrix: {\n\t\t\t\tvalue: []\n\t\t\t},\n\t\t\tspotLights: {\n\t\t\t\tvalue: [],\n\t\t\t\tproperties: {\n\t\t\t\t\tcolor: {},\n\t\t\t\t\tposition: {},\n\t\t\t\t\tdirection: {},\n\t\t\t\t\tdistance: {},\n\t\t\t\t\tconeCos: {},\n\t\t\t\t\tpenumbraCos: {},\n\t\t\t\t\tdecay: {}\n\t\t\t\t}\n\t\t\t},\n\t\t\tspotLightShadows: {\n\t\t\t\tvalue: [],\n\t\t\t\tproperties: {\n\t\t\t\t\tshadowBias: {},\n\t\t\t\t\tshadowNormalBias: {},\n\t\t\t\t\tshadowRadius: {},\n\t\t\t\t\tshadowMapSize: {}\n\t\t\t\t}\n\t\t\t},\n\t\t\tspotShadowMap: {\n\t\t\t\tvalue: []\n\t\t\t},\n\t\t\tspotShadowMatrix: {\n\t\t\t\tvalue: []\n\t\t\t},\n\t\t\tpointLights: {\n\t\t\t\tvalue: [],\n\t\t\t\tproperties: {\n\t\t\t\t\tcolor: {},\n\t\t\t\t\tposition: {},\n\t\t\t\t\tdecay: {},\n\t\t\t\t\tdistance: {}\n\t\t\t\t}\n\t\t\t},\n\t\t\tpointLightShadows: {\n\t\t\t\tvalue: [],\n\t\t\t\tproperties: {\n\t\t\t\t\tshadowBias: {},\n\t\t\t\t\tshadowNormalBias: {},\n\t\t\t\t\tshadowRadius: {},\n\t\t\t\t\tshadowMapSize: {},\n\t\t\t\t\tshadowCameraNear: {},\n\t\t\t\t\tshadowCameraFar: {}\n\t\t\t\t}\n\t\t\t},\n\t\t\tpointShadowMap: {\n\t\t\t\tvalue: []\n\t\t\t},\n\t\t\tpointShadowMatrix: {\n\t\t\t\tvalue: []\n\t\t\t},\n\t\t\themisphereLights: {\n\t\t\t\tvalue: [],\n\t\t\t\tproperties: {\n\t\t\t\t\tdirection: {},\n\t\t\t\t\tskyColor: {},\n\t\t\t\t\tgroundColor: {}\n\t\t\t\t}\n\t\t\t},\n\t\t\t// TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src\n\t\t\trectAreaLights: {\n\t\t\t\tvalue: [],\n\t\t\t\tproperties: {\n\t\t\t\t\tcolor: {},\n\t\t\t\t\tposition: {},\n\t\t\t\t\twidth: {},\n\t\t\t\t\theight: {}\n\t\t\t\t}\n\t\t\t},\n\t\t\tltc_1: {\n\t\t\t\tvalue: null\n\t\t\t},\n\t\t\tltc_2: {\n\t\t\t\tvalue: null\n\t\t\t}\n\t\t},\n\t\tpoints: {\n\t\t\tdiffuse: {\n\t\t\t\tvalue: new Color(0xeeeeee)\n\t\t\t},\n\t\t\topacity: {\n\t\t\t\tvalue: 1.0\n\t\t\t},\n\t\t\tsize: {\n\t\t\t\tvalue: 1.0\n\t\t\t},\n\t\t\tscale: {\n\t\t\t\tvalue: 1.0\n\t\t\t},\n\t\t\tmap: {\n\t\t\t\tvalue: null\n\t\t\t},\n\t\t\talphaMap: {\n\t\t\t\tvalue: null\n\t\t\t},\n\t\t\tuvTransform: {\n\t\t\t\tvalue: new Matrix3()\n\t\t\t}\n\t\t},\n\t\tsprite: {\n\t\t\tdiffuse: {\n\t\t\t\tvalue: new Color(0xeeeeee)\n\t\t\t},\n\t\t\topacity: {\n\t\t\t\tvalue: 1.0\n\t\t\t},\n\t\t\tcenter: {\n\t\t\t\tvalue: new Vector2(0.5, 0.5)\n\t\t\t},\n\t\t\trotation: {\n\t\t\t\tvalue: 0.0\n\t\t\t},\n\t\t\tmap: {\n\t\t\t\tvalue: null\n\t\t\t},\n\t\t\talphaMap: {\n\t\t\t\tvalue: null\n\t\t\t},\n\t\t\tuvTransform: {\n\t\t\t\tvalue: new Matrix3()\n\t\t\t}\n\t\t}\n\t};\n\n\tvar ShaderLib = {\n\t\tbasic: {\n\t\t\tuniforms: mergeUniforms([UniformsLib.common, UniformsLib.specularmap, UniformsLib.envmap, UniformsLib.aomap, UniformsLib.lightmap, UniformsLib.fog]),\n\t\t\tvertexShader: ShaderChunk.meshbasic_vert,\n\t\t\tfragmentShader: ShaderChunk.meshbasic_frag\n\t\t},\n\t\tlambert: {\n\t\t\tuniforms: mergeUniforms([UniformsLib.common, UniformsLib.specularmap, UniformsLib.envmap, UniformsLib.aomap, UniformsLib.lightmap, UniformsLib.emissivemap, UniformsLib.fog, UniformsLib.lights, {\n\t\t\t\temissive: {\n\t\t\t\t\tvalue: new Color(0x000000)\n\t\t\t\t}\n\t\t\t}]),\n\t\t\tvertexShader: ShaderChunk.meshlambert_vert,\n\t\t\tfragmentShader: ShaderChunk.meshlambert_frag\n\t\t},\n\t\tphong: {\n\t\t\tuniforms: mergeUniforms([UniformsLib.common, UniformsLib.specularmap, UniformsLib.envmap, UniformsLib.aomap, UniformsLib.lightmap, UniformsLib.emissivemap, UniformsLib.bumpmap, UniformsLib.normalmap, UniformsLib.displacementmap, UniformsLib.fog, UniformsLib.lights, {\n\t\t\t\temissive: {\n\t\t\t\t\tvalue: new Color(0x000000)\n\t\t\t\t}
1,\n\t\t\t\tspecular: {\n\t\t\t\t\tvalue: new Color(0x111111)\n\t\t\t\t},\n\t\t\t\tshininess: {\n\t\t\t\t\tvalue: 30\n\t\t\t\t}\n\t\t\t}]),\n\t\t\tvertexShader: ShaderChunk.meshphong_vert,\n\t\t\tfragmentShader: ShaderChunk.meshphong_frag\n\t\t},\n\t\tstandard: {\n\t\t\tuniforms: mergeUniforms([UniformsLib.common, UniformsLib.envmap, UniformsLib.aomap, UniformsLib.lightmap, UniformsLib.emissivemap, UniformsLib.bumpmap, UniformsLib.normalmap, UniformsLib.displacementmap, UniformsLib.roughnessmap, UniformsLib.metalnessmap, UniformsLib.fog, UniformsLib.lights, {\n\t\t\t\temissive: {\n\t\t\t\t\tvalue: new Color(0x000000)\n\t\t\t\t},\n\t\t\t\troughness: {\n\t\t\t\t\tvalue: 1.0\n\t\t\t\t},\n\t\t\t\tmetalness: {\n\t\t\t\t\tvalue: 0.0\n\t\t\t\t},\n\t\t\t\tenvMapIntensity: {\n\t\t\t\t\tvalue: 1\n\t\t\t\t} // temporary\n\n\t\t\t}]),\n\t\t\tvertexShader: ShaderChunk.meshphysical_vert,\n\t\t\tfragmentShader: ShaderChunk.meshphysical_frag\n\t\t},\n\t\ttoon: {\n\t\t\tuniforms: mergeUniforms([UniformsLib.common, UniformsLib.aomap, UniformsLib.lightmap, UniformsLib.emissivemap, UniformsLib.bumpmap, UniformsLib.normalmap, UniformsLib.displacementmap, UniformsLib.gradientmap, UniformsLib.fog, UniformsLib.lights, {\n\t\t\t\temissive: {\n\t\t\t\t\tvalue: new Color(0x000000)\n\t\t\t\t}\n\t\t\t}]),\n\t\t\tvertexShader: ShaderChunk.meshtoon_vert,\n\t\t\tfragmentShader: ShaderChunk.meshtoon_frag\n\t\t},\n\t\tmatcap: {\n\t\t\tuniforms: mergeUniforms([UniformsLib.common, UniformsLib.bumpmap, UniformsLib.normalmap, UniformsLib.displacementmap, UniformsLib.fog, {\n\t\t\t\tmatcap: {\n\t\t\t\t\tvalue: null\n\t\t\t\t}\n\t\t\t}]),\n\t\t\tvertexShader: ShaderChunk.meshmatcap_vert,\n\t\t\tfragmentShader: ShaderChunk.meshmatcap_frag\n\t\t},\n\t\tpoints: {\n\t\t\tuniforms: mergeUniforms([UniformsLib.points, UniformsLib.fog]),\n\t\t\tvertexShader: ShaderChunk.points_vert,\n\t\t\tfragmentShader: ShaderChunk.points_frag\n\t\t},\n\t\tdashed: {\n\t\t\tuniforms: mergeUniforms([UniformsLib.common, UniformsLib.fog, {\n\t\t\t\tscale: {\n\t\t\t\t\tvalue: 1\n\t\t\t\t},\n\t\t\t\tdashSize: {\n\t\t\t\t\tvalue: 1\n\t\t\t\t},\n\t\t\t\ttotalSize: {\n\t\t\t\t\tvalue: 2\n\t\t\t\t}\n\t\t\t}]),\n\t\t\tvertexShader: ShaderChunk.linedashed_vert,\n\t\t\tfragmentShader: ShaderChunk.linedashed_frag\n\t\t},\n\t\tdepth: {\n\t\t\tuniforms: mergeUniforms([UniformsLib.common, UniformsLib.displacementmap]),\n\t\t\tvertexShader: ShaderChunk.depth_vert,\n\t\t\tfragmentShader: ShaderChunk.depth_frag\n\t\t},\n\t\tnormal: {\n\t\t\tuniforms: mergeUniforms([UniformsLib.common, UniformsLib.bumpmap, UniformsLib.normalmap, UniformsLib.displacementmap, {\n\t\t\t\topacity: {\n\t\t\t\t\tvalue: 1.0\n\t\t\t\t}\n\t\t\t}]),\n\t\t\tvertexShader: ShaderChunk.normal_vert,\n\t\t\tfragmentShader: ShaderChunk.normal_frag\n\t\t},\n\t\tsprite: {\n\t\t\tuniforms: mergeUniforms([UniformsLib.sprite, UniformsLib.fog]),\n\t\t\tvertexShader: ShaderChunk.sprite_vert,\n\t\t\tfragmentShader: ShaderChunk.sprite_frag\n\t\t},\n\t\tbackground: {\n\t\t\tuniforms: {\n\t\t\t\tuvTransform: {\n\t\t\t\t\tvalue: new Matrix3()\n\t\t\t\t},\n\t\t\t\tt2D: {\n\t\t\t\t\tvalue: null\n\t\t\t\t}\n\t\t\t},\n\t\t\tvertexShader: ShaderChunk.background_vert,\n\t\t\tfragmentShader: ShaderChunk.background_frag\n\t\t},\n\n\t\t/* -------------------------------------------------------------------------\n\t\t//\tCube map shader\n\t\t ------------------------------------------------------------------------- */\n\t\tcube: {\n\t\t\tuniforms: mergeUniforms([UniformsLib.envmap, {\n\t\t\t\topacity: {\n\t\t\t\t\tvalue: 1.0\n\t\t\t\t}\n\t\t\t}]),\n\t\t\tvertexShader: ShaderChunk.cube_vert,\n\t\t\tfragmentShader: ShaderChunk.cube_frag\n\t\t},\n\t\tequirect: {\n\t\t\tuniforms: {\n\t\t\t\ttEquirect: {\n\t\t\t\t\tvalue: null\n\t\t\t\t}\n\t\t\t},\n\t\t\tvertexShader: ShaderChunk.equirect_vert,\n\t\t\tfragmentShader: ShaderChunk.equirect_frag\n\t\t},\n\t\tdistanceRGBA: {\n\t\t\tuniforms: mergeUniforms([UniformsLib.common, UniformsLib.displacementmap, {\n\t\t\t\treferencePosition: {\n\t\t\t\t\tvalue: new Vector3()\n\t\t\t\t},\n\t\t\t\tnearDistance: {\n\t\t\t\t\tvalue: 1\n\t\t\t\t},\n\t\t\t\tfarDistance: {\n\t\t\t\t\tvalue: 1000\n\t\t\t\t}\n\t\t\t}]),\n\t\t\tvertexShader: ShaderChunk.distanceRGBA_vert,\n\t\t\tfragmentShader: ShaderChunk.distanceRGBA_frag\n\t\t},\n\t\tshadow: {\n\t\t\tuniforms: mergeUniforms([UniformsLib.lights, UniformsLib.fog, {\n\t\t\t\tcolor: {\n\t\t\t\t\tvalue: new Color(0x00000)\n\t\t\t\t},\n\t\t\t\topacity: {\n\t\t\t\t\tvalue: 1.0\n\t\t\t\t}\n\t\t\t}]),\n\t\t\tvertexShader: ShaderChunk.shadow_vert,\n\t\t\tfragmentShader: ShaderChunk.shadow_frag\n\t\t}\n\t};
1\n\tShaderLib.physical = {\n\t\tuniforms: mergeUniforms([ShaderLib.standard.uniforms, {\n\t\t\tclearcoat: {\n\t\t\t\tvalue: 0\n\t\t\t},\n\t\t\tclearcoatMap: {\n\t\t\t\tvalue: null\n\t\t\t},\n\t\t\tclearcoatRoughness: {\n\t\t\t\tvalue: 0\n\t\t\t},\n\t\t\tclearcoatRoughnessMap: {\n\t\t\t\tvalue: null\n\t\t\t},\n\t\t\tclearcoatNormalScale: {\n\t\t\t\tvalue: new Vector2(1, 1)\n\t\t\t},\n\t\t\tclearcoatNormalMap: {\n\t\t\t\tvalue: null\n\t\t\t},\n\t\t\tsheen: {\n\t\t\t\tvalue: new Color(0x000000)\n\t\t\t},\n\t\t\ttransmission: {\n\t\t\t\tvalue: 0\n\t\t\t},\n\t\t\ttransmissionMap: {\n\t\t\t\tvalue: null\n\t\t\t}\n\t\t}]),\n\t\tvertexShader: ShaderChunk.meshphysical_vert,\n\t\tfragmentShader: ShaderChunk.meshphysical_frag\n\t};\n\n\tfunction WebGLBackground(renderer, cubemaps, state, objects, premultipliedAlpha) {\n\t\tvar clearColor = new Color(0x000000);\n\t\tvar clearAlpha = 0;\n\t\tvar planeMesh;\n\t\tvar boxMesh;\n\t\tvar currentBackground = null;\n\t\tvar currentBackgroundVersion = 0;\n\t\tvar currentTonemapping = null;\n\n\t\tfunction render(renderList, scene, camera, forceClear) {\n\t\t\tvar background = scene.isScene === true ? scene.background : null;\n\n\t\t\tif (background && background.isTexture) {\n\t\t\t\tbackground = cubemaps.get(background);\n\t\t\t} // Ignore background in AR\n\t\t\t// TODO: Reconsider this.\n\n\n\t\t\tvar xr = renderer.xr;\n\t\t\tvar session = xr.getSession && xr.getSession();\n\n\t\t\tif (session && session.environmentBlendMode === 'additive') {\n\t\t\t\tbackground = null;\n\t\t\t}\n\n\t\t\tif (background === null) {\n\t\t\t\tsetClear(clearColor, clearAlpha);\n\t\t\t} else if (background && background.isColor) {\n\t\t\t\tsetClear(background, 1);\n\t\t\t\tforceClear = true;\n\t\t\t}\n\n\t\t\tif (renderer.autoClear || forceClear) {\n\t\t\t\trenderer.clear(renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil);\n\t\t\t}\n\n\t\t\tif (background && (background.isCubeTexture || background.isWebGLCubeRenderTarget || background.mapping === CubeUVReflectionMapping)) {\n\t\t\t\tif (boxMesh === undefined) {\n\t\t\t\t\tboxMesh = new Mesh(new BoxBufferGeometry(1, 1, 1), new ShaderMaterial({\n\t\t\t\t\t\tname: 'BackgroundCubeMaterial',\n\t\t\t\t\t\tuniforms: cloneUniforms(ShaderLib.cube.uniforms),\n\t\t\t\t\t\tvertexShader: ShaderLib.cube.vertexShader,\n\t\t\t\t\t\tfragmentShader: ShaderLib.cube.fragmentShader,\n\t\t\t\t\t\tside: BackSide,\n\t\t\t\t\t\tdepthTest: false,\n\t\t\t\t\t\tdepthWrite: false,\n\t\t\t\t\t\tfog: false\n\t\t\t\t\t}));\n\t\t\t\t\tboxMesh.geometry.deleteAttribute('normal');\n\t\t\t\t\tboxMesh.geometry.deleteAttribute('uv');\n\n\t\t\t\t\tboxMesh.onBeforeRender = function (renderer, scene, camera) {\n\t\t\t\t\t\tthis.matrixWorld.copyPosition(camera.matrixWorld);\n\t\t\t\t\t}; // enable code injection for non-built-in material\n\n\n\t\t\t\t\tObject.defineProperty(boxMesh.material, 'envMap', {\n\t\t\t\t\t\tget: function get() {\n\t\t\t\t\t\t\treturn this.uniforms.envMap.value;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tobjects.update(boxMesh);\n\t\t\t\t}\n\n\t\t\t\tif (background.isWebGLCubeRenderTarget) {\n\t\t\t\t\t// TODO Deprecate\n\t\t\t\t\tbackground = background.texture;\n\t\t\t\t}\n\n\t\t\t\tboxMesh.material.uniforms.envMap.value = background;\n\t\t\t\tboxMesh.material.uniforms.flipEnvMap.value = background.isCubeTexture && background._needsFlipEnvMap ? -1 : 1;\n\n\t\t\t\tif (currentBackground !== background || currentBackgroundVersion !== background.version || currentTonemapping !== renderer.toneMapping) {\n\t\t\t\t\tboxMesh.material.needsUpdate = true;\n\t\t\t\t\tcurrentBackground = background;\n\t\t\t\t\tcurrentBackgroundVersion = background.version;\n\t\t\t\t\tcurrentTonemapping = renderer.toneMapping;\n\t\t\t\t} // push to the pre-sorted opaque render list\n\n\n\t\t\t\trenderList.unshift(boxMesh, boxMesh.geometry, boxMesh.material, 0, 0, null);\n\t\t\t} else if (background && background.isTexture) {\n\t\t\t\tif (planeMesh === undefined) {\n\t\t\t\t\tplaneMesh = new Mesh(new PlaneBufferGeometry(2, 2), new ShaderMaterial({\n\t\t\t\t\t\tname: 'BackgroundMaterial',\n\t\t\t\t\t\tuniforms: cloneUniforms(ShaderLib.background.uniforms),\n\t\t\t\t\t\tvertexShader: ShaderLib.background.vertexShader,\n\t\t\t\t\t\tfragmentShader: ShaderLib.background.fragmentShader,\n\t\t\t\t\t\tside: FrontSide,\n\t\t\t\t\t\tdepthTest: false,\n\t\t\t\t\t\tdepthWrite: false,\n\t\t\t\t\t\tfog: false\n\t\t\t\t\t}));\n\t\t\t\t\tplaneMesh.geometry.deleteAttribute('normal'); // enable code injection for non-built-in material\n\n\t\t\t\t\tObject.defineProperty(planeMesh.material, 'map', {\n\t\t\t\t\t\tget: function get() {\n\t\t\t\t\t\t\treturn this.uniforms.t2D.value;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tobjects.update(planeMesh);\n\t\t\t\t}\n\n\t\t\t\tplaneMesh.material.uniforms.t2D.value = background;\n\n\t\t\t\tif (background.matrixAutoUpdate === true) {\n\t\t\t\t\tbackground.updateMatrix();\n\t\t\t\t}\n\n\t\t\t\tplaneMesh.material.uniforms.uvTransform.value.copy(background.matrix);
1\n\n\t\t\t\tif (currentBackground !== background || currentBackgroundVersion !== background.version || currentTonemapping !== renderer.toneMapping) {\n\t\t\t\t\tplaneMesh.material.needsUpdate = true;\n\t\t\t\t\tcurrentBackground = background;\n\t\t\t\t\tcurrentBackgroundVersion = background.version;\n\t\t\t\t\tcurrentTonemapping = renderer.toneMapping;\n\t\t\t\t} // push to the pre-sorted opaque render list\n\n\n\t\t\t\trenderList.unshift(planeMesh, planeMesh.geometry, planeMesh.material, 0, 0, null);\n\t\t\t}\n\t\t}\n\n\t\tfunction setClear(color, alpha) {\n\t\t\tstate.buffers.color.setClear(color.r, color.g, color.b, alpha, premultipliedAlpha);\n\t\t}\n\n\t\treturn {\n\t\t\tgetClearColor: function getClearColor() {\n\t\t\t\treturn clearColor;\n\t\t\t},\n\t\t\tsetClearColor: function setClearColor(color, alpha) {\n\t\t\t\tif (alpha === void 0) {\n\t\t\t\t\talpha = 1;\n\t\t\t\t}\n\n\t\t\t\tclearColor.set(color);\n\t\t\t\tclearAlpha = alpha;\n\t\t\t\tsetClear(clearColor, clearAlpha);\n\t\t\t},\n\t\t\tgetClearAlpha: function getClearAlpha() {\n\t\t\t\treturn clearAlpha;\n\t\t\t},\n\t\t\tsetClearAlpha: function setClearAlpha(alpha) {\n\t\t\t\tclearAlpha = alpha;\n\t\t\t\tsetClear(clearColor, clearAlpha);\n\t\t\t},\n\t\t\trender: render\n\t\t};\n\t}\n\n\tfunction WebGLBindingStates(gl, extensions, attributes, capabilities) {\n\t\tvar maxVertexAttributes = gl.getParameter(34921);\n\t\tvar extension = capabilities.isWebGL2 ? null : extensions.get('OES_vertex_array_object');\n\t\tvar vaoAvailable = capabilities.isWebGL2 || extension !== null;\n\t\tvar bindingStates = {};\n\t\tvar defaultState = createBindingState(null);\n\t\tvar currentState = defaultState;\n\n\t\tfunction setup(object, material, program, geometry, index) {\n\t\t\tvar updateBuffers = false;\n\n\t\t\tif (vaoAvailable) {\n\t\t\t\tvar state = getBindingState(geometry, program, material);\n\n\t\t\t\tif (currentState !== state) {\n\t\t\t\t\tcurrentState = state;\n\t\t\t\t\tbindVertexArrayObject(currentState.object);\n\t\t\t\t}\n\n\t\t\t\tupdateBuffers = needsUpdate(geometry, index);\n\t\t\t\tif (updateBuffers) saveCache(geometry, index);\n\t\t\t} else {\n\t\t\t\tvar wireframe = material.wireframe === true;\n\n\t\t\t\tif (currentState.geometry !== geometry.id || currentState.program !== program.id || currentState.wireframe !== wireframe) {\n\t\t\t\t\tcurrentState.geometry = geometry.id;\n\t\t\t\t\tcurrentState.program = program.id;\n\t\t\t\t\tcurrentState.wireframe = wireframe;\n\t\t\t\t\tupdateBuffers = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (object.isInstancedMesh === true) {\n\t\t\t\tupdateBuffers = true;\n\t\t\t}\n\n\t\t\tif (index !== null) {\n\t\t\t\tattributes.update(index, 34963);\n\t\t\t}\n\n\t\t\tif (updateBuffers) {\n\t\t\t\tsetupVertexAttributes(object, material, program, geometry);\n\n\t\t\t\tif (index !== null) {\n\t\t\t\t\tgl.bindBuffer(34963, attributes.get(index).buffer);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction createVertexArrayObject() {\n\t\t\tif (capabilities.isWebGL2) return gl.createVertexArray();\n\t\t\treturn extension.createVertexArrayOES();\n\t\t}\n\n\t\tfunction bindVertexArrayObject(vao) {\n\t\t\tif (capabilities.isWebGL2) return gl.bindVertexArray(vao);\n\t\t\treturn extension.bindVertexArrayOES(vao);\n\t\t}\n\n\t\tfunction deleteVertexArrayObject(vao) {\n\t\t\tif (capabilities.isWebGL2) return gl.deleteVertexArray(vao);\n\t\t\treturn extension.deleteVertexArrayOES(vao);\n\t\t}\n\n\t\tfunction getBindingState(geometry, program, material) {\n\t\t\tvar wireframe = material.wireframe === true;\n\t\t\tvar programMap = bindingStates[geometry.id];\n\n\t\t\tif (programMap === undefined) {\n\t\t\t\tprogramMap = {};\n\t\t\t\tbindingStates[geometry.id] = programMap;\n\t\t\t}\n\n\t\t\tvar stateMap = programMap[program.id];\n\n\t\t\tif (stateMap === undefined) {\n\t\t\t\tstateMap = {};\n\t\t\t\tprogramMap[program.id] = stateMap;\n\t\t\t}\n\n\t\t\tvar state = stateMap[wireframe];\n\n\t\t\tif (state === undefined) {\n\t\t\t\tstate = createBindingState(createVertexArrayObject());\n\t\t\t\tstateMap[wireframe] = state;\n\t\t\t}\n\n\t\t\treturn state;\n\t\t}\n\n\t\tfunction createBindingState(vao) {\n\t\t\tvar newAttributes = [];\n\t\t\tvar enabledAttributes = [];\n\t\t\tvar attributeDivisors = [];\n\n\t\t\tfor (var i = 0; i < maxVertexAttributes;
1 i++) {\n\t\t\t\tnewAttributes[i] = 0;\n\t\t\t\tenabledAttributes[i] = 0;\n\t\t\t\tattributeDivisors[i] = 0;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t// for backward compatibility on non-VAO support browser\n\t\t\t\tgeometry: null,\n\t\t\t\tprogram: null,\n\t\t\t\twireframe: false,\n\t\t\t\tnewAttributes: newAttributes,\n\t\t\t\tenabledAttributes: enabledAttributes,\n\t\t\t\tattributeDivisors: attributeDivisors,\n\t\t\t\tobject: vao,\n\t\t\t\tattributes: {},\n\t\t\t\tindex: null\n\t\t\t};\n\t\t}\n\n\t\tfunction needsUpdate(geometry, index) {\n\t\t\tvar cachedAttributes = currentState.attributes;\n\t\t\tvar geometryAttributes = geometry.attributes;\n\t\t\tvar attributesNum = 0;\n\n\t\t\tfor (var key in geometryAttributes) {\n\t\t\t\tvar cachedAttribute = cachedAttributes[key];\n\t\t\t\tvar geometryAttribute = geometryAttributes[key];\n\t\t\t\tif (cachedAttribute === undefined) return true;\n\t\t\t\tif (cachedAttribute.attribute !== geometryAttribute) return true;\n\t\t\t\tif (cachedAttribute.data !== geometryAttribute.data) return true;\n\t\t\t\tattributesNum++;\n\t\t\t}\n\n\t\t\tif (currentState.attributesNum !== attributesNum) return true;\n\t\t\tif (currentState.index !== index) return true;\n\t\t\treturn false;\n\t\t}\n\n\t\tfunction saveCache(geometry, index) {\n\t\t\tvar cache = {};\n\t\t\tvar attributes = geometry.attributes;\n\t\t\tvar attributesNum = 0;\n\n\t\t\tfor (var key in attributes) {\n\t\t\t\tvar attribute = attributes[key];\n\t\t\t\tvar data = {};\n\t\t\t\tdata.attribute = attribute;\n\n\t\t\t\tif (attribute.data) {\n\t\t\t\t\tdata.data = attribute.data;\n\t\t\t\t}\n\n\t\t\t\tcache[key] = data;\n\t\t\t\tattributesNum++;\n\t\t\t}\n\n\t\t\tcurrentState.attributes = cache;\n\t\t\tcurrentState.attributesNum = attributesNum;\n\t\t\tcurrentState.index = index;\n\t\t}\n\n\t\tfunction initAttributes() {\n\t\t\tvar newAttributes = currentState.newAttributes;\n\n\t\t\tfor (var i = 0, il = newAttributes.length; i < il; i++) {\n\t\t\t\tnewAttributes[i] = 0;\n\t\t\t}\n\t\t}\n\n\t\tfunction enableAttribute(attribute) {\n\t\t\tenableAttributeAndDivisor(attribute, 0);\n\t\t}\n\n\t\tfunction enableAttributeAndDivisor(attribute, meshPerAttribute) {\n\t\t\tvar newAttributes = currentState.newAttributes;\n\t\t\tvar enabledAttributes = currentState.enabledAttributes;\n\t\t\tvar attributeDivisors = currentState.attributeDivisors;\n\t\t\tnewAttributes[attribute] = 1;\n\n\t\t\tif (enabledAttributes[attribute] === 0) {\n\t\t\t\tgl.enableVertexAttribArray(attribute);\n\t\t\t\tenabledAttributes[attribute] = 1;\n\t\t\t}\n\n\t\t\tif (attributeDivisors[attribute] !== meshPerAttribute) {\n\t\t\t\tvar _extension = capabilities.isWebGL2 ? gl : extensions.get('ANGLE_instanced_arrays');\n\n\t\t\t\t_extension[capabilities.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE'](attribute, meshPerAttribute);\n\n\t\t\t\tattributeDivisors[attribute] = meshPerAttribute;\n\t\t\t}\n\t\t}\n\n\t\tfunction disableUnusedAttributes() {\n\t\t\tvar newAttributes = currentState.newAttributes;\n\t\t\tvar enabledAttributes = currentState.enabledAttributes;\n\n\t\t\tfor (var i = 0, il = enabledAttributes.length; i < il; i++) {\n\t\t\t\tif (enabledAttributes[i] !== newAttributes[i]) {\n\t\t\t\t\tgl.disableVertexAttribArray(i);\n\t\t\t\t\tenabledAttributes[i] = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction vertexAttribPointer(index, size, type, normalized, stride, offset) {\n\t\t\tif (capabilities.isWebGL2 === true && (type === 5124 || type === 5125)) {\n\t\t\t\tgl.vertexAttribIPointer(index, size, type, stride, offset);\n\t\t\t} else {\n\t\t\t\tgl.vertexAttribPointer(index, size, type, normalized, stride, offset);\n\t\t\t}\n\t\t}\n\n\t\tfunction setupVertexAttributes(object, material, program, geometry) {\n\t\t\tif (capabilities.isWebGL2 === false && (object.isInstancedMesh || geometry.isInstancedBufferGeometry)) {\n\t\t\t\tif (extensions.get('ANGLE_instanced_arrays') === null) return;\n\t\t\t}\n\n\t\t\tinitAttributes();\n\t\t\tvar geometryAttributes = geometry.attributes;\n\t\t\tvar programAttributes = program.getAttributes();\n\t\t\tvar materialDefaultAttributeValues = material.defaultAttributeValues;\n\n\t\t\tfor (var name in programAttributes) {\n\t\t\t\tvar programAttribute = programAttributes[name];\n\n\t\t\t\tif (programAttribute >= 0) {\n\t\t\t\t\tvar geometryAttribute = geometryAttributes[name];\n\n\t\t\t\t\tif (geometryAttribute !== undefined) {\n\t\t\t\t\t\tvar normalized = geometryAttribute.normalized;\n\t\t\t\t\t\tvar size = geometryAttribute.itemSize;\n\t\t\t\t\t\tvar attribute = attributes.get(geometryAttribute); // TODO Attribute may not be available on context restore\n\n\t\t\t\t\t\tif (attribute === undefined) continue;\n\t\t\t\t\t\tvar buffer = attribute.buffer;\n\t\t\t\t\t\tvar type = attribute.type;\n\t\t\t\t\t\tvar bytesPerElement = attribute.bytesPerElement;\n\n\t\t\t\t\t\tif (geometryAttribute.isInterleavedBufferAttribute) {\n\t\t\t\t\t\t\tvar data = geometryAttribute.data;\n\t\t\t\t\t\t\tvar stride = data.stride;\n\t\t\t\t\t\t\tvar offset = geometryAttribute.offset;\n\n\t\t\t\t\t\t\tif (data && data.isInstancedInterleavedBuffer) {\n\t\t\t\t\t\t\t\tenableAttributeAndDivisor(programAttribute, data.meshPerAttribute);\n\n\t\t\t\t\t\t\t\tif (geometry._maxInstanceCount === undefined) {\n\t\t\t\t\t\t\t\t\tgeometry._maxInstanceCount = data.meshPerAttribute * data.count;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tenableAttribute(programAttribute);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tgl.bindBuffer(34962, buffer);\n\t\t\t\t\t\t\tvertexAttribPointer(programAttribute, size, type, normalized, stride * bytesPerElement, offset * bytesPerElement);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (geometryAttribute.isInstancedBufferAttribute) {\n\t\t\t\t\t\t\t\tenableAttributeAndDivisor(programAttribute, geometryAttribute.meshPerAttribute);\n\n\t\t\t\t\t\t\t\tif (geometry._maxInstanceCount === undefined) {\n\t\t\t\t\t\t\t\t\tgeometry._maxInstanceCount = geometryAttribute.meshPerAttribute * geometryAttribute.count;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tenableAttribute(programAttribute);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tgl.bindBuffer(34962, buffer);\n\t\t\t\t\t\t\tvertexAttribPointer(programAttribute, size, type, normalized, 0, 0);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (name === 'instanceMatrix') {\n\t\t\t\t\t\tvar _attribute = attributes.get(object.instanceMatrix); // TODO Attribute may not be available on context restore\n\n\n\t\t\t\t\t\tif (_attribute === undefined) continue;\n\t\t\t\t\t\tvar _buffer = _attribute.buffer;\n\t\t\t\t\t\tvar _type = _attribute.type;\n\t\t\t\t\t\tenableAttributeAndDivisor(programAttribute + 0, 1);\n\t\t\t\t\t\tenableAttributeAndDivisor(programAttribute + 1, 1);\n\t\t\t\t\t\tenableAttributeAndDivisor(programAttribute + 2, 1);\n\t\t\t\t\t\tenableAttributeAndDivisor(programAttribute + 3, 1);\n\t\t\t\t\t\tgl.bindBuffer(34962, _buffer);\n\t\t\t\t\t\tgl.vertexAttribPointer(programAttribute + 0, 4, _type, false, 64, 0);\n\t\t\t\t\t\tgl.vertexAttribPointer(programAttribute + 1, 4, _type, false, 64, 16);\n\t\t\t\t\t\tgl.vertexAttribPointer(programAttribute + 2, 4, _type, false, 64, 32);\n\t\t\t\t\t\tgl.vertexAttribPointer(programAttribute + 3, 4, _type, false, 64, 48);\n\t\t\t\t\t} else if (name === 'instanceColor') {\n\t\t\t\t\t\tvar _attribute2 = attributes.get(object.instanceColor); // TODO Attribute may not be available on context restore\n\n\n\t\t\t\t\t\tif (_attribute2 === undefined) continue;\n\t\t\t\t\t\tvar _buffer2 = _attribute2.buffer;\n\t\t\t\t\t\tvar _type2 = _attribute2.type;\n\t\t\t\t\t\tenableAttributeAndDivisor(programAttribute, 1);\n\t\t\t\t\t\tgl.bindBuffer(34962, _buffer2);\n\t\t\t\t\t\tgl.vertexAttribPointer(programAttribute, 3, _type2, false, 12, 0);\n\t\t\t\t\t} else if (materialDefaultAttributeValues !== undefined) {\n\t\t\t\t\t\tvar value = materialDefaultAttributeValues[name];\n\n\t\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\t\tswitch (value.length) {\n\t\t\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\t\t\tgl.vertexAttrib2fv(programAttribute, value);\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase 3:\n\t\t\t\t\t\t\t\t\tgl.vertexAttrib3fv(programAttribute, value);\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase 4:\n\t\t\t\t\t\t\t\t\tgl.vertexAttrib4fv(programAttribute, value);\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\tgl.vertexAttrib1fv(programAttribute, value);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdisableUnusedAttributes();\n\t\t}\n\n\t\tfunction dispose() {\n\t\t\treset();\n\n\t\t\tfor (var geometryId in bindingStates) {\n\t\t\t\tvar programMap = bindingStates[geometryId];\n\n\t\t\t\tfor (var programId in programMap) {\n\t\t\t\t\tvar stateMap = programMap[programId];\n\n\t\t\t\t\tfor (var wireframe in stateMap) {\n\t\t\t\t\t\tdeleteVertexArrayObject(stateMap[wireframe].object);\n\t\t\t\t\t\tdelete stateMap[wireframe];\n\t\t\t\t\t}\n\n\t\t\t\t\tdelete programMap[programId];\n\t\t\t\t}\n\n\t\t\t\tdelete bindingStates[geometryId];\n\t\t\t}\n\t\t}\n\n\t\tfunction releaseStatesOfGeometry(geometry) {\n\t\t\tif (bindingStates[geometry.id] === undefined) return;\n\t\t\tvar programMap = bindingStates[geometry.id];\n\n\t\t\tfor (var programId in programMap) {\n\t\t\t\tvar stateMap = programMap[programId];\n\n\t\t\t\tfor (var wireframe in stateMap) {\n\t\t\t\t\tdeleteVertexArrayObject(stateMap[wireframe].object);\n\t\t\t\t\tdelete stateMap[wireframe];\n\t\t\t\t}\n\n\t\t\t\tdelete programMap[programId];\n\t\t\t}\n\n\t\t\tdelete bindingStates[geometry.id];\n\t\t}\n\n\t\tfunction releaseStatesOfProgram(program) {\n\t\t\tfor (var geometryId in bindingStates) {\n\t\t\t\tvar programMap = bindingStates[geometryId];\n\t\t\t\tif (programMap[program.id] === undefined) continue;\n\t\t\t\tvar stateMap = programMap[program.id];\n\n\t\t\t\tfor (var wireframe in stateMap) {\n\t\t\t\t\tdeleteVertexArrayObject(stateMap[wireframe].object);\n\t\t\t\t\tdelete stateMap[wireframe];\n\t\t\t\t}\n\n\t\t\t\tdelete programMap[program.id];\n\t\t\t}\n\t\t}\n\n\t\tfunction reset() {\n\t\t\tresetDefaultState();\n\t\t\tif (currentState === defaultState) return;\n\t\t\tcurrentState = defaultState;\n\t\t\tbindVertexArrayObject(currentState.object);\n\t\t} // for backward-compatilibity\n\n\n\t\tfunction resetDefaultState() {\n\t\t\tdefaultState.geometry = null;\n\t\t\tdefaultState.program = null;\n\t\t\tdefaultState.wireframe = false;\n\t\t}
1\n\n\t\treturn {\n\t\t\tsetup: setup,\n\t\t\treset: reset,\n\t\t\tresetDefaultState: resetDefaultState,\n\t\t\tdispose: dispose,\n\t\t\treleaseStatesOfGeometry: releaseStatesOfGeometry,\n\t\t\treleaseStatesOfProgram: releaseStatesOfProgram,\n\t\t\tinitAttributes: initAttributes,\n\t\t\tenableAttribute: enableAttribute,\n\t\t\tdisableUnusedAttributes: disableUnusedAttributes\n\t\t};\n\t}\n\n\tfunction WebGLBufferRenderer(gl, extensions, info, capabilities) {\n\t\tvar isWebGL2 = capabilities.isWebGL2;\n\t\tvar mode;\n\n\t\tfunction setMode(value) {\n\t\t\tmode = value;\n\t\t}\n\n\t\tfunction render(start, count) {\n\t\t\tgl.drawArrays(mode, start, count);\n\t\t\tinfo.update(count, mode, 1);\n\t\t}\n\n\t\tfunction renderInstances(start, count, primcount) {\n\t\t\tif (primcount === 0) return;\n\t\t\tvar extension, methodName;\n\n\t\t\tif (isWebGL2) {\n\t\t\t\textension = gl;\n\t\t\t\tmethodName = 'drawArraysInstanced';\n\t\t\t} else {\n\t\t\t\textension = extensions.get('ANGLE_instanced_arrays');\n\t\t\t\tmethodName = 'drawArraysInstancedANGLE';\n\n\t\t\t\tif (extension === null) {\n\t\t\t\t\tconsole.error('THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.');\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\textension[methodName](mode, start, count, primcount);\n\t\t\tinfo.update(count, mode, primcount);\n\t\t} //\n\n\n\t\tthis.setMode = setMode;\n\t\tthis.render = render;\n\t\tthis.renderInstances = renderInstances;\n\t}\n\n\tfunction WebGLCapabilities(gl, extensions, parameters) {\n\t\tvar maxAnisotropy;\n\n\t\tfunction getMaxAnisotropy() {\n\t\t\tif (maxAnisotropy !== undefined) return maxAnisotropy;\n\t\t\tvar extension = extensions.get('EXT_texture_filter_anisotropic');\n\n\t\t\tif (extension !== null) {\n\t\t\t\tmaxAnisotropy = gl.getParameter(extension.MAX_TEXTURE_MAX_ANISOTROPY_EXT);\n\t\t\t} else {\n\t\t\t\tmaxAnisotropy = 0;\n\t\t\t}\n\n\t\t\treturn maxAnisotropy;\n\t\t}\n\n\t\tfunction getMaxPrecision(precision) {\n\t\t\tif (precision === 'highp') {\n\t\t\t\tif (gl.getShaderPrecisionFormat(35633, 36338).precision > 0 && gl.getShaderPrecisionFormat(35632, 36338).precision > 0) {\n\t\t\t\t\treturn 'highp';\n\t\t\t\t}\n\n\t\t\t\tprecision = 'mediump';\n\t\t\t}\n\n\t\t\tif (precision === 'mediump') {\n\t\t\t\tif (gl.getShaderPrecisionFormat(35633, 36337).precision > 0 && gl.getShaderPrecisionFormat(35632, 36337).precision > 0) {\n\t\t\t\t\treturn 'mediump';\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn 'lowp';\n\t\t}\n\t\t/* eslint-disable no-undef */\n\n\n\t\tvar isWebGL2 = typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext || typeof WebGL2ComputeRenderingContext !== 'undefined' && gl instanceof WebGL2ComputeRenderingContext;\n\t\t/* eslint-enable no-undef */\n\n\t\tvar precision = parameters.precision !== undefined ? parameters.precision : 'highp';\n\t\tvar maxPrecision = getMaxPrecision(precision);\n\n\t\tif (maxPrecision !== precision) {\n\t\t\tconsole.warn('THREE.WebGLRenderer:', precision, 'not supported, using', maxPrecision, 'instead.');\n\t\t\tprecision = maxPrecision;\n\t\t}\n\n\t\tvar logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;\n\t\tvar maxTextures = gl.getParameter(34930);\n\t\tvar maxVertexTextures = gl.getParameter(35660);\n\t\tvar maxTextureSize = gl.getParameter(3379);\n\t\tvar maxCubemapSize = gl.getParameter(34076);\n\t\tvar maxAttributes = gl.getParameter(34921);\n\t\tvar maxVertexUniforms = gl.getParameter(36347);\n\t\tvar maxVaryings = gl.getParameter(36348);\n\t\tvar maxFragmentUniforms = gl.getParameter(36349);\n\t\tvar vertexTextures = maxVertexTextures > 0;\n\t\tvar floatFragmentTextures = isWebGL2 || !!extensions.get('OES_texture_float');\n\t\tvar floatVertexTextures = vertexTextures && floatFragmentTextures;\n\t\tvar maxSamples = isWebGL2 ? gl.getParameter(36183) : 0;\n\t\treturn {\n\t\t\tisWebGL2: isWebGL2,\n\t\t\tgetMaxAnisotropy: getMaxAnisotropy,\n\t\t\tgetMaxPrecision: getMaxPrecision,\n\t\t\tprecision: precision,\n\t\t\tlogarithmicDepthBuffer: logarithmicDepthBuffer,\n\t\t\tmaxTextures: maxTextures,\n\t\t\tmaxVertexTextures: maxVertexTextures,\n\t\t\tmaxTextureSize: maxTextureSize,\n\t\t\tmaxCubemapSize: maxCubemapSize,\n\t\t\tmaxAttributes: maxAttributes,\n\t\t\tmaxVertexUniforms: maxVertexUniforms,\n\t\t\tmaxVaryings: maxVaryings,\n\t\t\tmaxFragmentUniforms: maxFragmentUniforms,\n\t\t\tvertexTextures: vertexTextures,\n\t\t\tfloatFragmentTextures: floatFragmentTextures,\n\t\t\tfloatVertexTextures: floatVertexTextures,\n\t\t\tmaxSamples: maxSamples\n\t\t};\n\t}\n\n\tfunction WebGLClipping(properties) {\n\t\tvar scope = this;\n\t\tvar globalState = null,\n\t\t\t\tnumGlobalPlanes = 0,\n\t\t\t\tlocalClippingEnabled = false,\n\t\t\t\trenderingShadows = false;\n\t\tvar plane = new Plane(),\n\t\t\t\tviewNormalMatrix = new Matrix3(),\n\t\t\t\tuniform = {\n\t\t\tvalue: null,\n\t\t\tneedsUpdate: false\n\t\t};\n\t\tthis.uniform = uniform;\n\t\tthis.numPlanes = 0;\n\t\tthis.numIntersection = 0;\n\n\t\tthis.init = function (planes, enableLocalClipping, camera) {\n\t\t\tvar enabled = planes.length !== 0 || enableLocalClipping || // enable state of previous frame - the clipping code has to\n\t\t\t// run another frame in order to reset the state:\n\t\t\tnumGlobalPlanes !== 0 || localClippingEnabled;\n\t\t\tlocalClippingEnabled = enableLocalClipping;\n\t\t\tglobalState = projectPlanes(planes, camera, 0);\n\t\t\tnumGlobalPlanes = planes.length;\n\t\t\treturn enabled;\n\t\t};\n\n\t\tthis.beginShadows = function () {\n\t\t\trenderingShadows = true;\n\t\t\tprojectPlanes(null);\n\t\t};\n\n\t\tthis.endShadows = function () {\n\t\t\trenderingShadows = false;\n\t\t\tresetGlobalState();\n\t\t};\n\n\t\tthis.setState = function (material, camera, useCache) {\n\t\t\tvar planes = material.clippingPlanes,\n\t\t\t\t\tclipIntersection = material.clipIntersection,\n\t\t\t\t\tclipShadows = material.clipSh
1adows;\n\t\t\tvar materialProperties = properties.get(material);\n\n\t\t\tif (!localClippingEnabled || planes === null || planes.length === 0 || renderingShadows && !clipShadows) {\n\t\t\t\t// there's no local clipping\n\t\t\t\tif (renderingShadows) {\n\t\t\t\t\t// there's no global clipping\n\t\t\t\t\tprojectPlanes(null);\n\t\t\t\t} else {\n\t\t\t\t\tresetGlobalState();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tvar nGlobal = renderingShadows ? 0 : numGlobalPlanes,\n\t\t\t\t\t\tlGlobal = nGlobal * 4;\n\t\t\t\tvar dstArray = materialProperties.clippingState || null;\n\t\t\t\tuniform.value = dstArray; // ensure unique state\n\n\t\t\t\tdstArray = projectPlanes(planes, camera, lGlobal, useCache);\n\n\t\t\t\tfor (var i = 0; i !== lGlobal; ++i) {\n\t\t\t\t\tdstArray[i] = globalState[i];\n\t\t\t\t}\n\n\t\t\t\tmaterialProperties.clippingState = dstArray;\n\t\t\t\tthis.numIntersection = clipIntersection ? this.numPlanes : 0;\n\t\t\t\tthis.numPlanes += nGlobal;\n\t\t\t}\n\t\t};\n\n\t\tfunction resetGlobalState() {\n\t\t\tif (uniform.value !== globalState) {\n\t\t\t\tuniform.value = globalState;\n\t\t\t\tuniform.needsUpdate = numGlobalPlanes > 0;\n\t\t\t}\n\n\t\t\tscope.numPlanes = numGlobalPlanes;\n\t\t\tscope.numIntersection = 0;\n\t\t}\n\n\t\tfunction projectPlanes(planes, camera, dstOffset, skipTransform) {\n\t\t\tvar nPlanes = planes !== null ? planes.length : 0;\n\t\t\tvar dstArray = null;\n\n\t\t\tif (nPlanes !== 0) {\n\t\t\t\tdstArray = uniform.value;\n\n\t\t\t\tif (skipTransform !== true || dstArray === null) {\n\t\t\t\t\tvar flatSize = dstOffset + nPlanes * 4,\n\t\t\t\t\t\t\tviewMatrix = camera.matrixWorldInverse;\n\t\t\t\t\tviewNormalMatrix.getNormalMatrix(viewMatrix);\n\n\t\t\t\t\tif (dstArray === null || dstArray.length < flatSize) {\n\t\t\t\t\t\tdstArray = new Float32Array(flatSize);\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (var i = 0, i4 = dstOffset; i !== nPlanes; ++i, i4 += 4) {\n\t\t\t\t\t\tplane.copy(planes[i]).applyMatrix4(viewMatrix, viewNormalMatrix);\n\t\t\t\t\t\tplane.normal.toArray(dstArray, i4);\n\t\t\t\t\t\tdstArray[i4 + 3] = plane.constant;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tuniform.value = dstArray;\n\t\t\t\tuniform.needsUpdate = true;\n\t\t\t}\n\n\t\t\tscope.numPlanes = nPlanes;\n\t\t\tscope.numIntersection = 0;\n\t\t\treturn dstArray;\n\t\t}\n\t}\n\n\tfunction WebGLCubeMaps(renderer) {\n\t\tvar cubemaps = new WeakMap();\n\n\t\tfunction mapTextureMapping(texture, mapping) {\n\t\t\tif (mapping === EquirectangularReflectionMapping) {\n\t\t\t\ttexture.mapping = CubeReflectionMapping;\n\t\t\t} else if (mapping === EquirectangularRefractionMapping) {\n\t\t\t\ttexture.mapping = CubeRefractionMapping;\n\t\t\t}\n\n\t\t\treturn texture;\n\t\t}\n\n\t\tfunction get(texture) {\n\t\t\tif (texture && texture.isTexture) {\n\t\t\t\tvar mapping = texture.mapping;\n\n\t\t\t\tif (mapping === EquirectangularReflectionMapping || mapping === EquirectangularRefractionMapping) {\n\t\t\t\t\tif (cubemaps.has(texture)) {\n\t\t\t\t\t\tvar cubemap = cubemaps.get(texture).texture;\n\t\t\t\t\t\treturn mapTextureMapping(cubemap, texture.mapping);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvar image = texture.image;\n\n\t\t\t\t\t\tif (image && image.height > 0) {\n\t\t\t\t\t\t\tvar currentRenderList = renderer.getRenderList();\n\t\t\t\t\t\t\tvar currentRenderTarget = renderer.getRenderTarget();\n\t\t\t\t\t\t\tvar renderTarget = new WebGLCubeRenderTarget(image.height / 2);\n\t\t\t\t\t\t\trenderTarget.fromEquirectangularTexture(renderer, texture);\n\t\t\t\t\t\t\tcubemaps.set(texture, renderTarget);\n\t\t\t\t\t\t\trenderer.setRenderTarget(currentRenderTarget);\n\t\t\t\t\t\t\trenderer.setRenderList(currentRenderList);\n\t\t\t\t\t\t\ttexture.addEventListener('dispose', onTextureDispose);\n\t\t\t\t\t\t\treturn mapTextureMapping(renderTarget.texture, texture.mapping);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// image not yet ready. try the conversion next frame\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn texture;\n\t\t}\n\n\t\tfunction onTextureDispose(event) {\n\t\t\tvar texture = event.target;\n\t\t\ttexture.removeEventListener('dispose', onTextureDispose);\n\t\t\tvar cubemap = cubemaps.get(texture);\n\n\t\t\tif (cubemap !== undefined) {\n\t\t\t\tcubemaps.delete(texture);\n\t\t\t\tcubemap.dispose();\n\t\t\t}\n\t\t}\n\n\t\tfunction dispose() {\n\t\t\tcubemaps = new WeakMap();\n\t\t}
1\n\n\t\treturn {\n\t\t\tget: get,\n\t\t\tdispose: dispose\n\t\t};\n\t}\n\n\tfunction WebGLExtensions(gl) {\n\t\tvar extensions = {};\n\t\treturn {\n\t\t\thas: function has(name) {\n\t\t\t\tif (extensions[name] !== undefined) {\n\t\t\t\t\treturn extensions[name] !== null;\n\t\t\t\t}\n\n\t\t\t\tvar extension;\n\n\t\t\t\tswitch (name) {\n\t\t\t\t\tcase 'WEBGL_depth_texture':\n\t\t\t\t\t\textension = gl.getExtension('WEBGL_depth_texture') || gl.getExtension('MOZ_WEBGL_depth_texture') || gl.getExtension('WEBKIT_WEBGL_depth_texture');\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'EXT_texture_filter_anisotropic':\n\t\t\t\t\t\textension = gl.getExtension('EXT_texture_filter_anisotropic') || gl.getExtension('MOZ_EXT_texture_filter_anisotropic') || gl.getExtension('WEBKIT_EXT_texture_filter_anisotropic');\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'WEBGL_compressed_texture_s3tc':\n\t\t\t\t\t\textension = gl.getExtension('WEBGL_compressed_texture_s3tc') || gl.getExtension('MOZ_WEBGL_compressed_texture_s3tc') || gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'WEBGL_compressed_texture_pvrtc':\n\t\t\t\t\t\textension = gl.getExtension('WEBGL_compressed_texture_pvrtc') || gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\textension = gl.getExtension(name);\n\t\t\t\t}\n\n\t\t\t\textensions[name] = extension;\n\t\t\t\treturn extension !== null;\n\t\t\t},\n\t\t\tget: function get(name) {\n\t\t\t\tif (!this.has(name)) {\n\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: ' + name + ' extension not supported.');\n\t\t\t\t}\n\n\t\t\t\treturn extensions[name];\n\t\t\t}\n\t\t};\n\t}\n\n\tfunction WebGLGeometries(gl, attributes, info, bindingStates) {\n\t\tvar geometries = new WeakMap();\n\t\tvar wireframeAttributes = new WeakMap();\n\n\t\tfunction onGeometryDispose(event) {\n\t\t\tvar geometry = event.target;\n\t\t\tvar buffergeometry = geometries.get(geometry);\n\n\t\t\tif (buffergeometry.index !== null) {\n\t\t\t\tattributes.remove(buffergeometry.index);\n\t\t\t}\n\n\t\t\tfor (var name in buffergeometry.attributes) {\n\t\t\t\tattributes.remove(buffergeometry.attributes[name]);\n\t\t\t}\n\n\t\t\tgeometry.removeEventListener('dispose', onGeometryDispose);\n\t\t\tgeometries.delete(geometry);\n\t\t\tvar attribute = wireframeAttributes.get(buffergeometry);\n\n\t\t\tif (attribute) {\n\t\t\t\tattributes.remove(attribute);\n\t\t\t\twireframeAttributes.delete(buffergeometry);\n\t\t\t}\n\n\t\t\tbindingStates.releaseStatesOfGeometry(buffergeometry);\n\n\t\t\tif (geometry.isInstancedBufferGeometry === true) {\n\t\t\t\tdelete geometry._maxInstanceCount;\n\t\t\t} //\n\n\n\t\t\tinfo.memory.geometries--;\n\t\t}\n\n\t\tfunction get(object, geometry) {\n\t\t\tvar buffergeometry = geometries.get(geometry);\n\t\t\tif (buffergeometry) return buffergeometry;\n\t\t\tgeometry.addEventListener('dispose', onGeometryDispose);\n\n\t\t\tif (geometry.isBufferGeometry) {\n\t\t\t\tbuffergeometry = geometry;\n\t\t\t} else if (geometry.isGeometry) {\n\t\t\t\tif (geometry._bufferGeometry === undefined) {\n\t\t\t\t\tgeometry._bufferGeometry = new BufferGeometry().setFromObject(object);\n\t\t\t\t}\n\n\t\t\t\tbuffergeometry = geometry._bufferGeometry;\n\t\t\t}\n\n\t\t\tgeometries.set(geometry, buffergeometry);\n\t\t\tinfo.memory.geometries++;\n\t\t\treturn buffergeometry;\n\t\t}\n\n\t\tfunction update(geometry) {\n\t\t\tvar geometryAttributes = geometry.attributes; // Updating index buffer in VAO now. See WebGLBindingStates.\n\n\t\t\tfor (var name in geometryAttributes) {\n\t\t\t\tattributes.update(geometryAttributes[name], 34962);\n\t\t\t} // morph targets\n\n\n\t\t\tvar morphAttributes = geometry.morphAttributes;\n\n\t\t\tfor (var _name in morphAttributes) {\n\t\t\t\tvar array = morphAttributes[_name];\n\n\t\t\t\tfor (var i = 0, l = array.length; i < l; i++) {\n\t\t\t\t\tattributes.update(array[i], 34962);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction updateWireframeAttribute(geometry) {\n\t\t\tvar indices = [];\n\t\t\tvar geometryIndex = geometry.index;\n\t\t\tvar geometryPosition = geometry.attributes.position;\n\t\t\tvar version = 0;\n\n\t\t\tif (geometryIndex !== null) {\n\t\t\t\tvar array = geometryIndex.array;\n\t\t\t\tversion = geometryIndex.version;\n\n\t\t\t\tfor (var i = 0, l = array.length; i < l; i += 3) {\n\t\t\t\t\tvar a = array[i + 0];\n\t\t\t\t\tvar b = array[i + 1];\n\t\t\t\t\tvar c = array[i + 2];\n\t\t\t\t\tindices.push(a, b, b, c, c, a);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tvar _array = geometryPosition.array;\n\t\t\t\tversion = geometryPosition.version;\n\n\t\t\t\tfor (var _i = 0, _l = _array.length / 3 - 1; _i < _l; _i += 3) {\n\t\t\t\t\tvar _a = _i + 0;\n\n\t\t\t\t\tvar _b = _i + 1;\n\n\t\t\t\t\tvar _c = _i + 2;\n\n\t\t\t\t\tindices.push(_a, _b, _b, _c, _c, _a);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar attribute = new (arrayMax(indices) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute)(indices, 1);\n\t\t\tattribute.version = version; // Updating index buffer in VAO now. See WebGLBindingStates\n\t\t\t//\n\n\t\t\tvar previousAttribute = wireframeAttributes.get(geometry);\n\t\t\tif (previousAttribute) attributes.remove(previousAttribute); //\n\n\t\t\twireframeAttributes.set(geometry, attribute);\n\t\t}\n\n\t\tfunction getWireframeAttribute(geometry) {\n\t\t\tvar currentAttribute = wireframeAttributes.get(geometry);\n\n\t\t\tif (currentAttribute) {\n\t\t\t\tvar geometryIndex = geometry.index;\n\n\t\t\t\tif (geometryIndex !== null) {\n\t\t\t\t\t// if the attribute is obsolete, create a new one\n\t\t\t\t\tif (currentAttribute.version < geometryIndex.version) {\n\t\t\t\t\t\tupdateWireframeAttribute(geometry);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tupdateWireframeAttribute(geometry);\n\t\t\t}\n\n\t\t\treturn wireframeAttributes.get(geometry);\n\t\t}\n\n\t\treturn {\n\t\t\tget: get,\n\t\t\tupdate: update,\n\t\t\tgetW
1ireframeAttribute: getWireframeAttribute\n\t\t};\n\t}\n\n\tfunction WebGLIndexedBufferRenderer(gl, extensions, info, capabilities) {\n\t\tvar isWebGL2 = capabilities.isWebGL2;\n\t\tvar mode;\n\n\t\tfunction setMode(value) {\n\t\t\tmode = value;\n\t\t}\n\n\t\tvar type, bytesPerElement;\n\n\t\tfunction setIndex(value) {\n\t\t\ttype = value.type;\n\t\t\tbytesPerElement = value.bytesPerElement;\n\t\t}\n\n\t\tfunction render(start, count) {\n\t\t\tgl.drawElements(mode, count, type, start * bytesPerElement);\n\t\t\tinfo.update(count, mode, 1);\n\t\t}\n\n\t\tfunction renderInstances(start, count, primcount) {\n\t\t\tif (primcount === 0) return;\n\t\t\tvar extension, methodName;\n\n\t\t\tif (isWebGL2) {\n\t\t\t\textension = gl;\n\t\t\t\tmethodName = 'drawElementsInstanced';\n\t\t\t} else {\n\t\t\t\textension = extensions.get('ANGLE_instanced_arrays');\n\t\t\t\tmethodName = 'drawElementsInstancedANGLE';\n\n\t\t\t\tif (extension === null) {\n\t\t\t\t\tconsole.error('THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.');\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\textension[methodName](mode, count, type, start * bytesPerElement, primcount);\n\t\t\tinfo.update(count, mode, primcount);\n\t\t} //\n\n\n\t\tthis.setMode = setMode;\n\t\tthis.setIndex = setIndex;\n\t\tthis.render = render;\n\t\tthis.renderInstances = renderInstances;\n\t}\n\n\tfunction WebGLInfo(gl) {\n\t\tvar memory = {\n\t\t\tgeometries: 0,\n\t\t\ttextures: 0\n\t\t};
1\n\t\tvar render = {\n\t\t\tframe: 0,\n\t\t\tcalls: 0,\n\t\t\ttriangles: 0,\n\t\t\tpoints: 0,\n\t\t\tlines: 0\n\t\t};\n\n\t\tfunction update(count, mode, instanceCount) {\n\t\t\trender.calls++;\n\n\t\t\tswitch (mode) {\n\t\t\t\tcase 4:\n\t\t\t\t\trender.triangles += instanceCount * (count / 3);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 1:\n\t\t\t\t\trender.lines += instanceCount * (count / 2);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 3:\n\t\t\t\t\trender.lines += instanceCount * (count - 1);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 2:\n\t\t\t\t\trender.lines += instanceCount * count;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 0:\n\t\t\t\t\trender.points += instanceCount * count;\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tconsole.error('THREE.WebGLInfo: Unknown draw mode:', mode);\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tfunction reset() {\n\t\t\trender.frame++;\n\t\t\trender.calls = 0;\n\t\t\trender.triangles = 0;\n\t\t\trender.points = 0;\n\t\t\trender.lines = 0;\n\t\t}\n\n\t\treturn {\n\t\t\tmemory: memory,\n\t\t\trender: render,\n\t\t\tprograms: null,\n\t\t\tautoReset: true,\n\t\t\treset: reset,\n\t\t\tupdate: update\n\t\t};\n\t}\n\n\tfunction numericalSort(a, b) {\n\t\treturn a[0] - b[0];\n\t}\n\n\tfunction absNumericalSort(a, b) {\n\t\treturn Math.abs(b[1]) - Math.abs(a[1]);\n\t}\n\n\tfunction WebGLMorphtargets(gl) {\n\t\tvar influencesList = {};\n\t\tvar morphInfluences = new Float32Array(8);\n\t\tvar workInfluences = [];\n\n\t\tfor (var i = 0; i < 8; i++) {\n\t\t\tworkInfluences[i] = [i, 0];\n\t\t}\n\n\t\tfunction update(object, geometry, material, program) {\n\t\t\tvar objectInfluences = object.morphTargetInfluences; // When object doesn't have morph target influences defined, we treat it as a 0-length array\n\t\t\t// This is important to make sure we set up morphTargetBaseInfluence / morphTargetInfluences\n\n\t\t\tvar length = objectInfluences === undefined ? 0 : objectInfluences.length;\n\t\t\tvar influences = influencesList[geometry.id];\n\n\t\t\tif (influences === undefined) {\n\t\t\t\t// initialise list\n\t\t\t\tinfluences = [];\n\n\t\t\t\tfor (var _i = 0; _i < length;
1 _i++) {\n\t\t\t\t\tinfluences[_i] = [_i, 0];\n\t\t\t\t}\n\n\t\t\t\tinfluencesList[geometry.id] = influences;\n\t\t\t} // Collect influences\n\n\n\t\t\tfor (var _i2 = 0; _i2 < length; _i2++) {\n\t\t\t\tvar influence = influences[_i2];\n\t\t\t\tinfluence[0] = _i2;\n\t\t\t\tinfluence[1] = objectInfluences[_i2];\n\t\t\t}\n\n\t\t\tinfluences.sort(absNumericalSort);\n\n\t\t\tfor (var _i3 = 0; _i3 < 8; _i3++) {\n\t\t\t\tif (_i3 < length && influences[_i3][1]) {\n\t\t\t\t\tworkInfluences[_i3][0] = influences[_i3][0];\n\t\t\t\t\tworkInfluences[_i3][1] = influences[_i3][1];\n\t\t\t\t} else {\n\t\t\t\t\tworkInfluences[_i3][0] = Number.MAX_SAFE_INTEGER;\n\t\t\t\t\tworkInfluences[_i3][1] = 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tworkInfluences.sort(numericalSort);\n\t\t\tvar morphTargets = material.morphTargets && geometry.morphAttributes.position;\n\t\t\tvar morphNormals = material.morphNormals && geometry.morphAttributes.normal;\n\t\t\tvar morphInfluencesSum = 0;\n\n\t\t\tfor (var _i4 = 0; _i4 < 8; _i4++) {\n\t\t\t\tvar _influence = workInfluences[_i4];\n\t\t\t\tvar index = _influence[0];\n\t\t\t\tvar value = _influence[1];\n\n\t\t\t\tif (index !== Number.MAX_SAFE_INTEGER && value) {\n\t\t\t\t\tif (morphTargets && geometry.getAttribute('morphTarget' + _i4) !== morphTargets[index]) {\n\t\t\t\t\t\tgeometry.setAttribute('morphTarget' + _i4, morphTargets[index]);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (morphNormals && geometry.getAttribute('morphNormal' + _i4) !== morphNormals[index]) {\n\t\t\t\t\t\tgeometry.setAttribute('morphNormal' + _i4, morphNormals[index]);\n\t\t\t\t\t}\n\n\t\t\t\t\tmorphInfluences[_i4] = value;\n\t\t\t\t\tmorphInfluencesSum += value;\n\t\t\t\t} else {\n\t\t\t\t\tif (morphTargets && geometry.hasAttribute('morphTarget' + _i4) === true) {\n\t\t\t\t\t\tgeometry.deleteAttribute('morphTarget' + _i4);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (morphNormals && geometry.hasAttribute('morphNormal' + _i4) === true) {\n\t\t\t\t\t\tgeometry.deleteAttribute('morphNormal' + _i4);\n\t\t\t\t\t}\n\n\t\t\t\t\tmorphInfluences[_i4] = 0;\n\t\t\t\t}\n\t\t\t} // GLSL shader uses formula baseinfluence * base + sum(target * influence)\n\t\t\t// This allows us to switch between absolute morphs and relative morphs without changing shader code\n\t\t\t// When baseinfluence = 1 - sum(influence), the above is equivalent to sum((target - base) * influence)\n\n\n\t\t\tvar morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;\n\t\t\tprogram.getUniforms().setValue(gl, 'morphTargetBaseInfluence', morphBaseInfluence);\n\t\t\tprogram.getUniforms().setValue(gl, 'morphTargetInfluences', morphInfluences);\n\t\t}\n\n\t\treturn {\n\t\t\tupdate: update\n\t\t};\n\t}\n\n\tfunction WebGLObjects(gl, geometries, attributes, info) {\n\t\tvar updateMap = new WeakMap();\n\n\t\tfunction update(object) {\n\t\t\tvar frame = info.render.frame;\n\t\t\tvar geometry = object.geometry;\n\t\t\tvar buffergeometry = geometries.get(object, geometry); // Update once per frame\n\n\t\t\tif (updateMap.get(buffergeometry) !== frame) {\n\t\t\t\tif (geometry.isGeometry) {\n\t\t\t\t\tbuffergeometry.updateFromObject(object);\n\t\t\t\t}\n\n\t\t\t\tgeometries.update(buffergeometry);\n\t\t\t\tupdateMap.set(buffergeometry, frame);\n\t\t\t}\n\n\t\t\tif (object.isInstancedMesh) {\n\t\t\t\tif (object.hasEventListener('dispose', onInstancedMeshDispose) === false) {\n\t\t\t\t\tobject.addEventListener('dispose', onInstancedMeshDispose);\n\t\t\t\t}\n\n\t\t\t\tattributes.update(object.instanceMatrix, 34962);\n\n\t\t\t\tif (object.instanceColor !== null) {\n\t\t\t\t\tattributes.update(object.instanceColor, 34962);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn buffergeometry;\n\t\t}\n\n\t\tfunction dispose() {\n\t\t\tupdateMap = new WeakMap();\n\t\t}\n\n\t\tfunction onInstancedMeshDispose(event) {\n\t\t\tvar instancedMesh = event.target;\n\t\t\tinstancedMesh.removeEventListener('dispose', onInstancedMeshDispose);\n\t\t\tattributes.remove(instancedMesh.instanceMatrix);\n\t\t\tif (instancedMesh.instanceColor !== null) attributes.remove(instancedMesh.instanceColor);\n\t\t}
1\n\n\t\treturn {\n\t\t\tupdate: update,\n\t\t\tdispose: dispose\n\t\t};\n\t}\n\n\tfunction DataTexture2DArray(data, width, height, depth) {\n\t\tif (data === void 0) {\n\t\t\tdata = null;\n\t\t}\n\n\t\tif (width === void 0) {\n\t\t\twidth = 1;\n\t\t}\n\n\t\tif (height === void 0) {\n\t\t\theight = 1;\n\t\t}\n\n\t\tif (depth === void 0) {\n\t\t\tdepth = 1;\n\t\t}\n\n\t\tTexture.call(this, null);\n\t\tthis.image = {\n\t\t\tdata: data,\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\tdepth: depth\n\t\t};\n\t\tthis.magFilter = NearestFilter;\n\t\tthis.minFilter = NearestFilter;\n\t\tthis.wrapR = ClampToEdgeWrapping;\n\t\tthis.generateMipmaps = false;\n\t\tthis.flipY = false;\n\t\tthis.needsUpdate = true;\n\t}\n\n\tDataTexture2DArray.prototype = Object.create(Texture.prototype);\n\tDataTexture2DArray.prototype.constructor = DataTexture2DArray;\n\tDataTexture2DArray.prototype.isDataTexture2DArray = true;\n\n\tfunction DataTexture3D(data, width, height, depth) {\n\t\tif (data === void 0) {\n\t\t\tdata = null;\n\t\t}\n\n\t\tif (width === void 0) {\n\t\t\twidth = 1;\n\t\t}\n\n\t\tif (height === void 0) {\n\t\t\theight = 1;\n\t\t}\n\n\t\tif (depth === void 0) {\n\t\t\tdepth = 1;\n\t\t}\n\n\t\t// We're going to add .setXXX() methods for setting properties later.\n\t\t// Users can still set in DataTexture3D directly.\n\t\t//\n\t\t//\tconst texture = new THREE.DataTexture3D( data, width, height, depth );\n\t\t// \ttexture.anisotropy = 16;\n\t\t//\n\t\t// See #14839\n\t\tTexture.call(this, null);\n\t\tthis.image = {\n\t\t\tdata: data,\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\tdepth: depth\n\t\t};\n\t\tthis.magFilter = NearestFilter;\n\t\tthis.minFilter = NearestFilter;\n\t\tthis.wrapR = ClampToEdgeWrapping;\n\t\tthis.generateMipmaps = false;\n\t\tthis.flipY = false;\n\t\tthis.needsUpdate = true;\n\t}\n\n\tDataTexture3D.prototype = Object.create(Texture.prototype);\n\tDataTexture3D.prototype.constructor = DataTexture3D;\n\tDataTexture3D.prototype.isDataTexture3D = true;\n\n\t/**\n\t * Uniforms of a program.\n\t * Those form a tree structure with a special top-level container for the root,\n\t * which you get by calling 'new WebGLUniforms( gl, program )'.\n\t *\n\t *\n\t * Properties of inner nodes including the top-level container:\n\t *\n\t * .seq - array of nested uniforms\n\t * .map - nested uniforms by name\n\t *\n\t *\n\t * Methods of all nodes except the top-level container:\n\t *\n\t * .setValue( gl, value, [textures] )\n\t *\n\t * \t\tuploads a uniform value(s)\n\t *\t\tthe 'textures' parameter is needed for sampler uniforms\n\t *\n\t *\n\t * Static methods of the top-level container (textures factorizations):\n\t *\n\t * .upload( gl, seq, values, textures )\n\t *\n\t * \t\tsets uniforms in 'seq' to 'values[id].value'\n\t *\n\t * .seqWithValue( seq, values ) : filteredSeq\n\t *\n\t * \t\tfilters 'seq' entries with corresponding entry in values\n\t *\n\t *\n\t * Methods of the top-level container (textures factorizations):\n\t *\n\t * .setValue( gl, name, value, textures )\n\t *\n\t * \t\tsets uniform with\tname 'name' to 'value'\n\t *\n\t * .setOptional( gl, obj, prop )\n\t *\n\t * \t\tlike .set for an optional property of the object\n\t *\n\t */\n\tvar emptyTexture = new Texture();\n\tvar emptyTexture2dArray = new DataTexture2DArray();\n\tvar emptyTexture3d = new DataTexture3D();\n\tvar emptyCubeTexture = new CubeTexture(); // --- Utilities ---\n\t// Array Caches (provide typed arrays for temporary by size)\n\n\tvar arrayCacheF32 = [];\n\tvar arrayCacheI32 = []; // Float32Array caches used for uploading Matrix uniforms\n\n\tvar mat4array = new Float32Array(16);\n\tvar mat3array = new Float32Array(9);\n\tvar mat2array = new Float32Array(4); // Flattening for arrays of vectors and matrices\n\n\tfunction flatten(array, nBlocks, blockSize) {\n\t\tvar firstElem = array[0];\n\t\tif (firstElem <= 0 || firstElem > 0) return array; // unoptimized: ! isNaN( firstElem )\n\t\t// see http://jacksondunstan.com/articles/983\n\n\t\tvar n = nBlocks * blockSize;\n\t\tvar r = arrayCacheF32[n];\n\n\t\tif (r === undefined) {\n\t\t\tr = new Float32Array(n);\n\t\t\tarrayCacheF32[n] = r;\n\t\t}\n\n\t\tif (nBlocks !== 0) {\n\t\t\tfirstElem.toArray(r, 0);\n\n\t\t\tfor (var i = 1, offset = 0; i !== nBlocks; ++i) {\n\t\t\t\toffset += blockSize;\n\t\t\t\tarray[i].toArray(r, offset);\n\t\t\t}\n\t\t}\n\n\t\treturn r;\n\t}\n\n\tfunction arraysEqual(a, b) {\n\t\tif (a.length !== b.length) return false;\n\n\t\tfor (var i = 0, l = a.length; i < l;
1 i++) {\n\t\t\tif (a[i] !== b[i]) return false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tfunction copyArray(a, b) {\n\t\tfor (var i = 0, l = b.length; i < l; i++) {\n\t\t\ta[i] = b[i];\n\t\t}\n\t} // Texture unit allocation\n\n\n\tfunction allocTexUnits(textures, n) {\n\t\tvar r = arrayCacheI32[n];\n\n\t\tif (r === undefined) {\n\t\t\tr = new Int32Array(n);\n\t\t\tarrayCacheI32[n] = r;\n\t\t}\n\n\t\tfor (var i = 0; i !== n; ++i) {\n\t\t\tr[i] = textures.allocateTextureUnit();\n\t\t}\n\n\t\treturn r;\n\t} // --- Setters ---\n\t// Note: Defining these methods externally, because they come in a bunch\n\t// and this way their names minify.\n\t// Single scalar\n\n\n\tfunction setValueV1f(gl, v) {\n\t\tvar cache = this.cache;\n\t\tif (cache[0] === v) return;\n\t\tgl.uniform1f(this.addr, v);\n\t\tcache[0] = v;\n\t} // Single float vector (from flat array or THREE.VectorN)\n\n\n\tfunction setValueV2f(gl, v) {\n\t\tvar cache = this.cache;\n\n\t\tif (v.x !== undefined) {\n\t\t\tif (cache[0] !== v.x || cache[1] !== v.y) {\n\t\t\t\tgl.uniform2f(this.addr, v.x, v.y);\n\t\t\t\tcache[0] = v.x;\n\t\t\t\tcache[1] = v.y;\n\t\t\t}\n\t\t} else {\n\t\t\tif (arraysEqual(cache, v)) return;\n\t\t\tgl.uniform2fv(this.addr, v);\n\t\t\tcopyArray(cache, v);\n\t\t}\n\t}\n\n\tfunction setValueV3f(gl, v) {\n\t\tvar cache = this.cache;\n\n\t\tif (v.x !== undefined) {\n\t\t\tif (cache[0] !== v.x || cache[1] !== v.y || cache[2] !== v.z) {\n\t\t\t\tgl.uniform3f(this.addr, v.x, v.y, v.z);\n\t\t\t\tcache[0] = v.x;\n\t\t\t\tcache[1] = v.y;\n\t\t\t\tcache[2] = v.z;\n\t\t\t}\n\t\t} else if (v.r !== undefined) {\n\t\t\tif (cache[0] !== v.r || cache[1] !== v.g || cache[2] !== v.b) {\n\t\t\t\tgl.uniform3f(this.addr, v.r, v.g, v.b);\n\t\t\t\tcache[0] = v.r;\n\t\t\t\tcache[1] = v.g;\n\t\t\t\tcache[2] = v.b;\n\t\t\t}\n\t\t} else {\n\t\t\tif (arraysEqual(cache, v)) return;\n\t\t\tgl.uniform3fv(this.addr, v);\n\t\t\tcopyArray(cache, v);\n\t\t}\n\t}\n\n\tfunction setValueV4f(gl, v) {\n\t\tvar cache = this.cache;\n\n\t\tif (v.x !== undefined) {\n\t\t\tif (cache[0] !== v.x || cache[1] !== v.y || cache[2] !== v.z || cache[3] !== v.w) {\n\t\t\t\tgl.uniform4f(this.addr, v.x, v.y, v.z, v.w);\n\t\t\t\tcache[0] = v.x;\n\t\t\t\tcache[1] = v.y;\n\t\t\t\tcache[2] = v.z;\n\t\t\t\tcache[3] = v.w;\n\t\t\t}\n\t\t} else {\n\t\t\tif (arraysEqual(cache, v)) return;\n\t\t\tgl.uniform4fv(this.addr, v);\n\t\t\tcopyArray(cache, v);\n\t\t}\n\t} // Single matrix (from flat array or MatrixN)\n\n\n\tfunction setValueM2(gl, v) {\n\t\tvar cache = this.cache;\n\t\tvar elements = v.elements;\n\n\t\tif (elements === undefined) {\n\t\t\tif (arraysEqual(cache, v)) return;\n\t\t\tgl.uniformMatrix2fv(this.addr, false, v);\n\t\t\tcopyArray(cache, v);\n\t\t} else {\n\t\t\tif (arraysEqual(cache, elements)) return;\n\t\t\tmat2array.set(elements);\n\t\t\tgl.uniformMatrix2fv(this.addr, false, mat2array);\n\t\t\tcopyArray(cache, elements);\n\t\t}\n\t}\n\n\tfunction setValueM3(gl, v) {\n\t\tvar cache = this.cache;\n\t\tvar elements = v.elements;\n\n\t\tif (elements === undefined) {\n\t\t\tif (arraysEqual(cache, v)) return;\n\t\t\tgl.uniformMatrix3fv(this.addr, false, v);\n\t\t\tcopyArray(cache, v);\n\t\t} else {\n\t\t\tif (arraysEqual(cache, elements)) return;\n\t\t\tmat3array.set(elements);\n\t\t\tgl.uniformMatrix3fv(this.addr, false, mat3array);\n\t\t\tcopyArray(cache, elements);\n\t\t}\n\t}\n\n\tfunction setValueM4(gl, v) {\n\t\tvar cache = this.cache;\n\t\tvar elements = v.elements;\n\n\t\tif (elements === undefined) {\n\t\t\tif (arraysEqual(cache, v)) return;\n\t\t\tgl.uniformMatrix4fv(this.addr, false, v);\n\t\t\tcopyArray(cache, v);\n\t\t} else {\n\t\t\tif (arraysEqual(cache, elements)) return;\n\t\t\tmat4array.set(elements);\n\t\t\tgl.uniformMatrix4fv(this.addr, false, mat4array);\n\t\t\tcopyArray(cache, elements);\n\t\t}\n\t} // Single texture (2D / Cube)\n\n\n\tfunction setValueT1(gl, v, textures) {\n\t\tvar cache = this.cache;\n\t\tvar unit = textures.allocateTextureUnit();\n\n\t\tif (cache[0] !== unit) {\n\t\t\tgl.uniform1i(this.addr, unit);\n\t\t\tcache[0] = unit;\n\t\t}\n\n\t\ttextures.safeSetTexture2D(v || emptyTexture, unit);\n\t}\n\n\tfunction setValueT2DArray1(gl, v, textures) {\n\t\tvar cache = this.cache;\n\t\tvar unit = textures.allocateTextureUnit();\n\n\t\tif (cache[0] !== unit) {\n\t\t\tgl.uniform1i(this.addr, unit);\n\t\t\tcache[0] = unit;\n\t\t}\n\n\t\ttextures.setTexture2DArray(v || emptyTexture2dArray, unit);\n\t}\n\n\tfunction setValueT3D1(gl, v, textures) {\n\t\tvar cache = this.cache;\n\t\tvar unit = textures.allocateTextureUnit();\n\n\t\tif (cache[0] !== unit) {\n\t\t\tgl.uniform1i(this.addr, unit);\n\t\t\tcache[0] = unit;\n\t\t}\n\n\t\ttextures.setTexture3D(v || emptyTexture3d, unit);\n\t}\n\n\tfunction setValueT6(gl, v, textures) {\n\t\tvar cache = this.cache;\n\t\tvar unit = textures.allocateTextureUnit();\n\n\t\tif (cache[0] !== unit) {\n\t\t\tgl.uniform1i(this.addr, unit);\n\t\t\tcache[0] = unit;\n\t\t}\n\n\t\ttextures.safeSetTextureCube(v || emptyCubeTexture, unit);\n\t} // Integer / Boolean vectors or arrays thereof (always flat arrays)\n\n\n\tfunction setValueV1i(gl, v) {\n\t\tvar cache = this.cache;\n\t\tif (cache[0] === v) return;\n\t\tgl.uniform1i(this.addr, v);\n\t\tcache[0] = v;\n\t}\n\n\tfunction setValueV2i(gl, v) {\n\t\tvar cache = this.cache;\n\t\tif (arraysEqual(cache, v)) return;\n\t\tgl.uniform2iv(this.addr, v);\n\t\tcopyArray(cache, v);\n\t}\n\n\tfunction setValueV3i(gl, v) {\n\t\tvar cache = this.cache;\n\t\tif (arraysEqual(cache, v)) return;\n\t\tgl.uniform3iv(this.addr, v);\n\t\tcopyArray(cache, v);\n\t}\n\n\tfunction setValueV4i(gl, v) {\n\t\tvar cache = this.cache;\n\t\tif (arraysEqual(cache, v)) return;\n\t\tgl.uniform4iv(this.addr, v);\n\t\tcopyArray(cache, v);\n\t} // uint\n\n\n\tfunction setValueV1ui(gl, v) {\n\t\tvar cache = this.cache;\n\t\tif (cache[0] === v) return;\n\t\tgl.uniform1ui(this.addr, v);\n\t\tcache[0] = v;\n\t} // Helper to pick the right setter for the singular case\n\n\n\tfunction getSingularSetter(type) {\n\t\tswitch (type) {\n\t\t\tcase 0x1406:\n\t\t\t\treturn setValueV1f;\n\t\t\t// FLOAT\n\n\t\t\tcase 0x8b50:\n\t\t\t\treturn setValueV2f;\n\t\t\t// _VEC2\n\n\t\t\tcase 0x8b51:\n\t\t\t\treturn setValueV3f;\n\t\t\t// _VEC3\n\n\t\t\tcase 0x8b52:\n\t\t\t\treturn setValueV4f;\n\t\t\t// _VEC4\n\n\t\t\tcase 0x8b5a:\n\t\t\t\treturn setValueM2;\n\t\t\t// _MAT2\n\n\t\t\tcase 0x8b5b:\n\t\t\t\treturn setValueM3;\n\t\t\t// _MAT3\n\n\t\t\tcase 0x8b5c:\n\t\t\t\treturn setValueM4;\n\t\t\t// _MAT4\n\n\t\t\tcase 0x1404:\n\t\t\tcase 0x8b56:\n\t\t\t\treturn setValueV1i;\n\t\t\t// INT, BOOL\n\n\t\t\tcase 0x8b53:\n\t\t\tcase 0x8b57:\n\t\t\t\treturn setValueV2i;\n\t\t\t// _VEC2\n\n\t\t\tcase 0x8b54:\n\t\t\tcase 0x8b58:\n\t\t\t\treturn setValueV3i;\n\t\t\t// _VEC3\n\n\t\t\tcase 0x8b55:\n\t\t\tcase 0x8b59:\n\t\t\t\treturn setValueV4i;\n\t\t\t// _VEC4\n\n\t\t\tcase 0x1405:\n\t\t\t\treturn setValueV1ui;\n\t\t\t// UINT\n\n\t\t\tcase 0x8b5e: // SAMPLER_2D\n\n\t\t\tcase 0x8d66: // SAMPLER_EXTERNAL_OES\n\n\t\t\tcase 0x8dca: // INT_SAMPLER_2D\n\n\t\t\tcase 0x8dd2: // UNSIGNED_INT_SAMPLER_2D\n\n\t\t\tcase 0x8b62:\n\t\t\t\t// SAMPLER_2D_SHADOW\n\t\t\t\treturn setValueT1;\n\n\t\t\tcase 0x8b5f: // SAMPLER_3D\n\n\t\t\tcase 0x8dcb: // INT_SAMPLER_3D\n\n\t\t\tcase 0x8dd3:\n\t\t\t\t// UNSIGNED_INT_SAMPLER_3D\n\t\t\t\treturn setValueT3D1;\n\n\t\t\tcase 0x8b60: // SAMPLER_CUBE\n\n\t\t\tcase 0x8dcc: // INT_SAMPLER_CUBE\n\n\t\t\tcase 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE\n\n\t\t\tcase 0x8dc5:\n\t\t\t\t// SAMPLER_CUBE_SHADOW\n\t\t\t\treturn setValueT6;\n\n\t\t\tcase 0x8dc1: // SAMPLER_2D_ARRAY\n\n\t\t\tcase 0x8dcf: // INT_SAMPLER_2D_ARRAY\n\n\t\t\tcase 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY\n\n\t\t\tcase 0x8dc4:\n\t\t\t\t// SAMPLER_2D_ARRAY_SHADOW\n\t\t\t\treturn setValueT2DArray1;\n\t\t}\n\t} // Array of scalars\n\n\n\tfunction setValueV1fArray(gl, v) {\n\t\tgl.uniform1fv(this.addr, v);\n\t} // Integer / Boolean vectors or arrays thereof (always flat arrays)\n\n\n\tfunction setValueV1iArray(gl, v) {\n\t\tgl.uniform1iv(this.addr, v);\n\t}\n\n\tfunction setValueV2iArray(gl, v) {\n\t\tgl.uniform2iv(this.addr, v);\n\t}\n\n\tfunction setValueV3iArray(gl, v) {\n\t\tgl.uniform3iv(this.addr, v);\n\t}\n\n\tfunction setValueV4iArray(gl, v) {\n\t\tgl.uniform4iv(this.addr, v);\n\t} // Array of vectors (flat or from THREE classes)\n\n\n\tfunction setValueV2fArray(gl, v) {\n\t\tvar data = flatten(v, this.size, 2);\n\t\tgl.uniform2fv(this.addr, data);\n\t}\n\n\tfunction setValueV3fArray(gl, v) {\n\t\tvar data = flatten(v, this.size, 3);\n\t\tgl.uniform3fv(this.addr, data);\n\t}\n\n\tfunction setValueV4fArray(gl, v) {\n\t\tvar data = flatten(v, this.size, 4);\n\t\tgl.uniform4fv(this.addr, data);\n\t} // Array of matrices (flat or from THREE clases)\n\n\n\tfunction setValueM2Array(gl, v) {\n\t\tvar data = flatten(v, this.size, 4);\n\t\tgl.uniformMatrix2fv(this.addr, false, data);\n\t}\n\n\tfunction setValueM3Array(gl, v) {\n\t\tvar data = flatten(v, this.size, 9);\n\t\tgl.uniformMatrix3fv(this.addr, false, data);\n\t}\n\n\tfunction setValueM4Array(gl, v) {\n\t\tvar data = flatten(v, this.size, 16);\n\t\tgl.uniformMatrix4fv(this.addr, false, data);\n\t} // Array of textures (2D / Cube)\n\n\n\tfunction setValueT1Array(gl, v, textures) {\n\t\tvar n = v.length;\n\t\tvar units = allocTexUnits(textures, n);\n\t\tgl.uniform1iv(this.addr, units);\n\n\t\tfor (var i = 0; i !== n; ++i) {\n\t\t\ttextures.safeSetTexture2D(v[i] || emptyTexture, units[i]);\n\t\t}\n\t}\n\n\tfunction setValueT6Array(gl, v, textures) {\n\t\tvar n = v.length;\n\t\tvar units = allocTexUnits(textures, n);\n\t\tgl.uniform1iv(this.addr, units);\n\n\t\tfor (var i = 0; i !== n; ++i) {\n\t\t\ttextures.safeSetTextureCube(v[i] || emptyCubeTexture, units[i]);\n\t\t}\n\t} // Helper to pick the right setter for a pure (bottom-level) array\n\n\n\tfunction getPureArraySetter(type) {\n\t\tswitch (type) {\n\t\t\tcase 0x1406:\n\t\t\t\treturn setValueV1fArray;\n\t\t\t// FLOAT\n\n\t\t\tcase 0x8b50:\n\t\t\t\treturn setValueV2fArray;\n\t\t\t// _VEC2\n\n\t\t\tcase 0x8b51:\n\t\t\t\treturn setValueV3fArray;\n\t\t\t// _VEC3\n\n\t\t\tcase 0x8b52:\n\t\t\t\treturn setValueV4fArray;\n\t\t\t// _VEC4\n\n\t\t\tcase 0x8b5a:\n\t\t\t\treturn setValueM2Array;\n\t\t\t// _MAT2\n\n\t\t\tcase 0x8b5b:\n\t\t\t\treturn setValueM3Array;\n\t\t\t// _MAT3\n\n\t\t\tcase 0x8b5c:\n\t\t\t\treturn setValueM4Array;\n\t\t\t// _MAT4\n\n\t\t\tcase 0x1404:\n\t\t\tcase 0x8b56:\n\t\t\t\treturn setValueV1iArray;\n\t\t\t// INT, BOOL\n\n\t\t\tcase 0x8b53:\n\t\t\tcase 0x8b57:\n\t\t\t\treturn setValueV2iArray;\n\t\t\t// _VEC2\n\n\t\t\tcase 0x8b54:\n\t\t\tcase 0x8b58:\n\t\t\t\treturn setValueV3iArray;\n\t\t\t// _VEC3\n\n\t\t\tcase 0x8b55:\n\t\t\tcase 0x8b59:\n\t\t\t\treturn setValueV4iArray;\n\t\t\t// _VEC4\n\n\t\t\tcase 0x8b5e: // SAMPLER_2D\n\n\t\t\tcase 0x8d66: // SAMPLER_EXTERNAL_OES\n\n\t\t\tcase 0x8dca: // INT_SAMPLER_2D\n\n\t\t\tcase 0x8dd2: // UNSIGNED_INT_SAMPLER_2D\n\n\t\t\tcase 0x8b62:\n\t\t\t\t// SAMPLER_2D_SHADOW\n\t\t\t\treturn setValueT1Array;\n\n\t\t\tcase 0x8b60: // SAMPLER_CUBE\n\n\t\t\tcase 0x8dcc: // INT_SAMPLER_CUBE\n\n\t\t\tcase 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE\n\n\t\t\tcase 0x8dc5:\n\t\t\t\t// SAMPLER_CUBE_SHADOW\n\t\t\t\treturn setValueT6Array;\n\t\t}\n\t} // --- Uniform Classes ---\n\n\n\tfunction SingleUniform(id, activeInfo, addr) {\n\t\tthis.id = id;\n\t\tthis.addr = addr;\n\t\tthis.cache = [];\n\t\tthis.setValue = getSingularSetter(activeInfo.type); // this.path = activeInfo.name; // DEBUG\n\t}\n\n\tfunction PureArrayUniform(id, activeInfo, addr) {\n\t\tthis.id = id;\n\t\tthis.addr = addr;\n\t\tthis.cache = [];\n\t\tthis.size = activeInfo.size;\n\t\tthis.setValue = getPureArraySetter(activeInfo.type); // this.path = activeInfo.name; // DEBUG\n\t}\n\n\tPureArrayUniform.prototype.updateCache = function (data) {\
1n\t\tvar cache = this.cache;\n\n\t\tif (data instanceof Float32Array && cache.length !== data.length) {\n\t\t\tthis.cache = new Float32Array(data.length);\n\t\t}\n\n\t\tcopyArray(cache, data);\n\t};\n\n\tfunction StructuredUniform(id) {\n\t\tthis.id = id;\n\t\tthis.seq = [];\n\t\tthis.map = {};\n\t}\n\n\tStructuredUniform.prototype.setValue = function (gl, value, textures) {\n\t\tvar seq = this.seq;\n\n\t\tfor (var i = 0, n = seq.length; i !== n; ++i) {\n\t\t\tvar u = seq[i];\n\t\t\tu.setValue(gl, value[u.id], textures);\n\t\t}\n\t}; // --- Top-level ---\n\t// Parser - builds up the property tree from the path strings\n\n\n\tvar RePathPart = /(\\w+)(\\])?(\\[|\\.)?/g; // extracts\n\t// \t- the identifier (member name or array index)\n\t//\t- followed by an optional right bracket (found when array index)\n\t//\t- followed by an optional left bracket or dot (type of subscript)\n\t//\n\t// Note: These portions can be read in a non-overlapping fashion and\n\t// allow straightforward parsing of the hierarchy that WebGL encodes\n\t// in the uniform names.\n\n\tfunction addUniform(container, uniformObject) {\n\t\tcontainer.seq.push(uniformObject);\n\t\tcontainer.map[uniformObject.id] = uniformObject;\n\t}\n\n\tfunction parseUniform(activeInfo, addr, container) {\n\t\tvar path = activeInfo.name,\n\t\t\t\tpathLength = path.length; // reset RegExp object, because of the early exit of a previous run\n\n\t\tRePathPart.lastIndex = 0;\n\n\t\twhile (true) {\n\t\t\tvar match = RePathPart.exec(path),\n\t\t\t\t\tmatchEnd = RePathPart.lastIndex;\n\t\t\tvar id = match[1];\n\t\t\tvar idIsIndex = match[2] === ']',\n\t\t\t\t\tsubscript = match[3];\n\t\t\tif (idIsIndex) id = id | 0; // convert to integer\n\n\t\t\tif (subscript === undefined || subscript === '[' && matchEnd + 2 === pathLength) {\n\t\t\t\t// bare name or \"pure\" bottom-level array \"[0]\" suffix\n\t\t\t\taddUniform(container, subscript === undefined ? new SingleUniform(id, activeInfo, addr) : new PureArrayUniform(id, activeInfo, addr));\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\t// step into inner node / create it in case it doesn't exist\n\t\t\t\tvar map = container.map;\n\t\t\t\tvar next = map[id];\n\n\t\t\t\tif (next === undefined) {\n\t\t\t\t\tnext = new StructuredUniform(id);\n\t\t\t\t\taddUniform(container, next);\n\t\t\t\t}\n\n\t\t\t\tcontainer = next;\n\t\t\t}\n\t\t}\n\t} // Root Container\n\n\n\tfunction WebGLUniforms(gl, program) {\n\t\tthis.seq = [];\n\t\tthis.map = {};\n\t\tvar n = gl.getProgramParameter(program, 35718);\n\n\t\tfor (var i = 0; i < n; ++i) {\n\t\t\tvar info = gl.getActiveUniform(program, i),\n\t\t\t\t\taddr = gl.getUniformLocation(program, info.name);\n\t\t\tparseUniform(info, addr, this);\n\t\t}\n\t}\n\n\tWebGLUniforms.prototype.setValue = function (gl, name, value, textures) {\n\t\tvar u = this.map[name];\n\t\tif (u !== undefined) u.setValue(gl, value, textures);\n\t};\n\n\tWebGLUniforms.prototype.setOptional = function (gl, object, name) {\n\t\tvar v = object[name];\n\t\tif (v !== undefined) this.setValue(gl, name, v);\n\t}; // Static interface\n\n\n\tWebGLUniforms.upload = function (gl, seq, values, textures) {\n\t\tfor (var i = 0, n = seq.length; i !== n; ++i) {\n\t\t\tvar u = seq[i],\n\t\t\t\t\tv = values[u.id];\n\n\t\t\tif (v.needsUpdate !== false) {\n\t\t\t\t// note: always updating when .needsUpdate is undefined\n\t\t\t\tu.setValue(gl, v.value, textures);\n\t\t\t}\n\t\t}\n\t};\n\n\tWebGLUniforms.seqWithValue = function (seq, values) {\n\t\tvar r = [];\n\n\t\tfor (var i = 0, n = seq.length; i !== n; ++i) {\n\t\t\tvar u = seq[i];\n\t\t\tif (u.id in values) r.push(u);\n\t\t}\n\n\t\treturn r;\n\t};\n\n\tfunction WebGLShader(gl, type, string) {\n\t\tvar shader = gl.createShader(type);\n\t\tgl.shaderSource(shader, string);\n\t\tgl.compileShader(shader);\n\t\treturn shader;\n\t}\n\n\tvar programIdCount = 0;\n\n\tfunction addLineNumbers(string) {\n\t\tvar lines = string.split('\\n');\n\n\t\tfor (var i = 0; i < lines.length; i++) {\n\t\t\tlines[i] = i + 1 + ': ' + lines[i];\n\t\t}\n\n\t\treturn lines.join('\\n');\n\t}\n\n\tfunction getEncodingComponents(encoding) {\n\t\tswitch (encoding) {\n\t\t\tcase LinearEncoding:\n\t\t\t\treturn ['Linear', '( value )'];\n\n\t\t\tcase sRGBEncoding:\n\t\t\t\treturn ['sRGB', '( value )'];\n\n\t\t\tcase RGBEEncoding:\n\t\t\t\treturn ['RGBE', '( value )'];\n\n\t\t\tcase RGBM7Encoding:\n\t\t\t\treturn ['RGBM', '( value, 7.0 )'];\n\n\t\t\tcase RGBM16Encoding:\n\t\t\t\treturn ['RGBM', '( value, 16.0 )'];\n\n\t\t\tcase RGBDEncoding:\n\t\t\t\treturn ['RGBD', '( value, 256.0 )'];\n\n\t\t\tcase GammaEncoding:\n\t\t\t\treturn ['Gamma', '( value, float( GAMMA_FACTOR ) )'];\n\n\t\t\tcase LogLuvEncoding:\n\t\t\t\treturn ['LogLuv', '( value )'];\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn('THREE.WebGLProgram: Unsupported encoding:', encoding);\n\t\t\t\treturn ['Linear', '( value )'];\n\t\t}\n\t}\n\n\tfunction getShaderErrors(gl, shader, type) {\n\t\tvar status = gl.getShaderParameter(shader, 35713);\n\t\tvar log = gl.getShaderInfoLog(shader).trim();\n\t\tif (status && log === '') return ''; // --enable-privileged-webgl-extension\n\t\t// console.log( '**' + type + '**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );\n\n\t\tvar source = gl.getShaderSource(shader);\n\t\treturn 'THREE.WebGLShader: gl.getShaderInfoLog() ' + type + '\\n' + log + addLineNumbers(source);\n\t}\n\n\tfunction getTexelDecodingFunction(functionName, encoding) {\n\t\tvar components = getEncodingComponents(encoding);\n\t\treturn 'vec4 ' + functionName + '( vec4 value ) { return ' + components[0] + 'ToLinear' + components[1] + '; }';\n\t}\n\n\tfunction getTexelEncodingFunction(functionName, encoding) {\n\t\tvar components = getEncodingComponents(encoding);\n\t\treturn 'vec4 ' + functionName + '( vec4 value ) { return LinearTo' + components[0] + components[1] + '; }';\n\t}\n\n\tfunction getToneMappingFunction(functionName, toneMapping) {\n\t\tvar toneMappingName;\n\n\t\tswitch (toneMapping) {\n\t\t\tcase LinearToneMapping:\n\t\t\t\ttoneMappingName = 'Linear';\n\t\t\t\tbreak;\n\n\t\t\tcase ReinhardToneMapping:\n\t\t\t\ttoneMappingName = 'Reinhard';\n\t\t\t\tbreak;\n\n\t\t\tcase CineonToneMapping:\n\t\t\t\ttoneMappingName = 'OptimizedCineon';\n\t\t\t\tbreak;\n\n\t\t\tcase ACESFilmicToneMapping:\n\t\t\t\ttoneMappingName = 'ACESFilmic';\n\t\t\t\tbreak;\n\n\t\t\tcase CustomToneMapping:\n\t\t\t\ttoneMappingName = 'Custom';\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn('THREE.WebGLProgram: Unsupported toneMapping:', toneMapping);\n\t\t\t\ttoneMappingName = 'Linear';\n\t\t}\n\n\t\treturn 'vec3 ' + functionName + '( vec3 color ) { return ' + toneMappingName + 'ToneMapping( color ); }';\n\t}\n\n\tfunction generateExtensions(parameters) {\n\t\tvar chunks = [parameters.extensionDerivatives || parameters.envMapCubeUV || parameters.bumpMap || parameters.tangentSpaceNormalMap || parameters.clearcoatNormalMap || parameters.flatShading || parameters.shaderID === 'physical' ? '#extension GL_OES_standard_derivatives : enable' : '', (parameters.extensionFragDepth || parameters.logarithmicDepthBuffer) && parameters.rendererExtensionFragDepth ? '#extension GL_EXT_frag_depth : enable' : '', parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ? '#extension GL_EXT_draw_buffers : require' : '', (parameters.extensionShaderTextureLOD || parameters.envMap) && parameters.rendererExtensionShaderTextureLod ? '#extension GL_EXT_shader_texture_lod : enable' : ''];\n\t\treturn chunks.filter(filterEmptyLine).join('\\n');\n\t}\n\n\tfunction generateDefines(defines) {\n\t\tvar chunks = [];\n\n\t\tfor (var name in defines) {\n\t\t\tvar value = defines[name];\n\t\t\tif (value === false) continue;\n\t\t\tchunks.push('#define ' + name + ' ' + value);\n\t\t}\n\n\t\treturn chunks.join('\\n');\n\t}\n\n\tfunction fetchAttributeLocations(gl, program) {\n\t\tvar attributes = {};\n\t\tvar n = gl.getProgramParameter(program, 35721);\n\n\t\tfor (var i = 0; i < n;
1 i++) {\n\t\t\tvar info = gl.getActiveAttrib(program, i);\n\t\t\tvar name = info.name; // console.log( 'THREE.WebGLProgram: ACTIVE VERTEX ATTRIBUTE:', name, i );\n\n\t\t\tattributes[name] = gl.getAttribLocation(program, name);\n\t\t}\n\n\t\treturn attributes;\n\t}\n\n\tfunction filterEmptyLine(string) {\n\t\treturn string !== '';\n\t}\n\n\tfunction replaceLightNums(string, parameters) {\n\t\treturn string.replace(/NUM_DIR_LIGHTS/g, parameters.numDirLights).replace(/NUM_SPOT_LIGHTS/g, parameters.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g, parameters.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, parameters.numPointLights).replace(/NUM_HEMI_LIGHTS/g, parameters.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g, parameters.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g, parameters.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, parameters.numPointLightShadows);\n\t}\n\n\tfunction replaceClippingPlaneNums(string, parameters) {\n\t\treturn string.replace(/NUM_CLIPPING_PLANES/g, parameters.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, parameters.numClippingPlanes - parameters.numClipIntersection);\n\t} // Resolve Includes\n\n\n\tvar includePattern = /^[ \\t]*#include +<([\\w\\d./]+)>/gm;\n\n\tfunction resolveIncludes(string) {\n\t\treturn string.replace(includePattern, includeReplacer);\n\t}\n\n\tfunction includeReplacer(match, include) {\n\t\tvar string = ShaderChunk[include];\n\n\t\tif (string === undefined) {\n\t\t\tthrow new Error('Can not resolve #include <' + include + '>');\n\t\t}\n\n\t\treturn resolveIncludes(string);\n\t} // Unroll Loops\n\n\n\tvar deprecatedUnrollLoopPattern = /#pragma unroll_loop[\\s]+?for \\( int i \\= (\\d+)\\; i < (\\d+)\\; i \\+\\+ \\) \\{([\\s\\S]+?)(?=\\})\\}/g;\n\tvar unrollLoopPattern = /#pragma unroll_loop_start\\s+for\\s*\\(\\s*int\\s+i\\s*=\\s*(\\d+)\\s*;\\s*i\\s*<\\s*(\\d+)\\s*;\\s*i\\s*\\+\\+\\s*\\)\\s*{([\\s\\S]+?)}\\s+#pragma unroll_loop_end/g;\n\n\tfunction unrollLoops(string) {\n\t\treturn string.replace(unrollLoopPattern, loopReplacer).replace(deprecatedUnrollLoopPattern, deprecatedLoopReplacer);\n\t}\n\n\tfunction deprecatedLoopReplacer(match, start, end, snippet) {\n\t\tconsole.warn('WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead.');\n\t\treturn loopReplacer(match, start, end, snippet);\n\t}\n\n\tfunction loopReplacer(match, start, end, snippet) {\n\t\tvar string = '';\n\n\t\tfor (var i = parseInt(start); i < parseInt(end); i++) {\n\t\t\tstring += snippet.replace(/\\[\\s*i\\s*\\]/g, '[ ' + i + ' ]').replace(/UNROLLED_LOOP_INDEX/g, i);\n\t\t}\n\n\t\treturn string;\n\t} //\n\n\n\tfunction generatePrecision(parameters) {\n\t\tvar precisionstring = 'precision ' + parameters.precision + ' float;\\nprecision ' + parameters.precision + ' int;';\n\n\t\tif (parameters.precision === 'highp') {\n\t\t\tprecisionstring += '\\n#define HIGH_PRECISION';\n\t\t} else if (parameters.precision === 'mediump') {\n\t\t\tprecisionstring += '\\n#define MEDIUM_PRECISION';\n\t\t} else if (parameters.precision === 'lowp') {\n\t\t\tprecisionstring += '\\n#define LOW_PRECISION';\n\t\t}\n\n\t\treturn precisionstring;\n\t}\n\n\tfunction generateShadowMapTypeDefine(parameters) {\n\t\tvar shadowMapTypeDefine = 'SHADOWMAP_TYPE_BASIC';\n\n\t\tif (parameters.shadowMapType === PCFShadowMap) {\n\t\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF';\n\t\t} else if (parameters.shadowMapType === PCFSoftShadowMap) {\n\t\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF_SOFT';\n\t\t} else if (parameters.shadowMapType === VSMShadowMap) {\n\t\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_VSM';\n\t\t}\n\n\t\treturn shadowMapTypeDefine;\n\t}\n\n\tfunction generateEnvMapTypeDefine(parameters) {\n\t\tvar envMapTypeDefine = 'ENVMAP_TYPE_CUBE';\n\n\t\tif (parameters.envMap) {\n\t\t\tswitch (parameters.envMapMode) {\n\t\t\t\tcase CubeReflectionMapping:\n\t\t\t\tcase CubeRefractionMapping:\n\t\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_CUBE';\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase CubeUVReflectionMapping:\n\t\t\t\tcase CubeUVRefractionMapping:\n\t\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_CUBE_UV';\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn envMapTypeDefine;\n\t}\n\n\tfunction generateEnvMapModeDefine(parameters) {\n\t\tvar envMapModeDefine = 'ENVMAP_MODE_REFLECTION';\n\n\t\tif (parameters.envMap) {\n\t\t\tswitch (parameters.envMapMode) {\n\t\t\t\tcase CubeRefractionMapping:\n\t\t\t\tcase CubeUVRefractionMapping:\n\t\t\t\t\tenvMapModeDefine = 'ENVMAP_MODE_REFRACTION';\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn envMapModeDefine;\n\t}\n\n\tfunction generateEnvMapBlendingDefine(parameters) {\n\t\tvar envMapBlendingDefine = 'ENVMAP_BLENDING_NONE';\n\n\t\tif (parameters.envMap) {\n\t\t\tswitch (parameters.combine) {\n\t\t\t\tcase MultiplyOperation:\n\t\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_MULTIPLY';\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MixOperation:\n\t\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_MIX';\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase AddOperation:\n\t\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_ADD';\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn envMapBlendingDefine;\n\t}\n\n\tfunction WebGLProgram(renderer, cacheKey, parameters, bindingStates) {\n\t\tvar gl = renderer.getContext();\n\t\tvar defines = parameters.defines;\n\t\tvar vertexShader = parameters.vertexShader;\n\t\tvar fragmentShader = parameters.fragmentShader;\n\t\tvar shadowMapTypeDefine = generateShadowMapTypeDefine(parameters);\n\t\tvar envMapTypeDefine = generateEnvMapTypeDefine(parameters);\n\t\tvar envMapModeDefine = generateEnvMapModeDefine(parameters);\n\t\tvar envMapBlendingDefine = generateEnvMapBlendingDefine(parameters);\n\t\tvar gammaFactorDefine = renderer.gammaFactor > 0 ? renderer.gammaFactor : 1.0;\n\t\tvar customExtensions = parameters.isWebGL2 ? '' : generateExtensions(parameters);\n\t\tvar customDefines = generateDefines(defines);\n\t\tvar program = gl.createProgram();\n\t\tvar prefixVertex, prefixFragment;\n\t\tvar versionString = parameters.glslVersion ? '#version ' + parameters.glslVersion + '\\n' : '';\n\n\t\tif (parameters.isRawShaderMaterial) {\n\t\t\tprefixVertex = [customDefines].filter(filterEmptyLine).join('\\n');\n\n\t\t\tif (prefixVertex.length > 0) {\n\t\t\t\tprefixVertex += '\\n';\n\t\t\t}\n\n\t\t\tprefixFragment = [customExtensions, customDefines].filter(filterEmptyLine).join('\\n');\n\n\t\t\tif (prefixFragment.length > 0) {\n\t\t\t\tprefixFragment += '\\n';\n\t\t\t}\n\t\t} else {\n\t\t\tprefixVertex = [generatePrecision(parameters), '#define SHADER_NAME ' + parameters.shaderName, customDefines, parameters.instancing ? '#define USE_INSTANCING' : '', parameters.instancingColor ? '#define USE_INSTANCING_COLOR' : '', parameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '', '#define GAMMA_FACTOR ' + gammaFactorDefine, '#define MAX_BONES ' + parameters.maxBones, parameters.useFog && parameters.fog ? '#define USE_FOG' : '', parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', parameters.envMap ? '#define ' + envMapModeDefine : '', parameters.lightMap ? '#define USE_LIGHTMAP' : '', parameters.aoMap ? '#define USE_AOMAP' : '', parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', parameters.bumpMap ? '#define USE_BUMPMAP' : '', parameters.normalMap ? '#define USE_NORMALMAP' : '', parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors ? '#define USE_COLOR' : '', parameters.vertexUvs ? '#define USE_UV' : '', parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.skinning ? '#define USE_SKINNING' : '', parameters.useVertexTexture ? '#define BONE_TEXTURE' : '', parameters.morphTargets ? '#define USE_MORPHTARGETS' : '', parameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', parameters.flipSided ? '#define FLIP_SIDED' : '', parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', parameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', 'uniform mat4 modelMatrix;', 'uniform mat4 modelViewMatrix;', 'uniform mat4 projectionMatrix;', 'uniform mat4 viewMatrix;', 'uniform mat3 normalMatrix;', 'uniform vec3 cameraPosition;', 'uniform bool isOrthographic;', '#ifdef USE_INSTANCING', '\tattribute mat4 instanceMatrix;', '#endif', '#ifdef USE_INSTANCING_COLOR', '\tattribute vec3 instanceColor;', '#endif', 'attribute vec3 position;', 'attribute vec3 normal;', 'attribute vec2 uv;', '#ifdef USE_TANGENT', '\tattribute vec4 tangent;', '#endif', '#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(filterEmptyLine).join('\\n');\n\t\t\tprefixFragment = [customExtensions, generatePrecision(parameters), '#define SHADER_NAME ' + parameters.shaderName, customDefines, parameters.alphaTest ? '#define ALPHATEST ' + parameters.alphaTest + (parameters.alphaTest % 1 ? '' : '.0') : '', // add '.0' if integer\n\t\t\t'#define GAMMA_FACTOR ' + gammaFactorDefine, parameters.useFog && parameters.fog ? '#define USE_FOG' : '', parameters.useFog && parameters.fogExp2 ? '#define FOG_EXP2' : '', parameters.map ? '#define USE_MAP' : '', parameters.matc
vendor: 5,997 bytes, line 1
1ap ? '#define USE_MATCAP' : '', parameters.envMap ? '#define USE_ENVMAP' : '', parameters.envMap ? '#define ' + envMapTypeDefine : '', parameters.envMap ? '#define ' + envMapModeDefine : '', parameters.envMap ? '#define ' + envMapBlendingDefine : '', parameters.lightMap ? '#define USE_LIGHTMAP' : '', parameters.aoMap ? '#define USE_AOMAP' : '', parameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '', parameters.bumpMap ? '#define USE_BUMPMAP' : '', parameters.normalMap ? '#define USE_NORMALMAP' : '', parameters.normalMap && parameters.objectSpaceNormalMap ? '#define OBJECTSPACE_NORMALMAP' : '', parameters.normalMap && parameters.tangentSpaceNormalMap ? '#define TANGENTSPACE_NORMALMAP' : '', parameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '', parameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '', parameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '', parameters.specularMap ? '#define USE_SPECULARMAP' : '', parameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '', parameters.metalnessMap ? '#define USE_METALNESSMAP' : '', parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.sheen ? '#define USE_SHEEN' : '', parameters.transmissionMap ? '#define USE_TRANSMISSIONMAP' : '', parameters.vertexTangents ? '#define USE_TANGENT' : '', parameters.vertexColors || parameters.instancingColor ? '#define USE_COLOR' : '', parameters.vertexUvs ? '#define USE_UV' : '', parameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '', parameters.gradientMap ? '#define USE_GRADIENTMAP' : '', parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', parameters.flipSided ? '#define FLIP_SIDED' : '', parameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '', parameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '', parameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '', parameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '', parameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '', parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ? '#define USE_LOGDEPTHBUF_EXT' : '', (parameters.extensionShaderTextureLOD || parameters.envMap) && parameters.rendererExtensionShaderTextureLod ? '#define TEXTURE_LOD_EXT' : '', 'uniform mat4 viewMatrix;', 'uniform vec3 cameraPosition;', 'uniform bool isOrthographic;', parameters.toneMapping !== NoToneMapping ? '#define TONE_MAPPING' : '', parameters.toneMapping !== NoToneMapping ? ShaderChunk['tonemapping_pars_fragment'] : '', // this code is required here because it is used by the toneMapping() function defined below\n\t\t\tparameters.toneMapping !== NoToneMapping ? getToneMappingFunction('toneMapping', parameters.toneMapping) : '', parameters.dithering ? '#define DITHERING' : '', ShaderChunk['encodings_pars_fragment'], // this code is required here because it is used by the various encoding/decoding function defined below\n\t\t\tparameters.map ? getTexelDecodingFunction('mapTexelToLinear', parameters.mapEncoding) : '', parameters.matcap ? getTexelDecodingFunction('matcapTexelToLinear', parameters.matcapEncoding) : '', parameters.envMap ? getTexelDecodingFunction('envMapTexelToLinear', parameters.envMapEncoding) : '', parameters.emissiveMap ? getTexelDecodingFunction('emissiveMapTexelToLinear', parameters.emissiveMapEncoding) : '', parameters.lightMap ? getTexelDecodingFunction('lightMapTexelToLinear', parameters.lightMapEncoding) : '', getTexelEncodingFunction('linearToOutputTexel', parameters.outputEncoding), parameters.depthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '', '\\n'].filter(filterEmptyLine).join('\\n');\n\t\t}\n\n\t\tvertexShader = resolveIncludes(vertexShader);\n\t\tvertexShader = replaceLightNums(vertexShader, parameters);\n\t\tvertexShader = replaceClippingPlaneNums(vertexShader, parameters);\n\t\tfragmentShader = resolveIncludes(fragmentShader);\n\t\tfragmentShader = replaceLightNums(fragmentShader, parameters);\n\t\tfragmentShader = replaceClippingPlaneNums(fragmentShader, parameters);\n\t\tvertexShader = unrollLoops(vertexShader);\n\t\tfragmentShader = unrollLoops(fragmentShader);\n\n\t\tif (parameters.isWebGL2 && parameters.isRawShaderMaterial !== true) {\n\t\t\t// GLSL 3.0 conversion for built-in materials and ShaderMaterial\n\t\t\tversionString = '#version 300 es\\n';\n\t\t\tprefixVertex = ['#define attribute in', '#define varying out', '#define texture2D texture'].join('\\n') + '\\n' + prefixVertex;\n\t\t\tprefixFragment = ['#define varying in', parameters.glslVersion === GLSL3 ? '' : 'out highp vec4 pc_fragColor;', parameters.glslVersion === GLSL3 ? '' : '#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' + prefixFragment;\n\t\t}\n\n\t\tvar vertexGlsl = versionString + prefixVertex + vertexShader;\n\t\tvar fragmentGlsl = versionString + prefixFragment + fragmentShader; // console.log( '*VERTEX*', vertexGlsl );\n\t\t// console.log( '*FRAGMENT*', fragmentGlsl );\n\n\t\tvar glVertexShader = WebGLShader(gl, 35633, vertexGlsl);\n\t\tvar glFragmentShader = WebGLShader(gl, 35632, fragmentGlsl);\n\t\tgl.attachShader(program, glVertexShader);\n\t\tgl.attachShader(program, glFragmentShader); // Force a particular attribute to index 0.\n\n\t\tif (parameters.index0AttributeName !== undefined) {\n\t\t\tgl.bindAttribLocation(program, 0, parameters.index0AttributeName);\n\t\t} else if (parameters.morphTargets === true) {\n\t\t\t// programs with morphTargets displace position out of attribute 0\n\t\t\tgl.bindAttribLocation(program, 0, 'position');\n\t\t}\n\n\t\tgl.linkProgram(program);
1 // check for link errors\n\n\t\tif (renderer.debug.checkShaderErrors) {\n\t\t\tvar programLog = gl.getProgramInfoLog(program).trim();\n\t\t\tvar vertexLog = gl.getShaderInfoLog(glVertexShader).trim();\n\t\t\tvar fragmentLog = gl.getShaderInfoLog(glFragmentShader).trim();\n\t\t\tvar runnable = true;\n\t\t\tvar haveDiagnostics = true;\n\n\t\t\tif (gl.getProgramParameter(program, 35714) === false) {\n\t\t\t\trunnable = false;\n\t\t\t\tvar vertexErrors = getShaderErrors(gl, glVertexShader, 'vertex');\n\t\t\t\tvar fragmentErrors = getShaderErrors(gl, glFragmentShader, 'fragment');\n\t\t\t\tconsole.error('THREE.WebGLProgram: shader error: ', gl.getError(), '35715', gl.getProgramParameter(program, 35715), 'gl.getProgramInfoLog', programLog, vertexErrors, fragmentErrors);\n\t\t\t} else if (programLog !== '') {\n\t\t\t\tconsole.warn('THREE.WebGLProgram: gl.getProgramInfoLog()', programLog);\n\t\t\t} else if (vertexLog === '' || fragmentLog === '') {\n\t\t\t\thaveDiagnostics = false;\n\t\t\t}\n\n\t\t\tif (haveDiagnostics) {\n\t\t\t\tthis.diagnostics = {\n\t\t\t\t\trunnable: runnable,\n\t\t\t\t\tprogramLog: programLog,\n\t\t\t\t\tvertexShader: {\n\t\t\t\t\t\tlog: vertexLog,\n\t\t\t\t\t\tprefix: prefixVertex\n\t\t\t\t\t},\n\t\t\t\t\tfragmentShader: {\n\t\t\t\t\t\tlog: fragmentLog,\n\t\t\t\t\t\tprefix: prefixFragment\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t} // Clean up\n\t\t// Crashes in iOS9 and iOS10. #18402\n\t\t// gl.detachShader( program, glVertexShader );\n\t\t// gl.detachShader( program, glFragmentShader );\n\n\n\t\tgl.deleteShader(glVertexShader);\n\t\tgl.deleteShader(glFragmentShader); // set up caching for uniform locations\n\n\t\tvar cachedUniforms;\n\n\t\tthis.getUniforms = function () {\n\t\t\tif (cachedUniforms === undefined) {\n\t\t\t\tcachedUniforms = new WebGLUniforms(gl, program);\n\t\t\t}\n\n\t\t\treturn cachedUniforms;\n\t\t}; // set up caching for attribute locations\n\n\n\t\tvar cachedAttributes;\n\n\t\tthis.getAttributes = function () {\n\t\t\tif (cachedAttributes === undefined) {\n\t\t\t\tcachedAttributes = fetchAttributeLocations(gl, program);\n\t\t\t}\n\n\t\t\treturn cachedAttributes;\n\t\t}; // free resource\n\n\n\t\tthis.destroy = function () {\n\t\t\tbindingStates.releaseStatesOfProgram(this);\n\t\t\tgl.deleteProgram(program);\n\t\t\tthis.program = undefined;\n\t\t}; //\n\n\n\t\tthis.name = parameters.shaderName;\n\t\tthis.id = programIdCount++;\n\t\tthis.cacheKey = cacheKey;\n\t\tthis.usedTimes = 1;\n\t\tthis.program = program;\n\t\tthis.vertexShader = glVertexShader;\n\t\tthis.fragmentShader = glFragmentShader;\n\t\treturn this;\n\t}\n\n\tfunction WebGLPrograms(renderer, cubemaps, extensions, capabilities, bindingStates, clipping) {\n\t\tvar programs = [];\n\t\tvar isWebGL2 = capabilities.isWebGL2;\n\t\tvar logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;\n\t\tvar floatVertexTextures = capabilities.floatVertexTextures;\n\t\tvar maxVertexUniforms = capabilities.maxVertexUniforms;\n\t\tvar vertexTextures = capabilities.vertexTextures;\n\t\tvar precision = capabilities.precision;\n\t\tvar shaderIDs = {\n\t\t\tMeshDepthMaterial: 'depth',\n\t\t\tMeshDistanceMaterial: 'distanceRGBA',\n\t\t\tMeshNormalMaterial: 'normal',\n\t\t\tMeshBasicMaterial: 'basic',\n\t\t\tMeshLambertMaterial: 'lambert',\n\t\t\tMeshPhongMaterial: 'phong',\n\t\t\tMeshToonMaterial: 'toon',\n\t\t\tMeshStandardMaterial: 'physical',\n\t\t\tMeshPhysicalMaterial: 'physical',\n\t\t\tMeshMatcapMaterial: 'matcap',\n\t\t\tLineBasicMaterial: 'basic',\n\t\t\tLineDashedMaterial: 'dashed',\n\t\t\tPointsMaterial: 'points',\n\t\t\tShadowMaterial: 'shadow',\n\t\t\tSpriteMaterial: 'sprite'\n\t\t};\n\t\tvar parameterNames = ['precision', 'isWebGL2', 'supportsVertexTextures', 'outputEncoding', 'instancing', 'instancingColor', 'map', 'mapEncoding', 'matcap', 'matcapEncoding', 'envMap', 'envMapMode', 'envMapEncoding', 'envMapCubeUV', 'lightMap', 'lightMapEncoding', 'aoMap', 'emissiveMap', 'emissiveMapEncoding', 'bumpMap', 'normalMap', 'objectSpaceNormalMap', 'tangentSpaceNormalMap', 'clearcoatMap', 'clearcoatRoughnessMap', 'clearcoatNormalMap', 'displacementMap', 'specularMap', 'roughnessMap', 'metalnessMap', 'gradientMap', 'alphaMap', 'combine', 'vertexColors', 'vertexTangents', 'vertexUvs', 'uvsVertexOnly', 'fog', 'useFog', 'fogExp2', 'flatShading', 'sizeAttenuation', 'logarithmicDepthBuffer', 'skinning', 'maxBones', 'useVertexTexture', 'morphTargets', 'morphNormals', 'maxMorphTargets', 'maxMorphNormals', 'premultipliedAlpha', 'numDirLights', 'numPointLights', 'numSpotLights', 'numHemiLights', 'numRectAreaLights', 'numDirLightShadows', 'numPointLightShadows', 'numSpotLightShadows', 'shadowMapEnabled', 'shadowMapType', 'toneMapping', 'physicallyCorrectLights', 'alphaTest', 'doubleSided', 'flipSided', 'numClippingPlanes', 'numClipIntersection', 'depthPacking', 'dithering', 'sheen', 'transmissionMap'];\n\n\t\tfunction getMaxBones(object) {\n\t\t\tvar skeleton = object.skeleton;\n\t\t\tvar bones = skeleton.bones;\n\n\t\t\tif (floatVertexTextures) {\n\t\t\t\treturn 1024;\n\t\t\t} else {\n\t\t\t\t// default for when object is not specified\n\t\t\t\t// ( for example when prebuilding shader to be used with multiple objects )\n\t\t\t\t//\n\t\t\t\t//\t- leave some extra space for other uniforms\n\t\t\t\t//\t- limit here is ANGLE's 254 max uniform vectors\n\t\t\t\t//\t\t(up to 54 should be safe)\n\t\t\t\tvar nVertexUniforms = maxVertexUniforms;\n\t\t\t\tvar nVertexMatrices = Math.floor((nVertexUniforms - 20) / 4);\n\t\t\t\tvar maxBones = Math.min(nVertexMatrices, bones.length);\n\n\t\t\t\tif (maxBones < bones.length) {\n\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Skeleton has ' + bones.length + ' bones. This GPU supports ' + max
1Bones + '.');\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\n\t\t\t\treturn maxBones;\n\t\t\t}\n\t\t}\n\n\t\tfunction getTextureEncodingFromMap(map) {\n\t\t\tvar encoding;\n\n\t\t\tif (map && map.isTexture) {\n\t\t\t\tencoding = map.encoding;\n\t\t\t} else if (map && map.isWebGLRenderTarget) {\n\t\t\t\tconsole.warn('THREE.WebGLPrograms.getTextureEncodingFromMap: don\\'t use render targets as textures. Use their .texture property instead.');\n\t\t\t\tencoding = map.texture.encoding;\n\t\t\t} else {\n\t\t\t\tencoding = LinearEncoding;\n\t\t\t}\n\n\t\t\treturn encoding;\n\t\t}\n\n\t\tfunction getParameters(material, lights, shadows, scene, object) {\n\t\t\tvar fog = scene.fog;\n\t\t\tvar environment = material.isMeshStandardMaterial ? scene.environment : null;\n\t\t\tvar envMap = cubemaps.get(material.envMap || environment);\n\t\t\tvar shaderID = shaderIDs[material.type]; // heuristics to create shader parameters according to lights in the scene\n\t\t\t// (not to blow over maxLights budget)\n\n\t\t\tvar maxBones = object.isSkinnedMesh ? getMaxBones(object) : 0;\n\n\t\t\tif (material.precision !== null) {\n\t\t\t\tprecision = capabilities.getMaxPrecision(material.precision);\n\n\t\t\t\tif (precision !== material.precision) {\n\t\t\t\t\tconsole.warn('THREE.WebGLProgram.getParameters:', material.precision, 'not supported, using', precision, 'instead.');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar vertexShader, fragmentShader;\n\n\t\t\tif (shaderID) {\n\t\t\t\tvar shader = ShaderLib[shaderID];\n\t\t\t\tvertexShader = shader.vertexShader;\n\t\t\t\tfragmentShader = shader.fragmentShader;\n\t\t\t} else {\n\t\t\t\tvertexShader = material.vertexShader;\n\t\t\t\tfragmentShader = material.fragmentShader;\n\t\t\t}\n\n\t\t\tvar currentRenderTarget = renderer.getRenderTarget();\n\t\t\tvar parameters = {\n\t\t\t\tisWebGL2: isWebGL2,\n\t\t\t\tshaderID: shaderID,\n\t\t\t\tshaderName: material.type,\n\t\t\t\tvertexShader: vertexShader,\n\t\t\t\tfragmentShader: fragmentShader,\n\t\t\t\tdefines: material.defines,\n\t\t\t\tisRawShaderMaterial: material.isRawShaderMaterial === true,\n\t\t\t\tglslVersion: material.glslVersion,\n\t\t\t\tprecision: precision,\n\t\t\t\tinstancing: object.isInstancedMesh === true,\n\t\t\t\tinstancingColor: object.isInstancedMesh === true && object.instanceColor !== null,\n\t\t\t\tsupportsVertexTextures: vertexTextures,\n\t\t\t\toutputEncoding: currentRenderTarget !== null ? getTextureEncodingFromMap(currentRenderTarget.texture) : renderer.outputEncoding,\n\t\t\t\tmap: !!material.map,\n\t\t\t\tmapEncoding: getTextureEncodingFromMap(material.map),\n\t\t\t\tmatcap: !!material.matcap,\n\t\t\t\tmatcapEncoding: getTextureEncodingFromMap(material.matcap),\n\t\t\t\tenvMap: !!envMap,\n\t\t\t\tenvMapMode: envMap && envMap.mapping,\n\t\t\t\tenvMapEncoding: getTextureEncodingFromMap(envMap),\n\t\t\t\tenvMapCubeUV: !!envMap && (envMap.mapping === CubeUVReflectionMapping || envMap.mapping === CubeUVRefractionMapping),\n\t\t\t\tlightMap: !!material.lightMap,\n\t\t\t\tlightMapEncoding: getTextureEncodingFromMap(material.lightMap),\n\t\t\t\taoMap: !!material.aoMap,\n\t\t\t\temissiveMap: !!material.emissiveMap,\n\t\t\t\temissiveMapEncoding: getTextureEncodingFromMap(material.emissiveMap),\n\t\t\t\tbumpMap: !!material.bumpMap,\n\t\t\t\tnormalMap: !!material.normalMap,\n\t\t\t\tobjectSpaceNormalMap: material.normalMapType === ObjectSpaceNormalMap,\n\t\t\t\ttangentSpaceNormalMap: material.normalMapType === TangentSpaceNormalMap,\n\t\t\t\tclearcoatMap: !!material.clearcoatMap,\n\t\t\t\tclearcoatRoughnessMap: !!material.clearcoatRoughnessMap,\n\t\t\t\tclearcoatNormalMap: !!material.clearcoatNormalMap,\n\t\t\t\tdisplacementMap: !!material.displacementMap,\n\t\t\t\troughnessMap: !!material.roughnessMap,\n\t\t\t\tmetalnessMap: !!material.metalnessMap,\n\t\t\t\tspecularMap: !!material.specularMap,\n\t\t\t\talphaMap: !!material.alphaMap,\n\t\t\t\tgradientMap: !!material.gradientMap,\n\t\t\t\tsheen: !!material.sheen,\n\t\t\t\ttransmissionMap: !!material.transmissionMap,\n\t\t\t\tcombine: material.combine,\n\t\t\t\tvertexTangents: material.normalMap && material.vertexTangents,\n\t\t\t\tvertexColors: material.vertexColors,\n\t\t\t\tvertexUvs: !!material.map || !!material.bumpMap || !!material.normalMap || !!material.specularMap || !!material.alphaMap || !!material.emissiveMap || !!material.roughnessMap || !!material.metalnessMap || !!material.clearcoatMap || !!material.clearcoatRoughnessMap || !!material.clearcoatNormalMap || !!material.displacementMap || !!material.transmissionMap,\n\t\t\t\tuvsVertexOnly: !(!!material.map || !!material.bumpMap || !!material.normalMap || !!material.specularMap || !!material.alphaMap || !!material.emissiveMap || !!material.roughnessMap || !!material.metalnessMap || !!material.clearcoatNormalMap || !!material.transmissionMap) && !!material.displacementMap,\n\t\t\t\tfog: !!fog,\n\t\t\t\tuseFog: material.fog,\n\t\t\t\tfogExp2: fog && fog.isFogExp2,\n\t\t\t\tflatShading: material.flatShading,\n\t\t\t\tsizeAttenuation: material.sizeAttenuation,\n\t\t\t\tlogarithmicDepthBuffer: logarithmicDepthBuffer,\n\t\t\t\tskinning: material.skinning && maxBones > 0,\n\t\t\t\tmaxBones: maxBones,\n\t\t\t\tuseVertexTexture: floatVertexTextures,\n\t\t\t\tmorphTargets: material.morphTargets,\n\t\t\t\tmorphNormals: material.morphNormals,\n\t\t\t\tmaxMorphTargets: renderer.maxMorphTargets,\n\t\t\t\tmaxMorphNormals: renderer.maxMorphNormals,\n\t\t\t\tnumDirLights: lights.directional.length,\n\t\t\t\tnumPointLights: lights.point.length,\n\t\t\t\tnumSpotLights: lights.spot.length,\n\t\t\t\tnumRectAreaLights: lights.rectArea.length,\n\t\t\t\tnumHemiLights: lights.hemi.length,\n\t\t\t\tnumDirLightShadows: lights.directionalShadowMap.length,\n\t\t\t\tnumPointLightShadows: lights.pointShadowMap.length,\n\t\t\t\tnumSpotLightShadows: lights.spotShadowMap.length,\n\t\t\t\tnumClippingPlanes: clipping.numPlanes,\n\t\t\t\tnumClipIntersection: clipping.numIntersection,\n\t\t\t\tdithering: material.dithering,\n\t\t\t\tshadowMapEnabled: renderer.shadowMap.enabled && shadows.length > 0,\n\t\t\t\tshadowMapType: renderer.shadowMap.type,\n\t\t\t\ttoneMapping: material.toneMapped ? renderer.toneMapping : NoToneMapping,\n\t\t\t\tphysicallyCorrectLights: renderer.physicallyCorrectLights,\n\t\t\t\tpremultipliedAlpha: material.premultipliedAlpha,\n\t\t\t\talphaTest: material.alphaTest,\n\t\t\t\tdoubleSided: material.side === DoubleSide,\n\t\t\t\tflipSided: material.side === BackSide,\n\t\t\t\tdepthPacking: material.depthPacking !== undefined ? material.depthPacking : false,\n\t\t\t\tindex0AttributeName: material.index0AttributeName,\n\t\t\t\textensionDerivatives: material.extensions && material.extensions.derivatives,\n\t\t\t\textensionFragDepth: material.extensions && material.extensions.fragDepth,\n\t\t\t\textensionDrawBuffers: material.extensions && material.extensions.drawBuffers,\n\t\t\t\textensionShaderTextureLOD: material.extensions && material.extensions.shaderTextureLOD,\n\t\t\t\trendererExtensionFragDepth: isWebGL2 || extensions.has('EXT_frag_depth'),\n\t\t\t\trendererExtensionDrawBuffers: isWebGL2 || extensions.has('WEBGL_draw_buffers'),\n\t\t\t\trendererExtensionShaderTextureLod: isWebGL2 || extensions.has('EXT_shader_texture_lod'),\n\t\t\t\tcustomProgramCacheKey: material.customProgramCacheKey()\n\t\t\t};\n\t\t\treturn parameters;\n\t\t}\n\n\t\tfunction getProgramCacheKey(parameters) {\n\t\t\tvar array = [];\n\n\t\t\tif (parameters.shaderID) {\n\t\t\t\tarray.push(parameters.shaderID);\n\t\t\t} else {\n\t\t\t\tarray.push(parameters.fragmentShader);\n\t\t\t\tarray.push(parameters.vertexShader);\n\t\t\t}\n\n\t\t\tif (parameters.defines !== undefined) {\n\t\t\t\tfor (var name in parameters.defines) {\n\t\t\t\t\tarray.push(name);\n\t\t\t\t\tarray.push(parameters.defines[name]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (parameters.isRawShaderMaterial === false) {\n\t\t\t\tfor (var i = 0; i < parameterNames.length;
1 i++) {\n\t\t\t\t\tarray.push(parameters[parameterNames[i]]);\n\t\t\t\t}\n\n\t\t\t\tarray.push(renderer.outputEncoding);\n\t\t\t\tarray.push(renderer.gammaFactor);\n\t\t\t}\n\n\t\t\tarray.push(parameters.customProgramCacheKey);\n\t\t\treturn array.join();\n\t\t}\n\n\t\tfunction getUniforms(material) {\n\t\t\tvar shaderID = shaderIDs[material.type];\n\t\t\tvar uniforms;\n\n\t\t\tif (shaderID) {\n\t\t\t\tvar shader = ShaderLib[shaderID];\n\t\t\t\tuniforms = UniformsUtils.clone(shader.uniforms);\n\t\t\t} else {\n\t\t\t\tuniforms = material.uniforms;\n\t\t\t}\n\n\t\t\treturn uniforms;\n\t\t}\n\n\t\tfunction acquireProgram(parameters, cacheKey) {\n\t\t\tvar program; // Check if code has been already compiled\n\n\t\t\tfor (var p = 0, pl = programs.length; p < pl; p++) {\n\t\t\t\tvar preexistingProgram = programs[p];\n\n\t\t\t\tif (preexistingProgram.cacheKey === cacheKey) {\n\t\t\t\t\tprogram = preexistingProgram;\n\t\t\t\t\t++program.usedTimes;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (program === undefined) {\n\t\t\t\tprogram = new WebGLProgram(renderer, cacheKey, parameters, bindingStates);\n\t\t\t\tprograms.push(program);\n\t\t\t}\n\n\t\t\treturn program;\n\t\t}\n\n\t\tfunction releaseProgram(program) {\n\t\t\tif (--program.usedTimes === 0) {\n\t\t\t\t// Remove from unordered set\n\t\t\t\tvar i = programs.indexOf(program);\n\t\t\t\tprograms[i] = programs[programs.length - 1];\n\t\t\t\tprograms.pop(); // Free WebGL resources\n\n\t\t\t\tprogram.destroy();\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tgetParameters: getParameters,\n\t\t\tgetProgramCacheKey: getProgramCacheKey,\n\t\t\tgetUniforms: getUniforms,\n\t\t\tacquireProgram: acquireProgram,\n\t\t\treleaseProgram: releaseProgram,\n\t\t\t// Exposed for resource monitoring & error feedback via renderer.info:\n\t\t\tprograms: programs\n\t\t};\n\t}\n\n\tfunction WebGLProperties() {\n\t\tvar properties = new WeakMap();\n\n\t\tfunction get(object) {\n\t\t\tvar map = properties.get(object);\n\n\t\t\tif (map === undefined) {\n\t\t\t\tmap = {};\n\t\t\t\tproperties.set(object, map);\n\t\t\t}\n\n\t\t\treturn map;\n\t\t}\n\n\t\tfunction remove(object) {\n\t\t\tproperties.delete(object);\n\t\t}\n\n\t\tfunction update(object, key, value) {\n\t\t\tproperties.get(object)[key] = value;\n\t\t}\n\n\t\tfunction dispose() {\n\t\t\tproperties = new WeakMap();\n\t\t}\n\n\t\treturn {\n\t\t\tget: get,\n\t\t\tremove: remove,\n\t\t\tupdate: update,\n\t\t\tdispose: dispose\n\t\t};\n\t}\n\n\tfunction painterSortStable(a, b) {\n\t\tif (a.groupOrder !== b.groupOrder) {\n\t\t\treturn a.groupOrder - b.groupOrder;\n\t\t} else if (a.renderOrder !== b.renderOrder) {\n\t\t\treturn a.renderOrder - b.renderOrder;\n\t\t} else if (a.program !== b.program) {\n\t\t\treturn a.program.id - b.program.id;\n\t\t} else if (a.material.id !== b.material.id) {\n\t\t\treturn a.material.id - b.material.id;\n\t\t} else if (a.z !== b.z) {\n\t\t\treturn a.z - b.z;\n\t\t} else {\n\t\t\treturn a.id - b.id;\n\t\t}\n\t}\n\n\tfunction reversePainterSortStable(a, b) {\n\t\tif (a.groupOrder !== b.groupOrder) {\n\t\t\treturn a.groupOrder - b.groupOrder;\n\t\t} else if (a.renderOrder !== b.renderOrder) {\n\t\t\treturn a.renderOrder - b.renderOrder;\n\t\t} else if (a.z !== b.z) {\n\t\t\treturn b.z - a.z;\n\t\t} else {\n\t\t\treturn a.id - b.id;\n\t\t}\n\t}\n\n\tfunction WebGLRenderList(properties) {\n\t\tvar renderItems = [];\n\t\tvar renderItemsIndex = 0;\n\t\tvar opaque = [];\n\t\tvar transparent = [];\n\t\tvar defaultProgram = {\n\t\t\tid: -1\n\t\t};\n\n\t\tfunction init() {\n\t\t\trenderItemsIndex = 0;\n\t\t\topaque.length = 0;\n\t\t\ttransparent.length = 0;\n\t\t}\n\n\t\tfunction getNextRenderItem(object, geometry, material, groupOrder, z, group) {\n\t\t\tvar renderItem = renderItems[renderItemsIndex];\n\t\t\tvar materialProperties = properties.get(material);\n\n\t\t\tif (renderItem === undefined) {\n\t\t\t\trenderItem = {\n\t\t\t\t\tid: object.id,\n\t\t\t\t\tobject: object,\n\t\t\t\t\tgeometry: geometry,\n\t\t\t\t\tmaterial: material,\n\t\t\t\t\tprogram: materialProperties.program || defaultProgram,\n\t\t\t\t\tgroupOrder: groupOrder,\n\t\t\t\t\trenderOrder: object.renderOrder,\n\t\t\t\t\tz: z,\n\t\t\t\t\tgroup: group\n\t\t\t\t};\n\t\t\t\trenderItems[renderItemsIndex] = renderItem;\n\t\t\t} else {\n\t\t\t\trenderItem.id = object.id;\n\t\t\t\trenderItem.object = object;\n\t\t\t\trenderItem.geometry = geometry;\n\t\t\t\trenderItem.material = material;\n\t\t\t\trenderItem.program = materialProperties.program || defaultProgram;\n\t\t\t\trenderItem.groupOrder = groupOrder;\n\t\t\t\trenderItem.renderOrder = object.renderOrder;\n\t\t\t\trenderItem.z = z;\n\t\t\t\trenderItem.group = group;\n\t\t\t}\n\n\t\t\trenderItemsIndex++;\n\t\t\treturn renderItem;\n\t\t}\n\n\t\tfunction push(object, geometry, material, groupOrder, z, group) {\n\t\t\tvar renderItem = getNextRenderItem(object, geometry, material, groupOrder, z, group);\n\t\t\t(material.transparent === true ? transparent : opaque).push(renderItem);\n\t\t}\n\n\t\tfunction unshift(object, geometry, material, groupOrder, z, group) {\n\t\t\tvar renderItem = getNextRenderItem(object, geometry, material, groupOrder, z, group);\n\t\t\t(material.transparent === true ? transparent : opaque).unshift(renderItem);\n\t\t}\n\n\t\tfunction sort(customOpaqueSort, customTransparentSort) {\n\t\t\tif (opaque.length > 1) opaque.sort(customOpaqueSort || painterSortStable);\n\t\t\tif (transparent.length > 1) transparent.sort(customTransparentSort || reversePainterSortStable);\n\t\t}\n\n\t\tfunction finish() {\n\t\t\t// Clear references from inactive renderItems in the list\n\t\t\tfor (var i = renderItemsIndex, il = renderItems.length; i < il;
1 i++) {\n\t\t\t\tvar renderItem = renderItems[i];\n\t\t\t\tif (renderItem.id === null) break;\n\t\t\t\trenderItem.id = null;\n\t\t\t\trenderItem.object = null;\n\t\t\t\trenderItem.geometry = null;\n\t\t\t\trenderItem.material = null;\n\t\t\t\trenderItem.program = null;\n\t\t\t\trenderItem.group = null;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\topaque: opaque,\n\t\t\ttransparent: transparent,\n\t\t\tinit: init,\n\t\t\tpush: push,\n\t\t\tunshift: unshift,\n\t\t\tfinish: finish,\n\t\t\tsort: sort\n\t\t};\n\t}\n\n\tfunction WebGLRenderLists(properties) {\n\t\tvar lists = new WeakMap();\n\n\t\tfunction get(scene, camera) {\n\t\t\tvar cameras = lists.get(scene);\n\t\t\tvar list;\n\n\t\t\tif (cameras === undefined) {\n\t\t\t\tlist = new WebGLRenderList(properties);\n\t\t\t\tlists.set(scene, new WeakMap());\n\t\t\t\tlists.get(scene).set(camera, list);\n\t\t\t} else {\n\t\t\t\tlist = cameras.get(camera);\n\n\t\t\t\tif (list === undefined) {\n\t\t\t\t\tlist = new WebGLRenderList(properties);\n\t\t\t\t\tcameras.set(camera, list);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn list;\n\t\t}\n\n\t\tfunction dispose() {\n\t\t\tlists = new WeakMap();\n\t\t}\n\n\t\treturn {\n\t\t\tget: get,\n\t\t\tdispose: dispose\n\t\t};\n\t}\n\n\tfunction UniformsCache() {\n\t\tvar lights = {};\n\t\treturn {\n\t\t\tget: function get(light) {\n\t\t\t\tif (lights[light.id] !== undefined) {\n\t\t\t\t\treturn lights[light.id];\n\t\t\t\t}\n\n\t\t\t\tvar uniforms;\n\n\t\t\t\tswitch (light.type) {\n\t\t\t\t\tcase 'DirectionalLight':\n\t\t\t\t\t\tuniforms = {\n\t\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\t\tcolor: new Color()\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'SpotLight':\n\t\t\t\t\t\tuniforms = {\n\t\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\t\tdistance: 0,\n\t\t\t\t\t\t\tconeCos: 0,\n\t\t\t\t\t\t\tpenumbraCos: 0,\n\t\t\t\t\t\t\tdecay: 0\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'PointLight':\n\t\t\t\t\t\tuniforms = {\n\t\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\t\tdistance: 0,\n\t\t\t\t\t\t\tdecay: 0\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'HemisphereLight':\n\t\t\t\t\t\tuniforms = {\n\t\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\t\tskyColor: new Color(),\n\t\t\t\t\t\t\tgroundColor: new Color()\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'RectAreaLight':\n\t\t\t\t\t\tuniforms = {\n\t\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\t\thalfWidth: new Vector3(),\n\t\t\t\t\t\t\thalfHeight: new Vector3()\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tlights[light.id] = uniforms;\n\t\t\t\treturn uniforms;\n\t\t\t}\n\t\t};\n\t}\n\n\tfunction ShadowUniformsCache() {\n\t\tvar lights = {};\n\t\treturn {\n\t\t\tget: function get(light) {\n\t\t\t\tif (lights[light.id] !== undefined) {\n\t\t\t\t\treturn lights[light.id];\n\t\t\t\t}\n\n\t\t\t\tvar uniforms;\n\n\t\t\t\tswitch (light.type) {\n\t\t\t\t\tcase 'DirectionalLight':\n\t\t\t\t\t\tuniforms = {\n\t\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\t\tshadowMapSize: new Vector2()\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'SpotLight':\n\t\t\t\t\t\tuniforms = {\n\t\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\t\tshadowMapSize: new Vector2()\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'PointLight':\n\t\t\t\t\t\tuniforms = {\n\t\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\t\tshadowMapSize: new Vector2(),\n\t\t\t\t\t\t\tshadowCameraNear: 1,\n\t\t\t\t\t\t\tshadowCameraFar: 1000\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t// TODO (abelnation): set RectAreaLight shadow uniforms\n\t\t\t\t}\n\n\t\t\t\tlights[light.id] = uniforms;\n\t\t\t\treturn uniforms;\n\t\t\t}\n\t\t};\n\t}\n\n\tvar nextVersion = 0;\n\n\tfunction shadowCastingLightsFirst(lightA, lightB) {\n\t\treturn (lightB.castShadow ? 1 : 0) - (lightA.castShadow ? 1 : 0);\n\t}\n\n\tfunction WebGLLights(extensions, capabilities) {\n\t\tvar cache = new UniformsCache();\n\t\tvar shadowCache = ShadowUniformsCache();\n\t\tvar state = {\n\t\t\tversion: 0,\n\t\t\thash: {\n\t\t\t\tdirectionalLength: -1,\n\t\t\t\tpointLength: -1,\n\t\t\t\tspotLength: -1,\n\t\t\t\trectAreaLength: -1,\n\t\t\t\themiLength: -1,\n\t\t\t\tnumDirectionalShadows: -1,\n\t\t\t\tnumPointShadows: -1,\n\t\t\t\tnumSpotShadows: -1\n\t\t\t},\n\t\t\tambient: [0, 0, 0],\n\t\t\tprobe: [],\n\t\t\tdirectional: [],\n\t\t\tdirectionalShadow: [],\n\t\t\tdirectionalShadowMap: [],\n\t\t\tdirectionalShadowMatrix: [],\n\t\t\tspot: [],\n\t\t\tspotShadow: [],\n\t\t\tspotShadowMap: [],\n\t\t\tspotShadowMatrix: [],\n\t\t\trectArea: [],\n\t\t\trectAreaLTC1: null,\n\t\t\trectAreaLTC2: null,\n\t\t\tpoint: [],\n\t\t\tpointShadow: [],\n\t\t\tpointShadowMap: [],\n\t\t\tpointShadowMatrix: [],\n\t\t\themi: []\n\t\t};\n\n\t\tfor (var i = 0; i < 9;
1 i++) {\n\t\t\tstate.probe.push(new Vector3());\n\t\t}\n\n\t\tvar vector3 = new Vector3();\n\t\tvar matrix4 = new Matrix4();\n\t\tvar matrix42 = new Matrix4();\n\n\t\tfunction setup(lights) {\n\t\t\tvar r = 0,\n\t\t\t\t\tg = 0,\n\t\t\t\t\tb = 0;\n\n\t\t\tfor (var _i = 0; _i < 9; _i++) {\n\t\t\t\tstate.probe[_i].set(0, 0, 0);\n\t\t\t}\n\n\t\t\tvar directionalLength = 0;\n\t\t\tvar pointLength = 0;\n\t\t\tvar spotLength = 0;\n\t\t\tvar rectAreaLength = 0;\n\t\t\tvar hemiLength = 0;\n\t\t\tvar numDirectionalShadows = 0;\n\t\t\tvar numPointShadows = 0;\n\t\t\tvar numSpotShadows = 0;\n\t\t\tlights.sort(shadowCastingLightsFirst);\n\n\t\t\tfor (var _i2 = 0, l = lights.length; _i2 < l; _i2++) {\n\t\t\t\tvar light = lights[_i2];\n\t\t\t\tvar color = light.color;\n\t\t\t\tvar intensity = light.intensity;\n\t\t\t\tvar distance = light.distance;\n\t\t\t\tvar shadowMap = light.shadow && light.shadow.map ? light.shadow.map.texture : null;\n\n\t\t\t\tif (light.isAmbientLight) {\n\t\t\t\t\tr += color.r * intensity;\n\t\t\t\t\tg += color.g * intensity;\n\t\t\t\t\tb += color.b * intensity;\n\t\t\t\t} else if (light.isLightProbe) {\n\t\t\t\t\tfor (var j = 0; j < 9; j++) {\n\t\t\t\t\t\tstate.probe[j].addScaledVector(light.sh.coefficients[j], intensity);\n\t\t\t\t\t}\n\t\t\t\t} else if (light.isDirectionalLight) {\n\t\t\t\t\tvar uniforms = cache.get(light);\n\t\t\t\t\tuniforms.color.copy(light.color).multiplyScalar(light.intensity);\n\n\t\t\t\t\tif (light.castShadow) {\n\t\t\t\t\t\tvar shadow = light.shadow;\n\t\t\t\t\t\tvar shadowUniforms = shadowCache.get(light);\n\t\t\t\t\t\tshadowUniforms.shadowBias = shadow.bias;\n\t\t\t\t\t\tshadowUniforms.shadowNormalBias = shadow.normalBias;\n\t\t\t\t\t\tshadowUniforms.shadowRadius = shadow.radius;\n\t\t\t\t\t\tshadowUniforms.shadowMapSize = shadow.mapSize;\n\t\t\t\t\t\tstate.directionalShadow[directionalLength] = shadowUniforms;\n\t\t\t\t\t\tstate.directionalShadowMap[directionalLength] = shadowMap;\n\t\t\t\t\t\tstate.directionalShadowMatrix[directionalLength] = light.shadow.matrix;\n\t\t\t\t\t\tnumDirectionalShadows++;\n\t\t\t\t\t}\n\n\t\t\t\t\tstate.directional[directionalLength] = uniforms;\n\t\t\t\t\tdirectionalLength++;\n\t\t\t\t} else if (light.isSpotLight) {\n\t\t\t\t\tvar _uniforms = cache.get(light);\n\n\t\t\t\t\t_uniforms.position.setFromMatrixPosition(light.matrixWorld);\n\n\t\t\t\t\t_uniforms.color.copy(color).multiplyScalar(intensity);\n\n\t\t\t\t\t_uniforms.distance = distance;\n\t\t\t\t\t_uniforms.coneCos = Math.cos(light.angle);\n\t\t\t\t\t_uniforms.penumbraCos = Math.cos(light.angle * (1 - light.penumbra));\n\t\t\t\t\t_uniforms.decay = light.decay;\n\n\t\t\t\t\tif (light.castShadow) {\n\t\t\t\t\t\tvar _shadow = light.shadow;\n\n\t\t\t\t\t\tvar _shadowUniforms = shadowCache.get(light);\n\n\t\t\t\t\t\t_shadowUniforms.shadowBias = _shadow.bias;\n\t\t\t\t\t\t_shadowUniforms.shadowNormalBias = _shadow.normalBias;\n\t\t\t\t\t\t_shadowUniforms.shadowRadius = _shadow.radius;\n\t\t\t\t\t\t_shadowUniforms.shadowMapSize = _shadow.mapSize;\n\t\t\t\t\t\tstate.spotShadow[spotLength] = _shadowUniforms;\n\t\t\t\t\t\tstate.spotShadowMap[spotLength] = shadowMap;\n\t\t\t\t\t\tstate.spotShadowMatrix[spotLength] = light.shadow.matrix;\n\t\t\t\t\t\tnumSpotShadows++;\n\t\t\t\t\t}\n\n\t\t\t\t\tstate.spot[spotLength] = _uniforms;\n\t\t\t\t\tspotLength++;\n\t\t\t\t} else if (light.isRectAreaLight) {\n\t\t\t\t\tvar _uniforms2 = cache.get(light); // (a) intensity is the total visible light emitted\n\t\t\t\t\t//uniforms.color.copy( color ).multiplyScalar( intensity / ( light.width * light.height * Math.PI ) );\n\t\t\t\t\t// (b) intensity is the brightness of the light\n\n\n\t\t\t\t\t_uniforms2.color.copy(color).multiplyScalar(intensity);\n\n\t\t\t\t\t_uniforms2.halfWidth.set(light.width * 0.5, 0.0, 0.0);\n\n\t\t\t\t\t_uniforms2.halfHeight.set(0.0, light.height * 0.5, 0.0);\n\n\t\t\t\t\tstate.rectArea[rectAreaLength] = _uniforms2;\n\t\t\t\t\trectAreaLength++;\n\t\t\t\t} else if (light.isPointLight) {\n\t\t\t\t\tvar _uniforms3 = cache.get(light);\n\n\t\t\t\t\t_uniforms3.color.copy(light.color).multiplyScalar(light.intensity);\n\n\t\t\t\t\t_uniforms3.distance = light.distance;\n\t\t\t\t\t_uniforms3.decay = light.decay;\n\n\t\t\t\t\tif (light.castShadow) {\n\t\t\t\t\t\tvar _shadow2 = light.shadow;\n\n\t\t\t\t\t\tvar _shadowUniforms2 = shadowCache.get(light);\n\n\t\t\t\t\t\t_shadowUniforms2.shadowBias = _shadow2.bias;\n\t\t\t\t\t\t_shadowUniforms2.shadowNormalBias = _shadow2.normalBias;\n\t\t\t\t\t\t_shadowUniforms2.shadowRadius = _shadow2.radius;\n\t\t\t\t\t\t_shadowUniforms2.shadowMapSize = _shadow2.mapSize;\n\t\t\t\t\t\t_shadowUniforms2.shadowCameraNear = _shadow2.camera.near;\n\t\t\t\t\t\t_shadowUniforms2.shadowCameraFar = _shadow2.camera.far;\n\t\t\t\t\t\tstate.pointShadow[pointLength] = _shadowUniforms2;\n\t\t\t\t\t\tstate.pointShadowMap[pointLength] = shadowMap;\n\t\t\t\t\t\tstate.pointShadowMatrix[pointLength] = light.shadow.matrix;\n\t\t\t\t\t\tnumPointShadows++;\n\t\t\t\t\t}\n\n\t\t\t\t\tstate.point[pointLength] = _uniforms3;\n\t\t\t\t\tpointLength++;\n\t\t\t\t} else if (light.isHemisphereLight) {\n\t\t\t\t\tvar _uniforms4 = cache.get(light);\n\n\t\t\t\t\t_uniforms4.skyColor.copy(light.color).multiplyScalar(intensity);\n\n\t\t\t\t\t_uniforms4.groundColor.copy(light.groundColor).multiplyScalar(intensity);\n\n\t\t\t\t\tstate.hemi[hemiLength] = _uniforms4;\n\t\t\t\t\themiLength++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (rectAreaLength > 0) {\n\t\t\t\tif (capabilities.isWebGL2) {\n\t\t\t\t\t// WebGL 2\n\t\t\t\t\tstate.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;\n\t\t\t\t\tstate.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;\n\t\t\t\t} else {\n\t\t\t\t\t// WebGL 1\n\t\t\t\t\tif (extensions.has('OES_texture_float_linear') === true) {\n\t\t\t\t\t\tstate.rectAreaLTC1 = UniformsLib.LTC_FLOAT_1;\n\t\t\t\t\t\tstate.rectAreaLTC2 = UniformsLib.LTC_FLOAT_2;\n\t\t\t\t\t} else if (extensions.has('OES_texture_half_float_linear') === true) {\n\t\t\t\t\t\tstate.rectAreaLTC1 = UniformsLib.LTC_HALF_1;\n\t\t\t\t\t\tstate.rectAreaLTC2 = UniformsLib.LTC_HALF_2;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error('THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstate.ambient[0] = r;\n\t\t\tstate.ambient[1] = g;\n\t\t\tstate.ambient[2] = b;\n\t\t\tvar hash = state.hash;\n\n\t\t\tif (hash.directionalLength !== directionalLength || hash.pointLength !== pointLength || hash.spotLength !== spotLength || hash.rectAreaLength !== rectAreaLength || hash.hemiLength !== hemiLength || hash.numDirectionalShadows !== numDirectionalShadows || hash.numPointShadows !== numPointShadows || hash.numSpotShadows !== numSpotShadows) {\n\t\t\t\tstate.directional.length = directionalLength;\n\t\t\t\tstate.spot.length = spotLength;\n\t\t\t\tstate.rectArea.length = rectAreaLength;\n\t\t\t\tstate.point.length = pointLength;\n\t\t\t\tstate.hemi.length = hemiLength;\n\t\t\t\tstate.directionalShadow.length = numDirectionalShadows;\n\t\t\t\tstate.directionalShadowMap.length = numDirectionalShadows;\n\t\t\t\tstate.pointShadow.length = numPointShadows;\n\t\t\t\tstate.pointShadowMap.length = numPointShadows;\n\t\t\t\tstate.spotShadow.length = numSpotShadows;\n\t\t\t\tstate.spotShadowMap.length = numSpotShadows;\n\t\t\t\tstate.directionalShadowMatrix.length = numDirectionalShadows;\n\t\t\t\tstate.pointShadowMatrix.length = numPointShadows;\n\t\t\t\tstate.spotShadowMatrix.length = numSpotShadows;\n\t\t\t\thash.directionalLength = directionalLength;\n\t\t\t\thash.pointLength = pointLength;\n\t\t\t\thash.spotLength = spotLength;\n\t\t\t\thash.rectAreaLength = rectAreaLength;\n\t\t\t\thash.hemiLength = hemiLength;\n\t\t\t\thash.numDirectionalShadows = numDirectionalShadows;\n\t\t\t\thash.numPointShadows = numPointShadows;\n\t\t\t\thash.numSpotShadows = numSpotShadows;
1\n\t\t\t\tstate.version = nextVersion++;\n\t\t\t}\n\t\t}\n\n\t\tfunction setupView(lights, camera) {\n\t\t\tvar directionalLength = 0;\n\t\t\tvar pointLength = 0;\n\t\t\tvar spotLength = 0;\n\t\t\tvar rectAreaLength = 0;\n\t\t\tvar hemiLength = 0;\n\t\t\tvar viewMatrix = camera.matrixWorldInverse;\n\n\t\t\tfor (var _i3 = 0, l = lights.length; _i3 < l; _i3++) {\n\t\t\t\tvar light = lights[_i3];\n\n\t\t\t\tif (light.isDirectionalLight) {\n\t\t\t\t\tvar uniforms = state.directional[directionalLength];\n\t\t\t\t\tuniforms.direction.setFromMatrixPosition(light.matrixWorld);\n\t\t\t\t\tvector3.setFromMatrixPosition(light.target.matrixWorld);\n\t\t\t\t\tuniforms.direction.sub(vector3);\n\t\t\t\t\tuniforms.direction.transformDirection(viewMatrix);\n\t\t\t\t\tdirectionalLength++;\n\t\t\t\t} else if (light.isSpotLight) {\n\t\t\t\t\tvar _uniforms5 = state.spot[spotLength];\n\n\t\t\t\t\t_uniforms5.position.setFromMatrixPosition(light.matrixWorld);\n\n\t\t\t\t\t_uniforms5.position.applyMatrix4(viewMatrix);\n\n\t\t\t\t\t_uniforms5.direction.setFromMatrixPosition(light.matrixWorld);\n\n\t\t\t\t\tvector3.setFromMatrixPosition(light.target.matrixWorld);\n\n\t\t\t\t\t_uniforms5.direction.sub(vector3);\n\n\t\t\t\t\t_uniforms5.direction.transformDirection(viewMatrix);\n\n\t\t\t\t\tspotLength++;\n\t\t\t\t} else if (light.isRectAreaLight) {\n\t\t\t\t\tvar _uniforms6 = state.rectArea[rectAreaLength];\n\n\t\t\t\t\t_uniforms6.position.setFromMatrixPosition(light.matrixWorld);\n\n\t\t\t\t\t_uniforms6.position.applyMatrix4(viewMatrix); // extract local rotation of light to derive width/height half vectors\n\n\n\t\t\t\t\tmatrix42.identity();\n\t\t\t\t\tmatrix4.copy(light.matrixWorld);\n\t\t\t\t\tmatrix4.premultiply(viewMatrix);\n\t\t\t\t\tmatrix42.extractRotation(matrix4);\n\n\t\t\t\t\t_uniforms6.halfWidth.set(light.width * 0.5, 0.0, 0.0);\n\n\t\t\t\t\t_uniforms6.halfHeight.set(0.0, light.height * 0.5, 0.0);\n\n\t\t\t\t\t_uniforms6.halfWidth.applyMatrix4(matrix42);\n\n\t\t\t\t\t_uniforms6.halfHeight.applyMatrix4(matrix42);\n\n\t\t\t\t\trectAreaLength++;\n\t\t\t\t} else if (light.isPointLight) {\n\t\t\t\t\tvar _uniforms7 = state.point[pointLength];\n\n\t\t\t\t\t_uniforms7.position.setFromMatrixPosition(light.matrixWorld);\n\n\t\t\t\t\t_uniforms7.position.applyMatrix4(viewMatrix);\n\n\t\t\t\t\tpointLength++;\n\t\t\t\t} else if (light.isHemisphereLight) {\n\t\t\t\t\tvar _uniforms8 = state.hemi[hemiLength];\n\n\t\t\t\t\t_uniforms8.direction.setFromMatrixPosition(light.matrixWorld);\n\n\t\t\t\t\t_uniforms8.direction.transformDirection(viewMatrix);\n\n\t\t\t\t\t_uniforms8.direction.normalize();\n\n\t\t\t\t\themiLength++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tsetup: setup,\n\t\t\tsetupView: setupView,\n\t\t\tstate: state\n\t\t};\n\t}\n\n\tfunction WebGLRenderState(extensions, capabilities) {\n\t\tvar lights = new WebGLLights(extensions, capabilities);\n\t\tvar lightsArray = [];\n\t\tvar shadowsArray = [];\n\n\t\tfunction init() {\n\t\t\tlightsArray.length = 0;\n\t\t\tshadowsArray.length = 0;\n\t\t}\n\n\t\tfunction pushLight(light) {\n\t\t\tlightsArray.push(light);\n\t\t}\n\n\t\tfunction pushShadow(shadowLight) {\n\t\t\tshadowsArray.push(shadowLight);\n\t\t}\n\n\t\tfunction setupLights() {\n\t\t\tlights.setup(lightsArray);\n\t\t}\n\n\t\tfunction setupLightsView(camera) {\n\t\t\tlights.setupView(lightsArray, camera);\n\t\t}\n\n\t\tvar state = {\n\t\t\tlightsArray: lightsArray,\n\t\t\tshadowsArray: shadowsArray,\n\t\t\tlights: lights\n\t\t};\n\t\treturn {\n\t\t\tinit: init,\n\t\t\tstate: state,\n\t\t\tsetupLights: setupLights,\n\t\t\tsetupLightsView: setupLightsView,\n\t\t\tpushLight: pushLight,\n\t\t\tpushShadow: pushShadow\n\t\t};\n\t}\n\n\tfunction WebGLRenderStates(extensions, capabilities) {\n\t\tvar renderStates = new WeakMap();\n\n\t\tfunction get(scene, renderCallDepth) {\n\t\t\tif (renderCallDepth === void 0) {\n\t\t\t\trenderCallDepth = 0;\n\t\t\t}\n\n\t\t\tvar renderState;\n\n\t\t\tif (renderStates.has(scene) === false) {\n\t\t\t\trenderState = new WebGLRenderState(extensions, capabilities);\n\t\t\t\trenderStates.set(scene, []);
1\n\t\t\t\trenderStates.get(scene).push(renderState);\n\t\t\t} else {\n\t\t\t\tif (renderCallDepth >= renderStates.get(scene).length) {\n\t\t\t\t\trenderState = new WebGLRenderState(extensions, capabilities);\n\t\t\t\t\trenderStates.get(scene).push(renderState);\n\t\t\t\t} else {\n\t\t\t\t\trenderState = renderStates.get(scene)[renderCallDepth];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn renderState;\n\t\t}\n\n\t\tfunction dispose() {\n\t\t\trenderStates = new WeakMap();\n\t\t}\n\n\t\treturn {\n\t\t\tget: get,\n\t\t\tdispose: dispose\n\t\t};\n\t}\n\n\t/**\n\t * parameters = {\n\t *\n\t *\topacity: <float>,\n\t *\n\t *\tmap: new THREE.Texture( <Image> ),\n\t *\n\t *\talphaMap: new THREE.Texture( <Image> ),\n\t *\n\t *\tdisplacementMap: new THREE.Texture( <Image> ),\n\t *\tdisplacementScale: <float>,\n\t *\tdisplacementBias: <float>,\n\t *\n\t *\twireframe: <boolean>,\n\t *\twireframeLinewidth: <float>\n\t * }\n\t */\n\n\tfunction MeshDepthMaterial(parameters) {\n\t\tMaterial.call(this);\n\t\tthis.type = 'MeshDepthMaterial';\n\t\tthis.depthPacking = BasicDepthPacking;\n\t\tthis.skinning = false;\n\t\tthis.morphTargets = false;\n\t\tthis.map = null;\n\t\tthis.alphaMap = null;\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.fog = false;\n\t\tthis.setValues(parameters);\n\t}\n\n\tMeshDepthMaterial.prototype = Object.create(Material.prototype);\n\tMeshDepthMaterial.prototype.constructor = MeshDepthMaterial;\n\tMeshDepthMaterial.prototype.isMeshDepthMaterial = true;\n\n\tMeshDepthMaterial.prototype.copy = function (source) {\n\t\tMaterial.prototype.copy.call(this, source);\n\t\tthis.depthPacking = source.depthPacking;\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\t\tthis.map = source.map;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\treturn this;\n\t};\n\n\t/**\n\t * parameters = {\n\t *\n\t *\treferencePosition: <float>,\n\t *\tnearDistance: <float>,\n\t *\tfarDistance: <float>,\n\t *\n\t *\tskinning: <bool>,\n\t *\tmorphTargets: <bool>,\n\t *\n\t *\tmap: new THREE.Texture( <Image> ),\n\t *\n\t *\talphaMap: new THREE.Texture( <Image> ),\n\t *\n\t *\tdisplacementMap: new THREE.Texture( <Image> ),\n\t *\tdisplacementScale: <float>,\n\t *\tdisplacementBias: <float>\n\t *\n\t * }\n\t */\n\n\tfunction MeshDistanceMaterial(parameters) {\n\t\tMaterial.call(this);\n\t\tthis.type = 'MeshDistanceMaterial';\n\t\tthis.referencePosition = new Vector3();\n\t\tthis.nearDistance = 1;\n\t\tthis.farDistance = 1000;\n\t\tthis.skinning = false;\n\t\tthis.morphTargets = false;\n\t\tthis.map = null;\n\t\tthis.alphaMap = null;\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\t\tthis.fog = false;\n\t\tthis.setValues(parameters);\n\t}\n\n\tMeshDistanceMaterial.prototype = Object.create(Material.prototype);\n\tMeshDistanceMaterial.prototype.constructor = MeshDistanceMaterial;\n\tMeshDistanceMaterial.prototype.isMeshDistanceMaterial = true;\n\n\tMeshDistanceMaterial.prototype.copy = function (source) {\n\t\tMaterial.prototype.copy.call(this, source);\n\t\tthis.referencePosition.copy(source.referencePosition);\n\t\tthis.nearDistance = source.nearDistance;\n\t\tthis.farDistance = source.farDistance;\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\t\tthis.map = source.map;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\t\treturn this;\n\t};\n\n\tvar vsm_frag = \"uniform sampler2D shadow_pass;\\nuniform vec2 resolution;\\nuniform float radius;\\n#include <packing>\\nvoid main() {\\n\\tfloat mean = 0.0;\\n\\tfloat squared_mean = 0.0;\\n\\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );
1\\n\\tfor ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\\n\\t\\t#ifdef HORIZONTAL_PASS\\n\\t\\t\\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\\n\\t\\t\\tmean += distribution.x;\\n\\t\\t\\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\\n\\t\\t#else\\n\\t\\t\\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\\n\\t\\t\\tmean += depth;\\n\\t\\t\\tsquared_mean += depth * depth;\\n\\t\\t#endif\\n\\t}\\n\\tmean = mean * HALF_SAMPLE_RATE;\\n\\tsquared_mean = squared_mean * HALF_SAMPLE_RATE;\\n\\tfloat std_dev = sqrt( squared_mean - mean * mean );\\n\\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\\n}\";\n\n\tvar vsm_vert = \"void main() {\\n\\tgl_Position = vec4( position, 1.0 );\\n}\";\n\n\tfunction WebGLShadowMap(_renderer, _objects, maxTextureSize) {\n\t\tvar _frustum = new Frustum();\n\n\t\tvar _shadowMapSize = new Vector2(),\n\t\t\t\t_viewportSize = new Vector2(),\n\t\t\t\t_viewport = new Vector4(),\n\t\t\t\t_depthMaterials = [],\n\t\t\t\t_distanceMaterials = [],\n\t\t\t\t_materialCache = {};\n\n\t\tvar shadowSide = {\n\t\t\t0: BackSide,\n\t\t\t1: FrontSide,\n\t\t\t2: DoubleSide\n\t\t};\n\t\tvar shadowMaterialVertical = new ShaderMaterial({\n\t\t\tdefines: {\n\t\t\t\tSAMPLE_RATE: 2.0 / 8.0,\n\t\t\t\tHALF_SAMPLE_RATE: 1.0 / 8.0\n\t\t\t},\n\t\t\tuniforms: {\n\t\t\t\tshadow_pass: {\n\t\t\t\t\tvalue: null\n\t\t\t\t},\n\t\t\t\tresolution: {\n\t\t\t\t\tvalue: new Vector2()\n\t\t\t\t},\n\t\t\t\tradius: {\n\t\t\t\t\tvalue: 4.0\n\t\t\t\t}\n\t\t\t},\n\t\t\tvertexShader: vsm_vert,\n\t\t\tfragmentShader: vsm_frag\n\t\t});\n\t\tvar shadowMaterialHorizontal = shadowMaterialVertical.clone();\n\t\tshadowMaterialHorizontal.defines.HORIZONTAL_PASS = 1;\n\t\tvar fullScreenTri = new BufferGeometry();\n\t\tfullScreenTri.setAttribute('position', new BufferAttribute(new Float32Array([-1, -1, 0.5, 3, -1, 0.5, -1, 3, 0.5]), 3));\n\t\tvar fullScreenMesh = new Mesh(fullScreenTri, shadowMaterialVertical);\n\t\tvar scope = this;\n\t\tthis.enabled = false;\n\t\tthis.autoUpdate = true;\n\t\tthis.needsUpdate = false;\n\t\tthis.type = PCFShadowMap;\n\n\t\tthis.render = function (lights, scene, camera) {\n\t\t\tif (scope.enabled === false) return;\n\t\t\tif (scope.autoUpdate === false && scope.needsUpdate === false) return;\n\t\t\tif (lights.length === 0) return;\n\n\t\t\tvar currentRenderTarget = _renderer.getRenderTarget();\n\n\t\t\tvar activeCubeFace = _renderer.getActiveCubeFace();\n\n\t\t\tvar activeMipmapLevel = _renderer.getActiveMipmapLevel();\n\n\t\t\tvar _state = _renderer.state; // Set GL state for depth map.\n\n\t\t\t_state.setBlending(NoBlending);\n\n\t\t\t_state.buffers.color.setClear(1, 1, 1, 1);\n\n\t\t\t_state.buffers.depth.setTest(true);\n\n\t\t\t_state.setScissorTest(false); // render depth map\n\n\n\t\t\tfor (var i = 0, il = lights.length; i < il; i++) {\n\t\t\t\tvar light = lights[i];\n\t\t\t\tvar shadow = light.shadow;\n\n\t\t\t\tif (shadow === undefined) {\n\t\t\t\t\tconsole.warn('THREE.WebGLShadowMap:', light, 'has no shadow.');\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (shadow.autoUpdate === false && shadow.needsUpdate === false) continue;\n\n\t\t\t\t_shadowMapSize.copy(shadow.mapSize);\n\n\t\t\t\tvar shadowFrameExtents = shadow.getFrameExtents();\n\n\t\t\t\t_shadowMapSize.multiply(shadowFrameExtents);\n\n\t\t\t\t_viewportSize.copy(shadow.mapSize);\n\n\t\t\t\tif (_shadowMapSize.x > maxTextureSize || _shadowMapSize.y > maxTextureSize) {\n\t\t\t\t\tif (_shadowMapSize.x > maxTextureSize) {\n\t\t\t\t\t\t_viewportSize.x = Math.floor(maxTextureSize / shadowFrameExtents.x);\n\t\t\t\t\t\t_shadowMapSize.x = _viewportSize.x * shadowFrameExtents.x;\n\t\t\t\t\t\tshadow.mapSize.x = _viewportSize.x;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (_shadowMapSize.y > maxTextureSize) {\n\t\t\t\t\t\t_viewportSize.y = Math.floor(maxTextureSize / shadowFrameExtents.y);\n\t\t\t\t\t\t_shadowMapSize.y = _viewportSize.y * shadowFrameExtents.y;\n\t\t\t\t\t\tshadow.mapSize.y = _viewportSize.y;\n\t\t\t\t\t}\n\t\t\t\t}
1\n\n\t\t\t\tif (shadow.map === null && !shadow.isPointLightShadow && this.type === VSMShadowMap) {\n\t\t\t\t\tvar pars = {\n\t\t\t\t\t\tminFilter: LinearFilter,\n\t\t\t\t\t\tmagFilter: LinearFilter,\n\t\t\t\t\t\tformat: RGBAFormat\n\t\t\t\t\t};\n\t\t\t\t\tshadow.map = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y, pars);\n\t\t\t\t\tshadow.map.texture.name = light.name + '.shadowMap';\n\t\t\t\t\tshadow.mapPass = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y, pars);\n\t\t\t\t\tshadow.camera.updateProjectionMatrix();\n\t\t\t\t}\n\n\t\t\t\tif (shadow.map === null) {\n\t\t\t\t\tvar _pars = {\n\t\t\t\t\t\tminFilter: NearestFilter,\n\t\t\t\t\t\tmagFilter: NearestFilter,\n\t\t\t\t\t\tformat: RGBAFormat\n\t\t\t\t\t};\n\t\t\t\t\tshadow.map = new WebGLRenderTarget(_shadowMapSize.x, _shadowMapSize.y, _pars);\n\t\t\t\t\tshadow.map.texture.name = light.name + '.shadowMap';\n\t\t\t\t\tshadow.camera.updateProjectionMatrix();\n\t\t\t\t}\n\n\t\t\t\t_renderer.setRenderTarget(shadow.map);\n\n\t\t\t\t_renderer.clear();\n\n\t\t\t\tvar viewportCount = shadow.getViewportCount();\n\n\t\t\t\tfor (var vp = 0; vp < viewportCount; vp++) {\n\t\t\t\t\tvar viewport = shadow.getViewport(vp);\n\n\t\t\t\t\t_viewport.set(_viewportSize.x * viewport.x, _viewportSize.y * viewport.y, _viewportSize.x * viewport.z, _viewportSize.y * viewport.w);\n\n\t\t\t\t\t_state.viewport(_viewport);\n\n\t\t\t\t\tshadow.updateMatrices(light, vp);\n\t\t\t\t\t_frustum = shadow.getFrustum();\n\t\t\t\t\trenderObject(scene, camera, shadow.camera, light, this.type);\n\t\t\t\t} // do blur pass for VSM\n\n\n\t\t\t\tif (!shadow.isPointLightShadow && this.type === VSMShadowMap) {\n\t\t\t\t\tVSMPass(shadow, camera);\n\t\t\t\t}\n\n\t\t\t\tshadow.needsUpdate = false;\n\t\t\t}\n\n\t\t\tscope.needsUpdate = false;\n\n\t\t\t_renderer.setRenderTarget(currentRenderTarget, activeCubeFace, activeMipmapLevel);\n\t\t};\n\n\t\tfunction VSMPass(shadow, camera) {\n\t\t\tvar geometry = _objects.update(fullScreenMesh); // vertical pass\n\n\n\t\t\tshadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture;\n\t\t\tshadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;\n\t\t\tshadowMaterialVertical.uniforms.radius.value = shadow.radius;\n\n\t\t\t_renderer.setRenderTarget(shadow.mapPass);\n\n\t\t\t_renderer.clear();\n\n\t\t\t_renderer.renderBufferDirect(camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null); // horizontal pass\n\n\n\t\t\tshadowMaterialHorizontal.uniforms.shadow_pass.value = shadow.mapPass.texture;\n\t\t\tshadowMaterialHorizontal.uniforms.resolution.value = shadow.mapSize;\n\t\t\tshadowMaterialHorizontal.uniforms.radius.value = shadow.radius;\n\n\t\t\t_renderer.setRenderTarget(shadow.map);\n\n\t\t\t_renderer.clear();\n\n\t\t\t_renderer.renderBufferDirect(camera, null, geometry, shadowMaterialHorizontal, fullScreenMesh, null);\n\t\t}\n\n\t\tfunction getDepthMaterialVariant(useMorphing, useSkinning, useInstancing) {\n\t\t\tvar index = useMorphing << 0 | useSkinning << 1 | useInstancing << 2;\n\t\t\tvar material = _depthMaterials[index];\n\n\t\t\tif (material === undefined) {\n\t\t\t\tmaterial = new MeshDepthMaterial({\n\t\t\t\t\tdepthPacking: RGBADepthPacking,\n\t\t\t\t\tmorphTargets: useMorphing,\n\t\t\t\t\tskinning: useSkinning\n\t\t\t\t});\n\t\t\t\t_depthMaterials[index] = material;\n\t\t\t}\n\n\t\t\treturn material;\n\t\t}\n\n\t\tfunction getDistanceMaterialVariant(useMorphing, useSkinning, useInstancing) {\n\t\t\tvar index = useMorphing << 0 | useSkinning << 1 | useInstancing << 2;\n\t\t\tvar material = _distanceMaterials[index];\n\n\t\t\tif (material === undefined) {\n\t\t\t\tmaterial = new MeshDistanceMaterial({\n\t\t\t\t\tmorphTargets: useMorphing,\n\t\t\t\t\tskinning: useSkinning\n\t\t\t\t});\n\t\t\t\t_distanceMaterials[index] = material;\n\t\t\t}\n\n\t\t\treturn material;\n\t\t}\n\n\t\tfunction getDepthMaterial(object, geometry, material, light, shadowCameraNear, shadowCameraFar, type) {\n\t\t\tvar result = null;\n\t\t\tvar getMaterialVariant = getDepthMaterialVariant;\n\t\t\tvar customMaterial = object.customDepthMaterial;\n\n\t\t\tif (light.isPointLight === true) {\n\t\t\t\tgetMaterialVariant = getDistanceMaterialVariant;\n\t\t\t\tcustomMaterial = object.customDistanceMaterial;\n\t\t\t}\n\n\t\t\tif (customMaterial === undefined) {\n\t\t\t\tvar useMorphing = false;\n\n\t\t\t\tif (material.morphTargets === true) {\n\t\t\t\t\tuseMorphing = geometry.morphAttributes && geometry.morphAttributes.position && geometry.morphAttributes.position.length > 0;\n\t\t\t\t}\n\n\t\t\t\tvar useSkinning = false;\n\n\t\t\t\tif (object.isSkinnedMesh === true) {\n\t\t\t\t\tif (material.skinning === true) {\n\t\t\t\t\t\tuseSkinning = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.warn('THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:', object);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvar useInstancing = object.isInstancedMesh === true;\n\t\t\t\tresult = getMaterialVariant(useMorphing, useSkinning, useInstancing);\n\t\t\t} else {\n\t\t\t\tresult = customMaterial;\n\t\t\t}
1\n\n\t\t\tif (_renderer.localClippingEnabled && material.clipShadows === true && material.clippingPlanes.length !== 0) {\n\t\t\t\t// in this case we need a unique material instance reflecting the\n\t\t\t\t// appropriate state\n\t\t\t\tvar keyA = result.uuid,\n\t\t\t\t\t\tkeyB = material.uuid;\n\t\t\t\tvar materialsForVariant = _materialCache[keyA];\n\n\t\t\t\tif (materialsForVariant === undefined) {\n\t\t\t\t\tmaterialsForVariant = {};\n\t\t\t\t\t_materialCache[keyA] = materialsForVariant;\n\t\t\t\t}\n\n\t\t\t\tvar cachedMaterial = materialsForVariant[keyB];\n\n\t\t\t\tif (cachedMaterial === undefined) {\n\t\t\t\t\tcachedMaterial = result.clone();\n\t\t\t\t\tmaterialsForVariant[keyB] = cachedMaterial;\n\t\t\t\t}\n\n\t\t\t\tresult = cachedMaterial;\n\t\t\t}\n\n\t\t\tresult.visible = material.visible;\n\t\t\tresult.wireframe = material.wireframe;\n\n\t\t\tif (type === VSMShadowMap) {\n\t\t\t\tresult.side = material.shadowSide !== null ? material.shadowSide : material.side;\n\t\t\t} else {\n\t\t\t\tresult.side = material.shadowSide !== null ? material.shadowSide : shadowSide[material.side];\n\t\t\t}
1\n\n\t\t\tresult.clipShadows = material.clipShadows;\n\t\t\tresult.clippingPlanes = material.clippingPlanes;\n\t\t\tresult.clipIntersection = material.clipIntersection;\n\t\t\tresult.wireframeLinewidth = material.wireframeLinewidth;\n\t\t\tresult.linewidth = material.linewidth;\n\n\t\t\tif (light.isPointLight === true && result.isMeshDistanceMaterial === true) {\n\t\t\t\tresult.referencePosition.setFromMatrixPosition(light.matrixWorld);\n\t\t\t\tresult.nearDistance = shadowCameraNear;\n\t\t\t\tresult.farDistance = shadowCameraFar;\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}\n\n\t\tfunction renderObject(object, camera, shadowCamera, light, type) {\n\t\t\tif (object.visible === false) return;\n\t\t\tvar visible = object.layers.test(camera.layers);\n\n\t\t\tif (visible && (object.isMesh || object.isLine || object.isPoints)) {\n\t\t\t\tif ((object.castShadow || object.receiveShadow && type === VSMShadowMap) && (!object.frustumCulled || _frustum.intersectsObject(object))) {\n\t\t\t\t\tobject.modelViewMatrix.multiplyMatrices(shadowCamera.matrixWorldInverse, object.matrixWorld);\n\n\t\t\t\t\tvar geometry = _objects.update(object);\n\n\t\t\t\t\tvar material = object.material;\n\n\t\t\t\t\tif (Array.isArray(material)) {\n\t\t\t\t\t\tvar groups = geometry.groups;\n\n\t\t\t\t\t\tfor (var k = 0, kl = groups.length; k < kl; k++) {\n\t\t\t\t\t\t\tvar group = groups[k];\n\t\t\t\t\t\t\tvar groupMaterial = material[group.materialIndex];\n\n\t\t\t\t\t\t\tif (groupMaterial && groupMaterial.visible) {\n\t\t\t\t\t\t\t\tvar depthMaterial = getDepthMaterial(object, geometry, groupMaterial, light, shadowCamera.near, shadowCamera.far, type);\n\n\t\t\t\t\t\t\t\t_renderer.renderBufferDirect(shadowCamera, null, geometry, depthMaterial, object, group);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (material.visible) {\n\t\t\t\t\t\tvar _depthMaterial = getDepthMaterial(object, geometry, material, light, shadowCamera.near, shadowCamera.far, type);\n\n\t\t\t\t\t\t_renderer.renderBufferDirect(shadowCamera, null, geometry, _depthMaterial, object, null);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar children = object.children;\n\n\t\t\tfor (var i = 0, l = children.length; i < l; i++) {\n\t\t\t\trenderObject(children[i], camera, shadowCamera, light, type);\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction WebGLState(gl, extensions, capabilities) {\n\t\tvar _equationToGL, _factorToGL;\n\n\t\tvar isWebGL2 = capabilities.isWebGL2;\n\n\t\tfunction ColorBuffer() {\n\t\t\tvar locked = false;\n\t\t\tvar color = new Vector4();\n\t\t\tvar currentColorMask = null;\n\t\t\tvar currentColorClear = new Vector4(0, 0, 0, 0);\n\t\t\treturn {\n\t\t\t\tsetMask: function setMask(colorMask) {\n\t\t\t\t\tif (currentColorMask !== colorMask && !locked) {\n\t\t\t\t\t\tgl.colorMask(colorMask, colorMask, colorMask, colorMask);\n\t\t\t\t\t\tcurrentColorMask = colorMask;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tsetLocked: function setLocked(lock) {\n\t\t\t\t\tlocked = lock;\n\t\t\t\t},\n\t\t\t\tsetClear: function setClear(r, g, b, a, premultipliedAlpha) {\n\t\t\t\t\tif (premultipliedAlpha === true) {\n\t\t\t\t\t\tr *= a;\n\t\t\t\t\t\tg *= a;\n\t\t\t\t\t\tb *= a;\n\t\t\t\t\t}\n\n\t\t\t\t\tcolor.set(r, g, b, a);\n\n\t\t\t\t\tif (currentColorClear.equals(color) === false) {\n\t\t\t\t\t\tgl.clearColor(r, g, b, a);\n\t\t\t\t\t\tcurrentColorClear.copy(color);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\treset: function reset() {\n\t\t\t\t\tlocked = false;\n\t\t\t\t\tcurrentColorMask = null;\n\t\t\t\t\tcurrentColorClear.set(-1, 0, 0, 0); // set to invalid state\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tfunction DepthBuffer() {\n\t\t\tvar locked = false;\n\t\t\tvar currentDepthMask = null;\n\t\t\tvar currentDepthFunc = null;\n\t\t\tvar currentDepthClear = null;\n\t\t\treturn {\n\t\t\t\tsetTest: function setTest(depthTest) {\n\t\t\t\t\tif (depthTest) {\n\t\t\t\t\t\tenable(2929);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdisable(2929);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tsetMask: function setMask(depthMask) {\n\t\t\t\t\tif (currentDepthMask !== depthMask && !locked) {\n\t\t\t\t\t\tgl.depthMask(depthMask);\n\t\t\t\t\t\tcurrentDepthMask = depthMask;\n\t\t\t\t\t}\n\t\t\t\t}
1,\n\t\t\t\tsetFunc: function setFunc(depthFunc) {\n\t\t\t\t\tif (currentDepthFunc !== depthFunc) {\n\t\t\t\t\t\tif (depthFunc) {\n\t\t\t\t\t\t\tswitch (depthFunc) {\n\t\t\t\t\t\t\t\tcase NeverDepth:\n\t\t\t\t\t\t\t\t\tgl.depthFunc(512);\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase AlwaysDepth:\n\t\t\t\t\t\t\t\t\tgl.depthFunc(519);\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase LessDepth:\n\t\t\t\t\t\t\t\t\tgl.depthFunc(513);\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase LessEqualDepth:\n\t\t\t\t\t\t\t\t\tgl.depthFunc(515);\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase EqualDepth:\n\t\t\t\t\t\t\t\t\tgl.depthFunc(514);\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase GreaterEqualDepth:\n\t\t\t\t\t\t\t\t\tgl.depthFunc(518);\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase GreaterDepth:\n\t\t\t\t\t\t\t\t\tgl.depthFunc(516);\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tcase NotEqualDepth:\n\t\t\t\t\t\t\t\t\tgl.depthFunc(517);\n\t\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\tgl.depthFunc(515);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tgl.depthFunc(515);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcurrentDepthFunc = depthFunc;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tsetLocked: function setLocked(lock) {\n\t\t\t\t\tlocked = lock;\n\t\t\t\t},\n\t\t\t\tsetClear: function setClear(depth) {\n\t\t\t\t\tif (currentDepthClear !== depth) {\n\t\t\t\t\t\tgl.clearDepth(depth);\n\t\t\t\t\t\tcurrentDepthClear = depth;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\treset: function reset() {\n\t\t\t\t\tlocked = false;\n\t\t\t\t\tcurrentDepthMask = null;\n\t\t\t\t\tcurrentDepthFunc = null;\n\t\t\t\t\tcurrentDepthClear = null;\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tfunction StencilBuffer() {\n\t\t\tvar locked = false;\n\t\t\tvar currentStencilMask = null;\n\t\t\tvar currentStencilFunc = null;\n\t\t\tvar currentStencilRef = null;\n\t\t\tvar currentStencilFuncMask = null;\n\t\t\tvar currentStencilFail = null;\n\t\t\tvar currentStencilZFail = null;\n\t\t\tvar currentStencilZPass = null;\n\t\t\tvar currentStencilClear = null;\n\t\t\treturn {\n\t\t\t\tsetTest: function setTest(stencilTest) {\n\t\t\t\t\tif (!locked) {\n\t\t\t\t\t\tif (stencilTest) {\n\t\t\t\t\t\t\tenable(2960);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdisable(2960);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tsetMask: function setMask(stencilMask) {\n\t\t\t\t\tif (currentStencilMask !== stencilMask && !locked) {\n\t\t\t\t\t\tgl.stencilMask(stencilMask);\n\t\t\t\t\t\tcurrentStencilMask = stencilMask;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tsetFunc: function setFunc(stencilFunc, stencilRef, stencilMask) {\n\t\t\t\t\tif (currentStencilFunc !== stencilFunc || currentStencilRef !== stencilRef || currentStencilFuncMask !== stencilMask) {\n\t\t\t\t\t\tgl.stencilFunc(stencilFunc, stencilRef, stencilMask);\n\t\t\t\t\t\tcurrentStencilFunc = stencilFunc;\n\t\t\t\t\t\tcurrentStencilRef = stencilRef;\n\t\t\t\t\t\tcurrentStencilFuncMask = stencilMask;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tsetOp: function setOp(stencilFail, stencilZFail, stencilZPass) {\n\t\t\t\t\tif (currentStencilFail !== stencilFail || currentStencilZFail !== stencilZFail || currentStencilZPass !== stencilZPass) {\n\t\t\t\t\t\tgl.stencilOp(stencilFail, stencilZFail, stencilZPass);\n\t\t\t\t\t\tcurrentStencilFail = stencilFail;\n\t\t\t\t\t\tcurrentStencilZFail = stencilZFail;\n\t\t\t\t\t\tcurrentStencilZPass = stencilZPass;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tsetLocked: function setLocked(lock) {\n\t\t\t\t\tlocked = lock;\n\t\t\t\t},\n\t\t\t\tsetClear: function setClear(stencil) {\n\t\t\t\t\tif (currentStencilClear !== stencil) {\n\t\t\t\t\t\tgl.clearStencil(stencil);\n\t\t\t\t\t\tcurrentStencilClear = stencil;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\treset: function reset() {\n\t\t\t\t\tlocked = false;\n\t\t\t\t\tcurrentStencilMask = null;\n\t\t\t\t\tcurrentStencilFunc = null;\n\t\t\t\t\tcurrentStencilRef = null;\n\t\t\t\t\tcurrentStencilFuncMask = null;\n\t\t\t\t\tcurrentStencilFail = null;\n\t\t\t\t\tcurrentStencilZFail = null;\n\t\t\t\t\tcurrentStencilZPass = null;\n\t\t\t\t\tcurrentStencilClear = null;\n\t\t\t\t}\n\t\t\t};\n\t\t} //\n\n\n\t\tvar colorBuffer = new ColorBuffer();\n\t\tvar depthBuffer = new DepthBuffer();\n\t\tvar stencilBuffer = new StencilBuffer();\n\t\tvar enabledCapabilities = {};\n\t\tvar currentProgram = null;\n\t\tvar currentBlendingEnabled = null;\n\t\tvar currentBlending = null;\n\t\tvar currentBlendEquation = null;\n\t\tvar currentBlendSrc = null;\n\t\tvar currentBlendDst = null;\n\t\tvar currentBlendEquationAlpha = null;\n\t\tvar currentBlendSrcAlpha = null;\n\t\tvar currentBlendDstAlpha = null;\n\t\tvar currentPremultipledAlpha = false;\n\t\tvar currentFlipSided = null;\n\t\tvar currentCullFace = null;\n\t\tvar currentLineWidth = null;\n\t\tvar currentPolygonOffsetFactor = null;\n\t\tvar currentPolygonOffsetUnits = null;\n\t\tvar maxTextures = gl.getParameter(35661);\n\t\tvar lineWidthAvailable = false;\n\t\tvar version = 0;\n\t\tvar glVersion = gl.getParameter(7938);\n\n\t\tif (glVersion.indexOf('WebGL') !== -1) {\n\t\t\tversion = parseFloat(/^WebGL (\\d)/.exec(glVersion)[1]);\n\t\t\tlineWidthAvailable = version >= 1.0;\n\t\t} else if (glVersion.indexOf('OpenGL ES') !== -1) {\n\t\t\tversion = parseFloat(/^OpenGL ES (\\d)/.exec(glVersion)[1]);\n\t\t\tlineWidthAvailable = version >= 2.0;\n\t\t}\n\n\t\tvar currentTextureSlot = null;\n\t\tvar currentBoundTextures = {};\n\t\tvar currentScissor = new Vector4();\n\t\tvar currentViewport = new Vector4();\n\n\t\tfunction createTexture(type, target, count) {\n\t\t\tvar data = new Uint8Array(4); // 4 is required to match default unpack alignment of 4.\n\n\t\t\tvar texture = gl.createTexture();\n\t\t\tgl.bindTexture(type, texture);\n\t\t\tgl.texParameteri(type, 10241, 9728);\n\t\t\tgl.texParameteri(type, 10240, 9728);\n\n\t\t\tfor (var i = 0; i < count;
1 i++) {\n\t\t\t\tgl.texImage2D(target + i, 0, 6408, 1, 1, 0, 6408, 5121, data);\n\t\t\t}\n\n\t\t\treturn texture;\n\t\t}\n\n\t\tvar emptyTextures = {};\n\t\temptyTextures[3553] = createTexture(3553, 3553, 1);\n\t\temptyTextures[34067] = createTexture(34067, 34069, 6); // init\n\n\t\tcolorBuffer.setClear(0, 0, 0, 1);\n\t\tdepthBuffer.setClear(1);\n\t\tstencilBuffer.setClear(0);\n\t\tenable(2929);\n\t\tdepthBuffer.setFunc(LessEqualDepth);\n\t\tsetFlipSided(false);\n\t\tsetCullFace(CullFaceBack);\n\t\tenable(2884);\n\t\tsetBlending(NoBlending); //\n\n\t\tfunction enable(id) {\n\t\t\tif (enabledCapabilities[id] !== true) {\n\t\t\t\tgl.enable(id);\n\t\t\t\tenabledCapabilities[id] = true;\n\t\t\t}\n\t\t}\n\n\t\tfunction disable(id) {\n\t\t\tif (enabledCapabilities[id] !== false) {\n\t\t\t\tgl.disable(id);\n\t\t\t\tenabledCapabilities[id] = false;\n\t\t\t}\n\t\t}\n\n\t\tfunction useProgram(program) {\n\t\t\tif (currentProgram !== program) {\n\t\t\t\tgl.useProgram(program);\n\t\t\t\tcurrentProgram = program;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn false;\n\t\t}\n\n\t\tvar equationToGL = (_equationToGL = {}, _equationToGL[AddEquation] = 32774, _equationToGL[SubtractEquation] = 32778, _equationToGL[ReverseSubtractEquation] = 32779, _equationToGL);\n\n\t\tif (isWebGL2) {\n\t\t\tequationToGL[MinEquation] = 32775;\n\t\t\tequationToGL[MaxEquation] = 32776;\n\t\t} else {\n\t\t\tvar extension = extensions.get('EXT_blend_minmax');\n\n\t\t\tif (extension !== null) {\n\t\t\t\tequationToGL[MinEquation] = extension.MIN_EXT;\n\t\t\t\tequationToGL[MaxEquation] = extension.MAX_EXT;\n\t\t\t}\n\t\t}\n\n\t\tvar factorToGL = (_factorToGL = {}, _factorToGL[ZeroFactor] = 0, _factorToGL[OneFactor] = 1, _factorToGL[SrcColorFactor] = 768, _factorToGL[SrcAlphaFactor] = 770, _factorToGL[SrcAlphaSaturateFactor] = 776, _factorToGL[DstColorFactor] = 774, _factorToGL[DstAlphaFactor] = 772, _factorToGL[OneMinusSrcColorFactor] = 769, _factorToGL[OneMinusSrcAlphaFactor] = 771, _factorToGL[OneMinusDstColorFactor] = 775, _factorToGL[OneMinusDstAlphaFactor] = 773, _factorToGL);\n\n\t\tfunction setBlending(blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha) {\n\t\t\tif (blending === NoBlending) {\n\t\t\t\tif (currentBlendingEnabled) {\n\t\t\t\t\tdisable(3042);\n\t\t\t\t\tcurrentBlendingEnabled = false;\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!currentBlendingEnabled) {\n\t\t\t\tenable(3042);\n\t\t\t\tcurrentBlendingEnabled = true;\n\t\t\t}\n\n\t\t\tif (blending !== CustomBlending) {\n\t\t\t\tif (blending !== currentBlending || premultipliedAlpha !== currentPremultipledAlpha) {\n\t\t\t\t\tif (currentBlendEquation !== AddEquation || currentBlendEquationAlpha !== AddEquation) {\n\t\t\t\t\t\tgl.blendEquation(32774);\n\t\t\t\t\t\tcurrentBlendEquation = AddEquation;\n\t\t\t\t\t\tcurrentBlendEquationAlpha = AddEquation;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (premultipliedAlpha) {\n\t\t\t\t\t\tswitch (blending) {\n\t\t\t\t\t\t\tcase NormalBlending:\n\t\t\t\t\t\t\t\tgl.blendFuncSeparate(1, 771, 1, 771);\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase AdditiveBlending:\n\t\t\t\t\t\t\t\tgl.blendFunc(1, 1);\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase SubtractiveBlending:\n\t\t\t\t\t\t\t\tgl.blendFuncSeparate(0, 0, 769, 771);\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase MultiplyBlending:\n\t\t\t\t\t\t\t\tgl.blendFuncSeparate(0, 768, 0, 770);\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tconsole.error('THREE.WebGLState: Invalid blending: ', blending);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tswitch (blending) {\n\t\t\t\t\t\t\tcase NormalBlending:\n\t\t\t\t\t\t\t\tgl.blendFuncSeparate(770, 771, 1, 771);\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase AdditiveBlending:\n\t\t\t\t\t\t\t\tgl.blendFunc(770, 1);\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase SubtractiveBlending:\n\t\t\t\t\t\t\t\tgl.blendFunc(0, 769);\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase MultiplyBlending:\n\t\t\t\t\t\t\t\tgl.blendFunc(0, 768);\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tconsole.error('THREE.WebGLState: Invalid blending: ', blending);\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrentBlendSrc = null;\n\t\t\t\t\tcurrentBlendDst = null;\n\t\t\t\t\tcurrentBlendSrcAlpha = null;\n\t\t\t\t\tcurrentBlendDstAlpha = null;\n\t\t\t\t\tcurrentBlending = blending;\n\t\t\t\t\tcurrentPremultipledAlpha = premultipliedAlpha;\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t} // custom blending\n\n\n\t\t\tblendEquationAlpha = blendEquationAlpha || blendEquation;\n\t\t\tblendSrcAlpha = blendSrcAlpha || blendSrc;\n\t\t\tblendDstAlpha = blendDstAlpha || blendDst;\n\n\t\t\tif (blendEquation !== currentBlendEquation || blendEquationAlpha !== currentBlendEquationAlpha) {\n\t\t\t\tgl.blendEquationSeparate(equationToGL[blendEquation], equationToGL[blendEquationAlpha]);\n\t\t\t\tcurrentBlendEquation = blendEquation;\n\t\t\t\tcurrentBlendEquationAlpha = blendEquationAlpha;\n\t\t\t}\n\n\t\t\tif (blendSrc !== currentBlendSrc || blendDst !== currentBlendDst || blendSrcAlpha !== currentBlendSrcAlpha || blendDstAlpha !== currentBlendDstAlpha) {\n\t\t\t\tgl.blendFuncSeparate(factorToGL[blendSrc], factorToGL[blendDst], factorToGL[blendSrcAlpha], factorToGL[blendDstAlpha]);\n\t\t\t\tcurrentBlendSrc = blendSrc;\n\t\t\t\tcurrentBlendDst = blendDst;\n\t\t\t\tcurrentBlendSrcAlpha = blendSrcAlpha;\n\t\t\t\tcurrentBlendDstAlpha = blendDstAlpha;\n\t\t\t}\n\n\t\t\tcurrentBlending = blending;\n\t\t\tcurrentPremultipledAlpha = null;\n\t\t}\n\n\t\tfunction setMaterial(material, frontFaceCW) {\n\t\t\tmaterial.side === DoubleSide ? disable(2884) : enable(2884);\n\t\t\tvar flipSided = material.side === BackSide;\n\t\t\tif (frontFaceCW) flipSided = !flipSided;\n\t\t\tsetFlipSided(flipSided);\n\t\t\tmaterial.blending === NormalBlending && material.transparent === false ? setBlending(NoBlending) : setBlending(material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.premultipliedAlpha);\n\t\t\tdepthBuffer.setFunc(material.depthFunc);\n\t\t\tdepthBuffer.setTest(material.depthTest);\n\t\t\tdepthBuffer.setMask(material.depthWrite);\n\t\t\tcolorBuffer.setMask(material.colorWrite);\n\t\t\tvar stencilWrite = material.stencilWrite;\n\t\t\tstencilBuffer.setTest(stencilWrite);\n\n\t\t\tif (stencilWrite) {\n\t\t\t\tstencilBuffer.setMask(material.stencilWriteMask);\n\t\t\t\tstencilBuffer.setFunc(material.stencilFunc, material.stencilRef, material.stencilFuncMask);\n\t\t\t\tstencilBuffer.setOp(material.stencilFail, material.stencilZFail, material.stencilZPass);\n\t\t\t}\n\n\t\t\tsetPolygonOffset(material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits);\n\t\t} //\n\n\n\t\tfunction setFlipSided(flipSided) {\n\t\t\tif (currentFlipSided !== flipSided) {\n\t\t\t\tif (flipSided) {\n\t\t\t\t\tgl.frontFace(2304);\n\t\t\t\t} else {\n\t\t\t\t\tgl.frontFace(2305);\n\t\t\t\t}\n\n\t\t\t\tcurrentFlipSided = flipSided;\n\t\t\t}\n\t\t}\n\n\t\tfunction setCullFace(cullFace) {\n\t\t\tif (cullFace !== CullFaceNone) {\n\t\t\t\tenable(2884);\n\n\t\t\t\tif (cullFace !== currentCullFace) {\n\t\t\t\t\tif (cullFace === CullFaceBack) {\n\t\t\t\t\t\tgl.cullFace(1029);\n\t\t\t\t\t} else if (cullFace === CullFaceFront) {\n\t\t\t\t\t\tgl.cullFace(1028);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tgl.cullFace(1032);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdisable(2884);\n\t\t\t}\n\n\t\t\tcurrentCullFace = cullFace;\n\t\t}\n\n\t\tfunction setLineWidth(width) {\n\t\t\tif (width !== currentLineWidth) {\n\t\t\t\tif (lineWidthAvailable) gl.lineWidth(width);\n\t\t\t\tcurrentLineWidth = width;\n\t\t\t}\n\t\t}\n\n\t\tfunction setPolygonOffset(polygonOffset, factor, units) {\n\t\t\tif (polygonOffset) {\n\t\t\t\tenable(32823);\n\n\t\t\t\tif (currentPolygonOffsetFactor !== factor || currentPolygonOffsetUnits !== units) {\n\t\t\t\t\tgl.polygonOffset(factor, units);\n\t\t\t\t\tcurrentPolygonOffsetFactor = factor;\n\t\t\t\t\tcurrentPolygonOffsetUnits = units;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdisable(32823);\n\t\t\t}\n\t\t}\n\n\t\tfunction setScissorTest(scissorTest) {\n\t\t\tif (scissorTest) {\n\t\t\t\tenable(3089);\n\t\t\t} else {\n\t\t\t\tdisable(3089);\n\t\t\t}\n\t\t} // texture\n\n\n\t\tfunction activeTexture(webglSlot) {\n\t\t\tif (webglSlot === undefined) webglSlot = 33984 + maxTextures - 1;\n\n\t\t\tif (currentTextureSlot !== webglSlot) {\n\t\t\t\tgl.activeTexture(webglSlot);\n\t\t\t\tcurrentTextureSlot = webglSlot;\n\t\t\t}\n\t\t}\n\n\t\tfunction bindTexture(webglType, webglTexture) {\n\t\t\tif (currentTextureSlot === null) {\n\t\t\t\tactiveTexture();\n\t\t\t}\n\n\t\t\tvar boundTexture = currentBoundTextures[currentTextureSlot];
1\n\n\t\t\tif (boundTexture === undefined) {\n\t\t\t\tboundTexture = {\n\t\t\t\t\ttype: undefined,\n\t\t\t\t\ttexture: undefined\n\t\t\t\t};\n\t\t\t\tcurrentBoundTextures[currentTextureSlot] = boundTexture;\n\t\t\t}\n\n\t\t\tif (boundTexture.type !== webglType || boundTexture.texture !== webglTexture) {\n\t\t\t\tgl.bindTexture(webglType, webglTexture || emptyTextures[webglType]);\n\t\t\t\tboundTexture.type = webglType;\n\t\t\t\tboundTexture.texture = webglTexture;\n\t\t\t}\n\t\t}\n\n\t\tfunction unbindTexture() {\n\t\t\tvar boundTexture = currentBoundTextures[currentTextureSlot];\n\n\t\t\tif (boundTexture !== undefined && boundTexture.type !== undefined) {\n\t\t\t\tgl.bindTexture(boundTexture.type, null);\n\t\t\t\tboundTexture.type = undefined;\n\t\t\t\tboundTexture.texture = undefined;\n\t\t\t}\n\t\t}\n\n\t\tfunction compressedTexImage2D() {\n\t\t\ttry {\n\t\t\t\tgl.compressedTexImage2D.apply(gl, arguments);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('THREE.WebGLState:', error);\n\t\t\t}\n\t\t}\n\n\t\tfunction texImage2D() {\n\t\t\ttry {\n\t\t\t\tgl.texImage2D.apply(gl, arguments);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('THREE.WebGLState:', error);\n\t\t\t}\n\t\t}\n\n\t\tfunction texImage3D() {\n\t\t\ttry {\n\t\t\t\tgl.texImage3D.apply(gl, arguments);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('THREE.WebGLState:', error);\n\t\t\t}\n\t\t} //\n\n\n\t\tfunction scissor(scissor) {\n\t\t\tif (currentScissor.equals(scissor) === false) {\n\t\t\t\tgl.scissor(scissor.x, scissor.y, scissor.z, scissor.w);\n\t\t\t\tcurrentScissor.copy(scissor);\n\t\t\t}\n\t\t}\n\n\t\tfunction viewport(viewport) {\n\t\t\tif (currentViewport.equals(viewport) === false) {\n\t\t\t\tgl.viewport(viewport.x, viewport.y, viewport.z, viewport.w);\n\t\t\t\tcurrentViewport.copy(viewport);\n\t\t\t}\n\t\t} //\n\n\n\t\tfunction reset() {\n\t\t\tenabledCapabilities = {};\n\t\t\tcurrentTextureSlot = null;\n\t\t\tcurrentBoundTextures = {};\n\t\t\tcurrentProgram = null;\n\t\t\tcurrentBlendingEnabled = null;\n\t\t\tcurrentBlending = null;\n\t\t\tcurrentBlendEquation = null;\n\t\t\tcurrentBlendSrc = null;\n\t\t\tcurrentBlendDst = null;\n\t\t\tcurrentBlendEquationAlpha = null;\n\t\t\tcurrentBlendSrcAlpha = null;\n\t\t\tcurrentBlendDstAlpha = null;\n\t\t\tcurrentPremultipledAlpha = false;\n\t\t\tcurrentFlipSided = null;\n\t\t\tcurrentCullFace = null;\n\t\t\tcurrentLineWidth = null;\n\t\t\tcurrentPolygonOffsetFactor = null;\n\t\t\tcurrentPolygonOffsetUnits = null;\n\t\t\tcolorBuffer.reset();\n\t\t\tdepthBuffer.reset();\n\t\t\tstencilBuffer.reset();\n\t\t}\n\n\t\treturn {\n\t\t\tbuffers: {\n\t\t\t\tcolor: colorBuffer,\n\t\t\t\tdepth: depthBuffer,\n\t\t\t\tstencil: stencilBuffer\n\t\t\t},\n\t\t\tenable: enable,\n\t\t\tdisable: disable,\n\t\t\tuseProgram: useProgram,\n\t\t\tsetBlending: setBlending,\n\t\t\tsetMaterial: setMaterial,\n\t\t\tsetFlipSided: setFlipSided,\n\t\t\tsetCullFace: setCullFace,\n\t\t\tsetLineWidth: setLineWidth,\n\t\t\tsetPolygonOffset: setPolygonOffset,\n\t\t\tsetScissorTest: setScissorTest,\n\t\t\tactiveTexture: activeTexture,\n\t\t\tbindTexture: bindTexture,\n\t\t\tunbindTexture: unbindTexture,\n\t\t\tcompressedTexImage2D: compressedTexImage2D,\n\t\t\ttexImage2D: texImage2D,\n\t\t\ttexImage3D: texImage3D,\n\t\t\tscissor: scissor,\n\t\t\tviewport: viewport,\n\t\t\treset: reset\n\t\t};\n\t}\n\n\tfunction WebGLTextures(_gl, extensions, state, properties, capabilities, utils, info) {\n\t\tvar _wrappingToGL, _filterToGL;\n\n\t\tvar isWebGL2 = capabilities.isWebGL2;\n\t\tvar maxTextures = capabilities.maxTextures;\n\t\tvar maxCubemapSize = capabilities.maxCubemapSize;\n\t\tvar maxTextureSize = capabilities.maxTextureSize;\n\t\tvar maxSamples = capabilities.maxSamples;\n\n\t\tvar _videoTextures = new WeakMap();\n\n\t\tvar _canvas; // cordova iOS (as of 5.0) still uses UIWebView, which provides OffscreenCanvas,\n\t\t// also OffscreenCanvas.getContext(\"webgl\"), but not OffscreenCanvas.getContext(\"2d\")!\n\t\t// Some implementations may only implement OffscreenCanvas partially (e.g. lacking 2d).\n\n\n\t\tvar useOffscreenCanvas = false;\n\n\t\ttry {\n\t\t\tuseOffscreenCanvas = typeof OffscreenCanvas !== 'undefined' && new OffscreenCanvas(1, 1).getContext('2d') !== null;\n\t\t} catch (err) {// Ignore any errors\n\t\t}\n\n\t\tfunction createCanvas(width, height) {\n\t\t\t// Use OffscreenCanvas when available. Specially needed in web workers\n\t\t\treturn useOffscreenCanvas ? new OffscreenCanvas(width, height) : document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');\n\t\t}\n\n\t\tfunction resizeImage(image, needsPowerOfTwo, needsNewCanvas, maxSize) {\n\t\t\tvar scale = 1; // handle case if texture exceeds max size\n\n\t\t\tif (image.width > maxSize || image.height > maxSize) {\n\t\t\t\tscale = maxSize / Math.max(image.width, image.height);\n\t\t\t} // only perform resize if necessary\n\n\n\t\t\tif (scale < 1 || needsPowerOfTwo === true) {\n\t\t\t\t// only perform resize for certain image types\n\t\t\t\tif (typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement || typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement || typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap) {\n\t\t\t\t\tvar floor = needsPowerOfTwo ? MathUtils.floorPowerOfTwo : Math.floor;\n\t\t\t\t\tvar width = floor(scale * image.width);\n\t\t\t\t\tvar height = floor(scale * image.height);\n\t\t\t\t\tif (_canvas === undefined) _canvas = createCanvas(width, height); // cube textures can't reuse the same canvas\n\n\t\t\t\t\tvar canvas = needsNewCanvas ? createCanvas(width, height) : _canvas;\n\t\t\t\t\tcanvas.width = width;\n\t\t\t\t\tcanvas.height = height;\n\t\t\t\t\tvar context = canvas.getContext('2d');\n\t\t\t\t\tcontext.drawImage(image, 0, 0, width, height);\n\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Texture has been resized from (' + image.width + 'x' + image.height + ') to (' + width + 'x' + height + ').');\n\t\t\t\t\treturn canvas;\n\t\t\t\t} else {\n\t\t\t\t\tif ('data' in image) {\n\t\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Image in DataTexture is too big (' + image.width + 'x' + image.height + ').');\n\t\t\t\t\t}\n\n\t\t\t\t\treturn image;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn image;\n\t\t}\n\n\t\tfunction isPowerOfTwo(image) {\n\t\t\treturn MathUtils.isPowerOfTwo(image.width) && MathUtils.isPowerOfTwo(image.height);\n\t\t}\n\n\t\tfunction textureNeedsPowerOfTwo(texture) {\n\t\t\tif (isWebGL2) return false;\n\t\t\treturn texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping || texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;\n\t\t}\n\n\t\tfunction textureNeedsGenerateMipmaps(texture, supportsMips) {\n\t\t\treturn texture.generateMipmaps && supportsMips && texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;\n\t\t}\n\n\t\tfunction generateMipmap(target, texture, width, height) {\n\t\t\t_gl.generateMipmap(target);\n\n\t\t\tvar textureProperties = properties.get(texture); // Note: Math.log( x ) * Math.LOG2E used instead of Math.log2( x ) which is not supported by IE11\n\n\t\t\ttextureProperties.__maxMipLevel = Math.log(Math.max(width, height)) * Math.LOG2E;\n\t\t}\n\n\t\tfunction getInternalFormat(internalFormatName, glFormat, glType) {\n\t\t\tif (isWebGL2 === false) return glFormat;\n\n\t\t\tif (internalFormatName !== null) {\n\t\t\t\tif (_gl[internalFormatName] !== undefined) return _gl[internalFormatName];\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format \\'' + internalFormatName + '\\'');\n\t\t\t}\n\n\t\t\tvar internalFormat = glFormat;\n\n\t\t\tif (glFormat === 6403) {\n\t\t\t\tif (glType === 5126) internalFormat = 33326;\n\t\t\t\tif (glType === 5131) internalFormat = 33325;\n\t\t\t\tif (glType === 5121) internalFormat = 33321;\n\t\t\t}\n\n\t\t\tif (glFormat === 6407) {\n\t\t\t\tif (glType === 5126) internalFormat = 34837;\n\t\t\t\tif (glType === 5131) internalFormat = 34843;\n\t\t\t\tif (glType === 5121) internalFormat = 32849;\n\t\t\t}\n\n\t\t\tif (glFormat === 6408) {\n\t\t\t\tif (glType === 5126) internalFormat = 34836;\n\t\t\t\tif (glType === 5131) internalFormat = 34842;\n\t\t\t\tif (glType === 5121) internalFormat = 32856;\n\t\t\t}\n\n\t\t\tif (internalFormat === 33325 || internalFormat === 33326 || internalFormat === 34842 || internalFormat === 34836) {\n\t\t\t\textensions.get('EXT_color_buffer_float');\n\t\t\t}\n\n\t\t\treturn internalFormat;\n\t\t} // Fallback filters for non-power-of-2 textures\n\n\n\t\tfunction filterFallback(f) {\n\t\t\tif (f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter) {\n\t\t\t\treturn 9728;\n\t\t\t}\n\n\t\t\treturn 9729;\n\t\t} //\n\n\n\t\tfunction onTextureDispose(event) {\n\t\t\tvar texture = event.target;\n\t\t\ttexture.removeEventListener('dispose', onTextureDispose);\n\t\t\tdeallocateTexture(texture);\n\n\t\t\tif (texture.isVideoTexture) {\n\t\t\t\t_videoTextures.delete(texture);\n\t\t\t}\n\n\t\t\tinfo.memory.textures--;\n\t\t}\n\n\t\tfunction onRenderTargetDispose(event) {\n\t\t\tvar renderTarget = event.target;\n\t\t\trenderTarget.removeEventListener('dispose', onRenderTargetDispose);\n\t\t\tdeallocateRenderTarget(renderTarget);\n\t\t\tinfo.memory.textures--;\n\t\t} //\n\n\n\t\tfunction deallocateTexture(texture) {\n\t\t\tvar textureProperties = properties.get(texture);\n\t\t\tif (textureProperties.__webglInit === undefined) return;\n\n\t\t\t_gl.deleteTexture(textureProperties.__webglTexture);\n\n\t\t\tproperties.remove(texture);\n\t\t}\n\n\t\tfunction deallocateRenderTarget(renderTarget) {\n\t\t\tvar renderTargetProperties = properties.get(renderTarget);\n\t\t\tvar textureProperties = properties.get(renderTarget.texture);\n\t\t\tif (!renderTarget) return;\n\n\t\t\tif (textureProperties.__webglTexture !== undefined) {\n\t\t\t\t_gl.deleteTexture(textureProperties.__webglTexture);\n\t\t\t}\n\n\t\t\tif (renderTarget.depthTexture) {\n\t\t\t\trenderTarget.depthTexture.dispose();\n\t\t\t}
1\n\n\t\t\tif (renderTarget.isWebGLCubeRenderTarget) {\n\t\t\t\tfor (var i = 0; i < 6; i++) {\n\t\t\t\t\t_gl.deleteFramebuffer(renderTargetProperties.__webglFramebuffer[i]);\n\n\t\t\t\t\tif (renderTargetProperties.__webglDepthbuffer) _gl.deleteRenderbuffer(renderTargetProperties.__webglDepthbuffer[i]);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t_gl.deleteFramebuffer(renderTargetProperties.__webglFramebuffer);\n\n\t\t\t\tif (renderTargetProperties.__webglDepthbuffer) _gl.deleteRenderbuffer(renderTargetProperties.__webglDepthbuffer);\n\t\t\t\tif (renderTargetProperties.__webglMultisampledFramebuffer) _gl.deleteFramebuffer(renderTargetProperties.__webglMultisampledFramebuffer);\n\t\t\t\tif (renderTargetProperties.__webglColorRenderbuffer) _gl.deleteRenderbuffer(renderTargetProperties.__webglColorRenderbuffer);\n\t\t\t\tif (renderTargetProperties.__webglDepthRenderbuffer) _gl.deleteRenderbuffer(renderTargetProperties.__webglDepthRenderbuffer);\n\t\t\t}\n\n\t\t\tproperties.remove(renderTarget.texture);\n\t\t\tproperties.remove(renderTarget);\n\t\t} //\n\n\n\t\tvar textureUnits = 0;\n\n\t\tfunction resetTextureUnits() {\n\t\t\ttextureUnits = 0;\n\t\t}\n\n\t\tfunction allocateTextureUnit() {\n\t\t\tvar textureUnit = textureUnits;\n\n\t\t\tif (textureUnit >= maxTextures) {\n\t\t\t\tconsole.warn('THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + maxTextures);\n\t\t\t}\n\n\t\t\ttextureUnits += 1;\n\t\t\treturn textureUnit;\n\t\t} //\n\n\n\t\tfunction setTexture2D(texture, slot) {\n\t\t\tvar textureProperties = properties.get(texture);\n\t\t\tif (texture.isVideoTexture) updateVideoTexture(texture);\n\n\t\t\tif (texture.version > 0 && textureProperties.__version !== texture.version) {\n\t\t\t\tvar image = texture.image;\n\n\t\t\t\tif (image === undefined) {\n\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Texture marked for update but image is undefined');\n\t\t\t\t} else if (image.complete === false) {\n\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Texture marked for update but image is incomplete');\n\t\t\t\t} else {\n\t\t\t\t\tuploadTexture(textureProperties, texture, slot);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstate.activeTexture(33984 + slot);\n\t\t\tstate.bindTexture(3553, textureProperties.__webglTexture);\n\t\t}\n\n\t\tfunction setTexture2DArray(texture, slot) {\n\t\t\tvar textureProperties = properties.get(texture);\n\n\t\t\tif (texture.version > 0 && textureProperties.__version !== texture.version) {\n\t\t\t\tuploadTexture(textureProperties, texture, slot);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tstate.activeTexture(33984 + slot);\n\t\t\tstate.bindTexture(35866, textureProperties.__webglTexture);\n\t\t}\n\n\t\tfunction setTexture3D(texture, slot) {\n\t\t\tvar textureProperties = properties.get(texture);\n\n\t\t\tif (texture.version > 0 && textureProperties.__version !== texture.version) {\n\t\t\t\tuploadTexture(textureProperties, texture, slot);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tstate.activeTexture(33984 + slot);\n\t\t\tstate.bindTexture(32879, textureProperties.__webglTexture);\n\t\t}\n\n\t\tfunction setTextureCube(texture, slot) {\n\t\t\tvar textureProperties = properties.get(texture);\n\n\t\t\tif (texture.version > 0 && textureProperties.__version !== texture.version) {\n\t\t\t\tuploadCubeTexture(textureProperties, texture, slot);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tstate.activeTexture(33984 + slot);\n\t\t\tstate.bindTexture(34067, textureProperties.__webglTexture);\n\t\t}\n\n\t\tvar wrappingToGL = (_wrappingToGL = {}, _wrappingToGL[RepeatWrapping] = 10497, _wrappingToGL[ClampToEdgeWrapping] = 33071, _wrappingToGL[MirroredRepeatWrapping] = 33648, _wrappingToGL);\n\t\tvar filterToGL = (_filterToGL = {}, _filterToGL[NearestFilter] = 9728, _filterToGL[NearestMipmapNearestFilter] = 9984, _filterToGL[NearestMipmapLinearFilter] = 9986, _filterToGL[LinearFilter] = 9729, _filterToGL[LinearMipmapNearestFilter] = 9985, _filterToGL[LinearMipmapLinearFilter] = 9987, _filterToGL);\n\n\t\tfunction setTextureParameters(textureType, texture, supportsMips) {\n\t\t\tif (supportsMips) {\n\t\t\t\t_gl.texParameteri(textureType, 10242, wrappingToGL[texture.wrapS]);\n\n\t\t\t\t_gl.texParameteri(textureType, 10243, wrappingToGL[texture.wrapT]);\n\n\t\t\t\tif (textureType === 32879 || textureType === 35866) {\n\t\t\t\t\t_gl.texParameteri(textureType, 32882, wrappingToGL[texture.wrapR]);\n\t\t\t\t}\n\n\t\t\t\t_gl.texParameteri(textureType, 10240, filterToGL[texture.magFilter]);\n\n\t\t\t\t_gl.texParameteri(textureType, 10241, filterToGL[texture.minFilter]);\n\t\t\t} else {\n\t\t\t\t_gl.texParameteri(textureType, 10242, 33071);\n\n\t\t\t\t_gl.texParameteri(textureType, 10243, 33071);\n\n\t\t\t\tif (textureType === 32879 || textureType === 35866) {\n\t\t\t\t\t_gl.texParameteri(textureType, 32882, 33071);\n\t\t\t\t}\n\n\t\t\t\tif (texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping) {\n\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.');\n\t\t\t\t}\n\n\t\t\t\t_gl.texParameteri(textureType, 10240, filterFallback(texture.magFilter));\n\n\t\t\t\t_gl.texParameteri(textureType, 10241, filterFallback(texture.minFilter));\n\n\t\t\t\tif (texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter) {\n\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar extension = extensions.get('EXT_texture_filter_anisotropic');\n\n\t\t\tif (extension) {\n\t\t\t\tif (texture.type === FloatType && extensions.get('OES_texture_float_linear') === null) return;\n\t\t\t\tif (texture.type === HalfFloatType && (isWebGL2 || extensions.get('OES_texture_half_float_linear')) === null) return;\n\n\t\t\t\tif (texture.anisotropy > 1 || properties.get(texture).__currentAnisotropy) {\n\t\t\t\t\t_gl.texParameterf(textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(texture.anisotropy, capabilities.getMaxAnisotropy()));\n\n\t\t\t\t\tproperties.get(texture).__currentAnisotropy = texture.anisotropy;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction initTexture(textureProperties, texture) {\n\t\t\tif (textureProperties.__webglInit === undefined) {\n\t\t\t\ttextureProperties.__webglInit = true;\n\t\t\t\ttexture.addEventListener('dispose', onTextureDispose);\n\t\t\t\ttextureProperties.__webglTexture = _gl.createTexture();\n\t\t\t\tinfo.memory.textures++;\n\t\t\t}\n\t\t}\n\n\t\tfunction uploadTexture(textureProperties, texture, slot) {\n\t\t\tvar textureType = 3553;\n\t\t\tif (texture.isDataTexture2DArray) textureType = 35866;\n\t\t\tif (texture.isDataTexture3D) textureType = 32879;\n\t\t\tinitTexture(textureProperties, texture);\n\t\t\tstate.activeTexture(33984 + slot);\n\t\t\tstate.bindTexture(textureType, textureProperties.__webglTexture);\n\n\t\t\t_gl.pixelStorei(37440, texture.flipY);\n\n\t\t\t_gl.pixelStorei(37441, texture.premultiplyAlpha);\n\n\t\t\t_gl.pixelStorei(3317, texture.unpackAlignment);\n\n\t\t\tvar needsPowerOfTwo = textureNeedsPowerOfTwo(texture) && isPowerOfTwo(texture.image) === false;\n\t\t\tvar image = resizeImage(texture.image, needsPowerOfTwo, false, maxTextureSize);\n\t\t\tvar supportsMips = isPowerOfTwo(image) || isWebGL2,\n\t\t\t\t\tglFormat = utils.convert(texture.format);\n\t\t\tvar glType = utils.convert(texture.type),\n\t\t\t\t\tglInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType);\n\t\t\tsetTextureParameters(textureType, texture, supportsMips);\n\t\t\tvar mipmap;\n\t\t\tvar mipmaps = texture.mipmaps;\n\n\t\t\tif (texture.isDepthTexture) {\n\t\t\t\t// populate depth texture with dummy data\n\t\t\t\tglInternalFormat = 6402;\n\n\t\t\t\tif (isWebGL2) {\n\t\t\t\t\tif (texture.type === FloatType) {\n\t\t\t\t\t\tglInternalFormat = 36012;\n\t\t\t\t\t} else if (texture.type === UnsignedIntType) {\n\t\t\t\t\t\tglInternalFormat = 33190;\n\t\t\t\t\t} else if (texture.type === UnsignedInt248Type) {\n\t\t\t\t\t\tglInternalFormat = 35056;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tglInternalFormat = 33189; // WebGL2 requires sized internalformat for glTexImage2D\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (texture.type === FloatType) {\n\t\t\t\t\t\tconsole.error('WebGLRenderer: Floating point depth texture requires WebGL2.');\n\t\t\t\t\t}\n\t\t\t\t} // validation checks for WebGL 1\n\n\n\t\t\t\tif (texture.format === DepthFormat && glInternalFormat === 6402) {\n\t\t\t\t\t// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are\n\t\t\t\t\t// DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT\n\t\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\t\tif (texture.type !== UnsignedShortType && texture.type !== UnsignedIntType) {\n\t\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.');\n\t\t\t\t\t\ttexture.type = UnsignedShortType;\n\t\t\t\t\t\tglType = utils.convert(texture.type);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (texture.format === DepthStencilFormat && glInternalFormat === 6402) {\n\t\t\t\t\t// Depth stencil textures need the DEPTH_STENCIL internal format\n\t\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\t\tglInternalFormat = 34041; // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are\n\t\t\t\t\t// DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.\n\t\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\n\t\t\t\t\tif (texture.type !== UnsignedInt248Type) {\n\t\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.');\n\t\t\t\t\t\ttexture.type = UnsignedInt248Type;\n\t\t\t\t\t\tglType = utils.convert(texture.type);\n\t\t\t\t\t}\n\t\t\t\t} //\n\n\n\t\t\t\tstate.texImage2D(3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null);\n\t\t\t} else if (texture.isDataTexture) {\n\t\t\t\t// use manually created mipmaps if available\n\t\t\t\t// if there are no manual mipmaps\n\t\t\t\t// set 0 level mipmap and then use GL to generate other mipmap levels\n\t\t\t\tif (mipmaps.length > 0 && supportsMips) {\n\t\t\t\t\tfor (var i = 0, il = mipmaps.length; i < il;
1 i++) {\n\t\t\t\t\t\tmipmap = mipmaps[i];\n\t\t\t\t\t\tstate.texImage2D(3553, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);\n\t\t\t\t\t}\n\n\t\t\t\t\ttexture.generateMipmaps = false;\n\t\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\t\t\t\t} else {\n\t\t\t\t\tstate.texImage2D(3553, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data);\n\t\t\t\t\ttextureProperties.__maxMipLevel = 0;\n\t\t\t\t}\n\t\t\t} else if (texture.isCompressedTexture) {\n\t\t\t\tfor (var _i = 0, _il = mipmaps.length; _i < _il; _i++) {\n\t\t\t\t\tmipmap = mipmaps[_i];\n\n\t\t\t\t\tif (texture.format !== RGBAFormat && texture.format !== RGBFormat) {\n\t\t\t\t\t\tif (glFormat !== null) {\n\t\t\t\t\t\t\tstate.compressedTexImage2D(3553, _i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()');\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate.texImage2D(3553, _i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\t\t\t} else if (texture.isDataTexture2DArray) {\n\t\t\t\tstate.texImage3D(35866, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);\n\t\t\t\ttextureProperties.__maxMipLevel = 0;\n\t\t\t} else if (texture.isDataTexture3D) {\n\t\t\t\tstate.texImage3D(32879, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data);\n\t\t\t\ttextureProperties.__maxMipLevel = 0;\n\t\t\t} else {\n\t\t\t\t// regular Texture (image, video, canvas)\n\t\t\t\t// use manually created mipmaps if available\n\t\t\t\t// if there are no manual mipmaps\n\t\t\t\t// set 0 level mipmap and then use GL to generate other mipmap levels\n\t\t\t\tif (mipmaps.length > 0 && supportsMips) {\n\t\t\t\t\tfor (var _i2 = 0, _il2 = mipmaps.length; _i2 < _il2; _i2++) {\n\t\t\t\t\t\tmipmap = mipmaps[_i2];\n\t\t\t\t\t\tstate.texImage2D(3553, _i2, glInternalFormat, glFormat, glType, mipmap);\n\t\t\t\t\t}\n\n\t\t\t\t\ttexture.generateMipmaps = false;\n\t\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\t\t\t\t} else {\n\t\t\t\t\tstate.texImage2D(3553, 0, glInternalFormat, glFormat, glType, image);\n\t\t\t\t\ttextureProperties.__maxMipLevel = 0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (textureNeedsGenerateMipmaps(texture, supportsMips)) {\n\t\t\t\tgenerateMipmap(textureType, texture, image.width, image.height);\n\t\t\t}\n\n\t\t\ttextureProperties.__version = texture.version;\n\t\t\tif (texture.onUpdate) texture.onUpdate(texture);\n\t\t}\n\n\t\tfunction uploadCubeTexture(textureProperties, texture, slot) {\n\t\t\tif (texture.image.length !== 6) return;\n\t\t\tinitTexture(textureProperties, texture);\n\t\t\tstate.activeTexture(33984 + slot);\n\t\t\tstate.bindTexture(34067, textureProperties.__webglTexture);\n\n\t\t\t_gl.pixelStorei(37440, texture.flipY);\n\n\t\t\tvar isCompressed = texture && (texture.isCompressedTexture || texture.image[0].isCompressedTexture);\n\t\t\tvar isDataTexture = texture.image[0] && texture.image[0].isDataTexture;\n\t\t\tvar cubeImage = [];\n\n\t\t\tfor (var i = 0; i < 6; i++) {\n\t\t\t\tif (!isCompressed && !isDataTexture) {\n\t\t\t\t\tcubeImage[i] = resizeImage(texture.image[i], false, true, maxCubemapSize);\n\t\t\t\t} else {\n\t\t\t\t\tcubeImage[i] = isDataTexture ? texture.image[i].image : texture.image[i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar image = cubeImage[0],\n\t\t\t\t\tsupportsMips = isPowerOfTwo(image) || isWebGL2,\n\t\t\t\t\tglFormat = utils.convert(texture.format),\n\t\t\t\t\tglType = utils.convert(texture.type),\n\t\t\t\t\tglInternalFormat = getInternalFormat(texture.internalFormat, glFormat, glType);\n\t\t\tsetTextureParameters(34067, texture, supportsMips);\n\t\t\tvar mipmaps;\n\n\t\t\tif (isCompressed) {\n\t\t\t\tfor (var _i3 = 0; _i3 < 6; _i3++) {\n\t\t\t\t\tmipmaps = cubeImage[_i3].mipmaps;\n\n\t\t\t\t\tfor (var j = 0; j < mipmaps.length;
1 j++) {\n\t\t\t\t\t\tvar mipmap = mipmaps[j];\n\n\t\t\t\t\t\tif (texture.format !== RGBAFormat && texture.format !== RGBFormat) {\n\t\t\t\t\t\t\tif (glFormat !== null) {\n\t\t\t\t\t\t\t\tstate.compressedTexImage2D(34069 + _i3, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tstate.texImage2D(34069 + _i3, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\t\t\t} else {\n\t\t\t\tmipmaps = texture.mipmaps;\n\n\t\t\t\tfor (var _i4 = 0; _i4 < 6; _i4++) {\n\t\t\t\t\tif (isDataTexture) {\n\t\t\t\t\t\tstate.texImage2D(34069 + _i4, 0, glInternalFormat, cubeImage[_i4].width, cubeImage[_i4].height, 0, glFormat, glType, cubeImage[_i4].data);\n\n\t\t\t\t\t\tfor (var _j = 0; _j < mipmaps.length; _j++) {\n\t\t\t\t\t\t\tvar _mipmap = mipmaps[_j];\n\t\t\t\t\t\t\tvar mipmapImage = _mipmap.image[_i4].image;\n\t\t\t\t\t\t\tstate.texImage2D(34069 + _i4, _j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate.texImage2D(34069 + _i4, 0, glInternalFormat, glFormat, glType, cubeImage[_i4]);\n\n\t\t\t\t\t\tfor (var _j2 = 0; _j2 < mipmaps.length; _j2++) {\n\t\t\t\t\t\t\tvar _mipmap2 = mipmaps[_j2];\n\t\t\t\t\t\t\tstate.texImage2D(34069 + _i4, _j2 + 1, glInternalFormat, glFormat, glType, _mipmap2.image[_i4]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length;\n\t\t\t}\n\n\t\t\tif (textureNeedsGenerateMipmaps(texture, supportsMips)) {\n\t\t\t\t// We assume images for cube map have the same size.\n\t\t\t\tgenerateMipmap(34067, texture, image.width, image.height);\n\t\t\t}\n\n\t\t\ttextureProperties.__version = texture.version;\n\t\t\tif (texture.onUpdate) texture.onUpdate(texture);\n\t\t} // Render targets\n\t\t// Setup storage for target texture and bind it to correct framebuffer\n\n\n\t\tfunction setupFrameBufferTexture(framebuffer, renderTarget, attachment, textureTarget) {\n\t\t\tvar glFormat = utils.convert(renderTarget.texture.format);\n\t\t\tvar glType = utils.convert(renderTarget.texture.type);\n\t\t\tvar glInternalFormat = getInternalFormat(renderTarget.texture.internalFormat, glFormat, glType);\n\t\t\tstate.texImage2D(textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null);\n\n\t\t\t_gl.bindFramebuffer(36160, framebuffer);\n\n\t\t\t_gl.framebufferTexture2D(36160, attachment, textureTarget, properties.get(renderTarget.texture).__webglTexture, 0);\n\n\t\t\t_gl.bindFramebuffer(36160, null);\n\t\t} // Setup storage for internal depth/stencil buffers and bind to correct framebuffer\n\n\n\t\tfunction setupRenderBufferStorage(renderbuffer, renderTarget, isMultisample) {\n\t\t\t_gl.bindRenderbuffer(36161, renderbuffer);\n\n\t\t\tif (renderTarget.depthBuffer && !renderTarget.stencilBuffer) {\n\t\t\t\tvar glInternalFormat = 33189;\n\n\t\t\t\tif (isMultisample) {\n\t\t\t\t\tvar depthTexture = renderTarget.depthTexture;\n\n\t\t\t\t\tif (depthTexture && depthTexture.isDepthTexture) {\n\t\t\t\t\t\tif (depthTexture.type === FloatType) {\n\t\t\t\t\t\t\tglInternalFormat = 36012;\n\t\t\t\t\t\t} else if (depthTexture.type === UnsignedIntType) {\n\t\t\t\t\t\t\tglInternalFormat = 33190;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tvar samples = getRenderTargetSamples(renderTarget);\n\n\t\t\t\t\t_gl.renderbufferStorageMultisample(36161, samples, glInternalFormat, renderTarget.width, renderTarget.height);\n\t\t\t\t} else {\n\t\t\t\t\t_gl.renderbufferStorage(36161, glInternalFormat, renderTarget.width, renderTarget.height);\n\t\t\t\t}\n\n\t\t\t\t_gl.framebufferRenderbuffer(36160, 36096, 36161, renderbuffer);\n\t\t\t} else if (renderTarget.depthBuffer && renderTarget.stencilBuffer) {\n\t\t\t\tif (isMultisample) {\n\t\t\t\t\tvar _samples = getRenderTargetSamples(renderTarget);\n\n\t\t\t\t\t_gl.renderbufferStorageMultisample(36161, _samples, 35056, renderTarget.width, renderTarget.height);\n\t\t\t\t} else {\n\t\t\t\t\t_gl.renderbufferStorage(36161, 34041, renderTarget.width, renderTarget.height);\n\t\t\t\t}\n\n\t\t\t\t_gl.framebufferRenderbuffer(36160, 33306, 36161, renderbuffer);\n\t\t\t} else {\n\t\t\t\tvar glFormat = utils.convert(renderTarget.texture.format);\n\t\t\t\tvar glType = utils.convert(renderTarget.texture.type);\n\n\t\t\t\tvar _glInternalFormat = getInternalFormat(renderTarget.texture.internalFormat, glFormat, glType);\n\n\t\t\t\tif (isMultisample) {\n\t\t\t\t\tvar _samples2 = getRenderTargetSamples(renderTarget);\n\n\t\t\t\t\t_gl.renderbufferStorageMultisample(36161, _samples2, _glInternalFormat, renderTarget.width, renderTarget.height);\n\t\t\t\t} else {\n\t\t\t\t\t_gl.renderbufferStorage(36161, _glInternalFormat, renderTarget.width, renderTarget.height);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t_gl.bindRenderbuffer(36161, null);\n\t\t} // Setup resources for a Depth Texture for a FBO (needs an extension)\n\n\n\t\tfunction setupDepthTexture(framebuffer, renderTarget) {\n\t\t\tvar isCube = renderTarget && renderTarget.isWebGLCubeRen
1derTarget;\n\t\t\tif (isCube) throw new Error('Depth Texture with cube render targets is not supported');\n\n\t\t\t_gl.bindFramebuffer(36160, framebuffer);\n\n\t\t\tif (!(renderTarget.depthTexture && renderTarget.depthTexture.isDepthTexture)) {\n\t\t\t\tthrow new Error('renderTarget.depthTexture must be an instance of THREE.DepthTexture');\n\t\t\t} // upload an empty depth texture with framebuffer size\n\n\n\t\t\tif (!properties.get(renderTarget.depthTexture).__webglTexture || renderTarget.depthTexture.image.width !== renderTarget.width || renderTarget.depthTexture.image.height !== renderTarget.height) {\n\t\t\t\trenderTarget.depthTexture.image.width = renderTarget.width;\n\t\t\t\trenderTarget.depthTexture.image.height = renderTarget.height;\n\t\t\t\trenderTarget.depthTexture.needsUpdate = true;\n\t\t\t}\n\n\t\t\tsetTexture2D(renderTarget.depthTexture, 0);\n\n\t\t\tvar webglDepthTexture = properties.get(renderTarget.depthTexture).__webglTexture;\n\n\t\t\tif (renderTarget.depthTexture.format === DepthFormat) {\n\t\t\t\t_gl.framebufferTexture2D(36160, 36096, 3553, webglDepthTexture, 0);\n\t\t\t} else if (renderTarget.depthTexture.format === DepthStencilFormat) {\n\t\t\t\t_gl.framebufferTexture2D(36160, 33306, 3553, webglDepthTexture, 0);\n\t\t\t} else {\n\t\t\t\tthrow new Error('Unknown depthTexture format');\n\t\t\t}\n\t\t} // Setup GL resources for a non-texture depth buffer\n\n\n\t\tfunction setupDepthRenderbuffer(renderTarget) {\n\t\t\tvar renderTargetProperties = properties.get(renderTarget);\n\t\t\tvar isCube = renderTarget.isWebGLCubeRenderTarget === true;\n\n\t\t\tif (renderTarget.depthTexture) {\n\t\t\t\tif (isCube) throw new Error('target.depthTexture not supported in Cube render targets');\n\t\t\t\tsetupDepthTexture(renderTargetProperties.__webglFramebuffer, renderTarget);\n\t\t\t} else {\n\t\t\t\tif (isCube) {\n\t\t\t\t\trenderTargetProperties.__webglDepthbuffer = [];\n\n\t\t\t\t\tfor (var i = 0; i < 6; i++) {\n\t\t\t\t\t\t_gl.bindFramebuffer(36160, renderTargetProperties.__webglFramebuffer[i]);\n\n\t\t\t\t\t\trenderTargetProperties.__webglDepthbuffer[i] = _gl.createRenderbuffer();\n\t\t\t\t\t\tsetupRenderBufferStorage(renderTargetProperties.__webglDepthbuffer[i], renderTarget, false);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t_gl.bindFramebuffer(36160, renderTargetProperties.__webglFramebuffer);\n\n\t\t\t\t\trenderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();\n\t\t\t\t\tsetupRenderBufferStorage(renderTargetProperties.__webglDepthbuffer, renderTarget, false);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t_gl.bindFramebuffer(36160, null);\n\t\t} // Set up GL resources for the render target\n\n\n\t\tfunction setupRenderTarget(renderTarget) {\n\t\t\tvar renderTargetProperties = properties.get(renderTarget);\n\t\t\tvar textureProperties = properties.get(renderTarget.texture);\n\t\t\trenderTarget.addEventListener('dispose', onRenderTargetDispose);\n\t\t\ttextureProperties.__webglTexture = _gl.createTexture();\n\t\t\tinfo.memory.textures++;\n\t\t\tvar isCube = renderTarget.isWebGLCubeRenderTarget === true;\n\t\t\tvar isMultisample = renderTarget.isWebGLMultisampleRenderTarget === true;\n\t\t\tvar supportsMips = isPowerOfTwo(renderTarget) || isWebGL2; // Handles WebGL2 RGBFormat fallback - #18858\n\n\t\t\tif (isWebGL2 && renderTarget.texture.format === RGBFormat && (renderTarget.texture.type === FloatType || renderTarget.texture.type === HalfFloatType)) {\n\t\t\t\trenderTarget.texture.format = RGBAFormat;\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.');\n\t\t\t} // Setup framebuffer\n\n\n\t\t\tif (isCube) {\n\t\t\t\trenderTargetProperties.__webglFramebuffer = [];\n\n\t\t\t\tfor (var i = 0; i < 6; i++) {\n\t\t\t\t\trenderTargetProperties.__webglFramebuffer[i] = _gl.createFramebuffer();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trenderTargetProperties.__webglFramebuffer = _gl.createFramebuffer();\n\n\t\t\t\tif (isMultisample) {\n\t\t\t\t\tif (isWebGL2) {\n\t\t\t\t\t\trenderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();
1\n\t\t\t\t\t\trenderTargetProperties.__webglColorRenderbuffer = _gl.createRenderbuffer();\n\n\t\t\t\t\t\t_gl.bindRenderbuffer(36161, renderTargetProperties.__webglColorRenderbuffer);\n\n\t\t\t\t\t\tvar glFormat = utils.convert(renderTarget.texture.format);\n\t\t\t\t\t\tvar glType = utils.convert(renderTarget.texture.type);\n\t\t\t\t\t\tvar glInternalFormat = getInternalFormat(renderTarget.texture.internalFormat, glFormat, glType);\n\t\t\t\t\t\tvar samples = getRenderTargetSamples(renderTarget);\n\n\t\t\t\t\t\t_gl.renderbufferStorageMultisample(36161, samples, glInternalFormat, renderTarget.width, renderTarget.height);\n\n\t\t\t\t\t\t_gl.bindFramebuffer(36160, renderTargetProperties.__webglMultisampledFramebuffer);\n\n\t\t\t\t\t\t_gl.framebufferRenderbuffer(36160, 36064, 36161, renderTargetProperties.__webglColorRenderbuffer);\n\n\t\t\t\t\t\t_gl.bindRenderbuffer(36161, null);\n\n\t\t\t\t\t\tif (renderTarget.depthBuffer) {\n\t\t\t\t\t\t\trenderTargetProperties.__webglDepthRenderbuffer = _gl.createRenderbuffer();\n\t\t\t\t\t\t\tsetupRenderBufferStorage(renderTargetProperties.__webglDepthRenderbuffer, renderTarget, true);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t_gl.bindFramebuffer(36160, null);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} // Setup color buffer\n\n\n\t\t\tif (isCube) {\n\t\t\t\tstate.bindTexture(34067, textureProperties.__webglTexture);\n\t\t\t\tsetTextureParameters(34067, renderTarget.texture, supportsMips);\n\n\t\t\t\tfor (var _i5 = 0; _i5 < 6; _i5++) {\n\t\t\t\t\tsetupFrameBufferTexture(renderTargetProperties.__webglFramebuffer[_i5], renderTarget, 36064, 34069 + _i5);\n\t\t\t\t}\n\n\t\t\t\tif (textureNeedsGenerateMipmaps(renderTarget.texture, supportsMips)) {\n\t\t\t\t\tgenerateMipmap(34067, renderTarget.texture, renderTarget.width, renderTarget.height);\n\t\t\t\t}\n\n\t\t\t\tstate.bindTexture(34067, null);\n\t\t\t} else {\n\t\t\t\tstate.bindTexture(3553, textureProperties.__webglTexture);\n\t\t\t\tsetTextureParameters(3553, renderTarget.texture, supportsMips);\n\t\t\t\tsetupFrameBufferTexture(renderTargetProperties.__webglFramebuffer, renderTarget, 36064, 3553);\n\n\t\t\t\tif (textureNeedsGenerateMipmaps(renderTarget.texture, supportsMips)) {\n\t\t\t\t\tgenerateMipmap(3553, renderTarget.texture, renderTarget.width, renderTarget.height);\n\t\t\t\t}\n\n\t\t\t\tstate.bindTexture(3553, null);\n\t\t\t} // Setup depth and stencil buffers\n\n\n\t\t\tif (renderTarget.depthBuffer) {\n\t\t\t\tsetupDepthRenderbuffer(renderTarget);\n\t\t\t}\n\t\t}\n\n\t\tfunction updateRenderTargetMipmap(renderTarget) {\n\t\t\tvar texture = renderTarget.texture;\n\t\t\tvar supportsMips = isPowerOfTwo(renderTarget) || isWebGL2;\n\n\t\t\tif (textureNeedsGenerateMipmaps(texture, supportsMips)) {\n\t\t\t\tvar target = renderTarget.isWebGLCubeRenderTarget ? 34067 : 3553;\n\n\t\t\t\tvar webglTexture = properties.get(texture).__webglTexture;\n\n\t\t\t\tstate.bindTexture(target, webglTexture);\n\t\t\t\tgenerateMipmap(target, texture, renderTarget.width, renderTarget.height);\n\t\t\t\tstate.bindTexture(target, null);\n\t\t\t}\n\t\t}\n\n\t\tfunction updateMultisampleRenderTarget(renderTarget) {\n\t\t\tif (renderTarget.isWebGLMultisampleRenderTarget) {\n\t\t\t\tif (isWebGL2) {\n\t\t\t\t\tvar renderTargetProperties = properties.get(renderTarget);\n\n\t\t\t\t\t_gl.bindFramebuffer(36008, renderTargetProperties.__webglMultisampledFramebuffer);\n\n\t\t\t\t\t_gl.bindFramebuffer(36009, renderTargetProperties.__webglFramebuffer);\n\n\t\t\t\t\tvar width = renderTarget.width;\n\t\t\t\t\tvar height = renderTarget.height;\n\t\t\t\t\tvar mask = 16384;\n\t\t\t\t\tif (renderTarget.depthBuffer) mask |= 256;\n\t\t\t\t\tif (renderTarget.stencilBuffer) mask |= 1024;\n\n\t\t\t\t\t_gl.blitFramebuffer(0, 0, width, height, 0, 0, width, height, mask, 9728);\n\n\t\t\t\t\t_gl.bindFramebuffer(36160, renderTargetProperties.__webglMultisampledFramebuffer); // see #18905\n\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn('THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction getRenderTargetSamples(renderTarget) {\n\t\t\treturn isWebGL2 && renderTarget.isWebGLMultisampleRenderTarget ? Math.min(maxSamples, renderTarget.samples) : 0;\n\t\t}\n\n\t\tfunction updateVideoTexture(texture) {\n\t\t\tvar frame = info.render.frame; // Check the last frame we updated the VideoTexture\n\n\t\t\tif (_videoTextures.get(texture) !== frame) {\n\t\t\t\t_videoTextures.set(texture, frame);
1\n\n\t\t\t\ttexture.update();\n\t\t\t}\n\t\t} // backwards compatibility\n\n\n\t\tvar warnedTexture2D = false;\n\t\tvar warnedTextureCube = false;\n\n\t\tfunction safeSetTexture2D(texture, slot) {\n\t\t\tif (texture && texture.isWebGLRenderTarget) {\n\t\t\t\tif (warnedTexture2D === false) {\n\t\t\t\t\tconsole.warn('THREE.WebGLTextures.safeSetTexture2D: don\\'t use render targets as textures. Use their .texture property instead.');\n\t\t\t\t\twarnedTexture2D = true;\n\t\t\t\t}\n\n\t\t\t\ttexture = texture.texture;\n\t\t\t}\n\n\t\t\tsetTexture2D(texture, slot);\n\t\t}\n\n\t\tfunction safeSetTextureCube(texture, slot) {\n\t\t\tif (texture && texture.isWebGLCubeRenderTarget) {\n\t\t\t\tif (warnedTextureCube === false) {\n\t\t\t\t\tconsole.warn('THREE.WebGLTextures.safeSetTextureCube: don\\'t use cube render targets as textures. Use their .texture property instead.');\n\t\t\t\t\twarnedTextureCube = true;\n\t\t\t\t}\n\n\t\t\t\ttexture = texture.texture;\n\t\t\t}\n\n\t\t\tsetTextureCube(texture, slot);\n\t\t} //\n\n\n\t\tthis.allocateTextureUnit = allocateTextureUnit;\n\t\tthis.resetTextureUnits = resetTextureUnits;\n\t\tthis.setTexture2D = setTexture2D;\n\t\tthis.setTexture2DArray = setTexture2DArray;\n\t\tthis.setTexture3D = setTexture3D;\n\t\tthis.setTextureCube = setTextureCube;\n\t\tthis.setupRenderTarget = setupRenderTarget;\n\t\tthis.updateRenderTargetMipmap = updateRenderTargetMipmap;\n\t\tthis.updateMultisampleRenderTarget = updateMultisampleRenderTarget;\n\t\tthis.safeSetTexture2D = safeSetTexture2D;\n\t\tthis.safeSetTextureCube = safeSetTextureCube;\n\t}\n\n\tfunction WebGLUtils(gl, extensions, capabilities) {\n\t\tvar isWebGL2 = capabilities.isWebGL2;\n\n\t\tfunction convert(p) {\n\t\t\tvar extension;\n\t\t\tif (p === UnsignedByteType) return 5121;\n\t\t\tif (p === UnsignedShort4444Type) return 32819;\n\t\t\tif (p === UnsignedShort5551Type) return 32820;\n\t\t\tif (p === UnsignedShort565Type) return 33635;\n\t\t\tif (p === ByteType) return 5120;\n\t\t\tif (p === ShortType) return 5122;\n\t\t\tif (p === UnsignedShortType) return 5123;\n\t\t\tif (p === IntType) return 5124;\n\t\t\tif (p === UnsignedIntType) return 5125;\n\t\t\tif (p === FloatType) return 5126;\n\n\t\t\tif (p === HalfFloatType) {\n\t\t\t\tif (isWebGL2) return 5131;\n\t\t\t\textension = extensions.get('OES_texture_half_float');\n\n\t\t\t\tif (extension !== null) {\n\t\t\t\t\treturn extension.HALF_FLOAT_OES;\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (p === AlphaFormat) return 6406;\n\t\t\tif (p === RGBFormat) return 6407;\n\t\t\tif (p === RGBAFormat) return 6408;\n\t\t\tif (p === LuminanceFormat) return 6409;\n\t\t\tif (p === LuminanceAlphaFormat) return 6410;\n\t\t\tif (p === DepthFormat) return 6402;\n\t\t\tif (p === DepthStencilFormat) return 34041;\n\t\t\tif (p === RedFormat) return 6403; // WebGL2 formats.\n\n\t\t\tif (p === RedIntegerFormat) return 36244;\n\t\t\tif (p === RGFormat) return 33319;\n\t\t\tif (p === RGIntegerFormat) return 33320;\n\t\t\tif (p === RGBIntegerFormat) return 36248;\n\t\t\tif (p === RGBAIntegerFormat) return 36249;\n\n\t\t\tif (p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format || p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format) {\n\t\t\t\textension = extensions.get('WEBGL_compressed_texture_s3tc');\n\n\t\t\t\tif (extension !== null) {\n\t\t\t\t\tif (p === RGB_S3TC_DXT1_Format) return extension.COMPRESSED_RGB_S3TC_DXT1_EXT;\n\t\t\t\t\tif (p === RGBA_S3TC_DXT1_Format) return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT;\n\t\t\t\t\tif (p === RGBA_S3TC_DXT3_Format) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT;\n\t\t\t\t\tif (p === RGBA_S3TC_DXT5_Format) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (p === RGB_PVRTC_4BPPV1_Format || p === RGB_PVRTC_2BPPV1_Format || p === RGBA_PVRTC_4BPPV1_Format || p === RGBA_PVRTC_2BPPV1_Format) {\n\t\t\t\textension = extensions.get('WEBGL_compressed_texture_pvrtc');\n\n\t\t\t\tif (extension !== null) {\n\t\t\t\t\tif (p === RGB_PVRTC_4BPPV1_Format) return extension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;\n\t\t\t\t\tif (p === RGB_PVRTC_2BPPV1_Format) return extension.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;\n\t\t\t\t\tif (p === RGBA_PVRTC_4BPPV1_Format) return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;\n\t\t\t\t\tif (p === RGBA_PVRTC_2BPPV1_Format) return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (p === RGB_ETC1_Format) {\n\t\t\t\textension = extensions.get('WEBGL_compressed_texture_etc1');\n\n\t\t\t\tif (extension !== null) {\n\t\t\t\t\treturn extension.COMPRESSED_RGB_ETC1_WEBGL;\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format) {\n\t\t\t\textension = extensions.get('WEBGL_compressed_texture_etc');\n\n\t\t\t\tif (extension !== null) {\n\t\t\t\t\tif (p === RGB_ETC2_Format) return extension.COMPRESSED_RGB8_ETC2;\n\t\t\t\t\tif (p === RGBA_ETC2_EAC_Format) return extension.COMPRESSED_RGBA8_ETC2_EAC;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (p === RGBA_ASTC_4x4_Format || p === RGBA_ASTC_5x4_Format || p === RGBA_ASTC_5x5_Format || p === RGBA_ASTC_6x5_Format || p === RGBA_ASTC_6x6_Format || p === RGBA_ASTC_8x5_Format || p === RGBA_ASTC_8x6_Format || p === RGBA_ASTC_8x8_Format || p === RGBA_ASTC_10x5_Format || p === RGBA_ASTC_10x6_Format || p === RGBA_ASTC_10x8_Format || p === RGBA_ASTC_10x10_Format || p === RGBA_ASTC_12x10_Format || p === RGBA_ASTC_12x12_Format || p === SRGB8_ALPHA8_ASTC_4x4_Format || p === SRGB8_ALPHA8_ASTC_5x4_Format || p === SRGB8_ALPHA8_ASTC_5x5_Format || p === SRGB8_ALPHA8_ASTC_6x5_Format || p === SRGB8_ALPHA8_ASTC_6x6_Format || p === SRGB8_ALPHA8_ASTC_8x5_Format || p === SRGB8_ALPHA8_ASTC_8x6_Format || p === SRGB8_ALPHA8_ASTC_8x8_Format || p === SRGB8_ALPHA8_ASTC_10x5_Format || p === SRGB8_ALPHA8_ASTC_10x6_Format || p === SRGB8_ALPHA8_ASTC_10x8_Format || p === SRGB8_ALPHA8_ASTC_10x10_Format || p === SRGB8_ALPHA8_ASTC_12x10_Format || p === SRGB8_ALPHA8_ASTC_12x12_Format) {\n\t\t\t\textension = extensions.get('WEBGL_compressed_texture_astc');\n\n\t\t\t\tif (extension !== null) {\n\t\t\t\t\t// TODO Complete?\n\t\t\t\t\treturn p;\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (p === RGBA_BPTC_Format) {\n\t\t\t\textension = extensions.get('EXT_texture_compression_bptc');\n\n\t\t\t\tif (extension !== null) {\n\t\t\t\t\t// TODO Complete?\n\t\t\t\t\treturn p;\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (p === UnsignedInt248Type) {\n\t\t\t\tif (isWebGL2) return 34042;\n\t\t\t\textension = extensions.get('WEBGL_depth_texture');\n\n\t\t\t\tif (extension !== null) {\n\t\t\t\t\treturn extension.UNSIGNED_INT_24_8_WEBGL;\n\t\t\t\t} else {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tconvert: convert\n\t\t};\n\t}\n\n\tfunction ArrayCamera(array) {\n\t\tif (array === void 0) {\n\t\t\tarray = [];\n\t\t}\n\n\t\tPerspectiveCamera.call(this);\n\t\tthis.cameras = array;\n\t}\n\n\tArrayCamera.prototype = Object.assign(Object.create(PerspectiveCamera.prototype), {\n\t\tconstructor: ArrayCamera,\n\t\tisArrayCamera: true\n\t});
1\n\n\tfunction Group() {\n\t\tObject3D.call(this);\n\t\tthis.type = 'Group';\n\t}\n\n\tGroup.prototype = Object.assign(Object.create(Object3D.prototype), {\n\t\tconstructor: Group,\n\t\tisGroup: true\n\t});\n\n\tfunction WebXRController() {\n\t\tthis._targetRay = null;\n\t\tthis._grip = null;\n\t\tthis._hand = null;\n\t}\n\n\tObject.assign(WebXRController.prototype, {\n\t\tconstructor: WebXRController,\n\t\tgetHandSpace: function getHandSpace() {\n\t\t\tif (this._hand === null) {\n\t\t\t\tthis._hand = new Group();\n\t\t\t\tthis._hand.matrixAutoUpdate = false;\n\t\t\t\tthis._hand.visible = false;\n\t\t\t\tthis._hand.joints = [];\n\t\t\t\tthis._hand.inputState = {\n\t\t\t\t\tpinching: false\n\t\t\t\t};\n\n\t\t\t\tif (window.XRHand) {\n\t\t\t\t\tfor (var i = 0; i <= window.XRHand.LITTLE_PHALANX_TIP; i++) {\n\t\t\t\t\t\t// The transform of this joint will be updated with the joint pose on each frame\n\t\t\t\t\t\tvar joint = new Group();\n\t\t\t\t\t\tjoint.matrixAutoUpdate = false;\n\t\t\t\t\t\tjoint.visible = false;\n\n\t\t\t\t\t\tthis._hand.joints.push(joint); // ??\n\n\n\t\t\t\t\t\tthis._hand.add(joint);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this._hand;\n\t\t},\n\t\tgetTargetRaySpace: function getTargetRaySpace() {\n\t\t\tif (this._targetRay === null) {\n\t\t\t\tthis._targetRay = new Group();\n\t\t\t\tthis._targetRay.matrixAutoUpdate = false;\n\t\t\t\tthis._targetRay.visible = false;\n\t\t\t}\n\n\t\t\treturn this._targetRay;\n\t\t},\n\t\tgetGripSpace: function getGripSpace() {\n\t\t\tif (this._grip === null) {\n\t\t\t\tthis._grip = new Group();\n\t\t\t\tthis._grip.matrixAutoUpdate = false;\n\t\t\t\tthis._grip.visible = false;\n\t\t\t}\n\n\t\t\treturn this._grip;\n\t\t},\n\t\tdispatchEvent: function dispatchEvent(event) {\n\t\t\tif (this._targetRay !== null) {\n\t\t\t\tthis._targetRay.dispatchEvent(event);\n\t\t\t}\n\n\t\t\tif (this._grip !== null) {\n\t\t\t\tthis._grip.dispatchEvent(event);\n\t\t\t}\n\n\t\t\tif (this._hand !== null) {\n\t\t\t\tthis._hand.dispatchEvent(event);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tdisconnect: function disconnect(inputSource) {\n\t\t\tthis.dispatchEvent({\n\t\t\t\ttype: 'disconnected',\n\t\t\t\tdata: inputSource\n\t\t\t});\n\n\t\t\tif (this._targetRay !== null) {\n\t\t\t\tthis._targetRay.visible = false;\n\t\t\t}\n\n\t\t\tif (this._grip !== null) {\n\t\t\t\tthis._grip.visible = false;\n\t\t\t}\n\n\t\t\tif (this._hand !== null) {\n\t\t\t\tthis._hand.visible = false;\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tupdate: function update(inputSource, frame, referenceSpace) {\n\t\t\tvar inputPose = null;\n\t\t\tvar gripPose = null;\n\t\t\tvar handPose = null;\n\t\t\tvar targetRay = this._targetRay;\n\t\t\tvar grip = this._grip;\n\t\t\tvar hand = this._hand;\n\n\t\t\tif (inputSource && frame.session.visibilityState !== 'visible-blurred') {\n\t\t\t\tif (hand && inputSource.hand) {\n\t\t\t\t\thandPose = true;\n\n\t\t\t\t\tfor (var i = 0; i <= window.XRHand.LITTLE_PHALANX_TIP; i++) {\n\t\t\t\t\t\tif (inputSource.hand[i]) {\n\t\t\t\t\t\t\t// Update the joints groups with the XRJoint poses\n\t\t\t\t\t\t\tvar jointPose = frame.getJointPose(inputSource.hand[i], referenceSpace);\n\t\t\t\t\t\t\tvar joint = hand.joints[i];\n\n\t\t\t\t\t\t\tif (jointPose !== null) {\n\t\t\t\t\t\t\t\tjoint.matrix.fromArray(jointPose.transform.matrix);\n\t\t\t\t\t\t\t\tjoint.matrix.decompose(joint.position, joint.rotation, joint.scale);\n\t\t\t\t\t\t\t\tjoint.jointRadius = jointPose.radius;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tjoint.visible = jointPose !== null; // Custom events\n\t\t\t\t\t\t\t// Check pinch\n\n\t\t\t\t\t\t\tvar indexTip = hand.joints[window.XRHand.INDEX_PHALANX_TIP];\n\t\t\t\t\t\t\tvar thumbTip = hand.joints[window.XRHand.THUMB_PHALANX_TIP];\n\t\t\t\t\t\t\tvar distance = indexTip.position.distanceTo(thumbTip.position);\n\t\t\t\t\t\t\tvar distanceToPinch = 0.02;\n\t\t\t\t\t\t\tvar threshold = 0.005;\n\n\t\t\t\t\t\t\tif (hand.inputState.pinching && distance > distanceToPinch + threshold) {\n\t\t\t\t\t\t\t\thand.inputState.pinching = false;\n\t\t\t\t\t\t\t\tthis.dispatchEvent({\n\t\t\t\t\t\t\t\t\ttype: 'pinchend',\n\t\t\t\t\t\t\t\t\thandedness: inputSource.handedness,\n\t\t\t\t\t\t\t\t\ttarget: this\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t} else if (!hand.inputState.pinching && distance <= distanceToPinch - threshold) {\n\t\t\t\t\t\t\t\thand.inputState.pinching = true;\n\t\t\t\t\t\t\t\tthis.dispatchEvent({\n\t\t\t\t\t\t\t\t\ttype: 'pinchstart',\n\t\t\t\t\t\t\t\t\thandedness: inputSource.handedness,\n\t\t\t\t\t\t\t\t\ttarget: this\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (targetRay !== null) {\n\t\t\t\t\t\tinputPose = frame.getPose(inputSource.targetRaySpace, referenceSpace);\n\n\t\t\t\t\t\tif (inputPose !== null) {\n\t\t\t\t\t\t\ttargetRay.matrix.fromArray(inputPose.transform.matrix);\n\t\t\t\t\t\t\ttargetRay.matrix.decompose(targetRay.position, targetRay.rotation, targetRay.scale);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (grip !== null && inputSource.gripSpace) {\n\t\t\t\t\t\tgripPose = frame.getPose(inputSource.gripSpace, referenceSpace);\n\n\t\t\t\t\t\tif (gripPose !== null) {\n\t\t\t\t\t\t\tgrip.matrix.fromArray(gripPose.transform.matrix);\n\t\t\t\t\t\t\tgrip.matrix.decompose(grip.position, grip.rotation, grip.scale);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (targetRay !== null) {\n\t\t\t\ttargetRay.visible = inputPose !== null;\n\t\t\t}\n\n\t\t\tif (grip !== null) {\n\t\t\t\tgrip.visible = gripPose !== null;\n\t\t\t}\n\n\t\t\tif (hand !== null) {\n\t\t\t\thand.visible = handPose !== null;\n\t\t\t}\n\n\t\t\treturn this;\n\t\t}\n\t});\n\n\tfunction WebXRManager(renderer, gl) {\n\t\tvar scope = this;\n\t\tvar session = null;\n\t\tvar framebufferScaleFactor = 1.0;\n\t\tvar referenceSpace = null;\n\t\tvar referenceSpaceType = 'local-floor';\n\t\tvar pose = null;\n\t\tvar controllers = [];\n\t\tvar inputSourcesMap = new Map(); //\n\n\t\tvar cameraL = new PerspectiveCamera();\n\t\tcameraL.layers.enable(1);\n\t\tcameraL.viewport = new Vector4();\n\t\tvar cameraR = new PerspectiveCamera();\n\t\tcameraR.layers.enable(2);\n\t\tcameraR.viewport = new Vector4();\n\t\tvar cameras = [cameraL, cameraR];\n\t\tvar cameraVR = new ArrayCamera();\n\t\tcameraVR.layers.enable(1);\n\t\tcameraVR.layers.enable(2);\n\t\tvar _currentDepthNear = null;\n\t\tvar _currentDepthFar = null; //\n\n\t\tthis.enabled = false;\n\t\tthis.isPresenting = false;\n\n\t\tthis.getController = function (index) {\n\t\t\tvar controller = controllers[index];\n\n\t\t\tif (controller === undefined) {\n\t\t\t\tcontroller = new WebXRController();\n\t\t\t\tcontrollers[index] = controller;\n\t\t\t}\n\n\t\t\treturn controller.getTargetRaySpace();\n\t\t};\n\n\t\tthis.getControllerGrip = function (index) {\n\t\t\tvar controller = controllers[index];\n\n\t\t\tif (controller === undefined) {\n\t\t\t\tcontroller = new WebXRController();\n\t\t\t\tcontrollers[index] = controller;\n\t\t\t}\n\n\t\t\treturn controller.getGripSpace();\n\t\t};\n\n\t\tthis.getHand = function (index) {\n\t\t\tvar controller = controllers[index];\n\n\t\t\tif (controller === undefined) {\n\t\t\t\tcontroller = new WebXRController();\n\t\t\t\tcontrollers[index] = controller;\n\t\t\t}\n\n\t\t\treturn controller.getHandSpace();\n\t\t}; //\n\n\n\t\tfunction onSessionEvent(event) {\n\t\t\tvar controller = inputSourcesMap.get(event.inputSource);\n\n\t\t\tif (controller) {\n\t\t\t\tcontroller.dispatchEvent({\n\t\t\t\t\ttype: event.type,\n\t\t\t\t\tdata: event.inputSource\n\t\t\t\t});\n\t\t\t}\n\t\t}
1\n\n\t\tfunction onSessionEnd() {\n\t\t\tinputSourcesMap.forEach(function (controller, inputSource) {\n\t\t\t\tcontroller.disconnect(inputSource);\n\t\t\t});\n\t\t\tinputSourcesMap.clear(); //\n\n\t\t\trenderer.setFramebuffer(null);\n\t\t\trenderer.setRenderTarget(renderer.getRenderTarget()); // Hack #15830\n\n\t\t\tanimation.stop();\n\t\t\tscope.isPresenting = false;\n\t\t\tscope.dispatchEvent({\n\t\t\t\ttype: 'sessionend'\n\t\t\t});\n\t\t}\n\n\t\tfunction onRequestReferenceSpace(value) {\n\t\t\treferenceSpace = value;\n\t\t\tanimation.setContext(session);\n\t\t\tanimation.start();\n\t\t\tscope.isPresenting = true;\n\t\t\tscope.dispatchEvent({\n\t\t\t\ttype: 'sessionstart'\n\t\t\t});\n\t\t}\n\n\t\tthis.setFramebufferScaleFactor = function (value) {\n\t\t\tframebufferScaleFactor = value;\n\n\t\t\tif (scope.isPresenting === true) {\n\t\t\t\tconsole.warn('THREE.WebXRManager: Cannot change framebuffer scale while presenting.');\n\t\t\t}\n\t\t};\n\n\t\tthis.setReferenceSpaceType = function (value) {\n\t\t\treferenceSpaceType = value;\n\n\t\t\tif (scope.isPresenting === true) {\n\t\t\t\tconsole.warn('THREE.WebXRManager: Cannot change reference space type while presenting.');\n\t\t\t}\n\t\t};\n\n\t\tthis.getReferenceSpace = function () {\n\t\t\treturn referenceSpace;\n\t\t};\n\n\t\tthis.getSession = function () {\n\t\t\treturn session;\n\t\t};\n\n\t\tthis.setSession = function (value) {\n\t\t\tsession = value;\n\n\t\t\tif (session !== null) {\n\t\t\t\tsession.addEventListener('select', onSessionEvent);\n\t\t\t\tsession.addEventListener('selectstart', onSessionEvent);\n\t\t\t\tsession.addEventListener('selectend', onSessionEvent);\n\t\t\t\tsession.addEventListener('squeeze', onSessionEvent);\n\t\t\t\tsession.addEventListener('squeezestart', onSessionEvent);\n\t\t\t\tsession.addEventListener('squeezeend', onSessionEvent);\n\t\t\t\tsession.addEventListener('end', onSessionEnd);\n\t\t\t\tvar attributes = gl.getContextAttributes();\n\n\t\t\t\tif (attributes.xrCompatible !== true) {\n\t\t\t\t\tgl.makeXRCompatible();\n\t\t\t\t}\n\n\t\t\t\tvar layerInit = {\n\t\t\t\t\tantialias: attributes.antialias,\n\t\t\t\t\talpha: attributes.alpha,\n\t\t\t\t\tdepth: attributes.depth,\n\t\t\t\t\tstencil: attributes.stencil,\n\t\t\t\t\tframebufferScaleFactor: framebufferScaleFactor\n\t\t\t\t}; // eslint-disable-next-line no-undef\n\n\t\t\t\tvar baseLayer = new XRWebGLLayer(session, gl, layerInit);\n\t\t\t\tsession.updateRenderState({\n\t\t\t\t\tbaseLayer: baseLayer\n\t\t\t\t});\n\t\t\t\tsession.requestReferenceSpace(referenceSpaceType).then(onRequestReferenceSpace); //\n\n\t\t\t\tsession.addEventListener('inputsourceschange', updateInputSources);\n\t\t\t}\n\t\t};\n\n\t\tfunction updateInputSources(event) {\n\t\t\tvar inputSources = session.inputSources; // Assign inputSources to available controllers\n\n\t\t\tfor (var i = 0; i < controllers.length; i++) {\n\t\t\t\tinputSourcesMap.set(inputSources[i], controllers[i]);\n\t\t\t} // Notify disconnected\n\n\n\t\t\tfor (var _i = 0; _i < event.removed.length;
1 _i++) {\n\t\t\t\tvar inputSource = event.removed[_i];\n\t\t\t\tvar controller = inputSourcesMap.get(inputSource);\n\n\t\t\t\tif (controller) {\n\t\t\t\t\tcontroller.dispatchEvent({\n\t\t\t\t\t\ttype: 'disconnected',\n\t\t\t\t\t\tdata: inputSource\n\t\t\t\t\t});\n\t\t\t\t\tinputSourcesMap.delete(inputSource);\n\t\t\t\t}\n\t\t\t} // Notify connected\n\n\n\t\t\tfor (var _i2 = 0; _i2 < event.added.length; _i2++) {\n\t\t\t\tvar _inputSource = event.added[_i2];\n\n\t\t\t\tvar _controller = inputSourcesMap.get(_inputSource);\n\n\t\t\t\tif (_controller) {\n\t\t\t\t\t_controller.dispatchEvent({\n\t\t\t\t\t\ttype: 'connected',\n\t\t\t\t\t\tdata: _inputSource\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} //\n\n\n\t\tvar cameraLPos = new Vector3();\n\t\tvar cameraRPos = new Vector3();\n\t\t/**\n\t\t * Assumes 2 cameras that are parallel and share an X-axis, and that\n\t\t * the cameras' projection and world matrices have already been set.\n\t\t * And that near and far planes are identical for both cameras.\n\t\t * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765\n\t\t */\n\n\t\tfunction setProjectionFromUnion(camera, cameraL, cameraR) {\n\t\t\tcameraLPos.setFromMatrixPosition(cameraL.matrixWorld);\n\t\t\tcameraRPos.setFromMatrixPosition(cameraR.matrixWorld);\n\t\t\tvar ipd = cameraLPos.distanceTo(cameraRPos);\n\t\t\tvar projL = cameraL.projectionMatrix.elements;\n\t\t\tvar projR = cameraR.projectionMatrix.elements; // VR systems will have identical far and near planes, and\n\t\t\t// most likely identical top and bottom frustum extents.\n\t\t\t// Use the left camera for these values.\n\n\t\t\tvar near = projL[14] / (projL[10] - 1);\n\t\t\tvar far = projL[14] / (projL[10] + 1);\n\t\t\tvar topFov = (projL[9] + 1) / projL[5];\n\t\t\tvar bottomFov = (projL[9] - 1) / projL[5];\n\t\t\tvar leftFov = (projL[8] - 1) / projL[0];\n\t\t\tvar rightFov = (projR[8] + 1) / projR[0];\n\t\t\tvar left = near * leftFov;\n\t\t\tvar right = near * rightFov; // Calculate the new camera's position offset from the\n\t\t\t// left camera. xOffset should be roughly half `ipd`.\n\n\t\t\tvar zOffset = ipd / (-leftFov + rightFov);\n\t\t\tvar xOffset = zOffset * -leftFov; // TODO: Better way to apply this offset?\n\n\t\t\tcameraL.matrixWorld.decompose(camera.position, camera.quaternion, camera.scale);\n\t\t\tcamera.translateX(xOffset);\n\t\t\tcamera.translateZ(zOffset);\n\t\t\tcamera.matrixWorld.compose(camera.position, camera.quaternion, camera.scale);\n\t\t\tcamera.matrixWorldInverse.copy(camera.matrixWorld).invert(); // Find the union of the frustum values of the cameras and scale\n\t\t\t// the values so that the near plane's position does not change in world space,\n\t\t\t// although must now be relative to the new union camera.\n\n\t\t\tvar near2 = near + zOffset;\n\t\t\tvar far2 = far + zOffset;\n\t\t\tvar left2 = left - xOffset;\n\t\t\tvar right2 = right + (ipd - xOffset);\n\t\t\tvar top2 = topFov * far / far2 * near2;\n\t\t\tvar bottom2 = bottomFov * far / far2 * near2;\n\t\t\tcamera.projectionMatrix.makePerspective(left2, right2, top2, bottom2, near2, far2);\n\t\t}\n\n\t\tfunction updateCamera(camera, parent) {\n\t\t\tif (parent === null) {\n\t\t\t\tcamera.matrixWorld.copy(camera.matrix);\n\t\t\t} else {\n\t\t\t\tcamera.matrixWorld.multiplyMatrices(parent.matrixWorld, camera.matrix);\n\t\t\t}\n\n\t\t\tcamera.matrixWorldInverse.copy(camera.matrixWorld).invert();\n\t\t}\n\n\t\tthis.getCamera = function (camera) {\n\t\t\tcameraVR.near = cameraR.near = cameraL.near = camera.near;\n\t\t\tcameraVR.far = cameraR.far = cameraL.far = camera.far;\n\n\t\t\tif (_currentDepthNear !== cameraVR.near || _currentDepthFar !== cameraVR.far) {\n\t\t\t\t// Note that the new renderState won't apply until the next frame. See #18320\n\t\t\t\tsession.updateRenderState({\n\t\t\t\t\tdepthNear: cameraVR.near,\n\t\t\t\t\tdepthFar: cameraVR.far\n\t\t\t\t});\n\t\t\t\t_currentDepthNear = cameraVR.near;\n\t\t\t\t_currentDepthFar = cameraVR.far;\n\t\t\t}\n\n\t\t\tvar parent = camera.parent;\n\t\t\tvar cameras = cameraVR.cameras;\n\t\t\tupdateCamera(cameraVR, parent);\n\n\t\t\tfor (var i = 0; i < cameras.length;
1 i++) {\n\t\t\t\tupdateCamera(cameras[i], parent);\n\t\t\t} // update camera and its children\n\n\n\t\t\tcamera.matrixWorld.copy(cameraVR.matrixWorld);\n\t\t\tvar children = camera.children;\n\n\t\t\tfor (var _i3 = 0, l = children.length; _i3 < l; _i3++) {\n\t\t\t\tchildren[_i3].updateMatrixWorld(true);\n\t\t\t} // update projection matrix for proper view frustum culling\n\n\n\t\t\tif (cameras.length === 2) {\n\t\t\t\tsetProjectionFromUnion(cameraVR, cameraL, cameraR);\n\t\t\t} else {\n\t\t\t\t// assume single camera setup (AR)\n\t\t\t\tcameraVR.projectionMatrix.copy(cameraL.projectionMatrix);\n\t\t\t}\n\n\t\t\treturn cameraVR;\n\t\t}; // Animation Loop\n\n\n\t\tvar onAnimationFrameCallback = null;\n\n\t\tfunction onAnimationFrame(time, frame) {\n\t\t\tpose = frame.getViewerPose(referenceSpace);\n\n\t\t\tif (pose !== null) {\n\t\t\t\tvar views = pose.views;\n\t\t\t\tvar baseLayer = session.renderState.baseLayer;\n\t\t\t\trenderer.setFramebuffer(baseLayer.framebuffer);\n\t\t\t\tvar cameraVRNeedsUpdate = false; // check if it's necessary to rebuild cameraVR's camera list\n\n\t\t\t\tif (views.length !== cameraVR.cameras.length) {\n\t\t\t\t\tcameraVR.cameras.length = 0;\n\t\t\t\t\tcameraVRNeedsUpdate = true;\n\t\t\t\t}\n\n\t\t\t\tfor (var i = 0; i < views.length; i++) {\n\t\t\t\t\tvar view = views[i];\n\t\t\t\t\tvar viewport = baseLayer.getViewport(view);\n\t\t\t\t\tvar camera = cameras[i];\n\t\t\t\t\tcamera.matrix.fromArray(view.transform.matrix);\n\t\t\t\t\tcamera.projectionMatrix.fromArray(view.projectionMatrix);\n\t\t\t\t\tcamera.viewport.set(viewport.x, viewport.y, viewport.width, viewport.height);\n\n\t\t\t\t\tif (i === 0) {\n\t\t\t\t\t\tcameraVR.matrix.copy(camera.matrix);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (cameraVRNeedsUpdate === true) {\n\t\t\t\t\t\tcameraVR.cameras.push(camera);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} //\n\n\n\t\t\tvar inputSources = session.inputSources;\n\n\t\t\tfor (var _i4 = 0; _i4 < controllers.length; _i4++) {\n\t\t\t\tvar controller = controllers[_i4];\n\t\t\t\tvar inputSource = inputSources[_i4];\n\t\t\t\tcontroller.update(inputSource, frame, referenceSpace);\n\t\t\t}\n\n\t\t\tif (onAnimationFrameCallback) onAnimationFrameCallback(time, frame);\n\t\t}\n\n\t\tvar animation = new WebGLAnimation();\n\t\tanimation.setAnimationLoop(onAnimationFrame);\n\n\t\tthis.setAnimationLoop = function (callback) {\n\t\t\tonAnimationFrameCallback = callback;\n\t\t};\n\n\t\tthis.dispose = function () {};\n\t}\n\n\tObject.assign(WebXRManager.prototype, EventDispatcher.prototype);\n\n\tfunction WebGLMaterials(properties) {\n\t\tfunction refreshFogUniforms(uniforms, fog) {\n\t\t\tuniforms.fogColor.value.copy(fog.color);\n\n\t\t\tif (fog.isFog) {\n\t\t\t\tuniforms.fogNear.value = fog.near;\n\t\t\t\tuniforms.fogFar.value = fog.far;\n\t\t\t} else if (fog.isFogExp2) {\n\t\t\t\tuniforms.fogDensity.value = fog.density;\n\t\t\t}\n\t\t}\n\n\t\tfunction refreshMaterialUniforms(uniforms, material, pixelRatio, height) {\n\t\t\tif (material.isMeshBasicMaterial) {\n\t\t\t\trefreshUniformsCommon(uniforms, material);\n\t\t\t} else if (material.isMeshLambertMaterial) {\n\t\t\t\trefreshUniformsCommon(uniforms, material);\n\t\t\t\trefreshUniformsLambert(uniforms, material);\n\t\t\t} else if (material.isMeshToonMaterial) {\n\t\t\t\trefreshUniformsCommon(uniforms, material);\n\t\t\t\trefreshUniformsToon(uniforms, material);\n\t\t\t} else if (material.isMeshPhongMaterial) {\n\t\t\t\trefreshUniformsCommon(uniforms, material);\n\t\t\t\trefreshUniformsPhong(uniforms, material);\n\t\t\t} else if (material.isMeshStandardMaterial) {\n\t\t\t\trefreshUniformsCommon(uniforms, material);\n\n\t\t\t\tif (material.isMeshPhysicalMaterial) {\n\t\t\t\t\trefreshUniformsPhysical(uniforms, material);\n\t\t\t\t} else {\n\t\t\t\t\trefreshUniformsStandard(uniforms, material);\n\t\t\t\t}\n\t\t\t} else if (material.isMeshMatcapMaterial) {\n\t\t\t\trefreshUniformsCommon(uniforms, material);\n\t\t\t\trefreshUniformsMatcap(uniforms, material);\n\t\t\t} else if (material.isMeshDepthMaterial) {\n\t\t\t\trefreshUniformsCommon(uniforms, material);\n\t\t\t\trefreshUniformsDepth(uniforms, material);\n\t\t\t} else if (material.isMeshDistanceMaterial) {\n\t\t\t\trefreshUniformsCommon(uniforms, material);\n\t\t\t\trefreshUniformsDistance(uniforms, material);\n\t\t\t} else if (material.isMeshNormalMaterial) {\n\t\t\t\trefreshUniformsCommon(uniforms, material);\n\t\t\t\trefreshUniformsNormal(uniforms, material);\n\t\t\t} else if (material.isLineBasicMaterial) {\n\t\t\t\trefreshUniformsLine(uniforms, material);\n\n\t\t\t\tif (material.isLineDashedMaterial) {\n\t\t\t\t\trefreshUniformsDash(uniforms, material);\n\t\t\t\t}\n\t\t\t} else if (material.isPointsMaterial) {\n\t\t\t\trefreshUniformsPoints(uniforms, material, pixelRatio, height);\n\t\t\t} else if (material.isSpriteMaterial) {\n\t\t\t\trefreshUniformsSprites(uniforms, material);\n\t\t\t} else if (material.isShadowMaterial) {\n\t\t\t\tuniforms.color.value.copy(material.color);\n\t\t\t\tuniforms.opacity.value = material.opacity;\n\t\t\t} else if (material.isShaderMaterial) {\n\t\t\t\tmaterial.uniformsNeedUpdate = false; // #15581\n\t\t\t}\n\t\t}\n\n\t\tfunction refreshUniformsCommon(uniforms, material) {\n\t\t\tuniforms.opacity.value = material.opacity;\n\n\t\t\tif (material.color) {\n\t\t\t\tuniforms.diffuse.value.copy(material.color);\n\t\t\t}\n\n\t\t\tif (material.emissive) {\n\t\t\t\tuniforms.emissive.value.copy(material.emissive).multiplyScalar(material.emissiveIntensity);\n\t\t\t}\n\n\t\t\tif (material.map) {\n\t\t\t\tuniforms.map.value = material.map;\n\t\t\t}\n\n\t\t\tif (material.alphaMap) {\n\t\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\t\t\t}\n\n\t\t\tif (material.specularMap) {\n\t\t\t\tuniforms.specularMap.value = material.specularMap;\n\t\t\t}\n\n\t\t\tvar envMap = properties.get(material).envMap;\n\n\t\t\tif (envMap) {\n\t\t\t\tuniforms.envMap.value = envMap;\n\t\t\t\tuniforms.flipEnvMap.value = envMap.isCubeTexture && envMap._needsFlipEnvMap ? -1 : 1;\n\t\t\t\tuniforms.reflectivity.value = material.reflectivity;\n\t\t\t\tuniforms.refractionRatio.value = material.refractionRatio;\n\n\t\t\t\tvar maxMipLevel = properties.get(envMap).__maxMipLevel;\n\n\t\t\t\tif (maxMipLevel !== undefined) {\n\t\t\t\t\tuniforms.maxMipLevel.value = maxMipLevel;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (material.lightMap) {\n\t\t\t\tuniforms.lightMap.value = material.lightMap;\n\t\t\t\tuniforms.lightMapIntensity.value = material.lightMapIntensity;\n\t\t\t}\n\n\t\t\tif (material.aoMap) {\n\t\t\t\tuniforms.aoMap.value = material.aoMap;\n\t\t\t\tuniforms.aoMapIntensity.value = material.aoMapIntensity;\n\t\t\t} // uv repeat and offset setting priorities\n\t\t\t// 1. color map\n\t\t\t// 2. specular map\n\t\t\t// 3. displacementMap map\n\t\t\t// 4. normal map\n\t\t\t// 5. bump map\n\t\t\t// 6. roughnessMap map\n\t\t\t// 7. metalnessMap map\n\t\t\t// 8. alphaMap map\n\t\t\t// 9. emissiveMap map\n\t\t\t// 10. clearcoat map\n\t\t\t// 11. clearcoat normal map\n\t\t\t// 12. clearcoat roughnessMap map\n\n\n\t\t\tvar uvScaleMap;\n\n\t\t\tif (material.map) {\n\t\t\t\tuvScaleMap = material.map;\n\t\t\t} else if (material.specularMap) {\n\t\t\t\tuvScaleMap = material.specularMap;\n\t\t\t} else if (material.displacementMap) {\n\t\t\t\tuvScaleMap = material.displacementMap;\n\t\t\t} else if (material.normalMap) {\n\t\t\t\tuvScaleMap = material.normalMap;\n\t\t\t} else if (material.bumpMap) {\n\t\t\t\tuvScaleMap = material.bumpMap;\n\t\t\t} else if (material.roughnessMap) {\n\t\t\t\tuvScaleMap = material.roughnessMap;\n\t\t\t} else if (material.metalnessMap) {\n\t\t\t\tuvScaleMap = material.metalnessMap;\n\t\t\t} else if (material.alphaMap) {\n\t\t\t\tuvScaleMap = material.alphaMap;\n\t\t\t} else if (material.emissiveMap) {\n\t\t\t\tuvScaleMap = material.emissiveMap;\n\t\t\t} else if (material.clearcoatMap) {\n\t\t\t\tuvScaleMap = material.clearcoatMap;\n\t\t\t} else if (material.clearcoatNormalMap) {\n\t\t\t\tuvScaleMap = material.clearcoatNormalMap;\n\t\t\t} else if (material.clearcoatRoughnessMap) {\n\t\t\t\tuvScaleMap = material.clearcoatRoughnessMap;\n\t\t\t}\n\n\t\t\tif (uvScaleMap !== undefined) {\n\t\t\t\t// backwards compatibility\n\t\t\t\tif (uvScaleMap.isWebGLRenderTarget) {\n\t\t\t\t\tuvScaleMap = uvScaleMap.texture;\n\t\t\t\t}\n\n\t\t\t\tif (uvScaleMap.matrixAutoUpdate === true) {\n\t\t\t\t\tuvScaleMap.updateMatrix();\n\t\t\t\t}\n\n\t\t\t\tuniforms.uvTransform.value.copy(uvScaleMap.matrix);\n\t\t\t} // uv repeat and offset setting priorities for uv2\n\t\t\t// 1. ao map\n\t\t\t// 2. light map\n\n\n\t\t\tvar uv2ScaleMap;\n\n\t\t\tif (material.aoMap) {\n\t\t\t\tuv2ScaleMap = material.aoMap;\n\t\t\t} else if (material.lightMap) {\n\t\t\t\tuv2ScaleMap = material.lightMap;\n\t\t\t}\n\n\t\t\tif (uv2ScaleMap !== undefined) {\n\t\t\t\t// backwards compatibility\n\t\t\t\tif (uv2ScaleMap.isWebGLRenderTarget) {\n\t\t\t\t\tuv2ScaleMap = uv2ScaleMap.texture;\n\t\t\t\t}\n\n\t\t\t\tif (uv2ScaleMap.matrixAutoUpdate === true) {\n\t\t\t\t\tuv2ScaleMap.updateMatrix();\n\t\t\t\t}\n\n\t\t\t\tuniforms.uv2Transform.value.copy(uv2ScaleMap.matrix);\n\t\t\t}\n\t\t}\n\n\t\tfunction refreshUniformsLine(uniforms, material) {\n\t\t\tuniforms.diffuse.value.copy(material.color);\n\t\t\tuniforms.opacity.value = material.opacity;\n\t\t}\n\n\t\tfunction refreshUniformsDash(uniforms, material) {\n\t\t\tuniforms.dashSize.value = material.dashSize;\n\t\t\tuniforms.totalSize.value = material.dashSize + material.gapSize;\n\t\t\tuniforms.scale.value = material.scale;\n\t\t}\n\n\t\tfunction refreshUniformsPoints(uniforms, material, pixelRatio, height) {\n\t\t\tuniforms.diffuse.value.copy(material.color);\n\t\t\tuniforms.opacity.value = material.opacity;\n\t\t\tuniforms.size.value = material.size * pixelRatio;\n\t\t\tuniforms.scale.value = height * 0.5;\n\n\t\t\tif (material.map) {\n\t\t\t\tuniforms.map.value = material.map;\n\t\t\t}\n\n\t\t\tif (material.alphaMap) {\n\t\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\t\t\t} // uv repeat and offset setting priorities\n\t\t\t// 1. color map\n\t\t\t// 2. alpha map\n\n\n\t\t\tvar uvScaleMap;\n\n\t\t\tif (material.map) {\n\t\t\t\tuvScaleMap = material.map;\n\t\t\t} else if (material.alphaMap) {\n\t\t\t\tuvScaleMap = material.alphaMap;\n\t\t\t}\n\n\t\t\tif (uvScaleMap !== undefined) {\n\t\t\t\tif (uvScaleMap.matrixAutoUpdate === true) {\n\t\t\t\t\tuvScaleMap.updateMatrix();\n\t\t\t\t}\n\n\t\t\t\tuniforms.uvTransform.value.copy(uvScaleMap.matrix);\n\t\t\t}\n\t\t}\n\n\t\tfunction refreshUniformsSprites(uniforms, material) {\n\t\t\tuniforms.diffuse.value.copy(material.color);\n\t\t\tuniforms.opacity.value = material.opacity;\n\t\t\tuniforms.rotation.value = material.rotation;\n\n\t\t\tif (material.map) {\n\t\t\t\tuniforms.map.value = material.map;\n\t\t\t}\n\n\t\t\tif (material.alphaMap) {\n\t\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\t\t\t} // uv repeat and offset setting priorities\n\t\t\t// 1. color map\n\t\t\t// 2. alpha map\n\n\n\t\t\tvar uvScaleMap;\n\n\t\t\tif (material.map) {\n\t\t\t\tuvScaleMap = material.map;\n\t\t\t} else if (material.alphaMap) {\n\t\t\t\tuvScaleMap = material.alphaMap;\n\t\t\t}\n\n\t\t\tif (uvScaleMap !== undefined) {\n\t\t\t\tif (uvScaleMap.matrixAutoUpdate === true) {\n\t\t\t\t\tuvScaleMap.updateMatrix();\n\t\t\t\t}\n\n\t\t\t\tuniforms.uvTransform.value.copy(uvScaleMap.matrix);\n\t\t\t}\n\t\t}\n\n\t\tfunction refreshUniformsLambert(uniforms, material) {\n\t\t\tif (material.emissiveMap) {\n\t\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\t\t\t}\n\t\t}\n\n\t\tfunction refreshUniformsPhong(uniforms, material) {\n\t\t\tuniforms.specular.value.copy(material.specular);\n\t\t\tuniforms.shininess.value = Math.max(material.shininess, 1e-4); // to prevent pow( 0.0, 0.0 )\n\n\t\t\tif (material.emissiveMap) {\n\t\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\t\t\t}\n\n\t\t\tif (material.bumpMap) {\n\t\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\t\tif (material.side === BackSide) uniforms.bumpScale.value *= -1;\n\t\t\t}\n\n\t\t\tif (material.normalMap) {\n\t\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\t\tuniforms.normalScale.value.copy(material.normalScale);\n\t\t\t\tif (material.side === BackSide) uniforms.normalScale.value.negate();\n\t\t\t}\n\n\t\t\tif (material.displacementMap) {\n\t\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\t\t\t}\n\t\t}\n\n\t\tfunction refreshUniformsToon(uniforms, material) {\n\t\t\tif (material.gradientMap) {\n\t\t\t\tuniforms.gradientMap.value = material.gradientMap;\n\t\t\t}\n\n\t\t\tif (material.emissiveMap) {\n\t\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\t\t\t}\n\n\t\t\tif (material.bumpMap) {\n\t\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\t\tif (material.side === BackSide) uniforms.bumpScale.value *= -1;\n\t\t\t}\n\n\t\t\tif (material.normalMap) {\n\t\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\t\tuniforms.normalScale.value.copy(material.normalScale);\n\t\t\t\tif (material.side === BackSide) uniforms.normalScale.value.negate();\n\t\t\t}\n\n\t\t\tif (material.displacementMap) {\n\t\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\t\t\t}\n\t\t}\n\n\t\tfunction refreshUniformsStandard(uniforms, material) {\n\t\t\tuniforms.roughness.value = material.roughness;\n\t\t\tuniforms.metalness.value = material.metalness;\n\n\t\t\tif (material.roughnessMap) {\n\t\t\t\tuniforms.roughnessMap.value = material.roughnessMap;\n\t\t\t}\n\n\t\t\tif (material.metalnessMap) {\n\t\t\t\tuniforms.metalnessMap.value = material.metalnessMap;\n\t\t\t}\n\n\t\t\tif (material.emissiveMap) {\n\t\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\t\t\t}\n\n\t\t\tif (material.bumpMap) {\n\t\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\t\tif (material.side === BackSide) uniforms.bumpScale.value *= -1;\n\t\t\t}\n\n\t\t\tif (material.normalMap) {\n\t\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\t\tuniforms.normalScale.value.copy(material.normalScale);\n\t\t\t\tif (material.side === BackSide) uniforms.normalScale.value.negate();\n\t\t\t}\n\n\t\t\tif (material.displacementMap) {\n\t\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\t\t\t}\n\n\t\t\tvar envMap = properties.get(material).envMap;\n\n\t\t\tif (envMap) {\n\t\t\t\t//uniforms.envMap.value = material.envMap; // part of uniforms common\n\t\t\t\tuniforms.envMapIntensity.value = material.envMapIntensity;\n\t\t\t}\n\t\t}\n\n\t\tfunction refreshUniformsPhysical(uniforms, material) {\n\t\t\trefreshUniformsStandard(uniforms, material);\n\t\t\tuniforms.reflectivity.value = material.reflectivity; // also part of uniforms common\n\n\t\t\tuniforms.clearcoat.value = material.clearcoat;
1\n\t\t\tuniforms.clearcoatRoughness.value = material.clearcoatRoughness;\n\t\t\tif (material.sheen) uniforms.sheen.value.copy(material.sheen);\n\n\t\t\tif (material.clearcoatMap) {\n\t\t\t\tuniforms.clearcoatMap.value = material.clearcoatMap;\n\t\t\t}\n\n\t\t\tif (material.clearcoatRoughnessMap) {\n\t\t\t\tuniforms.clearcoatRoughnessMap.value = material.clearcoatRoughnessMap;\n\t\t\t}\n\n\t\t\tif (material.clearcoatNormalMap) {\n\t\t\t\tuniforms.clearcoatNormalScale.value.copy(material.clearcoatNormalScale);\n\t\t\t\tuniforms.clearcoatNormalMap.value = material.clearcoatNormalMap;\n\n\t\t\t\tif (material.side === BackSide) {\n\t\t\t\t\tuniforms.clearcoatNormalScale.value.negate();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tuniforms.transmission.value = material.transmission;\n\n\t\t\tif (material.transmissionMap) {\n\t\t\t\tuniforms.transmissionMap.value = material.transmissionMap;\n\t\t\t}\n\t\t}\n\n\t\tfunction refreshUniformsMatcap(uniforms, material) {\n\t\t\tif (material.matcap) {\n\t\t\t\tuniforms.matcap.value = material.matcap;\n\t\t\t}\n\n\t\t\tif (material.bumpMap) {\n\t\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\t\tif (material.side === BackSide) uniforms.bumpScale.value *= -1;\n\t\t\t}\n\n\t\t\tif (material.normalMap) {\n\t\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\t\tuniforms.normalScale.value.copy(material.normalScale);\n\t\t\t\tif (material.side === BackSide) uniforms.normalScale.value.negate();\n\t\t\t}\n\n\t\t\tif (material.displacementMap) {\n\t\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\t\t\t}\n\t\t}\n\n\t\tfunction refreshUniformsDepth(uniforms, material) {\n\t\t\tif (material.displacementMap) {\n\t\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\t\t\t}\n\t\t}\n\n\t\tfunction refreshUniformsDistance(uniforms, material) {\n\t\t\tif (material.displacementMap) {\n\t\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\t\t\t}\n\n\t\t\tuniforms.referencePosition.value.copy(material.referencePosition);\n\t\t\tuniforms.nearDistance.value = material.nearDistance;\n\t\t\tuniforms.farDistance.value = material.farDistance;\n\t\t}\n\n\t\tfunction refreshUniformsNormal(uniforms, material) {\n\t\t\tif (material.bumpMap) {\n\t\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\t\tif (material.side === BackSide) uniforms.bumpScale.value *= -1;\n\t\t\t}\n\n\t\t\tif (material.normalMap) {\n\t\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\t\tuniforms.normalScale.value.copy(material.normalScale);\n\t\t\t\tif (material.side === BackSide) uniforms.normalScale.value.negate();\n\t\t\t}\n\n\t\t\tif (material.displacementMap) {\n\t\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\trefreshFogUniforms: refreshFogUniforms,\n\t\t\trefreshMaterialUniforms: refreshMaterialUniforms\n\t\t};\n\t}\n\n\tfunction createCanvasElement() {\n\t\tvar canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');\n\t\tcanvas.style.display = 'block';\n\t\treturn canvas;\n\t}\n\n\tfunction WebGLRenderer(parameters) {\n\t\tparameters = parameters || {};\n\n\t\tvar _canvas = parameters.canvas !== undefined ? parameters.canvas : createCanvasElement(),\n\t\t\t\t_context = parameters.context !== undefined ? parameters.context : null,\n\t\t\t\t_alpha = parameters.alpha !== undefined ? parameters.alpha : false,\n\t\t\t\t_depth = parameters.depth !== undefined ? parameters.depth : true,\n\t\t\t\t_stencil = parameters.stencil !== undefined ? parameters.stencil : true,\n\t\t\t\t_antialias = parameters.antialias !== undefined ? parameters.antialias : false,\n\t\t\t\t_premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true,\n\t\t\t\t_preserveDrawingBuffer = parameters.preserveDrawingBuffer !== undefined ? parameters.preserveDrawingBuffer : false,\n\t\t\t\t_powerPreference = parameters.powerPreference !== undefined ? parameters.powerPreference : 'default',\n\t\t\t\t_failIfMajorPerformanceCaveat = parameters.failIfMajorPerformanceCaveat !== undefined ? parameters.failIfMajorPerformanceCaveat : false;\n\n\t\tvar currentRenderList = null;\n\t\tvar currentRenderState = null; // render() can be called from within a callback triggered by another render.\n\t\t// We track this so that the nested render call gets its state isolated from the parent render call.\n\n\t\tvar renderStateStack = []; // public properties\n\n\t\tthis.domElement = _canvas; // Debug configuration container\n\n\t\tthis.debug = {\n\t\t\t/**\n\t\t\t * Enables error checking and reporting when shader programs are being compiled\n\t\t\t * @type {boolean}
1\n\t\t\t */\n\t\t\tcheckShaderErrors: true\n\t\t}; // clearing\n\n\t\tthis.autoClear = true;\n\t\tthis.autoClearColor = true;\n\t\tthis.autoClearDepth = true;\n\t\tthis.autoClearStencil = true; // scene graph\n\n\t\tthis.sortObjects = true; // user-defined clipping\n\n\t\tthis.clippingPlanes = [];\n\t\tthis.localClippingEnabled = false; // physically based shading\n\n\t\tthis.gammaFactor = 2.0; // for backwards compatibility\n\n\t\tthis.outputEncoding = LinearEncoding; // physical lights\n\n\t\tthis.physicallyCorrectLights = false; // tone mapping\n\n\t\tthis.toneMapping = NoToneMapping;\n\t\tthis.toneMappingExposure = 1.0; // morphs\n\n\t\tthis.maxMorphTargets = 8;\n\t\tthis.maxMorphNormals = 4; // internal properties\n\n\t\tvar _this = this;\n\n\t\tvar _isContextLost = false; // internal state cache\n\n\t\tvar _framebuffer = null;\n\t\tvar _currentActiveCubeFace = 0;\n\t\tvar _currentActiveMipmapLevel = 0;\n\t\tvar _currentRenderTarget = null;\n\t\tvar _currentFramebuffer = null;\n\n\t\tvar _currentMaterialId = -1;\n\n\t\tvar _currentCamera = null;\n\n\t\tvar _currentViewport = new Vector4();\n\n\t\tvar _currentScissor = new Vector4();\n\n\t\tvar _currentScissorTest = null; //\n\n\t\tvar _width = _canvas.width;\n\t\tvar _height = _canvas.height;\n\t\tvar _pixelRatio = 1;\n\t\tvar _opaqueSort = null;\n\t\tvar _transparentSort = null;\n\n\t\tvar _viewport = new Vector4(0, 0, _width, _height);\n\n\t\tvar _scissor = new Vector4(0, 0, _width, _height);\n\n\t\tvar _scissorTest = false; // frustum\n\n\t\tvar _frustum = new Frustum(); // clipping\n\n\n\t\tvar _clippingEnabled = false;\n\t\tvar _localClippingEnabled = false; // camera matrices cache\n\n\t\tvar _projScreenMatrix = new Matrix4();\n\n\t\tvar _vector3 = new Vector3();\n\n\t\tvar _emptyScene = {\n\t\t\tbackground: null,\n\t\t\tfog: null,\n\t\t\tenvironment: null,\n\t\t\toverrideMaterial: null,\n\t\t\tisScene: true\n\t\t};\n\n\t\tfunction getTargetPixelRatio() {\n\t\t\treturn _currentRenderTarget === null ? _pixelRatio : 1;\n\t\t} // initialize\n\n\n\t\tvar _gl = _context;\n\n\t\tfunction getContext(contextNames, contextAttributes) {\n\t\t\tfor (var i = 0; i < contextNames.length; i++) {\n\t\t\t\tvar contextName = contextNames[i];\n\n\t\t\t\tvar context = _canvas.getContext(contextName, contextAttributes);\n\n\t\t\t\tif (context !== null) return context;\n\t\t\t}\n\n\t\t\treturn null;\n\t\t}\n\n\t\ttry {\n\t\t\tvar contextAttributes = {\n\t\t\t\talpha: _alpha,\n\t\t\t\tdepth: _depth,\n\t\t\t\tstencil: _stencil,\n\t\t\t\tantialias: _antialias,\n\t\t\t\tpremultipliedAlpha: _premultipliedAlpha,\n\t\t\t\tpreserveDrawingBuffer: _preserveDrawingBuffer,\n\t\t\t\tpowerPreference: _powerPreference,\n\t\t\t\tfailIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat\n\t\t\t}; // event listeners must be registered before WebGL context is created, see #12753\n\n\t\t\t_canvas.addEventListener('webglcontextlost', onContextLost, false);\n\n\t\t\t_canvas.addEventListener('webglcontextrestored', onContextRestore, false);\n\n\t\t\tif (_gl === null) {\n\t\t\t\tvar contextNames = ['webgl2', 'webgl', 'experimental-webgl'];\n\n\t\t\t\tif (_this.isWebGL1Renderer === true) {\n\t\t\t\t\tcontextNames.shift();\n\t\t\t\t}\n\n\t\t\t\t_gl = getContext(contextNames, contextAttributes);\n\n\t\t\t\tif (_gl === null) {\n\t\t\t\t\tif (getContext(contextNames)) {\n\t\t\t\t\t\tthrow new Error('Error creating WebGL context with your selected attributes.');\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new Error('Error creating WebGL context.');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} // Some experimental-webgl implementations do not have getShaderPrecisionFormat\n\n\n\t\t\tif (_gl.getShaderPrecisionFormat === undefined) {\n\t\t\t\t_gl.getShaderPrecisionFormat = function () {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t'rangeMin': 1,\n\t\t\t\t\t\t'rangeMax': 1,\n\t\t\t\t\t\t'precision': 1\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error('THREE.WebGLRenderer: ' + error.message);\n\t\t\tthrow error;\n\t\t}\n\n\t\tvar extensions, capabilities, state, info;\n\t\tvar properties, textures, cubemaps, attributes, geometries, objects;\n\t\tvar programCache, materials, renderLists, renderStates, clipping;\n\t\tvar background, morphtargets, bufferRenderer, indexedBufferRenderer;\n\t\tvar utils, bindingStates;\n\n\t\tfunction initGLContext() {\n\t\t\textensions = new WebGLExtensions(_gl);\n\t\t\tcapabilities = new WebGLCapabilities(_gl, extensions, parameters);\n\n\t\t\tif (capabilities.isWebGL2 === false) {\n\t\t\t\textensions.get('WEBGL_depth_texture');\n\t\t\t\textensions.get('OES_texture_float');\n\t\t\t\textensions.get('OES_texture_half_float');\n\t\t\t\textensions.get('OES_texture_half_float_linear');\n\t\t\t\textensions.get('OES_standard_derivatives');\n\t\t\t\textensions.get('OES_element_index_uint');\n\t\t\t\textensions.get('OES_vertex_array_object');\n\t\t\t\textensions.get('ANGLE_instanced_arrays');\n\t\t\t}\n\n\t\t\textensions.get('OES_texture_float_linear');\n\t\t\tutils = new WebGLUtils(_gl, extensions, capabilities);\n\t\t\tstate = new WebGLState(_gl, extensions, capabilities);\n\t\t\tstate.scissor(_currentScissor.copy(_scissor).multiplyScalar(_pixelRatio).floor());\n\t\t\tstate.viewport(_currentViewport.copy(_viewport).multiplyScalar(_pixelRatio).floor());\n\t\t\tinfo = new WebGLInfo(_gl);\n\t\t\tproperties = new WebGLProperties();\n\t\t\ttextures = new WebGLTextures(_gl, extensions, state, properties, capabilities, utils, info);\n\t\t\tcubemaps = new WebGLCubeMaps(_this);\n\t\t\tattributes = new WebGLAttributes(_gl, capabilities);\n\t\t\tbindingStates = new WebGLBindingStates(_gl, extensions, attributes, capabilities);\n\t\t\tgeometries = new WebGLGeometries(_gl, attributes, info, bindingStates);\n\t\t\tobjects = new WebGLObjects(_gl, geometries, attributes, info);\n\t\t\tmorphtargets = new WebGLMorphtargets(_gl);\n\t\t\tclipping = new WebGLClipping(properties);\n\t\t\tprogramCache = new WebGLPrograms(_this, cubemaps, extensions, capabilities, bindingStates, clipping);\n\t\t\tmaterials = new WebGLMaterials(properties);\n\t\t\trenderLists = new WebGLRenderLists(properties);
1\n\t\t\trenderStates = new WebGLRenderStates(extensions, capabilities);\n\t\t\tbackground = new WebGLBackground(_this, cubemaps, state, objects, _premultipliedAlpha);\n\t\t\tbufferRenderer = new WebGLBufferRenderer(_gl, extensions, info, capabilities);\n\t\t\tindexedBufferRenderer = new WebGLIndexedBufferRenderer(_gl, extensions, info, capabilities);\n\t\t\tinfo.programs = programCache.programs;\n\t\t\t_this.capabilities = capabilities;\n\t\t\t_this.extensions = extensions;\n\t\t\t_this.properties = properties;\n\t\t\t_this.renderLists = renderLists;\n\t\t\t_this.state = state;\n\t\t\t_this.info = info;\n\t\t}\n\n\t\tinitGLContext(); // xr\n\n\t\tvar xr = new WebXRManager(_this, _gl);\n\t\tthis.xr = xr; // shadow map\n\n\t\tvar shadowMap = new WebGLShadowMap(_this, objects, capabilities.maxTextureSize);\n\t\tthis.shadowMap = shadowMap; // API\n\n\t\tthis.getContext = function () {\n\t\t\treturn _gl;\n\t\t};\n\n\t\tthis.getContextAttributes = function () {\n\t\t\treturn _gl.getContextAttributes();\n\t\t};\n\n\t\tthis.forceContextLoss = function () {\n\t\t\tvar extension = extensions.get('WEBGL_lose_context');\n\t\t\tif (extension) extension.loseContext();\n\t\t};\n\n\t\tthis.forceContextRestore = function () {\n\t\t\tvar extension = extensions.get('WEBGL_lose_context');\n\t\t\tif (extension) extension.restoreContext();\n\t\t};\n\n\t\tthis.getPixelRatio = function () {\n\t\t\treturn _pixelRatio;\n\t\t};\n\n\t\tthis.setPixelRatio = function (value) {\n\t\t\tif (value === undefined) return;\n\t\t\t_pixelRatio = value;\n\t\t\tthis.setSize(_width, _height, false);\n\t\t};\n\n\t\tthis.getSize = function (target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('WebGLRenderer: .getsize() now requires a Vector2 as an argument');\n\t\t\t\ttarget = new Vector2();\n\t\t\t}\n\n\t\t\treturn target.set(_width, _height);\n\t\t};\n\n\t\tthis.setSize = function (width, height, updateStyle) {\n\t\t\tif (xr.isPresenting) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: Can\\'t change size while VR device is presenting.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t_width = width;\n\t\t\t_height = height;\n\t\t\t_canvas.width = Math.floor(width * _pixelRatio);\n\t\t\t_canvas.height = Math.floor(height * _pixelRatio);\n\n\t\t\tif (updateStyle !== false) {\n\t\t\t\t_canvas.style.width = width + 'px';\n\t\t\t\t_canvas.style.height = height + 'px';\n\t\t\t}\n\n\t\t\tthis.setViewport(0, 0, width, height);\n\t\t};\n\n\t\tthis.getDrawingBufferSize = function (target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument');\n\t\t\t\ttarget = new Vector2();\n\t\t\t}\n\n\t\t\treturn target.set(_width * _pixelRatio, _height * _pixelRatio).floor();\n\t\t};\n\n\t\tthis.setDrawingBufferSize = function (width, height, pixelRatio) {\n\t\t\t_width = width;\n\t\t\t_height = height;\n\t\t\t_pixelRatio = pixelRatio;\n\t\t\t_canvas.width = Math.floor(width * pixelRatio);\n\t\t\t_canvas.height = Math.floor(height * pixelRatio);\n\t\t\tthis.setViewport(0, 0, width, height);\n\t\t};\n\n\t\tthis.getCurrentViewport = function (target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument');\n\t\t\t\ttarget = new Vector4();\n\t\t\t}\n\n\t\t\treturn target.copy(_currentViewport);\n\t\t};\n\n\t\tthis.getViewport = function (target) {\n\t\t\treturn target.copy(_viewport);\n\t\t};\n\n\t\tthis.setViewport = function (x, y, width, height) {\n\t\t\tif (x.isVector4) {\n\t\t\t\t_viewport.set(x.x, x.y, x.z, x.w);\n\t\t\t} else {\n\t\t\t\t_viewport.set(x, y, width, height);\n\t\t\t}\n\n\t\t\tstate.viewport(_currentViewport.copy(_viewport).multiplyScalar(_pixelRatio).floor());\n\t\t};\n\n\t\tthis.getScissor = function (target) {\n\t\t\treturn target.copy(_scissor);\n\t\t};\n\n\t\tthis.setScissor = function (x, y, width, height) {\n\t\t\tif (x.isVector4) {\n\t\t\t\t_scissor.set(x.x, x.y, x.z, x.w);\n\t\t\t} else {\n\t\t\t\t_scissor.set(x, y, width, height);\n\t\t\t}\n\n\t\t\tstate.scissor(_currentScissor.copy(_scissor).multiplyScalar(_pixelRatio).floor());\n\t\t};
1\n\n\t\tthis.getScissorTest = function () {\n\t\t\treturn _scissorTest;\n\t\t};\n\n\t\tthis.setScissorTest = function (boolean) {\n\t\t\tstate.setScissorTest(_scissorTest = boolean);\n\t\t};\n\n\t\tthis.setOpaqueSort = function (method) {\n\t\t\t_opaqueSort = method;\n\t\t};\n\n\t\tthis.setTransparentSort = function (method) {\n\t\t\t_transparentSort = method;\n\t\t}; // Clearing\n\n\n\t\tthis.getClearColor = function (target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('WebGLRenderer: .getClearColor() now requires a Color as an argument');\n\t\t\t\ttarget = new Color();\n\t\t\t}\n\n\t\t\treturn target.copy(background.getClearColor());\n\t\t};\n\n\t\tthis.setClearColor = function () {\n\t\t\tbackground.setClearColor.apply(background, arguments);\n\t\t};\n\n\t\tthis.getClearAlpha = function () {\n\t\t\treturn background.getClearAlpha();\n\t\t};\n\n\t\tthis.setClearAlpha = function () {\n\t\t\tbackground.setClearAlpha.apply(background, arguments);\n\t\t};\n\n\t\tthis.clear = function (color, depth, stencil) {\n\t\t\tvar bits = 0;\n\t\t\tif (color === undefined || color) bits |= 16384;\n\t\t\tif (depth === undefined || depth) bits |= 256;\n\t\t\tif (stencil === undefined || stencil) bits |= 1024;\n\n\t\t\t_gl.clear(bits);\n\t\t};\n\n\t\tthis.clearColor = function () {\n\t\t\tthis.clear(true, false, false);\n\t\t};\n\n\t\tthis.clearDepth = function () {\n\t\t\tthis.clear(false, true, false);\n\t\t};\n\n\t\tthis.clearStencil = function () {\n\t\t\tthis.clear(false, false, true);\n\t\t}; //\n\n\n\t\tthis.dispose = function () {\n\t\t\t_canvas.removeEventListener('webglcontextlost', onContextLost, false);\n\n\t\t\t_canvas.removeEventListener('webglcontextrestored', onContextRestore, false);\n\n\t\t\trenderLists.dispose();\n\t\t\trenderStates.dispose();\n\t\t\tproperties.dispose();\n\t\t\tcubemaps.dispose();\n\t\t\tobjects.dispose();\n\t\t\tbindingStates.dispose();\n\t\t\txr.dispose();\n\t\t\tanimation.stop();\n\t\t}; // Events\n\n\n\t\tfunction onContextLost(event) {\n\t\t\tevent.preventDefault();\n\t\t\tconsole.log('THREE.WebGLRenderer: Context Lost.');\n\t\t\t_isContextLost = true;\n\t\t}\n\n\t\tfunction onContextRestore()\n\t\t/* event */\n\t\t{\n\t\t\tconsole.log('THREE.WebGLRenderer: Context Restored.');\n\t\t\t_isContextLost = false;\n\t\t\tinitGLContext();\n\t\t}\n\n\t\tfunction onMaterialDispose(event) {\n\t\t\tvar material = event.target;\n\t\t\tmaterial.removeEventListener('dispose', onMaterialDispose);\n\t\t\tdeallocateMaterial(material);\n\t\t} // Buffer deallocation\n\n\n\t\tfunction deallocateMaterial(material) {\n\t\t\treleaseMaterialProgramReference(material);\n\t\t\tproperties.remove(material);\n\t\t}\n\n\t\tfunction releaseMaterialProgramReference(material) {\n\t\t\tvar programInfo = properties.get(material).program;\n\n\t\t\tif (programInfo !== undefined) {\n\t\t\t\tprogramCache.releaseProgram(programInfo);\n\t\t\t}\n\t\t} // Buffer rendering\n\n\n\t\tfunction renderObjectImmediate(object, program) {\n\t\t\tobject.render(function (object) {\n\t\t\t\t_this.renderBufferImmediate(object, program);\n\t\t\t});\n\t\t}\n\n\t\tthis.renderBufferImmediate = function (object, program) {\n\t\t\tbindingStates.initAttributes();\n\t\t\tvar buffers = properties.get(object);\n\t\t\tif (object.hasPositions && !buffers.position) buffers.position = _gl.createBuffer();\n\t\t\tif (object.hasNormals && !buffers.normal) buffers.normal = _gl.createBuffer();\n\t\t\tif (object.hasUvs && !buffers.uv) buffers.uv = _gl.createBuffer();\n\t\t\tif (object.hasColors && !buffers.color) buffers.color = _gl.createBuffer();\n\t\t\tvar programAttributes = program.getAttributes();\n\n\t\t\tif (object.hasPositions) {\n\t\t\t\t_gl.bindBuffer(34962, buffers.position);\n\n\t\t\t\t_gl.bufferData(34962, object.positionArray, 35048);\n\n\t\t\t\tbindingStates.enableAttribute(programAttributes.position);\n\n\t\t\t\t_gl.vertexAttribPointer(programAttributes.position, 3, 5126, false, 0, 0);\n\t\t\t}\n\n\t\t\tif (object.hasNormals) {\n\t\t\t\t_gl.bindBuffer(34962, buffers.normal);\n\n\t\t\t\t_gl.bufferData(34962, object.normalArray, 35048);\n\n\t\t\t\tbindingStates.enableAttribute(programAttributes.normal);\n\n\t\t\t\t_gl.vertexAttribPointer(programAttributes.normal, 3, 5126, false, 0, 0);\n\t\t\t}\n\n\t\t\tif (object.hasUvs) {\n\t\t\t\t_gl.bindBuffer(34962, buffers.uv);\n\n\t\t\t\t_gl.bufferData(34962, object.uvArray, 35048);\n\n\t\t\t\tbindingStates.enableAttribute(programAttributes.uv);\n\n\t\t\t\t_gl.vertexAttribPointer(programAttributes.uv, 2, 5126, false, 0, 0);\n\t\t\t}\n\n\t\t\tif (object.hasColors) {\n\t\t\t\t_gl.bindBuffer(34962, buffers.color);\n\n\t\t\t\t_gl.bufferData(34962, object.colorArray, 35048);\n\n\t\t\t\tbindingStates.enableAttribute(programAttributes.color);\n\n\t\t\t\t_gl.vertexAttribPointer(programAttributes.color, 3, 5126, false, 0, 0);\n\t\t\t}\n\n\t\t\tbindingStates.disableUnusedAttributes();\n\n\t\t\t_gl.drawArrays(4, 0, object.count);\n\n\t\t\tobject.count = 0;\n\t\t};\n\n\t\tthis.renderBufferDirect = function (camera, scene, geometry, material, object, group) {\n\t\t\tif (scene === null) scene = _emptyScene; // renderBufferDirect second parameter used to be fog (could be null)\n\n\t\t\tvar frontFaceCW = object.isMesh && object.matrixWorld.determinant() < 0;\n\t\t\tvar program = setProgram(camera, scene, material, object);\n\t\t\tstate.setMaterial(material, frontFaceCW); //\n\n\t\t\tvar index = geometry.index;\n\t\t\tvar position = geometry.attributes.position; //\n\n\t\t\tif (index === null) {\n\t\t\t\tif (position === undefined || position.count === 0) return;\n\t\t\t} else if (index.count === 0) {\n\t\t\t\treturn;\n\t\t\t} //\n\n\n\t\t\tvar rangeFactor = 1;\n\n\t\t\tif (material.wireframe === true) {\n\t\t\t\tindex = geometries.getWireframeAttribute(geometry);\n\t\t\t\trangeFactor = 2;\n\t\t\t}\n\n\t\t\tif (material.morphTargets || material.morphNormals) {\n\t\t\t\tmorphtargets.update(object, geometry, material, program);\n\t\t\t}\n\n\t\t\tbindingStates.setup(object, material, program, geometry, index);\n\t\t\tvar attribute;\n\t\t\tvar renderer = bufferRenderer;\n\n\t\t\tif (index !== null) {\n\t\t\t\tattribute = attributes.get(index);\n\t\t\t\trenderer = indexedBufferRenderer;\n\t\t\t\trenderer.setIndex(attribute);\n\t\t\t} //\n\n\n\t\t\tvar dataCount = index !== null ? index.count : position.count;\n\t\t\tvar rangeStart = geometry.drawRange.start * rangeFactor;
1\n\t\t\tvar rangeCount = geometry.drawRange.count * rangeFactor;\n\t\t\tvar groupStart = group !== null ? group.start * rangeFactor : 0;\n\t\t\tvar groupCount = group !== null ? group.count * rangeFactor : Infinity;\n\t\t\tvar drawStart = Math.max(rangeStart, groupStart);\n\t\t\tvar drawEnd = Math.min(dataCount, rangeStart + rangeCount, groupStart + groupCount) - 1;\n\t\t\tvar drawCount = Math.max(0, drawEnd - drawStart + 1);\n\t\t\tif (drawCount === 0) return; //\n\n\t\t\tif (object.isMesh) {\n\t\t\t\tif (material.wireframe === true) {\n\t\t\t\t\tstate.setLineWidth(material.wireframeLinewidth * getTargetPixelRatio());\n\t\t\t\t\trenderer.setMode(1);\n\t\t\t\t} else {\n\t\t\t\t\trenderer.setMode(4);\n\t\t\t\t}\n\t\t\t} else if (object.isLine) {\n\t\t\t\tvar lineWidth = material.linewidth;\n\t\t\t\tif (lineWidth === undefined) lineWidth = 1; // Not using Line*Material\n\n\t\t\t\tstate.setLineWidth(lineWidth * getTargetPixelRatio());\n\n\t\t\t\tif (object.isLineSegments) {\n\t\t\t\t\trenderer.setMode(1);\n\t\t\t\t} else if (object.isLineLoop) {\n\t\t\t\t\trenderer.setMode(2);\n\t\t\t\t} else {\n\t\t\t\t\trenderer.setMode(3);\n\t\t\t\t}\n\t\t\t} else if (object.isPoints) {\n\t\t\t\trenderer.setMode(0);\n\t\t\t} else if (object.isSprite) {\n\t\t\t\trenderer.setMode(4);\n\t\t\t}\n\n\t\t\tif (object.isInstancedMesh) {\n\t\t\t\trenderer.renderInstances(drawStart, drawCount, object.count);\n\t\t\t} else if (geometry.isInstancedBufferGeometry) {\n\t\t\t\tvar instanceCount = Math.min(geometry.instanceCount, geometry._maxInstanceCount);\n\t\t\t\trenderer.renderInstances(drawStart, drawCount, instanceCount);\n\t\t\t} else {\n\t\t\t\trenderer.render(drawStart, drawCount);\n\t\t\t}\n\t\t}; // Compile\n\n\n\t\tthis.compile = function (scene, camera) {\n\t\t\tcurrentRenderState = renderStates.get(scene);\n\t\t\tcurrentRenderState.init();\n\t\t\tscene.traverseVisible(function (object) {\n\t\t\t\tif (object.isLight && object.layers.test(camera.layers)) {\n\t\t\t\t\tcurrentRenderState.pushLight(object);\n\n\t\t\t\t\tif (object.castShadow) {\n\t\t\t\t\t\tcurrentRenderState.pushShadow(object);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t\tcurrentRenderState.setupLights();\n\t\t\tvar compiled = new WeakMap();\n\t\t\tscene.traverse(function (object) {\n\t\t\t\tvar material = object.material;\n\n\t\t\t\tif (material) {\n\t\t\t\t\tif (Array.isArray(material)) {\n\t\t\t\t\t\tfor (var i = 0; i < material.length; i++) {\n\t\t\t\t\t\t\tvar material2 = material[i];\n\n\t\t\t\t\t\t\tif (compiled.has(material2) === false) {\n\t\t\t\t\t\t\t\tinitMaterial(material2, scene, object);\n\t\t\t\t\t\t\t\tcompiled.set(material2);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (compiled.has(material) === false) {\n\t\t\t\t\t\tinitMaterial(material, scene, object);\n\t\t\t\t\t\tcompiled.set(material);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}; // Animation Loop\n\n\n\t\tvar onAnimationFrameCallback = null;\n\n\t\tfunction onAnimationFrame(time) {\n\t\t\tif (xr.isPresenting) return;\n\t\t\tif (onAnimationFrameCallback) onAnimationFrameCallback(time);\n\t\t}\n\n\t\tvar animation = new WebGLAnimation();\n\t\tanimation.setAnimationLoop(onAnimationFrame);\n\t\tif (typeof window !== 'undefined') animation.setContext(window);\n\n\t\tthis.setAnimationLoop = function (callback) {\n\t\t\tonAnimationFrameCallback = callback;\n\t\t\txr.setAnimationLoop(callback);\n\t\t\tcallback === null ? animation.stop() : animation.start();\n\t\t}; // Rendering\n\n\n\t\tthis.render = function (scene, camera) {\n\t\t\tvar renderTarget, forceClear;\n\n\t\t\tif (arguments[2] !== undefined) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead.');\n\t\t\t\trenderTarget = arguments[2];\n\t\t\t}\n\n\t\t\tif (arguments[3] !== undefined) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead.');\n\t\t\t\tforceClear = arguments[3];\n\t\t\t}\n\n\t\t\tif (camera !== undefined && camera.isCamera !== true) {\n\t\t\t\tconsole.error('THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (_isContextLost === true) return; // reset caching for this frame\n\n\t\t\tbindingStates.resetDefaultState();\n\t\t\t_currentMaterialId = -1;\n\t\t\t_currentCamera = null; // update scene graph\n\n\t\t\tif (scene.autoUpdate === true) scene.updateMatrixWorld(); // update camera matrices and frustum\n\n\t\t\tif (camera.parent === null) camera.updateMatrixWorld();\n\n\t\t\tif (xr.enabled === true && xr.isPresenting === true) {\n\t\t\t\tcamera = xr.getCamera(camera);\n\t\t\t} //\n\n\n\t\t\tif (scene.isScene === true) scene.onBeforeRender(_this, scene, camera, renderTarget || _currentRenderTarget);\n\t\t\tcurrentRenderState = renderStates.get(scene, renderStateStack.length);
1\n\t\t\tcurrentRenderState.init();\n\t\t\trenderStateStack.push(currentRenderState);\n\n\t\t\t_projScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);\n\n\t\t\t_frustum.setFromProjectionMatrix(_projScreenMatrix);\n\n\t\t\t_localClippingEnabled = this.localClippingEnabled;\n\t\t\t_clippingEnabled = clipping.init(this.clippingPlanes, _localClippingEnabled, camera);\n\t\t\tcurrentRenderList = renderLists.get(scene, camera);\n\t\t\tcurrentRenderList.init();\n\t\t\tprojectObject(scene, camera, 0, _this.sortObjects);\n\t\t\tcurrentRenderList.finish();\n\n\t\t\tif (_this.sortObjects === true) {\n\t\t\t\tcurrentRenderList.sort(_opaqueSort, _transparentSort);\n\t\t\t} //\n\n\n\t\t\tif (_clippingEnabled === true) clipping.beginShadows();\n\t\t\tvar shadowsArray = currentRenderState.state.shadowsArray;\n\t\t\tshadowMap.render(shadowsArray, scene, camera);\n\t\t\tcurrentRenderState.setupLights();\n\t\t\tcurrentRenderState.setupLightsView(camera);\n\t\t\tif (_clippingEnabled === true) clipping.endShadows(); //\n\n\t\t\tif (this.info.autoReset === true) this.info.reset();\n\n\t\t\tif (renderTarget !== undefined) {\n\t\t\t\tthis.setRenderTarget(renderTarget);\n\t\t\t} //\n\n\n\t\t\tbackground.render(currentRenderList, scene, camera, forceClear); // render scene\n\n\t\t\tvar opaqueObjects = currentRenderList.opaque;\n\t\t\tvar transparentObjects = currentRenderList.transparent;\n\t\t\tif (opaqueObjects.length > 0) renderObjects(opaqueObjects, scene, camera);\n\t\t\tif (transparentObjects.length > 0) renderObjects(transparentObjects, scene, camera); //\n\n\t\t\tif (scene.isScene === true) scene.onAfterRender(_this, scene, camera); //\n\n\t\t\tif (_currentRenderTarget !== null) {\n\t\t\t\t// Generate mipmap if we're using any kind of mipmap filtering\n\t\t\t\ttextures.updateRenderTargetMipmap(_currentRenderTarget); // resolve multisample renderbuffers to a single-sample texture if necessary\n\n\t\t\t\ttextures.updateMultisampleRenderTarget(_currentRenderTarget);\n\t\t\t} // Ensure depth buffer writing is enabled so it can be cleared on next render\n\n\n\t\t\tstate.buffers.depth.setTest(true);\n\t\t\tstate.buffers.depth.setMask(true);\n\t\t\tstate.buffers.color.setMask(true);\n\t\t\tstate.setPolygonOffset(false); // _gl.finish();\n\n\t\t\trenderStateStack.pop();\n\n\t\t\tif (renderStateStack.length > 0) {\n\t\t\t\tcurrentRenderState = renderStateStack[renderStateStack.length - 1];\n\t\t\t} else {\n\t\t\t\tcurrentRenderState = null;\n\t\t\t}\n\n\t\t\tcurrentRenderList = null;\n\t\t};\n\n\t\tfunction projectObject(object, camera, groupOrder, sortObjects) {\n\t\t\tif (object.visible === false) return;\n\t\t\tvar visible = object.layers.test(camera.layers);\n\n\t\t\tif (visible) {\n\t\t\t\tif (object.isGroup) {\n\t\t\t\t\tgroupOrder = object.renderOrder;\n\t\t\t\t} else if (object.isLOD) {\n\t\t\t\t\tif (object.autoUpdate === true) object.update(camera);\n\t\t\t\t} else if (object.isLight) {\n\t\t\t\t\tcurrentRenderState.pushLight(object);\n\n\t\t\t\t\tif (object.castShadow) {\n\t\t\t\t\t\tcurrentRenderState.pushShadow(object);\n\t\t\t\t\t}\n\t\t\t\t} else if (object.isSprite) {\n\t\t\t\t\tif (!object.frustumCulled || _frustum.intersectsSprite(object)) {\n\t\t\t\t\t\tif (sortObjects) {\n\t\t\t\t\t\t\t_vector3.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvar geometry = objects.update(object);\n\t\t\t\t\t\tvar material = object.material;\n\n\t\t\t\t\t\tif (material.visible) {\n\t\t\t\t\t\t\tcurrentRenderList.push(object, geometry, material, groupOrder, _vector3.z, null);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else if (object.isImmediateRenderObject) {\n\t\t\t\t\tif (sortObjects) {\n\t\t\t\t\t\t_vector3.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix);\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrentRenderList.push(object, null, object.material, groupOrder, _vector3.z, null);\n\t\t\t\t} else if (object.isMesh || object.isLine || object.isPoints) {\n\t\t\t\t\tif (object.isSkinnedMesh) {\n\t\t\t\t\t\t// update skeleton only once in a frame\n\t\t\t\t\t\tif (object.skeleton.frame !== info.render.frame) {\n\t\t\t\t\t\t\tobject.skeleton.update();\n\t\t\t\t\t\t\tobject.skeleton.frame = info.render.frame;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!object.frustumCulled || _frustum.intersectsObject(object)) {\n\t\t\t\t\t\tif (sortObjects) {\n\t\t\t\t\t\t\t_vector3.setFromMatrixPosition(object.matrixWorld).applyMatrix4(_projScreenMatrix);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvar _geometry = objects.update(object);\n\n\t\t\t\t\t\tvar _material = object.material;\n\n\t\t\t\t\t\tif (Array.isArray(_material)) {\n\t\t\t\t\t\t\tvar groups = _geometry.groups;\n\n\t\t\t\t\t\t\tfor (var i = 0, l = groups.length; i < l;
1 i++) {\n\t\t\t\t\t\t\t\tvar group = groups[i];\n\t\t\t\t\t\t\t\tvar groupMaterial = _material[group.materialIndex];\n\n\t\t\t\t\t\t\t\tif (groupMaterial && groupMaterial.visible) {\n\t\t\t\t\t\t\t\t\tcurrentRenderList.push(object, _geometry, groupMaterial, groupOrder, _vector3.z, group);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (_material.visible) {\n\t\t\t\t\t\t\tcurrentRenderList.push(object, _geometry, _material, groupOrder, _vector3.z, null);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar children = object.children;\n\n\t\t\tfor (var _i = 0, _l = children.length; _i < _l; _i++) {\n\t\t\t\tprojectObject(children[_i], camera, groupOrder, sortObjects);\n\t\t\t}\n\t\t}\n\n\t\tfunction renderObjects(renderList, scene, camera) {\n\t\t\tvar overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null;\n\n\t\t\tfor (var i = 0, l = renderList.length; i < l; i++) {\n\t\t\t\tvar renderItem = renderList[i];\n\t\t\t\tvar object = renderItem.object;\n\t\t\t\tvar geometry = renderItem.geometry;\n\t\t\t\tvar material = overrideMaterial === null ? renderItem.material : overrideMaterial;\n\t\t\t\tvar group = renderItem.group;\n\n\t\t\t\tif (camera.isArrayCamera) {\n\t\t\t\t\tvar cameras = camera.cameras;\n\n\t\t\t\t\tfor (var j = 0, jl = cameras.length; j < jl; j++) {\n\t\t\t\t\t\tvar camera2 = cameras[j];\n\n\t\t\t\t\t\tif (object.layers.test(camera2.layers)) {\n\t\t\t\t\t\t\tstate.viewport(_currentViewport.copy(camera2.viewport));\n\t\t\t\t\t\t\tcurrentRenderState.setupLightsView(camera2);\n\t\t\t\t\t\t\trenderObject(object, scene, camera2, geometry, material, group);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\trenderObject(object, scene, camera, geometry, material, group);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction renderObject(object, scene, camera, geometry, material, group) {\n\t\t\tobject.onBeforeRender(_this, scene, camera, geometry, material, group);\n\t\t\tobject.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, object.matrixWorld);\n\t\t\tobject.normalMatrix.getNormalMatrix(object.modelViewMatrix);\n\n\t\t\tif (object.isImmediateRenderObject) {\n\t\t\t\tvar program = setProgram(camera, scene, material, object);\n\t\t\t\tstate.setMaterial(material);\n\t\t\t\tbindingStates.reset();\n\t\t\t\trenderObjectImmediate(object, program);\n\t\t\t} else {\n\t\t\t\t_this.renderBufferDirect(camera, scene, geometry, material, object, group);\n\t\t\t}\n\n\t\t\tobject.onAfterRender(_this, scene, camera, geometry, material, group);\n\t\t}\n\n\t\tfunction initMaterial(material, scene, object) {\n\t\t\tif (scene.isScene !== true) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...\n\n\t\t\tvar materialProperties = properties.get(material);\n\t\t\tvar lights = currentRenderState.state.lights;\n\t\t\tvar shadowsArray = currentRenderState.state.shadowsArray;\n\t\t\tvar lightsStateVersion = lights.state.version;\n\t\t\tvar parameters = programCache.getParameters(material, lights.state, shadowsArray, scene, object);\n\t\t\tvar programCacheKey = programCache.getProgramCacheKey(parameters);\n\t\t\tvar program = materialProperties.program;\n\t\t\tvar programChange = true;\n\n\t\t\tif (program === undefined) {\n\t\t\t\t// new material\n\t\t\t\tmaterial.addEventListener('dispose', onMaterialDispose);\n\t\t\t} else if (program.cacheKey !== programCacheKey) {\n\t\t\t\t// changed glsl or parameters\n\t\t\t\treleaseMaterialProgramReference(material);\n\t\t\t} else if (materialProperties.lightsStateVersion !== lightsStateVersion) {\n\t\t\t\tprogramChange = false;\n\t\t\t} else if (parameters.shaderID !== undefined) {\n\t\t\t\t// same glsl and uniform list, envMap still needs the update here to avoid a frame-late effect\n\t\t\t\tvar environment = material.isMeshStandardMaterial ? scene.environment : null;\n\t\t\t\tmaterialProperties.envMap = cubemaps.get(material.envMap || environment);\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\t// only rebuild uniform list\n\t\t\t\tprogramChange = false;\n\t\t\t}\n\n\t\t\tif (programChange) {\n\t\t\t\tparameters.uniforms = programCache.getUniforms(material);\n\t\t\t\tmaterial.onBeforeCompile(parameters, _this);\n\t\t\t\tprogram = programCache.acquireProgram(parameters, programCacheKey);\n\t\t\t\tmaterialProperties.program = program;\n\t\t\t\tmaterialProperties.uniforms = parameters.uniforms;\n\t\t\t\tmaterialProperties.outputEncoding = parameters.outputEncoding;\n\t\t\t}\n\n\t\t\tvar uniforms = materialProperties.uniforms;\n\n\t\t\tif (!material.isShaderMaterial && !material.isRawShaderMaterial || material.clipping === true) {\n\t\t\t\tmaterialProperties.numClippingPlanes = clipping.numPlanes;\n\t\t\t\tmaterialProperties.numIntersection = clipping.numIntersection;\n\t\t\t\tuniforms.clippingPlanes = clipping.uniform;\n\t\t\t}\n\n\t\t\tmaterialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;\n\t\t\tmaterialProperties.fog = scene.fog;\n\t\t\tmaterialProperties.envMap = cubemaps.get(material.envMap || materialProperties.environment); // store the light setup it was created for\n\n\t\t\tmaterialProperties.needsLights = materialNeedsLights(material);\n\t\t\tmaterialProperties.lightsStateVersion = lightsStateVersion;\n\n\t\t\tif (materialProperties.needsLights) {\n\t\t\t\t// wire up the material to this renderer's lighting state\n\t\t\t\tuniforms.ambientLightColor.value = lights.state.ambient;\n\t\t\t\tuniforms.lightProbe.value = lights.state.probe;\n\t\t\t\tuniforms.directionalLights.value = lights.state.directional;\n\t\t\t\tuniforms.directionalLightShadows.value = lights.state.directionalShadow;\n\t\t\t\tuniforms.spotLights.value = lights.state.spot;\n\t\t\t\tuniforms.spotLightShadows.value = lights.state.spotShadow;\n\t\t\t\tuniforms.rectAreaLights.value = lights.state.rectArea;\n\t\t\t\tuniforms.ltc_1.value = lights.state.rectAreaLTC1;\n\t\t\t\tuniforms.ltc_2.value = lights.state.rectAreaLTC2;\n\t\t\t\tuniforms.pointLights.value = lights.state.point;\n\t\t\t\tuniforms.pointLightShadows.value = lights.state.pointShadow;\n\t\t\t\tuniforms.hemisphereLights.value = lights.state.hemi;\n\t\t\t\tuniforms.directionalShadowMap.value = lights.state.directionalShadowMap;\n\t\t\t\tuniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix;\n\t\t\t\tuniforms.spotShadowMap.value = lights.state.spotShadowMap;\n\t\t\t\tuniforms.spotShadowMatrix.value = lights.state.spotShadowMatrix;\n\t\t\t\tuniforms.pointShadowMap.value = lights.state.pointShadowMap;\n\t\t\t\tuniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix; // TODO (abelnation): add area lights shadow info to uniforms\n\t\t\t}\n\n\t\t\tvar progUniforms = materialProperties.program.getUniforms();\n\t\t\tvar uniformsList = WebGLUniforms.seqWithValue(progUniforms.seq, uniforms);\n\t\t\tmaterialProperties.uniformsList = uniformsList;\n\t\t}\n\n\t\tfunction setProgram(camera, scene, material, object) {\n\t\t\tif (scene.isScene !== true) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...\n\n\t\t\ttextures.resetTextureUnits();\n\t\t\tvar fog = scene.fog;\n\t\t\tvar environment = material.isMeshStandardMaterial ? scene.environment : null;\n\t\t\tvar encoding = _currentRenderTarget === null ? _this.outputEncoding : _currentRenderTarget.texture.encoding;\n\t\t\tvar envMap = cubemaps.get(material.envMap || environment);\n\t\t\tvar materialProperties = properties.get(material);\n\t\t\tvar lights = currentRenderState.state.lights;\n\n\t\t\tif (_clippingEnabled === true) {\n\t\t\t\tif (_localClippingEnabled === true || camera !== _currentCamera) {\n\t\t\t\t\tvar useCache = camera === _currentCamera && material.id === _currentMaterialId;
1 // we might want to call this function with some ClippingGroup\n\t\t\t\t\t// object instead of the material, once it becomes feasible\n\t\t\t\t\t// (#8465, #8379)\n\n\t\t\t\t\tclipping.setState(material, camera, useCache);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (material.version === materialProperties.__version) {\n\t\t\t\tif (material.fog && materialProperties.fog !== fog) {\n\t\t\t\t\tinitMaterial(material, scene, object);\n\t\t\t\t} else if (materialProperties.environment !== environment) {\n\t\t\t\t\tinitMaterial(material, scene, object);\n\t\t\t\t} else if (materialProperties.needsLights && materialProperties.lightsStateVersion !== lights.state.version) {\n\t\t\t\t\tinitMaterial(material, scene, object);\n\t\t\t\t} else if (materialProperties.numClippingPlanes !== undefined && (materialProperties.numClippingPlanes !== clipping.numPlanes || materialProperties.numIntersection !== clipping.numIntersection)) {\n\t\t\t\t\tinitMaterial(material, scene, object);\n\t\t\t\t} else if (materialProperties.outputEncoding !== encoding) {\n\t\t\t\t\tinitMaterial(material, scene, object);\n\t\t\t\t} else if (materialProperties.envMap !== envMap) {\n\t\t\t\t\tinitMaterial(material, scene, object);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tinitMaterial(material, scene, object);\n\t\t\t\tmaterialProperties.__version = material.version;\n\t\t\t}\n\n\t\t\tvar refreshProgram = false;\n\t\t\tvar refreshMaterial = false;\n\t\t\tvar refreshLights = false;\n\t\t\tvar program = materialProperties.program,\n\t\t\t\t\tp_uniforms = program.getUniforms(),\n\t\t\t\t\tm_uniforms = materialProperties.uniforms;\n\n\t\t\tif (state.useProgram(program.program)) {\n\t\t\t\trefreshProgram = true;\n\t\t\t\trefreshMaterial = true;\n\t\t\t\trefreshLights = true;\n\t\t\t}\n\n\t\t\tif (material.id !== _currentMaterialId) {\n\t\t\t\t_currentMaterialId = material.id;\n\t\t\t\trefreshMaterial = true;\n\t\t\t}\n\n\t\t\tif (refreshProgram || _currentCamera !== camera) {\n\t\t\t\tp_uniforms.setValue(_gl, 'projectionMatrix', camera.projectionMatrix);\n\n\t\t\t\tif (capabilities.logarithmicDepthBuffer) {\n\t\t\t\t\tp_uniforms.setValue(_gl, 'logDepthBufFC', 2.0 / (Math.log(camera.far + 1.0) / Math.LN2));\n\t\t\t\t}\n\n\t\t\t\tif (_currentCamera !== camera) {\n\t\t\t\t\t_currentCamera = camera; // lighting uniforms depend on the camera so enforce an update\n\t\t\t\t\t// now, in case this material supports lights - or later, when\n\t\t\t\t\t// the next material that does gets activated:\n\n\t\t\t\t\trefreshMaterial = true; // set to true on material change\n\n\t\t\t\t\trefreshLights = true; // remains set until update done\n\t\t\t\t} // load material specific uniforms\n\t\t\t\t// (shader material also gets them for the sake of genericity)\n\n\n\t\t\t\tif (material.isShaderMaterial || material.isMeshPhongMaterial || material.isMeshToonMaterial || material.isMeshStandardMaterial || material.envMap) {\n\t\t\t\t\tvar uCamPos = p_uniforms.map.cameraPosition;\n\n\t\t\t\t\tif (uCamPos !== undefined) {\n\t\t\t\t\t\tuCamPos.setValue(_gl, _vector3.setFromMatrixPosition(camera.matrixWorld));\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (material.isMeshPhongMaterial || material.isMeshToonMaterial || material.isMeshLambertMaterial || material.isMeshBasicMaterial || material.isMeshStandardMaterial || material.isShaderMaterial) {\n\t\t\t\t\tp_uniforms.setValue(_gl, 'isOrthographic', camera.isOrthographicCamera === true);\n\t\t\t\t}\n\n\t\t\t\tif (material.isMeshPhongMaterial || material.isMeshToonMaterial || material.isMeshLambertMaterial || material.isMeshBasicMaterial || material.isMeshStandardMaterial || material.isShaderMaterial || material.isShadowMaterial || material.skinning) {\n\t\t\t\t\tp_uniforms.setValue(_gl, 'viewMatrix', camera.matrixWorldInverse);\n\t\t\t\t}\n\t\t\t} // skinning uniforms must be set even if material didn't change\n\t\t\t// auto-setting of texture unit for bone texture must go before other textures\n\t\t\t// otherwise textures used for skinning can take over texture units reserved for other material textures\n\n\n\t\t\tif (material.skinning) {\n\t\t\t\tp_uniforms.setOptional(_gl, object, 'bindMatrix');\n\t\t\t\tp_uniforms.setOptional(_gl, object, 'bindMatrixInverse');\n\t\t\t\tvar skeleton = object.skeleton;\n\n\t\t\t\tif (skeleton) {\n\t\t\t\t\tvar bones = skeleton.bones;\n\n\t\t\t\t\tif (capabilities.floatVertexTextures) {\n\t\t\t\t\t\tif (skeleton.boneTexture === null) {\n\t\t\t\t\t\t\t// layout (1 matrix = 4 pixels)\n\t\t\t\t\t\t\t//\t\t\tRGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)\n\t\t\t\t\t\t\t//\twith\t8x8\tpixel texture max\t 16 bones * 4 pixels =\t(8 * 8)\n\t\t\t\t\t\t\t//\t\t\t 16x16 pixel texture max\t 64 bones * 4 pixels = (16 * 16)\n\t\t\t\t\t\t\t//\t\t\t 32x32 pixel texture max\t256 bones * 4 pixels = (32 * 32)\n\t\t\t\t\t\t\t//\t\t\t 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)\n\t\t\t\t\t\t\tvar size = Math.sqrt(bones.length * 4); // 4 pixels needed for 1 matrix\n\n\t\t\t\t\t\t\tsize = MathUtils.ceilPowerOfTwo(size);\n\t\t\t\t\t\t\tsize = Math.max(size, 4);\n\t\t\t\t\t\t\tvar boneMatrices = new Float32Array(size * size * 4); // 4 floats per RGBA pixel\n\n\t\t\t\t\t\t\tboneMatrices.set(skeleton.boneMatrices); // copy current values\n\n\t\t\t\t\t\t\tvar boneTexture = new DataTexture(boneMatr
1ices, size, size, RGBAFormat, FloatType);\n\t\t\t\t\t\t\tskeleton.boneMatrices = boneMatrices;\n\t\t\t\t\t\t\tskeleton.boneTexture = boneTexture;\n\t\t\t\t\t\t\tskeleton.boneTextureSize = size;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tp_uniforms.setValue(_gl, 'boneTexture', skeleton.boneTexture, textures);\n\t\t\t\t\t\tp_uniforms.setValue(_gl, 'boneTextureSize', skeleton.boneTextureSize);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tp_uniforms.setOptional(_gl, skeleton, 'boneMatrices');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (refreshMaterial || materialProperties.receiveShadow !== object.receiveShadow) {\n\t\t\t\tmaterialProperties.receiveShadow = object.receiveShadow;\n\t\t\t\tp_uniforms.setValue(_gl, 'receiveShadow', object.receiveShadow);\n\t\t\t}\n\n\t\t\tif (refreshMaterial) {\n\t\t\t\tp_uniforms.setValue(_gl, 'toneMappingExposure', _this.toneMappingExposure);\n\n\t\t\t\tif (materialProperties.needsLights) {\n\t\t\t\t\t// the current material requires lighting info\n\t\t\t\t\t// note: all lighting uniforms are always set correctly\n\t\t\t\t\t// they simply reference the renderer's state for their\n\t\t\t\t\t// values\n\t\t\t\t\t//\n\t\t\t\t\t// use the current material's .needsUpdate flags to set\n\t\t\t\t\t// the GL state when required\n\t\t\t\t\tmarkUniformsLightsNeedsUpdate(m_uniforms, refreshLights);\n\t\t\t\t} // refresh uniforms common to several materials\n\n\n\t\t\t\tif (fog && material.fog) {\n\t\t\t\t\tmaterials.refreshFogUniforms(m_uniforms, fog);\n\t\t\t\t}\n\n\t\t\t\tmaterials.refreshMaterialUniforms(m_uniforms, material, _pixelRatio, _height);\n\t\t\t\tWebGLUniforms.upload(_gl, materialProperties.uniformsList, m_uniforms, textures);\n\t\t\t}\n\n\t\t\tif (material.isShaderMaterial && material.uniformsNeedUpdate === true) {\n\t\t\t\tWebGLUniforms.upload(_gl, materialProperties.uniformsList, m_uniforms, textures);\n\t\t\t\tmaterial.uniformsNeedUpdate = false;\n\t\t\t}\n\n\t\t\tif (material.isSpriteMaterial) {\n\t\t\t\tp_uniforms.setValue(_gl, 'center', object.center);\n\t\t\t} // common matrices\n\n\n\t\t\tp_uniforms.setValue(_gl, 'modelViewMatrix', object.modelViewMatrix);\n\t\t\tp_uniforms.setValue(_gl, 'normalMatrix', object.normalMatrix);\n\t\t\tp_uniforms.setValue(_gl, 'modelMatrix', object.matrixWorld);\n\t\t\treturn program;\n\t\t} // If uniforms are marked as clean, they don't need to be loaded to the GPU.\n\n\n\t\tfunction markUniformsLightsNeedsUpdate(uniforms, value) {\n\t\t\tuniforms.ambientLightColor.needsUpdate = value;\n\t\t\tuniforms.lightProbe.needsUpdate = value;\n\t\t\tuniforms.directionalLights.needsUpdate = value;\n\t\t\tuniforms.directionalLightShadows.needsUpdate = value;\n\t\t\tuniforms.pointLights.needsUpdate = value;\n\t\t\tuniforms.pointLightShadows.needsUpdate = value;\n\t\t\tuniforms.spotLights.needsUpdate = value;\n\t\t\tuniforms.spotLightShadows.needsUpdate = value;\n\t\t\tuniforms.rectAreaLights.needsUpdate = value;\n\t\t\tuniforms.hemisphereLights.needsUpdate = value;\n\t\t}\n\n\t\tfunction materialNeedsLights(material) {\n\t\t\treturn material.isMeshLambertMaterial || material.isMeshToonMaterial || material.isMeshPhongMaterial || material.isMeshStandardMaterial || material.isShadowMaterial || material.isShaderMaterial && material.lights === true;\n\t\t} //\n\n\n\t\tthis.setFramebuffer = function (value) {\n\t\t\tif (_framebuffer !== value && _currentRenderTarget === null) _gl.bindFramebuffer(36160, value);\n\t\t\t_framebuffer = value;\n\t\t};\n\n\t\tthis.getActiveCubeFace = function () {\n\t\t\treturn _currentActiveCubeFace;\n\t\t};\n\n\t\tthis.getActiveMipmapLevel = function () {\n\t\t\treturn _currentActiveMipmapLevel;\n\t\t};\n\n\t\tthis.getRenderList = function () {\n\t\t\treturn currentRenderList;\n\t\t};\n\n\t\tthis.setRenderList = function (renderList) {\n\t\t\tcurrentRenderList = renderList;\n\t\t};\n\n\t\tthis.getRenderTarget = function () {\n\t\t\treturn _currentRenderTarget;\n\t\t};\n\n\t\tthis.setRenderTarget = function (renderTarget, activeCubeFace, activeMipmapLevel) {\n\t\t\tif (activeCubeFace === void 0) {\n\t\t\t\tactiveCubeFace = 0;\n\t\t\t}\n\n\t\t\tif (activeMipmapLevel === void 0) {\n\t\t\t\tactiveMipmapLevel = 0;\n\t\t\t}\n\n\t\t\t_currentRenderTarget = renderTarget;\n\t\t\t_currentActiveCubeFace = activeCubeFace;\n\t\t\t_currentActiveMipmapLevel = activeMipmapLevel;\n\n\t\t\tif (renderTarget && properties.get(renderTarget).__webglFramebuffer === undefined) {\n\t\t\t\ttextures.setupRenderTarget(renderTarget);\n\t\t\t}\n\n\t\t\tvar framebuffer = _framebuffer;\n\t\t\tvar isCube = false;\n\n\t\t\tif (renderTarget) {\n\t\t\t\tvar __webglFramebuffer = properties.get(renderTarget).__webglFramebuffer;
1\n\n\t\t\t\tif (renderTarget.isWebGLCubeRenderTarget) {\n\t\t\t\t\tframebuffer = __webglFramebuffer[activeCubeFace];\n\t\t\t\t\tisCube = true;\n\t\t\t\t} else if (renderTarget.isWebGLMultisampleRenderTarget) {\n\t\t\t\t\tframebuffer = properties.get(renderTarget).__webglMultisampledFramebuffer;\n\t\t\t\t} else {\n\t\t\t\t\tframebuffer = __webglFramebuffer;\n\t\t\t\t}\n\n\t\t\t\t_currentViewport.copy(renderTarget.viewport);\n\n\t\t\t\t_currentScissor.copy(renderTarget.scissor);\n\n\t\t\t\t_currentScissorTest = renderTarget.scissorTest;\n\t\t\t} else {\n\t\t\t\t_currentViewport.copy(_viewport).multiplyScalar(_pixelRatio).floor();\n\n\t\t\t\t_currentScissor.copy(_scissor).multiplyScalar(_pixelRatio).floor();\n\n\t\t\t\t_currentScissorTest = _scissorTest;\n\t\t\t}\n\n\t\t\tif (_currentFramebuffer !== framebuffer) {\n\t\t\t\t_gl.bindFramebuffer(36160, framebuffer);\n\n\t\t\t\t_currentFramebuffer = framebuffer;\n\t\t\t}\n\n\t\t\tstate.viewport(_currentViewport);\n\t\t\tstate.scissor(_currentScissor);\n\t\t\tstate.setScissorTest(_currentScissorTest);\n\n\t\t\tif (isCube) {\n\t\t\t\tvar textureProperties = properties.get(renderTarget.texture);\n\n\t\t\t\t_gl.framebufferTexture2D(36160, 36064, 34069 + activeCubeFace, textureProperties.__webglTexture, activeMipmapLevel);\n\t\t\t}\n\t\t};\n\n\t\tthis.readRenderTargetPixels = function (renderTarget, x, y, width, height, buffer, activeCubeFaceIndex) {\n\t\t\tif (!(renderTarget && renderTarget.isWebGLRenderTarget)) {\n\t\t\t\tconsole.error('THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar framebuffer = properties.get(renderTarget).__webglFramebuffer;\n\n\t\t\tif (renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined) {\n\t\t\t\tframebuffer = framebuffer[activeCubeFaceIndex];\n\t\t\t}\n\n\t\t\tif (framebuffer) {\n\t\t\t\tvar restore = false;\n\n\t\t\t\tif (framebuffer !== _currentFramebuffer) {\n\t\t\t\t\t_gl.bindFramebuffer(36160, framebuffer);\n\n\t\t\t\t\trestore = true;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tvar texture = renderTarget.texture;\n\t\t\t\t\tvar textureFormat = texture.format;\n\t\t\t\t\tvar textureType = texture.type;\n\n\t\t\t\t\tif (textureFormat !== RGBAFormat && utils.convert(textureFormat) !== _gl.getParameter(35739)) {\n\t\t\t\t\t\tconsole.error('THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.');\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (textureType !== UnsignedByteType && utils.convert(textureType) !== _gl.getParameter(35738) && // IE11, Edge and Chrome Mac < 52 (#9513)\n\t\t\t\t\t!(textureType === FloatType && (capabilities.isWebGL2 || extensions.get('OES_texture_float') || extensions.get('WEBGL_color_buffer_float'))) && // Chrome Mac >= 52 and Firefox\n\t\t\t\t\t!(textureType === HalfFloatType && (capabilities.isWebGL2 ? extensions.get('EXT_color_buffer_float') : extensions.get('EXT_color_buffer_half_float')))) {\n\t\t\t\t\t\tconsole.error('THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.');\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (_gl.checkFramebufferStatus(36160) === 36053) {\n\t\t\t\t\t\t// the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)\n\t\t\t\t\t\tif (x >= 0 && x <= renderTarget.width - width && y >= 0 && y <= renderTarget.height - height) {\n\t\t\t\t\t\t\t_gl.readPixels(x, y, width, height, utils.convert(textureFormat), utils.convert(textureType), buffer);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error('THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.');\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tif (restore) {\n\t\t\t\t\t\t_gl.bindFramebuffer(36160, _currentFramebuffer);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tthis.copyFramebufferToTexture = function (position, texture, level) {\n\t\t\tif (level === void 0) {\n\t\t\t\tlevel = 0;\n\t\t\t}\n\n\t\t\tvar levelScale = Math.pow(2, -level);\n\t\t\tvar width = Math.floor(texture.image.width * levelScale);\n\t\t\tvar height = Math.floor(texture.image.height * levelScale);\n\t\t\tvar glFormat = utils.convert(texture.format);\n\t\t\ttextures.setTexture2D(texture, 0);\n\n\t\t\t_gl.copyTexImage2D(3553, level, glFormat, position.x, position.y, width, height, 0);\n\n\t\t\tstate.unbindTexture();\n\t\t};\n\n\t\tthis.copyTextureToTexture = function (position, srcTexture, dstTexture, level) {\n\t\t\tif (level === void 0) {\n\t\t\t\tlevel = 0;\n\t\t\t}\n\n\t\t\tvar width = srcTexture.image.width;\n\t\t\tvar height = srcTexture.image.height;\n\t\t\tvar glFormat = utils.convert(dstTexture.format);\n\t\t\tvar glType = utils.convert(dstTexture.type);\n\t\t\ttextures.setTexture2D(dstTexture, 0); // As another texture upload may have changed pixelStorei\n\t\t\t// parameters, make sure they are correct for the dstTexture\n\n\t\t\t_gl.pixelStorei(37440, dstTexture.flipY);\n\n\t\t\t_gl.pixelStorei(37441, dstTexture.premultiplyAlpha);\n\n\t\t\t_gl.pixelStorei(3317, dstTexture.unpackAlignment);\n\n\t\t\tif (srcTexture.isDataTexture) {\n\t\t\t\t_gl.texSubImage2D(3553, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data);\n\t\t\t} else {\n\t\t\t\tif (srcTexture.isCompressedTexture) {\n\t\t\t\t\t_gl.compressedTexSubImage2D(3553, level, position.x, position.y, srcTexture.mipmaps[0].width, srcTexture.mipmaps[0].height, glFormat, srcTexture.mipmaps[0].data);\n\t\t\t\t} else {\n\t\t\t\t\t_gl.texSubImage2D(3553, level, position.x, position.y, glFormat, glType, srcTexture.image);\n\t\t\t\t}\n\t\t\t} // Generate mipmaps only when copying level 0\n\n\n\t\t\tif (level === 0 && dstTexture.generateMipmaps) _gl.generateMipmap(3553);\n\t\t\tstate.unbindTexture();\n\t\t};\n\n\t\tthis.initTexture = function (texture) {\n\t\t\ttextures.setTexture2D(texture, 0);\n\t\t\tstate.unbindTexture();\n\t\t};\n\n\t\tthis.resetState = function () {\n\t\t\tstate.reset();\n\t\t\tbindingStates.reset();\n\t\t};\n\n\t\tif (typeof __THREE_DEVTOOLS__ !== 'undefined') {\n\t\t\t__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', {\n\t\t\t\tdetail
1: this\n\t\t\t})); // eslint-disable-line no-undef\n\n\t\t}\n\t}\n\n\tfunction WebGL1Renderer(parameters) {\n\t\tWebGLRenderer.call(this, parameters);\n\t}\n\n\tWebGL1Renderer.prototype = Object.assign(Object.create(WebGLRenderer.prototype), {\n\t\tconstructor: WebGL1Renderer,\n\t\tisWebGL1Renderer: true\n\t});\n\n\tvar FogExp2 = /*#__PURE__*/function () {\n\t\tfunction FogExp2(color, density) {\n\t\t\tObject.defineProperty(this, 'isFogExp2', {\n\t\t\t\tvalue: true\n\t\t\t});\n\t\t\tthis.name = '';\n\t\t\tthis.color = new Color(color);\n\t\t\tthis.density = density !== undefined ? density : 0.00025;\n\t\t}\n\n\t\tvar _proto = FogExp2.prototype;\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new FogExp2(this.color, this.density);\n\t\t};\n\n\t\t_proto.toJSON = function toJSON()\n\t\t/* meta */\n\t\t{\n\t\t\treturn {\n\t\t\t\ttype: 'FogExp2',\n\t\t\t\tcolor: this.color.getHex(),\n\t\t\t\tdensity: this.density\n\t\t\t};\n\t\t};\n\n\t\treturn FogExp2;\n\t}();\n\n\tvar Fog = /*#__PURE__*/function () {\n\t\tfunction Fog(color, near, far) {\n\t\t\tObject.defineProperty(this, 'isFog', {\n\t\t\t\tvalue: true\n\t\t\t});\n\t\t\tthis.name = '';\n\t\t\tthis.color = new Color(color);\n\t\t\tthis.near = near !== undefined ? near : 1;\n\t\t\tthis.far = far !== undefined ? far : 1000;\n\t\t}\n\n\t\tvar _proto = Fog.prototype;\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new Fog(this.color, this.near, this.far);\n\t\t};\n\n\t\t_proto.toJSON = function toJSON()\n\t\t/* meta */\n\t\t{\n\t\t\treturn {\n\t\t\t\ttype: 'Fog',\n\t\t\t\tcolor: this.color.getHex(),\n\t\t\t\tnear: this.near,\n\t\t\t\tfar: this.far\n\t\t\t};\n\t\t};\n\n\t\treturn Fog;\n\t}();\n\n\tvar Scene = /*#__PURE__*/function (_Object3D) {\n\t\t_inheritsLoose(Scene, _Object3D);\n\n\t\tfunction Scene() {\n\t\t\tvar _this;\n\n\t\t\t_this = _Object3D.call(this) || this;\n\t\t\tObject.defineProperty(_assertThisInitialized(_this), 'isScene', {\n\t\t\t\tvalue: true\n\t\t\t});\n\t\t\t_this.type = 'Scene';\n\t\t\t_this.background = null;\n\t\t\t_this.environment = null;\n\t\t\t_this.fog = null;\n\t\t\t_this.overrideMaterial = null;\n\t\t\t_this.autoUpdate = true; // checked by the renderer\n\n\t\t\tif (typeof __THREE_DEVTOOLS__ !== 'undefined') {\n\t\t\t\t__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('observe', {\n\t\t\t\t\tdetail: _assertThisInitialized(_this)\n\t\t\t\t})); // eslint-disable-line no-undef\n\n\t\t\t}\n\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = Scene.prototype;\n\n\t\t_proto.copy = function copy(source, recursive) {\n\t\t\t_Object3D.prototype.copy.call(this, source, recursive);\n\n\t\t\tif (source.background !== null) this.background = source.background.clone();\n\t\t\tif (source.environment !== null) this.environment = source.environment.clone();\n\t\t\tif (source.fog !== null) this.fog = source.fog.clone();\n\t\t\tif (source.overrideMaterial !== null) this.overrideMaterial = source.overrideMaterial.clone();\n\t\t\tthis.autoUpdate = source.autoUpdate;\n\t\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.toJSON = function toJSON(meta) {\n\t\t\tvar data = _Object3D.prototype.toJSON.call(this, meta);\n\n\t\t\tif (this.background !== null) data.object.background = this.background.toJSON(meta);\n\t\t\tif (this.environment !== null) data.object.environment = this.environment.toJSON(meta);\n\t\t\tif (this.fog !== null) data.object.fog = this.fog.toJSON();\n\t\t\treturn data;\n\t\t};\n\n\t\treturn Scene;\n\t}(Object3D);\n\n\tfunction InterleavedBuffer(array, stride) {\n\t\tthis.array = array;\n\t\tthis.stride = stride;\n\t\tthis.count = array !== undefined ? array.length / stride : 0;\n\t\tthis.usage = StaticDrawUsage;\n\t\tthis.updateRange = {\n\t\t\toffset: 0,\n\t\t\tcount: -1\n\t\t};\n\t\tthis.version = 0;\n\t\tthis.uuid = MathUtils.generateUUID();\n\t}\n\n\tObject.defineProperty(InterleavedBuffer.prototype, 'needsUpdate', {\n\t\tset: function set(value) {\n\t\t\tif (value === true) this.version++;\n\t\t}\n\t});\n\tObject.assign(InterleavedBuffer.prototype, {\n\t\tisInterleavedBuffer: true,\n\t\tonUploadCallback: function onUploadCallback() {},\n\t\tsetUsage: function setUsage(value) {\n\t\t\tthis.usage = value;\n\t\t\treturn this;\n\t\t},\n\t\tcopy: function copy(source) {\n\t\t\tthis.array = new source.array.constructor(source.array);\n\t\t\tthis.count = source.count;\n\t\t\tthis.stride = source.stride;\n\t\t\tthis.usage = source.usage;\n\t\t\treturn this;\n\t\t},\n\t\tcopyAt: function copyAt(index1, attribute, index2) {\n\t\t\tindex1 *= this.stride;\n\t\t\tindex2 *= attribute.stride;\n\n\t\t\tfor (var i = 0, l = this.stride; i < l;
1 i++) {\n\t\t\t\tthis.array[index1 + i] = attribute.array[index2 + i];\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tset: function set(value, offset) {\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tthis.array.set(value, offset);\n\t\t\treturn this;\n\t\t},\n\t\tclone: function clone(data) {\n\t\t\tif (data.arrayBuffers === undefined) {\n\t\t\t\tdata.arrayBuffers = {};\n\t\t\t}\n\n\t\t\tif (this.array.buffer._uuid === undefined) {\n\t\t\t\tthis.array.buffer._uuid = MathUtils.generateUUID();\n\t\t\t}\n\n\t\t\tif (data.arrayBuffers[this.array.buffer._uuid] === undefined) {\n\t\t\t\tdata.arrayBuffers[this.array.buffer._uuid] = this.array.slice(0).buffer;\n\t\t\t}\n\n\t\t\tvar array = new this.array.constructor(data.arrayBuffers[this.array.buffer._uuid]);\n\t\t\tvar ib = new InterleavedBuffer(array, this.stride);\n\t\t\tib.setUsage(this.usage);\n\t\t\treturn ib;\n\t\t},\n\t\tonUpload: function onUpload(callback) {\n\t\t\tthis.onUploadCallback = callback;\n\t\t\treturn this;\n\t\t},\n\t\ttoJSON: function toJSON(data) {\n\t\t\tif (data.arrayBuffers === undefined) {\n\t\t\t\tdata.arrayBuffers = {};\n\t\t\t} // generate UUID for array buffer if necessary\n\n\n\t\t\tif (this.array.buffer._uuid === undefined) {\n\t\t\t\tthis.array.buffer._uuid = MathUtils.generateUUID();\n\t\t\t}\n\n\t\t\tif (data.arrayBuffers[this.array.buffer._uuid] === undefined) {\n\t\t\t\tdata.arrayBuffers[this.array.buffer._uuid] = Array.prototype.slice.call(new Uint32Array(this.array.buffer));\n\t\t\t} //\n\n\n\t\t\treturn {\n\t\t\t\tuuid: this.uuid,\n\t\t\t\tbuffer: this.array.buffer._uuid,\n\t\t\t\ttype: this.array.constructor.name,\n\t\t\t\tstride: this.stride\n\t\t\t};\n\t\t}\n\t});\n\n\tvar _vector$6 = new Vector3();\n\n\tfunction InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, normalized) {\n\t\tthis.name = '';\n\t\tthis.data = interleavedBuffer;\n\t\tthis.itemSize = itemSize;\n\t\tthis.offset = offset;\n\t\tthis.normalized = normalized === true;\n\t}\n\n\tObject.defineProperties(InterleavedBufferAttribute.prototype, {\n\t\tcount: {\n\t\t\tget: function get() {\n\t\t\t\treturn this.data.count;\n\t\t\t}\n\t\t},\n\t\tarray: {\n\t\t\tget: function get() {\n\t\t\t\treturn this.data.array;\n\t\t\t}\n\t\t},\n\t\tneedsUpdate: {\n\t\t\tset: function set(value) {\n\t\t\t\tthis.data.needsUpdate = value;\n\t\t\t}\n\t\t}\n\t});\n\tObject.assign(InterleavedBufferAttribute.prototype, {\n\t\tisInterleavedBufferAttribute: true,\n\t\tapplyMatrix4: function applyMatrix4(m) {\n\t\t\tfor (var i = 0, l = this.data.count; i < l; i++) {\n\t\t\t\t_vector$6.x = this.getX(i);\n\t\t\t\t_vector$6.y = this.getY(i);\n\t\t\t\t_vector$6.z = this.getZ(i);\n\n\t\t\t\t_vector$6.applyMatrix4(m);\n\n\t\t\t\tthis.setXYZ(i, _vector$6.x, _vector$6.y, _vector$6.z);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tsetX: function setX(index, x) {\n\t\t\tthis.data.array[index * this.data.stride + this.offset] = x;\n\t\t\treturn this;\n\t\t},\n\t\tsetY: function setY(index, y) {\n\t\t\tthis.data.array[index * this.data.stride + this.offset + 1] = y;\n\t\t\treturn this;\n\t\t},\n\t\tsetZ: function setZ(index, z) {\n\t\t\tthis.data.array[index * this.data.stride + this.offset + 2] = z;\n\t\t\treturn this;\n\t\t},\n\t\tsetW: function setW(index, w) {\n\t\t\tthis.data.array[index * this.data.stride + this.offset + 3] = w;\n\t\t\treturn this;\n\t\t},\n\t\tgetX: function getX(index) {\n\t\t\treturn this.data.array[index * this.data.stride + this.offset];\n\t\t},\n\t\tgetY: function getY(index) {\n\t\t\treturn this.data.array[index * this.data.stride + this.offset + 1];\n\t\t},\n\t\tgetZ: function getZ(index) {\n\t\t\treturn this.data.array[index * this.data.stride + this.offset + 2];\n\t\t},\n\t\tgetW: function getW(index) {\n\t\t\treturn this.data.array[index * this.data.stride + this.offset + 3];\n\t\t},\n\t\tsetXY: function setXY(index, x, y) {\n\t\t\tindex = index * this.data.stride + this.offset;\n\t\t\tthis.data.array[index + 0] = x;\n\t\t\tthis.data.array[index + 1] = y;\n\t\t\treturn this;\n\t\t},\n\t\tsetXYZ: function setXYZ(index, x, y, z) {\n\t\t\tindex = index * this.data.stride + this.offset;\n\t\t\tthis.data.array[index + 0] = x;\n\t\t\tthis.data.array[index + 1] = y;\n\t\t\tthis.data.array[index + 2] = z;\n\t\t\treturn this;\n\t\t},\n\t\tsetXYZW: function setXYZW(index, x, y, z, w) {\n\t\t\tindex = index * this.data.stride + this.offset;\n\t\t\tthis.data.array[index + 0] = x;\n\t\t\tthis.data.array[index + 1] = y;\n\t\t\tthis.data.array[index + 2] = z;\n\t\t\tthis.data.array[index + 3] = w;\n\t\t\treturn this;\n\t\t}
1,\n\t\tclone: function clone(data) {\n\t\t\tif (data === undefined) {\n\t\t\t\tconsole.log('THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.');\n\t\t\t\tvar array = [];\n\n\t\t\t\tfor (var i = 0; i < this.count; i++) {\n\t\t\t\t\tvar index = i * this.data.stride + this.offset;\n\n\t\t\t\t\tfor (var j = 0; j < this.itemSize; j++) {\n\t\t\t\t\t\tarray.push(this.data.array[index + j]);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new BufferAttribute(new this.array.constructor(array), this.itemSize, this.normalized);\n\t\t\t} else {\n\t\t\t\tif (data.interleavedBuffers === undefined) {\n\t\t\t\t\tdata.interleavedBuffers = {};\n\t\t\t\t}\n\n\t\t\t\tif (data.interleavedBuffers[this.data.uuid] === undefined) {\n\t\t\t\t\tdata.interleavedBuffers[this.data.uuid] = this.data.clone(data);\n\t\t\t\t}\n\n\t\t\t\treturn new InterleavedBufferAttribute(data.interleavedBuffers[this.data.uuid], this.itemSize, this.offset, this.normalized);\n\t\t\t}\n\t\t},\n\t\ttoJSON: function toJSON(data) {\n\t\t\tif (data === undefined) {\n\t\t\t\tconsole.log('THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.');\n\t\t\t\tvar array = [];\n\n\t\t\t\tfor (var i = 0; i < this.count; i++) {\n\t\t\t\t\tvar index = i * this.data.stride + this.offset;\n\n\t\t\t\t\tfor (var j = 0; j < this.itemSize; j++) {\n\t\t\t\t\t\tarray.push(this.data.array[index + j]);\n\t\t\t\t\t}\n\t\t\t\t} // deinterleave data and save it as an ordinary buffer attribute for now\n\n\n\t\t\t\treturn {\n\t\t\t\t\titemSize: this.itemSize,\n\t\t\t\t\ttype: this.array.constructor.name,\n\t\t\t\t\tarray: array,\n\t\t\t\t\tnormalized: this.normalized\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\t// save as true interlaved attribtue\n\t\t\t\tif (data.interleavedBuffers === undefined) {\n\t\t\t\t\tdata.interleavedBuffers = {};\n\t\t\t\t}\n\n\t\t\t\tif (data.interleavedBuffers[this.data.uuid] === undefined) {\n\t\t\t\t\tdata.interleavedBuffers[this.data.uuid] = this.data.toJSON(data);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tisInterleavedBufferAttribute: true,\n\t\t\t\t\titemSize: this.itemSize,\n\t\t\t\t\tdata: this.data.uuid,\n\t\t\t\t\toffset: this.offset,\n\t\t\t\t\tnormalized: this.normalized\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t});\n\n\t/**\n\t * parameters = {\n\t *\tcolor: <hex>,\n\t *\tmap: new THREE.Texture( <Image> ),\n\t *\talphaMap: new THREE.Texture( <Image> ),\n\t *\trotation: <float>,\n\t *\tsizeAttenuation: <bool>\n\t * }\n\t */\n\n\tfunction SpriteMaterial(parameters) {\n\t\tMaterial.call(this);\n\t\tthis.type = 'SpriteMaterial';\n\t\tthis.color = new Color(0xffffff);\n\t\tthis.map = null;\n\t\tthis.alphaMap = null;\n\t\tthis.rotation = 0;\n\t\tthis.sizeAttenuation = true;\n\t\tthis.transparent = true;\n\t\tthis.setValues(parameters);\n\t}\n\n\tSpriteMaterial.prototype = Object.create(Material.prototype);\n\tSpriteMaterial.prototype.constructor = SpriteMaterial;\n\tSpriteMaterial.prototype.isSpriteMaterial = true;\n\n\tSpriteMaterial.prototype.copy = function (source) {\n\t\tMaterial.prototype.copy.call(this, source);\n\t\tthis.color.copy(source.color);\n\t\tthis.map = source.map;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.rotation = source.rotation;\n\t\tthis.sizeAttenuation = source.sizeAttenuation;\n\t\treturn this;\n\t};\n\n\tvar _geometry;\n\n\tvar _intersectPoint = new Vector3();\n\n\tvar _worldScale = new Vector3();\n\n\tvar _mvPosition = new Vector3();\n\n\tvar _alignedPosition = new Vector2();\n\n\tvar _rotatedPosition = new Vector2();\n\n\tvar _viewWorldMatrix = new Matrix4();\n\n\tvar _vA$1 = new Vector3();\n\n\tvar _vB$1 = new Vector3();\n\n\tvar _vC$1 = new Vector3();\n\n\tvar _uvA$1 = new Vector2();\n\n\tvar _uvB$1 = new Vector2();\n\n\tvar _uvC$1 = new Vector2();\n\n\tfunction Sprite(material) {\n\t\tObject3D.call(this);\n\t\tthis.type = 'Sprite';\n\n\t\tif (_geometry === undefined) {\n\t\t\t_geometry = new BufferGeometry();\n\t\t\tvar float32Array = new Float32Array([-0.5, -0.5, 0, 0, 0, 0.5, -0.5, 0, 1, 0, 0.5, 0.5, 0, 1, 1, -0.5, 0.5, 0, 0, 1]);\n\t\t\tvar interleavedBuffer = new InterleavedBuffer(float32Array, 5);\n\n\t\t\t_geometry.setIndex([0, 1, 2, 0, 2, 3]);\n\n\t\t\t_geometry.setAttribute('position', new InterleavedBufferAttribute(interleavedBuffer, 3, 0, false));\n\n\t\t\t_geometry.setAttribute('uv', new InterleavedBufferAttribute(interleavedBuffer, 2, 3, false));\n\t\t}\n\n\t\tthis.geometry = _geometry;\n\t\tthis.material = material !== undefined ? material : new SpriteMaterial();\n\t\tthis.center = new Vector2(0.5, 0.5);\n\t}\n\n\tSprite.prototype = Object.assign(Object.create(Object3D.prototype), {\n\t\tconstructor: Sprite,\n\t\tisSprite: true,\n\t\traycast: function raycast(raycaster, intersects) {\n\t\t\tif (raycaster.camera === null) {\n\t\t\t\tconsole.error('THREE.Sprite: \"Raycaster.camera\" needs to be set in order to raycast against sprites.');\n\t\t\t}\n\n\t\t\t_worldScale.setFromMatrixScale(this.matrixWorld);\n\n\t\t\t_viewWorldMatrix.copy(raycaster.camera.matrixWorld);\n\n\t\t\tthis.modelViewMatrix.multiplyMatrices(raycaster.camera.matrixWorldInverse, this.matrixWorld);\n\n\t\t\t_mvPosition.setFromMatrixPosition(this.modelViewMatrix);\n\n\t\t\tif (raycaster.camera.isPerspectiveCamera && this.material.sizeAttenuation === false) {\n\t\t\t\t_worldScale.multiplyScalar(-_mvPosition.z);\n\t\t\t}\n\n\t\t\tvar rotation = this.material.rotation;\n\t\t\tvar sin, cos;\n\n\t\t\tif (rotation !== 0) {\n\t\t\t\tcos = Math.cos(rotation);\n\t\t\t\tsin = Math.sin(rotation);\n\t\t\t}\n\n\t\t\tvar center = this.center;\n\t\t\ttransformVertex(_vA$1.set(-0.5, -0.5, 0), _mvPosition, center, _worldScale, sin, cos);\n\t\t\ttransformVertex(_vB$1.set(0.5, -0.5, 0), _mvPosition, center, _worldScale, sin, cos);\n\t\t\ttransformVertex(_vC$1.set(0.5, 0.5, 0), _mvPosition, center, _worldScale, sin, cos);\n\n\t\t\t_uvA$1.set(0, 0);\n\n\t\t\t_uvB$1.set(1, 0);\n\n\t\t\t_uvC$1.set(1, 1); // check first triangle\n\n\n\t\t\tvar intersect = raycaster.ray.intersectTriangle(_vA$1, _vB$1, _vC$1, false, _intersectPoint);\n\n\t\t\tif (intersect === null) {\n\t\t\t\t// check second triangle\n\t\t\t\ttransformVertex(_vB$1.set(-0.5, 0.5, 0), _mvPosition, center, _worldScale, sin, cos);\n\n\t\t\t\t_uvB$1.set(0, 1);\n\n\t\t\t\tintersect = raycaster.ray.intersectTriangle(_vA$1, _vC$1, _vB$1, false, _intersectPoint);\n\n\t\t\t\tif (intersect === null) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar distance = raycaster.ray.origin.distanceTo(_intersectPoint);\n\t\t\tif (distance < raycaster.near || distance > raycaster.far) return;\n\t\t\tintersects.push({\n\t\t\t\tdistance: distance,\n\t\t\t\tpoint: _intersectPoint.clone(),\n\t\t\t\tuv: Triangle.getUV(_intersectPoint, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2()),\n\t\t\t\tface: null,\n\t\t\t\tobject: this\n\t\t\t});\n\t\t},\n\t\tcopy: function copy(source) {\n\t\t\tObject3D.prototype.copy.call(this, source);\n\t\t\tif (source.center !== undefined) this.center.copy(source.center);\n\t\t\tthis.material = source.material;\n\t\t\treturn this;\n\t\t}\n\t});\n\n\tfunction transformVertex(vertexPosition, mvPosition, center, scale, sin, cos) {\
1n\t\t// compute position in camera space\n\t\t_alignedPosition.subVectors(vertexPosition, center).addScalar(0.5).multiply(scale); // to check if rotation is not zero\n\n\n\t\tif (sin !== undefined) {\n\t\t\t_rotatedPosition.x = cos * _alignedPosition.x - sin * _alignedPosition.y;\n\t\t\t_rotatedPosition.y = sin * _alignedPosition.x + cos * _alignedPosition.y;\n\t\t} else {\n\t\t\t_rotatedPosition.copy(_alignedPosition);\n\t\t}\n\n\t\tvertexPosition.copy(mvPosition);\n\t\tvertexPosition.x += _rotatedPosition.x;\n\t\tvertexPosition.y += _rotatedPosition.y; // transform to world space\n\n\t\tvertexPosition.applyMatrix4(_viewWorldMatrix);\n\t}\n\n\tvar _v1$4 = new Vector3();\n\n\tvar _v2$2 = new Vector3();\n\n\tfunction LOD() {\n\t\tObject3D.call(this);\n\t\tthis._currentLevel = 0;\n\t\tthis.type = 'LOD';\n\t\tObject.defineProperties(this, {\n\t\t\tlevels: {\n\t\t\t\tenumerable: true,\n\t\t\t\tvalue: []\n\t\t\t}\n\t\t});\n\t\tthis.autoUpdate = true;\n\t}\n\n\tLOD.prototype = Object.assign(Object.create(Object3D.prototype), {\n\t\tconstructor: LOD,\n\t\tisLOD: true,\n\t\tcopy: function copy(source) {\n\t\t\tObject3D.prototype.copy.call(this, source, false);\n\t\t\tvar levels = source.levels;\n\n\t\t\tfor (var i = 0, l = levels.length; i < l; i++) {\n\t\t\t\tvar level = levels[i];\n\t\t\t\tthis.addLevel(level.object.clone(), level.distance);\n\t\t\t}\n\n\t\t\tthis.autoUpdate = source.autoUpdate;\n\t\t\treturn this;\n\t\t},\n\t\taddLevel: function addLevel(object, distance) {\n\t\t\tif (distance === void 0) {\n\t\t\t\tdistance = 0;\n\t\t\t}\n\n\t\t\tdistance = Math.abs(distance);\n\t\t\tvar levels = this.levels;\n\t\t\tvar l;\n\n\t\t\tfor (l = 0; l < levels.length; l++) {\n\t\t\t\tif (distance < levels[l].distance) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlevels.splice(l, 0, {\n\t\t\t\tdistance: distance,\n\t\t\t\tobject: object\n\t\t\t});\n\t\t\tthis.add(object);\n\t\t\treturn this;\n\t\t},\n\t\tgetCurrentLevel: function getCurrentLevel() {\n\t\t\treturn this._currentLevel;\n\t\t},\n\t\tgetObjectForDistance: function getObjectForDistance(distance) {\n\t\t\tvar levels = this.levels;\n\n\t\t\tif (levels.length > 0) {\n\t\t\t\tvar i, l;\n\n\t\t\t\tfor (i = 1, l = levels.length; i < l; i++) {\n\t\t\t\t\tif (distance < levels[i].distance) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn levels[i - 1].object;\n\t\t\t}\n\n\t\t\treturn null;\n\t\t},\n\t\traycast: function raycast(raycaster, intersects) {\n\t\t\tvar levels = this.levels;\n\n\t\t\tif (levels.length > 0) {\n\t\t\t\t_v1$4.setFromMatrixPosition(this.matrixWorld);\n\n\t\t\t\tvar distance = raycaster.ray.origin.distanceTo(_v1$4);\n\t\t\t\tthis.getObjectForDistance(distance).raycast(raycaster, intersects);\n\t\t\t}\n\t\t},\n\t\tupdate: function update(camera) {\n\t\t\tvar levels = this.levels;\n\n\t\t\tif (levels.length > 1) {\n\t\t\t\t_v1$4.setFromMatrixPosition(camera.matrixWorld);\n\n\t\t\t\t_v2$2.setFromMatrixPosition(this.matrixWorld);\n\n\t\t\t\tvar distance = _v1$4.distanceTo(_v2$2) / camera.zoom;\n\t\t\t\tlevels[0].object.visible = true;\n\t\t\t\tvar i, l;\n\n\t\t\t\tfor (i = 1, l = levels.length; i < l; i++) {\n\t\t\t\t\tif (distance >= levels[i].distance) {\n\t\t\t\t\t\tlevels[i - 1].object.visible = false;\n\t\t\t\t\t\tlevels[i].object.visible = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis._currentLevel = i - 1;\n\n\t\t\t\tfor (; i < l; i++) {\n\t\t\t\t\tlevels[i].object.visible = false;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\ttoJSON: function toJSON(meta) {\n\t\t\tvar data = Object3D.prototype.toJSON.call(this, meta);\n\t\t\tif (this.autoUpdate === false) data.object.autoUpdate = false;\n\t\t\tdata.object.levels = [];\n\t\t\tvar levels = this.levels;\n\n\t\t\tfor (var i = 0, l = levels.length; i < l; i++) {\n\t\t\t\tvar level = levels[i];\n\t\t\t\tdata.object.levels.push({\n\t\t\t\t\tobject: level.object.uuid,\n\t\t\t\t\tdistance: level.distance\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn data;\n\t\t}\n\t});\n\n\tvar _basePosition = new Vector3();\n\n\tvar _skinIndex = new Vector4();\n\n\tvar _skinWeight = new Vector4();\n\n\tvar _vector$7 = new Vector3();\n\n\tvar _matrix$1 = new Matrix4();\n\n\tfunction SkinnedMesh(geometry, material) {\n\t\tif (geometry && geometry.isGeometry) {\n\t\t\tconsole.error('THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.');\n\t\t}\n\n\t\tMesh.call(this, geometry, material);\n\t\tthis.type = 'SkinnedMesh';\n\t\tthis.bindMode = 'attached';\n\t\tthis.bindMatrix = new Matrix4();\n\t\tthis.bindMatrixInverse = new Matrix4();\n\t}\n\n\tSkinnedMesh.prototype = Object.assign(Object.create(Mesh.prototype), {\n\t\tconstructor: SkinnedMesh,\n\t\tisSkinnedMesh: true,\n\t\tcopy: function copy(source) {\n\t\t\tMesh.prototype.copy.call(this, source);\n\t\t\tthis.bindMode = source.bindMode;\n\t\t\tthis.bindMatrix.copy(source.bindMatrix);\n\t\t\tthis.bindMatrixInverse.copy(source.bindMatrixInverse);\n\t\t\tthis.skeleton = source.skeleton;\n\t\t\treturn this;\n\t\t},\n\t\tbind: function bind(skeleton, bindMatrix) {\n\t\t\tthis.skeleton = skeleton;\n\n\t\t\tif (bindMatrix === undefined) {\n\t\t\t\tthis.updateMatrixWorld(true);\n\t\t\t\tthis.skeleton.calculateInverses();\n\t\t\t\tbindMatrix = this.matrixWorld;\n\t\t\t}\n\n\t\t\tthis.bindMatrix.copy(bindMatrix);\n\t\t\tthis.bindMatrixInverse.copy(bindMatrix).invert();\n\t\t},\n\t\tpose: function pose() {\n\t\t\tthis.skeleton.pose();\n\t\t},\n\t\tnormalizeSkinWeights: function normalizeSkinWeights() {\n\t\t\tvar vector = new Vector4();\n\t\t\tvar skinWeight = this.geometry.attributes.skinWeight;\n\n\t\t\tfor (var i = 0, l = skinWeight.count; i < l;
1 i++) {\n\t\t\t\tvector.x = skinWeight.getX(i);\n\t\t\t\tvector.y = skinWeight.getY(i);\n\t\t\t\tvector.z = skinWeight.getZ(i);\n\t\t\t\tvector.w = skinWeight.getW(i);\n\t\t\t\tvar scale = 1.0 / vector.manhattanLength();\n\n\t\t\t\tif (scale !== Infinity) {\n\t\t\t\t\tvector.multiplyScalar(scale);\n\t\t\t\t} else {\n\t\t\t\t\tvector.set(1, 0, 0, 0); // do something reasonable\n\t\t\t\t}\n\n\t\t\t\tskinWeight.setXYZW(i, vector.x, vector.y, vector.z, vector.w);\n\t\t\t}\n\t\t},\n\t\tupdateMatrixWorld: function updateMatrixWorld(force) {\n\t\t\tMesh.prototype.updateMatrixWorld.call(this, force);\n\n\t\t\tif (this.bindMode === 'attached') {\n\t\t\t\tthis.bindMatrixInverse.copy(this.matrixWorld).invert();\n\t\t\t} else if (this.bindMode === 'detached') {\n\t\t\t\tthis.bindMatrixInverse.copy(this.bindMatrix).invert();\n\t\t\t} else {\n\t\t\t\tconsole.warn('THREE.SkinnedMesh: Unrecognized bindMode: ' + this.bindMode);\n\t\t\t}\n\t\t},\n\t\tboneTransform: function boneTransform(index, target) {\n\t\t\tvar skeleton = this.skeleton;\n\t\t\tvar geometry = this.geometry;\n\n\t\t\t_skinIndex.fromBufferAttribute(geometry.attributes.skinIndex, index);\n\n\t\t\t_skinWeight.fromBufferAttribute(geometry.attributes.skinWeight, index);\n\n\t\t\t_basePosition.fromBufferAttribute(geometry.attributes.position, index).applyMatrix4(this.bindMatrix);\n\n\t\t\ttarget.set(0, 0, 0);\n\n\t\t\tfor (var i = 0; i < 4; i++) {\n\t\t\t\tvar weight = _skinWeight.getComponent(i);\n\n\t\t\t\tif (weight !== 0) {\n\t\t\t\t\tvar boneIndex = _skinIndex.getComponent(i);\n\n\t\t\t\t\t_matrix$1.multiplyMatrices(skeleton.bones[boneIndex].matrixWorld, skeleton.boneInverses[boneIndex]);\n\n\t\t\t\t\ttarget.addScaledVector(_vector$7.copy(_basePosition).applyMatrix4(_matrix$1), weight);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn target.applyMatrix4(this.bindMatrixInverse);\n\t\t}\n\t});\n\n\tfunction Bone() {\n\t\tObject3D.call(this);\n\t\tthis.type = 'Bone';\n\t}\n\n\tBone.prototype = Object.assign(Object.create(Object3D.prototype), {\n\t\tconstructor: Bone,\n\t\tisBone: true\n\t});\n\n\tvar _offsetMatrix = new Matrix4();\n\n\tvar _identityMatrix = new Matrix4();\n\n\tfunction Skeleton(bones, boneInverses) {\n\t\tif (bones === void 0) {\n\t\t\tbones = [];\n\t\t}\n\n\t\tif (boneInverses === void 0) {\n\t\t\tboneInverses = [];\n\t\t}\n\n\t\tthis.uuid = MathUtils.generateUUID();\n\t\tthis.bones = bones.slice(0);\n\t\tthis.boneInverses = boneInverses;\n\t\tthis.boneMatrices = null;\n\t\tthis.boneTexture = null;\n\t\tthis.boneTextureSize = 0;\n\t\tthis.frame = -1;\n\t\tthis.init();\n\t}\n\n\tObject.assign(Skeleton.prototype, {\n\t\tinit: function init() {\n\t\t\tvar bones = this.bones;\n\t\t\tvar boneInverses = this.boneInverses;\n\t\t\tthis.boneMatrices = new Float32Array(bones.length * 16); // calculate inverse bone matrices if necessary\n\n\t\t\tif (boneInverses.length === 0) {\n\t\t\t\tthis.calculateInverses();\n\t\t\t} else {\n\t\t\t\t// handle special case\n\t\t\t\tif (bones.length !== boneInverses.length) {\n\t\t\t\t\tconsole.warn('THREE.Skeleton: Number of inverse bone matrices does not match amount of bones.');\n\t\t\t\t\tthis.boneInverses = [];\n\n\t\t\t\t\tfor (var i = 0, il = this.bones.length; i < il; i++) {\n\t\t\t\t\t\tthis.boneInverses.push(new Matrix4());\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tcalculateInverses: function calculateInverses() {\n\t\t\tthis.boneInverses.length = 0;\n\n\t\t\tfor (var i = 0, il = this.bones.length; i < il; i++) {\n\t\t\t\tvar inverse = new Matrix4();\n\n\t\t\t\tif (this.bones[i]) {\n\t\t\t\t\tinverse.copy(this.bones[i].matrixWorld).invert();\n\t\t\t\t}\n\n\t\t\t\tthis.boneInverses.push(inverse);\n\t\t\t}\n\t\t},\n\t\tpose: function pose() {\n\t\t\t// recover the bind-time world matrices\n\t\t\tfor (var i = 0, il = this.bones.length; i < il; i++) {\n\t\t\t\tvar bone = this.bones[i];\n\n\t\t\t\tif (bone) {\n\t\t\t\t\tbone.matrixWorld.copy(this.boneInverses[i]).invert();\n\t\t\t\t}\n\t\t\t} // compute the local matrices, positions, rotations and scales\n\n\n\t\t\tfor (var _i = 0, _il = this.bones.length; _i < _il; _i++) {\n\t\t\t\tvar _bone = this.bones[_i];\n\n\t\t\t\tif (_bone) {\n\t\t\t\t\tif (_bone.parent && _bone.parent.isBone) {\n\t\t\t\t\t\t_bone.matrix.copy(_bone.parent.matrixWorld).invert();\n\n\t\t\t\t\t\t_bone.matrix.multiply(_bone.matrixWorld);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t_bone.matrix.copy(_bone.matrixWorld);\n\t\t\t\t\t}\n\n\t\t\t\t\t_bone.matrix.decompose(_bone.position, _bone.quaternion, _bone.scale);\n\t\t\t\t}\n\t\t\t}\n\t\t}
1,\n\t\tupdate: function update() {\n\t\t\tvar bones = this.bones;\n\t\t\tvar boneInverses = this.boneInverses;\n\t\t\tvar boneMatrices = this.boneMatrices;\n\t\t\tvar boneTexture = this.boneTexture; // flatten bone matrices to array\n\n\t\t\tfor (var i = 0, il = bones.length; i < il; i++) {\n\t\t\t\t// compute the offset between the current and the original transform\n\t\t\t\tvar matrix = bones[i] ? bones[i].matrixWorld : _identityMatrix;\n\n\t\t\t\t_offsetMatrix.multiplyMatrices(matrix, boneInverses[i]);\n\n\t\t\t\t_offsetMatrix.toArray(boneMatrices, i * 16);\n\t\t\t}\n\n\t\t\tif (boneTexture !== null) {\n\t\t\t\tboneTexture.needsUpdate = true;\n\t\t\t}\n\t\t},\n\t\tclone: function clone() {\n\t\t\treturn new Skeleton(this.bones, this.boneInverses);\n\t\t},\n\t\tgetBoneByName: function getBoneByName(name) {\n\t\t\tfor (var i = 0, il = this.bones.length; i < il; i++) {\n\t\t\t\tvar bone = this.bones[i];\n\n\t\t\t\tif (bone.name === name) {\n\t\t\t\t\treturn bone;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t},\n\t\tdispose: function dispose() {\n\t\t\tif (this.boneTexture !== null) {\n\t\t\t\tthis.boneTexture.dispose();\n\t\t\t\tthis.boneTexture = null;\n\t\t\t}\n\t\t},\n\t\tfromJSON: function fromJSON(json, bones) {\n\t\t\tthis.uuid = json.uuid;\n\n\t\t\tfor (var i = 0, l = json.bones.length; i < l; i++) {\n\t\t\t\tvar uuid = json.bones[i];\n\t\t\t\tvar bone = bones[uuid];\n\n\t\t\t\tif (bone === undefined) {\n\t\t\t\t\tconsole.warn('THREE.Skeleton: No bone found with UUID:', uuid);\n\t\t\t\t\tbone = new Bone();\n\t\t\t\t}\n\n\t\t\t\tthis.bones.push(bone);\n\t\t\t\tthis.boneInverses.push(new Matrix4().fromArray(json.boneInverses[i]));\n\t\t\t}\n\n\t\t\tthis.init();\n\t\t\treturn this;\n\t\t},\n\t\ttoJSON: function toJSON() {\n\t\t\tvar data = {\n\t\t\t\tmetadata: {\n\t\t\t\t\tversion: 4.5,\n\t\t\t\t\ttype: 'Skeleton',\n\t\t\t\t\tgenerator: 'Skeleton.toJSON'\n\t\t\t\t},\n\t\t\t\tbones: [],\n\t\t\t\tboneInverses: []\n\t\t\t};\n\t\t\tdata.uuid = this.uuid;\n\t\t\tvar bones = this.bones;\n\t\t\tvar boneInverses = this.boneInverses;\n\n\t\t\tfor (var i = 0, l = bones.length; i < l; i++) {\n\t\t\t\tvar bone = bones[i];\n\t\t\t\tdata.bones.push(bone.uuid);\n\t\t\t\tvar boneInverse = boneInverses[i];\n\t\t\t\tdata.boneInverses.push(boneInverse.toArray());\n\t\t\t}\n\n\t\t\treturn data;\n\t\t}\n\t});\n\n\tvar _instanceLocalMatrix = new Matrix4();\n\n\tvar _instanceWorldMatrix = new Matrix4();\n\n\tvar _instanceIntersects = [];\n\n\tvar _mesh = new Mesh();\n\n\tfunction InstancedMesh(geometry, material, count) {\n\t\tMesh.call(this, geometry, material);\n\t\tthis.instanceMatrix = new BufferAttribute(new Float32Array(count * 16), 16);\n\t\tthis.instanceColor = null;\n\t\tthis.count = count;\n\t\tthis.frustumCulled = false;\n\t}\n\n\tInstancedMesh.prototype = Object.assign(Object.create(Mesh.prototype), {\n\t\tconstructor: InstancedMesh,\n\t\tisInstancedMesh: true,\n\t\tcopy: function copy(source) {\n\t\t\tMesh.prototype.copy.call(this, source);\n\t\t\tthis.instanceMatrix.copy(source.instanceMatrix);\n\t\t\tthis.count = source.count;\n\t\t\treturn this;\n\t\t},\n\t\tgetColorAt: function getColorAt(index, color) {\n\t\t\tcolor.fromArray(this.instanceColor.array, index * 3);\n\t\t},\n\t\tgetMatrixAt: function getMatrixAt(index, matrix) {\n\t\t\tmatrix.fromArray(this.instanceMatrix.array, index * 16);\n\t\t},\n\t\traycast: function raycast(raycaster, intersects) {\n\t\t\tvar matrixWorld = this.matrixWorld;\n\t\t\tvar raycastTimes = this.count;\n\t\t\t_mesh.geometry = this.geometry;\n\t\t\t_mesh.material = this.material;\n\t\t\tif (_mesh.material === undefined) return;\n\n\t\t\tfor (var instanceId = 0; instanceId < raycastTimes; instanceId++) {\n\t\t\t\t// calculate the world matrix for each instance\n\t\t\t\tthis.getMatrixAt(instanceId, _instanceLocalMatrix);\n\n\t\t\t\t_instanceWorldMatrix.multiplyMatrices(matrixWorld, _instanceLocalMatrix); // the mesh represents this single instance\n\n\n\t\t\t\t_mesh.matrixWorld = _instanceWorldMatrix;\n\n\t\t\t\t_mesh.raycast(raycaster, _instanceIntersects); // process the result of raycast\n\n\n\t\t\t\tfor (var i = 0, l = _instanceIntersects.length; i < l;
1 i++) {\n\t\t\t\t\tvar intersect = _instanceIntersects[i];\n\t\t\t\t\tintersect.instanceId = instanceId;\n\t\t\t\t\tintersect.object = this;\n\t\t\t\t\tintersects.push(intersect);\n\t\t\t\t}\n\n\t\t\t\t_instanceIntersects.length = 0;\n\t\t\t}\n\t\t},\n\t\tsetColorAt: function setColorAt(index, color) {\n\t\t\tif (this.instanceColor === null) {\n\t\t\t\tthis.instanceColor = new BufferAttribute(new Float32Array(this.count * 3), 3);\n\t\t\t}\n\n\t\t\tcolor.toArray(this.instanceColor.array, index * 3);\n\t\t},\n\t\tsetMatrixAt: function setMatrixAt(index, matrix) {\n\t\t\tmatrix.toArray(this.instanceMatrix.array, index * 16);\n\t\t},\n\t\tupdateMorphTargets: function updateMorphTargets() {},\n\t\tdispose: function dispose() {\n\t\t\tthis.dispatchEvent({\n\t\t\t\ttype: 'dispose'\n\t\t\t});\n\t\t}\n\t});\n\n\t/**\n\t * parameters = {\n\t *\tcolor: <hex>,\n\t *\topacity: <float>,\n\t *\n\t *\tlinewidth: <float>,\n\t *\tlinecap: \"round\",\n\t *\tlinejoin: \"round\"\n\t * }\n\t */\n\n\tfunction LineBasicMaterial(parameters) {\n\t\tMaterial.call(this);\n\t\tthis.type = 'LineBasicMaterial';\n\t\tthis.color = new Color(0xffffff);\n\t\tthis.linewidth = 1;\n\t\tthis.linecap = 'round';\n\t\tthis.linejoin = 'round';\n\t\tthis.morphTargets = false;\n\t\tthis.setValues(parameters);\n\t}\n\n\tLineBasicMaterial.prototype = Object.create(Material.prototype);\n\tLineBasicMaterial.prototype.constructor = LineBasicMaterial;\n\tLineBasicMaterial.prototype.isLineBasicMaterial = true;\n\n\tLineBasicMaterial.prototype.copy = function (source) {\n\t\tMaterial.prototype.copy.call(this, source);\n\t\tthis.color.copy(source.color);\n\t\tthis.linewidth = source.linewidth;\n\t\tthis.linecap = source.linecap;\n\t\tthis.linejoin = source.linejoin;\n\t\tthis.morphTargets = source.morphTargets;\n\t\treturn this;\n\t};\n\n\tvar _start = new Vector3();\n\n\tvar _end = new Vector3();\n\n\tvar _inverseMatrix$1 = new Matrix4();\n\n\tvar _ray$1 = new Ray();\n\n\tvar _sphere$2 = new Sphere();\n\n\tfunction Line(geometry, material) {\n\t\tif (geometry === void 0) {\n\t\t\tgeometry = new BufferGeometry();\n\t\t}\n\n\t\tif (material === void 0) {\n\t\t\tmaterial = new LineBasicMaterial();\n\t\t}\n\n\t\tObject3D.call(this);\n\t\tthis.type = 'Line';\n\t\tthis.geometry = geometry;\n\t\tthis.material = material;\n\t\tthis.updateMorphTargets();\n\t}\n\n\tLine.prototype = Object.assign(Object.create(Object3D.prototype), {\n\t\tconstructor: Line,\n\t\tisLine: true,\n\t\tcopy: function copy(source) {\n\t\t\tObject3D.prototype.copy.call(this, source);\n\t\t\tthis.material = source.material;\n\t\t\tthis.geometry = source.geometry;\n\t\t\treturn this;\n\t\t},\n\t\tcomputeLineDistances: function computeLineDistances() {\n\t\t\tvar geometry = this.geometry;\n\n\t\t\tif (geometry.isBufferGeometry) {\n\t\t\t\t// we assume non-indexed geometry\n\t\t\t\tif (geometry.index === null) {\n\t\t\t\t\tvar positionAttribute = geometry.attributes.position;\n\t\t\t\t\tvar lineDistances = [0];\n\n\t\t\t\t\tfor (var i = 1, l = positionAttribute.count; i < l; i++) {\n\t\t\t\t\t\t_start.fromBufferAttribute(positionAttribute, i - 1);\n\n\t\t\t\t\t\t_end.fromBufferAttribute(positionAttribute, i);\n\n\t\t\t\t\t\tlineDistances[i] = lineDistances[i - 1];\n\t\t\t\t\t\tlineDistances[i] += _start.distanceTo(_end);\n\t\t\t\t\t}\n\n\t\t\t\t\tgeometry.setAttribute('lineDistance', new Float32BufferAttribute(lineDistances, 1));\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn('THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.');\n\t\t\t\t}\n\t\t\t} else if (geometry.isGeometry) {\n\t\t\t\tvar vertices = geometry.vertices;\n\t\t\t\tvar _lineDistances = geometry.lineDistances;\n\t\t\t\t_lineDistances[0] = 0;\n\n\t\t\t\tfor (var _i = 1, _l = vertices.length; _i < _l; _i++) {\n\t\t\t\t\t_lineDistances[_i] = _lineDistances[_i - 1];\n\t\t\t\t\t_lineDistances[_i] += vertices[_i - 1].distanceTo(vertices[_i]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\traycast: function raycast(raycaster, intersects) {\n\t\t\tvar geometry = this.geometry;\n\t\t\tvar matrixWorld = this.matrixWorld;\n\t\t\tvar threshold = raycaster.params.Line.threshold; // Checking boundingSphere distance to ray\n\n\t\t\tif (geometry.boundingSphere === null) geometry.computeBoundingSphere();\n\n\t\t\t_sphere$2.copy(geometry.boundingSphere);
1\n\n\t\t\t_sphere$2.applyMatrix4(matrixWorld);\n\n\t\t\t_sphere$2.radius += threshold;\n\t\t\tif (raycaster.ray.intersectsSphere(_sphere$2) === false) return; //\n\n\t\t\t_inverseMatrix$1.copy(matrixWorld).invert();\n\n\t\t\t_ray$1.copy(raycaster.ray).applyMatrix4(_inverseMatrix$1);\n\n\t\t\tvar localThreshold = threshold / ((this.scale.x + this.scale.y + this.scale.z) / 3);\n\t\t\tvar localThresholdSq = localThreshold * localThreshold;\n\t\t\tvar vStart = new Vector3();\n\t\t\tvar vEnd = new Vector3();\n\t\t\tvar interSegment = new Vector3();\n\t\t\tvar interRay = new Vector3();\n\t\t\tvar step = this.isLineSegments ? 2 : 1;\n\n\t\t\tif (geometry.isBufferGeometry) {\n\t\t\t\tvar index = geometry.index;\n\t\t\t\tvar attributes = geometry.attributes;\n\t\t\t\tvar positionAttribute = attributes.position;\n\n\t\t\t\tif (index !== null) {\n\t\t\t\t\tvar indices = index.array;\n\n\t\t\t\t\tfor (var i = 0, l = indices.length - 1; i < l; i += step) {\n\t\t\t\t\t\tvar a = indices[i];\n\t\t\t\t\t\tvar b = indices[i + 1];\n\t\t\t\t\t\tvStart.fromBufferAttribute(positionAttribute, a);\n\t\t\t\t\t\tvEnd.fromBufferAttribute(positionAttribute, b);\n\n\t\t\t\t\t\tvar distSq = _ray$1.distanceSqToSegment(vStart, vEnd, interRay, interSegment);\n\n\t\t\t\t\t\tif (distSq > localThresholdSq) continue;\n\t\t\t\t\t\tinterRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation\n\n\t\t\t\t\t\tvar distance = raycaster.ray.origin.distanceTo(interRay);\n\t\t\t\t\t\tif (distance < raycaster.near || distance > raycaster.far) continue;\n\t\t\t\t\t\tintersects.push({\n\t\t\t\t\t\t\tdistance: distance,\n\t\t\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\t\t\tpoint: interSegment.clone().applyMatrix4(this.matrixWorld),\n\t\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\t\tface: null,\n\t\t\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\t\t\tobject: this\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (var _i2 = 0, _l2 = positionAttribute.count - 1; _i2 < _l2; _i2 += step) {\n\t\t\t\t\t\tvStart.fromBufferAttribute(positionAttribute, _i2);\n\t\t\t\t\t\tvEnd.fromBufferAttribute(positionAttribute, _i2 + 1);\n\n\t\t\t\t\t\tvar _distSq = _ray$1.distanceSqToSegment(vStart, vEnd, interRay, interSegment);\n\n\t\t\t\t\t\tif (_distSq > localThresholdSq) continue;\n\t\t\t\t\t\tinterRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation\n\n\t\t\t\t\t\tvar _distance = raycaster.ray.origin.distanceTo(interRay);\n\n\t\t\t\t\t\tif (_distance < raycaster.near || _distance > raycaster.far) continue;\n\t\t\t\t\t\tintersects.push({\n\t\t\t\t\t\t\tdistance: _distance,\n\t\t\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\t\t\tpoint: interSegment.clone().applyMatrix4(this.matrixWorld),\n\t\t\t\t\t\t\tindex: _i2,\n\t\t\t\t\t\t\tface: null,\n\t\t\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\t\t\tobject: this\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (geometry.isGeometry) {\n\t\t\t\tvar vertices = geometry.vertices;\n\t\t\t\tvar nbVertices = vertices.length;\n\n\t\t\t\tfor (var _i3 = 0; _i3 < nbVertices - 1; _i3 += step) {\n\t\t\t\t\tvar _distSq2 = _ray$1.distanceSqToSegment(vertices[_i3], vertices[_i3 + 1], interRay, interSegment);\n\n\t\t\t\t\tif (_distSq2 > localThresholdSq) continue;\n\t\t\t\t\tinterRay.applyMatrix4(this.matrixWorld); //Move back to world space for distance calculation\n\n\t\t\t\t\tvar _distance2 = raycaster.ray.origin.distanceTo(interRay);\n\n\t\t\t\t\tif (_distance2 < raycaster.near || _distance2 > raycaster.far) continue;\n\t\t\t\t\tintersects.push({\n\t\t\t\t\t\tdistance: _distance2,\n\t\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\t\tpoint: interSegment.clone().applyMatrix4(this.matrixWorld),\n\t\t\t\t\t\tindex: _i3,\n\t\t\t\t\t\tface: null,\n\t\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\t\tobject: this\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tupdateMorphTargets: function updateMorphTargets() {\n\t\t\tvar geometry = this.geometry;\n\n\t\t\tif (geometry.isBufferGeometry) {\n\t\t\t\tvar morphAttributes = geometry.morphAttributes;\n\t\t\t\tvar keys = Object.keys(morphAttributes);\n\n\t\t\t\tif (keys.length > 0) {\n\t\t\t\t\tvar morphAttribute = morphAttributes[keys[0]];\n\n\t\t\t\t\tif (morphAttribute !== undefined) {\n\t\t\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\t\t\tfor (var m = 0, ml = morphAttribute.length; m < ml; m++) {\n\t\t\t\t\t\t\tvar name = morphAttribute[m].name || String(m);\n\t\t\t\t\t\t\tthis.morphTargetInfluences.push(0);\n\t\t\t\t\t\t\tthis.morphTargetDictionary[name] = m;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tvar morphTargets = geometry.morphTargets;\n\n\t\t\t\tif (morphTargets !== undefined && morphTargets.length > 0) {\n\t\t\t\t\tconsole.error('THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\tvar _start$1 = new Vector3();\n\n\tvar _end$1 = new Vector3();\n\n\tfunction LineSegments(geometry, material) {\n\t\tLine.call(this, geometry, material);\n\t\tthis.type = 'LineSegments';\n\t}\n\n\tLineSegments.prototype = Object.assign(Object.create(Line.prototype), {\n\t\tconstructor: LineSegments,\n\t\tisLineSegments: true,\n\t\tcomputeLineDistances: function computeLineDistances() {\n\t\t\tvar geometry = this.geometry;\n\n\t\t\tif (geometry.isBufferGeometry) {\n\t\t\t\t// we assume non-indexed geometry\n\t\t\t\tif (geometry.index === null) {\n\t\t\t\t\tvar positionAttribute = geometry.attributes.position;\n\t\t\t\t\tvar lineDistances = [];\n\n\t\t\t\t\tfor (var i = 0, l = positionAttribute.count; i < l; i += 2) {\n\t\t\t\t\t\t_start$1.fromBufferAttribute(positionAttribute, i);\n\n\t\t\t\t\t\t_end$1.fromBufferAttribute(positionAttribute, i + 1);\n\n\t\t\t\t\t\tlineDistances[i] = i === 0 ? 0 : lineDistances[i - 1];\n\t\t\t\t\t\tlineDistances[i + 1] = lineDistances[i] + _start$1.distanceTo(_end$1);\n\t\t\t\t\t}\n\n\t\t\t\t\tgeometry.setAttribute('lineDistance', new Float32BufferAttribute(lineDistances, 1));\n\t\t\t\t} else {\n\t\t\t\t\tconsole.warn('THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.');\n\t\t\t\t}\n\t\t\t} else if (geometry.isGeometry) {\n\t\t\t\tvar vertices = geometry.vertices;\n\t\t\t\tvar _lineDistances = geometry.lineDistances;\n\n\t\t\t\tfor (var _i = 0, _l = vertices.length; _i < _l; _i += 2) {\n\t\t\t\t\t_start$1.copy(vertices[_i]);\n\n\t\t\t\t\t_end$1.copy(vertices[_i + 1]);\n\n\t\t\t\t\t_lineDistances[_i] = _i === 0 ? 0 : _lineDistances[_i - 1];\n\t\t\t\t\t_lineDistances[_i + 1] = _lineDistances[_i] + _start$1.distanceTo(_end$1);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this;\n\t\t}\n\t});\n\n\tfunction LineLoop(geometry, material) {\n\t\tLine.call(this, geometry, material);\n\t\tthis.type = 'LineLoop';\n\t}\n\n\tLineLoop.prototype = Object.assign(Object.create(Line.prototype), {\n\t\tconstructor: LineLoop,\n\t\tisLineLoop: true\n\t});\n\n\t/**\n\t * parameters = {\n\t *\tcolor: <hex>,\n\t *\topacity: <float>,\n\t *\tmap: new THREE.Texture( <Image> ),\n\t *\talphaMap: new THREE.Texture( <Image> ),\n\t *\n\t *\tsize: <float>,\n\t *\tsizeAttenuation: <bool>\n\t *\n\t *\tmorphTargets: <bool>\n\t * }\n\t */\n\n\tfunction PointsMaterial(parameters) {\n\t\tMaterial.call(this);\n\t\tthis.type = 'PointsMaterial';\n\t\tthis.color = new Color(0xffffff);\n\t\tthis.map = null;\n\t\tthis.alphaMap = null;\n\t\tthis.size = 1;\n\t\tthis.sizeAttenuation = true;\n\t\tthis.morphTargets = false;\n\t\tthis.setValues(parameters);\n\t}\n\n\tPointsMaterial.prototype = Object.create(Material.prototype);\n\tPointsMaterial.prototype.constructor = PointsMaterial;\n\tPointsMaterial.prototype.isPointsMaterial = true;\n\n\tPointsMaterial.prototype.copy = function (source) {\n\t\tMaterial.prototype.copy.call(this, source);\n\t\tthis.color.copy(source.color);\n\t\tthis.map = source.map;\n\t\tthis.alphaMap = source.alphaMap;
1\n\t\tthis.size = source.size;\n\t\tthis.sizeAttenuation = source.sizeAttenuation;\n\t\tthis.morphTargets = source.morphTargets;\n\t\treturn this;\n\t};\n\n\tvar _inverseMatrix$2 = new Matrix4();\n\n\tvar _ray$2 = new Ray();\n\n\tvar _sphere$3 = new Sphere();\n\n\tvar _position$1 = new Vector3();\n\n\tfunction Points(geometry, material) {\n\t\tif (geometry === void 0) {\n\t\t\tgeometry = new BufferGeometry();\n\t\t}\n\n\t\tif (material === void 0) {\n\t\t\tmaterial = new PointsMaterial();\n\t\t}\n\n\t\tObject3D.call(this);\n\t\tthis.type = 'Points';\n\t\tthis.geometry = geometry;\n\t\tthis.material = material;\n\t\tthis.updateMorphTargets();\n\t}\n\n\tPoints.prototype = Object.assign(Object.create(Object3D.prototype), {\n\t\tconstructor: Points,\n\t\tisPoints: true,\n\t\tcopy: function copy(source) {\n\t\t\tObject3D.prototype.copy.call(this, source);\n\t\t\tthis.material = source.material;\n\t\t\tthis.geometry = source.geometry;\n\t\t\treturn this;\n\t\t},\n\t\traycast: function raycast(raycaster, intersects) {\n\t\t\tvar geometry = this.geometry;\n\t\t\tvar matrixWorld = this.matrixWorld;\n\t\t\tvar threshold = raycaster.params.Points.threshold; // Checking boundingSphere distance to ray\n\n\t\t\tif (geometry.boundingSphere === null) geometry.computeBoundingSphere();\n\n\t\t\t_sphere$3.copy(geometry.boundingSphere);\n\n\t\t\t_sphere$3.applyMatrix4(matrixWorld);\n\n\t\t\t_sphere$3.radius += threshold;\n\t\t\tif (raycaster.ray.intersectsSphere(_sphere$3) === false) return; //\n\n\t\t\t_inverseMatrix$2.copy(matrixWorld).invert();\n\n\t\t\t_ray$2.copy(raycaster.ray).applyMatrix4(_inverseMatrix$2);\n\n\t\t\tvar localThreshold = threshold / ((this.scale.x + this.scale.y + this.scale.z) / 3);\n\t\t\tvar localThresholdSq = localThreshold * localThreshold;\n\n\t\t\tif (geometry.isBufferGeometry) {\n\t\t\t\tvar index = geometry.index;\n\t\t\t\tvar attributes = geometry.attributes;\n\t\t\t\tvar positionAttribute = attributes.position;\n\n\t\t\t\tif (index !== null) {\n\t\t\t\t\tvar indices = index.array;\n\n\t\t\t\t\tfor (var i = 0, il = indices.length; i < il; i++) {\n\t\t\t\t\t\tvar a = indices[i];\n\n\t\t\t\t\t\t_position$1.fromBufferAttribute(positionAttribute, a);\n\n\t\t\t\t\t\ttestPoint(_position$1, a, localThresholdSq, matrixWorld, raycaster, intersects, this);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (var _i = 0, l = positionAttribute.count; _i < l; _i++) {\n\t\t\t\t\t\t_position$1.fromBufferAttribute(positionAttribute, _i);\n\n\t\t\t\t\t\ttestPoint(_position$1, _i, localThresholdSq, matrixWorld, raycaster, intersects, this);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tvar vertices = geometry.vertices;\n\n\t\t\t\tfor (var _i2 = 0, _l = vertices.length; _i2 < _l; _i2++) {\n\t\t\t\t\ttestPoint(vertices[_i2], _i2, localThresholdSq, matrixWorld, raycaster, intersects, this);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tupdateMorphTargets: function updateMorphTargets() {\n\t\t\tvar geometry = this.geometry;\n\n\t\t\tif (geometry.isBufferGeometry) {\n\t\t\t\tvar morphAttributes = geometry.morphAttributes;\n\t\t\t\tvar keys = Object.keys(morphAttributes);\n\n\t\t\t\tif (keys.length > 0) {\n\t\t\t\t\tvar morphAttribute = morphAttributes[keys[0]];\n\n\t\t\t\t\tif (morphAttribute !== undefined) {\n\t\t\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\t\t\tfor (var m = 0, ml = morphAttribute.length; m < ml; m++) {\n\t\t\t\t\t\t\tvar name = morphAttribute[m].name || String(m);\n\t\t\t\t\t\t\tthis.morphTargetInfluences.push(0);\n\t\t\t\t\t\t\tthis.morphTargetDictionary[name] = m;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tvar morphTargets = geometry.morphTargets;\n\n\t\t\t\tif (morphTargets !== undefined && morphTargets.length > 0) {\n\t\t\t\t\tconsole.error('THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\n\tfunction testPoint(point, index, localThresholdSq, matrixWorld, raycaster, intersects, object) {\n\t\tvar rayPointDistanceSq = _ray$2.distanceSqToPoint(point);\n\n\t\tif (rayPointDistanceSq < localThresholdSq) {\n\t\t\tvar intersectPoint = new Vector3();\n\n\t\t\t_ray$2.closestPointToPoint(point, intersectPoint);\n\n\t\t\tintersectPoint.applyMatrix4(matrixWorld);\n\t\t\tvar distance = raycaster.ray.origin.distanceTo(intersectPoint);\n\t\t\tif (distance < raycaster.near || distance > raycaster.far) return;\n\t\t\tintersects.push({\n\t\t\t\tdistance: distance,\n\t\t\t\tdistanceToRay: Math.sqrt(rayPointDistanceSq),\n\t\t\t\tpoint: intersectPoint,\n\t\t\t\tindex: index,\n\t\t\t\tface: null,\n\t\t\t\tobject: object\n\t\t\t});\n\t\t}\n\t}\n\n\tfunction VideoTexture(video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy) {\n\t\tTexture.call(this, video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);\n\t\tthis.format = format !== undefined ? format : RGBFormat;\n\t\tthis.minFilter = minFilter !== undefined ? minFilter : LinearFilter;
1\n\t\tthis.magFilter = magFilter !== undefined ? magFilter : LinearFilter;\n\t\tthis.generateMipmaps = false;\n\t\tvar scope = this;\n\n\t\tfunction updateVideo() {\n\t\t\tscope.needsUpdate = true;\n\t\t\tvideo.requestVideoFrameCallback(updateVideo);\n\t\t}\n\n\t\tif ('requestVideoFrameCallback' in video) {\n\t\t\tvideo.requestVideoFrameCallback(updateVideo);\n\t\t}\n\t}\n\n\tVideoTexture.prototype = Object.assign(Object.create(Texture.prototype), {\n\t\tconstructor: VideoTexture,\n\t\tclone: function clone() {\n\t\t\treturn new this.constructor(this.image).copy(this);\n\t\t},\n\t\tisVideoTexture: true,\n\t\tupdate: function update() {\n\t\t\tvar video = this.image;\n\t\t\tvar hasVideoFrameCallback = ('requestVideoFrameCallback' in video);\n\n\t\t\tif (hasVideoFrameCallback === false && video.readyState >= video.HAVE_CURRENT_DATA) {\n\t\t\t\tthis.needsUpdate = true;\n\t\t\t}\n\t\t}\n\t});\n\n\tfunction CompressedTexture(mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding) {\n\t\tTexture.call(this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding);\n\t\tthis.image = {\n\t\t\twidth: width,\n\t\t\theight: height\n\t\t};\n\t\tthis.mipmaps = mipmaps; // no flipping for cube textures\n\t\t// (also flipping doesn't work for compressed textures )\n\n\t\tthis.flipY = false; // can't generate mipmaps for compressed textures\n\t\t// mips must be embedded in DDS files\n\n\t\tthis.generateMipmaps = false;\n\t}\n\n\tCompressedTexture.prototype = Object.create(Texture.prototype);\n\tCompressedTexture.prototype.constructor = CompressedTexture;\n\tCompressedTexture.prototype.isCompressedTexture = true;\n\n\tfunction CanvasTexture(canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy) {\n\t\tTexture.call(this, canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);\n\t\tthis.needsUpdate = true;\n\t}\n\n\tCanvasTexture.prototype = Object.create(Texture.prototype);\n\tCanvasTexture.prototype.constructor = CanvasTexture;\n\tCanvasTexture.prototype.isCanvasTexture = true;\n\n\tfunction DepthTexture(width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format) {\n\t\tformat = format !== undefined ? format : DepthFormat;\n\n\t\tif (format !== DepthFormat && format !== DepthStencilFormat) {\n\t\t\tthrow new Error('DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat');\n\t\t}\n\n\t\tif (type === undefined && format === DepthFormat) type = UnsignedShortType;\n\t\tif (type === undefined && format === DepthStencilFormat) type = UnsignedInt248Type;\n\t\tTexture.call(this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy);\n\t\tthis.image = {\n\t\t\twidth: width,\n\t\t\theight: height\n\t\t};\n\t\tthis.magFilter = magFilter !== undefined ? magFilter : NearestFilter;\n\t\tthis.minFilter = minFilter !== undefined ? minFilter : NearestFilter;\n\t\tthis.flipY = false;\n\t\tthis.generateMipmaps = false;\n\t}\n\n\tDepthTexture.prototype = Object.create(Texture.prototype);\n\tDepthTexture.prototype.constructor = DepthTexture;\n\tDepthTexture.prototype.isDepthTexture = true;\n\n\tvar _geometryId = 0; // Geometry uses even numbers as Id\n\n\tvar _m1$3 = new Matrix4();\n\n\tvar _obj$1 = new Object3D();\n\n\tvar _offset$1 = new Vector3();\n\n\tfunction Geometry() {\n\t\tObject.defineProperty(this, 'id', {\n\t\t\tvalue: _geometryId += 2\n\t\t});\n\t\tthis.uuid = MathUtils.generateUUID();\n\t\tthis.name = '';\n\t\tthis.type = 'Geometry';\n\t\tthis.vertices = [];\n\t\tthis.colors = [];\n\t\tthis.faces = [];\n\t\tthis.faceVertexUvs = [[]];\n\t\tthis.morphTargets = [];\n\t\tthis.morphNormals = [];\n\t\tthis.skinWeights = [];\n\t\tthis.skinIndices = [];\n\t\tthis.lineDistances = [];\n\t\tthis.boundingBox = null;\n\t\tthis.boundingSphere = null; // update flags\n\n\t\tthis.elementsNeedUpdate = false;\n\t\tthis.verticesNeedUpdate = false;\n\t\tthis.uvsNeedUpdate = false;\n\t\tthis.normalsNeedUpdate = false;\n\t\tthis.colorsNeedUpdate = false;\n\t\tthis.lineDistancesNeedUpdate = false;\n\t\tthis.groupsNeedUpdate = false;\n\t}\n\n\tGeometry.prototype = Object.assign(Object.create(EventDispatcher.prototype), {\n\t\tconstructor: Geometry,\n\t\tisGeometry: true,\n\t\tapplyMatrix4: function applyMatrix4(matrix) {\n\t\t\tvar normalMatrix = new Matrix3().getNormalMatrix(matrix);\n\n\t\t\tfor (var i = 0, il = this.vertices.length; i < il;
1 i++) {\n\t\t\t\tvar vertex = this.vertices[i];\n\t\t\t\tvertex.applyMatrix4(matrix);\n\t\t\t}\n\n\t\t\tfor (var _i = 0, _il = this.faces.length; _i < _il; _i++) {\n\t\t\t\tvar face = this.faces[_i];\n\t\t\t\tface.normal.applyMatrix3(normalMatrix).normalize();\n\n\t\t\t\tfor (var j = 0, jl = face.vertexNormals.length; j < jl; j++) {\n\t\t\t\t\tface.vertexNormals[j].applyMatrix3(normalMatrix).normalize();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.boundingBox !== null) {\n\t\t\t\tthis.computeBoundingBox();\n\t\t\t}\n\n\t\t\tif (this.boundingSphere !== null) {\n\t\t\t\tthis.computeBoundingSphere();\n\t\t\t}\n\n\t\t\tthis.verticesNeedUpdate = true;\n\t\t\tthis.normalsNeedUpdate = true;\n\t\t\treturn this;\n\t\t},\n\t\trotateX: function rotateX(angle) {\n\t\t\t// rotate geometry around world x-axis\n\t\t\t_m1$3.makeRotationX(angle);\n\n\t\t\tthis.applyMatrix4(_m1$3);\n\t\t\treturn this;\n\t\t},\n\t\trotateY: function rotateY(angle) {\n\t\t\t// rotate geometry around world y-axis\n\t\t\t_m1$3.makeRotationY(angle);\n\n\t\t\tthis.applyMatrix4(_m1$3);\n\t\t\treturn this;\n\t\t},\n\t\trotateZ: function rotateZ(angle) {\n\t\t\t// rotate geometry around world z-axis\n\t\t\t_m1$3.makeRotationZ(angle);\n\n\t\t\tthis.applyMatrix4(_m1$3);\n\t\t\treturn this;\n\t\t},\n\t\ttranslate: function translate(x, y, z) {\n\t\t\t// translate geometry\n\t\t\t_m1$3.makeTranslation(x, y, z);\n\n\t\t\tthis.applyMatrix4(_m1$3);\n\t\t\treturn this;\n\t\t},\n\t\tscale: function scale(x, y, z) {\n\t\t\t// scale geometry\n\t\t\t_m1$3.makeScale(x, y, z);\n\n\t\t\tthis.applyMatrix4(_m1$3);\n\t\t\treturn this;\n\t\t},\n\t\tlookAt: function lookAt(vector) {\n\t\t\t_obj$1.lookAt(vector);\n\n\t\t\t_obj$1.updateMatrix();\n\n\t\t\tthis.applyMatrix4(_obj$1.matrix);\n\t\t\treturn this;\n\t\t},\n\t\tfromBufferGeometry: function fromBufferGeometry(geometry) {\n\t\t\tvar scope = this;\n\t\t\tvar index = geometry.index !== null ? geometry.index : undefined;\n\t\t\tvar attributes = geometry.attributes;\n\n\t\t\tif (attributes.position === undefined) {\n\t\t\t\tconsole.error('THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion.');\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tvar position = attributes.position;\n\t\t\tvar normal = attributes.normal;\n\t\t\tvar color = attributes.color;\n\t\t\tvar uv = attributes.uv;\n\t\t\tvar uv2 = attributes.uv2;\n\t\t\tif (uv2 !== undefined) this.faceVertexUvs[1] = [];\n\n\t\t\tfor (var i = 0; i < position.count; i++) {\n\t\t\t\tscope.vertices.push(new Vector3().fromBufferAttribute(position, i));\n\n\t\t\t\tif (color !== undefined) {\n\t\t\t\t\tscope.colors.push(new Color().fromBufferAttribute(color, i));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction addFace(a, b, c, materialIndex) {\n\t\t\t\tvar vertexColors = color === undefined ? [] : [scope.colors[a].clone(), scope.colors[b].clone(), scope.colors[c].clone()];\n\t\t\t\tvar vertexNormals = normal === undefined ? [] : [new Vector3().fromBufferAttribute(normal, a), new Vector3().fromBufferAttribute(normal, b), new Vector3().fromBufferAttribute(normal, c)];\n\t\t\t\tvar face = new Face3(a, b, c, vertexNormals, vertexColors, materialIndex);\n\t\t\t\tscope.faces.push(face);\n\n\t\t\t\tif (uv !== undefined) {\n\t\t\t\t\tscope.faceVertexUvs[0].push([new Vector2().fromBufferAttribute(uv, a), new Vector2().fromBufferAttribute(uv, b), new Vector2().fromBufferAttribute(uv, c)]);\n\t\t\t\t}\n\n\t\t\t\tif (uv2 !== undefined) {\n\t\t\t\t\tscope.faceVertexUvs[1].push([new Vector2().fromBufferAttribute(uv2, a), new Vector2().fromBufferAttribute(uv2, b), new Vector2().fromBufferAttribute(uv2, c)]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar groups = geometry.groups;\n\n\t\t\tif (groups.length > 0) {\n\t\t\t\tfor (var _i2 = 0; _i2 < groups.length; _i2++) {\n\t\t\t\t\tvar group = groups[_i2];\n\t\t\t\t\tvar start = group.start;\n\t\t\t\t\tvar count = group.count;\n\n\t\t\t\t\tfor (var j = start, jl = start + count; j < jl; j += 3) {\n\t\t\t\t\t\tif (index !== undefined) {\n\t\t\t\t\t\t\taddFace(index.getX(j), index.getX(j + 1), index.getX(j + 2), group.materialIndex);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\taddFace(j, j + 1, j + 2, group.materialIndex);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (index !== undefined) {\n\t\t\t\t\tfor (var _i3 = 0; _i3 < index.count; _i3 += 3) {\n\t\t\t\t\t\taddFace(index.getX(_i3), index.getX(_i3 + 1), index.getX(_i3 + 2));\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor (var _i4 = 0; _i4 < position.count; _i4 += 3) {\n\t\t\t\t\t\taddFace(_i4, _i4 + 1, _i4 + 2);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.computeFaceNormals();\n\n\t\t\tif (geometry.boundingBox !== null) {\n\t\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\t\t\t}\n\n\t\t\tif (geometry.boundingSphere !== null) {\n\t\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tcenter: function center() {\n\t\t\tthis.computeBoundingBox();\n\t\t\tthis.boundingBox.getCenter(_offset$1).negate();\n\t\t\tthis.translate(_offset$1.x, _offset$1.y, _offset$1.z);\n\t\t\treturn this;\n\t\t},\n\t\tnormalize: function normalize() {\n\t\t\tthis.computeBoundingSphere();\n\t\t\tvar center = this.boundingSphere.center;\n\t\t\tvar radius = this.boundingSphere.radius;
1\n\t\t\tvar s = radius === 0 ? 1 : 1.0 / radius;\n\t\t\tvar matrix = new Matrix4();\n\t\t\tmatrix.set(s, 0, 0, -s * center.x, 0, s, 0, -s * center.y, 0, 0, s, -s * center.z, 0, 0, 0, 1);\n\t\t\tthis.applyMatrix4(matrix);\n\t\t\treturn this;\n\t\t},\n\t\tcomputeFaceNormals: function computeFaceNormals() {\n\t\t\tvar cb = new Vector3(),\n\t\t\t\t\tab = new Vector3();\n\n\t\t\tfor (var f = 0, fl = this.faces.length; f < fl; f++) {\n\t\t\t\tvar face = this.faces[f];\n\t\t\t\tvar vA = this.vertices[face.a];\n\t\t\t\tvar vB = this.vertices[face.b];\n\t\t\t\tvar vC = this.vertices[face.c];\n\t\t\t\tcb.subVectors(vC, vB);\n\t\t\t\tab.subVectors(vA, vB);\n\t\t\t\tcb.cross(ab);\n\t\t\t\tcb.normalize();\n\t\t\t\tface.normal.copy(cb);\n\t\t\t}\n\t\t},\n\t\tcomputeVertexNormals: function computeVertexNormals(areaWeighted) {\n\t\t\tif (areaWeighted === void 0) {\n\t\t\t\tareaWeighted = true;\n\t\t\t}\n\n\t\t\tvar vertices = new Array(this.vertices.length);\n\n\t\t\tfor (var v = 0, vl = this.vertices.length; v < vl; v++) {\n\t\t\t\tvertices[v] = new Vector3();\n\t\t\t}\n\n\t\t\tif (areaWeighted) {\n\t\t\t\t// vertex normals weighted by triangle areas\n\t\t\t\t// http://www.iquilezles.org/www/articles/normals/normals.htm\n\t\t\t\tvar cb = new Vector3(),\n\t\t\t\t\t\tab = new Vector3();\n\n\t\t\t\tfor (var f = 0, fl = this.faces.length; f < fl; f++) {\n\t\t\t\t\tvar face = this.faces[f];\n\t\t\t\t\tvar vA = this.vertices[face.a];\n\t\t\t\t\tvar vB = this.vertices[face.b];\n\t\t\t\t\tvar vC = this.vertices[face.c];\n\t\t\t\t\tcb.subVectors(vC, vB);\n\t\t\t\t\tab.subVectors(vA, vB);\n\t\t\t\t\tcb.cross(ab);\n\t\t\t\t\tvertices[face.a].add(cb);\n\t\t\t\t\tvertices[face.b].add(cb);\n\t\t\t\t\tvertices[face.c].add(cb);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.computeFaceNormals();\n\n\t\t\t\tfor (var _f = 0, _fl = this.faces.length; _f < _fl; _f++) {\n\t\t\t\t\tvar _face = this.faces[_f];\n\n\t\t\t\t\tvertices[_face.a].add(_face.normal);\n\n\t\t\t\t\tvertices[_face.b].add(_face.normal);\n\n\t\t\t\t\tvertices[_face.c].add(_face.normal);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (var _v = 0, _vl = this.vertices.length; _v < _vl; _v++) {\n\t\t\t\tvertices[_v].normalize();\n\t\t\t}\n\n\t\t\tfor (var _f2 = 0, _fl2 = this.faces.length; _f2 < _fl2; _f2++) {\n\t\t\t\tvar _face2 = this.faces[_f2];\n\t\t\t\tvar vertexNormals = _face2.vertexNormals;\n\n\t\t\t\tif (vertexNormals.length === 3) {\n\t\t\t\t\tvertexNormals[0].copy(vertices[_face2.a]);\n\t\t\t\t\tvertexNormals[1].copy(vertices[_face2.b]);\n\t\t\t\t\tvertexNormals[2].copy(vertices[_face2.c]);\n\t\t\t\t} else {\n\t\t\t\t\tvertexNormals[0] = vertices[_face2.a].clone();\n\t\t\t\t\tvertexNormals[1] = vertices[_face2.b].clone();\n\t\t\t\t\tvertexNormals[2] = vertices[_face2.c].clone();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.faces.length > 0) {\n\t\t\t\tthis.normalsNeedUpdate = true;\n\t\t\t}\n\t\t},\n\t\tcomputeFlatVertexNormals: function computeFlatVertexNormals() {\n\t\t\tthis.computeFaceNormals();\n\n\t\t\tfor (var f = 0, fl = this.faces.length; f < fl; f++) {\n\t\t\t\tvar face = this.faces[f];\n\t\t\t\tvar vertexNormals = face.vertexNormals;\n\n\t\t\t\tif (vertexNormals.length === 3) {\n\t\t\t\t\tvertexNormals[0].copy(face.normal);\n\t\t\t\t\tvertexNormals[1].copy(face.normal);\n\t\t\t\t\tvertexNormals[2].copy(face.normal);\n\t\t\t\t} else {\n\t\t\t\t\tvertexNormals[0] = face.normal.clone();\n\t\t\t\t\tvertexNormals[1] = face.normal.clone();\n\t\t\t\t\tvertexNormals[2] = face.normal.clone();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.faces.length > 0) {\n\t\t\t\tthis.normalsNeedUpdate = true;\n\t\t\t}\n\t\t},\n\t\tcomputeMorphNormals: function computeMorphNormals() {\n\t\t\t// save original normals\n\t\t\t// - create temp variables on first access\n\t\t\t//\t otherwise just copy (for faster repeated calls)\n\t\t\tfor (var f = 0, fl = this.faces.length; f < fl; f++) {\n\t\t\t\tvar face = this.faces[f];
1\n\n\t\t\t\tif (!face.__originalFaceNormal) {\n\t\t\t\t\tface.__originalFaceNormal = face.normal.clone();\n\t\t\t\t} else {\n\t\t\t\t\tface.__originalFaceNormal.copy(face.normal);\n\t\t\t\t}\n\n\t\t\t\tif (!face.__originalVertexNormals) face.__originalVertexNormals = [];\n\n\t\t\t\tfor (var i = 0, il = face.vertexNormals.length; i < il; i++) {\n\t\t\t\t\tif (!face.__originalVertexNormals[i]) {\n\t\t\t\t\t\tface.__originalVertexNormals[i] = face.vertexNormals[i].clone();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tface.__originalVertexNormals[i].copy(face.vertexNormals[i]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} // use temp geometry to compute face and vertex normals for each morph\n\n\n\t\t\tvar tmpGeo = new Geometry();\n\t\t\ttmpGeo.faces = this.faces;\n\n\t\t\tfor (var _i5 = 0, _il2 = this.morphTargets.length; _i5 < _il2; _i5++) {\n\t\t\t\t// create on first access\n\t\t\t\tif (!this.morphNormals[_i5]) {\n\t\t\t\t\tthis.morphNormals[_i5] = {};\n\t\t\t\t\tthis.morphNormals[_i5].faceNormals = [];\n\t\t\t\t\tthis.morphNormals[_i5].vertexNormals = [];\n\t\t\t\t\tvar dstNormalsFace = this.morphNormals[_i5].faceNormals;\n\t\t\t\t\tvar dstNormalsVertex = this.morphNormals[_i5].vertexNormals;\n\n\t\t\t\t\tfor (var _f3 = 0, _fl3 = this.faces.length; _f3 < _fl3; _f3++) {\n\t\t\t\t\t\tvar faceNormal = new Vector3();\n\t\t\t\t\t\tvar vertexNormals = {\n\t\t\t\t\t\t\ta: new Vector3(),\n\t\t\t\t\t\t\tb: new Vector3(),\n\t\t\t\t\t\t\tc: new Vector3()\n\t\t\t\t\t\t};\n\t\t\t\t\t\tdstNormalsFace.push(faceNormal);\n\t\t\t\t\t\tdstNormalsVertex.push(vertexNormals);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvar morphNormals = this.morphNormals[_i5]; // set vertices to morph target\n\n\t\t\t\ttmpGeo.vertices = this.morphTargets[_i5].vertices; // compute morph normals\n\n\t\t\t\ttmpGeo.computeFaceNormals();\n\t\t\t\ttmpGeo.computeVertexNormals(); // store morph normals\n\n\t\t\t\tfor (var _f4 = 0, _fl4 = this.faces.length; _f4 < _fl4; _f4++) {\n\t\t\t\t\tvar _face3 = this.faces[_f4];\n\t\t\t\t\tvar _faceNormal = morphNormals.faceNormals[_f4];\n\t\t\t\t\tvar _vertexNormals = morphNormals.vertexNormals[_f4];\n\n\t\t\t\t\t_faceNormal.copy(_face3.normal);\n\n\t\t\t\t\t_vertexNormals.a.copy(_face3.vertexNormals[0]);\n\n\t\t\t\t\t_vertexNormals.b.copy(_face3.vertexNormals[1]);\n\n\t\t\t\t\t_vertexNormals.c.copy(_face3.vertexNormals[2]);\n\t\t\t\t}\n\t\t\t} // restore original normals\n\n\n\t\t\tfor (var _f5 = 0, _fl5 = this.faces.length; _f5 < _fl5; _f5++) {\n\t\t\t\tvar _face4 = this.faces[_f5];
1\n\t\t\t\t_face4.normal = _face4.__originalFaceNormal;\n\t\t\t\t_face4.vertexNormals = _face4.__originalVertexNormals;\n\t\t\t}\n\t\t},\n\t\tcomputeBoundingBox: function computeBoundingBox() {\n\t\t\tif (this.boundingBox === null) {\n\t\t\t\tthis.boundingBox = new Box3();\n\t\t\t}\n\n\t\t\tthis.boundingBox.setFromPoints(this.vertices);\n\t\t},\n\t\tcomputeBoundingSphere: function computeBoundingSphere() {\n\t\t\tif (this.boundingSphere === null) {\n\t\t\t\tthis.boundingSphere = new Sphere();\n\t\t\t}\n\n\t\t\tthis.boundingSphere.setFromPoints(this.vertices);\n\t\t},\n\t\tmerge: function merge(geometry, matrix, materialIndexOffset) {\n\t\t\tif (materialIndexOffset === void 0) {\n\t\t\t\tmaterialIndexOffset = 0;\n\t\t\t}\n\n\t\t\tif (!(geometry && geometry.isGeometry)) {\n\t\t\t\tconsole.error('THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.', geometry);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar normalMatrix;\n\t\t\tvar vertexOffset = this.vertices.length,\n\t\t\t\t\tvertices1 = this.vertices,\n\t\t\t\t\tvertices2 = geometry.vertices,\n\t\t\t\t\tfaces1 = this.faces,\n\t\t\t\t\tfaces2 = geometry.faces,\n\t\t\t\t\tcolors1 = this.colors,\n\t\t\t\t\tcolors2 = geometry.colors;\n\n\t\t\tif (matrix !== undefined) {\n\t\t\t\tnormalMatrix = new Matrix3().getNormalMatrix(matrix);\n\t\t\t} // vertices\n\n\n\t\t\tfor (var i = 0, il = vertices2.length; i < il; i++) {\n\t\t\t\tvar vertex = vertices2[i];\n\t\t\t\tvar vertexCopy = vertex.clone();\n\t\t\t\tif (matrix !== undefined) vertexCopy.applyMatrix4(matrix);\n\t\t\t\tvertices1.push(vertexCopy);\n\t\t\t} // colors\n\n\n\t\t\tfor (var _i6 = 0, _il3 = colors2.length; _i6 < _il3; _i6++) {\n\t\t\t\tcolors1.push(colors2[_i6].clone());\n\t\t\t} // faces\n\n\n\t\t\tfor (var _i7 = 0, _il4 = faces2.length; _i7 < _il4;
1 _i7++) {\n\t\t\t\tvar face = faces2[_i7];\n\t\t\t\tvar normal = void 0,\n\t\t\t\t\t\tcolor = void 0;\n\t\t\t\tvar faceVertexNormals = face.vertexNormals,\n\t\t\t\t\t\tfaceVertexColors = face.vertexColors;\n\t\t\t\tvar faceCopy = new Face3(face.a + vertexOffset, face.b + vertexOffset, face.c + vertexOffset);\n\t\t\t\tfaceCopy.normal.copy(face.normal);\n\n\t\t\t\tif (normalMatrix !== undefined) {\n\t\t\t\t\tfaceCopy.normal.applyMatrix3(normalMatrix).normalize();\n\t\t\t\t}\n\n\t\t\t\tfor (var j = 0, jl = faceVertexNormals.length; j < jl; j++) {\n\t\t\t\t\tnormal = faceVertexNormals[j].clone();\n\n\t\t\t\t\tif (normalMatrix !== undefined) {\n\t\t\t\t\t\tnormal.applyMatrix3(normalMatrix).normalize();\n\t\t\t\t\t}\n\n\t\t\t\t\tfaceCopy.vertexNormals.push(normal);\n\t\t\t\t}\n\n\t\t\t\tfaceCopy.color.copy(face.color);\n\n\t\t\t\tfor (var _j = 0, _jl = faceVertexColors.length; _j < _jl; _j++) {\n\t\t\t\t\tcolor = faceVertexColors[_j];\n\t\t\t\t\tfaceCopy.vertexColors.push(color.clone());\n\t\t\t\t}\n\n\t\t\t\tfaceCopy.materialIndex = face.materialIndex + materialIndexOffset;\n\t\t\t\tfaces1.push(faceCopy);\n\t\t\t} // uvs\n\n\n\t\t\tfor (var _i8 = 0, _il5 = geometry.faceVertexUvs.length; _i8 < _il5; _i8++) {\n\t\t\t\tvar faceVertexUvs2 = geometry.faceVertexUvs[_i8];\n\t\t\t\tif (this.faceVertexUvs[_i8] === undefined) this.faceVertexUvs[_i8] = [];\n\n\t\t\t\tfor (var _j2 = 0, _jl2 = faceVertexUvs2.length; _j2 < _jl2; _j2++) {\n\t\t\t\t\tvar uvs2 = faceVertexUvs2[_j2],\n\t\t\t\t\t\t\tuvsCopy = [];\n\n\t\t\t\t\tfor (var k = 0, kl = uvs2.length; k < kl; k++) {\n\t\t\t\t\t\tuvsCopy.push(uvs2[k].clone());\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.faceVertexUvs[_i8].push(uvsCopy);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tmergeMesh: function mergeMesh(mesh) {\n\t\t\tif (!(mesh && mesh.isMesh)) {\n\t\t\t\tconsole.error('THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.', mesh);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (mesh.matrixAutoUpdate) mesh.updateMatrix();\n\t\t\tthis.merge(mesh.geometry, mesh.matrix);\n\t\t},\n\n\t\t/*\n\t\t * Checks for duplicate vertices with hashmap.\n\t\t * Duplicated vertices are removed\n\t\t * and faces' vertices are updated.\n\t\t */\n\t\tmergeVertices: function mergeVertices(precisionPoints) {\n\t\t\tif (precisionPoints === void 0) {\n\t\t\t\tprecisionPoints = 4;\n\t\t\t}\n\n\t\t\tvar verticesMap = {}; // Hashmap for looking up vertices by position coordinates (and making sure they are unique)\n\n\t\t\tvar unique = [],\n\t\t\t\t\tchanges = [];\n\t\t\tvar precision = Math.pow(10, precisionPoints);\n\n\t\t\tfor (var i = 0, il = this.vertices.length; i < il; i++) {\n\t\t\t\tvar v = this.vertices[i];\n\t\t\t\tvar key = Math.round(v.x * precision) + '_' + Math.round(v.y * precision) + '_' + Math.round(v.z * precision);\n\n\t\t\t\tif (verticesMap[key] === undefined) {\n\t\t\t\t\tverticesMap[key] = i;\n\t\t\t\t\tunique.push(this.vertices[i]);\n\t\t\t\t\tchanges[i] = unique.length - 1;\n\t\t\t\t} else {\n\t\t\t\t\t//console.log('Duplicate vertex found. ', i, ' could be using ', verticesMap[key]);\n\t\t\t\t\tchanges[i] = changes[verticesMap[key]];\n\t\t\t\t}\n\t\t\t} // if faces are completely degenerate after merging vertices, we\n\t\t\t// have to remove them from the geometry.\n\n\n\t\t\tvar faceIndicesToRemove = [];\n\n\t\t\tfor (var _i9 = 0, _il6 = this.faces.length; _i9 < _il6; _i9++) {\n\t\t\t\tvar face = this.faces[_i9];\n\t\t\t\tface.a = changes[face.a];\n\t\t\t\tface.b = changes[face.b];\n\t\t\t\tface.c = changes[face.c];\n\t\t\t\tvar indices = [face.a, face.b, face.c]; // if any duplicate vertices are found in a Face3\n\t\t\t\t// we have to remove the face as nothing can be saved\n\n\t\t\t\tfor (var n = 0; n < 3;
1 n++) {\n\t\t\t\t\tif (indices[n] === indices[(n + 1) % 3]) {\n\t\t\t\t\t\tfaceIndicesToRemove.push(_i9);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (var _i10 = faceIndicesToRemove.length - 1; _i10 >= 0; _i10--) {\n\t\t\t\tvar idx = faceIndicesToRemove[_i10];\n\t\t\t\tthis.faces.splice(idx, 1);\n\n\t\t\t\tfor (var j = 0, jl = this.faceVertexUvs.length; j < jl; j++) {\n\t\t\t\t\tthis.faceVertexUvs[j].splice(idx, 1);\n\t\t\t\t}\n\t\t\t} // Use unique set of vertices\n\n\n\t\t\tvar diff = this.vertices.length - unique.length;\n\t\t\tthis.vertices = unique;\n\t\t\treturn diff;\n\t\t},\n\t\tsetFromPoints: function setFromPoints(points) {\n\t\t\tthis.vertices = [];\n\n\t\t\tfor (var i = 0, l = points.length; i < l; i++) {\n\t\t\t\tvar point = points[i];\n\t\t\t\tthis.vertices.push(new Vector3(point.x, point.y, point.z || 0));\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tsortFacesByMaterialIndex: function sortFacesByMaterialIndex() {\n\t\t\tvar faces = this.faces;\n\t\t\tvar length = faces.length; // tag faces\n\n\t\t\tfor (var i = 0; i < length; i++) {\n\t\t\t\tfaces[i]._id = i;\n\t\t\t} // sort faces\n\n\n\t\t\tfunction materialIndexSort(a, b) {\n\t\t\t\treturn a.materialIndex - b.materialIndex;\n\t\t\t}\n\n\t\t\tfaces.sort(materialIndexSort); // sort uvs\n\n\t\t\tvar uvs1 = this.faceVertexUvs[0];\n\t\t\tvar uvs2 = this.faceVertexUvs[1];\n\t\t\tvar newUvs1, newUvs2;\n\t\t\tif (uvs1 && uvs1.length === length) newUvs1 = [];\n\t\t\tif (uvs2 && uvs2.length === length) newUvs2 = [];\n\n\t\t\tfor (var _i11 = 0; _i11 < length; _i11++) {\n\t\t\t\tvar id = faces[_i11]._id;\n\t\t\t\tif (newUvs1) newUvs1.push(uvs1[id]);\n\t\t\t\tif (newUvs2) newUvs2.push(uvs2[id]);\n\t\t\t}\n\n\t\t\tif (newUvs1) this.faceVertexUvs[0] = newUvs1;\n\t\t\tif (newUvs2) this.faceVertexUvs[1] = newUvs2;\n\t\t},\n\t\ttoJSON: function toJSON() {\n\t\t\tvar data = {\n\t\t\t\tmetadata: {\n\t\t\t\t\tversion: 4.5,\n\t\t\t\t\ttype: 'Geometry',\n\t\t\t\t\tgenerator: 'Geometry.toJSON'\n\t\t\t\t}\n\t\t\t}; // standard Geometry serialization\n\n\t\t\tdata.uuid = this.uuid;\n\t\t\tdata.type = this.type;\n\t\t\tif (this.name !== '') data.name = this.name;\n\n\t\t\tif (this.parameters !== undefined) {\n\t\t\t\tvar parameters = this.parameters;\n\n\t\t\t\tfor (var key in parameters) {\n\t\t\t\t\tif (parameters[key] !== undefined) data[key] = parameters[key];\n\t\t\t\t}\n\n\t\t\t\treturn data;\n\t\t\t}\n\n\t\t\tvar vertices = [];\n\n\t\t\tfor (var i = 0; i < this.vertices.length; i++) {\n\t\t\t\tvar vertex = this.vertices[i];\n\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z);\n\t\t\t}\n\n\t\t\tvar faces = [];\n\t\t\tvar normals = [];\n\t\t\tvar normalsHash = {};\n\t\t\tvar colors = [];\n\t\t\tvar colorsHash = {};\n\t\t\tvar uvs = [];\n\t\t\tvar uvsHash = {};\n\n\t\t\tfor (var _i12 = 0; _i12 < this.faces.length; _i12++) {\n\t\t\t\tvar face = this.faces[_i12];\n\t\t\t\tvar hasMaterial = true;\n\t\t\t\tvar hasFaceUv = false; // deprecated\n\n\t\t\t\tvar hasFaceVertexUv = this.faceVertexUvs[0][_i12] !== undefined;\n\t\t\t\tvar hasFaceNormal = face.normal.length() > 0;\n\t\t\t\tvar hasFaceVertexNormal = face.vertexNormals.length > 0;\n\t\t\t\tvar hasFaceColor = face.color.r !== 1 || face.color.g !== 1 || face.color.b !== 1;\n\t\t\t\tvar hasFaceVertexColor = face.vertexColors.length > 0;\n\t\t\t\tvar faceType = 0;\n\t\t\t\tfaceType = setBit(faceType, 0, 0); // isQuad\n\n\t\t\t\tfaceType = setBit(faceType, 1, hasMaterial);\n\t\t\t\tfaceType = setBit(faceType, 2, hasFaceUv);\n\t\t\t\tfaceType = setBit(faceType, 3, hasFaceVertexUv);\n\t\t\t\tfaceType = setBit(faceType, 4, hasFaceNormal);\n\t\t\t\tfaceType = setBit(faceType, 5, hasFaceVertexNormal);\n\t\t\t\tfaceType = setBit(faceType, 6, hasFaceColor);\n\t\t\t\tfaceType = setBit(faceType, 7, hasFaceVertexColor);\n\t\t\t\tfaces.push(faceType);\n\t\t\t\tfaces.push(face.a, face.b, face.c);\n\t\t\t\tfaces.push(face.materialIndex);\n\n\t\t\t\tif (hasFaceVertexUv) {\n\t\t\t\t\tvar faceVertexUvs = this.faceVertexUvs[0][_i12];\n\t\t\t\t\tfaces.push(getUvIndex(faceVertexUvs[0]), getUvIndex(faceVertexUvs[1]), getUvIndex(faceVertexUvs[2]));\n\t\t\t\t}\n\n\t\t\t\tif (hasFaceNormal) {\n\t\t\t\t\tfaces.push(getNormalIndex(face.normal));\n\t\t\t\t}\n\n\t\t\t\tif (hasFaceVertexNormal) {\n\t\t\t\t\tvar vertexNormals = face.vertexNormals;\n\t\t\t\t\tfaces.push(getNormalIndex(vertexNormals[0]), getNormalIndex(vertexNormals[1]), getNormalIndex(vertexNormals[2]));\n\t\t\t\t}\n\n\t\t\t\tif (hasFaceColor) {\n\t\t\t\t\tfaces.push(getColorIndex(face.color));\n\t\t\t\t}\n\n\t\t\t\tif (hasFaceVertexColor) {\n\t\t\t\t\tvar vertexColors = face.vertexColors;\n\t\t\t\t\tfaces.push(getColorIndex(vertexColors[0]), getColorIndex(vertexColors[1]), getColorIndex(vertexColors[2]));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction setBit(value, position, enabled) {\n\t\t\t\treturn enabled ? value | 1 << position : value & ~(1 << position);\n\t\t\t}\n\n\t\t\tfunction getNormalIndex(normal) {\n\t\t\t\tvar hash = normal.x.toString() + normal.y.toString() + normal.z.toString();\n\n\t\t\t\tif (normalsHash[hash] !== undefined) {\n\t\t\t\t\treturn normalsHash[hash];\n\t\t\t\t}\n\n\t\t\t\tnormalsHash[hash] = normals.length / 3;\n\t\t\t\tnormals.push(normal.x, normal.y, normal.z);\n\t\t\t\treturn normalsHash[hash];\n\t\t\t}\n\n\t\t\tfunction getColorIndex(color) {\n\t\t\t\tvar hash = color.r.toString() + color.g.toString() + color.b.toString();\n\n\t\t\t\tif (colorsHash[hash] !== undefined) {\n\t\t\t\t\treturn colorsHash[hash];\n\t\t\t\t}\n\n\t\t\t\tcolorsHash[hash] = colors.length;\n\t\t\t\tcolors.push(color.getHex());\n\t\t\t\treturn colorsHash[hash];\n\t\t\t}\n\n\t\t\tfunction getUvIndex(uv) {\n\t\t\t\tvar hash = uv.x.toString() + uv.y.toString();\n\n\t\t\t\tif (uvsHash[hash] !== undefined) {\n\t\t\t\t\treturn uvsHash[hash];\n\t\t\t\t}\n\n\t\t\t\tuvsHash[hash] = uvs.length / 2;\n\t\t\t\tuvs.push(uv.x, uv.y);\n\t\t\t\treturn uvsHash[hash];\n\t\t\t}\n\n\t\t\tdata.data = {};\n\t\t\tdata.data.vertices = vertices;\n\t\t\tdata.data.normals = normals;\n\t\t\tif (colors.length > 0) data.data.colors = colors;\n\t\t\tif (uvs.length > 0) data.data.uvs = [uvs]; // temporal backward compatibility\n\n\t\t\tdata.data.faces = faces;\n\t\t\treturn data;\n\t\t},\n\t\tclone: function clone() {\n\t\t\t/*\n\t\t\t // Handle primitives\n\t\t\t\t const parameters = this.parameters;\n\t\t\t\t if ( parameters !== undefined ) {\n\t\t\t\t const values = [];\n\t\t\t\t for ( const key in parameters ) {\n\t\t\t\t values.push( parameters[ key ] );\n\t\t\t\t }\n\t\t\t\t const geometry = Object.create( this.constructor.prototype );\n\t\t\t this.constructor.apply( geometry, values );\n\t\t\t return geometry;\n\t\t\t\t }\n\t\t\t\t return new this.constructor().copy( this );\n\t\t\t */\n\t\t\treturn new Geometry().copy(this);\n\t\t},\n\t\tcopy: function copy(source) {\n\t\t\t// reset\n\t\t\tthis.vertices = [];\n\t\t\tthis.colors = [];\n\t\t\tthis.faces = [];\n\t\t\tthis.faceVertexUvs = [[]];\n\t\t\tthis.morphTargets = [];\n\t\t\tthis.morphNormals = [];\n\t\t\tthis.skinWeights = [];\n\t\t\tthis.skinIndices = [];\n\t\t\tthis.lineDistances = [];\n\t\t\tthis.boundingBox = null;\n\t\t\tthis.boundingSphere = null; // name\n\n\t\t\tthis.name = source.name; // vertices\n\n\t\t\tvar vertices = source.vertices;\n\n\t\t\tfor (var i = 0, il = vertices.length; i < il;
1 i++) {\n\t\t\t\tthis.vertices.push(vertices[i].clone());\n\t\t\t} // colors\n\n\n\t\t\tvar colors = source.colors;\n\n\t\t\tfor (var _i13 = 0, _il7 = colors.length; _i13 < _il7; _i13++) {\n\t\t\t\tthis.colors.push(colors[_i13].clone());\n\t\t\t} // faces\n\n\n\t\t\tvar faces = source.faces;\n\n\t\t\tfor (var _i14 = 0, _il8 = faces.length; _i14 < _il8; _i14++) {\n\t\t\t\tthis.faces.push(faces[_i14].clone());\n\t\t\t} // face vertex uvs\n\n\n\t\t\tfor (var _i15 = 0, _il9 = source.faceVertexUvs.length; _i15 < _il9; _i15++) {\n\t\t\t\tvar faceVertexUvs = source.faceVertexUvs[_i15];\n\n\t\t\t\tif (this.faceVertexUvs[_i15] === undefined) {\n\t\t\t\t\tthis.faceVertexUvs[_i15] = [];\n\t\t\t\t}\n\n\t\t\t\tfor (var j = 0, jl = faceVertexUvs.length; j < jl; j++) {\n\t\t\t\t\tvar uvs = faceVertexUvs[j],\n\t\t\t\t\t\t\tuvsCopy = [];\n\n\t\t\t\t\tfor (var k = 0, kl = uvs.length; k < kl; k++) {\n\t\t\t\t\t\tvar uv = uvs[k];\n\t\t\t\t\t\tuvsCopy.push(uv.clone());\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.faceVertexUvs[_i15].push(uvsCopy);\n\t\t\t\t}\n\t\t\t} // morph targets\n\n\n\t\t\tvar morphTargets = source.morphTargets;\n\n\t\t\tfor (var _i16 = 0, _il10 = morphTargets.length; _i16 < _il10; _i16++) {\n\t\t\t\tvar morphTarget = {};\n\t\t\t\tmorphTarget.name = morphTargets[_i16].name; // vertices\n\n\t\t\t\tif (morphTargets[_i16].vertices !== undefined) {\n\t\t\t\t\tmorphTarget.vertices = [];\n\n\t\t\t\t\tfor (var _j3 = 0, _jl3 = morphTargets[_i16].vertices.length; _j3 < _jl3; _j3++) {\n\t\t\t\t\t\tmorphTarget.vertices.push(morphTargets[_i16].vertices[_j3].clone());\n\t\t\t\t\t}\n\t\t\t\t} // normals\n\n\n\t\t\t\tif (morphTargets[_i16].normals !== undefined) {\n\t\t\t\t\tmorphTarget.normals = [];\n\n\t\t\t\t\tfor (var _j4 = 0, _jl4 = morphTargets[_i16].normals.length; _j4 < _jl4; _j4++) {\n\t\t\t\t\t\tmorphTarget.normals.push(morphTargets[_i16].normals[_j4].clone());\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.morphTargets.push(morphTarget);\n\t\t\t} // morph normals\n\n\n\t\t\tvar morphNormals = source.morphNormals;\n\n\t\t\tfor (var _i17 = 0, _il11 = morphNormals.length; _i17 < _il11; _i17++) {\n\t\t\t\tvar morphNormal = {}; // vertex normals\n\n\t\t\t\tif (morphNormals[_i17].vertexNormals !== undefined) {\n\t\t\t\t\tmorphNormal.vertexNormals = [];\n\n\t\t\t\t\tfor (var _j5 = 0, _jl5 = morphNormals[_i17].vertexNormals.length; _j5 < _jl5; _j5++) {\n\t\t\t\t\t\tvar srcVertexNormal = morphNormals[_i17].vertexNormals[_j5];\n\t\t\t\t\t\tvar destVertexNormal = {};\n\t\t\t\t\t\tdestVertexNormal.a = srcVertexNormal.a.clone();\n\t\t\t\t\t\tdestVertexNormal.b = srcVertexNormal.b.clone();\n\t\t\t\t\t\tdestVertexNormal.c = srcVertexNormal.c.clone();\n\t\t\t\t\t\tmorphNormal.vertexNormals.push(destVertexNormal);\n\t\t\t\t\t}\n\t\t\t\t} // face normals\n\n\n\t\t\t\tif (morphNormals[_i17].faceNormals !== undefined) {\n\t\t\t\t\tmorphNormal.faceNormals = [];\n\n\t\t\t\t\tfor (var _j6 = 0, _jl6 = morphNormals[_i17].faceNormals.length; _j6 < _jl6; _j6++) {\n\t\t\t\t\t\tmorphNormal.faceNormals.push(morphNormals[_i17].faceNormals[_j6].clone());\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.morphNormals.push(morphNormal);\n\t\t\t} // skin weights\n\n\n\t\t\tvar skinWeights = source.skinWeights;\n\n\t\t\tfor (var _i18 = 0, _il12 = skinWeights.length; _i18 < _il12; _i18++) {\n\t\t\t\tthis.skinWeights.push(skinWeights[_i18].clone());\n\t\t\t} // skin indices\n\n\n\t\t\tvar skinIndices = source.skinIndices;\n\n\t\t\tfor (var _i19 = 0, _il13 = skinIndices.length; _i19 < _il13; _i19++) {\n\t\t\t\tthis.skinIndices.push(skinIndices[_i19].clone());\n\t\t\t} // line distances\n\n\n\t\t\tvar lineDistances = source.lineDistances;\n\n\t\t\tfor (var _i20 = 0, _il14 = lineDistances.length; _i20 < _il14; _i20++) {\n\t\t\t\tthis.lineDistances.push(lineDistances[_i20]);\n\t\t\t} // bounding box\n\n\n\t\t\tvar boundingBox = source.boundingBox;\n\n\t\t\tif (boundingBox !== null) {\n\t\t\t\tthis.boundingBox = boundingBox.clone();\n\t\t\t} // bounding sphere\n\n\n\t\t\tvar boundingSphere = source.boundingSphere;\n\n\t\t\tif (boundingSphere !== null) {\n\t\t\t\tthis.boundingSphere = boundingSphere.clone();\n\t\t\t} // update flags\n\n\n\t\t\tthis.elementsNeedUpdate = source.elementsNeedUpdate;\n\t\t\tthis.verticesNeedUpdate = source.verticesNeedUpdate;\n\t\t\tthis.uvsNeedUpdate = source.uvsNeedUpdate;\n\t\t\tthis.normalsNeedUpdate = source.normalsNeedUpdate;\n\t\t\tthis.colorsNeedUpdate = source.colorsNeedUpdate;\n\t\t\tthis.lineDistancesNeedUpdate = source.lineDistancesNeedUpdate;\n\t\t\tthis.groupsNeedUpdate = source.groupsNeedUpdate;\n\t\t\treturn this;\n\t\t},\n\t\tdispose: function dispose() {\n\t\t\tthis.dispatchEvent({\n\t\t\t\ttype: 'dispose'\n\t\t\t});\n\t\t}\n\t});\n\n\tvar BoxGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(BoxGeometry, _Geometry);\n\n\t\tfunction BoxGeometry(width, height, depth, widthSegments, heightSegments, depthSegments) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'BoxGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\twidth: width,\n\t\t\t\theight: height,\n\t\t\t\tdepth: depth,\n\t\t\t\twidthSegments: widthSegments,\n\t\t\t\theightSegments: heightSegments,\n\t\t\t\tdepthSegments: depthSegments\n\t\t\t};\n\n\t\t\t_this.fromBufferGeometry(new BoxBufferGeometry(width, height, depth, widthSegments, heightSegments, depthSegments));\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn BoxGeometry;\n\t}(Geometry);\n\n\tvar CircleBufferGeometry = /*#__PURE__*/function (_BufferGeometry) {\n\t\t_inheritsLoose(CircleBufferGeometry, _BufferGeometry);\n\n\t\tfunction CircleBufferGeometry(radius, segments, thetaStart, thetaLength) {\n\t\t\tvar _this;\n\n\t\t\tif (radius === void 0) {\n\t\t\t\tradius = 1;\n\t\t\t}\n\n\t\t\tif (segments === void 0) {\n\t\t\t\tsegments = 8;\n\t\t\t}\n\n\t\t\tif (thetaStart === void 0) {\n\t\t\t\tthetaStart = 0;\n\t\t\t}\n\n\t\t\tif (thetaLength === void 0) {\n\t\t\t\tthetaLength = Math.PI * 2;\n\t\t\t}\n\n\t\t\t_this = _BufferGeometry.call(this) || this;
1\n\t\t\t_this.type = 'CircleBufferGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\tsegments: segments,\n\t\t\t\tthetaStart: thetaStart,\n\t\t\t\tthetaLength: thetaLength\n\t\t\t};\n\t\t\tsegments = Math.max(3, segments); // buffers\n\n\t\t\tvar indices = [];\n\t\t\tvar vertices = [];\n\t\t\tvar normals = [];\n\t\t\tvar uvs = []; // helper variables\n\n\t\t\tvar vertex = new Vector3();\n\t\t\tvar uv = new Vector2(); // center point\n\n\t\t\tvertices.push(0, 0, 0);\n\t\t\tnormals.push(0, 0, 1);\n\t\t\tuvs.push(0.5, 0.5);\n\n\t\t\tfor (var s = 0, i = 3; s <= segments; s++, i += 3) {\n\t\t\t\tvar segment = thetaStart + s / segments * thetaLength; // vertex\n\n\t\t\t\tvertex.x = radius * Math.cos(segment);\n\t\t\t\tvertex.y = radius * Math.sin(segment);\n\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z); // normal\n\n\t\t\t\tnormals.push(0, 0, 1); // uvs\n\n\t\t\t\tuv.x = (vertices[i] / radius + 1) / 2;\n\t\t\t\tuv.y = (vertices[i + 1] / radius + 1) / 2;\n\t\t\t\tuvs.push(uv.x, uv.y);\n\t\t\t} // indices\n\n\n\t\t\tfor (var _i = 1; _i <= segments; _i++) {\n\t\t\t\tindices.push(_i, _i + 1, 0);\n\t\t\t} // build geometry\n\n\n\t\t\t_this.setIndex(indices);\n\n\t\t\t_this.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\n\t\t\t_this.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\n\t\t\t_this.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn CircleBufferGeometry;\n\t}(BufferGeometry);\n\n\tvar CircleGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(CircleGeometry, _Geometry);\n\n\t\tfunction CircleGeometry(radius, segments, thetaStart, thetaLength) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'CircleGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\tsegments: segments,\n\t\t\t\tthetaStart: thetaStart,\n\t\t\t\tthetaLength: thetaLength\n\t\t\t};\n\n\t\t\t_this.fromBufferGeometry(new CircleBufferGeometry(radius, segments, thetaStart, thetaLength));\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn CircleGeometry;\n\t}(Geometry);\n\n\tvar CylinderBufferGeometry = /*#__PURE__*/function (_BufferGeometry) {\n\t\t_inheritsLoose(CylinderBufferGeometry, _BufferGeometry);\n\n\t\tfunction CylinderBufferGeometry(radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength) {\n\t\t\tvar _this;\n\n\t\t\tif (radiusTop === void 0) {\n\t\t\t\tradiusTop = 1;\n\t\t\t}\n\n\t\t\tif (radiusBottom === void 0) {\n\t\t\t\tradiusBottom = 1;\n\t\t\t}\n\n\t\t\tif (height === void 0) {\n\t\t\t\theight = 1;\n\t\t\t}\n\n\t\t\tif (radialSegments === void 0) {\n\t\t\t\tradialSegments = 8;\n\t\t\t}\n\n\t\t\tif (heightSegments === void 0) {\n\t\t\t\theightSegments = 1;\n\t\t\t}\n\n\t\t\tif (openEnded === void 0) {\n\t\t\t\topenEnded = false;\n\t\t\t}\n\n\t\t\tif (thetaStart === void 0) {\n\t\t\t\tthetaStart = 0;\n\t\t\t}\n\n\t\t\tif (thetaLength === void 0) {\n\t\t\t\tthetaLength = Math.PI * 2;\n\t\t\t}\n\n\t\t\t_this = _BufferGeometry.call(this) || this;\n\t\t\t_this.type = 'CylinderBufferGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tradiusTop: radiusTop,\n\t\t\t\tradiusBottom: radiusBottom,\n\t\t\t\theight: height,\n\t\t\t\tradialSegments: radialSegments,\n\t\t\t\theightSegments: heightSegments,\n\t\t\t\topenEnded: openEnded,\n\t\t\t\tthetaStart: thetaStart,\n\t\t\t\tthetaLength: thetaLength\n\t\t\t};\n\n\t\t\tvar scope = _assertThisInitialized(_this);\n\n\t\t\tradialSegments = Math.floor(radialSegments);\n\t\t\theightSegments = Math.floor(heightSegments); // buffers\n\n\t\t\tvar indices = [];\n\t\t\tvar vertices = [];\n\t\t\tvar normals = [];\n\t\t\tvar uvs = []; // helper variables\n\n\t\t\tvar index = 0;\n\t\t\tvar indexArray = [];\n\t\t\tvar halfHeight = height / 2;\n\t\t\tvar groupStart = 0; // generate geometry\n\n\t\t\tgenerateTorso();\n\n\t\t\tif (openEnded === false) {\n\t\t\t\tif (radiusTop > 0) generateCap(true);\n\t\t\t\tif (radiusBottom > 0) generateCap(false);\n\t\t\t} // build geometry\n\n\n\t\t\t_this.setIndex(indices);\n\n\t\t\t_this.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\n\t\t\t_this.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\n\t\t\t_this.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\n\t\t\tfunction generateTorso() {\n\t\t\t\tvar normal = new Vector3();\n\t\t\t\tvar vertex = new Vector3();\n\t\t\t\tvar groupCount = 0; // this will be used to calculate the normal\n\n\t\t\t\tvar slope = (radiusBottom - radiusTop) / height; // generate vertices, normals and uvs\n\n\t\t\t\tfor (var y = 0; y <= heightSegments;
1 y++) {\n\t\t\t\t\tvar indexRow = [];\n\t\t\t\t\tvar v = y / heightSegments; // calculate the radius of the current row\n\n\t\t\t\t\tvar radius = v * (radiusBottom - radiusTop) + radiusTop;\n\n\t\t\t\t\tfor (var x = 0; x <= radialSegments; x++) {\n\t\t\t\t\t\tvar u = x / radialSegments;\n\t\t\t\t\t\tvar theta = u * thetaLength + thetaStart;\n\t\t\t\t\t\tvar sinTheta = Math.sin(theta);\n\t\t\t\t\t\tvar cosTheta = Math.cos(theta); // vertex\n\n\t\t\t\t\t\tvertex.x = radius * sinTheta;\n\t\t\t\t\t\tvertex.y = -v * height + halfHeight;\n\t\t\t\t\t\tvertex.z = radius * cosTheta;\n\t\t\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z); // normal\n\n\t\t\t\t\t\tnormal.set(sinTheta, slope, cosTheta).normalize();\n\t\t\t\t\t\tnormals.push(normal.x, normal.y, normal.z); // uv\n\n\t\t\t\t\t\tuvs.push(u, 1 - v); // save index of vertex in respective row\n\n\t\t\t\t\t\tindexRow.push(index++);\n\t\t\t\t\t} // now save vertices of the row in our index array\n\n\n\t\t\t\t\tindexArray.push(indexRow);\n\t\t\t\t} // generate indices\n\n\n\t\t\t\tfor (var _x = 0; _x < radialSegments; _x++) {\n\t\t\t\t\tfor (var _y = 0; _y < heightSegments; _y++) {\n\t\t\t\t\t\t// we use the index array to access the correct indices\n\t\t\t\t\t\tvar a = indexArray[_y][_x];\n\t\t\t\t\t\tvar b = indexArray[_y + 1][_x];\n\t\t\t\t\t\tvar c = indexArray[_y + 1][_x + 1];\n\t\t\t\t\t\tvar d = indexArray[_y][_x + 1]; // faces\n\n\t\t\t\t\t\tindices.push(a, b, d);\n\t\t\t\t\t\tindices.push(b, c, d); // update group counter\n\n\t\t\t\t\t\tgroupCount += 6;\n\t\t\t\t\t}\n\t\t\t\t} // add a group to the geometry. this will ensure multi material support\n\n\n\t\t\t\tscope.addGroup(groupStart, groupCount, 0); // calculate new start value for groups\n\n\t\t\t\tgroupStart += groupCount;\n\t\t\t}\n\n\t\t\tfunction generateCap(top) {\n\t\t\t\t// save the index of the first center vertex\n\t\t\t\tvar centerIndexStart = index;\n\t\t\t\tvar uv = new Vector2();\n\t\t\t\tvar vertex = new Vector3();\n\t\t\t\tvar groupCount = 0;\n\t\t\t\tvar radius = top === true ? radiusTop : radiusBottom;\n\t\t\t\tvar sign = top === true ? 1 : -1; // first we generate the center vertex data of the cap.\n\t\t\t\t// because the geometry needs one set of uvs per face,\n\t\t\t\t// we must generate a center vertex per face/segment\n\n\t\t\t\tfor (var x = 1; x <= radialSegments; x++) {\n\t\t\t\t\t// vertex\n\t\t\t\t\tvertices.push(0, halfHeight * sign, 0); // normal\n\n\t\t\t\t\tnormals.push(0, sign, 0); // uv\n\n\t\t\t\t\tuvs.push(0.5, 0.5); // increase index\n\n\t\t\t\t\tindex++;\n\t\t\t\t} // save the index of the last center vertex\n\n\n\t\t\t\tvar centerIndexEnd = index; // now we generate the surrounding vertices, normals and uvs\n\n\t\t\t\tfor (var _x2 = 0; _x2 <= radialSegments; _x2++) {\n\t\t\t\t\tvar u = _x2 / radialSegments;\n\t\t\t\t\tvar theta = u * thetaLength + thetaStart;\n\t\t\t\t\tvar cosTheta = Math.cos(theta);\n\t\t\t\t\tvar sinTheta = Math.sin(theta); // vertex\n\n\t\t\t\t\tvertex.x = radius * sinTheta;\n\t\t\t\t\tvertex.y = halfHeight * sign;\n\t\t\t\t\tvertex.z = radius * cosTheta;\n\t\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z); // normal\n\n\t\t\t\t\tnormals.push(0, sign, 0); // uv\n\n\t\t\t\t\tuv.x = cosTheta * 0.5 + 0.5;\n\t\t\t\t\tuv.y = sinTheta * 0.5 * sign + 0.5;\n\t\t\t\t\tuvs.push(uv.x, uv.y); // increase index\n\n\t\t\t\t\tindex++;\n\t\t\t\t} // generate indices\n\n\n\t\t\t\tfor (var _x3 = 0; _x3 < radialSegments; _x3++) {\n\t\t\t\t\tvar c = centerIndexStart + _x3;\n\t\t\t\t\tvar i = centerIndexEnd + _x3;\n\n\t\t\t\t\tif (top === true) {\n\t\t\t\t\t\t// face top\n\t\t\t\t\t\tindices.push(i, i + 1, c);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// face bottom\n\t\t\t\t\t\tindices.push(i + 1, i, c);\n\t\t\t\t\t}\n\n\t\t\t\t\tgroupCount += 3;\n\t\t\t\t} // add a group to the geometry. this will ensure multi material support\n\n\n\t\t\t\tscope.addGroup(groupStart, groupCount, top === true ? 1 : 2); // calculate new start value for groups\n\n\t\t\t\tgroupStart += groupCount;\n\t\t\t}\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn CylinderBufferGeometry;\n\t}(BufferGeometry);\n\n\tvar CylinderGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(CylinderGeometry, _Geometry);\n\n\t\tfunction CylinderGeometry(radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'CylinderGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tradiusTop: radiusTop,\n\t\t\t\tradiusBottom: radiu
1sBottom,\n\t\t\t\theight: height,\n\t\t\t\tradialSegments: radialSegments,\n\t\t\t\theightSegments: heightSegments,\n\t\t\t\topenEnded: openEnded,\n\t\t\t\tthetaStart: thetaStart,\n\t\t\t\tthetaLength: thetaLength\n\t\t\t};\n\n\t\t\t_this.fromBufferGeometry(new CylinderBufferGeometry(radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength));\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn CylinderGeometry;\n\t}(Geometry);\n\n\tvar ConeGeometry = /*#__PURE__*/function (_CylinderGeometry) {\n\t\t_inheritsLoose(ConeGeometry, _CylinderGeometry);\n\n\t\tfunction ConeGeometry(radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength) {\n\t\t\tvar _this;\n\n\t\t\t_this = _CylinderGeometry.call(this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength) || this;\n\t\t\t_this.type = 'ConeGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\theight: height,\n\t\t\t\tradialSegments: radialSegments,\n\t\t\t\theightSegments: heightSegments,\n\t\t\t\topenEnded: openEnded,\n\t\t\t\tthetaStart: thetaStart,\n\t\t\t\tthetaLength: thetaLength\n\t\t\t};\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn ConeGeometry;\n\t}(CylinderGeometry);\n\n\tvar ConeBufferGeometry = /*#__PURE__*/function (_CylinderBufferGeomet) {\n\t\t_inheritsLoose(ConeBufferGeometry, _CylinderBufferGeomet);\n\n\t\tfunction ConeBufferGeometry(radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength) {\n\t\t\tvar _this;\n\n\t\t\tif (radius === void 0) {\n\t\t\t\tradius = 1;\n\t\t\t}\n\n\t\t\tif (height === void 0) {\n\t\t\t\theight = 1;\n\t\t\t}\n\n\t\t\tif (radialSegments === void 0) {\n\t\t\t\tradialSegments = 8;\n\t\t\t}\n\n\t\t\tif (heightSegments === void 0) {\n\t\t\t\theightSegments = 1;\n\t\t\t}\n\n\t\t\tif (openEnded === void 0) {\n\t\t\t\topenEnded = false;\n\t\t\t}\n\n\t\t\tif (thetaStart === void 0) {\n\t\t\t\tthetaStart = 0;\n\t\t\t}\n\n\t\t\tif (thetaLength === void 0) {\n\t\t\t\tthetaLength = Math.PI * 2;\n\t\t\t}\n\n\t\t\t_this = _CylinderBufferGeomet.call(this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength) || this;\n\t\t\t_this.type = 'ConeBufferGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\theight: height,\n\t\t\t\tradialSegments: radialSegments,\n\t\t\t\theightSegments: heightSegments,\n\t\t\t\topenEnded: openEnded,\n\t\t\t\tthetaStart: thetaStart,\n\t\t\t\tthetaLength: thetaLength\n\t\t\t};\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn ConeBufferGeometry;\n\t}(CylinderBufferGeometry);\n\n\tvar PolyhedronBufferGeometry = /*#__PURE__*/function (_BufferGeometry) {\n\t\t_inheritsLoose(PolyhedronBufferGeometry, _BufferGeometry);\n\n\t\tfunction PolyhedronBufferGeometry(vertices, indices, radius, detail) {\n\t\t\tvar _this;\n\n\t\t\tif (radius === void 0) {\n\t\t\t\tradius = 1;\n\t\t\t}\n\n\t\t\tif (detail === void 0) {\n\t\t\t\tdetail = 0;\n\t\t\t}\n\n\t\t\t_this = _BufferGeometry.call(this) || this;\n\t\t\t_this.type = 'PolyhedronBufferGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tvertices: vertices,\n\t\t\t\tindices: indices,\n\t\t\t\tradius: radius,\n\t\t\t\tdetail: detail\n\t\t\t}; // default buffer data\n\n\t\t\tvar vertexBuffer = [];\n\t\t\tvar uvBuffer = []; // the subdivision creates the vertex buffer data\n\n\t\t\tsubdivide(detail); // all vertices should lie on a conceptual sphere with a given radius\n\n\t\t\tapplyRadius(radius); // finally, create the uv data\n\n\t\t\tgenerateUVs(); // build non-indexed geometry\n\n\t\t\t_this.setAttribute('position', new Float32BufferAttribute(vertexBuffer, 3));\n\n\t\t\t_this.setAttribute('normal', new Float32BufferAttribute(vertexBuffer.slice(), 3));\n\n\t\t\t_this.setAttribute('uv', new Float32BufferAttribute(uvBuffer, 2));\n\n\t\t\tif (detail === 0) {\n\t\t\t\t_this.computeVertexNormals(); // flat normals\n\n\t\t\t} else {\n\t\t\t\t_this.normalizeNormals(); // smooth normals\n\n\t\t\t} // helper functions\n\n\n\t\t\tfunction subdivide(detail) {\n\t\t\t\tvar a = new Vector3();\n\t\t\t\tvar b = new Vector3();\n\t\t\t\tvar c = new Vector3(); // iterate over all faces and apply a subdivison with the given detail value\n\n\t\t\t\tfor (var i = 0; i < indices.length; i += 3) {\n\t\t\t\t\t// get the vertices of the face\n\t\t\t\t\tgetVertexByIndex(indices[i + 0], a);\n\t\t\t\t\tgetVertexByIndex(indices[i + 1], b);\n\t\t\t\t\tgetVertexByIndex(indices[i + 2], c); // perform subdivision\n\n\t\t\t\t\tsubdivideFace(a, b, c, detail);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction subdivideFace(a, b, c, detail) {\n\t\t\t\tvar cols = detail + 1; // we use this multidimensional array as a data structure for creating the subdivision\n\n\t\t\t\tvar v = []; // construct all of the vertices for this subdivision\n\n\t\t\t\tfor (var i = 0; i <= cols;
1 i++) {\n\t\t\t\t\tv[i] = [];\n\t\t\t\t\tvar aj = a.clone().lerp(c, i / cols);\n\t\t\t\t\tvar bj = b.clone().lerp(c, i / cols);\n\t\t\t\t\tvar rows = cols - i;\n\n\t\t\t\t\tfor (var j = 0; j <= rows; j++) {\n\t\t\t\t\t\tif (j === 0 && i === cols) {\n\t\t\t\t\t\t\tv[i][j] = aj;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tv[i][j] = aj.clone().lerp(bj, j / rows);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} // construct all of the faces\n\n\n\t\t\t\tfor (var _i = 0; _i < cols; _i++) {\n\t\t\t\t\tfor (var _j = 0; _j < 2 * (cols - _i) - 1; _j++) {\n\t\t\t\t\t\tvar k = Math.floor(_j / 2);\n\n\t\t\t\t\t\tif (_j % 2 === 0) {\n\t\t\t\t\t\t\tpushVertex(v[_i][k + 1]);\n\t\t\t\t\t\t\tpushVertex(v[_i + 1][k]);\n\t\t\t\t\t\t\tpushVertex(v[_i][k]);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tpushVertex(v[_i][k + 1]);\n\t\t\t\t\t\t\tpushVertex(v[_i + 1][k + 1]);\n\t\t\t\t\t\t\tpushVertex(v[_i + 1][k]);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction applyRadius(radius) {\n\t\t\t\tvar vertex = new Vector3(); // iterate over the entire buffer and apply the radius to each vertex\n\n\t\t\t\tfor (var i = 0; i < vertexBuffer.length; i += 3) {\n\t\t\t\t\tvertex.x = vertexBuffer[i + 0];\n\t\t\t\t\tvertex.y = vertexBuffer[i + 1];\n\t\t\t\t\tvertex.z = vertexBuffer[i + 2];\n\t\t\t\t\tvertex.normalize().multiplyScalar(radius);\n\t\t\t\t\tvertexBuffer[i + 0] = vertex.x;\n\t\t\t\t\tvertexBuffer[i + 1] = vertex.y;\n\t\t\t\t\tvertexBuffer[i + 2] = vertex.z;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction generateUVs() {\n\t\t\t\tvar vertex = new Vector3();\n\n\t\t\t\tfor (var i = 0; i < vertexBuffer.length; i += 3) {\n\t\t\t\t\tvertex.x = vertexBuffer[i + 0];\n\t\t\t\t\tvertex.y = vertexBuffer[i + 1];\n\t\t\t\t\tvertex.z = vertexBuffer[i + 2];\n\t\t\t\t\tvar u = azimuth(vertex) / 2 / Math.PI + 0.5;\n\t\t\t\t\tvar v = inclination(vertex) / Math.PI + 0.5;\n\t\t\t\t\tuvBuffer.push(u, 1 - v);\n\t\t\t\t}\n\n\t\t\t\tcorrectUVs();\n\t\t\t\tcorrectSeam();\n\t\t\t}\n\n\t\t\tfunction correctSeam() {\n\t\t\t\t// handle case when face straddles the seam, see #3269\n\t\t\t\tfor (var i = 0; i < uvBuffer.length; i += 6) {\n\t\t\t\t\t// uv data of a single face\n\t\t\t\t\tvar x0 = uvBuffer[i + 0];\n\t\t\t\t\tvar x1 = uvBuffer[i + 2];\n\t\t\t\t\tvar x2 = uvBuffer[i + 4];\n\t\t\t\t\tvar max = Math.max(x0, x1, x2);\n\t\t\t\t\tvar min = Math.min(x0, x1, x2); // 0.9 is somewhat arbitrary\n\n\t\t\t\t\tif (max > 0.9 && min < 0.1) {\n\t\t\t\t\t\tif (x0 < 0.2) uvBuffer[i + 0] += 1;\n\t\t\t\t\t\tif (x1 < 0.2) uvBuffer[i + 2] += 1;\n\t\t\t\t\t\tif (x2 < 0.2) uvBuffer[i + 4] += 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction pushVertex(vertex) {\n\t\t\t\tvertexBuffer.push(vertex.x, vertex.y, vertex.z);\n\t\t\t}\n\n\t\t\tfunction getVertexByIndex(index, vertex) {\n\t\t\t\tvar stride = index * 3;\n\t\t\t\tvertex.x = vertices[stride + 0];\n\t\t\t\tvertex.y = vertices[stride + 1];\n\t\t\t\tvertex.z = vertices[stride + 2];\n\t\t\t}\n\n\t\t\tfunction correctUVs() {\n\t\t\t\tvar a = new Vector3();\n\t\t\t\tvar b = new Vector3();\n\t\t\t\tvar c = new Vector3();\n\t\t\t\tvar centroid = new Vector3();\n\t\t\t\tvar uvA = new Vector2();\n\t\t\t\tvar uvB = new Vector2();\n\t\t\t\tvar uvC = new Vector2();\n\n\t\t\t\tfor (var i = 0, j = 0; i < vertexBuffer.length; i += 9, j += 6) {\n\t\t\t\t\ta.set(vertexBuffer[i + 0], vertexBuffer[i + 1], vertexBuffer[i + 2]);\n\t\t\t\t\tb.set(vertexBuffer[i + 3], vertexBuffer[i + 4], vertexBuffer[i + 5]);\n\t\t\t\t\tc.set(vertexBuffer[i + 6], vertexBuffer[i + 7], vertexBuffer[i + 8]);\n\t\t\t\t\tuvA.set(uvBuffer[j + 0], uvBuffer[j + 1]);\n\t\t\t\t\tuvB.set(uvBuffer[j + 2], uvBuffer[j + 3]);\n\t\t\t\t\tuvC.set(uvBuffer[j + 4], uvBuffer[j + 5]);\n\t\t\t\t\tcentroid.copy(a).add(b).add(c).divideScalar(3);\n\t\t\t\t\tvar azi = azimuth(centroid);\n\t\t\t\t\tcorrectUV(uvA, j + 0, a, azi);\n\t\t\t\t\tcorrectUV(uvB, j + 2, b, azi);\n\t\t\t\t\tcorrectUV(uvC, j + 4, c, azi);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction correctUV(uv, stride, vector, azimuth) {\n\t\t\t\tif (azimuth < 0 && uv.x === 1) {\n\t\t\t\t\tuvBuffer[stride] = uv.x - 1;\n\t\t\t\t}\n\n\t\t\t\tif (vector.x === 0 && vector.z === 0) {\n\t\t\t\t\tuvBuffer[stride] = azimuth / 2 / Math.PI + 0.5;\n\t\t\t\t}\n\t\t\t} // Angle around the Y axis, counter-clockwise when looking from above.\n\n\n\t\t\tfunction azimuth(vector) {\n\t\t\t\treturn Math.atan2(vector.z, -vector.x);\n\t\t\t} // Angle above the XZ plane.\n\n\n\t\t\tfunction inclination(vector) {\n\t\t\t\treturn Math.atan2(-vector.y, Math.sqrt(vector.x * vector.x + vector.z * vector.z));\n\t\t\t}\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn PolyhedronBufferGeometry;\n\t}(BufferGeometry);\n\n\tvar DodecahedronBufferGeometry = /*#__PURE__*/function (_PolyhedronBufferGeom) {\n\t\t_inheritsLoose(DodecahedronBufferGeometry, _PolyhedronBufferGeom);\n\n\t\tfunction DodecahedronBufferGeometry(radius, detail) {\n\t\t\tvar _this;\n\n\t\t\tif (radius === void 0) {\n\t\t\t\tradius = 1;\n\t\t\t}\n\n\t\t\tif (detail === void 0) {\n\t\t\t\tdetail = 0;\n\t\t\t}\n\n\t\t\tvar t = (1 + Math.sqrt(5)) / 2;\n\t\t\tvar r = 1 / t;\n\t\t\tvar vertices = [// (±1, ±1, ±1)\n\t\t\t-1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, // (0, ±1/Ï, ±Ï)\n\t\t\t0, -r, -t, 0, -r, t, 0, r, -t, 0, r, t, // (±1/Ï, ±Ï, 0)\n\t\t\t-r, -t, 0, -r, t, 0, r, -t, 0, r, t, 0, // (±Ï, 0, ±1/Ï)\n\t\t\t-t, 0, -r, t, 0, -r, -t, 0, r, t, 0, r];\n\t\t\tvar indices = [3, 11, 7, 3, 7, 15, 3, 15, 13, 7, 19, 17, 7, 17, 6, 7, 6, 15, 17, 4, 8, 17, 8, 10, 17, 10, 6, 8, 0, 16, 8, 16, 2, 8, 2, 10, 0, 12, 1, 0, 1, 18, 0, 18, 16, 6, 10, 2, 6, 2, 13, 6, 13, 15, 2, 16, 18, 2, 18, 3, 2, 3, 13, 18, 1, 9, 18, 9, 11, 18, 11, 3, 4, 14, 12, 4, 12, 0, 4, 0, 8, 11, 9, 5, 11, 5, 19, 11, 19, 7, 19, 5, 14, 19, 14, 4, 19, 4,
117, 1, 12, 14, 1, 14, 5, 1, 5, 9];\n\t\t\t_this = _PolyhedronBufferGeom.call(this, vertices, indices, radius, detail) || this;\n\t\t\t_this.type = 'DodecahedronBufferGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\tdetail: detail\n\t\t\t};\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn DodecahedronBufferGeometry;\n\t}(PolyhedronBufferGeometry);\n\n\tvar DodecahedronGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(DodecahedronGeometry, _Geometry);\n\n\t\tfunction DodecahedronGeometry(radius, detail) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'DodecahedronGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\tdetail: detail\n\t\t\t};\n\n\t\t\t_this.fromBufferGeometry(new DodecahedronBufferGeometry(radius, detail));\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn DodecahedronGeometry;\n\t}(Geometry);\n\n\tvar _v0$2 = new Vector3();\n\n\tvar _v1$5 = new Vector3();\n\n\tvar _normal$1 = new Vector3();\n\n\tvar _triangle = new Triangle();\n\n\tvar EdgesGeometry = /*#__PURE__*/function (_BufferGeometry) {\n\t\t_inheritsLoose(EdgesGeometry, _BufferGeometry);\n\n\t\tfunction EdgesGeometry(geometry, thresholdAngle) {\n\t\t\tvar _this;\n\n\t\t\t_this = _BufferGeometry.call(this) || this;\n\t\t\t_this.type = 'EdgesGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tthresholdAngle: thresholdAngle\n\t\t\t};\n\t\t\tthresholdAngle = thresholdAngle !== undefined ? thresholdAngle : 1;\n\n\t\t\tif (geometry.isGeometry) {\n\t\t\t\tgeometry = new BufferGeometry().fromGeometry(geometry);\n\t\t\t}\n\n\t\t\tvar precisionPoints = 4;\n\t\t\tvar precision = Math.pow(10, precisionPoints);\n\t\t\tvar thresholdDot = Math.cos(MathUtils.DEG2RAD * thresholdAngle);\n\t\t\tvar indexAttr = geometry.getIndex();\n\t\t\tvar positionAttr = geometry.getAttribute('position');\n\t\t\tvar indexCount = indexAttr ? indexAttr.count : positionAttr.count;\n\t\t\tvar indexArr = [0, 0, 0];\n\t\t\tvar vertKeys = ['a', 'b', 'c'];\n\t\t\tvar hashes = new Array(3);\n\t\t\tvar edgeData = {};\n\t\t\tvar vertices = [];\n\n\t\t\tfor (var i = 0; i < indexCount; i += 3) {\n\t\t\t\tif (indexAttr) {\n\t\t\t\t\tindexArr[0] = indexAttr.getX(i);\n\t\t\t\t\tindexArr[1] = indexAttr.getX(i + 1);\n\t\t\t\t\tindexArr[2] = indexAttr.getX(i + 2);\n\t\t\t\t} else {\n\t\t\t\t\tindexArr[0] = i;\n\t\t\t\t\tindexArr[1] = i + 1;\n\t\t\t\t\tindexArr[2] = i + 2;\n\t\t\t\t}\n\n\t\t\t\tvar a = _triangle.a,\n\t\t\t\t\t\tb = _triangle.b,\n\t\t\t\t\t\tc = _triangle.c;\n\t\t\t\ta.fromBufferAttribute(positionAttr, indexArr[0]);\n\t\t\t\tb.fromBufferAttribute(positionAttr, indexArr[1]);\n\t\t\t\tc.fromBufferAttribute(positionAttr, indexArr[2]);\n\n\t\t\t\t_triangle.getNormal(_normal$1); // create hashes for the edge from the vertices\n\n\n\t\t\t\thashes[0] = Math.round(a.x * precision) + \",\" + Math.round(a.y * precision) + \",\" + Math.round(a.z * precision);\n\t\t\t\thashes[1] = Math.round(b.x * precision) + \",\" + Math.round(b.y * precision) + \",\" + Math.round(b.z * precision);\n\t\t\t\thashes[2] = Math.round(c.x * precision) + \",\" + Math.round(c.y * precision) + \",\" + Math.round(c.z * precision); // skip degenerate triangles\n\n\t\t\t\tif (hashes[0] === hashes[1] || hashes[1] === hashes[2] || hashes[2] === hashes[0]) {\n\t\t\t\t\tcontinue;\n\t\t\t\t} // iterate over every edge\n\n\n\t\t\t\tfor (var j = 0; j < 3;
1 j++) {\n\t\t\t\t\t// get the first and next vertex making up the edge\n\t\t\t\t\tvar jNext = (j + 1) % 3;\n\t\t\t\t\tvar vecHash0 = hashes[j];\n\t\t\t\t\tvar vecHash1 = hashes[jNext];\n\t\t\t\t\tvar v0 = _triangle[vertKeys[j]];\n\t\t\t\t\tvar v1 = _triangle[vertKeys[jNext]];\n\t\t\t\t\tvar hash = vecHash0 + \"_\" + vecHash1;\n\t\t\t\t\tvar reverseHash = vecHash1 + \"_\" + vecHash0;\n\n\t\t\t\t\tif (reverseHash in edgeData && edgeData[reverseHash]) {\n\t\t\t\t\t\t// if we found a sibling edge add it into the vertex array if\n\t\t\t\t\t\t// it meets the angle threshold and delete the edge from the map.\n\t\t\t\t\t\tif (_normal$1.dot(edgeData[reverseHash].normal) <= thresholdDot) {\n\t\t\t\t\t\t\tvertices.push(v0.x, v0.y, v0.z);\n\t\t\t\t\t\t\tvertices.push(v1.x, v1.y, v1.z);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tedgeData[reverseHash] = null;\n\t\t\t\t\t} else if (!(hash in edgeData)) {\n\t\t\t\t\t\t// if we've already got an edge here then skip adding a new one\n\t\t\t\t\t\tedgeData[hash] = {\n\t\t\t\t\t\t\tindex0: indexArr[j],\n\t\t\t\t\t\t\tindex1: indexArr[jNext],\n\t\t\t\t\t\t\tnormal: _normal$1.clone()\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} // iterate over all remaining, unmatched edges and add them to the vertex array\n\n\n\t\t\tfor (var key in edgeData) {\n\t\t\t\tif (edgeData[key]) {\n\t\t\t\t\tvar _edgeData$key = edgeData[key],\n\t\t\t\t\t\t\tindex0 = _edgeData$key.index0,\n\t\t\t\t\t\t\tindex1 = _edgeData$key.index1;\n\n\t\t\t\t\t_v0$2.fromBufferAttribute(positionAttr, index0);\n\n\t\t\t\t\t_v1$5.fromBufferAttribute(positionAttr, index1);\n\n\t\t\t\t\tvertices.push(_v0$2.x, _v0$2.y, _v0$2.z);\n\t\t\t\t\tvertices.push(_v1$5.x, _v1$5.y, _v1$5.z);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t_this.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn EdgesGeometry;\n\t}(BufferGeometry);\n\n\t/**\n\t * Port from https://github.com/mapbox/earcut (v2.2.2)\n\t */\n\tvar Earcut = {\n\t\ttriangulate: function triangulate(data, holeIndices, dim) {\n\t\t\tdim = dim || 2;\n\t\t\tvar hasHoles = holeIndices && holeIndices.length;\n\t\t\tvar outerLen = hasHoles ? holeIndices[0] * dim : data.length;\n\t\t\tvar outerNode = linkedList(data, 0, outerLen, dim, true);\n\t\t\tvar triangles = [];\n\t\t\tif (!outerNode || outerNode.next === outerNode.prev) return triangles;\n\t\t\tvar minX, minY, maxX, maxY, x, y, invSize;\n\t\t\tif (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim); // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox\n\n\t\t\tif (data.length > 80 * dim) {\n\t\t\t\tminX = maxX = data[0];\n\t\t\t\tminY = maxY = data[1];\n\n\t\t\t\tfor (var i = dim; i < outerLen; i += dim) {\n\t\t\t\t\tx = data[i];\n\t\t\t\t\ty = data[i + 1];\n\t\t\t\t\tif (x < minX) minX = x;\n\t\t\t\t\tif (y < minY) minY = y;\n\t\t\t\t\tif (x > maxX) maxX = x;\n\t\t\t\t\tif (y > maxY) maxY = y;\n\t\t\t\t} // minX, minY and invSize are later used to transform coords into integers for z-order calculation\n\n\n\t\t\t\tinvSize = Math.max(maxX - minX, maxY - minY);\n\t\t\t\tinvSize = invSize !== 0 ? 1 / invSize : 0;\n\t\t\t}\n\n\t\t\tearcutLinked(outerNode, triangles, dim, minX, minY, invSize);\n\t\t\treturn triangles;\n\t\t}\n\t}; // create a circular doubly linked list from polygon points in the specified winding order\n\n\tfunction linkedList(data, start, end, dim, clockwise) {\n\t\tvar i, last;\n\n\t\tif (clockwise === signedArea(data, start, end, dim) > 0) {\n\t\t\tfor (i = start; i < end; i += dim) {\n\t\t\t\tlast = insertNode(i, data[i], data[i + 1], last);\n\t\t\t}\n\t\t} else {\n\t\t\tfor (i = end - dim; i >= start; i -= dim) {\n\t\t\t\tlast = insertNode(i, data[i], data[i + 1], last);\n\t\t\t}\n\t\t}\n\n\t\tif (last && equals(last, last.next)) {\n\t\t\tremoveNode(last);\n\t\t\tlast = last.next;\n\t\t}\n\n\t\treturn last;\n\t} // eliminate colinear or duplicate points\n\n\n\tfunction filterPoints(start, end) {\n\t\tif (!start) return start;\n\t\tif (!end) end = start;\n\t\tvar p = start,\n\t\t\t\tagain;\n\n\t\tdo {\n\t\t\tagain = false;\n\n\t\t\tif (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {\n\t\t\t\tremoveNode(p);\n\t\t\t\tp = end = p.prev;\n\t\t\t\tif (p === p.next) break;\n\t\t\t\tagain = true;\n\t\t\t} else {\n\t\t\t\tp = p.next;\n\t\t\t}\n\t\t}
1 while (again || p !== end);\n\n\t\treturn end;\n\t} // main ear slicing loop which triangulates a polygon (given as a linked list)\n\n\n\tfunction earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {\n\t\tif (!ear) return; // interlink polygon nodes in z-order\n\n\t\tif (!pass && invSize) indexCurve(ear, minX, minY, invSize);\n\t\tvar stop = ear,\n\t\t\t\tprev,\n\t\t\t\tnext; // iterate through ears, slicing them one by one\n\n\t\twhile (ear.prev !== ear.next) {\n\t\t\tprev = ear.prev;\n\t\t\tnext = ear.next;\n\n\t\t\tif (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {\n\t\t\t\t// cut off the triangle\n\t\t\t\ttriangles.push(prev.i / dim);\n\t\t\t\ttriangles.push(ear.i / dim);\n\t\t\t\ttriangles.push(next.i / dim);\n\t\t\t\tremoveNode(ear); // skipping the next vertex leads to less sliver triangles\n\n\t\t\t\tear = next.next;\n\t\t\t\tstop = next.next;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tear = next; // if we looped through the whole remaining polygon and can't find any more ears\n\n\t\t\tif (ear === stop) {\n\t\t\t\t// try filtering points and slicing again\n\t\t\t\tif (!pass) {\n\t\t\t\t\tearcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1); // if this didn't work, try curing all small self-intersections locally\n\t\t\t\t} else if (pass === 1) {\n\t\t\t\t\tear = cureLocalIntersections(filterPoints(ear), triangles, dim);\n\t\t\t\t\tearcutLinked(ear, triangles, dim, minX, minY, invSize, 2); // as a last resort, try splitting the remaining polygon into two\n\t\t\t\t} else if (pass === 2) {\n\t\t\t\t\tsplitEarcut(ear, triangles, dim, minX, minY, invSize);\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t} // check whether a polygon node forms a valid ear with adjacent nodes\n\n\n\tfunction isEar(ear) {\n\t\tvar a = ear.prev,\n\t\t\t\tb = ear,\n\t\t\t\tc = ear.next;\n\t\tif (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\t\t// now make sure we don't have other points inside the potential ear\n\n\t\tvar p = ear.next.next;\n\n\t\twhile (p !== ear.prev) {\n\t\t\tif (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n\t\t\tp = p.next;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tfunction isEarHashed(ear, minX, minY, invSize) {\n\t\tvar a = ear.prev,\n\t\t\t\tb = ear,\n\t\t\t\tc = ear.next;\n\t\tif (area(a, b, c) >= 0) return false; // reflex, can't be an ear\n\t\t// triangle bbox; min & max are calculated like this for speed\n\n\t\tvar minTX = a.x < b.x ? a.x < c.x ? a.x : c.x : b.x < c.x ? b.x : c.x,\n\t\t\t\tminTY = a.y < b.y ? a.y < c.y ? a.y : c.y : b.y < c.y ? b.y : c.y,\n\t\t\t\tmaxTX = a.x > b.x ? a.x > c.x ? a.x : c.x : b.x > c.x ? b.x : c.x,\n\t\t\t\tmaxTY = a.y > b.y ? a.y > c.y ? a.y : c.y : b.y > c.y ? b.y : c.y; // z-order range for the current triangle bbox;\n\n\t\tvar minZ = zOrder(minTX, minTY, minX, minY, invSize),\n\t\t\t\tmaxZ = zOrder(maxTX, maxTY, minX, minY, invSize);\n\t\tvar p = ear.prevZ,\n\t\t\t\tn = ear.nextZ; // look for points inside the triangle in both directions\n\n\t\twhile (p && p.z >= minZ && n && n.z <= maxZ) {\n\t\t\tif (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n\t\t\tp = p.prevZ;\n\t\t\tif (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n\t\t\tn = n.nextZ;\n\t\t} // look for remaining points in decreasing z-order\n\n\n\t\twhile (p && p.z >= minZ) {\n\t\t\tif (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;\n\t\t\tp = p.prevZ;\n\t\t} // look for remaining points in increasing z-order\n\n\n\t\twhile (n && n.z <= maxZ) {\n\t\t\tif (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;\n\t\t\tn = n.nextZ;\n\t\t}\n\n\t\treturn true;\n\t} // go through all polygon nodes and cure small local self-intersections\n\n\n\tfunction cureLocalIntersections(start, triangles, dim) {\n\t\tvar p
1= start;\n\n\t\tdo {\n\t\t\tvar a = p.prev,\n\t\t\t\t\tb = p.next.next;\n\n\t\t\tif (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {\n\t\t\t\ttriangles.push(a.i / dim);\n\t\t\t\ttriangles.push(p.i / dim);\n\t\t\t\ttriangles.push(b.i / dim); // remove two nodes involved\n\n\t\t\t\tremoveNode(p);\n\t\t\t\tremoveNode(p.next);\n\t\t\t\tp = start = b;\n\t\t\t}\n\n\t\t\tp = p.next;\n\t\t} while (p !== start);\n\n\t\treturn filterPoints(p);\n\t} // try splitting polygon into two and triangulate them independently\n\n\n\tfunction splitEarcut(start, triangles, dim, minX, minY, invSize) {\n\t\t// look for a valid diagonal that divides the polygon into two\n\t\tvar a = start;\n\n\t\tdo {\n\t\t\tvar b = a.next.next;\n\n\t\t\twhile (b !== a.prev) {\n\t\t\t\tif (a.i !== b.i && isValidDiagonal(a, b)) {\n\t\t\t\t\t// split the polygon in two by the diagonal\n\t\t\t\t\tvar c = splitPolygon(a, b); // filter colinear points around the cuts\n\n\t\t\t\t\ta = filterPoints(a, a.next);\n\t\t\t\t\tc = filterPoints(c, c.next); // run earcut on each half\n\n\t\t\t\t\tearcutLinked(a, triangles, dim, minX, minY, invSize);\n\t\t\t\t\tearcutLinked(c, triangles, dim, minX, minY, invSize);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tb = b.next;\n\t\t\t}\n\n\t\t\ta = a.next;\n\t\t} while (a !== start);\n\t} // link every hole into the outer loop, producing a single-ring polygon without holes\n\n\n\tfunction eliminateHoles(data, holeIndices, outerNode, dim) {\n\t\tvar queue = [];\n\t\tvar i, len, start, end, list;\n\n\t\tfor (i = 0, len = holeIndices.length; i < len; i++) {\n\t\t\tstart = holeIndices[i] * dim;\n\t\t\tend = i < len - 1 ? holeIndices[i + 1] * dim : data.length;\n\t\t\tlist = linkedList(data, start, end, dim, false);\n\t\t\tif (list === list.next) list.steiner = true;\n\t\t\tqueue.push(getLeftmost(list));\n\t\t}\n\n\t\tqueue.sort(compareX); // process holes from left to right\n\n\t\tfor (i = 0; i < queue.length; i++) {\n\t\t\teliminateHole(queue[i], outerNode);\n\t\t\touterNode = filterPoints(outerNode, outerNode.next);\n\t\t}\n\n\t\treturn outerNode;\n\t}\n\n\tfunction compareX(a, b) {\n\t\treturn a.x - b.x;\n\t} // find a bridge between vertices that connects hole with an outer ring and and link it\n\n\n\tfunction eliminateHole(hole, outerNode) {\n\t\touterNode = findHoleBridge(hole, outerNode);\n\n\t\tif (outerNode) {\n\t\t\tvar b = splitPolygon(outerNode, hole); // filter collinear points around the cuts\n\n\t\t\tfilterPoints(outerNode, outerNode.next);\n\t\t\tfilterPoints(b, b.next);\n\t\t}\n\t} // David Eberly's algorithm for finding a bridge between hole and outer polygon\n\n\n\tfunction findHoleBridge(hole, outerNode) {\n\t\tvar p = outerNode;\n\t\tvar hx = hole.x;\n\t\tvar hy = hole.y;\n\t\tvar qx = -Infinity,\n\t\t\t\tm; // find a segment intersected by a ray from the hole's leftmost point to the left;\n\t\t// segment's endpoint with lesser x will be potential connection point\n\n\t\tdo {\n\t\t\tif (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {\n\t\t\t\tvar x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);\n\n\t\t\t\tif (x <= hx && x > qx) {\n\t\t\t\t\tqx = x;\n\n\t\t\t\t\tif (x === hx) {\n\t\t\t\t\t\tif (hy === p.y) return p;\n\t\t\t\t\t\tif (hy === p.next.y) return p.next;\n\t\t\t\t\t}\n\n\t\t\t\t\tm = p.x < p.next.x ? p : p.next;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tp = p.next;\n\t\t} while (p !== outerNode);\n\n\t\tif (!m) return null;\n\t\tif (hx === qx) return m; // hole touches outer segment; pick leftmost endpoint\n\t\t// look for points inside the triangle of hole point, segment intersection and endpoint;\n\t\t// if there are no points found, we have a valid connection;\n\t\t// otherwise choose the point of the minimum angle with the ray as connection point\n\n\t\tvar stop = m,\n\t\t\t\tmx = m.x,\n\t\t\t\tmy = m.y;\n\t\tvar tanMin = Infinity,\n\t\t\t\ttan;\n\t\tp = m;\n\n\t\tdo {\n\t\t\tif (hx >= p.x && p.x >= mx && hx !== p.x && pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {\n\t\t\t\ttan = Math.abs(hy - p.y) / (hx - p.x); // tangential\n\n\t\t\t\tif (locallyInside(p, hole) && (tan < tanMin || tan === tanMin && (p.x > m.x || p.x === m.x && sectorContainsSector(m, p)))) {\n\t\t\t\t\tm = p;\n\t\t\t\t\ttanMin = tan;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tp = p.next;\n\t\t} while (p !== stop);\n\n\t\treturn m;\n\t} // whether sector in vertex m contains sector in vertex p in the same coordinates\n\n\n\tfunction sectorContainsSector(m, p) {\n\t\treturn area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;\n\t} // interlink polygon nodes in z-order\n\n\n\tfunction indexCurve(start, minX, minY, invSize) {\n\t\tvar p
1= start;\n\n\t\tdo {\n\t\t\tif (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, invSize);\n\t\t\tp.prevZ = p.prev;\n\t\t\tp.nextZ = p.next;\n\t\t\tp = p.next;\n\t\t} while (p !== start);\n\n\t\tp.prevZ.nextZ = null;\n\t\tp.prevZ = null;\n\t\tsortLinked(p);\n\t} // Simon Tatham's linked list merge sort algorithm\n\t// http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html\n\n\n\tfunction sortLinked(list) {\n\t\tvar i,\n\t\t\t\tp,\n\t\t\t\tq,\n\t\t\t\te,\n\t\t\t\ttail,\n\t\t\t\tnumMerges,\n\t\t\t\tpSize,\n\t\t\t\tqSize,\n\t\t\t\tinSize = 1;\n\n\t\tdo {\n\t\t\tp = list;\n\t\t\tlist = null;\n\t\t\ttail = null;\n\t\t\tnumMerges = 0;\n\n\t\t\twhile (p) {\n\t\t\t\tnumMerges++;\n\t\t\t\tq = p;\n\t\t\t\tpSize = 0;\n\n\t\t\t\tfor (i = 0; i < inSize; i++) {\n\t\t\t\t\tpSize++;\n\t\t\t\t\tq = q.nextZ;\n\t\t\t\t\tif (!q) break;\n\t\t\t\t}\n\n\t\t\t\tqSize = inSize;\n\n\t\t\t\twhile (pSize > 0 || qSize > 0 && q) {\n\t\t\t\t\tif (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {\n\t\t\t\t\t\te = p;\n\t\t\t\t\t\tp = p.nextZ;\n\t\t\t\t\t\tpSize--;\n\t\t\t\t\t} else {\n\t\t\t\t\t\te = q;\n\t\t\t\t\t\tq = q.nextZ;\n\t\t\t\t\t\tqSize--;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (tail) tail.nextZ = e;else list = e;\n\t\t\t\t\te.prevZ = tail;\n\t\t\t\t\ttail = e;\n\t\t\t\t}\n\n\t\t\t\tp = q;\n\t\t\t}\n\n\t\t\ttail.nextZ = null;\n\t\t\tinSize *= 2;\n\t\t} while (numMerges > 1);\n\n\t\treturn list;\n\t} // z-order of a point given coords and inverse of the longer side of data bbox\n\n\n\tfunction zOrder(x, y, minX, minY, invSize) {\n\t\t// coords are transformed into non-negative 15-bit integer range\n\t\tx = 32767 * (x - minX) * invSize;\n\t\ty = 32767 * (y - minY) * invSize;\n\t\tx = (x | x << 8) & 0x00FF00FF;\n\t\tx = (x | x << 4) & 0x0F0F0F0F;\n\t\tx = (x | x << 2) & 0x33333333;\n\t\tx = (x | x << 1) & 0x55555555;\n\t\ty = (y | y << 8) & 0x00FF00FF;\n\t\ty = (y | y << 4) & 0x0F0F0F0F;\n\t\ty = (y | y << 2) & 0x33333333;\n\t\ty = (y | y << 1) & 0x55555555;\n\t\treturn x | y << 1;\n\t} // find the leftmost node of a polygon ring\n\n\n\tfunction getLeftmost(start) {\n\t\tvar p = start,\n\t\t\t\tleftmost = start;\n\n\t\tdo {\n\t\t\tif (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y) leftmost = p;\n\t\t\tp = p.next;\n\t\t} while (p !== start);\n\n\t\treturn leftmost;\n\t} // check if a point lies within a convex triangle\n\n\n\tfunction pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {\n\t\treturn (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;\n\t} // check if a diagonal between two polygon nodes is valid (lies in polygon interior)\n\n\n\tfunction isValidDiagonal(a, b) {\n\t\treturn a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && ( // dones't intersect other edges\n\t\tlocallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && ( // locally visible\n\t\tarea(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors\n\t\tequals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0); // special zero-length case\n\t} // signed area of a triangle\n\n\n\tfunction area(p, q, r) {\n\t\treturn (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);\n\t} // check if two points are equal\n\n\n\tfunction equals(p1, p2) {\n\t\treturn p1.x === p2.x && p1.y === p2.y;\n\t} // check if two segments intersect\n\n\n\tfunction intersects(p1, q1, p2, q2) {\n\t\tvar o1 = sign(area(p1, q1, p2));\n\t\tvar o2 = sign(area(p1, q1, q2));\n\t\tvar o3 = sign(area(p2, q2, p1));\n\t\tvar o4 = sign(area(p2, q2, q1));\n\t\tif (o1 !== o2 && o3 !== o4) return true; // general case\n\n\t\tif (o1 === 0 && onSegment(p1, p2, q1)) return true; // p1, q1 and p2 are collinear and p2 lies on p1q1\n\n\t\tif (o2 === 0 && onSegment(p1, q2, q1)) return true; // p1, q1 and q2 are collinear and q2 lies on p1q1\n\n\t\tif (o3 === 0 && onSegment(p2, p1, q2)) return true; // p2, q2 and p1 are collinear and p1 lies on p2q2\n\n\t\tif (o4 === 0 && onSegment(p2, q1, q2)) return true; // p2, q2 and q1 are collinear and q1 lies on p2q2\n\n\t\treturn false;\n\t}
1 // for collinear points p, q, r, check if point q lies on segment pr\n\n\n\tfunction onSegment(p, q, r) {\n\t\treturn q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);\n\t}\n\n\tfunction sign(num) {\n\t\treturn num > 0 ? 1 : num < 0 ? -1 : 0;\n\t} // check if a polygon diagonal intersects any polygon segments\n\n\n\tfunction intersectsPolygon(a, b) {\n\t\tvar p = a;\n\n\t\tdo {\n\t\t\tif (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i && intersects(p, p.next, a, b)) return true;\n\t\t\tp = p.next;\n\t\t} while (p !== a);\n\n\t\treturn false;\n\t} // check if a polygon diagonal is locally inside the polygon\n\n\n\tfunction locallyInside(a, b) {\n\t\treturn area(a.prev, a, a.next) < 0 ? area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;\n\t} // check if the middle point of a polygon diagonal is inside the polygon\n\n\n\tfunction middleInside(a, b) {\n\t\tvar p = a,\n\t\t\t\tinside = false;\n\t\tvar px = (a.x + b.x) / 2,\n\t\t\t\tpy = (a.y + b.y) / 2;\n\n\t\tdo {\n\t\t\tif (p.y > py !== p.next.y > py && p.next.y !== p.y && px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x) inside = !inside;\n\t\t\tp = p.next;\n\t\t} while (p !== a);\n\n\t\treturn inside;\n\t} // link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;\n\t// if one belongs to the outer ring and another to a hole, it merges it into a single ring\n\n\n\tfunction splitPolygon(a, b) {\n\t\tvar a2 = new Node(a.i, a.x, a.y),\n\t\t\t\tb2 = new Node(b.i, b.x, b.y),\n\t\t\t\tan = a.next,\n\t\t\t\tbp = b.prev;\n\t\ta.next = b;\n\t\tb.prev = a;\n\t\ta2.next = an;\n\t\tan.prev = a2;\n\t\tb2.next = a2;\n\t\ta2.prev = b2;\n\t\tbp.next = b2;\n\t\tb2.prev = bp;\n\t\treturn b2;\n\t} // create a node and optionally link it with previous one (in a circular doubly linked list)\n\n\n\tfunction insertNode(i, x, y, last) {\n\t\tvar p = new Node(i, x, y);\n\n\t\tif (!last) {\n\t\t\tp.prev = p;\n\t\t\tp.next = p;\n\t\t} else {\n\t\t\tp.next = last.next;\n\t\t\tp.prev = last;\n\t\t\tlast.next.prev = p;\n\t\t\tlast.next = p;\n\t\t}\n\n\t\treturn p;\n\t}\n\n\tfunction removeNode(p) {\n\t\tp.next.prev = p.prev;\n\t\tp.prev.next = p.next;\n\t\tif (p.prevZ) p.prevZ.nextZ = p.nextZ;\n\t\tif (p.nextZ) p.nextZ.prevZ = p.prevZ;\n\t}\n\n\tfunction Node(i, x, y) {\n\t\t// vertex index in coordinates array\n\t\tthis.i = i; // vertex coordinates\n\n\t\tthis.x = x;\n\t\tthis.y = y; // previous and next vertex nodes in a polygon ring\n\n\t\tthis.prev = null;\n\t\tthis.next = null; // z-order curve value\n\n\t\tthis.z = null; // previous and next nodes in z-order\n\n\t\tthis.prevZ = null;\n\t\tthis.nextZ = null; // indicates whether this is a steiner point\n\n\t\tthis.steiner = false;\n\t}\n\n\tfunction signedArea(data, start, end, dim) {\n\t\tvar sum = 0;\n\n\t\tfor (var i = start, j = end - dim; i < end; i += dim) {\n\t\t\tsum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);\n\t\t\tj = i;\n\t\t}\n\n\t\treturn sum;\n\t}\n\n\tvar ShapeUtils = {\n\t\t// calculate area of the contour polygon\n\t\tarea: function area(contour) {\n\t\t\tvar n = contour.length;\n\t\t\tvar a = 0.0;\n\n\t\t\tfor (var p = n - 1, q = 0; q < n; p = q++) {\n\t\t\t\ta += contour[p].x * contour[q].y - contour[q].x * contour[p].y;\n\t\t\t}\n\n\t\t\treturn a * 0.5;\n\t\t},\n\t\tisClockWise: function isClockWise(pts) {\n\t\t\treturn ShapeUtils.area(pts) < 0;\n\t\t},\n\t\ttriangulateShape: function triangulateShape(contour, holes) {\n\t\t\tvar vertices = []; // flat array of vertices like [ x0,y0, x1,y1, x2,y2, ... ]\n\n\t\t\tvar holeIndices = []; // array of hole indices\n\n\t\t\tvar faces = []; // final array of vertex indices like [ [ a,b,d ], [ b,c,d ] ]\n\n\t\t\tremoveDupEndPts(contour);\n\t\t\taddContour(vertices, contour); //\n\n\t\t\tvar holeIndex = contour.length;\n\t\t\tholes.forEach(removeDupEndPts);\n\n\t\t\tfor (var i = 0; i < holes.length; i++) {\n\t\t\t\tholeIndices.push(holeIndex);\n\t\t\t\tholeIndex += holes[i].length;\n\t\t\t\taddContour(vertices, holes[i]);\n\t\t\t} //\n\n\n\t\t\tvar triangles = Earcut.triangulate(vertices, holeIndices); //\n\n\t\t\tfor (var _i = 0; _i < triangles.length; _i += 3) {\n\t\t\t\tfaces.push(triangles.slice(_i, _i + 3));\n\t\t\t}\n\n\t\t\treturn faces;\n\t\t}\n\t};\n\n\tfunction removeDupEndPts(points) {\n\t\tvar l = points.length;\n\n\t\tif (l > 2 && points[l - 1].equals(points[0])) {\n\t\t\tpoints.pop();\n\t\t}\n\t}\n\n\tfunction addContour(vertices, contour) {\n\t\tfor (var i = 0; i < contour.length;
1 i++) {\n\t\t\tvertices.push(contour[i].x);\n\t\t\tvertices.push(contour[i].y);\n\t\t}\n\t}\n\n\tvar ExtrudeBufferGeometry = /*#__PURE__*/function (_BufferGeometry) {\n\t\t_inheritsLoose(ExtrudeBufferGeometry, _BufferGeometry);\n\n\t\tfunction ExtrudeBufferGeometry(shapes, options) {\n\t\t\tvar _this;\n\n\t\t\t_this = _BufferGeometry.call(this) || this;\n\t\t\t_this.type = 'ExtrudeBufferGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tshapes: shapes,\n\t\t\t\toptions: options\n\t\t\t};\n\t\t\tshapes = Array.isArray(shapes) ? shapes : [shapes];\n\n\t\t\tvar scope = _assertThisInitialized(_this);\n\n\t\t\tvar verticesArray = [];\n\t\t\tvar uvArray = [];\n\n\t\t\tfor (var i = 0, l = shapes.length; i < l; i++) {\n\t\t\t\tvar shape = shapes[i];\n\t\t\t\taddShape(shape);\n\t\t\t} // build geometry\n\n\n\t\t\t_this.setAttribute('position', new Float32BufferAttribute(verticesArray, 3));\n\n\t\t\t_this.setAttribute('uv', new Float32BufferAttribute(uvArray, 2));\n\n\t\t\t_this.computeVertexNormals(); // functions\n\n\n\t\t\tfunction addShape(shape) {\n\t\t\t\tvar placeholder = []; // options\n\n\t\t\t\tvar curveSegments = options.curveSegments !== undefined ? options.curveSegments : 12;\n\t\t\t\tvar steps = options.steps !== undefined ? options.steps : 1;\n\t\t\t\tvar depth = options.depth !== undefined ? options.depth : 100;\n\t\t\t\tvar bevelEnabled = options.bevelEnabled !== undefined ? options.bevelEnabled : true;\n\t\t\t\tvar bevelThickness = options.bevelThickness !== undefined ? options.bevelThickness : 6;\n\t\t\t\tvar bevelSize = options.bevelSize !== undefined ? options.bevelSize : bevelThickness - 2;\n\t\t\t\tvar bevelOffset = options.bevelOffset !== undefined ? options.bevelOffset : 0;\n\t\t\t\tvar bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3;\n\t\t\t\tvar extrudePath = options.extrudePath;\n\t\t\t\tvar uvgen = options.UVGenerator !== undefined ? options.UVGenerator : WorldUVGenerator; // deprecated options\n\n\t\t\t\tif (options.amount !== undefined) {\n\t\t\t\t\tconsole.warn('THREE.ExtrudeBufferGeometry: amount has been renamed to depth.');\n\t\t\t\t\tdepth = options.amount;\n\t\t\t\t} //\n\n\n\t\t\t\tvar extrudePts,\n\t\t\t\t\t\textrudeByPath = false;\n\t\t\t\tvar splineTube, binormal, normal, position2;\n\n\t\t\t\tif (extrudePath) {\n\t\t\t\t\textrudePts = extrudePath.get
1SpacedPoints(steps);\n\t\t\t\t\textrudeByPath = true;\n\t\t\t\t\tbevelEnabled = false; // bevels not supported for path extrusion\n\t\t\t\t\t// SETUP TNB variables\n\t\t\t\t\t// TODO1 - have a .isClosed in spline?\n\n\t\t\t\t\tsplineTube = extrudePath.computeFrenetFrames(steps, false); // console.log(splineTube, 'splineTube', splineTube.normals.length, 'steps', steps, 'extrudePts', extrudePts.length);\n\n\t\t\t\t\tbinormal = new Vector3();\n\t\t\t\t\tnormal = new Vector3();\n\t\t\t\t\tposition2 = new Vector3();\n\t\t\t\t} // Safeguards if bevels are not enabled\n\n\n\t\t\t\tif (!bevelEnabled) {\n\t\t\t\t\tbevelSegments = 0;\n\t\t\t\t\tbevelThickness = 0;\n\t\t\t\t\tbevelSize = 0;\n\t\t\t\t\tbevelOffset = 0;\n\t\t\t\t} // Variables initialization\n\n\n\t\t\t\tvar shapePoints = shape.extractPoints(curveSegments);\n\t\t\t\tvar vertices = shapePoints.shape;\n\t\t\t\tvar holes = shapePoints.holes;\n\t\t\t\tvar reverse = !ShapeUtils.isClockWise(vertices);\n\n\t\t\t\tif (reverse) {\n\t\t\t\t\tvertices = vertices.reverse(); // Maybe we should also check if holes are in the opposite direction, just to be safe ...\n\n\t\t\t\t\tfor (var h = 0, hl = holes.length; h < hl; h++) {\n\t\t\t\t\t\tvar ahole = holes[h];\n\n\t\t\t\t\t\tif (ShapeUtils.isClockWise(ahole)) {\n\t\t\t\t\t\t\tholes[h] = ahole.reverse();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvar faces = ShapeUtils.triangulateShape(vertices, holes);\n\t\t\t\t/* Vertices */\n\n\t\t\t\tvar contour = vertices; // vertices has all points but contour has only points of circumference\n\n\t\t\t\tfor (var _h = 0, _hl = holes.length; _h < _hl; _h++) {\n\t\t\t\t\tvar _ahole = holes[_h];\n\t\t\t\t\tvertices = vertices.concat(_ahole);\n\t\t\t\t}\n\n\t\t\t\tfunction scalePt2(pt, vec, size) {\n\t\t\t\t\tif (!vec) console.error('THREE.ExtrudeGeometry: vec does not exist');\n\t\t\t\t\treturn vec.clone().multiplyScalar(size).add(pt);\n\t\t\t\t}\n\n\t\t\t\tvar vlen = vertices.length,\n\t\t\t\t\t\tflen = faces.length; // Find directions for point movement\n\n\t\t\t\tfunction getBevelVec(inPt, inPrev, inNext) {\n\t\t\t\t\t// computes for inPt the corresponding point inPt' on a new contour\n\t\t\t\t\t//\t shifted by 1 unit (length of normalized vector) to the left\n\t\t\t\t\t// if we walk along contour clockwise, this new contour is outside the old one\n\t\t\t\t\t//\n\t\t\t\t\t// inPt' is the intersection of the two lines parallel to the two\n\t\t\t\t\t//\tadjacent edges of inPt at a distance of 1 unit on the left side.\n\t\t\t\t\tvar v_trans_x, v_trans_y, shrink_by; // resulting translation vector for inPt\n\t\t\t\t\t// good reading for geometry algorithms (here: line-line intersection)\n\t\t\t\t\t// http://geomalgorithms.com/a05-_intersect-1.html\n\n\t\t\t\t\tvar v_prev_x = inPt.x - inPrev.x,\n\t\t\t\t\t\t\tv_prev_y = inPt.y - inPrev.y;\n\t\t\t\t\tvar v_next_x = inNext.x - inPt.x,\n\t\t\t\t\t\t\tv_next_y = inNext.y - inPt.y;\n\t\t\t\t\tvar v_prev_lensq = v_prev_x * v_prev_x + v_prev_y * v_prev_y;
1 // check for collinear edges\n\n\t\t\t\t\tvar collinear0 = v_prev_x * v_next_y - v_prev_y * v_next_x;\n\n\t\t\t\t\tif (Math.abs(collinear0) > Number.EPSILON) {\n\t\t\t\t\t\t// not collinear\n\t\t\t\t\t\t// length of vectors for normalizing\n\t\t\t\t\t\tvar v_prev_len = Math.sqrt(v_prev_lensq);\n\t\t\t\t\t\tvar v_next_len = Math.sqrt(v_next_x * v_next_x + v_next_y * v_next_y); // shift adjacent points by unit vectors to the left\n\n\t\t\t\t\t\tvar ptPrevShift_x = inPrev.x - v_prev_y / v_prev_len;\n\t\t\t\t\t\tvar ptPrevShift_y = inPrev.y + v_prev_x / v_prev_len;\n\t\t\t\t\t\tvar ptNextShift_x = inNext.x - v_next_y / v_next_len;\n\t\t\t\t\t\tvar ptNextShift_y = inNext.y + v_next_x / v_next_len; // scaling factor for v_prev to intersection point\n\n\t\t\t\t\t\tvar sf = ((ptNextShift_x - ptPrevShift_x) * v_next_y - (ptNextShift_y - ptPrevShift_y) * v_next_x) / (v_prev_x * v_next_y - v_prev_y * v_next_x); // vector from inPt to intersection point\n\n\t\t\t\t\t\tv_trans_x = ptPrevShift_x + v_prev_x * sf - inPt.x;\n\t\t\t\t\t\tv_trans_y = ptPrevShift_y + v_prev_y * sf - inPt.y; // Don't normalize!, otherwise sharp corners become ugly\n\t\t\t\t\t\t//\tbut prevent crazy spikes\n\n\t\t\t\t\t\tvar v_trans_lensq = v_trans_x * v_trans_x + v_trans_y * v_trans_y;\n\n\t\t\t\t\t\tif (v_trans_lensq <= 2) {\n\t\t\t\t\t\t\treturn new Vector2(v_trans_x, v_trans_y);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tshrink_by = Math.sqrt(v_trans_lensq / 2);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// handle special case of collinear edges\n\t\t\t\t\t\tvar direction_eq = false; // assumes: opposite\n\n\t\t\t\t\t\tif (v_prev_x > Number.EPSILON) {\n\t\t\t\t\t\t\tif (v_next_x > Number.EPSILON) {\n\t\t\t\t\t\t\t\tdirection_eq = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (v_prev_x < -Number.EPSILON) {\n\t\t\t\t\t\t\t\tif (v_next_x < -Number.EPSILON) {\n\t\t\t\t\t\t\t\t\tdirection_eq = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif (Math.sign(v_prev_y) === Math.sign(v_next_y)) {\n\t\t\t\t\t\t\t\t\tdirection_eq = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (direction_eq) {\n\t\t\t\t\t\t\t// console.log(\"Warning: lines are a straight sequence\");\n\t\t\t\t\t\t\tv_trans_x = -v_prev_y;\n\t\t\t\t\t\t\tv_trans_y = v_prev_x;\n\t\t\t\t\t\t\tshrink_by = Math.sqrt(v_prev_lensq);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// console.log(\"Warning: lines are a straight spike\");\n\t\t\t\t\t\t\tv_trans_x = v_prev_x;\n\t\t\t\t\t\t\tv_trans_y = v_prev_y;\n\t\t\t\t\t\t\tshrink_by = Math.sqrt(v_prev_lensq / 2);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn new Vector2(v_trans_x / shrink_by, v_trans_y / shrink_by);\n\t\t\t\t}\n\n\t\t\t\tvar contourMovements = [];\n\n\t\t\t\tfor (var _i = 0, il = contour.length, j = il - 1, k = _i + 1; _i < il; _i++, j++, k++) {\n\t\t\t\t\tif (j === il) j = 0;\n\t\t\t\t\tif (k === il) k = 0; //\t(j)---(i)---(k)\n\t\t\t\t\t// console.log('i,j,k', i, j , k)\n\n\t\t\t\t\tcontourMovements[_i] = getBevelVec(contour[_i], contour[j], contour[k]);\n\t\t\t\t}\n\n\t\t\t\tvar holesMovements = [];\n\t\t\t\tvar oneHoleMovements,\n\t\t\t\t\t\tverticesMovements = contourMovements.concat();\n\n\t\t\t\tfor (var _h2 = 0, _hl2 = holes.length; _h2 < _hl2; _h2++) {\n\t\t\t\t\tvar _ahole2 = holes[_h2];\n\t\t\t\t\toneHoleMovements = [];\n\n\t\t\t\t\tfor (var _i2 = 0, _il = _ahole2.length, _j = _il - 1, _k = _i2 + 1; _i2 < _il; _i2++, _j++, _k++) {\n\t\t\t\t\t\tif (_j === _il) _j = 0;\n\t\t\t\t\t\tif (_k === _il) _k = 0; //\t(j)---(i)---(k)\n\n\t\t\t\t\t\toneHoleMovements[_i2] = getBevelVec(_ahole2[_i2], _ahole2[_j], _ahole2[_k]);\n\t\t\t\t\t}\n\n\t\t\t\t\tholesMovements.push(oneHoleMovements);\n\t\t\t\t\tverticesMovements = verticesMovements.concat(oneHoleMovements);\n\t\t\t\t} // Loop bevelSegments, 1 for the front, 1 for the back\n\n\n\t\t\t\tfor (var b = 0; b < bevelSegments; b++) {\n\t\t\t\t\t//for ( b = bevelSegments; b > 0; b -- ) {\n\t\t\t\t\tvar t = b / bevelSegments;\n\t\t\t\t\tvar z = bevelThickness * Math.cos(t * Math.PI / 2);\n\n\t\t\t\t\tvar _bs = bevelSize * Math.sin(t * Math.PI / 2) + bevelOffset; // contract shape\n\n\n\t\t\t\t\tfor (var _i3 = 0, _il2 = contour.length; _i3 < _il2; _i3++) {\n\t\t\t\t\t\tvar vert = scalePt2(contour[_i3], contourMovements[_i3], _bs);\n\t\t\t\t\t\tv(vert.x, vert.y, -z);\n\t\t\t\t\t} // expand holes\n\n\n\t\t\t\t\tfor (var _h3 = 0, _hl3 = holes.length; _h3 < _hl3; _h3++) {\n\t\t\t\t\t\tvar _ahole3 = holes[_h3];\n\t\t\t\t\t\toneHoleMovements = holesMovements[_h3];\n\n\t\t\t\t\t\tfor (var _i4 = 0, _il3 = _ahole3.length; _i4 < _il3; _i4++) {\n\t\t\t\t\t\t\tvar _vert = scalePt2(_ahole3[_i4], oneHoleMovements[_i4], _bs);\n\n\t\t\t\t\t\t\tv(_vert.x, _vert.y, -z);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvar bs = bevelSize + bevelOffset; // Back facing vertices\n\n\t\t\t\tfor (var _i5 = 0; _i5 < vlen;
1 _i5++) {\n\t\t\t\t\tvar _vert2 = bevelEnabled ? scalePt2(vertices[_i5], verticesMovements[_i5], bs) : vertices[_i5];\n\n\t\t\t\t\tif (!extrudeByPath) {\n\t\t\t\t\t\tv(_vert2.x, _vert2.y, 0);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// v( vert.x, vert.y + extrudePts[ 0 ].y, extrudePts[ 0 ].x );\n\t\t\t\t\t\tnormal.copy(splineTube.normals[0]).multiplyScalar(_vert2.x);\n\t\t\t\t\t\tbinormal.copy(splineTube.binormals[0]).multiplyScalar(_vert2.y);\n\t\t\t\t\t\tposition2.copy(extrudePts[0]).add(normal).add(binormal);\n\t\t\t\t\t\tv(position2.x, position2.y, position2.z);\n\t\t\t\t\t}\n\t\t\t\t} // Add stepped vertices...\n\t\t\t\t// Including front facing vertices\n\n\n\t\t\t\tfor (var s = 1; s <= steps; s++) {\n\t\t\t\t\tfor (var _i6 = 0; _i6 < vlen; _i6++) {\n\t\t\t\t\t\tvar _vert3 = bevelEnabled ? scalePt2(vertices[_i6], verticesMovements[_i6], bs) : vertices[_i6];\n\n\t\t\t\t\t\tif (!extrudeByPath) {\n\t\t\t\t\t\t\tv(_vert3.x, _vert3.y, depth / steps * s);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// v( vert.x, vert.y + extrudePts[ s - 1 ].y, extrudePts[ s - 1 ].x );\n\t\t\t\t\t\t\tnormal.copy(splineTube.normals[s]).multiplyScalar(_vert3.x);\n\t\t\t\t\t\t\tbinormal.copy(splineTube.binormals[s]).multiplyScalar(_vert3.y);\n\t\t\t\t\t\t\tposition2.copy(extrudePts[s]).add(normal).add(binormal);\n\t\t\t\t\t\t\tv(position2.x, position2.y, position2.z);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} // Add bevel segments planes\n\t\t\t\t//for ( b = 1; b <= bevelSegments; b ++ ) {\n\n\n\t\t\t\tfor (var _b = bevelSegments - 1; _b >= 0; _b--) {\n\t\t\t\t\tvar _t = _b / bevelSegments;\n\n\t\t\t\t\tvar _z = bevelThickness * Math.cos(_t * Math.PI / 2);\n\n\t\t\t\t\tvar _bs2 = bevelSize * Math.sin(_t * Math.PI / 2) + bevelOffset; // contract shape\n\n\n\t\t\t\t\tfor (var _i7 = 0, _il4 = contour.length; _i7 < _il4;
1 _i7++) {\n\t\t\t\t\t\tvar _vert4 = scalePt2(contour[_i7], contourMovements[_i7], _bs2);\n\n\t\t\t\t\t\tv(_vert4.x, _vert4.y, depth + _z);\n\t\t\t\t\t} // expand holes\n\n\n\t\t\t\t\tfor (var _h4 = 0, _hl4 = holes.length; _h4 < _hl4; _h4++) {\n\t\t\t\t\t\tvar _ahole4 = holes[_h4];\n\t\t\t\t\t\toneHoleMovements = holesMovements[_h4];\n\n\t\t\t\t\t\tfor (var _i8 = 0, _il5 = _ahole4.length; _i8 < _il5; _i8++) {\n\t\t\t\t\t\t\tvar _vert5 = scalePt2(_ahole4[_i8], oneHoleMovements[_i8], _bs2);\n\n\t\t\t\t\t\t\tif (!extrudeByPath) {\n\t\t\t\t\t\t\t\tv(_vert5.x, _vert5.y, depth + _z);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tv(_vert5.x, _vert5.y + extrudePts[steps - 1].y, extrudePts[steps - 1].x + _z);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t/* Faces */\n\t\t\t\t// Top and bottom faces\n\n\n\t\t\t\tbuildLidFaces(); // Sides faces\n\n\t\t\t\tbuildSideFaces(); /////\tInternal functions\n\n\t\t\t\tfunction buildLidFaces() {\n\t\t\t\t\tvar start = verticesArray.length / 3;\n\n\t\t\t\t\tif (bevelEnabled) {\n\t\t\t\t\t\tvar layer = 0; // steps + 1\n\n\t\t\t\t\t\tvar offset = vlen * layer; // Bottom faces\n\n\t\t\t\t\t\tfor (var _i9 = 0; _i9 < flen; _i9++) {\n\t\t\t\t\t\t\tvar face = faces[_i9];\n\t\t\t\t\t\t\tf3(face[2] + offset, face[1] + offset, face[0] + offset);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlayer = steps + bevelSegments * 2;\n\t\t\t\t\t\toffset = vlen * layer; // Top faces\n\n\t\t\t\t\t\tfor (var _i10 = 0; _i10 < flen; _i10++) {\n\t\t\t\t\t\t\tvar _face = faces[_i10];\n\t\t\t\t\t\t\tf3(_face[0] + offset, _face[1] + offset, _face[2] + offset);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Bottom faces\n\t\t\t\t\t\tfor (var _i11 = 0; _i11 < flen; _i11++) {\n\t\t\t\t\t\t\tvar _face2 = faces[_i11];\n\t\t\t\t\t\t\tf3(_face2[2], _face2[1], _face2[0]);\n\t\t\t\t\t\t} // Top faces\n\n\n\t\t\t\t\t\tfor (var _i12 = 0; _i12 < flen; _i12++) {\n\t\t\t\t\t\t\tvar _face3 = faces[_i12];\n\t\t\t\t\t\t\tf3(_face3[0] + vlen * steps, _face3[1] + vlen * steps, _face3[2] + vlen * steps);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tscope.addGroup(start, verticesArray.length / 3 - start, 0);\n\t\t\t\t} // Create faces for the z-sides of the shape\n\n\n\t\t\t\tfunction buildSideFaces() {\n\t\t\t\t\tvar start = verticesArray.length / 3;\n\t\t\t\t\tvar layeroffset = 0;\n\t\t\t\t\tsidewalls(contour, layeroffset);\n\t\t\t\t\tlayeroffset += contour.length;\n\n\t\t\t\t\tfor (var _h5 = 0, _hl5 = holes.length; _h5 < _hl5; _h5++) {\n\t\t\t\t\t\tvar _ahole5 = holes[_h5];\n\t\t\t\t\t\tsidewalls(_ahole5, layeroffset); //, true\n\n\t\t\t\t\t\tlayeroffset += _ahole5.length;\n\t\t\t\t\t}\n\n\t\t\t\t\tscope.addGroup(start, verticesArray.length / 3 - start, 1);\n\t\t\t\t}\n\n\t\t\t\tfunction sidewalls(contour, layeroffset) {\n\t\t\t\t\tvar i = contour.length;\n\n\t\t\t\t\twhile (--i >= 0) {\n\t\t\t\t\t\tvar _j2 = i;\n\n\t\t\t\t\t\tvar _k2 = i - 1;\n\n\t\t\t\t\t\tif (_k2 < 0) _k2 = contour.length - 1; //console.log('b', i,j, i-1, k,vertices.length);\n\n\t\t\t\t\t\tfor (var _s = 0, sl = steps + bevelSegments * 2; _s < sl;
1 _s++) {\n\t\t\t\t\t\t\tvar slen1 = vlen * _s;\n\t\t\t\t\t\t\tvar slen2 = vlen * (_s + 1);\n\n\t\t\t\t\t\t\tvar a = layeroffset + _j2 + slen1,\n\t\t\t\t\t\t\t\t\t_b2 = layeroffset + _k2 + slen1,\n\t\t\t\t\t\t\t\t\tc = layeroffset + _k2 + slen2,\n\t\t\t\t\t\t\t\t\td = layeroffset + _j2 + slen2;\n\n\t\t\t\t\t\t\tf4(a, _b2, c, d);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfunction v(x, y, z) {\n\t\t\t\t\tplaceholder.push(x);\n\t\t\t\t\tplaceholder.push(y);\n\t\t\t\t\tplaceholder.push(z);\n\t\t\t\t}\n\n\t\t\t\tfunction f3(a, b, c) {\n\t\t\t\t\taddVertex(a);\n\t\t\t\t\taddVertex(b);\n\t\t\t\t\taddVertex(c);\n\t\t\t\t\tvar nextIndex = verticesArray.length / 3;\n\t\t\t\t\tvar uvs = uvgen.generateTopUV(scope, verticesArray, nextIndex - 3, nextIndex - 2, nextIndex - 1);\n\t\t\t\t\taddUV(uvs[0]);\n\t\t\t\t\taddUV(uvs[1]);\n\t\t\t\t\taddUV(uvs[2]);\n\t\t\t\t}\n\n\t\t\t\tfunction f4(a, b, c, d) {\n\t\t\t\t\taddVertex(a);\n\t\t\t\t\taddVertex(b);\n\t\t\t\t\taddVertex(d);\n\t\t\t\t\taddVertex(b);\n\t\t\t\t\taddVertex(c);\n\t\t\t\t\taddVertex(d);\n\t\t\t\t\tvar nextIndex = verticesArray.length / 3;\n\t\t\t\t\tvar uvs = uvgen.generateSideWallUV(scope, verticesArray, nextIndex - 6, nextIndex - 3, nextIndex - 2, nextIndex - 1);\n\t\t\t\t\taddUV(uvs[0]);\n\t\t\t\t\taddUV(uvs[1]);\n\t\t\t\t\taddUV(uvs[3]);\n\t\t\t\t\taddUV(uvs[1]);\n\t\t\t\t\taddUV(uvs[2]);\n\t\t\t\t\taddUV(uvs[3]);\n\t\t\t\t}\n\n\t\t\t\tfunction addVertex(index) {\n\t\t\t\t\tverticesArray.push(placeholder[index * 3 + 0]);\n\t\t\t\t\tverticesArray.push(placeholder[index * 3 + 1]);\n\t\t\t\t\tverticesArray.push(placeholder[index * 3 + 2]);\n\t\t\t\t}\n\n\t\t\t\tfunction addUV(vector2) {\n\t\t\t\t\tuvArray.push(vector2.x);\n\t\t\t\t\tuvArray.push(vector2.y);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = ExtrudeBufferGeometry.prototype;\n\n\t\t_proto.toJSON = function toJSON() {\n\t\t\tvar data = BufferGeometry.prototype.toJSON.call(this);\n\t\t\tvar shapes = this.parameters.shapes;\n\t\t\tvar options = this.parameters.options;\n\t\t\treturn _toJSON(shapes, options, data);\n\t\t};\n\n\t\treturn ExtrudeBufferGeometry;\n\t}(BufferGeometry);\n\n\tvar WorldUVGenerator = {\n\t\tgenerateTopUV: function generateTopUV(geometry, vertices, indexA, indexB, indexC) {\n\t\t\tvar a_x = vertices[indexA * 3];\n\t\t\tvar a_y = vertices[indexA * 3 + 1];\n\t\t\tvar b_x = vertices[indexB * 3];\n\t\t\tvar b_y = vertices[indexB * 3 + 1];\n\t\t\tvar c_x = vertices[indexC * 3];\n\t\t\tvar c_y = vertices[indexC * 3 + 1];\n\t\t\treturn [new Vector2(a_x, a_y), new Vector2(b_x, b_y), new Vector2(c_x, c_y)];\n\t\t},\n\t\tgenerateSideWallUV: function generateSideWallUV(geometry, vertices, indexA, indexB, indexC, indexD) {\n\t\t\tvar a_x = vertices[indexA * 3];\n\t\t\tvar a_y = vertices[indexA * 3 + 1];\n\t\t\tvar a_z = vertices[indexA * 3 + 2];\n\t\t\tvar b_x = vertices[indexB * 3];\n\t\t\tvar b_y = vertices[indexB * 3 + 1];\n\t\t\tvar b_z = vertices[indexB * 3 + 2];\n\t\t\tvar c_x = vertices[indexC * 3];\n\t\t\tvar c_y = vertices[indexC * 3 + 1];\n\t\t\tvar c_z = vertices[indexC * 3 + 2];\n\t\t\tvar d_x = vertices[indexD * 3];\n\t\t\tvar d_y = vertices[indexD * 3 + 1];\n\t\t\tvar d_z = vertices[indexD * 3 + 2];\n\n\t\t\tif (Math.abs(a_y - b_y) < 0.01) {\n\t\t\t\treturn [new Vector2(a_x, 1 - a_z), new Vector2(b_x, 1 - b_z), new Vector2(c_x, 1 - c_z), new Vector2(d_x, 1 - d_z)];\n\t\t\t} else {\n\t\t\t\treturn [new Vector2(a_y, 1 - a_z), new Vector2(b_y, 1 - b_z), new Vector2(c_y, 1 - c_z), new Vector2(d_y, 1 - d_z)];\n\t\t\t}\n\t\t}\n\t};\n\n\tfunction _toJSON(shapes, options, data) {\n\t\tdata.shapes = [];\n\n\t\tif (Array.isArray(shapes)) {\n\t\t\tfor (var i = 0, l = shapes.length; i < l; i++) {\n\t\t\t\tvar shape = shapes[i];\n\t\t\t\tdata.shapes.push(shape.uuid);\n\t\t\t}\n\t\t} else {\n\t\t\tdata.shapes.push(shapes.uuid);\n\t\t}\n\n\t\tif (options.extrudePath !== undefined) data.options.extrudePath = options.extrudePath.toJSON();\n\t\treturn data;\n\t}\n\n\tvar ExtrudeGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(ExtrudeGeometry, _Geometry);\n\n\t\tfunction ExtrudeGeometry(shapes, options) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'ExtrudeGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tshapes: shapes,\n\t\t\t\toptions: options\n\t\t\t};\n\n\t\t\t_this.fromBufferGeometry(new ExtrudeBufferGeometry(shapes, options));\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = ExtrudeGeometry.prototype;\n\n\t\t_proto.toJSON = function toJSON() {\n\t\t\tvar data = _Geometry.prototype.toJSON.call(this);\n\n\t\t\tvar shapes = this.parameters.shapes;\n\t\t\tvar options = this.parameters.options;\n\t\t\treturn _toJSON$1(shapes, options, data);\n\t\t};\n\n\t\treturn ExtrudeGeometry;\n\t}(Geometry);\n\n\tfunction _toJSON$1(shapes, options, data) {\n\t\tdata.shapes = [];\n\n\t\tif (Array.isArray(shapes)) {\n\t\t\tfor (var i = 0, l = shapes.length; i < l;
1 i++) {\n\t\t\t\tvar shape = shapes[i];\n\t\t\t\tdata.shapes.push(shape.uuid);\n\t\t\t}\n\t\t} else {\n\t\t\tdata.shapes.push(shapes.uuid);\n\t\t}\n\n\t\tif (options.extrudePath !== undefined) data.options.extrudePath = options.extrudePath.toJSON();\n\t\treturn data;\n\t}\n\n\tvar IcosahedronBufferGeometry = /*#__PURE__*/function (_PolyhedronBufferGeom) {\n\t\t_inheritsLoose(IcosahedronBufferGeometry, _PolyhedronBufferGeom);\n\n\t\tfunction IcosahedronBufferGeometry(radius, detail) {\n\t\t\tvar _this;\n\n\t\t\tif (radius === void 0) {\n\t\t\t\tradius = 1;\n\t\t\t}\n\n\t\t\tif (detail === void 0) {\n\t\t\t\tdetail = 0;\n\t\t\t}\n\n\t\t\tvar t = (1 + Math.sqrt(5)) / 2;\n\t\t\tvar vertices = [-1, t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, 0, -1, t, 0, 1, t, 0, -1, -t, 0, 1, -t, t, 0, -1, t, 0, 1, -t, 0, -1, -t, 0, 1];\n\t\t\tvar indices = [0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 0, 10, 11, 1, 5, 9, 5, 11, 4, 11, 10, 2, 10, 7, 6, 7, 1, 8, 3, 9, 4, 3, 4, 2, 3, 2, 6, 3, 6, 8, 3, 8, 9, 4, 9, 5, 2, 4, 11, 6, 2, 10, 8, 6, 7, 9, 8, 1];\n\t\t\t_this = _PolyhedronBufferGeom.call(this, vertices, indices, radius, detail) || this;\n\t\t\t_this.type = 'IcosahedronBufferGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\tdetail: detail\n\t\t\t};\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn IcosahedronBufferGeometry;\n\t}(PolyhedronBufferGeometry);\n\n\tvar IcosahedronGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(IcosahedronGeometry, _Geometry);\n\n\t\tfunction IcosahedronGeometry(radius, detail) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'IcosahedronGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\tdetail: detail\n\t\t\t};\n\n\t\t\t_this.fromBufferGeometry(new IcosahedronBufferGeometry(radius, detail));\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn IcosahedronGeometry;\n\t}(Geometry);\n\n\tvar LatheBufferGeometry = /*#__PURE__*/function (_BufferGeometry) {\n\t\t_inheritsLoose(LatheBufferGeometry, _BufferGeometry);\n\n\t\tfunction LatheBufferGeometry(points, segments, phiStart, phiLength) {\n\t\t\tvar _this;\n\n\t\t\tif (segments === void 0) {\n\t\t\t\tsegments = 12;\n\t\t\t}\n\n\t\t\tif (phiStart === void 0) {\n\t\t\t\tphiStart = 0;\n\t\t\t}\n\n\t\t\tif (phiLength === void 0) {\n\t\t\t\tphiLength = Math.PI * 2;\n\t\t\t}\n\n\t\t\t_this = _BufferGeometry.call(this) || this;\n\t\t\t_this.type = 'LatheBufferGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tpoints: points,\n\t\t\t\tsegments: segments,\n\t\t\t\tphiStart: phiStart,\n\t\t\t\tphiLength: phiLength\n\t\t\t};\n\t\t\tsegments = Math.floor(segments); // clamp phiLength so it's in range of [ 0, 2PI ]\n\n\t\t\tphiLength = MathUtils.clamp(phiLength, 0, Math.PI * 2); // buffers\n\n\t\t\tvar indices = [];\n\t\t\tvar vertices = [];\n\t\t\tvar uvs = []; // helper variables\n\n\t\t\tvar inverseSegments = 1.0 / segments;\n\t\t\tvar vertex = new Vector3();\n\t\t\tvar uv = new Vector2(); // generate vertices and uvs\n\n\t\t\tfor (var i = 0; i <= segments; i++) {\n\t\t\t\tvar phi = phiStart + i * inverseSegments * phiLength;\n\t\t\t\tvar sin = Math.sin(phi);\n\t\t\t\tvar cos = Math.cos(phi);\n\n\t\t\t\tfor (var j = 0; j <= points.length - 1; j++) {\n\t\t\t\t\t// vertex\n\t\t\t\t\tvertex.x = points[j].x * sin;\n\t\t\t\t\tvertex.y = points[j].y;\n\t\t\t\t\tvertex.z = points[j].x * cos;\n\t\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z); // uv\n\n\t\t\t\t\tuv.x = i / segments;\n\t\t\t\t\tuv.y = j / (points.length - 1);\n\t\t\t\t\tuvs.push(uv.x, uv.y);\n\t\t\t\t}\n\t\t\t} // indices\n\n\n\t\t\tfor (var _i = 0; _i < segments; _i++) {\n\t\t\t\tfor (var _j = 0; _j < points.length - 1; _j++) {\n\t\t\t\t\tvar base = _j + _i * points.length;\n\t\t\t\t\tvar a = base;\n\t\t\t\t\tvar b = base + points.length;\n\t\t\t\t\tvar c = base + points.length + 1;\n\t\t\t\t\tvar d = base + 1; // faces\n\n\t\t\t\t\tindices.push(a, b, d);\n\t\t\t\t\tindices.push(b, c, d);\n\t\t\t\t}\n\t\t\t} // build geometry\n\n\n\t\t\t_this.setIndex(indices);\n\n\t\t\t_this.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\n\t\t\t_this.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); // generate normals\n\n\n\t\t\t_this.computeVertexNormals(); // if the geometry is closed, we need to average the normals along the seam.\n\t\t\t// because the corresponding vertices are identical (but still have different UVs).\n\n\n\t\t\tif (phiLength === Math.PI * 2) {\n\t\t\t\tvar normals = _this.attributes.normal.array;\n\t\t\t\tvar n1 = new Vector3();\n\t\t\t\tvar n2 = new Vector3();\n\t\t\t\tvar n = new Vector3(); // this is the buffer offset for the last line of vertices\n\n\t\t\t\tvar _base = segments * points.length * 3;\n\n\t\t\t\tfor (var _i2 = 0, _j2 = 0; _i2 < points.length; _i2++, _j2 += 3) {\n\t\t\t\t\t// select the normal of the vertex in the first line\n\t\t\t\t\tn1.x = normals[_j2 + 0];\n\t\t\t\t\tn1.y = normals[_j2 + 1];\n\t\t\t\t\tn1.z = normals[_j2 + 2]; // select the normal of the vertex in the last line\n\n\t\t\t\t\tn2.x = normals[_base + _j2 + 0];\n\t\t\t\t\tn2.y = normals[_base + _j2 + 1];\n\t\t\t\t\tn2.z = normals[_base + _j2 + 2]; // average normals\n\n\t\t\t\t\tn.addVectors(n1, n2).normalize(); // assign the new values to both normals\n\n\t\t\t\t\tnormals[_j2 + 0] = normals[_base + _j2 + 0] = n.x;\n\t\t\t\t\tnormals[_j2 + 1] = normals[_base + _j2 + 1] = n.y;\n\t\t\t\t\tnormals[_j2 + 2] = normals[_base + _j2 + 2] = n.z;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn LatheBufferGeometry;\n\t}(BufferGeometry);\n\n\tvar LatheGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(LatheGeometry, _Geometry);\n\n\t\tfunction LatheGeometry(points, segments, phiStart, phiLength) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'LatheGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tpoints: points,\n\t\t\t\tsegments: segments,\n\t\t\t\tphiStart: phiStart,\n\t\t\t\tphiLength: phiLength\n\t\t\t};\n\n\t\t\t_this.fromBufferGeometry(new LatheBufferGeometry(points, segments, phiStart, phiLength));\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn LatheGeometry;\n\t}(Geometry);\n\n\tvar OctahedronBufferGeometry = /*#__PURE__*/function (_PolyhedronBufferGeom) {\n\t\t_inheritsLoose(OctahedronBufferGeometry, _PolyhedronBufferGeom);\n\n\t\tfunction OctahedronBufferGeometry(radius, detail) {\n\t\t\tvar _this;\n\n\t\t\tif (radius === void 0) {\n\t\t\t\tradius = 1;\n\t\t\t}\n\n\t\t\tif (detail === void 0) {\n\t\t\t\tdetail = 0;\n\t\t\t}\n\n\t\t\tvar vertices = [1, 0, 0, -1, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 1, 0, 0, -1];\n\t\t\tvar indices = [0, 2, 4, 0, 4, 3, 0, 3, 5, 0, 5, 2, 1, 2, 5, 1, 5, 3, 1, 3, 4, 1, 4, 2];\n\t\t\t_this = _PolyhedronBufferGeom.call(this, vertices, indices, radius, detail) || this;\n\t\t\t_this.type = 'OctahedronBufferGeometry';
1\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\tdetail: detail\n\t\t\t};\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn OctahedronBufferGeometry;\n\t}(PolyhedronBufferGeometry);\n\n\tvar OctahedronGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(OctahedronGeometry, _Geometry);\n\n\t\tfunction OctahedronGeometry(radius, detail) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'OctahedronGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\tdetail: detail\n\t\t\t};\n\n\t\t\t_this.fromBufferGeometry(new OctahedronBufferGeometry(radius, detail));\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn OctahedronGeometry;\n\t}(Geometry);\n\n\t/**\n\t * Parametric Surfaces Geometry\n\t * based on the brilliant article by @prideout https://prideout.net/blog/old/blog/index.html@p=44.html\n\t */\n\n\tfunction ParametricBufferGeometry(func, slices, stacks) {\n\t\tBufferGeometry.call(this);\n\t\tthis.type = 'ParametricBufferGeometry';\n\t\tthis.parameters = {\n\t\t\tfunc: func,\n\t\t\tslices: slices,\n\t\t\tstacks: stacks\n\t\t}; // buffers\n\n\t\tvar indices = [];\n\t\tvar vertices = [];\n\t\tvar normals = [];\n\t\tvar uvs = [];\n\t\tvar EPS = 0.00001;\n\t\tvar normal = new Vector3();\n\t\tvar p0 = new Vector3(),\n\t\t\t\tp1 = new Vector3();\n\t\tvar pu = new Vector3(),\n\t\t\t\tpv = new Vector3();\n\n\t\tif (func.length < 3) {\n\t\t\tconsole.error('THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.');\n\t\t} // generate vertices, normals and uvs\n\n\n\t\tvar sliceCount = slices + 1;\n\n\t\tfor (var i = 0; i <= stacks; i++) {\n\t\t\tvar v = i / stacks;\n\n\t\t\tfor (var j = 0; j <= slices; j++) {\n\t\t\t\tvar u = j / slices; // vertex\n\n\t\t\t\tfunc(u, v, p0);\n\t\t\t\tvertices.push(p0.x, p0.y, p0.z); // normal\n\t\t\t\t// approximate tangent vectors via finite differences\n\n\t\t\t\tif (u - EPS >= 0) {\n\t\t\t\t\tfunc(u - EPS, v, p1);\n\t\t\t\t\tpu.subVectors(p0, p1);\n\t\t\t\t} else {\n\t\t\t\t\tfunc(u + EPS, v, p1);\n\t\t\t\t\tpu.subVectors(p1, p0);\n\t\t\t\t}\n\n\t\t\t\tif (v - EPS >= 0) {\n\t\t\t\t\tfunc(u, v - EPS, p1);\n\t\t\t\t\tpv.subVectors(p0, p1);\n\t\t\t\t} else {\n\t\t\t\t\tfunc(u, v + EPS, p1);\n\t\t\t\t\tpv.subVectors(p1, p0);\n\t\t\t\t} // cross product of tangent vectors returns surface normal\n\n\n\t\t\t\tnormal.crossVectors(pu, pv).normalize();\n\t\t\t\tnormals.push(normal.x, normal.y, normal.z); // uv\n\n\t\t\t\tuvs.push(u, v);\n\t\t\t}\n\t\t} // generate indices\n\n\n\t\tfor (var _i = 0; _i < stacks; _i++) {\n\t\t\tfor (var _j = 0; _j < slices; _j++) {\n\t\t\t\tvar a = _i * sliceCount + _j;\n\t\t\t\tvar b = _i * sliceCount + _j + 1;\n\t\t\t\tvar c = (_i + 1) * sliceCount + _j + 1;\n\t\t\t\tvar d = (_i + 1) * sliceCount + _j; // faces one and two\n\n\t\t\t\tindices.push(a, b, d);\n\t\t\t\tindices.push(b, c, d);\n\t\t\t}\n\t\t} // build geometry\n\n\n\t\tthis.setIndex(indices);\n\t\tthis.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\tthis.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\t\tthis.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\t}\n\n\tParametricBufferGeometry.prototype = Object.create(BufferGeometry.prototype);\n\tParametricBufferGeometry.prototype.constructor = ParametricBufferGeometry;\n\n\t/**\n\t * Parametric Surfaces Geometry\n\t * based on the brilliant article by @prideout https://prideout.net/blog/old/blog/index.html@p=44.html\n\t */\n\n\tfunction ParametricGeometry(func, slices, stacks) {\n\t\tGeometry.call(this);\n\t\tthis.type = 'ParametricGeometry';\n\t\tthis.parameters = {\n\t\t\tfunc: func,\n\t\t\tslices: slices,\n\t\t\tstacks: stacks\n\t\t};\n\t\tthis.fromBufferGeometry(new ParametricBufferGeometry(func, slices, stacks));\n\t\tthis.mergeVertices();\n\t}\n\n\tParametricGeometry.prototype = Object.create(Geometry.prototype);\n\tParametricGeometry.prototype.constructor = ParametricGeometry;\n\n\tvar PlaneGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(PlaneGeometry, _Geometry);\n\n\t\tfunction PlaneGeometry(width, height, widthSegments, heightSegments) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'PlaneGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\twidth: width,\n\t\t\t\theight: height,\n\t\t\t\twidthSegments: widthSegments,\n\t\t\t\theightSegments: heightSegments\n\t\t\t};\n\n\t\t\t_this.fromBufferGeometry(new PlaneBufferGeometry(width, height, widthSegments, heightSegments));\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn PlaneGeometry;\n\t}(Geometry);\n\n\tvar PolyhedronGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(PolyhedronGeometry, _Geometry);\n\n\t\tfunction PolyhedronGeometry(vertices, indices, radius, detail) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'PolyhedronGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tvertices: vertices,\n\t\t\t\tindices: indices,\n\t\t\t\tradius: radius,\
1n\t\t\t\tdetail: detail\n\t\t\t};\n\n\t\t\t_this.fromBufferGeometry(new PolyhedronBufferGeometry(vertices, indices, radius, detail));\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn PolyhedronGeometry;\n\t}(Geometry);\n\n\tvar RingBufferGeometry = /*#__PURE__*/function (_BufferGeometry) {\n\t\t_inheritsLoose(RingBufferGeometry, _BufferGeometry);\n\n\t\tfunction RingBufferGeometry(innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength) {\n\t\t\tvar _this;\n\n\t\t\tif (innerRadius === void 0) {\n\t\t\t\tinnerRadius = 0.5;\n\t\t\t}\n\n\t\t\tif (outerRadius === void 0) {\n\t\t\t\touterRadius = 1;\n\t\t\t}\n\n\t\t\tif (thetaSegments === void 0) {\n\t\t\t\tthetaSegments = 8;\n\t\t\t}\n\n\t\t\tif (phiSegments === void 0) {\n\t\t\t\tphiSegments = 1;\n\t\t\t}\n\n\t\t\tif (thetaStart === void 0) {\n\t\t\t\tthetaStart = 0;\n\t\t\t}\n\n\t\t\tif (thetaLength === void 0) {\n\t\t\t\tthetaLength = Math.PI * 2;\n\t\t\t}\n\n\t\t\t_this = _BufferGeometry.call(this) || this;\n\t\t\t_this.type = 'RingBufferGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tinnerRadius: innerRadius,\n\t\t\t\touterRadius: outerRadius,\n\t\t\t\tthetaSegments: thetaSegments,\n\t\t\t\tphiSegments: phiSegments,\n\t\t\t\tthetaStart: thetaStart,\n\t\t\t\tthetaLength: thetaLength\n\t\t\t};\n\t\t\tthetaSegments = Math.max(3, thetaSegments);\n\t\t\tphiSegments = Math.max(1, phiSegments); // buffers\n\n\t\t\tvar indices = [];\n\t\t\tvar vertices = [];\n\t\t\tvar normals = [];\n\t\t\tvar uvs = []; // some helper variables\n\n\t\t\tvar radius = innerRadius;\n\t\t\tvar radiusStep = (outerRadius - innerRadius) / phiSegments;\n\t\t\tvar vertex = new Vector3();\n\t\t\tvar uv = new Vector2(); // generate vertices, normals and uvs\n\n\t\t\tfor (var j = 0; j <= phiSegments; j++) {\n\t\t\t\tfor (var i = 0; i <= thetaSegments; i++) {\n\t\t\t\t\t// values are generate from the inside of the ring to the outside\n\t\t\t\t\tvar segment = thetaStart + i / thetaSegments * thetaLength; // vertex\n\n\t\t\t\t\tvertex.x = radius * Math.cos(segment);\n\t\t\t\t\tvertex.y = radius * Math.sin(segment);\n\t\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z); // normal\n\n\t\t\t\t\tnormals.push(0, 0, 1); // uv\n\n\t\t\t\t\tuv.x = (vertex.x / outerRadius + 1) / 2;\n\t\t\t\t\tuv.y = (vertex.y / outerRadius + 1) / 2;\n\t\t\t\t\tuvs.push(uv.x, uv.y);\n\t\t\t\t} // increase the radius for next row of vertices\n\n\n\t\t\t\tradius += radiusStep;\n\t\t\t} // indices\n\n\n\t\t\tfor (var _j = 0; _j < phiSegments; _j++) {\n\t\t\t\tvar thetaSegmentLevel = _j * (thetaSegments + 1);\n\n\t\t\t\tfor (var _i = 0; _i < thetaSegments; _i++) {\n\t\t\t\t\tvar _segment = _i + thetaSegmentLevel;\n\n\t\t\t\t\tvar a = _segment;\n\t\t\t\t\tvar b = _segment + thetaSegments + 1;\n\t\t\t\t\tvar c = _segment + thetaSegments + 2;\n\t\t\t\t\tvar d = _segment + 1; // faces\n\n\t\t\t\t\tindices.push(a, b, d);\n\t\t\t\t\tindices.push(b, c, d);\n\t\t\t\t}\n\t\t\t} // build geometry\n\n\n\t\t\t_this.setIndex(indices);\n\n\t\t\t_this.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\n\t\t\t_this.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\n\t\t\t_this.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn RingBufferGeometry;\n\t}(BufferGeometry);\n\n\tvar RingGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(RingGeometry, _Geometry);\n\n\t\tfunction RingGeometry(innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'RingGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tinnerRadius: innerRadius,\n\t\t\t\touterRadius: outerRadius,\n\t\t\t\tthetaSegments: thetaSegments,\n\t\t\t\tphiSegments: phiSegments,\n\t\t\t\tthetaStart: thetaStart,\n\t\t\t\tthetaLength: thetaLength\n\t\t\t};\n\n\t\t\t_this.fromBufferGeometry(new RingBufferGeometry(innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength));\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn RingGeometry;\n\t}(Geometry);\n\n\tvar ShapeBufferGeometry = /*#__PURE__*/function (_BufferGeometry) {\n\t\t_inheritsLoose(ShapeBufferGeometry, _BufferGeometry);\n\n\t\tfunction ShapeBufferGeometry(shapes, curveSegments) {\n\t\t\tvar _this;\n\n\t\t\tif (curveSegments === void 0) {\n\t\t\t\tcurveSegments = 12;\n\t\t\t}\n\n\t\t\t_this = _BufferGeometry.call(this) || this;\n\t\t\t_this.type = 'ShapeBufferGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tshapes: shapes,\n\t\t\t\tcurveSegments: curveSegments\n\t\t\t}; // buffers\n\n\t\t\tvar indices = [];\n\t\t\tvar vertices = [];\n\t\t\tvar normals = [];\n\t\t\tvar uvs = []; // helper variables\n\n\t\t\tvar groupStart = 0;\n\t\t\tvar groupCount = 0;
1 // allow single and array values for \"shapes\" parameter\n\n\t\t\tif (Array.isArray(shapes) === false) {\n\t\t\t\taddShape(shapes);\n\t\t\t} else {\n\t\t\t\tfor (var i = 0; i < shapes.length; i++) {\n\t\t\t\t\taddShape(shapes[i]);\n\n\t\t\t\t\t_this.addGroup(groupStart, groupCount, i); // enables MultiMaterial support\n\n\n\t\t\t\t\tgroupStart += groupCount;\n\t\t\t\t\tgroupCount = 0;\n\t\t\t\t}\n\t\t\t} // build geometry\n\n\n\t\t\t_this.setIndex(indices);\n\n\t\t\t_this.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\n\t\t\t_this.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\n\t\t\t_this.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); // helper functions\n\n\n\t\t\tfunction addShape(shape) {\n\t\t\t\tvar indexOffset = vertices.length / 3;\n\t\t\t\tvar points = shape.extractPoints(curveSegments);\n\t\t\t\tvar shapeVertices = points.shape;\n\t\t\t\tvar shapeHoles = points.holes; // check direction of vertices\n\n\t\t\t\tif (ShapeUtils.isClockWise(shapeVertices) === false) {\n\t\t\t\t\tshapeVertices = shapeVertices.reverse();\n\t\t\t\t}\n\n\t\t\t\tfor (var _i = 0, l = shapeHoles.length; _i < l; _i++) {\n\t\t\t\t\tvar shapeHole = shapeHoles[_i];\n\n\t\t\t\t\tif (ShapeUtils.isClockWise(shapeHole) === true) {\n\t\t\t\t\t\tshapeHoles[_i] = shapeHole.reverse();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tvar faces = ShapeUtils.triangulateShape(shapeVertices, shapeHoles); // join vertices of inner and outer paths to a single array\n\n\t\t\t\tfor (var _i2 = 0, _l = shapeHoles.length; _i2 < _l; _i2++) {\n\t\t\t\t\tvar _shapeHole = shapeHoles[_i2];\n\t\t\t\t\tshapeVertices = shapeVertices.concat(_shapeHole);\n\t\t\t\t} // vertices, normals, uvs\n\n\n\t\t\t\tfor (var _i3 = 0, _l2 = shapeVertices.length; _i3 < _l2; _i3++) {\n\t\t\t\t\tvar vertex = shapeVertices[_i3];\n\t\t\t\t\tvertices.push(vertex.x, vertex.y, 0);\n\t\t\t\t\tnormals.push(0, 0, 1);\n\t\t\t\t\tuvs.push(vertex.x, vertex.y); // world uvs\n\t\t\t\t} // incides\n\n\n\t\t\t\tfor (var _i4 = 0, _l3 = faces.length; _i4 < _l3; _i4++) {\n\t\t\t\t\tvar face = faces[_i4];\n\t\t\t\t\tvar a = face[0] + indexOffset;\n\t\t\t\t\tvar b = face[1] + indexOffset;\n\t\t\t\t\tvar c = face[2] + indexOffset;\n\t\t\t\t\tindices.push(a, b, c);\n\t\t\t\t\tgroupCount += 3;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = ShapeBufferGeometry.prototype;\n\n\t\t_proto.toJSON = function toJSON() {\n\t\t\tvar data = BufferGeometry.prototype.toJSON.call(this);\n\t\t\tvar shapes = this.parameters.shapes;\n\t\t\treturn _toJSON$2(shapes, data);\n\t\t};\n\n\t\treturn ShapeBufferGeometry;\n\t}(BufferGeometry);\n\n\tfunction _toJSON$2(shapes, data) {\n\t\tdata.shapes = [];\n\n\t\tif (Array.isArray(shapes)) {\n\t\t\tfor (var i = 0, l = shapes.length; i < l; i++) {\n\t\t\t\tvar shape = shapes[i];\n\t\t\t\tdata.shapes.push(shape.uuid);\n\t\t\t}\n\t\t} else {\n\t\t\tdata.shapes.push(shapes.uuid);\n\t\t}\n\n\t\treturn data;\n\t}\n\n\tvar ShapeGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(ShapeGeometry, _Geometry);\n\n\t\tfunction ShapeGeometry(shapes, curveSegments) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'ShapeGeometry';\n\n\t\t\tif (typeof curveSegments === 'object') {\n\t\t\t\tconsole.warn('THREE.ShapeGeometry: Options parameter has been removed.');\n\t\t\t\tcurveSegments = curveSegments.curveSegments;\n\t\t\t}\n\n\t\t\t_this.parameters = {\n\t\t\t\tshapes: shapes,\n\t\t\t\tcurveSegments: curveSegments\n\t\t\t};\n\n\t\t\t_this.fromBufferGeometry(new ShapeBufferGeometry(shapes, curveSegments));\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = ShapeGeometry.prototype;\n\n\t\t_proto.toJSON = function toJSON() {\n\t\t\tvar data = Geometry.prototype.toJSON.call(this);\n\t\t\tvar shapes = this.parameters.shapes;\n\t\t\treturn _toJSON$3(shapes, data);\n\t\t};\n\n\t\treturn ShapeGeometry;\n\t}(Geometry);\n\n\tfunction _toJSON$3(shapes, data) {\n\t\tdata.shapes = [];\n\n\t\tif (Array.isArray(shapes)) {\n\t\t\tfor (var i = 0, l = shapes.length; i < l;
1 i++) {\n\t\t\t\tvar shape = shapes[i];\n\t\t\t\tdata.shapes.push(shape.uuid);\n\t\t\t}\n\t\t} else {\n\t\t\tdata.shapes.push(shapes.uuid);\n\t\t}\n\n\t\treturn data;\n\t}\n\n\tvar SphereBufferGeometry = /*#__PURE__*/function (_BufferGeometry) {\n\t\t_inheritsLoose(SphereBufferGeometry, _BufferGeometry);\n\n\t\tfunction SphereBufferGeometry(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength) {\n\t\t\tvar _this;\n\n\t\t\tif (radius === void 0) {\n\t\t\t\tradius = 1;\n\t\t\t}\n\n\t\t\tif (widthSegments === void 0) {\n\t\t\t\twidthSegments = 8;\n\t\t\t}\n\n\t\t\tif (heightSegments === void 0) {\n\t\t\t\theightSegments = 6;\n\t\t\t}\n\n\t\t\tif (phiStart === void 0) {\n\t\t\t\tphiStart = 0;\n\t\t\t}\n\n\t\t\tif (phiLength === void 0) {\n\t\t\t\tphiLength = Math.PI * 2;\n\t\t\t}\n\n\t\t\tif (thetaStart === void 0) {\n\t\t\t\tthetaStart = 0;\n\t\t\t}\n\n\t\t\tif (thetaLength === void 0) {\n\t\t\t\tthetaLength = Math.PI;\n\t\t\t}\n\n\t\t\t_this = _BufferGeometry.call(this) || this;\n\t\t\t_this.type = 'SphereBufferGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\twidthSegments: widthSegments,\n\t\t\t\theightSegments: heightSegments,\n\t\t\t\tphiStart: phiStart,\n\t\t\t\tphiLength: phiLength,\n\t\t\t\tthetaStart: thetaStart,\n\t\t\t\tthetaLength: thetaLength\n\t\t\t};\n\t\t\twidthSegments = Math.max(3, Math.floor(widthSegments));\n\t\t\theightSegments = Math.max(2, Math.floor(heightSegments));\n\t\t\tvar thetaEnd = Math.min(thetaStart + thetaLength, Math.PI);\n\t\t\tvar index = 0;\n\t\t\tvar grid = [];\n\t\t\tvar vertex = new Vector3();\n\t\t\tvar normal = new Vector3(); // buffers\n\n\t\t\tvar indices = [];\n\t\t\tvar vertices = [];\n\t\t\tvar normals = [];\n\t\t\tvar uvs = []; // generate vertices, normals and uvs\n\n\t\t\tfor (var iy = 0; iy <= heightSegments; iy++) {\n\t\t\t\tvar verticesRow = [];\n\t\t\t\tvar v = iy / heightSegments; // special case for the poles\n\n\t\t\t\tvar uOffset = 0;\n\n\t\t\t\tif (iy == 0 && thetaStart == 0) {\n\t\t\t\t\tuOffset = 0.5 / widthSegments;\n\t\t\t\t} else if (iy == heightSegments && thetaEnd == Math.PI) {\n\t\t\t\t\tuOffset = -0.5 / widthSegments;\n\t\t\t\t}\n\n\t\t\t\tfor (var ix = 0; ix <= widthSegments; ix++) {\n\t\t\t\t\tvar u = ix / widthSegments; // vertex\n\n\t\t\t\t\tvertex.x = -radius * Math.cos(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength);\n\t\t\t\t\tvertex.y = radius * Math.cos(thetaStart + v * thetaLength);\n\t\t\t\t\tvertex.z = radius * Math.sin(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength);\n\t\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z); // normal\n\n\t\t\t\t\tnormal.copy(vertex).normalize();\n\t\t\t\t\tnormals.push(normal.x, normal.y, normal.z); // uv\n\n\t\t\t\t\tuvs.push(u + uOffset, 1 - v);\n\t\t\t\t\tverticesRow.push(index++);\n\t\t\t\t}\n\n\t\t\t\tgrid.push(verticesRow);\n\t\t\t} // indices\n\n\n\t\t\tfor (var _iy = 0; _iy < heightSegments; _iy++) {\n\t\t\t\tfor (var _ix = 0; _ix < widthSegments; _ix++) {\n\t\t\t\t\tvar a = grid[_iy][_ix + 1];\n\t\t\t\t\tvar b = grid[_iy][_ix];\n\t\t\t\t\tvar c = grid[_iy + 1][_ix];\n\t\t\t\t\tvar d = grid[_iy + 1][_ix + 1];\n\t\t\t\t\tif (_iy !== 0 || thetaStart > 0) indices.push(a, b, d);\n\t\t\t\t\tif (_iy !== heightSegments - 1 || thetaEnd < Math.PI) indices.push(b, c, d);\n\t\t\t\t}\n\t\t\t} // build geometry\n\n\n\t\t\t_this.setIndex(indices);\n\n\t\t\t_this.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\n\t\t\t_this.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\n\t\t\t_this.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn SphereBufferGeometry;\n\t}(BufferGeometry);\n\n\tvar SphereGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(SphereGeometry, _Geometry);\n\n\t\tfunction SphereGeometry(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'SphereGeometry';
1\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\twidthSegments: widthSegments,\n\t\t\t\theightSegments: heightSegments,\n\t\t\t\tphiStart: phiStart,\n\t\t\t\tphiLength: phiLength,\n\t\t\t\tthetaStart: thetaStart,\n\t\t\t\tthetaLength: thetaLength\n\t\t\t};\n\n\t\t\t_this.fromBufferGeometry(new SphereBufferGeometry(radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength));\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn SphereGeometry;\n\t}(Geometry);\n\n\tvar TetrahedronBufferGeometry = /*#__PURE__*/function (_PolyhedronBufferGeom) {\n\t\t_inheritsLoose(TetrahedronBufferGeometry, _PolyhedronBufferGeom);\n\n\t\tfunction TetrahedronBufferGeometry(radius, detail) {\n\t\t\tvar _this;\n\n\t\t\tif (radius === void 0) {\n\t\t\t\tradius = 1;\n\t\t\t}\n\n\t\t\tif (detail === void 0) {\n\t\t\t\tdetail = 0;\n\t\t\t}\n\n\t\t\tvar vertices = [1, 1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1];\n\t\t\tvar indices = [2, 1, 0, 0, 3, 2, 1, 3, 0, 2, 3, 1];\n\t\t\t_this = _PolyhedronBufferGeom.call(this, vertices, indices, radius, detail) || this;\n\t\t\t_this.type = 'TetrahedronBufferGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\tdetail: detail\n\t\t\t};\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn TetrahedronBufferGeometry;\n\t}(PolyhedronBufferGeometry);\n\n\tvar TetrahedronGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(TetrahedronGeometry, _Geometry);\n\n\t\tfunction TetrahedronGeometry(radius, detail) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'TetrahedronGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\tdetail: detail\n\t\t\t};\n\n\t\t\t_this.fromBufferGeometry(new TetrahedronBufferGeometry(radius, detail));\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn TetrahedronGeometry;\n\t}(Geometry);\n\n\tvar TextBufferGeometry = /*#__PURE__*/function (_ExtrudeBufferGeometr) {\n\t\t_inheritsLoose(TextBufferGeometry, _ExtrudeBufferGeometr);\n\n\t\tfunction TextBufferGeometry(text, parameters) {\n\t\t\tvar _this;\n\n\t\t\tif (parameters === void 0) {\n\t\t\t\tparameters = {};\n\t\t\t}\n\n\t\t\tvar font = parameters.font;\n\n\t\t\tif (!(font && font.isFont)) {\n\t\t\t\tconsole.error('THREE.TextGeometry: font parameter is not an instance of THREE.Font.');\n\t\t\t\treturn new BufferGeometry() || _assertThisInitialized(_this);\n\t\t\t}\n\n\t\t\tvar shapes = font.generateShapes(text, parameters.size); // translate parameters to ExtrudeGeometry API\n\n\t\t\tparameters.depth = parameters.height !== undefined ? parameters.height : 50; // defaults\n\n\t\t\tif (parameters.bevelThickness === undefined) parameters.bevelThickness = 10;\n\t\t\tif (parameters.bevelSize === undefined) parameters.bevelSize = 8;\n\t\t\tif (parameters.bevelEnabled === undefined) parameters.bevelEnabled = false;\n\t\t\t_this = _ExtrudeBufferGeometr.call(this, shapes, parameters) || this;\n\t\t\t_this.type = 'TextBufferGeometry';\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn TextBufferGeometry;\n\t}(ExtrudeBufferGeometry);\n\n\tvar TextGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(TextGeometry, _Geometry);\n\n\t\tfunction TextGeometry(text, parameters) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'TextGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\ttext: text,\n\t\t\t\tparameters: parameters\n\t\t\t};\n\n\t\t\t_this.fromBufferGeometry(new TextBufferGeometry(text, parameters));\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn TextGeometry;\n\t}(Geometry);\n\n\tvar TorusBufferGeometry = /*#__PURE__*/function (_BufferGeometry) {\n\t\t_inheritsLoose(TorusBufferGeometry, _BufferGeometry);\n\n\t\tfunction TorusBufferGeometry(radius, tube, radialSegments, tubularSegments, arc) {\n\t\t\tvar _this;\n\n\t\t\tif (radius === void 0) {\n\t\t\t\tradius = 1;\n\t\t\t}\n\n\t\t\tif (tube === void 0) {\n\t\t\t\ttube = 0.4;\n\t\t\t}\n\n\t\t\tif (radialSegments === void 0) {\n\t\t\t\tradialSegments = 8;\n\t\t\t}\n\n\t\t\tif (tubularSegments === void 0) {\n\t\t\t\ttubularSegments = 6;\n\t\t\t}\n\n\t\t\tif (arc === void 0) {\n\t\t\t\tarc = Math.PI * 2;\n\t\t\t}\n\n\t\t\t_this = _BufferGeometry.call(this) || this;\n\t\t\t_this.type = 'TorusBufferGeometry';
1\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\ttube: tube,\n\t\t\t\tradialSegments: radialSegments,\n\t\t\t\ttubularSegments: tubularSegments,\n\t\t\t\tarc: arc\n\t\t\t};\n\t\t\tradialSegments = Math.floor(radialSegments);\n\t\t\ttubularSegments = Math.floor(tubularSegments); // buffers\n\n\t\t\tvar indices = [];\n\t\t\tvar vertices = [];\n\t\t\tvar normals = [];\n\t\t\tvar uvs = []; // helper variables\n\n\t\t\tvar center = new Vector3();\n\t\t\tvar vertex = new Vector3();\n\t\t\tvar normal = new Vector3(); // generate vertices, normals and uvs\n\n\t\t\tfor (var j = 0; j <= radialSegments; j++) {\n\t\t\t\tfor (var i = 0; i <= tubularSegments; i++) {\n\t\t\t\t\tvar u = i / tubularSegments * arc;\n\t\t\t\t\tvar v = j / radialSegments * Math.PI * 2; // vertex\n\n\t\t\t\t\tvertex.x = (radius + tube * Math.cos(v)) * Math.cos(u);\n\t\t\t\t\tvertex.y = (radius + tube * Math.cos(v)) * Math.sin(u);\n\t\t\t\t\tvertex.z = tube * Math.sin(v);\n\t\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z); // normal\n\n\t\t\t\t\tcenter.x = radius * Math.cos(u);\n\t\t\t\t\tcenter.y = radius * Math.sin(u);\n\t\t\t\t\tnormal.subVectors(vertex, center).normalize();\n\t\t\t\t\tnormals.push(normal.x, normal.y, normal.z); // uv\n\n\t\t\t\t\tuvs.push(i / tubularSegments);\n\t\t\t\t\tuvs.push(j / radialSegments);\n\t\t\t\t}\n\t\t\t} // generate indices\n\n\n\t\t\tfor (var _j = 1; _j <= radialSegments; _j++) {\n\t\t\t\tfor (var _i = 1; _i <= tubularSegments; _i++) {\n\t\t\t\t\t// indices\n\t\t\t\t\tvar a = (tubularSegments + 1) * _j + _i - 1;\n\t\t\t\t\tvar b = (tubularSegments + 1) * (_j - 1) + _i - 1;\n\t\t\t\t\tvar c = (tubularSegments + 1) * (_j - 1) + _i;\n\t\t\t\t\tvar d = (tubularSegments + 1) * _j + _i; // faces\n\n\t\t\t\t\tindices.push(a, b, d);\n\t\t\t\t\tindices.push(b, c, d);\n\t\t\t\t}\n\t\t\t} // build geometry\n\n\n\t\t\t_this.setIndex(indices);\n\n\t\t\t_this.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\n\t\t\t_this.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\n\t\t\t_this.setAttribute('uv', new Float32BufferAttribute(uvs, 2));\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn TorusBufferGeometry;\n\t}(BufferGeometry);\n\n\tvar TorusGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(TorusGeometry, _Geometry);\n\n\t\tfunction TorusGeometry(radius, tube, radialSegments, tubularSegments, arc) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'TorusGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\ttube: tube,\n\t\t\t\tradialSegments: radialSegments,\n\t\t\t\ttubularSegments: tubularSegments,\n\t\t\t\tarc: arc\n\t\t\t};\n\n\t\t\t_this.fromBufferGeometry(new TorusBufferGeometry(radius, tube, radialSegments, tubularSegments, arc));\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn TorusGeometry;\n\t}(Geometry);\n\n\tvar TorusKnotBufferGeometry = /*#__PURE__*/function (_BufferGeometry) {\n\t\t_inheritsLoose(TorusKnotBufferGeometry, _BufferGeometry);\n\n\t\tfunction TorusKnotBufferGeometry(radius, tube, tubularSegments, radialSegments, p, q) {\n\t\t\tvar _this;\n\n\t\t\tif (radius === void 0) {\n\t\t\t\tradius = 1;\n\t\t\t}\n\n\t\t\tif (tube === void 0) {\n\t\t\t\ttube = 0.4;\n\t\t\t}\n\n\t\t\tif (tubularSegments === void 0) {\n\t\t\t\ttubularSegments = 64;\n\t\t\t}\n\n\t\t\tif (radialSegments === void 0) {\n\t\t\t\tradialSegments = 8;\n\t\t\t}\n\n\t\t\tif (p === void 0) {\n\t\t\t\tp = 2;\n\t\t\t}\n\n\t\t\tif (q === void 0) {\n\t\t\t\tq = 3;\n\t\t\t}\n\n\t\t\t_this = _BufferGeometry.call(this) || this;\n\t\t\t_this.type = 'TorusKnotBufferGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\ttube: tube,\n\t\t\t\ttubularSegments: tubularSegments,\n\t\t\t\tradialSegments: radialSegments,\n\t\t\t\tp: p,\n\t\t\t\tq: q\n\t\t\t};\n\t\t\ttubularSegments = Math.floor(tubularSegments);\n\t\t\tradialSegments = Math.floor(radialSegments); // buffers\n\n\t\t\tvar indices = [];\n\t\t\tvar vertices = [];\n\t\t\tvar normals = [];\n\t\t\tvar uvs = []; // helper variables\n\n\t\t\tvar vertex = new Vector3();\n\t\t\tvar normal = new Vector3();\n\t\t\tvar P1 = new Vector3();\n\t\t\tvar P2 = new Vector3();\n\t\t\tvar B = new Vector3();\n\t\t\tvar T = new Vector3();\n\t\t\tvar N = new Vector3(); // generate vertices, normals and uvs\n\n\t\t\tfor (var i = 0; i <= tubularSegments; ++i) {\n\t\t\t\t// the radian \"u\" is used to calculate the position on the torus curve of the current tubular segement\n\t\t\t\tvar u = i / tubularSegments * p * Math.PI * 2; // now we calculate two points. P1 is our current position on the curve, P2 is a little farther ahead.\n\t\t\t\t// these points are used to create a special \"coordinate space\", which is necessary to calculate the correct vertex positions\n\n\t\t\t\tcalculatePositionOnCurve(u, p, q, radius, P1);\n\t\t\t\tcalculatePositionOnCurve(u + 0.01, p, q, radius, P2); // calculate orthonormal basis\n\n\t\t\t\tT.subVectors(P2, P1);\n\t\t\t\tN.addVectors(P2, P1);\n\t\t\t\tB.crossVectors(T, N);\n\t\t\t\tN.crossVectors(B, T); // normalize B, N. T can be ignored, we don't use it\n\n\t\t\t\tB.normalize();\n\t\t\t\tN.normalize();\n\n\t\t\t\tfor (var j = 0; j <= radialSegments; ++j) {\n\t\t\t\t\t// now calculate the vertices. they are nothing more than an extrusion of the torus curve.\n\t\t\t\t\t// because we extrude a shape in the xy-plane, there is no need to calculate a z-value.\n\t\t\t\t\tvar v = j / radialSegments * Math.PI * 2;\n\t\t\t\t\tvar cx = -tube * Math.cos(v);\n\t\t\t\t\tvar cy = tube * Math.sin(v); // now calculate the final vertex position.\n\t\t\t\t\t// first we orient the extrusion with our basis vectos, then we add it to the current position on the curve\
1n\n\t\t\t\t\tvertex.x = P1.x + (cx * N.x + cy * B.x);\n\t\t\t\t\tvertex.y = P1.y + (cx * N.y + cy * B.y);\n\t\t\t\t\tvertex.z = P1.z + (cx * N.z + cy * B.z);\n\t\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z); // normal (P1 is always the center/origin of the extrusion, thus we can use it to calculate the normal)\n\n\t\t\t\t\tnormal.subVectors(vertex, P1).normalize();\n\t\t\t\t\tnormals.push(normal.x, normal.y, normal.z); // uv\n\n\t\t\t\t\tuvs.push(i / tubularSegments);\n\t\t\t\t\tuvs.push(j / radialSegments);\n\t\t\t\t}\n\t\t\t} // generate indices\n\n\n\t\t\tfor (var _j = 1; _j <= tubularSegments; _j++) {\n\t\t\t\tfor (var _i = 1; _i <= radialSegments; _i++) {\n\t\t\t\t\t// indices\n\t\t\t\t\tvar a = (radialSegments + 1) * (_j - 1) + (_i - 1);\n\t\t\t\t\tvar b = (radialSegments + 1) * _j + (_i - 1);\n\t\t\t\t\tvar c = (radialSegments + 1) * _j + _i;\n\t\t\t\t\tvar d = (radialSegments + 1) * (_j - 1) + _i; // faces\n\n\t\t\t\t\tindices.push(a, b, d);\n\t\t\t\t\tindices.push(b, c, d);\n\t\t\t\t}\n\t\t\t} // build geometry\n\n\n\t\t\t_this.setIndex(indices);\n\n\t\t\t_this.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\n\t\t\t_this.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\n\t\t\t_this.setAttribute('uv', new Float32BufferAttribute(uvs, 2)); // this function calculates the current position on the torus curve\n\n\n\t\t\tfunction calculatePositionOnCurve(u, p, q, radius, position) {\n\t\t\t\tvar cu = Math.cos(u);\n\t\t\t\tvar su = Math.sin(u);\n\t\t\t\tvar quOverP = q / p * u;\n\t\t\t\tvar cs = Math.cos(quOverP);\n\t\t\t\tposition.x = radius * (2 + cs) * 0.5 * cu;\n\t\t\t\tposition.y = radius * (2 + cs) * su * 0.5;\n\t\t\t\tposition.z = radius * Math.sin(quOverP) * 0.5;\n\t\t\t}\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn TorusKnotBufferGeometry;\n\t}(BufferGeometry);\n\n\tvar TorusKnotGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(TorusKnotGeometry, _Geometry);\n\n\t\tfunction TorusKnotGeometry(radius, tube, tubularSegments, radialSegments, p, q, heightScale) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'TorusKnotGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tradius: radius,\n\t\t\t\ttube: tube,\n\t\t\t\ttubularSegments: tubularSegments,\n\t\t\t\tradialSegments: radialSegments,\n\t\t\t\tp: p,\n\t\t\t\tq: q\n\t\t\t};\n\t\t\tif (heightScale !== undefined) console.warn('THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead.');\n\n\t\t\t_this.fromBufferGeometry(new TorusKnotBufferGeometry(radius, tube, tubularSegments, radialSegments, p, q));\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn TorusKnotGeometry;\n\t}(Geometry);\n\n\tvar TubeBufferGeometry = /*#__PURE__*/function (_BufferGeometry) {\n\t\t_inheritsLoose(TubeBufferGeometry, _BufferGeometry);\n\n\t\tfunction TubeBufferGeometry(path, tubularSegments, radius, radialSegments, closed) {\n\t\t\tvar _this;\n\n\t\t\tif (tubularSegments === void 0) {\n\t\t\t\ttubularSegments = 64;\n\t\t\t}\n\n\t\t\tif (radius === void 0) {\n\t\t\t\tradius = 1;\n\t\t\t}\n\n\t\t\tif (radialSegments === void 0) {\n\t\t\t\tradialSegments = 8;\n\t\t\t}\n\n\t\t\tif (closed === void 0) {\n\t\t\t\tclosed = false;\n\t\t\t}\n\n\t\t\t_this = _BufferGeometry.call(this) || this;\n\t\t\t_this.type = 'TubeBufferGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tpath: path,\n\t\t\t\ttubularSegments: tubularSegments,\n\t\t\t\tradius: radius,\n\t\t\t\tradialSegments: radialSegments,\n\t\t\t\tclosed: closed\n\t\t\t};\n\t\t\tvar frames = path.computeFrenetFrames(tubularSegments, closed); // expose internals\n\n\t\t\t_this.tangents = frames.tangents;\n\t\t\t_this.normals = frames.normals;\n\t\t\t_this.binormals = frames.binormals; // helper variables\n\n\t\t\tvar vertex = new Vector3();\n\t\t\tvar normal = new Vector3();\n\t\t\tvar uv = new Vector2();\n\t\t\tvar P = new Vector3(); // buffer\n\n\t\t\tvar vertices = [];\n\t\t\tvar normals = [];\n\t\t\tvar uvs = [];\n\t\t\tvar indices = []; // create buffer data\n\n\t\t\tgenerateBufferData(); // build geometry\n\n\t\t\t_this.setIndex(indices);\n\n\t\t\t_this.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\n\t\t\t_this.setAttribute('normal', new Float32BufferAttribute(normals, 3));\n\n\t\t\t_this.setAttribute('uv', new Float32BufferAttribute(uvs, 2));
1 // functions\n\n\n\t\t\tfunction generateBufferData() {\n\t\t\t\tfor (var i = 0; i < tubularSegments; i++) {\n\t\t\t\t\tgenerateSegment(i);\n\t\t\t\t} // if the geometry is not closed, generate the last row of vertices and normals\n\t\t\t\t// at the regular position on the given path\n\t\t\t\t//\n\t\t\t\t// if the geometry is closed, duplicate the first row of vertices and normals (uvs will differ)\n\n\n\t\t\t\tgenerateSegment(closed === false ? tubularSegments : 0); // uvs are generated in a separate function.\n\t\t\t\t// this makes it easy compute correct values for closed geometries\n\n\t\t\t\tgenerateUVs(); // finally create faces\n\n\t\t\t\tgenerateIndices();\n\t\t\t}\n\n\t\t\tfunction generateSegment(i) {\n\t\t\t\t// we use getPointAt to sample evenly distributed points from the given path\n\t\t\t\tP = path.getPointAt(i / tubularSegments, P); // retrieve corresponding normal and binormal\n\n\t\t\t\tvar N = frames.normals[i];\n\t\t\t\tvar B = frames.binormals[i]; // generate normals and vertices for the current segment\n\n\t\t\t\tfor (var j = 0; j <= radialSegments; j++) {\n\t\t\t\t\tvar v = j / radialSegments * Math.PI * 2;\n\t\t\t\t\tvar sin = Math.sin(v);\n\t\t\t\t\tvar cos = -Math.cos(v); // normal\n\n\t\t\t\t\tnormal.x = cos * N.x + sin * B.x;\n\t\t\t\t\tnormal.y = cos * N.y + sin * B.y;\n\t\t\t\t\tnormal.z = cos * N.z + sin * B.z;\n\t\t\t\t\tnormal.normalize();\n\t\t\t\t\tnormals.push(normal.x, normal.y, normal.z); // vertex\n\n\t\t\t\t\tvertex.x = P.x + radius * normal.x;\n\t\t\t\t\tvertex.y = P.y + radius * normal.y;\n\t\t\t\t\tvertex.z = P.z + radius * normal.z;\n\t\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction generateIndices() {\n\t\t\t\tfor (var j = 1; j <= tubularSegments; j++) {\n\t\t\t\t\tfor (var i = 1; i <= radialSegments; i++) {\n\t\t\t\t\t\tvar a = (radialSegments + 1) * (j - 1) + (i - 1);\n\t\t\t\t\t\tvar b = (radialSegments + 1) * j + (i - 1);\n\t\t\t\t\t\tvar c = (radialSegments + 1) * j + i;\n\t\t\t\t\t\tvar d = (radialSegments + 1) * (j - 1) + i; // faces\n\n\t\t\t\t\t\tindices.push(a, b, d);\n\t\t\t\t\t\tindices.push(b, c, d);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction generateUVs() {\n\t\t\t\tfor (var i = 0; i <= tubularSegments; i++) {\n\t\t\t\t\tfor (var j = 0; j <= radialSegments; j++) {\n\t\t\t\t\t\tuv.x = i / tubularSegments;\n\t\t\t\t\t\tuv.y = j / radialSegments;\n\t\t\t\t\t\tuvs.push(uv.x, uv.y);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = TubeBufferGeometry.prototype;\n\n\t\t_proto.toJSON = function toJSON() {\n\t\t\tvar data = BufferGeometry.prototype.toJSON.call(this);\n\t\t\tdata.path = this.parameters.path.toJSON();\n\t\t\treturn data;\n\t\t};\n\n\t\treturn TubeBufferGeometry;\n\t}(BufferGeometry);\n\n\tvar TubeGeometry = /*#__PURE__*/function (_Geometry) {\n\t\t_inheritsLoose(TubeGeometry, _Geometry);\n\n\t\tfunction TubeGeometry(path, tubularSegments, radius, radialSegments, closed, taper) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Geometry.call(this) || this;\n\t\t\t_this.type = 'TubeGeometry';\n\t\t\t_this.parameters = {\n\t\t\t\tpath: path,\n\t\t\t\ttubularSegments: tubularSegments,\n\t\t\t\tradius: radius,\n\t\t\t\tradialSegments: radialSegments,\n\t\t\t\tclosed: closed\n\t\t\t};\n\t\t\tif (taper !== undefined) console.warn('THREE.TubeGeometry: taper has been removed.');\n\t\t\tvar bufferGeometry = new TubeBufferGeometry(path, tubularSegments, radius, radialSegments, closed); // expose internals\n\n\t\t\t_this.tangents = bufferGeometry.tangents;\n\t\t\t_this.normals = bufferGeometry.normals;\n\t\t\t_this.binormals = bufferGeometry.binormals; // create geometry\n\n\t\t\t_this.fromBufferGeometry(bufferGeometry);\n\n\t\t\t_this.mergeVertices();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn TubeGeometry;\n\t}(Geometry);\n\n\tvar WireframeGeometry = /*#__PURE__*/function (_BufferGeometry) {\n\t\t_inheritsLoose(WireframeGeometry, _BufferGeometry);\n\n\t\tfunction WireframeGeometry(geometry) {\n\t\t\tvar _this;\n\n\t\t\t_this = _BufferGeometry.call(this) || this;\n\t\t\t_this.type = 'WireframeGeometry'; // buffer\n\n\t\t\tvar vertices = []; // helper variables\n\n\t\t\tvar edge = [0, 0],\n\t\t\t\t\tedges = {};\n\t\t\tvar keys = ['a', 'b', 'c']; // different logic for Geometry and BufferGeometry\n\n\t\t\tif (geometry && geometry.isGeometry) {\n\t\t\t\t// create a data structure that contains all edges without duplicates\n\t\t\t\tvar faces = geometry.faces;\n\n\t\t\t\tfor (var i = 0, l = faces.length; i < l;
1 i++) {\n\t\t\t\t\tvar face = faces[i];\n\n\t\t\t\t\tfor (var j = 0; j < 3; j++) {\n\t\t\t\t\t\tvar edge1 = face[keys[j]];\n\t\t\t\t\t\tvar edge2 = face[keys[(j + 1) % 3]];\n\t\t\t\t\t\tedge[0] = Math.min(edge1, edge2); // sorting prevents duplicates\n\n\t\t\t\t\t\tedge[1] = Math.max(edge1, edge2);\n\t\t\t\t\t\tvar key = edge[0] + ',' + edge[1];\n\n\t\t\t\t\t\tif (edges[key] === undefined) {\n\t\t\t\t\t\t\tedges[key] = {\n\t\t\t\t\t\t\t\tindex1: edge[0],\n\t\t\t\t\t\t\t\tindex2: edge[1]\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} // generate vertices\n\n\n\t\t\t\tfor (var _key in edges) {\n\t\t\t\t\tvar e = edges[_key];\n\t\t\t\t\tvar vertex = geometry.vertices[e.index1];\n\t\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z);\n\t\t\t\t\tvertex = geometry.vertices[e.index2];\n\t\t\t\t\tvertices.push(vertex.x, vertex.y, vertex.z);\n\t\t\t\t}\n\t\t\t} else if (geometry && geometry.isBufferGeometry) {\n\t\t\t\tvar _vertex = new Vector3();\n\n\t\t\t\tif (geometry.index !== null) {\n\t\t\t\t\t// indexed BufferGeometry\n\t\t\t\t\tvar position = geometry.attributes.position;\n\t\t\t\t\tvar indices = geometry.index;\n\t\t\t\t\tvar groups = geometry.groups;\n\n\t\t\t\t\tif (groups.length === 0) {\n\t\t\t\t\t\tgroups = [{\n\t\t\t\t\t\t\tstart: 0,\n\t\t\t\t\t\t\tcount: indices.count,\n\t\t\t\t\t\t\tmaterialIndex: 0\n\t\t\t\t\t\t}];\n\t\t\t\t\t} // create a data structure that contains all eges without duplicates\n\n\n\t\t\t\t\tfor (var o = 0, ol = groups.length; o < ol; ++o) {\n\t\t\t\t\t\tvar group = groups[o];\n\t\t\t\t\t\tvar start = group.start;\n\t\t\t\t\t\tvar count = group.count;\n\n\t\t\t\t\t\tfor (var _i = start, _l = start + count; _i < _l; _i += 3) {\n\t\t\t\t\t\t\tfor (var _j = 0; _j < 3; _j++) {\n\t\t\t\t\t\t\t\tvar _edge = indices.getX(_i + _j);\n\n\t\t\t\t\t\t\t\tvar _edge2 = indices.getX(_i + (_j + 1) % 3);\n\n\t\t\t\t\t\t\t\tedge[0] = Math.min(_edge, _edge2); // sorting prevents duplicates\n\n\t\t\t\t\t\t\t\tedge[1] = Math.max(_edge, _edge2);\n\n\t\t\t\t\t\t\t\tvar _key2 = edge[0] + ',' + edge[1];\n\n\t\t\t\t\t\t\t\tif (edges[_key2] === undefined) {\n\t\t\t\t\t\t\t\t\tedges[_key2] = {\n\t\t\t\t\t\t\t\t\t\tindex1: edge[0],\n\t\t\t\t\t\t\t\t\t\tindex2: edge[1]\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} // generate vertices\n\n\n\t\t\t\t\tfor (var _key3 in edges) {\n\t\t\t\t\t\tvar _e = edges[_key3];\n\n\t\t\t\t\t\t_vertex.fromBufferAttribute(position, _e.index1);\n\n\t\t\t\t\t\tvertices.push(_vertex.x, _vertex.y, _vertex.z);\n\n\t\t\t\t\t\t_vertex.fromBufferAttribute(position, _e.index2);\n\n\t\t\t\t\t\tvertices.push(_vertex.x, _vertex.y, _vertex.z);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// non-indexed BufferGeometry\n\t\t\t\t\tvar _position = geometry.attributes.position;\n\n\t\t\t\t\tfor (var _i2 = 0, _l2 = _position.count / 3; _i2 < _l2; _i2++) {\n\t\t\t\t\t\tfor (var _j2 = 0; _j2 < 3; _j2++) {\n\t\t\t\t\t\t\t// three edges per triangle, an edge is represented as (index1, index2)\n\t\t\t\t\t\t\t// e.g. the first triangle has the following edges: (0,1),(1,2),(2,0)\n\t\t\t\t\t\t\tvar index1 = 3 * _i2 + _j2;\n\n\t\t\t\t\t\t\t_vertex.fromBufferAttribute(_position, index1);\n\n\t\t\t\t\t\t\tvertices.push(_vertex.x, _vertex.y, _vertex.z);\n\t\t\t\t\t\t\tvar index2 = 3 * _i2 + (_j2 + 1) % 3;\n\n\t\t\t\t\t\t\t_vertex.fromBufferAttribute(_position, index2);\n\n\t\t\t\t\t\t\tvertices.push(_vertex.x, _vertex.y, _vertex.z);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} // build geometry\n\n\n\t\t\t_this.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn WireframeGeometry;\n\t}(BufferGeometry);\n\n\tvar Geometries = /*#__PURE__*/Object.freeze({\n\t\t__proto__: null,\n\t\tBoxGeometry: BoxGeometry,\n\t\tBoxBufferGeometry: BoxBufferGeometry,\n\t\tCircleGeometry: CircleGeometry,\n\t\tCircleBufferGeometry: CircleBufferGeometry,\n\t\tConeGeometry: ConeGeometry,\n\t\tConeBufferGeometry: ConeBufferGeometry,\n\t\tCylinderGeometry: CylinderGeometry,\n\t\tCylinderBufferGeometry: CylinderBufferGeometry,\n\t\tDodecahedronGeometry: DodecahedronGeometry,\n\t\tDodecahedronBufferGeometry: DodecahedronBufferGeometry,\n\t\tEdgesGeometry: EdgesGeometry,\n\t\tExtrudeGeometry: ExtrudeGeometry,\n\t\tExtrudeBufferGeometry: ExtrudeBufferGeometry,\n\t\tIcosahedronGeometry: IcosahedronGeometry,\n\t\tIcosahedronBufferGeometry: IcosahedronBufferGeometry,\n\t\tLatheGeometry: LatheGeometry,\n\t\tLatheBufferGeometry: LatheBufferGeometry,\n\t\tOctahedronGeometry: OctahedronGeometry,\n\t\tOctahedronBufferGeometry: OctahedronBufferGeometry,\n\t\tParametricGeometry: ParametricGeometry,\n\t\tParametricBufferGeometry: ParametricBufferGeometry,\n\t\tPlaneGeometry: PlaneGeometry,\n\t\tPlaneBufferGeometry: PlaneBufferGeometry,\n\t\tPolyhedronGeometry: PolyhedronGeometry,\n\t\tPolyhedronBufferGeometry: PolyhedronBufferGeometry,\n\t\tRingGeometry: RingGeometry,\n\t\tRingBufferGeometry: RingBufferGeometry,\n\t\tShapeGeometry: ShapeGeometry,\n\t\tShapeBufferGeometry: ShapeBufferGeometry,\n\t\tSphereGeometry: SphereGeometry,\n\t\tSphereBufferGeometry: SphereBufferGeometry,\n\t\tTetrahedronGeometry: TetrahedronGeometry,\n\t\tTetrahedronBufferGeometry: TetrahedronBufferGeometry,\n\t\tTextGeometry: TextGeometry,\n\t\tTextBufferGeometry: TextBufferGeometry,\n\t\tTorusGeometry: TorusGeometry,\n\t\tTorusBufferGeometry: TorusBufferGeometry,\n\t\tTorusKnotGeometry: TorusKnotGeometry,\n\t\tTorusKnotBufferGeometry: TorusKnotBufferGeometry,\n\t\tTubeGeometry: TubeGeometry,\n\t\tTubeBufferGeometry: TubeBufferGeometry,\n\t\tWireframeGeometry: WireframeGeometry\n\t});\n\n\t/**\n\t * parameters = {\n\t *\tcolor: <THREE.Color>\n\t * }\n\t */\n\n\tfunction ShadowMaterial(parameters) {\n\t\tMaterial.call(this);\n\t\tthis.type = 'ShadowMaterial';\n\t\tthis.color = new Color(0x000000);\n\t\tthis.transparent = true;\n\t\tthis.setValues(parameters);\n\t}\n\n\tShadowMaterial.prototype = Object.create(Material.prototype);\n\tShadowMaterial.prototype.constructor = ShadowMaterial;\n\tShadowMaterial.prototype.isShadowMaterial = true;\n\n\tShadowMaterial.prototype.copy = function (source) {\n\t\tMaterial.prototype.copy.call(this, source);\n\t\tthis.color.copy(source.color);\n\t\treturn this;\n\t};\n\n\tfunction RawShaderMaterial(parameters) {\n\t\tShaderMaterial.call(this, parameters);\n\t\tthis.type = 'RawShaderMaterial';\n\t}
1\n\n\tRawShaderMaterial.prototype = Object.create(ShaderMaterial.prototype);\n\tRawShaderMaterial.prototype.constructor = RawShaderMaterial;\n\tRawShaderMaterial.prototype.isRawShaderMaterial = true;\n\n\t/**\n\t * parameters = {\n\t *\tcolor: <hex>,\n\t *\troughness: <float>,\n\t *\tmetalness: <float>,\n\t *\topacity: <float>,\n\t *\n\t *\tmap: new THREE.Texture( <Image> ),\n\t *\n\t *\tlightMap: new THREE.Texture( <Image> ),\n\t *\tlightMapIntensity: <float>\n\t *\n\t *\taoMap: new THREE.Texture( <Image> ),\n\t *\taoMapIntensity: <float>\n\t *\n\t *\temissive: <hex>,\n\t *\temissiveIntensity: <float>\n\t *\temissiveMap: new THREE.Texture( <Image> ),\n\t *\n\t *\tbumpMap: new THREE.Texture( <Image> ),\n\t *\tbumpScale: <float>,\n\t *\n\t *\tnormalMap: new THREE.Texture( <Image> ),\n\t *\tnormalMapType: THREE.TangentSpaceNormalMap,\n\t *\tnormalScale: <Vector2>,\n\t *\n\t *\tdisplacementMap: new THREE.Texture( <Image> ),\n\t *\tdisplacementScale: <float>,\n\t *\tdisplacementBias: <float>,\n\t *\n\t *\troughnessMap: new THREE.Texture( <Image> ),\n\t *\n\t *\tmetalnessMap: new THREE.Texture( <Image> ),\n\t *\n\t *\talphaMap: new THREE.Texture( <Image> ),\n\t *\n\t *\tenvMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ),\n\t *\tenvMapIntensity: <float>\n\t *\n\t *\trefractionRatio: <float>,\n\t *\n\t *\twireframe: <boolean>,\n\t *\twireframeLinewidth: <float>,\n\t *\n\t *\tskinning: <bool>,\n\t *\tmorphTargets: <bool>,\n\t *\tmorphNormals: <bool>\n\t * }\n\t */\n\n\tfunction MeshStandardMaterial(parameters) {\n\t\tMaterial.call(this);\n\t\tthis.defines = {\n\t\t\t'STANDARD': ''\n\t\t};\n\t\tthis.type = 'MeshStandardMaterial';\n\t\tthis.color = new Color(0xffffff); // diffuse\n\n\t\tthis.roughness = 1.0;\n\t\tthis.metalness = 0.0;\n\t\tthis.map = null;\n\t\tthis.lightMap = null;\n\t\tthis.lightMapIntensity = 1.0;\n\t\tthis.aoMap = null;\n\t\tthis.aoMapIntensity = 1.0;\n\t\tthis.emissive = new Color(0x000000);\n\t\tthis.emissiveIntensity = 1.0;\n\t\tthis.emissiveMap = null;\n\t\tthis.bumpMap = null;\n\t\tthis.bumpScale = 1;\n\t\tthis.normalMap = null;\n\t\tthis.normalMapType = TangentSpaceNormalMap;\n\t\tthis.normalScale = new Vector2(1, 1);\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\t\tthis.roughnessMap = null;\n\t\tthis.metalnessMap = null;\n\t\tthis.alphaMap = null;\n\t\tthis.envMap = null;\n\t\tthis.envMapIntensity = 1.0;\n\t\tthis.refractionRatio = 0.98;\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.wireframeLinecap = 'round';\n\t\tthis.wireframeLinejoin = 'round';\n\t\tthis.skinning = false;\n\t\tthis.morphTargets = false;\n\t\tthis.morphNormals = false;\n\t\tthis.vertexTangents = false;\n\t\tthis.setValues(parameters);\n\t}\n\n\tMeshStandardMaterial.prototype = Object.create(Material.prototype);\n\tMeshStandardMaterial.prototype.constructor = MeshStandardMaterial;\n\tMeshStandardMaterial.prototype.isMeshStandardMaterial = true;\n\n\tMeshStandardMaterial.prototype.copy = function (source) {\n\t\tMaterial.prototype.copy.call(this, source);\n\t\tthis.defines = {\n\t\t\t'STANDARD': ''\n\t\t};\n\t\tthis.color.copy(source.color);\n\t\tthis.roughness = source.roughness;\n\t\tthis.metalness = source.metalness;\n\t\tthis.map = source.map;\n\t\tthis.lightMap = source.lightMap;\n\t\tthis.lightMapIntensity = source.lightMapIntensity;\n\t\tthis.aoMap = source.aoMap;\n\t\tthis.aoMapIntensity = source.aoMapIntensity;\n\t\tthis.emissive.copy(source.emissive);\n\t\tthis.emissiveMap = source.emissiveMap;\n\t\tthis.emissiveIntensity = source.emissiveIntensity;\n\t\tthis.bumpMap = source.bumpMap;\n\t\tthis.bumpScale = source.bumpScale;\n\t\tthis.normalMap = source.normalMap;\n\t\tthis.normalMapType = source.normalMapType;\n\t\tthis.normalScale.copy(source.normalScale);\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\t\tthis.roughnessMap = source.roughnessMap;\n\t\tthis.metalnessMap = source.metalnessMap;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.envMap = source.envMap;\n\t\tthis.envMapIntensity = source.envMapIntensity;\n\t\tthis.refractionRatio = source.refractionRatio;\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.wireframeLinecap = source.wireframeLinecap;\n\t\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\t\tthis.morphNormals = source.morphNormals;\n\t\tthis.vertexTangents = source.vertexTangents;\n\t\treturn this;\n\t};\n\n\t/**\n\t * parameters = {\n\t *\tclearcoat: <float>,\n\t *\tclearcoatMap: new THREE.Texture( <Image> ),\n\t *\tclearcoatRoughness: <float>,\n\t *\tclearcoatRoughnessMap: new THREE.Texture( <Image> ),\n\t *\tclearcoatNormalScale: <Vector2>,\n\t *\tclearcoatNormalMap: new THREE.Texture( <Image> ),\n\t *\n\t *\treflectivity: <float>,\n\t *\tior: <float>,\n\t *\n\t *\tsheen: <Color>,\n\t *\n\t *\ttransmission: <float>,\n\t *\ttransmissionMap: new THREE.Texture( <Image> )\n\t * }\n\t */\n\n\tfunction MeshPhysicalMaterial(parameters) {\n\t\tMeshStandardMaterial.call(this);\n\t\tthis.defines = {\n\t\t\t'STANDARD': '',\n\t\t\t'PHYSICAL': ''\n\t\t};\n\t\tthis.type = 'MeshPhysicalMaterial';\n\t\tthis.clearcoat = 0.0;\n\t\tthis.clearcoatMap = null;\n\t\tthis.clearcoatRoughness = 0.0;\n\t\tthis.clearcoatRoughnessMap = null;\n\t\tthis.clearcoatNormalScale = new Vector2(1, 1);\n\t\tthis.clearcoatNormalMap = null;\n\t\tthis.reflectivity = 0.5; // maps to F0 = 0.04\n\n\t\tObject.defineProperty(this, 'ior', {\n\t\t\tget: function get() {\n\t\t\t\treturn (1 + 0.4 * this.reflectivity) / (1 - 0.4 * this.reflectivity);\n\t\t\t},\n\t\t\tset: function set(ior) {\n\t\t\t\tthis.reflectivity = MathUtils.clamp(2.5 * (ior - 1) / (ior + 1), 0, 1);\n\t\t\t}\n\t\t});\n\t\tthis.sheen = null; // null will disable sheen bsdf\n\n\t\tthis.transmission = 0.0;\n\t\tthis.transmissionMap = null;\n\t\tthis.setValues(parameters);\n\t}\n\n\tMeshPhysicalMaterial.prototype = Object.create(MeshStandardMaterial.prototype);\n\tMeshPhysicalMaterial.prototype.constructor = MeshPhysicalMaterial;\n\tMeshPhysicalMaterial.prototype.isMeshPhysicalMaterial = true;\n\n\tMeshPhysicalMaterial.prototype.copy = function (source) {\n\t\tMeshStandardMaterial.prototype.copy.call(this, source);\n\t\tthis.defines = {\n\t\t\t'STANDARD': '',\n\t\t\t'PHYSICAL': ''\n\t\t};\n\t\tthis.clearcoat = source.clearcoat;
1\n\t\tthis.clearcoatMap = source.clearcoatMap;\n\t\tthis.clearcoatRoughness = source.clearcoatRoughness;\n\t\tthis.clearcoatRoughnessMap = source.clearcoatRoughnessMap;\n\t\tthis.clearcoatNormalMap = source.clearcoatNormalMap;\n\t\tthis.clearcoatNormalScale.copy(source.clearcoatNormalScale);\n\t\tthis.reflectivity = source.reflectivity;\n\n\t\tif (source.sheen) {\n\t\t\tthis.sheen = (this.sheen || new Color()).copy(source.sheen);\n\t\t} else {\n\t\t\tthis.sheen = null;\n\t\t}\n\n\t\tthis.transmission = source.transmission;\n\t\tthis.transmissionMap = source.transmissionMap;\n\t\treturn this;\n\t};\n\n\t/**\n\t * parameters = {\n\t *\tcolor: <hex>,\n\t *\tspecular: <hex>,\n\t *\tshininess: <float>,\n\t *\topacity: <float>,\n\t *\n\t *\tmap: new THREE.Texture( <Image> ),\n\t *\n\t *\tlightMap: new THREE.Texture( <Image> ),\n\t *\tlightMapIntensity: <float>\n\t *\n\t *\taoMap: new THREE.Texture( <Image> ),\n\t *\taoMapIntensity: <float>\n\t *\n\t *\temissive: <hex>,\n\t *\temissiveIntensity: <float>\n\t *\temissiveMap: new THREE.Texture( <Image> ),\n\t *\n\t *\tbumpMap: new THREE.Texture( <Image> ),\n\t *\tbumpScale: <float>,\n\t *\n\t *\tnormalMap: new THREE.Texture( <Image> ),\n\t *\tnormalMapType: THREE.TangentSpaceNormalMap,\n\t *\tnormalScale: <Vector2>,\n\t *\n\t *\tdisplacementMap: new THREE.Texture( <Image> ),\n\t *\tdisplacementScale: <float>,\n\t *\tdisplacementBias: <float>,\n\t *\n\t *\tspecularMap: new THREE.Texture( <Image> ),\n\t *\n\t *\talphaMap: new THREE.Texture( <Image> ),\n\t *\n\t *\tenvMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ),\n\t *\tcombine: THREE.MultiplyOperation,\n\t *\treflectivity: <float>,\n\t *\trefractionRatio: <float>,\n\t *\n\t *\twireframe: <boolean>,\n\t *\twireframeLinewidth: <float>,\n\t *\n\t *\tskinning: <bool>,\n\t *\tmorphTargets: <bool>,\n\t *\tmorphNormals: <bool>\n\t * }\n\t */\n\n\tfunction MeshPhongMaterial(parameters) {\n\t\tMaterial.call(this);\n\t\tthis.type = 'MeshPhongMaterial';\n\t\tthis.color = new Color(0xffffff); // diffuse\n\n\t\tthis.specular = new Color(0x111111);\n\t\tthis.shininess = 30;\n\t\tthis.map = null;\n\t\tthis.lightMap = null;\n\t\tthis.lightMapIntensity = 1.0;\n\t\tthis.aoMap = null;\n\t\tthis.aoMapIntensity = 1.0;\n\t\tthis.emissive = new Color(0x000000);\n\t\tthis.emissiveIntensity = 1.0;\n\t\tthis.emissiveMap = null;\n\t\tthis.bumpMap = null;\n\t\tthis.bumpScale = 1;\n\t\tthis.normalMap = null;\n\t\tthis.normalMapType = TangentSpaceNormalMap;\n\t\tthis.normalScale = new Vector2(1, 1);\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\t\tthis.specularMap = null;\n\t\tthis.alphaMap = null;\n\t\tthis.envMap = null;\n\t\tthis.combine = MultiplyOperation;\n\t\tthis.reflectivity = 1;\n\t\tthis.refractionRatio = 0.98;\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.wireframeLinecap = 'round';\n\t\tthis.wireframeLinejoin = 'round';\n\t\tthis.skinning = false;\n\t\tthis.morphTargets = false;\n\t\tthis.morphNormals = false;\n\t\tthis.setValues(parameters);\n\t}\n\n\tMeshPhongMaterial.prototype = Object.create(Material.prototype);\n\tMeshPhongMaterial.prototype.constructor = MeshPhongMaterial;\n\tMeshPhongMaterial.prototype.isMeshPhongMaterial = true;\n\n\tMeshPhongMaterial.prototype.copy = function (source) {\n\t\tMaterial.prototype.copy.call(this, source);\n\t\tthis.color.copy(source.color);\n\t\tthis.specular.copy(source.specular);\n\t\tthis.shininess = source.shininess;\n\t\tthis.map = source.map;\n\t\tthis.lightMap = source.lightMap;\n\t\tthis.lightMapIntensity = source.lightMapIntensity;\n\t\tthis.aoMap = source.aoMap;\n\t\tthis.aoMapIntensity = source.aoMapIntensity;\n\t\tthis.emissive.copy(source.emissive);\n\t\tthis.emissiveMap = source.emissiveMap;\n\t\tthis.emissiveIntensity = source.emissiveIntensity;\n\t\tthis.bumpMap = source.bumpMap;\n\t\tthis.bumpScale = source.bumpScale;\n\t\tthis.normalMap = source.normalMap;\n\t\tthis.normalMapType = source.normalMapType;\n\t\tthis.normalScale.copy(source.normalScale);\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\t\tthis.specularMap = source.specularMap;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.envMap = source.envMap;\n\t\tthis.combine = source.combine;\n\t\tthis.reflectivity = source.reflectivity;\n\t\tthis.refractionRatio = source.refractionRatio;\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.wireframeLinecap = source.wireframeLinecap;\n\t\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\t\tthis.morphNormals = source.morphNormals;\n\t\treturn this;\n\t};\n\n\t/**\n\t * parameters = {\n\t *\tcolor: <hex>,\n\t *\n\t *\tmap: new THREE.Texture( <Image> ),\n\t *\tgradientMap: new THREE.Texture( <Image> ),\n\t *\n\t *\tlightMap: new THREE.Texture( <Image> ),\n\t *\tlightMapIntensity: <float>\n\t *\n\t *\taoMap: new THREE.Texture( <Image> ),\n\t *\taoMapIntensity: <float>\n\t *\n\t *\temissive: <hex>,\n\t *\temissiveIntensity: <float>\n\t *\temissiveMap: new THREE.Texture( <Image> ),\n\t *\n\t *\tbumpMap: new THREE.Texture( <Image> ),\n\t *\tbumpScale: <float>,\n\t *\n\t *\tnormalMap: new THREE.Texture( <Image> ),\n\t *\tnormalMapType: THREE.TangentSpaceNormalMap,\n\t *\tnormalScale: <Vector2>,\n\t *\n\t *\tdisplacementMap: new THREE.Texture( <Image> ),\n\t *\tdisplacementScale: <float>,\n\t *\tdisplacementBias: <float>,\n\t *\n\t *\talphaMap: new THREE.Texture( <Image> ),\n\t *\n\t *\twireframe: <boolean>,\n\t *\twireframeLinewidth: <float>,\n\t *\n\t *\tskinning: <bool>,\n\t *\tmorphTargets: <bool>,\n\t *\tmorphNormals: <bool>\n\t * }\n\t */\n\n\tfunction MeshToonMaterial(parameters) {\n\t\tMaterial.call(this);\n\t\tthis.defines = {\n\t\t\t'TOON': ''\n\t\t};\n\t\tthis.type = 'MeshToonMaterial';\n\t\tthis.color = new Color(0xffffff);\n\t\tthis.map = null;\n\t\tthis.gradientMap = null;\n\t\tthis.lightMap = null;\n\t\tthis.lightMapIntensity = 1.0;\n\t\tthis.aoMap = null;\n\t\tthis.aoMapIntensity = 1.0;\n\t\tthis.emissive = new Color(0x000000);\n\t\tthis.emissiveIntensity = 1.0;\n\t\tthis.emissiveMap = null;\n\t\tthis.bumpMap = null;\n\t\tthis.bumpScale = 1;\n\t\tthis.normalMap = null;\n\t\tthis.normalMapType = TangentSpaceNormalMap;\n\t\tthis.normalScale = new Vector2(1, 1);\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\t\tthis.alphaMap = null;\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.wireframeLinecap = 'round';\n\t\tthis.wireframeLinejoin = 'round';\n\t\tthis.skinning = false;\n\t\tthis.morphTargets = false;\n\t\tthis.morphNormals = false;\n\t\tthis.setValues(parameters);\n\t}\n\n\tMeshToonMaterial.prototype = Object.create(Material.prototype);\n\tMeshToonMaterial.prototype.constructor = MeshToonMaterial;\n\tMeshToonMaterial.prototype.isMeshToonMaterial = true;\n\n\tMeshToonMaterial.prototype.copy = function (source) {\n\t\tMaterial.prototype.copy.call(this, source);\n\t\tthis.color.copy(source.color);\n\t\tthis.map = source.map;\n\t\tthis.gradientMap = source.gradientMap;\n\t\tthis.lightMap = source.lightMap;\n\t\tthis.lightMapIntensity = source.lightMapIntensity;\n\t\tthis.aoMap = source.aoMap;\n\t\tthis.aoMapIntensity = source.aoMapIntensity;\n\t\tthis.emissive.copy(source.emissive);\n\t\tthis.emissiveMap = source.emissiveMap;\n\t\tthis.emissiveIntensity = source.emissiveIntensity;\n\t\tthis.bumpMap = source.bumpMap;\n\t\tthis.bumpScale = source.bumpScale;\n\t\tthis.normalMap = source.normalMap;\n\t\tthis.normalMapType = source.normalMapType;\n\t\tthis.normalScale.copy(source.normalScale);\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.wireframeLinecap = source.wireframeLinecap;\n\t\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\t\tthis.morphNormals = source.morphNormals;\n\t\treturn this;\n\t};\n\n\t/**\n\t * parameters = {\n\t *\topacity: <float>,\n\t *\n\t *\tbumpMap: new THREE.Texture( <Image> ),\n\t *\tbumpScale: <float>,\n\t *\n\t *\tnormalMap: new THREE.Texture( <Image> ),\n\t *\tnormalMapType: THREE.TangentSpaceNormalMap,\n\t *\tnormalScale: <Vector2>,\n\t *\n\t *\tdisplacementMap: new THREE.Texture( <Image> ),\n\t *\tdisplacementScale: <float>,\n\t *\tdisplacementBias: <float>,\n\t *\n\t *\twireframe: <boolean>,\n\t *\twireframeLinewidth: <float>\n\t *\n\t *\tskinning: <bool>,\n\t *\tmorphTargets: <bool>,\n\t *\tmorphNormals: <bool>\n\t * }\n\t */\n\n\tfunction MeshNormalMaterial(parameters) {\n\t\tMaterial.call(this);\n\t\tthis.type = 'MeshNormalMaterial';\n\t\tthis.bumpMap = null;\n\t\tthis.bumpScale = 1;\n\t\tthis.normalMap = null;\n\t\tthis.normalMapType = TangentSpaceNormalMap;\n\t\tthis.normalScale = new Vector2(1, 1);\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.fog = false;\n\t\tthis.skinning = false;\n\t\tthis.morphTargets = false;\n\t\tthis.morphNormals = false;\n\t\tthis.setValues(parameters);\n\t}\n\n\tMeshNormalMaterial.prototype = Object.create(Material.prototype);\n\tMeshNormalMaterial.prototype.constructor = MeshNormalMaterial;\n\tMeshNormalMaterial.prototype.isMeshNormalMaterial = true;\n\n\tMeshNormalMaterial.prototype.copy = function (source) {\n\t\tMaterial.prototype.copy.call(this, source);\n\t\tthis.bumpMap = source.bumpMap;\n\t\tthis.bumpScale = source.bumpScale;\n\t\tthis.normalMap = source.normalMap;\n\t\tthis.normalMapType = source.normalMapType;\n\t\tthis.normalScale.copy(source.normalScale);\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\t\tthis.morphNormals = source.morphNormals;\n\t\treturn this;\n\t};\n\n\t/**\n\t * parameters = {\n\t *\tcolor: <hex>,\n\t *\topacity: <float>,\n\t *\n\t *\tmap: new THREE.Texture( <Image> ),\n\t *\n\t *\tlightMap: new THREE.Texture( <Image> ),\n\t *\tlightMapIntensity: <float>\n\t *\n\t *\taoMap: new THREE.Texture( <Image> ),\n\t *\taoMapIntensity: <float>\n\t *\n\t *\temissive: <hex>,\n\t *\temissiveIntensity: <float>\n\t *\temissiveMap: new THREE.Texture( <Image> ),\n\t *\n\t *\tspecularMap: new THREE.Texture( <Image> ),\n\t *\n\t *\talphaMap: new THREE.Texture( <Image> ),\n\t *\n\t *\tenvMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ),\n\t *\tcombine: THREE.Multiply,\n\t *\treflectivity: <float>,\n\t *\trefractionRatio: <float>,\n\t *\n\t *\twireframe: <boolean>,\n\t *\twireframeLinewidth: <float>,\n\t *\n\t *\tskinning: <bool>,\n\t *\tmorphTargets: <bool>,\n\t *\tmorphNormals: <bool>\n\t * }\n\t */\n\n\tfunction MeshLambertMaterial(parameters) {\n\t\tMaterial.call(this);\n\t\tthis.type = 'MeshLambertMaterial';\n\t\tthis.color = new Color(0xffffff); // diffuse\n\n\t\tthis.map = null;\n\t\tthis.lightMap = null;\n\t\tthis.lightMapIntensity = 1.0;\n\t\tthis.aoMap = null;\n\t\tthis.aoMapIntensity = 1.0;\n\t\tthis.emissive = new Color(0x000000);\n\t\tthis.emissiveIntensity = 1.0;\n\t\tthis.emissiveMap = null;\n\t\tthis.specularMap = null;\n\t\tthis.alphaMap = null;\n\t\tthis.envMap = null;\n\t\tthis.combine = MultiplyOperation;\n\t\tthis.reflectivity = 1;\n\t\tthis.refractionRatio = 0.98;\n\t\tthis.wireframe = false;\n\t\tthis.wireframeLinewidth = 1;\n\t\tthis.wireframeLinecap = 'round';\n\t\tthis.wireframeLinejoin = 'round';\n\t\tthis.skinning = false;\n\t\tthis.morphTargets = false;\n\t\tthis.morphNormals = false;\n\t\tthis.setValues(parameters);\n\t}\n\n\tMeshLambertMaterial.prototype = Object.create(Material.prototype);\n\tMeshLambertMaterial.prototype.constructor = MeshLambertMaterial;\n\tMeshLambertMaterial.prototype.isMeshLambertMaterial = true;\n\n\tMeshLambertMaterial.prototype.copy = function (source) {\n\t\tMaterial.prototype.copy.call(this, source);\n\t\tthis.color.copy(source.color);\n\t\tthis.map = source.map;\n\t\tthis.lightMap = source.lightMap;\n\t\tthis.lightMapIntensity = source.lightMapIntensity;\n\t\tthis.aoMap = source.aoMap;\n\t\tthis.aoMapIntensity = source.aoMapIntensity;\n\t\tthis.emissive.copy(source.emissive);\n\t\tthis.emissiveMap = source.emissiveMap;\n\t\tthis.emissiveIntensity = source.emissiveIntensity;\n\t\tthis.specularMap = source.specularMap;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.envMap = source.envMap;\n\t\tthis.combine = source.combine;\n\t\tthis.reflectivity = source.reflectivity;\n\t\tthis.refractionRatio = source.refractionRatio;\n\t\tthis.wireframe = source.wireframe;\n\t\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\t\tthis.wireframeLinecap = source.wireframeLinecap;\n\t\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\t\tthis.morphNormals = source.morphNormals;\n\t\treturn this;\n\t};\n\n\t/**\n\t * parameters = {\n\t *\tcolor: <hex>,\n\t *\topacity: <float>,\n\t *\n\t *\tmatcap: new THREE.Texture( <Image> ),\n\t *\n\t *\tmap: new THREE.Texture( <Image> ),\n\t *\n\t *\tbumpMap: new THREE.Texture( <Image> ),\n\t *\tbumpScale: <float>,\n\t *\n\t *\tnormalMap: new THREE.Texture( <Image> ),\n\t *\tnormalMapType: THREE.TangentSpaceNormalMap,\n\t *\tnormalScale: <Vector2>,\n\t *\n\t *\tdisplacementMap: new THREE.Texture( <Image> ),\n\t *\tdisplacementScale: <float>,\n\t *\tdisplacementBias: <float>,\n\t *\n\t *\talphaMap: new THREE.Texture( <Image> ),\n\t *\n\t *\tskinning: <bool>,\n\t *\tmorphTargets: <bool>,\n\t *\tmorphNormals: <bool>\n\t * }\n\t */\n\n\tfunction MeshMatcapMaterial(parameters) {\n\t\tMaterial.call(this);\n\t\tthis.defines = {\n\t\t\t'MATCAP': ''\n\t\t};\n\t\tthis.type = 'MeshMatcapMaterial';\n\t\tthis.color = new Color(0xffffff); // diffuse\n\n\t\tthis.matcap = null;\n\t\tthis.map = null;\n\t\tthis.bumpMap = null;\n\t\tthis.bumpScale = 1;\n\t\tthis.normalMap = null;\n\t\tthis.normalMapType = TangentSpaceNormalMap;\n\t\tthis.normalScale = new Vector2(1, 1);\n\t\tthis.displacementMap = null;\n\t\tthis.displacementScale = 1;\n\t\tthis.displacementBias = 0;\n\t\tthis.alphaMap = null;\n\t\tthis.skinning = false;\n\t\tthis.morphTargets = false;\n\t\tthis.morphNormals = false;\n\t\tthis.setValues(parameters);\n\t}\n\n\tMeshMatcapMaterial.prototype = Object.create(Material.prototype);\n\tMeshMatcapMaterial.prototype.constructor = MeshMatcapMaterial;
1\n\tMeshMatcapMaterial.prototype.isMeshMatcapMaterial = true;\n\n\tMeshMatcapMaterial.prototype.copy = function (source) {\n\t\tMaterial.prototype.copy.call(this, source);\n\t\tthis.defines = {\n\t\t\t'MATCAP': ''\n\t\t};\n\t\tthis.color.copy(source.color);\n\t\tthis.matcap = source.matcap;\n\t\tthis.map = source.map;\n\t\tthis.bumpMap = source.bumpMap;\n\t\tthis.bumpScale = source.bumpScale;\n\t\tthis.normalMap = source.normalMap;\n\t\tthis.normalMapType = source.normalMapType;\n\t\tthis.normalScale.copy(source.normalScale);\n\t\tthis.displacementMap = source.displacementMap;\n\t\tthis.displacementScale = source.displacementScale;\n\t\tthis.displacementBias = source.displacementBias;\n\t\tthis.alphaMap = source.alphaMap;\n\t\tthis.skinning = source.skinning;\n\t\tthis.morphTargets = source.morphTargets;\n\t\tthis.morphNormals = source.morphNormals;\n\t\treturn this;\n\t};\n\n\t/**\n\t * parameters = {\n\t *\tcolor: <hex>,\n\t *\topacity: <float>,\n\t *\n\t *\tlinewidth: <float>,\n\t *\n\t *\tscale: <float>,\n\t *\tdashSize: <float>,\n\t *\tgapSize: <float>\n\t * }\n\t */\n\n\tfunction LineDashedMaterial(parameters) {\n\t\tLineBasicMaterial.call(this);\n\t\tthis.type = 'LineDashedMaterial';\n\t\tthis.scale = 1;\n\t\tthis.dashSize = 3;\n\t\tthis.gapSize = 1;\n\t\tthis.setValues(parameters);\n\t}\n\n\tLineDashedMaterial.prototype = Object.create(LineBasicMaterial.prototype);\n\tLineDashedMaterial.prototype.constructor = LineDashedMaterial;\n\tLineDashedMaterial.prototype.isLineDashedMaterial = true;\n\n\tLineDashedMaterial.prototype.copy = function (source) {\n\t\tLineBasicMaterial.prototype.copy.call(this, source);\n\t\tthis.scale = source.scale;\n\t\tthis.dashSize = source.dashSize;\n\t\tthis.gapSize = source.gapSize;\n\t\treturn this;\n\t};\n\n\tvar Materials = /*#__PURE__*/Object.freeze({\n\t\t__proto__: null,\n\t\tShadowMaterial: ShadowMaterial,\n\t\tSpriteMaterial: SpriteMaterial,\n\t\tRawShaderMaterial: RawShaderMaterial,\n\t\tShaderMaterial: ShaderMaterial,\n\t\tPointsMaterial: PointsMaterial,\n\t\tMeshPhysicalMaterial: MeshPhysicalMaterial,\n\t\tMeshStandardMaterial: MeshStandardMaterial,\n\t\tMeshPhongMaterial: MeshPhongMaterial,\n\t\tMeshToonMaterial: MeshToonMaterial,\n\t\tMeshNormalMaterial: MeshNormalMaterial,\n\t\tMeshLambertMaterial: MeshLambertMaterial,\n\t\tMeshDepthMaterial: MeshDepthMaterial,\n\t\tMeshDistanceMaterial: MeshDistanceMaterial,\n\t\tMeshBasicMaterial: MeshBasicMaterial,\n\t\tMeshMatcapMaterial: MeshMatcapMaterial,\n\t\tLineDashedMaterial: LineDashedMaterial,\n\t\tLineBasicMaterial: LineBasicMaterial,\n\t\tMaterial: Material\n\t});\n\n\tvar AnimationUtils = {\n\t\t// same as Array.prototype.slice, but also works on typed arrays\n\t\tarraySlice: function arraySlice(array, from, to) {\n\t\t\tif (AnimationUtils.isTypedArray(array)) {\n\t\t\t\t// in ios9 array.subarray(from, undefined) will return empty array\n\t\t\t\t// but array.subarray(from) or array.subarray(from, len) is correct\n\t\t\t\treturn new array.constructor(array.subarray(from, to !== undefined ? to : array.length));\n\t\t\t}\n\n\t\t\treturn array.slice(from, to);\n\t\t},\n\t\t// converts an array to a specific type\n\t\tconvertArray: function convertArray(array, type, forceClone) {\n\t\t\tif (!array || // let 'undefined' and 'null' pass\n\t\t\t!forceClone && array.constructor === type) return array;\n\n\t\t\tif (typeof type.BYTES_PER_ELEMENT === 'number') {\n\t\t\t\treturn new type(array); // create typed array\n\t\t\t}\n\n\t\t\treturn Array.prototype.slice.call(array); // create Array\n\t\t},\n\t\tisTypedArray: function isTypedArray(object) {\n\t\t\treturn ArrayBuffer.isView(object) && !(object instanceof DataView);\n\t\t},\n\t\t// returns an array by which times and values can be sorted\n\t\tgetKeyframeOrder: function getKeyframeOrder(times) {\n\t\t\tfunction compareTime(i, j) {\n\t\t\t\treturn times[i] - times[j];\n\t\t\t}\n\n\t\t\tvar n = times.length;\n\t\t\tvar result = new Array(n);\n\n\t\t\tfor (var i = 0; i !== n; ++i) {\n\t\t\t\tresult[i] = i;\n\t\t\t}\n\n\t\t\tresult.sort(compareTime);\n\t\t\treturn result;\n\t\t},\n\t\t// uses the array previously returned by 'getKeyframeOrder' to sort data\n\t\tsortedArray: function sortedArray(values, stride, order) {\n\t\t\tvar nValues = values.length;\n\t\t\tvar result = new values.constructor(nValues);\n\n\t\t\tfor (var i = 0, dstOffset = 0; dstOffset !== nValues; ++i) {\n\t\t\t\tvar srcOffset = order[i] * stride;\n\n\t\t\t\tfor (var j = 0; j !== stride; ++j) {\n\t\t\t\t\tresult[dstOffset++] = values[srcOffset + j];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn result;\n\t\t},\n\t\t// function for parsing AOS keyframe formats\n\t\tflattenJSON: function flattenJSON(jsonKeys, times, values, valuePropertyName) {\n\t\t\tvar i = 1,\n\t\t\t\t\tkey = jsonKeys[0];\n\n\t\t\twhile (key !== undefined && key[valuePropertyName] === undefined) {\n\t\t\t\tkey = jsonKeys[i++];\n\t\t\t}\n\n\t\t\tif (key === undefined) return; // no data\n\n\t\t\tvar value = key[valuePropertyName];\n\t\t\tif (value === undefined) return; // no data\n\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\tdo {\n\t\t\t\t\tvalue = key[valuePropertyName];\n\n\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\ttimes.push(key.time);\n\t\t\t\t\t\tvalues.push.apply(values, value); // push all elements\n\t\t\t\t\t}\n\n\t\t\t\t\tkey = jsonKeys[i++];\n\t\t\t\t} while (key !== undefined);\n\t\t\t} else if (value.toArray !== undefined) {\n\t\t\t\t// ...assume THREE.Math-ish\n\t\t\t\tdo {\n\t\t\t\t\tvalue = key[valuePropertyName];\n\n\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\ttimes.push(key.time);\n\t\t\t\t\t\tvalue.toArray(values, values.length);\n\t\t\t\t\t}\n\n\t\t\t\t\tkey = jsonKeys[i++];\n\t\t\t\t} while (key !== undefined);\n\t\t\t} else {\n\t\t\t\t// otherwise push as-is\n\t\t\t\tdo {\n\t\t\t\t\tvalue = key[valuePropertyName];\n\n\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\ttimes.push(key.time);\n\t\t\t\t\t\tvalues.push(value);\n\t\t\t\t\t}\n\n\t\t\t\t\tkey = jsonKeys[i++];\n\t\t\t\t} while (key !== undefined);\n\t\t\t}\n\t\t},\n\t\tsubclip: function subclip(sourceClip, name, startFrame, endFrame, fps) {\n\t\t\tif (fps === void 0) {\n\t\t\t\tfps = 30;\n\t\t\t}\n\n\t\t\tvar clip = sourceClip.clone();\n\t\t\tclip.name = name;\n\t\t\tvar tracks = [];\n\n\t\t\tfor (var i = 0; i < clip.tracks.length; ++i) {\n\t\t\t\tvar track = clip.tracks[i];\n\t\t\t\tvar valueSize = track.getValueSize();\n\t\t\t\tvar times = [];\n\t\t\t\tvar values = [];\n\n\t\t\t\tfor (var j = 0; j < track.times.length; ++j) {\n\t\t\t\t\tvar frame = track.times[j] * fps;\n\t\t\t\t\tif (frame < startFrame || frame >= endFrame) continue;\n\t\t\t\t\ttimes.push(track.times[j]);\n\n\t\t\t\t\tfor (var k = 0; k < valueSize; ++k) {\n\t\t\t\t\t\tvalues.push(track.values[j * valueSize + k]);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (times.length === 0) continue;\n\t\t\t\ttrack.times = AnimationUtils.convertArray(times, track.times.constructor);\n\t\t\t\ttrack.values = AnimationUtils.convertArray(values, track.values.constructor);\n\t\t\t\ttracks.push(track);\n\t\t\t}\n\n\t\t\tclip.tracks = tracks; // find minimum .times value across all tracks in the trimmed clip\n\n\t\t\tvar minStartTime = Infinity;\n\n\t\t\tfor (var _i = 0; _i < clip.tracks.length; ++_i) {\n\t\t\t\tif (minStartTime > clip.tracks[_i].times[0]) {\n\t\t\t\t\tminStartTime = clip.tracks[_i].times[0];\n\t\t\t\t}\n\t\t\t} // shift all tracks such that clip begins at t=0\n\n\n\t\t\tfor (var _i2 = 0; _i2 < clip.tracks.length; ++_i2) {\n\t\t\t\tclip.tracks[_i2].shift(-1 * minStartTime);\n\t\t\t}\n\n\t\t\tclip.resetDuration();\n\t\t\treturn clip;\n\t\t},\n\t\tmakeClipAdditive: function makeClipAdditive(targetClip, referenceFrame, referenceClip, fps) {\n\t\t\tif (referenceFrame === void 0) {\n\t\t\t\treferenceFrame = 0;\n\t\t\t}\n\n\t\t\tif (referenceClip === void 0) {\n\t\t\t\treferenceClip = targetClip;\n\t\t\t}\n\n\t\t\tif (fps === void 0) {\n\t\t\t\tfps = 30;\n\t\t\t}\n\n\t\t\tif (fps <= 0) fps = 30;\n\t\t\tvar numTracks = referenceClip.tracks.length;\n\t\t\tvar referenceTime = referenceFrame / fps; // Make each track's values relative to the values at the reference frame\n\n\t\t\tvar _loop = function _loop(i) {\n\t\t\t\tvar referenceTrack = referenceClip.tracks[i];\n\t\t\t\tvar referenceTrackType = referenceTrack.ValueTypeName; // Skip this track if it's non-numeric\n\n\t\t\t\tif (referenceTrackType === 'bool' || referenceTrackType === 'string') return \"continue\"; // Find the track in the target clip whose name and type matches the reference track\n\n\t\t\t\tvar targetTrack = targetClip.tracks.find(function (track) {\n\t\t\t\t\treturn track.name === referenceTrack.name && track.ValueTypeName === referenceTrackType;\n\t\t\t\t});\n\t\t\t\tif (targetTrack === undefined) return \"continue\";\n\t\t\t\tvar referenceOffset = 0;\n\t\t\t\tvar referenceValueSize = referenceTrack.getValueSize();\n\n\t\t\t\tif (referenceTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline) {\n\t\t\t\t\treferenceOffset = referenceValueSize / 3;\n\t\t\t\t}\n\n\t\t\t\tvar targetOffset = 0;\n\t\t\t\tvar targetValueSize = targetTrack.getValueSize();\n\n\t\t\t\tif (targetTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline) {\n\t\t\t\t\ttargetOffset = targetValueSize / 3;\n\t\t\t\t}\n\n\t\t\t\tvar lastIndex = referenceTrack.times.length - 1;\n\t\t\t\tvar referenceValue = void 0; // Find the value to subtract out of the track\n\n\t\t\t\tif (referenceTime <= referenceTrack.times[0]) {\n\t\t\t\t\t// Reference frame is earlier than the first keyframe, so just use the first keyframe\n\t\t\t\t\tvar startIndex = referenceOffset;\n\t\t\t\t\tvar endIndex = referenceValueSize - referenceOffset;\n\t\t\t\t\treferenceValue = AnimationUtils.arraySlice(referenceTrack.values, startIndex, endIndex);\n\t\t\t\t} else if (referenceTime >= referenceTrack.times[lastIndex]) {\n\t\t\t\t\t// Reference frame is after the last keyframe, so just use the last keyframe\n\t\t\t\t\tvar _startIndex = lastIndex * referenceValueSize + referenceOffset;\n\n\t\t\t\t\tvar _endIndex = _startIndex + referenceValueSize - referenceOffset;\n\n\t\t\t\t\treferenceValue = AnimationUtils.arraySlice(referenceTrack.values, _startIndex, _endIndex);\n\t\t\t\t} else {\n\t\t\t\t\t// Interpolate to the reference value\n\t\t\t\t\tvar interpolant = referenceTrack.createInterpolant();\n\t\t\t\t\tvar _startIndex2 = referenceOffset;\n\n\t\t\t\t\tvar _endIndex2 = referenceValueSize - referenceOffset;\n\n\t\t\t\t\tinterpolant.evaluate(referenceTime);\n\t\t\t\t\treferenceValue = AnimationUtils.arraySlice(interpolant.resultBuffer, _startIndex2, _endIndex2);\n\t\t\t\t} // Conjugate the quaternion\n\n\n\t\t\t\tif (referenceTrackType === 'quaternion') {\n\t\t\t\t\tvar referenceQuat = new Quaternion().fromArray(referenceValue).normalize().conjugate();\n\t\t\t\t\treferenceQuat.toArray(referenceValue);\n\t\t\t\t} // Subtract the reference value from all of the track values\n\n\n\t\t\t\tvar numTimes = targetTrack.times.length;\n\n\t\t\t\tfor (var j = 0; j < numTimes; ++j) {\n\t\t\t\t\tvar valueStart = j * targetValueSize + targetOffset;\n\n\t\t\t\t\tif (referenceTrackType === 'quaternion') {\n\t\t\t\t\t\t// Multiply the conjugate for quaternion track types\n\t\t\t\t\t\tQuaternion.multiplyQuaternionsFlat(targetTrack.values, valueStart, referenceValue, 0, targetTrack.values, valueStart);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvar valueEnd = targetValueSize - targetOffset * 2; // Subtract each value for all other numeric track types\n\n\t\t\t\t\t\tfor (var k = 0; k < valueEnd; ++k) {\n\t\t\t\t\t\t\ttargetTrack.values[valueStart + k] -= referenceValue[k];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tfor (var i = 0; i < numTracks; ++i) {\n\t\t\t\tvar _ret = _loop(i);\n\n\t\t\t\tif (_ret === \"continue\") continue;\n\t\t\t}\n\n\t\t\ttargetClip.blendMode = AdditiveAnimationBlendMode;\n\t\t\treturn targetClip;\n\t\t}\n\t};\n\n\t/**\n\t * Abstract base class of interpolants over parametric samples.\n\t *\n\t * The parameter domain is one dimensional, typically the time or a path\n\t * along a curve defined by the data.\n\t *\n\t * The sample values can have any dimensionality and derived classes may\n\t * apply special interpretations to the data.\n\t *\n\t * This class provides the interval seek in a Template Method, deferring\n\t * the actual interpolation to derived classes.\n\t *\n\t * Time complexity is O(1) for linear access crossing at most two points\n\t * and O(log N) for random access, where N is the number of positions.\n\t *\n\t * References:\n\t *\n\t * \t\thttp://www.oodesign.com/template-method-pattern.html\n\t *\n\t */\n\tfunction Interpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {\n\t\tthis.parameterPositions = parameterPositions;\n\t\tthis._cachedIndex = 0;\n\t\tthis.resultBuffer = resultBuffer !== undefined ? resultBuffer : new s
1ampleValues.constructor(sampleSize);\n\t\tthis.sampleValues = sampleValues;\n\t\tthis.valueSize = sampleSize;\n\t}\n\n\tObject.assign(Interpolant.prototype, {\n\t\tevaluate: function evaluate(t) {\n\t\t\tvar pp = this.parameterPositions;\n\t\t\tvar i1 = this._cachedIndex,\n\t\t\t\t\tt1 = pp[i1],\n\t\t\t\t\tt0 = pp[i1 - 1];\n\n\t\t\tvalidate_interval: {\n\t\t\t\tseek: {\n\t\t\t\t\tvar right;\n\n\t\t\t\t\tlinear_scan: {\n\t\t\t\t\t\t//- See http://jsperf.com/comparison-to-undefined/3\n\t\t\t\t\t\t//- slower code:\n\t\t\t\t\t\t//-\n\t\t\t\t\t\t//- \t\t\t\tif ( t >= t1 || t1 === undefined ) {\n\t\t\t\t\t\tforward_scan: if (!(t < t1)) {\n\t\t\t\t\t\t\tfor (var giveUpAt = i1 + 2;;) {\n\t\t\t\t\t\t\t\tif (t1 === undefined) {\n\t\t\t\t\t\t\t\t\tif (t < t0) break forward_scan; // after end\n\n\t\t\t\t\t\t\t\t\ti1 = pp.length;\n\t\t\t\t\t\t\t\t\tthis._cachedIndex = i1;\n\t\t\t\t\t\t\t\t\treturn this.afterEnd_(i1 - 1, t, t0);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (i1 === giveUpAt) break; // this loop\n\n\t\t\t\t\t\t\t\tt0 = t1;\n\t\t\t\t\t\t\t\tt1 = pp[++i1];\n\n\t\t\t\t\t\t\t\tif (t < t1) {\n\t\t\t\t\t\t\t\t\t// we have arrived at the sought interval\n\t\t\t\t\t\t\t\t\tbreak seek;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} // prepare binary search on the right side of the index\n\n\n\t\t\t\t\t\t\tright = pp.length;\n\t\t\t\t\t\t\tbreak linear_scan;\n\t\t\t\t\t\t} //- slower code:\n\t\t\t\t\t\t//-\t\t\t\t\tif ( t < t0 || t0 === undefined ) {\n\n\n\t\t\t\t\t\tif (!(t >= t0)) {\n\t\t\t\t\t\t\t// looping?\n\t\t\t\t\t\t\tvar t1global = pp[1];\n\n\t\t\t\t\t\t\tif (t < t1global) {\n\t\t\t\t\t\t\t\ti1 = 2; // + 1, using the scan for the details\n\n\t\t\t\t\t\t\t\tt0 = t1global;\n\t\t\t\t\t\t\t} // linear reverse scan\n\n\n\t\t\t\t\t\t\tfor (var _giveUpAt = i1 - 2;;) {\n\t\t\t\t\t\t\t\tif (t0 === undefined) {\n\t\t\t\t\t\t\t\t\t// before start\n\t\t\t\t\t\t\t\t\tthis._cachedIndex = 0;\n\t\t\t\t\t\t\t\t\treturn this.beforeStart_(0, t, t1);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tif (i1 === _giveUpAt) break; // this loop\n\n\t\t\t\t\t\t\t\tt1 = t0;\n\t\t\t\t\t\t\t\tt0 = pp[--i1 - 1];\n\n\t\t\t\t\t\t\t\tif (t >= t0) {\n\t\t\t\t\t\t\t\t\t// we have arrived at the sought interval\n\t\t\t\t\t\t\t\t\tbreak seek;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} // prepare binary search on the left side of the index\n\n\n\t\t\t\t\t\t\tright = i1;\n\t\t\t\t\t\t\ti1 = 0;\n\t\t\t\t\t\t\tbreak linear_scan;\n\t\t\t\t\t\t} // the interval is valid\n\n\n\t\t\t\t\t\tbreak validate_interval;\n\t\t\t\t\t} // linear scan\n\t\t\t\t\t// binary search\n\n\n\t\t\t\t\twhile (i1 < right) {\n\t\t\t\t\t\tvar mid = i1 + right >>> 1;\n\n\t\t\t\t\t\tif (t < pp[mid]) {\n\t\t\t\t\t\t\tright = mid;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ti1 = mid + 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tt1 = pp[i1];\n\t\t\t\t\tt0 = pp[i1 - 1]; // check boundary cases, again\n\n\t\t\t\t\tif (t0 === undefined) {\n\t\t\t\t\t\tthis._cachedIndex = 0;\n\t\t\t\t\t\treturn this.beforeStart_(0, t, t1);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (t1 === undefined) {\n\t\t\t\t\t\ti1 = pp.length;\n\t\t\t\t\t\tthis._cachedIndex = i1;\n\t\t\t\t\t\treturn this.afterEnd_(i1 - 1, t0, t);\n\t\t\t\t\t}\n\t\t\t\t} // seek\n\n\n\t\t\t\tthis._cachedIndex = i1;\n\t\t\t\tthis.intervalChanged_(i1, t0, t1);\n\t\t\t} // validate_interval\n\n\n\t\t\treturn this.interpolate_(i1, t0, t, t1);\n\t\t},\n\t\tsettings: null,\n\t\t// optional, subclass-specific settings structure\n\t\t// Note: The indirection allows central control of many interpolants.\n\t\t// --- Protected interface\n\t\tDefaultSettings_: {},\n\t\tgetSettings_: function getSettings_() {\n\t\t\treturn this.settings || this.DefaultSettings_;\n\t\t},\n\t\tcopySampleValue_: function copySampleValue_(index) {\n\t\t\t// copies a sample value to the result buffer\n\t\t\tvar result = this.resultBuffer,\n\t\t\t\t\tvalues = this.sampleValues,\n\t\t\t\t\tstride = this.valueSize,\n\t\t\t\t\toffset = index * stride;\n\n\t\t\tfor (var i = 0; i !== stride; ++i) {\n\t\t\t\tresult[i] = values[offset + i];\n\t\t\t}\n\n\t\t\treturn result;\n\t\t},\n\t\t// Template methods for derived classes:\n\t\tinterpolate_: function interpolate_()\n\t\t/* i1, t0, t, t1 */\n\t\t{\n\t\t\tthrow new Error('call to abstract method'); // implementations shall return this.resultBuffer\n\t\t},\n\t\tintervalChanged_: function intervalChanged_()\n\t\t/* i1, t0, t1 */\n\t\t{// empty\n\t\t}\n\t}); // DECLARE ALIAS AFTER assign prototype\n\n\tObject.assign(Interpolant.prototype, {\n\t\t//( 0, t, t0 ), returns this.resultBuffer\n\t\tbeforeStart_: Interpolant.prototype.copySampleValue_,\n\t\t//( N-1, tN-1, t ), returns this.resultBuffer\n\t\tafterEnd_: Interpolant.prototype.copySampleValue_\n\t});\n\n\t/**\n\t * Fast and simple cubic spline interpolant.\n\t *\n\t * It was derived from a Hermitian construction setting the first derivative\n\t * at each sample position to the linear slope between neighboring positions\n\t * over their parameter interval.\n\t */\n\n\tfunction CubicInterpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {\n\t\tInterpolant.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);\n\t\tthis._weightPrev = -0;\n\t\tthis._offsetPrev = -0;\n\t\tthis._weightNext = -0;\n\t\tthis._offsetNext = -0;\n\t}\n\n\tCubicInterpolant.prototype = Object.assign(Object.create(Interpolant.prototype), {\n\t\tconstructor: CubicInterpolant,\n\t\tDefaultSettings_: {\n\t\t\tendingStart: ZeroCurvatureEnding,\n\t\t\tendingEnd: ZeroCurvatureEnding\n\t\t},\n\t\tintervalChanged_: function intervalChanged_(i1, t0, t1) {\n\t\t\tvar pp = this.parameterPositions;\n\t\t\tvar iPrev = i1 - 2,\n\t\t\t\t\tiNext = i1 + 1,\n\t\t\t\t\ttPrev = pp[iPrev],\n\t\t\t\t\ttNext = pp[iNext];\n\n\t\t\tif (tPrev === undefined) {\n\t\t\t\tswitch (this.getSettings_().endingStart) {\n\t\t\t\t\tcase ZeroSlopeEnding:\n\t\t\t\t\t\t// f'(t0) = 0\n\t\t\t\t\t\tiPrev = i1;\n\t\t\t\t\t\ttPrev = 2 * t0 - t1;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase WrapAroundEnding:\n\t\t\t\t\t\t// use the other end of the curve\
1n\t\t\t\t\t\tiPrev = pp.length - 2;\n\t\t\t\t\t\ttPrev = t0 + pp[iPrev] - pp[iPrev + 1];\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t// ZeroCurvatureEnding\n\t\t\t\t\t\t// f''(t0) = 0 a.k.a. Natural Spline\n\t\t\t\t\t\tiPrev = i1;\n\t\t\t\t\t\ttPrev = t1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (tNext === undefined) {\n\t\t\t\tswitch (this.getSettings_().endingEnd) {\n\t\t\t\t\tcase ZeroSlopeEnding:\n\t\t\t\t\t\t// f'(tN) = 0\n\t\t\t\t\t\tiNext = i1;\n\t\t\t\t\t\ttNext = 2 * t1 - t0;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase WrapAroundEnding:\n\t\t\t\t\t\t// use the other end of the curve\n\t\t\t\t\t\tiNext = 1;\n\t\t\t\t\t\ttNext = t1 + pp[1] - pp[0];\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\t// ZeroCurvatureEnding\n\t\t\t\t\t\t// f''(tN) = 0, a.k.a. Natural Spline\n\t\t\t\t\t\tiNext = i1 - 1;\n\t\t\t\t\t\ttNext = t0;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar halfDt = (t1 - t0) * 0.5,\n\t\t\t\t\tstride = this.valueSize;\n\t\t\tthis._weightPrev = halfDt / (t0 - tPrev);\n\t\t\tthis._weightNext = halfDt / (tNext - t1);\n\t\t\tthis._offsetPrev = iPrev * stride;\n\t\t\tthis._offsetNext = iNext * stride;\n\t\t},\n\t\tinterpolate_: function interpolate_(i1, t0, t, t1) {\n\t\t\tvar result = this.resultBuffer,\n\t\t\t\t\tvalues = this.sampleValues,\n\t\t\t\t\tstride = this.valueSize,\n\t\t\t\t\to1 = i1 * stride,\n\t\t\t\t\to0 = o1 - stride,\n\t\t\t\t\toP = this._offsetPrev,\n\t\t\t\t\toN = this._offsetNext,\n\t\t\t\t\twP = this._weightPrev,\n\t\t\t\t\twN = this._weightNext,\n\t\t\t\t\tp = (t - t0) / (t1 - t0),\n\t\t\t\t\tpp = p * p,\n\t\t\t\t\tppp = pp * p; // evaluate polynomials\n\n\t\t\tvar sP = -wP * ppp + 2 * wP * pp - wP * p;\n\t\t\tvar s0 = (1 + wP) * ppp + (-1.5 - 2 * wP) * pp + (-0.5 + wP) * p + 1;\n\t\t\tvar s1 = (-1 - wN) * ppp + (1.5 + wN) * pp + 0.5 * p;\n\t\t\tvar sN = wN * ppp - wN * pp; // combine data linearly\n\n\t\t\tfor (var i = 0; i !== stride; ++i) {\n\t\t\t\tresult[i] = sP * values[oP + i] + s0 * values[o0 + i] + s1 * values[o1 + i] + sN * values[oN + i];\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}\n\t});\n\n\tfunction LinearInterpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {\n\t\tInterpolant.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);\n\t}\n\n\tLinearInterpolant.prototype = Object.assign(Object.create(Interpolant.prototype), {\n\t\tconstructor: LinearInterpolant,\n\t\tinterpolate_: function interpolate_(i1, t0, t, t1) {\n\t\t\tvar result = this.resultBuffer,\n\t\t\t\t\tvalues = this.sampleValues,\n\t\t\t\t\tstride = this.valueSize,\n\t\t\t\t\toffset1 = i1 * stride,\n\t\t\t\t\toffset0 = offset1 - stride,\n\t\t\t\t\tweight1 = (t - t0) / (t1 - t0),\n\t\t\t\t\tweight0 = 1 - weight1;\n\n\t\t\tfor (var i = 0; i !== stride; ++i) {\n\t\t\t\tresult[i] = values[offset0 + i] * weight0 + values[offset1 + i] * weight1;\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}\n\t});\n\n\t/**\n\t *\n\t * Interpolant that evaluates to the sample value at the position preceeding\n\t * the parameter.\n\t */\n\n\tfunction DiscreteInterpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {\n\t\tInterpolant.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);\n\t}\n\n\tDiscreteInterpolant.prototype = Object.assign(Object.create(Interpolant.prototype), {\n\t\tconstructor: DiscreteInterpolant,\n\t\tinterpolate_: function interpolate_(i1\n\t\t/*, t0, t, t1 */\n\t\t) {\n\t\t\treturn this.copySampleValue_(i1 - 1);\n\t\t}\n\t});\n\n\tfunction KeyframeTrack(name, times, values, interpolation) {\n\t\tif (name === undefined) throw new Error('THREE.KeyframeTrack: track name is undefined');\n\t\tif (times === undefined || times.length === 0) throw new Error('THREE.KeyframeTrack: no keyframes in track named ' + n
1ame);\n\t\tthis.name = name;\n\t\tthis.times = AnimationUtils.convertArray(times, this.TimeBufferType);\n\t\tthis.values = AnimationUtils.convertArray(values, this.ValueBufferType);\n\t\tthis.setInterpolation(interpolation || this.DefaultInterpolation);\n\t} // Static methods\n\n\n\tObject.assign(KeyframeTrack, {\n\t\t// Serialization (in static context, because of constructor invocation\n\t\t// and automatic invocation of .toJSON):\n\t\ttoJSON: function toJSON(track) {\n\t\t\tvar trackType = track.constructor;\n\t\t\tvar json; // derived classes can define a static toJSON method\n\n\t\t\tif (trackType.toJSON !== undefined) {\n\t\t\t\tjson = trackType.toJSON(track);\n\t\t\t} else {\n\t\t\t\t// by default, we assume the data can be serialized as-is\n\t\t\t\tjson = {\n\t\t\t\t\t'name': track.name,\n\t\t\t\t\t'times': AnimationUtils.convertArray(track.times, Array),\n\t\t\t\t\t'values': AnimationUtils.convertArray(track.values, Array)\n\t\t\t\t};\n\t\t\t\tvar interpolation = track.getInterpolation();\n\n\t\t\t\tif (interpolation !== track.DefaultInterpolation) {\n\t\t\t\t\tjson.interpolation = interpolation;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tjson.type = track.ValueTypeName; // mandatory\n\n\t\t\treturn json;\n\t\t}\n\t});\n\tObject.assign(KeyframeTrack.prototype, {\n\t\tconstructor: KeyframeTrack,\n\t\tTimeBufferType: Float32Array,\n\t\tValueBufferType: Float32Array,\n\t\tDefaultInterpolation: InterpolateLinear,\n\t\tInterpolantFactoryMethodDiscrete: function InterpolantFactoryMethodDiscrete(result) {\n\t\t\treturn new DiscreteInterpolant(this.times, this.values, this.getValueSize(), result);\n\t\t},\n\t\tInterpolantFactoryMethodLinear: function InterpolantFactoryMethodLinear(result) {\n\t\t\treturn new LinearInterpolant(this.times, this.values, this.getValueSize(), result);\n\t\t},\n\t\tInterpolantFactoryMethodSmooth: function InterpolantFactoryMethodSmooth(result) {\n\t\t\treturn new CubicInterpolant(this.times, this.values, this.getValueSize(), result);\n\t\t},\n\t\tsetInterpolation: function setInterpolation(interpolation) {\n\t\t\tvar factoryMethod;\n\n\t\t\tswitch (interpolation) {\n\t\t\t\tcase InterpolateDiscrete:\n\t\t\t\t\tfactoryMethod = this.InterpolantFactoryMethodDiscrete;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase InterpolateLinear:\n\t\t\t\t\tfactoryMethod = this.InterpolantFactoryMethodLinear;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase InterpolateSmooth:\n\t\t\t\t\tfactoryMethod = this.InterpolantFactoryMethodSmooth;\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (factoryMethod === undefined) {\n\t\t\t\tvar message = 'unsupported interpolation for ' + this.ValueTypeName + ' keyframe track named ' + this.name;\n\n\t\t\t\tif (this.createInterpolant === undefined) {\n\t\t\t\t\t// fall back to default, unless the default itself is messed up\n\t\t\t\t\tif (interpolation !== this.DefaultInterpolation) {\n\t\t\t\t\t\tthis.setInterpolation(this.DefaultInterpolation);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new Error(message); // fatal, in this case\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconsole.warn('THREE.KeyframeTrack:', message);\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\tthis.createInterpolant = factoryMethod;\n\t\t\treturn this;\n\t\t},\n\t\tgetInterpolation: function getInterpolation() {\n\t\t\tswitch (this.createInterpolant) {\n\t\t\t\tcase this.InterpolantFactoryMethodDiscrete:\n\t\t\t\t\treturn InterpolateDiscrete;\n\n\t\t\t\tcase this.InterpolantFactoryMethodLinear:\n\t\t\t\t\treturn InterpolateLinear;\n\n\t\t\t\tcase this.InterpolantFactoryMethodSmooth:\n\t\t\t\t\treturn InterpolateSmooth;\n\t\t\t}\n\t\t},\n\t\tgetValueSize: function getValueSize() {\n\t\t\treturn this.values.length / this.times.length;\n\t\t},\n\t\t// move all keyframes either forwards or backwards in time\n\t\tshift: function shift(timeOffset) {\n\t\t\tif (timeOffset !== 0.0) {\n\t\t\t\tvar times = this.times;\n\n\t\t\t\tfor (var i = 0, n = times.length; i !== n; ++i) {\n\t\t\t\t\ttimes[i] += timeOffset;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\t// scale all keyframe times by a factor (useful for frame <-> seconds conversions)\n\t\tscale: function scale(timeScale) {\n\t\t\tif (timeScale !== 1.0) {\n\t\t\t\tvar times = this.times;\n\n\t\t\t\tfor (var i = 0, n = times.length; i !== n; ++i) {\n\t\t\t\t\ttimes[i] *= timeScale;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\t// removes keyframes before and after animation without changing any values within the range [startTime, endTime].\n\t\t// IMPORTANT: We do not shift around keys to the start of the track time, because for interpolated keys this will change their values\n\t\ttrim: function trim(startTime, endTime) {\n\t\t\tvar times = this.times,\n\t\t\t\t\tnKeys = times.length;\n\t\t\tvar from = 0,\n\t\t\t\t\tto = nKeys - 1;\n\n\t\t\twhile (from !== nKeys && times[from] < startTime) {\n\t\t\t\t++from;\n\t\t\t}\n\n\t\t\twhile (to !== -1 && times[to] > endTime) {\n\t\t\t\t--to;\n\t\t\t}\n\n\t\t\t++to; // inclusive -> exclusive bound\n\n\t\t\tif (from !== 0 || to !== nKeys) {\n\t\t\t\t// empty tracks are forbidden, so keep at least one keyframe\n\t\t\t\tif (from >= to) {\n\t\t\t\t\tto = Math.max(to, 1);\n\t\t\t\t\tfrom = to - 1;\n\t\t\t\t}\n\n\t\t\t\tvar stride = this.getValueSize();\n\t\t\t\tthis.times = AnimationUtils.arraySlice(times, from, to);\n\t\t\t\tthis.values = AnimationUtils.arraySlice(this.values, from * stride, to * stride);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\t// ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable\n\t\tvalidate: function validate() {\n\t\t\tvar valid = true;\n\t\t\tvar valueSize = this.getValueSize();\n\n\t\t\tif (valueSize - Math.floor(valueSize) !== 0) {\n\t\t\t\tconsole.error('THREE.KeyframeTrack: Invalid value size in track.', this);\n\t\t\t\tvalid = false;\n\t\t\t}\n\n\t\t\tvar times = this.times,\n\t\t\t\t\tvalues = this.values,\n\t\t\t\t\tnKeys = times.length;\n\n\t\t\tif (nKeys === 0) {\n\t\t\t\tconsole.error('THREE.KeyframeTrack: Track is empty.', this);\n\t\t\t\tvalid = false;\n\t\t\t}\n\n\t\t\tvar prevTime = null;\n\n\t\t\tfor (var i = 0; i !== nKeys;
1 i++) {\n\t\t\t\tvar currTime = times[i];\n\n\t\t\t\tif (typeof currTime === 'number' && isNaN(currTime)) {\n\t\t\t\t\tconsole.error('THREE.KeyframeTrack: Time is not a valid number.', this, i, currTime);\n\t\t\t\t\tvalid = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (prevTime !== null && prevTime > currTime) {\n\t\t\t\t\tconsole.error('THREE.KeyframeTrack: Out of order keys.', this, i, currTime, prevTime);\n\t\t\t\t\tvalid = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tprevTime = currTime;\n\t\t\t}\n\n\t\t\tif (values !== undefined) {\n\t\t\t\tif (AnimationUtils.isTypedArray(values)) {\n\t\t\t\t\tfor (var _i = 0, n = values.length; _i !== n; ++_i) {\n\t\t\t\t\t\tvar value = values[_i];\n\n\t\t\t\t\t\tif (isNaN(value)) {\n\t\t\t\t\t\t\tconsole.error('THREE.KeyframeTrack: Value is not a valid number.', this, _i, value);\n\t\t\t\t\t\t\tvalid = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn valid;\n\t\t},\n\t\t// removes equivalent sequential keys as common in morph target sequences\n\t\t// (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --\x3e (0,0,1,1,0,0)\n\t\toptimize: function optimize() {\n\t\t\t// times or values may be shared with other tracks, so overwriting is unsafe\n\t\t\tvar times = AnimationUtils.arraySlice(this.times),\n\t\t\t\t\tvalues = AnimationUtils.arraySlice(this.values),\n\t\t\t\t\tstride = this.getValueSize(),\n\t\t\t\t\tsmoothInterpolation = this.getInterpolation() === InterpolateSmooth,\n\t\t\t\t\tlastIndex = times.length - 1;\n\t\t\tvar writeIndex = 1;\n\n\t\t\tfor (var i = 1; i < lastIndex; ++i) {\n\t\t\t\tvar keep = false;\n\t\t\t\tvar time = times[i];\n\t\t\t\tvar timeNext = times[i + 1]; // remove adjacent keyframes scheduled at the same time\n\n\t\t\t\tif (time !== timeNext && (i !== 1 || time !== time[0])) {\n\t\t\t\t\tif (!smoothInterpolation) {\n\t\t\t\t\t\t// remove unnecessary keyframes same as their neighbors\n\t\t\t\t\t\tvar offset = i * stride,\n\t\t\t\t\t\t\t\toffsetP = offset - stride,\n\t\t\t\t\t\t\t\toffsetN = offset + stride;\n\n\t\t\t\t\t\tfor (var j = 0; j !== stride; ++j) {\n\t\t\t\t\t\t\tvar value = values[offset + j];\n\n\t\t\t\t\t\t\tif (value !== values[offsetP + j] || value !== values[offsetN + j]) {\n\t\t\t\t\t\t\t\tkeep = true;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tkeep = true;\n\t\t\t\t\t}\n\t\t\t\t} // in-place compaction\n\n\n\t\t\t\tif (keep) {\n\t\t\t\t\tif (i !== writeIndex) {\n\t\t\t\t\t\ttimes[writeIndex] = times[i];\n\t\t\t\t\t\tvar readOffset = i * stride,\n\t\t\t\t\t\t\t\twriteOffset = writeIndex * stride;\n\n\t\t\t\t\t\tfor (var _j = 0; _j !== stride; ++_j) {\n\t\t\t\t\t\t\tvalues[writeOffset + _j] = values[readOffset + _j];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t++writeIndex;\n\t\t\t\t}\n\t\t\t} // flush last keyframe (compaction looks ahead)\n\n\n\t\t\tif (lastIndex > 0) {\n\t\t\t\ttimes[writeIndex] = times[lastIndex];\n\n\t\t\t\tfor (var _readOffset = lastIndex * stride, _writeOffset = writeIndex * stride, _j2 = 0; _j2 !== stride; ++_j2) {\n\t\t\t\t\tvalues[_writeOffset + _j2] = values[_readOffset + _j2];\n\t\t\t\t}\n\n\t\t\t\t++writeIndex;\n\t\t\t}\n\n\t\t\tif (writeIndex !== times.length) {\n\t\t\t\tthis.times = AnimationUtils.arraySlice(times, 0, writeIndex);\n\t\t\t\tthis.values = AnimationUtils.arraySlice(values, 0, writeIndex * stride);\n\t\t\t} else {\n\t\t\t\tthis.times = times;\n\t\t\t\tthis.values = values;\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tclone: function clone() {\n\t\t\tvar times = AnimationUtils.arraySlice(this.times, 0);\n\t\t\tvar values = AnimationUtils.arraySlice(this.values, 0);\n\t\t\tvar TypedKeyframeTrack = this.constructor;\n\t\t\tvar track = new TypedKeyframeTrack(this.name, times, values); // Interpolant argument to constructor is not saved, so copy the factory method directly.\n\n\t\t\ttrack.createInterpolant = this.createInterpolant;\n\t\t\treturn track;\n\t\t}\n\t});\n\n\t/**\n\t * A Track of Boolean keyframe values.\n\t */\n\n\tfunction BooleanKeyframeTrack(name, times, values) {\n\t\tKeyframeTrack.call(this, name, times, values);\n\t}\n\n\tBooleanKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {\n\t\tconstructor: BooleanKeyframeTrack,\n\t\tValueTypeName: 'bool',\n\t\tValueBufferType: Array,\n\t\tDefaultInterpolation: InterpolateDiscrete,\n\t\tInterpolantFactoryMethodLinear: undefined,\n\t\tInterpolantFactoryMethodSmooth: undefined // Note: Actually this track could have a optimized / compressed\n\t\t// representation of a single value and a custom interpolant that\n\t\t// computes \"firstValue ^ isOdd( index )\".\n\n\t});\n\n\t/**\n\t * A Track of keyframe values that represent color.\n\t */\n\n\tfunction ColorKeyframeTrack(name, times, values, interpolation) {\n\t\tKeyframeTrack.call(this, name, times, values, interpolation);\n\t}\n\n\tColorKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {\n\t\tconstructor: ColorKeyframeTrack,\n\t\tValueTypeName: 'color' // ValueBufferType is
1inherited\n\t\t// DefaultInterpolation is inherited\n\t\t// Note: Very basic implementation and nothing special yet.\n\t\t// However, this is the place for color space parameterization.\n\n\t});\n\n\t/**\n\t * A Track of numeric keyframe values.\n\t */\n\n\tfunction NumberKeyframeTrack(name, times, values, interpolation) {\n\t\tKeyframeTrack.call(this, name, times, values, interpolation);\n\t}\n\n\tNumberKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {\n\t\tconstructor: NumberKeyframeTrack,\n\t\tValueTypeName: 'number' // ValueBufferType is inherited\n\t\t// DefaultInterpolation is inherited\n\n\t});\n\n\t/**\n\t * Spherical linear unit quaternion interpolant.\n\t */\n\n\tfunction QuaternionLinearInterpolant(parameterPositions, sampleValues, sampleSize, resultBuffer) {\n\t\tInterpolant.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);\n\t}\n\n\tQuaternionLinearInterpolant.prototype = Object.assign(Object.create(Interpolant.prototype), {\n\t\tconstructor: QuaternionLinearInterpolant,\n\t\tinterpolate_: function interpolate_(i1, t0, t, t1) {\n\t\t\tvar result = this.resultBuffer,\n\t\t\t\t\tvalues = this.sampleValues,\n\t\t\t\t\tstride = this.valueSize,\n\t\t\t\t\talpha = (t - t0) / (t1 - t0);\n\t\t\tvar offset = i1 * stride;\n\n\t\t\tfor (var end = offset + stride; offset !== end; offset += 4) {\n\t\t\t\tQuaternion.slerpFlat(result, 0, values, offset - stride, values, offset, alpha);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}\n\t});\n\n\t/**\n\t * A Track of quaternion keyframe values.\n\t */\n\n\tfunction QuaternionKeyframeTrack(name, times, values, interpolation) {\n\t\tKeyframeTrack.call(this, name, times, values, interpolation);\n\t}\n\n\tQuaternionKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {\n\t\tconstructor: QuaternionKeyframeTrack,\n\t\tValueTypeName: 'quaternion',\n\t\t// ValueBufferType is inherited\n\t\tDefaultInterpolation: InterpolateLinear,\n\t\tInterpolantFactoryMethodLinear: function InterpolantFactoryMethodLinear(result) {\n\t\t\treturn new QuaternionLinearInterpolant(this.times, this.values, this.getValueSize(), result);\n\t\t},\n\t\tInterpolantFactoryMethodSmooth: undefined // not yet implemented\n\n\t});\n\n\t/**\n\t * A Track that interpolates Strings\n\t */\n\n\tfunction StringKeyframeTrack(name, times, values, interpolation) {\n\t\tKeyframeTrack.call(this, name, times, values, interpolation);\n\t}\n\n\tStringKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {\n\t\tconstructor: StringKeyframeTrack,\n\t\tValueTypeName: 'string',\n\t\tValueBufferType: Array,\n\t\tDefaultInterpolation: InterpolateDiscrete,\n\t\tInterpolantFactoryMethodLinear: undefined,\n\t\tInterpolantFactoryMethodSmooth: undefined\n\t});\n\n\t/**\n\t * A Track of vectored keyframe values.\n\t */\n\n\tfunction VectorKeyframeTrack(name, times, values, interpolation) {\n\t\tKeyframeTrack.call(this, name, times, values, interpolation);\n\t}\n\n\tVectorKeyframeTrack.prototype = Object.assign(Object.create(KeyframeTrack.prototype), {\n\t\tconstructor: VectorKeyframeTrack,\n\t\tValueTypeName: 'vector' // ValueBufferType is inherited\n\t\t// DefaultInterpolation is inherited\n\n\t});\n\n\tfunction AnimationClip(name, duration, tracks, blendMode) {\n\t\tif (duration === void 0) {\n\t\t\tduration = -1;\n\t\t}\n\n\t\tif (blendMode === void 0) {\n\t\t\tblendMode = NormalAnimationBlendMode;\n\t\t}\n\n\t\tthis.name = name;\n\t\tthis.tracks = tracks;\n\t\tthis.duration = duration;\n\t\tthis.blendMode = blendMode;\n\t\tthis.uuid = MathUtils.generateUUID(); // this means it should figure out its duration by scanning the tracks\n\n\t\tif (this.duration < 0) {\n\t\t\tthis.resetDuration();\n\t\t}\n\t}\n\n\tfunction getTrackTypeForValueTypeName(typeName) {\n\t\tswitch (typeName.toLowerCase()) {\n\t\t\tcase 'scalar':\n\t\t\tcase 'double':\n\t\t\tcase 'float':\n\t\t\tcase 'number':\n\t\t\tcase 'integer':\n\t\t\t\treturn NumberKeyframeTrack;\n\n\t\t\tcase 'vector':\n\t\t\tcase 'vector2':\n\t\t\tcase 'vector3':\n\t\t\tcase 'vector4':\n\t\t\t\treturn VectorKeyframeTrack;\n\n\t\t\tcase 'color':\n\t\t\t\treturn ColorKeyframeTrack;\n\n\t\t\tcase 'quaternion':\n\t\t\t\treturn QuaternionKeyframeTrack;\n\n\t\t\tcase 'bool':\n\t\t\tcase 'boolean':\n\t\t\t\treturn BooleanKeyframeTrack;\n\n\t\t\tcase 'string':\n\t\t\t\treturn StringKeyframeTrack;\n\t\t}\n\n\t\tthrow new Error('THREE.KeyframeTrack: Unsupported typeName: ' + typeName);\n\t}\n\n\tfunction parseKeyframeTrack(json) {\n\t\tif (json.type === undefined) {\n\t\t\tthrow new Error('THREE.KeyframeTrack: track type undefined, can not parse');\n\t\t}\n\n\t\tvar trackType = getTrackTypeForValueTypeName(json.type);\n\n\t\tif (json.times === undefined) {\n\t\t\tvar times = [],\n\t\t\t\t\tvalues = [];\n\t\t\tAnimationUtils.flattenJSON(json.keys, times, values, 'value');\n\t\t\tjson.times = times;\n\t\t\tjson.values = values;\n\t\t} // derived classes can define a static parse method\n\n\n\t\tif (trackType.parse !== undefined) {\n\t\t\treturn trackType.parse(json);\n\t\t} else {\n\t\t\t// by default, we assume a constructor compatible with the base\n\t\t\treturn new trackType(json.name, json.times, json.values, json.interpolation);\n\t\t}\n\t}\n\n\tObject.assign(AnimationClip, {\n\t\tparse: function parse(json) {\n\t\t\tvar tracks = [],\n\t\t\t\t\tjsonTracks = json.tracks,\n\t\t\t\t\tframeTime = 1.0 / (json.fps || 1.0);\n\n\t\t\tfor (var i = 0, n = jsonTracks.length; i !== n; ++i) {\n\t\t\t\ttracks.push(parseKeyframeTrack(jsonTracks[i]).scale(frameTime));\n\t\t\t}\n\n\t\t\tvar clip = new AnimationClip(json.name, json.duration, tracks, json.blendMode);\n\t\t\tclip.uuid = json.uuid;\n\t\t\treturn clip;\n\t\t},\n\t\ttoJSON: function toJSON(clip) {\n\t\t\tvar tracks = [],\n\t\t\t\t\tclipTracks = clip.tracks;\n\t\t\tvar json = {\n\t\t\t\t'name': clip.name,\n\t\t\t\t'duration': clip.duration,\n\t\t\t\t'tracks': tracks,\n\t\t\t\t'uuid': clip.uuid,\n\t\t\t\t'blendMode': clip.blendMode\n\t\t\t};\n\n\t\t\tfor (var i = 0, n = clipTracks.length; i !== n; ++i) {\n\t\t\t\ttracks.push(KeyframeTrack.toJSON(clipTracks[i]));\n\t\t\t}\n\n\t\t\treturn json;\n\t\t},\n\t\tCreateFromMorphTargetSequence: function CreateFromMorphTargetSequence(name, morphTargetSequence, fps, noLoop) {\n\t\t\tvar numMorphTargets = morphTargetSequence.length;\n\t\t\tvar tracks = [];\n\n\t\t\tfor (var i = 0; i < numMorphTargets;
1 i++) {\n\t\t\t\tvar times = [];\n\t\t\t\tvar values = [];\n\t\t\t\ttimes.push((i + numMorphTargets - 1) % numMorphTargets, i, (i + 1) % numMorphTargets);\n\t\t\t\tvalues.push(0, 1, 0);\n\t\t\t\tvar order = AnimationUtils.getKeyframeOrder(times);\n\t\t\t\ttimes = AnimationUtils.sortedArray(times, 1, order);\n\t\t\t\tvalues = AnimationUtils.sortedArray(values, 1, order); // if there is a key at the first frame, duplicate it as the\n\t\t\t\t// last frame as well for perfect loop.\n\n\t\t\t\tif (!noLoop && times[0] === 0) {\n\t\t\t\t\ttimes.push(numMorphTargets);\n\t\t\t\t\tvalues.push(values[0]);\n\t\t\t\t}\n\n\t\t\t\ttracks.push(new NumberKeyframeTrack('.morphTargetInfluences[' + morphTargetSequence[i].name + ']', times, values).scale(1.0 / fps));\n\t\t\t}\n\n\t\t\treturn new AnimationClip(name, -1, tracks);\n\t\t},\n\t\tfindByName: function findByName(objectOrClipArray, name) {\n\t\t\tvar clipArray = objectOrClipArray;\n\n\t\t\tif (!Array.isArray(objectOrClipArray)) {\n\t\t\t\tvar o = objectOrClipArray;\n\t\t\t\tclipArray = o.geometry && o.geometry.animations || o.animations;\n\t\t\t}\n\n\t\t\tfor (var i = 0; i < clipArray.length; i++) {\n\t\t\t\tif (clipArray[i].name === name) {\n\t\t\t\t\treturn clipArray[i];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn null;\n\t\t},\n\t\tCreateClipsFromMorphTargetSequences: function CreateClipsFromMorphTargetSequences(morphTargets, fps, noLoop) {\n\t\t\tvar animationToMorphTargets = {}; // tested with https://regex101.com/ on trick sequences\n\t\t\t// such flamingo_flyA_003, flamingo_run1_003, crdeath0059\n\n\t\t\tvar pattern = /^([\\w-]*?)([\\d]+)$/; // sort morph target names into animation groups based\n\t\t\t// patterns like Walk_001, Walk_002, Run_001, Run_002\n\n\t\t\tfor (var i = 0, il = morphTargets.length; i < il; i++) {\n\t\t\t\tvar morphTarget = morphTargets[i];\n\t\t\t\tvar parts = morphTarget.name.match(pattern);\n\n\t\t\t\tif (parts && parts.length > 1) {\n\t\t\t\t\tvar name = parts[1];\n\t\t\t\t\tvar animationMorphTargets = animationToMorphTargets[name];\n\n\t\t\t\t\tif (!animationMorphTargets) {\n\t\t\t\t\t\tanimationToMorphTargets[name] = animationMorphTargets = [];\n\t\t\t\t\t}\n\n\t\t\t\t\tanimationMorphTargets.push(morphTarget);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar clips = [];\n\n\t\t\tfor (var _name in animationToMorphTargets) {\n\t\t\t\tclips.push(AnimationClip.CreateFromMorphTargetSequence(_name, animationToMorphTargets[_name], fps, noLoop));\n\t\t\t}\n\n\t\t\treturn clips;\n\t\t},\n\t\t// parse the animation.hierarchy format\n\t\tparseAnimation: function parseAnimation(animation, bones) {\n\t\t\tif (!animation) {\n\t\t\t\tconsole.error('THREE.AnimationClip: No animation in JSONLoader data.');\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tvar addNonemptyTrack = function addNonemptyTrack(trackType, trackName, animationKeys, propertyName, destTracks) {\n\t\t\t\t// only return track if there are actually keys.\n\t\t\t\tif (animationKeys.length !== 0) {\n\t\t\t\t\tvar times = [];\n\t\t\t\t\tvar values = [];\n\t\t\t\t\tAnimationUtils.flattenJSON(animationKeys, times, values, propertyName); // empty keys are filtered out, so check again\n\n\t\t\t\t\tif (times.length !== 0) {\n\t\t\t\t\t\tdestTracks.push(new trackType(trackName, times, values));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tvar tracks = [];\n\t\t\tvar clipName = animation.name || 'default';\n\t\t\tvar fps = animation.fps || 30;\n\t\t\tvar blendMode = animation.blendMode; // automatic length determination in AnimationClip.\n\n\t\t\tvar duration = animation.length || -1;\n\t\t\tvar hierarchyTracks = animation.hierarchy || [];\n\n\t\t\tfor (var h = 0; h < hierarchyTracks.length; h++) {\n\t\t\t\tvar animationKeys = hierarchyTracks[h].keys; // skip empty tracks\n\n\t\t\t\tif (!animationKeys || animationKeys.length === 0) continue; // process morph targets\n\n\t\t\t\tif (animationKeys[0].morphTargets) {\n\t\t\t\t\t// figure out all morph targets used in this track\n\t\t\t\t\tvar morphTargetNames = {};\n\t\t\t\t\tvar k = void 0;\n\n\t\t\t\t\tfor (k = 0; k < animationKeys.length; k++) {\n\t\t\t\t\t\tif (animationKeys[k].morphTargets) {\n\t\t\t\t\t\t\tfor (var m = 0; m < animationKeys[k].morphTargets.length; m++) {\n\t\t\t\t\t\t\t\tmorphTargetNames[animationKeys[k].morphTargets[m]] = -1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} // create a track for each morph target with all zero\n\t\t\t\t\t// morphTargetInfluences except for the keys in which\n\t\t\t\t\t// the morphTarget is named.\n\n\n\t\t\t\t\tfor (var morphTargetName in morphTargetNames) {\n\t\t\t\t\t\tvar times = [];\n\t\t\t\t\t\tvar values = [];\n\n\t\t\t\t\t\tfor (var _m = 0; _m !== animationKeys[k].morphTargets.length; ++_m) {\n\t\t\t\t\t\t\tvar animationKey = animationKeys[k];\n\t\t\t\t\t\t\ttimes.push(animationKey.time);\n\t\t\t\t\t\t\tvalues.push(animationKey.morphTarget === morphTargetName ? 1 : 0);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttracks.push(new NumberKeyframeTrack('.morphTargetInfluence[' + morphTargetName + ']', times, values));\n\t\t\t\t\t}\n\n\t\t\t\t\tduration = morphTargetNames.length * (fps || 1.0);\n\t\t\t\t} else {\n\t\t\t\t\t// ...assume skeletal animation\n\t\t\t\t\tvar boneName = '.bones[' + bones[h
1].name + ']';\n\t\t\t\t\taddNonemptyTrack(VectorKeyframeTrack, boneName + '.position', animationKeys, 'pos', tracks);\n\t\t\t\t\taddNonemptyTrack(QuaternionKeyframeTrack, boneName + '.quaternion', animationKeys, 'rot', tracks);\n\t\t\t\t\taddNonemptyTrack(VectorKeyframeTrack, boneName + '.scale', animationKeys, 'scl', tracks);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (tracks.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tvar clip = new AnimationClip(clipName, duration, tracks, blendMode);\n\t\t\treturn clip;\n\t\t}\n\t});\n\tObject.assign(AnimationClip.prototype, {\n\t\tresetDuration: function resetDuration() {\n\t\t\tvar tracks = this.tracks;\n\t\t\tvar duration = 0;\n\n\t\t\tfor (var i = 0, n = tracks.length; i !== n; ++i) {\n\t\t\t\tvar track = this.tracks[i];\n\t\t\t\tduration = Math.max(duration, track.times[track.times.length - 1]);\n\t\t\t}\n\n\t\t\tthis.duration = duration;\n\t\t\treturn this;\n\t\t},\n\t\ttrim: function trim() {\n\t\t\tfor (var i = 0; i < this.tracks.length; i++) {\n\t\t\t\tthis.tracks[i].trim(0, this.duration);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tvalidate: function validate() {\n\t\t\tvar valid = true;\n\n\t\t\tfor (var i = 0; i < this.tracks.length; i++) {\n\t\t\t\tvalid = valid && this.tracks[i].validate();\n\t\t\t}\n\n\t\t\treturn valid;\n\t\t},\n\t\toptimize: function optimize() {\n\t\t\tfor (var i = 0; i < this.tracks.length; i++) {\n\t\t\t\tthis.tracks[i].optimize();\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tclone: function clone() {\n\t\t\tvar tracks = [];\n\n\t\t\tfor (var i = 0; i < this.tracks.length; i++) {\n\t\t\t\ttracks.push(this.tracks[i].clone());\n\t\t\t}\n\n\t\t\treturn new AnimationClip(this.name, this.duration, tracks, this.blendMode);\n\t\t},\n\t\ttoJSON: function toJSON() {\n\t\t\treturn AnimationClip.toJSON(this);\n\t\t}\n\t});\n\n\tvar Cache = {\n\t\tenabled: false,\n\t\tfiles: {},\n\t\tadd: function add(key, file) {\n\t\t\tif (this.enabled === false) return; // console.log( 'THREE.Cache', 'Adding key:', key );\n\n\t\t\tthis.files[key] = file;\n\t\t},\n\t\tget: function get(key) {\n\t\t\tif (this.enabled === false) return; // console.log( 'THREE.Cache', 'Checking key:', key );\n\n\t\t\treturn this.files[key];\n\t\t},\n\t\tremove: function remove(key) {\n\t\t\tdelete this.files[key];\n\t\t},\n\t\tclear: function clear() {\n\t\t\tthis.files = {};\n\t\t}\n\t};\n\n\tfunction LoadingManager(onLoad, onProgress, onError) {\n\t\tvar scope = this;\n\t\tvar isLoading = false;\n\t\tvar itemsLoaded = 0;\n\t\tvar itemsTotal = 0;\n\t\tvar urlModifier = undefined;\n\t\tvar handlers = []; // Refer to #5689 for the reason why we don't set .onStart\n\t\t// in the constructor\n\n\t\tthis.onStart = undefined;\n\t\tthis.onLoad = onLoad;\n\t\tthis.onProgress = onProgress;\n\t\tthis.onError = onError;\n\n\t\tthis.itemStart = function (url) {\n\t\t\titemsTotal++;\n\n\t\t\tif (isLoading === false) {\n\t\t\t\tif (scope.onStart !== undefined) {\n\t\t\t\t\tscope.onStart(url, itemsLoaded, itemsTotal);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tisLoading = true;\n\t\t};\n\n\t\tthis.itemEnd = function (url) {\n\t\t\titemsLoaded++;\n\n\t\t\tif (scope.onProgress !== undefined) {\n\t\t\t\tscope.onProgress(url, itemsLoaded, itemsTotal);\n\t\t\t}\n\n\t\t\tif (itemsLoaded === itemsTotal) {\n\t\t\t\tisLoading = false;\n\n\t\t\t\tif (scope.onLoad !== undefined) {\n\t\t\t\t\tscope.onLoad();\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tthis.itemError = function (url) {\n\t\t\tif (scope.onError !== undefined) {\n\t\t\t\tscope.onError(url);\n\t\t\t}\n\t\t};\n\n\t\tthis.resolveURL = function (url) {\n\t\t\tif (urlModifier) {\n\t\t\t\treturn urlModifier(url);\n\t\t\t}\n\n\t\t\treturn url;\n\t\t};\n\n\t\tthis.setURLModifier = function (transform) {\n\t\t\turlModifier = transform;\n\t\t\treturn this;\n\t\t};\n\n\t\tthis.addHandler = function (regex, loader) {\n\t\t\thandlers.push(regex, loader);\n\t\t\treturn this;\n\t\t};\n\n\t\tthis.removeHandler = function (regex) {\n\t\t\tvar index = handlers.indexOf(regex);\n\n\t\t\tif (index !== -1) {\n\t\t\t\thandlers.splice(index, 2);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\tthis.getHandler = function (file) {\n\t\t\tfor (var i = 0, l = handlers.length; i < l; i += 2) {\n\t\t\t\tvar regex = handlers[i];\n\t\t\t\tvar loader = handlers[i + 1];\n\t\t\t\tif (regex.global) regex.lastIndex = 0;
1 // see #17920\n\n\t\t\t\tif (regex.test(file)) {\n\t\t\t\t\treturn loader;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn null;\n\t\t};\n\t}\n\n\tvar DefaultLoadingManager = new LoadingManager();\n\n\tfunction Loader(manager) {\n\t\tthis.manager = manager !== undefined ? manager : DefaultLoadingManager;\n\t\tthis.crossOrigin = 'anonymous';\n\t\tthis.withCredentials = false;\n\t\tthis.path = '';\n\t\tthis.resourcePath = '';\n\t\tthis.requestHeader = {};\n\t}\n\n\tObject.assign(Loader.prototype, {\n\t\tload: function load()\n\t\t/* url, onLoad, onProgress, onError */\n\t\t{},\n\t\tloadAsync: function loadAsync(url, onProgress) {\n\t\t\tvar scope = this;\n\t\t\treturn new Promise(function (resolve, reject) {\n\t\t\t\tscope.load(url, resolve, onProgress, reject);\n\t\t\t});\n\t\t},\n\t\tparse: function parse()\n\t\t/* data */\n\t\t{},\n\t\tsetCrossOrigin: function setCrossOrigin(crossOrigin) {\n\t\t\tthis.crossOrigin = crossOrigin;\n\t\t\treturn this;\n\t\t},\n\t\tsetWithCredentials: function setWithCredentials(value) {\n\t\t\tthis.withCredentials = value;\n\t\t\treturn this;\n\t\t},\n\t\tsetPath: function setPath(path) {\n\t\t\tthis.path = path;\n\t\t\treturn this;\n\t\t},\n\t\tsetResourcePath: function setResourcePath(resourcePath) {\n\t\t\tthis.resourcePath = resourcePath;\n\t\t\treturn this;\n\t\t},\n\t\tsetRequestHeader: function setRequestHeader(requestHeader) {\n\t\t\tthis.requestHeader = requestHeader;\n\t\t\treturn this;\n\t\t}\n\t});\n\n\tvar loading = {};\n\n\tfunction FileLoader(manager) {\n\t\tLoader.call(this, manager);\n\t}\n\n\tFileLoader.prototype = Object.assign(Object.create(Loader.prototype), {\n\t\tconstructor: FileLoader,\n\t\tload: function load(url, onLoad, onProgress, onError) {\n\t\t\tif (url === undefined) url = '';\n\t\t\tif (this.path !== undefined) url = this.path + url;\n\t\t\turl = this.manager.resolveURL(url);\n\t\t\tvar scope = this;\n\t\t\tvar cached = Cache.get(url);\n\n\t\t\tif (cached !== undefined) {\n\t\t\t\tscope.manager.itemStart(url);\n\t\t\t\tsetTimeout(function () {\n\t\t\t\t\tif (onLoad) onLoad(cached);\n\t\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t\t}, 0);\n\t\t\t\treturn cached;\n\t\t\t} // Check if request is duplicate\n\n\n\t\t\tif (loading[url] !== undefined) {\n\t\t\t\tloading[url].push({\n\t\t\t\t\tonLoad: onLoad,\n\t\t\t\t\tonProgress: onProgress,\n\t\t\t\t\tonError: onError\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t} // Check for data: URI\n\n\n\t\t\tvar dataUriRegex = /^data:(.*?)(;base64)?,(.*)$/;\n\t\t\tvar dataUriRegexResult = url.match(dataUriRegex);\n\t\t\tvar request; // Safari can not handle Data URIs through XMLHttpRequest so process manually\n\n\t\t\tif (dataUriRegexResult) {\n\t\t\t\tvar mimeType = dataUriRegexResult[1];\n\t\t\t\tvar isBase64 = !!dataUriRegexResult[2];\n\t\t\t\tvar data = dataUriRegexResult[3];\n\t\t\t\tdata = decodeURIComponent(data);\n\t\t\t\tif (isBase64) data = atob(data);\n\n\t\t\t\ttry {\n\t\t\t\t\tvar response;\n\t\t\t\t\tvar responseType = (this.responseType || '').toLowerCase();\n\n\t\t\t\t\tswitch (responseType) {\n\t\t\t\t\t\tcase 'arraybuffer':\n\t\t\t\t\t\tcase 'blob':\n\t\t\t\t\t\t\tvar view = new Uint8Array(data.length);\n\n\t\t\t\t\t\t\tfor (var i = 0; i < data.length; i++) {\n\t\t\t\t\t\t\t\tview[i] = data.charCodeAt(i);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (responseType === 'blob') {\n\t\t\t\t\t\t\t\tresponse = new Blob([view.buffer], {\n\t\t\t\t\t\t\t\t\ttype: mimeType\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tresponse = view.buffer;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'document':\n\t\t\t\t\t\t\tvar parser = new DOMParser();\n\t\t\t\t\t\t\tresponse = parser.parseFromString(data, mimeType);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'json':\n\t\t\t\t\t\t\tresponse = JSON.parse(data);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t// 'text' or other\n\t\t\t\t\t\t\tresponse = data;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t} // Wait for next browser tick like standard XMLHttpRequest event dispatching does\n\n\n\t\t\t\t\tsetTimeout(function () {\n\t\t\t\t\t\tif (onLoad) onLoad(response);\n\t\t\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t\t\t}, 0);\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// Wait for next browser tick like standard XMLHttpRequest event dispatching does\n\t\t\t\t\tsetTimeout(function () {\n\t\t\t\t\t\tif (onError) onError(error);\n\t\t\t\t\t\tscope.manager.itemError(url);\n\t\t\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t\t\t}, 0);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Initialise array for duplicate requests\n\t\t\t\tloading[url] = [];\n\t\t\t\tloading[url].push({\n\t\t\t\t\tonLoad: onLoad,\n\t\t\t\t\tonProgress: onProgress,\n\t\t\t\t\tonError: onError\n\t\t\t\t});\n\t\t\t\trequest = new XMLHttpRequest();\n\t\t\t\trequest.open('GET', url, true);\n\t\t\t\trequest.addEventListener('load', function (event) {\n\t\t\t\t\tvar response = this.response;\n\t\t\t\t\tvar callbacks = loading[url];\n\t\t\t\t\tdelete loading[url];\n\n\t\t\t\t\tif (this.status === 200 || this.status === 0) {\n\t\t\t\t\t\t// Some browsers return HTTP Status 0 when using non-http protocol\n\t\t\t\t\t\t// e.g. 'file://' or 'data://'. Handle as success.\n\t\t\t\t\t\tif (this.status === 0) console.warn('THREE.FileLoader: HTTP Status 0 received.'); // Add to cache only on HTTP success, so that we do not cache\n\t\t\t\t\t\t// error response bodies as proper responses to requests.\n\n\t\t\t\t\t\tCache.add(url, response);\n\n\t\t\t\t\t\tfor (var _i = 0, il = callbacks.length; _i < il;
1 _i++) {\n\t\t\t\t\t\t\tvar callback = callbacks[_i];\n\t\t\t\t\t\t\tif (callback.onLoad) callback.onLoad(response);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfor (var _i2 = 0, _il = callbacks.length; _i2 < _il; _i2++) {\n\t\t\t\t\t\t\tvar _callback = callbacks[_i2];\n\t\t\t\t\t\t\tif (_callback.onError) _callback.onError(event);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tscope.manager.itemError(url);\n\t\t\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t\t\t}\n\t\t\t\t}, false);\n\t\t\t\trequest.addEventListener('progress', function (event) {\n\t\t\t\t\tvar callbacks = loading[url];\n\n\t\t\t\t\tfor (var _i3 = 0, il = callbacks.length; _i3 < il; _i3++) {\n\t\t\t\t\t\tvar callback = callbacks[_i3];\n\t\t\t\t\t\tif (callback.onProgress) callback.onProgress(event);\n\t\t\t\t\t}\n\t\t\t\t}, false);\n\t\t\t\trequest.addEventListener('error', function (event) {\n\t\t\t\t\tvar callbacks = loading[url];\n\t\t\t\t\tdelete loading[url];\n\n\t\t\t\t\tfor (var _i4 = 0, il = callbacks.length; _i4 < il; _i4++) {\n\t\t\t\t\t\tvar callback = callbacks[_i4];\n\t\t\t\t\t\tif (callback.onError) callback.onError(event);\n\t\t\t\t\t}\n\n\t\t\t\t\tscope.manager.itemError(url);\n\t\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t\t}, false);\n\t\t\t\trequest.addEventListener('abort', function (event) {\n\t\t\t\t\tvar callbacks = loading[url];\n\t\t\t\t\tdelete loading[url];\n\n\t\t\t\t\tfor (var _i5 = 0, il = callbacks.length; _i5 < il; _i5++) {\n\t\t\t\t\t\tvar callback = callbacks[_i5];\n\t\t\t\t\t\tif (callback.onError) callback.onError(event);\n\t\t\t\t\t}\n\n\t\t\t\t\tscope.manager.itemError(url);\n\t\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t\t}, false);\n\t\t\t\tif (this.responseType !== undefined) request.responseType = this.responseType;\n\t\t\t\tif (this.withCredentials !== undefined) request.withCredentials = this.withCredentials;\n\t\t\t\tif (request.overrideMimeType) request.overrideMimeType(this.mimeType !== undefined ? this.mimeType : 'text/plain');\n\n\t\t\t\tfor (var header in this.requestHeader) {\n\t\t\t\t\trequest.setRequestHeader(header, this.requestHeader[header]);\n\t\t\t\t}\n\n\t\t\t\trequest.send(null);\n\t\t\t}\n\n\t\t\tscope.manager.itemStart(url);\n\t\t\treturn request;\n\t\t},\n\t\tsetResponseType: function setResponseType(value) {\n\t\t\tthis.responseType = value;\n\t\t\treturn this;\n\t\t},\n\t\tsetMimeType: function setMimeType(value) {\n\t\t\tthis.mimeType = value;\n\t\t\treturn this;\n\t\t}\n\t});\n\n\tfunction AnimationLoader(manager) {\n\t\tLoader.call(this, manager);\n\t}\n\n\tAnimationLoader.prototype = Object.assign(Object.create(Loader.prototype), {\n\t\tconstructor: AnimationLoader,\n\t\tload: function load(url, onLoad, onProgress, onError) {\n\t\t\tvar scope = this;\n\t\t\tvar loader = new FileLoader(scope.manager);\n\t\t\tloader.setPath(scope.path);\n\t\t\tloader.setRequestHeader(scope.requestHeader);\n\t\t\tloader.setWithCredentials(scope.withCredentials);\n\t\t\tloader.load(url, function (text) {\n\t\t\t\ttry {\n\t\t\t\t\tonLoad(scope.parse(JSON.parse(text)));\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (onError) {\n\t\t\t\t\t\tonError(e);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error(e);\n\t\t\t\t\t}\n\n\t\t\t\t\tscope.manager.itemError(url);\n\t\t\t\t}\n\t\t\t}, onProgress, onError);\n\t\t},\n\t\tparse: function parse(json) {\n\t\t\tvar animations = [];\n\n\t\t\tfor (var i = 0; i < json.length; i++) {\n\t\t\t\tvar clip = AnimationClip.parse(json[i]);\n\t\t\t\tanimations.push(clip);\n\t\t\t}\n\n\t\t\treturn animations;\n\t\t}\n\t});\n\n\t/**\n\t * Abstract Base class to block based textures loader (dds, pvr, ...)\n\t *\n\t * Sub classes have to implement the parse() method which will be used in load().\n\t */\n\n\tfunction CompressedTextureLoader(manager) {\n\t\tLoader.call(this, manager);\n\t}\n\n\tCompressedTextureLoader.prototype = Object.assign(Object.create(Loader.prototype), {\n\t\tconstructor: CompressedTextureLoader,\n\t\tload: function load(url, onLoad, onProgress, onError) {\n\t\t\tvar scope = this;\n\t\t\tvar images = [];\n\t\t\tvar texture = new CompressedTexture();\n\t\t\tvar loader = new FileLoader(this.manager);\n\t\t\tloader.setPath(this.path);\n\t\t\tloader.setResponseType('arraybuffer');\n\t\t\tloader.setRequestHeader(this.requestHeader);\n\t\t\tloader.setWithCredentials(scope.withCredentials);\n\t\t\tvar loaded = 0;\n\n\t\t\tfunction loadTexture(i) {\n\t\t\t\tloader.load(url[i], function (buffer) {\n\t\t\t\t\tvar texDatas = scope.parse(buffer, true);\n\t\t\t\t\timages[i] = {\n\t\t\t\t\t\twidth: texDatas.width,\n\t\t\t\t\t\theight: texDatas.height,\n\t\t\t\t\t\tformat: texDatas.format,\n\t\t\t\t\t\tmipmaps: texDatas.mipmaps\n\t\t\t\t\t};\n\t\t\t\t\tloaded += 1;\n\n\t\t\t\t\tif (loaded === 6) {\n\t\t\t\t\t\tif (texDatas.mipmapCount === 1) texture.minFilter = LinearFilter;\n\t\t\t\t\t\ttexture.image = images;\n\t\t\t\t\t\ttexture.format = texDatas.format;\n\t\t\t\t\t\ttexture.needsUpdate = true;\n\t\t\t\t\t\tif (onLoad) onLoad(texture);\n\t\t\t\t\t}\n\t\t\t\t}, onProgress, onError);\n\t\t\t}
1\n\n\t\t\tif (Array.isArray(url)) {\n\t\t\t\tfor (var i = 0, il = url.length; i < il; ++i) {\n\t\t\t\t\tloadTexture(i);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// compressed cubemap texture stored in a single DDS file\n\t\t\t\tloader.load(url, function (buffer) {\n\t\t\t\t\tvar texDatas = scope.parse(buffer, true);\n\n\t\t\t\t\tif (texDatas.isCubemap) {\n\t\t\t\t\t\tvar faces = texDatas.mipmaps.length / texDatas.mipmapCount;\n\n\t\t\t\t\t\tfor (var f = 0; f < faces; f++) {\n\t\t\t\t\t\t\timages[f] = {\n\t\t\t\t\t\t\t\tmipmaps: []\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\tfor (var _i = 0; _i < texDatas.mipmapCount; _i++) {\n\t\t\t\t\t\t\t\timages[f].mipmaps.push(texDatas.mipmaps[f * texDatas.mipmapCount + _i]);\n\t\t\t\t\t\t\t\timages[f].format = texDatas.format;\n\t\t\t\t\t\t\t\timages[f].width = texDatas.width;\n\t\t\t\t\t\t\t\timages[f].height = texDatas.height;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttexture.image = images;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttexture.image.width = texDatas.width;\n\t\t\t\t\t\ttexture.image.height = texDatas.height;\n\t\t\t\t\t\ttexture.mipmaps = texDatas.mipmaps;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (texDatas.mipmapCount === 1) {\n\t\t\t\t\t\ttexture.minFilter = LinearFilter;\n\t\t\t\t\t}\n\n\t\t\t\t\ttexture.format = texDatas.format;\n\t\t\t\t\ttexture.needsUpdate = true;\n\t\t\t\t\tif (onLoad) onLoad(texture);\n\t\t\t\t}, onProgress, onError);\n\t\t\t}\n\n\t\t\treturn texture;\n\t\t}\n\t});\n\n\tfunction ImageLoader(manager) {\n\t\tLoader.call(this, manager);\n\t}\n\n\tImageLoader.prototype = Object.assign(Object.create(Loader.prototype), {\n\t\tconstructor: ImageLoader,\n\t\tload: function load(url, onLoad, onProgress, onError) {\n\t\t\tif (this.path !== undefined) url = this.path + url;\n\t\t\turl = this.manager.resolveURL(url);\n\t\t\tvar scope = this;\n\t\t\tvar cached = Cache.get(url);\n\n\t\t\tif (cached !== undefined) {\n\t\t\t\tscope.manager.itemStart(url);\n\t\t\t\tsetTimeout(function () {\n\t\t\t\t\tif (onLoad) onLoad(cached);\n\t\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t\t}, 0);\n\t\t\t\treturn cached;\n\t\t\t}\n\n\t\t\tvar image = document.createElementNS('http://www.w3.org/1999/xhtml', 'img');\n\n\t\t\tfunction onImageLoad() {\n\t\t\t\timage.removeEventListener('load', onImageLoad, false);\n\t\t\t\timage.removeEventListener('error', onImageError, false);\n\t\t\t\tCache.add(url, this);\n\t\t\t\tif (onLoad) onLoad(this);\n\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t}\n\n\t\t\tfunction onImageError(event) {\n\t\t\t\timage.removeEventListener('load', onImageLoad, false);\n\t\t\t\timage.removeEventListener('error', onImageError, false);\n\t\t\t\tif (onError) onError(event);\n\t\t\t\tscope.manager.itemError(url);\n\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t}\n\n\t\t\timage.addEventListener('load', onImageLoad, false);\n\t\t\timage.addEventListener('error', onImageError, false);\n\n\t\t\tif (url.substr(0, 5) !== 'data:') {\n\t\t\t\tif (this.crossOrigin !== undefined) image.crossOrigin = this.crossOrigin;\n\t\t\t}\n\n\t\t\tscope.manager.itemStart(url);\n\t\t\timage.src = url;\n\t\t\treturn image;\n\t\t}\n\t});\n\n\tfunction CubeTextureLoader(manager) {\n\t\tLoader.call(this, manager);\n\t}\n\n\tCubeTextureLoader.prototype = Object.assign(Object.create(Loader.prototype), {\n\t\tconstructor: CubeTextureLoader,\n\t\tload: function load(urls, onLoad, onProgress, onError) {\n\t\t\tvar texture = new CubeTexture();\n\t\t\tvar loader = new ImageLoader(this.manager);\n\t\t\tloader.setCrossOrigin(this.crossOrigin);\n\t\t\tloader.setPath(this.path);\n\t\t\tvar loaded = 0;\n\n\t\t\tfunction loadTexture(i) {\n\t\t\t\tloader.load(urls[i], function (image) {\n\t\t\t\t\ttexture.images[i] = image;\n\t\t\t\t\tloaded++;\n\n\t\t\t\t\tif (loaded === 6) {\n\t\t\t\t\t\ttexture.needsUpdate = true;\n\t\t\t\t\t\tif (onLoad) onLoad(texture);\n\t\t\t\t\t}\n\t\t\t\t}, undefined, onError);\n\t\t\t}\n\n\t\t\tfor (var i = 0; i < urls.length; ++i) {\n\t\t\t\tloadTexture(i);\n\t\t\t}\n\n\t\t\treturn texture;\n\t\t}\n\t});\n\n\t/**\n\t * Abstract Base class to load generic binary textures formats (rgbe, hdr, ...)\n\t *\n\t * Sub classes have to implement the parse() method which will be used in load().\n\t */\n\n\tfunction DataTextureLoader(manager) {\n\t\tLoa
1der.call(this, manager);\n\t}\n\n\tDataTextureLoader.prototype = Object.assign(Object.create(Loader.prototype), {\n\t\tconstructor: DataTextureLoader,\n\t\tload: function load(url, onLoad, onProgress, onError) {\n\t\t\tvar scope = this;\n\t\t\tvar texture = new DataTexture();\n\t\t\tvar loader = new FileLoader(this.manager);\n\t\t\tloader.setResponseType('arraybuffer');\n\t\t\tloader.setRequestHeader(this.requestHeader);\n\t\t\tloader.setPath(this.path);\n\t\t\tloader.setWithCredentials(scope.withCredentials);\n\t\t\tloader.load(url, function (buffer) {\n\t\t\t\tvar texData = scope.parse(buffer);\n\t\t\t\tif (!texData) return;\n\n\t\t\t\tif (texData.image !== undefined) {\n\t\t\t\t\ttexture.image = texData.image;\n\t\t\t\t} else if (texData.data !== undefined) {\n\t\t\t\t\ttexture.image.width = texData.width;\n\t\t\t\t\ttexture.image.height = texData.height;\n\t\t\t\t\ttexture.image.data = texData.data;\n\t\t\t\t}\n\n\t\t\t\ttexture.wrapS = texData.wrapS !== undefined ? texData.wrapS : ClampToEdgeWrapping;\n\t\t\t\ttexture.wrapT = texData.wrapT !== undefined ? texData.wrapT : ClampToEdgeWrapping;\n\t\t\t\ttexture.magFilter = texData.magFilter !== undefined ? texData.magFilter : LinearFilter;\n\t\t\t\ttexture.minFilter = texData.minFilter !== undefined ? texData.minFilter : LinearFilter;\n\t\t\t\ttexture.anisotropy = texData.anisotropy !== undefined ? texData.anisotropy : 1;\n\n\t\t\t\tif (texData.format !== undefined) {\n\t\t\t\t\ttexture.format = texData.format;\n\t\t\t\t}\n\n\t\t\t\tif (texData.type !== undefined) {\n\t\t\t\t\ttexture.type = texData.type;\n\t\t\t\t}\n\n\t\t\t\tif (texData.mipmaps !== undefined) {\n\t\t\t\t\ttexture.mipmaps = texData.mipmaps;\n\t\t\t\t\ttexture.minFilter = LinearMipmapLinearFilter; // presumably...\n\t\t\t\t}\n\n\t\t\t\tif (texData.mipmapCount === 1) {\n\t\t\t\t\ttexture.minFilter = LinearFilter;\n\t\t\t\t}\n\n\t\t\t\ttexture.needsUpdate = true;\n\t\t\t\tif (onLoad) onLoad(texture, texData);\n\t\t\t}, onProgress, onError);\n\t\t\treturn texture;\n\t\t}\n\t});\n\n\tfunction TextureLoader(manager) {\n\t\tLoader.call(this, manager);\n\t}\n\n\tTextureLoader.prototype = Object.assign(Object.create(Loader.prototype), {\n\t\tconstructor: TextureLoader,\n\t\tload: function load(url, onLoad, onProgress, onError) {\n\t\t\tvar texture = new Texture();\n\t\t\tvar loader = new ImageLoader(this.manager);\n\t\t\tloader.setCrossOrigin(this.crossOrigin);\n\t\t\tloader.setPath(this.path);\n\t\t\tloader.load(url, function (image) {\n\t\t\t\ttexture.image = image; // JPEGs can't have an alpha channel, so memory can be saved by storing them as RGB.\n\n\t\t\t\tvar isJPEG = url.search(/\\.jpe?g($|\\?)/i) > 0 || url.search(/^data\\:image\\/jpeg/) === 0;\n\t\t\t\ttexture.format = isJPEG ? RGBFormat : RGBAFormat;\n\t\t\t\ttexture.needsUpdate = true;\n\n\t\t\t\tif (onLoad !== undefined) {\n\t\t\t\t\tonLoad(texture);\n\t\t\t\t}\n\t\t\t}, onProgress, onError);\n\t\t\treturn texture;\n\t\t}\n\t});\n\n\t/**\n\t * Extensible curve object.\n\t *\n\t * Some common of curve methods:\n\t * .getPoint( t, optionalTarget ), .getTangent( t, optionalTarget )\n\t * .getPointAt( u, optionalTarget ), .getTangentAt( u, optionalTarget )\n\t * .getPoints(), .getSpacedPoints()\n\t * .getLength()\n\t * .updateArcLengths()\n\t *\n\t * This following curves inherit from THREE.Curve:\n\t *\n\t * -- 2D curves --\n\t * THREE.ArcCurve\n\t * THREE.CubicBezierCurve\n\t * THREE.EllipseCurve\n\t * THREE.LineCurve\n\t * THREE.QuadraticBezierCurve\n\t * THREE.SplineCurve\n\t *\n\t * -- 3D curves --\n\t * THREE.C
1atmullRomCurve3\n\t * THREE.CubicBezierCurve3\n\t * THREE.LineCurve3\n\t * THREE.QuadraticBezierCurve3\n\t *\n\t * A series of curves can be represented as a THREE.CurvePath.\n\t *\n\t **/\n\n\tfunction Curve() {\n\t\tthis.type = 'Curve';\n\t\tthis.arcLengthDivisions = 200;\n\t}\n\n\tObject.assign(Curve.prototype, {\n\t\t// Virtual base class method to overwrite and implement in subclasses\n\t\t//\t- t [0 .. 1]\n\t\tgetPoint: function getPoint()\n\t\t/* t, optionalTarget */\n\t\t{\n\t\t\tconsole.warn('THREE.Curve: .getPoint() not implemented.');\n\t\t\treturn null;\n\t\t},\n\t\t// Get point at relative position in curve according to arc length\n\t\t// - u [0 .. 1]\n\t\tgetPointAt: function getPointAt(u, optionalTarget) {\n\t\t\tvar t = this.getUtoTmapping(u);\n\t\t\treturn this.getPoint(t, optionalTarget);\n\t\t},\n\t\t// Get sequence of points using getPoint( t )\n\t\tgetPoints: function getPoints(divisions) {\n\t\t\tif (divisions === void 0) {\n\t\t\t\tdivisions = 5;\n\t\t\t}\n\n\t\t\tvar points = [];\n\n\t\t\tfor (var d = 0; d <= divisions; d++) {\n\t\t\t\tpoints.push(this.getPoint(d / divisions));\n\t\t\t}\n\n\t\t\treturn points;\n\t\t},\n\t\t// Get sequence of points using getPointAt( u )\n\t\tgetSpacedPoints: function getSpacedPoints(divisions) {\n\t\t\tif (divisions === void 0) {\n\t\t\t\tdivisions = 5;\n\t\t\t}\n\n\t\t\tvar points = [];\n\n\t\t\tfor (var d = 0; d <= divisions; d++) {\n\t\t\t\tpoints.push(this.getPointAt(d / divisions));\n\t\t\t}\n\n\t\t\treturn points;\n\t\t},\n\t\t// Get total curve arc length\n\t\tgetLength: function getLength() {\n\t\t\tvar lengths = this.getLengths();\n\t\t\treturn lengths[lengths.length - 1];\n\t\t},\n\t\t// Get list of cumulative segment lengths\n\t\tgetLengths: function getLengths(divisions) {\n\t\t\tif (divisions === undefined) divisions = this.arcLengthDivisions;\n\n\t\t\tif (this.cacheArcLengths && this.cacheArcLengths.length === divisions + 1 && !this.needsUpdate) {\n\t\t\t\treturn this.cacheArcLengths;\n\t\t\t}\n\n\t\t\tthis.needsUpdate = false;\n\t\t\tvar cache = [];\n\t\t\tvar current,\n\t\t\t\t\tlast = this.getPoint(0);\n\t\t\tvar sum = 0;\n\t\t\tcache.push(0);\n\n\t\t\tfor (var p = 1; p <= divisions; p++) {\n\t\t\t\tcurrent = this.getPoint(p / divisions);\n\t\t\t\tsum += current.distanceTo(last);\n\t\t\t\tcache.push(sum);\n\t\t\t\tlast = current;\n\t\t\t}\n\n\t\t\tthis.cacheArcLengths = cache;\n\t\t\treturn cache; // { sums: cache, sum: sum }; Sum is in the last element.\n\t\t},\n\t\tupdateArcLengths: function updateArcLengths() {\n\t\t\tthis.needsUpdate = true;\n\t\t\tthis.getLengths();\n\t\t},\n\t\t// Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant\n\t\tgetUtoTmapping: function getUtoTmapping(u, distance) {\n\t\t\tvar arcLengths = this.getLengths();\n\t\t\tvar i = 0;\n\t\t\tvar il = arcLengths.length;\n\t\t\tvar targetArcLength; // The targeted u distance value to get\n\n\t\t\tif (distance) {\n\t\t\t\ttargetArcLength = distance;\n\t\t\t} else {\n\t\t\t\ttargetArcLength = u * arcLengths[il - 1];\n\t\t\t} // binary search for the index with largest value smaller than target u distance\n\n\n\t\t\tvar low = 0,\n\t\t\t\t\thigh = il - 1,\n\t\t\t\t\tcomparison;\n\n\t\t\twhile (low <= high) {\n\t\t\t\ti = Math.floor(low + (high - low) / 2); // less likely to overflow, though probably not issue here, JS doesn't really have integers, all numbers are floats\n\n\t\t\t\tcomparison = arcLengths[i] - targetArcLength;\n\n\t\t\t\tif (comparison < 0) {\n\t\t\t\t\tlow = i + 1;\n\t\t\t\t} else if (comparison > 0) {\n\t\t\t\t\thigh = i - 1;\n\t\t\t\t} else {\n\t\t\t\t\thigh = i;\n\t\t\t\t\tbreak; // DONE\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ti = high;\n\n\t\t\tif (arcLengths[i] === targetArcLength) {\n\t\t\t\treturn i / (il - 1);\n\t\t\t} // we could get finer grain at lengths, or use simple interpolation between two points\n\n\n\t\t\tvar lengthBefore = arcLengths[i];\n\t\t\tvar lengthAfter = arcLengths[i + 1];\n\t\t\tvar segmentLength = lengthAfter - lengthBefore; // determine where we are between the 'before' and 'after' points\n\n\t\t\tvar segmentFraction = (targetArcLength - lengthBefore) /
1segmentLength; // add that fractional amount to t\n\n\t\t\tvar t = (i + segmentFraction) / (il - 1);\n\t\t\treturn t;\n\t\t},\n\t\t// Returns a unit vector tangent at t\n\t\t// In case any sub curve does not implement its tangent derivation,\n\t\t// 2 points a small delta apart will be used to find its gradient\n\t\t// which seems to give a reasonable approximation\n\t\tgetTangent: function getTangent(t, optionalTarget) {\n\t\t\tvar delta = 0.0001;\n\t\t\tvar t1 = t - delta;\n\t\t\tvar t2 = t + delta; // Capping in case of danger\n\n\t\t\tif (t1 < 0) t1 = 0;\n\t\t\tif (t2 > 1) t2 = 1;\n\t\t\tvar pt1 = this.getPoint(t1);\n\t\t\tvar pt2 = this.getPoint(t2);\n\t\t\tvar tangent = optionalTarget || (pt1.isVector2 ? new Vector2() : new Vector3());\n\t\t\ttangent.copy(pt2).sub(pt1).normalize();\n\t\t\treturn tangent;\n\t\t},\n\t\tgetTangentAt: function getTangentAt(u, optionalTarget) {\n\t\t\tvar t = this.getUtoTmapping(u);\n\t\t\treturn this.getTangent(t, optionalTarget);\n\t\t},\n\t\tcomputeFrenetFrames: function computeFrenetFrames(segments, closed) {\n\t\t\t// see http://www.cs.indiana.edu/pub/techreports/TR425.pdf\n\t\t\tvar normal = new Vector3();\n\t\t\tvar tangents = [];\n\t\t\tvar normals = [];\n\t\t\tvar binormals = [];\n\t\t\tvar vec = new Vector3();\n\t\t\tvar mat = new Matrix4(); // compute the tangent vectors for each segment on the curve\n\n\t\t\tfor (var i = 0; i <= segments; i++) {\n\t\t\t\tvar u = i / segments;\n\t\t\t\ttangents[i] = this.getTangentAt(u, new Vector3());\n\t\t\t\ttangents[i].normalize();\n\t\t\t} // select an initial normal vector perpendicular to the first tangent vector,\n\t\t\t// and in the direction of the minimum tangent xyz component\n\n\n\t\t\tnormals[0] = new Vector3();\n\t\t\tbinormals[0] = new Vector3();\n\t\t\tvar min = Number.MAX_VALUE;\n\t\t\tvar tx = Math.abs(tangents[0].x);\n\t\t\tvar ty = Math.abs(tangents[0].y);\n\t\t\tvar tz = Math.abs(tangents[0].z);\n\n\t\t\tif (tx <= min) {\n\t\t\t\tmin = tx;\n\t\t\t\tnormal.set(1, 0, 0);\n\t\t\t}\n\n\t\t\tif (ty <= min) {\n\t\t\t\tmin = ty;\n\t\t\t\tnormal.set(0, 1, 0);\n\t\t\t}\n\n\t\t\tif (tz <= min) {\n\t\t\t\tnormal.set(0, 0, 1);\n\t\t\t}\n\n\t\t\tvec.crossVectors(tangents[0], normal).normalize();\n\t\t\tnormals[0].crossVectors(tangents[0], vec);\n\t\t\tbinormals[0].crossVectors(tangents[0], normals[0]); // compute the slowly-varying normal and binormal vectors for each segment on the curve\n\n\t\t\tfor (var _i = 1; _i <= segments; _i++) {\n\t\t\t\tnormals[_i] = normals[_i - 1].clone();\n\t\t\t\tbinormals[_i] = binormals[_i - 1].clone();\n\t\t\t\tvec.crossVectors(tangents[_i - 1], tangents[_i]);\n\n\t\t\t\tif (vec.length() > Number.EPSILON) {\n\t\t\t\t\tvec.normalize();\n\t\t\t\t\tvar theta = Math.acos(MathUtils.clamp(tangents[_i - 1].dot(tangents[_i]), -1, 1)); // clamp for floating pt errors\n\n\t\t\t\t\tnormals[_i].applyMatrix4(mat.makeRotationAxis(vec, theta));\n\t\t\t\t}\n\n\t\t\t\tbinormals[_i].crossVectors(tangents[_i], normals[_i]);\n\t\t\t} // if the curve is closed, postprocess the vectors so the first and last normal vectors are the same\n\n\n\t\t\tif (closed === true) {\n\t\t\t\tvar _theta = Math.acos(MathUtils.clamp(normals[0].dot(normals[segments]), -1, 1));\n\n\t\t\t\t_theta /= segments;\n\n\t\t\t\tif (tangents[0].dot(vec.crossVectors(normals[0], normals[segments])) > 0) {\n\t\t\t\t\t_theta = -_theta;\n\t\t\t\t}\n\n\t\t\t\tfor (var _i2 = 1; _i2 <= segments; _i2++) {\n\t\t\t\t\t// twist a little...\n\t\t\t\t\tnormals[_i2].applyMatrix4(mat.makeRotationAxis(tangents[_i2], _theta * _i2));\n\n\t\t\t\t\tbinormals[_i2].crossVectors(tangents[_i2], normals[_i2]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttangents: tangents,\n\t\t\t\tnormals: normals,\n\t\t\t\tbinormals: binormals\n\t\t\t};\n\t\t},\n\t\tclone: function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t},\n\t\tcopy: function copy(source) {\n\t\t\tthis.arcLengthDivisions = source.arcLengthDivisions;\n\t\t\treturn this;\n\t\t},\n\t\ttoJSON: function toJSON() {\n\t\t\tvar data = {\n\t\t\t\tmetadata: {\n\t\t\t\t\tversion: 4.5,\n\t\t\t\t\ttype: 'Curve',\n\t\t\t\t\tgenerator: 'Curve.toJSON'\n\t\t\t\t}\n\t\t\t};\n\t\t\tdata.arcLengthDivisions = this.arcLengthDivisions;\n\t\t\tdata.type = this.type;\n\t\t\treturn data;\n\t\t},\n\t\tfromJSON: function fromJSON(json) {\n\t\t\tthis.arcLengthDivisions = json.arcLengthDivisions;\n\t\t\treturn this;\n\t\t}\n\t});\n\n\tfunction EllipseCurve(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation) {\n\t\tCurve.call(this);\n\t\tthis.type = 'EllipseCurve';\n\t\tthis.aX = aX || 0;\n\t\tthis.aY = aY || 0;\n\t\tthis.xRadius = xRadius || 1;\n\t\tthis.yRadius = yRadius || 1;\n\t\tthis.aStartAngle = aStartAngle || 0;\n\t\tthis.aEndAngle = aEndAngle || 2 * Math.PI;\n\t\tthis.aClockwise = aClockwise || false;\n\t\tthis.aRotation = aRotation || 0;\n\t}\n\n\tEllipseCurve.prototype = Object.create(Curve.prototype);\n\tEllipseCurve.prototype.constructor = EllipseCurve;\n\tEllipseCurve.prototype.isEllipseCurve = true;\n\n\tEllipseCurve.prototype.getPoint = function (t, optionalTarget) {\n\t\tvar point = optionalTarget || new Vector2();
1\n\t\tvar twoPi = Math.PI * 2;\n\t\tvar deltaAngle = this.aEndAngle - this.aStartAngle;\n\t\tvar samePoints = Math.abs(deltaAngle) < Number.EPSILON; // ensures that deltaAngle is 0 .. 2 PI\n\n\t\twhile (deltaAngle < 0) {\n\t\t\tdeltaAngle += twoPi;\n\t\t}\n\n\t\twhile (deltaAngle > twoPi) {\n\t\t\tdeltaAngle -= twoPi;\n\t\t}\n\n\t\tif (deltaAngle < Number.EPSILON) {\n\t\t\tif (samePoints) {\n\t\t\t\tdeltaAngle = 0;\n\t\t\t} else {\n\t\t\t\tdeltaAngle = twoPi;\n\t\t\t}\n\t\t}\n\n\t\tif (this.aClockwise === true && !samePoints) {\n\t\t\tif (deltaAngle === twoPi) {\n\t\t\t\tdeltaAngle = -twoPi;\n\t\t\t} else {\n\t\t\t\tdeltaAngle = deltaAngle - twoPi;\n\t\t\t}\n\t\t}\n\n\t\tvar angle = this.aStartAngle + t * deltaAngle;\n\t\tvar x = this.aX + this.xRadius * Math.cos(angle);\n\t\tvar y = this.aY + this.yRadius * Math.sin(angle);\n\n\t\tif (this.aRotation !== 0) {\n\t\t\tvar cos = Math.cos(this.aRotation);\n\t\t\tvar sin = Math.sin(this.aRotation);\n\t\t\tvar tx = x - this.aX;\n\t\t\tvar ty = y - this.aY; // Rotate the point about the center of the ellipse.\n\n\t\t\tx = tx * cos - ty * sin + this.aX;\n\t\t\ty = tx * sin + ty * cos + this.aY;\n\t\t}\n\n\t\treturn point.set(x, y);\n\t};\n\n\tEllipseCurve.prototype.copy = function (source) {\n\t\tCurve.prototype.copy.call(this, source);\n\t\tthis.aX = source.aX;\n\t\tthis.aY = source.aY;\n\t\tthis.xRadius = source.xRadius;\n\t\tthis.yRadius = source.yRadius;
1\n\t\tthis.aStartAngle = source.aStartAngle;\n\t\tthis.aEndAngle = source.aEndAngle;\n\t\tthis.aClockwise = source.aClockwise;\n\t\tthis.aRotation = source.aRotation;\n\t\treturn this;\n\t};\n\n\tEllipseCurve.prototype.toJSON = function () {\n\t\tvar data = Curve.prototype.toJSON.call(this);\n\t\tdata.aX = this.aX;\n\t\tdata.aY = this.aY;\n\t\tdata.xRadius = this.xRadius;\n\t\tdata.yRadius = this.yRadius;\n\t\tdata.aStartAngle = this.aStartAngle;\n\t\tdata.aEndAngle = this.aEndAngle;\n\t\tdata.aClockwise = this.aClockwise;\n\t\tdata.aRotation = this.aRotation;\n\t\treturn data;\n\t};\n\n\tEllipseCurve.prototype.fromJSON = function (json) {\n\t\tCurve.prototype.fromJSON.call(this, json);\n\t\tthis.aX = json.aX;\n\t\tthis.aY = json.aY;\n\t\tthis.xRadius = json.xRadius;\n\t\tthis.yRadius = json.yRadius;\n\t\tthis.aStartAngle = json.aStartAngle;\n\t\tthis.aEndAngle = json.aEndAngle;\n\t\tthis.aClockwise = json.aClockwise;\n\t\tthis.aRotation = json.aRotation;\n\t\treturn this;\n\t};\n\n\tfunction ArcCurve(aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) {\n\t\tEllipseCurve.call(this, aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise);\n\t\tthis.type = 'ArcCurve';\n\t}\n\n\tArcCurve.prototype = Object.create(EllipseCurve.prototype);\n\tArcCurve.prototype.constructor = ArcCurve;\n\tArcCurve.prototype.isArcCurve = true;\n\n\t/**\n\t * Centripetal CatmullRom Curve - which is useful for avoiding\n\t * cusps and self-intersections in non-uniform catmull rom curves.\n\t * http://www.cemyuksel.com/research/catmullrom_param/catmullrom.pdf\n\t *\n\t * curve.type accepts centripetal(default), chordal and catmullrom\n\t * curve.tension is used for catmullrom which defaults to 0.5\n\t */\n\n\t/*\n\tBased on an optimized c++ solution in\n\t - http://stackoverflow.com/questions/9489736/catmull-rom-curve-with-no-cusps-and-no-self-intersections/\n\t - http://ideone.com/NoEbVM\n\n\tThis CubicPoly class could be used for reusing some variables and calculations,\n\tbut for three.js curve use, it could be possible inlined and flatten into a single function call\n\twhich can be placed in CurveUtils.\n\t*/\n\n\tfunction CubicPoly() {\n\t\tvar c0 = 0,\n\t\t\t\tc1 = 0,\n\t\t\t\tc2 = 0,\n\t\t\t\tc3 = 0;\n\t\t/*\n\t\t * Compute coefficients for a cubic polynomial\n\t\t *\t p(s) = c0 + c1*s + c2*s^2 + c3*s^3\n\t\t * such that\n\t\t *\t p(0) = x0, p(1) = x1\n\t\t *\tand\n\t\t *\t p'(0) = t0, p'(1) = t1.\n\t\t */\n\n\t\tfunction init(x0, x1, t0, t1) {\n\t\t\tc0 = x0;\n\t\t\tc1 = t0;\n\t\t\tc2 = -3 * x0 + 3 * x1 - 2 * t0 - t1;\n\t\t\tc3 = 2 * x0 - 2 * x1 + t0 + t1;\n\t\t}\n\n\t\treturn {\n\t\t\tinitCatmullRom: function initCatmullRom(x0, x1, x2, x3, tension) {\n\t\t\t\tinit(x1, x2, tension * (x2 - x0), tension * (x3 - x1));\n\t\t\t},\n\t\t\tinitNonuniformCatmullRom: function initNonuniformCatmullRom(x0, x1, x2, x3, dt0, dt1, dt2) {\n\t\t\t\t// compute tangents when parameterized in [t1,t2]\n\t\t\t\tvar t1 = (x1 - x0) / dt0 - (x2 - x0) / (dt0 + dt1) + (x2 - x1) / dt1;\n\t\t\t\tvar t2 = (x2 - x1) / dt1 - (x3 - x1) / (dt1 + dt2) + (x3 - x2) / dt2; // rescale tangents for parametrization in [0,1]\n\n\t\t\t\tt1 *= dt1;\n\t\t\t\tt2 *= dt1;\n\t\t\t\tinit(x1, x2, t1, t2);\n\t\t\t},\n\t\t\tcalc: function calc(t) {\n\t\t\t\tvar t2 = t * t;\n\t\t\t\tvar t3 = t2 * t;\n\t\t\t\treturn c0 + c1 * t + c2 * t2 + c3 * t3;\n\t\t\t}\n\t\t};\n\t} //\n\n\n\tvar tmp = new Vector3();\n\tvar px = new CubicPoly(),\n\t\t\tpy = new CubicPoly(),\n\t\t\tpz = new CubicPoly();\n\n\tfunction CatmullRomCurve3(points, closed, curveType, tension) {\n\t\tif (points === void 0) {\n\t\t\tpoints = [];\n\t\t}\n\n\t\tif (closed === void 0) {\n\t\t\tclosed = false;\n\t\t}\n\n\t\tif (curveType === void 0) {\n\t\t\tcurveType = 'centripetal';\n\t\t}\n\n\t\tif (tension === void 0) {\n\t\t\ttension = 0.5;\n\t\t}\n\n\t\tCurve.call(this);\n\t\tthis.type = 'CatmullRomCurve3';\n\t\tthis.points = points;\n\t\tthis.closed = closed;\n\t\tthis.curveType = curveType;\n\t\tthis.tension = tension;\n\t}\n\n\tCatmullRomCurve3.prototype = Object.create(Curve.prototype);\n\tCatmullRomCurve3.prototype.constructor = CatmullRomCurve3;\n\tCatmullRomCurve3.prototype.isCatmullRomCurve3 = true;\n\n\tCatmullRomCurve3.prototype.getPoint = function (t, optionalTarget) {\n\t\tif (optionalTarget === void 0) {\n\t\t\toptionalTarget = new Vector3();\n\t\t}\n\n\t\tvar point = optionalTarget;\n\t\tvar points = this.points;\n\t\tvar l = points.length;
1\n\t\tvar p = (l - (this.closed ? 0 : 1)) * t;\n\t\tvar intPoint = Math.floor(p);\n\t\tvar weight = p - intPoint;\n\n\t\tif (this.closed) {\n\t\t\tintPoint += intPoint > 0 ? 0 : (Math.floor(Math.abs(intPoint) / l) + 1) * l;\n\t\t} else if (weight === 0 && intPoint === l - 1) {\n\t\t\tintPoint = l - 2;\n\t\t\tweight = 1;\n\t\t}\n\n\t\tvar p0, p3; // 4 points (p1 & p2 defined below)\n\n\t\tif (this.closed || intPoint > 0) {\n\t\t\tp0 = points[(intPoint - 1) % l];\n\t\t} else {\n\t\t\t// extrapolate first point\n\t\t\ttmp.subVectors(points[0], points[1]).add(points[0]);\n\t\t\tp0 = tmp;\n\t\t}\n\n\t\tvar p1 = points[intPoint % l];\n\t\tvar p2 = points[(intPoint + 1) % l];\n\n\t\tif (this.closed || intPoint + 2 < l) {\n\t\t\tp3 = points[(intPoint + 2) % l];\n\t\t} else {\n\t\t\t// extrapolate last point\n\t\t\ttmp.subVectors(points[l - 1], points[l - 2]).add(points[l - 1]);\n\t\t\tp3 = tmp;\n\t\t}\n\n\t\tif (this.curveType === 'centripetal' || this.curveType === 'chordal') {\n\t\t\t// init Centripetal / Chordal Catmull-Rom\n\t\t\tvar pow = this.curveType === 'chordal' ? 0.5 : 0.25;\n\t\t\tvar dt0 = Math.pow(p0.distanceToSquared(p1), pow);\n\t\t\tvar dt1 = Math.pow(p1.distanceToSquared(p2), pow);\n\t\t\tvar dt2 = Math.pow(p2.distanceToSquared(p3), pow); // safety check for repeated points\n\n\t\t\tif (dt1 < 1e-4) dt1 = 1.0;\n\t\t\tif (dt0 < 1e-4) dt0 = dt1;\n\t\t\tif (dt2 < 1e-4) dt2 = dt1;\n\t\t\tpx.initNonuniformCatmullRom(p0.x, p1.x, p2.x, p3.x, dt0, dt1, dt2);\n\t\t\tpy.initNonuniformCatmullRom(p0.y, p1.y, p2.y, p3.y, dt0, dt1, dt2);\n\t\t\tpz.initNonuniformCatmullRom(p0.z, p1.z, p2.z, p3.z, dt0, dt1, dt2);\n\t\t} else if (this.curveType === 'catmullrom') {\n\t\t\tpx.initCatmullRom(p0.x, p1.x, p2.x, p3.x, this.tension);\n\t\t\tpy.initCatmullRom(p0.y, p1.y, p2.y, p3.y, this.tension);\n\t\t\tpz.initCatmullRom(p0.z, p1.z, p2.z, p3.z, this.tension);\n\t\t}\n\n\t\tpoint.set(px.calc(weight), py.calc(weight), pz.calc(weight));\n\t\treturn point;\n\t};\n\n\tCatmullRomCurve3.prototype.copy = function (source) {\n\t\tCurve.prototype.copy.call(this, source);\n\t\tthis.points = [];\n\n\t\tfor (var i = 0, l = source.points.length; i < l; i++) {\n\t\t\tvar point = source.points[i];\n\t\t\tthis.points.push(point.clone());\n\t\t}\n\n\t\tthis.closed = source.closed;\n\t\tthis.curveType = source.curveType;\n\t\tthis.tension = source.tension;\n\t\treturn this;\n\t};\n\n\tCatmullRomCurve3.prototype.toJSON = function () {\n\t\tvar data = Curve.prototype.toJSON.call(this);\n\t\tdata.points = [];\n\n\t\tfor (var i = 0, l = this.points.length; i < l; i++) {\n\t\t\tvar point = this.points[i];\n\t\t\tdata.points.push(point.toArray());\n\t\t}\n\n\t\tdata.closed = this.closed;\n\t\tdata.curveType = this.curveType;\n\t\tdata.tension = this.tension;\n\t\treturn data;\n\t};\n\n\tCatmullRomCurve3.prototype.fromJSON = function (json) {\n\t\tCurve.prototype.fromJSON.call(this, json);\n\t\tthis.points = [];\n\n\t\tfor (var i = 0, l = json.points.length; i < l; i++) {\n\t\t\tvar point = json.points[i];\n\t\t\tthis.points.push(new Vector3().fromArray(point));\n\t\t}\n\n\t\tthis.closed = json.closed;\n\t\tthis.curveType = json.curveType;\n\t\tthis.tension = json.tension;\n\t\treturn this;\n\t};\n\n\t/**\n\t * Bezier Curves formulas obtained from\n\t * http://en.wikipedia.org/wiki/Bézier_curve\n\t */\n\tfunction CatmullRom(t, p0, p1, p2, p3) {\n\t\tvar v0 = (p2 - p0) * 0.5;\n\t\tvar v1 = (p3 - p1) * 0.5;\n\t\tvar t2 = t * t;\n\t\tvar t3 = t * t2;\n\t\treturn (2 * p1 - 2 * p2 + v0 + v1) * t3 + (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 + v0 * t + p1;\n\t} //\n\n\n\tfunction QuadraticBezierP0(t, p) {\n\t\tvar k = 1 - t;\n\t\treturn k * k * p;\n\t}\n\n\tfunction QuadraticBezierP1(t, p) {\n\t\treturn 2 * (1 - t) * t * p;\n\t}\n\n\tfunction QuadraticBezierP2(t, p) {\n\t\treturn t * t * p;\n\t}\n\n\tfunction QuadraticBezier(t, p0, p1, p2) {\n\t\treturn QuadraticBezierP0(t, p0) + QuadraticBezierP1(t, p1) + QuadraticBezierP2(t, p2);\n\t} //\n\n\n\tfunction CubicBezierP0(t, p) {\n\t\tvar k = 1 - t;\n\t\treturn k * k * k * p;\n\t}\n\n\tfunction CubicBezierP1(t, p) {\n\t\tvar k = 1 - t;\n\t\treturn 3 * k * k * t * p;\n\t}\n\n\tfunction CubicBezierP2(t, p) {\n\t\treturn 3 * (1 - t) * t * t * p;\n\t}\n\n\tfunction CubicBezierP3(t, p) {\n\t\treturn t * t * t * p;\n\t}\n\n\tfunction CubicBezier(t, p0, p1, p2, p3) {\n\t\treturn CubicBezierP0(t, p0) + CubicBezierP1(t, p1) + CubicBezierP2(t, p2) + CubicBezierP3(t, p3);\n\t}\n\n\tfunction CubicBezierCurve(v0, v1, v2, v3) {\n\t\tif (v0 === void 0) {\n\t\t\tv0 = new Vector2();\n\t\t}\n\n\t\tif (v1 === void 0) {\n\t\t\tv1 = new Vector2();\n\t\t}\n\n\t\tif (v2 === void 0) {\n\t\t\tv2 = new Vector2();\n\t\t}\n\n\t\tif (v3 === void 0) {\n\t\t\tv3 = new Vector2();\n\t\t}\n\n\t\tCurve.call(this);\n\t\tthis.type = 'CubicBezierCurve';\n\t\tthis.v0 = v0;\n\t\tthis.v1 = v1;\n\t\tthis.v2 = v2;\n\t\tthis.v3 = v3;\n\t}\n\n\tCubicBezierCurve.prototype = Object.create(Curve.prototype);\n\tCubicBezierCurve.prototype.constructor = CubicBezierCurve;\n\tCubicBezierCurve.prototype.isCubicBezierCurve = true;\n\n\tCubicBezierCurve.prototype.getPoint = function (t, optionalTarget) {\n\t\tif (optionalTarget === void 0) {\n\t\t\toptionalTarget = new Vector2();\n\t\t}\n\n\t\tvar point = optionalTarget;\n\t\tvar v0 = this.v0,\n\t\t\t\tv1 = this.v1,\n\t\t\t\tv2 = this.v2,\n\t\t\t\tv3 = this.v3;
1\n\t\tpoint.set(CubicBezier(t, v0.x, v1.x, v2.x, v3.x), CubicBezier(t, v0.y, v1.y, v2.y, v3.y));\n\t\treturn point;\n\t};\n\n\tCubicBezierCurve.prototype.copy = function (source) {\n\t\tCurve.prototype.copy.call(this, source);\n\t\tthis.v0.copy(source.v0);\n\t\tthis.v1.copy(source.v1);\n\t\tthis.v2.copy(source.v2);\n\t\tthis.v3.copy(source.v3);\n\t\treturn this;\n\t};\n\n\tCubicBezierCurve.prototype.toJSON = function () {\n\t\tvar data = Curve.prototype.toJSON.call(this);\n\t\tdata.v0 = this.v0.toArray();\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\t\tdata.v3 = this.v3.toArray();\n\t\treturn data;\n\t};\n\n\tCubicBezierCurve.prototype.fromJSON = function (json) {\n\t\tCurve.prototype.fromJSON.call(this, json);\n\t\tthis.v0.fromArray(json.v0);\n\t\tthis.v1.fromArray(json.v1);\n\t\tthis.v2.fromArray(json.v2);\n\t\tthis.v3.fromArray(json.v3);\n\t\treturn this;\n\t};\n\n\tfunction CubicBezierCurve3(v0, v1, v2, v3) {\n\t\tif (v0 === void 0) {\n\t\t\tv0 = new Vector3();\n\t\t}\n\n\t\tif (v1 === void 0) {\n\t\t\tv1 = new Vector3();\n\t\t}\n\n\t\tif (v2 === void 0) {\n\t\t\tv2 = new Vector3();\n\t\t}\n\n\t\tif (v3 === void 0) {\n\t\t\tv3 = new Vector3();\n\t\t}\n\n\t\tCurve.call(this);\n\t\tthis.type = 'CubicBezierCurve3';\n\t\tthis.v0 = v0;\n\t\tthis.v1 = v1;\n\t\tthis.v2 = v2;\n\t\tthis.v3 = v3;\n\t}\n\n\tCubicBezierCurve3.prototype = Object.create(Curve.prototype);\n\tCubicBezierCurve3.prototype.constructor = CubicBezierCurve3;\n\tCubicBezierCurve3.prototype.isCubicBezierCurve3 = true;\n\n\tCubicBezierCurve3.prototype.getPoint = function (t, optionalTarget) {\n\t\tif (optionalTarget === void 0) {\n\t\t\toptionalTarget = new Vector3();\n\t\t}\n\n\t\tvar point = optionalTarget;\n\t\tvar v0 = this.v0,\n\t\t\t\tv1 = this.v1,\n\t\t\t\tv2 = this.v2,\n\t\t\t\tv3 = this.v3;\n\t\tpoint.set(CubicBezier(t, v0.x, v1.x, v2.x, v3.x), CubicBezier(t, v0.y, v1.y, v2.y, v3.y), CubicBezier(t, v0.z, v1.z, v2.z, v3.z));\n\t\treturn point;\n\t};\n\n\tCubicBezierCurve3.prototype.copy = function (source) {\n\t\tCurve.prototype.copy.call(this, source);\n\t\tthis.v0.copy(source.v0);\n\t\tthis.v1.copy(source.v1);\n\t\tthis.v2.copy(source.v2);\n\t\tthis.v3.copy(source.v3);\n\t\treturn this;\n\t};\n\n\tCubicBezierCurve3.prototype.toJSON = function () {\n\t\tvar data = Curve.prototype.toJSON.call(this);\n\t\tdata.v0 = this.v0.toArray();\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\t\tdata.v3 = this.v3.toArray();\n\t\treturn data;\n\t};\n\n\tCubicBezierCurve3.prototype.fromJSON = function (json) {\n\t\tCurve.prototype.fromJSON.call(this, json);\n\t\tthis.v0.fromArray(json.v0);\n\t\tthis.v1.fromArray(json.v1);\n\t\tthis.v2.fromArray(json.v2);\n\t\tthis.v3.fromArray(json.v3);\n\t\treturn this;\n\t};\n\n\tfunction LineCurve(v1, v2) {\n\t\tif (v1 === void 0) {\n\t\t\tv1 = new Vector2();\n\t\t}\n\n\t\tif (v2 === void 0) {\n\t\t\tv2 = new Vector2();\n\t\t}\n\n\t\tCurve.call(this);\n\t\tthis.type = 'LineCurve';\n\t\tthis.v1 = v1;\n\t\tthis.v2 = v2;\n\t}\n\n\tLineCurve.prototype = Object.create(Curve.prototype);\n\tLineCurve.prototype.constructor = LineCurve;\n\tLineCurve.prototype.isLineCurve = true;\n\n\tLineCurve.prototype.getPoint = function (t, optionalTarget) {\n\t\tif (optionalTarget === void 0) {\n\t\t\toptionalTarget = new Vector2();\n\t\t}\n\n\t\tvar point = optionalTarget;\n\n\t\tif (t === 1) {\n\t\t\tpoint.copy(this.v2);\n\t\t} else {\n\t\t\tpoint.copy(this.v2).sub(this.v1);\n\t\t\tpoint.multiplyScalar(t).add(this.v1);\n\t\t}\n\n\t\treturn point;\n\t}; // Line curve is linear, so we can overwrite default getPointAt\n\n\n\tLineCurve.prototype.getPointAt = function (u, optionalTarget) {\n\t\treturn this.getPoint(u, optionalTarget);\n\t};\n\n\tLineCurve.prototype.getTangent = function (t, optionalTarget) {\n\t\tvar tangent = optionalTarget || new Vector2();\n\t\ttangent.copy(this.v2).sub(this.v1).normalize();\n\t\treturn tangent;\n\t};\n\n\tLineCurve.prototype.copy = function (source) {\n\t\tCurve.prototype.copy.call(this, source);\n\t\tthis.v1.copy(source.v1);\n\t\tthis.v2.copy(source.v2);\n\t\treturn this;\n\t};\n\n\tLineCurve.prototype.toJSON = function () {\n\t\tvar data = Curve.prototype.toJSON.call(this);\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\t\treturn data;\n\t};\n\n\tLineCurve.prototype.fromJSON = function (json) {\n\t\tCurve.prototype.fromJSON.call(this, json);\n\t\tthis.v1.fromArray(json.v1);\n\t\tthis.v2.fromArray(json.v2);\n\t\treturn this;\n\t};\n\n\tfunction LineCurve3(v1, v2) {\n\t\tif (v1 === void 0) {\n\t\t\tv1 = new Vector3();\n\t\t}\n\n\t\tif (v2 === void 0) {\n\t\t\tv2 = new Vector3();\n\t\t}\n\n\t\tCurve.call(this);\n\t\tthis.type = 'LineCurve3';\n\t\tthis.v1 = v1;\n\t\tthis.v2 = v2;\n\t}\n\n\tLineCurve3.prototype = Object.create(Curve.prototype);\n\tLineCurve3.prototype.constructor = LineCurve3;\n\tLineCurve3.prototype.isLineCurve3 = true;\n\n\tLineCurve3.prototype.getPoint = function (t, optionalTarget) {\n\t\tif (optionalTarget === void 0) {\n\t\t\toptionalTarget = new Vector3();\n\t\t}\n\n\t\tvar point = optionalTarget;\n\n\t\tif (t === 1) {\n\t\t\tpoint.copy(this.v2);\n\t\t} else {\n\t\t\tpoint.copy(this.v2).sub(this.v1);\n\t\t\tpoint.multiplyScalar(t).add(this.v1);\n\t\t}\n\n\t\treturn point;\n\t}; // Line curve is linear, so we can overwrite default getPointAt\n\n\n\tLineCurve3.prototype.getPointAt = function (u, optionalTarget) {\n\t\treturn this.getPoint(u, optionalTarget);\n\t};\n\n\tLineCurve3.prototype.copy = function (source) {\n\t\tCurve.prototype.copy.call(this, source);\n\t\tthis.v1.copy(source.v1);\n\t\tthis.v2.copy(source.v2);\n\t\treturn this;\n\t};\n\n\tLineCurve3.prototype.toJSON = function () {\n\t\tvar data = Curve.prototype.toJSON.call(this);\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\t\treturn data;\n\t};\n\n\tLineCurve3.prototype.fromJSON = function (json) {\n\t\tCurve.prototype.fromJSON.call(this, json);\n\t\tthis.v1.fromArray(json.v1);\n\t\tthis.v2.fromArray(json.v2);\n\t\treturn this;\n\t};\n\n\tfunction QuadraticBezierCurve(v0, v1, v2) {\n\t\tif (v0 === void 0) {\n\t\t\tv0 = new Vector2();\n\t\t}\n\n\t\tif (v1 === void 0) {\n\t\t\tv1 = new Vector2();\n\t\t}\n\n\t\tif (v2 === void 0) {\n\t\t\tv2 = new Vector2();\n\t\t}\n\n\t\tCurve.call(this);\n\t\tthis.type = 'QuadraticBezierCurve';\n\t\tthis.v0 = v0;\n\t\tthis.v1 = v1;\n\t\tthis.v2 = v2;\n\t}\n\n\tQuadraticBezierCurve.prototype = Object.create(Curve.prototype);\n\tQuadraticBezierCurve.prototype.constructor = QuadraticBezierCurve;\n\tQuadraticBezierCurve.prototype.isQuadraticBezierCurve = true;\n\n\tQuadraticBezierCurve.prototype.getPoint = function (t, optionalTarget) {\n\t\tif (optionalTarget === void 0) {\n\t\t\toptionalTarget = new Vector2();\n\t\t}\n\n\t\tvar point = optionalTarget;\n\t\tvar v0 = this.v0,\n\t\t\t\tv1 = this.v1,\n\t\t\t\tv2 = this.v2;\n\t\tpoint.set(QuadraticBezier(t, v0.x, v1.x, v2.x), QuadraticBezier(t, v0.y, v1.y, v2.y));\n\t\treturn point;\n\t};\n\n\tQuadraticBezierCurve.prototype.copy = function (source) {\n\t\tCurve.prototype.copy.call(this, source);\n\t\tthis.v0.copy(source.v0);\n\t\tthis.v1.copy(source.v1);\n\t\tthis.v2.copy(source.v2);\n\t\treturn this;\n\t};\n\n\tQuadraticBezierCurve.prototype.toJSON = function () {\n\t\tvar data = Curve.prototype.toJSON.call(this);\n\t\tdata.v0 = this.v0.toArray();\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\t\treturn data;\n\t};\n\n\tQuadraticBezierCurve.prototype.fromJSON = function (json) {\n\t\tCurve.prototype.fromJSON.call(this, json);\n\t\tthis.v0.fromArray(json.v0);\n\t\tthis.v1.fromArray(json.v1);\n\t\tthis.v2.fromArray(json.v2);\n\t\treturn this;\n\t};\n\n\tfunction QuadraticBezierCurve3(v0, v1, v2) {\n\t\tif (v0 === void 0) {\n\t\t\tv0 = new Vector3();\n\t\t}\n\n\t\tif (v1 === void 0) {\n\t\t\tv1 = new Vector3();\n\t\t}\n\n\t\tif (v2 === void 0) {\n\t\t\tv2 = new Vector3();\n\t\t}\n\n\t\tCurve.call(this);\n\t\tthis.type = 'QuadraticBezierCurve3';\n\t\tthis.v0 = v0;\n\t\tthis.v1 = v1;\n\t\tthis.v2 = v2;\n\t}\n\n\tQuadraticBezierCurve3.prototype = Object.create(Curve.prototype);\n\tQuadraticBezierCurve3.prototype.constructor = QuadraticBezierCurve3;\n\tQuadraticBezierCurve3.prototype.isQuadraticBezierCurve3 = true;\n\n\tQuadraticBezierCurve3.prototype.getPoint = function (t, optionalTarget) {\n\t\tif (optionalTarget === void 0) {\n\t\t\toptionalTarget = new Vector3();\n\t\t}\n\n\t\tvar point = optionalTarget;\n\t\tvar v0 = this.v0,\n\t\t\t\tv1 = this.v1,\n\t\t\t\tv2 = this.v2;\n\t\tpoint.set(QuadraticBezier(t, v0.x, v1.x, v2.x), QuadraticBezier(t, v0.y, v1.y, v2.y), QuadraticBezier(t, v0.z, v1.z, v2.z));\n\t\treturn point;\n\t};\n\n\tQuadraticBezierCurve3.prototype.copy = function (source) {\n\t\tCurve.prototype.copy.call(this, source);\n\t\tthis.v0.copy(source.v0);\n\t\tthis.v1.copy(source.v1);\n\t\tthis.v2.copy(source.v2);\n\t\treturn this;\n\t};\n\n\tQuadraticBezierCurve3.prototype.toJSON = function () {\n\t\tvar data = Curve.prototype.toJSON.call(this);\n\t\tdata.v0 = this.v0.toArray();\n\t\tdata.v1 = this.v1.toArray();\n\t\tdata.v2 = this.v2.toArray();\n\t\treturn data;\n\t};\n\n\tQuadraticBezierCurve3.prototype.fromJSON = function (json) {\n\t\tCurve.prototype.fromJSON.call(this, json);\n\t\tthis.v0.fromArray(json.v0);\n\t\tthis.v1.fromArray(json.v1);\n\t\tthis.v2.fromArray(json.v2);\n\t\treturn this;\n\t};\n\n\tfunction SplineCurve(points) {\n\t\tif (points === void 0) {\n\t\t\tpoints = [];\n\t\t}\n\n\t\tCurve.call(this);\n\t\tthis.type = 'SplineCurve';\n\t\tthis.points = points;\n\t}\n\n\tSplineCurve.prototype = Object.create(Curve.prototype);\n\tSplineCurve.prototype.constructor = SplineCurve;\n\tSplineCurve.prototype.isSplineCurve = true;\n\n\tSplineCurve.prototype.getPoint = function (t, optionalTarget) {\n\t\tif (optionalTarget === void 0) {\n\t\t\toptionalTarget = new Vector2();\n\t\t}\n\n\t\tvar point = optionalTarget;\n\t\tvar points = this.points;
1\n\t\tvar p = (points.length - 1) * t;\n\t\tvar intPoint = Math.floor(p);\n\t\tvar weight = p - intPoint;\n\t\tvar p0 = points[intPoint === 0 ? intPoint : intPoint - 1];\n\t\tvar p1 = points[intPoint];\n\t\tvar p2 = points[intPoint > points.length - 2 ? points.length - 1 : intPoint + 1];\n\t\tvar p3 = points[intPoint > points.length - 3 ? points.length - 1 : intPoint + 2];\n\t\tpoint.set(CatmullRom(weight, p0.x, p1.x, p2.x, p3.x), CatmullRom(weight, p0.y, p1.y, p2.y, p3.y));\n\t\treturn point;\n\t};\n\n\tSplineCurve.prototype.copy = function (source) {\n\t\tCurve.prototype.copy.call(this, source);\n\t\tthis.points = [];\n\n\t\tfor (var i = 0, l = source.points.length; i < l; i++) {\n\t\t\tvar point = source.points[i];\n\t\t\tthis.points.push(point.clone());\n\t\t}\n\n\t\treturn this;\n\t};\n\n\tSplineCurve.prototype.toJSON = function () {\n\t\tvar data = Curve.prototype.toJSON.call(this);\n\t\tdata.points = [];\n\n\t\tfor (var i = 0, l = this.points.length; i < l; i++) {\n\t\t\tvar point = this.points[i];\n\t\t\tdata.points.push(point.toArray());\n\t\t}\n\n\t\treturn data;\n\t};\n\n\tSplineCurve.prototype.fromJSON = function (json) {\n\t\tCurve.prototype.fromJSON.call(this, json);\n\t\tthis.points = [];\n\n\t\tfor (var i = 0, l = json.points.length; i < l; i++) {\n\t\t\tvar point = json.points[i];\n\t\t\tthis.points.push(new Vector2().fromArray(point));\n\t\t}\n\n\t\treturn this;\n\t};\n\n\tvar Curves = /*#__PURE__*/Object.freeze({\n\t\t__proto__: null,\n\t\tArcCurve: ArcCurve,\n\t\tCatmullRomCurve3: CatmullRomCurve3,\n\t\tCubicBezierCurve: CubicBezierCurve,\n\t\tCubicBezierCurve3: CubicBezierCurve3,\n\t\tEllipseCurve: EllipseCurve,\n\t\tLineCurve: LineCurve,\n\t\tLineCurve3: LineCurve3,\n\t\tQuadraticBezierCurve: QuadraticBezierCurve,\n\t\tQuadraticBezierCurve3: QuadraticBezierCurve3,\n\t\tSplineCurve: SplineCurve\n\t});\n\n\t/**************************************************************\n\t *\tCurved Path - a curve path is simply a array of connected\n\t *\tcurves, but retains the api of a curve\n\t **************************************************************/\n\n\tfunction CurvePath() {\n\t\tCurve.call(this);\n\t\tthis.type = 'CurvePath';\n\t\tthis.curves = [];\n\t\tthis.autoClose = false; // Automatically closes the path\n\t}\n\n\tCurvePath.prototype = Object.assign(Object.create(Curve.prototype), {\n\t\tconstructor: CurvePath,\n\t\tadd: function add(curve) {\n\t\t\tthis.curves.push(curve);\n\t\t},\n\t\tclosePath: function closePath() {\n\t\t\t// Add a line curve if start and end of lines are not connected\n\t\t\tvar startPoint = this.curves[0].getPoint(0);\n\t\t\tvar endPoint = this.curves[this.curves.length - 1].getPoint(1);\n\n\t\t\tif (!startPoint.equals(endPoint)) {\n\t\t\t\tthis.curves.push(new LineCurve(endPoint, startPoint));\n\t\t\t}\n\t\t},\n\t\t// To get accurate point with reference to\n\t\t// entire path distance at time t,\n\t\t// following has to be done:\n\t\t// 1. Length of each sub path have to be known\n\t\t// 2. Locate and identify type of curve\n\t\t// 3. Get t for the curve\n\t\t// 4. Return curve.getPointAt(t')\n\t\tgetPoint: function getPoint(t) {\n\t\t\tvar d = t * this.getLength();\n\t\t\tvar curveLengths = this.getCurveLengths();\n\t\t\tvar i = 0; // To think about boundaries points.\n\n\t\t\twhile (i < curveLengths.length) {\n\t\t\t\tif (curveLengths[i] >= d) {\n\t\t\t\t\tvar diff = curveLengths[i] - d;\n\t\t\t\t\tvar curve = this.curves[i];\n\t\t\t\t\tvar segmentLength = curve.getLength();\n\t\t\t\t\tvar u = segmentLength === 0 ? 0 : 1 - diff / segmentLength;\n\t\t\t\t\treturn curve.getPointAt(u);\n\t\t\t\t}\n\n\t\t\t\ti++;\n\t\t\t}\n\n\t\t\treturn null; // loop where sum != 0, sum > d , sum+1 <d\n\t\t},\n\t\t// We cannot use the default THREE.Curve getPoint() with getLength() because in\n\t\t// THREE.Curve, getLength() depends on getPoint() but in THREE.CurvePath\n\t\t// getPoint() depends on getLength\n\t\tgetLength: function getLength() {\n\t\t\tvar lens = this.getCurveLengths();\n\t\t\treturn lens[lens.length - 1];\n\t\t},\n\t\t// cacheLengths must be recalculated.\n\t\tupdateArcLengths: function updateArcLengths() {\n\t\t\tthis.needsUpdate = true;\n\t\t\tthis.cacheLengths = null;\n\t\t\tthis.getCurveLengths();\n\t\t}
1,\n\t\t// Compute lengths and cache them\n\t\t// We cannot overwrite getLengths() because UtoT mapping uses it.\n\t\tgetCurveLengths: function getCurveLengths() {\n\t\t\t// We use cache values if curves and cache array are same length\n\t\t\tif (this.cacheLengths && this.cacheLengths.length === this.curves.length) {\n\t\t\t\treturn this.cacheLengths;\n\t\t\t} // Get length of sub-curve\n\t\t\t// Push sums into cached array\n\n\n\t\t\tvar lengths = [];\n\t\t\tvar sums = 0;\n\n\t\t\tfor (var i = 0, l = this.curves.length; i < l; i++) {\n\t\t\t\tsums += this.curves[i].getLength();\n\t\t\t\tlengths.push(sums);\n\t\t\t}\n\n\t\t\tthis.cacheLengths = lengths;\n\t\t\treturn lengths;\n\t\t},\n\t\tgetSpacedPoints: function getSpacedPoints(divisions) {\n\t\t\tif (divisions === void 0) {\n\t\t\t\tdivisions = 40;\n\t\t\t}\n\n\t\t\tvar points = [];\n\n\t\t\tfor (var i = 0; i <= divisions; i++) {\n\t\t\t\tpoints.push(this.getPoint(i / divisions));\n\t\t\t}\n\n\t\t\tif (this.autoClose) {\n\t\t\t\tpoints.push(points[0]);\n\t\t\t}\n\n\t\t\treturn points;\n\t\t},\n\t\tgetPoints: function getPoints(divisions) {\n\t\t\tif (divisions === void 0) {\n\t\t\t\tdivisions = 12;\n\t\t\t}\n\n\t\t\tvar points = [];\n\t\t\tvar last;\n\n\t\t\tfor (var i = 0, curves = this.curves; i < curves.length; i++) {\n\t\t\t\tvar curve = curves[i];\n\t\t\t\tvar resolution = curve && curve.isEllipseCurve ? divisions * 2 : curve && (curve.isLineCurve || curve.isLineCurve3) ? 1 : curve && curve.isSplineCurve ? divisions * curve.points.length : divisions;\n\t\t\t\tvar pts = curve.getPoints(resolution);\n\n\t\t\t\tfor (var j = 0; j < pts.length; j++) {\n\t\t\t\t\tvar point = pts[j];\n\t\t\t\t\tif (last && last.equals(point)) continue; // ensures no consecutive points are duplicates\n\n\t\t\t\t\tpoints.push(point);\n\t\t\t\t\tlast = point;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.autoClose && points.length > 1 && !points[points.length - 1].equals(points[0])) {\n\t\t\t\tpoints.push(points[0]);\n\t\t\t}\n\n\t\t\treturn points;\n\t\t},\n\t\tcopy: function copy(source) {\n\t\t\tCurve.prototype.copy.call(this, source);\n\t\t\tthis.curves = [];\n\n\t\t\tfor (var i = 0, l = source.curves.length; i < l; i++) {\n\t\t\t\tvar curve = source.curves[i];\n\t\t\t\tthis.curves.push(curve.clone());\n\t\t\t}\n\n\t\t\tthis.autoClose = source.autoClose;\n\t\t\treturn this;\n\t\t},\n\t\ttoJSON: function toJSON() {\n\t\t\tvar data = Curve.prototype.toJSON.call(this);\n\t\t\tdata.autoClose = this.autoClose;\n\t\t\tdata.curves = [];\n\n\t\t\tfor (var i = 0, l = this.curves.length; i < l; i++) {\n\t\t\t\tvar curve = this.curves[i];\n\t\t\t\tdata.curves.push(curve.toJSON());\n\t\t\t}\n\n\t\t\treturn data;\n\t\t},\n\t\tfromJSON: function fromJSON(json) {\n\t\t\tCurve.prototype.fromJSON.call(this, json);\n\t\t\tthis.autoClose = json.autoClose;\n\t\t\tthis.curves = [];\n\n\t\t\tfor (var i = 0, l = json.curves.length; i < l; i++) {\n\t\t\t\tvar curve = json.curves[i];\n\t\t\t\tthis.curves.push(new Curves[curve.type]().fromJSON(curve));\n\t\t\t}\n\n\t\t\treturn this;\n\t\t}\n\t});\n\n\tfunction Path(points) {\n\t\tCurvePath.call(this);\n\t\tthis.type = 'Path';\n\t\tthis.currentPoint = new Vector2();\n\n\t\tif (points) {\n\t\t\tthis.setFromPoints(points);\n\t\t}\n\t}\n\n\tPath.prototype = Object.assign(Object.create(CurvePath.prototype), {\n\t\tconstructor: Path,\n\t\tsetFromPoints: function setFromPoints(points) {\n\t\t\tthis.moveTo(points[0].x, points[0].y);\n\n\t\t\tfor (var i = 1, l = points.length; i < l; i++) {\n\t\t\t\tthis.lineTo(points[i].x, points[i].y);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\tmoveTo: function moveTo(x, y) {\n\t\t\tthis.currentPoint.set(x, y); // TODO consider referencing vectors instead of copying?\n\n\t\t\treturn this;\n\t\t},\n\t\tlineTo: function lineTo(x, y) {\n\t\t\tvar curve = new LineCurve(this.currentPoint.clone(), new Vector2(x, y));\n\t\t\tthis.curves.push(curve);\n\t\t\tthis.currentPoint.set(x, y);\n\t\t\treturn this;\n\t\t},\n\t\tquadraticCurveTo: function quadraticCurveTo(aCPx, aCPy, aX, aY) {\n\t\t\tvar curve = new QuadraticBezierCurve(this.currentPoint.clone(), new Vector2(aCPx, aCPy), new Vector2(aX, aY));\n\t\t\tthis.curves.push(curve);\n\t\t\tthis.currentPoint.set(aX, aY);\n\t\t\treturn this;\n\t\t},\n\t\tbezierCurveTo: function bezierCurveTo(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY) {\n\t\t\tvar curve = new CubicBezierCurve(this.currentPoint.clone(), new Vector2(aCP1x, aCP1y), new Vector2(aCP2x, aCP2y), new Vector2(aX, aY));\n\t\t\tthis.curves.push(curve);\n\t\t\tthis.currentPoint.set(aX, aY);\n\t\t\treturn this;\n\t\t},\n\t\tsplineThru: function splineThru(pts\n\t\t/*Array of Vector*/\n\t\t) {\n\t\t\tvar npts = [this.currentPoint.clone()].concat(pts);\n\t\t\tvar curve = new SplineCurve(npts);\n\t\t\tthis.curves.push(curve);\n\t\t\tthis.currentPoint.copy(pts[pts.length - 1]);\n\t\t\treturn this;\n\t\t},\n\t\tarc: function arc(aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) {\n\t\t\tvar x0 = this.currentPoint.x;\n\t\t\tvar y0 = this.currentPoint.y;\n\t\t\tthis.absarc(aX + x0, aY + y0, aRadius, aStartAngle, aEndAngle, aClockwise);\n\t\t\treturn this;\n\t\t},\n\t\tabsarc: function absarc(aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) {\n\t\t\tthis.absellipse(aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise);\n\t\t\treturn this;\n\t\t},\n\t\tellipse: function ellipse(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation) {\n\t\t\tvar x0 = this.currentPoint.x;\n\t\t\tvar y0 = this.currentPoint.y;\n\t\t\tthis.absellipse(aX + x0, aY + y0, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation);\n\t\t\treturn this;\n\t\t},\n\t\tabsellipse: function absellipse(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation) {\n\t\t\tvar curve = new EllipseCurve(aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation);\n\n\t\t\tif (this.curves.length > 0) {\n\t\t\t\t// if a previous curve is present, attempt to join\n\t\t\t\tvar firstPoint = curve.getPoint(0);\n\n\t\t\t\tif (!firstPoint.equals(this.currentPoint)) {\n\t\t\t\t\tthis.lineTo(firstPoint.x, firstPoint.y);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis.curves.push(curve);\n\t\t\tvar lastPoint = curve.getPoint(1);\n\t\t\tthis.currentPoint.copy(lastPoint);\n\t\t\treturn this;\n\t\t},\n\t\tcopy: function copy(source) {\n\t\t\tCurvePath.prototype.copy.call(this, source);\n\t\t\tthis.currentPoint.copy(source.currentPoint);\n\t\t\treturn this;\n\t\t},\n\t\ttoJSON: function toJSON() {\n\t\t\tvar data = CurvePath.prototype.toJSON.call(this);\n\t\t\tdata.currentPoint = this.currentPoint.toArray();\n\t\t\treturn data;\n\t\t},\n\t\tfromJSON: function fromJSON(json) {\n\t\t\tCurvePath.prototype.fromJSON.call(this, json);\n\t\t\tthis.currentPoint.fromArray(json.currentPoint);\n\t\t\treturn this;\n\t\t}\n\t});\n\n\tfunction Shape(points) {\n\t\tPath.call(this, points);\n\t\tthis.uuid = MathUtils.generateUUID();\n\t\tthis.type = 'Shape';\n\t\tthis.holes = [];\n\t}\n\n\tShape.prototype = Object.assign(Object.create(Path.prototype), {\n\t\tconstructor: Shape,\n\t\tgetPointsHoles: function getPointsHoles(divisions) {\n\t\t\tvar holesPts = [];\n\n\t\t\tfor (var i = 0, l = this.holes.length; i < l;
1 i++) {\n\t\t\t\tholesPts[i] = this.holes[i].getPoints(divisions);\n\t\t\t}\n\n\t\t\treturn holesPts;\n\t\t},\n\t\t// get points of shape and holes (keypoints based on segments parameter)\n\t\textractPoints: function extractPoints(divisions) {\n\t\t\treturn {\n\t\t\t\tshape: this.getPoints(divisions),\n\t\t\t\tholes: this.getPointsHoles(divisions)\n\t\t\t};\n\t\t},\n\t\tcopy: function copy(source) {\n\t\t\tPath.prototype.copy.call(this, source);\n\t\t\tthis.holes = [];\n\n\t\t\tfor (var i = 0, l = source.holes.length; i < l; i++) {\n\t\t\t\tvar hole = source.holes[i];\n\t\t\t\tthis.holes.push(hole.clone());\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\ttoJSON: function toJSON() {\n\t\t\tvar data = Path.prototype.toJSON.call(this);\n\t\t\tdata.uuid = this.uuid;\n\t\t\tdata.holes = [];\n\n\t\t\tfor (var i = 0, l = this.holes.length; i < l; i++) {\n\t\t\t\tvar hole = this.holes[i];\n\t\t\t\tdata.holes.push(hole.toJSON());\n\t\t\t}\n\n\t\t\treturn data;\n\t\t},\n\t\tfromJSON: function fromJSON(json) {\n\t\t\tPath.prototype.fromJSON.call(this, json);\n\t\t\tthis.uuid = json.uuid;\n\t\t\tthis.holes = [];\n\n\t\t\tfor (var i = 0, l = json.holes.length; i < l; i++) {\n\t\t\t\tvar hole = json.holes[i];\n\t\t\t\tthis.holes.push(new Path().fromJSON(hole));\n\t\t\t}\n\n\t\t\treturn this;\n\t\t}\n\t});\n\n\tfunction Light(color, intensity) {\n\t\tif (intensity === void 0) {\n\t\t\tintensity = 1;\n\t\t}\n\n\t\tObject3D.call(this);\n\t\tthis.type = 'Light';\n\t\tthis.color = new Color(color);\n\t\tthis.intensity = intensity;\n\t}\n\n\tLight.prototype = Object.assign(Object.create(Object3D.prototype), {\n\t\tconstructor: Light,\n\t\tisLight: true,\n\t\tcopy: function copy(source) {\n\t\t\tObject3D.prototype.copy.call(this, source);\n\t\t\tthis.color.copy(source.color);\n\t\t\tthis.intensity = source.intensity;\n\t\t\treturn this;\n\t\t},\n\t\ttoJSON: function toJSON(meta) {\n\t\t\tvar data = Object3D.prototype.toJSON.call(this, meta);\n\t\t\tdata.object.color = this.color.getHex();\n\t\t\tdata.object.intensity = this.intensity;\n\t\t\tif (this.groundColor !== undefined) data.object.groundColor = this.groundColor.getHex();\n\t\t\tif (this.distance !== undefined) data.object.distance = this.distance;\n\t\t\tif (this.angle !== undefined) data.object.angle = this.angle;\n\t\t\tif (this.decay !== undefined) data.object.decay = this.decay;\n\t\t\tif (this.penumbra !== undefined) data.object.penumbra = this.penumbra;\n\t\t\tif (this.shadow !== undefined) data.object.shadow = this.shadow.toJSON();\n\t\t\treturn data;\n\t\t}\n\t});\n\n\tfunction HemisphereLight(skyColor, groundColor, intensity) {\n\t\tLight.call(this, skyColor, intensity);\n\t\tthis.type = 'HemisphereLight';\n\t\tthis.position.copy(Object3D.DefaultUp);\n\t\tthis.updateMatrix();\n\t\tthis.groundColor = new Color(groundColor);\n\t}\n\n\tHemisphereLight.prototype = Object.assign(Object.create(Light.prototype), {\n\t\tconstructor: HemisphereLight,\n\t\tisHemisphereLight: true,\n\t\tcopy: function copy(source) {\n\t\t\tLight.prototype.copy.call(this, source);\n\t\t\tthis.groundColor.copy(source.groundColor);\n\t\t\treturn this;\n\t\t}\n\t});\n\n\tfunction LightShadow(camera) {\n\t\tthis.camera = camera;\n\t\tthis.bias = 0;\n\t\tthis.normalBias = 0;\n\t\tthis.radius = 1;\n\t\tthis.mapSize = new Vector2(512, 512);\n\t\tthis.map = null;\n\t\tthis.mapPass = null;\n\t\tthis.matrix = new Matrix4();\n\t\tthis.autoUpdate = true;\n\t\tthis.needsUpdate = false;\n\t\tthis._frustum = new Frustum();\n\t\tthis._frameExtents = new Vector2(1, 1);\n\t\tthis._viewportCount = 1;\n\t\tthis._viewports = [new Vector4(0, 0, 1, 1)];\n\t}\n\n\tObject.assign(LightShadow.prototype, {\n\t\t_projScreenMatrix: new Matrix4(),\n\t\t_lightPositionWorld: new Vector3(),\n\t\t_lookTarget: new Vector3(),\n\t\tgetViewportCount: function getViewportCount() {\n\t\t\treturn this._viewportCount;\n\t\t},\n\t\tgetFrustum: function getFrustum() {\n\t\t\treturn this._frustum;\n\t\t},\n\t\tupdateMatrices: function updateMatrices(light) {\n\t\t\tvar shadowCamera = this.camera,\n\t\t\t\t\tshadowMatrix = this.matrix,\n\t\t\t\t\tprojScreenMatrix = this._projScreenMatrix,\n\t\t\t\t\tlookTarget = this._lookTarget,\n\t\t\t\t\tlightPositionWorld = this._lightPositionWorld;\n\t\t\tlightPositionWorld.setFromMatrixPosition(light.matrixWorld);\n\t\t\tshadowCamera.position.copy(lightPositionWorld);\n\t\t\tlookTarget.setFromMatrixPosition(light.target.matrixWorld);\n\t\t\tshadowCamera.lookAt(lookTarget);\n\t\t\tshadowCamera.updateMatrixWorld();\n\t\t\tprojScreenMatrix.multiplyMatrices(shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse);\n\n\t\t\tthis._frustum.setFromProjectionMatrix(projScreenMatrix);\n\n\t\t\tshadowMatrix.set(0.5, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 1.0);\n\t\t\tshadowMatrix.multiply(shadowCamera.projectionMatrix);\n\t\t\tshadowMatrix.multiply(shadowCamera.matrixWorldInverse);\n\t\t},\n\t\tgetViewport: function getViewport(viewportIndex) {\n\t\t\treturn this._viewports[viewportIndex];\n\t\t},\n\t\tgetFrameExtents: function getFrameExtents() {\n\t\t\treturn this._frameExtents;\n\t\t},\n\t\tcopy: function copy(source) {\n\t\t\tthis.camera = source.camera.clone();\n\t\t\tthis.bias = source.bias;
1\n\t\t\tthis.radius = source.radius;\n\t\t\tthis.mapSize.copy(source.mapSize);\n\t\t\treturn this;\n\t\t},\n\t\tclone: function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t},\n\t\ttoJSON: function toJSON() {\n\t\t\tvar object = {};\n\t\t\tif (this.bias !== 0) object.bias = this.bias;\n\t\t\tif (this.normalBias !== 0) object.normalBias = this.normalBias;\n\t\t\tif (this.radius !== 1) object.radius = this.radius;\n\t\t\tif (this.mapSize.x !== 512 || this.mapSize.y !== 512) object.mapSize = this.mapSize.toArray();\n\t\t\tobject.camera = this.camera.toJSON(false).object;\n\t\t\tdelete object.camera.matrix;\n\t\t\treturn object;\n\t\t}\n\t});\n\n\tfunction SpotLightShadow() {\n\t\tLightShadow.call(this, new PerspectiveCamera(50, 1, 0.5, 500));\n\t\tthis.focus = 1;\n\t}\n\n\tSpotLightShadow.prototype = Object.assign(Object.create(LightShadow.prototype), {\n\t\tconstructor: SpotLightShadow,\n\t\tisSpotLightShadow: true,\n\t\tupdateMatrices: function updateMatrices(light) {\n\t\t\tvar camera = this.camera;\n\t\t\tvar fov = MathUtils.RAD2DEG * 2 * light.angle * this.focus;\n\t\t\tvar aspect = this.mapSize.width / this.mapSize.height;\n\t\t\tvar far = light.distance || camera.far;\n\n\t\t\tif (fov !== camera.fov || aspect !== camera.aspect || far !== camera.far) {\n\t\t\t\tcamera.fov = fov;\n\t\t\t\tcamera.aspect = aspect;\n\t\t\t\tcamera.far = far;\n\t\t\t\tcamera.updateProjectionMatrix();\n\t\t\t}\n\n\t\t\tLightShadow.prototype.updateMatrices.call(this, light);\n\t\t}\n\t});\n\n\tfunction SpotLight(color, intensity, distance, angle, penumbra, decay) {\n\t\tLight.call(this, color, intensity);\n\t\tthis.type = 'SpotLight';\n\t\tthis.position.copy(Object3D.DefaultUp);\n\t\tthis.updateMatrix();\n\t\tthis.target = new Object3D();\n\t\tObject.defineProperty(this, 'power', {\n\t\t\tget: function get() {\n\t\t\t\t// intensity = power per solid angle.\n\t\t\t\t// ref: equation (17) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t\t\t\treturn this.intensity * Math.PI;\n\t\t\t},\n\t\t\tset: function set(power) {\n\t\t\t\t// intensity = power per solid angle.\n\t\t\t\t// ref: equation (17) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t\t\t\tthis.intensity = power / Math.PI;\n\t\t\t}\n\t\t});\n\t\tthis.distance = distance !== undefined ? distance : 0;\n\t\tthis.angle = angle !== undefined ? angle : Math.PI / 3;\n\t\tthis.penumbra = penumbra !== undefined ? penumbra : 0;\n\t\tthis.decay = decay !== undefined ? decay : 1; // for physically correct lights, should be 2.\n\n\t\tthis.shadow = new SpotLightShadow();\n\t}\n\n\tSpotLight.prototype = Object.assign(Object.create(Light.prototype), {\n\t\tconstructor: SpotLight,\n\t\tisSpotLight: true,\n\t\tcopy: function copy(source) {\n\t\t\tLight.prototype.copy.call(this, source);\n\t\t\tthis.distance = source.distance;\n\t\t\tthis.angle = source.angle;\n\t\t\tthis.penumbra = source.penumbra;\n\t\t\tthis.decay = source.decay;\n\t\t\tthis.target = source.target.clone();\n\t\t\tthis.shadow = source.shadow.clone();\n\t\t\treturn this;\n\t\t}\n\t});\n\n\tfunction PointLightShadow() {\n\t\tLightShadow.call(this, new PerspectiveCamera(90, 1, 0.5, 500));\n\t\tthis._frameExtents = new Vector2(4, 2);\n\t\tthis._viewportCount = 6;\n\t\tthis._viewports = [// These viewports map a cube-map onto a 2D texture with the\n\t\t// following orientation:\n\t\t//\n\t\t//\txzXZ\n\t\t//\t y Y\n\t\t//\n\t\t// X - Positive x direction\n\t\t// x - Negative x direction\n\t\t// Y - Positive y direction\n\t\t// y - Negative y direction\n\t\t// Z - Positive z direction\n\t\t// z - Negative z direction\n\t\t// positive X\n\t\tnew Vector4(2, 1, 1, 1), // negative X\n\t\tnew Vector4(0, 1, 1, 1), // positive Z\n\t\tnew Vector4(3, 1, 1, 1), // negative Z\n\t\tnew Vector4(1, 1, 1, 1), // positive Y\n\t\tnew Vector4(3, 0, 1, 1), // negative Y\n\t\tnew Vector4(1, 0, 1, 1)];\n\t\tthis._cubeDirections = [new Vector3(1, 0, 0), new Vector3(-1, 0, 0), new Vector3(0, 0, 1), new Vector3(0, 0, -1), new Vector3(0, 1, 0), new Vector3(0, -1, 0)];\n\t\tthis._cubeUps = [new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1), new Vector3(0, 0, -1)];\n\t}\n\n\tPointLightShadow.prototype = Object.assign(Object.create(LightShadow.prototype), {\n\t\tconstructor: PointLightShadow,\n\t\tisPointLightShadow: true,\n\t\tupdateMatrices: function updateMatrices(light, viewportIndex) {\n\t\t\tif (viewportIndex === void 0) {\n\t\t\t\tviewportIndex = 0;\n\t\t\t}\n\n\t\t\tvar camera = this.camera,\n\t\t\t\t\tshadowMatrix = this.matrix,\n\t\t\t\t\tlightPositionWorld = this._lightPositionWorld,\n\t\t\t\t\tlookTarget = this._lookTarget,\n\t\t\t\t\tprojScreenMatrix = this._projScreenMatrix;\n\t\t\tlightPositionWorld.setFromMatrixPosition(light.matrixWorld);\n\t\t\tcamera.position.copy(lightPositionWorld);\n\t\t\tlookTarget.copy(camera.position);\n\t\t\tlookTarget.add(this._cubeDirections[viewportIndex]);\n\t\t\tcamera.up.copy(this._cubeUps[viewportIndex]);\n\t\t\tcamera.lookAt(lookTarget);\n\t\t\tcamera.updateMatrixWorld();\n\t\t\tshadowMatrix.makeTranslation(-lightPositionWorld.x, -lightPositionWorld.y, -lightPositionWorld.z);\n\t\t\tprojScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);\n\n\t\t\tthis._frustum.setFromProjectionMatrix(projScreenMatrix);\n\t\t}\n\t});\n\n\tfunction PointLight(color, intensity, distance, decay) {\n\t\tLight.call(this, color, intensity);\n\t\tthis.type = 'PointLight';\n\t\tObject.defineProperty(this, 'power', {\n\t\t\tget: function get() {\n\t\t\t\t// intensity = power per solid angle.\n\t\t\t\t// ref: equation (15) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t\t\t\treturn this.intensity * 4 * Math.PI;\n\t\t\t},\n\t\t\tset: function set(power) {\n\t\t\t\t// intensity = power per solid angle.\n\t\t\t\t// ref: equation (15) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t\t\t\tthis.intensity = power / (4 * Math.PI);\n\t\t\t}\n\t\t});\n\t\tthis.distance = distance !== undefined ? distance : 0;\n\t\tthis.decay = decay !== undefined ? decay : 1; // for physically correct lights, should be 2.\n\n\t\tthis.shadow = new PointLightShadow();\n\t}\n\n\tPointLight.prototype = Object.assign(Object.create(Light.prototype), {\n\t\tconstructor: PointLight,\n\t\tisPointLight: true,\n\t\tcopy: function copy(source) {\n\t\t\tLight.prototype.copy.call(this, source);\n\t\t\tthis.distance = source.distance;\n\t\t\tthis.decay = source.decay;\n\t\t\tthis.shadow = source.shadow.clone();\n\t\t\treturn this;\n\t\t}\n\t});
1\n\n\tfunction OrthographicCamera(left, right, top, bottom, near, far) {\n\t\tif (left === void 0) {\n\t\t\tleft = -1;\n\t\t}\n\n\t\tif (right === void 0) {\n\t\t\tright = 1;\n\t\t}\n\n\t\tif (top === void 0) {\n\t\t\ttop = 1;\n\t\t}\n\n\t\tif (bottom === void 0) {\n\t\t\tbottom = -1;\n\t\t}\n\n\t\tif (near === void 0) {\n\t\t\tnear = 0.1;\n\t\t}\n\n\t\tif (far === void 0) {\n\t\t\tfar = 2000;\n\t\t}\n\n\t\tCamera.call(this);\n\t\tthis.type = 'OrthographicCamera';\n\t\tthis.zoom = 1;\n\t\tthis.view = null;\n\t\tthis.left = left;\n\t\tthis.right = right;\n\t\tthis.top = top;\n\t\tthis.bottom = bottom;\n\t\tthis.near = near;\n\t\tthis.far = far;\n\t\tthis.updateProjectionMatrix();\n\t}\n\n\tOrthographicCamera.prototype = Object.assign(Object.create(Camera.prototype), {\n\t\tconstructor: OrthographicCamera,\n\t\tisOrthographicCamera: true,\n\t\tcopy: function copy(source, recursive) {\n\t\t\tCamera.prototype.copy.call(this, source, recursive);\n\t\t\tthis.left = source.left;\n\t\t\tthis.right = source.right;\n\t\t\tthis.top = source.top;\n\t\t\tthis.bottom = source.bottom;\n\t\t\tthis.near = source.near;\n\t\t\tthis.far = source.far;\n\t\t\tthis.zoom = source.zoom;\n\t\t\tthis.view = source.view === null ? null : Object.assign({}, source.view);\n\t\t\treturn this;\n\t\t},\n\t\tsetViewOffset: function setViewOffset(fullWidth, fullHeight, x, y, width, height) {\n\t\t\tif (this.view === null) {\n\t\t\t\tthis.view = {\n\t\t\t\t\tenabled: true,\n\t\t\t\t\tfullWidth: 1,\n\t\t\t\t\tfullHeight: 1,\n\t\t\t\t\toffsetX: 0,\n\t\t\t\t\toffsetY: 0,\n\t\t\t\t\twidth: 1,\n\t\t\t\t\theight: 1\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tthis.view.enabled = true;\n\t\t\tthis.view.fullWidth = fullWidth;\n\t\t\tthis.view.fullHeight = fullHeight;\n\t\t\tthis.view.offsetX = x;\n\t\t\tthis.view.offsetY = y;\n\t\t\tthis.view.width = width;\n\t\t\tthis.view.height = height;\n\t\t\tthis.updateProjectionMatrix();\n\t\t},\n\t\tclearViewOffset: function clearViewOffset() {\n\t\t\tif (this.view !== null) {\n\t\t\t\tthis.view.enabled = false;\n\t\t\t}\n\n\t\t\tthis.updateProjectionMatrix();\n\t\t},\n\t\tupdateProjectionMatrix: function updateProjectionMatrix() {\n\t\t\tvar dx = (this.right - this.left) / (2 * this.zoom);\n\t\t\tvar dy = (this.top - this.bottom) / (2 * this.zoom);\n\t\t\tvar cx = (this.right + this.left) / 2;\n\t\t\tvar cy = (this.top + this.bottom) / 2;\n\t\t\tvar left = cx - dx;\n\t\t\tvar right = cx + dx;\n\t\t\tvar top = cy + dy;\n\t\t\tvar bottom = cy - dy;\n\n\t\t\tif (this.view !== null && this.view.enabled) {\n\t\t\t\tvar scaleW = (this.right - this.left) / this.view.fullWidth / this.zoom;\n\t\t\t\tvar scaleH = (this.top - this.bottom) / this.view.fullHeight / this.zoom;\n\t\t\t\tleft += scaleW * this.view.offsetX;\n\t\t\t\tright = left + scaleW * this.view.width;\n\t\t\t\ttop -= scaleH * this.view.offsetY;\n\t\t\t\tbottom = top - scaleH * this.view.height;\n\t\t\t}\n\n\t\t\tthis.projectionMatrix.makeOrthographic(left, right, top, bottom, this.near, this.far);\n\t\t\tthis.projectionMatrixInverse.copy(this.projectionMatrix).invert();\n\t\t},\n\t\ttoJSON: function toJSON(meta) {\n\t\t\tvar data = Object3D.prototype.toJSON.call(this, meta);\n\t\t\tdata.object.zoom = this.zoom;\n\t\t\tdata.object.left = this.left;\n\t\t\tdata.object.right = this.right;\n\t\t\tdata.object.top = this.top;\n\t\t\tdata.object.bottom = this.bottom;\n\t\t\tdata.object.near = this.near;\n\t\t\tdata.object.far = this.far;\n\t\t\tif (this.view !== null) data.object.view = Object.assign({}, this.view);\n\t\t\treturn data;\n\t\t}\n\t});\n\n\tfunction DirectionalLightShadow() {\n\t\tLightShadow.call(this, new OrthographicCamera(-5, 5, 5, -5, 0.5, 500));\n\t}\n\n\tDirectionalLightShadow.prototype = Object.assign(Object.create(LightShadow.prototype), {\n\t\tconstructor: DirectionalLightShadow,\n\t\tisDirectionalLightShadow: true,\n\t\tupdateMatrices: function updateMatrices(light) {\n\t\t\tLightShadow.prototype.updateMatrices.call(this, light);\n\t\t}\n\t});\n\n\tfunction DirectionalLight(color, intensity) {\n\t\tLight.call(this, color, intensity);\n\t\tthis.type = 'DirectionalLight';\n\t\tthis.position.copy(Object3D.DefaultUp);\n\t\tthis.updateMatrix();\n\t\tthis.target = new Object3D();\n\t\tthis.shadow = new DirectionalLightShadow();\n\t}\n\n\tDirectionalLight.prototype = Object.assign(Object.create(Light.prototype), {\n\t\tconstructor: DirectionalLight,\n\t\tisDirectionalLight: true,\n\t\tcopy: function copy(source) {\n\t\t\tLight.prototype.copy.call(this, source);\n\t\t\tthis.target = source.target.clone();\n\t\t\tthis.shadow = source.shadow.clone();\n\t\t\treturn this;\n\t\t}\n\t});\n\n\tfunction AmbientLight(color, intensity) {\n\t\tLight.call(this, color, intensity);\n\t\tthis.type = 'AmbientLight';\n\t}\n\n\tAmbientLight.prototype = Object.assign(Object.create(Light.prototype), {\n\t\tconstructor: AmbientLight,\n\t\tisAmbientLight: true\n\t});\n\n\tfunction RectAreaLight(color, intensity, width, height) {\n\t\tLight.call(this, color, intensity);\n\t\tthis.type = 'RectAreaLight';\n\t\tthis.width = width !== undefined ? width : 10;\n\t\tthis.height = height !== undefined ? height : 10;\n\t}\n\n\tRectAreaLight.prototype = Object.assign(Object.create(Light.prototype), {\n\t\tconstructor: RectAreaLight,\n\t\tisRectAreaLight: true,\n\t\tcopy: function copy(source) {\n\t\t\tLight.prototype.copy.call(this, source);\n\t\t\tthis.width = source.width;\n\t\t\tthis.height = source.height;\n\t\t\treturn this;\n\t\t},\n\t\ttoJSON: function toJSON(meta) {\n\t\t\tvar data = Light.prototype.toJSON.call(this, meta);\n\t\t\tdata.object.width = this.width;\n\t\t\tdata.object.height = this.height;\n\t\t\treturn data;\n\t\t}\n\t});\n\n\t/**\n\t * Primary reference:\n\t *\t https://graphics.stanford.edu/papers/envmap/envmap.pdf\n\t *\n\t * Secondary reference:\n\t *\t https://www.ppsloan.org/publications/StupidSH36.pdf\n\t */\n\t// 3-band SH defined by 9 coefficients\n\n\tvar SphericalHarmonics3 = /*#__PURE__*/function () {\n\t\tfunction SphericalHarmonics3() {\n\t\t\tObject.defineProperty(this, 'isSphericalHarmonics3', {\n\t\t\t\tvalue: true\n\t\t\t});\n\t\t\tthis.coefficients = [];\n\n\t\t\tfor (var i = 0; i < 9;
1 i++) {\n\t\t\t\tthis.coefficients.push(new Vector3());\n\t\t\t}\n\t\t}\n\n\t\tvar _proto = SphericalHarmonics3.prototype;\n\n\t\t_proto.set = function set(coefficients) {\n\t\t\tfor (var i = 0; i < 9; i++) {\n\t\t\t\tthis.coefficients[i].copy(coefficients[i]);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.zero = function zero() {\n\t\t\tfor (var i = 0; i < 9; i++) {\n\t\t\t\tthis.coefficients[i].set(0, 0, 0);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t} // get the radiance in the direction of the normal\n\t\t// target is a Vector3\n\t\t;\n\n\t\t_proto.getAt = function getAt(normal, target) {\n\t\t\t// normal is assumed to be unit length\n\t\t\tvar x = normal.x,\n\t\t\t\t\ty = normal.y,\n\t\t\t\t\tz = normal.z;\n\t\t\tvar coeff = this.coefficients; // band 0\n\n\t\t\ttarget.copy(coeff[0]).multiplyScalar(0.282095); // band 1\n\n\t\t\ttarget.addScaledVector(coeff[1], 0.488603 * y);\n\t\t\ttarget.addScaledVector(coeff[2], 0.488603 * z);\n\t\t\ttarget.addScaledVector(coeff[3], 0.488603 * x); // band 2\n\n\t\t\ttarget.addScaledVector(coeff[4], 1.092548 * (x * y));\n\t\t\ttarget.addScaledVector(coeff[5], 1.092548 * (y * z));\n\t\t\ttarget.addScaledVector(coeff[6], 0.315392 * (3.0 * z * z - 1.0));\n\t\t\ttarget.addScaledVector(coeff[7], 1.092548 * (x * z));\n\t\t\ttarget.addScaledVector(coeff[8], 0.546274 * (x * x - y * y));\n\t\t\treturn target;\n\t\t} // get the irradiance (radiance convolved with cosine lobe) in the direction of the normal\n\t\t// target is a Vector3\n\t\t// https://graphics.stanford.edu/papers/envmap/envmap.pdf\n\t\t;\n\n\t\t_proto.getIrradianceAt = function getIrradianceAt(normal, target) {\n\t\t\t// normal is assumed to be unit length\n\t\t\tvar x = normal.x,\n\t\t\t\t\ty = normal.y,\n\t\t\t\t\tz = normal.z;\n\t\t\tvar coeff = this.coefficients; // band 0\n\n\t\t\ttarget.copy(coeff[0]).multiplyScalar(0.886227); // Ï * 0.282095\n\t\t\t// band 1\n\n\t\t\ttarget.addScaledVector(coeff[1], 2.0 * 0.511664 * y); // ( 2 * Ï / 3 ) * 0.488603\n\n\t\t\ttarget.addScaledVector(coeff[2], 2.0 * 0.511664 * z);\n\t\t\ttarget.addScaledVector(coeff[3], 2.0 * 0.511664 * x); // band 2\n\n\t\t\ttarget.addScaledVector(coeff[4], 2.0 * 0.429043 * x * y); // ( Ï / 4 ) * 1.092548\n\n\t\t\ttarget.addScaledVector(coeff[5], 2.0 * 0.429043 * y * z);\n\t\t\ttarget.addScaledVector(coeff[6], 0.743125 * z * z - 0.247708); // ( Ï / 4 ) * 0.315392 * 3\n\n\t\t\ttarget.addScaledVector(coeff[7], 2.0 * 0.429043 * x * z);\n\t\t\ttarget.addScaledVector(coeff[8], 0.429043 * (x * x - y * y)); // ( Ï / 4 ) * 0.546274\n\n\t\t\treturn target;\n\t\t};\n\n\t\t_proto.add = function add(sh) {\n\t\t\tfor (var i = 0; i < 9; i++) {\n\t\t\t\tthis.coefficients[i].add(sh.coefficients[i]);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.addScaledSH = function addScaledSH(sh, s) {\n\t\t\tfor (var i = 0; i < 9; i++) {\n\t\t\t\tthis.coefficients[i].addScaledVector(sh.coefficients[i], s);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.scale = function scale(s) {\n\t\t\tfor (var i = 0; i < 9; i++) {\n\t\t\t\tthis.coefficients[i].multiplyScalar(s);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.lerp = function lerp(sh, alpha) {\n\t\t\tfor (var i = 0; i < 9; i++) {\n\t\t\t\tthis.coefficients[i].lerp(sh.coefficients[i], alpha);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.equals = function equals(sh) {\n\t\t\tfor (var i = 0; i < 9; i++) {\n\t\t\t\tif (!this.coefficients[i].equals(sh.coefficients[i])) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn true;\n\t\t};\n\n\t\t_proto.copy = function copy(sh) {\n\t\t\treturn this.set(sh.coefficients);\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t};\n\n\t\t_proto.fromArray = function fromArray(array, offset) {\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tvar coefficients = this.coefficients;\n\n\t\t\tfor (var i = 0; i < 9; i++) {\n\t\t\t\tcoefficients[i].fromArray(array, offset + i * 3);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.toArray = function toArray(array, offset) {\n\t\t\tif (array === void 0) {\n\t\t\t\tarray = [];\n\t\t\t}\n\n\t\t\tif (offset === void 0) {\n\t\t\t\toffset = 0;\n\t\t\t}\n\n\t\t\tvar coefficients = this.coefficients;\n\n\t\t\tfor (var i = 0; i < 9;
1 i++) {\n\t\t\t\tcoefficients[i].toArray(array, offset + i * 3);\n\t\t\t}\n\n\t\t\treturn array;\n\t\t} // evaluate the basis functions\n\t\t// shBasis is an Array[ 9 ]\n\t\t;\n\n\t\tSphericalHarmonics3.getBasisAt = function getBasisAt(normal, shBasis) {\n\t\t\t// normal is assumed to be unit length\n\t\t\tvar x = normal.x,\n\t\t\t\t\ty = normal.y,\n\t\t\t\t\tz = normal.z; // band 0\n\n\t\t\tshBasis[0] = 0.282095; // band 1\n\n\t\t\tshBasis[1] = 0.488603 * y;\n\t\t\tshBasis[2] = 0.488603 * z;\n\t\t\tshBasis[3] = 0.488603 * x; // band 2\n\n\t\t\tshBasis[4] = 1.092548 * x * y;\n\t\t\tshBasis[5] = 1.092548 * y * z;\n\t\t\tshBasis[6] = 0.315392 * (3 * z * z - 1);\n\t\t\tshBasis[7] = 1.092548 * x * z;\n\t\t\tshBasis[8] = 0.546274 * (x * x - y * y);\n\t\t};\n\n\t\treturn SphericalHarmonics3;\n\t}();\n\n\tfunction LightProbe(sh, intensity) {\n\t\tLight.call(this, undefined, intensity);\n\t\tthis.type = 'LightProbe';\n\t\tthis.sh = sh !== undefined ? sh : new SphericalHarmonics3();\n\t}\n\n\tLightProbe.prototype = Object.assign(Object.create(Light.prototype), {\n\t\tconstructor: LightProbe,\n\t\tisLightProbe: true,\n\t\tcopy: function copy(source) {\n\t\t\tLight.prototype.copy.call(this, source);\n\t\t\tthis.sh.copy(source.sh);\n\t\t\treturn this;\n\t\t},\n\t\tfromJSON: function fromJSON(json) {\n\t\t\tthis.intensity = json.intensity; // TODO: Move this bit to Light.fromJSON();\n\n\t\t\tthis.sh.fromArray(json.sh);\n\t\t\treturn this;\n\t\t},\n\t\ttoJSON: function toJSON(meta) {\n\t\t\tvar data = Light.prototype.toJSON.call(this, meta);\n\t\t\tdata.object.sh = this.sh.toArray();\n\t\t\treturn data;\n\t\t}\n\t});\n\n\tfunction MaterialLoader(manager) {\n\t\tLoader.call(this, manager);\n\t\tthis.textures = {};\n\t}\n\n\tMaterialLoader.prototype = Object.assign(Object.create(Loader.prototype), {\n\t\tconstructor: MaterialLoader,\n\t\tload: function load(url, onLoad, onProgress, onError) {\n\t\t\tvar scope = this;\n\t\t\tvar loader = new FileLoader(scope.manager);\n\t\t\tloader.setPath(scope.path);\n\t\t\tloader.setRequestHeader(scope.requestHeader);\n\t\t\tloader.setWithCredentials(scope.withCredentials);\n\t\t\tloader.load(url, function (text) {\n\t\t\t\ttry {\n\t\t\t\t\tonLoad(scope.parse(JSON.parse(text)));\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (onError) {\n\t\t\t\t\t\tonError(e);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error(e);\n\t\t\t\t\t}\n\n\t\t\t\t\tscope.manager.itemError(url);\n\t\t\t\t}\n\t\t\t}, onProgress, onError);\n\t\t},\n\t\tparse: function parse(json) {\n\t\t\tvar textures = this.textures;\n\n\t\t\tfunction getTexture(name) {\n\t\t\t\tif (textures[name] === undefined) {\n\t\t\t\t\tconsole.warn('THREE.MaterialLoader: Undefined texture', name);\n\t\t\t\t}\n\n\t\t\t\treturn textures[name];\n\t\t\t}\n\n\t\t\tvar material = new Materials[json.type]();\n\t\t\tif (json.uuid !== undefined) material.uuid = json.uuid;\n\t\t\tif (json.name !== undefined) material.name = json.name;\n\t\t\tif (json.color !== undefined && material.color !== undefined) material.color.setHex(json.color);\n\t\t\tif (json.roughness !== undefined) material.roughness = json.roughness;\n\t\t\tif (json.metalness !== undefined) material.metalness = json.metalness;\n\t\t\tif (json.sheen !== undefined) material.sheen = new Color().setHex(json.sheen);\n\t\t\tif (json.emissive !== undefined && material.emissive !== undefined) material.emissive.setHex(json.emissive);\n\t\t\tif (json.specular !== undefined && material.specular !== undefined) material.specular.setHex(json.specular);\n\t\t\tif (json.shininess !== undefined) material.shininess = json.shininess;\n\t\t\tif (json.clearcoat !== undefined) material.clearcoat = json.clearcoat;\n\t\t\tif (json.clearcoatRoughness !== undefined) material.clearcoatRoughness = json.clearcoatRoughness;\n\t\t\tif (json.fog !== undefined) material.fog = json.fog;\n\t\t\tif (json.flatShading !== undefined) material.flatShading = json.flatShading;\n\t\t\tif (json.blending !== undefined) material.blending = json.blending;\n\t\t\tif (json.combine !== undefined) material.combine = json.combine;\n\t\t\tif (json.side !== undefined) material.side = json.side;\n\t\t\tif (json.opacity !== undefined) material.opacity = json.opacity;\n\t\t\tif (json.transparent !== undefined) material.transparent = json.transparent;\n\t\t\tif (json.alphaTest !== undefined) material.alphaTest = json.alphaTest;\n\t\t\tif (json.depthTest !== undefined) material.depthTest = json.depthTest;\n\t\t\tif (json.depthWrite !== undefined) material.depthWrite = json.depthWrite;\n\t\t\tif (json.colorWrite !== undefined) material.colorWrite = json.colorWrite;\n\t\t\tif (json.stencilWrite !== undefined) material.stencilWrite = json.stencilWrite;\n\t\t\tif (json.stencilWriteMask !== undefined) material.stencilWriteMask = json.stencilWriteMask;\n\t\t\tif (json.stencilFunc !== undefined) material.stencilFunc = json.stencilFunc;\n\t\t\tif (json.stencilRef !== undefined) material.stencilRef = json.stencilRef;\n\t\t\tif (json.stencilFuncMask !== undefined) material.stencilFuncMask = json.stencilFuncMask;
1\n\t\t\tif (json.stencilFail !== undefined) material.stencilFail = json.stencilFail;\n\t\t\tif (json.stencilZFail !== undefined) material.stencilZFail = json.stencilZFail;\n\t\t\tif (json.stencilZPass !== undefined) material.stencilZPass = json.stencilZPass;\n\t\t\tif (json.wireframe !== undefined) material.wireframe = json.wireframe;\n\t\t\tif (json.wireframeLinewidth !== undefined) material.wireframeLinewidth = json.wireframeLinewidth;\n\t\t\tif (json.wireframeLinecap !== undefined) material.wireframeLinecap = json.wireframeLinecap;\n\t\t\tif (json.wireframeLinejoin !== undefined) material.wireframeLinejoin = json.wireframeLinejoin;\n\t\t\tif (json.rotation !== undefined) material.rotation = json.rotation;\n\t\t\tif (json.linewidth !== 1) material.linewidth = json.linewidth;\n\t\t\tif (json.dashSize !== undefined) material.dashSize = json.dashSize;\n\t\t\tif (json.gapSize !== undefined) material.gapSize = json.gapSize;\n\t\t\tif (json.scale !== undefined) material.scale = json.scale;\n\t\t\tif (json.polygonOffset !== undefined) material.polygonOffset = json.polygonOffset;\n\t\t\tif (json.polygonOffsetFactor !== undefined) material.polygonOffsetFactor = json.polygonOffsetFactor;\n\t\t\tif (json.polygonOffsetUnits !== undefined) material.polygonOffsetUnits = json.polygonOffsetUnits;\n\t\t\tif (json.skinning !== undefined) material.skinning = json.skinning;\n\t\t\tif (json.morphTargets !== undefined) material.morphTargets = json.morphTargets;\n\t\t\tif (json.morphNormals !== undefined) material.morphNormals = json.morphNormals;\n\t\t\tif (json.dithering !== undefined) material.dithering = json.dithering;\n\t\t\tif (json.vertexTangents !== undefined) material.vertexTangents = json.vertexTangents;\n\t\t\tif (json.visible !== undefined) material.visible = json.visible;\n\t\t\tif (json.toneMapped !== undefined) material.toneMapped = json.toneMapped;\n\t\t\tif (json.userData !== undefined) material.userData = json.userData;\n\n\t\t\tif (json.vertexColors !== undefined) {\n\t\t\t\tif (typeof json.vertexColors === 'number') {\n\t\t\t\t\tmaterial.vertexColors = json.vertexColors > 0 ? true : false;\n\t\t\t\t} else {\n\t\t\t\t\tmaterial.vertexColors = json.vertexColors;\n\t\t\t\t}\n\t\t\t} // Shader Material\n\n\n\t\t\tif (json.uniforms !== undefined) {\n\t\t\t\tfor (var name in json.uniforms) {\n\t\t\t\t\tvar uniform = json.uniforms[name];\n\t\t\t\t\tmaterial.uniforms[name] = {};\n\n\t\t\t\t\tswitch (uniform.type) {\n\t\t\t\t\t\tcase 't':\n\t\t\t\t\t\t\tmaterial.uniforms[name].value = getTexture(uniform.value);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'c':\n\t\t\t\t\t\t\tmaterial.uniforms[name].value = new Color().setHex(uniform.value);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'v2':\n\t\t\t\t\t\t\tmaterial.uniforms[name].value = new Vector2().fromArray(uniform.value);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'v3':\n\t\t\t\t\t\t\tmaterial.uniforms[name].value = new Vector3().fromArray(uniform.value);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'v4':\n\t\t\t\t\t\t\tmaterial.uniforms[name].value = new Vector4().fromArray(uniform.value);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'm3':\n\t\t\t\t\t\t\tmaterial.uniforms[name].value = new Matrix3().fromArray(uniform.value);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'm4':\n\t\t\t\t\t\t\tmaterial.uniforms[name].value = new Matrix4().fromArray(uniform.value);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tmaterial.uniforms[name].value = uniform.value;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (json.defines !== undefined) material.defines = json.defines;\n\t\t\tif (json.vertexShader !== undefined) material.vertexShader = json.vertexShader;\n\t\t\tif (json.fragmentShader !== undefined) material.fragmentShader = json.fragmentShader;\n\n\t\t\tif (json.extensions !== undefined) {\n\t\t\t\tfor (var key in json.extensions) {\n\t\t\t\t\tmaterial.extensions[key] = json.extensions[key];\n\t\t\t\t}\n\t\t\t} // Deprecated\n\n\n\t\t\tif (json.shading !== undefined) material.flatShading = json.shading === 1; // THREE.FlatShading\n\t\t\t// for PointsMaterial\n\n\t\t\tif (json.size !== undefined) material.size = json.size;\n\t\t\tif (json.sizeAttenuation !== undefined) material.sizeAttenuation = json.sizeAttenuation; // maps\n\n\t\t\tif (json.map !== undefined) material.map = getTexture(json.map);\n\t\t\tif (json.matcap !== undefined) material.matcap = getTexture(json.matcap);\n\t\t\tif (json.alphaMap !== undefined) material.alphaMap = getTexture(json.alphaMap);\n\t\t\tif (json.bumpMap !== undefined) material.bumpMap = getTexture(json.bumpMap);\n\t\t\tif (json.bumpScale !== undefined) material.bumpScale = json.bumpScale;\n\t\t\tif (json.normalMap !== undefined) material.normalMap = getTexture(json.normalMap);\n\t\t\tif (json.normalMapType !== undefined) material.normalMapType = json.normalMapType;\n\n\t\t\tif (json.normalScale !== undefined) {\n\t\t\t\tvar normalScale = json.normalScale;\n\n\t\t\t\tif (Array.isArray(normalScale) === false) {\n\t\t\t\t\t// Blender exporter used to export a scalar. See #7459\n\t\t\t\t\tnormalScale = [normalScale, normalScale];\n\t\t\t\t}\n\n\t\t\t\tmaterial.normalScale = new Vector2().fromArray(normalScale);\n\t\t\t}\n\n\t\t\tif (json.displacementMap !== undefined) material.displacementMap = getTexture(json.displacementMap);\n\t\t\tif (json.displacementScale !== undefined) material.displacementScale = json.displacementScale;\n\t\t\tif (json.displacementBias !== undefined) material.displacementBias = json.displacementBias;\n\t\t\tif (json.roughnessMap !== undefined) material.roughnessMap = getTexture(json.roughnessMap);\n\t\t\tif (json.metalnessMap !== undefined) material.metalnessMap = getTexture(json.metalnessMap);\n\t\t\tif (json.emissiveMap !== undefined) material.emissiveMap = getTexture(json.emissiveMap);\n\t\t\tif (json.emissiveIntensity !== undefined) material.emissiveIntensity = json.emissiveIntensity;\n\t\t\tif (json.specularMap !== undefined) material.specularMap = getTexture(json.specularMap);\n\t\t\tif (json.envMap !== undefined) material.envMap = getTexture(json.envMap);\n\t\t\tif (json.envMapIntensity !== undefined) material.envMapIntensity = json.envMapIntensity;\n\t\t\tif (json.reflectivity !== undefined) material.reflectivity = json.reflectivity;\n\t\t\tif (json.refractionRatio !== undefined) material.refractionRatio = json.refractionRatio;\n\t\t\tif (json.lightMap !== undefined) material.lightMap = getTexture(json.lightMap);\n\t\t\tif (json.lightMapIntensity !== undefined) material.lightMapIntensity = json.lightMapIntensity;\n\t\t\tif (json.aoMap !== undefined) material.aoMap = getTexture(json.aoMap);\n\t\t\tif (json.aoMapIntensity !== undefined) material.aoMapIntensity = json.aoMapIntensity;\n\t\t\tif (json.gradientMap !== undefined) material.gradientMap = getTexture(json.gradientMap);\n\t\t\tif (json.clearcoatMap !== undefined) material.clearcoatMap = getTexture(json.clearcoatMap);\n\t\t\tif (json.clearcoatRoughnessMap !== undefined) material.clearcoatRoughnessMap = getTexture(json.clearcoatRoughnessMap);\n\t\t\tif (json.clearcoatNormalMap !== undefined) material.clearcoatNormalMap = getTexture(json.clearcoatNormalMap);\n\t\t\tif (json.clearcoatNormalScale !== undefined) material.clearcoatNormalScale = new Vector2().fromArray(json.clearcoatNormalScale);\n\t\t\tif (json.transmission !== undefined) material.transmission = json.transmission;\n\t\t\tif (json.transmissionMap !== undefined) material.transmissionMap = getTexture(json.transmissionMap);\n\t\t\treturn material;\n\t\t},\n\t\tsetTextures: function setTextures(value) {\n\t\t\tthis.textures = value;\n\t\t\treturn this;\n\t\t}\n\t});\n\n\tvar LoaderUtils = {\n\t\tdecodeText: function decodeText(array) {\n\t\t\tif (typeof TextDecoder !== 'undefined') {\n\t\t\t\treturn new TextDecoder().decode(array);\n\t\t\t} // Avoid the String.fromCharCode.apply(null, array) shortcut, which\n\t\t\t// throws a \"maximum call stack size exceeded\" error for large arrays.\n\n\n\t\t\tvar s = '';\n\n\t\t\tfor (var i = 0, il = array.length; i < il;
1 i++) {\n\t\t\t\t// Implicitly assumes little-endian.\n\t\t\t\ts += String.fromCharCode(array[i]);\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\t// merges multi-byte utf-8 characters.\n\t\t\t\treturn decodeURIComponent(escape(s));\n\t\t\t} catch (e) {\n\t\t\t\t// see #16358\n\t\t\t\treturn s;\n\t\t\t}\n\t\t},\n\t\textractUrlBase: function extractUrlBase(url) {\n\t\t\tvar index = url.lastIndexOf('/');\n\t\t\tif (index === -1) return './';\n\t\t\treturn url.substr(0, index + 1);\n\t\t}\n\t};\n\n\tfunction InstancedBufferGeometry() {\n\t\tBufferGeometry.call(this);\n\t\tthis.type = 'InstancedBufferGeometry';\n\t\tthis.instanceCount = Infinity;\n\t}\n\n\tInstancedBufferGeometry.prototype = Object.assign(Object.create(BufferGeometry.prototype), {\n\t\tconstructor: InstancedBufferGeometry,\n\t\tisInstancedBufferGeometry: true,\n\t\tcopy: function copy(source) {\n\t\t\tBufferGeometry.prototype.copy.call(this, source);\n\t\t\tthis.instanceCount = source.instanceCount;\n\t\t\treturn this;\n\t\t},\n\t\tclone: function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t},\n\t\ttoJSON: function toJSON() {\n\t\t\tvar data = BufferGeometry.prototype.toJSON.call(this);\n\t\t\tdata.instanceCount = this.instanceCount;\n\t\t\tdata.isInstancedBufferGeometry = true;\n\t\t\treturn data;\n\t\t}\n\t});\n\n\tfunction InstancedBufferAttribute(array, itemSize, normalized, meshPerAttribute) {\n\t\tif (typeof normalized === 'number') {\n\t\t\tmeshPerAttribute = normalized;\n\t\t\tnormalized = false;\n\t\t\tconsole.error('THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.');\n\t\t}\n\n\t\tBufferAttribute.call(this, array, itemSize, normalized);\n\t\tthis.meshPerAttribute = meshPerAttribute || 1;\n\t}\n\n\tInstancedBufferAttribute.prototype = Object.assign(Object.create(BufferAttribute.prototype), {\n\t\tconstructor: InstancedBufferAttribute,\n\t\tisInstancedBufferAttribute: true,\n\t\tcopy: function copy(source) {\n\t\t\tBufferAttribute.prototype.copy.call(this, source);\n\t\t\tthis.meshPerAttribute = source.meshPerAttribute;\n\t\t\treturn this;\n\t\t},\n\t\ttoJSON: function toJSON() {\n\t\t\tvar data = BufferAttribute.prototype.toJSON.call(this);\n\t\t\tdata.meshPerAttribute = this.meshPerAttribute;\n\t\t\tdata.isInstancedBufferAttribute = true;\n\t\t\treturn data;\n\t\t}\n\t});\n\n\tfunction BufferGeometryLoader(manager) {\n\t\tLoader.call(this, manager);\n\t}\n\n\tBufferGeometryLoader.prototype = Object.assign(Object.create(Loader.prototype), {\n\t\tconstructor: BufferGeometryLoader,\n\t\tload: function load(url, onLoad, onProgress, onError) {\n\t\t\tvar scope = this;\n\t\t\tvar loader = new FileLoader(scope.manager);\n\t\t\tloader.setPath(scope.path);\n\t\t\tloader.setRequestHeader(scope.requestHeader);\n\t\t\tloader.setWithCredentials(scope.withCredentials);\n\t\t\tloader.load(url, function (text) {\n\t\t\t\ttry {\n\t\t\t\t\tonLoad(scope.parse(JSON.parse(text)));\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (onError) {\n\t\t\t\t\t\tonError(e);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error(e);\n\t\t\t\t\t}\n\n\t\t\t\t\tscope.manager.itemError(url);\n\t\t\t\t}\n\t\t\t}, onProgress, onError);\n\t\t},\n\t\tparse: function parse(json) {\n\t\t\tvar interleavedBufferMap = {};\n\t\t\tvar arrayBufferMap = {};\n\n\t\t\tfunction getInterleavedBuffer(json, uuid) {\n\t\t\t\tif (interleavedBufferMap[uuid] !== undefined) return interleavedBufferMap[uuid];\n\t\t\t\tvar interleavedBuffers = json.interleavedBuffers;\n\t\t\t\tvar interleavedBuffer = interleavedBuffers[uuid];\n\t\t\t\tvar buffer = getArrayBuffer(json, interleavedBuffer.buffer);\n\t\t\t\tvar array = getTypedArray(interleavedBuffer.type, buffer);\n\t\t\t\tvar ib = new InterleavedBuffer(array, interleavedBuffer.stride);\n\t\t\t\tib.uuid = interleavedBuffer.uuid;\n\t\t\t\tinterleavedBufferMap[uuid] = ib;\n\t\t\t\treturn ib;\n\t\t\t}\n\n\t\t\tfunction getArrayBuffer(json, uuid) {\n\t\t\t\tif (arrayBufferMap[uuid] !== undefined) return arrayBufferMap[uuid];\n\t\t\t\tvar arrayBuffers = json.arrayBuffers;\n\t\t\t\tvar arrayBuffer = arrayBuffers[uuid];\n\t\t\t\tvar ab = new Uint32Array(arrayBuffer).buffer;\n\t\t\t\tarrayBufferMap[uuid] = ab;\n\t\t\t\treturn ab;\n\t\t\t}\n\n\t\t\tvar geometry = json.isInstancedBufferGeometry ? new InstancedBufferGeometry() : new BufferGeometry();\n\t\t\tvar index = json.data.index;\n\n\t\t\tif (index !== undefined) {\n\t\t\t\tvar typedArray = getTypedArray(index.t
1ype, index.array);\n\t\t\t\tgeometry.setIndex(new BufferAttribute(typedArray, 1));\n\t\t\t}\n\n\t\t\tvar attributes = json.data.attributes;\n\n\t\t\tfor (var key in attributes) {\n\t\t\t\tvar attribute = attributes[key];\n\t\t\t\tvar bufferAttribute = void 0;\n\n\t\t\t\tif (attribute.isInterleavedBufferAttribute) {\n\t\t\t\t\tvar interleavedBuffer = getInterleavedBuffer(json.data, attribute.data);\n\t\t\t\t\tbufferAttribute = new InterleavedBufferAttribute(interleavedBuffer, attribute.itemSize, attribute.offset, attribute.normalized);\n\t\t\t\t} else {\n\t\t\t\t\tvar _typedArray = getTypedArray(attribute.type, attribute.array);\n\n\t\t\t\t\tvar bufferAttributeConstr = attribute.isInstancedBufferAttribute ? InstancedBufferAttribute : BufferAttribute;\n\t\t\t\t\tbufferAttribute = new bufferAttributeConstr(_typedArray, attribute.itemSize, attribute.normalized);\n\t\t\t\t}\n\n\t\t\t\tif (attribute.name !== undefined) bufferAttribute.name = attribute.name;\n\t\t\t\tgeometry.setAttribute(key, bufferAttribute);\n\t\t\t}\n\n\t\t\tvar morphAttributes = json.data.morphAttributes;\n\n\t\t\tif (morphAttributes) {\n\t\t\t\tfor (var _key in morphAttributes) {\n\t\t\t\t\tvar attributeArray = morphAttributes[_key];\n\t\t\t\t\tvar array = [];\n\n\t\t\t\t\tfor (var i = 0, il = attributeArray.length; i < il; i++) {\n\t\t\t\t\t\tvar _attribute = attributeArray[i];\n\n\t\t\t\t\t\tvar _bufferAttribute = void 0;\n\n\t\t\t\t\t\tif (_attribute.isInterleavedBufferAttribute) {\n\t\t\t\t\t\t\tvar _interleavedBuffer = getInterleavedBuffer(json.data, _attribute.data);\n\n\t\t\t\t\t\t\t_bufferAttribute = new InterleavedBufferAttribute(_interleavedBuffer, _attribute.itemSize, _attribute.offset, _attribute.normalized);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvar _typedArray2 = getTypedArray(_attribute.type, _attribute.array);\n\n\t\t\t\t\t\t\t_bufferAttribute = new BufferAttribute(_typedArray2, _attribute.itemSize, _attribute.normalized);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (_attribute.name !== undefined) _bufferAttribute.name = _attribute.name;\n\t\t\t\t\t\tarray.push(_bufferAttribute);\n\t\t\t\t\t}\n\n\t\t\t\t\tgeometry.morphAttributes[_key] = array;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar morphTargetsRelative = json.data.morphTargetsRelative;\n\n\t\t\tif (morphTargetsRelative) {\n\t\t\t\tgeometry.morphTargetsRelative = true;\n\t\t\t}\n\n\t\t\tvar groups = json.data.groups || json.data.drawcalls || json.data.offsets;\n\n\t\t\tif (groups !== undefined) {\n\t\t\t\tfor (var _i = 0, n = groups.length; _i !== n; ++_i) {\n\t\t\t\t\tvar group = groups[_i];\n\t\t\t\t\tgeometry.addGroup(group.start, group.count, group.materialIndex);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar boundingSphere = json.data.boundingSphere;\n\n\t\t\tif (boundingSphere !== undefined) {\n\t\t\t\tvar center = new Vector3();\n\n\t\t\t\tif (boundingSphere.center !== undefined) {\n\t\t\t\t\tcenter.fromArray(boundingSphere.center);\n\t\t\t\t}\n\n\t\t\t\tgeometry.boundingSphere = new Sphere(center, boundingSphere.radius);\n\t\t\t}\n\n\t\t\tif (json.name) geometry.name = json.name;\n\t\t\tif (json.userData) geometry.userData = json.userData;\n\t\t\treturn geometry;\n\t\t}\n\t});\n\n\tvar ObjectLoader = /*#__PURE__*/function (_Loader) {\n\t\t_inheritsLoose(ObjectLoader, _Loader);\n\n\t\tfunction ObjectLoader(manager) {\n\t\t\treturn _Loader.call(this, manager) || this;\n\t\t}\n\n\t\tvar _proto = ObjectLoader.prototype;\n\n\t\t_proto.load = function load(url, onLoad, onProgress, onError) {\n\t\t\tvar scope = this;\n\t\t\tvar path = this.path === '' ? LoaderUtils.extractUrlBase(url) : this.path;\n\t\t\tthis.resourcePath = this.resourcePath || path;\n\t\t\tvar loader = new FileLoader(this.manager);\n\t\t\tloader.setPath(this.path);\n\t\t\tloader.setRequestHeader(this.requestHeader);\n\t\t\tloader.setWithCredentials(this.withCredentials);\n\t\t\tloader.load(url, function (text) {\n\t\t\t\tvar json = null;\n\n\t\t\t\ttry {\n\t\t\t\t\tjson = JSON.parse(text);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (onError !== undefined) onError(error);\n\t\t\t\t\tconsole.error('THREE:ObjectLoader: Can\\'t parse ' + url + '.', error.message);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tvar metadata = json.metadata;\n\n\t\t\t\tif (metadata === undefined || metadata.type === undefined || metadata.type.toLowerCase() === 'geometry') {\n\t\t\t\t\tconsole.error('THREE.ObjectLoader: Can\\'t load ' + url);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tscope.parse(json, onLoad);\n\t\t\t}, onProgress, onError);\n\t\t};\n\n\t\t_proto.parse = function parse(json, onLoad) {\n\t\t\tvar animations = this.parseAnimations(json.animations);\n\t\t\tvar shapes = this.parseShapes(json.shapes);\n\t\t\tvar geometries = this.parseGeometries(json.geometries, shapes);\n\t\t\tvar images = this.parseImages(json.images, function () {\n\t\t\t\tif (onLoad !== undefined) onLoad(object);\n\t\t\t});\n\t\t\tvar textures = this.parseTextures(json.textures, images);\n\t\t\tvar materials = this.parseMaterials(json.materials, textures);\n\t\t\tvar object = this.parseObject(json.object, geometries, materials, animations);\n\t\t\tvar skeletons = this.parseSkeletons(json.skeletons, object);\n\t\t\tthis.bindSkeletons(object, skeletons); //\n\n\t\t\tif (onLoad !== undefined) {\n\t\t\t\tvar hasImages = false;\n\n\t\t\t\tfor (var uuid in images) {\n\t\t\t\t\tif (images[uuid] instanceof HTMLImageElement) {\n\t\t\t\t\t\thasImages = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (hasImages === false) onLoad(object);\n\t\t\t}\n\n\t\t\treturn object;\n\t\t};\n\n\t\t_proto.parseShapes = function parseShapes(json) {\n\t\t\tvar shapes = {};\n\n\t\t\tif (json !== undefined) {\n\t\t\t\tfor (var i = 0, l = json.length; i < l;
1 i++) {\n\t\t\t\t\tvar shape = new Shape().fromJSON(json[i]);\n\t\t\t\t\tshapes[shape.uuid] = shape;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn shapes;\n\t\t};\n\n\t\t_proto.parseSkeletons = function parseSkeletons(json, object) {\n\t\t\tvar skeletons = {};\n\t\t\tvar bones = {}; // generate bone lookup table\n\n\t\t\tobject.traverse(function (child) {\n\t\t\t\tif (child.isBone) bones[child.uuid] = child;\n\t\t\t}); // create skeletons\n\n\t\t\tif (json !== undefined) {\n\t\t\t\tfor (var i = 0, l = json.length; i < l; i++) {\n\t\t\t\t\tvar skeleton = new Skeleton().fromJSON(json[i], bones);\n\t\t\t\t\tskeletons[skeleton.uuid] = skeleton;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn skeletons;\n\t\t};\n\n\t\t_proto.parseGeometries = function parseGeometries(json, shapes) {\n\t\t\tvar geometries = {};\n\t\t\tvar geometryShapes;\n\n\t\t\tif (json !== undefined) {\n\t\t\t\tvar bufferGeometryLoader = new BufferGeometryLoader();\n\n\t\t\t\tfor (var i = 0, l = json.length; i < l; i++) {\n\t\t\t\t\tvar geometry = void 0;\n\t\t\t\t\tvar data = json[i];\n\n\t\t\t\t\tswitch (data.type) {\n\t\t\t\t\t\tcase 'PlaneGeometry':\n\t\t\t\t\t\tcase 'PlaneBufferGeometry':\n\t\t\t\t\t\t\tgeometry = new Geometries[data.type](data.width, data.height, data.widthSegments, data.heightSegments);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'BoxGeometry':\n\t\t\t\t\t\tcase 'BoxBufferGeometry':\n\t\t\t\t\t\tcase 'CubeGeometry':\n\t\t\t\t\t\t\t// backwards compatible\n\t\t\t\t\t\t\tgeometry = new Geometries[data.type](data.width, data.height, data.depth, data.widthSegments, data.heightSegments, data.depthSegments);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'CircleGeometry':\n\t\t\t\t\t\tcase 'CircleBufferGeometry':\n\t\t\t\t\t\t\tgeometry = new Geometries[data.type](data.radius, data.segments, data.thetaStart, data.thetaLength);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'CylinderGeometry':\n\t\t\t\t\t\tcase 'CylinderBufferGeometry':\n\t\t\t\t\t\t\tgeometry = new Geometries[data.type](data.radiusTop, data.radiusBottom, data.height, data.radialSegments, data.heightSegments, data.openEnded, data.thetaStart, data.thetaLength);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'ConeGeometry':\n\t\t\t\t\t\tcase 'ConeBufferGeometry':\n\t\t\t\t\t\t\tgeometry = new Geometries[data.type](data.radius, data.height, data.radialSegments, data.heightSegments, data.openEnded, data.thetaStart, data.thetaLength);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'SphereGeometry':\n\t\t\t\t\t\tcase 'SphereBufferGeometry':\n\t\t\t\t\t\t\tgeometry = new Geometries[data.type](data.radius, data.widthSegments, data.heightSegments, data.phiStart, data.phiLength, data.thetaStart, data.thetaLength);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'DodecahedronGeometry':\n\t\t\t\t\t\tcase 'DodecahedronBufferGeometry':\n\t\t\t\t\t\tcase 'IcosahedronGeometry':\n\t\t\t\t\t\tcase 'IcosahedronBufferGeometry':\n\t\t\t\t\t\tcase 'OctahedronGeometry':\n\t\t\t\t\t\tcase 'OctahedronBufferGeometry':\n\t\t\t\t\t\tcase 'TetrahedronGeometry':\n\t\t\t\t\t\tcase 'TetrahedronBufferGeometry':\n\t\t\t\t\t\t\tgeometry = new Geometries[data.type](data.radius, data.detail);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'RingGeometry':\n\t\t\t\t\t\tcase 'RingBufferGeometry':\n\t\t\t\t\t\t\tgeometry = new Geometries[data.type](data.innerRadius, data.outerRadius, data.thetaSegments, data.phiSegments, data.thetaStart, data.thetaLength);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'TorusGeometry':\n\t\t\t\t\t\tcase 'TorusBufferGeometry':\n\t\t\t\t\t\t\tgeometry = new Geometries[data.type](data.radius, data.tube, data.radialSegments, data.tubularSegments, data.arc);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'TorusKnotGeometry':\n\t\t\t\t\t\tcase 'TorusKnotBufferGeometry':\n\t\t\t\t\t\t\tgeometry = new Geometries[data.type](data.radius, data.tube, data.tubularSegments, data.radialSegments, data.p, data.q);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'TubeGeometry':\n\t\t\t\t\t\tcase 'TubeBufferGeometry':\n\t\t\t\t\t\t\t// This only works for built-in curves (e.g. CatmullRomCurve3).\n\t\t\t\t\t\t\t// User defined curves or instances of CurvePath will not be deserialized.\n\t\t\t\t\t\t\tgeometry = new Geometries[data.type](new Curves[data.path.type]().fromJSON(data.path), data.tubularSegments, data.radius, data.radialSegments, data.closed);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'LatheGeometry':\n\t\t\t\t\t\tcase 'LatheBufferGeometry':\n\t\t\t\t\t\t\tgeometry = new Geometries[data.type](data.points, data.segments, data.phiStart, data.phiLength);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'PolyhedronGeometry':\n\t\t\t\t\t\tcase 'PolyhedronBufferGeometry':\n\t\t\t\t\t\t\tgeometry = new Geometries[data.type](data.vertices, data.indices, data.radius, data.details);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'ShapeGeometry':\n\t\t\t\t\t\tcase 'ShapeBufferGeometry':\n\t\t\t\t\t\t\tgeometryShapes = [];\n\n\t\t\t\t\t\t\tfor (var j = 0, jl = data.shapes.length; j < jl;
1 j++) {\n\t\t\t\t\t\t\t\tvar shape = shapes[data.shapes[j]];\n\t\t\t\t\t\t\t\tgeometryShapes.push(shape);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tgeometry = new Geometries[data.type](geometryShapes, data.curveSegments);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'ExtrudeGeometry':\n\t\t\t\t\t\tcase 'ExtrudeBufferGeometry':\n\t\t\t\t\t\t\tgeometryShapes = [];\n\n\t\t\t\t\t\t\tfor (var _j = 0, _jl = data.shapes.length; _j < _jl; _j++) {\n\t\t\t\t\t\t\t\tvar _shape = shapes[data.shapes[_j]];\n\t\t\t\t\t\t\t\tgeometryShapes.push(_shape);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tvar extrudePath = data.options.extrudePath;\n\n\t\t\t\t\t\t\tif (extrudePath !== undefined) {\n\t\t\t\t\t\t\t\tdata.options.extrudePath = new Curves[extrudePath.type]().fromJSON(extrudePath);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tgeometry = new Geometries[data.type](geometryShapes, data.options);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'BufferGeometry':\n\t\t\t\t\t\tcase 'InstancedBufferGeometry':\n\t\t\t\t\t\t\tgeometry = bufferGeometryLoader.parse(data);\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase 'Geometry':\n\t\t\t\t\t\t\tconsole.error('THREE.ObjectLoader: Loading \"Geometry\" is not supported anymore.');\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tconsole.warn('THREE.ObjectLoader: Unsupported geometry type \"' + data.type + '\"');\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tgeometry.uuid = data.uuid;\n\t\t\t\t\tif (data.name !== undefined) geometry.name = data.name;\n\t\t\t\t\tif (geometry.isBufferGeometry === true && data.userData !== undefined) geometry.userData = data.userData;\n\t\t\t\t\tgeometries[data.uuid] = geometry;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn geometries;\n\t\t};\n\n\t\t_proto.parseMaterials = function parseMaterials(json, textures) {\n\t\t\tvar cache = {}; // MultiMaterial\n\n\t\t\tvar materials = {};\n\n\t\t\tif (json !== undefined) {\n\t\t\t\tvar loader = new MaterialLoader();\n\t\t\t\tloader.setTextures(textures);\n\n\t\t\t\tfor (var i = 0, l = json.length; i < l; i++) {\n\t\t\t\t\tvar data = json[i];\n\n\t\t\t\t\tif (data.type === 'MultiMaterial') {\n\t\t\t\t\t\t// Deprecated\n\t\t\t\t\t\tvar array = [];\n\n\t\t\t\t\t\tfor (var j = 0; j < data.materials.length; j++) {\n\t\t\t\t\t\t\tvar material = data.materials[j];\n\n\t\t\t\t\t\t\tif (cache[material.uuid] === undefined) {\n\t\t\t\t\t\t\t\tcache[material.uuid] = loader.parse(material);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tarray.push(cache[material.uuid]);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tmaterials[data.uuid] = array;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (cache[data.uuid] === undefined) {\n\t\t\t\t\t\t\tcache[data.uuid] = loader.parse(data);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tmaterials[data.uuid] = cache[data.uuid];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn materials;\n\t\t};\n\n\t\t_proto.parseAnimations = function parseAnimations(json) {\n\t\t\tvar animations = {};\n\n\t\t\tif (json !== undefined) {\n\t\t\t\tfor (var i = 0; i < json.length; i++) {\n\t\t\t\t\tvar data = json[i];\n\t\t\t\t\tvar clip = AnimationClip.parse(data);\n\t\t\t\t\tanimations[clip.uuid] = clip;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn animations;\n\t\t};\n\n\t\t_proto.parseImages = function parseImages(json, onLoad) {\n\t\t\tvar scope = this;\n\t\t\tvar images = {};\n\t\t\tvar loader;\n\n\t\t\tfunction loadImage(url) {\n\t\t\t\tscope.manager.itemStart(url);\n\t\t\t\treturn loader.load(url, function () {\n\t\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t\t}, undefined, function () {\n\t\t\t\t\tscope.manager.itemError(url);\n\t\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tfunction deserializeImage(image) {\n\t\t\t\tif (typeof image === 'string') {\n\t\t\t\t\tvar url = image;\n\t\t\t\t\tvar path = /^(\\/\\/)|([a-z]+:(\\/\\/)?)/i.test(url) ? url : scope.resourcePath + url;\n\t\t\t\t\treturn loadImage(path);\n\t\t\t\t} else {\n\t\t\t\t\tif (image.data) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tdata: getTypedArray(image.type, image.data),\n\t\t\t\t\t\t\twidth: image.width,\n\t\t\t\t\t\t\theight: image.height\n\t\t\t\t\t\t};\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (json !== undefined && json.length > 0) {\n\t\t\t\tvar manager = new LoadingManager(onLoad);\n\t\t\t\tloader = new ImageLoader(manager);\n\t\t\t\tloader.setCrossOrigin(this.crossOrigin);\n\n\t\t\t\tfor (var i = 0, il = json.length; i < il;
1 i++) {\n\t\t\t\t\tvar image = json[i];\n\t\t\t\t\tvar url = image.url;\n\n\t\t\t\t\tif (Array.isArray(url)) {\n\t\t\t\t\t\t// load array of images e.g CubeTexture\n\t\t\t\t\t\timages[image.uuid] = [];\n\n\t\t\t\t\t\tfor (var j = 0, jl = url.length; j < jl; j++) {\n\t\t\t\t\t\t\tvar currentUrl = url[j];\n\t\t\t\t\t\t\tvar deserializedImage = deserializeImage(currentUrl);\n\n\t\t\t\t\t\t\tif (deserializedImage !== null) {\n\t\t\t\t\t\t\t\tif (deserializedImage instanceof HTMLImageElement) {\n\t\t\t\t\t\t\t\t\timages[image.uuid].push(deserializedImage);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// special case: handle array of data textures for cube textures\n\t\t\t\t\t\t\t\t\timages[image.uuid].push(new DataTexture(deserializedImage.data, deserializedImage.width, deserializedImage.height));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// load single image\n\t\t\t\t\t\tvar _deserializedImage = deserializeImage(image.url);\n\n\t\t\t\t\t\tif (_deserializedImage !== null) {\n\t\t\t\t\t\t\timages[image.uuid] = _deserializedImage;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn images;\n\t\t};\n\n\t\t_proto.parseTextures = function parseTextures(json, images) {\n\t\t\tfunction parseConstant(value, type) {\n\t\t\t\tif (typeof value === 'number') return value;\n\t\t\t\tconsole.warn('THREE.ObjectLoader.parseTexture: Constant should be in numeric form.', value);\n\t\t\t\treturn type[value];\n\t\t\t}\n\n\t\t\tvar textures = {};\n\n\t\t\tif (json !== undefined) {\n\t\t\t\tfor (var i = 0, l = json.length; i < l; i++) {\n\t\t\t\t\tvar data = json[i];\n\n\t\t\t\t\tif (data.image === undefined) {\n\t\t\t\t\t\tconsole.warn('THREE.ObjectLoader: No \"image\" specified for', data.uuid);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (images[data.image] === undefined) {\n\t\t\t\t\t\tconsole.warn('THREE.ObjectLoader: Undefined image', data.image);\n\t\t\t\t\t}\n\n\t\t\t\t\tvar texture = void 0;\n\t\t\t\t\tvar image = images[data.image];\n\n\t\t\t\t\tif (Array.isArray(image)) {\n\t\t\t\t\t\ttexture = new CubeTexture(image);\n\t\t\t\t\t\tif (image.length === 6) texture.needsUpdate = true;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (image && image.data) {\n\t\t\t\t\t\t\ttexture = new DataTexture(image.data, image.width, image.height);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttexture = new Texture(image);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (image) texture.needsUpdate = true; // textures can have undefined image data\n\t\t\t\t\t}\n\n\t\t\t\t\ttexture.uuid = data.uuid;\n\t\t\t\t\tif (data.name !== undefined) texture.name = data.name;\n\t\t\t\t\tif (data.mapping !== undefined) texture.mapping = parseConstant(data.mapping, TEXTURE_MAPPING);\n\t\t\t\t\tif (data.offset !== undefined) texture.offset.fromArray(data.offset);\n\t\t\t\t\tif (data.repeat !== undefined) texture.repeat.fromArray(data.repeat);\n\t\t\t\t\tif (data.center !== undefined) texture.center.fromArray(data.center);\n\t\t\t\t\tif (data.rotation !== undefined) texture.rotation = data.rotation;\n\n\t\t\t\t\tif (data.wrap !== undefined) {\n\t\t\t\t\t\ttexture.wrapS = parseConstant(data.wrap[0], TEXTURE_WRAPPING);\n\t\t\t\t\t\ttexture.wrapT = parseConstant(data.wrap[1], TEXTURE_WRAPPING);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (data.format !== undefined) texture.format = data.format;\n\t\t\t\t\tif (data.type !== undefined) texture.type = data.type;\n\t\t\t\t\tif (data.encoding !== undefined) texture.encoding = data.encoding;\n\t\t\t\t\tif (data.minFilter !== undefined) texture.minFilter = parseConstant(data.minFilter, TEXTURE_FILTER);\n\t\t\t\t\tif (data.magFilter !== undefined) texture.magFilter = parseConstant(data.magFilter, TEXTURE_FILTER);\n\t\t\t\t\tif (data.anisotropy !== undefined) texture.anisotropy = data.anisotropy;\n\t\t\t\t\tif (data.flipY !== undefined) texture.flipY = data.flipY;\n\t\t\t\t\tif (data.premultiplyAlpha !== undefined) texture.premultiplyAlpha = data.premultiplyAlpha;\n\t\t\t\t\tif (data.unpackAlignment !== undefined) texture.unpackAlignment = data.unpackAlignment;\n\t\t\t\t\ttextures[data.uuid] = texture;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn textures;\n\t\t};\n\n\t\t_proto.parseObject = function parseObject(data, geometries, materials, animations) {\n\t\t\tvar object;\n\n\t\t\tfunction getGeometry(name) {\n\t\t\t\tif (geometries[name] === undefined) {\n\t\t\t\t\tconsole.warn('THREE.ObjectLoader: Undefined geometry', name);\n\t\t\t\t}\n\n\t\t\t\treturn geometries[name];\n\t\t\t}\n\n\t\t\tfunction getMaterial(name) {\n\t\t\t\tif (name === undefined) return undefined;
1\n\n\t\t\t\tif (Array.isArray(name)) {\n\t\t\t\t\tvar array = [];\n\n\t\t\t\t\tfor (var i = 0, l = name.length; i < l; i++) {\n\t\t\t\t\t\tvar uuid = name[i];\n\n\t\t\t\t\t\tif (materials[uuid] === undefined) {\n\t\t\t\t\t\t\tconsole.warn('THREE.ObjectLoader: Undefined material', uuid);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tarray.push(materials[uuid]);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn array;\n\t\t\t\t}\n\n\t\t\t\tif (materials[name] === undefined) {\n\t\t\t\t\tconsole.warn('THREE.ObjectLoader: Undefined material', name);\n\t\t\t\t}\n\n\t\t\t\treturn materials[name];\n\t\t\t}\n\n\t\t\tvar geometry, material;\n\n\t\t\tswitch (data.type) {\n\t\t\t\tcase 'Scene':\n\t\t\t\t\tobject = new Scene();\n\n\t\t\t\t\tif (data.background !== undefined) {\n\t\t\t\t\t\tif (Number.isInteger(data.background)) {\n\t\t\t\t\t\t\tobject.background = new Color(data.background);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (data.fog !== undefined) {\n\t\t\t\t\t\tif (data.fog.type === 'Fog') {\n\t\t\t\t\t\t\tobject.fog = new Fog(data.fog.color, data.fog.near, data.fog.far);\n\t\t\t\t\t\t} else if (data.fog.type === 'FogExp2') {\n\t\t\t\t\t\t\tobject.fog = new FogExp2(data.fog.color, data.fog.density);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'PerspectiveCamera':\n\t\t\t\t\tobject = new PerspectiveCamera(data.fov, data.aspect, data.near, data.far);\n\t\t\t\t\tif (data.focus !== undefined) object.focus = data.focus;\n\t\t\t\t\tif (data.zoom !== undefined) object.zoom = data.zoom;\n\t\t\t\t\tif (data.filmGauge !== undefined) object.filmGauge = data.filmGauge;\n\t\t\t\t\tif (data.filmOffset !== undefined) object.filmOffset = data.filmOffset;\n\t\t\t\t\tif (data.view !== undefined) object.view = Object.assign({}, data.view);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'OrthographicCamera':\n\t\t\t\t\tobject = new OrthographicCamera(data.left, data.right, data.top, data.bottom, data.near, data.far);\n\t\t\t\t\tif (data.zoom !== undefined) object.zoom = data.zoom;\n\t\t\t\t\tif (data.view !== undefined) object.view = Object.assign({}, data.view);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'AmbientLight':\n\t\t\t\t\tobject = new AmbientLight(data.color, data.intensity);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'DirectionalLight':\n\t\t\t\t\tobject = new DirectionalLight(data.color, data.intensity);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'PointLight':\n\t\t\t\t\tobject = new PointLight(data.color, data.intensity, data.distance, data.decay);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'RectAreaLight':\n\t\t\t\t\tobject = new RectAreaLight(data.color, data.intensity, data.width, data.height);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'SpotLight':\n\t\t\t\t\tobject = new SpotLight(data.color, data.intensity, data.distance, data.angle, data.penumbra, data.decay);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'HemisphereLight':\n\t\t\t\t\tobject = new HemisphereLight(data.color, data.groundColor, data.intensity);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'LightProbe':\n\t\t\t\t\tobject = new LightProbe().fromJSON(data);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'SkinnedMesh':\n\t\t\t\t\tgeometry = getGeometry(data.geometry);\n\t\t\t\t\tmaterial = getMaterial(data.material);\n\t\t\t\t\tobject = new SkinnedMesh(geometry, material);\n\t\t\t\t\tif (data.bindMode !== undefined) object.bindMode = data.bindMode;\n\t\t\t\t\tif (data.bindMatrix !== undefined) object.bindMatrix.fromArray(data.bindMatrix);\n\t\t\t\t\tif (data.skeleton !== undefined) object.skeleton = data.skeleton;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Mesh':\n\t\t\t\t\tgeometry = getGeometry(data.geometry);\n\t\t\t\t\tmaterial = getMaterial(data.material);\n\t\t\t\t\tobject = new Mesh(geometry, material);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'InstancedMesh':\n\t\t\t\t\tgeometry = getGeometry(data.geometry);\n\t\t\t\t\tmaterial = getMaterial(data.material);\n\t\t\t\t\tvar count = data.count;\n\t\t\t\t\tvar instanceMatrix = data.instanceMatrix;\n\t\t\t\t\tobject = new InstancedMesh(geometry, material, count);\n\t\t\t\t\tobject.instanceMatrix = new BufferAttribute(new Float32Array(instanceMatrix.array), 16);\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'LOD':\n\t\t\t\t\tobject = new LOD();\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Line':\n\t\t\t\t\tobject = new Line(getGeometry(data.geometry), getMaterial(data.material));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'LineLoop':\n\t\t\t\t\tobject = new LineLoop(getGeometry(data.geometry), getMaterial(data.material));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'LineSegments':\n\t\t\t\t\tobject = new LineSegments(getGeometry(data.geometry), getMaterial(data.material));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'PointCloud':\n\t\t\t\tcase 'Points':\n\t\t\t\t\tobject = new Points(getGeometry(data.geometry), getMaterial(data.material));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Sprite':\n\t\t\t\t\tobject = new Sprite(getMaterial(data.material));\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Group':\n\t\t\t\t\tobject = new Group();\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'Bone':\n\t\t\t\t\tobject = new Bone();\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\tobject = new Object3D();\n\t\t\t}\n\n\t\t\tobject.uuid = data.uuid;\n\t\t\tif (data.name !== undefined) object.name = data.name;\n\n\t\t\tif (data.matrix !== undefined) {\n\t\t\t\tobject.matrix.fromArray(data.matrix
1);\n\t\t\t\tif (data.matrixAutoUpdate !== undefined) object.matrixAutoUpdate = data.matrixAutoUpdate;\n\t\t\t\tif (object.matrixAutoUpdate) object.matrix.decompose(object.position, object.quaternion, object.scale);\n\t\t\t} else {\n\t\t\t\tif (data.position !== undefined) object.position.fromArray(data.position);\n\t\t\t\tif (data.rotation !== undefined) object.rotation.fromArray(data.rotation);\n\t\t\t\tif (data.quaternion !== undefined) object.quaternion.fromArray(data.quaternion);\n\t\t\t\tif (data.scale !== undefined) object.scale.fromArray(data.scale);\n\t\t\t}\n\n\t\t\tif (data.castShadow !== undefined) object.castShadow = data.castShadow;\n\t\t\tif (data.receiveShadow !== undefined) object.receiveShadow = data.receiveShadow;\n\n\t\t\tif (data.shadow) {\n\t\t\t\tif (data.shadow.bias !== undefined) object.shadow.bias = data.shadow.bias;\n\t\t\t\tif (data.shadow.normalBias !== undefined) object.shadow.normalBias = data.shadow.normalBias;\n\t\t\t\tif (data.shadow.radius !== undefined) object.shadow.radius = data.shadow.radius;\n\t\t\t\tif (data.shadow.mapSize !== undefined) object.shadow.mapSize.fromArray(data.shadow.mapSize);\n\t\t\t\tif (data.shadow.camera !== undefined) object.shadow.camera = this.parseObject(data.shadow.camera);\n\t\t\t}\n\n\t\t\tif (data.visible !== undefined) object.visible = data.visible;\n\t\t\tif (data.frustumCulled !== undefined) object.frustumCulled = data.frustumCulled;\n\t\t\tif (data.renderOrder !== undefined) object.renderOrder = data.renderOrder;\n\t\t\tif (data.userData !== undefined) object.userData = data.userData;\n\t\t\tif (data.layers !== undefined) object.layers.mask = data.layers;\n\n\t\t\tif (data.children !== undefined) {\n\t\t\t\tvar children = data.children;\n\n\t\t\t\tfor (var i = 0; i < children.length; i++) {\n\t\t\t\t\tobject.add(this.parseObject(children[i], geometries, materials, animations));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (data.animations !== undefined) {\n\t\t\t\tvar objectAnimations = data.animations;\n\n\t\t\t\tfor (var _i = 0; _i < objectAnimations.length;
1 _i++) {\n\t\t\t\t\tvar uuid = objectAnimations[_i];\n\t\t\t\t\tobject.animations.push(animations[uuid]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (data.type === 'LOD') {\n\t\t\t\tif (data.autoUpdate !== undefined) object.autoUpdate = data.autoUpdate;\n\t\t\t\tvar levels = data.levels;\n\n\t\t\t\tfor (var l = 0; l < levels.length; l++) {\n\t\t\t\t\tvar level = levels[l];\n\t\t\t\t\tvar child = object.getObjectByProperty('uuid', level.object);\n\n\t\t\t\t\tif (child !== undefined) {\n\t\t\t\t\t\tobject.addLevel(child, level.distance);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn object;\n\t\t};\n\n\t\t_proto.bindSkeletons = function bindSkeletons(object, skeletons) {\n\t\t\tif (Object.keys(skeletons).length === 0) return;\n\t\t\tobject.traverse(function (child) {\n\t\t\t\tif (child.isSkinnedMesh === true && child.skeleton !== undefined) {\n\t\t\t\t\tvar skeleton = skeletons[child.skeleton];\n\n\t\t\t\t\tif (skeleton === undefined) {\n\t\t\t\t\t\tconsole.warn('THREE.ObjectLoader: No skeleton found with UUID:', child.skeleton);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tchild.bind(skeleton, child.bindMatrix);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\t/* DEPRECATED */\n\t\t;\n\n\t\t_proto.setTexturePath = function setTexturePath(value) {\n\t\t\tconsole.warn('THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath().');\n\t\t\treturn this.setResourcePath(value);\n\t\t};\n\n\t\treturn ObjectLoader;\n\t}(Loader);\n\n\tvar TEXTURE_MAPPING = {\n\t\tUVMapping: UVMapping,\n\t\tCubeReflectionMapping: CubeReflectionMapping,\n\t\tCubeRefractionMapping: CubeRefractionMapping,\n\t\tEquirectangularReflectionMapping: EquirectangularReflectionMapping,\n\t\tEquirectangularRefractionMapping: EquirectangularRefractionMapping,\n\t\tCubeUVReflectionMapping: CubeUVReflectionMapping,\n\t\tCubeUVRefractionMapping: CubeUVRefractionMapping\n\t};\n\tvar TEXTURE_WRAPPING = {\n\t\tRepeatWrapping: RepeatWrapping,\n\t\tClampToEdgeWrapping: ClampToEdgeWrapping,\n\t\tMirroredRepeatWrapping: MirroredRepeatWrapping\n\t};\n\tvar TEXTURE_FILTER = {\n\t\tNearestFilter: NearestFilter,\n\t\tNearestMipmapNearestFilter: NearestMipmapNearestFilter,\n\t\tNearestMipmapLinearFilter: NearestMipmapLinearFilter,\n\t\tLinearFilter: LinearFilter,\n\t\tLinearMipmapNearestFilter: LinearMipmapNearestFilter,\n\t\tLinearMipmapLinearFilter: LinearMipmapLinearFilter\n\t};\n\n\tfunction ImageBitmapLoader(manager) {\n\t\tif (typeof createImageBitmap === 'undefined') {\n\t\t\tconsole.warn('THREE.ImageBitmapLoader: createImageBitmap() not supported.');\n\t\t}\n\n\t\tif (typeof fetch === 'undefined') {\n\t\t\tconsole.warn('THREE.ImageBitmapLoader: fetch() not supported.');\n\t\t}\n\n\t\tLoader.call(this, manager);\n\t\tthis.options = {\n\t\t\tpremultiplyAlpha: 'none'\n\t\t};\n\t}\n\n\tImageBitmapLoader.prototype = Object.assign(Object.create(Loader.prototype), {\n\t\tconstructor: ImageBitmapLoader,\n\t\tisImageBitmapLoader: true,\n\t\tsetOptions: function setOptions(options) {\n\t\t\tthis.options = options;\n\t\t\treturn this;\n\t\t},\n\t\tload: function load(url, onLoad, onProgress, onError) {\n\t\t\tif (url === undefined) url = '';\n\t\t\tif (this.path !== undefined) url = this.path + url;\n\t\t\turl = this.manager.resolveURL(url);\n\t\t\tvar scope = this;\n\t\t\tvar cached = Cache.get(url);\n\n\t\t\tif (cached !== undefined) {\n\t\t\t\tscope.manager.itemStart(url);\n\t\t\t\tsetTimeout(function () {\n\t\t\t\t\tif (onLoad) onLoad(cached);\n\t\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t\t}, 0);\n\t\t\t\treturn cached;\n\t\t\t}\n\n\t\t\tvar fetchOptions = {};\n\t\t\tfetchOptions.credentials = this.crossOrigin === 'anonymous' ? 'same-origin' : 'include';\n\t\t\tfetch(url, fetchOptions).then(function (res) {\n\t\t\t\treturn res.blob();\n\t\t\t}).then(function (blob) {\n\t\t\t\treturn createImageBitmap(blob, scope.options);\n\t\t\t}).then(function (imageBitmap) {\n\t\t\t\tCache.add(url, imageBitmap);\n\t\t\t\tif (onLoad) onLoad(imageBitmap);\n\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t}).catch(function (e) {\n\t\t\t\tif (onError) onError(e);\n\t\t\t\tscope.manager.itemError(url);\n\t\t\t\tscope.manager.itemEnd(url);\n\t\t\t});\n\t\t\tscope.manager.itemStart(url);\n\t\t}\n\t});\n\n\tfunction ShapePath() {\n\t\tthis.type = 'ShapePath';\n\t\tthis.color = new Color();\n\t\tthis.subPaths = [];\n\t\tthis.currentPath = null;\n\t}\n\n\tObject.assign(ShapePath.prototype, {\n\t\tmoveTo: function moveTo(x, y) {\n\t\t\tthis.currentPath = new Path();\n\t\t\tthis.subPaths.push(this.currentPath);\n\t\t\tthis.currentPath.moveTo(x, y);\n\t\t\treturn this;\n\t\t},\n\t\tlineTo: function lineTo(x, y) {\n\t\t\tthis.currentPath.lineTo(x, y);\n\t\t\treturn this;\n\t\t},\n\t\tquadraticCurveTo: function quadraticCurveTo(aCPx, aCPy, aX, aY) {\n\t\t\tthis.currentPath.quadraticCurveTo(aCPx, aCPy, aX, aY);\n\t\t\treturn this;\n\t\t},\n\t\tbezierCurveTo: function bezierCurveTo(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY) {\n\t\t\tthis.currentPath.bezierCurveTo(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY);\n\t\t\treturn this;\n\t\t},\n\t\tsplineThru: function splineThru(pts) {\n\t\t\tthis.currentPath.splineThru(pts);\n\t\t\treturn this;\n\t\t},\n\t\ttoShapes: function toShapes(isCCW, noHoles) {\n\t\t\tfunction toShapesNoHoles(inSubpaths) {\n\t\t\t\tvar shapes = [];\n\n\t\t\t\tfor (var i = 0, l = inSubpaths.length; i < l;
1 i++) {\n\t\t\t\t\tvar _tmpPath = inSubpaths[i];\n\n\t\t\t\t\tvar _tmpShape = new Shape();\n\n\t\t\t\t\t_tmpShape.curves = _tmpPath.curves;\n\t\t\t\t\tshapes.push(_tmpShape);\n\t\t\t\t}\n\n\t\t\t\treturn shapes;\n\t\t\t}\n\n\t\t\tfunction isPointInsidePolygon(inPt, inPolygon) {\n\t\t\t\tvar polyLen = inPolygon.length; // inPt on polygon contour => immediate success\t\tor\n\t\t\t\t// toggling of inside/outside at every single! intersection point of an edge\n\t\t\t\t//\twith the horizontal line through inPt, left of inPt\n\t\t\t\t//\tnot counting lowerY endpoints of edges and whole edges on that line\n\n\t\t\t\tvar inside = false;\n\n\t\t\t\tfor (var p = polyLen - 1, q = 0; q < polyLen; p = q++) {\n\t\t\t\t\tvar edgeLowPt = inPolygon[p];\n\t\t\t\t\tvar edgeHighPt = inPolygon[q];\n\t\t\t\t\tvar edgeDx = edgeHighPt.x - edgeLowPt.x;\n\t\t\t\t\tvar edgeDy = edgeHighPt.y - edgeLowPt.y;\n\n\t\t\t\t\tif (Math.abs(edgeDy) > Number.EPSILON) {\n\t\t\t\t\t\t// not parallel\n\t\t\t\t\t\tif (edgeDy < 0) {\n\t\t\t\t\t\t\tedgeLowPt = inPolygon[q];\n\t\t\t\t\t\t\tedgeDx = -edgeDx;\n\t\t\t\t\t\t\tedgeHighPt = inPolygon[p];\n\t\t\t\t\t\t\tedgeDy = -edgeDy;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (inPt.y < edgeLowPt.y || inPt.y > edgeHighPt.y) continue;\n\n\t\t\t\t\t\tif (inPt.y === edgeLowPt.y) {\n\t\t\t\t\t\t\tif (inPt.x === edgeLowPt.x) return true; // inPt is on contour ?\n\t\t\t\t\t\t\t// continue;\t\t\t\t// no intersection or edgeLowPt => doesn't count !!!\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvar perpEdge = edgeDy * (inPt.x - edgeLowPt.x) - edgeDx * (inPt.y - edgeLowPt.y);\n\t\t\t\t\t\t\tif (perpEdge === 0) return true; // inPt is on contour ?\n\n\t\t\t\t\t\t\tif (perpEdge < 0) continue;\n\t\t\t\t\t\t\tinside = !inside; // true intersection left of inPt\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// parallel or collinear\n\t\t\t\t\t\tif (inPt.y !== edgeLowPt.y) continue; // parallel\n\t\t\t\t\t\t// edge lies on the same horizontal line as inPt\n\n\t\t\t\t\t\tif (edgeHighPt.x <= inPt.x && inPt.x <= edgeLowPt.x || edgeLowPt.x <= inPt.x && inPt.x <= edgeHighPt.x) return true; // inPt: Point on contour !\n\t\t\t\t\t\t// continue;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn inside;\n\t\t\t}\n\n\t\t\tvar isClockWise = ShapeUtils.isClockWise;\n\t\t\tvar subPaths = this.subPaths;\n\t\t\tif (subPaths.length === 0) return [];\n\t\t\tif (noHoles === true) return toShapesNoHoles(subPaths);\n\t\t\tvar solid, tmpPath, tmpShape;\n\t\t\tvar shapes = [];\n\n\t\t\tif (subPaths.length === 1) {\n\t\t\t\ttmpPath = subPaths[0];\n\t\t\t\ttmpShape = new Shape();\n\t\t\t\ttmpShape.curves = tmpPath.curves;\n\t\t\t\tshapes.push(tmpShape);\n\t\t\t\treturn shapes;\n\t\t\t}\n\n\t\t\tvar holesFirst = !isClockWise(subPaths[0].getPoints());\n\t\t\tholesFirst = isCCW ? !holesFirst : holesFirst; // console.log(\"Holes first\", holesFirst);\n\n\t\t\tvar betterShapeHoles = [];\n\t\t\tvar newShapes = [];\n\t\t\tvar newShapeHoles = [];\n\t\t\tvar mainIdx = 0;\n\t\t\tvar tmpPoints;\n\t\t\tnewShapes[mainIdx] = undefined;\n\t\t\tnewShapeHoles[mainIdx] = [];\n\n\t\t\tfor (var i = 0, l = subPaths.length; i < l; i++) {\n\t\t\t\ttmpPath = subPaths[i];\n\t\t\t\ttmpPoints = tmpPath.getPoints();\n\t\t\t\tsolid = isClockWise(tmpPoints);\n\t\t\t\tsolid = isCCW ? !solid : solid;\n\n\t\t\t\tif (solid) {\n\t\t\t\t\tif (!holesFirst && newShapes[mainIdx]) mainIdx++;\n\t\t\t\t\tnewShapes[mainIdx] = {\n\t\t\t\t\t\ts: new Shape(),\n\t\t\t\t\t\tp: tmpPoints\n\t\t\t\t\t};\n\t\t\t\t\tnewShapes[mainIdx].s.curves = tmpPath.curves;\n\t\t\t\t\tif (holesFirst) mainIdx++;\n\t\t\t\t\tnewShapeHoles[mainIdx] = []; //console.log('cw', i);\n\t\t\t\t} else {\n\t\t\t\t\tnewShapeHoles[mainIdx].push({\n\t\t\t\t\t\th: tmpPath,\n\t\t\t\t\t\tp: tmpPoints[0]\n\t\t\t\t\t}); //console.log('ccw', i);\n\t\t\t\t}\n\t\t\t} // only Holes? -> probably all Shapes with wrong orientation\n\n\n\t\t\tif (!newShapes[0]) return toShapesNoHoles(subPaths);\n\n\t\t\tif (newShapes.length > 1) {\n\t\t\t\tvar ambiguous = false;\n\t\t\t\tvar toChange = [];\n\n\t\t\t\tfor (var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx++) {\n\t\t\t\t\tbetterShapeHoles[sIdx] = [];\n\t\t\t\t}\n\n\t\t\t\tfor (var _sIdx = 0, _sLen = newShapes.length; _sIdx < _sLen; _sIdx++) {\n\t\t\t\t\tvar sho = newShapeHoles[_sIdx];\n\n\t\t\t\t\tfor (var hIdx = 0; hIdx < sho.length; hIdx++) {\n\t\t\t\t\t\tvar ho = sho[hIdx];\n\t\t\t\t\t\tvar hole_unassigned = true;\n\n\t\t\t\t\t\tfor (var s2Idx = 0; s2Idx < newShapes.length; s2Idx++) {\n\t\t\t\t\t\t\tif (isPointInsidePolygon(ho.p, newShapes[s2Idx].p)) {\n\t\t\t\t\t\t\t\tif (_sIdx !== s2Idx) toChange.push({\n\t\t\t\t\t\t\t\t\tfroms: _sIdx,\n\t\t\t\t\t\t\t\t\ttos: s2Idx,\n\t\t\t\t\t\t\t\t\thole: hIdx\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tif (hole_unassigned) {\n\t\t\t\t\t\t\t\t\thole_unassigned = false;\n\t\t\t\t\t\t\t\t\tbetterShapeHoles[s2Idx].push(ho);\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tambiguous = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (hole_unassigned) {\n\t\t\t\t\t\t\tbetterShapeHoles[_sIdx].push(ho);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} // console.log(\"ambiguous: \", ambiguous);\n\n\n\t\t\t\tif (toChange.length > 0) {\n\t\t\t\t\t// console.log(\"to change: \", toChange);
1\n\t\t\t\t\tif (!ambiguous) newShapeHoles = betterShapeHoles;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar tmpHoles;\n\n\t\t\tfor (var _i = 0, il = newShapes.length; _i < il; _i++) {\n\t\t\t\ttmpShape = newShapes[_i].s;\n\t\t\t\tshapes.push(tmpShape);\n\t\t\t\ttmpHoles = newShapeHoles[_i];\n\n\t\t\t\tfor (var j = 0, jl = tmpHoles.length; j < jl; j++) {\n\t\t\t\t\ttmpShape.holes.push(tmpHoles[j].h);\n\t\t\t\t}\n\t\t\t} //console.log(\"shape\", shapes);\n\n\n\t\t\treturn shapes;\n\t\t}\n\t});\n\n\tfunction Font(data) {\n\t\tthis.type = 'Font';\n\t\tthis.data = data;\n\t}\n\n\tObject.assign(Font.prototype, {\n\t\tisFont: true,\n\t\tgenerateShapes: function generateShapes(text, size) {\n\t\t\tif (size === void 0) {\n\t\t\t\tsize = 100;\n\t\t\t}\n\n\t\t\tvar shapes = [];\n\t\t\tvar paths = createPaths(text, size, this.data);\n\n\t\t\tfor (var p = 0, pl = paths.length; p < pl; p++) {\n\t\t\t\tArray.prototype.push.apply(shapes, paths[p].toShapes());\n\t\t\t}\n\n\t\t\treturn shapes;\n\t\t}\n\t});\n\n\tfunction createPaths(text, size, data) {\n\t\tvar chars = Array.from ? Array.from(text) : String(text).split(''); // workaround for IE11, see #13988\n\n\t\tvar scale = size / data.resolution;\n\t\tvar line_height = (data.boundingBox.yMax - data.boundingBox.yMin + data.underlineThickness) * scale;\n\t\tvar paths = [];\n\t\tvar offsetX = 0,\n\t\t\t\toffsetY = 0;\n\n\t\tfor (var i = 0; i < chars.length; i++) {\n\t\t\tvar char = chars[i];\n\n\t\t\tif (char === '\\n') {\n\t\t\t\toffsetX = 0;\n\t\t\t\toffsetY -= line_height;\n\t\t\t} else {\n\t\t\t\tvar ret = createPath(char, scale, offsetX, offsetY, data);\n\t\t\t\toffsetX += ret.offsetX;\n\t\t\t\tpaths.push(ret.path);\n\t\t\t}\n\t\t}\n\n\t\treturn paths;\n\t}\n\n\tfunction createPath(char, scale, offsetX, offsetY, data) {\n\t\tvar glyph = data.glyphs[char] || data.glyphs['?'];\n\n\t\tif (!glyph) {\n\t\t\tconsole.error('THREE.Font: character \"' + char + '\" does not exists in font family ' + data.familyName + '.');\n\t\t\treturn;\n\t\t}\n\n\t\tvar path = new ShapePath();\n\t\tvar x, y, cpx, cpy, cpx1, cpy1, cpx2, cpy2;\n\n\t\tif (glyph.o) {\n\t\t\tvar outline = glyph._cachedOutline || (glyph._cachedOutline = glyph.o.split(' '));\n\n\t\t\tfor (var i = 0, l = outline.length; i < l;) {\n\t\t\t\tvar action = outline[i++];\n\n\t\t\t\tswitch (action) {\n\t\t\t\t\tcase 'm':\n\t\t\t\t\t\t// moveTo\n\t\t\t\t\t\tx = outline[i++] * scale + offsetX;\n\t\t\t\t\t\ty = outline[i++] * scale + offsetY;\n\t\t\t\t\t\tpath.moveTo(x, y);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'l':\n\t\t\t\t\t\t// lineTo\n\t\t\t\t\t\tx = outline[i++] * scale + offsetX;\n\t\t\t\t\t\ty = outline[i++] * scale + offsetY;\n\t\t\t\t\t\tpath.lineTo(x, y);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'q':\n\t\t\t\t\t\t// quadraticCurveTo\n\t\t\t\t\t\tcpx = outline[i++] * scale + offsetX;\n\t\t\t\t\t\tcpy = outline[i++] * scale + offsetY;\n\t\t\t\t\t\tcpx1 = outline[i++] * scale + offsetX;\n\t\t\t\t\t\tcpy1 = outline[i++] * scale + offsetY;\n\t\t\t\t\t\tpath.quadraticCurveTo(cpx1, cpy1, cpx, cpy);\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'b':\n\t\t\t\t\t\t// bezierCurveTo\n\t\t\t\t\t\tcpx = outline[i++] * scale + offsetX;\n\t\t\t\t\t\tcpy = outline[i++] * scale + offsetY;\n\t\t\t\t\t\tcpx1 = outline[i++] * scale + offsetX;\n\t\t\t\t\t\tcpy1 = outline[i++] * scale + offsetY;\n\t\t\t\t\t\tcpx2 = outline[i++] * scale + offsetX;\n\t\t\t\t\t\tcpy2 = outline[i++] * scale + offsetY;\n\t\t\t\t\t\tpath.bezierCurveTo(cpx1, cpy1, cpx2, cpy2, cpx, cpy);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\toffsetX: glyph.ha * scale,\n\t\t\tpath: path\n\t\t};\n\t}\n\n\tfunction FontLoader(manager) {\n\t\tLoader.call(this, manager);\n\t}\n\n\tFontLoader.prototype = Object.assign(Object.create(Loader.prototype), {\n\t\tconstructor: FontLoader,\n\t\tload: function load(url, onLoad, onProgress, onError) {\n\t\t\tvar scope = this;\n\t\t\tvar loader = new FileLoader(this.manager);\n\t\t\tloader.setPath(this.path);\n\t\t\tloader.setRequestHeader(this.requestHeader);\n\t\t\tloader.setWithCredentials(scope.withCredentials);\n\t\t\tloader.load(url, function (text) {\n\t\t\t\tvar json;\n\n\t\t\t\ttry {\n\t\t\t\t\tjson = JSON.parse(text);\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.warn('THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead.');\n\t\t\t\t\tjson = JSON.parse(text.substring(65, text.length - 2));\n\t\t\t\t}\n\n\t\t\t\tvar font = scope.parse(json);\n\t\t\t\tif (onLoad) onLoad(font);\n\t\t\t}, onProgress, onError);\n\t\t},\n\t\tparse: function parse(json) {\n\t\t\treturn new Font(json);\n\t\t}\n\t});\n\n\tvar _context;\n\n\tvar AudioContext = {\n\t\tgetContext: function getContext() {\n\t\t\tif (_context === undefined) {\n\t\t\t\t_context = new (window.AudioContext || window.webkitAudioContext)();\n\t\t\t}\n\n\t\t\treturn _context;\n\t\t},\n\t\tsetContext: function setContext(value) {\n\t\t\t_context = value;\n\t\t}\n\t};
1\n\n\tfunction AudioLoader(manager) {\n\t\tLoader.call(this, manager);\n\t}\n\n\tAudioLoader.prototype = Object.assign(Object.create(Loader.prototype), {\n\t\tconstructor: AudioLoader,\n\t\tload: function load(url, onLoad, onProgress, onError) {\n\t\t\tvar scope = this;\n\t\t\tvar loader = new FileLoader(scope.manager);\n\t\t\tloader.setResponseType('arraybuffer');\n\t\t\tloader.setPath(scope.path);\n\t\t\tloader.setRequestHeader(scope.requestHeader);\n\t\t\tloader.setWithCredentials(scope.withCredentials);\n\t\t\tloader.load(url, function (buffer) {\n\t\t\t\ttry {\n\t\t\t\t\t// Create a copy of the buffer. The `decodeAudioData` method\n\t\t\t\t\t// detaches the buffer when complete, preventing reuse.\n\t\t\t\t\tvar bufferCopy = buffer.slice(0);\n\t\t\t\t\tvar context = AudioContext.getContext();\n\t\t\t\t\tcontext.decodeAudioData(bufferCopy, function (audioBuffer) {\n\t\t\t\t\t\tonLoad(audioBuffer);\n\t\t\t\t\t});\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (onError) {\n\t\t\t\t\t\tonError(e);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error(e);\n\t\t\t\t\t}\n\n\t\t\t\t\tscope.manager.itemError(url);\n\t\t\t\t}\n\t\t\t}, onProgress, onError);\n\t\t}\n\t});\n\n\tfunction HemisphereLightProbe(skyColor, groundColor, intensity) {\n\t\tLightProbe.call(this, undefined, intensity);\n\t\tvar color1 = new Color().set(skyColor);\n\t\tvar color2 = new Color().set(groundColor);\n\t\tvar sky = new Vector3(color1.r, color1.g, color1.b);\n\t\tvar ground = new Vector3(color2.r, color2.g, color2.b); // without extra factor of PI in the shader, should = 1 / Math.sqrt( Math.PI );\n\n\t\tvar c0 = Math.sqrt(Math.PI);\n\t\tvar c1 = c0 * Math.sqrt(0.75);\n\t\tthis.sh.coefficients[0].copy(sky).add(ground).multiplyScalar(c0);\n\t\tthis.sh.coefficients[1].copy(sky).sub(ground).multiplyScalar(c1);\n\t}\n\n\tHemisphereLightProbe.prototype = Object.assign(Object.create(LightProbe.prototype), {\n\t\tconstructor: HemisphereLightProbe,\n\t\tisHemisphereLightProbe: true,\n\t\tcopy: function copy(source) {\n\t\t\t// modifying colors not currently supported\n\t\t\tLightProbe.prototype.copy.call(this, source);\n\t\t\treturn this;\n\t\t},\n\t\ttoJSON: function toJSON(meta) {\n\t\t\tvar data = LightProbe.prototype.toJSON.call(this, meta); // data.sh = this.sh.toArray(); // todo\n\n\t\t\treturn data;\n\t\t}\n\t});\n\n\tfunction AmbientLightProbe(color, intensity) {\n\t\tLightProbe.call(this, undefined, intensity);\n\t\tvar color1 = new Color().set(color); // without extra factor of PI in the shader, would be 2 / Math.sqrt( Math.PI );\n\n\t\tthis.sh.coefficients[0].set(color1.r, color1.g, color1.b).multiplyScalar(2 * Math.sqrt(Math.PI));\n\t}\n\n\tAmbientLightProbe.prototype = Object.assign(Object.create(LightProbe.prototype), {\n\t\tconstructor: AmbientLightProbe,\n\t\tisAmbientLightProbe: true,\n\t\tcopy: function copy(source) {\n\t\t\t// modifying color not currently supported\n\t\t\tLightProbe.prototype.copy.call(this, source);\n\t\t\treturn this;\n\t\t},\n\t\ttoJSON: function toJSON(meta) {\n\t\t\tvar data = LightProbe.prototype.toJSON.call(this, meta); // data.sh = this.sh.toArray(); // todo\n\n\t\t\treturn data;\n\t\t}\n\t});\n\n\tvar _eyeRight = new Matrix4();\n\n\tvar _eyeLeft = new Matrix4();\n\n\tfunction StereoCamera() {\n\t\tthis.type = 'StereoCamera';\n\t\tthis.aspect = 1;\n\t\tthis.eyeSep = 0.064;\n\t\tthis.cameraL = new PerspectiveCamera();\n\t\tthis.cameraL.layers.enable(1);\n\t\tthis.cameraL.matrixAutoUpdate = false;\n\t\tthis.cameraR = new PerspectiveCamera();\n\t\tthis.cameraR.layers.enable(2);\n\t\tthis.cameraR.matrixAutoUpdate = false;\n\t\tthis._cache = {\n\t\t\tfocus: null,\n\t\t\tfov: null,\n\t\t\taspect: null,\n\t\t\tnear: null,\n\t\t\tfar: null,\n\t\t\tzoom: null,\n\t\t\teyeSep: null\n\t\t};\n\t}\n\n\tObject.assign(StereoCamera.prototype, {\n\t\tupdate: function update(camera) {\n\t\t\tvar cache = this._cache;\n\t\t\tvar needsUpdate = cache.focus !== camera.focus || cache.fov !== camera.fov || cache.aspect !== camera.aspect * this.aspect || cache.near !== camera.near || cache.far !== camera.far || cache.zoom !== camera.zoom || cache.eyeSep !== this.eyeSep;\n\n\t\t\tif (needsUpdate) {\n\t\t\t\tcache.focus = camera.focus;\n\t\t\t\tcache.fov = camera.fov;\n\t\t\t\tcache.aspect = camera.aspect * this.aspect;\n\t\t\t\tcache.near = camera.near;\n\t\t\t\tcache.far = camera.far;\n\t\t\t\tcache.zoom = camera.zoom;\n\t\t\t\tcache.eyeSep = this.eyeSep; // Off-axis stereoscopic effect based on\n\t\t\t\t// http://paulbourke.net/stereographics/stereorender/\n\n\t\t\t\tvar projectionMatrix = camera.projectionMatrix.clone();\n\t\t\t\tvar eyeSepHalf = cache.eyeSep / 2;\n\t\t\t\tvar eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus;\n\t\t\t\tvar ymax = cache.near * Math.tan(MathUtils.DEG2RAD * cache.fov * 0.5) / cache.zoom;\n\t\t\t\tvar xmin, xmax; // translate xOffset\n\n\t\t\t\t_eyeLeft.elements[12] = -eyeSepHalf;\n\t\t\t\t_eyeRight.elements[12] = eyeSepHalf; // for left eye\n\n\t\t\t\txmin = -ymax * cache.aspect + eyeSepOnProjection;\n\t\t\t\txmax = ymax * cache.aspect + eyeSepOnProjection;\n\t\t\t\tprojectionMatrix.elements[0] = 2 * cache.near / (xmax - xmin);\n\t\t\t\tprojectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin);\n\t\t\t\tthis.cameraL.projectionMatrix.copy(projectionMatrix); // for right eye\n\n\t\t\t\txmin = -ymax * cache.aspect - eyeSepOnProjection;\n\t\t\t\txmax = ymax * cache.aspect - eyeSepOnProjection;\n\t\t\t\tprojectionMatrix.elements[0] = 2 * cache.near / (xmax - xmin);\n\t\t\t\tprojectionMatrix.elements[8] = (xmax + xmin) / (xmax - xmin);\n\t\t\t\tthis.cameraR.projectionMatrix.copy(projectionMatrix);\n\t\t\t}\n\n\t\t\tthis.cameraL.matrixWorld.copy(camera.matrixWorld).multiply(_eyeLeft);\n\t\t\tthis.cameraR.matrixWorld.copy(camera.matrixWorld).multiply(_eyeRight);\n\t\t}\n\t});\n\n\tvar Clock = /*#__PURE__*/function () {\n\t\tfunction Clock(autoStart) {\n\t\t\tthis.autoStart = autoStart !== undefined ? autoStart : true;\n\t\t\tthis.startTime = 0;\n\t\t\tthis.oldTime = 0;\n\t\t\tthis.elapsedTime = 0;\n\t\t\tthis.running = false;\n\t\t}\n\n\t\tvar _proto = Clock.prototype;\n\n\t\t_proto.start = function start() {\n\t\t\tthis.startTime = n
1ow();\n\t\t\tthis.oldTime = this.startTime;\n\t\t\tthis.elapsedTime = 0;\n\t\t\tthis.running = true;\n\t\t};\n\n\t\t_proto.stop = function stop() {\n\t\t\tthis.getElapsedTime();\n\t\t\tthis.running = false;\n\t\t\tthis.autoStart = false;\n\t\t};\n\n\t\t_proto.getElapsedTime = function getElapsedTime() {\n\t\t\tthis.getDelta();\n\t\t\treturn this.elapsedTime;\n\t\t};\n\n\t\t_proto.getDelta = function getDelta() {\n\t\t\tvar diff = 0;\n\n\t\t\tif (this.autoStart && !this.running) {\n\t\t\t\tthis.start();\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\tif (this.running) {\n\t\t\t\tvar newTime = now();\n\t\t\t\tdiff = (newTime - this.oldTime) / 1000;\n\t\t\t\tthis.oldTime = newTime;\n\t\t\t\tthis.elapsedTime += diff;\n\t\t\t}\n\n\t\t\treturn diff;\n\t\t};\n\n\t\treturn Clock;\n\t}();\n\n\tfunction now() {\n\t\treturn (typeof performance === 'undefined' ? Date : performance).now(); // see #10732\n\t}\n\n\tvar _position$2 = /*@__PURE__*/new Vector3();\n\n\tvar _quaternion$3 = /*@__PURE__*/new Quaternion();\n\n\tvar _scale$1 = /*@__PURE__*/new Vector3();\n\n\tvar _orientation = /*@__PURE__*/new Vector3();\n\n\tvar AudioListener = /*#__PURE__*/function (_Object3D) {\n\t\t_inheritsLoose(AudioListener, _Object3D);\n\n\t\tfunction AudioListener() {\n\t\t\tvar _this;\n\n\t\t\t_this = _Object3D.call(this) || this;\n\t\t\t_this.type = 'AudioListener';\n\t\t\t_this.context = AudioContext.getContext();\n\t\t\t_this.gain = _this.context.createGain();\n\n\t\t\t_this.gain.connect(_this.context.destination);\n\n\t\t\t_this.filter = null;\n\t\t\t_this.timeDelta = 0; // private\n\n\t\t\t_this._clock = new Clock();\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = AudioListener.prototype;\n\n\t\t_proto.getInput = function getInput() {\n\t\t\treturn this.gain;\n\t\t};\n\n\t\t_proto.removeFilter = function removeFilter() {\n\t\t\tif (this.filter !== null) {\n\t\t\t\tthis.gain.disconnect(this.filter);\n\t\t\t\tthis.filter.disconnect(this.context.destination);\n\t\t\t\tthis.gain.connect(this.context.destination);\n\t\t\t\tthis.filter = null;\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.getFilter = function getFilter() {\n\t\t\treturn this.filter;\n\t\t};\n\n\t\t_proto.setFilter = function setFilter(value) {\n\t\t\tif (this.filter !== null) {\n\t\t\t\tthis.gain.disconnect(this.filter);\n\t\t\t\tthis.filter.disconnect(this.context.destination);\n\t\t\t} else {\n\t\t\t\tthis.gain.disconnect(this.context.destination);\n\t\t\t}\n\n\t\t\tthis.filter = value;\n\t\t\tthis.gain.connect(this.filter);\n\t\t\tthis.filter.connect(this.context.destination);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.getMasterVolume = function getMasterVolume() {\n\t\t\treturn this.gain.gain.value;\n\t\t};\n\n\t\t_proto.setMasterVolume = function setMasterVolume(value) {\n\t\t\tthis.gain.gain.setTargetAtTime(value, this.context.currentTime, 0.01);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.updateMatrixWorld = function updateMatrixWorld(force) {\n\t\t\t_Object3D.prototype.updateMatrixWorld.call(this, force);\n\n\t\t\tvar listener = this.context.listener;\n\t\t\tvar up = this.up;\n\t\t\tthis.timeDelta = this._clock.getDelta();\n\t\t\tthis.matrixWorld.decompose(_position$2, _quaternion$3, _scale$1);\n\n\t\t\t_orientation.set(0, 0, -1).applyQuaternion(_quaternion$3);\n\n\t\t\tif (listener.positionX) {\n\t\t\t\t// code path for Chrome (see #14393)\n\t\t\t\tvar endTime = this.context.currentTime + this.timeDelta;\n\t\t\t\tlistener.positionX.linearRampToValueAtTime(_position$2.x, endTime);\n\t\t\t\tlistener.positionY.linearRampToValueAtTime(_position$2.y, endTime);\n\t\t\t\tlistener.positionZ.linearRampToValueAtTime(_position$2.z, endTime);\n\t\t\t\tlistener.forwardX.linearRampToValueAtTime(_orientation.x, endTime);\n\t\t\t\tlistener.forwardY.linearRampToValueAtTime(_orientation.y, endTime);\n\t\t\t\tlistener.forwardZ.linearRampToValueAtTime(_orientation.z, endTime);\n\t\t\t\tlistener.upX.linearRampToValueAtTime(up.x, endTime);\n\t\t\t\tlistener.upY.linearRampToValueAtTime(up.y, endTime);\n\t\t\t\tlistener.upZ.linearRampToValueAtTime(up.z, endTime);\n\t\t\t} else {\n\t\t\t\tlistener.setPosition(_position$2.x, _position$2.y, _position$2.z);\n\t\t\t\tlistener.setOrientation(_orientation.x, _orientation.y, _orientation.z, up.x, up.y, up.z);\n\t\t\t}\n\t\t};\n\n\t\treturn AudioListener;\n\t}(Object3D);
1\n\n\tvar Audio = /*#__PURE__*/function (_Object3D) {\n\t\t_inheritsLoose(Audio, _Object3D);\n\n\t\tfunction Audio(listener) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Object3D.call(this) || this;\n\t\t\t_this.type = 'Audio';\n\t\t\t_this.listener = listener;\n\t\t\t_this.context = listener.context;\n\t\t\t_this.gain = _this.context.createGain();\n\n\t\t\t_this.gain.connect(listener.getInput());\n\n\t\t\t_this.autoplay = false;\n\t\t\t_this.buffer = null;\n\t\t\t_this.detune = 0;\n\t\t\t_this.loop = false;\n\t\t\t_this.loopStart = 0;\n\t\t\t_this.loopEnd = 0;\n\t\t\t_this.offset = 0;\n\t\t\t_this.duration = undefined;\n\t\t\t_this.playbackRate = 1;\n\t\t\t_this.isPlaying = false;\n\t\t\t_this.hasPlaybackControl = true;\n\t\t\t_this.source = null;\n\t\t\t_this.sourceType = 'empty';\n\t\t\t_this._startedAt = 0;\n\t\t\t_this._progress = 0;\n\t\t\t_this._connected = false;\n\t\t\t_this.filters = [];\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = Audio.prototype;\n\n\t\t_proto.getOutput = function getOutput() {\n\t\t\treturn this.gain;\n\t\t};\n\n\t\t_proto.setNodeSource = function setNodeSource(audioNode) {\n\t\t\tthis.hasPlaybackControl = false;\n\t\t\tthis.sourceType = 'audioNode';\n\t\t\tthis.source = audioNode;\n\t\t\tthis.connect();\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setMediaElementSource = function setMediaElementSource(mediaElement) {\n\t\t\tthis.hasPlaybackControl = false;\n\t\t\tthis.sourceType = 'mediaNode';\n\t\t\tthis.source = this.context.createMediaElementSource(mediaElement);\n\t\t\tthis.connect();\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setMediaStreamSource = function setMediaStreamSource(mediaStream) {\n\t\t\tthis.hasPlaybackControl = false;\n\t\t\tthis.sourceType = 'mediaStreamNode';\n\t\t\tthis.source = this.context.createMediaStreamSource(mediaStream);\n\t\t\tthis.connect();\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setBuffer = function setBuffer(audioBuffer) {\n\t\t\tthis.buffer = audioBuffer;\n\t\t\tthis.sourceType = 'buffer';\n\t\t\tif (this.autoplay) this.play();\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.play = function play(delay) {\n\t\t\tif (delay === void 0) {\n\t\t\t\tdelay = 0;\n\t\t\t}\n\n\t\t\tif (this.isPlaying === true) {\n\t\t\t\tconsole.warn('THREE.Audio: Audio is already playing.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (this.hasPlaybackControl === false) {\n\t\t\t\tconsole.warn('THREE.Audio: this Audio has no playback control.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis._startedAt = this.context.currentTime + delay;\n\t\t\tvar source = this.context.createBufferSource();\n\t\t\tsource.buffer = this.buffer;\n\t\t\tsource.loop = this.loop;\n\t\t\tsource.loopStart = this.loopStart;\n\t\t\tsource.loopEnd = this.loopEnd;\n\t\t\tsource.onended = this.onEnded.bind(this);\n\t\t\tsource.start(this._startedAt, this._progress + this.offset, this.duration);\n\t\t\tthis.isPlaying = true;\n\t\t\tthis.source = source;\n\t\t\tthis.setDetune(this.detune);\n\t\t\tthis.setPlaybackRate(this.playbackRate);\n\t\t\treturn this.connect();\n\t\t};\n\n\t\t_proto.pause = function pause() {\n\t\t\tif (this.hasPlaybackControl === false) {\n\t\t\t\tconsole.warn('THREE.Audio: this Audio has no playback control.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (this.isPlaying === true) {\n\t\t\t\t// update current progress\n\t\t\t\tthis._progress += Math.max(this.context.currentTime - this._startedAt, 0) * this.playbackRate;\n\n\t\t\t\tif (this.loop === true) {\n\t\t\t\t\t// ensure _progress does not exceed duration with looped audios\n\t\t\t\t\tthis._progress = this._progress % (this.duration || this.buffer.duration);\n\t\t\t\t}\n\n\t\t\t\tthis.source.stop();\n\t\t\t\tthis.source.onended = null;\n\t\t\t\tthis.isPlaying = false;\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.stop = function stop() {\n\t\t\tif (this.hasPlaybackControl === false) {\n\t\t\t\tconsole.warn('THREE.Audio: this Audio has no playback control.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis._progress = 0;\n\t\t\tthis.source.stop();\n\t\t\tthis.source.onended = null;\n\t\t\tthis.isPlaying = false;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.connect = function connect() {\n\t\t\tif (this.filters.length > 0) {\n\t\t\t\tthis.source.connect(this.filters[0]);\n\n\t\t\t\tfor (var i = 1, l = this.filters.length; i < l;
1 i++) {\n\t\t\t\t\tthis.filters[i - 1].connect(this.filters[i]);\n\t\t\t\t}\n\n\t\t\t\tthis.filters[this.filters.length - 1].connect(this.getOutput());\n\t\t\t} else {\n\t\t\t\tthis.source.connect(this.getOutput());\n\t\t\t}\n\n\t\t\tthis._connected = true;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.disconnect = function disconnect() {\n\t\t\tif (this.filters.length > 0) {\n\t\t\t\tthis.source.disconnect(this.filters[0]);\n\n\t\t\t\tfor (var i = 1, l = this.filters.length; i < l; i++) {\n\t\t\t\t\tthis.filters[i - 1].disconnect(this.filters[i]);\n\t\t\t\t}\n\n\t\t\t\tthis.filters[this.filters.length - 1].disconnect(this.getOutput());\n\t\t\t} else {\n\t\t\t\tthis.source.disconnect(this.getOutput());\n\t\t\t}\n\n\t\t\tthis._connected = false;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.getFilters = function getFilters() {\n\t\t\treturn this.filters;\n\t\t};\n\n\t\t_proto.setFilters = function setFilters(value) {\n\t\t\tif (!value) value = [];\n\n\t\t\tif (this._connected === true) {\n\t\t\t\tthis.disconnect();\n\t\t\t\tthis.filters = value.slice();\n\t\t\t\tthis.connect();\n\t\t\t} else {\n\t\t\t\tthis.filters = value.slice();\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setDetune = function setDetune(value) {\n\t\t\tthis.detune = value;\n\t\t\tif (this.source.detune === undefined) return; // only set detune when available\n\n\t\t\tif (this.isPlaying === true) {\n\t\t\t\tthis.source.detune.setTargetAtTime(this.detune, this.context.currentTime, 0.01);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.getDetune = function getDetune() {\n\t\t\treturn this.detune;\n\t\t};\n\n\t\t_proto.getFilter = function getFilter() {\n\t\t\treturn this.getFilters()[0];\n\t\t};\n\n\t\t_proto.setFilter = function setFilter(filter) {\n\t\t\treturn this.setFilters(filter ? [filter] : []);\n\t\t};\n\n\t\t_proto.setPlaybackRate = function setPlaybackRate(value) {\n\t\t\tif (this.hasPlaybackControl === false) {\n\t\t\t\tconsole.warn('THREE.Audio: this Audio has no playback control.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.playbackRate = value;\n\n\t\t\tif (this.isPlaying === true) {\n\t\t\t\tthis.source.playbackRate.setTargetAtTime(this.playbackRate, this.context.currentTime, 0.01);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.getPlaybackRate = function getPlaybackRate() {\n\t\t\treturn this.playbackRate;\n\t\t};\n\n\t\t_proto.onEnded = function onEnded() {\n\t\t\tthis.isPlaying = false;\n\t\t};\n\n\t\t_proto.getLoop = function getLoop() {\n\t\t\tif (this.hasPlaybackControl === false) {\n\t\t\t\tconsole.warn('THREE.Audio: this Audio has no playback control.');\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn this.loop;\n\t\t};\n\n\t\t_proto.setLoop = function setLoop(value) {\n\t\t\tif (this.hasPlaybackControl === false) {\n\t\t\t\tconsole.warn('THREE.Audio: this Audio has no playback control.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.loop = value;\n\n\t\t\tif (this.isPlaying === true) {\n\t\t\t\tthis.source.loop = this.loop;\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setLoopStart = function setLoopStart(value) {\n\t\t\tthis.loopStart = value;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setLoopEnd = function setLoopEnd(value) {\n\t\t\tthis.loopEnd = value;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.getVolume = function getVolume() {\n\t\t\treturn this.gain.gain.value;\n\t\t};\n\n\t\t_proto.setVolume = function setVolume(value) {\n\t\t\tthis.gain.gain.setTargetAtTime(value, this.context.currentTime, 0.01);\n\t\t\treturn this;\n\t\t};\n\n\t\treturn Audio;\n\t}(Object3D);\n\n\tvar _position$3 = /*@__PURE__*/new Vector3();\n\n\tvar _quaternion$4 = /*@__PURE__*/new Quaternion();\n\n\tvar _scale$2 = /*@__PURE__*/new Vector3();\n\n\tvar _orientation$1 = /*@__PURE__*/new Vector3();\n\n\tvar PositionalAudio = /*#__PURE__*/function (_Audio) {\n\t\t_inheritsLoose(PositionalAudio, _Audio);\n\n\t\tfunction PositionalAudio(listener) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Audio.call(this, listener) || this;\n\t\t\t_this.panner = _this.context.createPanner();\n\t\t\t_this.panner.panningModel = 'HRTF';\n\n\t\t\t_this.panner.connect(_this.gain);\n\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = PositionalAudio.prototype;\n\n\t\t_proto.getOutput = function getOutput() {\n\t\t\treturn this.panner;\n\t\t};\n\n\t\t_proto.getRefDistance = function getRefDistance() {\n\t\t\treturn this.panner.refDistance;\n\t\t};\n\n\t\t_proto.setRefDistance = function setRefDistance(value) {\n\t\t\tthis.panner.refDistance = value;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.getRolloffFactor = function getRolloffFactor() {\n\t\t\treturn this.panner.rolloffFactor;
1\n\t\t};\n\n\t\t_proto.setRolloffFactor = function setRolloffFactor(value) {\n\t\t\tthis.panner.rolloffFactor = value;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.getDistanceModel = function getDistanceModel() {\n\t\t\treturn this.panner.distanceModel;\n\t\t};\n\n\t\t_proto.setDistanceModel = function setDistanceModel(value) {\n\t\t\tthis.panner.distanceModel = value;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.getMaxDistance = function getMaxDistance() {\n\t\t\treturn this.panner.maxDistance;\n\t\t};\n\n\t\t_proto.setMaxDistance = function setMaxDistance(value) {\n\t\t\tthis.panner.maxDistance = value;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setDirectionalCone = function setDirectionalCone(coneInnerAngle, coneOuterAngle, coneOuterGain) {\n\t\t\tthis.panner.coneInnerAngle = coneInnerAngle;\n\t\t\tthis.panner.coneOuterAngle = coneOuterAngle;\n\t\t\tthis.panner.coneOuterGain = coneOuterGain;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.updateMatrixWorld = function updateMatrixWorld(force) {\n\t\t\t_Audio.prototype.updateMatrixWorld.call(this, force);\n\n\t\t\tif (this.hasPlaybackControl === true && this.isPlaying === false) return;\n\t\t\tthis.matrixWorld.decompose(_position$3, _quaternion$4, _scale$2);\n\n\t\t\t_orientation$1.set(0, 0, 1).applyQuaternion(_quaternion$4);\n\n\t\t\tvar panner = this.panner;\n\n\t\t\tif (panner.positionX) {\n\t\t\t\t// code path for Chrome and Firefox (see #14393)\n\t\t\t\tvar endTime = this.context.currentTime + this.listener.timeDelta;\n\t\t\t\tpanner.positionX.linearRampToValueAtTime(_position$3.x, endTime);\n\t\t\t\tpanner.positionY.linearRampToValueAtTime(_position$3.y, endTime);\n\t\t\t\tpanner.positionZ.linearRampToValueAtTime(_position$3.z, endTime);\n\t\t\t\tpanner.orientationX.linearRampToValueAtTime(_orientation$1.x, endTime);\n\t\t\t\tpanner.orientationY.linearRampToValueAtTime(_orientation$1.y, endTime);\n\t\t\t\tpanner.orientationZ.linearRampToValueAtTime(_orientation$1.z, endTime);\n\t\t\t} else {\n\t\t\t\tpanner.setPosition(_position$3.x, _position$3.y, _position$3.z);\n\t\t\t\tpanner.setOrientation(_orientation$1.x, _orientation$1.y, _orientation$1.z);\n\t\t\t}\n\t\t};\n\n\t\treturn PositionalAudio;\n\t}(Audio);\n\n\tvar AudioAnalyser = /*#__PURE__*/function () {\n\t\tfunction AudioAnalyser(audio, fftSize) {\n\t\t\tif (fftSize === void 0) {\n\t\t\t\tfftSize = 2048;\n\t\t\t}\n\n\t\t\tthis.analyser = audio.context.createAnalyser();\n\t\t\tthis.analyser.fftSize = fftSize;\n\t\t\tthis.data = new Uint8Array(this.analyser.frequencyBinCount);\n\t\t\taudio.getOutput().connect(this.analyser);\n\t\t}\n\n\t\tvar _proto = AudioAnalyser.prototype;\n\n\t\t_proto.getFrequencyData = function getFrequencyData() {\n\t\t\tthis.analyser.getByteFrequencyData(this.data);\n\t\t\treturn this.data;\n\t\t};\n\n\t\t_proto.getAverageFrequency = function getAverageFrequency() {\n\t\t\tvar value = 0;\n\t\t\tvar data = this.getFrequencyData();\n\n\t\t\tfor (var i = 0; i < data.length; i++) {\n\t\t\t\tvalue += data[i];\n\t\t\t}\n\n\t\t\treturn value / data.length;\n\t\t};\n\n\t\treturn AudioAnalyser;\n\t}();\n\n\tfunction PropertyMixer(binding, typeName, valueSize) {\n\t\tthis.binding = binding;\n\t\tthis.valueSize = valueSize;\n\t\tvar mixFunction, mixFunctionAdditive, setIdentity; // buffer layout: [ incoming | accu0 | accu1 | orig | addAccu | (optional work) ]\n\t\t//\n\t\t// interpolators can use .buffer as their .result\n\t\t// the data then goes to 'incoming'\n\t\t//\n\t\t// 'accu0' and 'accu1' are used frame-interleaved for\n\t\t// the cumulative result and are compared to detect\n\t\t// changes\n\t\t//\n\t\t// 'orig' stores the original state of the property\n\t\t//\n\t\t// 'add' is used for additive cumulative results\n\t\t//\n\t\t// 'work' is optional and is only present for quaternion types. It is used\n\t\t// to store intermediate quaternion multiplication results\n\n\t\tswitch (typeName) {\n\t\t\tcase 'quaternion':\n\t\t\t\tmixFunction = this._slerp;\n\t\t\t\tmixFunctionAdditive = this._slerpAdditive;\n\t\t\t\tsetIdentity = this._setAdditiveIdentityQuaternion;\n\t\t\t\tthis.buffer = new Float64Array(valueSize * 6);\n\t\t\t\tthis._workIndex = 5;\n\t\t\t\tbreak;\n\n\t\t\tcase 'string':\n\t\t\tcase 'bool':\n\t\t\t\tmixFunction = this._select; // Use the regular mix function and for additive on these types,\n\t\t\t\t// additive is not relevant for non-numeric types\n\n\t\t\t\tmixFunctionAdditive = this._select;\n\t\t\t\tsetIdentity = this._setAdditiveIdentityOther;\n\t\t\t\tthis.buffer = new Array(valueSize * 5);\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tmixFunction = this._lerp;\n\t\t\t\tmixFunctionAdditive = this._lerpAdditive;\n\t\t\t\tsetIdentity = this._setAdditiveIdentityNumeric;\n\t\t\t\tthis.buffer = new Float64Array(valueSize * 5);\n\t\t}\n\n\t\tthis._mixBufferRegion = mixFunction;\n\t\tthis._mixBufferRegionAdditive = mixFunctionAdditive;\n\t\tthis._setIdentity = setIdentity;\n\t\tthis._origIndex = 3;\n\t\tthis._addIndex = 4;\n\t\tthis.cumulativeWeight = 0;\n\t\tthis.cumulativeWeightAdditive = 0;\n\t\tthis.useCount = 0;\n\t\tthis.referenceCount = 0;\n\t}\n\n\tObject.assign(PropertyMixer.prototype, {\n\t\t// accumulate data in the 'incoming' region into 'accu<i>'\n\t\taccumulate: function accumulate(accuIndex, weight) {\n\t\t\t// note: happily accumulating nothing when weight = 0, the caller knows\n\t\t\t// the weight and shouldn't have made the call in the first place\n\t\t\tvar buffer = this.buffer,\n\t\t\t\t\tstride = this.valueSize,\n\t\t\t\t\toffset = accuIndex * stride + stride;\n\t\t\tvar currentWeight = this.cumulativeWeight;\n\n\t\t\tif (currentWeight === 0) {\n\t\t\t\t// accuN := incoming * weight\n\t\t\t\tfor (var i = 0; i !== stride; ++i) {\n\t\t\t\t\tbuffer[offset + i] = buffer[i];\n\t\t\t\t}\n\n\t\t\t\tcurrentWeight = weight;\n\t\t\t} else {\n\t\t\t\t// accuN := accuN + incoming * weight\n\t\t\t\tcurrentWeight += weight;\n\t\t\t\tvar mix = weight / currentWeight;\n\n\t\t\t\tthis._mixBufferRegion(buffer, offset, 0, mix, stride);\n\t\t\t}\n\n\t\t\tthis.cumulativeWeight = currentWeight;\n\t\t},\n\t\t// accumulate data in the 'incoming' region into 'add'\n\t\taccumulateAdditive: function accumulateAdditive(weight) {\n\t\t\tvar buffer = this.buffer,\n\t\t\t\t\tstride = this.valueSize,\n\t\t\t\t\toffset = stride * this._addIndex;\n\n\t\t\tif (this.cumulativeWeightAdditive === 0) {\n\t\t\t\t// add = identity\n\t\t\t\tthis._setIdentity();\n\t\t\t} // add := add + incoming * weight\n\n\n\t\t\tthis._mixBufferRegionAdditive(buffer, offset, 0, weight, stride);\n\n\t\t\tthis.cumulativeWeightAdditive += weight;\n\t\t},\n\t\t// apply the state of 'accu<i>' to the binding when accus differ\n\t\tapply: function apply(accuIndex) {\n\t\t\tvar stride = this.valueSize,\n\t\t\t\t\tbuffer = this.buffer,\n\t\t\t\t\toffset = accuIndex * stride + stride,\n\t\t\t\t\tweight = this.cumulativeWeight,\n\t\t\t\t\tweightAdditive = this.cumulativeWeightAdditive,\n\t\t\t\t\tbinding = this.binding;\n\t\t\tthis.cumulativeWeight = 0;\n\t\t\tthis.cumulativeWeightAdditive = 0;\n\n\t\t\tif (weight < 1) {\n\t\t\t\t// accuN := accuN + original * ( 1 - cumulativeWeight )\n\t\t\t\tvar originalValueOffset = stride * this._origIndex;\n\n\t\t\t\tthis._mixBufferRegion(buffer, offset, originalValueOffset, 1 - weight, stride);\n\t\t\t}\n\n\t\t\tif (weightAdditive > 0) {\n\t\t\t\t// accuN := accuN + additive accuN\n\t\t\t\tthis._mixBufferRegionAdditive(buffer, offset, this._addIndex * stride, 1, stride);\n\t\t\t}\n\n\t\t\tfor (var i = stride, e = stride + stride; i !== e; ++i) {\n\t\t\t\tif (buffer[i] !== buffer[i + stride]) {\n\t\t\t\t\t// value has changed -> update scene graph\n\t\t\t\t\tbinding.setValue(buffer, offset);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// remember the state of the bound property and copy it to both accus\n\t\tsaveOriginalState: function saveOriginalState() {\n\t\t\tvar binding = this.binding;\n\t\t\tvar buffer = this.buffer,\n\t\t\t\t\tstride = this.valueSize,\n\t\t\t\t\toriginalValueOffset = stride * this._origIndex;\n\t\t\tbinding.getValue(buffer, originalValueOffset); // accu[0..1] := orig -- initially detect changes against the original\n\n\t\t\tfor (var i = stride, e = originalValueOffset; i !== e; ++i) {\n\t\t\t\tbuffer[i] = buffer[originalValueOffset + i % stride];\n\t\t\t} // Add to identity for additive\n\n\n\t\t\tthis._setIdentity();\n\n\t\t\tthis.cumulativeWeight = 0;\n\t\t\tthis.cumulativeWeightAdditive = 0;\n\t\t},\n\t\t// apply the state previously taken via 'saveOriginalState' to the binding\n\t\trestoreOriginalState: function restoreOriginalState() {\n\t\t\tvar originalValueOffset = this.valueSize * 3;\n\t\t\tthis.binding.setValue(this.buffer, originalValueOffset);\n\t\t},\n\t\t_setAdditiveIdentityNumeric: function _setAdditiveIdentityNumeric() {\n\t\t\tvar startIndex = this._addIndex * this.valueSize;\n\t\t\tvar endIndex = startIndex + this.valueSize;\n\n\t\t\tfor (var i = startIndex; i < endIndex;
1 i++) {\n\t\t\t\tthis.buffer[i] = 0;\n\t\t\t}\n\t\t},\n\t\t_setAdditiveIdentityQuaternion: function _setAdditiveIdentityQuaternion() {\n\t\t\tthis._setAdditiveIdentityNumeric();\n\n\t\t\tthis.buffer[this._addIndex * this.valueSize + 3] = 1;\n\t\t},\n\t\t_setAdditiveIdentityOther: function _setAdditiveIdentityOther() {\n\t\t\tvar startIndex = this._origIndex * this.valueSize;\n\t\t\tvar targetIndex = this._addIndex * this.valueSize;\n\n\t\t\tfor (var i = 0; i < this.valueSize; i++) {\n\t\t\t\tthis.buffer[targetIndex + i] = this.buffer[startIndex + i];\n\t\t\t}\n\t\t},\n\t\t// mix functions\n\t\t_select: function _select(buffer, dstOffset, srcOffset, t, stride) {\n\t\t\tif (t >= 0.5) {\n\t\t\t\tfor (var i = 0; i !== stride; ++i) {\n\t\t\t\t\tbuffer[dstOffset + i] = buffer[srcOffset + i];\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t_slerp: function _slerp(buffer, dstOffset, srcOffset, t) {\n\t\t\tQuaternion.slerpFlat(buffer, dstOffset, buffer, dstOffset, buffer, srcOffset, t);\n\t\t},\n\t\t_slerpAdditive: function _slerpAdditive(buffer, dstOffset, srcOffset, t, stride) {\n\t\t\tvar workOffset = this._workIndex * stride; // Store result in intermediate buffer offset\n\n\t\t\tQuaternion.multiplyQuaternionsFlat(buffer, workOffset, buffer, dstOffset, buffer, srcOffset); // Slerp to the intermediate result\n\n\t\t\tQuaternion.slerpFlat(buffer, dstOffset, buffer, dstOffset, buffer, workOffset, t);\n\t\t},\n\t\t_lerp: function _lerp(buffer, dstOffset, srcOffset, t, stride) {\n\t\t\tvar s = 1 - t;\n\n\t\t\tfor (var i = 0; i !== stride; ++i) {\n\t\t\t\tvar j = dstOffset + i;\n\t\t\t\tbuffer[j] = buffer[j] * s + buffer[srcOffset + i] * t;\n\t\t\t}\n\t\t},\n\t\t_lerpAdditive: function _lerpAdditive(buffer, dstOffset, srcOffset, t, stride) {\n\t\t\tfor (var i = 0; i !== stride; ++i) {\n\t\t\t\tvar j = dstOffset + i;\n\t\t\t\tbuffer[j] = buffer[j] + buffer[srcOffset + i] * t;\n\t\t\t}\n\t\t}\n\t});\n\n\t// Characters [].:/ are reserved for track binding syntax.\n\tvar _RESERVED_CHARS_RE = '\\\\[\\\\]\\\\.:\\\\/';\n\n\tvar _reservedRe = new RegExp('[' + _RESERVED_CHARS_RE + ']', 'g'); // Attempts to allow node names from any language. ES5's `\\w` regexp matches\n\t// only latin characters, and the unicode \\p{L} is not yet supported. So\n\t// instead, we exclude reserved characters and match everything else.\n\n\n\tvar _wordChar = '[^' + _RESERVED_CHARS_RE + ']';\n\n\tvar _wordCharOrDot = '[^' + _RESERVED_CHARS_RE.replace('\\\\.', '') + ']'; // Parent directories, delimited by '/' or ':'. Currently unused, but must\n\t// be matched to parse the rest of the track name.\n\n\n\tvar _directoryRe = /((?:WC+[\\/:])*)/.source.replace('WC', _wordChar); // Target node. May contain word characters (a-zA-Z0-9_) and '.' or '-'.\n\n\n\tvar _nodeRe = /(WCOD+)?/.source.replace('WCOD', _wordCharOrDot); // Object on target node, and accessor. May not contain reserved\n\t// characters. Accessor may contain any character except closing bracket.\n\n\n\tvar _objectRe = /(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace('WC', _wordChar); // Property and accessor. May not contain reserved characters. Accessor may\n\t// contain any non-bracket characters.\n\n\n\tvar _propertyRe = /\\.(WC+)(?:\\[(.+)\\])?/.source.replace('WC', _wordChar);\n\n\tvar _trackRe = new RegExp('' + '^' + _directoryRe + _nodeRe + _objectRe + _propertyRe + '$');\n\n\tvar _supportedObjectNames = ['material', 'materials', 'bones'];\n\n\tfunction Composite(targetGroup, path, optionalParsedPath) {\n\t\tvar parsedPath = optionalParsedPath || PropertyBinding.parseTrackName(path);\n\t\tthis._targetGroup = targetGroup;\n\t\tthis._bindings = targetGroup.subscribe_(path, parsedPath);\n\t}\n\n\tObject.assign(Composite.prototype, {\n\t\tgetValue: function getValue(array, offset) {\n\t\t\tthis.bind(); // bind all binding\n\n\t\t\tvar firstValidIndex = this._targetGroup.nCachedObjects_,\n\t\t\t\t\tbinding = this._bindings[firstValidIndex]; // and only call .getValue on the first\n\n\t\t\tif (binding !== undefined) binding.getValue(array, offset);\n\t\t},\n\t\tsetValue: function setValue(array, offset) {\n\t\t\tvar bindings = this._bindings;\n\n\t\t\tfor (var i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++i) {\n\t\t\t\tbindings[i].setValue(array, offset);\n\t\t\t}\n\t\t},\n\t\tbind: function bind() {\n\t\t\tvar bindings = this._bindings;\n\n\t\t\tfor (var i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++i) {\n\t\t\t\tbindings[i].bind();\n\t\t\t}\n\t\t},\n\t\tunbind: function unbind() {\n\t\t\tvar bindings = this._bindings;\n\n\t\t\tfor (var i = this._targetGroup.nCachedObjects_, n = bindings.length; i !== n; ++i) {\n\t\t\t\tbindings[i].unbind();\n\t\t\t}\n\t\t}\n\t});\n\n\tfunction PropertyBinding(rootNode, path, parsedPath) {\n\t\tthis.path = path;\n\t\tthis.parsedPath = parsedPath || PropertyBinding.parseTrackName(path);\n\t\tthis.node = PropertyBinding.findNode(rootNode, this.parsedPath.nodeName) || rootNode;\n\t\tthis.rootNode = rootNode;\n\t}\n\n\tObject.assign(PropertyBinding, {\n\t\tComposite: Composite,\n\t\tcreate: function create(root, path, parsedPath) {\n\t\t\tif (!(root && root.isAnimationObjectGroup)) {\n\t\t\t\treturn new PropertyBinding(root, path, parsedPath);\n\t\t\t} else {\n\t\t\t\treturn new PropertyBinding.Composite(root, path, parsedPath);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Replaces spaces with underscores and removes unsupported characters from\n\t\t * node names, to ensure compatibility with parseTrackName().\n\t\t *\n\t\t * @param {string} name Node name to be sanitized.\n\t\t * @return {string}\n\t\t */\n\t\tsanitizeNodeName: function sanitizeNodeName(name) {\n\t\t\treturn name.replace(/\\s/g, '_').replace(_reservedRe, '');\n\t\t},\n\t\tparseTrackName: function parseTrackName(trackName) {\n\t\t\tvar matches = _trackRe.exec(trackName);\n\n\t\t\tif (!matches) {\n\t\t\t\tthrow new Error('PropertyBinding: Cannot parse trackName: ' + trackName);\n\t\t\t}\n\n\t\t\tvar results = {\n\t\t\t\t// directoryName: matches[ 1 ], // (tschw) currently unused\n\t\t\t\tno
1deName: matches[2],\n\t\t\t\tobjectName: matches[3],\n\t\t\t\tobjectIndex: matches[4],\n\t\t\t\tpropertyName: matches[5],\n\t\t\t\t// required\n\t\t\t\tpropertyIndex: matches[6]\n\t\t\t};\n\t\t\tvar lastDot = results.nodeName && results.nodeName.lastIndexOf('.');\n\n\t\t\tif (lastDot !== undefined && lastDot !== -1) {\n\t\t\t\tvar objectName = results.nodeName.substring(lastDot + 1); // Object names must be checked against an allowlist. Otherwise, there\n\t\t\t\t// is no way to parse 'foo.bar.baz': 'baz' must be a property, but\n\t\t\t\t// 'bar' could be the objectName, or part of a nodeName (which can\n\t\t\t\t// include '.' characters).\n\n\t\t\t\tif (_supportedObjectNames.indexOf(objectName) !== -1) {\n\t\t\t\t\tresults.nodeName = results.nodeName.substring(0, lastDot);\n\t\t\t\t\tresults.objectName = objectName;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (results.propertyName === null || results.propertyName.length === 0) {\n\t\t\t\tthrow new Error('PropertyBinding: can not parse propertyName from trackName: ' + trackName);\n\t\t\t}\n\n\t\t\treturn results;\n\t\t},\n\t\tfindNode: function findNode(root, nodeName) {\n\t\t\tif (!nodeName || nodeName === '' || nodeName === '.' || nodeName === -1 || nodeName === root.name || nodeName === root.uuid) {\n\t\t\t\treturn root;\n\t\t\t} // search into skeleton bones.\n\n\n\t\t\tif (root.skeleton) {\n\t\t\t\tvar bone = root.skeleton.getBoneByName(nodeName);\n\n\t\t\t\tif (bone !== undefined) {\n\t\t\t\t\treturn bone;\n\t\t\t\t}\n\t\t\t} // search into node subtree.\n\n\n\t\t\tif (root.children) {\n\t\t\t\tvar searchNodeSubtree = function searchNodeSubtree(children) {\n\t\t\t\t\tfor (var i = 0; i < children.length; i++) {\n\t\t\t\t\t\tvar childNode = children[i];\n\n\t\t\t\t\t\tif (childNode.name === nodeName || childNode.uuid === nodeName) {\n\t\t\t\t\t\t\treturn childNode;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tvar result = searchNodeSubtree(childNode.children);\n\t\t\t\t\t\tif (result) return result;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn null;\n\t\t\t\t};\n\n\t\t\t\tvar subTreeNode = searchNodeSubtree(root.children);\n\n\t\t\t\tif (subTreeNode) {\n\t\t\t\t\treturn subTreeNode;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn null;\n\t\t}\n\t});\n\tObject.assign(PropertyBinding.prototype, {\n\t\t// prototype, continued\n\t\t// these are used to \"bind\" a nonexistent property\n\t\t_getValue_unavailable: function _getValue_unavailable() {},\n\t\t_setValue_unavailable: function _setValue_unavailable() {},\n\t\tBindingType: {\n\t\t\tDirect: 0,\n\t\t\tEntireArray: 1,\n\t\t\tArrayElement: 2,\n\t\t\tHasFromToArray: 3\n\t\t},\n\t\tVersioning: {\n\t\t\tNone: 0,\n\t\t\tNeedsUpdate: 1,\n\t\t\tMatrixWorldNeedsUpdate: 2\n\t\t},\n\t\tGetterByBindingType: [function getValue_direct(buffer, offset) {\n\t\t\tbuffer[offset] = this.node[this.propertyName];\n\t\t}, function getValue_array(buffer, offset) {\n\t\t\tvar source = this.resolvedProperty;\n\n\t\t\tfor (var i = 0, n = source.length; i !== n; ++i) {\n\t\t\t\tbuffer[offset++] = source[i];\n\t\t\t}\n\t\t}, function getValue_arrayElement(buffer, offset) {\n\t\t\tbuffer[offset] = this.resolvedProperty[this.propertyIndex];\n\t\t}, function getValue_toArray(buffer, offset) {\n\t\t\tthis.resolvedProperty.toArray(buffer, offset);\n\t\t}],\n\t\tSetterByBindingTypeAndVersioning: [[// Direct\n\t\tfunction setValue_direct(buffer, offset) {\n\t\t\tthis.targetObject[this.propertyName] = buffer[offset];\n\t\t}, function setValue_direct_setNeedsUpdate(buffer, offset) {\n\t\t\tthis.targetObject[this.propertyName] = buffer[offset];\n\t\t\tthis.targetObject.needsUpdate = true;\n\t\t}, function setValue_direct_setMatrixWorldNeedsUpdate(buffer, offset) {\n\t\t\tthis.targetObject[this.propertyName] = buffer[offset];\n\t\t\tthis.targetObject.matrixWorldNeedsUpdate = true;\n\t\t}], [// EntireArray\n\t\tfunction setValue_array(buffer, offset) {\n\t\t\tvar dest = this.resolvedProperty;\n\n\t\t\tfor (var i = 0, n = dest.length; i !== n; ++i) {\n\t\t\t\tdest[i] = buffer[offset++];\n\t\t\t}\n\t\t}, function setValue_array_setNeedsUpdate(buffer, offset) {\n\t\t\tvar dest = this.resolvedProperty;\n\n\t\t\tfor (var i = 0, n = dest.length; i !== n; ++i) {\n\t\t\t\tdest[i] = buffer[offset++];\n\t\t\t}\n\n\t\t\tthis.targetObject.needsUpdate = true;\n\t\t}
1, function setValue_array_setMatrixWorldNeedsUpdate(buffer, offset) {\n\t\t\tvar dest = this.resolvedProperty;\n\n\t\t\tfor (var i = 0, n = dest.length; i !== n; ++i) {\n\t\t\t\tdest[i] = buffer[offset++];\n\t\t\t}\n\n\t\t\tthis.targetObject.matrixWorldNeedsUpdate = true;\n\t\t}], [// ArrayElement\n\t\tfunction setValue_arrayElement(buffer, offset) {\n\t\t\tthis.resolvedProperty[this.propertyIndex] = buffer[offset];\n\t\t}, function setValue_arrayElement_setNeedsUpdate(buffer, offset) {\n\t\t\tthis.resolvedProperty[this.propertyIndex] = buffer[offset];\n\t\t\tthis.targetObject.needsUpdate = true;\n\t\t}, function setValue_arrayElement_setMatrixWorldNeedsUpdate(buffer, offset) {\n\t\t\tthis.resolvedProperty[this.propertyIndex] = buffer[offset];\n\t\t\tthis.targetObject.matrixWorldNeedsUpdate = true;\n\t\t}], [// HasToFromArray\n\t\tfunction setValue_fromArray(buffer, offset) {\n\t\t\tthis.resolvedProperty.fromArray(buffer, offset);\n\t\t}, function setValue_fromArray_setNeedsUpdate(buffer, offset) {\n\t\t\tthis.resolvedProperty.fromArray(buffer, offset);\n\t\t\tthis.targetObject.needsUpdate = true;\n\t\t}, function setValue_fromArray_setMatrixWorldNeedsUpdate(buffer, offset) {\n\t\t\tthis.resolvedProperty.fromArray(buffer, offset);\n\t\t\tthis.targetObject.matrixWorldNeedsUpdate = true;\n\t\t}]],\n\t\tgetValue: function getValue_unbound(targetArray, offset) {\n\t\t\tthis.bind();\n\t\t\tthis.getValue(targetArray, offset); // Note: This class uses a State pattern on a per-method basis:\n\t\t\t// 'bind' sets 'this.getValue' / 'setValue' and shadows the\n\t\t\t// prototype version of these methods with one that represents\n\t\t\t// the bound state. When the property is not found, the methods\n\t\t\t// become no-ops.\n\t\t},\n\t\tsetValue: function getValue_unbound(sourceArray, offset) {\n\t\t\tthis.bind();\n\t\t\tthis.setValue(sourceArray, offset);\n\t\t},\n\t\t// create getter / setter pair for a property in the scene graph\n\t\tbind: function bind() {\n\t\t\tvar targetObject = this.node;\n\t\t\tvar parsedPath = this.parsedPath;\n\t\t\tvar objectName = parsedPath.objectName;\n\t\t\tvar propertyName = parsedPath.propertyName;\n\t\t\tvar propertyIndex = parsedPath.propertyIndex;\n\n\t\t\tif (!targetObject) {\n\t\t\t\ttargetObject = PropertyBinding.findNode(this.rootNode, parsedPath.nodeName) || this.rootNode;\n\t\t\t\tthis.node = targetObject;\n\t\t\t} // set fail state so we can just 'return' on error\n\n\n\t\t\tthis.getValue = this._getValue_unavailable;\n\t\t\tthis.setValue = this._setValue_unavailable; // ensure there is a value node\n\n\t\t\tif (!targetObject) {\n\t\t\t\tconsole.error('THREE.PropertyBinding: Trying to update node for track: ' + this.path + ' but it wasn\\'t found.');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (objectName) {\n\t\t\t\tvar objectIndex = parsedPath.objectIndex; // special cases were we need to reach deeper into the hierarchy to get the face materials....\n\n\t\t\t\tswitch (objectName) {\n\t\t\t\t\tcase 'materials':\n\t\t\t\t\t\tif (!targetObject.material) {\n\t\t\t\t\t\t\tconsole.error('THREE.PropertyBinding: Can not bind to material as node does not have a material.', this);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!targetObject.material.materials) {\n\t\t\t\t\t\t\tconsole.error('THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.', this);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttargetObject = targetObject.material.materials;\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase 'bones':\n\t\t\t\t\t\tif (!targetObject.skeleton) {\n\t\t\t\t\t\t\tconsole.error('THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.', this);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t} // potential future optimization: skip this if propertyIndex is already an integer\n\t\t\t\t\t\t// and convert the integer string to a true integer.\n\n\n\t\t\t\t\t\ttargetObject = targetObject.skeleton.bones; // support resolving morphTarget names into indices.\n\n\t\t\t\t\t\tfor (var i = 0; i < targetObject.length; i++) {\n\t\t\t\t\t\t\tif (targetObject[i].name === objectIndex) {\n\t\t\t\t\t\t\t\tobjectIndex = i;\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tif (targetObject[objectName] === undefined) {\n\t\t\t\t\t\t\tconsole.error('THREE.PropertyBinding: Can not bind to objectName of node undefined.', this);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttargetObject = targetObject[objectName];\n\t\t\t\t}\n\n\t\t\t\tif (objectIndex !== undefined) {\n\t\t\t\t\tif (targetObject[objectIndex] === undefined) {\n\t\t\t\t\t\tconsole.error('THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.', this, targetObject);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\ttargetObject = targetObject[objectIndex];\n\t\t\t\t}\n\t\t\t} // resolve property\n\n\n\t\t\tvar nodeProperty = targetObject[propertyName];\n\n\t\t\tif (nodeProperty === undefined) {\n\t\t\t\tvar nodeName = parsedPath.nodeName;\n\t\t\t\tconsole.error('THREE.PropertyBinding: Trying to update property for track: ' + nodeName + '.' + propertyName + ' but it wasn\\'t found.', targetObject);\n\t\t\t\treturn;\n\t\t\t} // determine versioning scheme\n\n\n\t\t\tvar versioning = this.Versioning.None;\n\t\t\tthis.targetObject = targetObject;\n\n\t\t\tif (targetObject.needsUpdate !== undefined) {\n\t\t\t\t// material\n\t\t\t\tversioning = this.Versioning.NeedsUpdate;\n\t\t\t} else if (targetObject.matrixWorldNeedsUpdate !== undefined) {\n\t\t\t\t// node transform\n\t\t\t\tversioning = this.Versioning.MatrixWorldNeedsUpdate;\n\t\t\t} // determine how the property gets bound\n\n\n\t\t\tvar bindingType = this.BindingType.Direct;\n\n\t\t\tif (propertyIndex !== undefined) {\n\t\t\t\t// access a sub element of the property array (only primitives are supported right now)\n\t\t\t\tif (propertyName === 'morphTargetInfluences') {\n\t\t\t\t\t// potential optimization, skip this if propertyIndex is already an integer, and convert the integer string to a true integer.\n\t\t\t\t\t// support resolving morphTarget names into indices.\n\t\t\t\t\tif (!targetObject.geometry) {\n\t\t\t\t\t\tconsole.error('THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.', this);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (targetObject.geometry.isBufferGeometry) {\n\t\t\t\t\t\tif (!targetObject.geometry.morphAttributes) {\n\t\t\t\t\t\t\tconsole.error('THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.', this);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (targetObject.morphTargetDictionary[propertyIndex] !== undefined) {\n\t\t\t\t\t\t\tpropertyIndex = targetObject.morphTargetDictionary[propertyIndex];\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.error('THREE.PropertyBinding: Can not bind to morphTargetInfluences on THREE.Geometry. Use THREE.BufferGeometry instead.', this);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tbindingType = this.BindingType.ArrayElement;\n\t\t\t\tthis.resolvedProperty = nodeProperty;\n\t\t\t\tthis.propertyIndex = propertyIndex;\n\t\t\t} else if (nodeProperty.fromArray !== undefined && nodeProperty.toArray !== undefined) {\n\t\t\t\t// must use copy for Object3D.Euler/Quaternion\n\t\t\t\tbindingType = this.BindingType.HasFromToArray;\n\t\t\t\tthis.resolvedProperty = nodeProperty;\n\t\t\t} else if (Array.isArray(nodeProperty)) {\n\t\t\t\tbindingType = this.BindingType.EntireArray;\n\t\t\t\tthis.resolvedProperty = nodeProperty;\n\t\t\t} else {\n\t\t\t\tthis.propertyName = propertyName;\n\t\t\t} // select getter / setter\n\n\n\t\t\tthis.getValue = this.GetterByBindingType[bindingType];\n\t\t\tthis.setValue = this.SetterByBindingTypeAndVersioning[bindingType][versioning];\n\t\t},\n\t\tunbind: function unbind() {\n\t\t\tthis.node = null; // back to the prototype version of getValue / setValue\n\t\t\t// note: avoiding to mutate the shape of 'this' via 'delete'\n\n\t\t\tthis.getValue = this._getValue_unbound;\n\t\t\tthis.setValue = this._setValue_unbound;\n\t\t}\n\t}); // DECLARE ALIAS AFTER assign prototype\n\n\tObject.assign(PropertyBinding.prototype, {\n\t\t// initial state of these methods that calls 'bind'\n\t\t_getValue_unbound: PropertyBinding.prototype.getValue,\n\t\t_setValue_unbound: PropertyBinding.prototype.setValue\n\t});\n\n\t/**\n\t *\n\t * A group of objects that receives a shared animation state.\n\t *\n\t * Usage:\n\t *\n\t *\t- Add objects you would otherwise pass as 'root' to the\n\t *\t\tconstructor or the .clipAction method of AnimationMixer.\n\t *\n\t *\t- Instead pass this object as 'root'.\n\t *\n\t *\t- You can also add and remove objects later when the mixer\n\t *\t\tis running.\n\t *\n\t * Note:\n\t *\n\t *\t\tObjects of this class appear as one object to the mixer,\n\t *\t\tso cache
1control of the individual objects must be done\n\t *\t\ton the group.\n\t *\n\t * Limitation:\n\t *\n\t *\t- The animated properties must be compatible among the\n\t *\t\tall objects in the group.\n\t *\n\t *\t- A single property can either be controlled through a\n\t *\t\ttarget group or directly, but not both.\n\t */\n\n\tfunction AnimationObjectGroup() {\n\t\tthis.uuid = MathUtils.generateUUID(); // cached objects followed by the active ones\n\n\t\tthis._objects = Array.prototype.slice.call(arguments);\n\t\tthis.nCachedObjects_ = 0; // threshold\n\t\t// note: read by PropertyBinding.Composite\n\n\t\tvar indices = {};\n\t\tthis._indicesByUUID = indices; // for bookkeeping\n\n\t\tfor (var i = 0, n = arguments.length; i !== n; ++i) {\n\t\t\tindices[arguments[i].uuid] = i;\n\t\t}\n\n\t\tthis._paths = []; // inside: string\n\n\t\tthis._parsedPaths = []; // inside: { we don't care, here }\n\n\t\tthis._bindings = []; // inside: Array< PropertyBinding >\n\n\t\tthis._bindingsIndicesByPath = {}; // inside: indices in these arrays\n\n\t\tvar scope = this;\n\t\tthis.stats = {\n\t\t\tobjects: {\n\t\t\t\tget total() {\n\t\t\t\t\treturn scope._objects.length;\n\t\t\t\t},\n\n\t\t\t\tget inUse() {\n\t\t\t\t\treturn this.total - scope.nCachedObjects_;\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tget bindingsPerObject() {\n\t\t\t\treturn scope._bindings.length;\n\t\t\t}\n\n\t\t};\n\t}\n\n\tObject.assign(AnimationObjectGroup.prototype, {\n\t\tisAnimationObjectGroup: true,\n\t\tadd: function add() {\n\t\t\tvar objects = this._objects,\n\t\t\t\t\tindicesByUUID = this._indicesByUUID,\n\t\t\t\t\tpaths = this._paths,\n\t\t\t\t\tparsedPaths = this._parsedPaths,\n\t\t\t\t\tbindings = this._bindings,\n\t\t\t\t\tnBindings = bindings.length;\n\t\t\tvar knownObject = undefined,\n\t\t\t\t\tnObjects = objects.length,\n\t\t\t\t\tnCachedObjects = this.nCachedObjects_;\n\n\t\t\tfor (var i = 0, n = arguments.length; i !== n; ++i) {\n\t\t\t\tvar object = arguments[i],\n\t\t\t\t\t\tuuid = object.uuid;\n\t\t\t\tvar index = indicesByUUID[uuid];\n\n\t\t\t\tif (index === undefined) {\n\t\t\t\t\t// unknown object -> add it to the ACTIVE region\n\t\t\t\t\tindex = nObjects++;\n\t\t\t\t\tindicesByUUID[uuid] = index;\n\t\t\t\t\tobjects.push(object); // accounting is done, now do the same for all bindings\n\n\t\t\t\t\tfor (var j = 0, m = nBindings; j !== m; ++j) {\n\t\t\t\t\t\tbindings[j].push(new PropertyBinding(object, paths[j], parsedPaths[j]));\n\t\t\t\t\t}\n\t\t\t\t} else if (index < nCachedObjects) {\n\t\t\t\t\tknownObject = objects[index]; // move existing object to the ACTIVE region\n\n\t\t\t\t\tvar firstActiveIndex = --nCachedObjects,\n\t\t\t\t\t\t\tlastCachedObject = objects[firstActiveIndex];\n\t\t\t\t\tindicesByUUID[lastCachedObject.uuid] = index;\n\t\t\t\t\tobjects[index] = lastCachedObject;\n\t\t\t\t\tindicesByUUID[uuid] = firstActiveIndex;\n\t\t\t\t\tobjects[firstActiveIndex] = object; // accounting is done, now do the same for all bindings\n\n\t\t\t\t\tfor (var _j = 0, _m = nBindings; _j !== _m; ++_j) {\n\t\t\t\t\t\tvar bindingsForPath = bindings[_j],\n\t\t\t\t\t\t\t\tlastCached = bindingsForPath[firstActiveIndex];\n\t\t\t\t\t\tvar binding = bindingsForPath[index];\n\t\t\t\t\t\tbindingsForPath[index] = lastCached;\n\n\t\t\t\t\t\tif (binding === undefined) {\n\t\t\t\t\t\t\t// since we do not bother to create new bindings\n\t\t\t\t\t\t\t// for objects that are cached, the binding may\n\t\t\t\t\t\t\t// or may not exist\n\t\t\t\t\t\t\tbinding = new PropertyBinding(object, paths[_j], parsedPaths[_j]);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbindingsForPath[firstActiveIndex] = binding;\n\t\t\t\t\t}\n\t\t\t\t} else if (objects[index] !== knownObject) {\n\t\t\t\t\tconsole.error('THREE.AnimationObjectGroup: Different objects with the same UUID ' + 'detected. Clean the caches or recreate your infrastructure when reloading scenes.');\n\t\t\t\t} // else the object is already where we want it to be\n\n\t\t\t} // for arguments\n\n\n\t\t\tthis.nCachedObjects_ = nCachedObjects;\n\t\t},\n\t\tremove: function remove() {\n\t\t\tvar objects = this._objects,\n\t\t\t\t\tindicesByUUID = this._indicesByUUID,\
1n\t\t\t\t\tbindings = this._bindings,\n\t\t\t\t\tnBindings = bindings.length;\n\t\t\tvar nCachedObjects = this.nCachedObjects_;\n\n\t\t\tfor (var i = 0, n = arguments.length; i !== n; ++i) {\n\t\t\t\tvar object = arguments[i],\n\t\t\t\t\t\tuuid = object.uuid,\n\t\t\t\t\t\tindex = indicesByUUID[uuid];\n\n\t\t\t\tif (index !== undefined && index >= nCachedObjects) {\n\t\t\t\t\t// move existing object into the CACHED region\n\t\t\t\t\tvar lastCachedIndex = nCachedObjects++,\n\t\t\t\t\t\t\tfirstActiveObject = objects[lastCachedIndex];\n\t\t\t\t\tindicesByUUID[firstActiveObject.uuid] = index;\n\t\t\t\t\tobjects[index] = firstActiveObject;\n\t\t\t\t\tindicesByUUID[uuid] = lastCachedIndex;\n\t\t\t\t\tobjects[lastCachedIndex] = object; // accounting is done, now do the same for all bindings\n\n\t\t\t\t\tfor (var j = 0, m = nBindings; j !== m; ++j) {\n\t\t\t\t\t\tvar bindingsForPath = bindings[j],\n\t\t\t\t\t\t\t\tfirstActive = bindingsForPath[lastCachedIndex],\n\t\t\t\t\t\t\t\tbinding = bindingsForPath[index];\n\t\t\t\t\t\tbindingsForPath[index] = firstActive;\n\t\t\t\t\t\tbindingsForPath[lastCachedIndex] = binding;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} // for arguments\n\n\n\t\t\tthis.nCachedObjects_ = nCachedObjects;\n\t\t},\n\t\t// remove & forget\n\t\tuncache: function uncache() {\n\t\t\tvar objects = this._objects,\n\t\t\t\t\tindicesByUUID = this._indicesByUUID,\n\t\t\t\t\tbindings = this._bindings,\n\t\t\t\t\tnBindings = bindings.length;\n\t\t\tvar nCachedObjects = this.nCachedObjects_,\n\t\t\t\t\tnObjects = objects.length;\n\n\t\t\tfor (var i = 0, n = arguments.length; i !== n; ++i) {\n\t\t\t\tvar object = arguments[i],\n\t\t\t\t\t\tuuid = object.uuid,\n\t\t\t\t\t\tindex = indicesByUUID[uuid];\n\n\t\t\t\tif (index !== undefined) {\n\t\t\t\t\tdelete indicesByUUID[uuid];\n\n\t\t\t\t\tif (index < nCachedObjects) {\n\t\t\t\t\t\t// object is cached, shrink the CACHED region\n\t\t\t\t\t\tvar firstActiveIndex = --nCachedObjects,\n\t\t\t\t\t\t\t\tlastCachedObject = objects[firstActiveIndex],\n\t\t\t\t\t\t\t\tlastIndex = --nObjects,\n\t\t\t\t\t\t\t\tlastObject = objects[lastIndex]; // last cached object takes this object's place\n\n\t\t\t\t\t\tindicesByUUID[lastCachedObject.uuid] = index;\n\t\t\t\t\t\tobjects[index] = lastCachedObject; // last object goes to the activated slot and pop\n\n\t\t\t\t\t\tindicesByUUID[lastObject.uuid] = firstActiveIndex;\n\t\t\t\t\t\tobjects[firstActiveIndex] = lastObject;\n\t\t\t\t\t\tobjects.pop(); // accounting is done, now do the same for all bindings\n\n\t\t\t\t\t\tfor (var j = 0, m = nBindings; j !== m; ++j) {\n\t\t\t\t\t\t\tvar bindingsForPath = bindings[j],\n\t\t\t\t\t\t\t\t\tlastCached = bindingsForPath[firstActiveIndex],\n\t\t\t\t\t\t\t\t\tlast = bindingsForPath[lastIndex];\n\t\t\t\t\t\t\tbindingsForPath[index] = lastCached;\n\t\t\t\t\t\t\tbindingsForPath[firstActiveIndex] = last;\n\t\t\t\t\t\t\tbindingsForPath.pop();\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// object is active, just swap with the last and pop\n\t\t\t\t\t\tvar _lastIndex = --nObjects,\n\t\t\t\t\t\t\t\t_lastObject = objects[_lastIndex];\n\n\t\t\t\t\t\tif (_lastIndex > 0) {\n\t\t\t\t\t\t\tindicesByUUID[_lastObject.uuid] = index;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tobjects[index] = _lastObject;\n\t\t\t\t\t\tobjects.pop(); // accounting is done, now do the same for all bindings\n\n\t\t\t\t\t\tfor (var _j2 = 0, _m2 = nBindings; _j2 !== _m2; ++_j2) {\n\t\t\t\t\t\t\tvar _bindingsForPath = bindings[_j2];\n\t\t\t\t\t\t\t_bindingsForPath[index] = _bindingsForPath[_lastIndex];\n\n\t\t\t\t\t\t\t_bindingsForPath.pop();\n\t\t\t\t\t\t}\n\t\t\t\t\t} // cached or active\n\n\t\t\t\t} // if object is known\n\n\t\t\t} // for arguments\n\n\n\t\t\tthis.nCachedObjects_ = nCachedObjects;\n\t\t},\n\t\t// Internal interface used by befriended PropertyBinding.Composite:\n\t\tsubscribe_: function subscribe_(path, parsedPath) {\n\t\t\t// returns an array of bindings for the given path that is changed\n\t\t\t// according to the contained objects in the group\n\t\t\tvar indicesByPath = this._bindingsIndicesByPath;\n\t\t\tvar index = indicesByPath[path];\n\t\t\tvar bindings = this._bindings;\n\t\t\tif (index !== undefined) return bindings[index];\n\t\t\tvar paths = this._paths,\n\t\t\t\t\tparsedPaths = this._parsedPaths,\n\t\t\t\t\tobjects = this._objects,\n\t\t\t\t\tnObjects = objects.length,\n\t\t\t\t\tnCachedObjects = this.nCachedObjects_,\n\t\t\t\t\tbindingsForPath
1= new Array(nObjects);\n\t\t\tindex = bindings.length;\n\t\t\tindicesByPath[path] = index;\n\t\t\tpaths.push(path);\n\t\t\tparsedPaths.push(parsedPath);\n\t\t\tbindings.push(bindingsForPath);\n\n\t\t\tfor (var i = nCachedObjects, n = objects.length; i !== n; ++i) {\n\t\t\t\tvar object = objects[i];\n\t\t\t\tbindingsForPath[i] = new PropertyBinding(object, path, parsedPath);\n\t\t\t}\n\n\t\t\treturn bindingsForPath;\n\t\t},\n\t\tunsubscribe_: function unsubscribe_(path) {\n\t\t\t// tells the group to forget about a property path and no longer\n\t\t\t// update the array previously obtained with 'subscribe_'\n\t\t\tvar indicesByPath = this._bindingsIndicesByPath,\n\t\t\t\t\tindex = indicesByPath[path];\n\n\t\t\tif (index !== undefined) {\n\t\t\t\tvar paths = this._paths,\n\t\t\t\t\t\tparsedPaths = this._parsedPaths,\n\t\t\t\t\t\tbindings = this._bindings,\n\t\t\t\t\t\tlastBindingsIndex = bindings.length - 1,\n\t\t\t\t\t\tlastBindings = bindings[lastBindingsIndex],\n\t\t\t\t\t\tlastBindingsPath = path[lastBindingsIndex];\n\t\t\t\tindicesByPath[lastBindingsPath] = index;\n\t\t\t\tbindings[index] = lastBindings;\n\t\t\t\tbindings.pop();\n\t\t\t\tparsedPaths[index] = parsedPaths[lastBindingsIndex];\n\t\t\t\tparsedPaths.pop();\n\t\t\t\tpaths[index] = paths[lastBindingsIndex];\n\t\t\t\tpaths.pop();\n\t\t\t}\n\t\t}\n\t});\n\n\tvar AnimationAction = /*#__PURE__*/function () {\n\t\tfunction AnimationAction(mixer, clip, localRoot, blendMode) {\n\t\t\tif (localRoot === void 0) {\n\t\t\t\tlocalRoot = null;\n\t\t\t}\n\n\t\t\tif (blendMode === void 0) {\n\t\t\t\tblendMode = clip.blendMode;\n\t\t\t}\n\n\t\t\tthis._mixer = mixer;\n\t\t\tthis._clip = clip;\n\t\t\tthis._localRoot = localRoot;\n\t\t\tthis.blendMode = blendMode;\n\t\t\tvar tracks = clip.tracks,\n\t\t\t\t\tnTracks = tracks.length,\n\t\t\t\t\tinterpolants = new Array(nTracks);\n\t\t\tvar interpolantSettings = {\n\t\t\t\tendingStart: ZeroCurvatureEnding,\n\t\t\t\tendingEnd: ZeroCurvatureEnding\n\t\t\t};\n\n\t\t\tfor (var i = 0; i !== nTracks; ++i) {\n\t\t\t\tvar interpolant = tracks[i].createInterpolant(null);\n\t\t\t\tinterpolants[i] = interpolant;\n\t\t\t\tinterpolant.settings = interpolantSettings;\n\t\t\t}\n\n\t\t\tthis._interpolantSettings = interpolantSettings;\n\t\t\tthis._interpolants = interpolants; // bound by the mixer\n\t\t\t// inside: PropertyMixer (managed by the mixer)\n\n\t\t\tthis._propertyBindings = new Array(nTracks);\n\t\t\tthis._cacheIndex = null; // for the memory manager\n\n\t\t\tthis._byClipCacheIndex = null; // for the memory manager\n\n\t\t\tthis._timeScaleInterpolant = null;\n\t\t\tthis._weightInterpolant = null;\n\t\t\tthis.loop = LoopRepeat;\n\t\t\tthis._loopCount = -1; // global mixer time when the action is to be started\n\t\t\t// it's set back to 'null' upon start of the action\n\n\t\t\tthis._startTime = null; // scaled local time of the action\n\t\t\t// gets clamped or wrapped to 0..clip.duration according to loop\n\n\t\t\tthis.time = 0;\n\t\t\tthis.timeScale = 1;\n\t\t\tthis._effectiveTimeScale = 1;\n\t\t\tthis.weight = 1;\n\t\t\tthis._effectiveWeight = 1;\n\t\t\tthis.repetitions = Infinity; // no. of repetitions when looping\n\n\t\t\tthis.paused = false; // true -> zero effective time scale\n\n\t\t\tthis.enabled = true; // false -> zero effective weight\n\n\t\t\tthis.clampWhenFinished = false; // keep feeding the last frame?\n\n\t\t\tthis.zeroSlopeAtStart = true; // for smooth interpolation w/o separate\n\n\t\t\tthis.zeroSlopeAtEnd = true; // clips for start, loop and end\n\t\t} // State & Scheduling\n\n\n\t\tvar _proto = AnimationAction.prototype;\n\n\t\t_proto.play = function play() {\n\t\t\tthis._mixer._activateAction(this);\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.stop = function stop() {\n\t\t\tthis._mixer._deactivateAction(this);\n\n\t\t\treturn this.reset();\n\t\t};\n\n\t\t_proto.reset = function reset() {\n\t\t\tthis.paused = false;\n\t\t\tthis.enabled = true;\n\t\t\tthis.time = 0; // restart clip\n\n\t\t\tthis._loopCount = -1; // forget previous loops\n\n\t\t\tthis._startTime = null; // forget scheduling\n\n\t\t\treturn this.stopFading().stopWarping();\n\t\t};\n\n\t\t_proto.isRunning = function isRunning() {\n\t\t\treturn this.enabled && !this.paused && this.timeScale !== 0 && this._startTime === null && this._mixer._isActiveAction(this);\n\t\t} // return true when play has been called\n\t\t;\n\n\t\t_proto.isScheduled = function isScheduled() {\n\t\t\treturn this._mixer._isActiveAction(this);\n\t\t};\n\n\t\t_proto.startAt = function startAt(time) {\n\t\t\tthis._startTime = time;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setLoop = function setLoop(mode, repetitions) {\n\t\t\tthis.loop = mode;\n\t\t\tthis.repetitions = repetitions;\n\t\t\treturn this;\n\t\t} // Weight\n\t\t// set the weight stopping any scheduled fading\n\t\t// although .enabled = false yields an effective weight of zero, this\n\t\t// method does *not* change .enabled, because it would be confusing\n\t\t;\n\n\t\t_proto.setEffectiveWeight = function setEffectiveWeight(weight) {\n\t\t\tthis.weight = weight; // note: same logic as when updated at runtime\n\n\t\t\tthis._effectiveWeight = this.enabled ? weight : 0;\n\t\t\treturn this.stopFading();\n\t\t} // return the weight considering fading and .enabled\n\t\t;\n\n\t\t_proto.getEffectiveWeight = function getEffectiveWeight() {\n\t\t\treturn this._effectiveWeight;\n\t\t};\n\n\t\t_proto.fadeIn = function fadeIn(duration) {\n\t\t\treturn this._scheduleFading(duration, 0, 1);\n\t\t};\n\n\t\t_proto.fadeOut = function fadeOut(duration) {\n\t\t\treturn this._scheduleFading(duration, 1, 0);\n\t\t};\n\n\t\t_proto.crossFadeFrom = function crossFadeFrom(fadeOutAction, duration, warp) {\n\t\t\tfadeOutAction.fadeOut(duration);\n\t\t\tthis.fadeIn(duration);\n\n\t\t\tif (warp) {\n\t\t\t\tvar fadeInDuration = this._clip.duration,\n\t\t\t\t\t\tfadeOutDuration = fadeOutAction._clip.duration,\n\t\t\t\t\t\tstartEndRatio = fadeOutDuration / fadeInDuration,\n\t\t\t\t\t\tendStartRatio = fadeInDuration / fadeOutDuration;\n\t\t\t\tfadeOutAction.warp(1.0, startEndRatio, duration);\n\t\t\t\tthis.warp(endStartRatio, 1.0, duration);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.crossFadeTo = function crossFadeTo(fadeInAction, duration, warp) {\n\t\t\treturn fadeInAction.crossFadeFrom(this, duration, warp);\n\t\t};\n\n\t\t_proto.stopFading = function stopFading() {\n\t\t\tvar weightInterpolant = this._weightInterpolant;\n\n\t\t\tif (weightInterpolant !== null) {\n\t\t\t\tthis._weightInterpolant = null;\n\n\t\t\t\tthis._mixer._takeBackControlInterpolant(weightInterpolant);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t} // Time Scale Control\n\t\t// set the time scale stopping any scheduled warping\n\t\t// although .paused = true yields an effective time scale of zero, this\n\t\t// method does *not* change .paused, because it would be confusing\n\t\t;\n\n\t\t_proto.setEffectiveTimeScale = function setEffectiveTimeScale(timeScale) {\n\t\t\tthis.timeScale = timeScale;\n\t\t\tthis._effectiveTimeScale = this.paused ? 0 : timeScale;\n\t\t\treturn this.stopWarping();\n\t\t} // return the time scale considering warping and .paused\n\t\t;\n\n\t\t_proto.getEffectiveTimeScale = function getEffectiveTimeScale() {\n\t\t\treturn this._effectiveTimeScale;\n\t\t};\n\n\t\t_proto.setDuration = function setDuration(duration) {\n\t\t\tthis.timeScale = this._clip.duration / duration;\n\t\t\treturn this.stopWarping();\n\t\t};\n\n\t\t_proto.syncWith = function syncWith(action) {\n\t\t\tthis.time = action.time;\n\t\t\tthis.timeScale = action.timeScale;\n\t\t\treturn this.stopWarping();\n\t\t};\n\n\t\t_proto.halt = function halt(duration) {\n\t\t\treturn this.warp(this._effectiveTimeScale, 0, duration);\n\t\t};\n\n\t\t_proto.warp = function warp(startTimeScale, endTimeScale, duration) {\n\t\t\tvar mixer = this._mixer,\n\t\t\t\t\tnow = mixer.time,\n\t\t\t\t\ttimeScale = this.timeScale;\n\t\t\tvar interpolant = this._timeScaleInterpolant;\n\n\t\t\tif (interpolant === null) {\n\t\t\t\tinterpolant = mixer._lendControlInterpolant();\n\t\t\t\tthis._timeScaleInterpolant = interpolant;\n\t\t\t}\n\n\t\t\tvar times = interpolant.parameterPositions,\n\t\t\t\t\tvalues = interpolant.sampleValues;\n\t\t\ttimes[0] = now;\n\t\t\ttimes[1] = now + duration;\n\t\t\tvalues[0] = startTimeScale / timeScale;\n\t\t\tvalues[1] = endTimeScale / timeScale;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.stopWarping = function stopWarping() {\n\t\t\tvar timeScaleInterpolant = this._timeScaleInterpolant;\n\n\t\t\tif (timeScaleInterpolant !== null) {\n\t\t\t\tthis._timeScaleInterpolant = null;\n\n\t\t\t\tthis._mixer._takeBackControlInterpolant(timeScaleInterpolant);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t} // Object Accessors\n\t\t;\n\n\t\t_proto.getMixer = function getMixer() {\n\t\t\treturn this._mixer;\n\t\t};\n\n\t\t_proto.getClip = function getClip() {\n\t\t\treturn this._clip;\n\t\t};\n\n\t\t_proto.getRoot = function getRoot() {\n\t\t\treturn this._localRoot || this._mixer._root;\n\t\t} // Interna\n\t\t;\n\n\t\t_proto._update = function _update(time, deltaTime, timeDirection, accuIndex) {\n\t\t\t// called by the mixer\n\t\t\tif (!this.enabled) {\n\t\t\t\t// call ._updateWeight() to update ._effectiveWeight\n\t\t\t\tthis._updateWeight(time);\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar startTime = this._startTime;\n\n\t\t\tif (startTime !== null) {\n\t\t\t\t// check for scheduled start of action\n\t\t\t\tvar timeRunning = (time - startTime) * timeDirection;\n\n\t\t\t\tif (timeRunning < 0 || timeDirection === 0) {\n\t\t\t\t\treturn; // yet to come / don't decide when delta = 0\n\t\t\t\t} // start\n\n\n\t\t\t\tthis._startTime = null; // unschedule\n\n\t\t\t\tdeltaTime = timeDirection * timeRunning;\n\t\t\t} // apply time scale and advance time\n\n\n\t\t\tdeltaTime *= this._updateTimeScale(time);\n\n\t\t\tvar clipTime = this._updateTime(deltaTime); // note: _updateTime may disable the action resulting in\n\t\t\t// an effective weight of 0\n\n\n\t\t\tvar weight = this._updateWeight(time);\n\n\t\t\tif (weight > 0) {\n\t\t\t\tvar _interpolants = this._interpolants;\n\t\t\t\tvar propertyMixers = this._propertyBindings;\n\n\t\t\t\tswitch (this.blendMode) {\n\t\t\t\t\tcase AdditiveAnimationBlendMode:\n\t\t\t\t\t\tfor (var j = 0, m = _interpolants.length; j !== m; ++j) {\n\t\t\t\t\t\t\t_interpolants[j].evaluate(clipTime);\n\n\t\t\t\t\t\t\tpropertyMixers[j].accumulateAdditive(weight);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\tcase NormalAnimationBlendMode:\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tfor (var _j = 0, _m = _interpolants.length; _j !== _m; ++_j) {\n\t\t\t\t\t\t\t_interpolants[_j].evaluate(clipTime);\n\n\t\t\t\t\t\t\tpropertyMixers[_j].accumulate(accuIndex, weight);\n\t\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\t_proto._updateWeight = function _updateWeight(time) {\n\t\t\tvar weight = 0;\n\n\t\t\tif (this.enabled) {\n\t\t\t\tweight = this.weight;\n\t\t\t\tvar interpolant = this._weightInterpolant;\n\n\t\t\t\tif (interpolant !== null) {\n\t\t\t\t\tvar interpolantValue = interpolant.evaluate(time)[0];\n\t\t\t\t\tweight *= interpolantValue;\n\n\t\t\t\t\tif (time > interpolant.parameterPositions[1]) {\n\t\t\t\t\t\tthis.stopFading();\n\n\t\t\t\t\t\tif (interpolantValue === 0) {\n\t\t\t\t\t\t\t// faded out, disable\n\t\t\t\t\t\t\tthis.enabled = false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._effectiveWeight = weight;\n\t\t\treturn weight;\n\t\t};\n\n\t\t_proto._updateTimeScale = function _updateTimeScale(time) {\n\t\t\tvar timeScale = 0;\n\n\t\t\tif (!this.paused) {\n\t\t\t\ttimeScale = this.timeScale;\n\t\t\t\tvar interpolant = this._timeScaleInterpolant;\n\n\t\t\t\tif (interpolant !== null) {\n\t\t\t\t\tvar interpolantValue = interpolant.evaluate(time)[0];\n\t\t\t\t\ttimeScale *= interpolantValue;\n\n\t\t\t\t\tif (time > interpolant.parameterPositions[1]) {\n\t\t\t\t\t\tthis.stopWarping();\n\n\t\t\t\t\t\tif (timeScale === 0) {\n\t\t\t\t\t\t\t// motion has halted, pause\n\t\t\t\t\t\t\tthis.paused = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// warp done - apply final time scale\n\t\t\t\t\t\t\tthis.timeScale = timeScale;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._effectiveTimeScale = timeScale;\n\t\t\treturn timeScale;\n\t\t};\n\n\t\t_proto._updateTime = function _updateTime(deltaTime) {\n\t\t\tvar duration = this._clip.duration;\n\t\t\tvar loop = this.loop;\n\t\t\tvar time = this.time + deltaTime;\n\t\t\tvar loopCount = this._loopCount;\n\t\t\tvar pingPong = loop === LoopPingPong;\n\n\t\t\tif (deltaTime === 0) {\n\t\t\t\tif (loopCount === -1) return time;\n\t\t\t\treturn pingPong && (loopCount & 1) === 1 ? duration - time : time;\n\t\t\t}\n\n\t\t\tif (loop === LoopOnce) {\n\t\t\t\tif (loopCount === -1) {\n\t\t\t\t\t// just started\n\t\t\t\t\tthis._loopCount = 0;\n\n\t\t\t\t\tthis._setEndings(true, true, false);\n\t\t\t\t}\n\n\t\t\t\thandle_stop: {\n\t\t\t\t\tif (time >= duration) {\n\t\t\t\t\t\ttime = duration;\n\t\t\t\t\t} else if (time < 0) {\n\t\t\t\t\t\ttime = 0;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.time = time;\n\t\t\t\t\t\tbreak handle_stop;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this.clampWhenFinished) this.paused = true;else this.enabled = false;\n\t\t\t\t\tthis.time = time;\n\n\t\t\t\t\tthis._mixer.dispatchEvent({\n\t\t\t\t\t\ttype: 'finished',\n\t\t\t\t\t\taction: this,\n\t\t\t\t\t\tdirection: deltaTime < 0 ? -1 : 1\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// repetitive Repeat or PingPong\n\t\t\t\tif (loopCount === -1) {\n\t\t\t\t\t// just started\n\t\t\t\t\tif (deltaTime >= 0) {\n\t\t\t\t\t\tloopCount = 0;\n\n\t\t\t\t\t\tthis._setEndings(true, this.repetitions === 0, pingPong);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// when looping in reverse direction, the initial\n\t\t\t\t\t\t// transition through zero counts as a repetition,\n\t\t\t\t\t\t// so leave loopCount at -1\n\t\t\t\t\t\tthis._setEndings(this.repetitions === 0, true, pingPong);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (time >= duration || time < 0) {\n\t\t\t\t\t// wrap around\n\t\t\t\t\tvar loopDelta = Math.floor(time / duration); // signed\n\n\t\t\t\t\ttime -= duration * loopDelta;\n\t\t\t\t\tloopCount += Math.abs(loopDelta);\n\t\t\t\t\tvar pending = this.repetitions - loopCount;\n\n\t\t\t\t\tif (pending <= 0) {\n\t\t\t\t\t\t// have to stop (switch state, clamp time, fire event)\n\t\t\t\t\t\tif (this.clampWhenFinished) this.paused = true;else this.enabled = false;\n\t\t\t\t\t\ttime = deltaTime > 0 ? duration : 0;\n\t\t\t\t\t\tthis.time = time;\n\n\t\t\t\t\t\tthis._mixer.dispatchEvent({\n\t\t\t\t\t\t\ttype: 'finished',\n\t\t\t\t\t\t\taction: this,\n\t\t\t\t\t\t\tdirection: deltaTime > 0 ? 1 : -1\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// keep running\n\t\t\t\t\t\tif (pending === 1) {\n\t\t\t\t\t\t\t// entering the last round\n\t\t\t\t\t\t\tvar atStart = deltaTime < 0;\n\n\t\t\t\t\t\t\tthis._setEndings(atStart, !atStart, pingPong);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis._setEndings(false, false, pingPong);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis._loopCount = loopCount;\n\t\t\t\t\t\tthis.time = time;\n\n\t\t\t\t\t\tthis._mixer.dispatchEvent({\n\t\t\t\t\t\t\ttype: 'loop',\n\t\t\t\t\t\t\taction: this,\n\t\t\t\t\t\t\tloopDelta: loopDelta\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.time = time;\n\t\t\t\t}\n\n\t\t\t\tif (pingPong && (loopCount & 1) === 1) {\n\t\t\t\t\t// invert time for the \"pong round\"\n\t\t\t\t\treturn duration - time;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn time;\n\t\t};\n\n\t\t_proto._setEndings = function _setEndings(atStart, atEnd, pingPong) {\n\t\t\tvar settings = this._interpolantSettings;\n\n\t\t\tif (pingPong) {\n\t\t\t\tsettings.endingStart = ZeroSlopeEnding;\n\t\t\t\tsettings.endingEnd = ZeroSlopeEnding;\n\t\t\t} else {\n\t\t\t\t// assuming for LoopOnce atStart == atEnd == true\n\t\t\t\tif (atStart) {\n\t\t\t\t\tsettings.endingStart = this.zeroSlopeAtStart ? ZeroSlopeEnding : ZeroCurvatureEnding;\n\t\t\t\t} else {\n\t\t\t\t\tsettings.endingStart = WrapAroundEnding;\n\t\t\t\t}\n\n\t\t\t\tif (atEnd) {\n\t\t\t\t\tsettings.endingEnd = this.zeroSlopeAtEnd ? ZeroSlopeEnding : ZeroCurvatureEnding;\n\t\t\t\t} else {\n\t\t\t\t\tsettings.endingEnd = WrapAroundEnding;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\t_proto._scheduleFading = function _scheduleFading(duration, weightNow, weightThen) {\n\t\t\tvar mixer = this._mixer,\n\t\t\t\t\tnow = mixer.time;\n\t\t\tvar interpolant = this._weightInterpolant;\n\n\t\t\tif (interpolant ===
1 null) {\n\t\t\t\tinterpolant = mixer._lendControlInterpolant();\n\t\t\t\tthis._weightInterpolant = interpolant;\n\t\t\t}\n\n\t\t\tvar times = interpolant.parameterPositions,\n\t\t\t\t\tvalues = interpolant.sampleValues;\n\t\t\ttimes[0] = now;\n\t\t\tvalues[0] = weightNow;\n\t\t\ttimes[1] = now + duration;\n\t\t\tvalues[1] = weightThen;\n\t\t\treturn this;\n\t\t};\n\n\t\treturn AnimationAction;\n\t}();\n\n\tfunction AnimationMixer(root) {\n\t\tthis._root = root;\n\n\t\tthis._initMemoryManager();\n\n\t\tthis._accuIndex = 0;\n\t\tthis.time = 0;\n\t\tthis.timeScale = 1.0;\n\t}\n\n\tAnimationMixer.prototype = Object.assign(Object.create(EventDispatcher.prototype), {\n\t\tconstructor: AnimationMixer,\n\t\t_bindAction: function _bindAction(action, prototypeAction) {\n\t\t\tvar root = action._localRoot || this._root,\n\t\t\t\t\ttracks = action._clip.tracks,\n\t\t\t\t\tnTracks = tracks.length,\n\t\t\t\t\tbindings = action._propertyBindings,\n\t\t\t\t\tinterpolants = action._interpolants,\n\t\t\t\t\trootUuid = root.uuid,\n\t\t\t\t\tbindingsByRoot = this._bindingsByRootAndName;\n\t\t\tvar bindingsByName = bindingsByRoot[rootUuid];\n\n\t\t\tif (bindingsByName === undefined) {\n\t\t\t\tbindingsByName = {};\n\t\t\t\tbindingsByRoot[rootUuid] = bindingsByName;\n\t\t\t}\n\n\t\t\tfor (var i = 0; i !== nTracks; ++i) {\n\t\t\t\tvar track = tracks[i],\n\t\t\t\t\t\ttrackName = track.name;\n\t\t\t\tvar binding = bindingsByName[trackName];\n\n\t\t\t\tif (binding !== undefined) {\n\t\t\t\t\tbindings[i] = binding;\n\t\t\t\t} else {\n\t\t\t\t\tbinding = bindings[i];\n\n\t\t\t\t\tif (binding !== undefined) {\n\t\t\t\t\t\t// existing binding, make sure the cache knows\n\t\t\t\t\t\tif (binding._cacheIndex === null) {\n\t\t\t\t\t\t\t++binding.referenceCount;\n\n\t\t\t\t\t\t\tthis._addInactiveBinding(binding, rootUuid, trackName);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tvar path = prototypeAction && prototypeAction._propertyBindings[i].binding.parsedPath;\n\t\t\t\t\tbinding = new PropertyMixer(PropertyBinding.create(root, trackName, path), track.ValueTypeName, track.getValueSize());\n\t\t\t\t\t++binding.referenceCount;\n\n\t\t\t\t\tthis._addInactiveBinding(binding, rootUuid, trackName);\n\n\t\t\t\t\tbindings[i] = binding;\n\t\t\t\t}\n\n\t\t\t\tinterpolants[i].resultBuffer = binding.buffer;\n\t\t\t}\n\t\t},\n\t\t_activateAction: function _activateAction(action) {\n\t\t\tif (!this._isActiveAction(action)) {\n\t\t\t\tif (action._cacheIndex === null) {\n\t\t\t\t\t// this action has been forgotten by the cache, but the user\n\t\t\t\t\t// appears to be still using it -> rebind\n\t\t\t\t\tvar rootUuid = (action._localRoot || this._root).uuid,\n\t\t\t\t\t\t\tclipUuid = action._clip.uuid,\n\t\t\t\t\t\t\tactionsForClip = this._actionsByClip[clipUuid];\n\n\t\t\t\t\tthis._bindAction(action, actionsForClip && actionsForClip.knownActions[0]);\n\n\t\t\t\t\tthis._addInactiveAction(action, clipUuid, rootUuid);\n\t\t\t\t}\n\n\t\t\t\tvar bindings = action._propertyBindings; // increment reference counts / sort out state\n\n\t\t\t\tfor (var i = 0, n = bindings.length; i !== n; ++i) {\n\t\t\t\t\tvar binding = bindings[i];\n\n\t\t\t\t\tif (binding.useCount++ === 0) {\n\t\t\t\t\t\tthis._lendBinding(binding);\n\n\t\t\t\t\t\tbinding.saveOriginalState();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis._lendAction(action);\n\t\t\t}\n\t\t},\n\t\t_deactivateAction: function _deactivateAction(action) {\n\t\t\tif (this._isActiveAction(action)) {\n\t\t\t\tvar bindings = action._propertyBindings; // decrement reference counts / sort out state\n\n\t\t\t\tfor (var i = 0, n = bindings.length; i !== n; ++i) {\n\t\t\t\t\tvar binding = bindings[i];\n\n\t\t\t\t\tif (--binding.useCount === 0) {\n\t\t\t\t\t\tbinding.restoreOriginalState();\n\n\t\t\t\t\t\tthis._takeBackBinding(binding);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis._takeBackAction(action);\n\t\t\t}\n\t\t},\n\t\t// Memory manager\n\t\t_initMemoryManager: function _initMemoryManager() {\n\t\t\tthis._actions = []; // 'nActiveActions' followed by inactive ones\n\n\t\t\tthis._nActiveActions = 0;\n\t\t\tthis._actionsByClip = {}; // inside:\n\t\t\t// {\n\t\t\t// \tknownActions: Array< AnimationAction > - used as prototypes\n\t\t\t// \tactionByRoot: AnimationAction - lookup\n\t\t\t// }\n\n\t\t\tthis._bindings = []; // 'nActiveBindings' followed by inactive ones\n\n\t\t\tthis._nActiveBindings = 0;\n\t\t\tthis._bindingsByRootAndName = {}; // inside: Map< name, PropertyMixer >\n\n\t\t\tthis._controlInterpolants = []; // same game as above\n\n\t\t\tthis._nActiveControlInterpolants = 0;\n\t\t\tvar scope = this;\n\t\t\tthis.stats = {\n\t\t\t\tactions: {\n\t\t\t\t\tget total() {\n\t\t\t\t\t\treturn scope._actions.length;\n\t\t\t\t\t},\n\n\t\t\t\t\tget inUse() {\n\t\t\t\t\t\treturn scope._nActiveActions;\n\t\t\t\t\t}\n\n\t\t\t\t},\n\t\t\t\tbindings: {\n\t\t\t\t\tget total() {\n\t\t\t\t\t\treturn scope._bindings.length;\n\t\t\t\t\t},\n\n\t\t\t\t\tget inUse() {\n\t\t\t\t\t\treturn scope._nActiveBindings;\n\t\t\t\t\t}\n\n\t\t\t\t},\n\t\t\t\tcontrolInterpolants: {\n\t\t\t\t\tget total() {\n\t\t\t\t\t\treturn scope._controlInterpolants.length;\n\t\t\t\t\t},\n\n\t\t\t\t\tget inUse() {\n\t\t\t\t\t\treturn scope._nActiveControlInterpolants;\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t\t// Memory management for AnimationAction objects\n\t\t_isActiveAction: function _isActiveAction(action) {\n\t\t\tvar index = action._cacheIndex;\n\t\t\treturn index !== null && index < this._nActiveActions;\n\t\t},\n\t\t_addInactiveAction: function _addInactiveAction(action, clipUuid, rootUuid) {\n\t\t\tvar actions = this._actions,\n\t\t\t\t\tactionsByClip = this._actionsByClip;\n\t\t\tvar actionsForClip = actionsByClip[clipUuid];\n\n\t\t\tif (actionsForClip === undefined) {\n\t\t\t\tactionsForClip = {\n\t\t\t\t\tknownActions: [action],\n\t\t\t\t\tactionByRoot: {}\n\t\t\t\t};\n\t\t\t\taction._byClipCacheIndex = 0;\n\t\t\t\tactionsByClip[clipUuid] = actionsForClip;\n\t\t\t} else {\n\t\t\t\tvar knownActions = actionsForClip.knownActions;\n\t\t\t\taction._byClipCacheIndex = knownActions.length;\n\t\t\t\tknownActions.push(action);\n\t\t\t}\n\n\t\t\taction._cacheIndex = actions.length;\n\t\t\tactions.push(action);\n\t\t\tactionsForClip.actionByRoot[rootUuid] = action;\n\t\t},\n\t\t_removeInactiveAction: function _removeInactiveAction(action) {\n\t\t\tvar actions = this._actions,\n\t\t\t\t\tlastInactiveAction = actions[actions.length - 1],\n\t\t\t\t\tcacheIndex = action._cacheIndex;
1\n\t\t\tlastInactiveAction._cacheIndex = cacheIndex;\n\t\t\tactions[cacheIndex] = lastInactiveAction;\n\t\t\tactions.pop();\n\t\t\taction._cacheIndex = null;\n\t\t\tvar clipUuid = action._clip.uuid,\n\t\t\t\t\tactionsByClip = this._actionsByClip,\n\t\t\t\t\tactionsForClip = actionsByClip[clipUuid],\n\t\t\t\t\tknownActionsForClip = actionsForClip.knownActions,\n\t\t\t\t\tlastKnownAction = knownActionsForClip[knownActionsForClip.length - 1],\n\t\t\t\t\tbyClipCacheIndex = action._byClipCacheIndex;\n\t\t\tlastKnownAction._byClipCacheIndex = byClipCacheIndex;\n\t\t\tknownActionsForClip[byClipCacheIndex] = lastKnownAction;\n\t\t\tknownActionsForClip.pop();\n\t\t\taction._byClipCacheIndex = null;\n\t\t\tvar actionByRoot = actionsForClip.actionByRoot,\n\t\t\t\t\trootUuid = (action._localRoot || this._root).uuid;\n\t\t\tdelete actionByRoot[rootUuid];\n\n\t\t\tif (knownActionsForClip.length === 0) {\n\t\t\t\tdelete actionsByClip[clipUuid];\n\t\t\t}\n\n\t\t\tthis._removeInactiveBindingsForAction(action);\n\t\t},\n\t\t_removeInactiveBindingsForAction: function _removeInactiveBindingsForAction(action) {\n\t\t\tvar bindings = action._propertyBindings;\n\n\t\t\tfor (var i = 0, n = bindings.length; i !== n; ++i) {\n\t\t\t\tvar binding = bindings[i];\n\n\t\t\t\tif (--binding.referenceCount === 0) {\n\t\t\t\t\tthis._removeInactiveBinding(binding);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t_lendAction: function _lendAction(action) {\n\t\t\t// [ active actions |\tinactive actions\t]\n\t\t\t// [\tactive actions >| inactive actions ]\n\t\t\t//\t\t\t\t\t\t\t\t s\t\t\t\ta\n\t\t\t//\t\t\t\t\t\t\t\t\t<-swap->\n\t\t\t//\t\t\t\t\t\t\t\t a\t\t\t\ts\n\t\t\tvar actions = this._actions,\n\t\t\t\t\tprevIndex = action._cacheIndex,\n\t\t\t\t\tlastActiveIndex = this._nActiveActions++,\n\t\t\t\t\tfirstInactiveAction = actions[lastActiveIndex];\n\t\t\taction._cacheIndex = lastActiveIndex;\n\t\t\tactions[lastActiveIndex] = action;\n\t\t\tfirstInactiveAction._cacheIndex = prevIndex;\n\t\t\tactions[prevIndex] = firstInactiveAction;\n\t\t},\n\t\t_takeBackAction: function _takeBackAction(action) {\n\t\t\t// [\tactive actions\t| inactive actions ]\n\t\t\t// [ active actions |< inactive actions\t]\n\t\t\t//\t\t\t\ta\t\t\t\ts\n\t\t\t//\t\t\t\t <-swap->\n\t\t\t//\t\t\t\ts\t\t\t\ta\n\t\t\tvar actions = this._actions,\n\t\t\t\t\tprevIndex = action._cacheIndex,\n\t\t\t\t\tfirstInactiveIndex = --this._nActiveActions,\n\t\t\t\t\tlastActiveAction = actions[firstInactiveIndex];\n\t\t\taction._cacheIndex = firstInactiveIndex;\n\t\t\tactions[firstInactiveIndex] = action;\n\t\t\tlastActiveAction._cacheIndex = prevIndex;\n\t\t\tactions[prevIndex] = lastActiveAction;\n\t\t},\n\t\t// Memory management for PropertyMixer objects\n\t\t_addInactiveBinding: function _addInactiveBinding(binding, rootUuid, trackName) {\n\t\t\tvar bindingsByRoot = this._bindingsByRootAndName,\n\t\t\t\t\tbindings = this._bindings;\n\t\t\tvar bindingByName = bindingsByRoot[rootUuid];\n\n\t\t\tif (bindingByName === undefined) {\n\t\t\t\tbindingByName = {};\n\t\t\t\tbindingsByRoot[rootUuid] = bindingByName;\n\t\t\t}\n\n\t\t\tbindingByName[trackName] = binding;\n\t\t\tbinding._cacheIndex = bindings.length;\n\t\t\tbindings.push(binding);\n\t\t},\n\t\t_removeInactiveBinding: function _removeInactiveBinding(binding) {\n\t\t\tvar bindings = this._bindings,\n\t\t\t\t\tpropBinding = binding.binding,\n\t\t\t\t\trootUuid = propBinding.rootNode.uuid,\n\t\t\t\t\ttrackName = propBinding.path,\n\t\t\t\t\tbindingsByRoot = this._bindingsByRootAndName,\n\t\t\t\t\tbindingByName = bindingsByRoot[rootUuid],\n\t\t\t\t\tlastInactiveBinding = bindings[bindings.length - 1],\n\t\t\t\t\tcacheIndex = binding._cacheIndex;\n\t\t\tlastInactiveBinding._cacheIndex = cacheIndex;\n\t\t\tbindings[cacheIndex] = lastInactiveBinding;\n\t\t\tbindings.pop();\n\t\t\tdelete bindingByName[trackName];\n\n\t\t\tif (Object.keys(bindingByName).length === 0) {\n\t\t\t\tdelete bindingsByRoot[rootUuid];\n\t\t\t}\n\t\t},\n\t\t_lendBinding: function _lendBinding(binding) {\n\t\t\tvar bindings = this._bindings,\n\t\t\t\t\tprevIndex = binding._cacheIndex,\n\t\t\t\t\tlastActiveIndex = this._nActiveBindings++,\n\t\t\t\t\tfirstInactiveBinding = bindings[lastActiveIndex];\n\t\t\tbinding._cacheIndex = lastActiveIndex;\n\t\t\tbindings[lastActiveIndex] = binding;\n\t\t\tfirstInactiveBinding._cacheIndex = prevIndex;\n\t\t\tbindings[prevIndex] = firstInactiveBinding;\n\t\t},\n\t\t_takeBackBinding: function _takeBackBinding(binding) {\n\t\t\tvar bindings = this._bindings,\n\t\t\t\t\tprevIndex = binding._cacheIndex,\n\t\t\t\t\tfirstInactiveIndex = --this._nActiveBindings,\n\t\t\t\t\tlastActiveBinding = bindings[firstInactiveIndex];\n\t\t\tbinding._cacheIndex = firstInactiveIndex;\n\t\t\tbindings[firstInactiveIndex] = binding;\n\t\t\tlastActiveBinding._cacheIndex = prevIndex;\n\t\t\tbindings[prevIndex] = lastActiveBinding;\n\t\t},\n\t\t// Memory management of Interpolants for weight and time scale\n\t\t_lendControlInterpolant: function _lendControlInterpolant() {\n\t\t\tvar interpolants = this._controlInterpolants,\n\t\t\t\t\tlastActiveIndex = this._nActiveControlInterpolants++;\n\t\t\tvar interpolant = interpolants[lastActiveIndex];\n\n\t\t\tif (interpolant === undefined) {\n\t\t\t\tinterpolant = new LinearInterpolant(new Float32Array(2), new Float32Array(2), 1, this._controlInterpolantsResultBuffer);\n\t\t\t\tinterpolant.__cacheIndex = lastActiveIndex;\n\t\t\t\tinterpolants[lastActiveIndex] = interpolant;\n\t\t\t}\n\n\t\t\treturn interpolant;\n\t\t},\n\t\t_takeBackControlInterpolant: function _takeBackControlInterpolant(interpolant) {\n\t\t\tvar interpolants = this._controlInterpolants,\n\t\t\t\t\tprevIndex = interpolant.__cacheIndex,\n\t\t\t\t\tfirstInactiveIndex = --this._nActiveControlInterpolants,\n\t\t\t\t\tlastActiveInterpolant = interpolants[firstInactiveIndex];\n\t\t\tinterpolant.__cacheIndex = firstInactiveIndex;\n\t\t\tinterpolants[firstInactiveIndex] = interpolant;\n\t\t\tlastActiveInterpolant.__cacheIndex = prevIndex;\n\t\t\tinterpolants[prevIndex] = lastActiveInterpolant;\n\t\t},\n\t\t_controlInterpolantsResultBuffer: new Float32Array(1),\n\t\t// return an action for a clip optionally using a custom root target\n\t\t// object (this method allocates a lot of dynamic memory in case a\n\t\t// previously unknown clip/root combination is specified)\n\t\tclipAction: function clipAction(clip, optionalRoot, blendMode) {\n\t\t\tvar root = optionalRoot || this._root,\n\t\t\t\t\trootUuid = root.uuid;\n\t\t\tvar clipObject = typeof clip === 'string' ? AnimationClip.findByName(root, clip) : clip;\n\t\t\tvar clipUuid = clipObject !== null ? clipObject.uuid : clip;\n\t\t\tvar actionsForClip = this._actionsByClip[clipUuid];\n\t\t\tvar prototypeAction = null;\n\n\t\t\tif (blendMode === undefined) {\n\t\t\t\tif (clipObject !== null) {\n\t\t\t\t\tblendMode = clipObject.blendMode;\n\t\t\t\t} else {\n\t\t\t\t\tblendMode = NormalAnimationBlendMode;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (actionsForClip !== undefined) {\n\t\t\t\tvar existingAction = actionsForClip.actionByRoot[rootUuid];\n\n\t\t\t\tif (existingAction !== undefined && existingAction.blendMode === blendMode) {\n\t\t\t\t\treturn existingAction;\n\t\t\t\t} // we know the clip, so we don't have to parse all\n\t\t\t\t// the bindings again but can just copy\n\n\n\t\t\t\tprototypeAction = actionsForClip.knownActions[0]; // also, take the clip from the prototype action\n\n\t\t\t\tif (clipObject === null) clipObject = prototypeAction._clip;\n\t\t\t} // clip must be known when specified via string\n\n\n\t\t\tif (clipObject === null) return null; // allocate all resources required to run it\n\n\t\t\tvar newAction = new AnimationAction(this, clipObject, optionalRoot, blendMode);\n\n\t\t\tthis._bindAction(newAction, prototypeAction); // and make the action known to the memory manager\n\n\n\t\t\tthis._addInactiveAction(newAction, clipUuid, rootUuid);\n\n\t\t\treturn newAction;\n\t\t},\n\t\t// get an existing action\n\t\texistingAction: function existingAction(clip, optionalRoot) {\n\t\t\tvar root = optionalRoot || this._root,\n\t\t\t\t\trootUuid = root.uuid,\n\t\t\t\t\tclipObject = typeof clip === 'string' ? AnimationClip.findByName(root, clip) : clip,\n\t\t\t\t\tclipUuid = clipObject ? clipObject.uuid : clip,\n\t\t\t\t\tactionsForClip = this._actionsByClip[clipUuid];\n\n\t\t\tif (actionsForClip !== undefined) {\n\t\t\t\treturn actionsForClip.actionByRoot[rootUuid] || null;\n\t\t\t}\n\n\t\t\treturn null;\n\t\t}
1,\n\t\t// deactivates all previously scheduled actions\n\t\tstopAllAction: function stopAllAction() {\n\t\t\tvar actions = this._actions,\n\t\t\t\t\tnActions = this._nActiveActions;\n\n\t\t\tfor (var i = nActions - 1; i >= 0; --i) {\n\t\t\t\tactions[i].stop();\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\t// advance the time and update apply the animation\n\t\tupdate: function update(deltaTime) {\n\t\t\tdeltaTime *= this.timeScale;\n\t\t\tvar actions = this._actions,\n\t\t\t\t\tnActions = this._nActiveActions,\n\t\t\t\t\ttime = this.time += deltaTime,\n\t\t\t\t\ttimeDirection = Math.sign(deltaTime),\n\t\t\t\t\taccuIndex = this._accuIndex ^= 1; // run active actions\n\n\t\t\tfor (var i = 0; i !== nActions; ++i) {\n\t\t\t\tvar action = actions[i];\n\n\t\t\t\taction._update(time, deltaTime, timeDirection, accuIndex);\n\t\t\t} // update scene graph\n\n\n\t\t\tvar bindings = this._bindings,\n\t\t\t\t\tnBindings = this._nActiveBindings;\n\n\t\t\tfor (var _i = 0; _i !== nBindings; ++_i) {\n\t\t\t\tbindings[_i].apply(accuIndex);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t},\n\t\t// Allows you to seek to a specific time in an animation.\n\t\tsetTime: function setTime(timeInSeconds) {\n\t\t\tthis.time = 0; // Zero out time attribute for AnimationMixer object;\n\n\t\t\tfor (var i = 0; i < this._actions.length; i++) {\n\t\t\t\tthis._actions[i].time = 0; // Zero out time attribute for all associated AnimationAction objects.\n\t\t\t}\n\n\t\t\treturn this.update(timeInSeconds); // Update used to set exact time. Returns \"this\" AnimationMixer object.\n\t\t},\n\t\t// return this mixer's root target object\n\t\tgetRoot: function getRoot() {\n\t\t\treturn this._root;\n\t\t},\n\t\t// free all resources specific to a particular clip\n\t\tuncacheClip: function uncacheClip(clip) {\n\t\t\tvar actions = this._actions,\n\t\t\t\t\tclipUuid = clip.uuid,\n\t\t\t\t\tactionsByClip = this._actionsByClip,\n\t\t\t\t\tactionsForClip = actionsByClip[clipUuid];\n\n\t\t\tif (actionsForClip !== undefined) {\n\t\t\t\t// note: just calling _removeInactiveAction would mess up the\n\t\t\t\t// iteration state and also require updating the state we can\n\t\t\t\t// just throw away\n\t\t\t\tvar actionsToRemove = actionsForClip.knownActions;\n\n\t\t\t\tfor (var i = 0, n = actionsToRemove.length; i !== n; ++i) {\n\t\t\t\t\tvar action = actionsToRemove[i];\n\n\t\t\t\t\tthis._deactivateAction(action);\n\n\t\t\t\t\tvar cacheIndex = action._cacheIndex,\n\t\t\t\t\t\t\tlastInactiveAction = actions[actions.length - 1];\n\t\t\t\t\taction._cacheIndex = null;\n\t\t\t\t\taction._byClipCacheIndex = null;\n\t\t\t\t\tlastInactiveAction._cacheIndex = cacheIndex;\n\t\t\t\t\tactions[cacheIndex] = lastInactiveAction;\n\t\t\t\t\tactions.pop();\n\n\t\t\t\t\tthis._removeInactiveBindingsForAction(action);\n\t\t\t\t}\n\n\t\t\t\tdelete actionsByClip[clipUuid];\n\t\t\t}\n\t\t},\n\t\t// free all resources specific to a particular root target object\n\t\tuncacheRoot: function uncacheRoot(root) {\n\t\t\tvar rootUuid = root.uuid,\n\t\t\t\t\tactionsByClip = this._actionsByClip;\n\n\t\t\tfor (var clipUuid in actionsByClip) {\n\t\t\t\tvar actionByRoot = actionsByClip[clipUuid].actionByRoot,\n\t\t\t\t\t\taction = actionByRoot[rootUuid];\n\n\t\t\t\tif (action !== undefined) {\n\t\t\t\t\tthis._deactivateAction(action);\n\n\t\t\t\t\tthis._removeInactiveAction(action);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar bindingsByRoot = this._bindingsByRootAndName,\n\t\t\t\t\tbindingByName = bindingsByRoot[rootUuid];\n\n\t\t\tif (bindingByName !== undefined) {\n\t\t\t\tfor (var trackName in bindingByName) {\n\t\t\t\t\tvar binding = bindingByName[trackName];\n\t\t\t\t\tbinding.restoreOriginalState();\n\n\t\t\t\t\tthis._removeInactiveBinding(binding);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t// remove a targeted clip from the cache\n\t\tuncacheAction: function uncacheAction(clip, optionalRoot) {\n\t\t\tvar action = this.existingAction(clip, optionalRoot);\n\n\t\t\tif (action !== null) {\n\t\t\t\tthis._deactivateAction(action);\n\n\t\t\t\tthis._removeInactiveAction(action);\n\t\t\t}\n\t\t}\n\t});\n\n\tvar Uniform = /*#__PURE__*/function () {\n\t\tfunction Uniform(value) {\n\t\t\tif (typeof value === 'string') {\n\t\t\t\tconsole.warn('THREE.Uniform: Type parameter is no longer needed.');\n\t\t\t\tvalue = arguments[1];\n\t\t\t}\n\n\t\t\tthis.value = value;\n\t\t}\n\n\t\tvar _proto = Uniform.prototype;\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new Uniform(this.value.clone === undefined ? this.value : this.value.clone());\n\t\t};\n\n\t\treturn Uniform;\n\t}();\n\n\tfunction InstancedInterleavedBuffer(array, stride, meshPerAttribute) {\n\t\tInterleavedBuffer.call(this, array, stride);\n\t\tthis.meshPerAttribute = meshPerAttribute || 1;\n\t}\n\n\tInstancedInterleavedBuffer.prototype = Object.assign(Object.create(InterleavedBuffer.prototype), {\n\t\tconstructor: InstancedInterleavedBuffer,\n\t\tisInstancedInterleavedBuffer: true,\n\t\tcopy: function copy(source) {\n\t\t\tInterleavedBuffer.prototype.copy.call(this, source);\n\t\t\tthis.meshPerAttribute = source.meshPerAttribute;\n\t\t\treturn this;\n\t\t}
1,\n\t\tclone: function clone(data) {\n\t\t\tvar ib = InterleavedBuffer.prototype.clone.call(this, data);\n\t\t\tib.meshPerAttribute = this.meshPerAttribute;\n\t\t\treturn ib;\n\t\t},\n\t\ttoJSON: function toJSON(data) {\n\t\t\tvar json = InterleavedBuffer.prototype.toJSON.call(this, data);\n\t\t\tjson.isInstancedInterleavedBuffer = true;\n\t\t\tjson.meshPerAttribute = this.meshPerAttribute;\n\t\t\treturn json;\n\t\t}\n\t});\n\n\tfunction GLBufferAttribute(buffer, type, itemSize, elementSize, count) {\n\t\tthis.buffer = buffer;\n\t\tthis.type = type;\n\t\tthis.itemSize = itemSize;\n\t\tthis.elementSize = elementSize;\n\t\tthis.count = count;\n\t\tthis.version = 0;\n\t}\n\n\tObject.defineProperty(GLBufferAttribute.prototype, 'needsUpdate', {\n\t\tset: function set(value) {\n\t\t\tif (value === true) this.version++;\n\t\t}\n\t});\n\tObject.assign(GLBufferAttribute.prototype, {\n\t\tisGLBufferAttribute: true,\n\t\tsetBuffer: function setBuffer(buffer) {\n\t\t\tthis.buffer = buffer;\n\t\t\treturn this;\n\t\t},\n\t\tsetType: function setType(type, elementSize) {\n\t\t\tthis.type = type;\n\t\t\tthis.elementSize = elementSize;\n\t\t\treturn this;\n\t\t},\n\t\tsetItemSize: function setItemSize(itemSize) {\n\t\t\tthis.itemSize = itemSize;\n\t\t\treturn this;\n\t\t},\n\t\tsetCount: function setCount(count) {\n\t\t\tthis.count = count;\n\t\t\treturn this;\n\t\t}\n\t});\n\n\tfunction Raycaster(origin, direction, near, far) {\n\t\tthis.ray = new Ray(origin, direction); // direction is assumed to be normalized (for accurate distance calculations)\n\n\t\tthis.near = near || 0;\n\t\tthis.far = far || Infinity;\n\t\tthis.camera = null;\n\t\tthis.layers = new Layers();\n\t\tthis.params = {\n\t\t\tMesh: {},\n\t\t\tLine: {\n\t\t\t\tthreshold: 1\n\t\t\t},\n\t\t\tLOD: {},\n\t\t\tPoints: {\n\t\t\t\tthreshold: 1\n\t\t\t},\n\t\t\tSprite: {}\n\t\t};\n\t\tObject.defineProperties(this.params, {\n\t\t\tPointCloud: {\n\t\t\t\tget: function get() {\n\t\t\t\t\tconsole.warn('THREE.Raycaster: params.PointCloud has been renamed to params.Points.');\n\t\t\t\t\treturn this.Points;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tfunction ascSort(a, b) {\n\t\treturn a.distance - b.distance;\n\t}\n\n\tfunction _intersectObject(object, raycaster, intersects, recursive) {\n\t\tif (object.layers.test(raycaster.layers)) {\n\t\t\tobject.raycast(raycaster, intersects);\n\t\t}\n\n\t\tif (recursive === true) {\n\t\t\tvar children = object.children;\n\n\t\t\tfor (var i = 0, l = children.length; i < l; i++) {\n\t\t\t\t_intersectObject(children[i], raycaster, intersects, true);\n\t\t\t}\n\t\t}\n\t}\n\n\tObject.assign(Raycaster.prototype, {\n\t\tset: function set(origin, direction) {\n\t\t\t// direction is assumed to be normalized (for accurate distance calculations)\n\t\t\tthis.ray.set(origin, direction);\n\t\t},\n\t\tsetFromCamera: function setFromCamera(coords, camera) {\n\t\t\tif (camera && camera.isPerspectiveCamera) {\n\t\t\t\tthis.ray.origin.setFromMatrixPosition(camera.matrixWorld);\n\t\t\t\tthis.ray.direction.set(coords.x, coords.y, 0.5).unproject(camera).sub(this.ray.origin).normalize();\n\t\t\t\tthis.camera = camera;\n\t\t\t} else if (camera && camera.isOrthographicCamera) {\n\t\t\t\tthis.ray.origin.set(coords.x, coords.y, (camera.near + camera.far) / (camera.near - camera.far)).unproject(camera); // set origin in plane of camera\n\n\t\t\t\tthis.ray.direction.set(0, 0, -1).transformDirection(camera.matrixWorld);\n\t\t\t\tthis.camera = camera;\n\t\t\t} else {\n\t\t\t\tconsole.error('THREE.Raycaster: Unsupported camera type: ' + camera.type);\n\t\t\t}\n\t\t},\n\t\tintersectObject: function intersectObject(object, recursive, optionalTarget) {\n\t\t\tvar intersects = optionalTarget || [];\n\n\t\t\t_intersectObject(object, this, intersects, recursive);\n\n\t\t\tintersects.sort(ascSort);\n\t\t\treturn intersects;\n\t\t},\n\t\tintersectObjects: function intersectObjects(objects, recursive, optionalTarget) {\n\t\t\tvar intersects = optionalTarget || [];\n\n\t\t\tif (Array.isArray(objects) === false) {\n\t\t\t\tconsole.warn('THREE.Raycaster.intersectObjects: objects is not an Array.');\n\t\t\t\treturn intersects;\n\t\t\t}\n\n\t\t\tfor (var i = 0, l = objects.length; i < l;
1 i++) {\n\t\t\t\t_intersectObject(objects[i], this, intersects, recursive);\n\t\t\t}\n\n\t\t\tintersects.sort(ascSort);\n\t\t\treturn intersects;\n\t\t}\n\t});\n\n\t/**\n\t * Ref: https://en.wikipedia.org/wiki/Spherical_coordinate_system\n\t *\n\t * The polar angle (phi) is measured from the positive y-axis. The positive y-axis is up.\n\t * The azimuthal angle (theta) is measured from the positive z-axis.\n\t */\n\n\tvar Spherical = /*#__PURE__*/function () {\n\t\tfunction Spherical(radius, phi, theta) {\n\t\t\tif (radius === void 0) {\n\t\t\t\tradius = 1;\n\t\t\t}\n\n\t\t\tif (phi === void 0) {\n\t\t\t\tphi = 0;\n\t\t\t}\n\n\t\t\tif (theta === void 0) {\n\t\t\t\ttheta = 0;\n\t\t\t}\n\n\t\t\tthis.radius = radius;\n\t\t\tthis.phi = phi; // polar angle\n\n\t\t\tthis.theta = theta; // azimuthal angle\n\n\t\t\treturn this;\n\t\t}\n\n\t\tvar _proto = Spherical.prototype;\n\n\t\t_proto.set = function set(radius, phi, theta) {\n\t\t\tthis.radius = radius;\n\t\t\tthis.phi = phi;\n\t\t\tthis.theta = theta;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t};\n\n\t\t_proto.copy = function copy(other) {\n\t\t\tthis.radius = other.radius;\n\t\t\tthis.phi = other.phi;\n\t\t\tthis.theta = other.theta;\n\t\t\treturn this;\n\t\t} // restrict phi to be betwee EPS and PI-EPS\n\t\t;\n\n\t\t_proto.makeSafe = function makeSafe() {\n\t\t\tvar EPS = 0.000001;\n\t\t\tthis.phi = Math.max(EPS, Math.min(Math.PI - EPS, this.phi));\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromVector3 = function setFromVector3(v) {\n\t\t\treturn this.setFromCartesianCoords(v.x, v.y, v.z);\n\t\t};\n\n\t\t_proto.setFromCartesianCoords = function setFromCartesianCoords(x, y, z) {\n\t\t\tthis.radius = Math.sqrt(x * x + y * y + z * z);\n\n\t\t\tif (this.radius === 0) {\n\t\t\t\tthis.theta = 0;\n\t\t\t\tthis.phi = 0;\n\t\t\t} else {\n\t\t\t\tthis.theta = Math.atan2(x, z);\n\t\t\t\tthis.phi = Math.acos(MathUtils.clamp(y / this.radius, -1, 1));\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\treturn Spherical;\n\t}();\n\n\t/**\n\t * Ref: https://en.wikipedia.org/wiki/Cylindrical_coordinate_system\n\t */\n\tvar Cylindrical = /*#__PURE__*/function () {\n\t\tfunction Cylindrical(radius, theta, y) {\n\t\t\tthis.radius = radius !== undefined ? radius : 1.0; // distance from the origin to a point in the x-z plane\n\n\t\t\tthis.theta = theta !== undefined ? theta : 0; // counterclockwise angle in the x-z plane measured in radians from the positive z-axis\n\n\t\t\tthis.y = y !== undefined ? y : 0; // height above the x-z plane\n\n\t\t\treturn this;\n\t\t}\n\n\t\tvar _proto = Cylindrical.prototype;\n\n\t\t_proto.set = function set(radius, theta, y) {\n\t\t\tthis.radius = radius;\n\t\t\tthis.theta = theta;\n\t\t\tthis.y = y;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t};\n\n\t\t_proto.copy = function copy(other) {\n\t\t\tthis.radius = other.radius;\n\t\t\tthis.theta = other.theta;\n\t\t\tthis.y = other.y;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromVector3 = function setFromVector3(v) {\n\t\t\treturn this.setFromCartesianCoords(v.x, v.y, v.z);\n\t\t};\n\n\t\t_proto.setFromCartesianCoords = function setFromCartesianCoords(x, y, z) {\n\t\t\tthis.radius = Math.sqrt(x * x + z * z);\n\t\t\tthis.theta = Math.atan2(x, z);\n\t\t\tthis.y = y;\n\t\t\treturn this;\n\t\t};\n\n\t\treturn Cylindrical;\n\t}();\n\n\tvar _vector$8 = /*@__PURE__*/new Vector2();\n\n\tvar Box2 = /*#__PURE__*/function () {\n\t\tfunction Box2(min, max) {\n\t\t\tObject.defineProperty(this, 'isBox2', {\n\t\t\t\tvalue: true\n\t\t\t});\n\t\t\tthis.min = min !== undefined ? min : new Vector2(+Infinity, +Infinity);\n\t\t\tthis.max = max !== undefined ? max : new Vector2(-Infinity, -Infinity);\n\t\t}\n\n\t\tvar _proto = Box2.prototype;\n\n\t\t_proto.set = function set(min, max) {\n\t\t\tthis.min.copy(min);\n\t\t\tthis.max.copy(max);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromPoints = function setFromPoints(points) {\n\t\t\tthis.makeEmpty();\n\n\t\t\tfor (var i = 0, il = points.length; i < il;
1 i++) {\n\t\t\t\tthis.expandByPoint(points[i]);\n\t\t\t}\n\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.setFromCenterAndSize = function setFromCenterAndSize(center, size) {\n\t\t\tvar halfSize = _vector$8.copy(size).multiplyScalar(0.5);\n\n\t\t\tthis.min.copy(center).sub(halfSize);\n\t\t\tthis.max.copy(center).add(halfSize);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t};\n\n\t\t_proto.copy = function copy(box) {\n\t\t\tthis.min.copy(box.min);\n\t\t\tthis.max.copy(box.max);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.makeEmpty = function makeEmpty() {\n\t\t\tthis.min.x = this.min.y = +Infinity;\n\t\t\tthis.max.x = this.max.y = -Infinity;\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.isEmpty = function isEmpty() {\n\t\t\t// this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes\n\t\t\treturn this.max.x < this.min.x || this.max.y < this.min.y;\n\t\t};\n\n\t\t_proto.getCenter = function getCenter(target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Box2: .getCenter() target is now required');\n\t\t\t\ttarget = new Vector2();\n\t\t\t}\n\n\t\t\treturn this.isEmpty() ? target.set(0, 0) : target.addVectors(this.min, this.max).multiplyScalar(0.5);\n\t\t};\n\n\t\t_proto.getSize = function getSize(target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Box2: .getSize() target is now required');\n\t\t\t\ttarget = new Vector2();\n\t\t\t}\n\n\t\t\treturn this.isEmpty() ? target.set(0, 0) : target.subVectors(this.max, this.min);\n\t\t};\n\n\t\t_proto.expandByPoint = function expandByPoint(point) {\n\t\t\tthis.min.min(point);\n\t\t\tthis.max.max(point);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.expandByVector = function expandByVector(vector) {\n\t\t\tthis.min.sub(vector);\n\t\t\tthis.max.add(vector);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.expandByScalar = function expandByScalar(scalar) {\n\t\t\tthis.min.addScalar(-scalar);\n\t\t\tthis.max.addScalar(scalar);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.containsPoint = function containsPoint(point) {\n\t\t\treturn point.x < this.min.x || point.x > this.max.x || point.y < this.min.y || point.y > this.max.y ? false : true;\n\t\t};\n\n\t\t_proto.containsBox = function containsBox(box) {\n\t\t\treturn this.min.x <= box.min.x && box.max.x <= this.max.x && this.min.y <= box.min.y && box.max.y <= this.max.y;\n\t\t};\n\n\t\t_proto.getParameter = function getParameter(point, target) {\n\t\t\t// This can potentially have a divide by zero if the box\n\t\t\t// has a size dimension of 0.\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Box2: .getParameter() target is now required');\n\t\t\t\ttarget = new Vector2();\n\t\t\t}\n\n\t\t\treturn target.set((point.x - this.min.x) / (this.max.x - this.min.x), (point.y - this.min.y) / (this.max.y - this.min.y));\n\t\t};\n\n\t\t_proto.intersectsBox = function intersectsBox(box) {\n\t\t\t// using 4 splitting planes to rule out intersections\n\t\t\treturn box.max.x < this.min.x || box.min.x > this.max.x || box.max.y < this.min.y || box.min.y > this.max.y ? false : true;\n\t\t};\n\n\t\t_proto.clampPoint = function clampPoint(point, target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Box2: .clampPoint() target is now required');\n\t\t\t\ttarget = new Vector2();\n\t\t\t}\n\n\t\t\treturn target.copy(point).clamp(this.min, this.max);\n\t\t};\n\n\t\t_proto.distanceToPoint = function distanceToPoint(point) {\n\t\t\tvar clampedPoint = _vector$8.copy(point).clamp(this.min, this.max);\n\n\t\t\treturn clampedPoint.sub(point).length();\n\t\t};\n\n\t\t_proto.intersect = function intersect(box) {\n\t\t\tthis.min.max(box.min);\n\t\t\tthis.max.min(box.max);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.union = function union(box) {\n\t\t\tthis.min.min(box.min);\n\t\t\tthis.max.max(box.max);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.translate = function translate(offset) {\n\t\t\tthis.min.add(offset);\n\t\t\tthis.max.add(offset);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.equals = function equals(box) {\n\t\t\treturn box.min.equals(this.min) && box.max.equals(this.max);\n\t\t};\n\n\t\treturn Box2;\n\t}();\n\n\tvar _startP = /*@__PURE__*/new Vector3();\n\n\tvar _startEnd = /*@__PURE__*/new Vector3();\n\n\tvar Line3 = /*#__PURE__*/function () {\n\t\tfunction Line3(start, end) {\n\t\t\tthis.start = start !== undefined ? start : new Vector3();\n\t\t\tthis.end = end !== undefined ? end : new Vector3();\n\t\t}\n\n\t\tvar _proto = Line3.prototype;\n\n\t\t_proto.set = function set(start, end) {\n\t\t\tthis.start.copy(start);
1\n\t\t\tthis.end.copy(end);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.clone = function clone() {\n\t\t\treturn new this.constructor().copy(this);\n\t\t};\n\n\t\t_proto.copy = function copy(line) {\n\t\t\tthis.start.copy(line.start);\n\t\t\tthis.end.copy(line.end);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.getCenter = function getCenter(target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Line3: .getCenter() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\treturn target.addVectors(this.start, this.end).multiplyScalar(0.5);\n\t\t};\n\n\t\t_proto.delta = function delta(target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Line3: .delta() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\treturn target.subVectors(this.end, this.start);\n\t\t};\n\n\t\t_proto.distanceSq = function distanceSq() {\n\t\t\treturn this.start.distanceToSquared(this.end);\n\t\t};\n\n\t\t_proto.distance = function distance() {\n\t\t\treturn this.start.distanceTo(this.end);\n\t\t};\n\n\t\t_proto.at = function at(t, target) {\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Line3: .at() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\treturn this.delta(target).multiplyScalar(t).add(this.start);\n\t\t};\n\n\t\t_proto.closestPointToPointParameter = function closestPointToPointParameter(point, clampToLine) {\n\t\t\t_startP.subVectors(point, this.start);\n\n\t\t\t_startEnd.subVectors(this.end, this.start);\n\n\t\t\tvar startEnd2 = _startEnd.dot(_startEnd);\n\n\t\t\tvar startEnd_startP = _startEnd.dot(_startP);\n\n\t\t\tvar t = startEnd_startP / startEnd2;\n\n\t\t\tif (clampToLine) {\n\t\t\t\tt = MathUtils.clamp(t, 0, 1);\n\t\t\t}\n\n\t\t\treturn t;\n\t\t};\n\n\t\t_proto.closestPointToPoint = function closestPointToPoint(point, clampToLine, target) {\n\t\t\tvar t = this.closestPointToPointParameter(point, clampToLine);\n\n\t\t\tif (target === undefined) {\n\t\t\t\tconsole.warn('THREE.Line3: .closestPointToPoint() target is now required');\n\t\t\t\ttarget = new Vector3();\n\t\t\t}\n\n\t\t\treturn this.delta(target).multiplyScalar(t).add(this.start);\n\t\t};\n\n\t\t_proto.applyMatrix4 = function applyMatrix4(matrix) {\n\t\t\tthis.start.applyMatrix4(matrix);\n\t\t\tthis.end.applyMatrix4(matrix);\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.equals = function equals(line) {\n\t\t\treturn line.start.equals(this.start) && line.end.equals(this.end);\n\t\t};\n\n\t\treturn Line3;\n\t}();\n\n\tfunction ImmediateRenderObject(material) {\n\t\tObject3D.call(this);\n\t\tthis.material = material;\n\n\t\tthis.render = function ()\n\t\t/* renderCallback */\n\t\t{};\n\n\t\tthis.hasPositions = false;\n\t\tthis.hasNormals = false;\n\t\tthis.hasColors = false;\n\t\tthis.hasUvs = false;\n\t\tthis.positionArray = null;\n\t\tthis.normalArray = null;\n\t\tthis.colorArray = null;\n\t\tthis.uvArray = null;\n\t\tthis.count = 0;\n\t}\n\n\tImmediateRenderObject.prototype = Object.create(Object3D.prototype);\n\tImmediateRenderObject.prototype.constructor = ImmediateRenderObject;\n\tImmediateRenderObject.prototype.isImmediateRenderObject = true;\n\n\tvar _vector$9 = /*@__PURE__*/new Vector3();\n\n\tvar SpotLightHelper = /*#__PURE__*/function (_Object3D) {\n\t\t_inheritsLoose(SpotLightHelper, _Object3D);\n\n\t\tfunction SpotLightHelper(light, color) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Object3D.call(this) || this;\n\t\t\t_this.light = light;\n\n\t\t\t_this.light.updateMatrixWorld();\n\n\t\t\t_this.matrix = light.matrixWorld;\n\t\t\t_this.matrixAutoUpdate = false;\n\t\t\t_this.color = color;\n\t\t\tvar geometry = new BufferGeometry();\n\t\t\tvar positions = [0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, -1, 1];\n\n\t\t\tfor (var i = 0, j = 1, l = 32; i < l; i++, j++) {\n\t\t\t\tvar p1 = i / l * Math.PI * 2;\n\t\t\t\tvar p2 = j / l * Math.PI * 2;\n\t\t\t\tpositions.push(Math.cos(p1), Math.sin(p1), 1, Math.cos(p2), Math.sin(p2), 1);\n\t\t\t}\n\n\t\t\tgeometry.setAttribute('position', new Float32BufferAttribute(positions, 3));\n\t\t\tvar material = new LineBasicMaterial({\n\t\t\t\tfog: false,\n\t\t\t\ttoneMapped: false\n\t\t\t});\n\t\t\t_this.cone = new LineSegments(geometry, material);\n\n\t\t\t_this.add(_this.cone);\n\n\t\t\t_this.update();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = SpotLightHelper.prototype;\n\n\t\t_proto.dispose = function dispose() {\n\t\t\tthis.cone.geometry.dispose();\n\t\t\tthis.cone.material.dispose();\n\t\t};
1\n\n\t\t_proto.update = function update() {\n\t\t\tthis.light.updateMatrixWorld();\n\t\t\tvar coneLength = this.light.distance ? this.light.distance : 1000;\n\t\t\tvar coneWidth = coneLength * Math.tan(this.light.angle);\n\t\t\tthis.cone.scale.set(coneWidth, coneWidth, coneLength);\n\n\t\t\t_vector$9.setFromMatrixPosition(this.light.target.matrixWorld);\n\n\t\t\tthis.cone.lookAt(_vector$9);\n\n\t\t\tif (this.color !== undefined) {\n\t\t\t\tthis.cone.material.color.set(this.color);\n\t\t\t} else {\n\t\t\t\tthis.cone.material.color.copy(this.light.color);\n\t\t\t}\n\t\t};\n\n\t\treturn SpotLightHelper;\n\t}(Object3D);\n\n\tvar _vector$a = /*@__PURE__*/new Vector3();\n\n\tvar _boneMatrix = /*@__PURE__*/new Matrix4();\n\n\tvar _matrixWorldInv = /*@__PURE__*/new Matrix4();\n\n\tvar SkeletonHelper = /*#__PURE__*/function (_LineSegments) {\n\t\t_inheritsLoose(SkeletonHelper, _LineSegments);\n\n\t\tfunction SkeletonHelper(object) {\n\t\t\tvar _this;\n\n\t\t\tvar bones = getBoneList(object);\n\t\t\tvar geometry = new BufferGeometry();\n\t\t\tvar vertices = [];\n\t\t\tvar colors = [];\n\t\t\tvar color1 = new Color(0, 0, 1);\n\t\t\tvar color2 = new Color(0, 1, 0);\n\n\t\t\tfor (var i = 0; i < bones.length; i++) {\n\t\t\t\tvar bone = bones[i];\n\n\t\t\t\tif (bone.parent && bone.parent.isBone) {\n\t\t\t\t\tvertices.push(0, 0, 0);\n\t\t\t\t\tvertices.push(0, 0, 0);\n\t\t\t\t\tcolors.push(color1.r, color1.g, color1.b);\n\t\t\t\t\tcolors.push(color2.r, color2.g, color2.b);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tgeometry.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\t\tgeometry.setAttribute('color', new Float32BufferAttribute(colors, 3));\n\t\t\tvar material = new LineBasicMaterial({\n\t\t\t\tvertexColors: true,\n\t\t\t\tdepthTest: false,\n\t\t\t\tdepthWrite: false,\n\t\t\t\ttoneMapped: false,\n\t\t\t\ttransparent: true\n\t\t\t});\n\t\t\t_this = _LineSegments.call(this, geometry, material) || this;\n\t\t\t_this.type = 'SkeletonHelper';\n\t\t\t_this.isSkeletonHelper = true;\n\t\t\t_this.root = object;\n\t\t\t_this.bones = bones;\n\t\t\t_this.matrix = object.matrixWorld;\n\t\t\t_this.matrixAutoUpdate = false;\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = SkeletonHelper.prototype;\n\n\t\t_proto.updateMatrixWorld = function updateMatrixWorld(force) {\n\t\t\tvar bones = this.bones;\n\t\t\tvar geometry = this.geometry;\n\t\t\tvar position = geometry.getAttribute('position');\n\n\t\t\t_matrixWorldInv.copy(this.root.matrixWorld).invert();\n\n\t\t\tfor (var i = 0, j = 0; i < bones.length; i++) {\n\t\t\t\tvar bone = bones[i];\n\n\t\t\t\tif (bone.parent && bone.parent.isBone) {\n\t\t\t\t\t_boneMatrix.multiplyMatrices(_matrixWorldInv, bone.matrixWorld);\n\n\t\t\t\t\t_vector$a.setFromMatrixPosition(_boneMatrix);\n\n\t\t\t\t\tposition.setXYZ(j, _vector$a.x, _vector$a.y, _vector$a.z);\n\n\t\t\t\t\t_boneMatrix.multiplyMatrices(_matrixWorldInv, bone.parent.matrixWorld);\n\n\t\t\t\t\t_vector$a.setFromMatrixPosition(_boneMatrix);\n\n\t\t\t\t\tposition.setXYZ(j + 1, _vector$a.x, _vector$a.y, _vector$a.z);\n\t\t\t\t\tj += 2;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tgeometry.getAttribute('position').needsUpdate = true;\n\n\t\t\t_LineSegments.prototype.updateMatrixWorld.call(this, force);\n\t\t};\n\n\t\treturn SkeletonHelper;\n\t}(LineSegments);\n\n\tfunction getBoneList(object) {\n\t\tvar boneList = [];\n\n\t\tif (object && object.isBone) {\n\t\t\tboneList.push(object);\n\t\t}\n\n\t\tfor (var i = 0; i < object.children.length; i++) {\n\t\t\tboneList.push.apply(boneList, getBoneList(object.children[i]));\n\t\t}\n\n\t\treturn boneList;\n\t}\n\n\tvar PointLightHelper = /*#__PURE__*/function (_Mesh) {\n\t\t_inheritsLoose(PointLightHelper, _Mesh);\n\n\t\tfunction PointLightHelper(light, sphereSize, color) {\n\t\t\tvar _this;\n\n\t\t\tvar geometry = new SphereBufferGeometry(sphereSize, 4, 2);\n\t\t\tvar material = new MeshBasicMaterial({\n\t\t\t\twireframe: true,\n\t\t\t\tfog: false,\n\t\t\t\ttoneMapped: false\n\t\t\t});\n\t\t\t_this = _Mesh.call(this, geometry, material) || this;\n\t\t\t_this.light = light;\n\n\t\t\t_this.light.updateMatrixWorld();\n\n\t\t\t_this.color = color;\n\t\t\t_this.type = 'PointLightHelper';\n\t\t\t_this.matrix = _this.light.matrixWorld;\n\t\t\t_this.matrixAutoUpdate = false;\n\n\t\t\t_this.update();\n\t\t\t/*\n\t\t\t// TODO: delete this comment?\n\t\t\tconst distanceGeometry = new THREE.IcosahedronBufferGeometry( 1, 2 );\n\t\t\tconst distanceMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false, wireframe: true, op
1acity: 0.1, transparent: true } );\n\t\t\tthis.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial );\n\t\t\tthis.lightDistance = new THREE.Mesh( distanceGeometry, distanceMaterial );\n\t\t\tconst d = light.distance;\n\t\t\tif ( d === 0.0 ) {\n\t\t\t\tthis.lightDistance.visible = false;\n\t\t\t} else {\n\t\t\t\tthis.lightDistance.scale.set( d, d, d );\n\t\t\t}\n\t\t\tthis.add( this.lightDistance );\n\t\t\t*/\n\n\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = PointLightHelper.prototype;\n\n\t\t_proto.dispose = function dispose() {\n\t\t\tthis.geometry.dispose();\n\t\t\tthis.material.dispose();\n\t\t};\n\n\t\t_proto.update = function update() {\n\t\t\tif (this.color !== undefined) {\n\t\t\t\tthis.material.color.set(this.color);\n\t\t\t} else {\n\t\t\t\tthis.material.color.copy(this.light.color);\n\t\t\t}\n\t\t\t/*\n\t\t\tconst d = this.light.distance;\n\t\t\t\tif ( d === 0.0 ) {\n\t\t\t\t\tthis.lightDistance.visible = false;\n\t\t\t\t} else {\n\t\t\t\t\tthis.lightDistance.visible = true;\n\t\t\t\tthis.lightDistance.scale.set( d, d, d );\n\t\t\t\t}\n\t\t\t*/\n\n\t\t};\n\n\t\treturn PointLightHelper;\n\t}(Mesh);\n\n\tvar _vector$b = /*@__PURE__*/new Vector3();\n\n\tvar _color1 = /*@__PURE__*/new Color();\n\n\tvar _color2 = /*@__PURE__*/new Color();\n\n\tvar HemisphereLightHelper = /*#__PURE__*/function (_Object3D) {\n\t\t_inheritsLoose(HemisphereLightHelper, _Object3D);\n\n\t\tfunction HemisphereLightHelper(light, size, color) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Object3D.call(this) || this;\n\t\t\t_this.light = light;\n\n\t\t\t_this.light.updateMatrixWorld();\n\n\t\t\t_this.matrix = light.matrixWorld;\n\t\t\t_this.matrixAutoUpdate = false;\n\t\t\t_this.color = color;\n\t\t\tvar geometry = new OctahedronBufferGeometry(size);\n\t\t\tgeometry.rotateY(Math.PI * 0.5);\n\t\t\t_this.material = new MeshBasicMaterial({\n\t\t\t\twireframe: true,\n\t\t\t\tfog: false,\n\t\t\t\ttoneMapped: false\n\t\t\t});\n\t\t\tif (_this.color === undefined) _this.material.vertexColors = true;\n\t\t\tvar position = geometry.getAttribute('position');\n\t\t\tvar colors = new Float32Array(position.count * 3);\n\t\t\tgeometry.setAttribute('color', new BufferAttribute(colors, 3));\n\n\t\t\t_this.add(new Mesh(geometry, _this.material));\n\n\t\t\t_this.update();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = HemisphereLightHelper.prototype;\n\n\t\t_proto.dispose = function dispose() {\n\t\t\tthis.children[0].geometry.dispose();\n\t\t\tthis.children[0].material.dispose();\n\t\t};\n\n\t\t_proto.update = function update() {\n\t\t\tvar mesh = this.children[0];\n\n\t\t\tif (this.color !== undefined) {\n\t\t\t\tthis.material.color.set(this.color);\n\t\t\t} else {\n\t\t\t\tvar colors = mesh.geometry.getAttribute('color');\n\n\t\t\t\t_color1.copy(this.light.color);\n\n\t\t\t\t_color2.copy(this.light.groundColor);\n\n\t\t\t\tfor (var i = 0, l = colors.count; i < l; i++) {\n\t\t\t\t\tvar color = i < l / 2 ? _color1 : _color2;\n\t\t\t\t\tcolors.setXYZ(i, color.r, color.g, color.b);\n\t\t\t\t}\n\n\t\t\t\tcolors.needsUpdate = true;\n\t\t\t}\n\n\t\t\tmesh.lookAt(_vector$b.setFromMatrixPosition(this.light.matrixWorld).negate());\n\t\t};\n\n\t\treturn HemisphereLightHelper;\n\t}(Object3D);\n\n\tvar GridHelper = /*#__PURE__*/function (_LineSegments) {\n\t\t_inheritsLoose(GridHelper, _LineSegments);\n\n\t\tfunction GridHelper(size, divisions, color1, color2) {\n\t\t\tvar _this;\n\n\t\t\tif (size === void 0) {\n\t\t\t\tsize = 10;\n\t\t\t}\n\n\t\t\tif (divisions === void 0) {\n\t\t\t\tdivisions = 10;\n\t\t\t}\n\n\t\t\tif (color1 === void 0) {\n\t\t\t\tcolor1 = 0x444444;\n\t\t\t}\n\n\t\t\tif (color2 === void 0) {\n\t\t\t\tcolor2 = 0x888888;\n\t\t\t}\n\n\t\t\tcolor1 = new Color(color1);\n\t\t\tcolor2 = new Color(color2);\n\t\t\tvar center = divisions / 2;\n\t\t\tvar step = size / divisions;\n\t\t\tvar halfSize = size / 2;\n\t\t\tvar vertices = [],\n\t\t\t\t\tcolors = [];\n\n\t\t\tfor (var i = 0, j = 0, k = -halfSize; i <= divisions; i++, k += step) {\n\t\t\t\tvertices.push(-halfSize, 0, k, halfSize, 0, k);\n\t\t\t\tvertices.push(k, 0, -halfSize, k, 0, halfSize);\n\t\t\t\tvar color = i === center ? color1 : color2;\n\t\t\t\tcolor.toArray(colors, j);\n\t\t\t\tj += 3;\n\t\t\t\tcolor.toArray(colors, j);\n\t\t\t\tj += 3;\n\t\t\t\tcolor.toArray(colors, j);\n\t\t\t\tj += 3;\n\t\t\t\tcolor.toArray(colors, j);\n\t\t\t\tj += 3;\n\t\t\t}\n\n\t\t\tvar geometry = new BufferGeometry();\n\t\t\tgeometry.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\t\tgeometry.setAttribute('color', new Float32BufferAttribute(colors, 3));\n\t\t\tvar material = new LineBasicMaterial({\n\t\t\t\tvertexColors: true,\n\t\t\t\ttoneMapped: false\n\t\t\t});\n\t\t\t_this = _LineSegments.call(this, geometry, material) || this;\n\t\t\t_this.type = 'GridHelper';\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn GridHelper;\n\t}(LineSegments);\n\n\tvar PolarGridHelper = /*#__PURE__*/function (_LineSegments) {\n\t\t_inheritsLoose(PolarGridHelper, _LineSegments);\n\n\t\tfunction PolarGridHelper(radius, radials, circles, divisions, color1, color2) {\n\t\t\tvar _this;\n\n\t\t\tif (radius === void 0) {\n\t\t\t\tradius = 10;\n\t\t\t}\n\n\t\t\tif (radials === void 0) {\n\t\t\t\tradials = 16;\n\t\t\t}\n\n\t\t\tif (circles === void 0) {\n\t\t\t\tcircles = 8;\n\t\t\t}\n\n\t\t\tif (divisions === void 0) {\n\t\t\t\tdivisions = 64;\n\t\t\t}\n\n\t\t\tif (color1 === void 0) {\n\t\t\t\tcolor1 = 0x444444;\n\t\t\t}\n\n\t\t\tif (color2 === void 0) {\n\t\t\t\tcolor2 = 0x888888;\n\t\t\t}\n\n\t\t\tcolor1 = new Color(color1);\n\t\t\tcolor2 = new Color(color2);\n\t\t\tvar vertices = [];\n\t\t\tvar colors = []; // create the radials\n\n\t\t\tfor (var i = 0; i <= radials;
1 i++) {\n\t\t\t\tvar v = i / radials * (Math.PI * 2);\n\t\t\t\tvar x = Math.sin(v) * radius;\n\t\t\t\tvar z = Math.cos(v) * radius;\n\t\t\t\tvertices.push(0, 0, 0);\n\t\t\t\tvertices.push(x, 0, z);\n\t\t\t\tvar color = i & 1 ? color1 : color2;\n\t\t\t\tcolors.push(color.r, color.g, color.b);\n\t\t\t\tcolors.push(color.r, color.g, color.b);\n\t\t\t} // create the circles\n\n\n\t\t\tfor (var _i = 0; _i <= circles; _i++) {\n\t\t\t\tvar _color = _i & 1 ? color1 : color2;\n\n\t\t\t\tvar r = radius - radius / circles * _i;\n\n\t\t\t\tfor (var j = 0; j < divisions; j++) {\n\t\t\t\t\t// first vertex\n\t\t\t\t\tvar _v = j / divisions * (Math.PI * 2);\n\n\t\t\t\t\tvar _x = Math.sin(_v) * r;\n\n\t\t\t\t\tvar _z = Math.cos(_v) * r;\n\n\t\t\t\t\tvertices.push(_x, 0, _z);\n\t\t\t\t\tcolors.push(_color.r, _color.g, _color.b); // second vertex\n\n\t\t\t\t\t_v = (j + 1) / divisions * (Math.PI * 2);\n\t\t\t\t\t_x = Math.sin(_v) * r;\n\t\t\t\t\t_z = Math.cos(_v) * r;\n\t\t\t\t\tvertices.push(_x, 0, _z);\n\t\t\t\t\tcolors.push(_color.r, _color.g, _color.b);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar geometry = new BufferGeometry();\n\t\t\tgeometry.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\t\tgeometry.setAttribute('color', new Float32BufferAttribute(colors, 3));\n\t\t\tvar material = new LineBasicMaterial({\n\t\t\t\tvertexColors: true,\n\t\t\t\ttoneMapped: false\n\t\t\t});\n\t\t\t_this = _LineSegments.call(this, geometry, material) || this;\n\t\t\t_this.type = 'PolarGridHelper';\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn PolarGridHelper;\n\t}(LineSegments);\n\n\tvar _v1$6 = /*@__PURE__*/new Vector3();\n\n\tvar _v2$3 = /*@__PURE__*/new Vector3();\n\n\tvar _v3$1 = /*@__PURE__*/new Vector3();\n\n\tvar DirectionalLightHelper = /*#__PURE__*/function (_Object3D) {\n\t\t_inheritsLoose(DirectionalLightHelper, _Object3D);\n\n\t\tfunction DirectionalLightHelper(light, size, color) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Object3D.call(this) || this;\n\t\t\t_this.light = light;\n\n\t\t\t_this.light.updateMatrixWorld();\n\n\t\t\t_this.matrix = light.matrixWorld;\n\t\t\t_this.matrixAutoUpdate = false;\n\t\t\t_this.color = color;\n\t\t\tif (size === undefined) size = 1;\n\t\t\tvar geometry = new BufferGeometry();\n\t\t\tgeometry.setAttribute('position', new Float32BufferAttribute([-size, size, 0, size, size, 0, size, -size, 0, -size, -size, 0, -size, size, 0], 3));\n\t\t\tvar material = new LineBasicMaterial({\n\t\t\t\tfog: false,\n\t\t\t\ttoneMapped: false\n\t\t\t});\n\t\t\t_this.lightPlane = new Line(geometry, material);\n\n\t\t\t_this.add(_this.lightPlane);\n\n\t\t\tgeometry = new BufferGeometry();\n\t\t\tgeometry.setAttribute('position', new Float32BufferAttribute([0, 0, 0, 0, 0, 1], 3));\n\t\t\t_this.targetLine = new Line(geometry, material);\n\n\t\t\t_this.add(_this.targetLine);\n\n\t\t\t_this.update();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = DirectionalLightHelper.prototype;\n\n\t\t_proto.dispose = function dispose() {\n\t\t\tthis.lightPlane.geometry.dispose();\n\t\t\tthis.lightPlane.material.dispose();\n\t\t\tthis.targetLine.geometry.dispose();\n\t\t\tthis.targetLine.material.dispose();\n\t\t};\n\n\t\t_proto.update = function update() {\n\t\t\t_v1$6.setFromMatrixPosition(this.light.matrixWorld);\n\n\t\t\t_v2$3.setFromMatrixPosition(this.light.target.matrixWorld);\n\n\t\t\t_v3$1.subVectors(_v2$3, _v1$6);\n\n\t\t\tthis.lightPlane.lookAt(_v2$3);\n\n\t\t\tif (this.color !== undefined) {\n\t\t\t\tthis.lightPlane.material.color.set(this.color);\n\t\t\t\tthis.targetLine.material.color.set(this.color);\n\t\t\t} else {\n\t\t\t\tthis.lightPlane.material.color.copy(this.light.color);\n\t\t\t\tthis.targetLine.material.color.copy(this.light.color);\n\t\t\t}\n\n\t\t\tthis.targetLine.lookAt(_v2$3);\n\t\t\tthis.targetLine.scale.z = _v3$1.length();\n\t\t};\n\n\t\treturn DirectionalLightHelper;\n\t}(Object3D);\n\n\tvar _vector$c = /*@__PURE__*/new Vector3();\n\n\tvar _camera = /*@__PURE__*/new Camera();\n\t/**\n\t *\t- shows frustum, line of sight and up of the camera\n\t *\t- suitable for fast updates\n\t * \t- based on frustum visualization in lightgl.js shadowmap example\n\t *\t\thttp://evanw.github.com/lightgl.js/tests/shadowmap.html\n\t */\n\n\n\tvar CameraHelper = /*#__PURE__*/function (_LineSegments) {\n\t\t_inheritsLoose(CameraHelper, _LineSegments);\n\n\t\tfunction CameraHelper(camera) {\n\t\t\tvar _this;\n\n\t\t\tvar geometry = new BufferGeometry();\n\t\t\tvar material = new LineBasicMaterial({\n\t\t\t\tcolor: 0xffffff,\n\t\t\t\tvertexColors: true,\n\t\t\t\ttoneMapped: false\n\t\t\t});\n\t\t\tvar vertices = [];\n\t\t\tvar colors = [];\n\t\t\tvar pointMap = {}; // colors\n\n\t\t\tvar colorFrustum = new Color(0xffaa00);\n\t\t\tvar colorCone = new Color(0xff0000);\n\t\t\tvar colorUp = new Color(0x00aaff);\n\t\t\tvar colorTarget = new Color(0xffffff);\n\t\t\tvar colorCross = new Color(0x333333); // near\n\n\t\t\taddLine('n1', 'n2', colorFrustum);\n\t\t\taddLine('n2', 'n4', colorFrustum);\n\t\t\taddLine('n4', 'n3', colorFrustum);\n\t\t\taddLine('n3', 'n1', colorFrustum); // far\n\n\t\t\taddLine('f1', 'f2', colorFrustum);\n\t\t\taddLine('f2', 'f4', colorFrustum);\n\t\t\taddLine('f4', 'f3', colorFrustum);\n\t\t\taddLine('f3', 'f1', colorFrustum); // sides\n\n\t\t\taddLine('n1', 'f1', colorFrustum);\n\t\t\taddLine('n2', 'f2', colorFrustum);\n\t\t\taddLine('n3', 'f3', colorFrustum);\n\t\t\taddLine('n4', 'f4', colorFrustum); // cone\n\n\t\t\taddLine('p', 'n1', colorCone);\n\t\t\taddLine('p', 'n2', colorCone);\n\t\t\taddLine('p', 'n3', colorCone);\n\t\t\taddLine('p', 'n4', colorCone); // up\n\n\t\t\taddLine('u1', 'u2', colorUp);\n\t\t\taddLine('u2', 'u3', colorUp);\n\t\t\taddLine('u3', 'u1', colorUp); // target\n\n\t\t\taddLine('c', 't', colorTarget);\n\t\t\taddLine('p', 'c', colorCross); // cross\n\n\t\t\taddLine('cn1', 'cn2', colorCross);\n\t\t\taddLine('cn3', 'cn4', colorCross);\n\t\t\taddLine('cf1', 'cf2', colorCross);\n\t\t\taddLine('cf3', 'cf4', colorCross);\n\n\t\t\tfunction addLine(a, b, color) {\n\t\t\t\taddPoint(a, color);\n\t\t\t\taddPoint(b, color);\n\t\t\t}\n\n\t\t\tfunction addPoint(id, color) {\n\t\t\t\tvertices.push(0, 0, 0);\n\t\t\t\tcolors.push(color.r, color.g, color.b);\n\n\t\t\t\tif (pointMap[id] === undefined) {\n\t\t\t\t\tpointMap[id] = [];\n\t\t\t\t}\n\n\t\t\t\tpointMap[id].push(vertices.length / 3 - 1);\n\t\t\t}\n\n\t\t\tgeometry.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\t\tgeometry.setAttribute('color', new Float32BufferAttribute(colors, 3));\n\t\t\t_this = _LineSegments.call(this, geometry, material) || this;\n\t\t\t_this.type = 'CameraHelper';\n\t\t\t_this.camera = camera;\n\t\t\tif (_this.camera.updateProjectionMatrix) _this.camera.updateProjectionMatrix();\n\t\t\t_this.matrix = camera.matrixWorld;\n\t\t\t_this.matrixAutoUpdate = false;\n\t\t\t_this.pointMap = pointMap;\n\n\t\t\t_this.update();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = CameraHelper.prototype;
1\n\n\t\t_proto.update = function update() {\n\t\t\tvar geometry = this.geometry;\n\t\t\tvar pointMap = this.pointMap;\n\t\t\tvar w = 1,\n\t\t\t\t\th = 1; // we need just camera projection matrix inverse\n\t\t\t// world matrix must be identity\n\n\t\t\t_camera.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse); // center / target\n\n\n\t\t\tsetPoint('c', pointMap, geometry, _camera, 0, 0, -1);\n\t\t\tsetPoint('t', pointMap, geometry, _camera, 0, 0, 1); // near\n\n\t\t\tsetPoint('n1', pointMap, geometry, _camera, -w, -h, -1);\n\t\t\tsetPoint('n2', pointMap, geometry, _camera, w, -h, -1);\n\t\t\tsetPoint('n3', pointMap, geometry, _camera, -w, h, -1);\n\t\t\tsetPoint('n4', pointMap, geometry, _camera, w, h, -1); // far\n\n\t\t\tsetPoint('f1', pointMap, geometry, _camera, -w, -h, 1);\n\t\t\tsetPoint('f2', pointMap, geometry, _camera, w, -h, 1);\n\t\t\tsetPoint('f3', pointMap, geometry, _camera, -w, h, 1);\n\t\t\tsetPoint('f4', pointMap, geometry, _camera, w, h, 1); // up\n\n\t\t\tsetPoint('u1', pointMap, geometry, _camera, w * 0.7, h * 1.1, -1);\n\t\t\tsetPoint('u2', pointMap, geometry, _camera, -w * 0.7, h * 1.1, -1);\n\t\t\tsetPoint('u3', pointMap, geometry, _camera, 0, h * 2, -1); // cross\n\n\t\t\tsetPoint('cf1', pointMap, geometry, _camera, -w, 0, 1);\n\t\t\tsetPoint('cf2', pointMap, geometry, _camera, w, 0, 1);\n\t\t\tsetPoint('cf3', pointMap, geometry, _camera, 0, -h, 1);\n\t\t\tsetPoint('cf4', pointMap, geometry, _camera, 0, h, 1);\n\t\t\tsetPoint('cn1', pointMap, geometry, _camera, -w, 0, -1);\n\t\t\tsetPoint('cn2', pointMap, geometry, _camera, w, 0, -1);\n\t\t\tsetPoint('cn3', pointMap, geometry, _camera, 0, -h, -1);\n\t\t\tsetPoint('cn4', pointMap, geometry, _camera, 0, h, -1);\n\t\t\tgeometry.getAttribute('position').needsUpdate = true;\n\t\t};\n\n\t\treturn CameraHelper;\n\t}(LineSegments);\n\n\tfunction setPoint(point, pointMap, geometry, camera, x, y, z) {\n\t\t_vector$c.set(x, y, z).unproject(camera);\n\n\t\tvar points = pointMap[point];\n\n\t\tif (points !== undefined) {\n\t\t\tvar position = geometry.getAttribute('position');\n\n\t\t\tfor (var i = 0, l = points.length; i < l; i++) {\n\t\t\t\tposition.setXYZ(points[i], _vector$c.x, _vector$c.y, _vector$c.z);\n\t\t\t}\n\t\t}\n\t}\n\n\tvar _box$3 = /*@__PURE__*/new Box3();\n\n\tvar BoxHelper = /*#__PURE__*/function (_LineSegments) {\n\t\t_inheritsLoose(BoxHelper, _LineSegments);\n\n\t\tfunction BoxHelper(object, color) {\n\t\t\tvar _this;\n\n\t\t\tif (color === void 0) {\n\t\t\t\tcolor = 0xffff00;\n\t\t\t}\n\n\t\t\tvar indices = new Uint16Array([0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7]);\n\t\t\tvar positions = new Float32Array(8 * 3);\n\t\t\tvar geometry = new BufferGeometry();\n\t\t\tgeometry.setIndex(new BufferAttribute(indices, 1));\n\t\t\tgeometry.setAttribute('position', new BufferAttribute(positions, 3));\n\t\t\t_this = _LineSegments.call(this, geometry, new LineBasicMaterial({\n\t\t\t\tcolor: color,\n\t\t\t\ttoneMapped: false\n\t\t\t})) || this;\n\t\t\t_this.object = object;\n\t\t\t_this.type = 'BoxHelper';\n\t\t\t_this.matrixAutoUpdate = false;\n\n\t\t\t_this.update();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = BoxHelper.prototype;\n\n\t\t_proto.update = function update(object) {\n\t\t\tif (object !== undefined) {\n\t\t\t\tconsole.warn('THREE.BoxHelper: .update() has no longer arguments.');\n\t\t\t}\n\n\t\t\tif (this.object !== undefined) {\n\t\t\t\t_box$3.setFromObject(this.object);\n\t\t\t}\n\n\t\t\tif (_box$3.isEmpty()) return;\n\t\t\tvar min = _box$3.min;\n\t\t\tvar max = _box$3.max;\n\t\t\t/*\n\t\t\t\t5____4\n\t\t\t1/___0/|\n\t\t\t| 6__|_7\n\t\t\t2/___3/\n\t\t\t\t0: max.x, max.y, max.z\n\t\t\t1: min.x, max.y, max.z\n\t\t\t2: min.x, min.y, max.z\n\t\t\t3: max.x, min.y, max.z\n\t\t\t4: max.x, max.y, min.z\n\t\t\t5: min.x, max.y, min.z\n\t\t\t6: min.x, min.y, min.z\n\t\t\t7: max.x, min.y, min.z\n\t\t\t*/\n\n\t\t\tvar position = this.geometry.attributes.position;\n\t\t\tvar array = position.array;\n\t\t\tarray[0] = max.x;\n\t\t\tarray[1] = max.y;\n\t\t\tarray[2] = max.z;\n\t\t\tarray[3] = min.x;\n\t\t\tarray[4] = max.y;\n\t\t\tarray[5] = max.z;\n\t\t\tarray[6] = min.x;\n\t\t\tarray[7] = min.y;\n\t\t\tarray[8] = max.z;\n\t\t\tarray[9] = max.x;\n\t\t\tarray[10] = min.y;\n\t\t\tarray[11] = max.z;\n\t\t\tarray[12] = max.x;\n\t\t\tarray[13] = max.y;\n\t\t\tarray[14] = min.z;\n\t\t\tarray[15] = min.x;\n\t\t\tarray[16] = max.y;\n\t\t\tarray[17] = min.z;\n\t\t\tarray[18] = min.x;\n\t\t\tarray[19] = min.y;\n\t\t\tarray[20] = min.z;\n\t\t\tarray[21] = max.x;\n\t\t\tarray[22] = min.y;\n\t\t\tarray[23] = min.z;\n\t\t\tposition.needsUpdate = true;\n\t\t\tthis.geometry.computeBoundingSphere();\n\t\t};\n\n\t\t_proto.setFromObject = function setFromObject(object) {\n\t\t\tthis.object = object;\n\t\t\tthis.update();\n\t\t\treturn this;\n\t\t};\n\n\t\t_proto.copy = function copy(source) {\n\t\t\tLineSegments.prototype.copy.call(this, source);\n\t\t\tthis.object = source.object;\n\t\t\treturn this;\n\t\t};\n\n\t\treturn BoxHelper;\n\t}(LineSegments);\n\n\tvar Box3Helper = /*#__PURE__*/function (_LineSegments) {\n\t\t_inheritsLoose(Box3Helper, _LineSegments);\n\n\t\tfunction Box3Helper(box, color) {\n\t\t\tvar _this;\n\n\t\t\tif (color === void 0) {\n\t\t\t\tcolor = 0xffff00;\n\t\t\t}\n\n\t\t\tvar indices = new Uint16Array([0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7]);\n\t\t\tvar positions = [1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1];\n\t\t\tvar geometry = new BufferGeometry();\n\t\t\tgeometry.setIndex(new BufferAttribute(indices, 1));\n\t\t\tgeometry.setAttribute('position', new Float32BufferAttribute(positions, 3));\n\t\t\t_this = _LineSegments.call(this, geometry, new LineBasicMaterial({\n\t\t\t\tcolor: color,\n\t\t\t\ttoneMapped: false\n\t\t\t})) || this;\n\t\t\t_this.box = box;\n\t\t\t_this.type = 'Box3Helper';\n\n\t\t\t_this.geometry.computeBoundingSphere();\n\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = Box3Helper.prototype;\n\n\t\t_proto.updateMatrixWorld = function updateMatrixWorld(force) {\n\t\t\tvar box = this.box;\n\t\t\tif (box.isEmpty()) return;\n\t\t\tbox.getCenter(this.position);\n\t\t\tbox.getSize(this.scale);\n\t\t\tthis.scale.multiplyScalar(0.5);\n\n\t\t\t_LineSegments.prototype.updateMatrixWorld.call(this, force);\n\t\t};\n\n\t\treturn Box3Helper;\n\t}(LineSegments);\n\n\tvar PlaneHelper = /*#__PURE__*/function (_Line) {\n\t\t_inheritsLoose(PlaneHelper, _Line);\n\n\t\tfunction PlaneHelper(plane, size, hex) {\n\t\t\tvar _this;\n\n\t\t\tif (size === void 0) {\n\t\t\t\tsize = 1;\n\t\t\t}\n\n\t\t\tif (hex === void 0) {\n\t\t\t\thex = 0xffff00;\n\t\t\t}\n\n\t\t\tvar color = hex;\n\t\t\tvar positions = [1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0];\n\t\t\tvar geometry = new BufferGeometry();\n\t\t\tgeometry.setAttribute('position', new Float32BufferAttribute(positions, 3));\n\t\t\tgeometry.computeBoundingSphere();\n\t\t\t_this = _Line.call(this, geometry, new LineBasicMaterial({\n\t\t\t\tcolor: color,\n\t\t\t\ttoneMapped: false\n\t\t\t})) || this;\n\t\t\t_this.type = 'PlaneHelper';\n\t\t\t_this.plane = plane;\n\t\t\t_this.size = size;\n\t\t\tvar positions2 = [1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1];\n\t\t\tvar geometry2 = new BufferGeometry();\n\t\t\tgeometry2.setAttribute('position', new Float32BufferAttribute(positions2, 3));\n\t\t\tgeometry2.computeBoundingSphere();\n\n\t\t\t_this.add(new Mesh(geometry2, new MeshBasicMaterial({\n\t\t\t\tcolor: color,\n\t\t\t\topacity: 0.2,\n\t\t\t\ttransparent: true,\n\t\t\t\tdepthWrite: false,\n\t\t\t\ttoneMapped: false\n\t\t\t})));\n\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = PlaneHelper.prototype;\n\n\t\t_proto.updateMatrixWorld = function updateMatrixWorld(force) {\n\t\t\tvar scale = -this.plane.constant;\n\t\t\tif (Math.abs(scale) < 1e-8) scale = 1e-8; // sign does not matter\n\n\t\t\tthis.scale.set(0.5 * this.size, 0.5 * this.size, scale);\n\t\t\tthis.children[0].material.side = scale < 0 ? BackSide : FrontSide; // renderer flips side when determinant < 0; flipping not wanted here\n\n\t\t\tthis.lookAt(this.plane.normal);\n\n\t\t\t_Line.prototype.updateMatrixWorld.call(this, force);\n\t\t};\n\n\t\treturn PlaneHelper;\n\t}(Line);\n\n\tvar _axis = /*@__PURE__*/new Vector3();\n\n\tvar _lineGeometry, _coneGeometry;
1\n\n\tvar ArrowHelper = /*#__PURE__*/function (_Object3D) {\n\t\t_inheritsLoose(ArrowHelper, _Object3D);\n\n\t\tfunction ArrowHelper(dir, origin, length, color, headLength, headWidth) {\n\t\t\tvar _this;\n\n\t\t\t_this = _Object3D.call(this) || this; // dir is assumed to be normalized\n\n\t\t\t_this.type = 'ArrowHelper';\n\t\t\tif (dir === undefined) dir = new Vector3(0, 0, 1);\n\t\t\tif (origin === undefined) origin = new Vector3(0, 0, 0);\n\t\t\tif (length === undefined) length = 1;\n\t\t\tif (color === undefined) color = 0xffff00;\n\t\t\tif (headLength === undefined) headLength = 0.2 * length;\n\t\t\tif (headWidth === undefined) headWidth = 0.2 * headLength;\n\n\t\t\tif (_lineGeometry === undefined) {\n\t\t\t\t_lineGeometry = new BufferGeometry();\n\n\t\t\t\t_lineGeometry.setAttribute('position', new Float32BufferAttribute([0, 0, 0, 0, 1, 0], 3));\n\n\t\t\t\t_coneGeometry = new CylinderBufferGeometry(0, 0.5, 1, 5, 1);\n\n\t\t\t\t_coneGeometry.translate(0, -0.5, 0);\n\t\t\t}\n\n\t\t\t_this.position.copy(origin);\n\n\t\t\t_this.line = new Line(_lineGeometry, new LineBasicMaterial({\n\t\t\t\tcolor: color,\n\t\t\t\ttoneMapped: false\n\t\t\t}));\n\t\t\t_this.line.matrixAutoUpdate = false;\n\n\t\t\t_this.add(_this.line);\n\n\t\t\t_this.cone = new Mesh(_coneGeometry, new MeshBasicMaterial({\n\t\t\t\tcolor: color,\n\t\t\t\ttoneMapped: false\n\t\t\t}));\n\t\t\t_this.cone.matrixAutoUpdate = false;\n\n\t\t\t_this.add(_this.cone);\n\n\t\t\t_this.setDirection(dir);\n\n\t\t\t_this.setLength(length, headLength, headWidth);\n\n\t\t\treturn _this;\n\t\t}\n\n\t\tvar _proto = ArrowHelper.prototype;\n\n\t\t_proto.setDirection = function setDirection(dir) {\n\t\t\t// dir is assumed to be normalized\n\t\t\tif (dir.y > 0.99999) {\n\t\t\t\tthis.quaternion.set(0, 0, 0, 1);\n\t\t\t} else if (dir.y < -0.99999) {\n\t\t\t\tthis.quaternion.set(1, 0, 0, 0);\n\t\t\t} else {\n\t\t\t\t_axis.set(dir.z, 0, -dir.x).normalize();\n\n\t\t\t\tvar radians = Math.acos(dir.y);\n\t\t\t\tthis.quaternion.setFromAxisAngle(_axis, radians);\n\t\t\t}\n\t\t};\n\n\t\t_proto.setLength = function setLength(length, headLength, headWidth) {\n\t\t\tif (headLength === undefined) headLength = 0.2 * length;\n\t\t\tif (headWidth === undefined) headWidth = 0.2 * headLength;\n\t\t\tthis.line.scale.set(1, Math.max(0.0001, length - headLength), 1); // see #17458\n\n\t\t\tthis.line.updateMatrix();\n\t\t\tthis.cone.scale.set(headWidth, headLength, headWidth);\n\t\t\tthis.cone.position.y = length;\n\t\t\tthis.cone.updateMatrix();\n\t\t};\n\n\t\t_proto.setColor = function setColor(color) {\n\t\t\tthis.line.material.color.set(color);\n\t\t\tthis.cone.material.color.set(color);\n\t\t};\n\n\t\t_proto.copy = function copy(source) {\n\t\t\t_Object3D.prototype.copy.call(this, source, false);\n\n\t\t\tthis.line.copy(source.line);\n\t\t\tthis.cone.copy(source.cone);\n\t\t\treturn this;\n\t\t};\n\n\t\treturn ArrowHelper;\n\t}(Object3D);\n\n\tvar AxesHelper = /*#__PURE__*/function (_LineSegments) {\n\t\t_inheritsLoose(AxesHelper, _LineSegments);\n\n\t\tfunction AxesHelper(size) {\n\t\t\tvar _this;\n\n\t\t\tif (size === void 0) {\n\t\t\t\tsize = 1;\n\t\t\t}\n\n\t\t\tvar vertices = [0, 0, 0, size, 0, 0, 0, 0, 0, 0, size, 0, 0, 0, 0, 0, 0, size];\n\t\t\tvar colors = [1, 0, 0, 1, 0.6, 0, 0, 1, 0, 0.6, 1, 0, 0, 0, 1, 0, 0.6, 1];\n\t\t\tvar geometry = new BufferGeometry();\n\t\t\tgeometry.setAttribute('position', new Float32BufferAttribute(vertices, 3));\n\t\t\tgeometry.setAttribute('color', new Float32BufferAttribute(colors, 3));\n\t\t\tvar material = new LineBasicMaterial({\n\t\t\t\tvertexColors: true,\n\t\t\t\ttoneMapped: false\n\t\t\t});\n\t\t\t_this = _LineSegments.call(this, geometry, material) || this;\n\t\t\t_this.type = 'AxesHelper';\n\t\t\treturn _this;\n\t\t}\n\n\t\treturn AxesHelper;\n\t}(LineSegments);\n\n\tvar _floatView = new Float32Array(1);\n\n\tvar _int32View = new Int32Array(_floatView.buffer);\n\n\tvar DataUtils = {\n\t\t// Converts float32 to float16 (stored as uint16 value).\n\t\ttoHalfFloat: function toHalfFloat(val) {\n\t\t\t// Source: http://gamedev.stackexchange.com/questions/17326/conversion-of-a-number-from-single-precision-floating-point-representation-to-a/17410#17410\n\n\t\t\t/* This method is faster than the OpenEXR implementation (very often\n\t\t\t* used, eg. in Ogre), with the additional benefit of rounding, inspired\n\t\t\t* by James Tursa?s half-precision code. */\n\t\t\t_floatView[0] = val;\n\t\t\tvar x = _int32View[0];\n\t\t\tvar bits = x >> 16 & 0x8000;\n\t\t\t/* Get the sign */\n\n\t\t\tvar m = x >> 12 & 0x07ff;
1\n\t\t\t/* Keep one extra bit for rounding */\n\n\t\t\tvar e = x >> 23 & 0xff;\n\t\t\t/* Using int is faster here */\n\n\t\t\t/* If zero, or denormal, or exponent underflows too much for a denormal\n\t\t\t\t* half, return signed zero. */\n\n\t\t\tif (e < 103) return bits;\n\t\t\t/* If NaN, return NaN. If Inf or exponent overflow, return Inf. */\n\n\t\t\tif (e > 142) {\n\t\t\t\tbits |= 0x7c00;\n\t\t\t\t/* If exponent was 0xff and one mantissa bit was set, it means NaN,\n\t\t\t\t\t\t\t* not Inf, so make sure we set one mantissa bit too. */\n\n\t\t\t\tbits |= (e == 255 ? 0 : 1) && x & 0x007fffff;\n\t\t\t\treturn bits;\n\t\t\t}\n\t\t\t/* If exponent underflows but not too much, return a denormal */\n\n\n\t\t\tif (e < 113) {\n\t\t\t\tm |= 0x0800;\n\t\t\t\t/* Extra rounding may overflow and set mantissa to 0 and exponent\n\t\t\t\t\t* to 1, which is OK. */\n\n\t\t\t\tbits |= (m >> 114 - e) + (m >> 113 - e & 1);\n\t\t\t\treturn bits;\n\t\t\t}\n\n\t\t\tbits |= e - 112 << 10 | m >> 1;\n\t\t\t/* Extra rounding. An overflow will set mantissa to 0 and increment\n\t\t\t\t* the exponent, which is OK. */\n\n\t\t\tbits += m & 1;\n\t\t\treturn bits;\n\t\t}\n\t};\n\n\tvar _ENCODINGS;\n\tvar LOD_MIN = 4;\n\tvar LOD_MAX = 8;\n\tvar SIZE_MAX = Math.pow(2, LOD_MAX); // The standard deviations (radians) associated with the extra mips. These are\n\t// chosen to approximate a Trowbridge-Reitz distribution function times the\n\t// geometric shadowing function. These sigma values squared must match the\n\t// variance #defines in cube_uv_reflection_fragment.glsl.js.\n\n\tvar EXTRA_LOD_SIGMA = [0.125, 0.215, 0.35, 0.446, 0.526, 0.582];\n\tvar TOTAL_LODS = LOD_MAX - LOD_MIN + 1 + EXTRA_LOD_SIGMA.length; // The maximum length of the blur for loop. Smaller sigmas will use fewer\n\t// samples and exit early, but not recompile the shader.\n\n\tvar MAX_SAMPLES = 20;\n\tvar ENCODINGS = (_ENCODINGS = {}, _ENCODINGS[LinearEncoding] = 0, _ENCODINGS[sRGBEncoding] = 1, _ENCODINGS[RGBEEncoding] = 2, _ENCODINGS[RGBM7Encoding] = 3, _ENCODINGS[RGBM16Encoding] = 4, _ENCODINGS[RGBDEncoding] = 5, _ENCODINGS[GammaEncoding] = 6, _ENCODINGS);\n\n\tvar _flatCamera = /*@__PURE__*/new OrthographicCamera();\n\n\tvar _createPlanes2 = /*@__PURE__*/_createPlanes(),\n\t\t\t_lodPlanes = _createPlanes2._lodPlanes,\n\t\t\t_sizeLods = _createPlanes2._sizeLods,\n\t\t\t_sigmas = _createPlanes2._sigmas;\n\n\tvar _clearColor = /*@__PURE__*/new Color();\n\n\tvar _oldTarget = null; // Golden Ratio\n\n\tvar PHI = (1 + Math.sqrt(5)) / 2;\n\tvar INV_PHI = 1 / PHI; // Vertices of a dodecahedron (except the opposites, which represent the\n\t// same axis), used as axis directions evenly spread on a sphere.\n\n\tvar _axisDirections = [/*@__PURE__*/new Vector3(1, 1, 1), /*@__PURE__*/new Vector3(-1, 1, 1), /*@__PURE__*/new Vector3(1, 1, -1), /*@__PURE__*/new Vector3(-1, 1, -1), /*@__PURE__*/new Vector3(0, PHI, INV_PHI), /*@__PURE__*/new Vector3(0, PHI, -INV_PHI), /*@__PURE__*/new Vector3(INV_PHI, 0, PHI), /*@__PURE__*/new Vector3(-INV_PHI, 0, PHI), /*@__PURE__*/new Vector3(PHI, INV_PHI, 0), /*@__PURE__*/new Vector3(-PHI, INV_PHI, 0)];\n\t/**\n\t * This class generates a Prefiltered, Mipmapped Radiance Environment Map\n\t * (PMREM) from a cubeMap environment texture. This allows different levels of\n\t * blur to be quickly accessed based on material roughness. It is packed into a\n\t * special CubeUV format that allows us to perform custom interpolation so that\n\t * we can support nonlinear formats such as RGBE. Unlike a traditional mipmap\n\t * chain, it only goes down to the LOD_MIN level (above), and then creates extra\n\t * even more filtered 'mips' at the same LOD_MIN resolution, associated with\n\t * higher roughness levels. In this way we maintain resolution to smoothly\n\t * interpolate diffuse lighting while limiting sampling computation.\n\t */\n\n\tvar PMREMGenerator = /*#__PURE__*/function () {\n\t\tfunction PMREMGenerator(renderer) {\n\t\t\tthis._renderer = renderer;\n\t\t\tthis._pingPongRenderTarget = null;\n\t\t\tthis._blurMaterial = _getBlurShader(MAX_SAMPLES);\n\t\t\tthis._equirectShader = null;\n\t\t\tthis._cubemapShader = null;\n\n\t\t\tthis._compileMaterial(this._blurMaterial);\n\t\t}\n\t\t/**\n\t\t * Generates a PMREM from a supplied Scene, which can be faster than using an\n\t\t * image if networking bandwidth is low. Optional sigma specifies a blur radius\n\t\t * in radians to be applied to the scene before PMREM generation. Optional near\n\t\t * and far planes ensure the scene is rendered in its entirety (the cubeCamera\n\t\t * is placed at the origin).\n\t\t */\n\n\n\t\tvar _proto = PMREMGenerator.prototype;\n\n\t\t_proto.fromScene = function fromScene(scene, sigma, near, far) {\n\t\t\tif (sigma === void 0) {\n\t\t\t\tsigma = 0;\n\t\t\t}\n\n\t\t\tif (near === void 0) {\n\t\t\t\tnear = 0.1;\n\t\t\t}\n\n\t\t\tif (far === void 0) {\n\t\t\t\tfar = 100;\n\t\t\t}\n\n\t\t\t_oldTarget = this._renderer.getRenderTarget();\n\n\t\t\tvar cubeUVRenderTarget = this._allocateTargets();\n\n\t\t\tthis._sceneToCubeUV(scene, near, far, cubeUVRenderTarget);\n\n\t\t\tif (sigma > 0) {\n\t\t\t\tthis._blur(cubeUVRenderTarget, 0, 0, sigma);\n\t\t\t}\n\n\t\t\tthis._applyPMREM(cubeUVRenderTarget);\n\n\t\t\tthis._cleanup(cubeUVRenderTarget);\n\n\t\t\treturn cubeUVRenderTarget;\n\t\t}\n\t\t/**\n\t\t * Generates a PMREM from an equirectangular texture, which can be either LDR\n\t\t * (RGBFormat) or HDR (RGBEFormat). The ideal input image size is 1k (1024 x 512),\n\t\t * as this matches best with the 256 x 256 cubemap output.\n\t\t */\n\t\t;
1\n\n\t\t_proto.fromEquirectangular = function fromEquirectangular(equirectangular) {\n\t\t\treturn this._fromTexture(equirectangular);\n\t\t}\n\t\t/**\n\t\t * Generates a PMREM from an cubemap texture, which can be either LDR\n\t\t * (RGBFormat) or HDR (RGBEFormat). The ideal input cube size is 256 x 256,\n\t\t * as this matches best with the 256 x 256 cubemap output.\n\t\t */\n\t\t;\n\n\t\t_proto.fromCubemap = function fromCubemap(cubemap) {\n\t\t\treturn this._fromTexture(cubemap);\n\t\t}\n\t\t/**\n\t\t * Pre-compiles the cubemap shader. You can get faster start-up by invoking this method during\n\t\t * your texture's network fetch for increased concurrency.\n\t\t */\n\t\t;\n\n\t\t_proto.compileCubemapShader = function compileCubemapShader() {\n\t\t\tif (this._cubemapShader === null) {\n\t\t\t\tthis._cubemapShader = _getCubemapShader();\n\n\t\t\t\tthis._compileMaterial(this._cubemapShader);\n\t\t\t}\n\t\t}\n\t\t/**\n\t\t * Pre-compiles the equirectangular shader. You can get faster start-up by invoking this method during\n\t\t * your texture's network fetch for increased concurrency.\n\t\t */\n\t\t;\n\n\t\t_proto.compileEquirectangularShader = function compileEquirectangularShader() {\n\t\t\tif (this._equirectShader === null) {\n\t\t\t\tthis._equirectShader = _getEquirectShader();\n\n\t\t\t\tthis._compileMaterial(this._equirectShader);\n\t\t\t}\n\t\t}\n\t\t/**\n\t\t * Disposes of the PMREMGenerator's internal memory. Note that PMREMGenerator is a static class,\n\t\t * so you should not need more than one PMREMGenerator object. If you do, calling dispose() on\n\t\t * one of them will cause any others to also become unusable.\n\t\t */\n\t\t;\n\n\t\t_proto.dispose = function dispose() {\n\t\t\tthis._blurMaterial.dispose();\n\n\t\t\tif (this._cubemapShader !== null) this._cubemapShader.dispose();\n\t\t\tif (this._equirectShader !== null) this._equirectShader.dispose();\n\n\t\t\tfor (var i = 0; i < _lodPlanes.length; i++) {\n\t\t\t\t_lodPlanes[i].dispose();\n\t\t\t}\n\t\t} // private interface\n\t\t;\n\n\t\t_proto._cleanup = function _cleanup(outputTarget) {\n\t\t\tthis._pingPongRenderTarget.dispose();\n\n\t\t\tthis._renderer.setRenderTarget(_oldTarget);\n\n\t\t\toutputTarget.scissorTest = false;\n\n\t\t\t_setViewport(outputTarget, 0, 0, outputTarget.width, outputTarget.height);\n\t\t};\n\n\t\t_proto._fromTexture = function _fromTexture(texture) {\n\t\t\t_oldTarget = this._renderer.getRenderTarget();\n\n\t\t\tvar cubeUVRenderTarget = this._allocateTargets(texture);\n\n\t\t\tthis._textureToCubeUV(texture, cubeUVRenderTarget);\n\n\t\t\tthis._applyPMREM(cubeUVRenderTarget);\n\n\t\t\tthis._cleanup(cubeUVRenderTarget);\n\n\t\t\treturn cubeUVRenderTarget;\n\t\t};\n\n\t\t_proto._allocateTargets = function _allocateTargets(texture) {\n\t\t\t// warning: null texture is valid\n\t\t\tvar params = {\n\t\t\t\tmagFilter: NearestFilter,\n\t\t\t\tminFilter: NearestFilter,\n\t\t\t\tgenerateMipmaps: false,\n\t\t\t\ttype: UnsignedByteType,\n\t\t\t\tformat: RGBEFormat,\n\t\t\t\tencoding: _isLDR(texture) ? texture.encoding : RGBEEncoding,\n\t\t\t\tdepthBuffer: false\n\t\t\t};\n\n\t\t\tvar cubeUVRenderTarget = _createRenderTarget(params);\n\n\t\t\tcubeUVRenderTarget.depthBuffer = texture ? false : true;\n\t\t\tthis._pingPongRenderTarget = _createRenderTarget(params);\n\t\t\treturn cubeUVRenderTarget;\n\t\t};\n\n\t\t_proto._compileMaterial = function _compileMaterial(material) {\n\t\t\tvar tmpMesh = new Mesh(_lodPlanes[0], material);\n\n\t\t\tthis._renderer.compile(tmpMesh, _flatCamera);\n\t\t};\n\n\t\t_proto._sceneToCubeUV = function _sceneToCubeUV(scene, near, far, cubeUVRenderTarget) {\n\t\t\tvar fov = 90;\n\t\t\tvar aspect = 1;\n\t\t\tvar cubeCamera = new PerspectiveCamera(fov, aspect, near, far);\n\t\t\tvar upSign = [1, -1, 1, 1, 1, 1];\n\t\t\tvar forwardSign = [1, 1, 1, -1, -1, -1];\n\t\t\tvar renderer = this._renderer;\n\t\t\tvar outputEncoding = renderer.outputEncoding;\n\t\t\tvar toneMapping = renderer.toneMapping;\n\t\t\trenderer.getClearColor(_clearColor);\n\t\t\tvar clearAlpha = renderer.getClearAlpha();\n\t\t\trenderer.toneMapping = NoToneMapping;\n\t\t\trenderer.outputEncoding = LinearEncoding;\n\t\t\tvar background = scene.background;\n\n\t\t\tif (background && background.isColor) {\n\t\t\t\tbackground.convertSRGBToLinear(); // Convert linear to RGBE\n\n\t\t\t\tvar maxComponent = Math.max(background.r, background.g, background.b);\n\t\t\t\tvar fExp = Math.min(Math.max(Math.ceil(Math.log2(maxComponent)), -128.0), 127.0);\n\t\t\t\tbackground = background.multiplyScalar(Math.pow(2.0, -fExp));\n\t\t\t\tvar alpha = (fExp + 128.0) / 255.0;
1\n\t\t\t\trenderer.setClearColor(background, alpha);\n\t\t\t\tscene.background = null;\n\t\t\t}\n\n\t\t\tfor (var i = 0; i < 6; i++) {\n\t\t\t\tvar col = i % 3;\n\n\t\t\t\tif (col == 0) {\n\t\t\t\t\tcubeCamera.up.set(0, upSign[i], 0);\n\t\t\t\t\tcubeCamera.lookAt(forwardSign[i], 0, 0);\n\t\t\t\t} else if (col == 1) {\n\t\t\t\t\tcubeCamera.up.set(0, 0, upSign[i]);\n\t\t\t\t\tcubeCamera.lookAt(0, forwardSign[i], 0);\n\t\t\t\t} else {\n\t\t\t\t\tcubeCamera.up.set(0, upSign[i], 0);\n\t\t\t\t\tcubeCamera.lookAt(0, 0, forwardSign[i]);\n\t\t\t\t}\n\n\t\t\t\t_setViewport(cubeUVRenderTarget, col * SIZE_MAX, i > 2 ? SIZE_MAX : 0, SIZE_MAX, SIZE_MAX);\n\n\t\t\t\trenderer.setRenderTarget(cubeUVRenderTarget);\n\t\t\t\trenderer.render(scene, cubeCamera);\n\t\t\t}\n\n\t\t\trenderer.toneMapping = toneMapping;\n\t\t\trenderer.outputEncoding = outputEncoding;\n\t\t\trenderer.setClearColor(_clearColor, clearAlpha);\n\t\t};\n\n\t\t_proto._textureToCubeUV = function _textureToCubeUV(texture, cubeUVRenderTarget) {\n\t\t\tvar renderer = this._renderer;\n\n\t\t\tif (texture.isCubeTexture) {\n\t\t\t\tif (this._cubemapShader == null) {\n\t\t\t\t\tthis._cubemapShader = _getCubemapShader();\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (this._equirectShader == null) {\n\t\t\t\t\tthis._equirectShader = _getEquirectShader();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tvar material = texture.isCubeTexture ? this._cubemapShader : this._equirectShader;\n\t\t\tvar mesh = new Mesh(_lodPlanes[0], material);\n\t\t\tvar uniforms = material.uniforms;\n\t\t\tuniforms['envMap'].value = texture;\n\n\t\t\tif (!texture.isCubeTexture) {\n\t\t\t\tuniforms['texelSize'].value.set(1.0 / texture.image.width, 1.0 / texture.image.height);\n\t\t\t}\n\n\t\t\tuniforms['inputEncoding'].value = ENCODINGS[texture.encoding];\n\t\t\tuniforms['outputEncoding'].value = ENCODINGS[cubeUVRenderTarget.texture.encoding];\n\n\t\t\t_setViewport(cubeUVRenderTarget, 0, 0, 3 * SIZE_MAX, 2 * SIZE_MAX);\n\n\t\t\trenderer.setRenderTarget(cubeUVRenderTarget);\n\t\t\trenderer.render(mesh, _flatCamera);\n\t\t};\n\n\t\t_proto._applyPMREM = function _applyPMREM(cubeUVRenderTarget) {\n\t\t\tvar renderer = this._renderer;\n\t\t\tvar autoClear = renderer.autoClear;\n\t\t\trenderer.autoClear = false;\n\n\t\t\tfor (var i = 1; i < TOTAL_LODS; i++) {\n\t\t\t\tvar sigma = Math.sqrt(_sigmas[i] * _sigmas[i] - _sigmas[i - 1] * _sigmas[i - 1]);\n\t\t\t\tvar poleAxis = _axisDirections[(i - 1) % _axisDirections.length];\n\n\t\t\t\tthis._blur(cubeUVRenderTarget, i - 1, i, sigma, poleAxis);\n\t\t\t}\n\n\t\t\trenderer.autoClear = autoClear;\n\t\t}\n\t\t/**\n\t\t * This is a two-pass Gaussian blur for a cubemap. Normally this is done\n\t\t * vertically and horizontally, but this breaks down on a cube. Here we apply\n\t\t * the blur latitudinally (around the poles), and then longitudinally (towards\n\t\t * the poles) to approximate the orthogonally-separable blur. It is least\n\t\t * accurate at the poles, but still does a decent job.\n\t\t */\n\t\t;\n\n\t\t_proto._blur = function _blur(cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis) {\n\t\t\tvar pingPongRenderTarget = this._pingPongRenderTarget;\n\n\t\t\tthis._halfBlur(cubeUVRenderTarget, pingPongRenderTarget, lodIn, lodOut, sigma, 'latitudinal', poleAxis);\n\n\t\t\tthis._halfBlur(pingPongRenderTarget, cubeUVRenderTarget, lodOut, lodOut, sigma, 'longitudinal', poleAxis);\n\t\t};\n\n\t\t_proto._halfBlur = function _halfBlur(targetIn, targetOut, lodIn, lodOut, sigmaRadians, direction, poleAxis) {\n\t\t\tvar renderer = this._renderer;\n\t\t\tvar blurMaterial = this._blurMaterial;\n\n\t\t\tif (direction !== 'latitudinal' && direction !== 'longitudinal') {\n\t\t\t\tconsole.error('blur direction must be either latitudinal or longitudinal!');\n\t\t\t} // Number of standard deviations at which to cut off the discrete approximation.\n\n\n\t\t\tvar STANDARD_DEVIATIONS = 3;\n\t\t\tvar blurMesh = new Mesh(_lodPlanes[lodOut], blurMaterial);\n\t\t\tvar blurUniforms = blurMaterial.uniforms;\n\t\t\tvar pixels = _sizeLods[lodIn] - 1;\n\t\t\tvar radiansPerPixel = isFinite(sigmaRadians) ? Math.PI / (2 * pixels) : 2 * Math.PI / (2 * MAX_SAMPLES - 1);
1\n\t\t\tvar sigmaPixels = sigmaRadians / radiansPerPixel;\n\t\t\tvar samples = isFinite(sigmaRadians) ? 1 + Math.floor(STANDARD_DEVIATIONS * sigmaPixels) : MAX_SAMPLES;\n\n\t\t\tif (samples > MAX_SAMPLES) {\n\t\t\t\tconsole.warn(\"sigmaRadians, \" + sigmaRadians + \", is too large and will clip, as it requested \" + samples + \" samples when the maximum is set to \" + MAX_SAMPLES);\n\t\t\t}\n\n\t\t\tvar weights = [];\n\t\t\tvar sum = 0;\n\n\t\t\tfor (var i = 0; i < MAX_SAMPLES; ++i) {\n\t\t\t\tvar _x = i / sigmaPixels;\n\n\t\t\t\tvar weight = Math.exp(-_x * _x / 2);\n\t\t\t\tweights.push(weight);\n\n\t\t\t\tif (i == 0) {\n\t\t\t\t\tsum += weight;\n\t\t\t\t} else if (i < samples) {\n\t\t\t\t\tsum += 2 * weight;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (var _i = 0; _i < weights.length; _i++) {\n\t\t\t\tweights[_i] = weights[_i] / sum;\n\t\t\t}\n\n\t\t\tblurUniforms['envMap'].value = targetIn.texture;\n\t\t\tblurUniforms['samples'].value = samples;\n\t\t\tblurUniforms['weights'].value = weights;\n\t\t\tblurUniforms['latitudinal'].value = direction === 'latitudinal';\n\n\t\t\tif (poleAxis) {\n\t\t\t\tblurUniforms['poleAxis'].value = poleAxis;\n\t\t\t}\n\n\t\t\tblurUniforms['dTheta'].value = radiansPerPixel;\n\t\t\tblurUniforms['mipInt'].value = LOD_MAX - lodIn;\n\t\t\tblurUniforms['inputEncoding'].value = ENCODINGS[targetIn.texture.encoding];\n\t\t\tblurUniforms['outputEncoding'].value = ENCODINGS[targetIn.texture.encoding];\n\t\t\tvar outputSize = _sizeLods[lodOut];\n\t\t\tvar x = 3 * Math.max(0, SIZE_MAX - 2 * outputSize);\n\t\t\tvar y = (lodOut === 0 ? 0 : 2 * SIZE_MAX) + 2 * outputSize * (lodOut > LOD_MAX - LOD_MIN ? lodOut - LOD_MAX + LOD_MIN : 0);\n\n\t\t\t_setViewport(targetOut, x, y, 3 * outputSize, 2 * outputSize);\n\n\t\t\trenderer.setRenderTarget(targetOut);\n\t\t\trenderer.render(blurMesh, _flatCamera);\n\t\t};\n\n\t\treturn PMREMGenerator;\n\t}();\n\n\tfunction _isLDR(texture) {\n\t\tif (texture === undefined || texture.type !== UnsignedByteType) return false;\n\t\treturn texture.encoding === LinearEncoding || texture.encoding === sRGBEncoding || texture.encoding === GammaEncoding;\n\t}\n\n\tfunction _createPlanes() {\n\t\tvar _lodPlanes = [];\n\t\tvar _sizeLods = [];\n\t\tvar _sigmas = [];\n\t\tvar lod = LOD_MAX;\n\n\t\tfor (var i = 0; i < TOTAL_LODS; i++) {\n\t\t\tvar sizeLod = Math.pow(2, lod);\n\n\t\t\t_sizeLods.push(sizeLod);\n\n\t\t\tvar sigma = 1.0 / sizeLod;\n\n\t\t\tif (i > LOD_MAX - LOD_MIN) {\n\t\t\t\tsigma = EXTRA_LOD_SIGMA[i - LOD_MAX + LOD_MIN - 1];\n\t\t\t} else if (i == 0) {\n\t\t\t\tsigma = 0;\n\t\t\t}\n\n\t\t\t_sigmas.push(sigma);\n\n\t\t\tvar texelSize = 1.0 / (sizeLod - 1);\n\t\t\tvar min = -texelSize / 2;\n\t\t\tvar max = 1 + texelSize / 2;\n\t\t\tvar uv1 = [min, min, max, min, max, max, min, min, max, max, min, max];\n\t\t\tvar cubeFaces = 6;\n\t\t\tvar vertices = 6;\n\t\t\tvar positionSize = 3;\n\t\t\tvar uvSize = 2;\n\t\t\tvar faceIndexSize = 1;\n\t\t\tvar position = new Float32Array(positionSize * vertices * cubeFaces);\n\t\t\tvar uv = new Float32Array(uvSize * vertices * cubeFaces);\n\t\t\tvar faceIndex = new Float32Array(faceIndexSize * vertices * cubeFaces);\n\n\t\t\tfor (var face = 0; face < cubeFaces; face++) {\n\t\t\t\tvar x = face % 3 * 2 / 3 - 1;\n\t\t\t\tvar y = face > 2 ? 0 : -1;\n\t\t\t\tvar coordinates = [x, y, 0, x + 2 / 3, y, 0, x + 2 / 3, y + 1, 0, x, y, 0, x + 2 / 3, y + 1, 0, x, y + 1, 0];\n\t\t\t\tposition.set(coordinates, positionSize * vertices * face);\n\t\t\t\tuv.set(uv1, uvSize * vertices * face);\n\t\t\t\tvar fill = [face, face, face, face, face, face];\n\t\t\t\tfaceIndex.set(fill, faceIndexSize * vertices * face);\n\t\t\t}\n\n\t\t\tvar planes = new BufferGeometry();\n\t\t\tplanes.setAttribute('position', new BufferAttribute(position, positionSize));\n\t\t\tplanes.setAttribute('uv', new BufferAttribute(uv, uvSize));\n\t\t\tplanes.setAttribute('faceIndex', new BufferAttribute(faceIndex, faceIndexSize));\n\n\t\t\t_lodPlanes.push(planes);\n\n\t\t\tif (lod > LOD_MIN) {\n\t\t\t\tlod--;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\t_lodPlanes: _lodPlanes,\n\t\t\t_sizeLods: _sizeLods,\n\t\t\t_sigmas: _sigmas\n\t\t};\n\t}\n\n\tfunction _createRenderTarget(params) {\n\t\tvar cubeUVRenderTarget = new WebGLRenderTarget(3 * SIZE_MAX, 3 * SIZE_MAX, params);\n\t\tcubeUVRenderTarget.texture.mapping = CubeUVReflectionMapping;\n\t\tcubeUVRenderTarget.texture.name = 'PMREM.cubeUv';\n\t\tcubeUVRenderTarget.scissorTest = true;\n\t\treturn cubeUVRenderTarget;\n\t}\n\n\tfunction _setViewport(target, x, y, width, height) {\n\t\ttarget.viewport.set(x, y, width, height);\n\t\ttarget.scissor.set(x, y, width, height);\n\t}\n\n\tfunction _getBlurShader(maxSamples) {\n\t\tvar weights = new Float32Array(maxSamples);
1\n\t\tvar poleAxis = new Vector3(0, 1, 0);\n\t\tvar shaderMaterial = new RawShaderMaterial({\n\t\t\tname: 'SphericalGaussianBlur',\n\t\t\tdefines: {\n\t\t\t\t'n': maxSamples\n\t\t\t},\n\t\t\tuniforms: {\n\t\t\t\t'envMap': {\n\t\t\t\t\tvalue: null\n\t\t\t\t},\n\t\t\t\t'samples': {\n\t\t\t\t\tvalue: 1\n\t\t\t\t},\n\t\t\t\t'weights': {\n\t\t\t\t\tvalue: weights\n\t\t\t\t},\n\t\t\t\t'latitudinal': {\n\t\t\t\t\tvalue: false\n\t\t\t\t},\n\t\t\t\t'dTheta': {\n\t\t\t\t\tvalue: 0\n\t\t\t\t},\n\t\t\t\t'mipInt': {\n\t\t\t\t\tvalue: 0\n\t\t\t\t},\n\t\t\t\t'poleAxis': {\n\t\t\t\t\tvalue: poleAxis\n\t\t\t\t},\n\t\t\t\t'inputEncoding': {\n\t\t\t\t\tvalue: ENCODINGS[LinearEncoding]\n\t\t\t\t},\n\t\t\t\t'outputEncoding': {\n\t\t\t\t\tvalue: ENCODINGS[LinearEncoding]\n\t\t\t\t}\n\t\t\t},\n\t\t\tvertexShader: _getCommonVertexShader(),\n\t\t\tfragmentShader:\n\t\t\t/* glsl */\n\t\t\t\"\\n\\n\\t\\t\\tprecision mediump float;\\n\\t\\t\\tprecision mediump int;\\n\\n\\t\\t\\tvarying vec3 vOutputDirection;\\n\\n\\t\\t\\tuniform sampler2D envMap;\\n\\t\\t\\tuniform int samples;\\n\\t\\t\\tuniform float weights[ n ];\\n\\t\\t\\tuniform bool latitudinal;\\n\\t\\t\\tuniform float dTheta;\\n\\t\\t\\tuniform float mipInt;\\n\\t\\t\\tuniform vec3 poleAxis;\\n\\n\\t\\t\\t\" + _getEncodings() + \"\\n\\n\\t\\t\\t#define ENVMAP_TYPE_CUBE_UV\\n\\t\\t\\t#include <cube_uv_reflection_fragment>\\n\\n\\t\\t\\tvec3 getSample( float theta, vec3 axis ) {\\n\\n\\t\\t\\t\\tfloat cosTheta = cos( theta );\\n\\t\\t\\t\\t// Rodrigues' axis-angle rotation\\n\\t\\t\\t\\tvec3 sampleDirection = vOutputDirection * cosTheta\\n\\t\\t\\t\\t\\t+ cross( axis, vOutputDirection ) * sin( theta )\\n\\t\\t\\t\\t\\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\\n\\n\\t\\t\\t\\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\\n\\n\\t\\t\\t}\\n\\n\\t\\t\\tvoid main() {\\n\\n\\t\\t\\t\\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\\n\\n\\t\\t\\t\\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\\n\\n\\t\\t\\t\\t\\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\\n\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\taxis = normalize( axis );\\n\\n\\t\\t\\t\\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\\n\\t\\t\\t\\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\\n\\n\\t\\t\\t\\tfor ( int i = 1; i < n; i++ ) {\\n\\n\\t\\t\\t\\t\\tif ( i >= samples ) {\\n\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\n\\t\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t\\tfloat theta = dTheta * float( i );\\n\\t\\t\\t\\t\\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\\n\\t\\t\\t\\t\\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\\n\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\tgl_FragColor = linearToOutputTexel( gl_FragColor );\\n\\n\\t\\t\\t}\\n\\t\\t\",\n\t\t\tblending: NoBlending,\n\t\t\tdepthTest: false,\n\t\t\tdepthWrite: false\n\t\t});\n\t\treturn shaderMaterial;\n\t}\n\n\tfunction _getEquirectShader() {\n\t\tvar texelSize = new Vector2(1, 1);\n\t\tvar shaderMaterial = new RawShaderMaterial({\n\t\t\tname: 'EquirectangularToCubeUV',\n\t\t\tuniforms: {\n\t\t\t\t'envMap': {\n\t\t\t\t\tvalue: null\n\t\t\t\t},\n\t\t\t\t'texelSize': {\n\t\t\t\t\tvalue: texelSize\n\t\t\t\t},\n\t\t\t\t'inputEncoding': {\n\t\t\t\t\tvalue: ENCODINGS[LinearEncoding]\n\t\t\t\t},\n\t\t\t\t'outputEncoding': {\n\t\t\t\t\tvalue: ENCODINGS[LinearEncoding]\n\t\t\t\t}\n\t\t\t},\n\t\t\tvertexShader: _getCommonVertexShader(),\n\t\t\tfragmentShader:\n\t\t\t/* glsl */\n\t\t\t\"\\n\\n\\t\\t\\tprecision mediump float;\\n\\t\\t\\tprecision mediump int;\\n\\n\\t\\t\\tvarying vec3 vOutputDirection;\\n\\n\\t\\t\\tuniform sampler2D envMap;\\n\\t\\t\\tuniform vec2 texelSize;\\n\\n\\t\\t\\t\" + _getEncodings() + \"\\n\\n\\t\\t\\t#include <common>\\n\\n\\t\\t\\tvoid main() {\\n\\n\\t\\t\\t\\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\\n\\n\\t\\t\\t\\tvec3 outputDirection = normalize( vOutputDirection );\\n\\t\\t\\t\\tvec2 uv = equirectUv( outputDirection );\\n\\n\\t\\t\\t\\tvec2 f = fract( uv / texelSize - 0.5 );\\n\\t\\t\\t\\tuv -= f * texelSize;\\n\\t\\t\\t\\tvec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\\n\\t\\t\\t\\tuv.x += texelSize.x;\\n\\t\\t\\t\\tvec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\\n\\t\\t\\t\\tuv.y += texelSize.y;\\n\\t\\t\\t\\tvec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\\n\\t\\t\\t\\tuv.x -= texelSize.x;\\n\\t\\t\\t\\tvec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\\n\\n\\t\\t\\t\\tvec3 tm = mix( tl, tr, f.x );\\n\\t\\t\\t\\tvec3 bm = mix( bl, br, f.x );\\n\\t\\t\\t\\tgl_FragColor.rgb = mix( tm, bm, f.y );\\n\\n\\t\\t\\t\\tgl_FragColor = linearToOutputTexel( gl_FragColor );\\n\\n\\t\\t\\t}\\n\\t\\t\",\n\t\t\tblending: NoBlending,\n\t\t\tdepthTest: false,\n\t\t\tdepthWrite: false\n\t\t});\n\t\treturn shaderMaterial;\n\t}\n\n\tfunction _getCubemapShader() {\n\t\tvar shaderMaterial = new RawShaderMaterial({\n\t\t\tname: 'CubemapToCubeUV',\n\t\t\tuniforms: {\n\t\t\t\t'envMap': {\n\t\t\t\t\tvalue: null\n\t\t\t\t},\n\t\t\t\t'inputEncoding': {\n\t\t\t\t\tvalue: ENCODINGS[LinearEncoding]\n\t\t\t\t},\n\t\t\t\t'outputEncoding': {\n\t\t\t\t\tvalue: ENCODINGS[LinearEncoding]\n\t\t\t\t}\n\t\t\t},\n\t\t\tvertexShader: _getCommonVertexShader(),\n\t\t\tfragmentShader:\n\t\t\t/* glsl */\n\t\t\t\"\\n\\n\\t\\t\\tprecision mediump float;\\n\\t\\t\\tprecision mediump int;\\n\\n\\t\\t\\tvarying vec3 vOutputDirection;\\n\\n\\t\\t\\tuniform samplerCube envMap;\\n\\n\\t\\t\\t\" + _getEncodings() + \"\\n\\n\\t\\t\\tvoid main() {\\n\\n\\t\\t\\t\\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\\n\\t\\t\\t\\tgl_FragColor.rgb = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) ).rgb;\\n\\t\\t\\t\\tgl_FragColor = linearToOutputTexel( gl_FragColor );\\n\\n\\t\\t\\t}\\n\\t\\t\",\n\t\t\tblending: NoBlending,\n\t\t\tdepthTest: false,\n\t\t\tdepthWrite: false\n\t\t});\n\t\treturn shaderMaterial;\n\t}\n\n\tfunction _getCommonVertexShader() {\n\t\treturn (\n\t\t\t/* glsl */\n\t\t\t\"\\n\\n\\t\\tprecision mediump float;\\n\\t\\tprecision mediump int;\\n\\n\\t\\tattribute vec3 position;\\n\\t\\tattribute vec2 uv;\\n\\t\\tattribute float faceIndex;\\n\\n\\t\\tvarying vec3 vOutputDirection;\\n\\n\\t\\t// RH coordinate system; PMREM face-indexing convention\\n\\t\\tvec3 getDirection( vec2 uv, float face ) {\\n\\n\\t\\t\\tuv = 2.0 * uv - 1.0;\\n\\n\\t\\t\\tvec3 direction = vec3( uv, 1.0 );\\n\\n\\t\\t\\tif ( face == 0.0 ) {\\n\\n\\t\\t\\t\\tdirection = direction.zyx; // ( 1, v, u ) pos x\\n\\n\\t\\t\\t} else if ( face == 1.0 ) {\\n\\n\\t\\t\\t\\tdirection = direction.xzy;\\n\\t\\t\\t\\tdirection.xz *= -1.0;
1 // ( -u, 1, -v ) pos y\\n\\n\\t\\t\\t} else if ( face == 2.0 ) {\\n\\n\\t\\t\\t\\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\\n\\n\\t\\t\\t} else if ( face == 3.0 ) {\\n\\n\\t\\t\\t\\tdirection = direction.zyx;\\n\\t\\t\\t\\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\\n\\n\\t\\t\\t} else if ( face == 4.0 ) {\\n\\n\\t\\t\\t\\tdirection = direction.xzy;\\n\\t\\t\\t\\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\\n\\n\\t\\t\\t} else if ( face == 5.0 ) {\\n\\n\\t\\t\\t\\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\\n\\n\\t\\t\\t}\\n\\n\\t\\t\\treturn direction;\\n\\n\\t\\t}\\n\\n\\t\\tvoid main() {\\n\\n\\t\\t\\tvOutputDirection = getDirection( uv, faceIndex );\\n\\t\\t\\tgl_Position = vec4( position, 1.0 );\\n\\n\\t\\t}\\n\\t\"\n\t\t);\n\t}\n\n\tfunction _getEncodings() {\n\t\treturn (\n\t\t\t/* glsl */\n\t\t\t\"\\n\\n\\t\\tuniform int inputEncoding;\\n\\t\\tuniform int outputEncoding;\\n\\n\\t\\t#include <encodings_pars_fragment>\\n\\n\\t\\tvec4 inputTexelToLinear( vec4 value ) {\\n\\n\\t\\t\\tif ( inputEncoding == 0 ) {\\n\\n\\t\\t\\t\\treturn value;\\n\\n\\t\\t\\t} else if ( inputEncoding == 1 ) {\\n\\n\\t\\t\\t\\treturn sRGBToLinear( value );\\n\\n\\t\\t\\t} else if ( inputEncoding == 2 ) {\\n\\n\\t\\t\\t\\treturn RGBEToLinear( value );\\n\\n\\t\\t\\t} else if ( inputEncoding == 3 ) {\\n\\n\\t\\t\\t\\treturn RGBMToLinear( value, 7.0 );\\n\\n\\t\\t\\t} else if ( inputEncoding == 4 ) {\\n\\n\\t\\t\\t\\treturn RGBMToLinear( value, 16.0 );\\n\\n\\t\\t\\t} else if ( inputEncoding == 5 ) {\\n\\n\\t\\t\\t\\treturn RGBDToLinear( value, 256.0 );\\n\\n\\t\\t\\t} else {\\n\\n\\t\\t\\t\\treturn GammaToLinear( value, 2.2 );\\n\\n\\t\\t\\t}\\n\\n\\t\\t}\\n\\n\\t\\tvec4 linearToOutputTexel( vec4 value ) {\\n\\n\\t\\t\\tif ( outputEncoding == 0 ) {\\n\\n\\t\\t\\t\\treturn value;\\n\\n\\t\\t\\t} else if ( outputEncoding == 1 ) {\\n\\n\\t\\t\\t\\treturn LinearTosRGB( value );\\n\\n\\t\\t\\t} else if ( outputEncoding == 2 ) {\\n\\n\\t\\t\\t\\treturn LinearToRGBE( value );\\n\\n\\t\\t\\t} else if ( outputEncoding == 3 ) {\\n\\n\\t\\t\\t\\treturn LinearToRGBM( value, 7.0 );\\n\\n\\t\\t\\t} else if ( outputEncoding == 4 ) {\\n\\n\\t\\t\\t\\treturn LinearToRGBM( value, 16.0 );\\n\\n\\t\\t\\t} else if ( outputEncoding == 5 ) {\\n\\n\\t\\t\\t\\treturn LinearToRGBD( value, 256.0 );\\n\\n\\t\\t\\t} else {\\n\\n\\t\\t\\t\\treturn LinearToGamma( value, 2.2 );\\n\\n\\t\\t\\t}\\n\\n\\t\\t}\\n\\n\\t\\tvec4 envMapTexelToLinear( vec4 color ) {\\n\\n\\t\\t\\treturn inputTexelToLinear( color );\\n\\n\\t\\t}\\n\\t\"\n\t\t);\n\t}\n\n\tfunction Face4(a, b, c, d, normal, color, materialIndex) {\n\t\tconsole.warn('THREE.Face4 has been removed. A THREE.Face3 will be created instead.');\n\t\treturn new Face3(a, b, c, normal, color, materialIndex);\n\t}\n\tvar LineStrip = 0;\n\tvar LinePieces = 1;\n\tvar NoColors = 0;\n\tvar FaceColors = 1;\n\tvar VertexColors = 2;\n\tfunction MeshFaceMaterial(materials) {\n\t\tconsole.warn('THREE.MeshFaceMaterial has been removed. Use an Array instead.');\n\t\treturn materials;\n\t}\n\tfunction MultiMaterial(materials) {\n\t\tif (materials === void 0) {\n\t\t\tmaterials = [];\n\t\t}\n\n\t\tconsole.warn('THREE.MultiMaterial has been removed. Use an Array instead.');\n\t\tmaterials.isMultiMaterial = true;\n\t\tmaterials.materials = materials;\n\n\t\tmaterials.clone = function () {\n\t\t\treturn materials.slice();\n\t\t};\n\n\t\treturn materials;\n\t}\n\tfunction PointCloud(geometry, material) {\n\t\tconsole.warn('THREE.PointCloud has been renamed to THREE.Points.');\n\t\treturn new Points(geometry, material);\n\t}\n\tfunction Particle(material) {\n\t\tconsole.warn('THREE.Particle has been renamed to THREE.Sprite.');\n\t\treturn new Sprite(material);\n\t}\n\tfunction ParticleSystem(geometry, material) {\n\t\tconsole.warn('THREE.ParticleSystem has been renamed to THREE.Points.');\n\t\treturn new Points(geometry, material);\n\t}\n\tfunction PointCloudMaterial(parameters) {\n\t\tconsole.warn('THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial.');\n\t\treturn new PointsMaterial(parameters);\n\t}\n\tfunction ParticleBasicMaterial(parameters) {\n\t\tconsole.warn('THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial.');\n\t\treturn new PointsMaterial(parameters);\n\t}\n\tfunction ParticleSystemMaterial(parameters) {\n\t\tconsole.warn('THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial.');\n\t\treturn new PointsMaterial(parameters);\n\t}\n\tfunction Vertex(x, y, z) {\n\t\tconsole.warn('THREE.Vertex has been removed. Use THREE.Vector3 instead.');\n\t\treturn new Vector3(x, y, z);\n\t} //\n\n\tfunction DynamicBufferAttribute(array, itemSize) {\n\t\tconsole.warn('THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setUsage( THREE.DynamicDrawUsage ) instead.');\n\t\treturn new BufferAttribute(array, itemSize).setUsage(DynamicDrawUsage);\n\t}\n\tfunction Int8Attribute(array, itemSize) {\n\t\tconsole.warn('THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead.');\n\t\treturn new Int8BufferAttribute(array, itemSize);\n\t}\n\tfunction Uint8Attribute(array, itemSize) {\n\t\tconsole.warn('THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead.');\n\t\treturn new Uint8BufferAttribute(array, itemSize);\n\t}\n\tfunction Uint8ClampedAttribute(array, itemSize) {\n\t\tconsole.warn('THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead.');\n\t\treturn new Uint8ClampedBufferAttribute(array, itemSize);\n\t}\n\tfunction Int16Attribute(array, itemSize) {\n\t\tconsole.warn('THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead.');\n\t\treturn new Int16BufferAttribute(array, itemSize);\n\t}\n\tfunction Uint16Attribute(array, itemSize) {\n\t\tconsole.warn('THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead.');\n\t\treturn new Uint16BufferAttribute(array, itemSize);\n\t}\n\tfunction Int32Attribute(array, itemSize) {\n\t\tconsole.warn('THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead.');\n\t\treturn new Int32BufferAttribute(array, itemSize);\n\t}\n\tfunction Uint32Attribute(array, itemSize) {\n\t\tconsole.warn('THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead.');\n\t\treturn new Uint32BufferAttribute(array, itemSize);\n\t}\n\tfunction Float32Attribute(array, itemSize) {\n\t\tconsole.warn('THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead.');\n\t\treturn new Float32BufferAttribute(array, itemSize);\n\t}\n\tfunction Float64Attribute(array, itemSize) {\n\t\tconsole.warn('THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead.');\n\t\treturn new Float64BufferAttribute(array, itemSize);\n\t} //\n\n\tCurve.create = function (construct, getPoint) {\n\t\tconsole.log('THREE.Curve.create() has been deprecated');\n\t\tconstruct.prototype = Object.create(Curve.prototype);\n\t\tconstruct.prototype.constructor = construct;\n\t\tconstruct.prototype.getPoint = getPoint;\n\t\treturn construct;\n\t}; //\n\n\n\tObject.assign(CurvePath.prototype, {\n\t\tcreatePointsGeometry: function createPointsGeometry(divisions) {\n\t\t\tconsole.warn('THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.'); // generate geometry from path points (for Line or Points objects)\n\n\t\t\tvar pts = this.getPoints(divisions);\n\t\t\treturn this.createGeometry(pts);\n\t\t},\n\t\tcreateSpacedPointsGeometry: function createSpacedPointsGeometry(divisions) {\n\t\t\tconsole.warn('THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.'); // generate geometry from equidistant sampling along the path\n\n\t\t\tvar pts = this.get
1SpacedPoints(divisions);\n\t\t\treturn this.createGeometry(pts);\n\t\t},\n\t\tcreateGeometry: function createGeometry(points) {\n\t\t\tconsole.warn('THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.');\n\t\t\tvar geometry = new Geometry();\n\n\t\t\tfor (var i = 0, l = points.length; i < l; i++) {\n\t\t\t\tvar point = points[i];\n\t\t\t\tgeometry.vertices.push(new Vector3(point.x, point.y, point.z || 0));\n\t\t\t}\n\n\t\t\treturn geometry;\n\t\t}\n\t}); //\n\n\tObject.assign(Path.prototype, {\n\t\tfromPoints: function fromPoints(points) {\n\t\t\tconsole.warn('THREE.Path: .fromPoints() has been renamed to .setFromPoints().');\n\t\t\treturn this.setFromPoints(points);\n\t\t}\n\t}); //\n\n\tfunction ClosedSplineCurve3(points) {\n\t\tconsole.warn('THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.');\n\t\tCatmullRomCurve3.call(this, points);\n\t\tthis.type = 'catmullrom';\n\t\tthis.closed = true;\n\t}\n\tClosedSplineCurve3.prototype = Object.create(CatmullRomCurve3.prototype); //\n\n\tfunction SplineCurve3(points) {\n\t\tconsole.warn('THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.');\n\t\tCatmullRomCurve3.call(this, points);\n\t\tthis.type = 'catmullrom';\n\t}\n\tSplineCurve3.prototype = Object.create(CatmullRomCurve3.prototype); //\n\n\tfunction Spline(points) {\n\t\tconsole.warn('THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead.');\n\t\tCatmullRomCurve3.call(this, points);\n\t\tthis.type = 'catmullrom';\n\t}\n\tSpline.prototype = Object.create(CatmullRomCurve3.prototype);\n\tObject.assign(Spline.prototype, {\n\t\tinitFromArray: function initFromArray()\n\t\t/* a */\n\t\t{\n\t\t\tconsole.error('THREE.Spline: .initFromArray() has been removed.');\n\t\t},\n\t\tgetControlPointsArray: function getControlPointsArray()\n\t\t/* optionalTarget */\n\t\t{\n\t\t\tconsole.error('THREE.Spline: .getControlPointsArray() has been removed.');\n\t\t},\n\t\treparametrizeByArcLength: function reparametrizeByArcLength()\n\t\t/* samplingCoef */\n\t\t{\n\t\t\tconsole.error('THREE.Spline: .reparametrizeByArcLength() has been removed.');\n\t\t}\n\t}); //\n\n\tfunction AxisHelper(size) {\n\t\tconsole.warn('THREE.AxisHelper has been renamed to THREE.AxesHelper.');\n\t\treturn new AxesHelper(size);\n\t}\n\tfunction BoundingBoxHelper(object, color) {\n\t\tconsole.warn('THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead.');\n\t\treturn new BoxHelper(object, color);\n\t}\n\tfunction EdgesHelper(object, hex) {\n\t\tconsole.warn('THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead.');\n\t\treturn new LineSegments(new EdgesGeometry(object.geometry), new LineBasicMaterial({\n\t\t\tcolor: hex !== undefined ? hex : 0xffffff\n\t\t}));\n\t}\n\n\tGridHelper.prototype.setColors = function () {\n\t\tconsole.error('THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.');\n\t};\n\n\tSkeletonHelper.prototype.update = function () {\n\t\tconsole.error('THREE.SkeletonHelper: update() no longer needs to be called.');\n\t};\n\n\tfunction WireframeHelper(object, hex) {\n\t\tconsole.warn('THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead.');\n\t\treturn new LineSegments(new WireframeGeometry(object.geometry), new LineBasicMaterial({\n\t\t\tcolor: hex !== undefined ? hex : 0xffffff\n\t\t}));\n\t} //\n\n\tObject.assign(Loader.prototype, {\n\t\textractUrlBase: function extractUrlBase(url) {\n\t\t\tconsole.warn('THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead.');\n\t\t\treturn LoaderUtils.extractUrlBase(url);\n\t\t}\n\t});\n\tLoader.Handlers = {\n\t\tadd: function add()\n\t\t/* regex, loader */\n\t\t{\n\t\t\tconsole.error('THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.');\n\t\t},\n\t\tget: function get()\n\t\t/* file */\n\t\t{\n\t\t\tconsole.error('THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.');\n\t\t}\n\t};\n\tfunction XHRLoader(manager) {\n\t\tconsole.warn('THREE.XHRLoader has been renamed to THREE.FileLoader.');\n\t\treturn new FileLoader(manager);\n\t}\n\tfunction BinaryTextureLoader(manager) {\n\t\tconsole.warn('THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader.');\n\t\treturn new DataTextureLoader(manager);\n\t} //\n\n\tObject.assign(Box2.prototype, {\n\t\tcenter: function center(optionalTarget) {\n\t\t\tconsole.warn('THREE.Box2: .center() has been renamed to .getCenter().');\n\t\t\treturn this.getCenter(optionalTarget);\n\t\t},\n\t\tempty: function empty() {\n\t\t\tconsole.warn('THREE.Box2: .empty() has been renamed to .isEmpty().');\n\t\t\treturn this.isEmpty();\n\t\t},\n\t\tisIntersectionBox: function isIntersectionBox(box) {\n\t\t\tconsole.warn('THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().');\n\t\t\treturn this.intersectsBox(box);\n\t\t},\n\t\tsize: function size(optionalTarget) {\n\t\t\tconsole.warn('THREE.Box2: .size() has been renamed to .getSize().');
1\n\t\t\treturn this.getSize(optionalTarget);\n\t\t}\n\t});\n\tObject.assign(Box3.prototype, {\n\t\tcenter: function center(optionalTarget) {\n\t\t\tconsole.warn('THREE.Box3: .center() has been renamed to .getCenter().');\n\t\t\treturn this.getCenter(optionalTarget);\n\t\t},\n\t\tempty: function empty() {\n\t\t\tconsole.warn('THREE.Box3: .empty() has been renamed to .isEmpty().');\n\t\t\treturn this.isEmpty();\n\t\t},\n\t\tisIntersectionBox: function isIntersectionBox(box) {\n\t\t\tconsole.warn('THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().');\n\t\t\treturn this.intersectsBox(box);\n\t\t},\n\t\tisIntersectionSphere: function isIntersectionSphere(sphere) {\n\t\t\tconsole.warn('THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().');\n\t\t\treturn this.intersectsSphere(sphere);\n\t\t},\n\t\tsize: function size(optionalTarget) {\n\t\t\tconsole.warn('THREE.Box3: .size() has been renamed to .getSize().');\n\t\t\treturn this.getSize(optionalTarget);\n\t\t}\n\t});\n\tObject.assign(Sphere.prototype, {\n\t\tempty: function empty() {\n\t\t\tconsole.warn('THREE.Sphere: .empty() has been renamed to .isEmpty().');\n\t\t\treturn this.isEmpty();\n\t\t}\n\t});\n\n\tFrustum.prototype.setFromMatrix = function (m) {\n\t\tconsole.warn('THREE.Frustum: .setFromMatrix() has been renamed to .setFromProjectionMatrix().');\n\t\treturn this.setFromProjectionMatrix(m);\n\t};\n\n\tLine3.prototype.center = function (optionalTarget) {\n\t\tconsole.warn('THREE.Line3: .center() has been renamed to .getCenter().');\n\t\treturn this.getCenter(optionalTarget);\n\t};\n\n\tObject.assign(MathUtils, {\n\t\trandom16: function random16() {\n\t\t\tconsole.warn('THREE.Math: .random16() has been deprecated. Use Math.random() instead.');\n\t\t\treturn Math.random();\n\t\t},\n\t\tnearestPowerOfTwo: function nearestPowerOfTwo(value) {\n\t\t\tconsole.warn('THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo().');\n\t\t\treturn MathUtils.floorPowerOfTwo(value);\n\t\t},\n\t\tnextPowerOfTwo: function nextPowerOfTwo(value) {\n\t\t\tconsole.warn('THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo().');\n\t\t\treturn MathUtils.ceilPowerOfTwo(value);\n\t\t}\n\t});\n\tObject.assign(Matrix3.prototype, {\n\t\tflattenToArrayOffset: function flattenToArrayOffset(array, offset) {\n\t\t\tconsole.warn('THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.');\n\t\t\treturn this.toArray(array, offset);\n\t\t},\n\t\tmultiplyVector3: function multiplyVector3(vector) {\n\t\t\tconsole.warn('THREE.Matrix3: .multiplyVector3(
1) has been removed. Use vector.applyMatrix3( matrix ) instead.');\n\t\t\treturn vector.applyMatrix3(this);\n\t\t},\n\t\tmultiplyVector3Array: function multiplyVector3Array()\n\t\t/* a */\n\t\t{\n\t\t\tconsole.error('THREE.Matrix3: .multiplyVector3Array() has been removed.');\n\t\t},\n\t\tapplyToBufferAttribute: function applyToBufferAttribute(attribute) {\n\t\t\tconsole.warn('THREE.Matrix3: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix3( matrix ) instead.');\n\t\t\treturn attribute.applyMatrix3(this);\n\t\t},\n\t\tapplyToVector3Array: function applyToVector3Array()\n\t\t/* array, offset, length */\n\t\t{\n\t\t\tconsole.error('THREE.Matrix3: .applyToVector3Array() has been removed.');\n\t\t},\n\t\tgetInverse: function getInverse(matrix) {\n\t\t\tconsole.warn('THREE.Matrix3: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead.');\n\t\t\treturn this.copy(matrix).invert();\n\t\t}\n\t});\n\tObject.assign(Matrix4.prototype, {\n\t\textractPosition: function extractPosition(m) {\n\t\t\tconsole.warn('THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().');\n\t\t\treturn this.copyPosition(m);\n\t\t},\n\t\tflattenToArrayOffset: function flattenToArrayOffset(array, offset) {\n\t\t\tconsole.warn('THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.');\n\t\t\treturn this.toArray(array, offset);\n\t\t},\n\t\tgetPosition: function getPosition() {\n\t\t\tconsole.warn('THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.');\n\t\t\treturn new Vector3().setFromMatrixColumn(this, 3);\n\t\t},\n\t\tsetRotationFromQuaternion: function setRotationFromQuaternion(q) {\n\t\t\tconsole.warn('THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().');\n\t\t\treturn this.makeRotationFromQuaternion(q);\n\t\t},\n\t\tmultiplyToArray: function multiplyToArray() {\n\t\t\tconsole.warn('THREE.Matrix4: .multiplyToArray() has been removed.');\n\t\t},\n\t\tmultiplyVector3: function multiplyVector3(vector) {\n\t\t\tconsole.warn('THREE.Matrix4: .multiplyVector3(
1) has been removed. Use vector.applyMatrix4( matrix ) instead.');\n\t\t\treturn vector.applyMatrix4(this);\n\t\t},\n\t\tmultiplyVector4: function multiplyVector4(vector) {\n\t\t\tconsole.warn('THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.');\n\t\t\treturn vector.applyMatrix4(this);\n\t\t},\n\t\tmultiplyVector3Array: function multiplyVector3Array()\n\t\t/* a */\n\t\t{\n\t\t\tconsole.error('THREE.Matrix4: .multiplyVector3Array() has been removed.');\n\t\t},\n\t\trotateAxis: function rotateAxis(v) {\n\t\t\tconsole.warn('THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.');\n\t\t\tv.transformDirection(this);\n\t\t},\n\t\tcrossVector: function crossVector(vector) {\n\t\t\tconsole.warn('THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.');\n\t\t\treturn vector.applyMatrix4(this);\n\t\t},\n\t\ttranslate: function translate() {\n\t\t\tconsole.error('THREE.Matrix4: .translate() has been removed.');\n\t\t},\n\t\trotateX: function rotateX() {\n\t\t\tconsole.error('THREE.Matrix4: .rotateX() has been removed.');\n\t\t},\n\t\trotateY: function rotateY() {\n\t\t\tconsole.error('THREE.Matrix4: .rotateY() has been removed.');\n\t\t},\n\t\trotateZ: function rotateZ() {\n\t\t\tconsole.error('THREE.Matrix4: .rotateZ() has been removed.');\n\t\t},\n\t\trotateByAxis: function rotateByAxis() {\n\t\t\tconsole.error('THREE.Matrix4: .rotateByAxis() has been removed.');\n\t\t},\n\t\tapplyToBufferAttribute: function applyToBufferAttribute(attribute) {\n\t\t\tconsole.warn('THREE.Matrix4: .applyToBufferAttribute() has been removed. Use attribute.applyMatrix4( matrix ) instead.');\n\t\t\treturn attribute.applyMatrix4(this);\n\t\t},\n\t\tapplyToVector3Array: function applyToVector3Array()\n\t\t/* array, offset, length */\n\t\t{\n\t\t\tconsole.error('THREE.Matrix4: .applyToVector3Array() has been removed.');\n\t\t},\n\t\tmakeFrustum: function makeFrustum(left, right, bottom, top, near, far) {\n\t\t\tconsole.warn('THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead.');\n\t\t\treturn this.makePerspective(left, right, top, bottom, near, far);\n\t\t},\n\t\tgetInverse: function getInverse(matrix) {\n\t\t\tconsole.warn('THREE.Matrix4: .getInverse() has been removed. Use matrixInv.copy( matrix ).invert(); instead.');\n\t\t\treturn this.copy(matrix).invert();\n\t\t}\n\t});\n\n\tPlane.prototype.isIntersectionLine = function (line) {\n\t\tconsole.warn('THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().');\n\t\treturn this.intersectsLine(line);\n\t};\n\n\tObject.assign(Quaternion.prototype, {\n\t\tmultiplyVector3: function multiplyVector3(vector) {\n\t\t\tconsole.warn('THREE.Quaternion: .multiplyVector3(
1) has been removed. Use is now vector.applyQuaternion( quaternion ) instead.');\n\t\t\treturn vector.applyQuaternion(this);\n\t\t},\n\t\tinverse: function inverse() {\n\t\t\tconsole.warn('THREE.Quaternion: .inverse() has been renamed to invert().');\n\t\t\treturn this.invert();\n\t\t}\n\t});\n\tObject.assign(Ray.prototype, {\n\t\tisIntersectionBox: function isIntersectionBox(box) {\n\t\t\tconsole.warn('THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().');\n\t\t\treturn this.intersectsBox(box);\n\t\t},\n\t\tisIntersectionPlane: function isIntersectionPlane(plane) {\n\t\t\tconsole.warn('THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().');\n\t\t\treturn this.intersectsPlane(plane);\n\t\t},\n\t\tisIntersectionSphere: function isIntersectionSphere(sphere) {\n\t\t\tconsole.warn('THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().');\n\t\t\treturn this.intersectsSphere(sphere);\n\t\t}\n\t});\n\tObject.assign(Triangle.prototype, {\n\t\tarea: function area() {\n\t\t\tconsole.warn('THREE.Triangle: .area() has been renamed to .getArea().');\n\t\t\treturn this.getArea();\n\t\t},\n\t\tbarycoordFromPoint: function barycoordFromPoint(point, target) {\n\t\t\tconsole.warn('THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().');\n\t\t\treturn this.getBarycoord(point, target);\n\t\t},\n\t\tmidpoint: function midpoint(target) {\n\t\t\tconsole.warn('THREE.Triangle: .midpoint() has been renamed to .getMidpoint().');\n\t\t\treturn this.getMidpoint(target);\n\t\t},\n\t\tnormal: function normal(target) {\n\t\t\tconsole.warn('THREE.Triangle: .normal() has been renamed to .getNormal().');\n\t\t\treturn this.getNormal(target);\n\t\t},\n\t\tplane: function plane(target) {\n\t\t\tconsole.warn('THREE.Triangle: .plane() has been renamed to .getPlane().');\n\t\t\treturn this.getPlane(target);\n\t\t}\n\t});\n\tObject.assign(Triangle, {\n\t\tbarycoordFromPoint: function barycoordFromPoint(point, a, b, c, target) {\n\t\t\tconsole.warn('THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().');\n\t\t\treturn Triangle.getBarycoord(point, a, b, c, target);\n\t\t},\n\t\tnormal: function normal(a, b, c, target) {\n\t\t\tconsole.warn('THREE.Triangle: .normal() has been renamed to .getNormal().');\n\t\t\treturn Triangle.getNormal(a, b, c, target);\n\t\t}\n\t});\n\tObject.assign(Shape.prototype, {\n\t\textractAllPoints: function extractAllPoints(divisions) {\n\t\t\tconsole.warn('THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead.');\n\t\t\treturn this.extractPoints(divisions);\n\t\t},\n\t\textrude: function extrude(options) {\n\t\t\tconsole.warn('THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.');\n\t\t\treturn new ExtrudeGeometry(this, options);\n\t\t},\n\t\tmakeGeometry: function makeGeometry(options) {\n\t\t\tconsole.warn('THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.');\n\t\t\treturn new ShapeGeometry(this, options);\n\t\t}\n\t});\n\tObject.assign(Vector2.prototype, {\n\t\tfromAttribute: function fromAttribute(attribute, index, offset) {\n\t\t\tconsole.warn('THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute().');\n\t\t\treturn this.fromBufferAttribute(attribute, index, offset);\n\t\t},\n\t\tdistanceToManhattan: function distanceToManhattan(v) {\n\t\t\tconsole.warn('THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo().');\n\t\t\treturn this.manhattanDistanceTo(v);\n\t\t},\n\t\tlengthManhattan: function lengthManhattan() {\n\t\t\tconsole.warn('THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength().');\n\t\t\treturn this.manhattanLength();\n\t\t}\n\t});\n\tObject.assign(Vector3.prototype, {\n\t\tsetEulerFromRotationMatrix: function setEulerFromRotationMatrix() {\n\t\t\tconsole.error('THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.');\n\t\t},\n\t\tsetEulerFromQuaternion: function setEulerFromQuaternion() {\n\t\t\tconsole.error('THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.');\n\t\t}
1,\n\t\tgetPositionFromMatrix: function getPositionFromMatrix(m) {\n\t\t\tconsole.warn('THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().');\n\t\t\treturn this.setFromMatrixPosition(m);\n\t\t},\n\t\tgetScaleFromMatrix: function getScaleFromMatrix(m) {\n\t\t\tconsole.warn('THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().');\n\t\t\treturn this.setFromMatrixScale(m);\n\t\t},\n\t\tgetColumnFromMatrix: function getColumnFromMatrix(index, matrix) {\n\t\t\tconsole.warn('THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().');\n\t\t\treturn this.setFromMatrixColumn(matrix, index);\n\t\t},\n\t\tapplyProjection: function applyProjection(m) {\n\t\t\tconsole.warn('THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead.');\n\t\t\treturn this.applyMatrix4(m);\n\t\t},\n\t\tfromAttribute: function fromAttribute(attribute, index, offset) {\n\t\t\tconsole.warn('THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute().');\n\t\t\treturn this.fromBufferAttribute(attribute, index, offset);\n\t\t},\n\t\tdistanceToManhattan: function distanceToManhattan(v) {\n\t\t\tconsole.warn('THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo().');\n\t\t\treturn this.manhattanDistanceTo(v);\n\t\t},\n\t\tlengthManhattan: function lengthManhattan() {\n\t\t\tconsole.warn('THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength().');\n\t\t\treturn this.manhattanLength();\n\t\t}\n\t});\n\tObject.assign(Vector4.prototype, {\n\t\tfromAttribute: function fromAttribute(attribute, index, offset) {\n\t\t\tconsole.warn('THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().');\n\t\t\treturn this.fromBufferAttribute(attribute, index, offset);\n\t\t},\n\t\tlengthManhattan: function lengthManhattan() {\n\t\t\tconsole.warn('THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength().');\n\t\t\treturn this.manhattanLength();\n\t\t}\n\t}); //\n\n\tObject.assign(Geometry.prototype, {\n\t\tcomputeTangents: function computeTangents() {\n\t\t\tconsole.error('THREE.Geometry: .computeTangents() has been removed.');\n\t\t},\n\t\tcomputeLineDistances: function computeLineDistances() {\n\t\t\tconsole.error('THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.');\n\t\t},\n\t\tapplyMatrix: function applyMatrix(matrix) {\n\t\t\tconsole.warn('THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4().');\n\t\t\treturn this.applyMatrix4(matrix);\n\t\t}\n\t});\n\tObject.assign(Object3D.prototype, {\n\t\tgetChildByName: function getChildByName(name) {\n\t\t\tconsole.warn('THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().');\n\t\t\treturn this.getObjectByName(name);\n\t\t},\n\t\trenderDepth: function renderDepth() {\n\t\t\tconsole.warn('THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.');\n\t\t},\n\t\ttranslate: function translate(distance, axis) {\n\t\t\tconsole.warn('THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.');\n\t\t\treturn this.translateOnAxis(axis, distance);\n\t\t},\n\t\tgetWorldRotation: function getWorldRotation() {\n\t\t\tconsole.error('THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.');\n\t\t},\n\t\tapplyMatrix: function applyMatrix(matrix) {\n\t\t\tconsole.warn('THREE.Object3D: .applyMatrix() has been renamed to .applyMatrix4().');\n\t\t\treturn this.applyMatrix4(matrix);\n\t\t}\n\t});\n\tObject.defineProperties(Object3D.prototype, {\n\t\teulerOrder: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.Object3D: .eulerOrder is now .rotation.order.');\n\t\t\t\treturn this.rotation.order;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.Object3D: .eulerOrder is now .rotation.order.');\n\t\t\t\tthis.rotation.order = value;\n\t\t\t}\n\t\t},\n\t\tuseQuaternion: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.Object3D: .useQuaternion has been removed. The library n
1ow uses quaternions by default.');\n\t\t\t},\n\t\t\tset: function set() {\n\t\t\t\tconsole.warn('THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.');\n\t\t\t}\n\t\t}\n\t});\n\tObject.assign(Mesh.prototype, {\n\t\tsetDrawMode: function setDrawMode() {\n\t\t\tconsole.error('THREE.Mesh: .setDrawMode() has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.');\n\t\t}\n\t});\n\tObject.defineProperties(Mesh.prototype, {\n\t\tdrawMode: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.error('THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode.');\n\t\t\t\treturn TrianglesDrawMode;\n\t\t\t},\n\t\t\tset: function set() {\n\t\t\t\tconsole.error('THREE.Mesh: .drawMode has been removed. The renderer now always assumes THREE.TrianglesDrawMode. Transform your geometry via BufferGeometryUtils.toTrianglesDrawMode() if necessary.');\n\t\t\t}\n\t\t}\n\t});\n\tObject.defineProperties(LOD.prototype, {\n\t\tobjects: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.LOD: .objects has been renamed to .levels.');\n\t\t\t\treturn this.levels;\n\t\t\t}\n\t\t}\n\t});\n\tObject.defineProperty(Skeleton.prototype, 'useVertexTexture', {\n\t\tget: function get() {\n\t\t\tconsole.warn('THREE.Skeleton: useVertexTexture has been removed.');\n\t\t},\n\t\tset: function set() {\n\t\t\tconsole.warn('THREE.Skeleton: useVertexTexture has been removed.');\n\t\t}\n\t});\n\n\tSkinnedMesh.prototype.initBones = function () {\n\t\tconsole.error('THREE.SkinnedMesh: initBones() has been removed.');\n\t};\n\n\tObject.defineProperty(Curve.prototype, '__arcLengthDivisions', {\n\t\tget: function get() {\n\t\t\tconsole.warn('THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.');\n\t\t\treturn this.arcLengthDivisions;\n\t\t},\n\t\tset: function set(value) {\n\t\t\tconsole.warn('THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.');\n\t\t\tthis.arcLengthDivisions = value;\n\t\t}\n\t}); //\n\n\tPerspectiveCamera.prototype.setLens = function (focalLength, filmGauge) {\n\t\tconsole.warn('THREE.PerspectiveCamera.setLens is deprecated. ' + 'Use .setFocalLength and .filmGauge for a photographic setup.');\n\t\tif (filmGauge !== undefined) this.filmGauge = filmGauge;\n\t\tthis.setFocalLength(focalLength);\n\t}; //\n\n\n\tObject.defineProperties(Light.prototype, {\n\t\tonlyShadow: {\n\t\t\tset: function set() {\n\t\t\t\tconsole.warn('THREE.Light: .onlyShadow has been removed.');\n\t\t\t}\n\t\t},\n\t\tshadowCameraFov: {\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.Light: .shadowCameraFov is now .shadow.camera.fov.');\n\t\t\t\tthis.shadow.camera.fov = value;\n\t\t\t}\n\t\t},\n\t\tshadowCameraLeft: {\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.Light: .shadowCameraLeft is now .shadow.camera.left.');\n\t\t\t\tthis.shadow.camera.left = value;\n\t\t\t}\n\t\t},\n\t\tshadowCameraRight: {\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.Light: .shadowCameraRight is now .shadow.camera.right.');\n\t\t\t\tthis.shadow.camera.right = value;\n\t\t\t}\n\t\t},\n\t\tshadowCameraTop: {\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.Light: .shadowCameraTop is now .shadow.camera.top.');\n\t\t\t\tthis.shadow.camera.top = value;\n\t\t\t}\n\t\t},\n\t\tshadowCameraBottom: {\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.');\n\t\t\t\tthis.shadow.camera.bottom = value;\n\t\t\t}\n\t\t},\n\t\tshadowCameraNear: {\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.Light: .shadowCameraNear is now .shadow.camera.near.');\n\t\t\t\tthis.shadow.camera.near = value;\n\t\t\t}\n\t\t},\n\t\tshadowCameraFar: {\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.Light: .shadowCameraFar is now .shadow.camera.far.');\n\t\t\t\tthis.shadow.camera.far = value;\n\t\t\t}\n\t\t},\n\t\tshadowCameraVisible: {\n\t\t\tset: function set() {\n\t\t\t\tconsole.warn('THREE.Light: .shadowCameraVisible has been removed. Use new THREE.C
1ameraHelper( light.shadow.camera ) instead.');\n\t\t\t}\n\t\t},\n\t\tshadowBias: {\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.Light: .shadowBias is now .shadow.bias.');\n\t\t\t\tthis.shadow.bias = value;\n\t\t\t}\n\t\t},\n\t\tshadowDarkness: {\n\t\t\tset: function set() {\n\t\t\t\tconsole.warn('THREE.Light: .shadowDarkness has been removed.');\n\t\t\t}\n\t\t},\n\t\tshadowMapWidth: {\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.');\n\t\t\t\tthis.shadow.mapSize.width = value;\n\t\t\t}\n\t\t},\n\t\tshadowMapHeight: {\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.');\n\t\t\t\tthis.shadow.mapSize.height = value;\n\t\t\t}\n\t\t}\n\t}); //\n\n\tObject.defineProperties(BufferAttribute.prototype, {\n\t\tlength: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.BufferAttribute: .length has been deprecated. Use .count instead.');\n\t\t\t\treturn this.array.length;\n\t\t\t}\n\t\t},\n\t\tdynamic: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead.');\n\t\t\t\treturn this.usage === DynamicDrawUsage;\n\t\t\t},\n\t\t\tset: function set()\n\t\t\t/* value */\n\t\t\t{\n\t\t\t\tconsole.warn('THREE.BufferAttribute: .dynamic has been deprecated. Use .usage instead.');\n\t\t\t\tthis.setUsage(DynamicDrawUsage);\n\t\t\t}\n\t\t}\n\t});\n\tObject.assign(BufferAttribute.prototype, {\n\t\tsetDynamic: function setDynamic(value) {\n\t\t\tconsole.warn('THREE.BufferAttribute: .setDynamic() has been deprecated. Use .setUsage() instead.');\n\t\t\tthis.setUsage(value === true ? DynamicDrawUsage : StaticDrawUsage);\n\t\t\treturn this;\n\t\t},\n\t\tcopyIndicesArray: function copyIndicesArray()\n\t\t/* indices */\n\t\t{\n\t\t\tconsole.error('THREE.BufferAttribute: .copyIndicesArray() has been removed.');\n\t\t},\n\t\tsetArray: function setArray()\n\t\t/* array */\n\t\t{\n\t\t\tconsole.error('THREE.BufferAttribute: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers');\n\t\t}\n\t});\n\tObject.assign(BufferGeometry.prototype, {\n\t\taddIndex: function addIndex(index) {\n\t\t\tconsole.warn('THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().');\n\t\t\tthis.setIndex(index);\n\t\t},\n\t\taddAttribute: function addAttribute(name, attribute) {\n\t\t\tconsole.warn('THREE.BufferGeometry: .addAttribute() has been renamed to .setAttribute().');\n\n\t\t\tif (!(attribute && attribute.isBufferAttribute) && !(attribute && attribute.isInterleavedBufferAttribute)) {\n\t\t\t\tconsole.warn('THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).');\n\t\t\t\treturn this.setAttribute(name, new BufferAttribute(arguments[1], arguments[2]));\n\t\t\t}\n\n\t\t\tif (name === 'index') {\n\t\t\t\tconsole.warn('THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute.');\n\t\t\t\tthis.setIndex(attribute);\n\t\t\t\treturn this;\n\t\t\t}\n\n\t\t\treturn this.setAttribute(name, attribute);\n\t\t},\n\t\taddDrawCall: function addDrawCall(start, count, indexOffset) {\n\t\t\tif (indexOffset !== undefined) {\n\t\t\t\tconsole.warn('THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.');\n\t\t\t}\n\n\t\t\tconsole.warn('THREE.BufferGeometry: .addDrawCall() is now .addGroup().');\n\t\t\tthis.addGroup(start, count);\n\t\t},\n\t\tclearDrawCalls: function clearDrawCalls() {\n\t\t\tconsole.warn('THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().');\n\t\t\tthis.clearGroups();\n\t\t},\n\t\tcomputeTangents: function computeTangents() {\n\t\t\tconsole.warn('THREE.BufferGeometry: .computeTangents() has been removed.');\n\t\t},\n\t\tcomputeOffsets: function computeOffsets() {\n\t\t\tconsole.warn('THREE.BufferGeometry: .computeOffsets() has been removed.');\n\t\t},\n\t\tremoveAttribute: function removeAttribute(name) {\n\t\t\tconsole.warn('THREE.BufferGeometry: .removeAttribute() has been renamed to .deleteAttribute().');\n\t\t\treturn this.deleteAttribute(name);\n\t\t},\n\t\tapplyMatrix: function applyMatrix(matrix) {\n\t\t\tconsole.warn('THREE.BufferGeometry: .applyM
1atrix() has been renamed to .applyMatrix4().');\n\t\t\treturn this.applyMatrix4(matrix);\n\t\t}\n\t});\n\tObject.defineProperties(BufferGeometry.prototype, {\n\t\tdrawcalls: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.error('THREE.BufferGeometry: .drawcalls has been renamed to .groups.');\n\t\t\t\treturn this.groups;\n\t\t\t}\n\t\t},\n\t\toffsets: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.BufferGeometry: .offsets has been renamed to .groups.');\n\t\t\t\treturn this.groups;\n\t\t\t}\n\t\t}\n\t});\n\tObject.defineProperties(InstancedBufferGeometry.prototype, {\n\t\tmaxInstancedCount: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount.');\n\t\t\t\treturn this.instanceCount;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.InstancedBufferGeometry: .maxInstancedCount has been renamed to .instanceCount.');\n\t\t\t\tthis.instanceCount = value;\n\t\t\t}\n\t\t}\n\t});\n\tObject.defineProperties(Raycaster.prototype, {\n\t\tlinePrecision: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead.');\n\t\t\t\treturn this.params.Line.threshold;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.Raycaster: .linePrecision has been deprecated. Use .params.Line.threshold instead.');\n\t\t\t\tthis.params.Line.threshold = value;\n\t\t\t}\n\t\t}\n\t});\n\tObject.defineProperties(InterleavedBuffer.prototype, {\n\t\tdynamic: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead.');\n\t\t\t\treturn this.usage === DynamicDrawUsage;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.InterleavedBuffer: .length has been deprecated. Use .usage instead.');\n\t\t\t\tthis.setUsage(value);\n\t\t\t}\n\t\t}\n\t});\n\tObject.assign(InterleavedBuffer.prototype, {\n\t\tsetDynamic: function setDynamic(value) {\n\t\t\tconsole.warn('THREE.InterleavedBuffer: .setDynamic() has been deprecated. Use .setUsage() instead.');\n\t\t\tthis.setUsage(value === true ? DynamicDrawUsage : StaticDrawUsage);\n\t\t\treturn this;\n\t\t},\n\t\tsetArray: function setArray()\n\t\t/* array */\n\t\t{\n\t\t\tconsole.error('THREE.InterleavedBuffer: .setArray has been removed. Use BufferGeometry .setAttribute to replace/resize attribute buffers');\n\t\t}\n\t}); //\n\n\tObject.assign(ExtrudeBufferGeometry.prototype, {\n\t\tgetArrays: function getArrays() {\n\t\t\tconsole.error('THREE.ExtrudeBufferGeometry: .getArrays() has been removed.');\n\t\t},\n\t\taddShapeList: function addShapeList() {\n\t\t\tconsole.error('THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.');\n\t\t},\n\t\taddShape: function addShape() {\n\t\t\tconsole.error('THREE.ExtrudeBufferGeometry: .addShape() has been removed.');\n\t\t}\n\t}); //\n\n\tObject.assign(Scene.prototype, {\n\t\tdispose: function dispose() {\n\t\t\tconsole.error('THREE.Scene: .dispose() has been removed.');\n\t\t}\n\t}); //\n\n\tObject.defineProperties(Uniform.prototype, {\n\t\tdynamic: {\n\t\t\tset: function set() {\n\t\t\t\tconsole.warn('THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.');\n\t\t\t}\n\t\t},\n\t\tonUpdate: {\n\t\t\tvalue: function value() {\n\t\t\t\tconsole.warn('THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.');\n\t\t\t\treturn this;\n\t\t\t}\n\t\t}\n\t}); //\n\n\tObject.defineProperties(Material.prototype, {\n\t\twrapAround: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.Material: .wrapAround has been removed.');\n\t\t\t},\n\t\t\tset: function set() {\n\t\t\t\tconsole.warn('THREE.Material: .wrapAround has been removed.');\n\t\t\t}\n\t\t},\n\t\toverdraw: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.Material: .overdraw has been removed.');\n\t\t\t},\n\t\t\tset: function set() {\n\t\t\t\tconsole.warn('THREE.Material: .overdraw has been removed.');\n\t\t\t}\n\t\t},\n\t\twrapRGB: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.Material: .wrapRGB has been removed.');\n\t\t\t\treturn new Color();\n\t\t\t}\n\t\t},\n\t\tshading: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.error('THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.');\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.');\n\t\t\t\tthis.flatShading = value === FlatShading;\n\t\t\t}\n\t\t},\n\t\tstencilMask: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.' + this.type + ': .stencilMask has been removed. Use .stencilFuncMask instead.');\n\t\t\t\treturn this.stencilFuncMask;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.' + this.type + ': .stencilMask has been removed. Use .stencilFuncMask instead.');\n\t\t\t\tthis.stencilFuncMask = value;\n\t\t\t}\n\t\t}\n\t});\n\tObject.defineProperties(MeshPhongMaterial.prototype, {\n\t\tmetal: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.');\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\tset: function set() {\n\t\t\t\tconsole.warn('THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead');\n\t\t\t}\n\t\t}\n\t});\n\tObject.defineProperties(MeshPhysicalMaterial.prototype, {\n\t\ttransparency: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission.');\n\t\t\t\treturn this.transmission;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.MeshPhysicalMaterial: .transparency has been renamed to .transmission.');\n\t\t\t\tthis.transmission = value;\n\t\t\t}\n\t\t}\n\t});\n\tObject.defineProperties(ShaderMaterial.prototype, {\n\t\tderivatives: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.');\n\t\t\t\treturn this.extensions.derivatives;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.');\n\t\t\t\tthis.extensions.derivatives = value;\n\t\t\t}\n\t\t}\n\t}); //\n\n\tObject.assign(WebGLRenderer.prototype, {\n\t\tclearTarget: function clearTarget(renderTarget, color, depth, stencil) {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead.');\n\t\t\tthis.setRenderTarget(renderTarget);\n\t\t\tthis.clear(color, depth, stencil);\n\t\t},\n\t\tanimate: function animate(callback) {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .animate() is now .setAnimationLoop().');\n\t\t\tthis.setAnimationLoop(callback);\n\t\t},\n\t\tgetCurrentRenderTarget: function getCurrentRenderTarget() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget().');\n\t\t\treturn this.getRenderTarget();\n\t\t},\n\t\tgetMaxAnisotropy: function getMaxAnisotropy() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy().');\n\t\t\treturn this.capabilities.getMaxAnisotropy();\n\t\t},\n\t\tgetPrecision: function getPrecision() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision.');\n\t\t\treturn this.capabilities.precision;\n\t\t},\n\t\tresetGLState: function resetGLState() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .resetGLState() is now .state.reset().');\n\t\t\treturn this.state.reset();\n\t\t},\n\t\tsupportsFloatTextures: function supportsFloatTextures() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( \\'OES_texture_float\\' ).');\n\t\t\treturn this.extensions.get('OES_texture_float');\n\t\t},\n\t\tsupportsHalfFloatTextures: function supportsHalfFloatTextures() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( \\'OES_texture_half_float\\' ).');\n\t\t\treturn this.extensions.get('OES_texture_half_float');\n\t\t},\n\t\tsupportsStandardDerivatives: function supportsStandardDerivatives() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( \\'OES_standard_derivatives\\' ).');\n\t\t\treturn this.extensions.get('OES_standard_derivatives');\n\t\t},\n\t\tsupportsCompressedTextureS3TC: function supportsCompressedTextureS3TC() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( \\'WEBGL_compressed_texture_s3tc\\' ).');\n\t\t\treturn this.extensions.get('WEBGL_compressed_texture_s3tc');\n\t\t},\n\t\tsupportsCompressedTexturePVRTC: function supportsCompressedTexturePVRTC() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( \\'WEBGL_compressed_texture_pvrtc\\' ).');\n\t\t\treturn this.extensions.get('WEBGL_compressed_texture_pvrtc');\n\t\t},\n\t\tsupportsBlendMinMax: function supportsBlendMinMax() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( \\'EXT_blend_minmax\\' ).');\n\t\t\treturn this.extensions.get('EXT_blend_minmax');\n\t\t},\n\t\tsupportsVertexTextures: function supportsVertexTextures() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures.');\n\t\t\treturn this.capabilities.vertexTextures;\n\t\t},\n\t\tsupportsInstancedArrays: function supportsInstancedArrays() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( \\'ANGLE_
1instanced_arrays\\' ).');\n\t\t\treturn this.extensions.get('ANGLE_instanced_arrays');\n\t\t},\n\t\tenableScissorTest: function enableScissorTest(boolean) {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().');\n\t\t\tthis.setScissorTest(boolean);\n\t\t},\n\t\tinitMaterial: function initMaterial() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .initMaterial() has been removed.');\n\t\t},\n\t\taddPrePlugin: function addPrePlugin() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .addPrePlugin() has been removed.');\n\t\t},\n\t\taddPostPlugin: function addPostPlugin() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .addPostPlugin() has been removed.');\n\t\t},\n\t\tupdateShadowMap: function updateShadowMap() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .updateShadowMap() has been removed.');\n\t\t},\n\t\tsetFaceCulling: function setFaceCulling() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .setFaceCulling() has been removed.');\n\t\t},\n\t\tallocTextureUnit: function allocTextureUnit() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .allocTextureUnit() has been removed.');\n\t\t},\n\t\tsetTexture: function setTexture() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .setTexture() has been removed.');\n\t\t},\n\t\tsetTexture2D: function setTexture2D() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .setTexture2D() has been removed.');\n\t\t},\n\t\tsetTextureCube: function setTextureCube() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .setTextureCube() has been removed.');\n\t\t},\n\t\tgetActiveMipMapLevel: function getActiveMipMapLevel() {\n\t\t\tconsole.warn('THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel().');\n\t\t\treturn this.getActiveMipmapLevel();\n\t\t}\n\t});\n\tObject.defineProperties(WebGLRenderer.prototype, {\n\t\tshadowMapEnabled: {\n\t\t\tget: function get() {\n\t\t\t\treturn this.shadowMap.enabled;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.');\n\t\t\t\tthis.shadowMap.enabled = value;\n\t\t\t}\n\t\t},\n\t\tshadowMapType: {\n\t\t\tget: function get() {\n\t\t\t\treturn this.shadowMap.type;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.');\n\t\t\t\tthis.shadowMap.type = value;\n\t\t\t}\n\t\t},\n\t\tshadowMapCullFace: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.');\n\t\t\t\treturn undefined;\n\t\t\t},\n\t\t\tset: function set()\n\t\t\t/* value */\n\t\t\t{\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.');\n\t\t\t}\n\t\t},\n\t\tcontext: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .context has been removed. Use .getContext() instead.');\n\t\t\t\treturn this.getContext();\n\t\t\t}\n\t\t},\n\t\tvr: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .vr has been renamed to .xr');\n\t\t\t\treturn this.xr;\n\t\t\t}\n\t\t},\n\t\tgammaInput: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.');\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\tset: function set() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .gammaInput has been removed. Set the encoding for textures via Texture.encoding instead.');\n\t\t\t}\n\t\t},\n\t\tgammaOutput: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead.');\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .gammaOutput has been removed. Set WebGLRenderer.outputEncoding instead.');\n\t\t\t\tthis.outputEncoding = value === true ? sRGBEncoding : LinearEncoding;\n\t\t\t}\n\t\t},\n\t\ttoneMappingWhitePoint: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.');\n\t\t\t\treturn 1.0;\n\t\t\t},\n\t\t\tset: function set() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .toneMappingWhitePoint has been removed.');\n\t\t\t}\n\t\t}\n\t});\n\tObject.defineProperties(WebGLShadowMap.prototype, {\n\t\tcullFace: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.');\n\t\t\t\treturn undefined;\n\t\t\t},\n\t\t\tset: function set()\n\t\t\t/* cullFace */\n\t\t\t{\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.');\n\t\t\t}\n\t\t},\n\t\trenderReverseSided: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.');\n\t\t\t\treturn undefined;\n\t\t\t},\n\t\t\tset: function set() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.');\n\t\t\t}\n\t\t}
1,\n\t\trenderSingleSided: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.');\n\t\t\t\treturn undefined;\n\t\t\t},\n\t\t\tset: function set() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.');\n\t\t\t}\n\t\t}\n\t});\n\tfunction WebGLRenderTargetCube(width, height, options) {\n\t\tconsole.warn('THREE.WebGLRenderTargetCube( width, height, options ) is now WebGLCubeRenderTarget( size, options ).');\n\t\treturn new WebGLCubeRenderTarget(width, options);\n\t} //\n\n\tObject.defineProperties(WebGLRenderTarget.prototype, {\n\t\twrapS: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.');\n\t\t\t\treturn this.texture.wrapS;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.');\n\t\t\t\tthis.texture.wrapS = value;\n\t\t\t}\n\t\t},\n\t\twrapT: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.');\n\t\t\t\treturn this.texture.wrapT;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.');\n\t\t\t\tthis.texture.wrapT = value;\n\t\t\t}\n\t\t},\n\t\tmagFilter: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.');\n\t\t\t\treturn this.texture.magFilter;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.');\n\t\t\t\tthis.texture.magFilter = value;\n\t\t\t}\n\t\t},\n\t\tminFilter: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.');\n\t\t\t\treturn this.texture.minFilter;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.');\n\t\t\t\tthis.texture.minFilter = value;\n\t\t\t}\n\t\t},\n\t\tanisotropy: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.');\n\t\t\t\treturn this.texture.anisotropy;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.');\n\t\t\t\tthis.texture.anisotropy = value;\n\t\t\t}\n\t\t},\n\t\toffset: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .offset is now .texture.offset.');\n\t\t\t\treturn this.texture.offset;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .offset is now .texture.offset.');\n\t\t\t\tthis.texture.offset = value;\n\t\t\t}\n\t\t},\n\t\trepeat: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .repeat is now .texture.repeat.');\n\t\t\t\treturn this.texture.repeat;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .repeat is now .texture.repeat.');\n\t\t\t\tthis.texture.repeat = value;\n\t\t\t}\n\t\t},\n\t\tformat: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .format is now .texture.format.');\n\t\t\t\treturn this.texture.format;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .format is now .texture.format.');\n\t\t\t\tthis.texture.format = value;\n\t\t\t}\n\t\t},\n\t\ttype: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .type is now .texture.type.');\n\t\t\t\treturn this.texture.type;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .type is now .texture.type.');\n\t\t\t\tthis.texture.type = value;\n\t\t\t}\n\t\t},\n\t\tgenerateMipmaps: {\n\t\t\tget: function get() {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.');\n\t\t\t\treturn this.texture.generateMipmaps;\n\t\t\t},\n\t\t\tset: function set(value) {\n\t\t\t\tconsole.warn('THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.');\n\t\t\t\tthis.texture.generateMipmaps = value;\n\t\t\t}\n\t\t}\n\t}); //\n\n\tObject.defineProperties(Audio.prototype, {\n\t\tload: {\n\t\t\tvalue: function value(file) {\n\t\t\t\tconsole.warn('THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.');\n\t\t\t\tvar scope = this;\n\t\t\t\tvar audioLoader = new AudioLoader();\n\t\t\t\taudioLoader.load(file, function (buffer) {\n\t\t\t\t\tscope.setBuffer(buffer);\n\t\t\t\t});\n\t\t\t\treturn this;\n\t\t\t}\n\t\t},\n\t\tstartTime: {\n\t\t\tset: function set() {\n\t\t\t\tconsole.warn('THREE.Audio: .startTime is now .play( delay ).');\n\t\t\t}\n\t\t}\n\t});\n\n\tAudioAnalyser.prototype.getData = function () {\n\t\tconsole.warn('THREE.AudioAnalyser: .getData() is now .getFrequencyData().');\n\t\treturn this.getFrequencyData();\n\t}; //\n\n\n\tCubeCamera.prototype.updateCubeMap = function (renderer, scene) {\n\t\tconsole.warn('THREE.CubeCamera: .updateCubeMap() is now .update(
1).');\n\t\treturn this.update(renderer, scene);\n\t};\n\n\tCubeCamera.prototype.clear = function (renderer, color, depth, stencil) {\n\t\tconsole.warn('THREE.CubeCamera: .clear() is now .renderTarget.clear().');\n\t\treturn this.renderTarget.clear(renderer, color, depth, stencil);\n\t}; //\n\n\n\tvar GeometryUtils = {\n\t\tmerge: function merge(geometry1, geometry2, materialIndexOffset) {\n\t\t\tconsole.warn('THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.');\n\t\t\tvar matrix;\n\n\t\t\tif (geometry2.isMesh) {\n\t\t\t\tgeometry2.matrixAutoUpdate && geometry2.updateMatrix();\n\t\t\t\tmatrix = geometry2.matrix;\n\t\t\t\tgeometry2 = geometry2.geometry;\n\t\t\t}\n\n\t\t\tgeometry1.merge(geometry2, matrix, materialIndexOffset);\n\t\t},\n\t\tcenter: function center(geometry) {\n\t\t\tconsole.warn('THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead.');\n\t\t\treturn geometry.center();\n\t\t}\n\t};\n\tImageUtils.crossOrigin = undefined;\n\n\tImageUtils.loadTexture = function (url, mapping, onLoad, onError) {\n\t\tconsole.warn('THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.');\n\t\tvar loader = new TextureLoader();\n\t\tloader.setCrossOrigin(this.crossOrigin);\n\t\tvar texture = loader.load(url, onLoad, undefined, onError);\n\t\tif (mapping) texture.mapping = mapping;\n\t\treturn texture;\n\t};\n\n\tImageUtils.loadTextureCube = function (urls, mapping, onLoad, onError) {\n\t\tconsole.warn('THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.');\n\t\tvar loader = new CubeTextureLoader();\n\t\tloader.setCrossOrigin(this.crossOrigin);\n\t\tvar texture = loader.load(urls, onLoad, undefined, onError);\n\t\tif (mapping) texture.mapping = mapping;\n\t\treturn texture;\n\t};\n\n\tImageUtils.loadCompressedTexture = function () {\n\t\tconsole.error('THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.');\n\t};\n\n\tImageUtils.loadCompressedTextureCube = function () {\n\t\tconsole.error('THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.');\n\t}; //\n\n\n\tfunction CanvasRenderer() {\n\t\tconsole.error('THREE.CanvasRenderer has been removed');\n\t} //\n\n\tfunction JSONLoader() {\n\t\tconsole.error('THREE.JSONLoader has been removed.');\n\t} //\n\n\tvar SceneUtils = {\n\t\tcreateMultiMaterialObject: function createMultiMaterialObject()\n\t\t/* geometry, materials */\n\t\t{\n\t\t\tconsole.error('THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js');\n\t\t},\n\t\tdetach: function detach()\n\t\t/* child, parent, scene */\n\t\t{\n\t\t\tconsole.error('THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js');\n\t\t},\n\t\tattach: function attach()\n\t\t/* child, scene, parent */\n\t\t{\n\t\t\tconsole.error('THREE.SceneUtils has been moved to /examples/jsm/utils/SceneUtils.js');\n\t\t}\n\t}; //\n\n\tfunction LensFlare() {\n\t\tconsole.error('THREE.LensFlare has been moved to /examples/jsm/objects/Lensflare.js');\n\t}\n\n\tif (typeof __THREE_DEVTOOLS__ !== 'undefined') {\n\t\t/* eslint-disable no-undef */\n\t\t__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent('register', {\n\t\t\tdetail: {\n\t\t\t\trevision: REVISION\n\t\t\t}\n\t\t}));\n\t\t/* eslint-enable no-undef */\n\n\t}\n\n\texports.ACESFilmicToneMapping = ACESFilmicToneMapping;\n\texports.AddEquation = AddEquation;\n\texports.AddOperation = AddOperation;\n\texports.AdditiveAnimationBlendMode = AdditiveAnimationBlendMode;\n\texports.AdditiveBlending = AdditiveBlending;\n\texports.AlphaFormat = AlphaFormat;\n\texports.AlwaysDepth = AlwaysDepth;\n\texports.AlwaysStencilFunc = AlwaysStencilFunc;\n\texports.AmbientLight = AmbientLight;\n\texports.AmbientLightProbe = AmbientLightProbe;\n\texports.AnimationClip = AnimationClip;\n\texports.AnimationLoader = AnimationLoader;\n\texports.AnimationMixer = AnimationMixer;\n\texports.AnimationObjectGroup = AnimationObjectGroup;\n\texports.AnimationUtils = AnimationUtils;
1\n\texports.ArcCurve = ArcCurve;\n\texports.ArrayCamera = ArrayCamera;\n\texports.ArrowHelper = ArrowHelper;\n\texports.Audio = Audio;\n\texports.AudioAnalyser = AudioAnalyser;\n\texports.AudioContext = AudioContext;\n\texports.AudioListener = AudioListener;\n\texports.AudioLoader = AudioLoader;\n\texports.AxesHelper = AxesHelper;\n\texports.AxisHelper = AxisHelper;\n\texports.BackSide = BackSide;\n\texports.BasicDepthPacking = BasicDepthPacking;\n\texports.BasicShadowMap = BasicShadowMap;\n\texports.BinaryTextureLoader = BinaryTextureLoader;\n\texports.Bone = Bone;\n\texports.BooleanKeyframeTrack = BooleanKeyframeTrack;\n\texports.BoundingBoxHelper = BoundingBoxHelper;\n\texports.Box2 = Box2;\n\texports.Box3 = Box3;\n\texports.Box3Helper = Box3Helper;\n\texports.BoxBufferGeometry = BoxBufferGeometry;\n\texports.BoxGeometry = BoxGeometry;\n\texports.BoxHelper = BoxHelper;\n\texports.BufferAttribute = BufferAttribute;\n\texports.BufferGeometry = BufferGeometry;\n\texports.BufferGeometryLoader = BufferGeometryLoader;\n\texports.ByteType = ByteType;\n\texports.Cache = Cache;\n\texports.Camera = Camera;\n\texports.CameraHelper = CameraHelper;\n\texports.CanvasRenderer = CanvasRenderer;\n\texports.CanvasTexture = CanvasTexture;\n\texports.CatmullRomCurve3 = CatmullRomCurve3;\n\texports.CineonToneMapping = CineonToneMapping;\n\texports.CircleBufferGeometry = CircleBufferGeometry;\n\texports.CircleGeometry = CircleGeometry;\n\texports.ClampToEdgeWrapping = ClampToEdgeWrapping;\n\texports.Clock = Clock;\n\texports.ClosedSplineCurve3 = ClosedSplineCurve3;\n\texports.Color = Color;\n\texports.ColorKeyframeTrack = ColorKeyframeTrack;\n\texports.CompressedTexture = CompressedTexture;\n\texports.CompressedTextureLoader = CompressedTextureLoader;\n\texports.ConeBufferGeometry = ConeBufferGeometry;\n\texports.ConeGeometry = ConeGeometry;\n\texports.CubeCamera = CubeCamera;\n\texports.CubeGeometry = BoxGeometry;\n\texports.CubeReflectionMapping = CubeReflectionMapping;\n\texports.CubeRefractionMapping = CubeRefractionMapping;\n\texports.CubeTexture = CubeTexture;\n\texports.CubeTextureLoader = CubeTextureLoader;\n\texports.CubeUVReflectionMapping = CubeUVReflectionMapping;\n\texports.CubeUVRefractionMapping = CubeUVRefractionMapping;\n\texports.CubicBezierCurve = CubicBezierCurve;\n\texports.CubicBezierCurve3 = CubicBezierCurve3;\n\texports.CubicInterpolant = CubicInterpolant;\n\texports.CullFaceBack = CullFaceBack;\n\texports.CullFaceFront = CullFaceFront;\n\texports.CullFaceFrontBack = CullFaceFrontBack;\n\texports.CullFaceNone = CullFaceNone;\n\texports.Curve = Curve;\n\texports.CurvePath = CurvePath;\n\texports.CustomBlending = CustomBlending;\n\texports.CustomToneMapping = CustomToneMapping;\n\texports.CylinderBufferGeometry = CylinderBufferGeometry;\n\texports.CylinderGeometry = CylinderGeometry;\n\texports.Cylindrical = Cylindrical;\n\texports.DataTexture = DataTexture;\n\texports.DataTexture2DArray = DataTexture2DArray;\n\texports.DataTexture3D = DataTexture3D;
1\n\texports.DataTextureLoader = DataTextureLoader;\n\texports.DataUtils = DataUtils;\n\texports.DecrementStencilOp = DecrementStencilOp;\n\texports.DecrementWrapStencilOp = DecrementWrapStencilOp;\n\texports.DefaultLoadingManager = DefaultLoadingManager;\n\texports.DepthFormat = DepthFormat;\n\texports.DepthStencilFormat = DepthStencilFormat;\n\texports.DepthTexture = DepthTexture;\n\texports.DirectionalLight = DirectionalLight;\n\texports.DirectionalLightHelper = DirectionalLightHelper;\n\texports.DiscreteInterpolant = DiscreteInterpolant;\n\texports.DodecahedronBufferGeometry = DodecahedronBufferGeometry;\n\texports.DodecahedronGeometry = DodecahedronGeometry;\n\texports.DoubleSide = DoubleSide;\n\texports.DstAlphaFactor = DstAlphaFactor;\n\texports.DstColorFactor = DstColorFactor;\n\texports.DynamicBufferAttribute = DynamicBufferAttribute;\n\texports.DynamicCopyUsage = DynamicCopyUsage;\n\texports.DynamicDrawUsage = DynamicDrawUsage;\n\texports.DynamicReadUsage = DynamicReadUsage;\n\texports.EdgesGeometry = EdgesGeometry;\n\texports.EdgesHelper = EdgesHelper;\n\texports.EllipseCurve = EllipseCurve;\n\texports.EqualDepth = EqualDepth;\n\texports.EqualStencilFunc = EqualStencilFunc;\n\texports.EquirectangularReflectionMapping = EquirectangularReflectionMapping;\n\texports.EquirectangularRefractionMapping = EquirectangularRefractionMapping;\n\texports.Euler = Euler;\n\texports.EventDispatcher = EventDispatcher;\n\texports.ExtrudeBufferGeometry = ExtrudeBufferGeometry;\n\texports.ExtrudeGeometry = ExtrudeGeometry;\n\texports.Face3 = Face3;\n\texports.Face4 = Face4;\n\texports.FaceColors = FaceColors;\n\texports.FileLoader = FileLoader;\n\texports.FlatShading = FlatShading;\n\texports.Float16BufferAttribute = Float16BufferAttribute;\n\texports.Float32Attribute = Float32Attribute;\n\texports.Float32BufferAttribute = Float32BufferAttribute;\n\texports.Float64Attribute = Float64Attribute;\n\texports.Float64BufferAttribute = Float64BufferAttribute;\n\texports.FloatType = FloatType;\n\texports.Fog = Fog;\n\texports.FogExp2 = FogExp2;\n\texports.Font = Font;\n\texports.FontLoader = FontLoader;\n\texports.FrontSide = FrontSide;\n\texports.Frustum = Frustum;\n\texports.GLBufferAttribute = GLBufferAttribute;\n\texports.GLSL1 = GLSL1;\n\texports.GLSL3 = GLSL3;\n\texports.GammaEncoding = GammaEncoding;\n\texports.Geometry = Geometry;\n\texports.GeometryUtils = GeometryUtils;\n\texports.GreaterDepth = GreaterDepth;\n\texports.GreaterEqualDepth = GreaterEqualDepth;\n\texports.GreaterEqualStencilFunc = GreaterEqualStencilFunc;\n\texports.GreaterStencilFunc = GreaterStencilFunc;\n\texports.GridHelper = GridHelper;\n\texports.Group = Group;\n\texports.HalfFloatType = HalfFloatType;\n\texports.HemisphereLight = HemisphereLight;\n\texports.HemisphereLightHelper = HemisphereLightHelper;\n\texports.HemisphereLightProbe = HemisphereLightProbe;\n\texports.IcosahedronBufferGeometry = IcosahedronBufferGeometry;\n\texports.IcosahedronGeometry = IcosahedronGeometry;\n\texports.ImageBitmapLoader = ImageBitmapLoader;\n\texports.ImageLoader = ImageLoader;\n\texports.ImageUtils = ImageUtils;\n\texports.ImmediateRenderObject = ImmediateRenderObject;\n\texports.IncrementStencilOp = IncrementStencilOp;\n\texports.IncrementWrapStencilOp = IncrementWrapStencilOp;\n\texports.InstancedBufferAttribute = InstancedBufferAttribute;\n\texports.InstancedBufferGeometry = InstancedBufferGeometry;\n\texports.InstancedInterleavedBuffer = InstancedInterleavedBuffer;\n\texports.InstancedMesh = InstancedMesh;\n\texports.Int16Attribute = Int16Attribute;\n\texports.Int16BufferAttribute = Int16BufferAttribute;\n\texports.Int32Attribute = Int32Attribute;\n\texports.Int32BufferAttribute = Int32BufferAttribute;\n\texports.Int8Attribute = Int8Attribute;\n\texports.Int8BufferAttribute = Int8BufferAttribute;\n\texports.IntType = IntType;\n\texports.InterleavedBuffer = InterleavedBuffer;\n\texports.InterleavedBufferAttribute = InterleavedBufferAttribute;\n\texports.Interpolant = Interpolant;\n\texports.InterpolateDiscrete = InterpolateDiscrete;\n\texports.InterpolateLinear = InterpolateLinear;\n\texports.InterpolateSmooth = InterpolateSmooth;
1\n\texports.InvertStencilOp = InvertStencilOp;\n\texports.JSONLoader = JSONLoader;\n\texports.KeepStencilOp = KeepStencilOp;\n\texports.KeyframeTrack = KeyframeTrack;\n\texports.LOD = LOD;\n\texports.LatheBufferGeometry = LatheBufferGeometry;\n\texports.LatheGeometry = LatheGeometry;\n\texports.Layers = Layers;\n\texports.LensFlare = LensFlare;\n\texports.LessDepth = LessDepth;\n\texports.LessEqualDepth = LessEqualDepth;\n\texports.LessEqualStencilFunc = LessEqualStencilFunc;\n\texports.LessStencilFunc = LessStencilFunc;\n\texports.Light = Light;\n\texports.LightProbe = LightProbe;\n\texports.Line = Line;\n\texports.Line3 = Line3;\n\texports.LineBasicMaterial = LineBasicMaterial;\n\texports.LineCurve = LineCurve;\n\texports.LineCurve3 = LineCurve3;\n\texports.LineDashedMaterial = LineDashedMaterial;\n\texports.LineLoop = LineLoop;\n\texports.LinePieces = LinePieces;\n\texports.LineSegments = LineSegments;\n\texports.LineStrip = LineStrip;\n\texports.LinearEncoding = LinearEncoding;\n\texports.LinearFilter = LinearFilter;\n\texports.LinearInterpolant = LinearInterpolant;\n\texports.LinearMipMapLinearFilter = LinearMipMapLinearFilter;\n\texports.LinearMipMapNearestFilter = LinearMipMapNearestFilter;\n\texports.LinearMipmapLinearFilter = LinearMipmapLinearFilter;\n\texports.LinearMipmapNearestFilter = LinearMipmapNearestFilter;\n\texports.LinearToneMapping = LinearToneMapping;\n\texports.Loader = Loader;\n\texports.LoaderUtils = LoaderUtils;\n\texports.LoadingManager = LoadingManager;\n\texports.LogLuvEncoding = LogLuvEncoding;\n\texports.LoopOnce = LoopOnce;\n\texports.LoopPingPong = LoopPingPong;\n\texports.LoopRepeat = LoopRepeat;\n\texports.LuminanceAlphaFormat = LuminanceAlphaFormat;\n\texports.LuminanceFormat = LuminanceFormat;\n\texports.MOUSE = MOUSE;\n\texports.Material = Material;\n\texports.MaterialLoader = MaterialLoader;\n\texports.Math = MathUtils;\n\texports.MathUtils = MathUtils;\n\texports.Matrix3 = Matrix3;\n\texports.Matrix4 = Matrix4;\n\texports.MaxEquation = MaxEquation;\n\texports.Mesh = Mesh;\n\texports.MeshBasicMaterial = MeshBasicMaterial;\n\texports.MeshDepthMaterial = MeshDepthMaterial;\n\texports.MeshDistanceMaterial = MeshDistanceMaterial;\n\texports.MeshFaceMaterial = MeshFaceMaterial;\n\texports.MeshLambertMaterial = MeshLambertMaterial;\n\texports.MeshMatcapMaterial = MeshMatcapMaterial;\n\texports.MeshNormalMaterial = MeshNormalMaterial;\n\texports.MeshPhongMaterial = MeshPhongMaterial;\n\texports.MeshPhysicalMaterial = MeshPhysicalMaterial;\n\texports.MeshStandardMaterial = MeshStandardMaterial;\n\texports.MeshToonMaterial = MeshToonMaterial;\n\texports.MinEquation = MinEquation;\n\texports.MirroredRepeatWrapping = MirroredRepeatWrapping;\n\texports.MixOperation = MixOperation;\n\texports.MultiMaterial = MultiMaterial;\n\texports.MultiplyBlending = MultiplyBlending;\n\texports.MultiplyOperation = MultiplyOperation;\n\texports.NearestFilter = NearestFilter;\n\texports.NearestMipMapLinearFilter = NearestMipMapLinearFilter;\n\texports.NearestMipMapNearestFilter = NearestMipMapNearestFilter;\n\texports.NearestMipmapLinearFilter = NearestMipmapLinearFilter;\n\texports.NearestMipmapNearestFilter = NearestMipmapNearestFilter;\n\texports.NeverDepth = NeverDepth;\n\texports.NeverStencilFunc = NeverStencilFunc;\n\texports.NoBlending = NoBlending;\n\texports.NoColors = NoColors;\n\texports.NoToneMapping = NoToneMapping;\n\texports.NormalAnimationBlendMode = NormalAnimationBlendMode;\n\texports.NormalBlending = NormalBlending;\n\texports.NotEqualDepth = NotEqualDepth;\n\texports.NotEqualStencilFunc = NotEqualStencilFunc;\n\texports.NumberKeyframeTrack = NumberKeyframeTrack;\n\texports.Object3D = Object3D;
1\n\texports.ObjectLoader = ObjectLoader;\n\texports.ObjectSpaceNormalMap = ObjectSpaceNormalMap;\n\texports.OctahedronBufferGeometry = OctahedronBufferGeometry;\n\texports.OctahedronGeometry = OctahedronGeometry;\n\texports.OneFactor = OneFactor;\n\texports.OneMinusDstAlphaFactor = OneMinusDstAlphaFactor;\n\texports.OneMinusDstColorFactor = OneMinusDstColorFactor;\n\texports.OneMinusSrcAlphaFactor = OneMinusSrcAlphaFactor;\n\texports.OneMinusSrcColorFactor = OneMinusSrcColorFactor;\n\texports.OrthographicCamera = OrthographicCamera;\n\texports.PCFShadowMap = PCFShadowMap;\n\texports.PCFSoftShadowMap = PCFSoftShadowMap;\n\texports.PMREMGenerator = PMREMGenerator;\n\texports.ParametricBufferGeometry = ParametricBufferGeometry;\n\texports.ParametricGeometry = ParametricGeometry;\n\texports.Particle = Particle;\n\texports.ParticleBasicMaterial = ParticleBasicMaterial;\n\texports.ParticleSystem = ParticleSystem;\n\texports.ParticleSystemMaterial = ParticleSystemMaterial;\n\texports.Path = Path;\n\texports.PerspectiveCamera = PerspectiveCamera;\n\texports.Plane = Plane;\n\texports.PlaneBufferGeometry = PlaneBufferGeometry;\n\texports.PlaneGeometry = PlaneGeometry;\n\texports.PlaneHelper = PlaneHelper;\n\texports.PointCloud = PointCloud;\n\texports.PointCloudMaterial = PointCloudMaterial;\n\texports.PointLight = PointLight;\n\texports.PointLightHelper = PointLightHelper;\n\texports.Points = Points;\n\texports.PointsMaterial = PointsMaterial;\n\texports.PolarGridHelper = PolarGridHelper;\n\texports.PolyhedronBufferGeometry = PolyhedronBufferGeometry;\n\texports.PolyhedronGeometry = PolyhedronGeometry;\n\texports.PositionalAudio = PositionalAudio;\n\texports.PropertyBinding = PropertyBinding;\n\texports.PropertyMixer = PropertyMixer;\n\texports.QuadraticBezierCurve = QuadraticBezierCurve;\n\texports.QuadraticBezierCurve3 = QuadraticBezierCurve3;\n\texports.Quaternion = Quaternion;\n\texports.QuaternionKeyframeTrack = QuaternionKeyframeTrack;\n\texports.QuaternionLinearInterpolant = QuaternionLinearInterpolant;\n\texports.REVISION = REVISION;\n\texports.RGBADepthPacking = RGBADepthPacking;\n\texports.RGBAFormat = RGBAFormat;\n\texports.RGBAIntegerFormat = RGBAIntegerFormat;\n\texports.RGBA_ASTC_10x10_Format = RGBA_ASTC_10x10_Format;\n\texports.RGBA_ASTC_10x5_Format = RGBA_ASTC_10x5_Format;\n\texports.RGBA_ASTC_10x6_Format = RGBA_ASTC_10x6_Format;\n\texports.RGBA_ASTC_10x8_Format = RGBA_ASTC_10x8_Format;\n\texports.RGBA_ASTC_12x10_Format = RGBA_ASTC_12x10_Format;\n\texports.RGBA_ASTC_12x12_Format = RGBA_ASTC_12x12_Format;\n\texports.RGBA_ASTC_4x4_Format = RGBA_ASTC_4x4_Format;\n\texports.RGBA_ASTC_5x4_Format = RGBA_ASTC_5x4_Format;\n\texports.RGBA_ASTC_5x5_Format = RGBA_ASTC_5x5_Format;\n\texports.RGBA_ASTC_6x5_Format = RGBA_ASTC_6x5_Format;\n\texports.RGBA_ASTC_6x6_Format = RGBA_ASTC_6x6_Format;\n\texports.RGBA_ASTC_8x5_Format = RGBA_ASTC_8x5_Format;\n\texports.RGBA_ASTC_8x6_Format = RGBA_ASTC_8x6_Format;\n\texports.RGBA_ASTC_8x8_Format = RGBA_ASTC_8x8_Format;\n\texports.RGBA_BPTC_Format = RGBA_BPTC_Format;\n\texports.RGBA_ETC2_EAC_Format = RGBA_ETC2_EAC_Format;\n\texports.RGBA_PVRTC_2BPPV1_Format = RGBA_PVRTC_2BPPV1_Format;\n\texports.RGBA_PVRTC_4BPPV1_Format = RGBA_PVRTC_4BPPV1_Format;\n\texports.RGBA_S3TC_DXT1_Format = RGBA_S3TC_DXT1_Format;\n\texports.RGBA_S3TC_DXT3_Format = RGBA_S3TC_DXT3_Format;\n\texports.RGBA_S3TC_DXT5_Format = RGBA_S3TC_DXT5_Format;\n\texports.RGBDEncoding = RGBDEncoding;\n\texports.RGBEEncoding = RGBEEncoding;\n\texports.RGBEFormat = RGBEFormat;\n\texports.RGBFormat = RGBFormat;\n\texports.RGBIntegerFormat = RGBIntegerFormat;\n\texports.RGBM16Encoding = RGBM16Encoding;\n\texports.RGBM7Encoding = RGBM7Encoding;\n\texports.RGB_ETC1_Format = RGB_ETC1_Format;\n\texports.RGB_ETC2_Format = RGB_ETC2_Format;\n\texports.RGB_PVRTC_2BPPV1_Format = RGB_PVRTC_2BPPV1_Format;\n\texports.RGB_PVRTC_4BPPV1_Format = RGB_PVRTC_4BPPV1_Format;\n\texports.RGB_S3TC_DXT1_Format = RGB_S3TC_DXT1_Format;\n\texports.RGFormat = RGFormat;\n\texports.RGIntegerFormat = RGIntegerFormat;\n\texports.RawShaderMaterial = RawShaderMaterial;\n\texports.Ray = Ray;
1\n\texports.Raycaster = Raycaster;\n\texports.RectAreaLight = RectAreaLight;\n\texports.RedFormat = RedFormat;\n\texports.RedIntegerFormat = RedIntegerFormat;\n\texports.ReinhardToneMapping = ReinhardToneMapping;\n\texports.RepeatWrapping = RepeatWrapping;\n\texports.ReplaceStencilOp = ReplaceStencilOp;\n\texports.ReverseSubtractEquation = ReverseSubtractEquation;\n\texports.RingBufferGeometry = RingBufferGeometry;\n\texports.RingGeometry = RingGeometry;\n\texports.SRGB8_ALPHA8_ASTC_10x10_Format = SRGB8_ALPHA8_ASTC_10x10_Format;\n\texports.SRGB8_ALPHA8_ASTC_10x5_Format = SRGB8_ALPHA8_ASTC_10x5_Format;\n\texports.SRGB8_ALPHA8_ASTC_10x6_Format = SRGB8_ALPHA8_ASTC_10x6_Format;\n\texports.SRGB8_ALPHA8_ASTC_10x8_Format = SRGB8_ALPHA8_ASTC_10x8_Format;\n\texports.SRGB8_ALPHA8_ASTC_12x10_Format = SRGB8_ALPHA8_ASTC_12x10_Format;\n\texports.SRGB8_ALPHA8_ASTC_12x12_Format = SRGB8_ALPHA8_ASTC_12x12_Format;\n\texports.SRGB8_ALPHA8_ASTC_4x4_Format = SRGB8_ALPHA8_ASTC_4x4_Format;\n\texports.SRGB8_ALPHA8_ASTC_5x4_Format = SRGB8_ALPHA8_ASTC_5x4_Format;\n\texports.SRGB8_ALPHA8_ASTC_5x5_Format = SRGB8_ALPHA8_ASTC_5x5_Format;\n\texports.SRGB8_ALPHA8_ASTC_6x5_Format = SRGB8_ALPHA8_ASTC_6x5_Format;\n\texports.SRGB8_ALPHA8_ASTC_6x6_Format = SRGB8_ALPHA8_ASTC_6x6_Format;\n\texports.SRGB8_ALPHA8_ASTC_8x5_Format = SRGB8_ALPHA8_ASTC_8x5_Format;\n\texports.SRGB8_ALPHA8_ASTC_8x6_Format = SRGB8_ALPHA8_ASTC_8x6_Format;\n\texports.SRGB8_ALPHA8_ASTC_8x8_Format = SRGB8_ALPHA8_ASTC_8x8_Format;\n\texports.Scene = Scene;\n\texports.SceneUtils = SceneUtils;\n\texports.ShaderChunk = ShaderChunk;\n\texports.ShaderLib = ShaderLib;\n\texports.ShaderMaterial = ShaderMaterial;\n\texports.ShadowMaterial = ShadowMaterial;\n\texports.Shape = Shape;\n\texports.ShapeBufferGeometry = ShapeBufferGeometry;\n\texports.ShapeGeometry = ShapeGeometry;\n\texports.ShapePath = ShapePath;\n\texports.ShapeUtils = ShapeUtils;\n\texports.ShortType = ShortType;\n\texports.Skeleton = Skeleton;\n\texports.SkeletonHelper = SkeletonHelper;\n\texports.SkinnedMesh = SkinnedMesh;\n\texports.SmoothShading = SmoothShading;\n\texports.Sphere = Sphere;\n\texports.SphereBufferGeometry = SphereBufferGeometry;\n\texports.SphereGeometry = SphereGeometry;\n\texports.Spherical = Spherical;\n\texports.SphericalHarmonics3 = SphericalHarmonics3;\n\texports.Spline = Spline;\n\texports.SplineCurve = SplineCurve;\n\texports.SplineCurve3 = SplineCurve3;\n\texports.SpotLight = SpotLight;\n\texports.SpotLightHelper = SpotLightHelper;\n\texports.Sprite = Sprite;\n\texports.SpriteMaterial = SpriteMaterial;\n\texports.SrcAlphaFactor = SrcAlphaFactor;\n\texports.SrcAlphaSaturateFactor = SrcAlphaSaturateFactor;\n\texports.SrcColorFactor = SrcColorFactor;\n\texports.StaticCopyUsage = StaticCopyUsage;\n\texports.StaticDrawUsage = StaticDrawUsage;\n\texports.StaticReadUsage = StaticReadUsage;\n\texports.StereoCamera = StereoCamera;\n\texports.StreamCopyUsage = StreamCopyUsage;\n\texports.StreamDrawUsage = StreamDrawUsage;
1\n\texports.StreamReadUsage = StreamReadUsage;\n\texports.StringKeyframeTrack = StringKeyframeTrack;\n\texports.SubtractEquation = SubtractEquation;\n\texports.SubtractiveBlending = SubtractiveBlending;\n\texports.TOUCH = TOUCH;\n\texports.TangentSpaceNormalMap = TangentSpaceNormalMap;\n\texports.TetrahedronBufferGeometry = TetrahedronBufferGeometry;\n\texports.TetrahedronGeometry = TetrahedronGeometry;\n\texports.TextBufferGeometry = TextBufferGeometry;\n\texports.TextGeometry = TextGeometry;\n\texports.Texture = Texture;\n\texports.TextureLoader = TextureLoader;\n\texports.TorusBufferGeometry = TorusBufferGeometry;\n\texports.TorusGeometry = TorusGeometry;\n\texports.TorusKnotBufferGeometry = TorusKnotBufferGeometry;\n\texports.TorusKnotGeometry = TorusKnotGeometry;\n\texports.Triangle = Triangle;\n\texports.TriangleFanDrawMode = TriangleFanDrawMode;\n\texports.TriangleStripDrawMode = TriangleStripDrawMode;\n\texports.TrianglesDrawMode = TrianglesDrawMode;\n\texports.TubeBufferGeometry = TubeBufferGeometry;\n\texports.TubeGeometry = TubeGeometry;\n\texports.UVMapping = UVMapping;\n\texports.Uint16Attribute = Uint16Attribute;\n\texports.Uint16BufferAttribute = Uint16BufferAttribute;\n\texports.Uint32Attribute = Uint32Attribute;\n\texports.Uint32BufferAttribute = Uint32BufferAttribute;\n\texports.Uint8Attribute = Uint8Attribute;\n\texports.Uint8BufferAttribute = Uint8BufferAttribute;\n\texports.Uint8ClampedAttribute = Uint8ClampedAttribute;\n\texports.Uint8ClampedBufferAttribute = Uint8ClampedBufferAttribute;\n\texports.Uniform = Uniform;\n\texports.UniformsLib = UniformsLib;\n\texports.UniformsUtils = UniformsUtils;\n\texports.UnsignedByteType = UnsignedByteType;\n\texports.UnsignedInt248Type = UnsignedInt248Type;\n\texports.UnsignedIntType = UnsignedIntType;\n\texports.UnsignedShort4444Type = UnsignedShort4444Type;\n\texports.UnsignedShort5551Type = UnsignedShort5551Type;\n\texports.UnsignedShort565Type = UnsignedShort565Type;\n\texports.UnsignedShortType = UnsignedShortType;\n\texports.VSMShadowMap = VSMShadowMap;\n\texports.Vector2 = Vector2;\n\texports.Vector3 = Vector3;\n\texports.Vector4 = Vector4;\n\texports.VectorKeyframeTrack = VectorKeyframeTrack;\n\texports.Vertex = Vertex;\n\texports.VertexColors = VertexColors;\n\texports.VideoTexture = VideoTexture;\n\texports.WebGL1Renderer = WebGL1Renderer;\n\texports.WebGLCubeRenderTarget = WebGLCubeRenderTarget;\n\texports.WebGLMultisampleRenderTarget = WebGLMultisampleRenderTarget;\n\texports.WebGLRenderTarget = WebGLRenderTarget;\n\texports.WebGLRenderTargetCube = WebGLRenderTargetCube;\n\texports.WebGLRenderer = WebGLRenderer;\n\texports.WebGLUtils = WebGLUtils;\n\texports.WireframeGeometry = WireframeGeometry;\n\texports.WireframeHelper = WireframeHelper;\n\texports.WrapAroundEnding = WrapAroundEnding;\n\texports.XHRLoader = XHRLoader;\n\texports.ZeroCurvatureEnding = ZeroCurvatureEnding;\n\texports.ZeroFactor = ZeroFactor;\n\texports.ZeroSlopeEnding = ZeroSlopeEnding;\n\texports.ZeroStencilOp = ZeroStencilOp;\n\texports.sRGBEncoding = sRGBEncoding;\n\n\tObject.defineProperty(exports, '__esModule', { value: true });\n\n})));\n\n <\/script>\n {{tokenData}}\n <style type=\"text/css\">\n body {\n margin: 0;\n padding: 0;\n }\n canvas {\n padding: 0;\n margin: auto;\n display: block;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n }\n </style>\n </head>\n <body>\n {{script}}\n </body>\n</html>",regl:"<html><head>{{prelude}}\n <script>(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n (global.createREGL = factory());\n}(this, (function () { 'use strict';\n\nvar isTypedArray = function (x) {\n return (\n x instanceof Uint8Array ||\n x instanceof Uint16Array ||\n x instanceof Uint32Array ||\n x instanceof Int8Array ||\n x instanceof Int16Array ||\n x instanceof Int32Array ||\n x instanceof Float32Array ||\n x instanceof Float64Array ||\n x instanceof Uint8ClampedArray\n )\n}\n\nvar extend = function (base, opts) {\n var keys = Object.keys(opts)\n for (var i = 0; i < keys.length; ++i) {\n base[keys[i]] = opts[keys[i]]\n }\n return base\n}\n\n// Error checking and parameter validation.\n//\n// Statements for the form `check.someProcedure(...)` get removed by\n// a browserify transform for optimized/minified bundles.\n//\n/* globals atob */\nvar endl = '\\n'\n\n// only used for extracting shader names. if atob not present, then errors\n// will be slightly crappier\nfunction decodeB64 (str) {\n if (typeof atob !== 'undefined') {\n return atob(str)\n }\n return 'base64:' + str\n}\n\nfunction raise (message) {\n var error = new Error('(regl) ' + message)\n console.error(error)\n throw error\n}\n\nfunction check (pred, message) {\n if (!pred) {\n raise(message)\n }\n}\n\nfunction encolon (message) {\n if (message) {\n return ': ' + message\n }\n return ''\n}\n\nfunction checkParameter (param, possibilities, message) {\n if (!(param in possibilities)) {\n raise('unknown parameter (' + param + ')' + encolon(message) +\n '. possible values: ' + Object.keys(possibilities).join())\n }\n}\n\nfunction checkIsTypedArray (data, message) {\n if (!isTypedArray(data)) {\n raise(\n 'invalid parameter type' + encolon(message) +\n '. must be a typed array')\n }\n}\n\nfunction standardTypeEh (value, type) {\n switch (type) {\n case 'number': return typeof value === 'number'\n case 'object': return typeof value === 'object'\n case 'string': return typeof value === 'string'\n case 'boolean': return typeof value === 'boolean'\n case 'function': return typeof value === 'function'\n case 'undefined': return typeof value === 'undefined'\n case 'symbol': return typeof value === 'symbol'\n }\n}\n\nfunction checkTypeOf (value, type, message) {\n if (!standardTypeEh(value, type)) {\n raise(\n 'invalid parameter type' + encolon(message) +\n '. expected ' + type + ', got ' + (typeof value))\n }\n}\n\nfunction checkNonNegativeInt (value, message) {\n if (!((value >= 0) &&\n ((value | 0) === value))) {\n raise('invalid parameter type, (' + value + ')' + encolon(message) +\n '. must be a nonnegative integer')\n }\n}\n\nfunction checkOneOf (value, list, message) {\n if (list.indexOf(value) < 0) {\n raise('invalid value' + encolon(message) + '. must be one of: ' + list)\n }\n}\n\nvar constructorKeys = [\n 'gl',\n 'canvas',\n 'container',\n 'attributes',\n 'pixelRatio',\n 'extensions',\n 'optionalExtensions',\n 'profile',\n 'onDone'\n]\n\nfunction checkConstructor (obj) {\n Object.keys(obj).forEac
1h(function (key) {\n if (constructorKeys.indexOf(key) < 0) {\n raise('invalid regl constructor argument \"' + key + '\". must be one of ' + constructorKeys)\n }\n })\n}\n\nfunction leftPad (str, n) {\n str = str + ''\n while (str.length < n) {\n str = ' ' + str\n }\n return str\n}\n\nfunction ShaderFile () {\n this.name = 'unknown'\n this.lines = []\n this.index = {}\n this.hasErrors = false\n}\n\nfunction ShaderLine (number, line) {\n this.number = number\n this.line = line\n this.errors = []\n}\n\nfunction ShaderError (fileNumber, lineNumber, message) {\n this.file = fileNumber\n this.line = lineNumber\n this.message = message\n}\n\nfunction guessCommand () {\n var error = new Error()\n var stack = (error.stack || error).toString()\n var pat = /compileProcedure.*\\n\\s*at.*\\((.*)\\)/.exec(stack)\n if (pat) {\n return pat[1]\n }\n var pat2 = /compileProcedure.*\\n\\s*at\\s+(.*)(\\n|$)/.exec(stack)\n if (pat2) {\n return pat2[1]\n }\n return 'unknown'\n}\n\nfunction guessCallSite () {\n var error = new Error()\n var stack = (error.stack || error).toString()\n var pat = /at REGLCommand.*\\n\\s+at.*\\((.*)\\)/.exec(stack)\n if (pat) {\n return pat[1]\n }\n var pat2 = /at REGLCommand.*\\n\\s+at\\s+(.*)\\n/.exec(stack)\n if (pat2) {\n return pat2[1]\n }\n return 'unknown'\n}\n\nfunction parseSource (source, command) {\n var lines = source.split('\\n')\n var lineNumber = 1\n var fileNumber = 0\n var files = {\n unknown: new ShaderFile(),\n 0: new ShaderFile()\n }\n files.unknown.name = files[0].name = command || guessCommand()\n files.unknown.lines.push(new ShaderLine(0, ''))\n for (var i = 0; i < lines.length; ++i) {\n var line = lines[i]\n var parts = /^\\s*#\\s*(\\w+)\\s+(.+)\\s*$/.exec(line)\n if (parts) {\n switch (parts[1]) {\n case 'line':\n var lineNumberInfo = /(\\d+)(\\s+\\d+)?/.exec(parts[2])\n if (lineNumberInfo) {\n lineNumber = lineNumberInfo[1] | 0\n if (lineNumberInfo[2]) {\n fileNumber = lineNumberInfo[2] | 0\n if (!(fileNumber in files)) {\n files[fileNumber] = new ShaderFile()\n }\n }\n }\n break\n case 'define':\n var nameInfo = /SHADER_NAME(_B64)?\\s+(.*)$/.exec(parts[2])\n if (nameInfo) {\n files[fileNumber].name = (nameInfo[1]\n ? decodeB64(nameInfo[2])\n : nameInfo[2])\n }\n break\n }\n }\n files[fileNumber].lines.push(new ShaderLine(lineNumber++, line))\n }\n Object.keys(files).forEach(function (fileNumber) {\n var file = files[fileNumber]\n file.lines.forEach(function (line) {\n file.index[line.number] = line\n })\n })\n return files\n}\n\nfunction parseErrorLog (errLog) {\n var result = []\n errLog.split('\\n').forEach(function (errMsg) {\n if (errMsg.length < 5) {\n return\n }\n var parts = /^ERROR:\\s+(\\d+):(\\d+):\\s*(.*)$/.exec(errMsg)\n if (parts) {\n result.push(new ShaderError(\n parts[1] | 0,\n parts[2] | 0,\n parts[3].trim()))\n } else if (errMsg.length > 0) {\n result.push(new ShaderError('unknown', 0, errMsg))\n }\n })\n return result\n}\n\nfunction annotateFiles (files, errors) {\n errors.forEach(function (error) {\n var file = files[error.file]\n if (file) {\n var line = file.index[error.line]\n if (line) {\n line.errors.push(error)\n file.hasErrors = true\n return\n }\n }\n files.unknown.hasErrors = true\n files.unknown.lines[0].errors.push(error)\n })\n}\n\nfunction checkShaderError (gl, shader, source, type, command) {\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n var errLog = gl.getShaderInfoLog(shader)\n var typeName = type === gl.FRAGMENT_SHADER ? 'fragment' : 'vertex'\n checkCommandType(source, 'string', typeName + ' shader source must be a string', command)\n var files = parseSource(source, command)\n var errors = parseErrorLog(errLog)\n annotateFiles(files, errors)\n\n Ob
1ject.keys(files).forEach(function (fileNumber) {\n var file = files[fileNumber]\n if (!file.hasErrors) {\n return\n }\n\n var strings = ['']\n var styles = ['']\n\n function push (str, style) {\n strings.push(str)\n styles.push(style || '')\n }\n\n push('file number ' + fileNumber + ': ' + file.name + '\\n', 'color:red;text-decoration:underline;font-weight:bold')\n\n file.lines.forEach(function (line) {\n if (line.errors.length > 0) {\n push(leftPad(line.number, 4) + '| ', 'background-color:yellow; font-weight:bold')\n push(line.line + endl, 'color:red; background-color:yellow; font-weight:bold')\n\n // try to guess token\n var offset = 0\n line.errors.forEach(function (error) {\n var message = error.message\n var token = /^\\s*'(.*)'\\s*:\\s*(.*)$/.exec(message)\n if (token) {\n var tokenPat = token[1]\n message = token[2]\n switch (tokenPat) {\n case 'assign':\n tokenPat = '='\n break\n }\n offset = Math.max(line.line.indexOf(tokenPat, offset), 0)\n } else {\n offset = 0\n }\n\n push(leftPad('| ', 6))\n push(leftPad('^^^', offset + 3) + endl, 'font-weight:bold')\n push(leftPad('| ', 6))\n push(message + endl, 'font-weight:bold')\n })\n push(leftPad('| ', 6) + endl)\n } else {\n push(leftPad(line.number, 4) + '| ')\n push(line.line + endl, 'color:red')\n }\n })\n if (typeof document !== 'undefined' && !window.chrome) {\n styles[0] = strings.join('%c')\n console.log.apply(console, styles)\n } else {\n console.log(strings.join(''))\n }\n })\n\n check.raise('Error compiling ' + typeName + ' shader, ' + files[0].name)\n }\n}\n\nfunction checkLinkError (gl, program, fragShader, vertShader, command) {\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n var errLog = gl.getProgramInfoLog(program)\n var fragParse = parseSource(fragShader, command)\n var vertParse = parseSource(vertShader, command)\n\n var header = 'Error linking program with vertex shader, \"' +\n vertParse[0].name + '\", and fragment shader \"' + fragParse[0].name + '\"'\n\n if (typeof document !== 'undefined') {\n console.log('%c' + header + endl + '%c' + errLog,\n 'color:red;text-decoration:underline;font-weight:bold',\n 'color:red')\n } else {\n console.log(header + endl + errLog)\n }\n check.raise(header)\n }\n}\n\nfunction saveCommandRef (object) {\n object._commandRef = guessCommand()\n}\n\nfunction saveDrawCommandInfo (opts, uniforms, attributes, stringStore) {\n saveCommandRef(opts)\n\n function id (str) {\n if (str) {\n return stringStore.id(str)\n }\n return 0\n }\n opts._fragId = id(opts.static.frag)\n opts._vertId = id(opts.static.vert)\n\n function addProps (dict, set) {\n Object.keys(set).forEach(function (u) {\n dict[stringStore.id(u)] = true\n })\n }\n\n var uniformSet = opts._uniformSet = {}\n addProps(uniformSet, uniforms.static)\n addProps(uniformSet, uniforms.dynamic)\n\n var attributeSet = opts._attributeSet = {}\n addProps(attributeSet, attributes.static)\n addProps(attributeSet, attributes.dynamic)\n\n opts._hasCount = (\n 'count' in opts.static ||\n 'count' in opts.dynamic ||\n 'elements' in opts.static ||\n 'elements' in opts.dynamic)\n}\n\nfunction commandRaise (message, command) {\n var callSite = guessCallSite()\n raise(message +\n ' in command ' + (command || guessCommand()) +\n (callSite === 'unknown' ? '' : ' called from ' + callSite))\n}\n\nfunction checkCommand (pred, message, command) {\n if (!pred) {\n commandRaise(message, command || guessCommand())\n }\n}\n\nfunction checkParameterCommand (param, possibilities, message, command) {\n if (!(param in possibilities)) {\n commandRaise(\n 'unknown parameter (' + param + ')' + encolon(message) +\n '. possible values: ' + Object.keys(possibilities).join(),\n command || guessCommand())\n }\n}\n\nfunction checkCommandType (value, type, message, command) {\n if (!standardTypeEh(value, type)) {\n commandRaise(\n 'invalid parameter type' + encolon(message) +\n '. expected ' + type + ', got ' + (typeof value),\n command || guessCommand())\n }\n}\n\nfunction checkOptional (block) {\n block()\n}\n\nfunction checkFramebufferFormat (attachment, texFormats, rbFormats) {\n if (attachment.texture) {\n checkOneOf(\n attachment.texture._texture.internalformat,\n texFormats,\n 'unsupported texture format for attachment')\n } else {\n checkOneOf(\n attachment.renderbuffer._renderbuffer.format,\n rbFormats,\n 'unsupported renderbuffer format for attachment')\n }\n}
1\n\nvar GL_CLAMP_TO_EDGE = 0x812F\n\nvar GL_NEAREST = 0x2600\nvar GL_NEAREST_MIPMAP_NEAREST = 0x2700\nvar GL_LINEAR_MIPMAP_NEAREST = 0x2701\nvar GL_NEAREST_MIPMAP_LINEAR = 0x2702\nvar GL_LINEAR_MIPMAP_LINEAR = 0x2703\n\nvar GL_BYTE = 5120\nvar GL_UNSIGNED_BYTE = 5121\nvar GL_SHORT = 5122\nvar GL_UNSIGNED_SHORT = 5123\nvar GL_INT = 5124\nvar GL_UNSIGNED_INT = 5125\nvar GL_FLOAT = 5126\n\nvar GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033\nvar GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034\nvar GL_UNSIGNED_SHORT_5_6_5 = 0x8363\nvar GL_UNSIGNED_INT_24_8_WEBGL = 0x84FA\n\nvar GL_HALF_FLOAT_OES = 0x8D61\n\nvar TYPE_SIZE = {}\n\nTYPE_SIZE[GL_BYTE] =\nTYPE_SIZE[GL_UNSIGNED_BYTE] = 1\n\nTYPE_SIZE[GL_SHORT] =\nTYPE_SIZE[GL_UNSIGNED_SHORT] =\nTYPE_SIZE[GL_HALF_FLOAT_OES] =\nTYPE_SIZE[GL_UNSIGNED_SHORT_5_6_5] =\nTYPE_SIZE[GL_UNSIGNED_SHORT_4_4_4_4] =\nTYPE_SIZE[GL_UNSIGNED_SHORT_5_5_5_1] = 2\n\nTYPE_SIZE[GL_INT] =\nTYPE_SIZE[GL_UNSIGNED_INT] =\nTYPE_SIZE[GL_FLOAT] =\nTYPE_SIZE[GL_UNSIGNED_INT_24_8_WEBGL] = 4\n\nfunction pixelSize (type, channels) {\n if (type === GL_UNSIGNED_SHORT_5_5_5_1 ||\n type === GL_UNSIGNED_SHORT_4_4_4_4 ||\n type === GL_UNSIGNED_SHORT_5_6_5) {\n return 2\n } else if (type === GL_UNSIGNED_INT_24_8_WEBGL) {\n return 4\n } else {\n return TYPE_SIZE[type] * channels\n }\n}\n\nfunction isPow2 (v) {\n return !(v & (v - 1)) && (!!v)\n}\n\nfunction checkTexture2D (info, mipData, limits) {\n var i\n var w = mipData.width\n var h = mipData.height\n var c = mipData.channels\n\n // Check texture shape\n check(w > 0 && w <= limits.maxTextureSize &&\n h > 0 && h <= limits.maxTextureSize,\n 'invalid texture shape')\n\n // check wrap mode\n if (info.wrapS !== GL_CLAMP_TO_EDGE || info.wrapT !== GL_CLAMP_TO_EDGE) {\n check(isPow2(w) && isPow2(h),\n 'incompatible wrap mode for texture, both width and height must be power of 2')\n }\n\n if (mipData.mipmask === 1) {\n if (w !== 1 && h !== 1) {\n check(\n info.minFilter !== GL_NEAREST_MIPMAP_NEAREST &&\n info.minFilter !== GL_NEAREST_MIPMAP_LINEAR &&\n info.minFilter !== GL_LINEAR_MIPMAP_NEAREST &&\n info.minFilter !== GL_LINEAR_MIPMAP_LINEAR,\n 'min filter requires mipmap')\n }\n } else {\n // texture must be power of 2\n check(isPow2(w) && isPow2(h),\n 'texture must be a square power of 2 to support mipmapping')\n check(mipData.mipmask === (w << 1) - 1,\n 'missing or incomplete mipmap data')\n }\n\n if (mipData.type === GL_FLOAT) {\n if (limits.extensions.indexOf('oes_texture_float_linear') < 0) {\n check(info.minFilter === GL_NEAREST && info.magFilter === GL_NEAREST,\n 'filter not supported, must enable oes_texture_float_linear')\n }\n check(!info.genMipmaps,\n 'mipmap generation not supported with float textures')\n }\n\n // check image complete\n var mipimages = mipData.images\n for (i = 0; i < 16; ++i) {\n if (mipimages[i]) {\n var mw = w >> i\n var mh = h >> i\n check(mipData.mipmask & (1 << i), 'missing mipmap data')\n\n var img = mipimages[i]\n\n check(\n img.width === mw &&\n img.height === mh,\n 'invalid shape for mip images')\n\n check(\n img.format === mipData.format &&\n img.internalformat === mipData.internalformat &&\n img.type === mipData.type,\n 'incompatible type for mip image')\n\n if (img.compressed) {\n // TODO: check size for compressed images\n } else if (img.data) {\n // check(img.data.byteLength === mw * mh *\n // Math.max(pixelSize(img.type, c), img.unpackAlignment),\n var rowSize = Math.ceil(pixelSize(img.type, c) * mw / img.unpackAlignment) * img.unpackAlignment\n check(img.data.byteLength === rowSize * mh,\n 'invalid data for image, buffer size is inconsistent with image format')\n } else if (img.element) {\n // TODO: check element can be loaded\n } else if (img.copy) {\n // TODO: check compatible format and type\n }\n } else if (!info.genMipmaps) {\n check((mipData.mipmask & (1 << i)) === 0, 'extra mipmap data')\n }\n }\n\n if (mipData.compressed) {\n check(!info.genMipmaps,\n 'mipmap generation for compressed images not supported')\n }\n}\n\nfunction checkTextureCube (texture, info, faces, limits) {\n var w = texture.width\n var h
1= texture.height\n var c = texture.channels\n\n // Check texture shape\n check(\n w > 0 && w <= limits.maxTextureSize && h > 0 && h <= limits.maxTextureSize,\n 'invalid texture shape')\n check(\n w === h,\n 'cube map must be square')\n check(\n info.wrapS === GL_CLAMP_TO_EDGE && info.wrapT === GL_CLAMP_TO_EDGE,\n 'wrap mode not supported by cube map')\n\n for (var i = 0; i < faces.length; ++i) {\n var face = faces[i]\n check(\n face.width === w && face.height === h,\n 'inconsistent cube map face shape')\n\n if (info.genMipmaps) {\n check(!face.compressed,\n 'can not generate mipmap for compressed textures')\n check(face.mipmask === 1,\n 'can not specify mipmaps and generate mipmaps')\n } else {\n // TODO: check mip and filter mode\n }\n\n var mipmaps = face.images\n for (var j = 0; j < 16; ++j) {\n var img = mipmaps[j]\n if (img) {\n var mw = w >> j\n var mh = h >> j\n check(face.mipmask & (1 << j), 'missing mipmap data')\n check(\n img.width === mw &&\n img.height === mh,\n 'invalid shape for mip images')\n check(\n img.format === texture.format &&\n img.internalformat === texture.internalformat &&\n img.type === texture.type,\n 'incompatible type for mip image')\n\n if (img.compressed) {\n // TODO: check size for compressed images\n } else if (img.data) {\n check(img.data.byteLength === mw * mh *\n Math.max(pixelSize(img.type, c), img.unpackAlignment),\n 'invalid data for image, buffer size is inconsistent with image format')\n } else if (img.element) {\n // TODO: check element can be loaded\n } else if (img.copy) {\n // TODO: check compatible format and type\n }\n }\n }\n }\n}\n\nvar check$1 = extend(check, {\n optional: checkOptional,\n raise: raise,\n commandRaise: commandRaise,\n command: checkCommand,\n parameter: checkParameter,\n commandParameter: checkParameterCommand,\n constructor: checkConstructor,\n type: checkTypeOf,\n commandType: checkCommandType,\n isTypedArray: checkIsTypedArray,\n nni: checkNonNegativeInt,\n oneOf: checkOneOf,\n shaderError: checkShaderError,\n linkError: checkLinkError,\n callSite: guessCallSite,\n saveCommandRef: saveCommandRef,\n saveDrawInfo: saveDrawCommandInfo,\n framebufferFormat: checkFramebufferFormat,\n guessCommand: guessCommand,\n texture2D: checkTexture2D,\n textureCube: checkTextureCube\n});\n\nvar VARIABLE_COUNTER = 0\n\nvar DYN_FUNC = 0\nvar DYN_CONSTANT = 5\nvar DYN_ARRAY = 6\n\nfunction DynamicVariable (type, data) {\n this.id = (VARIABLE_COUNTER++)\n this.type = type\n this.data = data\n}\n\nfunction escapeStr (str) {\n return str.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')\n}\n\nfunction splitParts (str) {\n if (str.length === 0) {\n return []\n }\n\n var firstChar = str.charAt(0)\n var lastChar = str.charAt(str.length - 1)\n\n if (str.length > 1 &&\n firstChar === lastChar &&\n (firstChar === '\"' || firstChar === \"'\")) {\n return ['\"' + escapeStr(str.substr(1, str.length - 2)) + '\"']\n }\n\n var parts = /\\[(false|true|null|\\d+|'[^']*'|\"[^\"]*\")\\]/.exec(str)\n if (parts) {\n return (\n splitParts(str.substr(0, parts.index))\n .concat(splitParts(parts[1]))\n .concat(splitParts(str.substr(parts.index + parts[0].length)))\n )\n }\n\n var subparts = str.split('.')\n if (subparts.length === 1) {\n return ['\"' + escapeStr(str) + '\"']\n }\n\n var result = []\n for (var i = 0; i < subparts.length; ++i) {\n result = result.concat(splitParts(subparts[i]))\n }\n return result\n}\n\nfunction toAccessorString (str) {\n return '[' + splitParts(str).join('][') + ']'\n}\n\nfunction defineDynamic (type, data) {\n return new DynamicVariable(type, toAccessorString(data + ''))\n}\n\nfunction isDynamic (x) {\n return (typeof x === 'function' && !x._reglType) || (x instanceof DynamicVariable)\n}\n\nfunction unbox (x, path) {\n if (typeof x === 'function') {\n return new DynamicVariable(DYN_FUNC, x)\n } else if (typeof x === 'number' || typeof x === 'boolean') {\n return new DynamicVariable(DYN_CONSTANT, x)\n } else if (Array.isArray(x)) {\n return new DynamicVariable(DYN_ARRAY, x.map(function (y, i) { return unbox(y, path + '[' + i + ']') }))\n } else if (x instanceof DynamicVariable) {\n return x\n }\n check$1(false, 'invalid option type in uniform ' + path)\n}\n\nvar dynamic = {\n DynamicVariable: DynamicVariable,\n define: defineDynamic,\n isDynamic: isDynamic,\n unbox: unbox,\n accessor: toAccessorString\n};\n\n/* globals requestAnimationFrame, cancelAnimationFrame */\nvar raf = {\n next: typeof requestAnimationFrame === 'function'\n ? function (cb) { return requestAnimationFrame(cb) }\n : function (cb) { return setTimeout(cb, 16) },\n cancel: typeof cancelAnimationFrame === 'function'\n ? function (raf) { return cancelAnimationFrame(raf) }\n : clearTimeout\n};\n\n/* globals performance */\nvar clock = (typeof performance !== 'undefined' && performance.now)\n ? function () { return performance.now() }\n : function () { return +(new Date()) };\n\nfunction createStringStore () {\n var stringIds = { '': 0 }\n var stringValues = ['']\n return {\n id: function (str) {\n var result = stringIds[str]\n if (result) {\n return result\n }\n result = stringIds[str] = stringValues.length\n str
1ingValues.push(str)\n return result\n },\n\n str: function (id) {\n return stringValues[id]\n }\n }\n}\n\n// Context and canvas creation helper functions\nfunction createCanvas (element, onDone, pixelRatio) {\n var canvas = document.createElement('canvas')\n extend(canvas.style, {\n border: 0,\n margin: 0,\n padding: 0,\n top: 0,\n left: 0,\n width: '100%',\n height: '100%'\n })\n element.appendChild(canvas)\n\n if (element === document.body) {\n canvas.style.position = 'absolute'\n extend(element.style, {\n margin: 0,\n padding: 0\n })\n }\n\n function resize () {\n var w = window.innerWidth\n var h = window.innerHeight\n if (element !== document.body) {\n var bounds = canvas.getBoundingClientRect()\n w = bounds.right - bounds.left\n h = bounds.bottom - bounds.top\n }\n canvas.width = pixelRatio * w\n canvas.height = pixelRatio * h\n }\n\n var resizeObserver\n if (element !== document.body && typeof ResizeObserver === 'function') {\n // ignore 'ResizeObserver' is not defined\n // eslint-disable-next-line\n resizeObserver = new ResizeObserver(function () {\n // setTimeout to avoid flicker\n setTimeout(resize)\n })\n resizeObserver.observe(element)\n } else {\n window.addEventListener('resize', resize, false)\n }\n\n function onDestroy () {\n if (resizeObserver) {\n resizeObserver.disconnect()\n } else {\n window.removeEventListener('resize', resize)\n }\n element.removeChild(canvas)\n }\n\n resize()\n\n return {\n canvas: canvas,\n onDestroy: onDestroy\n }\n}\n\nfunction createContext (canvas, contextAttributes) {\n function get (name) {\n try {\n return canvas.getContext(name, contextAttributes)\n } catch (e) {\n return null\n }\n }\n return (\n get('webgl') ||\n get('experimental-webgl') ||\n get('webgl-experimental')\n )\n}\n\nfunction isHTMLElement (obj) {\n return (\n typeof obj.nodeName === 'string' &&\n typeof obj.appendChild === 'function' &&\n typeof obj.getBoundingClientRect === 'function'\n )\n}\n\nfunction isWebGLContext (obj) {\n return (\n typeof obj.drawArrays === 'function' ||\n typeof obj.drawElements === 'function'\n )\n}\n\nfunction parseExtensions (input) {\n if (typeof input === 'string') {\n return input.split()\n }\n check$1(Array.isArray(input), 'invalid extension array')\n return input\n}\n\nfunction getElement (desc) {\n if (typeof desc === 'string') {\n check$1(typeof document !== 'undefined', 'not supported outside of DOM')\n return document.querySelector(desc)\n }\n return desc\n}\n\nfunction parseArgs (args_) {\n var args = args_ || {}\n var element, container, canvas, gl\n var contextAttributes = {}\n var extensions = []\n var optionalExtensions = []\n var pixelRatio = (typeof window === 'undefined' ? 1 : window.devicePixelRatio)\n var profile = false\n var onDone = function (err) {\n if (err) {\n check$1.raise(err)\n }\n }\n var onDestroy = function () {}\n if (typeof args === 'string') {\n check$1(\n typeof document !== 'undefined',\n 'selector queries only supported in DOM enviroments')\n element = document.querySelector(args)\n check$1(element, 'invalid query string for element')\n } else if (typeof args === 'object') {\n if (isHTMLElement(args)) {\n element = args\n } else if (isWebGLContext(args)) {\n gl = args\n canvas = gl.canvas\n } else {\n check$1.constructor(args)\n if ('gl' in args) {\n gl = args.gl\n } else if ('canvas' in args) {\n canvas = getElement(args.canvas)\n } else if ('container' in args) {\n container = getElement(args.container)\n }\n if ('attributes' in args) {\n contextAttributes = args.attributes\n check$1.type(contextAttributes, 'object', 'invalid context attributes')\n }\n if ('extensions' in args) {\n extensions = parseExtensions(args.extensions)\n }\n if ('optionalExtensions' in args) {\n optionalExtensions = parseExtensions(args.optionalExtensions)\n }\n if ('onDone' in args) {\n check$1.type(\n args.onDone, 'function',\n 'invalid or missing onDone callback')\n onDone = args.onDone\n }\n if ('profile' in args) {\n profile = !!args.profile\n }\n if ('pixelRatio' in args) {\n pixelRatio = +args.pixelRatio\n check$1(pixelRatio > 0, 'invalid pixel ratio')\n }\n }\n } else {\n check$1.raise('invalid arguments to regl')\n }\n\n if (element) {\n if (element.nodeName.toLowerCase() === 'canvas') {\n canvas = element\n } else {\n container = element\n }\n }\n\n if (!gl) {\n if (!canvas) {\n check$1(\n typeof document !== 'undefined',\n 'must manually specify webgl context outside of DOM environments')\n var result = createCanvas(container || document.body, onDone, pixelRatio)\n if (!result) {\n return null\n }\n canvas = result.canvas\n onDestroy = result.onDestroy\n }\n // workaround for chromium bug, premultiplied alpha value is platform dependent\n if (contextAttributes.premultipliedAlpha === undefined) contextAttributes.premultipliedAlpha = true\n gl = createContext(canvas, contextAttributes)\n }\n\n if (!gl) {\n onDestroy()\n onDone('webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org')\n return null\n }\n\n return {\n gl: gl,\n canvas: canvas,\n container: container,\n extensions: extensions,\n optionalExtensions: optionalExtensions,\n pixelRatio: pixelRatio,\n profile: profile,\n onDone: onDone,\n onDestroy: onDestroy\n }\n}\n\nfunction createExtensionCache (gl, config) {\n var extensions = {}\n\n function tryLoadExtension (name_) {\n check$1.type(name_, 'string', 'extension name must be string')\n var name = name_.toLowerCase()\n var ext\n try {\n ext = extensions[name] = gl.getExtension(name)\n } catch (e) {}\n return !!ext\n }\n\n for (var i = 0; i < config.extensions.length; ++i) {\n var name = config.extensions[i]\n if (!tryLoadExtension(name)) {\
1n config.onDestroy()\n config.onDone('\"' + name + '\" extension is not supported by the current WebGL context, try upgrading your system or a different browser')\n return null\n }\n }\n\n config.optionalExtensions.forEach(tryLoadExtension)\n\n return {\n extensions: extensions,\n restore: function () {\n Object.keys(extensions).forEach(function (name) {\n if (extensions[name] && !tryLoadExtension(name)) {\n throw new Error('(regl): error restoring extension ' + name)\n }\n })\n }\n }\n}\n\nfunction loop (n, f) {\n var result = Array(n)\n for (var i = 0; i < n; ++i) {\n result[i] = f(i)\n }\n return result\n}\n\nvar GL_BYTE$1 = 5120\nvar GL_UNSIGNED_BYTE$2 = 5121\nvar GL_SHORT$1 = 5122\nvar GL_UNSIGNED_SHORT$1 = 5123\nvar GL_INT$1 = 5124\nvar GL_UNSIGNED_INT$1 = 5125\nvar GL_FLOAT$2 = 5126\n\nfunction nextPow16 (v) {\n for (var i = 16; i <= (1 << 28); i *= 16) {\n if (v <= i) {\n return i\n }\n }\n return 0\n}\n\nfunction log2 (v) {\n var r, shift\n r = (v > 0xFFFF) << 4\n v >>>= r\n shift = (v > 0xFF) << 3\n v >>>= shift; r |= shift\n shift = (v > 0xF) << 2\n v >>>= shift; r |= shift\n shift = (v > 0x3) << 1\n v >>>= shift; r |= shift\n return r | (v >> 1)\n}\n\nfunction createPool () {\n var bufferPool = loop(8, function () {\n return []\n })\n\n function alloc (n) {\n var sz = nextPow16(n)\n var bin = bufferPool[log2(sz) >> 2]\n if (bin.length > 0) {\n return bin.pop()\n }\n return new ArrayBuffer(sz)\n }\n\n function free (buf) {\n bufferPool[log2(buf.byteLength) >> 2].push(buf)\n }\n\n function allocType (type, n) {\n var result = null\n switch (type) {\n case GL_BYTE$1:\n result = new Int8Array(alloc(n), 0, n)\n break\n case GL_UNSIGNED_BYTE$2:\n result = new Uint8Array(alloc(n), 0, n)\n break\n case GL_SHORT$1:\n result = new Int16Array(alloc(2 * n), 0, n)\n break\n case GL_UNSIGNED_SHORT$1:\n result = new Uint16Array(alloc(2 * n), 0, n)\n break\n case GL_INT$1:\n result = new Int32Array(alloc(4 * n), 0, n)\n break\n case GL_UNSIGNED_INT$1:\n result = new Uint32Array(alloc(4 * n), 0, n)\n break\n case GL_FLOAT$2:\n result = new Float32Array(alloc(4 * n), 0, n)\n break\n default:\n return null\n }\n if (result.length !== n) {\n return result.subarray(0, n)\n }\n return result\n }\n\n function freeType (array) {\n free(array.buffer)\n }\n\n return {\n alloc: alloc,\n free: free,\n allocType: allocType,\n freeType: freeType\n }\n}\n\nvar pool = createPool()\n\n// zero pool for initial zero data\npool.zero = createPool()\n\nvar GL_SUBPIXEL_BITS = 0x0D50\nvar GL_RED_BITS = 0x0D52\nvar GL_GREEN_BITS = 0x0D53\nvar GL_BLUE_BITS = 0x0D54\nvar GL_ALPHA_BITS = 0x0D55\nvar GL_DEPTH_BITS = 0x0D56\nvar GL_STENCIL_BITS = 0x0D57\n\nvar GL_ALIASED_POINT_SIZE_RANGE = 0x846D\nvar GL_ALIASED_LINE_WIDTH_RANGE = 0x846E\n\nvar GL_MAX_TEXTURE_SIZE = 0x0D33\nvar GL_MAX_VIEWPORT_DIMS = 0x0D3A\nvar GL_MAX_VERTEX_ATTRIBS = 0x8869\nvar GL_MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB\nvar GL_MAX_VARYING_VECTORS = 0x8DFC\nvar GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D\nvar GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C\nvar GL_MAX_TEXTURE_IMAGE_UNITS = 0x8872\nvar GL_MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD\nvar GL_MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C\nvar GL_MAX_RENDERBUFFER_SIZE = 0x84E8\n\nvar GL_VENDOR = 0x1F00\nvar GL_RENDERER = 0x1F01\nvar GL_VERSION = 0x1F02\nvar GL_SHADING_LANGUAGE_VERSION = 0x8B8C\n\nvar GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF\n\nvar GL_MAX_COLOR_ATTACHMENTS_WEBGL = 0x8CDF\nvar GL_MAX_DRAW_BUFFERS_WEBGL = 0x8824\n\nvar GL_TEXTURE_2D = 0x0DE1\nvar GL_TEXTURE_CUBE_MAP = 0x8513\nvar GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515\nvar GL_TEXTURE0 = 0x84C0\nvar GL_RGBA = 0x1908\nvar GL_FLOAT$1 = 0x1406\nvar GL_UNSIGNED_BYTE$1 = 0x1401\nvar GL_FRAMEBUFFER = 0x8D40\nvar GL_FRAMEBUFFER_COMPLETE = 0x8CD5\nvar GL_COLOR_ATTACHMENT0 = 0x8CE0\nvar GL_COLOR_BUFFER_BIT$1 = 0x4000\n\nvar wrapLimits = function (gl, extensions) {\n var maxAnisotropic = 1\n if (extensions.ext_texture_filter_anisotropic) {\n maxAnisotropic = gl.getParameter(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)\n }\n\n var maxDrawbuffers = 1\n var maxColorAttachments = 1\n if (extensions.webgl_draw_buffers) {\n maxDrawbuffers = gl.getParameter(GL_MAX_DRAW_BUFFERS_WEBGL)\n maxColorAttachments = gl.getParameter(GL_MAX_COLOR_ATTACHMENTS_WEBGL)\n }\n\n // detect if reading float textures is available (Safari doesn't support)\n var readFloat = !!extensions.oes_texture_float\n if (readFloat) {\n var readFloatTexture = gl.createTexture()\n gl.bindTexture(GL_TEXTURE_2D, readFloatTexture)\n gl.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_FLOAT$1, null)\n\n var fbo = gl.createFramebuffer()\n gl.bindFramebuffer(GL_FRAMEBUFFER, fbo)\n gl.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, readFloatTexture, 0)\n gl.bindTexture(GL_TEXTURE_2D, null)\n\n if (gl.checkFramebufferStatus(GL_FRAMEBUFFER) !== GL_FRAMEBUFFER_COMPLETE) readFloat = false\n\n else {\n gl.viewport(0, 0, 1, 1)\n gl.clearColor(1.0, 0.0, 0.0, 1.0)\n gl.clear(GL_COLOR_BUFFER_BIT$1)\n var pixels = pool.allocType(GL_FLOAT$1, 4)\n gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT$1, pixels)\n\n if (gl.getError()) readFloat = false\n else {\n gl.deleteFramebuffer(fbo)\n gl.deleteTexture(readFloatTexture)\n\n readFloat = pixels[0] === 1.0\n }\n\n pool.freeType(pixels)\n }\n }\n\n // detect non power of two cube textures support (IE doesn't support)\n var isIE = typeof navigator !== 'undefined' && (/MSIE/.test(navigator.userAgent) || /Trident\\//.test(navigator.appVersion) || /Edge/.test(navigator.userAgent))\n\n var npotTextureCube = true\n\n if (!isIE) {\n var cubeTexture = gl.createTexture()\n var data = pool.allocType(GL_UNSIGNED_BYTE$1, 36)\n gl.activeTexture(GL_TEXTURE0)\n gl.bindTexture(GL_TEXTURE_CUBE_MAP,
1cubeTexture)\n gl.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE$1, data)\n pool.freeType(data)\n gl.bindTexture(GL_TEXTURE_CUBE_MAP, null)\n gl.deleteTexture(cubeTexture)\n npotTextureCube = !gl.getError()\n }\n\n return {\n // drawing buffer bit depth\n colorBits: [\n gl.getParameter(GL_RED_BITS),\n gl.getParameter(GL_GREEN_BITS),\n gl.getParameter(GL_BLUE_BITS),\n gl.getParameter(GL_ALPHA_BITS)\n ],\n depthBits: gl.getParameter(GL_DEPTH_BITS),\n stencilBits: gl.getParameter(GL_STENCIL_BITS),\n subpixelBits: gl.getParameter(GL_SUBPIXEL_BITS),\n\n // supported extensions\n extensions: Object.keys(extensions).filter(function (ext) {\n return !!extensions[ext]\n }),\n\n // max aniso samples\n maxAnisotropic: maxAnisotropic,\n\n // max draw buffers\n maxDrawbuffers: maxDrawbuffers,\n maxColorAttachments: maxColorAttachments,\n\n // point and line size ranges\n pointSizeDims: gl.getParameter(GL_ALIASED_POINT_SIZE_RANGE),\n lineWidthDims: gl.getParameter(GL_ALIASED_LINE_WIDTH_RANGE),\n maxViewportDims: gl.getParameter(GL_MAX_VIEWPORT_DIMS),\n maxCombinedTextureUnits: gl.getParameter(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS),\n maxCubeMapSize: gl.getParameter(GL_MAX_CUBE_MAP_TEXTURE_SIZE),\n maxRenderbufferSize: gl.getParameter(GL_MAX_RENDERBUFFER_SIZE),\n maxTextureUnits: gl.getParameter(GL_MAX_TEXTURE_IMAGE_UNITS),\n maxTextureSize: gl.getParameter(GL_MAX_TEXTURE_SIZE),\n maxAttributes: gl.getParameter(GL_MAX_VERTEX_ATTRIBS),\n maxVertexUniforms: gl.getParameter(GL_MAX_VERTEX_UNIFORM_VECTORS),\n maxVertexTextureUnits: gl.getParameter(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS),\n maxVaryingVectors: gl.getParameter(GL_MAX_VARYING_VECTORS),\n maxFragmentUniforms: gl.getParameter(GL_MAX_FRAGMENT_UNIFORM_VECTORS),\n\n // vendor info\n glsl: gl.getParameter(GL_SHADING_LANGUAGE_VERSION),\n renderer: gl.getParameter(GL_RENDERER),\n vendor: gl.getParameter(GL_VENDOR),\n version: gl.getParameter(GL_VERSION),\n\n // quirks\n readFloat: readFloat,\n npotTextureCube: npotTextureCube\n }\n}\n\nfunction isNDArrayLike (obj) {\n return (\n !!obj &&\n typeof obj === 'object' &&\n Array.isArray(obj.shape) &&\n Array.isArray(obj.stride) &&\n typeof obj.offset === 'number' &&\n obj.shape.length === obj.stride.length &&\n (Array.isArray(obj.data) ||\n isTypedArray(obj.data)))\n}\n\nvar values = function (obj) {\n return Object.keys(obj).map(function (key) { return obj[key] })\n}\n\nvar flattenUtils = {\n shape: arrayShape$1,\n flatten: flattenArray\n};\n\nfunction flatten1D (array, nx, out) {\n for (var i = 0; i < nx; ++i) {\n out[i] = array[i]\n }\n}\n\nfunction flatten2D (array, nx, ny, out) {\n var ptr = 0\n for (var i = 0; i < nx; ++i) {\n var row = array[i]\n for (var j = 0; j < ny; ++j) {\n out[ptr++] = row[j]\n }\n }\n}\n\nfunction flatten3D (array, nx, ny, nz, out, ptr_) {\n var ptr = ptr_\n for (var i = 0; i < nx; ++i) {\n var row = array[i]\n for (var j = 0; j < ny; ++j) {\n var col = row[j]\n for (var k = 0; k < nz; ++k) {\n out[ptr++] = col[k]\n }\n }\n }\n}\n\nfunction flattenRec (array, shape, level, out, ptr) {\n var stride = 1\n for (var i = level + 1; i < shape.length; ++i) {\n stride *= shape[i]\n }\n var n = shape[level]\n if (shape.length - level === 4) {\n var nx = shape[level + 1]\n var ny = shape[level + 2]\n var nz = shape[level + 3]\n for (i = 0; i < n; ++i) {\n flatten3D(array[i], nx, ny, nz, out, ptr)\n ptr += stride\n }\n } else {\n for (i = 0; i < n; ++i) {\n flattenRec(array[i], shape, level + 1, out, ptr)\n ptr += stride\n }\n }\n}\n\nfunction flattenArray (array, shape, type, out_) {\n var sz = 1\n if (shape.length) {\n for (var i = 0; i < shape.length; ++i) {\n sz *= shape[i]\n }\n } else {\n sz = 0\n }\n var out = out_ || pool.allocType(type, sz)\n switch (shape.length) {\n case 0:\n break\n case 1:\n flatten1D(array, shape[0], out)\n break\n case 2:\n flatten2D(array, shape[0], shape[1], out)\n break\n case 3:\n flatten3D(array, shape[0], shape[1], shape[2], out, 0)\n break\n default:\n flattenRec(array, shape, 0, out, 0)\n }\n return out\n}\n\nfunction arrayShape$1 (array_) {\n var shape = []\n for (var array = array_; array.length; array = array[0]) {\n shape.push(array.length)\n }\n return shape\n}\n\nvar arrayTypes = {\n\t\"[object Int8Array]\": 5120,\n\t\"[object Int16Array]\": 5122,\n\t\"[object Int32Array]\": 5124,\n\t\"[object Uint8Array]\": 5121,\n\t\"[object Uint8ClampedArray]\": 5121,\n\t\"[object Uint16Array]\": 5123,\n\t\"[object Uint32Array]\": 5125,\n\t\"[object Float32Array]\": 5126,\n\t\"[object Float64Array
1]\": 5121,\n\t\"[object ArrayBuffer]\": 5121\n};\n\nvar int8 = 5120;\nvar int16 = 5122;\nvar int32 = 5124;\nvar uint8 = 5121;\nvar uint16 = 5123;\nvar uint32 = 5125;\nvar float = 5126;\nvar float32 = 5126;\nvar glTypes = {\n\tint8: int8,\n\tint16: int16,\n\tint32: int32,\n\tuint8: uint8,\n\tuint16: uint16,\n\tuint32: uint32,\n\tfloat: float,\n\tfloat32: float32\n};\n\nvar dynamic$1 = 35048;\nvar stream = 35040;\nvar usageTypes = {\n\tdynamic: dynamic$1,\n\tstream: stream,\n\t\"static\": 35044\n};\n\nvar arrayFlatten = flattenUtils.flatten\nvar arrayShape = flattenUtils.shape\n\nvar GL_STATIC_DRAW = 0x88E4\nvar GL_STREAM_DRAW = 0x88E0\n\nvar GL_UNSIGNED_BYTE$3 = 5121\nvar GL_FLOAT$3 = 5126\n\nvar DTYPES_SIZES = []\nDTYPES_SIZES[5120] = 1 // int8\nDTYPES_SIZES[5122] = 2 // int16\nDTYPES_SIZES[5124] = 4 // int32\nDTYPES_SIZES[5121] = 1 // uint8\nDTYPES_SIZES[5123] = 2 // uint16\nDTYPES_SIZES[5125] = 4 // uint32\nDTYPES_SIZES[5126] = 4 // float32\n\nfunction typedArrayCode (data) {\n return arrayTypes[Object.prototype.toString.call(data)] | 0\n}\n\nfunction copyArray (out, inp) {\n for (var i = 0; i < inp.length; ++i) {\n out[i] = inp[i]\n }\n}\n\nfunction transpose (\n result, data, shapeX, shapeY, strideX, strideY, offset) {\n var ptr = 0\n for (var i = 0; i < shapeX; ++i) {\n for (var j = 0; j < shapeY; ++j) {\n result[ptr++] = data[strideX * i + strideY * j + offset]\n }\n }\n}\n\nfunction wrapBufferState (gl, stats, config, destroyBuffer) {\n var bufferCount = 0\n var bufferSet = {}\n\n function REGLBuffer (type) {\n this.id = bufferCount++\n this.buffer = gl.createBuffer()\n this.type = type\n this.usage = GL_STATIC_DRAW\n this.byteLength = 0\n this.dimension = 1\n this.dtype = GL_UNSIGNED_BYTE$3\n\n this.persistentData = null\n\n if (config.profile) {\n this.stats = { size: 0 }\n }\n }\n\n REGLBuffer.prototype.bind = function () {\n gl.bindBuffer(this.type, this.buffer)\n }\n\n REGLBuffer.prototype.destroy = function () {\n destroy(this)\n }\n\n var streamPool = []\n\n function createStream (type, data) {\n var buffer = streamPool.pop()\n if (!buffer) {\n buffer = new REGLBuffer(type)\n }\n buffer.bind()\n initBufferFromData(buffer, data, GL_STREAM_DRAW, 0, 1, false)\n return buffer\n }\n\n function destroyStream (stream$$1) {\n streamPool.push(stream$$1)\n }\n\n function initBufferFromTypedArray (buffer, data, usage) {\n buffer.byteLength = data.byteLength\n gl.bufferData(buffer.type, data, usage)\n }\n\n function initBufferFromData (buffer, data, usage, dtype, dimension, persist) {\n var shape\n buffer.usage = usage\n if (Array.isArray(data)) {\n buffer.dtype = dtype || GL_FLOAT$3\n if (data.length > 0) {\n var flatData\n if (Array.isArray(data[0])) {\n shape = arrayShape(data)\n var dim = 1\n for (var i = 1; i < shape.length; ++i) {\n dim *= shape[i]\n }\n buffer.dimension = dim\n flatData = arrayFlatten(data, shape, buffer.dtype)\n initBufferFromTypedArray(buffer, flatData, usage)\n if (persist) {\n buffer.persistentData = flatData\n } else {\n pool.freeType(flatData)\n }\n } else if (typeof data[0] === 'number') {\n buffer.dimension = dimension\n var typedData = pool.allocType(buffer.dtype, data.length)\n copyArray(typedData, data)\n initBufferFromTypedArray(buffer, typedData, usage)\n if (persist) {\n buffer.persistentData = typedData\n } else {\n pool.freeType(typedData)\n }\n } else if (isTypedArray(data[0])) {\n buffer.dimension = data[0].length\n buffer.dtype = dtype || typedArrayCode(data[0]) || GL_FLOAT$3\n flatData = arrayFlatten(\n data,\n [data.length, data[0].length],\n buffer.dtype)\n initBufferFromTypedArray(buffer, flatData, usage)\n if (persist) {\n buffer.persistentData = flatData\n } else {\n pool.freeType(flatData)\n }\n } else {\n check$1.raise('invalid buffer data')\n }\n }\n } else if (isTypedArray(data)) {\n buffer.dtype = dtype || typedArrayCode(data)\n buffer.dimension = dimension\n initBufferFromTypedArray(buffer, data, usage)\n if (persist) {\n buffer.persistentData = new Uint8Array(new Uint8Array(data.buffer))\n }\n } else if (isNDArrayLike(data)) {\n shape = data.shape\n var stride = data.stride\n var offset = data.offset\n\n var shapeX = 0\n var shapeY = 0\n var strideX = 0\n var strideY = 0\n if (shape.length === 1) {\n shapeX = shape[0]\n shapeY = 1\n str
1ideX = stride[0]\n strideY = 0\n } else if (shape.length === 2) {\n shapeX = shape[0]\n shapeY = shape[1]\n strideX = stride[0]\n strideY = stride[1]\n } else {\n check$1.raise('invalid shape')\n }\n\n buffer.dtype = dtype || typedArrayCode(data.data) || GL_FLOAT$3\n buffer.dimension = shapeY\n\n var transposeData = pool.allocType(buffer.dtype, shapeX * shapeY)\n transpose(transposeData,\n data.data,\n shapeX, shapeY,\n strideX, strideY,\n offset)\n initBufferFromTypedArray(buffer, transposeData, usage)\n if (persist) {\n buffer.persistentData = transposeData\n } else {\n pool.freeType(transposeData)\n }\n } else if (data instanceof ArrayBuffer) {\n buffer.dtype = GL_UNSIGNED_BYTE$3\n buffer.dimension = dimension\n initBufferFromTypedArray(buffer, data, usage)\n if (persist) {\n buffer.persistentData = new Uint8Array(new Uint8Array(data))\n }\n } else {\n check$1.raise('invalid buffer data')\n }\n }\n\n function destroy (buffer) {\n stats.bufferCount--\n\n // remove attribute link\n destroyBuffer(buffer)\n\n var handle = buffer.buffer\n check$1(handle, 'buffer must not be deleted already')\n gl.deleteBuffer(handle)\n buffer.buffer = null\n delete bufferSet[buffer.id]\n }\n\n function createBuffer (options, type, deferInit, persistent) {\n stats.bufferCount++\n\n var buffer = new REGLBuffer(type)\n bufferSet[buffer.id] = buffer\n\n function reglBuffer (options) {\n var usage = GL_STATIC_DRAW\n var data = null\n var byteLength = 0\n var dtype = 0\n var dimension = 1\n if (Array.isArray(options) ||\n isTypedArray(options) ||\n isNDArrayLike(options) ||\n options instanceof ArrayBuffer) {\n data = options\n } else if (typeof options === 'number') {\n byteLength = options | 0\n } else if (options) {\n check$1.type(\n options, 'object',\n 'buffer arguments must be an object, a number or an array')\n\n if ('data' in options) {\n check$1(\n data === null ||\n Array.isArray(data) ||\n isTypedArray(data) ||\n isNDArrayLike(data),\n 'invalid data for buffer')\n data = options.data\n }\n\n if ('usage' in options) {\n check$1.parameter(options.usage, usageTypes, 'invalid buffer usage')\n usage = usageTypes[options.usage]\n }\n\n if ('type' in options) {\n check$1.parameter(options.type, glTypes, 'invalid buffer type')\n dtype = glTypes[options.type]\n }\n\n if ('dimension' in options) {\n check$1.type(options.dimension, 'number', 'invalid dimension')\n dimension = options.dimension | 0\n }\n\n if ('length' in options) {\n check$1.nni(byteLength, 'buffer length must be a nonnegative integer')\n byteLength = options.length | 0\n }\n }\n\n buffer.bind()\n if (!data) {\n // #475\n if (byteLength) gl.bufferData(buffer.type, byteLength, usage)\n buffer.dtype = dtype || GL_UNSIGNED_BYTE$3\n buffer.usage = usage\n buffer.dimension = dimension\n buffer.byteLength = byteLength\n } else {\n initBufferFromData(buffer, data, usage, dtype, dimension, persistent)\n }\n\n if (config.profile) {\n buffer.stats.size = buffer.byteLength * DTYPES_SIZES[buffer.dtype]\n }\n\n return reglBuffer\n }\n\n function setSubData (data, offset) {\n check$1(offset + data.byteLength <= buffer.byteLength,\n 'invalid buffer subdata call, buffer is too small. ' + ' Can\\'t write data of size ' + data.byteLength + ' starting from offset ' + offset + ' to a buffer of size ' + buffer.byteLength)\n\n gl.bufferSubData(buffer.type, offset, data)\n }\n\n function subdata (data, offset_) {\n var offset = (offset_ || 0) | 0\n var shape\n buffer.bind()\n if (isTypedArray(data) || data instanceof ArrayBuffer) {\n setSubData(data, offset)\n } else if (Array.isArray(data)) {\n if (data.length > 0) {\n if (typeof data[0] === 'number') {\n var converted = pool.allocType(buffer.dtype, data.length)\n copyArray(converted, data)\n setSubData(converted, offset)\n pool.freeType(converted)\n } else if (Array.isArray(data[0]) || isTypedArray(data[0])) {\n shape = arrayShape(data)\n var flatData = arrayFlatten(data, shape, buffer.dtype)\n setSubData(flatData, offset)\n pool.freeType(flatData)\n } else {\n check$1.raise('invalid buffer data')\n }\n }\n } else if (isNDArrayLike(data)) {\n shape = data.shape\n var stride = data.stride\n\n var shapeX = 0\n var shapeY = 0\n var strideX = 0\n var strideY = 0\n if (shape.length === 1) {\n shapeX = shape[0]\n shapeY = 1\n str
1ideX = stride[0]\n strideY = 0\n } else if (shape.length === 2) {\n shapeX = shape[0]\n shapeY = shape[1]\n strideX = stride[0]\n strideY = stride[1]\n } else {\n check$1.raise('invalid shape')\n }\n var dtype = Array.isArray(data.data)\n ? buffer.dtype\n : typedArrayCode(data.data)\n\n var transposeData = pool.allocType(dtype, shapeX * shapeY)\n transpose(transposeData,\n data.data,\n shapeX, shapeY,\n strideX, strideY,\n data.offset)\n setSubData(transposeData, offset)\n pool.freeType(transposeData)\n } else {\n check$1.raise('invalid data for buffer subdata')\n }\n return reglBuffer\n }\n\n if (!deferInit) {\n reglBuffer(options)\n }\n\n reglBuffer._reglType = 'buffer'\n reglBuffer._buffer = buffer\n reglBuffer.subdata = subdata\n if (config.profile) {\n reglBuffer.stats = buffer.stats\n }\n reglBuffer.destroy = function () { destroy(buffer) }\n\n return reglBuffer\n }\n\n function restoreBuffers () {\n values(bufferSet).forEach(function (buffer) {\n buffer.buffer = gl.createBuffer()\n gl.bindBuffer(buffer.type, buffer.buffer)\n gl.bufferData(\n buffer.type, buffer.persistentData || buffer.byteLength, buffer.usage)\n })\n }\n\n if (config.profile) {\n stats.getTotalBufferSize = function () {\n var total = 0\n // TODO: Right now, the streams are not part of the total count.\n Object.keys(bufferSet).forEach(function (key) {\n total += bufferSet[key].stats.size\n })\n return total\n }\n }\n\n return {\n create: createBuffer,\n\n createStream: createStream,\n destroyStream: destroyStream,\n\n clear: function () {\n values(bufferSet).forEach(destroy)\n streamPool.forEach(destroy)\n },\n\n getBuffer: function (wrapper) {\n if (wrapper && wrapper._buffer instanceof REGLBuffer) {\n return wrapper._buffer\n }\n return null\n },\n\n restore: restoreBuffers,\n\n _initBuffer: initBufferFromData\n }\n}\n\nvar points = 0;\nvar point = 0;\nvar lines = 1;\nvar line = 1;\nvar triangles = 4;\nvar triangle = 4;\nvar primTypes = {\n\tpoints: points,\n\tpoint: point,\n\tlines: lines,\n\tline: line,\n\ttriangles: triangles,\n\ttriangle: triangle,\n\t\"line loop\": 2,\n\t\"line strip\": 3,\n\t\"triangle strip\": 5,\n\t\"triangle fan\": 6\n};\n\nvar GL_POINTS = 0\nvar GL_LINES = 1\nvar GL_TRIANGLES = 4\n\nvar GL_BYTE$2 = 5120\nvar GL_UNSIGNED_BYTE$4 = 5121\nvar GL_SHORT$2 = 5122\nvar GL_UNSIGNED_SHORT$2 = 5123\nvar GL_INT$2 = 5124\nvar GL_UNSIGNED_INT$2 = 5125\n\nvar GL_ELEMENT_ARRAY_BUFFER = 34963\n\nvar GL_STREAM_DRAW$1 = 0x88E0\nvar GL_STATIC_DRAW$1 = 0x88E4\n\nfunction wrapElementsState (gl, extensions, bufferState, stats) {\n var elementSet = {}\n var elementCount = 0\n\n var elementTypes = {\n 'uint8': GL_UNSIGNED_BYTE$4,\n 'uint16': GL_UNSIGNED_SHORT$2\n }\n\n if (extensions.oes_element_index_uint) {\n elementTypes.uint32 = GL_UNSIGNED_INT$2\n }\n\n function REGLElementBuffer (buffer) {\n this.id = elementCount++\n elementSet[this.id] = this\n this.buffer = buffer\n this.primType = GL_TRIANGLES\n this.vertCount = 0\n this.type = 0\n }\n\n REGLElementBuffer.prototype.bind = function () {\n this.buffer.bind()\n }\n\n var bufferPool = []\n\n function createElementStream (data) {\n var result = bufferPool.pop()\n if (!result) {\n result = new REGLElementBuffer(bufferState.create(\n null,\n GL_ELEMENT_ARRAY_BUFFER,\n true,\n false)._buffer)\n }\n initElements(result, data, GL_STREAM_DRAW$1, -1, -1, 0, 0)\n return result\n }\n\n function destroyElementStream (elements) {\n bufferPool.push(elements)\n }\n\n function initElements (\n elements,\n data,\n usage,\n prim,\n count,\n byteLength,\n type) {\n elements.buffer.bind()\n var dtype\n if (data) {\n var predictedType = type\n if (!type && (\n !isTypedArray(data) ||\n (isNDArrayLike(data) && !isTypedArray(data.data)))) {\n predictedType = extensions.oes_element_index_uint\n ? GL_UNSIGNED_INT$2\n : GL_UNSIGNED_SHORT$2\n }\n bufferState._initBuffer(\n elements.buffer,\n data,\n usage,\n predictedType,\n 3)\n } else {\n gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, byteLength, usage)\n elements.buffer.dtype = dtype || GL_UNSIGNED_BYTE$4\n elements.buffer.usage = usage\n elements.buffer.dimension = 3\n elements.buffer.byteLength = byteLength\n }\n\n dtype = type\n if (!type) {\n switch (elements.buffer.dtype) {\n case GL_UNSIGNED_BYTE$4:\n case GL_BYTE$2:\n dtype = GL_UNSIGNED_BYTE$4\n break\n\n case GL_UNSIGNED_SHORT$2:\n case GL_SHORT$2:\n dtype = GL_UNSIGNED_SHORT$2\n break\n\n case GL_UNSIGNED_INT$2:\n case GL_INT$2:\n dtype = GL_UNSIGNED_INT$2\n break\n\n default:\n check$1.raise('unsupported type for element array')\n }\n elements.buffer.dtype = dtype\n }\n elements.type = dtype\n\n // Check oes_element_index_uint extension\n check$1(\n dtype !== GL_
1UNSIGNED_INT$2 ||\n !!extensions.oes_element_index_uint,\n '32 bit element buffers not supported, enable oes_element_index_uint first')\n\n // try to guess default primitive type and arguments\n var vertCount = count\n if (vertCount < 0) {\n vertCount = elements.buffer.byteLength\n if (dtype === GL_UNSIGNED_SHORT$2) {\n vertCount >>= 1\n } else if (dtype === GL_UNSIGNED_INT$2) {\n vertCount >>= 2\n }\n }\n elements.vertCount = vertCount\n\n // try to guess primitive type from cell dimension\n var primType = prim\n if (prim < 0) {\n primType = GL_TRIANGLES\n var dimension = elements.buffer.dimension\n if (dimension === 1) primType = GL_POINTS\n if (dimension === 2) primType = GL_LINES\n if (dimension === 3) primType = GL_TRIANGLES\n }\n elements.primType = primType\n }\n\n function destroyElements (elements) {\n stats.elementsCount--\n\n check$1(elements.buffer !== null, 'must not double destroy elements')\n delete elementSet[elements.id]\n elements.buffer.destroy()\n elements.buffer = null\n }\n\n function createElements (options, persistent) {\n var buffer = bufferState.create(null, GL_ELEMENT_ARRAY_BUFFER, true)\n var elements = new REGLElementBuffer(buffer._buffer)\n stats.elementsCount++\n\n function reglElements (options) {\n if (!options) {\n buffer()\n elements.primType = GL_TRIANGLES\n elements.vertCount = 0\n elements.type = GL_UNSIGNED_BYTE$4\n } else if (typeof options === 'number') {\n buffer(options)\n elements.primType = GL_TRIANGLES\n elements.vertCount = options | 0\n elements.type = GL_UNSIGNED_BYTE$4\n } else {\n var data = null\n var usage = GL_STATIC_DRAW$1\n var primType = -1\n var vertCount = -1\n var byteLength = 0\n var dtype = 0\n if (Array.isArray(options) ||\n isTypedArray(options) ||\n isNDArrayLike(options)) {\n data = options\n } else {\n check$1.type(options, 'object', 'invalid arguments for elements')\n if ('data' in options) {\n data = options.data\n check$1(\n Array.isArray(data) ||\n isTypedArray(data) ||\n isNDArrayLike(data),\n 'invalid data for element buffer')\n }\n if ('usage' in options) {\n check$1.parameter(\n options.usage,\n usageTypes,\n 'invalid element buffer usage')\n usage = usageTypes[options.usage]\n }\n if ('primitive' in options) {\n check$1.parameter(\n options.primitive,\n primTypes,\n 'invalid element buffer primitive')\n primType = primTypes[options.primitive]\n }\n if ('count' in options) {\n check$1(\n typeof options.count === 'number' && options.count >= 0,\n 'invalid vertex count for elements')\n vertCount = options.count | 0\n }\n if ('type' in options) {\n check$1.parameter(\n options.type,\n elementTypes,\n 'invalid buffer type')\n dtype = elementTypes[options.type]\n }\n if ('length' in options) {\n byteLength = options.length | 0\n } else {\n byteLength = vertCount\n if (dtype === GL_UNSIGNED_SHORT$2 || dtype === GL_SHORT$2) {\n byteLength *= 2\n } else if (dtype === GL_UNSIGNED_INT$2 || dtype === GL_INT$2) {\n byteLength *= 4\n }\n }\n }\n initElements(\n elements,\n data,\n usage,\n primType,\n vertCount,\n byteLength,\n dtype)\n }\n\n return reglElements\n }\n\n reglElements(options)\n\n reglElements._reglType = 'elements'\n reglElements._elements = elements\n reglElements.subdata = function (data, offset) {\n buffer.subdata(data, offset)\n return reglElements\n }\n reglElements.destroy = function () {\n destroyElements(elements)\n }\n\n return reglElements\n }\n\n return {\n create: createElements,\n createStream: createElementStream,\n destroyStream: destroyElementStream,\n getElements: function (elements) {\n if (typeof elements === 'function' &&\n elements._elements instanceof REGLElementBuffer) {\n return elements._elements\n }\n return null\n },\n clear: function () {\n values(elementSet).forEach(destroyElements)\n }\n }\n}\n\nvar FLOAT = new Float32Array(1)\nvar INT = new Uint32Array(FLOAT.buffer)\n\nvar GL_UNSIGNED_SHORT$4 = 5123\n\nfunction convertToHalfFloat (array) {\n var ushorts = pool.allocType(GL_UNSIGNED_SHORT$4, array.length)\n\n for (var i = 0; i < array.length; ++i) {\n if (isNaN(array[i])) {\n ushorts[i] = 0xffff\n } else if (array[i] === Infinity) {\n ushorts[i] = 0x7c00\n } else if (array[i] === -Infinity) {\n ushorts[i] = 0xfc00\n } else {\n FLOAT[0] = array[i]\n var x = INT[0]\n\n var sgn = (x >>> 31) << 15\n var exp = ((x << 1) >>> 24) - 127\n var frac = (x >> 13) & ((1 << 10) - 1)\n\n if (exp < -24) {\n // round non-representable denormals to 0\n ushorts[i] = sgn\n } else if (exp < -14) {\n // handle denormals\n var s = -14 - exp\n ushorts[i] = sgn + ((frac + (1 << 10)) >> s)\n } else if (exp > 15) {\n // round overflow to +/- Infinity\n ushorts[i] = sgn + 0x7c00\n } else {\n // otherwise convert directly\n ushorts[i] = sgn + ((exp + 15) << 10) + frac\n }\n }\n }\n\n return ushorts\n}
1\n\nfunction isArrayLike (s) {\n return Array.isArray(s) || isTypedArray(s)\n}\n\nvar isPow2$1 = function (v) {\n return !(v & (v - 1)) && (!!v)\n}\n\nvar GL_COMPRESSED_TEXTURE_FORMATS = 0x86A3\n\nvar GL_TEXTURE_2D$1 = 0x0DE1\nvar GL_TEXTURE_CUBE_MAP$1 = 0x8513\nvar GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 = 0x8515\n\nvar GL_RGBA$1 = 0x1908\nvar GL_ALPHA = 0x1906\nvar GL_RGB = 0x1907\nvar GL_LUMINANCE = 0x1909\nvar GL_LUMINANCE_ALPHA = 0x190A\n\nvar GL_RGBA4 = 0x8056\nvar GL_RGB5_A1 = 0x8057\nvar GL_RGB565 = 0x8D62\n\nvar GL_UNSIGNED_SHORT_4_4_4_4$1 = 0x8033\nvar GL_UNSIGNED_SHORT_5_5_5_1$1 = 0x8034\nvar GL_UNSIGNED_SHORT_5_6_5$1 = 0x8363\nvar GL_UNSIGNED_INT_24_8_WEBGL$1 = 0x84FA\n\nvar GL_DEPTH_COMPONENT = 0x1902\nvar GL_DEPTH_STENCIL = 0x84F9\n\nvar GL_SRGB_EXT = 0x8C40\nvar GL_SRGB_ALPHA_EXT = 0x8C42\n\nvar GL_HALF_FLOAT_OES$1 = 0x8D61\n\nvar GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0\nvar GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1\nvar GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2\nvar GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3\n\nvar GL_COMPRESSED_RGB_ATC_WEBGL = 0x8C92\nvar GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL = 0x8C93\nvar GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL = 0x87EE\n\nvar GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00\nvar GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01\nvar GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02\nvar GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03\n\nvar GL_COMPRESSED_RGB_ETC1_WEBGL = 0x8D64\n\nvar GL_UNSIGNED_BYTE$5 = 0x1401\nvar GL_UNSIGNED_SHORT$3 = 0x1403\nvar GL_UNSIGNED_INT$3 = 0x1405\nvar GL_FLOAT$4 = 0x1406\n\nvar GL_TEXTURE_WRAP_S = 0x2802\nvar GL_TEXTURE_WRAP_T = 0x2803\n\nvar GL_REPEAT = 0x2901\nvar GL_CLAMP_TO_EDGE$1 = 0x812F\nvar GL_MIRRORED_REPEAT = 0x8370\n\nvar GL_TEXTURE_MAG_FILTER = 0x2800\nvar GL_TEXTURE_MIN_FILTER = 0x2801\n\nvar GL_NEAREST$1 = 0x2600\nvar GL_LINEAR = 0x2601\nvar GL_NEAREST_MIPMAP_NEAREST$1 = 0x2700\nvar GL_LINEAR_MIPMAP_NEAREST$1 = 0x2701\nvar GL_NEAREST_MIPMAP_LINEAR$1 = 0x2702\nvar GL_LINEAR_MIPMAP_LINEAR$1 = 0x2703\n\nvar GL_GENERATE_MIPMAP_HINT = 0x8192\nvar GL_DONT_CARE = 0x1100\nvar GL_FASTEST = 0x1101\nvar GL_NICEST = 0x1102\n\nvar GL_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE\n\nvar GL_UNPACK_ALIGNMENT = 0x0CF5\nvar GL_UNPACK_FLIP_Y_WEBGL = 0x9240\nvar GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL = 0x9241\nvar GL_UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243\n\nvar GL_BROWSER_DEFAULT_WEBGL = 0x9244\n\nvar GL_TEXTURE0$1 = 0x84C0\n\nvar MIPMAP_FILTERS = [\n GL_NEAREST_MIPMAP_NEAREST$1,\n GL_NEAREST_MIPMAP_LINEAR$1,\n GL_LINEAR_MIPMAP_NEAREST$1,\n GL_LINEAR_MIPMAP_LINEAR$1\n]\n\nvar CHANNELS_FORMAT = [\n 0,\n GL_LUMINANCE,\n GL_LUMINANCE_ALPHA,\n GL_RGB,\n GL_RGBA$1\n]\n\nvar FORMAT_CHANNELS = {}\nFORMAT_CHANNELS[GL_LUMINANCE] =\nFORMAT_CHANNELS[GL_ALPHA] =\nFORMAT_CHANNELS[GL_DEPTH_COMPONENT] = 1\nFORMAT_CHANNELS[GL_DEPTH_STENCIL] =\nFORMAT_CHANNELS[GL_LUMINANCE_ALPHA] = 2\nFORMAT_CHANNELS[GL_RGB] =\nFORMAT_CHANNELS[GL_SRGB_EXT] = 3\nFORMAT_CHANNELS[GL_RGBA$1] =\nFORMAT_CHANNELS[GL_SRGB_ALPHA_EXT] = 4\n\nfunction objectName (str) {\n return '[object ' + str + ']'\n}\n\nvar CANVAS_CLASS = objectName('HTMLCanvasElement')\nvar OFFSCREENCANVAS_CLASS = objectName('OffscreenCanvas')\nvar CONTEXT2D_CLASS = objectName('CanvasRenderingContext2D')\nvar BITMAP_CLASS = objectName('ImageBitmap')\nvar IMAGE_CLASS = objectName('HTMLImageElement')\nvar VIDEO_CLASS = objectName('HTMLVideoElement')\n\nvar PIXEL_CLASSES = Object.keys(arrayTypes).concat([\n CANVAS_CLASS,\n OFFSCREENCANVAS_CLASS,\n CONTEXT2D_CLASS,\n BITMAP_CLASS,\n IMAGE_CLASS,\n VIDEO_CLASS\n])\n\n// for every texture type, store\n// the size in bytes.\nvar TYPE_SIZES = []\nTYPE_SIZES[GL_UNSIGNED_BYTE$5] = 1\nTYPE_SIZES[GL_FLOAT$4] = 4\nTYPE_SIZES[GL_HALF_FLOAT_OES$1] = 2\n\nTYPE_SIZES[GL_UNSIGNED_SHORT$3] = 2\nTYPE_SIZES[GL_UNSIGNED_INT$3] = 4\n\nvar FORMAT_SIZES_SPECIAL = []\nFORMAT_SIZES_SPECIAL[GL_RGBA4] = 2\nFORMAT_SIZES_SPECIAL[GL_RGB5_A1] = 2\nFORMAT_SIZES_SPECIAL[GL_RGB565] = 2\nFORMAT_SIZES_SPECIAL[GL_DEPTH_STENCIL] = 4\n\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_S3TC_DXT1_EXT] = 0.5\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_S3TC_DXT1_EXT] = 0.5\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_S3TC_DXT3_EXT] = 1\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_S3TC_DXT5_EXT] = 1\n\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_ATC_WEBGL] = 0.5\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL] = 1\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL] = 1\n\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = 0.5\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = 0.25\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = 0.5\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = 0.25\n\nFORMAT_SIZES_SPECIAL[GL_COMPRESSED_RGB_ETC1_WEBGL] = 0.5\n\nfunction isNumericArray (arr) {\n return (\n Array.isArray(arr) &&\n (arr.length === 0 ||\n typeof arr[0] === 'number'))\n}\n\nfunction isRectArray (arr) {\n if (!Array.isArray(arr)) {\n return false\n }\n var width = arr.length\n if (width === 0 || !isArrayLike(arr[0])) {\n return false\n }\n return true\n}\n\nfunction classString (x) {\n return Object.prototype.toString.call(x)\n}\n\nfunction isCanvasElement (object) {\n return classString(object) === CANVAS_CLASS\n}\n\nfunction isOffscreenCanvas (object) {\n return classString(object) === OFFSCREENCANVAS_CLASS\n}\n\nfunction isContext2D (object) {\n return classString(object) === CONTEXT2D_CLASS\n}\n\nfunction isBitmap (object) {\n return classString(object) === BITMAP_CLASS\n}\n\nfunction isImageElement (object) {\n return classString(object) === IMAGE_CLASS\n}\n\nfunction isVideoElement (object) {\n return classString(object) === VIDEO_CLASS\n}\n\nfunction isPixelData (object) {\n if (!object) {\n return false\n }\n var className = classString(object)\n if (PIXEL_CLASSES.indexOf(className) >= 0) {\n return true\n }\n return (\n isNumericArray(object) ||\n isRectArray(object) ||\n isNDArrayLike(object))\n}
1\n\nfunction typedArrayCode$1 (data) {\n return arrayTypes[Object.prototype.toString.call(data)] | 0\n}\n\nfunction convertData (result, data) {\n var n = data.length\n switch (result.type) {\n case GL_UNSIGNED_BYTE$5:\n case GL_UNSIGNED_SHORT$3:\n case GL_UNSIGNED_INT$3:\n case GL_FLOAT$4:\n var converted = pool.allocType(result.type, n)\n converted.set(data)\n result.data = converted\n break\n\n case GL_HALF_FLOAT_OES$1:\n result.data = convertToHalfFloat(data)\n break\n\n default:\n check$1.raise('unsupported texture type, must specify a typed array')\n }\n}\n\nfunction preConvert (image, n) {\n return pool.allocType(\n image.type === GL_HALF_FLOAT_OES$1\n ? GL_FLOAT$4\n : image.type, n)\n}\n\nfunction postConvert (image, data) {\n if (image.type === GL_HALF_FLOAT_OES$1) {\n image.data = convertToHalfFloat(data)\n pool.freeType(data)\n } else {\n image.data = data\n }\n}\n\nfunction transposeData (image, array, strideX, strideY, strideC, offset) {\n var w = image.width\n var h = image.height\n var c = image.channels\n var n = w * h * c\n var data = preConvert(image, n)\n\n var p = 0\n for (var i = 0; i < h; ++i) {\n for (var j = 0; j < w; ++j) {\n for (var k = 0; k < c; ++k) {\n data[p++] = array[strideX * j + strideY * i + strideC * k + offset]\n }\n }\n }\n\n postConvert(image, data)\n}\n\nfunction getTextureSize (format, type, width, height, isMipmap, isCube) {\n var s\n if (typeof FORMAT_SIZES_SPECIAL[format] !== 'undefined') {\n // we have a special array for dealing with weird color formats such as RGB5A1\n s = FORMAT_SIZES_SPECIAL[format]\n } else {\n s = FORMAT_CHANNELS[format] * TYPE_SIZES[type]\n }\n\n if (isCube) {\n s *= 6\n }\n\n if (isMipmap) {\n // compute the total size of all the mipmaps.\n var total = 0\n\n var w = width\n while (w >= 1) {\n // we can only use mipmaps on a square image,\n // so we can simply use the width and ignore the height:\n total += s * w * w\n w /= 2\n }\n return total\n } else {\n return s * width * height\n }\n}\n\nfunction createTextureSet (\n gl, extensions, limits, reglPoll, contextState, stats, config) {\n // -------------------------------------------------------\n // Initialize constants and parameter tables here\n // -------------------------------------------------------\n var mipmapHint = {\n \"don't care\": GL_DONT_CARE,\n 'dont care': GL_DONT_CARE,\n 'nice': GL_NICEST,\n 'fast': GL_FASTEST\n }\n\n var wrapModes = {\n 'repeat': GL_REPEAT,\n 'clamp': GL_CLAMP_TO_EDGE$1,\n 'mirror': GL_MIRRORED_REPEAT\n }\n\n var magFilters = {\n 'nearest': GL_NEAREST$1,\n 'linear': GL_LINEAR\n }\n\n var minFilters = extend({\n 'mipmap': GL_LINEAR_MIPMAP_LINEAR$1,\n 'nearest mipmap nearest': GL_NEAREST_MIPMAP_NEAREST$1,\n 'linear mipmap nearest': GL_LINEAR_MIPMAP_NEAREST$1,\n 'nearest mipmap linear': GL_NEAREST_MIPMAP_LINEAR$1,\n 'linear mipmap linear': GL_LINEAR_MIPMAP_LINEAR$1\n }, magFilters)\n\n var colorSpace = {\n 'none': 0,\n 'browser': GL_BROWSER_DEFAULT_WEBGL\n }\n\n var textureTypes = {\n 'uint8': GL_UNSIGNED_BYTE$5,\n 'rgba4': GL_UNSIGNED_SHORT_4_4_4_4$1,\n 'rgb565': GL_UNSIGNED_SHORT_5_6_5$1,\n 'rgb5 a1': GL_UNSIGNED_SHORT_5_5_5_1$1\n }\n\n var textureFormats = {\n 'alpha': GL_ALPHA,\n 'luminance': GL_LUMINANCE,\n 'luminance alpha': GL_LUMINANCE_ALPHA,\n 'rgb': GL_RGB,\n 'rgba': GL_RGBA$1,\n 'rgba4': GL_RGBA4,\n 'rgb5 a1': GL_RGB5_A1,\n 'rgb565': GL_RGB565\n }\n\n var compressedTextureFormats = {}\n\n if (extensions.ext_srgb) {\n textureFormats.srgb = GL_SRGB_EXT\n textureFormats.srgba = GL_SRGB_ALPHA_EXT\n }\n\n if (extensions.oes_texture_float) {\n textureTypes.float32 = textureTypes.float = GL_FLOAT$4\n }\n\n if (extensions.oes_texture_half_float) {\n textureTypes['float16'] = textureTypes['half float'] = GL_HALF_FLOAT_OES$1\n }\n\n if (extensions.webgl_depth_texture) {\n extend(textureFormats, {\n 'depth': G
1L_DEPTH_COMPONENT,\n 'depth stencil': GL_DEPTH_STENCIL\n })\n\n extend(textureTypes, {\n 'uint16': GL_UNSIGNED_SHORT$3,\n 'uint32': GL_UNSIGNED_INT$3,\n 'depth stencil': GL_UNSIGNED_INT_24_8_WEBGL$1\n })\n }\n\n if (extensions.webgl_compressed_texture_s3tc) {\n extend(compressedTextureFormats, {\n 'rgb s3tc dxt1': GL_COMPRESSED_RGB_S3TC_DXT1_EXT,\n 'rgba s3tc dxt1': GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,\n 'rgba s3tc dxt3': GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,\n 'rgba s3tc dxt5': GL_COMPRESSED_RGBA_S3TC_DXT5_EXT\n })\n }\n\n if (extensions.webgl_compressed_texture_atc) {\n extend(compressedTextureFormats, {\n 'rgb atc': GL_COMPRESSED_RGB_ATC_WEBGL,\n 'rgba atc explicit alpha': GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,\n 'rgba atc interpolated alpha': GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL\n })\n }\n\n if (extensions.webgl_compressed_texture_pvrtc) {\n extend(compressedTextureFormats, {\n 'rgb pvrtc 4bppv1': GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,\n 'rgb pvrtc 2bppv1': GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,\n 'rgba pvrtc 4bppv1': GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,\n 'rgba pvrtc 2bppv1': GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG\n })\n }\n\n if (extensions.webgl_compressed_texture_etc1) {\n compressedTextureFormats['rgb etc1'] = GL_COMPRESSED_RGB_ETC1_WEBGL\n }\n\n // Copy over all texture formats\n var supportedCompressedFormats = Array.prototype.slice.call(\n gl.getParameter(GL_COMPRESSED_TEXTURE_FORMATS))\n Object.keys(compressedTextureFormats).forEach(function (name) {\n var format = compressedTextureFormats[name]\n if (supportedCompressedFormats.indexOf(format) >= 0) {\n textureFormats[name] = format\n }\n })\n\n var supportedFormats = Object.keys(textureFormats)\n limits.textureFormats = supportedFormats\n\n // associate with every format string its\n // corresponding GL-value.\n var textureFormatsInvert = []\n Object.keys(textureFormats).forEach(function (key) {\n var val = textureFormats[key]\n textureFormatsInvert[val] = key\n })\n\n // associate with every type string its\n // corresponding GL-value.\n var textureTypesInvert = []\n Object.keys(textureTypes).forEach(function (key) {\n var val = textureTypes[key]\n textureTypesInvert[val] = key\n })\n\n var magFiltersInvert = []\n Object.keys(magFilters).forEach(function (key) {\n var val = magFilters[key]\n magFiltersInvert[val] = key\n })\n\n var minFiltersInvert = []\n Object.keys(minFilters).forEach(function (key) {\n var val = minFilters[key]\n minFiltersInvert[val] = key\n })\n\n var wrapModesInvert = []\n Object.keys(wrapModes).forEach(function (key) {\n var val = wrapModes[key]\n wrapModesInvert[val] = key\n })\n\n // colorFormats[] gives the format (channels) associated to an\n // internalformat\n var colorFormats = supportedFormats.reduce(function (color, key) {\n var glenum = textureFormats[key]\n if (glenum === GL_LUMINANCE ||\n glenum === GL_ALPHA ||\n glenum === GL_LUMINANCE ||\n glenum === GL_LUMINANCE_ALPHA ||\n glenum === GL_DEPTH_COMPONENT ||\n glenum === GL_DEPTH_STENCIL ||\n (extensions.ext_srgb &&\n (glenum === GL_SRGB_EXT ||\n glenum === GL_SRGB_ALPHA_EXT))) {\n color[glenum] = glenum\n } else if (glenum === GL_RGB5_A1 || key.indexOf('rgba') >= 0) {\n color[glenum] = GL_RGBA$1\n } else {\n color[glenum] = GL_RGB\n }\n return color\n }, {})\n\n function TexFlags () {\n // format info\n this.internalformat = GL_RGBA$1\n this.format = GL_RGBA$1\n this.type = GL_UNSIGNED_BYTE$5\n this.compressed = false\n\n // pixel storage\n this.premultiplyAlpha = false\n this.flipY = false\n this.unpackAlignment = 1\n this.colorSpace = GL_BROWSER_DEFAULT_WEBGL\n\n // shape info\n this.width = 0\n this.height = 0\n this.channels = 0\n }\n\n function copyFlags (result, other) {\n result.internalformat = other.internalformat\n result.format = other.format\n result.type = other.type\n result.compressed = other.compressed\n\n result.premultiplyAlpha = other.premultiplyAlpha\n result.flipY = other.flipY\n result.unpackAlignment = other.unpackAlignment\n result.colorSpace = other.colorSpace\n\n result.width = other.width\n result.height = other.height\n result.channels = other.channels\n }\n\n function parseFlags (flags, options) {\n if (typeof options !== 'object' || !options) {\n return\n }\n\n if ('premultiplyAlpha' in options) {\n check$1.type(options.premultiplyAlpha, 'boolean',\n 'invalid premultiplyAlpha')\n flags.premultiplyAlpha = options.premultiplyAlpha\n }\n\n if ('flipY' in options) {\n check$1.type(options.flipY, 'boolean',\n 'invalid texture flip')\n flags.flipY = options.flipY\n }\n\n if ('alignment' in options) {\n check$1.oneOf(options.alignment, [1, 2, 4, 8],\n 'invalid texture unpack alignment')\n flags.unpackAlignment = options.alignment\n }
1\n\n if ('colorSpace' in options) {\n check$1.parameter(options.colorSpace, colorSpace,\n 'invalid colorSpace')\n flags.colorSpace = colorSpace[options.colorSpace]\n }\n\n if ('type' in options) {\n var type = options.type\n check$1(extensions.oes_texture_float ||\n !(type === 'float' || type === 'float32'),\n 'you must enable the OES_texture_float extension in order to use floating point textures.')\n check$1(extensions.oes_texture_half_float ||\n !(type === 'half float' || type === 'float16'),\n 'you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures.')\n check$1(extensions.webgl_depth_texture ||\n !(type === 'uint16' || type === 'uint32' || type === 'depth stencil'),\n 'you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures.')\n check$1.parameter(type, textureTypes,\n 'invalid texture type')\n flags.type = textureTypes[type]\n }\n\n var w = flags.width\n var h = flags.height\n var c = flags.channels\n var hasChannels = false\n if ('shape' in options) {\n check$1(Array.isArray(options.shape) && options.shape.length >= 2,\n 'shape must be an array')\n w = options.shape[0]\n h = options.shape[1]\n if (options.shape.length === 3) {\n c = options.shape[2]\n check$1(c > 0 && c <= 4, 'invalid number of channels')\n hasChannels = true\n }\n check$1(w >= 0 && w <= limits.maxTextureSize, 'invalid width')\n check$1(h >= 0 && h <= limits.maxTextureSize, 'invalid height')\n } else {\n if ('radius' in options) {\n w = h = options.radius\n check$1(w >= 0 && w <= limits.maxTextureSize, 'invalid radius')\n }\n if ('width' in options) {\n w = options.width\n check$1(w >= 0 && w <= limits.maxTextureSize, 'invalid width')\n }\n if ('height' in options) {\n h = options.height\n check$1(h >= 0 && h <= limits.maxTextureSize, 'invalid height')\n }\n if ('channels' in options) {\n c = options.channels\n check$1(c > 0 && c <= 4, 'invalid number of channels')\n hasChannels = true\n }\n }\n flags.width = w | 0\n flags.height = h | 0\n flags.channels = c | 0\n\n var hasFormat = false\n if ('format' in options) {\n var formatStr = options.format\n check$1(extensions.webgl_depth_texture ||\n !(formatStr === 'depth' || formatStr === 'depth stencil'),\n 'you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures.')\n check$1.parameter(formatStr, textureFormats,\n 'invalid texture format')\n var internalformat = flags.internalformat = textureFormats[formatStr]\n flags.format = colorFormats[internalformat]\n if (formatStr in textureTypes) {\n if (!('type' in options)) {\n flags.type = textureTypes[formatStr]\n }\n }\n if (formatStr in compressedTextureFormats) {\n flags.compressed = true\n }\n hasFormat = true\n }\n\n // Reconcile channels and format\n if (!hasChannels && hasFormat) {\n flags.channels = FORMAT_CHANNELS[flags.format]\n } else if (hasChannels && !hasFormat) {\n if (flags.channels !== CHANNELS_FORMAT[flags.format]) {\n flags.format = flags.internalformat = CHANNELS_FORMAT[flags.channels]\n }\n } else if (hasFormat && hasChannels) {\n check$1(\n flags.channels === FORMAT_CHANNELS[flags.format],\n 'number of channels inconsistent with specified format')\n }\n }\n\n function setFlags (flags) {\n gl.pixelStorei(GL_UNPACK_FLIP_Y_WEBGL, flags.flipY)\n gl.pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_WEBGL, flags.premultiplyAlpha)\n gl.pixelStorei(GL_UNPACK_COLORSPACE_CONVERSION_WEBGL, flags.colorSpace)\n gl.pixelStorei(GL_UNPACK_ALIGNMENT, flags.unpackAlignment)\n }\n\n // -------------------------------------------------------\n // Tex image data\n // -------------------------------------------------------\n function TexImage () {\n TexFlags.call(this)\n\n this.xOffset = 0\n this.yOffset = 0\n\n // data\n this.data = null\n this.needsFree = false\n\n // html element\n this.element = null\n\n // copyTexImage info\n this.needsCopy = false\n }\n\n function parseImage (image, options) {\n var data = null\n if (isPixelData(options)) {\n data = options\n } else if (options) {\n check$1.type(options, 'object', 'invalid pixel data type')\n parseFlags(image, options)\n if ('x' in options) {\n image.xOffset = options.x | 0\n }
1\n if ('y' in options) {\n image.yOffset = options.y | 0\n }\n if (isPixelData(options.data)) {\n data = options.data\n }\n }\n\n check$1(\n !image.compressed ||\n data instanceof Uint8Array,\n 'compressed texture data must be stored in a uint8array')\n\n if (options.copy) {\n check$1(!data, 'can not specify copy and data field for the same texture')\n var viewW = contextState.viewportWidth\n var viewH = contextState.viewportHeight\n image.width = image.width || (viewW - image.xOffset)\n image.height = image.height || (viewH - image.yOffset)\n image.needsCopy = true\n check$1(image.xOffset >= 0 && image.xOffset < viewW &&\n image.yOffset >= 0 && image.yOffset < viewH &&\n image.width > 0 && image.width <= viewW &&\n image.height > 0 && image.height <= viewH,\n 'copy texture read out of bounds')\n } else if (!data) {\n image.width = image.width || 1\n image.height = image.height || 1\n image.channels = image.channels || 4\n } else if (isTypedArray(data)) {\n image.channels = image.channels || 4\n image.data = data\n if (!('type' in options) && image.type === GL_UNSIGNED_BYTE$5) {\n image.type = typedArrayCode$1(data)\n }\n } else if (isNumericArray(data)) {\n image.channels = image.channels || 4\n convertData(image, data)\n image.alignment = 1\n image.needsFree = true\n } else if (isNDArrayLike(data)) {\n var array = data.data\n if (!Array.isArray(array) && image.type === GL_UNSIGNED_BYTE$5) {\n image.type = typedArrayCode$1(array)\n }\n var shape = data.shape\n var stride = data.stride\n var shapeX, shapeY, shapeC, strideX, strideY, strideC\n if (shape.length === 3) {\n shapeC = shape[2]\n strideC = stride[2]\n } else {\n check$1(shape.length === 2, 'invalid ndarray pixel data, must be 2 or 3D')\n shapeC = 1\n strideC = 1\n }\n shapeX = shape[0]\n shapeY = shape[1]\n strideX = stride[0]\n strideY = stride[1]\n image.alignment = 1\n image.width = shapeX\n image.height = shapeY\n image.channels = shapeC\n image.format = image.internalformat = CHANNELS_FORMAT[shapeC]\n image.needsFree = true\n transposeData(image, array, strideX, strideY, strideC, data.offset)\n } else if (isCanvasElement(data) || isOffscreenCanvas(data) || isContext2D(data)) {\n if (isCanvasElement(data) || isOffscreenCanvas(data)) {\n image.element = data\n } else {\n image.element = data.canvas\n }\n image.width = image.element.width\n image.height = image.element.height\n image.channels = 4\n } else if (isBitmap(data)) {\n image.element = data\n image.width = data.width\n image.height = data.height\n image.channels = 4\n } else if (isImageElement(data)) {\n image.element = data\n image.width = data.naturalWidth\n image.height = data.naturalHeight\n image.channels = 4\n } else if (isVideoElement(data)) {\n image.element = data\n image.width = data.videoWidth\n image.height = data.videoHeight\n image.channels = 4\n } else if (isRectArray(data)) {\n var w = image.width || data[0].length\n var h = image.height || data.length\n var c = image.channels\n if (isArrayLike(data[0][0])) {\n c = c || data[0][0].length\n } else {\n c = c || 1\n }\n var arrayShape = flattenUtils.shape(data)\n var n = 1\n for (var dd = 0; dd < arrayShape.length; ++dd) {\n n *= arrayShape[dd]\n }\n var allocData = preConvert(image, n)\n flattenUtils.flatten(data, arrayShape, '', allocData)\n postConvert(image, allocData)\n image.alignment = 1\n image.width = w\n image.height = h\n image.channels = c\n image.format = image.internalformat = CHANNELS_FORMAT[c]\n image.needsFree = true\n }\n\n if (image.type === GL_FLOAT$4) {\n check$1(limits.extensions.indexOf('oes_texture_float') >= 0,\n 'oes_texture_float extension not enabled')\n } else if (image.type === GL_HALF_FLOAT_OES$1) {\n check$1(limits.extensions.indexOf('oes_texture_half_float') >= 0,\n 'oes_texture_half_float extension not enabled')\n }\n\n // do compressed texture validation here.\n }\n\n function setImage (info, target, miplevel) {\n var element = info.element\n var data = info.data\n var internalformat = info.internalformat\n var format = info.format\n var type = info.type\n var width = info.width\n var height = info.height\n\n setFlags(info)\n\n if (element) {\n gl.texImage2D(target, miplevel, format, format, type, element)\n } else if (info.compressed) {\n gl.compressedTexImage2D(target, miplevel, internalformat, width, height, 0, data)\n }
1 else if (info.needsCopy) {\n reglPoll()\n gl.copyTexImage2D(\n target, miplevel, format, info.xOffset, info.yOffset, width, height, 0)\n } else {\n gl.texImage2D(target, miplevel, format, width, height, 0, format, type, data || null)\n }\n }\n\n function setSubImage (info, target, x, y, miplevel) {\n var element = info.element\n var data = info.data\n var internalformat = info.internalformat\n var format = info.format\n var type = info.type\n var width = info.width\n var height = info.height\n\n setFlags(info)\n\n if (element) {\n gl.texSubImage2D(\n target, miplevel, x, y, format, type, element)\n } else if (info.compressed) {\n gl.compressedTexSubImage2D(\n target, miplevel, x, y, internalformat, width, height, data)\n } else if (info.needsCopy) {\n reglPoll()\n gl.copyTexSubImage2D(\n target, miplevel, x, y, info.xOffset, info.yOffset, width, height)\n } else {\n gl.texSubImage2D(\n target, miplevel, x, y, width, height, format, type, data)\n }\n }\n\n // texImage pool\n var imagePool = []\n\n function allocImage () {\n return imagePool.pop() || new TexImage()\n }\n\n function freeImage (image) {\n if (image.needsFree) {\n pool.freeType(image.data)\n }\n TexImage.call(image)\n imagePool.push(image)\n }\n\n // -------------------------------------------------------\n // Mip map\n // -------------------------------------------------------\n function MipMap () {\n TexFlags.call(this)\n\n this.genMipmaps = false\n this.mipmapHint = GL_DONT_CARE\n this.mipmask = 0\n this.images = Array(16)\n }\n\n function parseMipMapFromShape (mipmap, width, height) {\n var img = mipmap.images[0] = allocImage()\n mipmap.mipmask = 1\n img.width = mipmap.width = width\n img.height = mipmap.height = height\n img.channels = mipmap.channels = 4\n }\n\n function parseMipMapFromObject (mipmap, options) {\n var imgData = null\n if (isPixelData(options)) {\n imgData = mipmap.images[0] = allocImage()\n copyFlags(imgData, mipmap)\n parseImage(imgData, options)\n mipmap.mipmask = 1\n } else {\n parseFlags(mipmap, options)\n if (Array.isArray(options.mipmap)) {\n var mipData = options.mipmap\n for (var i = 0; i < mipData.length; ++i) {\n imgData = mipmap.images[i] = allocImage()\n copyFlags(imgData, mipmap)\n imgData.width >>= i\n imgData.height >>= i\n parseImage(imgData, mipData[i])\n mipmap.mipmask |= (1 << i)\n }\n } else {\n imgData = mipmap.images[0] = allocImage()\n copyFlags(imgData, mipmap)\n parseImage(imgData, options)\n mipmap.mipmask = 1\n }\n }\n copyFlags(mipmap, mipmap.images[0])\n\n // For textures of the compressed format WEBGL_compressed_texture_s3tc\n // we must have that\n //\n // \"When level equals zero width and height must be a multiple of 4.\n // When level is greater than 0 width and height must be 0, 1, 2 or a multiple of 4. \"\n //\n // but we do not yet support having multiple mipmap levels for compressed textures,\n // so we only test for level zero.\n\n if (\n mipmap.compressed &&\n (\n mipmap.internalformat === GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||\n mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ||\n mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT3_EXT ||\n mipmap.internalformat === GL_COMPRESSED_RGBA_S3TC_DXT5_EXT\n )\n ) {\n check$1(mipmap.width % 4 === 0 && mipmap.height % 4 === 0,\n 'for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4')\n }\n }\n\n function setMipMap (mipmap, target) {\n var images = mipmap.images\n for (var i = 0; i < images.length; ++i) {\n if (!images[i]) {\n return\n }\n setImage(images[i], target, i)\n }\n }\n\n var mipPool = []\n\n function allocMipMap () {\n var result = mipPool.pop() || new MipMap()\n TexFlags.call(result)\n result.mipmask = 0\n for (var i = 0; i < 16; ++i) {\n result.images[i] = null\n }\n return result\n }\n\n function freeMipMap (mipmap) {\n var images = mipmap.images\n for (var i = 0; i < images.length; ++i) {\n if (images[i]) {\n freeImage(images[i])\n }\n images[i] = null\n }
1\n mipPool.push(mipmap)\n }\n\n // -------------------------------------------------------\n // Tex info\n // -------------------------------------------------------\n function TexInfo () {\n this.minFilter = GL_NEAREST$1\n this.magFilter = GL_NEAREST$1\n\n this.wrapS = GL_CLAMP_TO_EDGE$1\n this.wrapT = GL_CLAMP_TO_EDGE$1\n\n this.anisotropic = 1\n\n this.genMipmaps = false\n this.mipmapHint = GL_DONT_CARE\n }\n\n function parseTexInfo (info, options) {\n if ('min' in options) {\n var minFilter = options.min\n check$1.parameter(minFilter, minFilters)\n info.minFilter = minFilters[minFilter]\n if (MIPMAP_FILTERS.indexOf(info.minFilter) >= 0 && !('faces' in options)) {\n info.genMipmaps = true\n }\n }\n\n if ('mag' in options) {\n var magFilter = options.mag\n check$1.parameter(magFilter, magFilters)\n info.magFilter = magFilters[magFilter]\n }\n\n var wrapS = info.wrapS\n var wrapT = info.wrapT\n if ('wrap' in options) {\n var wrap = options.wrap\n if (typeof wrap === 'string') {\n check$1.parameter(wrap, wrapModes)\n wrapS = wrapT = wrapModes[wrap]\n } else if (Array.isArray(wrap)) {\n check$1.parameter(wrap[0], wrapModes)\n check$1.parameter(wrap[1], wrapModes)\n wrapS = wrapModes[wrap[0]]\n wrapT = wrapModes[wrap[1]]\n }\n } else {\n if ('wrapS' in options) {\n var optWrapS = options.wrapS\n check$1.parameter(optWrapS, wrapModes)\n wrapS = wrapModes[optWrapS]\n }\n if ('wrapT' in options) {\n var optWrapT = options.wrapT\n check$1.parameter(optWrapT, wrapModes)\n wrapT = wrapModes[optWrapT]\n }\n }\n info.wrapS = wrapS\n info.wrapT = wrapT\n\n if ('anisotropic' in options) {\n var anisotropic = options.anisotropic\n check$1(typeof anisotropic === 'number' &&\n anisotropic >= 1 && anisotropic <= limits.maxAnisotropic,\n 'aniso samples must be between 1 and ')\n info.anisotropic = options.anisotropic\n }\n\n if ('mipmap' in options) {\n var hasMipMap = false\n switch (typeof options.mipmap) {\n case 'string':\n check$1.parameter(options.mipmap, mipmapHint,\n 'invalid mipmap hint')\n info.mipmapHint = mipmapHint[options.mipmap]\n info.genMipmaps = true\n hasMipMap = true\n break\n\n case 'boolean':\n hasMipMap = info.genMipmaps = options.mipmap\n break\n\n case 'object':\n check$1(Array.isArray(options.mipmap), 'invalid mipmap type')\n info.genMipmaps = false\n hasMipMap = true\n break\n\n default:\n check$1.raise('invalid mipmap type')\n }\n if (hasMipMap && !('min' in options)) {\n info.minFilter = GL_NEAREST_MIPMAP_NEAREST$1\n }\n }\n }\n\n function setTexInfo (info, target) {\n gl.texParameteri(target, GL_TEXTURE_MIN_FILTER, info.minFilter)\n gl.texParameteri(target, GL_TEXTURE_MAG_FILTER, info.magFilter)\n gl.texParameteri(target, GL_TEXTURE_WRAP_S, info.wrapS)\n gl.texParameteri(target, GL_TEXTURE_WRAP_T, info.wrapT)\n if (extensions.ext_texture_filter_anisotropic) {\n gl.texParameteri(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, info.anisotropic)\n }\n if (info.genMipmaps) {\n gl.hint(GL_GENERATE_MIPMAP_HINT, info.mipmapHint)\n gl.generateMipmap(target)\n }\n }\n\n // -------------------------------------------------------\n // Full texture object\n // -------------------------------------------------------\n var textureCount = 0\n var textureSet = {}\n var numTexUnits = limits.maxTextureUnits\n var textureUnits = Array(numTexUnits).map(function () {\n return null\n })\n\n function REGLTexture (target) {\n TexFlags.call(this)\n this.mipmask = 0\n this.internalformat = GL_RGBA$1\n\n this.id = textureCount++\n\n this.refCount = 1\n\n this.target = target\n this.texture = gl.createTexture()\n\n this.unit = -1\n this.bindCount = 0\n\n this.texInfo = new TexInfo()\n\n if (config.profile) {\n this.stats = { size: 0 }\n }\n }\n\n function tempBind (texture) {\n gl.activeTexture(GL_TEXTURE0$1)\n gl.bindTexture(texture.target, texture.texture)\n }\n\n function tempRestore () {\n var prev = textureUnits[0]\n if (prev) {\n gl.bindTexture(prev.target, prev.texture)\n } else {\n gl.bindTexture(GL_TEXTURE_2D$1, null)\n }\n }\n\n function destroy (texture) {\n var handle = texture.texture\n check$1(handle, 'must not double destroy texture')\n var unit = texture.unit\n var target = texture.target\n if (unit >= 0) {\n gl.activeTexture(GL_TEXTURE0$1 + unit)\n gl.bindTexture(target, null)\n textureUnits[unit] = null\n }\n gl.deleteTexture(handle)\n texture.texture = null\n texture.params = null\n texture.pixels = null\n texture.refCount = 0\n delete textureSet[texture.id]\n stats.textureCount--\n }\n\n extend(REGLTexture.prototype, {\n bind: function () {\n var texture = this\n texture.bindCount += 1\n var unit = texture.unit\n if (unit < 0) {\n for (var i = 0; i < numTexUnits; ++i) {\n var other = textureUnits[i]\n if (other) {\n if (other.bindCount > 0) {\n continue\n }\n other.unit = -1\n }\n textureUnits[i] = texture\n unit = i\n break\n }\n if (unit >= numTexUnits) {\n check$1.raise('insufficient number of texture units')\n }\n if (config.profile && stats.maxTextureUnits < (unit + 1)) {\n stats.maxTextureUnits = unit + 1 // +1, since the units are zero-based\n }\n texture.unit = unit\n gl.activeTexture(GL_TEXTURE0$1 + unit)\n gl.bindTexture(texture.target, texture.texture)\n }\n return unit\n },\n\n unbind: function () {\n this.bindCount -= 1\n },\n\n decRef: function () {\n if (--this.refCount <= 0) {\n destroy(this)\n }\n }\n })\n\n function createTexture2D (a, b) {\n var texture = new REGLTexture(GL_TEXTURE_2D$1)\n textureSet[texture.id] = texture\n stats.textureCount++\n\n function reglTexture2D (a, b) {\n var texInfo = texture.texInfo\n TexInfo.call(texInfo)\n var mipData = allocMipMap()\n\n if (typeof a === 'number') {\n if (typeof b === 'number') {\n parseMipMapFromShape(mipData, a | 0, b | 0)\n } else {\n parseMipMapFromShape(mipData, a | 0, a | 0)\n }\n } else if (a) {\n check$1.type(a, 'object', 'invalid arguments to regl.texture')\n parseTexInfo(texInfo, a)\n parseMipMapFromObject(mipData, a)\n } else {\n // empty textures get assigned a default shape of 1x1\n parseMipMapFromShape(mipData, 1, 1)\n }
1\n\n if (texInfo.genMipmaps) {\n mipData.mipmask = (mipData.width << 1) - 1\n }\n texture.mipmask = mipData.mipmask\n\n copyFlags(texture, mipData)\n\n check$1.texture2D(texInfo, mipData, limits)\n texture.internalformat = mipData.internalformat\n\n reglTexture2D.width = mipData.width\n reglTexture2D.height = mipData.height\n\n tempBind(texture)\n setMipMap(mipData, GL_TEXTURE_2D$1)\n setTexInfo(texInfo, GL_TEXTURE_2D$1)\n tempRestore()\n\n freeMipMap(mipData)\n\n if (config.profile) {\n texture.stats.size = getTextureSize(\n texture.internalformat,\n texture.type,\n mipData.width,\n mipData.height,\n texInfo.genMipmaps,\n false)\n }\n reglTexture2D.format = textureFormatsInvert[texture.internalformat]\n reglTexture2D.type = textureTypesInvert[texture.type]\n\n reglTexture2D.mag = magFiltersInvert[texInfo.magFilter]\n reglTexture2D.min = minFiltersInvert[texInfo.minFilter]\n\n reglTexture2D.wrapS = wrapModesInvert[texInfo.wrapS]\n reglTexture2D.wrapT = wrapModesInvert[texInfo.wrapT]\n\n return reglTexture2D\n }\n\n function subimage (image, x_, y_, level_) {\n check$1(!!image, 'must specify image data')\n\n var x = x_ | 0\n var y = y_ | 0\n var level = level_ | 0\n\n var imageData = allocImage()\n copyFlags(imageData, texture)\n imageData.width = 0\n imageData.height = 0\n parseImage(imageData, image)\n imageData.width = imageData.width || ((texture.width >> level) - x)\n imageData.height = imageData.height || ((texture.height >> level) - y)\n\n check$1(\n texture.type === imageData.type &&\n texture.format === imageData.format &&\n texture.internalformat === imageData.internalformat,\n 'incompatible format for texture.subimage')\n check$1(\n x >= 0 && y >= 0 &&\n x + imageData.width <= texture.width &&\n y + imageData.height <= texture.height,\n 'texture.subimage write out of bounds')\n check$1(\n texture.mipmask & (1 << level),\n 'missing mipmap data')\n check$1(\n imageData.data || imageData.element || imageData.needsCopy,\n 'missing image data')\n\n tempBind(texture)\n setSubImage(imageData, GL_TEXTURE_2D$1, x, y, level)\n tempRestore()\n\n freeImage(imageData)\n\n return reglTexture2D\n }\n\n function resize (w_, h_) {\n var w = w_ | 0\n var h = (h_ | 0) || w\n if (w === texture.width && h === texture.height) {\n return reglTexture2D\n }\n\n reglTexture2D.width = texture.width = w\n reglTexture2D.height = texture.height = h\n\n tempBind(texture)\n\n for (var i = 0; texture.mipmask >> i; ++i) {\n var _w = w >> i\n var _h = h >> i\n if (!_w || !_h) break\n gl.texImage2D(\n GL_TEXTURE_2D$1,\n i,\n texture.format,\n _w,\n _h,\n 0,\n texture.format,\n texture.type,\n null)\n }\n tempRestore()\n\n // also, recompute the texture size.\n if (config.profile) {\n texture.stats.size = getTextureSize(\n texture.internalformat,\n texture.type,\n w,\n h,\n false,\n false)\n }\n\n return reglTexture2D\n }\n\n reglTexture2D(a, b)\n\n reglTexture2D.subimage = subimage\n reglTexture2D.resize = resize\n reglTexture2D._reglType = 'texture2d'\n reglTexture2D._texture = texture\n if (config.profile) {\n reglTexture2D.stats = texture.stats\n }\n reglTexture2D.destroy = function () {\n texture.decRef()\n }\n\n return reglTexture2D\n }\n\n function createTextureCube (a0, a1, a2, a3, a4, a5) {\n var texture = new REGLTexture(GL_TEXTURE_CUBE_MAP$1)\n textureSet[texture.id] = texture\n stats.cubeCount++\n\n var faces = new Array(6)\n\n function reglTextureCube (a0, a1, a2, a3, a4, a5) {\n var i\n var texInfo = texture.texInfo\n TexInfo.call(texInfo)\n for (i = 0; i < 6; ++i) {\n faces[i] = allocMipMap()\n }\n\n if (typeof a0 === 'number' || !a0) {\n var s = (a0 | 0) || 1\n for (i = 0; i < 6; ++i) {\n parseMipMapFromShape(faces[i], s, s)\n }\n } else if (typeof a0 === 'object') {\n if (a1) {\n parseMipMapFromObject(faces[0], a0)\n parseMipMapFromObject(faces[1], a1)\n parseMipMapFromObject(faces[2], a2)\n parseMipMapFromObject(faces[3], a3)\n parseMipMapFromObject(faces[4], a4)\n parseMipMapFromObject(faces[5], a5)\n } else {\n parseTexInfo(texInfo, a0)\n parseFlags(texture, a0)\n if ('faces' in a0) {\n var faceInput = a0.faces\n check$1(Array.isArray(faceInput) && faceInput.length === 6,\n 'cube faces must be a length 6 array')\n for (i = 0; i < 6; ++i) {\n check$1(typeof faceInput[i] === 'object' && !!faceInput[i],\n 'invalid input for cube map face')\n copyFlags(faces[i], texture)\n parseMipMapFromObject(faces[i], faceInput[i])\n }\n } else {\n for (i = 0; i < 6; ++i) {\n parseMipMapFromObject(faces[i], a0)\n }\n }\n }\n } else {\n check$1.raise('invalid arguments to cube map')\n }\n\n copyFlags(texture, faces[0])\n check$1.optional(function () {\n if (!limits.npotTextureCube) {\n check$1(isPow2$1(texture.width) && isPow2$1(texture.height), 'your browser does not support non power or two texture dimensions')\n }\n }
1)\n\n if (texInfo.genMipmaps) {\n texture.mipmask = (faces[0].width << 1) - 1\n } else {\n texture.mipmask = faces[0].mipmask\n }\n\n check$1.textureCube(texture, texInfo, faces, limits)\n texture.internalformat = faces[0].internalformat\n\n reglTextureCube.width = faces[0].width\n reglTextureCube.height = faces[0].height\n\n tempBind(texture)\n for (i = 0; i < 6; ++i) {\n setMipMap(faces[i], GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 + i)\n }\n setTexInfo(texInfo, GL_TEXTURE_CUBE_MAP$1)\n tempRestore()\n\n if (config.profile) {\n texture.stats.size = getTextureSize(\n texture.internalformat,\n texture.type,\n reglTextureCube.width,\n reglTextureCube.height,\n texInfo.genMipmaps,\n true)\n }\n\n reglTextureCube.format = textureFormatsInvert[texture.internalformat]\n reglTextureCube.type = textureTypesInvert[texture.type]\n\n reglTextureCube.mag = magFiltersInvert[texInfo.magFilter]\n reglTextureCube.min = minFiltersInvert[texInfo.minFilter]\n\n reglTextureCube.wrapS = wrapModesInvert[texInfo.wrapS]\n reglTextureCube.wrapT = wrapModesInvert[texInfo.wrapT]\n\n for (i = 0; i < 6; ++i) {\n freeMipMap(faces[i])\n }\n\n return reglTextureCube\n }\n\n function subimage (face, image, x_, y_, level_) {\n check$1(!!image, 'must specify image data')\n check$1(typeof face === 'number' && face === (face | 0) &&\n face >= 0 && face < 6, 'invalid face')\n\n var x = x_ | 0\n var y = y_ | 0\n var level = level_ | 0\n\n var imageData = allocImage()\n copyFlags(imageData, texture)\n imageData.width = 0\n imageData.height = 0\n parseImage(imageData, image)\n imageData.width = imageData.width || ((texture.width >> level) - x)\n imageData.height = imageData.height || ((texture.height >> level) - y)\n\n check$1(\n texture.type === imageData.type &&\n texture.format === imageData.format &&\n texture.internalformat === imageData.internalformat,\n 'incompatible format for texture.subimage')\n check$1(\n x >= 0 && y >= 0 &&\n x + imageData.width <= texture.width &&\n y + imageData.height <= texture.height,\n 'texture.subimage write out of bounds')\n check$1(\n texture.mipmask & (1 << level),\n 'missing mipmap data')\n check$1(\n imageData.data || imageData.element || imageData.needsCopy,\n 'missing image data')\n\n tempBind(texture)\n setSubImage(imageData, GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 + face, x, y, level)\n tempRestore()\n\n freeImage(imageData)\n\n return reglTextureCube\n }\n\n function resize (radius_) {\n var radius = radius_ | 0\n if (radius === texture.width) {\n return\n }\n\n reglTextureCube.width = texture.width = radius\n reglTextureCube.height = texture.height = radius\n\n tempBind(texture)\n for (var i = 0; i < 6; ++i) {\n for (var j = 0; texture.mipmask >> j; ++j) {\n gl.texImage2D(\n GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 + i,\n j,\n texture.format,\n radius >> j,\n radius >> j,\n 0,\n texture.format,\n texture.type,\n null)\n }\n }\n tempRestore()\n\n if (config.profile) {\n texture.stats.size = getTextureSize(\n texture.internalformat,\n texture.type,\n reglTextureCube.width,\n reglTextureCube.height,\n false,\n true)\n }\n\n return reglTextureCube\n }\n\n reglTextureCube(a0, a1, a2, a3, a4, a5)\n\n reglTextureCube.subimage = subimage\n reglTextureCube.resize = resize\n reglTextureCube._reglType = 'textureCube'\n reglTextureCube._texture = texture\n if (config.profile) {\n reglTextureCube.stats = texture.stats\n }\n reglTextureCube.destroy = function () {\n texture.decRef()\n }\n\n return reglTextureCube\n }\n\n // Called when regl is destroyed\n function destroyTextures () {\n for (var i = 0; i < numTexUnits; ++i) {\n gl.activeTexture(GL_TEXTURE0$1 + i)\n gl.bindTexture(GL_TEXTURE_2D$1, null)\n textureUnits[i] = null\n }\n values(textureSet).forEach(destroy)\n\n stats.cubeCount = 0\n stats.textureCount = 0\n }\n\n if (config.profile) {\n stats.getTotalTextureSize = function () {\n var total = 0\n Object.keys(textureSet).forEach(function (key) {\n total += textureSet[key].stats.size\n })\n return total\n }\n }\n\n function restoreTextures () {\n for (var i = 0; i < numTexUnits; ++i) {\n var tex = textureUnits[i]\n if (tex) {\n tex.bindCount = 0\n tex.unit = -1\n textureUnits[i] = null\n }\n }\n\n values(textureSet).forEach(function (texture) {\n texture.texture = gl.createTexture()\n gl.bindTexture(texture.target, texture.texture)\n for (var i = 0; i < 32; ++i) {\n if ((texture.mipmask & (1 << i)) === 0) {\n continue\n }\n if (texture.target === GL_TEXTURE_2D$1) {\n gl.texImage2D(GL_TEXTURE_2D$1,\n i,\n texture.internalformat,\n texture.width >> i,\n texture.height >> i,\n 0,\n texture.internalformat,\n texture.type,\n null)\n } else {\n for (var j = 0; j < 6; ++j) {\n gl.texImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X$1 + j,\n i,\n texture.internalformat,\n texture.width >> i,\n texture.height >> i,\n 0,\n texture.internalformat,\n texture.type,\n null)\n }\n }\n }\n setTexInfo(texture.texInfo, texture.target)\n })\n }\n\n function refreshTextures () {\n for (var i = 0; i < numTexUnits; ++i) {\n var tex = textureUnits[i]\n if (tex) {\n tex.bindCount = 0\n tex.unit = -1\n textureUnits[i] = null\n }\n gl.activeTexture(GL_TEXTURE0$1 + i)\n gl.bindTexture(GL_TEXTURE_2D$1, null)\n gl.bindTexture(GL_TEXTURE_CUBE_MAP$1, null)\n }\n }\n\n return {\n create2D: createTexture2D,\n createCube: createTextureCube,\n clear: destroyTextures,\n getTexture: function (wrapper) {\n return null\n },\n restore: restoreTextures,\n refresh: refreshTextures\n }\n}\n\nvar GL_RENDERBUFFER = 0x8D41\n\nvar GL_RGBA4$1 = 0x8056\nvar GL_RGB5_A1$1 = 0x8057\nvar GL_RGB565$1 = 0x8D62\nvar GL_DEPTH_COMPONENT16 = 0x81A5\nvar GL_STENCIL_INDEX8 = 0x8D48\nvar GL_DEPTH_STENCIL$1 = 0x84F9\n\nvar GL_SRGB8_ALPHA8_EXT = 0x8C43\n\nvar GL_RGBA32F_EXT = 0x8814\n\nvar GL_RGBA16F_EXT = 0x881A\nvar GL_RGB16F_EXT = 0x881B\n\nvar FORMAT_SIZES = []\n\nFORMAT_SIZES[GL_RGBA4$1] = 2\nFORMAT_SIZES[GL_RGB5_A1$1] = 2\nFORMAT_SIZES[GL_RGB565$1] = 2\n\nFORMAT_SIZES[GL_DEPTH_COMPONENT16] = 2\nFORMAT_SIZES[GL_STENCIL_INDEX8] = 1\nFORMAT_SIZES[GL_DEPTH_STENCIL$1] = 4\n\nFORMAT_SIZES[GL_SRGB8_ALPHA8_EXT] = 4\nFORMAT_SIZES[GL_RGBA32F_EXT] = 16\nFORMAT_SIZES[GL_RGBA16F_EXT] = 8\nFORMAT_SIZES[GL_RGB16F_EXT] = 6\n\nfunction getRenderbufferSize (format, width, height) {\n return FORMAT_SIZES[format] * width * height\n}\n\nvar wrapRenderbuffers = function (gl, extensions, limits, stats, config) {\n var formatTypes = {\n 'rgba4': GL_RGBA4$1,\n 'rgb565': GL_RGB565$1,\n 'rgb5 a1': GL_RGB5_A1$1,\n 'depth': G
1L_DEPTH_COMPONENT16,\n 'stencil': GL_STENCIL_INDEX8,\n 'depth stencil': GL_DEPTH_STENCIL$1\n }\n\n if (extensions.ext_srgb) {\n formatTypes['srgba'] = GL_SRGB8_ALPHA8_EXT\n }\n\n if (extensions.ext_color_buffer_half_float) {\n formatTypes['rgba16f'] = GL_RGBA16F_EXT\n formatTypes['rgb16f'] = GL_RGB16F_EXT\n }\n\n if (extensions.webgl_color_buffer_float) {\n formatTypes['rgba32f'] = GL_RGBA32F_EXT\n }\n\n var formatTypesInvert = []\n Object.keys(formatTypes).forEach(function (key) {\n var val = formatTypes[key]\n formatTypesInvert[val] = key\n })\n\n var renderbufferCount = 0\n var renderbufferSet = {}\n\n function REGLRenderbuffer (renderbuffer) {\n this.id = renderbufferCount++\n this.refCount = 1\n\n this.renderbuffer = renderbuffer\n\n this.format = GL_RGBA4$1\n this.width = 0\n this.height = 0\n\n if (config.profile) {\n this.stats = { size: 0 }\n }\n }\n\n REGLRenderbuffer.prototype.decRef = function () {\n if (--this.refCount <= 0) {\n destroy(this)\n }\n }\n\n function destroy (rb) {\n var handle = rb.renderbuffer\n check$1(handle, 'must not double destroy renderbuffer')\n gl.bindRenderbuffer(GL_RENDERBUFFER, null)\n gl.deleteRenderbuffer(handle)\n rb.renderbuffer = null\n rb.refCount = 0\n delete renderbufferSet[rb.id]\n stats.renderbufferCount--\n }\n\n function createRenderbuffer (a, b) {\n var renderbuffer = new REGLRenderbuffer(gl.createRenderbuffer())\n renderbufferSet[renderbuffer.id] = renderbuffer\n stats.renderbufferCount++\n\n function reglRenderbuffer (a, b) {\n var w = 0\n var h = 0\n var format = GL_RGBA4$1\n\n if (typeof a === 'object' && a) {\n var options = a\n if ('shape' in options) {\n var shape = options.shape\n check$1(Array.isArray(shape) && shape.length >= 2,\n 'invalid renderbuffer shape')\n w = shape[0] | 0\n h = shape[1] | 0\n } else {\n if ('radius' in options) {\n w = h = options.radius | 0\n }\n if ('width' in options) {\n w = options.width | 0\n }\n if ('height' in options) {\n h = options.height | 0\n }\n }\n if ('format' in options) {\n check$1.parameter(options.format, formatTypes,\n 'invalid renderbuffer format')\n format = formatTypes[options.format]\n }\n } else if (typeof a === 'number') {\n w = a | 0\n if (typeof b === 'number') {\n h = b | 0\n } else {\n h = w\n }\n } else if (!a) {\n w = h = 1\n } else {\n check$1.raise('invalid arguments to renderbuffer constructor')\n }\n\n // check shape\n check$1(\n w > 0 && h > 0 &&\n w <= limits.maxRenderbufferSize && h <= limits.maxRenderbufferSize,\n 'invalid renderbuffer size')\n\n if (w === renderbuffer.width &&\n h === renderbuffer.height &&\n format === renderbuffer.format) {\n return\n }\n\n reglRenderbuffer.width = renderbuffer.width = w\n reglRenderbuffer.height = renderbuffer.height = h\n renderbuffer.format = format\n\n gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffer.renderbuffer)\n gl.renderbufferStorage(GL_RENDERBUFFER, format, w, h)\n\n check$1(\n gl.getError() === 0,\n 'invalid render buffer format')\n\n if (config.profile) {\n renderbuffer.stats.size = getRenderbufferSize(renderbuffer.format, renderbuffer.width, renderbuffer.height)\n }\n reglRenderbuffer.format = formatTypesInvert[renderbuffer.format]\n\n return reglRenderbuffer\n }\n\n function resize (w_, h_) {\n var w = w_ | 0\n var h = (h_ | 0) || w\n\n if (w === renderbuffer.width && h === renderbuffer.height) {\n return reglRenderbuffer\n }\n\n // check shape\n check$1(\n w > 0 && h > 0 &&\n w <= limits.maxRenderbufferSize && h <= limits.maxRenderbufferSize,\n 'invalid renderbuffer size')\n\n reglRenderbuffer.width = renderbuffer.width = w\n reglRenderbuffer.he
1ight = renderbuffer.height = h\n\n gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffer.renderbuffer)\n gl.renderbufferStorage(GL_RENDERBUFFER, renderbuffer.format, w, h)\n\n check$1(\n gl.getError() === 0,\n 'invalid render buffer format')\n\n // also, recompute size.\n if (config.profile) {\n renderbuffer.stats.size = getRenderbufferSize(\n renderbuffer.format, renderbuffer.width, renderbuffer.height)\n }\n\n return reglRenderbuffer\n }\n\n reglRenderbuffer(a, b)\n\n reglRenderbuffer.resize = resize\n reglRenderbuffer._reglType = 'renderbuffer'\n reglRenderbuffer._renderbuffer = renderbuffer\n if (config.profile) {\n reglRenderbuffer.stats = renderbuffer.stats\n }\n reglRenderbuffer.destroy = function () {\n renderbuffer.decRef()\n }\n\n return reglRenderbuffer\n }\n\n if (config.profile) {\n stats.getTotalRenderbufferSize = function () {\n var total = 0\n Object.keys(renderbufferSet).forEach(function (key) {\n total += renderbufferSet[key].stats.size\n })\n return total\n }\n }\n\n function restoreRenderbuffers () {\n values(renderbufferSet).forEach(function (rb) {\n rb.renderbuffer = gl.createRenderbuffer()\n gl.bindRenderbuffer(GL_RENDERBUFFER, rb.renderbuffer)\n gl.renderbufferStorage(GL_RENDERBUFFER, rb.format, rb.width, rb.height)\n })\n gl.bindRenderbuffer(GL_RENDERBUFFER, null)\n }\n\n return {\n create: createRenderbuffer,\n clear: function () {\n values(renderbufferSet).forEach(destroy)\n },\n restore: restoreRenderbuffers\n }\n}\n\n// We store these constants so that the minifier can inline them\nvar GL_FRAMEBUFFER$1 = 0x8D40\nvar GL_RENDERBUFFER$1 = 0x8D41\n\nvar GL_TEXTURE_2D$2 = 0x0DE1\nvar GL_TEXTURE_CUBE_MAP_POSITIVE_X$2 = 0x8515\n\nvar GL_COLOR_ATTACHMENT0$1 = 0x8CE0\nvar GL_DEPTH_ATTACHMENT = 0x8D00\nvar GL_STENCIL_ATTACHMENT = 0x8D20\nvar GL_DEPTH_STENCIL_ATTACHMENT = 0x821A\n\nvar GL_FRAMEBUFFER_COMPLETE$1 = 0x8CD5\nvar GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6\nvar GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7\nvar GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9\nvar GL_FRAMEBUFFER_UNSUPPORTED = 0x8CDD\n\nvar GL_HALF_FLOAT_OES$2 = 0x8D61\nvar GL_UNSIGNED_BYTE$6 = 0x1401\nvar GL_FLOAT$5 = 0x1406\n\nvar GL_RGB$1 = 0x1907\nvar GL_RGBA$2 = 0x1908\n\nvar GL_DEPTH_COMPONENT$1 = 0x1902\n\nvar colorTextureFormatEnums = [\n GL_RGB$1,\n GL_RGBA$2\n]\n\n// for every texture format, store\n// the number of channels\nvar textureFormatChannels = []\ntextureFormatChannels[GL_RGBA$2] = 4\ntextureFormatChannels[GL_RGB$1] = 3\n\n// for every texture type, store\n// the size in bytes.\nvar textureTypeSizes = []\ntextureTypeSizes[GL_UNSIGNED_BYTE$6] = 1\ntextureTypeSizes[GL_FLOAT$5] = 4\ntextureTypeSizes[GL_HALF_FLOAT_OES$2] = 2\n\nvar GL_RGBA4$2 = 0x8056\nvar GL_RGB5_A1$2 = 0x8057\nvar GL_RGB565$2 = 0x8D62\nvar GL_DEPTH_COMPONENT16$1 = 0x81A5\nvar GL_STENCIL_INDEX8$1 = 0x8D48\nvar GL_DEPTH_STENCIL$2 = 0x84F9\n\nvar GL_SRGB8_ALPHA8_EXT$1 = 0x8C43\n\nvar GL_RGBA32F_EXT$1 = 0x8814\n\nvar GL_RGBA16F_EXT$1 = 0x881A\nvar GL_RGB16F_EXT$1 = 0x881B\n\nvar colorRen
1derbufferFormatEnums = [\n GL_RGBA4$2,\n GL_RGB5_A1$2,\n GL_RGB565$2,\n GL_SRGB8_ALPHA8_EXT$1,\n GL_RGBA16F_EXT$1,\n GL_RGB16F_EXT$1,\n GL_RGBA32F_EXT$1\n]\n\nvar statusCode = {}\nstatusCode[GL_FRAMEBUFFER_COMPLETE$1] = 'complete'\nstatusCode[GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT] = 'incomplete attachment'\nstatusCode[GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS] = 'incomplete dimensions'\nstatusCode[GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT] = 'incomplete, missing attachment'\nstatusCode[GL_FRAMEBUFFER_UNSUPPORTED] = 'unsupported'\n\nfunction wrapFBOState (\n gl,\n extensions,\n limits,\n textureState,\n renderbufferState,\n stats) {\n var framebufferState = {\n cur: null,\n next: null,\n dirty: false,\n setFBO: null\n }\n\n var colorTextureFormats = ['rgba']\n var colorRenderbufferFormats = ['rgba4', 'rgb565', 'rgb5 a1']\n\n if (extensions.ext_srgb) {\n colorRenderbufferFormats.push('srgba')\n }\n\n if (extensions.ext_color_buffer_half_float) {\n colorRenderbufferFormats.push('rgba16f', 'rgb16f')\n }\n\n if (extensions.webgl_color_buffer_float) {\n colorRenderbufferFormats.push('rgba32f')\n }\n\n var colorTypes = ['uint8']\n if (extensions.oes_texture_half_float) {\n colorTypes.push('half float', 'float16')\n }\n if (extensions.oes_texture_float) {\n colorTypes.push('float', 'float32')\n }\n\n function FramebufferAttachment (target, texture, renderbuffer) {\n this.target = target\n this.texture = texture\n this.renderbuffer = renderbuffer\n\n var w = 0\n var h = 0\n if (texture) {\n w = texture.width\n h = texture.height\n } else if (renderbuffer) {\n w = renderbuffer.width\n h = renderbuffer.height\n }\n this.width = w\n this.height = h\n }\n\n function decRef (attachment) {\n if (attachment) {\n if (attachment.texture) {\n attachment.texture._texture.decRef()\n }\n if (attachment.renderbuffer) {\n attachment.renderbuffer._renderbuffer.decRef()\n }\n }\n }\n\n function incRefAndCheckShape (attachment, width, height) {\n if (!attachment) {\n return\n }\n if (attachment.texture) {\n var texture = attachment.texture._texture\n var tw = Math.max(1, texture.width)\n var th = Math.max(1, texture.height)\n check$1(tw === width && th === height,\n 'inconsistent width/height for supplied texture')\n texture.refCount += 1\n } else {\n var renderbuffer = attachment.renderbuffer._renderbuffer\n check$1(\n renderbuffer.width === width && renderbuffer.height === height,\n 'inconsistent width/height for renderbuffer')\n renderbuffer.refCount += 1\n }\n }\n\n function attach (location, attachment) {\n if (attachment) {\n if (attachment.texture) {\n gl.framebufferTexture2D(\n GL_FRAMEBUFFER$1,\n location,\n attachment.target,\n attachment.texture._texture.texture,\n 0)\n } else {\n gl.framebufferRenderbuffer(\n GL_FRAMEBUFFER$1,\n location,\n GL_RENDERBUFFER$1,\n attachment.renderbuffer._renderbuffer.renderbuffer)\n }\n }\n }\n\n function parseAttachment (attachment) {\n var target = GL_TEXTURE_2D$2\n var texture = null\n var renderbuffer = null\n\n var data = attachment\n if (typeof attachment === 'object') {\n data = attachment.data\n if ('target' in attachment) {\n target = attachment.target | 0\n }\n }\n\n check$1.type(data, 'function', 'invalid attachment data')\n\n var type = data._reglType\n if (type === 'texture2d') {\n texture = data\n check$1(target === GL_TEXTURE_2D$2)\n } else if (type === 'textureCube') {\n texture = data\n check$1(\n target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X$2 &&\n target < GL_TEXTURE_CUBE_MAP_POSITIVE_X$2 + 6,\n 'invalid cube map target')\n } else if (type === 'renderbuffer') {\n renderbuffer = data\n target = GL_RENDERBUFFER$1\n } else {\n check$1.raise('invalid regl object for attachment')\n }\n\n return new FramebufferAttachment(target, texture, renderbuffer)\n }\n\n function allocAttachment (\n width,\n height,\n isTexture,\n format,\n type) {\n if (isTexture) {\n var texture = textureState.create2D({\n width: width,\n height: height,\n format: format,\n type: type\n })\n texture._texture.refCount = 0\n return new FramebufferAttachment(GL_TEXTURE_2D$2, texture, null)\n } else {\n var rb = renderbufferState.create({\n width: width,\n height: height,\n format: format\n })\n rb._renderbuffer.refCount = 0\n return new FramebufferAttachment(GL_RENDERBUFFER$1, null, rb)\n }\n }\n\n function unwrapAttachment (attachment) {\n return attachment && (attachment.texture || attachment.renderbuffer)\n }\n\n function resizeAttachment (attachment, w, h) {\n if (attachment) {\n if (attachment.texture) {\n attachment.texture.resize(w, h)\n } else if (attachment.renderbuffer) {\n attachment.renderbuffer.resize(w, h)\n }\n attachment.width = w\n attachment.height = h\n }\n }\n\n var framebufferCount = 0\n var framebufferSet = {}\n\n function REGLFramebuffer () {\n this.id = framebufferCount++\n framebufferSet[this.id] = this\n\n this.framebuffer = gl.createFramebuffer()\n this.width = 0\n this.height = 0\n\n this.colorAttachments = []\n this.depthAttachment = null\n this.stencilAttachment = null\n this.depthStencilAttachment = null\n }\n\n function decFBORefs (framebuffer) {\n framebuffer.colorAttachments.forEac
1h(decRef)\n decRef(framebuffer.depthAttachment)\n decRef(framebuffer.stencilAttachment)\n decRef(framebuffer.depthStencilAttachment)\n }\n\n function destroy (framebuffer) {\n var handle = framebuffer.framebuffer\n check$1(handle, 'must not double destroy framebuffer')\n gl.deleteFramebuffer(handle)\n framebuffer.framebuffer = null\n stats.framebufferCount--\n delete framebufferSet[framebuffer.id]\n }\n\n function updateFramebuffer (framebuffer) {\n var i\n\n gl.bindFramebuffer(GL_FRAMEBUFFER$1, framebuffer.framebuffer)\n var colorAttachments = framebuffer.colorAttachments\n for (i = 0; i < colorAttachments.length; ++i) {\n attach(GL_COLOR_ATTACHMENT0$1 + i, colorAttachments[i])\n }\n for (i = colorAttachments.length; i < limits.maxColorAttachments; ++i) {\n gl.framebufferTexture2D(\n GL_FRAMEBUFFER$1,\n GL_COLOR_ATTACHMENT0$1 + i,\n GL_TEXTURE_2D$2,\n null,\n 0)\n }\n\n gl.framebufferTexture2D(\n GL_FRAMEBUFFER$1,\n GL_DEPTH_STENCIL_ATTACHMENT,\n GL_TEXTURE_2D$2,\n null,\n 0)\n gl.framebufferTexture2D(\n GL_FRAMEBUFFER$1,\n GL_DEPTH_ATTACHMENT,\n GL_TEXTURE_2D$2,\n null,\n 0)\n gl.framebufferTexture2D(\n GL_FRAMEBUFFER$1,\n GL_STENCIL_ATTACHMENT,\n GL_TEXTURE_2D$2,\n null,\n 0)\n\n attach(GL_DEPTH_ATTACHMENT, framebuffer.depthAttachment)\n attach(GL_STENCIL_ATTACHMENT, framebuffer.stencilAttachment)\n attach(GL_DEPTH_STENCIL_ATTACHMENT, framebuffer.depthStencilAttachment)\n\n // Check status code\n var status = gl.checkFramebufferStatus(GL_FRAMEBUFFER$1)\n if (!gl.isContextLost() && status !== GL_FRAMEBUFFER_COMPLETE$1) {\n check$1.raise('framebuffer configuration not supported, status = ' +\n statusCode[status])\n }\n\n gl.bindFramebuffer(GL_FRAMEBUFFER$1, framebufferState.next ? framebufferState.next.framebuffer : null)\n framebufferState.cur = framebufferState.next\n\n // FIXME: Clear error code here. This is a work around for a bug in\n // headless-gl\n gl.getError()\n }\n\n function createFBO (a0, a1) {\n var framebuffer = new REGLFramebuffer()\n stats.framebufferCount++\n\n function reglFramebuffer (a, b) {\n var i\n\n check$1(framebufferState.next !== framebuffer,\n 'can not update framebuffer which is currently in use')\n\n var width = 0\n var height = 0\n\n var needsDepth = true\n var needsStencil = true\n\n var colorBuffer = null\n var colorTexture = true\n var colorFormat = 'rgba'\n var colorType = 'uint8'\n var colorCount = 1\n\n var depthBuffer = null\n var stencilBuffer = null\n var depthStencilBuffer = null\n var depthStencilTexture = false\n\n if (typeof a === 'number') {\n width = a | 0\n height = (b | 0) || width\n } else if (!a) {\n width = height = 1\n } else {\n check$1.type(a, 'object', 'invalid arguments for framebuffer')\n var options = a\n\n if ('shape' in options) {\n var shape = options.shape\n check$1(Array.isArray(shape) && shape.length >= 2,\n 'invalid shape for framebuffer')\n width = shape[0]\n height = shape[1]\n } else {\n if ('radius' in options) {\n width = height = options.radius\n }\n if ('width' in options) {\n width = options.width\n }\n if ('height' in options) {\n height = options.height\n }\n }\n\n if ('color' in options ||\n 'colors' in options) {\n colorBuffer =\n options.color ||\n options.colors\n if (Array.isArray(colorBuffer)) {\n check$1(\n colorBuffer.length === 1 || extensions.webgl_draw_buffers,\n 'multiple render targets not supported')\n }\n }\n\n if (!colorBuffer) {\n if ('colorCount' in options) {\n colorCount = options.colorCount | 0\n check$1(colorCount > 0, 'invalid color buffer count')\n }
1\n\n if ('colorTexture' in options) {\n colorTexture = !!options.colorTexture\n colorFormat = 'rgba4'\n }\n\n if ('colorType' in options) {\n colorType = options.colorType\n if (!colorTexture) {\n if (colorType === 'half float' || colorType === 'float16') {\n check$1(extensions.ext_color_buffer_half_float,\n 'you must enable EXT_color_buffer_half_float to use 16-bit render buffers')\n colorFormat = 'rgba16f'\n } else if (colorType === 'float' || colorType === 'float32') {\n check$1(extensions.webgl_color_buffer_float,\n 'you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers')\n colorFormat = 'rgba32f'\n }\n } else {\n check$1(extensions.oes_texture_float ||\n !(colorType === 'float' || colorType === 'float32'),\n 'you must enable OES_texture_float in order to use floating point framebuffer objects')\n check$1(extensions.oes_texture_half_float ||\n !(colorType === 'half float' || colorType === 'float16'),\n 'you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects')\n }\n check$1.oneOf(colorType, colorTypes, 'invalid color type')\n }\n\n if ('colorFormat' in options) {\n colorFormat = options.colorFormat\n if (colorTextureFormats.indexOf(colorFormat) >= 0) {\n colorTexture = true\n } else if (colorRenderbufferFormats.indexOf(colorFormat) >= 0) {\n colorTexture = false\n } else {\n check$1.optional(function () {\n if (colorTexture) {\n check$1.oneOf(\n options.colorFormat, colorTextureFormats,\n 'invalid color format for texture')\n } else {\n check$1.oneOf(\n options.colorFormat, colorRenderbufferFormats,\n 'invalid color format for renderbuffer')\n }\n })\n }\n }\n }\n\n if ('depthTexture' in options || 'depthStencilTexture' in options) {\n depthStencilTexture = !!(options.depthTexture ||\n options.depthStencilTexture)\n check$1(!depthStencilTexture || extensions.webgl_depth_texture,\n 'webgl_depth_texture extension not supported')\n }\n\n if ('depth' in options) {\n if (typeof options.depth === 'boolean') {\n needsDepth = options.depth\n } else {\n depthBuffer = options.depth\n needsStencil = false\n }\n }\n\n if ('stencil' in options) {\n if (typeof options.stencil === 'boolean') {\n needsStencil = options.stencil\n } else {\n stencilBuffer = options.stencil\n needsDepth = false\n }\n }\n\n if ('depthStencil' in options) {\n if (typeof options.depthStencil === 'boolean') {\n needsDepth = needsStencil = options.depthStencil\n } else {\n depthStencilBuffer = options.depthStencil\n needsDepth = false\n needsStencil = false\n }\n }\n }\n\n // parse attachments\n var colorAttachments = null\n var depthAttachment = null\n var stencilAttachment = null\n var depthStencilAttachment = null\n\n // Set up color attachments\n if (Array.isArray(colorBuffer)) {\n colorAttachments = colorBuffer.map(parseAttachment)\n } else if (colorBuffer) {\n colorAttachments = [parseAttachment(colorBuffer)]\n } else {\n colorAttachments = new Array(colorCount)\n for (i = 0; i < colorCount; ++i) {\n colorAttachments[i] = allocAttachment(\n width,\n height,\n colorTexture,\n colorFormat,\n colorType)\n }\n }\n\n check$1(extensions.webgl_draw_buffers || colorAttachments.length <= 1,\n 'you must enable the WEBGL_draw_buffers extension in order to use multiple color buffers.')\n check$1(colorAttachments.length <= limits.maxColorAttachments,\n 'too many color attachments, not supported')\n\n width = width || colorAttachments[0].width\n height = height || colorAttachments[0].height\n\n if (depthBuffer) {\n depthAttachment = parseAttachment(depthBuffer)\n } else if (needsDepth && !needsStencil) {\n depthAttachment = allocAttachment(\n width,\n height,\n depthStencilTexture,\n 'depth',\n 'uint32')\n }\n\n if (stencilBuffer) {\n stencilAttachment = parseAttachment(stencilBuffer)\n } else if (needsStencil && !needsDepth) {\n stencilAttachment = allocAttachment(\n width,\n height,\n false,\n 'stencil',\n 'uint8')\n }\n\n if (depthStencilBuffer) {\n depthStencilAttachment = parseAttachment(depthStencilBuffer)\n } else if (!depthBuffer && !stencilBuffer && needsStencil && needsDepth) {\n depthStencilAttachment = allocAttachment(\n width,\n height,\n depthStencilTexture,\n 'depth stencil',\n 'depth stencil')\n }\n\n check$1(\n (!!depthBuffer) + (!!stencilBuffer) + (!!depthStencilBuffer) <= 1,\n 'invalid framebuffer configuration, can specify exactly one depth/stencil attachment')\n\n var commonColorAttachmentSize = null\n\n for (i = 0; i < colorAttachments.length; ++i) {\n incRefAndCheckShape(colorAttachments[i], width, height)\n check$1(!colorAttachments[i] ||\n (colorAttachments[i].texture &&\n colorTextureFormatEnums.indexOf(colorAttachments[i].texture._texture.format) >= 0) ||\n (colorAttachments[i].renderbuffer &&\n colorRen
1derbufferFormatEnums.indexOf(colorAttachments[i].renderbuffer._renderbuffer.format) >= 0),\n 'framebuffer color attachment ' + i + ' is invalid')\n\n if (colorAttachments[i] && colorAttachments[i].texture) {\n var colorAttachmentSize =\n textureFormatChannels[colorAttachments[i].texture._texture.format] *\n textureTypeSizes[colorAttachments[i].texture._texture.type]\n\n if (commonColorAttachmentSize === null) {\n commonColorAttachmentSize = colorAttachmentSize\n } else {\n // We need to make sure that all color attachments have the same number of bitplanes\n // (that is, the same numer of bits per pixel)\n // This is required by the GLES2.0 standard. See the beginning of Chapter 4 in that document.\n check$1(commonColorAttachmentSize === colorAttachmentSize,\n 'all color attachments much have the same number of bits per pixel.')\n }\n }\n }\n incRefAndCheckShape(depthAttachment, width, height)\n check$1(!depthAttachment ||\n (depthAttachment.texture &&\n depthAttachment.texture._texture.format === GL_DEPTH_COMPONENT$1) ||\n (depthAttachment.renderbuffer &&\n depthAttachment.renderbuffer._renderbuffer.format === GL_DEPTH_COMPONENT16$1),\n 'invalid depth attachment for framebuffer object')\n incRefAndCheckShape(stencilAttachment, width, height)\n check$1(!stencilAttachment ||\n (stencilAttachment.renderbuffer &&\n stencilAttachment.renderbuffer._renderbuffer.format === GL_STENCIL_INDEX8$1),\n 'invalid stencil attachment for framebuffer object')\n incRefAndCheckShape(depthStencilAttachment, width, height)\n check$1(!depthStencilAttachment ||\n (depthStencilAttachment.texture &&\n depthStencilAttachment.texture._texture.format === GL_DEPTH_STENCIL$2) ||\n (depthStencilAttachment.renderbuffer &&\n depthStencilAttachment.renderbuffer._renderbuffer.format === GL_DEPTH_STENCIL$2),\n 'invalid depth-stencil attachment for framebuffer object')\n\n // decrement references\n decFBORefs(framebuffer)\n\n framebuffer.width = width\n framebuffer.height = height\n\n framebuffer.colorAttachments = colorAttachments\n framebuffer.depthAttachment = depthAttachment\n framebuffer.stencilAttachment = stencilAttachment\n framebuffer.depthStencilAttachment = depthStencilAttachment\n\n reglFramebuffer.color = colorAttachments.map(unwrapAttachment)\n reglFramebuffer.depth = unwrapAttachment(depthAttachment)\n reglFramebuffer.stencil = unwrapAttachment(stencilAttachment)\n reglFramebuffer.depthStencil = unwrapAttachment(depthStencilAttachment)\n\n reglFramebuffer.width = framebuffer.width\n reglFramebuffer.height = framebuffer.height\n\n updateFramebuffer(framebuffer)\n\n return reglFramebuffer\n }\n\n function resize (w_, h_) {\n check$1(framebufferState.next !== framebuffer,\n 'can not resize a framebuffer which is currently in use')\n\n var w = Math.max(w_ | 0, 1)\n var h = Math.max((h_ | 0) || w, 1)\n if (w === framebuffer.width && h === framebuffer.height) {\n return reglFramebuffer\n }\n\n // resize all buffers\n var colorAttachments = framebuffer.colorAttachments\n for (var i = 0; i < colorAttachments.length; ++i) {\n resizeAttachment(colorAttachments[i], w, h)\n }\n resizeAttachment(framebuffer.depthAttachment, w, h)\n resizeAttachment(framebuffer.stencilAttachment, w, h)\n resizeAttachment(framebuffer.depthStencilAttachment, w, h)\n\n framebuffer.width = reglFramebuffer.width = w\n framebuffer.height = reglFramebuffer.height = h\n\n updateFramebuffer(framebuffer)\n\n return reglFramebuffer\n }\n\n reglFramebuffer(a0, a1)\n\n return extend(reglFramebuffer, {\n resize: resize,\n _reglType: 'framebuffer',\n _framebuffer: framebuffer,\n destroy: function () {\n destroy(framebuffer)\n decFBORefs(framebuffer)\n },\n use: function (block) {\n framebufferState.setFBO({\n framebuffer: reglFramebuffer\n }, block)\n }\n })\n }\n\n function createCubeFBO (options) {\n var faces = Array(6)\n\n function reglFramebufferCube (a) {\n var i\n\n check$1(faces.indexOf(framebufferState.next) < 0,\n 'can not update framebuffer which is currently in use')\n\n var params = {\n color: null\n }\n\n var radius = 0\n\n var colorBuffer = null\n var colorFormat = 'rgba'\
1n var colorType = 'uint8'\n var colorCount = 1\n\n if (typeof a === 'number') {\n radius = a | 0\n } else if (!a) {\n radius = 1\n } else {\n check$1.type(a, 'object', 'invalid arguments for framebuffer')\n var options = a\n\n if ('shape' in options) {\n var shape = options.shape\n check$1(\n Array.isArray(shape) && shape.length >= 2,\n 'invalid shape for framebuffer')\n check$1(\n shape[0] === shape[1],\n 'cube framebuffer must be square')\n radius = shape[0]\n } else {\n if ('radius' in options) {\n radius = options.radius | 0\n }\n if ('width' in options) {\n radius = options.width | 0\n if ('height' in options) {\n check$1(options.height === radius, 'must be square')\n }\n } else if ('height' in options) {\n radius = options.height | 0\n }\n }\n\n if ('color' in options ||\n 'colors' in options) {\n colorBuffer =\n options.color ||\n options.colors\n if (Array.isArray(colorBuffer)) {\n check$1(\n colorBuffer.length === 1 || extensions.webgl_draw_buffers,\n 'multiple render targets not supported')\n }\n }\n\n if (!colorBuffer) {\n if ('colorCount' in options) {\n colorCount = options.colorCount | 0\n check$1(colorCount > 0, 'invalid color buffer count')\n }\n\n if ('colorType' in options) {\n check$1.oneOf(\n options.colorType, colorTypes,\n 'invalid color type')\n colorType = options.colorType\n }\n\n if ('colorFormat' in options) {\n colorFormat = options.colorFormat\n check$1.oneOf(\n options.colorFormat, colorTextureFormats,\n 'invalid color format for texture')\n }\n }\n\n if ('depth' in options) {\n params.depth = options.depth\n }\n\n if ('stencil' in options) {\n params.stencil = options.stencil\n }\n\n if ('depthStencil' in options) {\n params.depthStencil = options.depthStencil\n }\n }\n\n var colorCubes\n if (colorBuffer) {\n if (Array.isArray(colorBuffer)) {\n colorCubes = []\n for (i = 0; i < colorBuffer.length; ++i) {\n colorCubes[i] = colorBuffer[i]\n }\n } else {\n colorCubes = [ colorBuffer ]\n }\n } else {\n colorCubes = Array(colorCount)\n var cubeMapParams = {\n radius: radius,\n format: colorFormat,\n type: colorType\n }\n for (i = 0; i < colorCount; ++i) {\n colorCubes[i] = textureState.createCube(cubeMapParams)\n }\n }\n\n // Check color cubes\n params.color = Array(colorCubes.length)\n for (i = 0; i < colorCubes.length; ++i) {\n var cube = colorCubes[i]\n check$1(\n typeof cube === 'function' && cube._reglType === 'textureCube',\n 'invalid cube map')\n radius = radius || cube.width\n check$1(\n cube.width === radius && cube.height === radius,\n 'invalid cube map shape')\n params.color[i] = {\n target: GL_TEXTURE_CUBE_MAP_POSITIVE_X$2,\n data: colorCubes[i]\n }\n }\n\n for (i = 0; i < 6; ++i) {\n for (var j = 0; j < colorCubes.length; ++j) {\n params.color[j].target = GL_TEXTURE_CUBE_MAP_POSITIVE_X$2 + i\n }\n // reuse depth-stencil attachments across all cube maps\n if (i > 0) {\n params.depth = faces[0].depth\n params.stencil = faces[0].stencil\n params.depthStencil = faces[0].depthStencil\n }\n if (faces[i]) {\n (faces[i])(params)\n } else {\n faces[i] = createFBO(params)\n }\n }\n\n return extend(reglFramebufferCube, {\n width: radius,\
1n height: radius,\n color: colorCubes\n })\n }\n\n function resize (radius_) {\n var i\n var radius = radius_ | 0\n check$1(radius > 0 && radius <= limits.maxCubeMapSize,\n 'invalid radius for cube fbo')\n\n if (radius === reglFramebufferCube.width) {\n return reglFramebufferCube\n }\n\n var colors = reglFramebufferCube.color\n for (i = 0; i < colors.length; ++i) {\n colors[i].resize(radius)\n }\n\n for (i = 0; i < 6; ++i) {\n faces[i].resize(radius)\n }\n\n reglFramebufferCube.width = reglFramebufferCube.height = radius\n\n return reglFramebufferCube\n }\n\n reglFramebufferCube(options)\n\n return extend(reglFramebufferCube, {\n faces: faces,\n resize: resize,\n _reglType: 'framebufferCube',\n destroy: function () {\n faces.forEach(function (f) {\n f.destroy()\n })\n }\n })\n }\n\n function restoreFramebuffers () {\n framebufferState.cur = null\n framebufferState.next = null\n framebufferState.dirty = true\n values(framebufferSet).forEach(function (fb) {\n fb.framebuffer = gl.createFramebuffer()\n updateFramebuffer(fb)\n })\n }\n\n return extend(framebufferState, {\n getFramebuffer: function (object) {\n if (typeof object === 'function' && object._reglType === 'framebuffer') {\n var fbo = object._framebuffer\n if (fbo instanceof REGLFramebuffer) {\n return fbo\n }\n }\n return null\n },\n create: createFBO,\n createCube: createCubeFBO,\n clear: function () {\n values(framebufferSet).forEach(destroy)\n },\n restore: restoreFramebuffers\n })\n}\n\nvar GL_FLOAT$6 = 5126\nvar GL_ARRAY_BUFFER$1 = 34962\nvar GL_ELEMENT_ARRAY_BUFFER$1 = 34963\n\nvar VAO_OPTIONS = [\n 'attributes',\n 'elements',\n 'offset',\n 'count',\n 'primitive',\n 'instances'\n]\n\nfunction AttributeRecord () {\n this.state = 0\n\n this.x = 0.0\n this.y = 0.0\n this.z = 0.0\n this.w = 0.0\n\n this.buffer = null\n this.size = 0\n this.normalized = false\n this.type = GL_FLOAT$6\n this.offset = 0\n this.stride = 0\n this.divisor = 0\n}\n\nfunction wrapAttributeState (\n gl,\n extensions,\n limits,\n stats,\n bufferState,\n elementState,\n drawState) {\n var NUM_ATTRIBUTES = limits.maxAttributes\n var attributeBindings = new Array(NUM_ATTRIBUTES)\n for (var i = 0; i < NUM_ATTRIBUTES; ++i) {\n attributeBindings[i] = new AttributeRecord()\n }\n var vaoCount = 0\n var vaoSet = {}\n\n var state = {\n Record: AttributeRecord,\n scope: {},\n state: attributeBindings,\n currentVAO: null,\n targetVAO: null,\n restore: extVAO() ? restoreVAO : function () {},\n createVAO: createVAO,\n getVAO: getVAO,\n destroyBuffer: destroyBuffer,\n setVAO: extVAO() ? setVAOEXT : setVAOEmulated,\n clear: extVAO() ? destroyVAOEXT : function () {}\n }\n\n function destroyBuffer (buffer) {\n for (var i = 0; i < attributeBindings.length; ++i) {\n var record = attributeBindings[i]\n if (record.buffer === buffer) {\n gl.disableVertexAttribArray(i)\n record.buffer = null\n }\n }\n }\n\n function extVAO () {\n return extensions.oes_vertex_array_object\n }\n\n function extInstanced () {\n return extensions.angle_instanced_arrays\n }\n\n function getVAO (vao) {\n if (typeof vao === 'function' && vao._vao) {\n return vao._vao\n }\n return null\n }\n\n function setVAOEXT (vao) {\n if (vao === state.currentVAO) {\n return\n }\n var ext = extVAO()\n if (vao) {\n ext.bindVertexArrayOES(vao.vao)\n } else {\n ext.bindVertexArrayOES(null)\n }\n state.currentVAO = vao\n }\n\n function setVAOEmulated (vao) {\n if (vao === state.currentVAO) {\n return\n }\n if (vao) {\n vao.bindAttrs()\n } else {\n var exti = extInstanced()\n for (var i = 0; i < attributeBindings.length; ++i) {\n var binding = attributeBindings[i]\n if (binding.buffer) {\n gl.enableVertexAttribArray(i)\n binding.buffer.bind()\n gl.vertexAttribPointer(i, binding.size, binding.type, binding.normalized, binding.stride, binding.offfset)\n if (exti && binding.divisor) {\n exti.vertexAttribDivisorANGLE(i, binding.divisor)\n }\n } else {\n gl.disableVertexAttribArray(i)\n gl.vertexAttrib4f(i, binding.x, binding.y, binding.z, binding.w)\n }\n }\n if (drawState.elements) {\n gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER$1, drawState.elements.buffer.buffer)\n } else {\n gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER$1, null)\n }\n }\n state.currentVAO = vao\n }\n\n function destroyVAOEXT () {\n values(vaoSet).forEach(function (vao) {\n vao.destroy()\n })\n }\n\n function REGLVAO () {\n this.id = ++vaoCount\n this.attributes = []\n this.elements = null\n this.ownsElements = false\n this.count = 0\n this.offset = 0\n this.instances = -1\n this.primitive = 4\n var extension = extVAO()\n if (extension) {\n this.vao = extension.createVertexArrayOES()\n } else {\n this.vao = null\n }\n vaoSet[this.id] = this\n this.buffers = []\n }\n\n REGLVAO.prototype.bindAttrs = function () {\n var exti = extInstanced()\n var attributes = this.attributes\n for (var i = 0; i < attributes.length; ++i) {\n var attr = attributes[i]\n if (attr.buffer) {\n gl.enableVertexAttribArray(i)\n gl.bindBuffer(GL_ARRAY_BUFFER$1, attr.buffer.buffer)\n gl.vertexAttribPointer(i, attr.size, attr.type, attr.normalized, attr.stride, attr.offset)\n if (exti && attr.divisor) {\n exti.vertexAttribDivisorANGLE(i, attr.divisor)\n }\n } else {\n gl.disableVertexAttribArray(i)\n gl.vertexAttrib4f(i, attr.x, attr.y, attr.z, attr.w)\n }\n }\n for (var j = attributes.length; j < NUM_ATTRIBUTES; ++j) {\n gl.disableVertexAttribArray(j)\n }\n var elements = elementState.getElements(this.elements)\n if (elements) {\n gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER$1, elements.buffer.buffer)\n } else {\n gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER$1, null)\n }\n }\n\n REGLVAO.prototype.refresh = function () {\n var ext = extVAO()\n if (ext) {\n ext.bindVertexArrayOES(this.vao)\n this.bindAttrs()\n state.currentVAO = null\n ext.bindVertexArrayOES(null)\n }\n }\n\n REGLVAO.prototype.destroy = function () {\n if (this.vao) {\n var extension = extVAO()\n if (this === state.currentVAO) {\n state.currentVAO = null\n extension.bindVertexArrayOES(null)\n }\n extension.deleteVertexArrayOES(this.vao)\n this.vao = null\n }\n if (this.ownsElements) {\n this.elements.destroy()\n this.elements = null\n this.ownsElements = false\n }\n if (vaoSet[this.id]) {\n delete vaoSet[this.id]\n stats.vaoCount -= 1\n }\n }\n\n function restoreVAO () {\n var ext = extVAO()\n if (ext) {\n values(vaoSet).forEach(function (vao) {\n vao.refresh()\n })\n }\n }\n\n function createVAO (_attr) {\n var vao = new REGLVAO()\n stats.vaoCount += 1\n\n function updateVAO (options) {\n var attributes\n if (Array.isArray(options)) {\n attributes = options\n if (vao.elements && vao.ownsElements) {\n vao.elements.destroy()\n }\n vao.elements = null\n vao.ownsElements = false\n vao.offset = 0\n vao.count = 0\n vao.instances = -1\n vao.primitive = 4\n } else {\n check$1(typeof options === 'object', 'invalid arguments for create vao')\n check$1('attributes' in o
1ptions, 'must specify attributes for vao')\n if (options.elements) {\n var elements = options.elements\n if (vao.ownsElements) {\n if (typeof elements === 'function' && elements._reglType === 'elements') {\n vao.elements.destroy()\n vao.ownsElements = false\n } else {\n vao.elements(elements)\n vao.ownsElements = false\n }\n } else if (elementState.getElements(options.elements)) {\n vao.elements = options.elements\n vao.ownsElements = false\n } else {\n vao.elements = elementState.create(options.elements)\n vao.ownsElements = true\n }\n } else {\n vao.elements = null\n vao.ownsElements = false\n }\n attributes = options.attributes\n\n // set default vao\n vao.offset = 0\n vao.count = -1\n vao.instances = -1\n vao.primitive = 4\n\n // copy element properties\n if (vao.elements) {\n vao.count = vao.elements._elements.vertCount\n vao.primitive = vao.elements._elements.primType\n }\n\n if ('offset' in options) {\n vao.offset = options.offset | 0\n }\n if ('count' in options) {\n vao.count = options.count | 0\n }\n if ('instances' in options) {\n vao.instances = options.instances | 0\n }\n if ('primitive' in options) {\n check$1(options.primitive in primTypes, 'bad primitive type: ' + options.primitive)\n vao.primitive = primTypes[options.primitive]\n }\n\n check$1.optional(() => {\n var keys = Object.keys(options)\n for (var i = 0; i < keys.length; ++i) {\n check$1(VAO_OPTIONS.indexOf(keys[i]) >= 0, 'invalid option for vao: \"' + keys[i] + '\" valid options are ' + VAO_OPTIONS)\n }\n })\n check$1(Array.isArray(attributes), 'attributes must be an array')\n }\n\n check$1(attributes.length < NUM_ATTRIBUTES, 'too many attributes')\n check$1(attributes.length > 0, 'must specify at least one attribute')\n\n var bufUpdated = {}\n var nattributes = vao.attributes\n nattributes.length = attributes.length\n for (var i = 0; i < attributes.length; ++i) {\n var spec = attributes[i]\n var rec = nattributes[i] = new AttributeRecord()\n var data = spec.data || spec\n if (Array.isArray(data) || isTypedArray(data) || isNDArrayLike(data)) {\n var buf\n if (vao.buffers[i]) {\n buf = vao.buffers[i]\n if (isTypedArray(data) && buf._buffer.byteLength >= data.byteLength) {\n buf.subdata(data)\n } else {\n buf.destroy()\n vao.buffers[i] = null\n }\n }\n if (!vao.buffers[i]) {\n buf = vao.buffers[i] = bufferState.create(spec, GL_ARRAY_BUFFER$1, false, true)\n }\n rec.buffer = bufferState.getBuffer(buf)\n rec.size = rec.buffer.dimension | 0\n rec.normalized = false\n rec.type = rec.buffer.dtype\n rec.offset = 0\n rec.stride = 0\n rec.divisor = 0\n rec.state = 1\n bufUpdated[i] = 1\n } else if (bufferState.getBuffer(spec)) {\n rec.buffer = bufferState.getBuffer(spec)\n rec.size = rec.buffer.dimension | 0\n rec.normalized = false\n rec.type = rec.buffer.dtype\n rec.offset = 0\n rec.stride = 0\n rec.divisor = 0\n rec.state = 1\n } else if (bufferState.getBuffer(spec.buffer)) {\n rec.buffer = bufferState.getBuffer(spec.buffer)\n rec.size = ((+spec.size) || rec.buffer.dimension) | 0\n rec.normalized = !!spec.normalized || false\n if ('type' in spec) {\n check$1.parameter(spec.type, glTypes, 'invalid buffer type')\n rec.type = glTypes[spec.type]\n } else {\n rec.type = rec.buffer.dtype\n }\n rec.offset = (spec.offset || 0) | 0\n rec.stride = (spec.stride || 0) | 0\n rec.divisor = (spec.divisor || 0) | 0\n rec.state = 1\n\n check$1(rec.size >= 1 && rec.size <= 4, 'size must be between 1 and 4')\n check$1(rec.offset >= 0, 'invalid offset')\n check$1(rec.stride >= 0 && rec.stride <= 255, 'stride must be between 0 and 255')\n check$1(rec.divisor >= 0, 'divisor must be positive')\n check$1(!rec.divisor || !!extensions.angle_instanced_arrays, 'ANGLE_instanced_arrays must be enabled to use divisor')\n } else if ('x' in spec) {\n check$1(i > 0, 'first attribute must not be a constant')\n rec.x = +spec.x || 0\n rec.y = +spec.y || 0\n rec.z = +spec.z || 0\n rec.w = +spec.w || 0\n rec.state = 2\n } else {\n check$1(false, 'invalid attribute spec for location ' + i)\n }\n }\n\n // retire unused buffers\n for (var j = 0; j < vao.buffers.length; ++j) {\n if (!bufUpdated[j] && vao.buffers[j]) {\n vao.buffers[j].destroy()\n vao.buffers[j] = null\n }\n }\n\n vao.refresh()\n return updateVAO\n }\n\n updateVAO.destroy = function () {\n for (var j = 0; j < vao.buffers.length; ++j) {\n if (vao.buffers[j]) {\n vao.buffers[j].destroy()\n }\n }\n vao.buffers.length = 0\n\n if (vao.ownsElements) {\n vao.elements.destroy()\n vao.elements = null\n vao.ownsElements = false\n }\n\n vao.destroy()\n }\n\n updateVAO._vao = vao\n updateVAO._reglType = 'vao'\n\n return updateVAO(_attr)\n }\n\n return state\n}\n\nvar GL_FRAGMENT_SHADER = 35632\nvar GL_VERTEX_SHADER = 35633\n\nvar GL_ACTIVE_UNIFORMS = 0x8B86\nvar GL_ACTIVE_ATTRIBUTES = 0x8B89\n\nfunction wrapShaderState (gl, stringStore, stats, config) {\n // ===================================================\n // glsl compilation and linking\n // ===================================================\n var fragShaders = {}\n var vertShaders = {}\n\n function ActiveInfo (name, id, location, info) {\n this.name = name\n this.id = id\n this.location = location\n this.info = info\n }\n\n function insertActiveInfo (list, info) {\n for (var i = 0; i < list.length; ++i) {\n if (list[i].id === info.id) {\n list[i].location = info.location\n return\n }\n }\n list.push(info)\n }\n\n function getShader (type, id, command) {\n var cache = type === GL_FRAGMENT_SHADER ? fragShaders : vertShaders\n var shader = cache[id]\n\n if (!shader) {\n var source = stringStore.str(id)\n shader = gl.createShader(type)\n gl.shaderSource(shader, source)\n gl.compileShader(shader)\n check$1.shaderError(gl, shader, source, type, command)\n cache[id] = shader\n }\n\n return shader\n }\n\n // ===================================================\n // program linking\n // ===================================================\n var programCache = {}\n var programList = []\n\n var PROGRAM_COUNTER = 0\n\n function REGLProgram (fragId, vertId) {\n this.id = PROGRAM_COUNTER++\n this.fragId = fragId\n this.vertId = vertId\n this.program = null\n this.uniforms = []\n this.attributes = []\n this.refCount = 1\n\n if (config.profile) {\n this.stats = {\n uniformsCount: 0,\n attributesCount: 0\n }\n }\n }\n\n function linkProgram (desc, command, attributeLocations) {\n var i, info\n\n // -------------------------------\n // compile & link\n // -------------------------------\n var fragShader = getShader(GL_FRAGMENT_SHADER, desc.fragId)\n var vertShader = getShader(GL_VERTEX_SHADER, desc.vertId)\n\n var program = desc.program = gl.createProgram()\n gl.attachShader(program, fragShader)\n gl.attachShader(program, vertShader)\n if (attributeLocations) {\n for (i = 0; i < attributeLocations.length; ++i) {\n var binding = attributeLocations[i]\n gl.bindAttribLocation(program, binding[0], binding[1])\n }\n }\n\n gl.linkProgram(program)\n check$1.linkError(\n gl,\n program,\n str
1ingStore.str(desc.fragId),\n stringStore.str(desc.vertId),\n command)\n\n // -------------------------------\n // grab uniforms\n // -------------------------------\n var numUniforms = gl.getProgramParameter(program, GL_ACTIVE_UNIFORMS)\n if (config.profile) {\n desc.stats.uniformsCount = numUniforms\n }\n var uniforms = desc.uniforms\n for (i = 0; i < numUniforms; ++i) {\n info = gl.getActiveUniform(program, i)\n if (info) {\n if (info.size > 1) {\n for (var j = 0; j < info.size; ++j) {\n var name = info.name.replace('[0]', '[' + j + ']')\n insertActiveInfo(uniforms, new ActiveInfo(\n name,\n stringStore.id(name),\n gl.getUniformLocation(program, name),\n info))\n }\n }\n var uniName = info.name\n if (info.size > 1) {\n uniName = uniName.replace('[0]', '')\n }\n insertActiveInfo(uniforms, new ActiveInfo(\n uniName,\n stringStore.id(uniName),\n gl.getUniformLocation(program, uniName),\n info))\n }\n }\n\n // -------------------------------\n // grab attributes\n // -------------------------------\n var numAttributes = gl.getProgramParameter(program, GL_ACTIVE_ATTRIBUTES)\n if (config.profile) {\n desc.stats.attributesCount = numAttributes\n }\n\n var attributes = desc.attributes\n for (i = 0; i < numAttributes; ++i) {\n info = gl.getActiveAttrib(program, i)\n if (info) {\n insertActiveInfo(attributes, new ActiveInfo(\n info.name,\n stringStore.id(info.name),\n gl.getAttribLocation(program, info.name),\n info))\n }\n }\n }\n\n if (config.profile) {\n stats.getMaxUniformsCount = function () {\n var m = 0\n programList.forEach(function (desc) {\n if (desc.stats.uniformsCount > m) {\n m = desc.stats.uniformsCount\n }\n })\n return m\n }\n\n stats.getMaxAttributesCount = function () {\n var m = 0\n programList.forEach(function (desc) {\n if (desc.stats.attributesCount > m) {\n m = desc.stats.attributesCount\n }\n })\n return m\n }\n }\n\n function restoreShaders () {\n fragShaders = {}\n vertShaders = {}\n for (var i = 0; i < programList.length; ++i) {\n linkProgram(programList[i], null, programList[i].attributes.map(function (info) {\n return [info.location, info.name]\n }))\n }\n }\n\n return {\n clear: function () {\n var deleteShader = gl.deleteShader.bind(gl)\n values(fragShaders).forEach(deleteShader)\n fragShaders = {}\n values(vertShaders).forEach(deleteShader)\n vertShaders = {}\n\n programList.forEach(function (desc) {\n gl.deleteProgram(desc.program)\n })\n programList.length = 0\n programCache = {}\n\n stats.shaderCount = 0\n },\n\n program: function (vertId, fragId, command, attribLocations) {\n check$1.command(vertId >= 0, 'missing vertex shader', command)\n check$1.command(fragId >= 0, 'missing fragment shader', command)\n\n var cache = programCache[fragId]\n if (!cache) {\n cache = programCache[fragId] = {}\n }\n var prevProgram = cache[vertId]\n if (prevProgram) {\n prevProgram.refCount++\n if (!attribLocations) {\n return prevProgram\n }\n }\n var program = new REGLProgram(fragId, vertId)\n stats.shaderCount++\n linkProgram(program, command, attribLocations)\n if (!prevProgram) {\n cache[vertId] = program\n }\n programList.push(program)\n return extend(program, {\n destroy: function () {\n program.refCount--\n if (program.refCount <= 0) {\n gl.deleteProgram(program.program)\n var idx = programList.indexOf(program)\n programList.splice(idx, 1)\n stats.shaderCount--\n }\n // no program is linked to this vert anymore\n if (cache[program.vertId].refCount <= 0) {\n gl.deleteShader(vertShaders[program.vertId])\n delete vertShaders[program.vertId]\n delete programCache[program.fragId][program.vertId]\n }\n // no program is linked to this frag anymore\n if (!Object.keys(programCache[program.fragId]).length) {\n gl.deleteShader(fragShaders[program.fragId])\n delete fragShaders[program.fragId]\n delete programCache[program.fragId]\n }\n }\n })\n },\n\n restore: restoreShaders,\n\n shader: getShader,\n\n frag: -1,\n vert: -1\n }\n}\n\nvar GL_RGBA$3 = 6408\nvar GL_UNSIGNED_BYTE$7 = 5121\nvar GL_PACK_ALIGNMENT = 0x0D05\nvar GL_FLOAT$7 = 0x1406 // 5126\n\nfunction wrapReadPixels (\n gl,\n framebufferState,\n reglPoll,\n context,\n glAttributes,\n extensions,\n limits) {\n function readPixelsImpl (input) {\n var type\n if (framebufferState.next === null) {\n check$1(\n glAttributes.preserveDrawingBuffer,\n 'you must create a webgl context with \"preserveDrawingBuffer\":true in order to read pixels from the drawing buffer')\n type = GL_UNSIGNED_BYTE$7\n } else {\n check$1(\n framebufferState.next.colorAttachments[0].texture !== null,\n 'You cannot read from a renderbuffer')\n type = framebufferState.next.colorAttachments[0].texture._texture.type\n\n check$1.optional(function () {\n if (extensions.oes_texture_float) {\n check$1(\n type === GL_UNSIGNED_BYTE$7 || type === GL_FLOAT$7,\n 'Reading from a framebuffer is only allowed for the types \\'uint8\\' and \\'float\\'')\n\n if (type === GL_FLOAT$7) {\n check$1(limits.readFloat, 'Reading \\'float\\' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float')\n }\n } else {\n check$1(\n type === GL_UNSIGNED_BYTE$7,\n 'Reading from a framebuffer is only allowed for the type \\'uint8\\'')\n }\n })\n }\n\n var x = 0\n var y = 0\n var width = context.framebufferWidth\n var height = context.framebufferHeight\n var data = null\n\n if (isTypedArray(input)) {\n data = input\n } else if (input) {\n check$1.type(input, 'object', 'invalid arguments to regl.read()')\n x = input.x | 0\n y = input.y | 0\n check$1(\n x >= 0 && x < context.framebufferWidth,\n 'invalid x offset for regl.read')\n check$1(\n y >= 0 && y < context.framebufferHeight,\n 'invalid y offset for regl.read')\n width = (input.width || (context.framebufferWidth - x)) | 0\n height = (input.height || (context.framebufferHeight - y)) | 0\n data = input.data || null\n }
1\n\n // sanity check input.data\n if (data) {\n if (type === GL_UNSIGNED_BYTE$7) {\n check$1(\n data instanceof Uint8Array,\n 'buffer must be \\'Uint8Array\\' when reading from a framebuffer of type \\'uint8\\'')\n } else if (type === GL_FLOAT$7) {\n check$1(\n data instanceof Float32Array,\n 'buffer must be \\'Float32Array\\' when reading from a framebuffer of type \\'float\\'')\n }\n }\n\n check$1(\n width > 0 && width + x <= context.framebufferWidth,\n 'invalid width for read pixels')\n check$1(\n height > 0 && height + y <= context.framebufferHeight,\n 'invalid height for read pixels')\n\n // Update WebGL state\n reglPoll()\n\n // Compute size\n var size = width * height * 4\n\n // Allocate data\n if (!data) {\n if (type === GL_UNSIGNED_BYTE$7) {\n data = new Uint8Array(size)\n } else if (type === GL_FLOAT$7) {\n data = data || new Float32Array(size)\n }\n }\n\n // Type check\n check$1.isTypedArray(data, 'data buffer for regl.read() must be a typedarray')\n check$1(data.byteLength >= size, 'data buffer for regl.read() too small')\n\n // Run read pixels\n gl.pixelStorei(GL_PACK_ALIGNMENT, 4)\n gl.readPixels(x, y, width, height, GL_RGBA$3,\n type,\n data)\n\n return data\n }\n\n function readPixelsFBO (options) {\n var result\n framebufferState.setFBO({\n framebuffer: options.framebuffer\n }, function () {\n result = readPixelsImpl(options)\n })\n return result\n }\n\n function readPixels (options) {\n if (!options || !('framebuffer' in options)) {\n return readPixelsImpl(options)\n } else {\n return readPixelsFBO(options)\n }\n }\n\n return readPixels\n}\n\nfunction slice (x) {\n return Array.prototype.slice.call(x)\n}\n\nfunction join (x) {\n return slice(x).join('')\n}\n\nfunction createEnvironment () {\n // Unique variable id counter\n var varCounter = 0\n\n // Linked values are passed from this scope into the generated code block\n // Calling link() passes a value into the generated scope and returns\n // the variable name which it is bound to\n var linkedNames = []\n var linkedValues = []\n function link (value) {\n for (var i = 0; i < linkedValues.length; ++i) {\n if (linkedValues[i] === value) {\n return linkedNames[i]\n }\n }\n\n var name = 'g' + (varCounter++)\n linkedNames.push(name)\n linkedValues.push(value)\n return name\n }\n\n // create a code block\n function block () {\n var code = []\n function push () {\n code.push.apply(code, slice(arguments))\n }\n\n var vars = []\n function def () {\n var name = 'v' + (varCounter++)\n vars.push(name)\n\n if (arguments.length > 0) {\n code.push(name, '=')\n code.push.apply(code, slice(arguments))\n code.push(';')\n }\n\n return name\n }\n\n return extend(push, {\n def: def,\n toString: function () {\n return join([\n (vars.length > 0 ? 'var ' + vars.join(',') + ';' : ''),\n join(code)\n ])\n }\n })\n }\n\n function scope () {\n var entry = block()\n var exit = block()\n\n var entryToString = entry.toString\n var exitToString = exit.toString\n\n function save (object, prop) {\n exit(object, prop, '=', entry.def(object, prop), ';')\n }\n\n return extend(function () {\n entry.apply(entry, slice(arguments))\n }, {\n def: entry.def,\n entry: entry,\n exit: exit,\n save: save,\n set: function (object, prop, value) {\n save(object, prop)\n entry(object, prop, '=', value, ';')\n },\n toString: function () {\n return entryToString() + exitToString()\n }\n })\n }\n\n function conditional () {\n var pred = join(arguments)\n var thenBlock = scope()\n var elseBlock = scope()\n\n var thenToString = thenBlock.toString\n var elseToString = elseBlock.toString\n\n return extend(thenBlock, {\n then: function () {\n thenBlock.apply(thenBlock, slice(arguments))\n return this\n },\n else: function () {\n elseBlock.apply(elseBlock, slice(arguments))\n return this\n },\n toString: function () {\n var elseClause = elseToString()\n if (elseClause) {\n elseClause = 'else{' + elseClause + '}'\n }\n return join([\n 'if(', pred, '){',\n thenToString(),\n '}', elseClause\n ])\n }\n })\n }\n\n // procedure list\n var globalBlock = block()\n var procedures = {}\n function proc (name, count) {\n var args = []\n function arg () {\n var name = 'a' + args.length\n args.push(name)\n return name\n }\n\n count = count || 0\n for (var i = 0; i < count; ++i) {\n arg()\n }\n\n var body = scope()\n var bodyToString = body.toString\n\n var result = procedures[name] = extend(body, {\n arg: arg,\n toString: function () {\n return join([\n 'function(', args.join(), '){',\n bodyToString(),\n '}'\n ])\n }\n })\n\n return result\n }\n\n function compile () {\n var code = ['\"use strict\";
1',\n globalBlock,\n 'return {']\n Object.keys(procedures).forEach(function (name) {\n code.push('\"', name, '\":', procedures[name].toString(), ',')\n })\n code.push('}')\n var src = join(code)\n .replace(/;/g, ';\\n')\n .replace(/}/g, '}\\n')\n .replace(/{/g, '{\\n')\n var proc = Function.apply(null, linkedNames.concat(src))\n return proc.apply(null, linkedValues)\n }\n\n return {\n global: globalBlock,\n link: link,\n block: block,\n proc: proc,\n scope: scope,\n cond: conditional,\n compile: compile\n }\n}\n\n// \"cute\" names for vector components\nvar CUTE_COMPONENTS = 'xyzw'.split('')\n\nvar GL_UNSIGNED_BYTE$8 = 5121\n\nvar ATTRIB_STATE_POINTER = 1\nvar ATTRIB_STATE_CONSTANT = 2\n\nvar DYN_FUNC$1 = 0\nvar DYN_PROP$1 = 1\nvar DYN_CONTEXT$1 = 2\nvar DYN_STATE$1 = 3\nvar DYN_THUNK = 4\nvar DYN_CONSTANT$1 = 5\nvar DYN_ARRAY$1 = 6\n\nvar S_DITHER = 'dither'\nvar S_BLEND_ENABLE = 'blend.enable'\nvar S_BLEND_COLOR = 'blend.color'\nvar S_BLEND_EQUATION = 'blend.equation'\nvar S_BLEND_FUNC = 'blend.func'\nvar S_DEPTH_ENABLE = 'depth.enable'\nvar S_DEPTH_FUNC = 'depth.func'\nvar S_DEPTH_RANGE = 'depth.range'\nvar S_DEPTH_MASK = 'depth.mask'\nvar S_COLOR_MASK = 'colorMask'\nvar S_CULL_ENABLE = 'cull.enable'\nvar S_CULL_FACE = 'cull.face'\nvar S_FRONT_FACE = 'frontFace'\nvar S_LINE_WIDTH = 'lineWidth'\nvar S_POLYGON_OFFSET_ENABLE = 'polygonOffset.enable'\nvar S_POLYGON_OFFSET_OFFSET = 'polygonOffset.offset'\nvar S_SAMPLE_ALPHA = 'sample.alpha'\nvar S_SAMPLE_ENABLE = 'sample.enable'\nvar S_SAMPLE_COVERAGE = 'sample.coverage'\nvar S_STENCIL_ENABLE = 'stencil.enable'\nvar S_STENCIL_MASK = 'stencil.mask'\nvar S_STENCIL_FUNC = 'stencil.func'\nvar S_STENCIL_OPFRONT = 'stencil.opFront'\nvar S_STENCIL_OPBACK = 'stencil.opBack'\nvar S_SCISSOR_ENABLE = 'scissor.enable'\nvar S_SCISSOR_BOX = 'scissor.box'\nvar S_VIEWPORT = 'viewport'\n\nvar S_PROFILE = 'profile'\n\nvar S_FRAMEBUFFER = 'framebuffer'\nvar S_VERT = 'vert'\nvar S_FRAG = 'frag'\nvar S_ELEMENTS = 'elements'\nvar S_PRIMITIVE = 'primitive'\nvar S_COUNT = 'count'\nvar S_OFFSET = 'offset'\nvar S_INSTANCES = 'instances'\nvar S_VAO = 'vao'\n\nvar SUFFIX_WIDTH = 'Width'\nvar SUFFIX_HEIGHT = 'Height'\n\nvar S_FRAMEBUFFER_WIDTH = S_FRAMEBUFFER + SUFFIX_WIDTH\nvar S_FRAMEBUFFER_HEIGHT = S_FRAMEBUFFER + SUFFIX_HEIGHT\nvar S_VIEWPORT_WIDTH = S_VIEWPORT + SUFFIX_WIDTH\nvar S_VIEWPORT_HEIGHT = S_VIEWPORT + SUFFIX_HEIGHT\nvar S_DRAWINGBUFFER = 'drawingBuffer'\nvar S_DRAWINGBUFFER_WIDTH = S_DRAWINGBUFFER + SUFFIX_WIDTH\nvar S_DRAWINGBUFFER_HEIGHT = S_DRAWINGBUFFER + SUFFIX_HEIGHT\n\nvar NESTED_OPTIONS = [\n S_BLEND_FUNC,\n S_BLEND_EQUATION,\n S_STENCIL_FUNC,\n S_STENCIL_OPFRONT,\n S_STENCIL_OPBACK,\n S_SAMPLE_COVERAGE,\n S_VIEWPORT,\n S_SCISSOR_BOX,\n S_POLYGON_OFFSET_OFFSET\n]\n\nvar GL_ARRAY_BUFFER$2 = 34962\nvar GL_ELEMENT_ARRAY_BUFFER$2 = 34963\n\nvar GL_FRAGMENT_SHADER$1 = 35632\nvar GL_VERTEX_SHADER$1 = 35633\n\nvar GL_TEXTURE_2D$3 = 0x0DE1\nvar GL_TEXTURE_CUBE_MAP$2 = 0x8513\n\nvar GL_CULL_FACE = 0x0B44\nvar GL_BLEND = 0x0BE2\nvar GL_DITHER = 0x0BD0\nvar GL_STENCIL_TEST = 0x0B90\nvar GL_DEPTH_TEST = 0x0B71\nvar GL_SCISSOR_TEST = 0x0C11\nvar GL_POLYGON_OFFSET_FILL = 0x8037\nvar GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E\nvar GL_SAMPLE_COVERAGE = 0x80A0\n\nvar GL_FLOAT$8 = 5126\nvar GL_FLOAT_VEC2 = 35664\nvar GL_FLOAT_VEC3 = 35665\nvar GL_FLOAT_VEC4 = 35666\nvar GL_INT$3 = 5124\nvar GL_INT_VEC2 = 35667\nvar GL_INT_VEC3 = 35668\nvar GL_INT_VEC4 = 35669\nvar GL_BOOL = 35670\nvar GL_BOOL_VEC2 = 35671\nvar GL_BOOL_VEC3 = 35672\nvar GL_BOOL_VEC4 = 35673\nvar GL_FLOAT_MAT2 = 35674\nvar GL_FLOAT_MAT3 = 35675\nvar GL_FLOAT_MAT4 = 35676\nvar GL_SAMPLER_2D = 35678\nvar GL_SAMPLER_CUBE = 35680\n\nvar GL_TRIANGLES$1 = 4\n\nvar GL_FRONT = 1028\nvar GL_BACK = 1029\nvar GL_CW = 0x0900\nvar GL_CCW = 0x0901\nvar GL_MIN_EXT = 0x8007\nvar GL_MAX_EXT = 0x8008\nvar GL_ALWAYS = 519\nvar GL_KEEP = 7680\nvar GL_ZERO = 0\nvar GL_ONE = 1\nvar GL_FUNC_ADD = 0x8006\nvar GL_LESS = 513\n\nvar GL_FRAMEBUFFER$2 = 0x8D40\nvar GL_COLOR_ATTACHMENT0$2 = 0x8CE0\n\nvar blendFuncs = {\n '0': 0,\n '1': 1,\n 'zero': 0,\n 'one': 1,\n 'src color': 768,\n 'one minus src color': 769,\n 'src alpha': 770,\n 'one minus src alpha': 771,\n 'dst color': 774,\n 'one minus dst color': 775,\n 'dst alph
1a': 772,\n 'one minus dst alpha': 773,\n 'constant color': 32769,\n 'one minus constant color': 32770,\n 'constant alpha': 32771,\n 'one minus constant alpha': 32772,\n 'src alpha saturate': 776\n}\n\n// There are invalid values for srcRGB and dstRGB. See:\n// https://www.khronos.org/registry/webgl/specs/1.0/#6.13\n// https://github.com/KhronosGroup/WebGL/blob/0d3201f5f7ec3c0060bc1f04077461541f1987b9/conformance-suites/1.0.3/conformance/misc/webgl-specific.html#L56\nvar invalidBlendCombinations = [\n 'constant color, constant alpha',\n 'one minus constant color, constant alpha',\n 'constant color, one minus constant alpha',\n 'one minus constant color, one minus constant alpha',\n 'constant alpha, constant color',\n 'constant alpha, one minus constant color',\n 'one minus constant alpha, constant color',\n 'one minus constant alpha, one minus constant color'\n]\n\nvar compareFuncs = {\n 'never': 512,\n 'less': 513,\n '<': 513,\n 'equal': 514,\n '=': 514,\n '==': 514,\n '===': 514,\n 'lequal': 515,\n '<=': 515,\n 'greater': 516,\n '>': 516,\n 'notequal': 517,\n '!=': 517,\n '!==': 517,\n 'gequal': 518,\n '>=': 518,\n 'always': 519\n}\n\nvar stencilOps = {\n '0': 0,\n 'zero': 0,\n 'keep': 7680,\n 'replace': 7681,\n 'increment': 7682,\n 'decrement': 7683,\n 'increment wrap': 34055,\n 'decrement wrap': 34056,\n 'invert': 5386\n}\n\nvar shaderType = {\n 'frag': GL_FRAGMENT_SHADER$1,\n 'vert': GL_VERTEX_SHADER$1\n}\n\nvar orientationType = {\n 'cw': GL_CW,\n 'ccw': GL_CCW\n}\n\nfunction isBufferArgs (x) {\n return Array.isArray(x) ||\n isTypedArray(x) ||\n isNDArrayLike(x)\n}\n\n// Make sure viewport is processed first\nfunction sortState (state) {\n return state.sort(function (a, b) {\n if (a === S_VIEWPORT) {\n return -1\n } else if (b === S_VIEWPORT) {\n return 1\n }\n return (a < b) ? -1 : 1\n })\n}\n\nfunction Declaration (thisDep, contextDep, propDep, append) {\n this.thisDep = thisDep\n this.contextDep = contextDep\n this.propDep = propDep\n this.append = append\n}\n\nfunction isStatic (decl) {\n return decl && !(decl.thisDep || decl.contextDep || decl.propDep)\n}\n\nfunction createStaticDecl (append) {\n return new Declaration(false, false, false, append)\n}\n\nfunction createDynamicDecl (dyn, append) {\n var type = dyn.type\n if (type === DYN_FUNC$1) {\n var numArgs = dyn.data.length\n return new Declaration(\n true,\n numArgs >= 1,\n numArgs >= 2,\n append)\n } else if (type === DYN_THUNK) {\n var data = dyn.data\n return new Declaration(\n data.thisDep,\n data.contextDep,\n data.propDep,\n append)\n } else if (type === DYN_CONSTANT$1) {\n return new Declaration(\n false,\n false,\n false,\n append)\n } else if (type === DYN_ARRAY$1) {\n var thisDep = false\n var contextDep = false\n var propDep = false\n for (var i = 0; i < dyn.data.length; ++i) {\n var subDyn = dyn.data[i]\n if (subDyn.type === DYN_PROP$1) {\n propDep = true\n } else if (subDyn.type === DYN_CONTEXT$1) {\n contextDep = true\n } else if (subDyn.type === DYN_STATE$1) {\n thisDep = true\n } else if (subDyn.type === DYN_FUNC$1) {\n thisDep = true\n var subArgs = subDyn.data\n if (subArgs >= 1) {\n contextDep = true\n }\n if (subArgs >= 2) {\n propDep = true\n }\n } else if (subDyn.type === DYN_THUNK) {\n thisDep = thisDep || subDyn.data.thisDep\n contextDep = contextDep || subDyn.data.contextDep\n propDep = propDep || subDyn.data.propDep\n }\n }\n return new Declaration(\n thisDep,\n contextDep,\n propDep,\n append)\n } else {\n return new Declaration(\n type === DYN_STATE$1,\n type === DYN_CONTEXT$1,\n type === DYN_PROP$1,\n append)\n }\n}\n\nvar SCOPE_DECL = new Declaration(false, false, false, function () {})\n\nfunction reglCore (\n gl,\n stringStore,\n extensions,\n limits,\n bufferState,\n elementState,\n textureState,\n framebufferState,\n uniformState,\n attributeState,\n shaderState,\n drawState,\n contextState,\n timer,\n config) {\n var AttributeRecord = attributeState.Record\n\n var blendEquations = {\n 'add': 32774,\n 'subtract': 32778,\n 'reverse subtract': 32779\n }\n if (extensions.ext_blend_minmax) {\n blendEquations.min = GL_MIN_EXT\n blendEquations.max = GL_MAX_EXT\n }\n\n var extInstancing = extensions.angle_instanced_arrays\n var extDrawBuffers = extensions.webgl_draw_buffers\n var extVertexArrays = extensions.oes_vertex_array_object\n\n // ===================================================\n // ===================================================\n // WEBGL STATE\n // ===================================================\n // ===================================================\n var currentState = {\n dirty: true,\n profile: config.profile\n }\n var nextState = {}\n var GL_STATE_NAMES = []\n var GL_FLAGS = {}\n var GL_VARIABLES = {}\n\n function propName (name) {\n return name.replace('.', '_')\n }\n\n function stateFlag (sname, cap, init) {\n var name = propName(sname)\n GL_STATE_NAMES.push(sname)\n nextState[name] = currentState[name] = !!init\n GL_FLAGS[name] = cap\n }\n\n function stateVariable (sname, func, init) {\n var name = propName(sname)\n GL_STATE_NAMES.push(sname)\n if (Array.isArray(init)) {\n currentState[name] = init.slice()\n nextState[name] = init.slice()\n } else {\n currentState[name] = nextState[name] = init\n }\n GL_VARIABLES[name] = func\n }\n\n // Dithering\n stateFlag(S_DITHER, GL_DITHER)\n\n // Blending\n stateFlag(S_BLEND_ENABLE, GL_BLEND)\n stateVariable(S_BLEND_COLOR, 'blendColor', [0, 0, 0, 0])\n stateVariable(S_BLEND_EQUATION, 'blendEquationSeparate',\n [GL_FUNC_ADD, GL_FUNC_ADD])\n stateVariable(S_BLEND_FUNC, 'blendFuncSeparate',\n [GL_ONE, GL_ZERO, GL_ONE, GL_ZERO])\n\n // Depth\n stateFlag(S_DEPTH_ENABLE, GL_DEPTH_TEST, true)\n stateVariable(S_DEPTH_FUNC, 'depthFunc', GL_LESS)\n stateVariable(S_DEPTH_RANGE, 'depthRange', [0, 1])\n stateVariable(S_DEPTH_MASK, 'depthMask', true)\n\n // Color mask\n stateVariable(S_COLOR_MASK, S_COLOR_MASK, [true, true, true, true])\n\n // Face culling\n stateFlag(S_CULL_ENABLE, GL_CULL_FACE)\n stateVariable(S_CULL_FACE, 'cullFace', GL_BACK)\n\n // Front face orientation\n stateVariable(S_FRONT_FACE, S_FRONT_FACE, GL_CCW)\n\n // Line width\n stateVariable(S_LINE_WIDTH, S_LINE_WIDTH, 1)\n\n // Polygon offset\n stateFlag(S_POLYGON_OFFSET_ENABLE, GL_POLYGON_OFFSET_FILL)\n stateVariable(S_POLYGON_OFFSET_OFFSET, 'polygonOffset', [0, 0])\n\n // Sample coverage\n stateFlag(S_SAMPLE_ALPHA, GL_SAMPLE_ALPHA_TO_COVERAGE)\n stateFlag(S_SAMPLE_ENABLE, GL_SAMPLE_COVERAGE)\n stateVariable(S_SAMPLE_COVERAGE, 'sampleC
1overage', [1, false])\n\n // Stencil\n stateFlag(S_STENCIL_ENABLE, GL_STENCIL_TEST)\n stateVariable(S_STENCIL_MASK, 'stencilMask', -1)\n stateVariable(S_STENCIL_FUNC, 'stencilFunc', [GL_ALWAYS, 0, -1])\n stateVariable(S_STENCIL_OPFRONT, 'stencilOpSeparate',\n [GL_FRONT, GL_KEEP, GL_KEEP, GL_KEEP])\n stateVariable(S_STENCIL_OPBACK, 'stencilOpSeparate',\n [GL_BACK, GL_KEEP, GL_KEEP, GL_KEEP])\n\n // Scissor\n stateFlag(S_SCISSOR_ENABLE, GL_SCISSOR_TEST)\n stateVariable(S_SCISSOR_BOX, 'scissor',\n [0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight])\n\n // Viewport\n stateVariable(S_VIEWPORT, S_VIEWPORT,\n [0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight])\n\n // ===================================================\n // ===================================================\n // ENVIRONMENT\n // ===================================================\n // ===================================================\n var sharedState = {\n gl: gl,\n context: contextState,\n strings: stringStore,\n next: nextState,\n current: currentState,\n draw: drawState,\n elements: elementState,\n buffer: bufferState,\n shader: shaderState,\n attributes: attributeState.state,\n vao: attributeState,\n uniforms: uniformState,\n framebuffer: framebufferState,\n extensions: extensions,\n\n timer: timer,\n isBufferArgs: isBufferArgs\n }\n\n var sharedConstants = {\n primTypes: primTypes,\n compareFuncs: compareFuncs,\n blendFuncs: blendFuncs,\n blendEquations: blendEquations,\n stencilOps: stencilOps,\n glTypes: glTypes,\n orientationType: orientationType\n }\n\n check$1.optional(function () {\n sharedState.isArrayLike = isArrayLike\n })\n\n if (extDrawBuffers) {\n sharedConstants.backBuffer = [GL_BACK]\n sharedConstants.drawBuffer = loop(limits.maxDrawbuffers, function (i) {\n if (i === 0) {\n return [0]\n }\n return loop(i, function (j) {\n return GL_COLOR_ATTACHMENT0$2 + j\n })\n })\n }\n\n var drawCallCounter = 0\n function createREGLEnvironment () {\n var env = createEnvironment()\n var link = env.link\n var global = env.global\n env.id = drawCallCounter++\n\n env.batchId = '0'\n\n // link shared state\n var SHARED = link(sharedState)\n var shared = env.shared = {\n props: 'a0'\n }\n Object.keys(sharedState).forEach(function (prop) {\n shared[prop] = global.def(SHARED, '.', prop)\n })\n\n // Inject runtime assertion stuff for debug builds\n check$1.optional(function () {\n env.CHECK = link(check$1)\n env.commandStr = check$1.guessCommand()\n env.command = link(env.commandStr)\n env.assert = function (block, pred, message) {\n block(\n 'if(!(', pred, '))',\n this.CHECK, '.commandRaise(', link(message), ',', this.command, ');')\n }\n\n sharedConstants.invalidBlendCombinations = invalidBlendCombinations\n })\n\n // Copy GL state variables over\n var nextVars = env.next = {}\n var currentVars = env.current = {}\n Object.keys(GL_VARIABLES).forEach(function (variable) {\n if (Array.isArray(currentState[variable])) {\n nextVars[variable] = global.def(shared.next, '.', variable)\n currentVars[variable] = global.def(shared.current, '.', variable)\n }\n })\n\n // Initialize shared constants\n var constants = env.constants = {}\n Object.keys(sharedConstants).forEach(function (name) {\n constants[name] = global.def(JSON.stringify(sharedConstants[name]))\n })\n\n // Helper function for calling a block\n env.invoke = function (block, x) {\n switch (x.type) {\n case DYN_FUNC$1:\n var argList = [\n 'this',\n shared.context,\n shared.props,\n env.batchId\n ]\n return block.def(\n link(x.data), '.call(',\n argList.slice(0, Math.max(x.data.length + 1, 4)),\n ')')\n case DYN_PROP$1:\n return block.def(shared.props, x.data)\n case DYN_CONTEXT$1:\n return block.def(shared.context, x.data)\n case DYN_STATE$1:\n return block.def('this', x.data)\n case DYN_THUNK:\n x.data.append(env, block)\n return x.data.ref\n case DYN_CONSTANT$1:\n return x.data.toString()\n case DYN_ARRAY$1:\n return x.data.map(function (y) {\
1n return env.invoke(block, y)\n })\n }\n }\n\n env.attribCache = {}\n\n var scopeAttribs = {}\n env.scopeAttrib = function (name) {\n var id = stringStore.id(name)\n if (id in scopeAttribs) {\n return scopeAttribs[id]\n }\n var binding = attributeState.scope[id]\n if (!binding) {\n binding = attributeState.scope[id] = new AttributeRecord()\n }\n var result = scopeAttribs[id] = link(binding)\n return result\n }\n\n return env\n }\n\n // ===================================================\n // ===================================================\n // PARSING\n // ===================================================\n // ===================================================\n function parseProfile (options) {\n var staticOptions = options.static\n var dynamicOptions = options.dynamic\n\n var profileEnable\n if (S_PROFILE in staticOptions) {\n var value = !!staticOptions[S_PROFILE]\n profileEnable = createStaticDecl(function (env, scope) {\n return value\n })\n profileEnable.enable = value\n } else if (S_PROFILE in dynamicOptions) {\n var dyn = dynamicOptions[S_PROFILE]\n profileEnable = createDynamicDecl(dyn, function (env, scope) {\n return env.invoke(scope, dyn)\n })\n }\n\n return profileEnable\n }\n\n function parseFramebuffer (options, env) {\n var staticOptions = options.static\n var dynamicOptions = options.dynamic\n\n if (S_FRAMEBUFFER in staticOptions) {\n var framebuffer = staticOptions[S_FRAMEBUFFER]\n if (framebuffer) {\n framebuffer = framebufferState.getFramebuffer(framebuffer)\n check$1.command(framebuffer, 'invalid framebuffer object')\n return createStaticDecl(function (env, block) {\n var FRAMEBUFFER = env.link(framebuffer)\n var shared = env.shared\n block.set(\n shared.framebuffer,\n '.next',\n FRAMEBUFFER)\n var CONTEXT = shared.context\n block.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_WIDTH,\n FRAMEBUFFER + '.width')\n block.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_HEIGHT,\n FRAMEBUFFER + '.height')\n return FRAMEBUFFER\n })\n } else {\n return createStaticDecl(function (env, scope) {\n var shared = env.shared\n scope.set(\n shared.framebuffer,\n '.next',\n 'null')\n var CONTEXT = shared.context\n scope.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_WIDTH,\n CONTEXT + '.' + S_DRAWINGBUFFER_WIDTH)\n scope.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_HEIGHT,\n CONTEXT + '.' + S_DRAWINGBUFFER_HEIGHT)\n return 'null'\n })\n }\n } else if (S_FRAMEBUFFER in dynamicOptions) {\n var dyn = dynamicOptions[S_FRAMEBUFFER]\n return createDynamicDecl(dyn, function (env, scope) {\n var FRAMEBUFFER_FUNC = env.invoke(scope, dyn)\n var shared = env.shared\n var FRAMEBUFFER_STATE = shared.framebuffer\n var FRAMEBUFFER = scope.def(\n FRAMEBUFFER_STATE, '.getFramebuffer(', FRAMEBUFFER_FUNC, ')')\n\n check$1.optional(function () {\n env.assert(scope,\n '!' + FRAMEBUFFER_FUNC + '||' + FRAMEBUFFER,\n 'invalid framebuffer object')\n })\n\n scope.set(\n FRAMEBUFFER_STATE,\n '.next',\n FRAMEBUFFER)\n var CONTEXT = shared.context\n scope.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_WIDTH,\n FRAMEBUFFER + '?' + FRAMEBUFFER + '.width:' +\n CONTEXT + '.' + S_DRAWINGBUFFER_WIDTH)\n scope.set(\n CONTEXT,\n '.' + S_FRAMEBUFFER_HEIGHT,\n FRAMEBUFFER +\n '?' + FRAMEBUFFER + '.height:' +\n CONTEXT + '.' + S_DRAWINGBUFFER_HEIGHT)\n return FRAMEBUFFER\n })\n } else {\n return null\n }\n }\n\n function parseViewportScissor (options, framebuffer, env) {\n var staticOptions = options.static\n var dynamicOptions = options.dynamic\n\n function parseBox (param) {\n if (param in staticOptions) {\n var box = staticOptions[param]\n check$1.commandType(box, 'object', 'invalid ' + param, env.commandStr)\n\n var isStatic = true\n var x = box.x | 0\n var y = box.y | 0\n var w, h\n if ('width' in box) {\n w = box.width | 0\n check$1.command(w >= 0, 'invalid ' + param, env.commandStr)\n } else {\n isStatic = false\n }\n if ('height' in box) {\n h = box.height | 0\n check$1.command(h >= 0, 'invalid ' + param, env.commandStr)\n } else {\n isStatic = false\n }\n\n return new Declaration(\n !isStatic && framebuffer && framebuffer.thisDep,\n !isStatic && framebuffer && framebuffer.contextDep,\n !isStatic && framebuffer && framebuffer.propDep,\n function (env, scope) {\n var CONTEXT = env.shared.context\n var BOX_W = w\n if (!('width' in box)) {\n BOX_W = scope.def(CONTEXT, '.', S_FRAMEBUFFER_WIDTH, '-', x)\n }\n var BOX_H = h\n if (!('height' in box)) {\n BOX_H = scope.def(CONTEXT, '.', S_FRAMEBUFFER_HEIGHT, '-', y)\n }\n return [x, y, BOX_W, BOX_H]\n })\n } else if (param in dynamicOptions) {\n var dynBox = dynamicOptions[param]\n var result = createDynamicDecl(dynBox, function (env, scope) {\n var BOX = env.invoke(scope, dynBox)\n\n check$1.optional(function () {\n env.assert(scope,\n BOX + '&&typeof ' + BOX + '===\"object\"',\n 'invalid ' + param)\n })\n\n var CONTEXT = env.shared.context\n var BOX_X = scope.def(BOX, '.x|0')\n var BOX_Y = scope.def(BOX, '.y|0')\n var BOX_W = scope.def(\n '\"width\" in ', BOX, '?', BOX, '.width|0:',\n '(', CONTEXT, '.', S_FRAMEBUFFER_WIDTH, '-', BOX_X, ')')\n var BOX_H = scope.def(\n '\"height\" in ', BOX, '?', BOX, '.height|0:',\n '(', CONTEXT, '.', S_FRAMEBUFFER_HEIGHT, '-', BOX_Y, ')')\n\n check$1.optional(function () {\n env.assert(scope,\n BOX_W + '>=0&&' +\n BOX_H + '>=0',\n 'invalid ' + param)\n }
1)\n\n return [BOX_X, BOX_Y, BOX_W, BOX_H]\n })\n if (framebuffer) {\n result.thisDep = result.thisDep || framebuffer.thisDep\n result.contextDep = result.contextDep || framebuffer.contextDep\n result.propDep = result.propDep || framebuffer.propDep\n }\n return result\n } else if (framebuffer) {\n return new Declaration(\n framebuffer.thisDep,\n framebuffer.contextDep,\n framebuffer.propDep,\n function (env, scope) {\n var CONTEXT = env.shared.context\n return [\n 0, 0,\n scope.def(CONTEXT, '.', S_FRAMEBUFFER_WIDTH),\n scope.def(CONTEXT, '.', S_FRAMEBUFFER_HEIGHT)]\n })\n } else {\n return null\n }\n }\n\n var viewport = parseBox(S_VIEWPORT)\n\n if (viewport) {\n var prevViewport = viewport\n viewport = new Declaration(\n viewport.thisDep,\n viewport.contextDep,\n viewport.propDep,\n function (env, scope) {\n var VIEWPORT = prevViewport.append(env, scope)\n var CONTEXT = env.shared.context\n scope.set(\n CONTEXT,\n '.' + S_VIEWPORT_WIDTH,\n VIEWPORT[2])\n scope.set(\n CONTEXT,\n '.' + S_VIEWPORT_HEIGHT,\n VIEWPORT[3])\n return VIEWPORT\n })\n }\n\n return {\n viewport: viewport,\n scissor_box: parseBox(S_SCISSOR_BOX)\n }\n }\n\n function parseAttribLocations (options, attributes) {\n var staticOptions = options.static\n var staticProgram =\n typeof staticOptions[S_FRAG] === 'string' &&\n typeof staticOptions[S_VERT] === 'string'\n if (staticProgram) {\n if (Object.keys(attributes.dynamic).length > 0) {\n return null\n }\n var staticAttributes = attributes.static\n var sAttributes = Object.keys(staticAttributes)\n if (sAttributes.length > 0 && typeof staticAttributes[sAttributes[0]] === 'number') {\n var bindings = []\n for (var i = 0; i < sAttributes.length; ++i) {\n check$1(typeof staticAttributes[sAttributes[i]] === 'number', 'must specify all vertex attribute locations when using vaos')\n bindings.push([staticAttributes[sAttributes[i]] | 0, sAttributes[i]])\n }\n return bindings\n }\n }\n return null\n }\n\n function parseProgram (options, env, attribLocations) {\n var staticOptions = options.static\n var dynamicOptions = options.dynamic\n\n function parseShader (name) {\n if (name in staticOptions) {\n var id = stringStore.id(staticOptions[name])\n check$1.optional(function () {\n shaderState.shader(shaderType[name], id, check$1.guessCommand())\n })\n var result = createStaticDecl(function () {\n return id\n })\n result.id = id\n return result\n } else if (name in dynamicOptions) {\n var dyn = dynamicOptions[name]\n return createDynamicDecl(dyn, function (env, scope) {\n var str = env.invoke(scope, dyn)\n var id = scope.def(env.shared.strings, '.id(', str, ')')\n check$1.optional(function () {\n scope(\n env.shared.shader, '.shader(',\n shaderType[name], ',',\n id, ',',\n env.command, ');')\n })\n return id\n })\n }\n return null\n }\n\n var frag = parseShader(S_FRAG)\n var vert = parseShader(S_VERT)\n\n var program = null\n var progVar\n if (isStatic(frag) && isStatic(vert)) {\n program = shaderState.program(vert.id, frag.id, null, attribLocations)\n progVar = createStaticDecl(function (env, scope) {\n return env.link(program)\n })\n } else {\n progVar = new Declaration(\n (frag && frag.thisDep) || (vert && vert.thisDep),\n (frag && frag.contextDep) || (vert && vert.contextDep),\n (frag && frag.propDep) || (vert && vert.propDep),\n function (env, scope) {\n var SHADER_STATE = env.shared.shader\n var fragId\n if (frag) {\n fragId = frag.append(env, scope)\n } else {\n fragId = scope.def(SHADER_STATE, '.', S_FRAG)\n }\n var vertId\n if (vert) {\n vertId = vert.append(env, scope)\n } else {\n vertId = scope.def(SHADER_STATE, '.', S_VERT)\n }\n var progDef = SHADER_STATE + '.program(' + vertId + ',' + fragId\n check$1.optional(function () {\n progDef += ',' + env.command\n })\n return scope.def(progDef + ')')\n })\n }\n\n return {\n frag: frag,\n vert: vert,\n progVar: progVar,\n program: program\n }\n }\n\n function parseDraw (options, env) {\n var staticOptions = options.static\n var dynamicOptions = options.dynamic\n\n // TODO: should use VAO to get default values for offset properties\n // should move vao parse into here and out of the old stuff\n\n var staticDraw = {}\n var vaoActive = false\n\n function parseVAO () {\n if (S_VAO in staticOptions) {\n var vao = staticOptions[S_VAO]\n if (vao !== null && attributeState.getVAO(vao) === null) {\n vao = attributeState.createVAO(vao)\n }\n\n vaoActive = true\n staticDraw.vao = vao\n\n return createStaticDecl(function (env) {\n var vaoRef = attributeState.getVAO(vao)\n if (vaoRef) {\n return env.link(vaoRef)\n } else {\n return 'null'\n }\n })\n } else if (S_VAO in dynamicOptions) {\n vaoActive = true\n var dyn = dynamicOptions[S_VAO]\n return createDynamicDecl(dyn, function (env, scope) {\n var vaoRef = env.invoke(scope, dyn)\n return scope.def(env.shared.vao + '.getVAO(' + vaoRef + ')')\n })\n }\n return null\n }\n\n var vao = parseVAO()\n\n var elementsActive = false\n\n function parseElements () {\n if (S_ELEMENTS in staticOptions) {\n var elements = staticOptions[S_ELEMENTS]\n staticDraw.elements = elements\n if (isBufferArgs(elements)) {\n var e = staticDraw.elements = elementState.create(elements, true)\n elements = elementState.getElements(e)\n elementsActive = true\n } else if (elements) {\n elements = elementState.getElements(elements)\n elementsActive = true\n check$1.command(elements, 'invalid elements', env.commandStr)\n }\n\n var result = createStaticDecl(function (env, scope) {\n if (elements) {\n var result = env.link(elements)\n env.ELEMENTS = result\n return result\n }\n env.ELEMENTS = null\n return null\n })\n result.value = elements\n return result\n } else if (S_ELEMENTS in dynamicOptions) {\n elementsActive = true\n\n var dyn = dynamicOptions[S_ELEMENTS]\n return createDynamicDecl(dyn, function (env, scope) {\n var shared = env.shared\n\n var IS_BUFFER_ARGS = shared.isBufferArgs\n var ELEMENT_STATE = shared.elements\n\n var elementDefn = env.invoke(scope, dyn)\n var elements = scope.def('null')\n var elementStream = scope.def(IS_BUFFER_ARGS, '(', elementDefn, ')')\n\n var ifte = env.cond(elementStream)\n .then(elements, '=', ELEMENT_STATE, '.createStream(', elementDefn, ');')\n .else(elements, '=', ELEMENT_STATE, '.getElements(', elementDefn, ');')\n\n check$1.optional(function () {\n env.assert(ifte.else,\n '!' + elementDefn + '||' + elements,\n 'invalid elements')\n })\n\n scope.entry(ifte)\n scope.exit(\n env.cond(elementStream)\n .then(ELEMENT_STATE, '.destroyStream(', elements, ');'))\n\n env.ELEMENTS = elements\n\n return elements\n })\n } else if (vaoActive) {\n return new Declaration(\n vao.thisDep,\n vao.contextDep,\n vao.propDep,\n function (env, scope) {\n return scope.def(env.shared.vao + '.currentVAO?' + env.shared.elements + '.getElements(' + env.shared.vao + '.currentVAO.elements):null')\n })\n }\n return null\n }\n\n var elements = parseElements()\n\n function parsePrimitive () {\n if (S_PRIMITIVE in staticOptions) {\n var primitive = staticOptions[S_PRIMITIVE]\n staticDraw.primitive = primitive\n check$1.commandParameter(primitive, primTypes, 'invalid primitve', env.commandStr)\n return createStaticDecl(function (env, scope) {\n return primTypes[primitive]\n })\n } else if (S_PRIMITIVE in dynamicOptions) {\n var dynPrimitive = dynamicOptions[S_PRIMITIVE]\n return createDynamicDecl(dynPrimitive, function (env, scope) {\n var PRIM_TYPES = env.constants.primTypes\n var prim = env.invoke(scope, dynPrimitive)\n check$1.optional(function () {\n env.assert(scope,\n prim + ' in ' + PRIM_TYPES,\n 'invalid primitive, must be one of ' + Object.keys(primTypes))\n })\n return scope.def(PRIM_TYPES, '[', prim, ']')\n })\n } else if (elementsActive) {\n if (isStatic(elements)) {\n if (elements.value) {\n return createStaticDecl(function (env, scope) {\n return scope.def(env.ELEMENTS, '.primType')\n })\n } else {\n return createStaticDecl(function () {\n return GL_TRIANGLES$1\n })\n }\n } else {\n return new Declaration(\n elements.thisDep,\n elements.contextDep,\n elements.propDep,\n function (env, scope) {\n var elements = env.ELEMENTS\n return scope.def(elements, '?', elements, '.primType:', GL_TRIANGLES$1)\n })\n }\n } else if (vaoActive) {\n return new Declaration(\n vao.thisDep,\n vao.contextDep,\n vao.propDep,\n function (env, scope) {\n return scope.def(env.shared.vao + '.currentVAO?' + env.shared.vao + '.currentVAO.primitive:' + GL_TRIANGLES$1)\n })\n }\n return null\n }\n\n function parseParam (param, isOffset) {\n if (param in staticOptions) {\n var value = staticOptions[param] | 0\n if (isOffset) {\n staticDraw.offset = value\n } else {\n staticDraw.instances = value\n }\n check$1.command(!isOffset || value >= 0, 'invalid ' + param, env.commandStr)\n return createStaticDecl(function (env, scope) {\n if (isOffset) {\n env.OFFSET = value\n }\n return value\n })\n } else if (param in dynamicOptions) {\n var dynValue = dynamicOptions[param]\n return createDynamicDecl(dynValue, function (env, scope) {\n var result = env.invoke(scope, dynValue)\n if (isOffset) {\n env.OFFSET = result\n check$1.optional(function () {\n env.assert(scope,\n result + '>=0',\n 'invalid ' + param)\n })\n }\n return result\n })\n } else if (isOffset) {\n if (elementsActive) {\n return createStaticDecl(function (env, scope) {\n env.OFFSET = 0\n return 0\n })\n } else if (vaoActive) {\n return new Declaration(\n vao.thisDep,\n vao.contextDep,\n vao.propDep,\n function (env, scope) {\n return scope.def(env.shared.vao + '.currentVAO?' + env.shared.vao + '.currentVAO.offset:0')\n })\n }\n } else if (vaoActive) {\n return new Declaration(\n vao.thisDep,\n vao.contextDep,\n vao.propDep,\n function (env, scope) {\n return scope.def(env.shared.vao + '.currentVAO?' + env.shared.vao + '.currentVAO.instances:-1')\n })\n }\n return null\n }\n\n var OFFSET = parseParam(S_OFFSET, true)\n\n function parseVertCount () {\n if (S_COUNT in staticOptions) {\n var count = staticOptions[S_COUNT] | 0\n staticDraw.count = count\n check$1.command(\n typeof count === 'number' && count >= 0, 'invalid vertex count', env.commandStr)\n return createStaticDecl(function () {\n return count\n })\n } else if (S_COUNT in dynamicOptions) {\n var dynCount = dynamicOptions[S_COUNT]\n return createDynamicDecl(dynCount, function (env, scope) {\n var result = env.invoke(scope, dynCount)\n check$1.optional(function () {\n env.assert(scope,\n 'typeof ' + result + '===\"number\"&&' +\n result + '>=0&&' +\n result + '===(' + result + '|0)',\n 'invalid vertex count')\n })\n return result\n })\n } else if (elementsActive) {\n if (isStatic(elements)) {\n if (elements) {\n if (OFFSET) {\n return new Declaration(\n OFFSET.thisDep,\n OFFSET.contextDep,\n OFFSET.propDep,\n function (env, scope) {\n var result = scope.def(\n env.ELEMENTS, '.vertCount-', env.OFFSET)\n\n check$1.optional(function () {\n env.assert(scope,\n result + '>=0',\n 'invalid vertex offset/element buffer too small')\n })\n\n return result\n })\n } else {\n return createStaticDecl(function (env, scope) {\n return scope.def(env.ELEMENTS, '.vertCount')\n })\n }\n } else {\n var result = createStaticDecl(function () {\n return -1\n })\n check$1.optional(function () {\n result.MISSING = true\n })\n return result\n }\n } else {\n var variable = new Declaration(\n elements.thisDep || OFFSET.thisDep,\n elements.contextDep || OFFSET.contextDep,\n elements.propDep || OFFSET.propDep,\n function (env, scope) {\n var elements = env.ELEMENTS\n if (env.OFFSET) {\n return scope.def(elements, '?', elements, '.vertCount-',\n env.OFFSET, ':-1')\n }\n return scope.def(elements, '?', elements, '.vertCount:-1')\n })\n check$1.optional(function () {\n variable.DYNAMIC = true\n })\n return variable\n }\n } else if (vaoActive) {\n var countVariable = new Declaration(\n vao.thisDep,\n vao.contextDep,\n vao.propDep,\n function (env, scope) {\n return scope.def(env.shared.vao, '.currentVAO?', env.shared.vao, '.currentVAO.count:-1')\n })\n return countVariable\n }\n return null\n }\n\n var primitive = parsePrimitive()\n var count = parseVertCount()\n var instances = parseParam(S_INSTANCES, false)\n\n return {\n elements: elements,\n primitive: primitive,\n count: count,\n instances: instances,\n offset: OFFSET,\n vao: vao,\n\n vaoActive: vaoActive,\n elementsActive: elementsActive,\n\n // static draw props\n static: staticDraw\n }\n }\n\n function parseGLState (options, env) {\n var staticOptions = options.static\n var dynamicOptions = options.dynamic\n\n var STATE = {}\n\n GL_STATE_NAMES.forEach(function (prop) {\n var param = propName(prop)\n\n function parseParam (parseStatic, parseDynamic) {\n if (prop in staticOptions) {\n var value = parseStatic(staticOptions[prop])\n STATE[param] = createStaticDecl(function ()
1{\n return value\n })\n } else if (prop in dynamicOptions) {\n var dyn = dynamicOptions[prop]\n STATE[param] = createDynamicDecl(dyn, function (env, scope) {\n return parseDynamic(env, scope, env.invoke(scope, dyn))\n })\n }\n }\n\n switch (prop) {\n case S_CULL_ENABLE:\n case S_BLEND_ENABLE:\n case S_DITHER:\n case S_STENCIL_ENABLE:\n case S_DEPTH_ENABLE:\n case S_SCISSOR_ENABLE:\n case S_POLYGON_OFFSET_ENABLE:\n case S_SAMPLE_ALPHA:\n case S_SAMPLE_ENABLE:\n case S_DEPTH_MASK:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'boolean', prop, env.commandStr)\n return value\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n 'typeof ' + value + '===\"boolean\"',\n 'invalid flag ' + prop, env.commandStr)\n })\n return value\n })\n\n case S_DEPTH_FUNC:\n return parseParam(\n function (value) {\n check$1.commandParameter(value, compareFuncs, 'invalid ' + prop, env.commandStr)\n return compareFuncs[value]\n },\n function (env, scope, value) {\n var COMPARE_FUNCS = env.constants.compareFuncs\n check$1.optional(function () {\n env.assert(scope,\n value + ' in ' + COMPARE_FUNCS,\n 'invalid ' + prop + ', must be one of ' + Object.keys(compareFuncs))\n })\n return scope.def(COMPARE_FUNCS, '[', value, ']')\n })\n\n case S_DEPTH_RANGE:\n return parseParam(\n function (value) {\n check$1.command(\n isArrayLike(value) &&\n value.length === 2 &&\n typeof value[0] === 'number' &&\n typeof value[1] === 'number' &&\n value[0] <= value[1],\n 'depth range is 2d array',\n env.commandStr)\n return value\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n env.shared.isArrayLike + '(' + value + ')&&' +\n value + '.length===2&&' +\n 'typeof ' + value + '[0]===\"number\"&&' +\n 'typeof ' + value + '[1]===\"number\"&&' +\n value + '[0]<=' + value + '[1]',\n 'depth range must be a 2d array')\n })\n\n var Z_NEAR = scope.def('+', value, '[0]')\n var Z_FAR = scope.def('+', value, '[1]')\n return [Z_NEAR, Z_FAR]\n })\n\n case S_BLEND_FUNC:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'object', 'blend.func', env.commandStr)\n var srcRGB = ('srcRGB' in value ? value.srcRGB : value.src)\n var srcAlpha = ('srcAlpha' in value ? value.srcAlpha : value.src)\n var dstRGB = ('dstRGB' in value ? value.dstRGB : value.dst)\n var dstAlpha = ('dstAlpha' in value ? value.dstAlpha : value.dst)\n check$1.commandParameter(srcRGB, blendFuncs, param + '.srcRGB', env.commandStr)\n check$1.commandParameter(srcAlpha, blendFuncs, param + '.srcAlpha', env.commandStr)\n check$1.commandParameter(dstRGB, blendFuncs, param + '.dstRGB', env.commandStr)\n check$1.commandParameter(dstAlpha, blendFuncs, param + '.dstAlpha', env.commandStr)\n\n check$1.command(\n (invalidBlendCombinations.indexOf(srcRGB + ', ' + dstRGB) === -1),\n 'unallowed blending combination (srcRGB, dstRGB) = (' + srcRGB + ', ' + dstRGB + ')', env.commandStr)\n\n return [\n blendFuncs[srcRGB],\n blendFuncs[dstRGB],\n blendFuncs[srcAlpha],\n blendFuncs[dstAlpha]\n ]\n },\n function (env, scope, value) {\n var BLEND_FUNCS = env.constants.blendFuncs\n\n check$1.optional(function () {\n env.assert(scope,\n value + '&&typeof ' + value + '===\"object\"',\n 'invalid blend func, must be an object')\n })\n\n function read (prefix, suffix) {\n var func = scope.def(\n '\"', prefix, suffix, '\" in ', value,\n '?', value, '.', prefix, suffix,\n ':', value, '.', prefix)\n\n check$1.optional(function () {\n env.assert(scope,\n func + ' in ' + BLEND_FUNCS,\n 'invalid ' + prop + '.' + prefix + suffix + ', must be one of ' + Object.keys(blendFuncs))\n })\n\n return func\n }\n\n var srcRGB = read('src', 'RGB')\n var dstRGB = read('dst', 'RGB')\n\n check$1.optional(function () {\n var INVALID_BLEND_COMBINATIONS = env.constants.invalidBlendCombinations\n\n env.assert(scope,\n INVALID_BLEND_COMBINATIONS +\n '.indexOf(' + srcRGB + '+\", \"+' + dstRGB + ') === -1 ',\n 'unallowed blending combination for (srcRGB, dstRGB)'\n )\n })\n\n var SRC_RGB = scope.def(BLEND_FUNCS, '[', srcRGB, ']')\n var SRC_ALPHA = scope.def(BLEND_FUNCS, '[', read('src', 'Alpha'), ']')\n var DST_RGB = scope.def(BLEND_FUNCS, '[', dstRGB, ']')\n var DST_ALPHA = scope.def(BLEND_FUNCS, '[', read('dst', 'Alpha'), ']')\n\n return [SRC_RGB, DST_RGB, SRC_ALPHA, DST_ALPHA]\n })\n\n case S_BLEND_EQUATION:\n return parseParam(\n function (value) {\n if (typeof value === 'string') {\n check$1.commandParameter(value, blendEquations, 'invalid ' + prop, env.commandStr)\n return [\n blendEquations[value],\n blendEquations[value]\n ]\n } else if (typeof value === 'object') {\n check$1.commandParameter(\n value.rgb, blendEquations, prop + '.rgb', env.commandStr)\n check$1.commandParameter(\n value.alpha, blendEquations, prop + '.alpha', env.commandStr)\n return [\n blendEquations[value.rgb],\n blendEquations[value.alpha]\n ]\n } else {\n check$1.commandRaise('invalid blend.equation', env.commandStr)\n }\n },\n function (env, scope, value) {\n var BLEND_EQUATIONS = env.constants.blendEquations\n\n var RGB = scope.def()\n var ALPHA = scope.def()\n\n var ifte = env.cond('typeof ', value, '===\"string\"')\n\n check$1.optional(function () {\n function checkProp (block, name, value) {\n env.assert(block,\n value + ' in ' + BLEND_EQUATIONS,\n 'invalid ' + name + ', must be one of ' + Object.keys(blendEquations))\n }\n checkProp(ifte.then, prop, value)\n\n env.assert(ifte.else,\n value + '&&typeof ' + value + '===\"object\"',\n 'invalid ' + prop)\n checkProp(ifte.else, prop + '.rgb', value + '.rgb')\n checkProp(ifte.else, prop + '.alpha', value + '.alpha')\n })\n\n ifte.then(\n RGB, '=', ALPHA, '=', BLEND_EQUATIONS, '[', value, '];')\n ifte.else(\n RGB, '=', BLEND_EQUATIONS, '[', value, '.rgb];',\n ALPHA, '=', BLEND_EQUATIONS, '[', value, '.alpha];')\n\n scope(ifte)\n\n return [RGB, ALPHA]\n })\n\n case S_BLEND_COLOR:\n return parseParam(\n function (value) {\n check$1.command(\n isArrayLike(value) &&\n value.length === 4,\n 'blend.color must be a 4d array', env.commandStr)\n return loop(4, function (i) {\n return +value[i]\n })\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n env.shared.isArrayLike + '(' + value + ')&&' +\n value + '.length===4',\n 'blend.color must be a 4d array')\n })\n return loop(4, function (i) {\n return scope.def('+', value, '[', i, ']')\n })\n })\n\n case S_STENCIL_MASK:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'number', param, env.commandStr)\n return value | 0\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n 'typeof ' + value + '===\"number\"',\n 'invalid stencil.mask')\n })\n return scope.def(value, '|0')\n })\n\n case S_STENCIL_FUNC:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'object', param, env.commandStr)\n var cmp = value.cmp || 'keep'\n var ref = value.ref || 0\n var mask = 'mask' in value ? value.mask : -1\n check$1.commandParameter(cmp, compareFuncs, prop + '.cmp', env.commandStr)\n check$1.commandType(ref, 'number', prop + '.ref', env.commandStr)\n check$1.commandType(mask, 'number', prop + '.mask', env.commandStr)\n return [\n compareFuncs[cmp],\n ref,\n mask\n ]\n },\n function (env, scope, value) {\n var COMPARE_FUNCS = env.constants.compareFuncs\n check$1.optional(function () {\n function assert () {\n env.assert(scope,\n Array.prototype.join.call(arguments, ''),\n 'invalid stencil.func')\n }\n assert(value + '&&typeof ', value, '===\"object\"')\n assert('!(\"cmp\" in ', value, ')||(',\n value, '.cmp in ', COMPARE_FUNCS, ')')\n })\n var cmp = scope.def(\n '\"cmp\" in ', value,\n '?', COMPARE_FUNCS, '[', value, '.cmp]',\n ':', GL_KEEP)\n var ref = scope.def(value, '.ref|0')\n var mask = scope.def(\n '\"mask\" in ', value,\n '?', value, '.mask|0:-1')\n return [cmp, ref, mask]\n })\n\n case S_STENCIL_OPFRONT:\n case S_STENCIL_OPBACK:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'object', param, env.commandStr)\n var fail = value.fail || 'keep'\n var zfail = value.zfail || 'keep'\n var zpass = value.zpass || 'keep'\n check$1.commandParameter(fail, stencilOps, prop + '.fail', env.commandStr)\n check$1.commandParameter(zfail, stencilOps, prop + '.zfail', env.commandStr)\n check$1.commandParameter(zpass, stencilOps, prop + '.zpass', env.commandStr)\n return [\n prop === S_STENCIL_OPBACK ? GL_BACK : GL_FRONT,\n stencilOps[fail],\n stencilOps[zfail],\n stencilOps[zpass]\n ]\n },\n function (env, scope, value) {\n var STENCIL_OPS = env.constants.stencilOps\n\n check$1.optional(function () {\n env.assert(scope,\n value + '&&typeof ' + value + '===\"object\"',\n 'invalid ' + prop)\n })\n\n function read (name) {\n check$1.optional(function () {\n env.assert(scope,\n '!(\"' + name + '\" in ' + value + ')||' +\n '(' + value + '.' + name + ' in ' + STENCIL_OPS + ')',\n 'invalid ' + prop + '.' + name + ', must be one of ' + Object.keys(stencilOps))\n })\n\n return scope.def(\n '\"', name, '\" in ', value,\n '?', STENCIL_OPS, '[', value, '.', name, ']:',\n GL_KEEP)\n }\n\n return [\n prop === S_STENCIL_OPBACK ? GL_BACK : GL_FRONT,\n read('fail'),\n read('zfail'),\n read('zpass')\n ]\n })\n\n case S_POLYGON_OFFSET_OFFSET:\n return parseParam(\n function (value) {\n check$1.commandType(value, 'object', param, env.commandStr)\n var factor = value.factor | 0\n var units = value.units | 0\n check$1.commandType(factor, 'number', param + '.factor', env.commandStr)\n check$1.commandType(units, 'number', param + '.units', env.commandStr)\n return [factor, units]\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n value + '&&typeof ' + value + '===\"object\"',\n 'invalid ' + prop)\n })\n\n var FACTOR = scope.def(value, '.factor|0')\n var UNITS = scope.def(value, '.units|0')\n\n return [FACTOR, UNITS]\n })\n\n case S_CULL_FACE:\n return parseParam(\n function (value) {\n var face = 0\n if (value === 'front') {\n face = GL_FRONT\n } else if (value === 'back') {\n face = GL_BACK\n }\n check$1.command(!!face, param, env.commandStr)\n return face\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n value + '===\"front\"||' +\n value + '===\"back\"',\n 'invalid cull.face')\n })\n return scope.def(value, '===\"front\"?', GL_FRONT, ':', GL_BACK)\n })\n\n case S_LINE_WIDTH:\n return parseParam(\n function (value) {\n check$1.command(\n typeof value === 'number' &&\n value >= limits.lineWidthDims[0] &&\n value <= limits.lineWidthDims[1],\n 'invalid line width, must be a positive number between ' +\n limits.lineWidthDims[0] + ' and ' + limits.lineWidthDims[1], env.commandStr)\n return value\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n 'typeof ' + value + '===\"number\"&&' +\n value + '>=' + limits.lineWidthDims[0] + '&&' +\n value + '<=' + limits.lineWidthDims[1],\n 'invalid line width')\n })\n\n return value\n })\n\n case S_FRONT_FACE:\n return parseParam(\n function (value) {\n check$1.commandParameter(value, orientationType, param, env.commandStr)\n return orientationType[value]\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n value + '===\"cw\"||' +\n value + '===\"ccw\"',\n 'invalid frontFace, must be one of cw,ccw')\n })\n return scope.def(value + '===\"cw\"?' + GL_CW + ':' + GL_CCW)\n
1 })\n\n case S_COLOR_MASK:\n return parseParam(\n function (value) {\n check$1.command(\n isArrayLike(value) && value.length === 4,\n 'color.mask must be length 4 array', env.commandStr)\n return value.map(function (v) { return !!v })\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n env.shared.isArrayLike + '(' + value + ')&&' +\n value + '.length===4',\n 'invalid color.mask')\n })\n return loop(4, function (i) {\n return '!!' + value + '[' + i + ']'\n })\n })\n\n case S_SAMPLE_COVERAGE:\n return parseParam(\n function (value) {\n check$1.command(typeof value === 'object' && value, param, env.commandStr)\n var sampleValue = 'value' in value ? value.value : 1\n var sampleInvert = !!value.invert\n check$1.command(\n typeof sampleValue === 'number' &&\n sampleValue >= 0 && sampleValue <= 1,\n 'sample.coverage.value must be a number between 0 and 1', env.commandStr)\n return [sampleValue, sampleInvert]\n },\n function (env, scope, value) {\n check$1.optional(function () {\n env.assert(scope,\n value + '&&typeof ' + value + '===\"object\"',\n 'invalid sample.coverage')\n })\n var VALUE = scope.def(\n '\"value\" in ', value, '?+', value, '.value:1')\n var INVERT = scope.def('!!', value, '.invert')\n return [VALUE, INVERT]\n })\n }\n })\n\n return STATE\n }\n\n function parseUniforms (uniforms, env) {\n var staticUniforms = uniforms.static\n var dynamicUniforms = uniforms.dynamic\n\n var UNIFORMS = {}\n\n Object.keys(staticUniforms).forEach(function (name) {\n var value = staticUniforms[name]\n var result\n if (typeof value === 'number' ||\n typeof value === 'boolean') {\n result = createStaticDecl(function () {\n return value\n })\n } else if (typeof value === 'function') {\n var reglType = value._reglType\n if (reglType === 'texture2d' ||\n reglType === 'textureCube') {\n result = createStaticDecl(function (env) {\n return env.link(value)\n })\n } else if (reglType === 'framebuffer' ||\n reglType === 'framebufferCube') {\n check$1.command(value.color.length > 0,\n 'missing color attachment for framebuffer sent to uniform \"' + name + '\"', env.commandStr)\n result = createStaticDecl(function (env) {\n return env.link(value.color[0])\n })\n } else {\n check$1.commandRaise('invalid data for uniform \"' + name + '\"', env.commandStr)\n }\n } else if (isArrayLike(value)) {\n result = createStaticDecl(function (env) {\n var ITEM = env.global.def('[',\n loop(value.length, function (i) {\n check$1.command(\n typeof value[i] === 'number' ||\n typeof value[i] === 'boolean',\n 'invalid uniform ' + name, env.commandStr)\n return value[i]\n }), ']')\n return ITEM\n })\n } else {\n check$1.commandRaise('invalid or missing data for uniform \"' + name + '\"', env.commandStr)\n }\n result.value = value\n UNIFORMS[name] = result\n })\n\n Object.keys(dynamicUniforms).forEach(function (key) {\n var dyn = dynamicUniforms[key]\n UNIFORMS[key] = createDynamicDecl(dyn, function (env, scope) {\n return env.invoke(scope, dyn)\n })\n })\n\n return UNIFORMS\n }\n\n function parseAttributes (attributes, env) {\n var staticAttributes = attributes.static\n var dynamicAttributes = attributes.dynamic\n\n var attributeDefs = {}
1\n\n Object.keys(staticAttributes).forEach(function (attribute) {\n var value = staticAttributes[attribute]\n var id = stringStore.id(attribute)\n\n var record = new AttributeRecord()\n if (isBufferArgs(value)) {\n record.state = ATTRIB_STATE_POINTER\n record.buffer = bufferState.getBuffer(\n bufferState.create(value, GL_ARRAY_BUFFER$2, false, true))\n record.type = 0\n } else {\n var buffer = bufferState.getBuffer(value)\n if (buffer) {\n record.state = ATTRIB_STATE_POINTER\n record.buffer = buffer\n record.type = 0\n } else {\n check$1.command(typeof value === 'object' && value,\n 'invalid data for attribute ' + attribute, env.commandStr)\n if ('constant' in value) {\n var constant = value.constant\n record.buffer = 'null'\n record.state = ATTRIB_STATE_CONSTANT\n if (typeof constant === 'number') {\n record.x = constant\n } else {\n check$1.command(\n isArrayLike(constant) &&\n constant.length > 0 &&\n constant.length <= 4,\n 'invalid constant for attribute ' + attribute, env.commandStr)\n CUTE_COMPONENTS.forEach(function (c, i) {\n if (i < constant.length) {\n record[c] = constant[i]\n }\n })\n }\n } else {\n if (isBufferArgs(value.buffer)) {\n buffer = bufferState.getBuffer(\n bufferState.create(value.buffer, GL_ARRAY_BUFFER$2, false, true))\n } else {\n buffer = bufferState.getBuffer(value.buffer)\n }\n check$1.command(!!buffer, 'missing buffer for attribute \"' + attribute + '\"', env.commandStr)\n\n var offset = value.offset | 0\n check$1.command(offset >= 0,\n 'invalid offset for attribute \"' + attribute + '\"', env.commandStr)\n\n var stride = value.stride | 0\n check$1.command(stride >= 0 && stride < 256,\n 'invalid stride for attribute \"' + attribute + '\", must be integer betweeen [0, 255]', env.commandStr)\n\n var size = value.size | 0\n check$1.command(!('size' in value) || (size > 0 && size <= 4),\n 'invalid size for attribute \"' + attribute + '\", must be 1,2,3,4', env.commandStr)\n\n var normalized = !!value.normalized\n\n var type = 0\n if ('type' in value) {\n check$1.commandParameter(\n value.type, glTypes,\n 'invalid type for attribute ' + attribute, env.commandStr)\n type = glTypes[value.type]\n }\n\n var divisor = value.divisor | 0\n check$1.optional(function () {\n if ('divisor' in value) {\n check$1.command(divisor === 0 || extInstancing,\n 'cannot specify divisor for attribute \"' + attribute + '\", instancing not supported', env.commandStr)\n check$1.command(divisor >= 0,\n 'invalid divisor for attribute \"' + attribute + '\"', env.commandStr)\n }\n\n var command = env.commandStr\n\n var VALID_KEYS = [\n 'buffer',\n 'offset',\n 'divisor',\n 'normalized',\n 'type',\n 'size',\n 'stride'\n ]\n\n Object.keys(value).forEach(function (prop) {\n check$1.command(\n VALID_KEYS.indexOf(prop) >= 0,\n 'unknown parameter \"' + prop + '\" for attribute pointer \"' + attribute + '\" (valid parameters are ' + VALID_KEYS + ')',\n command)\n })\n })\n\n record.buffer = buffer\n record.state = ATTRIB_STATE_POINTER\n record.size = size\n record.normalized = normalized\n record.type = type || buffer.dtype\n record.offset = offset\n record.stride = stride\n record.divisor = divisor\n }\n }\n }\n\n attributeDefs[attribute] = createStaticDecl(function (env, scope) {\n var cache = env.attribCache\n if (id in cache) {\n return cache[id]\n }
1\n var result = {\n isStream: false\n }\n Object.keys(record).forEach(function (key) {\n result[key] = record[key]\n })\n if (record.buffer) {\n result.buffer = env.link(record.buffer)\n result.type = result.type || (result.buffer + '.dtype')\n }\n cache[id] = result\n return result\n })\n })\n\n Object.keys(dynamicAttributes).forEach(function (attribute) {\n var dyn = dynamicAttributes[attribute]\n\n function appendAttributeCode (env, block) {\n var VALUE = env.invoke(block, dyn)\n\n var shared = env.shared\n var constants = env.constants\n\n var IS_BUFFER_ARGS = shared.isBufferArgs\n var BUFFER_STATE = shared.buffer\n\n // Perform validation on attribute\n check$1.optional(function () {\n env.assert(block,\n VALUE + '&&(typeof ' + VALUE + '===\"object\"||typeof ' +\n VALUE + '===\"function\")&&(' +\n IS_BUFFER_ARGS + '(' + VALUE + ')||' +\n BUFFER_STATE + '.getBuffer(' + VALUE + ')||' +\n BUFFER_STATE + '.getBuffer(' + VALUE + '.buffer)||' +\n IS_BUFFER_ARGS + '(' + VALUE + '.buffer)||' +\n '(\"constant\" in ' + VALUE +\n '&&(typeof ' + VALUE + '.constant===\"number\"||' +\n shared.isArrayLike + '(' + VALUE + '.constant))))',\n 'invalid dynamic attribute \"' + attribute + '\"')\n })\n\n // allocate names for result\n var result = {\n isStream: block.def(false)\n }\n var defaultRecord = new AttributeRecord()\n defaultRecord.state = ATTRIB_STATE_POINTER\n Object.keys(defaultRecord).forEach(function (key) {\n result[key] = block.def('' + defaultRecord[key])\n })\n\n var BUFFER = result.buffer\n var TYPE = result.type\n block(\n 'if(', IS_BUFFER_ARGS, '(', VALUE, ')){',\n result.isStream, '=true;',\n BUFFER, '=', BUFFER_STATE, '.createStream(', GL_ARRAY_BUFFER$2, ',', VALUE, ');',\n TYPE, '=', BUFFER, '.dtype;',\n '}else{',\n BUFFER, '=', BUFFER_STATE, '.getBuffer(', VALUE, ');',\n 'if(', BUFFER, '){',\n TYPE, '=', BUFFER, '.dtype;',\n '}else if(\"constant\" in ', VALUE, '){',\n result.state, '=', ATTRIB_STATE_CONSTANT, ';',\n 'if(typeof ' + VALUE + '.constant === \"number\"){',\n result[CUTE_COMPONENTS[0]], '=', VALUE, '.constant;',\n CUTE_COMPONENTS.slice(1).map(function (n) {\n return result[n]\n }).join('='), '=0;',\n '}else{',\n CUTE_COMPONENTS.map(function (name, i) {\n return (\n result[name] + '=' + VALUE + '.constant.length>' + i +\n '?' + VALUE + '.constant[' + i + ']:0;'\n )\n }).join(''),\n '}}else{',\n 'if(', IS_BUFFER_ARGS, '(', VALUE, '.buffer)){',\n BUFFER, '=', BUFFER_STATE, '.createStream(', GL_ARRAY_BUFFER$2, ',', VALUE, '.buffer);',\n '}else{',\n BUFFER, '=', BUFFER_STATE, '.getBuffer(', VALUE, '.buffer);',\n '}',\n TYPE, '=\"type\" in ', VALUE, '?',\n constants.glTypes, '[', VALUE, '.type]:', BUFFER, '.dtype;',\n result.normalized, '=!!', VALUE, '.normalized;')\n function emitReadRecord (name) {\n block(result[name], '=', VALUE, '.', name, '|0;')\n }\n emitReadRecord('size')\n emitReadRecord('offset')\n emitReadRecord('stride')\n emitReadRecord('divisor')\n\n block('}}')\n\n block.exit(\n 'if(', result.isStream, '){',\n BUFFER_STATE, '.destroyStream(', BUFFER, ');',\n '}')\n\n return result\n }\n\n attributeDefs[attribute] = createDynamicDecl(dyn, appendAttributeCode)\n })\n\n return attributeDefs\n }\n\n function parseContext (context) {\n var staticContext = context.static\n var dynamicContext = context.dynamic\n var result = {}
1\n\n Object.keys(staticContext).forEach(function (name) {\n var value = staticContext[name]\n result[name] = createStaticDecl(function (env, scope) {\n if (typeof value === 'number' || typeof value === 'boolean') {\n return '' + value\n } else {\n return env.link(value)\n }\n })\n })\n\n Object.keys(dynamicContext).forEach(function (name) {\n var dyn = dynamicContext[name]\n result[name] = createDynamicDecl(dyn, function (env, scope) {\n return env.invoke(scope, dyn)\n })\n })\n\n return result\n }\n\n function parseArguments (options, attributes, uniforms, context, env) {\n var staticOptions = options.static\n var dynamicOptions = options.dynamic\n\n check$1.optional(function () {\n var KEY_NAMES = [\n S_FRAMEBUFFER,\n S_VERT,\n S_FRAG,\n S_ELEMENTS,\n S_PRIMITIVE,\n S_OFFSET,\n S_COUNT,\n S_INSTANCES,\n S_PROFILE,\n S_VAO\n ].concat(GL_STATE_NAMES)\n\n function checkKeys (dict) {\n Object.keys(dict).forEach(function (key) {\n check$1.command(\n KEY_NAMES.indexOf(key) >= 0,\n 'unknown parameter \"' + key + '\"',\n env.commandStr)\n })\n }\n\n checkKeys(staticOptions)\n checkKeys(dynamicOptions)\n })\n\n var attribLocations = parseAttribLocations(options, attributes)\n\n var framebuffer = parseFramebuffer(options, env)\n var viewportAndScissor = parseViewportScissor(options, framebuffer, env)\n var draw = parseDraw(options, env)\n var state = parseGLState(options, env)\n var shader = parseProgram(options, env, attribLocations)\n\n function copyBox (name) {\n var defn = viewportAndScissor[name]\n if (defn) {\n state[name] = defn\n }\n }\n copyBox(S_VIEWPORT)\n copyBox(propName(S_SCISSOR_BOX))\n\n var dirty = Object.keys(state).length > 0\n\n var result = {\n framebuffer: framebuffer,\n draw: draw,\n shader: shader,\n state: state,\n dirty: dirty,\n scopeVAO: null,\n drawVAO: null,\n useVAO: false,\n attributes: {}\n }\n\n result.profile = parseProfile(options, env)\n result.uniforms = parseUniforms(uniforms, env)\n result.drawVAO = result.scopeVAO = draw.vao\n // special case: check if we can statically allocate a vertex array object for this program\n if (!result.drawVAO &&\n shader.program &&\n !attribLocations &&\n extensions.angle_instanced_arrays &&\n draw.static.elements) {\n var useVAO = true\n var staticBindings = shader.program.attributes.map(function (attr) {\n var binding = attributes.static[attr]\n useVAO = useVAO && !!binding\n return binding\n })\n if (useVAO && staticBindings.length > 0) {\n var vao = attributeState.getVAO(attributeState.createVAO({\n attributes: staticBindings,\n elements: draw.static.elements\n }))\n result.drawVAO = new Declaration(null, null, null, function (env, scope) {\n return env.link(vao)\n })\n result.useVAO = true\n }\n }\n if (attribLocations) {\n result.useVAO = true\n } else {\n result.attributes = parseAttributes(attributes, env)\n }\n result.context = parseContext(context, env)\n return result\n }\n\n // ===================================================\n // ===================================================\n // COMMON UPDATE FUNCTIONS\n // ===================================================\n // ===================================================\n function emitContext (env, scope, context) {\n var shared = env.shared\n var CONTEXT = shared.context\n\n var contextEnter = env.scope()\n\n Object.keys(context).forEach(function (name) {\n scope.save(CONTEXT, '.' + name)\n var defn = context[name]\n var value = defn.append(env, scope)\n if (Array.isArray(value)) {\n contextEnter(CONTEXT, '.', name, '=[', value.join(), '];')\n } else {\n contextEnter(CONTEXT, '.', name, '=', value, ';')\n }\n })\n\n scope(contextEnter)\n }\n\n // ===================================================\n // ===================================================\n // COMMON DRAWING FUNCTIONS\n // ===================================================\n // ===================================================\n function emitPollFramebuffer (env, scope, framebuffer, skipCheck) {\n var shared = env.shared\n\n var GL = shared.gl\n var FRAMEBUFFER_STATE = shared.framebuffer\n var EXT_DRAW_BUFFERS\n if (extDrawBuffers) {\n EXT_DRAW_BUFFERS = scope.def(shared.extensions, '.webgl_draw_buffers')\n }\n\n var constants = env.constants\n\n var DRAW_BUFFERS = constants.drawBuffer\n var BACK_BUFFER = constants.backBuffer\n\n var NEXT\n if (framebuffer) {\n NEXT = framebuffer.append(env, scope)\n } else {\n NEXT = scope.def(FRAMEBUFFER_STATE, '.next')\n }\n\n if (!skipCheck) {\n scope('if(', NEXT, '!==', FRAMEBUFFER_STATE, '.cur){')\n }\n scope(\n 'if(', NEXT, '){',\n GL, '.bindFramebuffer(', GL_FRAMEBUFFER$2, ',', NEXT, '.framebuffer);')\n if (extDrawBuffers) {\n scope(EXT_DRAW_BUFFERS, '.drawBuffersWEBGL(',\n DRAW_BUFFERS, '[', NEXT, '.colorAttachments.length]);')\n }\n scope('}else{',\n GL, '.bindFramebuffer(', GL_FRAMEBUFFER$2, ',null);')\n if (extDrawBuffers) {\n scope(EXT_DRAW_BUFFERS, '.drawBuffersWEBGL(', BACK_BUFFER, ');')\n }\n scope(\n '}',\n FRAMEBUFFER_STATE, '.cur=', NEXT, ';')\n if (!skipCheck) {\n scope('}')\n }\n }\n\n function emitPollState (env, scope, args) {\n var shared = env.shared\n\n var GL = shared.gl\n\n var CURRENT_VARS = env.current\n var NEXT_VARS = env.next\n var CURRENT_STATE = shared.current\n var NEXT_STATE = shared.next\n\n var block = env.cond(CURRENT_STATE, '.dirty')\n\n GL_STATE_NAMES.forEach(function (prop) {\n var param = propName(prop)\n if (param in args.state) {\n return\n }\n\n var NEXT, CURRENT\n if (param in NEXT_VARS) {\n NEXT = NEXT_VARS[param]\n CURRENT = CURRENT_VARS[param]\n var parts = loop(currentState[param].length, function (i) {\n return block.def(NEXT, '[', i, ']')\n })\n block(env.cond(parts.map(function (p, i) {\n return p + '!==' + CURRENT + '[' + i + ']'\n }).join('||'))\n .then(\n GL, '.', GL_VARIABLES[param], '(', parts, ');',\n parts.map(function (p, i) {\n return CURRENT + '[' + i + ']=' + p\n }).join(';'), ';'))\n } else {\n NEXT = block.def(NEXT_STATE, '.', param)\n var ifte = env.cond(NEXT, '!==', CURRENT_STATE, '.', param)\n block(ifte)\n if (param in GL_FLAGS) {\n ifte(\n env.cond(NEXT)\n .then(GL, '.enable(', GL_FLAGS[param], ');')\n .else(GL, '.disable(', GL_FLAGS[param], ');'),\n CURRENT_STATE, '.', param, '=', NEXT, ';')\n } else {\n ifte(\n GL, '.', GL_VARIABLES[param], '(', NEXT, ');',\n CURRENT_STATE, '.', param, '=', NEXT, ';')\n }\n }\n })\n if (Object.keys(args.state).length === 0) {\n block(CURRENT_STATE, '.dirty=false;')\n }\n scope(block)\n }\n\n function emitSetOptions (env, scope, options, filter) {\n var shared = env.shared\n var CURRENT_VARS = env.current\n var CURRENT_STATE = shared.current\n var GL = shared.gl\n sortState(Object.keys(options)).forEac
1h(function (param) {\n var defn = options[param]\n if (filter && !filter(defn)) {\n return\n }\n var variable = defn.append(env, scope)\n if (GL_FLAGS[param]) {\n var flag = GL_FLAGS[param]\n if (isStatic(defn)) {\n if (variable) {\n scope(GL, '.enable(', flag, ');')\n } else {\n scope(GL, '.disable(', flag, ');')\n }\n } else {\n scope(env.cond(variable)\n .then(GL, '.enable(', flag, ');')\n .else(GL, '.disable(', flag, ');'))\n }\n scope(CURRENT_STATE, '.', param, '=', variable, ';')\n } else if (isArrayLike(variable)) {\n var CURRENT = CURRENT_VARS[param]\n scope(\n GL, '.', GL_VARIABLES[param], '(', variable, ');',\n variable.map(function (v, i) {\n return CURRENT + '[' + i + ']=' + v\n }).join(';'), ';')\n } else {\n scope(\n GL, '.', GL_VARIABLES[param], '(', variable, ');',\n CURRENT_STATE, '.', param, '=', variable, ';')\n }\n })\n }\n\n function injectExtensions (env, scope) {\n if (extInstancing) {\n env.instancing = scope.def(\n env.shared.extensions, '.angle_instanced_arrays')\n }\n }\n\n function emitProfile (env, scope, args, useScope, incrementCounter) {\n var shared = env.shared\n var STATS = env.stats\n var CURRENT_STATE = shared.current\n var TIMER = shared.timer\n var profileArg = args.profile\n\n function perfCounter () {\n if (typeof performance === 'undefined') {\n return 'Date.now()'\n } else {\n return 'performance.now()'\n }\n }\n\n var CPU_START, QUERY_COUNTER\n function emitProfileStart (block) {\n CPU_START = scope.def()\n block(CPU_START, '=', perfCounter(), ';')\n if (typeof incrementCounter === 'string') {\n block(STATS, '.count+=', incrementCounter, ';')\n } else {\n block(STATS, '.count++;')\n }\n if (timer) {\n if (useScope) {\n QUERY_COUNTER = scope.def()\n block(QUERY_COUNTER, '=', TIMER, '.getNumPendingQueries();')\n } else {\n block(TIMER, '.beginQuery(', STATS, ');')\n }\n }\n }\n\n function emitProfileEnd (block) {\n block(STATS, '.cpuTime+=', perfCounter(), '-', CPU_START, ';')\n if (timer) {\n if (useScope) {\n block(TIMER, '.pushScopeStats(',\n QUERY_COUNTER, ',',\n TIMER, '.getNumPendingQueries(),',\n STATS, ');')\n } else {\n block(TIMER, '.endQuery();')\n }\n }\n }\n\n function scopeProfile (value) {\n var prev = scope.def(CURRENT_STATE, '.profile')\n scope(CURRENT_STATE, '.profile=', value, ';')\n scope.exit(CURRENT_STATE, '.profile=', prev, ';')\n }\n\n var USE_PROFILE\n if (profileArg) {\n if (isStatic(profileArg)) {\n if (profileArg.enable) {\n emitProfileStart(scope)\n emitProfileEnd(scope.exit)\n scopeProfile('true')\n } else {\n scopeProfile('false')\n }\n return\n }\n USE_PROFILE = profileArg.append(env, scope)\n scopeProfile(USE_PROFILE)\n } else {\n USE_PROFILE = scope.def(CURRENT_STATE, '.profile')\n }\n\n var start = env.block()\n emitProfileStart(start)\n scope('if(', USE_PROFILE, '){', start, '}')\n var end = env.block()\n emitProfileEnd(end)\n scope.exit('if(', USE_PROFILE, '){', end, '}')\n }\n\n function emitAttributes (env, scope, args, attributes, filter) {\n var shared = env.shared\n\n function typeLength (x) {\n switch (x) {\n case GL_FLOAT_VEC2:\n case GL_INT_VEC2:\n case GL_BOOL_VEC2:\n return 2\n case GL_FLOAT_VEC3:\n case GL_INT_VEC3:\n case GL_BOOL_VEC3:\n return 3\n case GL_FLOAT_VEC4:\n case GL_INT_VEC4:\n case GL_BOOL_VEC4:\n return 4\n default:\n return 1\n }\n }\n\n function emitBindAttribute (ATTRIBUTE, size, record) {\n var GL = shared.gl\n\n var LOCATION = scope.def(ATTRIBUTE, '.location')\n var BINDING = scope.def(shared.attributes, '[', LOCATION, ']')\n\n var STATE = record.state\n var BUFFER = record.buffer\n var CONST_COMPONENTS = [\n record.x,\n record.y,\n record.z,\n record.w\n ]\n\n var COMMON_KEYS = [\n 'buffer',\n 'normalized',\n 'offset',\n 'stride'\n ]\n\n function emitBuffer () {\n scope(\n 'if(!', BINDING, '.buffer){',\n GL, '.enableVertexAttribArray(', LOCATION, ');}')\n\n var TYPE = record.type\n var SIZE\n if (!record.size) {\n SIZE = size\n } else {\n SIZE = scope.def(record.size, '||', size)\n }\n\n scope('if(',\n BINDING, '.type!==', TYPE, '||',\n BINDING, '.size!==', SIZE, '||',\n COMMON_KEYS.map(function (key) {\n return BINDING + '.' + key + '!==' + record[key]\n }).join('||'),\n '){',\n GL, '.bindBuffer(', GL_ARRAY_BUFFER$2, ',', BUFFER, '.buffer);',\n GL, '.vertexAttribPointer(', [\n LOCATION,\n SIZE,\n TYPE,\n record.normalized,\n record.stride,\n record.offset\n ], ');',\n BINDING, '.type=', TYPE, ';',\n BINDING, '.size=', SIZE, ';',\n COMMON_KEYS.map(function (key) {\n return BINDING + '.' + key + '=' + record[key] + ';'\n }).join(''),\n '}')\n\n if (extInstancing) {\n var DIVISOR = record.divisor\n scope(\n 'if(', BINDING, '.divisor!==', DIVISOR, '){',\n env.instancing, '.vertexAttribDivisorANGLE(', [LOCATION, DIVISOR], ');',\n BINDING, '.divisor=', DIVISOR, ';}')\n }\n }\n\n function emitConstant () {\n scope(\n 'if(', BINDING, '.buffer){',\n GL, '.disableVertexAttribArray(', LOCATION, ');',\n BINDING, '.buffer=null;',\n '}if(', CUTE_COMPONENTS.map(function (c, i) {\n return BINDING + '.' + c + '!==' + CONST_COMPONENTS[i]\n }).join('||'), '){',\n GL, '.vertexAttrib4f(', LOCATION, ',', CONST_COMPONENTS, ');',\n CUTE_COMPONENTS.map(function (c, i) {\n return BINDING + '.' + c + '=' + CONST_COMPONENTS[i] + ';'\n }).join(''),\n '}')\n }\n\n if (STATE === ATTRIB_STATE_POINTER) {\n emitBuffer()\n } else if (STATE === ATTRIB_STATE_CONSTANT) {\n emitConstant()\n } else {\n scope('if(', STATE, '===', ATTRIB_STATE_POINTER, '){')\n emitBuffer()\n scope('}else{')\n emitConstant()\n scope('}')\n }\n }
1\n\n attributes.forEach(function (attribute) {\n var name = attribute.name\n var arg = args.attributes[name]\n var record\n if (arg) {\n if (!filter(arg)) {\n return\n }\n record = arg.append(env, scope)\n } else {\n if (!filter(SCOPE_DECL)) {\n return\n }\n var scopeAttrib = env.scopeAttrib(name)\n check$1.optional(function () {\n env.assert(scope,\n scopeAttrib + '.state',\n 'missing attribute ' + name)\n })\n record = {}\n Object.keys(new AttributeRecord()).forEach(function (key) {\n record[key] = scope.def(scopeAttrib, '.', key)\n })\n }\n emitBindAttribute(\n env.link(attribute), typeLength(attribute.info.type), record)\n })\n }\n\n function emitUniforms (env, scope, args, uniforms, filter, isBatchInnerLoop) {\n var shared = env.shared\n var GL = shared.gl\n\n var definedArrUniforms = {}\n var infix\n for (var i = 0; i < uniforms.length; ++i) {\n var uniform = uniforms[i]\n var name = uniform.name\n var type = uniform.info.type\n var size = uniform.info.size\n var arg = args.uniforms[name]\n if (size > 1) {\n // either foo[n] or foos, avoid define both\n if (!arg) {\n continue\n }\n var arrUniformName = name.replace('[0]', '')\n if (definedArrUniforms[arrUniformName]) {\n continue\n }\n definedArrUniforms[arrUniformName] = 1\n }\n var UNIFORM = env.link(uniform)\n var LOCATION = UNIFORM + '.location'\n\n var VALUE\n if (arg) {\n if (!filter(arg)) {\n continue\n }\n if (isStatic(arg)) {\n var value = arg.value\n check$1.command(\n value !== null && typeof value !== 'undefined',\n 'missing uniform \"' + name + '\"', env.commandStr)\n if (type === GL_SAMPLER_2D || type === GL_SAMPLER_CUBE) {\n check$1.command(\n typeof value === 'function' &&\n ((type === GL_SAMPLER_2D &&\n (value._reglType === 'texture2d' ||\n value._reglType === 'framebuffer')) ||\n (type === GL_SAMPLER_CUBE &&\n (value._reglType === 'textureCube' ||\n value._reglType === 'framebufferCube'))),\n 'invalid texture for uniform ' + name, env.commandStr)\n var TEX_VALUE = env.link(value._texture || value.color[0]._texture)\n scope(GL, '.uniform1i(', LOCATION, ',', TEX_VALUE + '.bind());')\n scope.exit(TEX_VALUE, '.unbind();')\n } else if (\n type === GL_FLOAT_MAT2 ||\n type === GL_FLOAT_MAT3 ||\n type === GL_FLOAT_MAT4) {\n check$1.optional(function () {\n check$1.command(isArrayLike(value),\n 'invalid matrix for uniform ' + name, env.commandStr)\n check$1.command(\n (type === GL_FLOAT_MAT2 && value.length === 4) ||\n (type === GL_FLOAT_MAT3 && value.length === 9) ||\n (type === GL_FLOAT_MAT4 && value.length === 16),\n 'invalid length for matrix uniform ' + name, env.commandStr)\n })\n var MAT_VALUE = env.global.def('new Float32Array([' +\n Array.prototype.slice.call(value) + '])')\n var dim = 2\n if (type === GL_FLOAT_MAT3) {\n dim = 3\n } else if (type === GL_FLOAT_MAT4) {\n dim = 4\n }\n scope(\n GL, '.uniformMatrix', dim, 'fv(',\n LOCATION, ',false,', MAT_VALUE, ');')\n } else {\n switch (type) {\n case GL_FLOAT$8:\n if (size === 1) {\n check$1.commandType(value, 'number', 'uniform ' + name, env.commandStr)\n } else {\n check$1.command(\n isArrayLike(value) && (value.length === size),\n 'uniform ' + name, env.commandStr)\n }\n infix = '1f'\n break\n case GL_FLOAT_VEC2:\n check$1.command(\n isArrayLike(value) && (value.length && value.length % 2 === 0 && value.length <= size * 2),\n 'uniform ' + name, env.commandStr)\n infix = '2f'\n break\n case GL_FLOAT_VEC3:\n check$1.command(\n isArrayLike(value) && (value.length && value.length % 3 === 0 && value.length <= size * 3),\n 'uniform ' + name, env.commandStr)\n infix = '3f'\n break\n case GL_FLOAT_VEC4:\n check$1.command(\n isArrayLike(value) && (value.length && value.length % 4 === 0 && value.length <= size * 4),\n 'uniform ' + name, env.commandStr)\n infix = '4f'\n break\n case GL_BOOL:\n if (size === 1) {\n check$1.commandType(value, 'boolean', 'uniform ' + name, env.commandStr)\n } else {\n check$1.command(\n isArrayLike(value) && (value.length === size),\n 'uniform ' + name, env.commandStr)\n }\n infix = '1i'\n break\n case GL_INT$3:\n if (size === 1) {\n check$1.commandType(value, 'number', 'uniform ' + name, env.commandStr)\n } else {\n check$1.command(\n isArrayLike(value) && (value.length === size),\n 'uniform ' + name, env.commandStr)\n }\n infix = '1i'\n break\n case GL_BOOL_VEC2:\n check$1.command(\n isArrayLike(value) && (value.length && value.length % 2 === 0 && value.length <= size * 2),\n 'uniform ' + name, env.commandStr)\n infix = '2i'\n break\n case GL_INT_VEC2:\n check$1.command(\n isArrayLike(value) && (value.length && value.length % 2 === 0 && value.length <= size * 2),\n 'uniform ' + name, env.commandStr)\n infix = '2i'\n break\n case GL_BOOL_VEC3:\n check$1.command(\n isArrayLike(value) && (value.length && value.length % 3 === 0 && value.length <= size * 3),\n 'uniform ' + name, env.commandStr)\n infix = '3i'\n break\n case GL_INT_VEC3:\n check$1.command(\n isArrayLike(value) && (value.length && value.length % 3 === 0 && value.length <= size * 3),\n 'uniform ' + name, env.commandStr)\n infix = '3i'\n break\n case GL_BOOL_VEC4:\n check$1.command(\n isArrayLike(value) && (value.length && value.length % 4 === 0 && value.length <= size * 4),\n 'uniform ' + name, env.commandStr)\n infix = '4i'\n break\n case GL_INT_VEC4:\n check$1.command(\n isArrayLike(value) && (value.length && value.length % 4 === 0 && value.length <= size * 4),\n 'uniform ' + name, env.commandStr)\n infix = '4i'\n break\n }\n if (size > 1) {\n infix += 'v'\n value = env.global.def('[' +\n Array.prototype.slice.call(value) + ']')\n } else {\n value = isArrayLike(value) ? Array.prototype.slice.call(value) : value\n }\n scope(GL, '.uniform', infix, '(', LOCATION, ',',\n value,\n ');')\n }\n continue\n } else {\n VALUE = arg.append(env, scope)\n }\n } else {\n if (!filter(SCOPE_DECL)) {\n continue\n }\n VALUE = scope.def(shared.uniforms, '[', stringStore.id(name), ']')\n }\n\n if (type === GL_SAMPLER_2D) {\n check$1(!Array.isArray(VALUE), 'must specify a scalar prop for textures')\n scope(\n 'if(', VALUE, '&&', VALUE, '._reglType===\"framebuffer\"){',\n VALUE, '=', VALUE, '.color[0];',\n '}')\n } else if (type === GL_SAMPLER_CUBE) {\n check$1(!Array.isArray(VALUE), 'must specify a scalar prop for cube maps')\n scope(\n 'if(', VALUE, '&&', VALUE, '._reglType===\"framebufferCube\"){',\n VALUE, '=', VALUE, '.color[0];',\n '}')\n }\n\n // perform type validation\n check$1.optional(function () {\n function emitCheck (pred, message) {\n env.assert(scope, pred,\n 'bad data or missing for uniform \"' + name + '\". ' + message)\n }\n\n function checkType (type, size) {\n if (size === 1) {\n check$1(!Array.isArray(VALUE), 'must not specify an array type for uniform')\n }\n emitCheck(\n 'Array.isArray(' + VALUE + ') && typeof ' + VALUE + '[0]===\" ' + type + '\"' +\n ' || typeof ' + VALUE + '===\"' + type + '\"',\n 'invalid type, expected ' + type)\n }\n\n function checkVector (n, type, size) {\n if (Array.isArray(VALUE)) {\n check$1(VALUE.length && VALUE.length % n === 0 && VALUE.length <= n * size, 'must have length of ' + (size === 1 ? '' : 'n * ') + n)\n } else {\n emitCheck(\n shared.isArrayLike + '(' + VALUE + ')&&' + VALUE + '.length && ' + VALUE + '.length % ' + n + ' === 0' +\n ' && ' + VALUE + '.length<=' + n * size,\n 'invalid vector, should have length of ' + (size === 1 ? '' : 'n * ') + n, env.commandStr)\n }\n }\n\n function checkTexture (target) {\n check$1(!Array.isArray(VALUE), 'must not specify a value type')\n emitCheck(\n 'typeof ' + VALUE + '===\"function\"&&' +\n VALUE + '._reglType===\"texture' +\n (target === GL_TEXTURE_2D$3 ? '2d' : 'Cube') + '\"',\n 'invalid texture type', env.commandStr)\n }\n\n switch (type) {\n case GL_INT$3:\n checkType('number', size)\n break\n case GL_INT_VEC2:\n checkVector(2, 'number', size)\n break\n case GL_INT_VEC3:\n checkVector(3, 'number', size)\n break\n case GL_INT_VEC4:\n checkVector(4, 'number', size)\n break\n case GL_FLOAT$8:\n checkType('number', size)\n break\n case GL_FLOAT_VEC2:\n checkVector(2, 'number', size)\n break\n case GL_FLOAT_VEC3:\n checkVector(3, 'number', size)\n break\n case GL_FLOAT_VEC4:\n checkVector(4, 'number', size)\n break\n case GL_BOOL:\n checkType('boolean', size)\n break\n case GL_BOOL_VEC2:\n checkVector(2, 'boolean', size)\n break\n case GL_BOOL_VEC3:\n checkVector(3, 'boolean', size)\n break\n case GL_BOOL_VEC4:\n checkVector(4, 'boolean', size)\n break\n case GL_FLOAT_MAT2:\n checkVector(4, 'number', size)\n break\n case GL_FLOAT_MAT3:\n checkVector(9, 'number', size)\n break\n case GL_FLOAT_MAT4:\n checkVector(16, 'number', size)\n break\n case GL_SAMPLER_2D:\n checkTexture(GL_TEXTURE_2D$3)\n break\n case GL_SAMPLER_CUBE:\n checkTexture(GL_TEXTURE_CUBE_MAP$2)\n break\n }\n })\n\n var unroll = 1\n switch (type) {\n case GL_SAMPLER_2D:\n case GL_SAMPLER_CUBE:\n var TEX = scope.def(VALUE, '._texture')\n scope(GL, '.uniform1i(', LOCATION, ',', TEX, '.bind());')\n scope.exit(TEX, '.unbind();')\n continue\n\n case GL_INT$3:\n case GL_BOOL:\n infix = '1i'\n break\n\n case GL_INT_VEC2:\n case GL_BOOL_VEC2:\n infix = '2i'\n unroll = 2\n break\n\n case GL_INT_VEC3:\n case GL_BOOL_VEC3:\n infix = '3i'\n unroll = 3\n break\n\n case GL_INT_VEC4:\n case GL_BOOL_VEC4:\n infix = '4i'\n unroll = 4\n break\n\n case GL_FLOAT$8:\n infix = '1f'\n break\n\n case GL_FLOAT_VEC2:\n infix = '2f'\n unroll = 2\n break\n\n case GL_FLOAT_VEC3:\n infix = '3f'\n unroll = 3\n break\n\n case GL_FLOAT_VEC4:\n infix = '4f'\n unroll = 4\n break\n\n case GL_FLOAT_MAT2:\n infix = 'Matrix2fv'\n break\n\n case GL_FLOAT_MAT3:\n infix = 'Matrix3fv'\n break\n\n case GL_FLOAT_MAT4:\n infix = 'Matrix4fv'\n break\n }\n\n if (infix.indexOf('Matrix') === -1 && size > 1) {\n infix += 'v'\n unroll = 1\n }\n\n if (infix.charAt(0) === 'M') {\n scope(GL, '.uniform', infix, '(', LOCATION, ',')\n var matSize = Math.pow(type - GL_FLOAT_MAT2 + 2, 2)\n var STORAGE = env.global.def('new Float32Array(', matSize, ')')\n if (Array.isArray(VALUE)) {\n scope(\n 'false,(',\n loop(matSize, function (i) {\n return STORAGE + '[' + i + ']=' + VALUE[i]\n }), ',', STORAGE, ')')\n } else {\n scope(\n 'false,(Array.isArray(', VALUE, ')||', VALUE, ' instanceof Float32Array)?', VALUE, ':(',\n loop(matSize, function (i) {\n return STORAGE + '[' + i + ']=' + VALUE + '[' + i + ']'\n }), ',', STORAGE, ')')\n }\n scope(');')\n } else if (unroll > 1) {\n var prev = []\n var cur = []\n for (var j = 0; j < unroll; ++j) {\n if (Array.isArray(VALUE)) {\n cur.push(VALUE[j])\n } else {\n cur.push(scope.def(VALUE + '[' + j + ']'))\n }\n if (isBatchInnerLoop) {\n prev.push(scope.def())\n }\n }\n if (isBatchInnerLoop) {\n scope('if(!', env.batchId, '||', prev.map(function (p, i) {\n return p + '!==' + cur[i]\n }).join('||'), '){', prev.map(function (p, i) {\n return p + '=' + cur[i] + ';'\n }).join(''))\n }\n scope(GL, '.uniform', infix, '(', LOCATION, ',', cur.join(','), ');')\n if (isBatchInnerLoop) {\n scope('}')\n }\n } else {\n check$1(!Array.isArray(VALUE), 'uniform value must not be an array')\n if (isBatchInnerLoop) {\n var prevS = scope.def()\n scope('if(!', env.batchId, '||', prevS, '!==', VALUE, '){',\n prevS, '=', VALUE, ';')\n }\n scope(GL, '.uniform', infix, '(', LOCATION, ',', VALUE, ');')\n if (isBatchInnerLoop) {\n scope('}')\n }\n }\n }\n }\n\n function emitDraw (env, outer, inner, args) {\n var shared = env.shared\n var GL = shared.gl\n var DRAW_STATE = shared.draw\n\n var drawOptions = args.draw\n\n function emitElements () {\n var defn = drawOptions.elements\n var ELEMENTS\n var scope = outer\n if (defn) {\n if ((defn.contextDep && args.contextDynamic) || defn.propDep) {\n scope = inner\n }\n ELEMENTS = defn.append(env, scope)\n if (drawOptions.elementsActive) {\n scope(\n 'if(' + ELEMENTS + ')' +\n GL + '.bindBuffer(' + GL_ELEMENT_ARRAY_BUFFER$2 + ',' + ELEMENTS + '.buffer.buffer);')\n }\n } else {\n ELEMENTS = scope.def()\n scope(\n ELEMENTS, '=', DRAW_STATE, '.', S_ELEMENTS, ';',\n 'if(', ELEMENTS, '){',\n GL, '.bindBuffer
1(', GL_ELEMENT_ARRAY_BUFFER$2, ',', ELEMENTS, '.buffer.buffer);}',\n 'else if(', shared.vao, '.currentVAO){',\n ELEMENTS, '=', env.shared.elements + '.getElements(' + shared.vao, '.currentVAO.elements);',\n (!extVertexArrays ? 'if(' + ELEMENTS + ')' + GL + '.bindBuffer(' + GL_ELEMENT_ARRAY_BUFFER$2 + ',' + ELEMENTS + '.buffer.buffer);' : ''),\n '}')\n }\n return ELEMENTS\n }\n\n function emitCount () {\n var defn = drawOptions.count\n var COUNT\n var scope = outer\n if (defn) {\n if ((defn.contextDep && args.contextDynamic) || defn.propDep) {\n scope = inner\n }\n COUNT = defn.append(env, scope)\n check$1.optional(function () {\n if (defn.MISSING) {\n env.assert(outer, 'false', 'missing vertex count')\n }\n if (defn.DYNAMIC) {\n env.assert(scope, COUNT + '>=0', 'missing vertex count')\n }\n })\n } else {\n COUNT = scope.def(DRAW_STATE, '.', S_COUNT)\n check$1.optional(function () {\n env.assert(scope, COUNT + '>=0', 'missing vertex count')\n })\n }\n return COUNT\n }\n\n var ELEMENTS = emitElements()\n function emitValue (name) {\n var defn = drawOptions[name]\n if (defn) {\n if ((defn.contextDep && args.contextDynamic) || defn.propDep) {\n return defn.append(env, inner)\n } else {\n return defn.append(env, outer)\n }\n } else {\n return outer.def(DRAW_STATE, '.', name)\n }\n }\n\n var PRIMITIVE = emitValue(S_PRIMITIVE)\n var OFFSET = emitValue(S_OFFSET)\n\n var COUNT = emitCount()\n if (typeof COUNT === 'number') {\n if (COUNT === 0) {\n return\n }\n } else {\n inner('if(', COUNT, '){')\n inner.exit('}')\n }\n\n var INSTANCES, EXT_INSTANCING\n if (extInstancing) {\n INSTANCES = emitValue(S_INSTANCES)\n EXT_INSTANCING = env.instancing\n }\n\n var ELEMENT_TYPE = ELEMENTS + '.type'\n\n var elementsStatic = drawOptions.elements && isStatic(drawOptions.elements) && !drawOptions.vaoActive\n\n function emitInstancing () {\n function drawElements () {\n inner(EXT_INSTANCING, '.drawElementsInstancedANGLE(', [\n PRIMITIVE,\n COUNT,\n ELEMENT_TYPE,\n OFFSET + '<<((' + ELEMENT_TYPE + '-' + GL_UNSIGNED_BYTE$8 + ')>>1)',\n INSTANCES\n ], ');')\n }\n\n function drawArrays () {\n inner(EXT_INSTANCING, '.drawArraysInstancedANGLE(',\n [PRIMITIVE, OFFSET, COUNT, INSTANCES], ');')\n }\n\n if (ELEMENTS && ELEMENTS !== 'null') {\n if (!elementsStatic) {\n inner('if(', ELEMENTS, '){')\n drawElements()\n inner('}else{')\n drawArrays()\n inner('}')\n } else {\n drawElements()\n }\n } else {\n drawArrays()\n }\n }\n\n function emitRegular () {\n function drawElements () {\n inner(GL + '.drawElements(' + [\n PRIMITIVE,\n COUNT,\n ELEMENT_TYPE,\n OFFSET + '<<((' + ELEMENT_TYPE + '-' + GL_UNSIGNED_BYTE$8 + ')>>1)'\n ] + ');')\n }\n\n function drawArrays () {\n inner(GL + '.drawArrays(' + [PRIMITIVE, OFFSET, COUNT] + ');')\n }\n\n if (ELEMENTS && ELEMENTS !== 'null') {\n if (!elementsStatic) {\n inner('if(', ELEMENTS, '){')\n drawElements()\n inner('}else{')\n drawArrays()\n inner('}')\n } else {\n drawElements()\n }\n } else {\n drawArrays()\n }\n }\n\n if (extInstancing && (typeof INSTANCES !== 'number' || INSTANCES >= 0)) {\n if (typeof INSTANCES === 'string') {\n inner('if(', INSTANCES, '>0){')\n emitInstancing()\n inner('}else if(', INSTANCES, '<0){')\n emitRegular()\n inner('}')\n } else {\n emitInstancing()\n }\n } else {\n emitRegular()\n }\n }\n\n function createBody (emitBody, parentEnv, args, program, count) {\n var env = createREGLEnvironment()\n var scope = env.proc('body', count)\n check$1.optional(function () {\n env.commandStr = parentEnv.commandStr\n env.command = env.link(parentEnv.commandStr)\n })\n if (extInstancing) {\n env.instancing = scope.def(\n env.shared.extensions, '.angle_instanced_arrays')\n }\n emitBody(env, scope, args, program)\n return env.compile().body\n }\n\n // ===================================================\n // ===================================================\n // DRAW PROC\n // ===================================================\n // ===================================================\n function emitDrawBody (env, draw, args, program) {\n injectExtensions(env, draw)\n if (args.useVAO) {\n if (args.drawVAO) {\n draw(env.shared.vao, '.setVAO(', args.drawVAO.append(env, draw), ');')\n } else {\n draw(env.shared.vao, '.setVAO(', env.shared.vao, '.targetVAO);')\n }\n } else {\n draw(env.shared.vao, '.setVAO(null);')\n emitAttributes(env, draw, args, program.attributes, function () {\n return true\n })\n }\n emitUniforms(env, draw, args, program.uniforms, function () {\n return true\n }, false)\n emitDraw(env, draw, draw, args)\n }\n\n function emitDrawProc (env, args) {\n var draw = env.proc('draw', 1)\n\n injectExtensions(env, draw)\n\n emitContext(env, draw, args.context)\n emitPollFramebuffer(env, draw, args.framebuffer)\n\n emitPollState(env, draw, args)\n emitSetOptions(env, draw, args.state)\n\n emitProfile(env, draw, args, false, true)\n\n var program = args.shader.progVar.append(env, draw)\n draw(env.shared.gl, '.useProgram(', program, '.program);')\n\n if (args.shader.program) {\n emitDrawBody(env, draw, args, args.shader.program)\n } else {\n draw(env.shared.vao, '.setVAO(null);')\n var drawCache = env.global.def('{}')\n var PROG_ID = draw.def(program, '.id')\n var CACHED_PROC = draw.def(drawCache, '[', PROG_ID, ']')\n draw(\n env.cond(CACHED_PROC)\n .then(CACHED_PROC, '.call(this,a0);')\n .else(\n CACHED_PROC, '=', drawCache, '[', PROG_ID, ']=',\n env.link(function (program) {\n return createBody(emitDrawBody, env, args, program, 1)\n }), '(', program, ');',\n CACHED_PROC, '.call(this,a0);'))\n }\n\n if (Object.keys(args.state).length > 0) {\n draw(env.shared.current, '.dirty=true;')\n }\n if (env.shared.vao) {\n draw(env.shared.vao, '.setVAO(null);')\n }\n }\n\n // ===================================================\n // ===================================================\n // BATCH PROC\n // ===================================================\n // ===================================================\n\n function emitBatchDynamicShaderBody (env, scope, args, program) {\n env.batchId = 'a1'\n\n injectExtensions(env, scope)\n\n function all () {\n return true\n }\n\n emitAttributes(env, scope, args, program.attributes, all)\n emitUniforms(env, scope, args, program.uniforms, all, false)\n emitDraw(env, scope, scope, args)\n }\n\n function emitBatchBody (env, scope, args, program) {\n injectExtensions(env, scope)\n\n var contextDynamic = args.contextDep\n\n var BATCH_ID = scope.def()\n var PROP_LIST = 'a0'\n var NUM_PROPS = 'a1'\n var PROPS = scope.def()\n env.shared.props = PROPS\n env.batchId = BATCH_ID\n\n var outer = env.scope()\n var inner = env.scope()\n\n scope(\n outer.entry,\n 'for(', BATCH_ID, '=0;', BATCH_ID, '<', NUM_PROPS, ';++', BATCH_ID, '){',\n PROPS, '=', PROP_LIST, '[', BATCH_ID, '];',\n inner,\n '}',\n outer.exit)\n\n function isInnerDefn (defn) {\n return ((defn.contextDep && contextDynamic) || defn.propDep)\n }\n\n function isOuterDefn (defn) {\n return !isInnerDefn(defn)\n }\n\n if (args.needsContext) {\n emitContext(env, inner, args.context)\n }\n if (args.needsFramebuffer) {\n emitPollFramebuffer(env, inner, args.framebuffer)\n }\n emitSetOptions(env, inner, args.state, isInnerDefn)\n\n if (args.profile && isInnerDefn(args.profile)) {\
1n emitProfile(env, inner, args, false, true)\n }\n\n if (!program) {\n var progCache = env.global.def('{}')\n var PROGRAM = args.shader.progVar.append(env, inner)\n var PROG_ID = inner.def(PROGRAM, '.id')\n var CACHED_PROC = inner.def(progCache, '[', PROG_ID, ']')\n inner(\n env.shared.gl, '.useProgram(', PROGRAM, '.program);',\n 'if(!', CACHED_PROC, '){',\n CACHED_PROC, '=', progCache, '[', PROG_ID, ']=',\n env.link(function (program) {\n return createBody(\n emitBatchDynamicShaderBody, env, args, program, 2)\n }), '(', PROGRAM, ');}',\n CACHED_PROC, '.call(this,a0[', BATCH_ID, '],', BATCH_ID, ');')\n } else {\n if (args.useVAO) {\n if (args.drawVAO) {\n if (isInnerDefn(args.drawVAO)) {\n // vao is a prop\n inner(env.shared.vao, '.setVAO(', args.drawVAO.append(env, inner), ');')\n } else {\n // vao is invariant\n outer(env.shared.vao, '.setVAO(', args.drawVAO.append(env, outer), ');')\n }\n } else {\n // scoped vao binding\n outer(env.shared.vao, '.setVAO(', env.shared.vao, '.targetVAO);')\n }\n } else {\n outer(env.shared.vao, '.setVAO(null);')\n emitAttributes(env, outer, args, program.attributes, isOuterDefn)\n emitAttributes(env, inner, args, program.attributes, isInnerDefn)\n }\n emitUniforms(env, outer, args, program.uniforms, isOuterDefn, false)\n emitUniforms(env, inner, args, program.uniforms, isInnerDefn, true)\n emitDraw(env, outer, inner, args)\n }\n }\n\n function emitBatchProc (env, args) {\n var batch = env.proc('batch', 2)\n env.batchId = '0'\n\n injectExtensions(env, batch)\n\n // Check if any context variables depend on props\n var contextDynamic = false\n var needsContext = true\n Object.keys(args.context).forEach(function (name) {\n contextDynamic = contextDynamic || args.context[name].propDep\n })\n if (!contextDynamic) {\n emitContext(env, batch, args.context)\n needsContext = false\n }\n\n // framebuffer state affects framebufferWidth/height context vars\n var framebuffer = args.framebuffer\n var needsFramebuffer = false\n if (framebuffer) {\n if (framebuffer.propDep) {\n contextDynamic = needsFramebuffer = true\n } else if (framebuffer.contextDep && contextDynamic) {\n needsFramebuffer = true\n }\n if (!needsFramebuffer) {\n emitPollFramebuffer(env, batch, framebuffer)\n }\n } else {\n emitPollFramebuffer(env, batch, null)\n }\n\n // viewport is weird because it can affect context vars\n if (args.state.viewport && args.state.viewport.propDep) {\n contextDynamic = true\n }\n\n function isInnerDefn (defn) {\n return (defn.contextDep && contextDynamic) || defn.propDep\n }\n\n // set webgl options\n emitPollState(env, batch, args)\n emitSetOptions(env, batch, args.state, function (defn) {\n return !isInnerDefn(defn)\n })\n\n if (!args.profile || !isInnerDefn(args.profile)) {\n emitProfile(env, batch, args, false, 'a1')\n }\n\n // Save these values to args so that the batch body routine can use them\n args.contextDep = contextDynamic\n args.needsContext = needsContext\n args.needsFramebuffer = needsFramebuffer\n\n // determine if shader is dynamic\n var progDefn = args.shader.progVar\n if ((progDefn.contextDep && contextDynamic) || progDefn.propDep) {\n emitBatchBody(\n env,\n batch,\n args,\n null)\n } else {\n var PROGRAM = progDefn.append(env, batch)\n batch(env.shared.gl, '.useProgram(', PROGRAM, '.program);')\n if (args.shader.program) {\n emitBatchBody(\n env,\n batch,\n args,\n args.shader.program)\n } else {\n batch(env.shared.vao, '.setVAO(null);')\n var batchCache = env.global.def('{}')\n var PROG_ID = batch.def(PROGRAM, '.id')\n var CACHED_PROC = batch.def(batchCache, '[', PROG_ID, ']')\n batch(\n env.cond(CACHED_PROC)\n .then(CACHED_PROC, '.call(this,a0,a1);')\n .else(\n CACHED_PROC, '=', batchCache, '[', PROG_ID, ']=',\n env.link(function (program) {\n return createBody(emitBatchBody, env, args, program, 2)\n }), '(', PROGRAM, ');',\n CACHED_PROC, '.call(this,a0,a1);'))\n }\n }\n\n if (Object.keys(args.state).length > 0) {\n batch(env.shared.current, '.dirty=true;')\n }\n\n if (env.shared.vao) {\n batch(env.shared.vao, '.setVAO(null);')\n }\n }\n\n // ===================================================\n // ===================================================\n // SCOPE COMMAND\n // ===================================================\n // ===================================================\n function emitScopeProc (env, args) {\n var scope = env.proc('scope', 3)\n env.batchId = 'a2'\n\n var shared = env.shared\n var CURRENT_STATE = shared.current\n\n emitContext(env, scope, args.context)\n\n if (args.framebuffer) {\n args.framebuffer.append(env, scope)\n }
1\n\n sortState(Object.keys(args.state)).forEach(function (name) {\n var defn = args.state[name]\n var value = defn.append(env, scope)\n if (isArrayLike(value)) {\n value.forEach(function (v, i) {\n scope.set(env.next[name], '[' + i + ']', v)\n })\n } else {\n scope.set(shared.next, '.' + name, value)\n }\n })\n\n emitProfile(env, scope, args, true, true)\n\n ;[S_ELEMENTS, S_OFFSET, S_COUNT, S_INSTANCES, S_PRIMITIVE].forEach(\n function (opt) {\n var variable = args.draw[opt]\n if (!variable) {\n return\n }\n scope.set(shared.draw, '.' + opt, '' + variable.append(env, scope))\n })\n\n Object.keys(args.uniforms).forEach(function (opt) {\n var value = args.uniforms[opt].append(env, scope)\n if (Array.isArray(value)) {\n value = '[' + value.join() + ']'\n }\n scope.set(\n shared.uniforms,\n '[' + stringStore.id(opt) + ']',\n value)\n })\n\n Object.keys(args.attributes).forEach(function (name) {\n var record = args.attributes[name].append(env, scope)\n var scopeAttrib = env.scopeAttrib(name)\n Object.keys(new AttributeRecord()).forEach(function (prop) {\n scope.set(scopeAttrib, '.' + prop, record[prop])\n })\n })\n\n if (args.scopeVAO) {\n scope.set(shared.vao, '.targetVAO', args.scopeVAO.append(env, scope))\n }\n\n function saveShader (name) {\n var shader = args.shader[name]\n if (shader) {\n scope.set(shared.shader, '.' + name, shader.append(env, scope))\n }\n }\n saveShader(S_VERT)\n saveShader(S_FRAG)\n\n if (Object.keys(args.state).length > 0) {\n scope(CURRENT_STATE, '.dirty=true;')\n scope.exit(CURRENT_STATE, '.dirty=true;')\n }\n\n scope('a1(', env.shared.context, ',a0,', env.batchId, ');')\n }\n\n function isDynamicObject (object) {\n if (typeof object !== 'object' || isArrayLike(object)) {\n return\n }\n var props = Object.keys(object)\n for (var i = 0; i < props.length; ++i) {\n if (dynamic.isDynamic(object[props[i]])) {\n return true\n }\n }\n return false\n }\n\n function splatObject (env, options, name) {\n var object = options.static[name]\n if (!object || !isDynamicObject(object)) {\n return\n }\n\n var globals = env.global\n var keys = Object.keys(object)\n var thisDep = false\n var contextDep = false\n var propDep = false\n var objectRef = env.global.def('{}')\n keys.forEach(function (key) {\n var value = object[key]\n if (dynamic.isDynamic(value)) {\n if (typeof value === 'function') {\n value = object[key] = dynamic.unbox(value)\n }\n var deps = createDynamicDecl(value, null)\n thisDep = thisDep || deps.thisDep\n propDep = propDep || deps.propDep\n contextDep = contextDep || deps.contextDep\n } else {\n globals(objectRef, '.', key, '=')\n switch (typeof value) {\n case 'number':\n globals(value)\n break\n case 'string':\n globals('\"', value, '\"')\n break\n case 'object':\n if (Array.isArray(value)) {\n globals('[', value.join(), ']')\n }\n break\n default:\n globals(env.link(value))\n break\n }\n globals(';')\n }\n })\n\n function appendBlock (env, block) {\n keys.forEach(function (key) {\n var value = object[key]\n if (!dynamic.isDynamic(value)) {\n return\n }\n var ref = env.invoke(block, value)\n block(objectRef, '.', key, '=', ref, ';')\n })\n }\n\n options.dynamic[name] = new dynamic.DynamicVariable(DYN_THUNK, {\n thisDep: thisDep,\n contextDep: contextDep,\n propDep: propDep,\n ref: objectRef,\n append: appendBlock\n })\n delete options.static[name]\n }\n\n // ===========================================================================\n // ===========================================================================\n // MAIN DRAW COMMAND\n // ===========================================================================\n // ===========================================================================\n function compileCommand (options, attributes, uniforms, context, stats) {\n var env = createREGLEnvironment()\n\n // link stats, so that we can easily access it in the program.\n env.stats = env.link(stats)\n\n // splat options and attributes to allow for dynamic nested properties\n Ob
1ject.keys(attributes.static).forEach(function (key) {\n splatObject(env, attributes, key)\n })\n NESTED_OPTIONS.forEach(function (name) {\n splatObject(env, options, name)\n })\n\n var args = parseArguments(options, attributes, uniforms, context, env)\n\n emitDrawProc(env, args)\n emitScopeProc(env, args)\n emitBatchProc(env, args)\n\n return extend(env.compile(), {\n destroy: function () {\n args.shader.program.destroy()\n }\n })\n }\n\n // ===========================================================================\n // ===========================================================================\n // POLL / REFRESH\n // ===========================================================================\n // ===========================================================================\n return {\n next: nextState,\n current: currentState,\n procs: (function () {\n var env = createREGLEnvironment()\n var poll = env.proc('poll')\n var refresh = env.proc('refresh')\n var common = env.block()\n poll(common)\n refresh(common)\n\n var shared = env.shared\n var GL = shared.gl\n var NEXT_STATE = shared.next\n var CURRENT_STATE = shared.current\n\n common(CURRENT_STATE, '.dirty=false;')\n\n emitPollFramebuffer(env, poll)\n emitPollFramebuffer(env, refresh, null, true)\n\n // Refresh updates all attribute state changes\n var INSTANCING\n if (extInstancing) {\n INSTANCING = env.link(extInstancing)\n }\n\n // update vertex array bindings\n if (extensions.oes_vertex_array_object) {\n refresh(env.link(extensions.oes_vertex_array_object), '.bindVertexArrayOES(null);')\n }\n for (var i = 0; i < limits.maxAttributes; ++i) {\n var BINDING = refresh.def(shared.attributes, '[', i, ']')\n var ifte = env.cond(BINDING, '.buffer')\n ifte.then(\n GL, '.enableVertexAttribArray(', i, ');',\n GL, '.bindBuffer(',\n GL_ARRAY_BUFFER$2, ',',\n BINDING, '.buffer.buffer);',\n GL, '.vertexAttribPointer(',\n i, ',',\n BINDING, '.size,',\n BINDING, '.type,',\n BINDING, '.normalized,',\n BINDING, '.stride,',\n BINDING, '.offset);'\n ).else(\n GL, '.disableVertexAttribArray(', i, ');',\n GL, '.vertexAttrib4f(',\n i, ',',\n BINDING, '.x,',\n BINDING, '.y,',\n BINDING, '.z,',\n BINDING, '.w);',\n BINDING, '.buffer=null;')\n refresh(ifte)\n if (extInstancing) {\n refresh(\n INSTANCING, '.vertexAttribDivisorANGLE(',\n i, ',',\n BINDING, '.divisor);')\n }\n }\n refresh(\n env.shared.vao, '.currentVAO=null;',\n env.shared.vao, '.setVAO(', env.shared.vao, '.targetVAO);')\n\n Object.keys(GL_FLAGS).forEach(function (flag) {\n var cap = GL_FLAGS[flag]\n var NEXT = common.def(NEXT_STATE, '.', flag)\n var block = env.block()\n block('if(', NEXT, '){',\n GL, '.enable(', cap, ')}else{',\n GL, '.disable(', cap, ')}',\n CURRENT_STATE, '.', flag, '=', NEXT, ';')\n refresh(block)\n poll(\n 'if(', NEXT, '!==', CURRENT_STATE, '.', flag, '){',\n block,\n '}')\n })\n\n Object.keys(GL_VARIABLES).forEach(function (name) {\n var func = GL_VARIABLES[name]\n var init = currentState[name]\n var NEXT, CURRENT\n var block = env.block()\n block(GL, '.', func, '(')\n if (isArrayLike(init)) {\n var n = init.length\n NEXT = env.global.def(NEXT_STATE, '.', name)\n CURRENT = env.global.def(CURRENT_STATE, '.', name)\n block(\n loop(n, function (i) {\n return NEXT + '[' + i + ']'\n }), ');',\n loop(n, function (i) {\n return CURRENT + '[' + i + ']=' + NEXT + '[' + i + '];'\n }).join(''))\n poll(\n 'if(', loop(n, function (i) {\n return NEXT + '[' + i + ']!==' + CURRENT + '[' + i + ']'\n }).join('||'), '){',\n block,\n '}')\n } else {\n NEXT = common.def(NEXT_STATE, '.', name)\n CURRENT = common.def(CURRENT_STATE, '.', name)\n block(\n NEXT, ');',\n CURRENT_STATE, '.', name, '=', NEXT, ';')\n poll(\n 'if(', NEXT, '!==', CURRENT, '){',\n block,\n '}')\n }\n refresh(block)\n })\n\n return env.compile()\n })(),\n compile: compileCommand\n }\n}\n\nfunction stats () {\n return {\n vaoCount: 0,\n bufferCount: 0,\n elementsCount: 0,\n framebufferCount: 0,\n shaderCount: 0,\n textureCount: 0,\n cubeC
1ount: 0,\n renderbufferCount: 0,\n maxTextureUnits: 0\n }\n}\n\nvar GL_QUERY_RESULT_EXT = 0x8866\nvar GL_QUERY_RESULT_AVAILABLE_EXT = 0x8867\nvar GL_TIME_ELAPSED_EXT = 0x88BF\n\nvar createTimer = function (gl, extensions) {\n if (!extensions.ext_disjoint_timer_query) {\n return null\n }\n\n // QUERY POOL BEGIN\n var queryPool = []\n function allocQuery () {\n return queryPool.pop() || extensions.ext_disjoint_timer_query.createQueryEXT()\n }\n function freeQuery (query) {\n queryPool.push(query)\n }\n // QUERY POOL END\n\n var pendingQueries = []\n function beginQuery (stats) {\n var query = allocQuery()\n extensions.ext_disjoint_timer_query.beginQueryEXT(GL_TIME_ELAPSED_EXT, query)\n pendingQueries.push(query)\n pushScopeStats(pendingQueries.length - 1, pendingQueries.length, stats)\n }\n\n function endQuery () {\n extensions.ext_disjoint_timer_query.endQueryEXT(GL_TIME_ELAPSED_EXT)\n }\n\n //\n // Pending stats pool.\n //\n function PendingStats () {\n this.startQueryIndex = -1\n this.endQueryIndex = -1\n this.sum = 0\n this.stats = null\n }\n var pendingStatsPool = []\n function allocPendingStats () {\n return pendingStatsPool.pop() || new PendingStats()\n }\n function freePendingStats (pendingStats) {\n pendingStatsPool.push(pendingStats)\n }\n // Pending stats pool end\n\n var pendingStats = []\n function pushScopeStats (start, end, stats) {\n var ps = allocPendingStats()\n ps.startQueryIndex = start\n ps.endQueryIndex = end\n ps.sum = 0\n ps.stats = stats\n pendingStats.push(ps)\n }\n\n // we should call this at the beginning of the frame,\n // in order to update gpuTime\n var timeSum = []\n var queryPtr = []\n function update () {\n var ptr, i\n\n var n = pendingQueries.length\n if (n === 0) {\n return\n }\n\n // Reserve space\n queryPtr.length = Math.max(queryPtr.length, n + 1)\n timeSum.length = Math.max(timeSum.length, n + 1)\n timeSum[0] = 0\n queryPtr[0] = 0\n\n // Update all pending timer queries\n var queryTime = 0\n ptr = 0\n for (i = 0; i < pendingQueries.length; ++i) {\n var query = pendingQueries[i]\n if (extensions.ext_disjoint_timer_query.getQueryObjectEXT(query, GL_QUERY_RESULT_AVAILABLE_EXT)) {\n queryTime += extensions.ext_disjoint_timer_query.getQueryObjectEXT(query, GL_QUERY_RESULT_EXT)\n freeQuery(query)\n } else {\n pendingQueries[ptr++] = query\n }\n timeSum[i + 1] = queryTime\n queryPtr[i + 1] = ptr\n }\n pendingQueries.length = ptr\n\n // Update all pending stat queries\n ptr = 0\n for (i = 0; i < pendingStats.length; ++i) {\n var stats = pendingStats[i]\n var start = stats.startQueryIndex\n var end = stats.endQueryIndex\n stats.sum += timeSum[end] - timeSum[start]\n var startPtr = queryPtr[start]\n var endPtr = queryPtr[end]\n if (endPtr === startPtr) {\n stats.stats.gpuTime += stats.sum / 1e6\n freePendingStats(stats)\n } else {\n stats.startQueryIndex = startPtr\n stats.endQueryIndex = endPtr\n pendingStats[ptr++] = stats\n }\n }\n pendingStats.length = ptr\n }\n\n return {\n beginQuery: beginQuery,\n endQuery: endQuery,\n pushScopeStats: pushScopeStats,\n update: update,\n getNumPendingQueries: function () {\n return pendingQueries.length\n },\n clear: function () {\n queryPool.push.apply(queryPool, pendingQueries)\n for (var i = 0; i < queryPool.length; i++) {\n extensions.ext_disjoint_timer_query.deleteQueryEXT(queryPool[i])\n }\n pendingQueries.length = 0\n queryPool.length = 0\n },\n restore: function () {\n pendingQueries.length = 0\n queryPool.length = 0\n }\n }\n}\n\nvar GL_COLOR_BUFFER_BIT = 16384\nvar GL_DEPTH_BUFFER_BIT = 256\nvar GL_STENCIL_BUFFER_BIT = 1024\n\nvar GL_ARRAY_BUFFER = 34962\n\nvar CONTEXT_LOST_EVENT = 'webglcontextlost'\nvar CONTEXT_RESTORED_EVENT = 'webglcontextrestored'\n\nvar DYN_PROP = 1\nvar DYN_CONTEXT = 2\nvar DYN_STATE = 3\n\nfunction find (haystack, needle) {\n for (var i = 0; i < haystack.length; ++i) {\n if (haystack[i] === needle) {\n return i\n }\n }\n return -1\n}\n\nfunction wrapREGL (args) {\n var config = parseArgs(args)\n if (!config) {\n return null\n }\n\n var gl = config.gl\n var glAttributes = gl.getContextAttributes()\n var contextLost = gl.isContextLost()\n\n var extensionState = createExtensionCache(gl, config)\n if (!extensionState) {\n return null\n }
1\n\n var stringStore = createStringStore()\n var stats$$1 = stats()\n var extensions = extensionState.extensions\n var timer = createTimer(gl, extensions)\n\n var START_TIME = clock()\n var WIDTH = gl.drawingBufferWidth\n var HEIGHT = gl.drawingBufferHeight\n\n var contextState = {\n tick: 0,\n time: 0,\n viewportWidth: WIDTH,\n viewportHeight: HEIGHT,\n framebufferWidth: WIDTH,\n framebufferHeight: HEIGHT,\n drawingBufferWidth: WIDTH,\n drawingBufferHeight: HEIGHT,\n pixelRatio: config.pixelRatio\n }\n var uniformState = {}\n var drawState = {\n elements: null,\n primitive: 4, // GL_TRIANGLES\n count: -1,\n offset: 0,\n instances: -1\n }\n\n var limits = wrapLimits(gl, extensions)\n var bufferState = wrapBufferState(\n gl,\n stats$$1,\n config,\n destroyBuffer)\n var elementState = wrapElementsState(gl, extensions, bufferState, stats$$1)\n var attributeState = wrapAttributeState(\n gl,\n extensions,\n limits,\n stats$$1,\n bufferState,\n elementState,\n drawState)\n function destroyBuffer (buffer) {\n return attributeState.destroyBuffer(buffer)\n }\n var shaderState = wrapShaderState(gl, stringStore, stats$$1, config)\n var textureState = createTextureSet(\n gl,\n extensions,\n limits,\n function () { core.procs.poll() },\n contextState,\n stats$$1,\n config)\n var renderbufferState = wrapRenderbuffers(gl, extensions, limits, stats$$1, config)\n var framebufferState = wrapFBOState(\n gl,\n extensions,\n limits,\n textureState,\n renderbufferState,\n stats$$1)\n var core = reglCore(\n gl,\n stringStore,\n extensions,\n limits,\n bufferState,\n elementState,\n textureState,\n framebufferState,\n uniformState,\n attributeState,\n shaderState,\n drawState,\n contextState,\n timer,\n config)\n var readPixels = wrapReadPixels(\n gl,\n framebufferState,\n core.procs.poll,\n contextState,\n glAttributes, extensions, limits)\n\n var nextState = core.next\n var canvas = gl.canvas\n\n var rafCallbacks = []\n var lossCallbacks = []\n var restoreCallbacks = []\n var destroyCallbacks = [config.onDestroy]\n\n var activeRAF = null\n function handleRAF () {\n if (rafCallbacks.length === 0) {\n if (timer) {\n timer.update(
1)\n }\n activeRAF = null\n return\n }\n\n // schedule next animation frame\n activeRAF = raf.next(handleRAF)\n\n // poll for changes\n poll()\n\n // fire a callback for all pending rafs\n for (var i = rafCallbacks.length - 1; i >= 0; --i) {\n var cb = rafCallbacks[i]\n if (cb) {\n cb(contextState, null, 0)\n }\n }\n\n // flush all pending webgl calls\n gl.flush()\n\n // poll GPU timers *after* gl.flush so we don't delay command dispatch\n if (timer) {\n timer.update()\n }\n }\n\n function startRAF () {\n if (!activeRAF && rafCallbacks.length > 0) {\n activeRAF = raf.next(handleRAF)\n }\n }\n\n function stopRAF () {\n if (activeRAF) {\n raf.cancel(handleRAF)\n activeRAF = null\n }\n }\n\n function handleContextLoss (event) {\n event.preventDefault()\n\n // set context lost flag\n contextLost = true\n\n // pause request animation frame\n stopRAF()\n\n // lose context\n lossCallbacks.forEach(function (cb) {\n cb()\n })\n }\n\n function handleContextRestored (event) {\n // clear error code\n gl.getError()\n\n // clear context lost flag\n contextLost = false\n\n // refresh state\n extensionState.restore()\n shaderState.restore()\n bufferState.restore()\n textureState.restore()\n renderbufferState.restore()\n framebufferState.restore()\n attributeState.restore()\n if (timer) {\n timer.restore()\n }\n\n // refresh state\n core.procs.refresh()\n\n // restart RAF\n startRAF()\n\n // restore context\n restoreCallbacks.forEach(function (cb) {\n cb()\n })\n }\n\n if (canvas) {\n canvas.addEventListener(CONTEXT_LOST_EVENT, handleContextLoss, false)\n canvas.addEventListener(CONTEXT_RESTORED_EVENT, handleContextRestored, false)\n }\n\n function destroy () {\n rafCallbacks.length = 0\n stopRAF()\n\n if (canvas) {\n canvas.removeEventListener(CONTEXT_LOST_EVENT, handleContextLoss)\n canvas.removeEventListener(CONTEXT_RESTORED_EVENT, handleContextRestored)\n }\n\n shaderState.clear()\n framebufferState.clear()\n renderbufferState.clear()\n attributeState.clear()\n textureState.clear()\n elementState.clear()\n bufferState.clear()\n\n if (timer) {\n timer.clear()\n }\n\n destroyCallbacks.forEach(function (cb) {\n cb()\n })\n }\n\n function compileProcedure (options) {\n check$1(!!options, 'invalid args to regl({...})')\n check$1.type(options, 'object', 'invalid args to regl({...})')\n\n function flattenNestedOptions (options) {\n var result = extend({}, options)\n delete result.uniforms\n delete result.attributes\n delete result.context\n delete result.vao\n\n if ('stencil' in result && result.stencil.op) {\n result.stencil.opBack = result.stencil.opFront = result.stencil.op\n delete result.stencil.op\n }\n\n function merge (name) {\n if (name in result) {\n var child = result[name]\n delete result[name]\n Object.keys(child).forEach(function (prop) {\n result[name + '.' + prop] = child[prop]\n })\n }\n }\n merge('blend')\n merge('depth')\n merge('cull')\n merge('stencil')\n merge('polygonOffset')\n merge('scissor')\n merge('sample')\n\n if ('vao' in options) {\n result.vao = options.vao\n }\n\n return result\n }\n\n function separateDynamic (object, useArrays) {\n var staticItems = {}\n var dynamicItems = {}\n Object.keys(object).forEach(function (option) {\n var value = object[option]\n if (dynamic.isDynamic(value)) {\n dynamicItems[option] = dynamic.unbox(value, option)\n return\n } else if (useArrays && Array.isArray(value)) {\n for (var i = 0; i < value.length; ++i) {\n if (dynamic.isDynamic(value[i])) {\n dynamicItems[option] = dynamic.unbox(value, option)\n return\n }\n }\n }\n staticItems[option] = value\n })\n return {\n dynamic: dynamicItems,\n static: staticItems\n }\n }\n\n // Treat context variables separate from other dynamic variables\n var context = separateDynamic(options.context || {}, true)\n var uniforms = separateDynamic(options.uniforms || {}, true)\n var attributes = separateDynamic(options.attributes || {}, false)\n var opts = separateDynamic(flattenNestedOptions(options), false)\n\n var stats$$1 = {\n gpuTime: 0.0,\n cpuTime: 0.0,\n count: 0\n }\n\n var compiled = core.compile(opts, attributes, uniforms, context, stats$$1)\n\n var draw = compiled.draw\n var batch = compiled.batch\n var scope = compiled.scope\n\n // FIXME: we should modify code generation for batch commands so this\n // isn't necessary\n var EMPTY_ARRAY = []\n function reserve (count) {\n while (EMPTY_ARRAY.length < count) {\n EMPTY_ARRAY.push(null)\n }\n return EMPTY_ARRAY\n }
1\n\n function REGLCommand (args, body) {\n var i\n if (contextLost) {\n check$1.raise('context lost')\n }\n if (typeof args === 'function') {\n return scope.call(this, null, args, 0)\n } else if (typeof body === 'function') {\n if (typeof args === 'number') {\n for (i = 0; i < args; ++i) {\n scope.call(this, null, body, i)\n }\n } else if (Array.isArray(args)) {\n for (i = 0; i < args.length; ++i) {\n scope.call(this, args[i], body, i)\n }\n } else {\n return scope.call(this, args, body, 0)\n }\n } else if (typeof args === 'number') {\n if (args > 0) {\n return batch.call(this, reserve(args | 0), args | 0)\n }\n } else if (Array.isArray(args)) {\n if (args.length) {\n return batch.call(this, args, args.length)\n }\n } else {\n return draw.call(this, args)\n }\n }\n\n return extend(REGLCommand, {\n stats: stats$$1,\n destroy: function () {\n compiled.destroy()\n }\n })\n }\n\n var setFBO = framebufferState.setFBO = compileProcedure({\n framebuffer: dynamic.define.call(null, DYN_PROP, 'framebuffer')\n })\n\n function clearImpl (_, options) {\n var clearFlags = 0\n core.procs.poll()\n\n var c = options.color\n if (c) {\n gl.clearColor(+c[0] || 0, +c[1] || 0, +c[2] || 0, +c[3] || 0)\n clearFlags |= GL_COLOR_BUFFER_BIT\n }\n if ('depth' in options) {\n gl.clearDepth(+options.depth)\n clearFlags |= GL_DEPTH_BUFFER_BIT\n }\n if ('stencil' in options) {\n gl.clearStencil(options.stencil | 0)\n clearFlags |= GL_STENCIL_BUFFER_BIT\n }\n\n check$1(!!clearFlags, 'called regl.clear with no buffer specified')\n gl.clear(clearFlags)\n }\n\n function clear (options) {\n check$1(\n typeof options === 'object' && options,\n 'regl.clear() takes an object as input')\n if ('framebuffer' in options) {\n if (options.framebuffer &&\n options.framebuffer_reglType === 'framebufferCube') {\n for (var i = 0; i < 6; ++i) {\n setFBO(extend({\n framebuffer: options.framebuffer.faces[i]\n }, options), clearImpl)\n }\n } else {\n setFBO(options, clearImpl)\n }\n } else {\n clearImpl(null, options)\n }\n }\n\n function frame (cb) {\n check$1.type(cb, 'function', 'regl.frame() callback must be a function')\n rafCallbacks.push(cb)\n\n function cancel () {\n // FIXME: should we check something other than equals cb here?\n // what if a user calls frame twice with the same callback...\n //\n var i = find(rafCallbacks, cb)\n check$1(i >= 0, 'cannot cancel a frame twice')\n function pendingCancel () {\n var index = find(rafCallbacks, pendingCancel)\n rafCallbacks[index] = rafCallbacks[rafCallbacks.length - 1]\n rafCallbacks.length -= 1\n if (rafCallbacks.length <= 0) {\n stopRAF()\n }\n }\n rafCallbacks[i] = pendingCancel\n }\n\n startRAF()\n\n return {\n cancel: cancel\n }\n }\n\n // poll viewport\n function pollViewport () {\n var viewport = nextState.viewport\n var scissorBox = nextState.scissor_box\n viewport[0] = viewport[1] = scissorBox[0] = scissorBox[1] = 0\n contextState.viewportWidth =\n contextState.framebufferWidth =\n contextState.drawingBufferWidth =\n viewport[2] =\n scissorBox[2] = gl.drawingBufferWidth\n contextState.viewportHeight =\n contextState.framebufferHeight =\n contextState.drawingBufferHeight =\n viewport[3] =\n scissorBox[3] = gl.drawingBufferHeight\n }\n\n function poll () {\n contextState.tick += 1\n contextState.time = now()\n pollViewport()\n core.procs.poll()\n }\n\n function refresh () {\n textureState.refresh()\n pollViewport()\n core.procs.refresh()\n if (timer) {\n timer.update(
1)\n }\n }\n\n function now () {\n return (clock() - START_TIME) / 1000.0\n }\n\n refresh()\n\n function addListener (event, callback) {\n check$1.type(callback, 'function', 'listener callback must be a function')\n\n var callbacks\n switch (event) {\n case 'frame':\n return frame(callback)\n case 'lost':\n callbacks = lossCallbacks\n break\n case 'restore':\n callbacks = restoreCallbacks\n break\n case 'destroy':\n callbacks = destroyCallbacks\n break\n default:\n check$1.raise('invalid event, must be one of frame,lost,restore,destroy')\n }\n\n callbacks.push(callback)\n return {\n cancel: function () {\n for (var i = 0; i < callbacks.length; ++i) {\n if (callbacks[i] === callback) {\n callbacks[i] = callbacks[callbacks.length - 1]\n callbacks.pop()\n return\n }\n }\n }\n }\n }\n\n var regl = extend(compileProcedure, {\n // Clear current FBO\n clear: clear,\n\n // Short cuts for dynamic variables\n prop: dynamic.define.bind(null, DYN_PROP),\n context: dynamic.define.bind(null, DYN_CONTEXT),\n this: dynamic.define.bind(null, DYN_STATE),\n\n // executes an empty draw command\n draw: compileProcedure({}),\n\n // Resources\n buffer: function (options) {\n return bufferState.create(options, GL_ARRAY_BUFFER, false, false)\n },\n elements: function (options) {\n return elementState.create(options, false)\n },\n texture: textureState.create2D,\n cube: textureState.createCube,\n renderbuffer: renderbufferState.create,\n framebuffer: framebufferState.create,\n framebufferCube: framebufferState.createCube,\n vao: attributeState.createVAO,\n\n // Expose context attributes\n attributes: glAttributes,\n\n // Frame rendering\n frame: frame,\n on: addListener,\n\n // System limits\n limits: limits,\n hasExtension: function (name) {\n return limits.extensions.indexOf(name.toLowerCase()) >= 0\n },\n\n // Read pixels\n read: readPixels,\n\n // Destroy regl and all associated resources\n destroy: destroy,\n\n // Direct GL state manipulation\n _gl: gl,\n _refresh: refresh,\n\n poll: function () {\n poll()\n if (timer) {\n timer.update(
1)\n }\n },\n\n // Current time\n now: now,\n\n // regl Statistics Information\n stats: stats$$1\n })\n\n config.onDone(null, regl)\n\n return regl\n}\n\nreturn wrapREGL;\n\n})));\n//# sourceMappingURL=regl.js.map\n<\/script>\n {{tokenData}}<style type=\"text/css\">body {\n margin: 0;\n padding: 0;\n }\n canvas {\n padding: 0;\n margin: auto;\n display: block;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n }</style></head><body>{{script}}</body></html>"};const X=["p5js","js","threejs","regl","paper"];var Y=(t,n={})=>{let e,r="js";if(t.project.scriptType&&(r=t.project.scriptType),r=(r||"").toLowerCase(),r&&"vanilla"!==r&&"n/a"!==r||(r="js"),"p5"===r&&(r="p5js"),"three"===r&&(r="threejs"),!X.includes(r))return alert(`Error: Project type "${r}" not yet supported.`);t.project.scriptVersion&&(/n[\\/]?a/i.test(t.project.scriptVersion)||(e=t.project.scriptVersion));const a=parseInt(t.project.id,10),i=String(t.token.id),o=a<=2?{hashes:[t.token.hash],tokenId:i}:{hash:t.token.hash,tokenId:i},s=q[r]||q.js;let l,c;e=function(t,n){return"p5js"===t?n||"1.0.0":n}(r,e),"regl"===r?l="https://cdnjs.cloudflare.com/ajax/libs/regl/2.1.0/regl.min.js":"p5js"===r?l=`https://cdnjs.cloudflare.com/ajax/libs/p5.js/${e}/p5.min.js`:"paper"===r&&(l=`https://cdnjs.cloudflare.com/ajax/libs/paper.js/${r}/paper-full.min.js`),l&&(c=`<script src="${l}"><\/script>`);return function(t,n){n=n||{};const e=t.split(/\{\{|\}\}/);return e.map(function(t){return function(n,e){return e%2==0?n:t[n]}}(n)).join("")}(s,{version:e,prelude:function(t={}){const{inline:n=!1,width:e=512,height:r=512,fps:a=30,totalFrames:i=30,clickOnStart:o=!1}=t,s={width:e,height:r,fps:a,totalFrames:i,inline:n,clickOnStart:o};return`\n <script>\n ;(function () {\n const inline = ${JSON.stringify(n)};\n const settings = ${JSON.stringify(s)};\n const { fps, width, height, totalFrames, clickOnStart } = settings;\n\n // Patch pixel ratio\n window.devicePixelRatio = 1;\n window.innerWidth = width;\n window.innerHeight = height;\n document.documentElement.clientWidth = width;\n document.documentElement.clientHeight = height;\n\n // Get the time patch library\n ;window.__timelib__ = (function () {\n if (!("performance" in window)) {\n window.performance = {};\n }\n Date.now =\n Date.now ||\n function () {\n // thanks IE8\n return new Date().getTime();\n };\n if (!("now" in window.performance)) {\n var nowOffset = Date.now();\n if (performance.timing && performance.timing.navigationStart) {\n nowOffset = performance.timing.navigationStart;\n }\n window.performance.now = function now() {\n return Date.now() - nowOffset;\n };\n }\n\n let sessionStartTime = null;\n const startTimeOffset = 0;\n\n const _oldSetTimeout = window.setTimeout,\n _oldSetInterval = window.setInterval,\n _oldClearInterval = window.clearInterval,\n _oldClearTimeout = window.clearTimeout,\n _oldRequestAnimationFrame = window.requestAnimationFrame,\n _oldCancelAnimationFrame = window.cancelAnimationFrame,\n _oldNow = window.Date.now,\n _oldPerformanceNow = window.performance.now,\n _oldGetTime = window.Date.prototype.getTime;\n\n let startTime, time, performanceStartTime, performanceTime;\n\n let timeouts = [];\n let intervals = [];\n let requestAnimationFrameCallbacks = [];\n let elapsed = 0;\n let _attached = false;\n\n function attach() {\n if (_attached) return;\n timeouts.length = 0;\n elapsed = 0;\n _attached = true;\n if (sessionStartTime == null) {\n sessionStartTime = window.Date.now();\n }\n startTime = window.Date.now();\n time = startTime + startTimeOffset;\n performanceStartTime = window.performance.now();\n performanceTime = performanceStartTime + startTimeOffset;\n requestAnimationFrameCallbacks = [];\n timeouts = [];\n intervals = [];\n\n window.Date.prototype.getTime = function () {\n return time;\n };\n window.Date.now = function () {\n return time;\n };\n\n window.setTimeout = function (callback, delay) {\n var t = {\n callback: callback,\n triggerTime: time + delay,\n };\n timeouts.push(t);\n return t;\n };\n window.clearTimeout = function (id) {\n for (var j = 0; j < timeouts.length;
1 j++) {\n if (timeouts[j] == id) {\n timeouts.splice(j, 1);\n }\n }\n };\n window.setInterval = function (callback, delay) {\n var t = {\n callback: callback,\n delay,\n triggerTime: time + delay,\n };\n intervals.push(t);\n return t;\n };\n window.clearInterval = function (id) {\n for (var j = 0; j < intervals.length; j++) {\n if (intervals[j] == id) {\n intervals.splice(j, 1);\n }\n }\n };\n window.requestAnimationFrame = function (callback) {\n const cb = { callback };\n requestAnimationFrameCallbacks.push(cb);\n return cb;\n };\n window.cancelAnimationFrame = function (id) {\n for (var j = 0; j < requestAnimationFrameCallbacks.length; j++) {\n if (requestAnimationFrameCallbacks[j] == id) {\n requestAnimationFrameCallbacks.splice(j, 1);\n }\n }\n };\n window.performance.now = function () {\n return performanceTime;\n };\n }\n\n function step(dt = 0) {\n time += dt;\n performanceTime += dt;\n elapsed += dt;\n\n for (let j = 0; j < timeouts.length; j++) {\n if (time >= timeouts[j].triggerTime) {\n timeouts[j].callback();\n timeouts.splice(j, 1);\n }\n }\n\n for (let j = 0; j < intervals.length; j++) {\n if (time >= intervals[j].triggerTime) {\n intervals[j].callback();\n intervals[j].triggerTime += intervals[j].delay;\n }\n }\n\n const rafs = [...requestAnimationFrameCallbacks];\n requestAnimationFrameCallbacks = [];\n rafs.forEach(({ callback }) => {\n callback(time - sessionStartTime);\n });\n }\n\n function sleep(delay = 0) {\n return new Promise((resolve) => _oldSetTimeout.call(window, resolve, delay));\n }\n\n function detach() {\n if (!_attached) return;\n timeouts.length = 0;\n _attached = false;\n window.setTimeout = _oldSetTimeout;\n window.setInterval = _oldSetInterval;\n window.clearInterval = _oldClearInterval;\n window.clearTimeout = _oldClearTimeout;\n window.requestAnimationFrame = _oldRequestAnimationFrame;\n window.cancelAnimationFrame = _oldCancelAnimationFrame;\n window.Date.prototype.getTime = _oldGetTime;\n window.Date.now = _oldNow;\n window.performance.now = _oldPerformanceNow;\n }\n\n function getElapsedTime() {\n return elapsed;\n }\n\n return { getElapsedTime, attach, detach, step, sleep };\n})();\n\n function send (data, transfer) {\n if (typeof data === 'string') {\n data = { event: data };\n }\n window.parent.postMessage(data, "*", transfer);\n }\n\n // Attach it to avoid any frames starting\n // console.log("Waiting...", settings);\n send('init');\n const time = window.__timelib__;\n if (!inline) {\n time.attach();\n }\n\n const onload = new Promise(resolve => {\n // Wait for ready events\n const onload = () => {\n window.removeEventListener("load", onload);\n resolve();\n };\n window.addEventListener("load", onload);\n });\n\n const onready = new Promise(resolve => {\n // Wait for ready events\n const onready = () => {\n window.removeEventListener("DOMContentLoaded", onready);\n resolve();\n };\n window.addEventListener("DOMContentLoaded", onready);\n });\n\n Promise.all([onload, onready]).then(async () => {\n start();\n })\n\n async function waitForEvent (event) {\n return new Promise(resolve => {\n const msg = ev => {\n const d = ev.data;\n if (d.event === event) {\n window.removeEventListener('message', msg);\n resolve(d);\n }\n };\n window.addEventListener('message', msg, false);\n })\n }\n\n async function waitForFrame (frame) {\n return new Promise(resolve => {\n const msg = ev => {\n const d = ev.data;\n if (d.event === 'frame' && d.frame === frame) {\n window.removeEventListener('message', msg);\n resolve(d);\n }\n };\n window.addEventListener('message', msg, false);\n })\n }\n\n async function start () {\n const startEvent = waitForEvent('start');\n send('start');\n await startEvent;\n\n // Inline mode just runs as normal until cancel\n if (inline) return;\n\n // Create an encoding stream\n const frameList = Array(totalFrames)\n .fill()\n .map((_, i) => i);\n \n const canvas = findCanvas();\n if (!canvas) return console.warn("no canvas");\n\n if (clickOnStart) canvas.click();\n\n // const tmpCanvas = document.createElement('canvas');\n // const tmpContext = tmpCanvas.getContext('2d');\n // tmpCanvas.width = width;\n // tmpCanvas.height = height;\n\n for (let i of frameList) {\n const dt = (1 / fps) * 1000;\n time.step(dt);\n\n // tmpContext.clearRect(0, 0, width, height);\n // tmpContext.drawImage(canvas, 0, 0, width, height);\n // const pixels = tmpContext.getImageData(0, 0, width, height).data;\n const pixels = await createImageBitmap(canvas)\n const p = waitForFrame(i);\n send({ event: 'frame', pixels, frame: i }, [pixels]);\n await p;\n\n await time.sleep(0);\n }\n\n send('finish');
1\n\n function findCanvas() {\n const canvases = [...document.querySelectorAll("canvas")].filter(d => {\n return d.style.display !== 'none' && d.style.visibility !== 'hidden'\n });\n const canvas = canvases[canvases.length - 1];\n return canvas;\n }\n }\n })();\n <\/script>\n `}(n),vendor:c,tokenData:`<script>let tokenData = ${JSON.stringify(o)};<\/script>`,script:`<script>${t.project.script}<\/script>`})};const Z=(t,n,e)=>Math.max(Math.min(t,e),n);function J(t,n,e,r){let a=0,i=1e100;for(let o=0;o<r.length;o++){const s=r[o];let l=Q(s[0]-t);if(l>i)continue;if(l+=Q(s[1]-n),l>i)continue;l+=Q(s[2]-e),l>i||(i=l,a=o)}return a}function K(t,n,e,r){return t=Math.floor(t),n=Math.floor(n),4*((t=Z(t,0,e-1))+(n=Z(n,0,r-1))*e)}function Q(t){return t*t}let tt=document.createElement("canvas"),nt=tt.getContext("2d");var et;function rt(t,n=t.width,e=t.height,r="image/png",a=.9){tt.width=n,tt.height=e,nt.clearRect(0,0,n,e),nt.drawImage(t,0,0,n,e);return function(t){const n=t.indexOf(",");if(-1===n)return new Blob;const e=t.slice(n+1),r=atob(e),a=t.slice(0,n),i=/data:([^;]+)/.exec(a),o=(i?i[1]:"")||void 0,s=new ArrayBuffer(r.length),l=new Uint8Array(s);for(var c=0;c<r.length;c++)l[c]=r.charCodeAt(c);return new Blob([s],{type:o})}(tt.toDataURL(r,a))}async function at(t={}){const{fps:n=30,width:i,height:o,dithering:s=!1}=t,l=a();let c=!0;return{type:"image/gif",extension:".gif",async encode(t){const a=function(t,n=t.width,e=t.height){return tt.width=n,tt.height=e,nt.clearRect(0,0,n,e),nt.drawImage(t,0,0,n,e),nt.getImageData(0,0,n,e).data}(t,i,o),u=e(a,256),p=s?function(t,n,e,r){const a=new Uint8ClampedArray(t),i=new Array(65536),o=[0,0,0];return s(!0),s(!1),a;function s(t){for(let s=0;s<e;s++){let l=s%2==0;for(let c=0;c<n;c++){t&&(l=Math.random()>.5);const u=l?c:n-c-1,p=K(u,s,n,e),d=a[p+0],f=a[p+1],m=a[p+2],h=d<<8&63488|f<<2&992|m>>3,g=h in i?i[h]:i[h]=J(d,f,m,r),v=r[g],_=v[0],x=v[1],y=v[2];o[0]=d-_,o[1]=f-x,o[2]=m-y;const b=K(u,s+1,n,e),S=K(u+1,s+1,n,e),T=K(u+1,s,n,e),E=K(u-1,s,n,e);K(u+1,s-1,n,e);const w=K(u-1,s+1,n,e);a[p]=_,a[p+1]=x,a[p+2]=y,a[p+3]=255;for(let t=0;t<3;t++)l?(u>=0&&s<e-1&&(a[b+t]=a[b+t]+5*o[t]/16),u<n-1&&s<e-1&&(a[S+t]=a[S+t]+1*o[t]/16),s>=0&&u<n-1&&(a[T+t]=a[T+t]+7*o[t]/16),u>0&&s<e-1&&(a[w+t]=a[w+t]+3*o[t]/16)):(u>=0&&s<e-1&&(a[b+t]=a[b+t]+5*o[t]/16),u>0&&s<e-1&&(a[w+t]=a[w+t]+1*o[t]/16),s>=0&&u>0&&(a[E+t]=a[E+t]+7*o[t]/16),u<n-1&&s<e-1&&(a[S+t]=a[S+t]+3*o[t]/16))}}}}(a,i,o,u):a,d=r(p,u),f=1e3*(1/n);let m;m=u,l.writeFrame(d,i,o,{palette:m,delay:f}),c=!1},finish:async()=>(l.finish(),l.bytes())}}(et=document.createElement("canvas")).getContext&&et.getContext("2d")&&et.toDataURL("image/webp").indexOf("data:image/webp");function it(t){return{c:_,l:_,m:_,p:_,d:_}}function ot(t){let n,e=t[21]&&st(t);return{c(){e&&e.c(),n=E()},l(t){e&&e.l(t),n=E()},m(t,r){e&&e.m(t,r),g(t,n,r)},p(t,r){t[21]?e?e.p(t,r):(e=st(t),e.c(),e.m(n.parentNode,n)):e&&(e.d(1),e=null)},d(t){e&&e.d(t),t&&d(n)}}}function st(t){let n,e,r,a,i,o="inline"!==t[2]&<(t);return{c(){o&&o.c(),n=S(),e=c("iframe"),this.h()},l(t){o&&o.l(t),n=T(t),e=u(t,"IFRAME",{width:!0,height:!0,scrolling:!0,title:!0,srcdoc:!0,class:!0}),p(e).forEach(d),this.h()},h(){f(e,"width",r=t[0]+"px"),f(e,"height",a=t[1]+"px"),f(e,"scrolling","no"),f(e,"title",""),f(e,"srcdoc",i=t[21]),f(e,"class","svelte-scmy4a"),h(e,"visible","inline"===t[2])},m(t,r){o&&o.m(t,r),g(t,n,r),g(t,e,r)},p(t,s){"inline"!==t[2]?o?o.p(t,s):(o=lt(t),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null),1&s&&r!==(r=t[0]+"px")&&f(e,"width",r),2&s&&a!==(a=t[1]+"px")&&f(e,"height",a),32&s&&i!==(i=t[21])&&f(e,"srcdoc",i),4&s&&h(e,"visible","inline"===t[2])},d(t){o&&o.d(t),t&&d(n),t&&d(e)}}}function lt(t){let n;return{c(){n=c("canvas"),this.h()},l(t){n=u(t,"CANVAS",{style:!0}
1),p(n).forEach(d),this.h()},h(){m(n,"display","none")},m(e,r){g(e,n,r),t[12](n)},p:_,d(e){e&&d(n),t[12](null)}}}function ct(t){let n,e;return{c(){n=c("div"),e=w("loading..."),this.h()},l(t){n=u(t,"DIV",{class:!0});var r=p(n);e=A(r,"loading..."),r.forEach(d),this.h()},h(){f(n,"class","loading svelte-scmy4a")},m(t,r){g(t,n,r),M(n,e)},p:_,d(t){t&&d(n)}}}function ut(t){let n,e,r={ctx:t,current:null,token:null,hasCatch:!1,pending:ct,then:ot,catch:it,value:21};return l(e=t[5],r),{c(){n=c("div"),r.block.c(),this.h()},l(t){n=u(t,"DIV",{class:!0,style:!0});var e=p(n);r.block.l(e),e.forEach(d),this.h()},h(){f(n,"class","container svelte-scmy4a"),m(n,"width",t[3]+"px"),m(n,"height",t[4]+"px"),h(n,"hidden","png"===t[2])},m(t,e){g(t,n,e),r.block.m(n,r.anchor=null),r.mount=()=>n,r.anchor=null},p(a,[i]){t=a,r.ctx=t,32&i&&e!==(e=t[5])&&l(e,r)||v(r,t,i),8&i&&m(n,"width",t[3]+"px"),16&i&&m(n,"height",t[4]+"px"),4&i&&h(n,"hidden","png"===t[2])},i:_,o:_,d(t){t&&d(n),r.block.d(),r.token=null,r=null}}}const pt="collections/curated/projects/";function dt(t,n,e){const r=x();let a,i,o,s,l,c,u,p,{id:d="0"}=n,{fps:f=30}=n,{width:m=1080}=n,{height:h=1080}=n,{format:g="mp4"}=n,{totalFrames:v=30}=n,{dithering:_=!1}=n,S="inline"!==g;async function T(t){const n=t.source,a=t.data;if("start"===a.event)S&&r("progress",0),l?n.postMessage({event:"start"},"*"):S&&r("finish");else if("frame"===a.event){const t=a.frame,c=a.pixels;if(S&&(r("progress",t/v),await l.encode(c,t)),u){e(6,u.width=i*s,u),e(6,u.height=o*s,u),e(6,u.style.width=`${i}px`,u),e(6,u.style.height=`${o}px`,u),e(6,u.style.display="",u);u.getContext("2d").drawImage(c,0,0,u.width,u.height)}n.postMessage({event:"frame",frame:t},"*")}else if("finish"===a.event){const t=await l.finish();S&&(r("progress",1),t&&function(t,n,e){const r=t instanceof Blob?t:new Blob([t],{type:e}),a=URL.createObjectURL(r),i=document.createElement("a");i.href=a,i.download=n,i.click()}(t,`${p}${l.extension}`,l.type),r("finish"))}}async function E(t){const n=await async function(t){(t=String(t)).toLowerCase().includes(pt)&&(t=function(t){const n=(t=t.toLowerCase()).split(pt);let e,r;if(2==n.length){const t=n[1].split("/");r=t[0],e=t.includes("tokens")?t[t.length-1]:String(1e6*parseInt(t[1],10))}return e||alert("URL is incorrect; has to be in the form artblocks.io/collections/curated/...."),console.log("Got Contract:",r),console.log("Got TokenID:",e),e}(t));p=t;const n=parseInt(t,10);if(isNaN(n))throw new Error("id query parameter is not a number");const e=1e6,r=Math.floor(n/e),a=await async function(t){const{projects:n}=await $(H,`{\n projects(where: { projectId: "${t}", contract_in: ${W} }) {\n projectId\n name\n aspectRatio\n script\n scriptTypeAndVersion\n scriptJSON\n website\n artistName\n description\n license\n invocations\n maxInvocations\n paused\n currencySymbol\n pricePerTokenInWei\n script\n }\n}\n`);if(!n||0===n.length)return null;const e=n[0];if(e){if(e.id=e.projectId,null!=e.scriptJSON&&("string"==typeof e.scriptJSON&&(e.scriptJSON=JSON.parse(e.scriptJSON)),"aspectRatio"in e.scriptJSON&&(e.aspectRatio=parseFloat(e.scriptJSON.aspectRatio)),e.scriptType=e.scriptJSON.type,e.scriptVersion=e.scriptJSON.version),e.aspectRatio=parseFloat(e.aspectRatio)||0,e.scriptTypeAndVersion){const t=e.scriptTypeAndVersion.split("@"),n=t[0];let r="n/a";t.length>1&&(r=t[1]),e.scriptType=n,e.scriptVersion=r}e.scriptJSON||(e.scriptJSON={}),e.scriptJSON.type||(e.scriptJSON.type=e.type),e.scriptJSON.aspectRatio||(e.scriptJSON.aspectRatio=e.aspectRatio),e.maxInvocations=parseInt(e.maxInvocations,10),e.pricePerTokenInWei=parseInt(e.pricePerTokenInWei,10),e.invocations=parseInt(e.invocations,10)}return e}(r),i=await async function(t){const{tokens:n}=await $(H,`{\n tokens(where: { tokenId: "${t}", contract_in: ${W} }) {\n tokenId\n hash\n }\n}\n`);if(!n||0===n.length)return null;if(n.length>1)throw new Error("Received multiple tokens for id: "+t);const e=n[0];return{id:e.tokenId,hash:e.hash}}(t);return console.log(`Token ID: ${t}`),console.log(`Project ID: ${r}`),console.log("Project:",a),console.log("Token:",i),{id:t,project:a,token:i}}(t),a=!m,i=!h;if(a||i){let t=1;const r=1024;n&&n.project&&n.project.scriptJSON&&"number"==typeof n.project.scriptJSON.aspectRatio&&(t=n.project.scriptJSON.aspectRatio),a&&i?(e(1,h=r),e(0,m=Math.round(h*t))):a?e(0,m=Math.round(h*t)):e(1,h=Math.round(m/t))}let o={width:m,height:h,fps:f,totalFrames:v,dithering:_};if(l="mp4"===g?await async function(t={}){const{width:n,height:e,mp4:r,fps:a=30}=t,{loadMP4Module:i}=await window.MP4Encoder,o=(await i()).createWebCodecsEncoder({width:n,height:e,fps:a,codec:"avc1.420034",encoderOptions:{}});return{type:"video/mp4",extension:".mp4",async encode(t){await o.addFrame(t)},finish:async()=>await o.end()}}(o):"png"===g?await async function(t={}){const{width:n,height:e}=t;let r;return{type:"image/png",extension:".png",async encode(t){r=rt(t,n,e,"image/png")},finish:async()=>r}}(o):"frames"===g?await async function(t={}){const{width:n,height:e,type:r="image/png",prefix:a="",encoderOptions:i=.9,totalFrames:o=1e3}=t,s={"image/png":".png","image/webp":".webp","image/jpeg":".jpg"}[r];if(!s)throw new Error(`Invalid image mime type ${r}`);let l;try{l=await window.showDirectoryPicker()}catch(c){if(20===c.code||"AbortError"===c.name)return null;throw c}return{type:"image/png",extension:".png",async encode(t,c){const u=Math.max(3,String(o).length),p=String(c).padStart(u,"0"),d=`${a}${p}${s}`,f=await l.getFileHandle(d,{create:!0}),m=await f.createWritable(),h=rt(t,n,e,r,i);await m.write(h),await m.close()},async finish(){}}}
1(o):"gif"===g?await at(o):{type:"image/png",extension:".png",async encode(t){},finish:async()=>null},!l)return r("finish"),null;let s=!1;return n&&n.project&&"0"===String(n.project.projectId)&&"png"!==g&&(s=!0),Y(n,{inline:"inline"===g,fps:f,width:m,height:h,totalFrames:v,clickOnStart:s})}return y((()=>(window.addEventListener("message",T,!1),()=>{window.removeEventListener("message",T)}))),t.$$set=t=>{"id"in t&&e(7,d=t.id),"fps"in t&&e(8,f=t.fps),"width"in t&&e(0,m=t.width),"height"in t&&e(1,h=t.height),"format"in t&&e(2,g=t.format),"totalFrames"in t&&e(9,v=t.totalFrames),"dithering"in t&&e(10,_=t.dithering)},t.$$.update=()=>{2059&t.$$.dirty&&(e(11,a=m/h),s=window.devicePixelRatio,e(3,i=256),e(4,o=i/a)),4&t.$$.dirty&&(S="inline"!==g),128&t.$$.dirty&&e(5,c=E(d))},[m,h,g,i,o,c,u,d,f,v,_,a,function(t){b[t?"unshift":"push"]((()=>{u=t,e(6,u)}))}]}class ft extends i{constructor(t){super(),o(this,t,dt,ut,s,{id:7,fps:8,width:0,height:1,format:2,totalFrames:9,dithering:10})}}function mt(t){let n,e;return{c(){n=c("div"),e=c("div"),this.h()},l(t){n=u(t,"DIV",{class:!0,style:!0});var r=p(n);e=u(r,"DIV",{class:!0,style:!0}),p(e).forEach(d),r.forEach(d),this.h()},h(){f(e,"class","inner svelte-1c5vg33"),m(e,"background-color",t[0]),m(e,"width",t[1]),f(n,"class","container svelte-1c5vg33"),m(n,"border-color",t[0])},m(t,r){g(t,n,r),M(n,e)},p(t,[r]){1&r&&m(e,"background-color",t[0]),2&r&&m(e,"width",t[1]),1&r&&m(n,"border-color",t[0])},i:_,o:_,d(t){t&&d(n)}}}function ht(t,n,e){let r,{progress:a=.5}=n,{color:i="black"}=n;return t.$$set=t=>{"progress"in t&&e(2,a=t.progress),"color"in t&&e(0,i=t.color)},t.$$.update=()=>{4&t.$$.dirty&&e(1,r=`${Math.floor(100*a).toFixed(4)}%`)},[i,r,a]}class gt extends i{constructor(t){super(),o(this,t,ht,mt,s,{progress:2,color:0})}}function vt(t,n,e){const r=t.slice();return r[23]=n[e],r}function _t(t){let n,e,r,a,i,o,s,m,x,y,b,L,C,R,P,B,j,U,V,z,H,W,$,q,X,Y,Z,J,K,Q,tt,nt,et,rt,at,it,ot,st,lt,ct,ut,pt,dt,ft,mt,ht,gt,_t,xt,Lt,Ct,Rt,Bt,It,Ft,Gt,Dt="function"==typeof window.showDirectoryPicker&&function(t){let n,e;return{c(){n=c("option"),e=w("png sequence"),this.h()},l(t){n=u(t,"OPTION",{class:!0});var r=p(n);e=A(r,"png sequence"),r.forEach(d),this.h()},h(){n.__value="frames",n.value=n.__value,f(n,"class","svelte-fu4qjb")},m(t,r){g(t,n,r),M(n,e)},d(t){t&&d(n)}}}(),Nt={ctx:t,current:null,token:null,hasCatch:!1,pending:St,then:bt,catch:yt,value:22};l(Pt(),Nt);let Ot="gif"===t[5]&&Tt(t),kt=t[10],jt=[];for(let l=0;l<kt.length;l+=1)jt[l]=Et(vt(t,kt,l));let Ut={ctx:t,current:null,token:null,hasCatch:!1,pending:Mt,then:At,catch:wt,value:22};return l(Pt(),Ut),{c(){n=c("div"),e=c("div"),r=c("caption"),a=w("TokenID / ArtBlocks URL"),i=S(),o=c("input"),s=S(),m=c("div"),x=c("caption"),y=w("Format"),b=S(),L=c("select"),C=c("option"),R=w("gif"),P=c("option"),B=w("png still"),Dt&&Dt.c(),j=E(),Nt.block.c(),U=S(),Ot&&Ot.c(),V=S(),z=c("div"),H=c("caption"),W=w("Framerate"),$=S(),q=c("input"),X=S();for(let t=0;t<jt.length;t+=1)jt[t].c();Y=S(),Z=c("div"),J=c("caption"),K=w("Duration"),Q=S(),tt=c("input"),nt=S(),et=c("span"),rt=w("seconds"),at=S(),it=c("div"),ot=c("caption"),st=w("Dimensions"),lt=S(),ct=c("input"),ut=S(),pt=c("span"),dt=w("x"),ft=S(),mt=c("input"),ht=S(),gt=c("span"),_t=w("px "),xt=c("em"),Lt=w("(use 0 for 'auto')"),Ct=S(),Ut.block.c(),Rt=S(),Bt=c("button"),It=w("Render"),this.h()},l(t){n=u(t,"DIV",{class:!0});var l=p(n);e=u(l,"DIV",{class:!0});var c=p(e);r=u(c,"CAPTION",{class:!0});var f=p(r);a=A(f,"TokenID / ArtBlocks URL"),f.forEach(d),i=T(c),o=u(c,"INPUT",{class:!0,type:!0}),c.forEach(d),s=T(l),m=u(l,"DIV",{class:!0});var h=p(m);x=u(h,"CAPTION",{class:!0});var g=p(x);y=A(g,"Format"),g.forEach(d),b=T(h),L=u(h,"SELECT",{class:!0});var v=p(L);C=u(v,"OPTION",{class:!0});var _=p(C);R=A(_,"gif"),_.forEach(d),P=u(v,"OPTION",{class:!0});var S=p(P);B=A(S,"png still"),S.forEach(d),Dt&&Dt.l(v),j=E(),Nt.block.l(v),v.forEach(d),h.forEach(d),U=T(l),Ot&&Ot.l(l),V=T(l),z=u(l,"DIV",{class:!0});var w=p(z);H=u(w,"CAPTION",{class:!0});var M=p(H);W=A(M,"Framerate"),M.forEach(d),$=T(w),q=u(w,"INPUT",{class:!0,min:!0,step:!0,max:!0,type:!0}),X=T(w);for(let n=0;n<jt.length;n+=1)jt[n].l(w);
1w.forEach(d),Y=T(l),Z=u(l,"DIV",{class:!0});var I=p(Z);J=u(I,"CAPTION",{class:!0});var F=p(J);K=A(F,"Duration"),F.forEach(d),Q=T(I),tt=u(I,"INPUT",{class:!0,min:!0,step:!0,type:!0}),nt=T(I),et=u(I,"SPAN",{class:!0});var G=p(et);rt=A(G,"seconds"),G.forEach(d),I.forEach(d),at=T(l),it=u(l,"DIV",{class:!0});var D=p(it);ot=u(D,"CAPTION",{class:!0});var N=p(ot);st=A(N,"Dimensions"),N.forEach(d),lt=T(D),ct=u(D,"INPUT",{class:!0,min:!0,step:!0,max:!0,type:!0}),ut=T(D),pt=u(D,"SPAN",{class:!0});var O=p(pt);dt=A(O,"x"),O.forEach(d),ft=T(D),mt=u(D,"INPUT",{class:!0,min:!0,step:!0,max:!0,type:!0}),ht=T(D),gt=u(D,"SPAN",{class:!0});var k=p(gt);_t=A(k,"px "),xt=u(k,"EM",{class:!0});var vt=p(xt);Lt=A(vt,"(use 0 for 'auto')"),vt.forEach(d),k.forEach(d),D.forEach(d),Ct=T(l),Ut.block.l(l),Rt=T(l),Bt=u(l,"BUTTON",{class:!0});var yt=p(Bt);It=A(yt,"Render"),yt.forEach(d),l.forEach(d),this.h()},h(){f(r,"class","tab svelte-fu4qjb"),f(o,"class","token-id svelte-fu4qjb"),f(o,"type","text"),f(e,"class","field token-id-container svelte-fu4qjb"),f(x,"class","svelte-fu4qjb"),C.__value="gif",C.value=C.__value,f(C,"class","svelte-fu4qjb"),P.__value="png",P.value=P.__value,f(P,"class","svelte-fu4qjb"),f(L,"class","svelte-fu4qjb"),void 0===t[5]&&G((()=>t[15].call(L))),f(m,"class","field dimensions-container svelte-fu4qjb"),f(H,"class","svelte-fu4qjb"),f(q,"class","fps svelte-fu4qjb"),f(q,"min","1"),f(q,"step","1"),f(q,"max","60"),f(q,"type","number"),f(z,"class","field fps-container svelte-fu4qjb"),h(z,"hidden","inline"===t[5]||"png"===t[5]),f(J,"class","svelte-fu4qjb"),f(tt,"class","duration svelte-fu4qjb"),f(tt,"min","0"),f(tt,"step","0.1"),f(tt,"type","number"),f(et,"class","unit svelte-fu4qjb"),f(Z,"class","field duration-container svelte-fu4qjb"),h(Z,"hidden","inline"===t[5]||"png"===t[5]),f(ot,"class","svelte-fu4qjb"),f(ct,"class","dimensions svelte-fu4qjb"),f(ct,"min","0"),f(ct,"step","1"),f(ct,"max","4096"),f(ct,"type","number"),f(pt,"class","x-separator svelte-fu4qjb"),f(mt,"class","dimensions svelte-fu4qjb"),f(mt,"min","0"),f(mt,"step","1"),f(mt,"max","4096"),f(mt,"type","number"),f(xt,"class","svelte-fu4qjb"),f(gt,"class","unit svelte-fu4qjb"),f(it,"class","field dimensions-container svelte-fu4qjb"),f(Bt,"class","render button svelte-fu4qjb"),f(n,"class","settings svelte-fu4qjb")},m(l,c){g(l,n,c),M(n,e),M(e,r),M(r,a),M(e,i),M(e,o),D(o,t[2]),M(n,s),M(n,m),M(m,x),M(x,y),M(m,b),M(m,L),M(L,C),M(C,R),M(L,P),M(P,B),Dt&&Dt.m(L,null),M(L,j),Nt.block.m(L,Nt.anchor=null),Nt.mount=()=>L,Nt.anchor=null,N(L,t[5]),M(n,U),Ot&&Ot.m(n,null),M(n,V),M(n,z),M(z,H),M(H,W),M(z,$),M(z,q),D(q,t[0]),M(z,X);for(let t=0;t<jt.length;t+=1)jt[t].m(z,null);M(n,Y),M(n,Z),M(Z,J),M(J,K),M(Z,Q),M(Z,tt),D(tt,t[1]),M(Z,nt),M(Z,et),M(et,rt),M(n,at),M(n,it),M(it,ot),M(ot,st),M(it,lt),M(it,ct),D(ct,t[3]),M(it,ut),M(it,pt),M(pt,dt),M(it,ft),M(it,mt),D(mt,t[4]),M(it,ht),M(it,gt),M(gt,_t),M(gt,xt),M(xt,Lt),M(n,Ct),Ut.block.m(n,Ut.anchor=null),Ut.mount=()=>n,Ut.anchor=Rt,M(n,Rt),M(n,Bt),M(Bt,It),Ft||(Gt=[F(o,"input",t[14]),F(L,"change",t[15]),F(q,"input",t[17]),F(tt,"input",t[19]),F(ct,"input",t[20]),F(mt,"input",t[21]),F(Bt,"click",t[11])],Ft=!0)},p(e,r){if(t=e,4&r&&o.value!==t[2]&&D(o,t[2]),v(Nt,t,r),32&r&&N(L,t[5]),"gif"===t[5]?Ot?Ot.p(t,r):(Ot=Tt(t),Ot.c(),Ot.m(n,V)):Ot&&(Ot.d(1),Ot=null),1&r&&I(q.value)!==t[0]&&D(q,t[0]),1025&r){let n;for(kt=t[10],n=0;n<kt.length;n+=1){const e=vt(t,kt,n);jt[n]?jt[n].p(e,r):(jt[n]=Et(e),jt[n].c(),jt[n].m(z,null))}for(;n<jt.length;n+=1)jt[n].d(1);jt.length=kt.length}32&r&&h(z,"hidden","inline"===t[5]||"png"===t[5]),2&r&&I(tt.value)!==t[1]&&D(tt,t[1]),32&r&&h(Z,"hidden","inline"===t[5]||"png"===t[5]),8&r&&I(ct.value)!==t[3]&&D(ct,t[3]),16&r&&I(mt.value)!==t[4]&&D(mt,t[4]),v(Ut,t,r)},i:_,o:_,d(t){t&&d(n),Dt&&Dt.d(),Nt.block.d(),Nt.token=null,Nt=null,Ot&&Ot.d(),O(jt,t),Ut.block.d(),Ut.token=null,Ut=null,Ft=!1,k(Gt)}}}function xt(t){let n,e,r,a,i,o,s,l,m,h,v;const _=[Ct,Lt],x=[];function y(t,n){return"png"!==t[5]&&"inline"!==t[5]?0:1}return i=y(t),o=x[i]=_[i](t),l=new ft({props:{fps:t[0],dithering:t[6],totalFrames:"png"===t[5]?1:t[8],width:t[3],height:t[4],format:t[5],id:t[2]}}),l.$on("progress",t[13]),l.$on("finish",t[12]),{c(){n=c("div"),e=c("button"),r=w("Cancel"),a=S(),o.c(),s=S(),j(l.$$.fragment),this.h()},l(t){n=u(t,"DIV",{class:!0});var i=p(n);e=u(i,"BUTTON",{class:!0});var c=p(e);
1r=A(c,"Cancel"),c.forEach(d),a=T(i),o.l(i),i.forEach(d),s=T(t),U(l.$$.fragment,t),this.h()},h(){f(e,"class","button svelte-fu4qjb"),f(n,"class","row svelte-fu4qjb")},m(o,c){g(o,n,c),M(n,e),M(e,r),M(n,a),x[i].m(n,null),g(o,s,c),V(l,o,c),m=!0,h||(v=F(e,"click",t[12]),h=!0)},p(t,e){let r=i;i=y(t),i===r?x[i].p(t,e):(P(),L(x[r],1,1,(()=>{x[r]=null})),C(),o=x[i],o?o.p(t,e):(o=x[i]=_[i](t),o.c()),R(o,1),o.m(n,null));const a={};1&e&&(a.fps=t[0]),64&e&&(a.dithering=t[6]),288&e&&(a.totalFrames="png"===t[5]?1:t[8]),8&e&&(a.width=t[3]),16&e&&(a.height=t[4]),32&e&&(a.format=t[5]),4&e&&(a.id=t[2]),l.$set(a)},i(t){m||(R(o),R(l.$$.fragment,t),m=!0)},o(t){L(o),L(l.$$.fragment,t),m=!1},d(t){t&&d(n),x[i].d(),t&&d(s),z(l,t),h=!1,v()}}}function yt(t){return{c:_,l:_,m:_,p:_,d:_}}function bt(t){let n,e=t[22]&&function(t){let n,e;return{c(){n=c("option"),e=w("mp4"),this.h()},l(t){n=u(t,"OPTION",{class:!0});var r=p(n);e=A(r,"mp4"),r.forEach(d),this.h()},h(){n.__value="mp4",n.value=n.__value,f(n,"class","svelte-fu4qjb")},m(t,r){g(t,n,r),M(n,e)},d(t){t&&d(n)}}}();return{c(){e&&e.c(),n=E()},l(t){e&&e.l(t),n=E()},m(t,r){e&&e.m(t,r),g(t,n,r)},p:_,d(t){e&&e.d(t),t&&d(n)}}}function St(t){return{c:_,l:_,m:_,p:_,d:_}}function Tt(t){let n,e,r,a,i,o,s,l,m;return{c(){n=c("div"),e=c("caption"),r=w("Dithering"),a=S(),i=c("label"),o=c("input"),s=w("\n slower encoding, but higher quality gradients"),this.h()},l(t){n=u(t,"DIV",{class:!0});var l=p(n);e=u(l,"CAPTION",{class:!0});var c=p(e);r=A(c,"Dithering"),c.forEach(d),a=T(l),i=u(l,"LABEL",{class:!0});var f=p(i);o=u(f,"INPUT",{type:!0,class:!0}),s=A(f,"\n slower encoding, but higher quality gradients"),f.forEach(d),l.forEach(d),this.h()},h(){f(e,"class","svelte-fu4qjb"),f(o,"type","checkbox"),f(o,"class","svelte-fu4qjb"),f(i,"class","dither-box svelte-fu4qjb"),f(n,"class","field dimensions-container svelte-fu4qjb")},m(c,u){g(c,n,u),M(n,e),M(e,r),M(n,a),M(n,i),M(i,o),o.checked=t[6],M(i,s),l||(m=F(o,"change",t[16]),l=!0)},p(t,n){64&n&&(o.checked=t[6])},d(t){t&&d(n),l=!1,m()}}}function Et(t){let n,e,r,a,i=t[23]+"";function o(){return t[18](t[23])}return{c(){n=c("button"),e=w(i),this.h()},l(t){n=u(t,"BUTTON",{class:!0});var r=p(n);e=A(r,i),r.forEach(d),this.h()},h(){f(n,"class","svelte-fu4qjb")},m(t,i){g(t,n,i),M(n,e),r||(a=F(n,"click",o),r=!0)},p(n,e){t=n},d(t){t&&d(n),r=!1,a()}}}function wt(t){return{c:_,l:_,m:_,p:_,d:_}}function At(t){let n,e=!t[22]&&function(t){let n,e;return{c(){n=c("p"),e=w('Note: MP4 support disabled, please use Chrome with "Experimental Web\n Platform Features" enabled in chrome://flags.'),this.h()},l(t){n=u(t,"P",{class:!0});var r=p(n);e=A(r,'Note: MP4 support disabled, please use Chrome with "Experimental Web\n Platform Features" enabled in chrome://flags.'),r.forEach(d),this.h()},h(){f(n,"class","mp4-support svelte-fu4qjb")},m(t,r){g(t,n,r),M(n,e)},d(t){t&&d(n)}}}();return{c(){e&&e.c(),n=E()},l(t){e&&e.l(t),n=E()},m(t,r){e&&e.m(t,r),g(t,n,r)},p:_,d(t){e&&e.d(t),t&&d(n)}}}function Mt(t){return{c:_,l:_,m:_,p:_,d:_}}function Lt(t){let n,e;return{c(){n=c("div"),e=w("Rendering..."),this.h()},l(t){n=u(t,"DIV",{class:!0});var r=p(n);e=A(r,"Rendering..."),r.forEach(d),this.h()},h(){f(n,"class","rendering svelte-fu4qjb")},m(t,r){g(t,n,r),M(n,e)},p:_,i:_,o:_,d(t){t&&d(n)}}}function Ct(t){let n,e;return n=new gt({props:{progress:t[9]}}),{c(){j(n.$$.fragment)},l(t){U(n.$$.fragment,t)},m(t,r){V(n,t,r),e=!0},p(t,e){const r={};512&e&&(r.progress=t[9]),n.$set(r)},i(t){e||(R(n.$$.fragment,t),e=!0)},o(t){L(n.$$.fragment,t),e=!1},d(t){z(n,t)}}}function Rt(t){let n,e,r,a,i,o,s,l,m,h,v,_,x,y,b,E,B,I,F,G;const D=[xt,_t],N=[];function O(t,n){return t[7]?0:1}return I=O(t),F=N[I]=D[I](t),{c(){n=c("main"),e=c("div"),r=c("h1"),a=w("ArtBlocks Recorder"),i=S(),o=c("p"),s=w("Enter your configuration and click the "),l=c("strong"),m=w("Render"),h=w(" button to export\n the high quality media."),v=S(),_=c("p"),x=w("Made by\n "),y=c("a"),b=w("@mattdesl"),E=w("."),B=S(),F.c(),this.h()},l(t){n=u(t,"MAIN",{class:!0});var c=p(n);e=u(c,"DIV",{class:!0});var f=p(e);r=u(f,"H1",{class:!0});var g=p(r);a=A(g,"ArtBlocks Recorder"),g.forEach(d),i=T(f),o=u(f,"P",{class:!0});var S=p(o);s=A(S,"Enter your configuration and click the "),l=u(S,"STRONG",{class:!0});var w=p(l);
1m=A(w,"Render"),w.forEach(d),h=A(S," button to export\n the high quality media."),S.forEach(d),v=T(f),_=u(f,"P",{class:!0});var M=p(_);x=A(M,"Made by\n "),y=u(M,"A",{target:!0,href:!0,class:!0});var L=p(y);b=A(L,"@mattdesl"),L.forEach(d),E=A(M,"."),M.forEach(d),f.forEach(d),B=T(c),F.l(c),c.forEach(d),this.h()},h(){f(r,"class","svelte-fu4qjb"),f(l,"class","svelte-fu4qjb"),f(o,"class","svelte-fu4qjb"),f(y,"target","_blank"),f(y,"href","https://twitter.com/mattdesl"),f(y,"class","svelte-fu4qjb"),f(_,"class","svelte-fu4qjb"),f(e,"class","info svelte-fu4qjb"),f(n,"class","svelte-fu4qjb")},m(t,c){g(t,n,c),M(n,e),M(e,r),M(r,a),M(e,i),M(e,o),M(o,s),M(o,l),M(l,m),M(o,h),M(e,v),M(e,_),M(_,x),M(_,y),M(y,b),M(_,E),M(n,B),N[I].m(n,null),G=!0},p(t,[e]){let r=I;I=O(t),I===r?N[I].p(t,e):(P(),L(N[r],1,1,(()=>{N[r]=null})),C(),F=N[I],F?F.p(t,e):(F=N[I]=D[I](t),F.c()),R(F,1),F.m(n,null))},i(t){G||(R(F),G=!0)},o(t){L(F),G=!1},d(t){t&&d(n),N[I].d()}}}async function Pt(){const{isWebCodecsSupported:t}=await window.MP4Encoder;return t()}function Bt(t,n,e){let r,a="399000000",i=30,o=4,s=512,l=512,c="gif",u=!1,p=!1,d=0;return t.$$.update=()=>{3&t.$$.dirty&&e(8,r=Math.ceil(o*i))},[i,o,a,s,l,c,u,p,r,d,[24,25,30,50,60],function(){e(9,d=0),e(7,p=!0)},function(){e(7,p=!1)},({detail:t})=>{e(9,d=t)},function(){a=this.value,e(2,a)},function(){c=B(this),e(5,c)},function(){u=this.checked,e(6,u)},function(){i=I(this.value),e(0,i)},t=>{e(0,i=t)},function(){o=I(this.value),e(1,o)},function(){s=I(this.value),e(3,s)},function(){l=I(this.value),e(4,l)}]}new class extends i{constructor(t){super(),o(this,t,Bt,Rt,s,{})}}({target:document.body});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.