diff --git a/dist/main.min.js b/dist/main.min.js index 6005e14..a736e60 100644 --- a/dist/main.min.js +++ b/dist/main.min.js @@ -1,8 +1,8 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.MeshCat=e():t.MeshCat=e()}(window,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=47)}([function(t,e,n){var r=e.global=n(45),i=e.hasBuffer=r&&!!r.isBuffer,o=e.hasArrayBuffer="undefined"!=typeof ArrayBuffer,a=e.isArray=n(3);e.isArrayBuffer=o?function(t){return t instanceof ArrayBuffer||f(t)}:g;var s=e.isBuffer=i?r.isBuffer:g,c=e.isView=o?ArrayBuffer.isView||v("ArrayBuffer","buffer"):g;e.alloc=p,e.concat=function(t,n){n||(n=0,Array.prototype.forEach.call(t,function(t){n+=t.length}));var r=this!==e&&this||t[0],i=p.call(r,n),o=0;return Array.prototype.forEach.call(t,function(t){o+=d.copy.call(t,i,o)}),i},e.from=function(t){return"string"==typeof t?function(t){var e=3*t.length,n=p.call(this,e),r=d.write.call(n,t);e!==r&&(n=d.slice.call(n,0,r));return n}.call(this,t):m(this).from(t)};var u=e.Array=n(43),l=e.Buffer=n(42),h=e.Uint8Array=n(41),d=e.prototype=n(6);function p(t){return m(this).alloc(t)}var f=v("ArrayBuffer");function m(t){return s(t)?l:c(t)?h:a(t)?u:i?l:o?h:u}function g(){return!1}function v(t,e){return t="[object "+t+"]",function(n){return null!=n&&{}.toString.call(e?n[e]:n)===t}}},function(t,e,n){"use strict";function r(){}n.r(e),n.d(e,"WebGLRenderTargetCube",function(){return sn}),n.d(e,"WebGLRenderTarget",function(){return an}),n.d(e,"WebGLRenderer",function(){return Di}),n.d(e,"ShaderLib",function(){return _n}),n.d(e,"UniformsLib",function(){return bn}),n.d(e,"UniformsUtils",function(){return mn}),n.d(e,"ShaderChunk",function(){return fn}),n.d(e,"FogExp2",function(){return Fi}),n.d(e,"Fog",function(){return zi}),n.d(e,"Scene",function(){return Gi}),n.d(e,"Sprite",function(){return ji}),n.d(e,"LOD",function(){return Vi}),n.d(e,"SkinnedMesh",function(){return Xi}),n.d(e,"Skeleton",function(){return Wi}),n.d(e,"Bone",function(){return qi}),n.d(e,"Mesh",function(){return mr}),n.d(e,"LineSegments",function(){return Zi}),n.d(e,"LineLoop",function(){return Qi}),n.d(e,"Line",function(){return Ji}),n.d(e,"Points",function(){return $i}),n.d(e,"Group",function(){return to}),n.d(e,"VideoTexture",function(){return eo}),n.d(e,"DataTexture",function(){return cn}),n.d(e,"CompressedTexture",function(){return no}),n.d(e,"CubeTexture",function(){return vr}),n.d(e,"CanvasTexture",function(){return Pi}),n.d(e,"DepthTexture",function(){return ro}),n.d(e,"Texture",function(){return rn}),n.d(e,"CompressedTextureLoader",function(){return Pa}),n.d(e,"DataTextureLoader",function(){return Na}),n.d(e,"CubeTextureLoader",function(){return Ia}),n.d(e,"TextureLoader",function(){return ka}),n.d(e,"ObjectLoader",function(){return Fs}),n.d(e,"MaterialLoader",function(){return Rs}),n.d(e,"BufferGeometryLoader",function(){return Cs}),n.d(e,"DefaultLoadingManager",function(){return La}),n.d(e,"LoadingManager",function(){return Aa}),n.d(e,"JSONLoader",function(){return Ds}),n.d(e,"ImageLoader",function(){return Oa}),n.d(e,"ImageBitmapLoader",function(){return Vs}),n.d(e,"FontLoader",function(){return Ys}),n.d(e,"FileLoader",function(){return Ca}),n.d(e,"Loader",function(){return Us}),n.d(e,"LoaderUtils",function(){return Bs}),n.d(e,"Cache",function(){return Sa}),n.d(e,"AudioLoader",function(){return ac}),n.d(e,"SpotLightShadow",function(){return cs}),n.d(e,"SpotLight",function(){return us}),n.d(e,"PointLight",function(){return ls}),n.d(e,"RectAreaLight",function(){return fs}),n.d(e,"HemisphereLight",function(){return as}),n.d(e,"DirectionalLightShadow",function(){return hs}),n.d(e,"DirectionalLight",function(){return ds}),n.d(e,"AmbientLight",function(){return ps}),n.d(e,"LightShadow",function(){return ss}),n.d(e,"Light",function(){return os}),n.d(e,"StereoCamera",function(){return sc}),n.d(e,"PerspectiveCamera",function(){return ki}),n.d(e,"OrthographicCamera",function(){return Pn}),n.d(e,"CubeCamera",function(){return cc}),n.d(e,"ArrayCamera",function(){return Ui}),n.d(e,"Camera",function(){return Cn}),n.d(e,"AudioListener",function(){return uc}),n.d(e,"PositionalAudio",function(){return hc}),n.d(e,"AudioContext",function(){return oc}),n.d(e,"AudioAnalyser",function(){return dc}),n.d(e,"Audio",function(){return lc}),n.d(e,"VectorKeyframeTrack",function(){return As}),n.d(e,"StringKeyframeTrack",function(){return ms}),n.d(e,"QuaternionKeyframeTrack",function(){return bs}),n.d(e,"NumberKeyframeTrack",function(){return xs}),n.d(e,"ColorKeyframeTrack",function(){return _s}),n.d(e,"BooleanKeyframeTrack",function(){return gs}),n.d(e,"PropertyMixer",function(){return pc}),n.d(e,"PropertyBinding",function(){return Lc}),n.d(e,"KeyframeTrack",function(){return Ss}),n.d(e,"AnimationUtils",function(){return Ts}),n.d(e,"AnimationObjectGroup",function(){return Rc}),n.d(e,"AnimationMixer",function(){return Pc}),n.d(e,"AnimationClip",function(){return Ls}),n.d(e,"Uniform",function(){return Nc}),n.d(e,"InstancedBufferGeometry",function(){return Oc}),n.d(e,"BufferGeometry",function(){return Zn}),n.d(e,"Geometry",function(){return Un}),n.d(e,"InterleavedBufferAttribute",function(){return Ic}),n.d(e,"InstancedInterleavedBuffer",function(){return Uc}),n.d(e,"InterleavedBuffer",function(){return kc}),n.d(e,"InstancedBufferAttribute",function(){return Bc}),n.d(e,"Face3",function(){return Nn}),n.d(e,"Object3D",function(){return Rn}),n.d(e,"Raycaster",function(){return Dc}),n.d(e,"Layers",function(){return En}),n.d(e,"EventDispatcher",function(){return r}),n.d(e,"Clock",function(){return Gc}),n.d(e,"QuaternionLinearInterpolant",function(){return ys}),n.d(e,"LinearInterpolant",function(){return Es}),n.d(e,"DiscreteInterpolant",function(){return Ms}),n.d(e,"CubicInterpolant",function(){return ws}),n.d(e,"Interpolant",function(){return vs}),n.d(e,"Triangle",function(){return fr}),n.d(e,"Math",function(){return Ve}),n.d(e,"Spherical",function(){return Hc}),n.d(e,"Cylindrical",function(){return jc}),n.d(e,"Plane",function(){return hn}),n.d(e,"Frustum",function(){return dn}),n.d(e,"Sphere",function(){return ln}),n.d(e,"Ray",function(){return dr}),n.d(e,"Matrix4",function(){return qe}),n.d(e,"Matrix3",function(){return Je}),n.d(e,"Box3",function(){return un}),n.d(e,"Box2",function(){return Vc}),n.d(e,"Line3",function(){return pr}),n.d(e,"Euler",function(){return wn}),n.d(e,"Vector4",function(){return on}),n.d(e,"Vector3",function(){return Ye}),n.d(e,"Vector2",function(){return We}),n.d(e,"Quaternion",function(){return Xe}),n.d(e,"Color",function(){return vn}),n.d(e,"ImmediateRenderObject",function(){return Wc}),n.d(e,"VertexNormalsHelper",function(){return qc}),n.d(e,"SpotLightHelper",function(){return Xc}),n.d(e,"SkeletonHelper",function(){return Yc}),n.d(e,"PointLightHelper",function(){return Jc}),n.d(e,"RectAreaLightHelper",function(){return Zc}),n.d(e,"HemisphereLightHelper",function(){return Qc}),n.d(e,"GridHelper",function(){return Kc}),n.d(e,"PolarGridHelper",function(){return $c}),n.d(e,"FaceNormalsHelper",function(){return tu}),n.d(e,"DirectionalLightHelper",function(){return eu}),n.d(e,"CameraHelper",function(){return nu}),n.d(e,"BoxHelper",function(){return ru}),n.d(e,"Box3Helper",function(){return iu}),n.d(e,"PlaneHelper",function(){return ou}),n.d(e,"ArrowHelper",function(){return au}),n.d(e,"AxesHelper",function(){return su}),n.d(e,"Shape",function(){return is}),n.d(e,"Path",function(){return rs}),n.d(e,"ShapePath",function(){return Ws}),n.d(e,"Font",function(){return qs}),n.d(e,"CurvePath",function(){return ns}),n.d(e,"Curve",function(){return Ua}),n.d(e,"ShapeUtils",function(){return qo}),n.d(e,"WebGLUtils",function(){return Ii}),n.d(e,"WireframeGeometry",function(){return io}),n.d(e,"ParametricGeometry",function(){return oo}),n.d(e,"ParametricBufferGeometry",function(){return ao}),n.d(e,"TetrahedronGeometry",function(){return uo}),n.d(e,"TetrahedronBufferGeometry",function(){return lo}),n.d(e,"OctahedronGeometry",function(){return ho}),n.d(e,"OctahedronBufferGeometry",function(){return po}),n.d(e,"IcosahedronGeometry",function(){return fo}),n.d(e,"IcosahedronBufferGeometry",function(){return mo}),n.d(e,"DodecahedronGeometry",function(){return go}),n.d(e,"DodecahedronBufferGeometry",function(){return vo}),n.d(e,"PolyhedronGeometry",function(){return so}),n.d(e,"PolyhedronBufferGeometry",function(){return co}),n.d(e,"TubeGeometry",function(){return yo}),n.d(e,"TubeBufferGeometry",function(){return bo}),n.d(e,"TorusKnotGeometry",function(){return _o}),n.d(e,"TorusKnotBufferGeometry",function(){return xo}),n.d(e,"TorusGeometry",function(){return wo}),n.d(e,"TorusBufferGeometry",function(){return Eo}),n.d(e,"TextGeometry",function(){return Qo}),n.d(e,"TextBufferGeometry",function(){return Ko}),n.d(e,"SphereGeometry",function(){return $o}),n.d(e,"SphereBufferGeometry",function(){return ta}),n.d(e,"RingGeometry",function(){return ea}),n.d(e,"RingBufferGeometry",function(){return na}),n.d(e,"PlaneGeometry",function(){return $n}),n.d(e,"PlaneBufferGeometry",function(){return tr}),n.d(e,"LatheGeometry",function(){return ra}),n.d(e,"LatheBufferGeometry",function(){return ia}),n.d(e,"ShapeGeometry",function(){return oa}),n.d(e,"ShapeBufferGeometry",function(){return aa}),n.d(e,"ExtrudeGeometry",function(){return Jo}),n.d(e,"ExtrudeBufferGeometry",function(){return Zo}),n.d(e,"EdgesGeometry",function(){return ca}),n.d(e,"ConeGeometry",function(){return ha}),n.d(e,"ConeBufferGeometry",function(){return da}),n.d(e,"CylinderGeometry",function(){return ua}),n.d(e,"CylinderBufferGeometry",function(){return la}),n.d(e,"CircleGeometry",function(){return pa}),n.d(e,"CircleBufferGeometry",function(){return fa}),n.d(e,"BoxGeometry",function(){return Qn}),n.d(e,"BoxBufferGeometry",function(){return Kn}),n.d(e,"ShadowMaterial",function(){return ga}),n.d(e,"SpriteMaterial",function(){return Hi}),n.d(e,"RawShaderMaterial",function(){return va}),n.d(e,"ShaderMaterial",function(){return hr}),n.d(e,"PointsMaterial",function(){return Ki}),n.d(e,"MeshPhysicalMaterial",function(){return ba}),n.d(e,"MeshStandardMaterial",function(){return ya}),n.d(e,"MeshPhongMaterial",function(){return _a}),n.d(e,"MeshToonMaterial",function(){return xa}),n.d(e,"MeshNormalMaterial",function(){return wa}),n.d(e,"MeshLambertMaterial",function(){return Ea}),n.d(e,"MeshDepthMaterial",function(){return Li}),n.d(e,"MeshDistanceMaterial",function(){return Ri}),n.d(e,"MeshBasicMaterial",function(){return lr}),n.d(e,"LineDashedMaterial",function(){return Ma}),n.d(e,"LineBasicMaterial",function(){return Yi}),n.d(e,"Material",function(){return ur}),n.d(e,"Float64BufferAttribute",function(){return qn}),n.d(e,"Float32BufferAttribute",function(){return Wn}),n.d(e,"Uint32BufferAttribute",function(){return Vn}),n.d(e,"Int32BufferAttribute",function(){return jn}),n.d(e,"Uint16BufferAttribute",function(){return Hn}),n.d(e,"Int16BufferAttribute",function(){return Gn}),n.d(e,"Uint8ClampedBufferAttribute",function(){return zn}),n.d(e,"Uint8BufferAttribute",function(){return Fn}),n.d(e,"Int8BufferAttribute",function(){return Dn}),n.d(e,"BufferAttribute",function(){return Bn}),n.d(e,"ArcCurve",function(){return Da}),n.d(e,"CatmullRomCurve3",function(){return Va}),n.d(e,"CubicBezierCurve",function(){return Ya}),n.d(e,"CubicBezierCurve3",function(){return Ja}),n.d(e,"EllipseCurve",function(){return Ba}),n.d(e,"LineCurve",function(){return Za}),n.d(e,"LineCurve3",function(){return Qa}),n.d(e,"QuadraticBezierCurve",function(){return Ka}),n.d(e,"QuadraticBezierCurve3",function(){return $a}),n.d(e,"SplineCurve",function(){return ts}),n.d(e,"REVISION",function(){return p}),n.d(e,"MOUSE",function(){return f}),n.d(e,"CullFaceNone",function(){return m}),n.d(e,"CullFaceBack",function(){return g}),n.d(e,"CullFaceFront",function(){return v}),n.d(e,"CullFaceFrontBack",function(){return y}),n.d(e,"FrontFaceDirectionCW",function(){return b}),n.d(e,"FrontFaceDirectionCCW",function(){return _}),n.d(e,"BasicShadowMap",function(){return x}),n.d(e,"PCFShadowMap",function(){return w}),n.d(e,"PCFSoftShadowMap",function(){return E}),n.d(e,"FrontSide",function(){return M}),n.d(e,"BackSide",function(){return T}),n.d(e,"DoubleSide",function(){return S}),n.d(e,"FlatShading",function(){return A}),n.d(e,"SmoothShading",function(){return L}),n.d(e,"NoColors",function(){return R}),n.d(e,"FaceColors",function(){return C}),n.d(e,"VertexColors",function(){return P}),n.d(e,"NoBlending",function(){return N}),n.d(e,"NormalBlending",function(){return O}),n.d(e,"AdditiveBlending",function(){return I}),n.d(e,"SubtractiveBlending",function(){return k}),n.d(e,"MultiplyBlending",function(){return U}),n.d(e,"CustomBlending",function(){return B}),n.d(e,"AddEquation",function(){return D}),n.d(e,"SubtractEquation",function(){return F}),n.d(e,"ReverseSubtractEquation",function(){return z}),n.d(e,"MinEquation",function(){return G}),n.d(e,"MaxEquation",function(){return H}),n.d(e,"ZeroFactor",function(){return j}),n.d(e,"OneFactor",function(){return V}),n.d(e,"SrcColorFactor",function(){return W}),n.d(e,"OneMinusSrcColorFactor",function(){return q}),n.d(e,"SrcAlphaFactor",function(){return X}),n.d(e,"OneMinusSrcAlphaFactor",function(){return Y}),n.d(e,"DstAlphaFactor",function(){return J}),n.d(e,"OneMinusDstAlphaFactor",function(){return Z}),n.d(e,"DstColorFactor",function(){return Q}),n.d(e,"OneMinusDstColorFactor",function(){return K}),n.d(e,"SrcAlphaSaturateFactor",function(){return $}),n.d(e,"NeverDepth",function(){return tt}),n.d(e,"AlwaysDepth",function(){return et}),n.d(e,"LessDepth",function(){return nt}),n.d(e,"LessEqualDepth",function(){return rt}),n.d(e,"EqualDepth",function(){return it}),n.d(e,"GreaterEqualDepth",function(){return ot}),n.d(e,"GreaterDepth",function(){return at}),n.d(e,"NotEqualDepth",function(){return st}),n.d(e,"MultiplyOperation",function(){return ct}),n.d(e,"MixOperation",function(){return ut}),n.d(e,"AddOperation",function(){return lt}),n.d(e,"NoToneMapping",function(){return ht}),n.d(e,"LinearToneMapping",function(){return dt}),n.d(e,"ReinhardToneMapping",function(){return pt}),n.d(e,"Uncharted2ToneMapping",function(){return ft}),n.d(e,"CineonToneMapping",function(){return mt}),n.d(e,"UVMapping",function(){return gt}),n.d(e,"CubeReflectionMapping",function(){return vt}),n.d(e,"CubeRefractionMapping",function(){return yt}),n.d(e,"EquirectangularReflectionMapping",function(){return bt}),n.d(e,"EquirectangularRefractionMapping",function(){return _t}),n.d(e,"SphericalReflectionMapping",function(){return xt}),n.d(e,"CubeUVReflectionMapping",function(){return wt}),n.d(e,"CubeUVRefractionMapping",function(){return Et}),n.d(e,"RepeatWrapping",function(){return Mt}),n.d(e,"ClampToEdgeWrapping",function(){return Tt}),n.d(e,"MirroredRepeatWrapping",function(){return St}),n.d(e,"NearestFilter",function(){return At}),n.d(e,"NearestMipMapNearestFilter",function(){return Lt}),n.d(e,"NearestMipMapLinearFilter",function(){return Rt}),n.d(e,"LinearFilter",function(){return Ct}),n.d(e,"LinearMipMapNearestFilter",function(){return Pt}),n.d(e,"LinearMipMapLinearFilter",function(){return Nt}),n.d(e,"UnsignedByteType",function(){return Ot}),n.d(e,"ByteType",function(){return It}),n.d(e,"ShortType",function(){return kt}),n.d(e,"UnsignedShortType",function(){return Ut}),n.d(e,"IntType",function(){return Bt}),n.d(e,"UnsignedIntType",function(){return Dt}),n.d(e,"FloatType",function(){return Ft}),n.d(e,"HalfFloatType",function(){return zt}),n.d(e,"UnsignedShort4444Type",function(){return Gt}),n.d(e,"UnsignedShort5551Type",function(){return Ht}),n.d(e,"UnsignedShort565Type",function(){return jt}),n.d(e,"UnsignedInt248Type",function(){return Vt}),n.d(e,"AlphaFormat",function(){return Wt}),n.d(e,"RGBFormat",function(){return qt}),n.d(e,"RGBAFormat",function(){return Xt}),n.d(e,"LuminanceFormat",function(){return Yt}),n.d(e,"LuminanceAlphaFormat",function(){return Jt}),n.d(e,"RGBEFormat",function(){return Zt}),n.d(e,"DepthFormat",function(){return Qt}),n.d(e,"DepthStencilFormat",function(){return Kt}),n.d(e,"RGB_S3TC_DXT1_Format",function(){return $t}),n.d(e,"RGBA_S3TC_DXT1_Format",function(){return te}),n.d(e,"RGBA_S3TC_DXT3_Format",function(){return ee}),n.d(e,"RGBA_S3TC_DXT5_Format",function(){return ne}),n.d(e,"RGB_PVRTC_4BPPV1_Format",function(){return re}),n.d(e,"RGB_PVRTC_2BPPV1_Format",function(){return ie}),n.d(e,"RGBA_PVRTC_4BPPV1_Format",function(){return oe}),n.d(e,"RGBA_PVRTC_2BPPV1_Format",function(){return ae}),n.d(e,"RGB_ETC1_Format",function(){return se}),n.d(e,"RGBA_ASTC_4x4_Format",function(){return ce}),n.d(e,"RGBA_ASTC_5x4_Format",function(){return ue}),n.d(e,"RGBA_ASTC_5x5_Format",function(){return le}),n.d(e,"RGBA_ASTC_6x5_Format",function(){return he}),n.d(e,"RGBA_ASTC_6x6_Format",function(){return de}),n.d(e,"RGBA_ASTC_8x5_Format",function(){return pe}),n.d(e,"RGBA_ASTC_8x6_Format",function(){return fe}),n.d(e,"RGBA_ASTC_8x8_Format",function(){return me}),n.d(e,"RGBA_ASTC_10x5_Format",function(){return ge}),n.d(e,"RGBA_ASTC_10x6_Format",function(){return ve}),n.d(e,"RGBA_ASTC_10x8_Format",function(){return ye}),n.d(e,"RGBA_ASTC_10x10_Format",function(){return be}),n.d(e,"RGBA_ASTC_12x10_Format",function(){return _e}),n.d(e,"RGBA_ASTC_12x12_Format",function(){return xe}),n.d(e,"LoopOnce",function(){return we}),n.d(e,"LoopRepeat",function(){return Ee}),n.d(e,"LoopPingPong",function(){return Me}),n.d(e,"InterpolateDiscrete",function(){return Te}),n.d(e,"InterpolateLinear",function(){return Se}),n.d(e,"InterpolateSmooth",function(){return Ae}),n.d(e,"ZeroCurvatureEnding",function(){return Le}),n.d(e,"ZeroSlopeEnding",function(){return Re}),n.d(e,"WrapAroundEnding",function(){return Ce}),n.d(e,"TrianglesDrawMode",function(){return Pe}),n.d(e,"TriangleStripDrawMode",function(){return Ne}),n.d(e,"TriangleFanDrawMode",function(){return Oe}),n.d(e,"LinearEncoding",function(){return Ie}),n.d(e,"sRGBEncoding",function(){return ke}),n.d(e,"GammaEncoding",function(){return Ue}),n.d(e,"RGBEEncoding",function(){return Be}),n.d(e,"LogLuvEncoding",function(){return De}),n.d(e,"RGBM7Encoding",function(){return Fe}),n.d(e,"RGBM16Encoding",function(){return ze}),n.d(e,"RGBDEncoding",function(){return Ge}),n.d(e,"BasicDepthPacking",function(){return He}),n.d(e,"RGBADepthPacking",function(){return je}),n.d(e,"CubeGeometry",function(){return Qn}),n.d(e,"Face4",function(){return cu}),n.d(e,"LineStrip",function(){return uu}),n.d(e,"LinePieces",function(){return lu}),n.d(e,"MeshFaceMaterial",function(){return hu}),n.d(e,"MultiMaterial",function(){return du}),n.d(e,"PointCloud",function(){return pu}),n.d(e,"Particle",function(){return fu}),n.d(e,"ParticleSystem",function(){return mu}),n.d(e,"PointCloudMaterial",function(){return gu}),n.d(e,"ParticleBasicMaterial",function(){return vu}),n.d(e,"ParticleSystemMaterial",function(){return yu}),n.d(e,"Vertex",function(){return bu}),n.d(e,"DynamicBufferAttribute",function(){return _u}),n.d(e,"Int8Attribute",function(){return xu}),n.d(e,"Uint8Attribute",function(){return wu}),n.d(e,"Uint8ClampedAttribute",function(){return Eu}),n.d(e,"Int16Attribute",function(){return Mu}),n.d(e,"Uint16Attribute",function(){return Tu}),n.d(e,"Int32Attribute",function(){return Su}),n.d(e,"Uint32Attribute",function(){return Au}),n.d(e,"Float32Attribute",function(){return Lu}),n.d(e,"Float64Attribute",function(){return Ru}),n.d(e,"ClosedSplineCurve3",function(){return Cu}),n.d(e,"SplineCurve3",function(){return Pu}),n.d(e,"Spline",function(){return Nu}),n.d(e,"AxisHelper",function(){return Ou}),n.d(e,"BoundingBoxHelper",function(){return Iu}),n.d(e,"EdgesHelper",function(){return ku}),n.d(e,"WireframeHelper",function(){return Uu}),n.d(e,"XHRLoader",function(){return Bu}),n.d(e,"BinaryTextureLoader",function(){return Du}),n.d(e,"GeometryUtils",function(){return Fu}),n.d(e,"ImageUtils",function(){return zu}),n.d(e,"Projector",function(){return Gu}),n.d(e,"CanvasRenderer",function(){return Hu}),n.d(e,"SceneUtils",function(){return ju}),n.d(e,"LensFlare",function(){return Vu}),void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t}),void 0===Math.sign&&(Math.sign=function(t){return t<0?-1:t>0?1:+t}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n>8&255]+t[e>>16&255]+t[e>>24&255]+"-"+t[255&n]+t[n>>8&255]+"-"+t[n>>16&15|64]+t[n>>24&255]+"-"+t[63&r|128]+t[r>>8&255]+"-"+t[r>>16&255]+t[r>>24&255]+t[255&i]+t[i>>8&255]+t[i>>16&255]+t[i>>24&255]}}(),clamp:function(t,e,n){return Math.max(e,Math.min(n,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)},lerp:function(t,e,n){return(1-n)*t+n*e},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*Ve.DEG2RAD},radToDeg:function(t){return t*Ve.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}};function We(t,e){this.x=t||0,this.y=e||0}function qe(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function Xe(t,e,n,r){this._x=t||0,this._y=e||0,this._z=n||0,this._w=void 0!==r?r:1}function Ye(t,e,n){this.x=t||0,this.y=e||0,this.z=n||0}function Je(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}Object.defineProperties(We.prototype,{width:{get:function(){return this.x},set:function(t){this.x=t}},height:{get:function(){return this.y},set:function(t){this.y=t}}}),Object.assign(We.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},applyMatrix3:function(t){var e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:(i=new We,o=new We,function(t,e){return i.set(t,t),o.set(e,e),this.clamp(i,o)}),clampLength:function(t,e){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,n=this.y-t.y;return e*e+n*n},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var n=Math.cos(e),r=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*n-o*r+t.x,this.y=i*r+o*n+t.y,this}}),Object.assign(qe.prototype,{isMatrix4:!0,set:function(t,e,n,r,i,o,a,s,c,u,l,h,d,p,f,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=r,g[1]=i,g[5]=o,g[9]=a,g[13]=s,g[2]=c,g[6]=u,g[10]=l,g[14]=h,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new qe).fromArray(this.elements)},copy:function(t){var e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this},copyPosition:function(t){var e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this},extractBasis:function(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this},extractRotation:(h=new Ye,function(t){var e=this.elements,n=t.elements,r=1/h.setFromMatrixColumn(t,0).length(),i=1/h.setFromMatrixColumn(t,1).length(),o=1/h.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[4]=n[4]*i,e[5]=n[5]*i,e[6]=n[6]*i,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,this}),makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,n=t.x,r=t.y,i=t.z,o=Math.cos(n),a=Math.sin(n),s=Math.cos(r),c=Math.sin(r),u=Math.cos(i),l=Math.sin(i);if("XYZ"===t.order){var h=o*u,d=o*l,p=a*u,f=a*l;e[0]=s*u,e[4]=-s*l,e[8]=c,e[1]=d+p*c,e[5]=h-f*c,e[9]=-a*s,e[2]=f-h*c,e[6]=p+d*c,e[10]=o*s}else if("YXZ"===t.order){var m=s*u,g=s*l,v=c*u,y=c*l;e[0]=m+y*a,e[4]=v*a-g,e[8]=o*c,e[1]=o*l,e[5]=o*u,e[9]=-a,e[2]=g*a-v,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){m=s*u,g=s*l,v=c*u,y=c*l;e[0]=m-y*a,e[4]=-o*l,e[8]=v+g*a,e[1]=g+v*a,e[5]=o*u,e[9]=y-m*a,e[2]=-o*c,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){h=o*u,d=o*l,p=a*u,f=a*l;e[0]=s*u,e[4]=p*c-d,e[8]=h*c+f,e[1]=s*l,e[5]=f*c+h,e[9]=d*c-p,e[2]=-c,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var b=o*s,_=o*c,x=a*s,w=a*c;e[0]=s*u,e[4]=w-b*l,e[8]=x*l+_,e[1]=l,e[5]=o*u,e[9]=-a*u,e[2]=-c*u,e[6]=_*l+x,e[10]=b-w*l}else if("XZY"===t.order){b=o*s,_=o*c,x=a*s,w=a*c;e[0]=s*u,e[4]=-l,e[8]=c*u,e[1]=b*l+w,e[5]=o*u,e[9]=_*l-x,e[2]=x*l-_,e[6]=a*u,e[10]=w*l+b}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){var e=this.elements,n=t._x,r=t._y,i=t._z,o=t._w,a=n+n,s=r+r,c=i+i,u=n*a,l=n*s,h=n*c,d=r*s,p=r*c,f=i*c,m=o*a,g=o*s,v=o*c;return e[0]=1-(d+f),e[4]=l-v,e[8]=h+g,e[1]=l+v,e[5]=1-(u+f),e[9]=p-m,e[2]=h-g,e[6]=p+m,e[10]=1-(u+d),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:(c=new Ye,u=new Ye,l=new Ye,function(t,e,n){var r=this.elements;return l.subVectors(t,e),0===l.lengthSq()&&(l.z=1),l.normalize(),c.crossVectors(n,l),0===c.lengthSq()&&(1===Math.abs(n.z)?l.x+=1e-4:l.z+=1e-4,l.normalize(),c.crossVectors(n,l)),c.normalize(),u.crossVectors(l,c),r[0]=c.x,r[4]=u.x,r[8]=l.x,r[1]=c.y,r[5]=u.y,r[9]=l.y,r[2]=c.z,r[6]=u.z,r[10]=l.z,this}),multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var n=t.elements,r=e.elements,i=this.elements,o=n[0],a=n[4],s=n[8],c=n[12],u=n[1],l=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],y=n[7],b=n[11],_=n[15],x=r[0],w=r[4],E=r[8],M=r[12],T=r[1],S=r[5],A=r[9],L=r[13],R=r[2],C=r[6],P=r[10],N=r[14],O=r[3],I=r[7],k=r[11],U=r[15];return i[0]=o*x+a*T+s*R+c*O,i[4]=o*w+a*S+s*C+c*I,i[8]=o*E+a*A+s*P+c*k,i[12]=o*M+a*L+s*N+c*U,i[1]=u*x+l*T+h*R+d*O,i[5]=u*w+l*S+h*C+d*I,i[9]=u*E+l*A+h*P+d*k,i[13]=u*M+l*L+h*N+d*U,i[2]=p*x+f*T+m*R+g*O,i[6]=p*w+f*S+m*C+g*I,i[10]=p*E+f*A+m*P+g*k,i[14]=p*M+f*L+m*N+g*U,i[3]=v*x+y*T+b*R+_*O,i[7]=v*w+y*S+b*C+_*I,i[11]=v*E+y*A+b*P+_*k,i[15]=v*M+y*L+b*N+_*U,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToBufferAttribute:function(){var t=new Ye;return function(e){for(var n=0,r=e.count;n=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var b=Math.sqrt(y),_=Math.atan2(b,g*v);m=Math.sin(m*_)/b,a=Math.sin(a*_)/b}var x=a*v;if(s=s*m+h*x,c=c*m+d*x,u=u*m+p*x,l=l*m+f*x,m===1-a){var w=1/Math.sqrt(s*s+c*c+u*u+l*l);s*=w,c*=w,u*=w,l*=w}}t[e]=s,t[e+1]=c,t[e+2]=u,t[e+3]=l}}),Object.defineProperties(Xe.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(t){this._w=t,this.onChangeCallback()}}}),Object.assign(Xe.prototype,{set:function(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this.onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=t._x,r=t._y,i=t._z,o=t.order,a=Math.cos,s=Math.sin,c=a(n/2),u=a(r/2),l=a(i/2),h=s(n/2),d=s(r/2),p=s(i/2);return"XYZ"===o?(this._x=h*u*l+c*d*p,this._y=c*d*l-h*u*p,this._z=c*u*p+h*d*l,this._w=c*u*l-h*d*p):"YXZ"===o?(this._x=h*u*l+c*d*p,this._y=c*d*l-h*u*p,this._z=c*u*p-h*d*l,this._w=c*u*l+h*d*p):"ZXY"===o?(this._x=h*u*l-c*d*p,this._y=c*d*l+h*u*p,this._z=c*u*p+h*d*l,this._w=c*u*l-h*d*p):"ZYX"===o?(this._x=h*u*l-c*d*p,this._y=c*d*l+h*u*p,this._z=c*u*p-h*d*l,this._w=c*u*l+h*d*p):"YZX"===o?(this._x=h*u*l+c*d*p,this._y=c*d*l+h*u*p,this._z=c*u*p-h*d*l,this._w=c*u*l-h*d*p):"XZY"===o&&(this._x=h*u*l-c*d*p,this._y=c*d*l-h*u*p,this._z=c*u*p+h*d*l,this._w=c*u*l+h*d*p),!1!==e&&this.onChangeCallback(),this},setFromAxisAngle:function(t,e){var n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,n=t.elements,r=n[0],i=n[4],o=n[8],a=n[1],s=n[5],c=n[9],u=n[2],l=n[6],h=n[10],d=r+s+h;return d>0?(e=.5/Math.sqrt(d+1),this._w=.25/e,this._x=(l-c)*e,this._y=(o-u)*e,this._z=(a-i)*e):r>s&&r>h?(e=2*Math.sqrt(1+r-s-h),this._w=(l-c)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(o+u)/e):s>h?(e=2*Math.sqrt(1+s-r-h),this._w=(o-u)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(c+l)/e):(e=2*Math.sqrt(1+h-r-s),this._w=(a-i)/e,this._x=(o+u)/e,this._y=(c+l)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:function(){var t,e=new Ye;return function(n,r){return void 0===e&&(e=new Ye),(t=n.dot(r)+1)<1e-6?(t=0,Math.abs(n.x)>Math.abs(n.z)?e.set(-n.y,n.x,0):e.set(0,-n.z,n.y)):e.crossVectors(n,r),this._x=e.x,this._y=e.y,this._z=e.z,this._w=t,this.normalize()}}(),inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var n=t._x,r=t._y,i=t._z,o=t._w,a=e._x,s=e._y,c=e._z,u=e._w;return this._x=n*u+o*a+r*c-i*s,this._y=r*u+o*s+i*a-n*c,this._z=i*u+o*c+n*s-r*a,this._w=o*u-n*a-r*s-i*c,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var n=this._x,r=this._y,i=this._z,o=this._w,a=o*t._w+n*t._x+r*t._y+i*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=n,this._y=r,this._z=i,this;var s=Math.sqrt(1-a*a);if(Math.abs(s)<.001)return this._w=.5*(o+this._w),this._x=.5*(n+this._x),this._y=.5*(r+this._y),this._z=.5*(i+this._z),this;var c=Math.atan2(s,a),u=Math.sin((1-e)*c)/s,l=Math.sin(e*c)/s;return this._w=o*u+this._w*l,this._x=n*u+this._x*l,this._y=r*u+this._y*l,this._z=i*u+this._z*l,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(Ye.prototype,{isVector3:!0,set:function(t,e,n){return this.x=t,this.y=e,this.z=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:(d=new Xe,function(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(d.setFromEuler(t))}),applyAxisAngle:function(){var t=new Xe;return function(e,n){return this.applyQuaternion(t.setFromAxisAngle(e,n))}}(),applyMatrix3:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*r,this.y=i[1]*e+i[4]*n+i[7]*r,this.z=i[2]*e+i[5]*n+i[8]*r,this},applyMatrix4:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements,o=1/(i[3]*e+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*r+i[12])*o,this.y=(i[1]*e+i[5]*n+i[9]*r+i[13])*o,this.z=(i[2]*e+i[6]*n+i[10]*r+i[14])*o,this},applyQuaternion:function(t){var e=this.x,n=this.y,r=this.z,i=t.x,o=t.y,a=t.z,s=t.w,c=s*e+o*r-a*n,u=s*n+a*e-i*r,l=s*r+i*n-o*e,h=-i*e-o*n-a*r;return this.x=c*s+h*-i+u*-a-l*-o,this.y=u*s+h*-o+l*-i-c*-a,this.z=l*s+h*-a+c*-o-u*-i,this},project:function(){var t=new qe;return function(e){return t.multiplyMatrices(e.projectionMatrix,t.getInverse(e.matrixWorld)),this.applyMatrix4(t)}}(),unproject:function(){var t=new qe;return function(e){return t.multiplyMatrices(e.matrixWorld,t.getInverse(e.projectionMatrix)),this.applyMatrix4(t)}}(),transformDirection:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*r,this.y=i[1]*e+i[5]*n+i[9]*r,this.z=i[2]*e+i[6]*n+i[10]*r,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(){var t=new Ye,e=new Ye;return function(n,r){return t.set(n,n,n),e.set(r,r,r),this.clamp(t,e)}}(),clampLength:function(t,e){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},cross:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)},crossVectors:function(t,e){var n=t.x,r=t.y,i=t.z,o=e.x,a=e.y,s=e.z;return this.x=r*s-i*a,this.y=i*o-n*s,this.z=n*a-r*o,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(){var t=new Ye;return function(e){return t.copy(this).projectOnVector(e),this.sub(t)}}(),reflect:function(){var t=new Ye;return function(e){return this.sub(t.copy(e).multiplyScalar(2*this.dot(e)))}}(),angleTo:function(t){var e=this.dot(t)/Math.sqrt(this.lengthSq()*t.lengthSq());return Math.acos(Ve.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromCylindrical:function(t){return this.x=t.radius*Math.sin(t.theta),this.y=t.y,this.z=t.radius*Math.cos(t.theta),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}}),Object.assign(Je.prototype,{isMatrix3:!0,set:function(t,e,n,r,i,o,a,s,c){var u=this.elements;return u[0]=t,u[1]=r,u[2]=a,u[3]=e,u[4]=i,u[5]=s,u[6]=n,u[7]=o,u[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this},setFromMatrix4:function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToBufferAttribute:function(){var t=new Ye;return function(e){for(var n=0,r=e.count;n2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}(r)}),n.image=r.uuid}return e||(t.textures[this.uuid]=n),n},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(this.mapping===gt){if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Mt:t.x=t.x-Math.floor(t.x);break;case Tt:t.x=t.x<0?0:1;break;case St:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case Mt:t.y=t.y-Math.floor(t.y);break;case Tt:t.y=t.y<0?0:1;break;case St:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}this.flipY&&(t.y=1-t.y)}}}),Object.defineProperty(rn.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(on.prototype,{isVector4:!0,set:function(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,n=this.y,r=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*r+o[12]*i,this.y=o[1]*e+o[5]*n+o[9]*r+o[13]*i,this.z=o[2]*e+o[6]*n+o[10]*r+o[14]*i,this.w=o[3]*e+o[7]*n+o[11]*r+o[15]*i,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,n,r,i,o=t.elements,a=o[0],s=o[4],c=o[8],u=o[1],l=o[5],h=o[9],d=o[2],p=o[6],f=o[10];if(Math.abs(s-u)<.01&&Math.abs(c-d)<.01&&Math.abs(h-p)<.01){if(Math.abs(s+u)<.1&&Math.abs(c+d)<.1&&Math.abs(h+p)<.1&&Math.abs(a+l+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(a+1)/2,g=(l+1)/2,v=(f+1)/2,y=(s+u)/4,b=(c+d)/4,_=(h+p)/4;return m>g&&m>v?m<.01?(n=0,r=.707106781,i=.707106781):(r=y/(n=Math.sqrt(m)),i=b/n):g>v?g<.01?(n=.707106781,r=0,i=.707106781):(n=y/(r=Math.sqrt(g)),i=_/r):v<.01?(n=.707106781,r=.707106781,i=0):(n=b/(i=Math.sqrt(v)),r=_/i),this.set(n,r,i,e),this}var x=Math.sqrt((p-h)*(p-h)+(c-d)*(c-d)+(u-s)*(u-s));return Math.abs(x)<.001&&(x=1),this.x=(p-h)/x,this.y=(c-d)/x,this.z=(u-s)/x,this.w=Math.acos((a+l+f-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(){var t,e;return function(n,r){return void 0===t&&(t=new on,e=new on),t.set(n,n,n,n),e.set(r,r,r,r),this.clamp(t,e)}}(),clampLength:function(t,e){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}}),an.prototype=Object.assign(Object.create(r.prototype),{constructor:an,isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),sn.prototype=Object.create(an.prototype),sn.prototype.constructor=sn,sn.prototype.isWebGLRenderTargetCube=!0,cn.prototype=Object.create(rn.prototype),cn.prototype.constructor=cn,cn.prototype.isDataTexture=!0,Object.assign(un.prototype,{isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,a=-1/0,s=0,c=t.length;si&&(i=u),l>o&&(o=l),h>a&&(a=h)}return this.min.set(e,n,r),this.max.set(i,o,a),this},setFromBufferAttribute:function(t){for(var e=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,a=-1/0,s=0,c=t.count;si&&(i=u),l>o&&(o=l),h>a&&(a=h)}return this.min.set(e,n,r),this.max.set(i,o,a),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,n=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new Ye),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:(Qe=new Ye,function(t){return this.clampPoint(t.center,Qe),Qe.distanceToSquared(t.center)<=t.radius*t.radius}),intersectsPlane:function(t){var e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=t.constant&&n>=t.constant},intersectsTriangle:function(){var t=new Ye,e=new Ye,n=new Ye,r=new Ye,i=new Ye,o=new Ye,a=new Ye,s=new Ye,c=new Ye,u=new Ye;function l(r){var i,o;for(i=0,o=r.length-3;i<=o;i+=3){a.fromArray(r,i);var s=c.x*Math.abs(a.x)+c.y*Math.abs(a.y)+c.z*Math.abs(a.z),u=t.dot(a),l=e.dot(a),h=n.dot(a);if(Math.max(-Math.max(u,l,h),Math.min(u,l,h))>s)return!1}return!0}return function(a){if(this.isEmpty())return!1;this.getCenter(s),c.subVectors(this.max,s),t.subVectors(a.a,s),e.subVectors(a.b,s),n.subVectors(a.c,s),r.subVectors(e,t),i.subVectors(n,e),o.subVectors(t,n);var h=[0,-r.z,r.y,0,-i.z,i.y,0,-o.z,o.y,r.z,0,-r.x,i.z,0,-i.x,o.z,0,-o.x,-r.y,r.x,0,-i.y,i.x,0,-o.y,o.x,0];return!!l(h)&&(!!l(h=[1,0,0,0,1,0,0,0,1])&&(u.crossVectors(r,i),l(h=[u.x,u.y,u.z])))}}(),clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new Ye),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new Ye;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),getBoundingSphere:function(){var t=new Ye;return function(e){return void 0===e&&(console.warn("THREE.Box3: .getBoundingSphere() target is now required"),e=new ln),this.getCenter(e.center),e.radius=.5*this.getSize(t).length(),e}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:(Ze=[new Ye,new Ye,new Ye,new Ye,new Ye,new Ye,new Ye,new Ye],function(t){return this.isEmpty()?this:(Ze[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ze[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ze[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ze[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ze[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ze[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ze[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ze[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ze),this)}),translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),Object.assign(ln.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:(Ke=new un,function(t,e){var n=this.center;void 0!==e?n.copy(e):Ke.setFromPoints(t).getCenter(n);for(var r=0,i=0,o=t.length;ithis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e},getBoundingBox:function(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new un),t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}}),Object.assign(hn.prototype,{set:function(t,e){return this.normal.copy(t),this.constant=e,this},setComponents:function(t,e,n,r){return this.normal.set(t,e,n),this.constant=r,this},setFromNormalAndCoplanarPoint:function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},setFromCoplanarPoints:function(){var t=new Ye,e=new Ye;return function(n,r,i){var o=t.subVectors(i,r).cross(e.subVectors(n,r)).normalize();return this.setFromNormalAndCoplanarPoint(o,n),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,e){return void 0===e&&(console.warn("THREE.Plane: .projectPoint() target is now required"),e=new Ye),e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)},intersectLine:function(){var t=new Ye;return function(e,n){void 0===n&&(console.warn("THREE.Plane: .intersectLine() target is now required"),n=new Ye);var r=e.delta(t),i=this.normal.dot(r);if(0===i)return 0===this.distanceToPoint(e.start)?n.copy(e.start):void 0;var o=-(e.start.dot(this.normal)+this.constant)/i;return o<0||o>1?void 0:n.copy(r).multiplyScalar(o).add(e.start)}}(),intersectsLine:function(t){var e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new Ye),t.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var t=new Ye,e=new Je;return function(n,r){var i=r||e.getNormalMatrix(n),o=this.coplanarPoint(t).applyMatrix4(n),a=this.normal.applyMatrix3(i).normalize();return this.constant=-o.dot(a),this}}(),translate:function(t){return this.constant-=t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}}),Object.assign(dn.prototype,{set:function(t,e,n,r,i,o){var a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(r),a[4].copy(i),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,n=0;n<6;n++)e[n].copy(t.planes[n]);return this},setFromMatrix:function(t){var e=this.planes,n=t.elements,r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],c=n[5],u=n[6],l=n[7],h=n[8],d=n[9],p=n[10],f=n[11],m=n[12],g=n[13],v=n[14],y=n[15];return e[0].setComponents(a-r,l-s,f-h,y-m).normalize(),e[1].setComponents(a+r,l+s,f+h,y+m).normalize(),e[2].setComponents(a+i,l+c,f+d,y+g).normalize(),e[3].setComponents(a-i,l-c,f-d,y-g).normalize(),e[4].setComponents(a-o,l-u,f-p,y-v).normalize(),e[5].setComponents(a+o,l+u,f+p,y+v).normalize(),this},intersectsObject:(en=new ln,function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),en.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(en)}),intersectsSprite:function(){var t=new ln;return function(e){return t.center.set(0,0,0),t.radius=.7071067811865476,t.applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSphere:function(t){for(var e=this.planes,n=t.center,r=-t.radius,i=0;i<6;i++){if(e[i].distanceToPoint(n)0?t.min.x:t.max.x,tn.x=r.normal.x>0?t.max.x:t.min.x,$e.y=r.normal.y>0?t.min.y:t.max.y,tn.y=r.normal.y>0?t.max.y:t.min.y,$e.z=r.normal.z>0?t.min.z:t.max.z,tn.z=r.normal.z>0?t.max.z:t.min.z;var i=r.distanceToPoint($e),o=r.distanceToPoint(tn);if(i<0&&o<0)return!1}return!0}),containsPoint:function(t){for(var e=this.planes,n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}});var pn,fn={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif\n",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"\nvec3 transformed = vec3( position );\n",beginnormal_vertex:"\nvec3 objectNormal = vec3( normal );\n",bsdfs:"float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\n",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n",gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",lights_pars_begin:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n",lights_pars_maps:"#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif\n",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifndef STANDARD\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif\n",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\tgl_Position.z *= gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n",normal_fragment_maps:"#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\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\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",dithering_pars_fragment:"#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\n",uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}\n",shadow_vert:"#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n"},mn={merge:function(t){for(var e={},n=0;n>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,n){return this.r=t,this.g=e,this.b=n,this},setHSL:function(){function t(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}return function(e,n,r){if(e=Ve.euclideanModulo(e,1),n=Ve.clamp(n,0,1),r=Ve.clamp(r,0,1),0===n)this.r=this.g=this.b=r;else{var i=r<=.5?r*(1+n):r+n-r*n,o=2*r-i;this.r=t(o,i,e+1/3),this.g=t(o,i,e),this.b=t(o,i,e-1/3)}return this}}(),setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var n;if(n=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var r,i=n[1],o=n[2];switch(i){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,e(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,e(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return e(r[5]),this.setHSL(a,s,c)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(t)){var u,l=(u=n[1]).length;if(3===l)return this.r=parseInt(u.charAt(0)+u.charAt(0),16)/255,this.g=parseInt(u.charAt(1)+u.charAt(1),16)/255,this.b=parseInt(u.charAt(2)+u.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(u.charAt(0)+u.charAt(1),16)/255,this.g=parseInt(u.charAt(2)+u.charAt(3),16)/255,this.b=parseInt(u.charAt(4)+u.charAt(5),16)/255,this}t&&t.length>0&&(void 0!==(u=gn[t])?this.setHex(u):console.warn("THREE.Color: Unknown color "+t));return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var n=e>0?1/e:1;return this.r=Math.pow(t.r,n),this.g=Math.pow(t.g,n),this.b=Math.pow(t.b,n),this},convertGammaToLinear:function(){var t=this.r,e=this.g,n=this.b;return this.r=t*t,this.g=e*e,this.b=n*n,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});var e,n,r=this.r,i=this.g,o=this.b,a=Math.max(r,i,o),s=Math.min(r,i,o),c=(s+a)/2;if(s===a)e=0,n=0;else{var u=a-s;switch(n=c<=.5?u/(a+s):u/(2-a-s),a){case r:e=(i-o)/u+(i1){for(var e=0;e1){for(var e=0;e0){r.children=[];for(s=0;s0&&(n.geometries=h),d.length>0&&(n.materials=d),p.length>0&&(n.textures=p),f.length>0&&(n.images=f),a.length>0&&(n.shapes=a)}return n.object=r,n;function m(t){var e=[];for(var n in t){var r=t[n];delete r.metadata,e.push(r)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var n=0;ne&&(e=t[n]);return e}Un.prototype=Object.assign(Object.create(r.prototype),{constructor:Un,isGeometry:!0,applyMatrix:function(t){for(var e=(new Je).getNormalMatrix(t),n=0,r=this.vertices.length;n0)for(d=0;d0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,n;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,n,r,i;for(n=0,r=this.faces.length;n=0;n--){var f=d[n];for(this.faces.splice(f,1),a=0,s=this.faceVertexUvs.length;a0,g=p.vertexNormals.length>0,v=1!==p.color.r||1!==p.color.g||1!==p.color.b,y=p.vertexColors.length>0,b=0;if(b=E(b=E(b=E(b=E(b=E(b=E(b=E(b=E(b,0,0),1,!0),2,!1),3,f),4,m),5,g),6,v),7,y),a.push(b),a.push(p.a,p.b,p.c),a.push(p.materialIndex),f){var _=this.faceVertexUvs[0][i];a.push(S(_[0]),S(_[1]),S(_[2]))}if(m&&a.push(M(p.normal)),g){var x=p.vertexNormals;a.push(M(x[0]),M(x[1]),M(x[2]))}if(v&&a.push(T(p.color)),y){var w=p.vertexColors;a.push(T(w[0]),T(w[1]),T(w[2]))}}function E(t,e,n){return n?t|1<0&&(t.data.colors=u),h.length>0&&(t.data.uvs=[h]),t.data.faces=a,t},clone:function(){return(new Un).copy(this)},copy:function(t){var e,n,r,i,o,a;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var s=t.vertices;for(e=0,n=s.length;e0,a=i[1]&&i[1].length>0,s=t.morphTargets,c=s.length;if(c>0){e=[];for(var u=0;u0){l=[];for(u=0;u0?1:-1,u.push(R.x,R.y,R.z),l.push(y/m),l.push(1-b/g),A+=1}}for(b=0;b65535?Vn:Hn)(t,1):this.index=t},addAttribute:function(t,e){return e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute?"index"===t?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),void this.setIndex(e)):(this.attributes[t]=e,this):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),void this.addAttribute(t,new Bn(arguments[1],arguments[2])))},getAttribute:function(t){return this.attributes[t]},removeAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,n){this.groups.push({start:t,count:e,materialIndex:void 0!==n?n:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix:function(t){var e=this.attributes.position;void 0!==e&&(t.applyToBufferAttribute(e),e.needsUpdate=!0);var n=this.attributes.normal;void 0!==n&&((new Je).getNormalMatrix(t).applyToBufferAttribute(n),n.needsUpdate=!0);return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var t=new qe;return function(e){return t.makeRotationX(e),this.applyMatrix(t),this}}(),rotateY:function(){var t=new qe;return function(e){return t.makeRotationY(e),this.applyMatrix(t),this}}(),rotateZ:function(){var t=new qe;return function(e){return t.makeRotationZ(e),this.applyMatrix(t),this}}(),translate:function(){var t=new qe;return function(e,n,r){return t.makeTranslation(e,n,r),this.applyMatrix(t),this}}(),scale:function(){var t=new qe;return function(e,n,r){return t.makeScale(e,n,r),this.applyMatrix(t),this}}(),lookAt:function(){var t=new Rn;return function(e){t.lookAt(e),t.updateMatrix(),this.applyMatrix(t.matrix)}}(),center:function(){var t=new Ye;return function(){return this.computeBoundingBox(),this.boundingBox.getCenter(t).negate(),this.translate(t.x,t.y,t.z),this}}(),setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var n=new Wn(3*e.vertices.length,3),r=new Wn(3*e.colors.length,3);if(this.addAttribute("position",n.copyVector3sArray(e.vertices)),this.addAttribute("color",r.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var i=new Wn(e.lineDistances.length,1);this.addAttribute("lineDistance",i.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},setFromPoints:function(t){for(var e=[],n=0,r=t.length;n0){var n=new Float32Array(3*t.normals.length);this.addAttribute("normal",new Bn(n,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var r=new Float32Array(3*t.colors.length);this.addAttribute("color",new Bn(r,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new Bn(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var o=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new Bn(o,2).copyVector2sArray(t.uvs2))}for(var a in this.groups=t.groups,t.morphTargets){for(var s=[],c=t.morphTargets[a],u=0,l=c.length;u0){var p=new Wn(4*t.skinIndices.length,4);this.addAttribute("skinIndex",p.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var f=new Wn(4*t.skinWeights.length,4);this.addAttribute("skinWeight",f.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new un);var t=this.attributes.position;void 0!==t?this.boundingBox.setFromBufferAttribute(t):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var t=new un,e=new Ye;return function(){null===this.boundingSphere&&(this.boundingSphere=new ln);var n=this.attributes.position;if(n){var r=this.boundingSphere.center;t.setFromBufferAttribute(n),t.getCenter(r);for(var i=0,o=0,a=n.count;o0&&(t.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(t.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),t},clone:function(){return(new Zn).copy(this)},copy:function(t){var e,n,r;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var i=t.index;null!==i&&this.setIndex(i.clone());var o=t.attributes;for(e in o){var a=o[e];this.addAttribute(e,a.clone())}var s=t.morphAttributes;for(e in s){var c=[],u=s[e];for(n=0,r=u.length;n0&&(n.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(n.morphTargets=!0),!0===this.skinning&&(n.skinning=!0),!1===this.visible&&(n.visible=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),e){var i=r(t.textures),o=r(t.images);i.length>0&&(n.textures=i),o.length>0&&(n.images=o)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.lights=t.lights,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.overdraw=t.overdraw,this.visible=t.visible,this.userData=JSON.parse(JSON.stringify(t.userData)),this.clipShadows=t.clipShadows,this.clipIntersection=t.clipIntersection;var e=t.clippingPlanes,n=null;if(null!==e){var r=e.length;n=new Array(r);for(var i=0;i!==r;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.shadowSide=t.shadowSide,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),lr.prototype=Object.create(ur.prototype),lr.prototype.constructor=lr,lr.prototype.isMeshBasicMaterial=!0,lr.prototype.copy=function(t){return ur.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this},hr.prototype=Object.create(ur.prototype),hr.prototype.constructor=hr,hr.prototype.isShaderMaterial=!0,hr.prototype.copy=function(t){return ur.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=mn.clone(t.uniforms),this.defines=t.defines,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=t.extensions,this},hr.prototype.toJSON=function(t){var e=ur.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},Object.assign(dr.prototype,{set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return void 0===e&&(console.warn("THREE.Ray: .at() target is now required"),e=new Ye),e.copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(){var t=new Ye;return function(e){return this.origin.copy(this.at(e,t)),this}}(),closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new Ye),e.subVectors(t,this.origin);var n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(){var t=new Ye;return function(e){var n=t.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(t.copy(this.direction).multiplyScalar(n).add(this.origin),t.distanceToSquared(e))}}(),distanceSqToSegment:(nr=new Ye,rr=new Ye,ir=new Ye,function(t,e,n,r){nr.copy(t).add(e).multiplyScalar(.5),rr.copy(e).sub(t).normalize(),ir.copy(this.origin).sub(nr);var i,o,a,s,c=.5*t.distanceTo(e),u=-this.direction.dot(rr),l=ir.dot(this.direction),h=-ir.dot(rr),d=ir.lengthSq(),p=Math.abs(1-u*u);if(p>0)if(o=u*l-h,s=c*p,(i=u*h-l)>=0)if(o>=-s)if(o<=s){var f=1/p;a=(i*=f)*(i+u*(o*=f)+2*l)+o*(u*i+o+2*h)+d}else o=c,a=-(i=Math.max(0,-(u*o+l)))*i+o*(o+2*h)+d;else o=-c,a=-(i=Math.max(0,-(u*o+l)))*i+o*(o+2*h)+d;else o<=-s?a=-(i=Math.max(0,-(-u*c+l)))*i+(o=i>0?-c:Math.min(Math.max(-c,-h),c))*(o+2*h)+d:o<=s?(i=0,a=(o=Math.min(Math.max(-c,-h),c))*(o+2*h)+d):a=-(i=Math.max(0,-(u*c+l)))*i+(o=i>0?c:Math.min(Math.max(-c,-h),c))*(o+2*h)+d;else o=u>0?-c:c,a=-(i=Math.max(0,-(u*o+l)))*i+o*(o+2*h)+d;return n&&n.copy(this.direction).multiplyScalar(i).add(this.origin),r&&r.copy(rr).multiplyScalar(o).add(nr),a}),intersectSphere:function(){var t=new Ye;return function(e,n){t.subVectors(e.center,this.origin);var r=t.dot(this.direction),i=t.dot(t)-r*r,o=e.radius*e.radius;if(i>o)return null;var a=Math.sqrt(o-i),s=r-a,c=r+a;return s<0&&c<0?null:s<0?this.at(c,n):this.at(s,n)}}(),intersectsSphere:function(t){return this.distanceToPoint(t.center)<=t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null},intersectPlane:function(t,e){var n=this.distanceToPlane(t);return null===n?null:this.at(n,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var n,r,i,o,a,s,c=1/this.direction.x,u=1/this.direction.y,l=1/this.direction.z,h=this.origin;return c>=0?(n=(t.min.x-h.x)*c,r=(t.max.x-h.x)*c):(n=(t.max.x-h.x)*c,r=(t.min.x-h.x)*c),u>=0?(i=(t.min.y-h.y)*u,o=(t.max.y-h.y)*u):(i=(t.max.y-h.y)*u,o=(t.min.y-h.y)*u),n>o||i>r?null:((i>n||n!=n)&&(n=i),(o=0?(a=(t.min.z-h.z)*l,s=(t.max.z-h.z)*l):(a=(t.max.z-h.z)*l,s=(t.min.z-h.z)*l),n>s||a>r?null:((a>n||n!=n)&&(n=a),(s=0?n:r,e)))},intersectsBox:(er=new Ye,function(t){return null!==this.intersectBox(t,er)}),intersectTriangle:function(){var t=new Ye,e=new Ye,n=new Ye,r=new Ye;return function(i,o,a,s,c){e.subVectors(o,i),n.subVectors(a,i),r.crossVectors(e,n);var u,l=this.direction.dot(r);if(l>0){if(s)return null;u=1}else{if(!(l<0))return null;u=-1,l=-l}t.subVectors(this.origin,i);var h=u*this.direction.dot(n.crossVectors(t,n));if(h<0)return null;var d=u*this.direction.dot(e.cross(t));if(d<0)return null;if(h+d>l)return null;var p=-u*t.dot(r);return p<0?null:this.at(p/l,c)}}(),applyMatrix4:function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}}),Object.assign(pr.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return void 0===t&&(console.warn("THREE.Line3: .getCenter() target is now required"),t=new Ye),t.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return void 0===t&&(console.warn("THREE.Line3: .delta() target is now required"),t=new Ye),t.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){return void 0===e&&(console.warn("THREE.Line3: .at() target is now required"),e=new Ye),this.delta(e).multiplyScalar(t).add(this.start)},closestPointToPointParameter:(or=new Ye,ar=new Ye,function(t,e){or.subVectors(t,this.start),ar.subVectors(this.end,this.start);var n=ar.dot(ar),r=ar.dot(or)/n;return e&&(r=Ve.clamp(r,0,1)),r}),closestPointToPoint:function(t,e,n){var r=this.closestPointToPointParameter(t,e);return void 0===n&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),n=new Ye),this.delta(n).multiplyScalar(r).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}}),Object.assign(fr,{getNormal:(sr=new Ye,function(t,e,n,r){void 0===r&&(console.warn("THREE.Triangle: .getNormal() target is now required"),r=new Ye),r.subVectors(n,e),sr.subVectors(t,e),r.cross(sr);var i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}),getBarycoord:function(){var t=new Ye,e=new Ye,n=new Ye;return function(r,i,o,a,s){t.subVectors(a,i),e.subVectors(o,i),n.subVectors(r,i);var c=t.dot(t),u=t.dot(e),l=t.dot(n),h=e.dot(e),d=e.dot(n),p=c*h-u*u;if(void 0===s&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),s=new Ye),0===p)return s.set(-2,-1,-1);var f=1/p,m=(h*l-u*d)*f,g=(c*d-u*l)*f;return s.set(1-m-g,g,m)}}(),containsPoint:function(){var t=new Ye;return function(e,n,r,i){return fr.getBarycoord(e,n,r,i,t),t.x>=0&&t.y>=0&&t.x+t.y<=1}}()}),Object.assign(fr.prototype,{set:function(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this},setFromPointsAndIndices:function(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},getArea:function(){var t=new Ye,e=new Ye;return function(){return t.subVectors(this.c,this.b),e.subVectors(this.a,this.b),.5*t.cross(e).length()}}(),getMidpoint:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new Ye),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(t){return fr.getNormal(this.a,this.b,this.c,t)},getPlane:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new Ye),t.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(t,e){return fr.getBarycoord(t,this.a,this.b,this.c,e)},containsPoint:function(t){return fr.containsPoint(t,this.a,this.b,this.c)},intersectsBox:function(t){return t.intersectsTriangle(this)},closestPointToPoint:function(){var t=new hn,e=[new pr,new pr,new pr],n=new Ye,r=new Ye;return function(i,o){void 0===o&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),o=new Ye);var a=1/0;if(t.setFromCoplanarPoints(this.a,this.b,this.c),t.projectPoint(i,n),!0===this.containsPoint(n))o.copy(n);else{e[0].set(this.a,this.b),e[1].set(this.b,this.c),e[2].set(this.c,this.a);for(var s=0;s0){var a=i[o[0]];if(void 0!==a)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=a.length;t0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=s.length;tn.far?null:{distance:c,point:f.clone(),object:t}}function v(t,e,n,a,s,c,d,f){r.fromBufferAttribute(a,c),i.fromBufferAttribute(a,d),o.fromBufferAttribute(a,f);var v=g(t,t.material,e,n,r,i,o,p);if(v){s&&(u.fromBufferAttribute(s,c),l.fromBufferAttribute(s,d),h.fromBufferAttribute(s,f),v.uv=m(p,r,i,o,u,l,h));var y=new Nn(c,d,f);fr.getNormal(r,i,o,y.normal),v.face=y,v.faceIndex=c}return v}return function(d,f){var y,b=this.geometry,_=this.material,x=this.matrixWorld;if(void 0!==_&&(null===b.boundingSphere&&b.computeBoundingSphere(),n.copy(b.boundingSphere),n.applyMatrix4(x),!1!==d.ray.intersectsSphere(n)&&(t.getInverse(x),e.copy(d.ray).applyMatrix4(t),null===b.boundingBox||!1!==e.intersectsBox(b.boundingBox))))if(b.isBufferGeometry){var w,E,M,T,S,A=b.index,L=b.attributes.position,R=b.attributes.uv;if(null!==A)for(T=0,S=A.count;T0&&(O=B);for(var D=0,F=U.length;D0)return t;var i=e*n,o=xr[i];if(void 0===o&&(o=new Float32Array(i),xr[i]=o),0!==e){r.toArray(o,0);for(var a=1,s=0;a!==e;++a)s+=n,t[a].toArray(o,s)}return o}function Sr(t,e){var n=wr[e];void 0===n&&(n=new Int32Array(e),wr[e]=n);for(var r=0;r!==e;++r)n[r]=t.allocTextureUnit();return n}function Ar(t,e){t.uniform1f(this.addr,e)}function Lr(t,e){t.uniform1i(this.addr,e)}function Rr(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function Cr(t,e){void 0!==e.x?t.uniform3f(this.addr,e.x,e.y,e.z):void 0!==e.r?t.uniform3f(this.addr,e.r,e.g,e.b):t.uniform3fv(this.addr,e)}function Pr(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function Nr(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function Or(t,e){void 0===e.elements?t.uniformMatrix3fv(this.addr,!1,e):(Mr.set(e.elements),t.uniformMatrix3fv(this.addr,!1,Mr))}function Ir(t,e){void 0===e.elements?t.uniformMatrix4fv(this.addr,!1,e):(Er.set(e.elements),t.uniformMatrix4fv(this.addr,!1,Er))}function kr(t,e,n){var r=n.allocTextureUnit();t.uniform1i(this.addr,r),n.setTexture2D(e||yr,r)}function Ur(t,e,n){var r=n.allocTextureUnit();t.uniform1i(this.addr,r),n.setTextureCube(e||br,r)}function Br(t,e){t.uniform2iv(this.addr,e)}function Dr(t,e){t.uniform3iv(this.addr,e)}function Fr(t,e){t.uniform4iv(this.addr,e)}function zr(t,e){t.uniform1fv(this.addr,e)}function Gr(t,e){t.uniform1iv(this.addr,e)}function Hr(t,e){t.uniform2fv(this.addr,Tr(e,this.size,2))}function jr(t,e){t.uniform3fv(this.addr,Tr(e,this.size,3))}function Vr(t,e){t.uniform4fv(this.addr,Tr(e,this.size,4))}function Wr(t,e){t.uniformMatrix2fv(this.addr,!1,Tr(e,this.size,4))}function qr(t,e){t.uniformMatrix3fv(this.addr,!1,Tr(e,this.size,9))}function Xr(t,e){t.uniformMatrix4fv(this.addr,!1,Tr(e,this.size,16))}function Yr(t,e,n){var r=e.length,i=Sr(n,r);t.uniform1iv(this.addr,i);for(var o=0;o!==r;++o)n.setTexture2D(e[o]||yr,i[o])}function Jr(t,e,n){var r=e.length,i=Sr(n,r);t.uniform1iv(this.addr,i);for(var o=0;o!==r;++o)n.setTextureCube(e[o]||br,i[o])}function Zr(t,e,n){this.id=t,this.addr=n,this.setValue=function(t){switch(t){case 5126:return Ar;case 35664:return Rr;case 35665:return Cr;case 35666:return Pr;case 35674:return Nr;case 35675:return Or;case 35676:return Ir;case 35678:case 36198:return kr;case 35680:return Ur;case 5124:case 35670:return Lr;case 35667:case 35671:return Br;case 35668:case 35672:return Dr;case 35669:case 35673:return Fr}}(e.type)}function Qr(t,e,n){this.id=t,this.addr=n,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return zr;case 35664:return Hr;case 35665:return jr;case 35666:return Vr;case 35674:return Wr;case 35675:return qr;case 35676:return Xr;case 35678:return Yr;case 35680:return Jr;case 5124:case 35670:return Gr;case 35667:case 35671:return Br;case 35668:case 35672:return Dr;case 35669:case 35673:return Fr}}(e.type)}function Kr(t){this.id=t,_r.call(this)}Kr.prototype.setValue=function(t,e){for(var n=this.seq,r=0,i=n.length;r!==i;++r){var o=n[r];o.setValue(t,e[o.id])}};var $r=/([\w\d_]+)(\])?(\[|\.)?/g;function ti(t,e){t.seq.push(e),t.map[e.id]=e}function ei(t,e,n){var r=t.name,i=r.length;for($r.lastIndex=0;;){var o=$r.exec(r),a=$r.lastIndex,s=o[1],c="]"===o[2],u=o[3];if(c&&(s|=0),void 0===u||"["===u&&a+2===i){ti(n,void 0===u?new Zr(s,t,e):new Qr(s,t,e));break}var l=n.map[s];void 0===l&&ti(n,l=new Kr(s)),n=l}}function ni(t,e,n){_r.call(this),this.renderer=n;for(var r=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),i=0;i/gm,function(t,e){var n=fn[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return li(n)})}function hi(t){return t.replace(/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(t,e,n,r){for(var i="",o=parseInt(e);o0?t.gammaFactor:1,_=function(t,e,n){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.normalMap||e.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(t.fragDepth||e.logarithmicDepthBuffer)&&n.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",t.drawBuffers&&n.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(t.shaderTextureLOD||e.envMap)&&n.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(si).join("\n")}(r.extensions,o,e),x=function(t){var e=[];for(var n in t){var r=t[n];!1!==r&&e.push("#define "+n+" "+r)}return e.join("\n")}(s),M=a.createProgram();r.isRawShaderMaterial?((f=[x].filter(si).join("\n")).length>0&&(f+="\n"),(m=[_,x].filter(si).join("\n")).length>0&&(m+="\n")):(f=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,x,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+b,"#define MAX_BONES "+o.maxBones,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+d:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.displacementMap&&o.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.flatShading?"#define FLAT_SHADED":"",o.skinning?"#define USE_SKINNING":"",o.useVertexTexture?"#define BONE_TEXTURE":"",o.morphTargets?"#define USE_MORPHTARGETS":"",o.morphNormals&&!1===o.flatShading?"#define USE_MORPHNORMALS":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"",o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+l:"",o.sizeAttenuation?"#define USE_SIZEATTENUATION":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(si).join("\n"),m=[_,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,x,o.alphaTest?"#define ALPHATEST "+o.alphaTest:"","#define GAMMA_FACTOR "+b,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+h:"",o.envMap?"#define "+d:"",o.envMap?"#define "+p:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.gradientMap?"#define USE_GRADIENTMAP":"",o.flatShading?"#define FLAT_SHADED":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"",o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+l:"",o.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",o.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",o.envMap&&e.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",o.toneMapping!==ht?"#define TONE_MAPPING":"",o.toneMapping!==ht?fn.tonemapping_pars_fragment:"",o.toneMapping!==ht?function(t,e){var n;switch(e){case dt:n="Linear";break;case pt:n="Reinhard";break;case ft:n="Uncharted2";break;case mt:n="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+e)}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}("toneMapping",o.toneMapping):"",o.dithering?"#define DITHERING":"",o.outputEncoding||o.mapEncoding||o.envMapEncoding||o.emissiveMapEncoding?fn.encodings_pars_fragment:"",o.mapEncoding?ai("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?ai("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?ai("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?(g="linearToOutputTexel",v=o.outputEncoding,y=oi(v),"vec4 "+g+"( vec4 value ) { return LinearTo"+y[0]+y[1]+"; }"):"",o.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(si).join("\n")),c=ui(c=ci(c=li(c),o),o),u=ui(u=ci(u=li(u),o),o);var T=f+(c=hi(c)),S=m+(u=hi(u)),A=ri(a,a.VERTEX_SHADER,T),L=ri(a,a.FRAGMENT_SHADER,S);a.attachShader(M,A),a.attachShader(M,L),void 0!==r.index0AttributeName?a.bindAttribLocation(M,0,r.index0AttributeName):!0===o.morphTargets&&a.bindAttribLocation(M,0,"position"),a.linkProgram(M);var R,C,P=a.getProgramInfoLog(M).trim(),N=a.getShaderInfoLog(A).trim(),O=a.getShaderInfoLog(L).trim(),I=!0,k=!0;return!1===a.getProgramParameter(M,a.LINK_STATUS)?(I=!1,console.error("THREE.WebGLProgram: shader error: ",a.getError(),"gl.VALIDATE_STATUS",a.getProgramParameter(M,a.VALIDATE_STATUS),"gl.getProgramInfoLog",P,N,O)):""!==P?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",P):""!==N&&""!==O||(k=!1),k&&(this.diagnostics={runnable:I,material:r,programLog:P,vertexShader:{log:N,prefix:f},fragmentShader:{log:O,prefix:m}}),a.deleteShader(A),a.deleteShader(L),this.getUniforms=function(){return void 0===R&&(R=new ni(a,M,t)),R},this.getAttributes=function(){return void 0===C&&(C=function(t,e){for(var n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),i=0;i0,maxBones:d,useVertexTexture:n.floatVertexTextures,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:r.directional.length,numPointLights:r.point.length,numSpotLights:r.spot.length,numRectAreaLights:r.rectArea.length,numHemiLights:r.hemi.length,numClippingPlanes:c,numClipIntersection:u,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&l.receiveShadow&&o.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===S,flipSided:e.side===T,depthPacking:void 0!==e.depthPacking&&e.depthPacking}},this.getProgramCode=function(e,n){var r=[];if(n.shaderID?r.push(n.shaderID):(r.push(e.fragmentShader),r.push(e.vertexShader)),void 0!==e.defines)for(var i in e.defines)r.push(i),r.push(e.defines[i]);for(var a=0;a1&&n.sort(fi),r.length>1&&r.sort(mi)}}},t[r]=i),i},dispose:function(){t={}}}}var vi,yi,bi,_i,xi,wi,Ei,Mi,Ti=0;function Si(){var t=new function(){var t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];var n;switch(e.type){case"DirectionalLight":n={direction:new Ye,color:new vn,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new We};break;case"SpotLight":n={position:new Ye,direction:new Ye,color:new vn,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new We};break;case"PointLight":n={position:new Ye,color:new vn,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new We,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":n={direction:new Ye,skyColor:new vn,groundColor:new vn};break;case"RectAreaLight":n={color:new vn,position:new Ye,halfWidth:new Ye,halfHeight:new Ye}}return t[e.id]=n,n}}},e={id:Ti++,hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},n=new Ye,r=new qe,i=new qe;return{setup:function(o,a,s){for(var c=0,u=0,l=0,h=0,d=0,p=0,f=0,m=0,g=s.matrixWorldInverse,v=0,y=o.length;v0:s&&s.isGeometry&&(v=s.morphTargets&&s.morphTargets.length>0)),e.isSkinnedMesh&&!1===n.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e);var y=e.isSkinnedMesh&&n.skinning,b=0;v&&(b|=u),y&&(b|=l),c=h[b]}if(t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var _=c.uuid,x=n.uuid,w=f[_];void 0===w&&(w={},f[_]=w);var E=w[x];void 0===E&&(E=c.clone(),w[x]=E),c=E}return c.visible=n.visible,c.wireframe=n.wireframe,c.side=null!=n.shadowSide?n.shadowSide:m[n.side],c.clipShadows=n.clipShadows,c.clippingPlanes=n.clippingPlanes,c.clipIntersection=n.clipIntersection,c.wireframeLinewidth=n.wireframeLinewidth,c.linewidth=n.linewidth,r&&c.isMeshDistanceMaterial&&(c.referencePosition.copy(i),c.nearDistance=o,c.farDistance=a),c}function C(n,i,o,a){if(!1!==n.visible){if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&n.castShadow&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,n.matrixWorld);var s=e.update(n),u=n.material;if(Array.isArray(u))for(var l=s.groups,h=0,d=l.length;h 0 ) {","\t\tfloat fogFactor = 0.0;","\t\tif ( fogType == 1 ) {","\t\t\tfogFactor = smoothstep( fogNear, fogFar, fogDepth );","\t\t} else {","\t\t\tconst float LOG2 = 1.442695;","\t\t\tfogFactor = exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 );","\t\t\tfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","\t\t}","\t\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );","\t}","}"].join("\n")),e.compileShader(n),e.compileShader(r),e.attachShader(t,n),e.attachShader(t,r),e.linkProgram(t),t}(),c={position:e.getAttribLocation(s,"position"),uv:e.getAttribLocation(s,"uv")},u={uvOffset:e.getUniformLocation(s,"uvOffset"),uvScale:e.getUniformLocation(s,"uvScale"),rotation:e.getUniformLocation(s,"rotation"),center:e.getUniformLocation(s,"center"),scale:e.getUniformLocation(s,"scale"),color:e.getUniformLocation(s,"color"),map:e.getUniformLocation(s,"map"),opacity:e.getUniformLocation(s,"opacity"),modelViewMatrix:e.getUniformLocation(s,"modelViewMatrix"),projectionMatrix:e.getUniformLocation(s,"projectionMatrix"),fogType:e.getUniformLocation(s,"fogType"),fogDensity:e.getUniformLocation(s,"fogDensity"),fogNear:e.getUniformLocation(s,"fogNear"),fogFar:e.getUniformLocation(s,"fogFar"),fogColor:e.getUniformLocation(s,"fogColor"),fogDepth:e.getUniformLocation(s,"fogDepth"),alphaTest:e.getUniformLocation(s,"alphaTest")};var r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");r.width=8,r.height=8;var h=r.getContext("2d");h.fillStyle="white",h.fillRect(0,0,8,8),l=new Pi(r)}function m(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}this.render=function(i,g,v){if(0!==i.length){void 0===s&&f(),n.useProgram(s),n.initAttributes(),n.enableAttribute(c.position),n.enableAttribute(c.uv),n.disableUnusedAttributes(),n.disable(e.CULL_FACE),n.enable(e.BLEND),e.bindBuffer(e.ARRAY_BUFFER,o),e.vertexAttribPointer(c.position,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(c.uv,2,e.FLOAT,!1,16,8),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),e.uniformMatrix4fv(u.projectionMatrix,!1,v.projectionMatrix.elements),n.activeTexture(e.TEXTURE0),e.uniform1i(u.map,0);var y=0,b=0,_=g.fog;_?(e.uniform3f(u.fogColor,_.color.r,_.color.g,_.color.b),_.isFog?(e.uniform1f(u.fogNear,_.near),e.uniform1f(u.fogFar,_.far),e.uniform1i(u.fogType,1),y=1,b=1):_.isFogExp2&&(e.uniform1f(u.fogDensity,_.density),e.uniform1i(u.fogType,2),y=2,b=2)):(e.uniform1i(u.fogType,0),y=0,b=0);for(var x=0,w=i.length;xe||t.height>e){if("data"in t)return void console.warn("THREE.WebGLRenderer: image in DataTexture is too big ("+t.width+"x"+t.height+").");var n=e/Math.max(t.width,t.height),r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return r.width=Math.floor(t.width*n),r.height=Math.floor(t.height*n),r.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,r.width,r.height),console.warn("THREE.WebGLRenderer: image is too big ("+t.width+"x"+t.height+"). Resized to "+r.width+"x"+r.height,t),r}return t}function h(t){return Ve.isPowerOfTwo(t.width)&&Ve.isPowerOfTwo(t.height)}function d(t,e){return t.generateMipmaps&&e&&t.minFilter!==At&&t.minFilter!==Ct}function p(e,n,i,o){t.generateMipmap(e),r.get(n).__maxMipLevel=Math.log2(Math.max(i,o))}function f(e){return e===At||e===Lt||e===Rt?t.NEAREST:t.LINEAR}function m(e){var n=e.target;n.removeEventListener("dispose",m),function(e){var n=r.get(e);if(e.image&&n.__image__webglTextureCube)t.deleteTexture(n.__image__webglTextureCube);else{if(void 0===n.__webglInit)return;t.deleteTexture(n.__webglTexture)}r.remove(e)}(n),n.isVideoTexture&&delete u[n.id],a.memory.textures--}function g(e){var n=e.target;n.removeEventListener("dispose",g),function(e){var n=r.get(e),i=r.get(e.texture);if(!e)return;void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLRenderTargetCube)for(var o=0;o<6;o++)t.deleteFramebuffer(n.__webglFramebuffer[o]),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer[o]);else t.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer);r.remove(e.texture),r.remove(e)}(n),a.memory.textures--}function v(e,f){var g=r.get(e);if(e.isVideoTexture&&function(t){var e=t.id,n=a.render.frame;u[e]!==n&&(u[e]=n,t.update())}(e),e.version>0&&g.__version!==e.version){var v=e.image;if(void 0===v)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",e);else{if(!1!==v.complete)return void function(e,r,u){void 0===e.__webglInit&&(e.__webglInit=!0,r.addEventListener("dispose",m),e.__webglTexture=t.createTexture(),a.memory.textures++);n.activeTexture(t.TEXTURE0+u),n.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,r.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,r.unpackAlignment);var f=l(r.image,i.maxTextureSize);(function(t){return t.wrapS!==Tt||t.wrapT!==Tt||t.minFilter!==At&&t.minFilter!==Ct})(r)&&!1===h(f)&&(f=function(t){return t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof ImageBitmap?(void 0===s&&(s=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),s.width=Ve.floorPowerOfTwo(t.width),s.height=Ve.floorPowerOfTwo(t.height),s.getContext("2d").drawImage(t,0,0,s.width,s.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+t.width+"x"+t.height+"). Resized to "+s.width+"x"+s.height,t),s):t}(f));var g=h(f),v=o.convert(r.format),b=o.convert(r.type);y(t.TEXTURE_2D,r,g);var _,x=r.mipmaps;if(r.isDepthTexture){var w=t.DEPTH_COMPONENT;if(r.type===Ft){if(!c)throw new Error("Float Depth Texture only supported in WebGL2.0");w=t.DEPTH_COMPONENT32F}else c&&(w=t.DEPTH_COMPONENT16);r.format===Qt&&w===t.DEPTH_COMPONENT&&r.type!==Ut&&r.type!==Dt&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Ut,b=o.convert(r.type)),r.format===Kt&&(w=t.DEPTH_STENCIL,r.type!==Vt&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=Vt,b=o.convert(r.type))),n.texImage2D(t.TEXTURE_2D,0,w,f.width,f.height,0,v,b,null)}else if(r.isDataTexture)if(x.length>0&&g){for(var E=0,M=x.length;E-1?n.compressedTexImage2D(t.TEXTURE_2D,E,v,_.width,_.height,0,_.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(t.TEXTURE_2D,E,v,_.width,_.height,0,v,b,_.data);e.__maxMipLevel=x.length-1}else if(x.length>0&&g){for(var E=0,M=x.length;E1||r.get(a).__currentAnisotropy)&&(t.texParameterf(n,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function b(e,i,a,s){var c=o.convert(i.texture.format),u=o.convert(i.texture.type);n.texImage2D(s,0,c,i.width,i.height,0,c,u,null),t.bindFramebuffer(t.FRAMEBUFFER,e),t.framebufferTexture2D(t.FRAMEBUFFER,a,s,r.get(i.texture).__webglTexture,0),t.bindFramebuffer(t.FRAMEBUFFER,null)}function _(e,n){t.bindRenderbuffer(t.RENDERBUFFER,e),n.depthBuffer&&!n.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e)):n.depthBuffer&&n.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e)):t.renderbufferStorage(t.RENDERBUFFER,t.RGBA4,n.width,n.height),t.bindRenderbuffer(t.RENDERBUFFER,null)}function x(e){var n=r.get(e),i=!0===e.isWebGLRenderTargetCube;if(e.depthTexture){if(i)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,n){if(n&&n.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(t.FRAMEBUFFER,e),!n.depthTexture||!n.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(n.depthTexture).__webglTexture&&n.depthTexture.image.width===n.width&&n.depthTexture.image.height===n.height||(n.depthTexture.image.width=n.width,n.depthTexture.image.height=n.height,n.depthTexture.needsUpdate=!0),v(n.depthTexture,0);var i=r.get(n.depthTexture).__webglTexture;if(n.depthTexture.format===Qt)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,i,0);else{if(n.depthTexture.format!==Kt)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,i,0)}}(n.__webglFramebuffer,e)}else if(i){n.__webglDepthbuffer=[];for(var o=0;o<6;o++)t.bindFramebuffer(t.FRAMEBUFFER,n.__webglFramebuffer[o]),n.__webglDepthbuffer[o]=t.createRenderbuffer(),_(n.__webglDepthbuffer[o],e)}else t.bindFramebuffer(t.FRAMEBUFFER,n.__webglFramebuffer),n.__webglDepthbuffer=t.createRenderbuffer(),_(n.__webglDepthbuffer,e);t.bindFramebuffer(t.FRAMEBUFFER,null)}this.setTexture2D=v,this.setTextureCube=function(e,s){var c=r.get(e);if(6===e.image.length)if(e.version>0&&c.__version!==e.version){c.__image__webglTextureCube||(e.addEventListener("dispose",m),c.__image__webglTextureCube=t.createTexture(),a.memory.textures++),n.activeTexture(t.TEXTURE0+s),n.bindTexture(t.TEXTURE_CUBE_MAP,c.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var u=e&&e.isCompressedTexture,f=e.image[0]&&e.image[0].isDataTexture,g=[],v=0;v<6;v++)g[v]=u||f?f?e.image[v].image:e.image[v]:l(e.image[v],i.maxCubemapSize);var b=g[0],_=h(b),x=o.convert(e.format),w=o.convert(e.type);for(y(t.TEXTURE_CUBE_MAP,e,_),v=0;v<6;v++)if(u)for(var E,M=g[v].mipmaps,T=0,S=M.length;T-1?n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,T,x,E.width,E.height,0,E.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,T,x,E.width,E.height,0,x,w,E.data);else f?n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,x,g[v].width,g[v].height,0,x,w,g[v].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,x,x,w,g[v]);c.__maxMipLevel=u?M.length-1:0,d(e,_)&&p(t.TEXTURE_CUBE_MAP,e,b.width,b.height),c.__version=e.version,e.onUpdate&&e.onUpdate(e)}else n.activeTexture(t.TEXTURE0+s),n.bindTexture(t.TEXTURE_CUBE_MAP,c.__image__webglTextureCube)},this.setTextureCubeDynamic=function(e,i){n.activeTexture(t.TEXTURE0+i),n.bindTexture(t.TEXTURE_CUBE_MAP,r.get(e).__webglTexture)},this.setupRenderTarget=function(e){var i=r.get(e),o=r.get(e.texture);e.addEventListener("dispose",g),o.__webglTexture=t.createTexture(),a.memory.textures++;var s=!0===e.isWebGLRenderTargetCube,c=h(e);if(s){i.__webglFramebuffer=[];for(var u=0;u<6;u++)i.__webglFramebuffer[u]=t.createFramebuffer()}else i.__webglFramebuffer=t.createFramebuffer();if(s){for(n.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture),y(t.TEXTURE_CUBE_MAP,e.texture,c),u=0;u<6;u++)b(i.__webglFramebuffer[u],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+u);d(e.texture,c)&&p(t.TEXTURE_CUBE_MAP,e.texture,e.width,e.height),n.bindTexture(t.TEXTURE_CUBE_MAP,null)}else n.bindTexture(t.TEXTURE_2D,o.__webglTexture),y(t.TEXTURE_2D,e.texture,c),b(i.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),d(e.texture,c)&&p(t.TEXTURE_2D,e.texture,e.width,e.height),n.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&x(e)},this.updateRenderTargetMipmap=function(e){var i=e.texture;if(d(i,h(e))){var o=e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,a=r.get(i).__webglTexture;n.bindTexture(o,a),p(o,i,e.width,e.height),n.bindTexture(o,null)}}}function Ii(t,e){return{convert:function(n){var r;if(n===Mt)return t.REPEAT;if(n===Tt)return t.CLAMP_TO_EDGE;if(n===St)return t.MIRRORED_REPEAT;if(n===At)return t.NEAREST;if(n===Lt)return t.NEAREST_MIPMAP_NEAREST;if(n===Rt)return t.NEAREST_MIPMAP_LINEAR;if(n===Ct)return t.LINEAR;if(n===Pt)return t.LINEAR_MIPMAP_NEAREST;if(n===Nt)return t.LINEAR_MIPMAP_LINEAR;if(n===Ot)return t.UNSIGNED_BYTE;if(n===Gt)return t.UNSIGNED_SHORT_4_4_4_4;if(n===Ht)return t.UNSIGNED_SHORT_5_5_5_1;if(n===jt)return t.UNSIGNED_SHORT_5_6_5;if(n===It)return t.BYTE;if(n===kt)return t.SHORT;if(n===Ut)return t.UNSIGNED_SHORT;if(n===Bt)return t.INT;if(n===Dt)return t.UNSIGNED_INT;if(n===Ft)return t.FLOAT;if(n===zt&&null!==(r=e.get("OES_texture_half_float")))return r.HALF_FLOAT_OES;if(n===Wt)return t.ALPHA;if(n===qt)return t.RGB;if(n===Xt)return t.RGBA;if(n===Yt)return t.LUMINANCE;if(n===Jt)return t.LUMINANCE_ALPHA;if(n===Qt)return t.DEPTH_COMPONENT;if(n===Kt)return t.DEPTH_STENCIL;if(n===D)return t.FUNC_ADD;if(n===F)return t.FUNC_SUBTRACT;if(n===z)return t.FUNC_REVERSE_SUBTRACT;if(n===j)return t.ZERO;if(n===V)return t.ONE;if(n===W)return t.SRC_COLOR;if(n===q)return t.ONE_MINUS_SRC_COLOR;if(n===X)return t.SRC_ALPHA;if(n===Y)return t.ONE_MINUS_SRC_ALPHA;if(n===J)return t.DST_ALPHA;if(n===Z)return t.ONE_MINUS_DST_ALPHA;if(n===Q)return t.DST_COLOR;if(n===K)return t.ONE_MINUS_DST_COLOR;if(n===$)return t.SRC_ALPHA_SATURATE;if((n===$t||n===te||n===ee||n===ne)&&null!==(r=e.get("WEBGL_compressed_texture_s3tc"))){if(n===$t)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===te)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===ee)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===ne)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((n===re||n===ie||n===oe||n===ae)&&null!==(r=e.get("WEBGL_compressed_texture_pvrtc"))){if(n===re)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ie)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===oe)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===ae)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===se&&null!==(r=e.get("WEBGL_compressed_texture_etc1")))return r.COMPRESSED_RGB_ETC1_WEBGL;if((n===ce||n===ue||n===le||n===he||n===de||n===pe||n===fe||n===me||n===ge||n===ve||n===ye||n===be||n===_e||n===xe)&&null!==(r=e.get("WEBGL_compressed_texture_astc")))return n;if((n===G||n===H)&&null!==(r=e.get("EXT_blend_minmax"))){if(n===G)return r.MIN_EXT;if(n===H)return r.MAX_EXT}return n===Vt&&null!==(r=e.get("WEBGL_depth_texture"))?r.UNSIGNED_INT_24_8_WEBGL:0}}}function ki(t,e,n,r){Cn.call(this),this.type="PerspectiveCamera",this.fov=void 0!==t?t:50,this.zoom=1,this.near=void 0!==n?n:.1,this.far=void 0!==r?r:2e3,this.focus=10,this.aspect=void 0!==e?e:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function Ui(t){ki.call(this),this.cameras=t||[]}function Bi(t){var e=this,n=null,r=null,i=null,o=new qe,a=new qe;"undefined"!=typeof window&&"VRFrameData"in window&&(r=new window.VRFrameData);var s=new qe,c=new Xe,u=new Ye,l=new ki;l.bounds=new on(0,0,.5,1),l.layers.enable(1);var h=new ki;h.bounds=new on(.5,0,.5,1),h.layers.enable(2);var d,p,f=new Ui([l,h]);function m(){if(null!==n&&n.isPresenting){var r=n.getEyeParameters("left"),i=r.renderWidth,o=r.renderHeight;p=t.getPixelRatio(),d=t.getSize(),t.setDrawingBufferSize(2*i,o,1)}else e.enabled&&t.setDrawingBufferSize(d.width,d.height,p)}f.layers.enable(1),f.layers.enable(2),"undefined"!=typeof window&&window.addEventListener("vrdisplaypresentchange",m,!1),this.enabled=!1,this.userHeight=1.6,this.getDevice=function(){return n},this.setDevice=function(t){void 0!==t&&(n=t)},this.setPoseTarget=function(t){void 0!==t&&(i=t)},this.getCamera=function(t){if(null===n)return t;n.depthNear=t.near,n.depthFar=t.far,n.getFrameData(r);var d=n.stageParameters;d?o.fromArray(d.sittingToStandingTransform):o.makeTranslation(0,e.userHeight,0);var p=r.pose,m=null!==i?i:t;if(m.matrix.copy(o),m.matrix.decompose(m.position,m.quaternion,m.scale),null!==p.orientation&&(c.fromArray(p.orientation),m.quaternion.multiply(c)),null!==p.position&&(c.setFromRotationMatrix(o),u.fromArray(p.position),u.applyQuaternion(c),m.position.add(u)),m.updateMatrixWorld(),!1===n.isPresenting)return t;l.near=t.near,h.near=t.near,l.far=t.far,h.far=t.far,f.matrixWorld.copy(t.matrixWorld),f.matrixWorldInverse.copy(t.matrixWorldInverse),l.matrixWorldInverse.fromArray(r.leftViewMatrix),h.matrixWorldInverse.fromArray(r.rightViewMatrix),a.getInverse(o),l.matrixWorldInverse.multiply(a),h.matrixWorldInverse.multiply(a);var g=m.parent;null!==g&&(s.getInverse(g.matrixWorld),l.matrixWorldInverse.multiply(s),h.matrixWorldInverse.multiply(s)),l.matrixWorld.getInverse(l.matrixWorldInverse),h.matrixWorld.getInverse(h.matrixWorldInverse),l.projectionMatrix.fromArray(r.leftProjectionMatrix),h.projectionMatrix.fromArray(r.rightProjectionMatrix),f.projectionMatrix.copy(l.projectionMatrix);var v=n.getLayers();if(v.length){var y=v[0];null!==y.leftBounds&&4===y.leftBounds.length&&l.bounds.fromArray(y.leftBounds),null!==y.rightBounds&&4===y.rightBounds.length&&h.bounds.fromArray(y.rightBounds)}return f},this.getStandingMatrix=function(){return o},this.submitFrame=function(){n&&n.isPresenting&&n.submitFrame()},this.dispose=function(){"undefined"!=typeof window&&window.removeEventListener("vrdisplaypresentchange",m)}}function Di(t){console.log("THREE.WebGLRenderer",p);var e=void 0!==(t=t||{}).canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),n=void 0!==t.context?t.context:null,r=void 0!==t.alpha&&t.alpha,i=void 0===t.depth||t.depth,o=void 0===t.stencil||t.stencil,a=void 0!==t.antialias&&t.antialias,s=void 0===t.premultipliedAlpha||t.premultipliedAlpha,c=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,u=void 0!==t.powerPreference?t.powerPreference:"default",l=null,h=null;this.domElement=e,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=dt,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var d,f,y,b,_,x,w,E,M,A,L,C,P,D,F,z,G,H,j,V=this,W=!1,q=null,X=null,Y=-1,J="",Z=null,Q=null,K=new on,$=new on,ct=null,ut=0,lt=e.width,ht=e.height,pt=1,ft=new on(0,0,lt,ht),mt=new on(0,0,lt,ht),gt=!1,vt=new dn,yt=new function(){var t=this,e=null,n=0,r=!1,i=!1,o=new hn,a=new Je,s={value:null,needsUpdate:!1};function c(){s.value!==e&&(s.value=e,s.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function u(e,n,r,i){var c=null!==e?e.length:0,u=null;if(0!==c){if(u=s.value,!0!==i||null===u){var l=r+4*c,h=n.matrixWorldInverse;a.getNormalMatrix(h),(null===u||u.length0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var o=void 0!==n.precision?n.precision:"highp",a=i(o);a!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);var s=!0===n.logarithmicDepthBuffer,c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),l=t.getParameter(t.MAX_TEXTURE_SIZE),h=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),d=t.getParameter(t.MAX_VERTEX_ATTRIBS),p=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),f=t.getParameter(t.MAX_VARYING_VECTORS),m=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),g=u>0,v=!!e.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==r)return r;var n=e.get("EXT_texture_filter_anisotropic");return r=null!==n?t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:s,maxTextures:c,maxVertexTextures:u,maxTextureSize:l,maxCubemapSize:h,maxAttributes:d,maxVertexUniforms:p,maxVaryings:f,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:v,floatVertexTextures:g&&v}}(d,f,t),(b=new function(t,e,n){var r=new function(){var e=!1,n=new on,r=null,i=new on(0,0,0,0);return{setMask:function(n){r===n||e||(t.colorMask(n,n,n,n),r=n)},setLocked:function(t){e=t},setClear:function(e,r,o,a,s){!0===s&&(e*=a,r*=a,o*=a),n.set(e,r,o,a),!1===i.equals(n)&&(t.clearColor(e,r,o,a),i.copy(n))},reset:function(){e=!1,r=null,i.set(-1,0,0,0)}}},i=new function(){var e=!1,n=null,r=null,i=null;return{setTest:function(e){e?X(t.DEPTH_TEST):Y(t.DEPTH_TEST)},setMask:function(r){n===r||e||(t.depthMask(r),n=r)},setFunc:function(e){if(r!==e){if(e)switch(e){case tt:t.depthFunc(t.NEVER);break;case et:t.depthFunc(t.ALWAYS);break;case nt:t.depthFunc(t.LESS);break;case rt:t.depthFunc(t.LEQUAL);break;case it:t.depthFunc(t.EQUAL);break;case ot:t.depthFunc(t.GEQUAL);break;case at:t.depthFunc(t.GREATER);break;case st:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}else t.depthFunc(t.LEQUAL);r=e}},setLocked:function(t){e=t},setClear:function(e){i!==e&&(t.clearDepth(e),i=e)},reset:function(){e=!1,n=null,r=null,i=null}}},o=new function(){var e=!1,n=null,r=null,i=null,o=null,a=null,s=null,c=null,u=null;return{setTest:function(e){e?X(t.STENCIL_TEST):Y(t.STENCIL_TEST)},setMask:function(r){n===r||e||(t.stencilMask(r),n=r)},setFunc:function(e,n,a){r===e&&i===n&&o===a||(t.stencilFunc(e,n,a),r=e,i=n,o=a)},setOp:function(e,n,r){a===e&&s===n&&c===r||(t.stencilOp(e,n,r),a=e,s=n,c=r)},setLocked:function(t){e=t},setClear:function(e){u!==e&&(t.clearStencil(e),u=e)},reset:function(){e=!1,n=null,r=null,i=null,o=null,a=null,s=null,c=null,u=null}}},a=t.getParameter(t.MAX_VERTEX_ATTRIBS),s=new Uint8Array(a),c=new Uint8Array(a),u=new Uint8Array(a),l={},h=null,d=null,p=null,f=null,y=null,b=null,_=null,x=null,w=null,E=!1,M=null,A=null,L=null,R=null,C=null,P=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS),D=!1,F=0,z=t.getParameter(t.VERSION);-1!==z.indexOf("WebGL")?(F=parseFloat(/^WebGL\ ([0-9])/.exec(z)[1]),D=F>=1):-1!==z.indexOf("OpenGL ES")&&(F=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(z)[1]),D=F>=2);var G=null,H={},j=new on,V=new on;function W(e,n,r){var i=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(var a=0;a65535?Vn:Hn)(a,1),e.update(r,t.ELEMENT_ARRAY_BUFFER),i[n.id]=r,r}}}(d,E,_),A=new function(t,e){var n={};return{update:function(r){var i=e.render.frame,o=r.geometry,a=t.get(r,o);return n[a.id]!==i&&(o.isGeometry&&a.updateFromObject(r),t.update(a),n[a.id]=i),a},dispose:function(){n={}}}}(M,_),F=new function(t){var e={},n=new Float32Array(8);return{update:function(r,i,o,a){var s=r.morphTargetInfluences,c=s.length,u=e[i.id];if(void 0===u){u=[];for(var l=0;l=0){var u=i[s];if(void 0!==u){var l=u.normalized,h=u.itemSize,p=E.get(u);if(void 0===p)continue;var m=p.buffer,g=p.type,v=p.bytesPerElement;if(u.isInterleavedBufferAttribute){var y=u.data,_=y.stride,x=u.offset;y&&y.isInstancedInterleavedBuffer?(b.enableAttributeAndDivisor(c,y.meshPerAttribute),void 0===n.maxInstancedCount&&(n.maxInstancedCount=y.meshPerAttribute*y.count)):b.enableAttribute(c),d.bindBuffer(d.ARRAY_BUFFER,m),d.vertexAttribPointer(c,h,g,l,_*v,(r*_+x)*v)}else u.isInstancedBufferAttribute?(b.enableAttributeAndDivisor(c,u.meshPerAttribute),void 0===n.maxInstancedCount&&(n.maxInstancedCount=u.meshPerAttribute*u.count)):b.enableAttribute(c),d.bindBuffer(d.ARRAY_BUFFER,m),d.vertexAttribPointer(c,h,g,l,0,r*h*v)}else if(void 0!==a){var w=a[s];if(void 0!==w)switch(w.length){case 2:d.vertexAttrib2fv(c,w);break;case 3:d.vertexAttrib3fv(c,w);break;case 4:d.vertexAttrib4fv(c,w);break;default:d.vertexAttrib1fv(c,w)}}}}b.disableUnusedAttributes()}(r,s,n),null!==h&&d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,l.buffer));var v=1/0;null!==h?v=h.count:void 0!==p&&(v=p.count);var y=n.drawRange.start*m,_=n.drawRange.count*m,x=null!==o?o.start*m:0,w=null!==o?o.count*m:1/0,T=Math.max(y,x),S=Math.min(v,y+_,x+w)-1,A=Math.max(0,S-T+1);if(0!==A){if(i.isMesh)if(!0===r.wireframe)b.setLineWidth(r.wireframeLinewidth*Et()),g.setMode(d.LINES);else switch(i.drawMode){case Pe:g.setMode(d.TRIANGLES);break;case Ne:g.setMode(d.TRIANGLE_STRIP);break;case Oe:g.setMode(d.TRIANGLE_FAN)}else if(i.isLine){var L=r.linewidth;void 0===L&&(L=1),b.setLineWidth(L*Et()),i.isLineSegments?g.setMode(d.LINES):i.isLineLoop?g.setMode(d.LINE_LOOP):g.setMode(d.LINE_STRIP)}else i.isPoints&&g.setMode(d.POINTS);n&&n.isInstancedBufferGeometry?n.maxInstancedCount>0&&g.renderInstances(n,T,A):g.render(T,A)}},this.compile=function(t,e){(h=P.get(t,e)).init(),t.traverse(function(t){t.isLight&&(h.pushLight(t),t.castShadow&&h.pushShadow(t))}),h.setupLights(e),t.traverse(function(e){if(e.material)if(Array.isArray(e.material))for(var n=0;n=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(p=0;p=0&&t.numSupportedMorphNormals++}var f=r.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(r.numClippingPlanes=yt.numPlanes,r.numIntersection=yt.numIntersection,f.clippingPlanes=yt.uniform),r.fog=e,r.lightsHash=i.state.hash,t.lights&&(f.ambientLightColor.value=i.state.ambient,f.directionalLights.value=i.state.directional,f.spotLights.value=i.state.spot,f.rectAreaLights.value=i.state.rectArea,f.pointLights.value=i.state.point,f.hemisphereLights.value=i.state.hemi,f.directionalShadowMap.value=i.state.directionalShadowMap,f.directionalShadowMatrix.value=i.state.directionalShadowMatrix,f.spotShadowMap.value=i.state.spotShadowMap,f.spotShadowMatrix.value=i.state.spotShadowMatrix,f.pointShadowMap.value=i.state.pointShadowMap,f.pointShadowMatrix.value=i.state.pointShadowMatrix);var m=r.program.getUniforms(),g=ni.seqWithValue(m.seq,f);r.uniformsList=g}function Vt(t,e,n,r){ut=0;var i=x.get(n),o=h.state.lights;if(bt&&(_t||t!==Z)){var a=t===Z&&n.id===Y;yt.setState(n.clippingPlanes,n.clipIntersection,n.clipShadows,t,i,a)}!1===n.needsUpdate&&(void 0===i.program?n.needsUpdate=!0:n.fog&&i.fog!==e?n.needsUpdate=!0:n.lights&&i.lightsHash!==o.state.hash?n.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===yt.numPlanes&&i.numIntersection===yt.numIntersection||(n.needsUpdate=!0)),n.needsUpdate&&(jt(n,e,r),n.needsUpdate=!1);var s,c,u=!1,l=!1,p=!1,f=i.program,m=f.getUniforms(),g=i.shader.uniforms;if(b.useProgram(f.program)&&(u=!0,l=!0,p=!0),n.id!==Y&&(Y=n.id,l=!0),u||t!==Z){if(m.setValue(d,"projectionMatrix",t.projectionMatrix),y.logarithmicDepthBuffer&&m.setValue(d,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),Z!==(Q||t)&&(Z=Q||t,l=!0,p=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.envMap){var v=m.map.cameraPosition;void 0!==v&&v.setValue(d,wt.setFromMatrixPosition(t.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.skinning)&&m.setValue(d,"viewMatrix",t.matrixWorldInverse)}if(n.skinning){m.setOptional(d,r,"bindMatrix"),m.setOptional(d,r,"bindMatrixInverse");var _=r.skeleton;if(_){var w=_.bones;if(y.floatVertexTextures){if(void 0===_.boneTexture){var E=Math.sqrt(4*w.length);E=Ve.ceilPowerOfTwo(E),E=Math.max(E,4);var M=new Float32Array(E*E*4);M.set(_.boneMatrices);var T=new cn(M,E,E,Xt,Ft);T.needsUpdate=!0,_.boneMatrices=M,_.boneTexture=T,_.boneTextureSize=E}m.setValue(d,"boneTexture",_.boneTexture),m.setValue(d,"boneTextureSize",_.boneTextureSize)}else m.setOptional(d,_,"boneMatrices")}}return l&&(m.setValue(d,"toneMappingExposure",V.toneMappingExposure),m.setValue(d,"toneMappingWhitePoint",V.toneMappingWhitePoint),n.lights&&(c=p,(s=g).ambientLightColor.needsUpdate=c,s.directionalLights.needsUpdate=c,s.pointLights.needsUpdate=c,s.spotLights.needsUpdate=c,s.rectAreaLights.needsUpdate=c,s.hemisphereLights.needsUpdate=c),e&&n.fog&&function(t,e){t.fogColor.value=e.color,e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}(g,e),n.isMeshBasicMaterial?Wt(g,n):n.isMeshLambertMaterial?(Wt(g,n),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(g,n)):n.isMeshPhongMaterial?(Wt(g,n),n.isMeshToonMaterial?function(t,e){qt(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(g,n):qt(g,n)):n.isMeshStandardMaterial?(Wt(g,n),n.isMeshPhysicalMaterial?function(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,Yt(t,e)}(g,n):Yt(g,n)):n.isMeshDepthMaterial?(Wt(g,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(g,n)):n.isMeshDistanceMaterial?(Wt(g,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias);t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(g,n)):n.isMeshNormalMaterial?(Wt(g,n),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale);e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale));e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(g,n)):n.isLineBasicMaterial?(function(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}(g,n),n.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(g,n)):n.isPointsMaterial?function(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*pt,t.scale.value=.5*ht,t.map.value=e.map,null!==e.map){if(!0===e.map.matrixAutoUpdate){var n=e.map.offset,r=e.map.repeat,i=e.map.rotation,o=e.map.center;e.map.matrix.setUvTransform(n.x,n.y,r.x,r.y,i,o.x,o.y)}t.uvTransform.value.copy(e.map.matrix)}}(g,n):n.isShadowMaterial&&(g.color.value=n.color,g.opacity.value=n.opacity),void 0!==g.ltc_1&&(g.ltc_1.value=bn.LTC_1),void 0!==g.ltc_2&&(g.ltc_2.value=bn.LTC_2),ni.upload(d,i.uniformsList,g,V)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(ni.upload(d,i.uniformsList,g,V),n.uniformsNeedUpdate=!1),m.setValue(d,"modelViewMatrix",r.modelViewMatrix),m.setValue(d,"normalMatrix",r.normalMatrix),m.setValue(d,"modelMatrix",r.matrixWorld),f}function Wt(t,e){var n;if(t.opacity.value=e.opacity,e.color&&(t.diffuse.value=e.color),e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity),e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.specularMap&&(t.specularMap.value=e.specularMap),e.envMap&&(t.envMap.value=e.envMap,t.flipEnvMap.value=e.envMap&&e.envMap.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio,t.maxMipLevel.value=x.get(e.envMap).__maxMipLevel),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity),e.map?n=e.map:e.specularMap?n=e.specularMap:e.displacementMap?n=e.displacementMap:e.normalMap?n=e.normalMap:e.bumpMap?n=e.bumpMap:e.roughnessMap?n=e.roughnessMap:e.metalnessMap?n=e.metalnessMap:e.alphaMap?n=e.alphaMap:e.emissiveMap&&(n=e.emissiveMap),void 0!==n){if(n.isWebGLRenderTarget&&(n=n.texture),!0===n.matrixAutoUpdate){var r=n.offset,i=n.repeat,o=n.rotation,a=n.center;n.matrix.setUvTransform(r.x,r.y,i.x,i.y,o,a.x,a.y)}t.uvTransform.value.copy(n.matrix)}}function qt(t,e){t.specular.value=e.specular,t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function Yt(t,e){t.roughness.value=e.roughness,t.metalness.value=e.metalness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap),e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}this.animate=function(t){null!==(kt=t)?It||(Bt(),It=!0):Ut()},this.render=function(t,e,n,r){if(e&&e.isCamera){if(!W){J="",Y=-1,Z=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),St.enabled&&(e=St.getCamera(e)),(h=P.get(t,e)).init(),t.onBeforeRender(V,t,e,n),xt.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),vt.setFromMatrix(xt),_t=this.localClippingEnabled,bt=yt.init(this.clippingPlanes,_t,e),(l=C.get(t,e)).init(),function t(e,n,r){if(!1===e.visible)return;var i=e.layers.test(n.layers);if(i)if(e.isLight)h.pushLight(e),e.castShadow&&h.pushShadow(e);else if(e.isSprite)e.frustumCulled&&!vt.intersectsSprite(e)||h.pushSprite(e);else if(e.isImmediateRenderObject)r&&wt.setFromMatrixPosition(e.matrixWorld).applyMatrix4(xt),l.push(e,null,e.material,wt.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.update(),!e.frustumCulled||vt.intersectsObject(e))){r&&wt.setFromMatrixPosition(e.matrixWorld).applyMatrix4(xt);var o=A.update(e),a=e.material;if(Array.isArray(a))for(var s=o.groups,c=0,u=s.length;c=y.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+t+" texture units while this GPU supports only "+y.maxTextures),ut+=1,t},this.setTexture2D=(Nt=!1,function(t,e){t&&t.isWebGLRenderTarget&&(Nt||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),Nt=!0),t=t.texture),w.setTexture2D(t,e)}),this.setTexture=function(){var t=!1;return function(e,n){t||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),t=!0),w.setTexture2D(e,n)}}(),this.setTextureCube=function(){var t=!1;return function(e,n){e&&e.isWebGLRenderTargetCube&&(t||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),t=!0),e=e.texture),e&&e.isCubeTexture||Array.isArray(e.image)&&6===e.image.length?w.setTextureCube(e,n):w.setTextureCubeDynamic(e,n)}}(),this.getRenderTarget=function(){return q},this.setRenderTarget=function(t){q=t,t&&void 0===x.get(t).__webglFramebuffer&&w.setupRenderTarget(t);var e=null,n=!1;if(t){var r=x.get(t).__webglFramebuffer;t.isWebGLRenderTargetCube?(e=r[t.activeCubeFace],n=!0):e=r,K.copy(t.viewport),$.copy(t.scissor),ct=t.scissorTest}else K.copy(ft).multiplyScalar(pt),$.copy(mt).multiplyScalar(pt),ct=gt;if(X!==e&&(d.bindFramebuffer(d.FRAMEBUFFER,e),X=e),b.viewport(K),b.scissor($),b.setScissorTest(ct),n){var i=x.get(t.texture);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_CUBE_MAP_POSITIVE_X+t.activeCubeFace,i.__webglTexture,t.activeMipMapLevel)}},this.readRenderTargetPixels=function(t,e,n,r,i,o){if(t&&t.isWebGLRenderTarget){var a=x.get(t).__webglFramebuffer;if(a){var s=!1;a!==X&&(d.bindFramebuffer(d.FRAMEBUFFER,a),s=!0);try{var c=t.texture,u=c.format,l=c.type;if(u!==Xt&&j.convert(u)!==d.getParameter(d.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(l===Ot||j.convert(l)===d.getParameter(d.IMPLEMENTATION_COLOR_READ_TYPE)||l===Ft&&(f.get("OES_texture_float")||f.get("WEBGL_color_buffer_float"))||l===zt&&f.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");d.checkFramebufferStatus(d.FRAMEBUFFER)===d.FRAMEBUFFER_COMPLETE?e>=0&&e<=t.width-r&&n>=0&&n<=t.height-i&&d.readPixels(e,n,r,i,j.convert(u),j.convert(l),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&d.bindFramebuffer(d.FRAMEBUFFER,X)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(t,e,n){var r=e.image.width,i=e.image.height,o=j.convert(e.format);this.setTexture2D(e,0),d.copyTexImage2D(d.TEXTURE_2D,n||0,o,t.x,t.y,r,i,0)},this.copyTextureToTexture=function(t,e,n,r){var i=e.image.width,o=e.image.height,a=j.convert(n.format),s=j.convert(n.type),c=e.isDataTexture?e.image.data:e.image;this.setTexture2D(n,0),d.texSubImage2D(d.TEXTURE_2D,r||0,t.x,t.y,i,o,a,s,c)}}function Fi(t,e){this.name="",this.color=new vn(t),this.density=void 0!==e?e:25e-5}function zi(t,e,n){this.name="",this.color=new vn(t),this.near=void 0!==e?e:1,this.far=void 0!==n?n:1e3}function Gi(){Rn.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function Hi(t){ur.call(this),this.type="SpriteMaterial",this.color=new vn(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function ji(t){Rn.call(this),this.type="Sprite",this.material=void 0!==t?t:new Hi,this.center=new We(.5,.5)}function Vi(){Rn.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function Wi(t,e){if(t=t||[],this.bones=t.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===e)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var n=0,r=this.bones.length;n=0?(t(g-1e-5,m,h),d.subVectors(l,h)):(t(g+1e-5,m,h),d.subVectors(h,l)),m-1e-5>=0?(t(g,m-1e-5,h),p.subVectors(l,h)):(t(g,m+1e-5,h),p.subVectors(h,l)),u.crossVectors(d,p).normalize(),s.push(u.x,u.y,u.z),c.push(g,m)}}for(r=0;r.9&&a<.1&&(e<.2&&(o[t+0]+=1),n<.2&&(o[t+2]+=1),r<.2&&(o[t+4]+=1))}}()}(),this.addAttribute("position",new Wn(i,3)),this.addAttribute("normal",new Wn(i.slice(),3)),this.addAttribute("uv",new Wn(o,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}function uo(t,e){Un.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new lo(t,e)),this.mergeVertices()}function lo(t,e){co.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronBufferGeometry",this.parameters={radius:t,detail:e}}function ho(t,e){Un.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new po(t,e)),this.mergeVertices()}function po(t,e){co.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronBufferGeometry",this.parameters={radius:t,detail:e}}function fo(t,e){Un.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new mo(t,e)),this.mergeVertices()}function mo(t,e){var n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1];co.call(this,r,[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],t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}function go(t,e){Un.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new vo(t,e)),this.mergeVertices()}function vo(t,e){var n=(1+Math.sqrt(5))/2,r=1/n,i=[-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,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r];co.call(this,i,[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,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}function yo(t,e,n,r,i,o){Un.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:r,closed:i},void 0!==o&&console.warn("THREE.TubeGeometry: taper has been removed.");var a=new bo(t,e,n,r,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}function bo(t,e,n,r,i){Zn.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:r,closed:i},e=e||64,n=n||1,r=r||8,i=i||!1;var o=t.computeFrenetFrames(e,i);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;var a,s,c=new Ye,u=new Ye,l=new We,h=new Ye,d=[],p=[],f=[],m=[];function g(i){h=t.getPointAt(i/e,h);var a=o.normals[i],l=o.binormals[i];for(s=0;s<=r;s++){var f=s/r*Math.PI*2,m=Math.sin(f),g=-Math.cos(f);u.x=g*a.x+m*l.x,u.y=g*a.y+m*l.y,u.z=g*a.z+m*l.z,u.normalize(),p.push(u.x,u.y,u.z),c.x=h.x+n*u.x,c.y=h.y+n*u.y,c.z=h.z+n*u.z,d.push(c.x,c.y,c.z)}}!function(){for(a=0;an)){var r=t.ray.origin.distanceTo(vi);rt.far||e.push({distance:r,point:vi.clone(),face:null,object:this})}}),clone:function(){return new this.constructor(this.material).copy(this)},copy:function(t){return Rn.prototype.copy.call(this,t),void 0!==t.center&&this.center.copy(t.center),this}}),Vi.prototype=Object.assign(Object.create(Rn.prototype),{constructor:Vi,copy:function(t){Rn.prototype.copy.call(this,t,!1);for(var e=t.levels,n=0,r=e.length;n1){t.setFromMatrixPosition(n.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var i=t.distanceTo(e);r[0].object.visible=!0;for(var o=1,a=r.length;o=r[o].distance;o++)r[o-1].object.visible=!1,r[o].object.visible=!0;for(;oa))d.applyMatrix4(this.matrixWorld),(E=r.ray.origin.distanceTo(d))r.far||i.push({distance:E,point:h.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}else for(v=0,y=m.length/3-1;va))d.applyMatrix4(this.matrixWorld),(E=r.ray.origin.distanceTo(d))r.far||i.push({distance:E,point:h.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else if(s.isGeometry){var x=s.vertices,w=x.length;for(v=0;va))d.applyMatrix4(this.matrixWorld),(E=r.ray.origin.distanceTo(d))r.far||i.push({distance:E,point:h.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),Zi.prototype=Object.assign(Object.create(Ji.prototype),{constructor:Zi,isLineSegments:!0,computeLineDistances:function(){var t=new Ye,e=new Ye;return function(){var n=this.geometry;if(n.isBufferGeometry)if(null===n.index){for(var r=n.attributes.position,i=[],o=0,a=r.count;or.far)return;i.push({distance:c,distanceToRay:Math.sqrt(a),point:d.clone(),index:n,face:null,object:o})}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),to.prototype=Object.assign(Object.create(Rn.prototype),{constructor:to,isGroup:!0}),eo.prototype=Object.assign(Object.create(rn.prototype),{constructor:eo,isVideoTexture:!0,update:function(){var t=this.image;t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),no.prototype=Object.create(rn.prototype),no.prototype.constructor=no,no.prototype.isCompressedTexture=!0,ro.prototype=Object.create(rn.prototype),ro.prototype.constructor=ro,ro.prototype.isDepthTexture=!0,io.prototype=Object.create(Zn.prototype),io.prototype.constructor=io,oo.prototype=Object.create(Un.prototype),oo.prototype.constructor=oo,ao.prototype=Object.create(Zn.prototype),ao.prototype.constructor=ao,so.prototype=Object.create(Un.prototype),so.prototype.constructor=so,co.prototype=Object.create(Zn.prototype),co.prototype.constructor=co,uo.prototype=Object.create(Un.prototype),uo.prototype.constructor=uo,lo.prototype=Object.create(co.prototype),lo.prototype.constructor=lo,ho.prototype=Object.create(Un.prototype),ho.prototype.constructor=ho,po.prototype=Object.create(co.prototype),po.prototype.constructor=po,fo.prototype=Object.create(Un.prototype),fo.prototype.constructor=fo,mo.prototype=Object.create(co.prototype),mo.prototype.constructor=mo,go.prototype=Object.create(Un.prototype),go.prototype.constructor=go,vo.prototype=Object.create(co.prototype),vo.prototype.constructor=vo,yo.prototype=Object.create(Un.prototype),yo.prototype.constructor=yo,bo.prototype=Object.create(Zn.prototype),bo.prototype.constructor=bo,_o.prototype=Object.create(Un.prototype),_o.prototype.constructor=_o,xo.prototype=Object.create(Zn.prototype),xo.prototype.constructor=xo,wo.prototype=Object.create(Un.prototype),wo.prototype.constructor=wo,Eo.prototype=Object.create(Zn.prototype),Eo.prototype.constructor=Eo;var Mo=function(t,e,n){n=n||2;var r,i,o,a,s,c,u,l=e&&e.length,h=l?e[0]*n:t.length,d=To(t,0,h,n,!0),p=[];if(!d)return p;if(l&&(d=function(t,e,n,r){var i,o,a,s,c,u=[];for(i=0,o=e.length;i80*n){r=o=t[0],i=a=t[1];for(var f=n;fo&&(o=s),c>a&&(a=c);u=0!==(u=Math.max(o-r,a-i))?1/u:0}return Ao(d,p,n,r,i,u),p};function To(t,e,n,r,i){var o,a;if(i===function(t,e,n,r){for(var i=0,o=e,a=n-r;o0)for(o=e;o=e;o-=r)a=jo(o,t[o],t[o+1],a);return a&&Fo(a,a.next)&&(Vo(a),a=a.next),a}function So(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!Fo(r,r.next)&&0!==Do(r.prev,r,r.next))r=r.next;else{if(Vo(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function Ao(t,e,n,r,i,o,a){if(t){!a&&o&&function(t,e,n,r){var i=t;do{null===i.z&&(i.z=Io(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,o,a,s,c,u=1;do{for(n=t,t=null,o=null,a=0;n;){for(a++,r=n,s=0,e=0;e0||c>0&&r;)0!==s&&(0===c||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,c--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;n=r}o.nextZ=null,u*=2}while(a>1)}(i)}(t,r,i,o);for(var s,c,u=t;t.prev!==t.next;)if(s=t.prev,c=t.next,o?Ro(t,r,i,o):Lo(t))e.push(s.i/n),e.push(t.i/n),e.push(c.i/n),Vo(t),t=c.next,u=c.next;else if((t=c)===u){a?1===a?Ao(t=Co(t,e,n),e,n,r,i,o,2):2===a&&Po(t,e,n,r,i,o):Ao(So(t),e,n,r,i,o,1);break}}}function Lo(t){var e=t.prev,n=t,r=t.next;if(Do(e,n,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(Uo(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Do(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Ro(t,e,n,r){var i=t.prev,o=t,a=t.next;if(Do(i,o,a)>=0)return!1;for(var s=i.xo.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,l=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,h=Io(s,c,e,n,r),d=Io(u,l,e,n,r),p=t.nextZ;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&Uo(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&Do(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=h;){if(p!==t.prev&&p!==t.next&&Uo(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&Do(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function Co(t,e,n){var r=t;do{var i=r.prev,o=r.next.next;!Fo(i,o)&&zo(i,r,r.next,o)&&Go(i,o)&&Go(o,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(o.i/n),Vo(r),Vo(r.next),r=t=o),r=r.next}while(r!==t);return r}function Po(t,e,n,r,i,o){var a=t;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Bo(a,s)){var c=Ho(a,s);return a=So(a,a.next),c=So(c,c.next),Ao(a,e,n,r,i,o),void Ao(c,e,n,r,i,o)}s=s.next}a=a.next}while(a!==t)}function No(t,e){return t.x-e.x}function Oo(t,e){if(e=function(t,e){var n,r=e,i=t.x,o=t.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a){if(a=s,s===i){if(o===r.y)return r;if(o===r.next.y)return r.next}n=r.x=r.x&&r.x>=l&&i!==r.x&&Uo(on.x)&&Go(r,t)&&(n=r,d=c),r=r.next;return n}(t,e)){var n=Ho(e,t);So(n,n.next)}}function Io(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ko(t){var e=t,n=t;do{e.x=0&&(t-a)*(r-s)-(n-a)*(e-s)>=0&&(n-a)*(o-s)-(i-a)*(r-s)>=0}function Bo(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&zo(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&Go(t,e)&&Go(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)}function Do(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Fo(t,e){return t.x===e.x&&t.y===e.y}function zo(t,e,n,r){return!!(Fo(t,e)&&Fo(n,r)||Fo(t,r)&&Fo(n,e))||Do(t,e,n)>0!=Do(t,e,r)>0&&Do(n,r,t)>0!=Do(n,r,e)>0}function Go(t,e){return Do(t.prev,t,t.next)<0?Do(t,e,t.next)>=0&&Do(t,t.prev,e)>=0:Do(t,e,t.prev)<0||Do(t,t.next,e)<0}function Ho(t,e){var n=new Wo(t.i,t.x,t.y),r=new Wo(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function jo(t,e,n,r){var i=new Wo(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Vo(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Wo(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}var qo={area:function(t){for(var e=t.length,n=0,r=e-1,i=0;i2&&t[e-1].equals(t[0])&&t.pop()}function Yo(t,e){for(var n=0;n0)&&f.push(x,w,M),(c!==n-1||u0&&v(!0),e>0&&v(!1)),this.setIndex(u),this.addAttribute("position",new Wn(l,3)),this.addAttribute("normal",new Wn(h,3)),this.addAttribute("uv",new Wn(d,2))}function ha(t,e,n,r,i,o,a){ua.call(this,0,t,e,n,r,i,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:o,thetaLength:a}}function da(t,e,n,r,i,o,a){la.call(this,0,t,e,n,r,i,o,a),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:o,thetaLength:a}}function pa(t,e,n,r){Un.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},this.fromBufferGeometry(new fa(t,e,n,r)),this.mergeVertices()}function fa(t,e,n,r){Zn.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},t=t||1,e=void 0!==e?Math.max(3,e):8,n=void 0!==n?n:0,r=void 0!==r?r:2*Math.PI;var i,o,a=[],s=[],c=[],u=[],l=new Ye,h=new We;for(s.push(0,0,0),c.push(0,0,1),u.push(.5,.5),o=0,i=3;o<=e;o++,i+=3){var d=n+o/e*r;l.x=t*Math.cos(d),l.y=t*Math.sin(d),s.push(l.x,l.y,l.z),c.push(0,0,1),h.x=(s[i]/t+1)/2,h.y=(s[i+1]/t+1)/2,u.push(h.x,h.y)}for(i=1;i<=e;i++)a.push(i,i+1,0);this.setIndex(a),this.addAttribute("position",new Wn(s,3)),this.addAttribute("normal",new Wn(c,3)),this.addAttribute("uv",new Wn(u,2))}Jo.prototype=Object.create(Un.prototype),Jo.prototype.constructor=Jo,Zo.prototype=Object.create(Zn.prototype),Zo.prototype.constructor=Zo,Zo.prototype.getArrays=function(){var t=this.getAttribute("position"),e=t?Array.prototype.slice.call(t.array):[],n=this.getAttribute("uv"),r=n?Array.prototype.slice.call(n.array):[],i=this.index;return{position:e,uv:r,index:i?Array.prototype.slice.call(i.array):[]}},Zo.prototype.addShapeList=function(t,e){var n=t.length;e.arrays=this.getArrays();for(var r=0;rNumber.EPSILON){var d=Math.sqrt(l),p=Math.sqrt(c*c+u*u),f=e.x-s/d,m=e.y+a/d,g=((n.x-u/p-f)*u-(n.y+c/p-m)*c)/(a*u-s*c),v=(r=f+a*g-t.x)*r+(i=m+s*g-t.y)*i;if(v<=2)return new We(r,i);o=Math.sqrt(v/2)}else{var y=!1;a>Number.EPSILON?c>Number.EPSILON&&(y=!0):a<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(u)&&(y=!0),y?(r=-s,i=a,o=Math.sqrt(l)):(r=a,i=s,o=Math.sqrt(l/2))}return new We(r/o,i/o)}for(var G=[],H=0,j=C.length,V=j-1,W=H+1;H=0;N--){for(I=N/y,k=g*Math.cos(I*Math.PI/2),O=v*Math.sin(I*Math.PI/2),H=0,j=C.length;H=0;){n=H,(r=H-1)<0&&(r=t.length-1);var i=0,o=x+2*y;for(i=0;i0||0===t.search(/^data\:image\/jpeg/);i.format=r?qt:Xt,i.needsUpdate=!0,void 0!==e&&e(i)},n,r),i},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Object.assign(Ua.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,e){var n=this.getUtoTmapping(t);return this.getPoint(n,e)},getPoints:function(t){void 0===t&&(t=5);for(var e=[],n=0;n<=t;n++)e.push(this.getPoint(n/t));return e},getSpacedPoints:function(t){void 0===t&&(t=5);for(var e=[],n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,n,r=[],i=this.getPoint(0),o=0;for(r.push(0),n=1;n<=t;n++)o+=(e=this.getPoint(n/t)).distanceTo(i),r.push(o),i=e;return this.cacheArcLengths=r,r},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){var n,r=this.getLengths(),i=0,o=r.length;n=e||t*r[o-1];for(var a,s=0,c=o-1;s<=c;)if((a=r[i=Math.floor(s+(c-s)/2)]-n)<0)s=i+1;else{if(!(a>0)){c=i;break}c=i-1}if(r[i=c]===n)return i/(o-1);var u=r[i];return(i+(n-u)/(r[i+1]-u))/(o-1)},getTangent:function(t){var e=t-1e-4,n=t+1e-4;e<0&&(e=0),n>1&&(n=1);var r=this.getPoint(e);return this.getPoint(n).clone().sub(r).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var n,r,i,o=new Ye,a=[],s=[],c=[],u=new Ye,l=new qe;for(n=0;n<=t;n++)r=n/t,a[n]=this.getTangentAt(r),a[n].normalize();s[0]=new Ye,c[0]=new Ye;var h=Number.MAX_VALUE,d=Math.abs(a[0].x),p=Math.abs(a[0].y),f=Math.abs(a[0].z);for(d<=h&&(h=d,o.set(1,0,0)),p<=h&&(h=p,o.set(0,1,0)),f<=h&&o.set(0,0,1),u.crossVectors(a[0],o).normalize(),s[0].crossVectors(a[0],u),c[0].crossVectors(a[0],s[0]),n=1;n<=t;n++)s[n]=s[n-1].clone(),c[n]=c[n-1].clone(),u.crossVectors(a[n-1],a[n]),u.length()>Number.EPSILON&&(u.normalize(),i=Math.acos(Ve.clamp(a[n-1].dot(a[n]),-1,1)),s[n].applyMatrix4(l.makeRotationAxis(u,i))),c[n].crossVectors(a[n],s[n]);if(!0===e)for(i=Math.acos(Ve.clamp(s[0].dot(s[t]),-1,1)),i/=t,a[0].dot(u.crossVectors(s[0],s[t]))>0&&(i=-i),n=1;n<=t;n++)s[n].applyMatrix4(l.makeRotationAxis(a[n],i*n)),c[n].crossVectors(a[n],s[n]);return{tangents:a,normals:s,binormals:c}},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this},toJSON:function(){var t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t},fromJSON:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}),Ba.prototype=Object.create(Ua.prototype),Ba.prototype.constructor=Ba,Ba.prototype.isEllipseCurve=!0,Ba.prototype.getPoint=function(t,e){for(var n=e||new We,r=2*Math.PI,i=this.aEndAngle-this.aStartAngle,o=Math.abs(i)r;)i-=r;i0?0:(Math.floor(Math.abs(l)/s.length)+1)*s.length:0===h&&l===c-1&&(l=c-2,h=1),this.closed||l>0?n=s[(l-1)%c]:(za.subVectors(s[0],s[1]).add(s[0]),n=za),r=s[l%c],i=s[(l+1)%c],this.closed||l+2r.length-2?r.length-1:o+1],l=r[o>r.length-3?r.length-1:o+2];return n.set(Wa(a,s.x,c.x,u.x,l.x),Wa(a,s.y,c.y,u.y,l.y)),n},ts.prototype.copy=function(t){Ua.prototype.copy.call(this,t),this.points=[];for(var e=0,n=t.points.length;e=e){var i=n[r]-e,o=this.curves[r],a=o.getLength(),s=0===a?0:1-i/a;return o.getPointAt(s)}r++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,n=0,r=this.curves.length;n1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},copy:function(t){Ua.prototype.copy.call(this,t),this.curves=[];for(var e=0,n=t.curves.length;e0){var u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);var l=c.getPoint(1);this.currentPoint.copy(l)},copy:function(t){return ns.prototype.copy.call(this,t),this.currentPoint.copy(t.currentPoint),this},toJSON:function(){var t=ns.prototype.toJSON.call(this);return t.currentPoint=this.currentPoint.toArray(),t},fromJSON:function(t){return ns.prototype.fromJSON.call(this,t),this.currentPoint.fromArray(t.currentPoint),this}}),is.prototype=Object.assign(Object.create(rs.prototype),{constructor:is,getPointsHoles:function(t){for(var e=[],n=0,r=this.holes.length;n=i)break t;var s=e[1];t=(i=e[--n-1]))break e}o=n,n=0}for(;n>>1;t0?1:+t}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(t){if(void 0===t||null===t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n>8&255]+t[e>>16&255]+t[e>>24&255]+"-"+t[255&n]+t[n>>8&255]+"-"+t[n>>16&15|64]+t[n>>24&255]+"-"+t[63&r|128]+t[r>>8&255]+"-"+t[r>>16&255]+t[r>>24&255]+t[255&i]+t[i>>8&255]+t[i>>16&255]+t[i>>24&255]}}(),clamp:function(t,e,n){return Math.max(e,Math.min(n,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)},lerp:function(t,e,n){return(1-n)*t+n*e},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*ke.DEG2RAD},radToDeg:function(t){return t*ke.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}};function Ue(t,e){this.x=t||0,this.y=e||0}function Be(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function De(t,e,n,r){this._x=t||0,this._y=e||0,this._z=n||0,this._w=void 0!==r?r:1}function Fe(t,e,n){this.x=t||0,this.y=e||0,this.z=n||0}function ze(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}Object.defineProperties(Ue.prototype,{width:{get:function(){return this.x},set:function(t){this.x=t}},height:{get:function(){return this.y},set:function(t){this.y=t}}}),Object.assign(Ue.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},applyMatrix3:function(t){var e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:function(){var t=new Ue,e=new Ue;return function(n,r){return t.set(n,n),e.set(r,r),this.clamp(t,e)}}(),clampLength:function(t,e){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,n=this.y-t.y;return e*e+n*n},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var n=Math.cos(e),r=Math.sin(e),i=this.x-t.x,o=this.y-t.y;return this.x=i*n-o*r+t.x,this.y=i*r+o*n+t.y,this}}),Object.assign(Be.prototype,{isMatrix4:!0,set:function(t,e,n,r,i,o,a,s,c,u,l,h,d,p,f,m){var g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=r,g[1]=i,g[5]=o,g[9]=a,g[13]=s,g[2]=c,g[6]=u,g[10]=l,g[14]=h,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new Be).fromArray(this.elements)},copy:function(t){var e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this},copyPosition:function(t){var e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this},extractBasis:function(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this},extractRotation:function(){var t=new Fe;return function(e){var n=this.elements,r=e.elements,i=1/t.setFromMatrixColumn(e,0).length(),o=1/t.setFromMatrixColumn(e,1).length(),a=1/t.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[4]=r[4]*o,n[5]=r[5]*o,n[6]=r[6]*o,n[8]=r[8]*a,n[9]=r[9]*a,n[10]=r[10]*a,this}}(),makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,n=t.x,r=t.y,i=t.z,o=Math.cos(n),a=Math.sin(n),s=Math.cos(r),c=Math.sin(r),u=Math.cos(i),l=Math.sin(i);if("XYZ"===t.order){var h=o*u,d=o*l,p=a*u,f=a*l;e[0]=s*u,e[4]=-s*l,e[8]=c,e[1]=d+p*c,e[5]=h-f*c,e[9]=-a*s,e[2]=f-h*c,e[6]=p+d*c,e[10]=o*s}else if("YXZ"===t.order){var m=s*u,g=s*l,v=c*u,y=c*l;e[0]=m+y*a,e[4]=v*a-g,e[8]=o*c,e[1]=o*l,e[5]=o*u,e[9]=-a,e[2]=g*a-v,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){m=s*u,g=s*l,v=c*u,y=c*l;e[0]=m-y*a,e[4]=-o*l,e[8]=v+g*a,e[1]=g+v*a,e[5]=o*u,e[9]=y-m*a,e[2]=-o*c,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){h=o*u,d=o*l,p=a*u,f=a*l;e[0]=s*u,e[4]=p*c-d,e[8]=h*c+f,e[1]=s*l,e[5]=f*c+h,e[9]=d*c-p,e[2]=-c,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var b=o*s,_=o*c,x=a*s,w=a*c;e[0]=s*u,e[4]=w-b*l,e[8]=x*l+_,e[1]=l,e[5]=o*u,e[9]=-a*u,e[2]=-c*u,e[6]=_*l+x,e[10]=b-w*l}else if("XZY"===t.order){b=o*s,_=o*c,x=a*s,w=a*c;e[0]=s*u,e[4]=-l,e[8]=c*u,e[1]=b*l+w,e[5]=o*u,e[9]=_*l-x,e[2]=x*l-_,e[6]=a*u,e[10]=w*l+b}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromQuaternion:function(t){var e=this.elements,n=t._x,r=t._y,i=t._z,o=t._w,a=n+n,s=r+r,c=i+i,u=n*a,l=n*s,h=n*c,d=r*s,p=r*c,f=i*c,m=o*a,g=o*s,v=o*c;return e[0]=1-(d+f),e[4]=l-v,e[8]=h+g,e[1]=l+v,e[5]=1-(u+f),e[9]=p-m,e[2]=h-g,e[6]=p+m,e[10]=1-(u+d),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:function(){var t=new Fe,e=new Fe,n=new Fe;return function(r,i,o){var a=this.elements;return n.subVectors(r,i),0===n.lengthSq()&&(n.z=1),n.normalize(),t.crossVectors(o,n),0===t.lengthSq()&&(1===Math.abs(o.z)?n.x+=1e-4:n.z+=1e-4,n.normalize(),t.crossVectors(o,n)),t.normalize(),e.crossVectors(n,t),a[0]=t.x,a[4]=e.x,a[8]=n.x,a[1]=t.y,a[5]=e.y,a[9]=n.y,a[2]=t.z,a[6]=e.z,a[10]=n.z,this}}(),multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var n=t.elements,r=e.elements,i=this.elements,o=n[0],a=n[4],s=n[8],c=n[12],u=n[1],l=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],y=n[7],b=n[11],_=n[15],x=r[0],w=r[4],E=r[8],M=r[12],T=r[1],S=r[5],A=r[9],L=r[13],R=r[2],C=r[6],P=r[10],N=r[14],O=r[3],I=r[7],k=r[11],U=r[15];return i[0]=o*x+a*T+s*R+c*O,i[4]=o*w+a*S+s*C+c*I,i[8]=o*E+a*A+s*P+c*k,i[12]=o*M+a*L+s*N+c*U,i[1]=u*x+l*T+h*R+d*O,i[5]=u*w+l*S+h*C+d*I,i[9]=u*E+l*A+h*P+d*k,i[13]=u*M+l*L+h*N+d*U,i[2]=p*x+f*T+m*R+g*O,i[6]=p*w+f*S+m*C+g*I,i[10]=p*E+f*A+m*P+g*k,i[14]=p*M+f*L+m*N+g*U,i[3]=v*x+y*T+b*R+_*O,i[7]=v*w+y*S+b*C+_*I,i[11]=v*E+y*A+b*P+_*k,i[15]=v*M+y*L+b*N+_*U,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},applyToBufferAttribute:function(){var t=new Fe;return function(e){for(var n=0,r=e.count;n=0?1:-1,y=1-g*g;if(y>Number.EPSILON){var b=Math.sqrt(y),_=Math.atan2(b,g*v);m=Math.sin(m*_)/b,a=Math.sin(a*_)/b}var x=a*v;if(s=s*m+h*x,c=c*m+d*x,u=u*m+p*x,l=l*m+f*x,m===1-a){var w=1/Math.sqrt(s*s+c*c+u*u+l*l);s*=w,c*=w,u*=w,l*=w}}t[e]=s,t[e+1]=c,t[e+2]=u,t[e+3]=l}}),Object.defineProperties(De.prototype,{x:{get:function(){return this._x},set:function(t){this._x=t,this.onChangeCallback()}},y:{get:function(){return this._y},set:function(t){this._y=t,this.onChangeCallback()}},z:{get:function(){return this._z},set:function(t){this._z=t,this.onChangeCallback()}},w:{get:function(){return this._w},set:function(t){this._w=t,this.onChangeCallback()}}}),Object.assign(De.prototype,{set:function(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this.onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=t._x,r=t._y,i=t._z,o=t.order,a=Math.cos,s=Math.sin,c=a(n/2),u=a(r/2),l=a(i/2),h=s(n/2),d=s(r/2),p=s(i/2);return"XYZ"===o?(this._x=h*u*l+c*d*p,this._y=c*d*l-h*u*p,this._z=c*u*p+h*d*l,this._w=c*u*l-h*d*p):"YXZ"===o?(this._x=h*u*l+c*d*p,this._y=c*d*l-h*u*p,this._z=c*u*p-h*d*l,this._w=c*u*l+h*d*p):"ZXY"===o?(this._x=h*u*l-c*d*p,this._y=c*d*l+h*u*p,this._z=c*u*p+h*d*l,this._w=c*u*l-h*d*p):"ZYX"===o?(this._x=h*u*l-c*d*p,this._y=c*d*l+h*u*p,this._z=c*u*p-h*d*l,this._w=c*u*l+h*d*p):"YZX"===o?(this._x=h*u*l+c*d*p,this._y=c*d*l+h*u*p,this._z=c*u*p-h*d*l,this._w=c*u*l-h*d*p):"XZY"===o&&(this._x=h*u*l-c*d*p,this._y=c*d*l-h*u*p,this._z=c*u*p+h*d*l,this._w=c*u*l+h*d*p),!1!==e&&this.onChangeCallback(),this},setFromAxisAngle:function(t,e){var n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,n=t.elements,r=n[0],i=n[4],o=n[8],a=n[1],s=n[5],c=n[9],u=n[2],l=n[6],h=n[10],d=r+s+h;return d>0?(e=.5/Math.sqrt(d+1),this._w=.25/e,this._x=(l-c)*e,this._y=(o-u)*e,this._z=(a-i)*e):r>s&&r>h?(e=2*Math.sqrt(1+r-s-h),this._w=(l-c)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(o+u)/e):s>h?(e=2*Math.sqrt(1+s-r-h),this._w=(o-u)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(c+l)/e):(e=2*Math.sqrt(1+h-r-s),this._w=(a-i)/e,this._x=(o+u)/e,this._y=(c+l)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:function(){var t,e=new Fe;return function(n,r){return void 0===e&&(e=new Fe),(t=n.dot(r)+1)<1e-6?(t=0,Math.abs(n.x)>Math.abs(n.z)?e.set(-n.y,n.x,0):e.set(0,-n.z,n.y)):e.crossVectors(n,r),this._x=e.x,this._y=e.y,this._z=e.z,this._w=t,this.normalize()}}(),inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var n=t._x,r=t._y,i=t._z,o=t._w,a=e._x,s=e._y,c=e._z,u=e._w;return this._x=n*u+o*a+r*c-i*s,this._y=r*u+o*s+i*a-n*c,this._z=i*u+o*c+n*s-r*a,this._w=o*u-n*a-r*s-i*c,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var n=this._x,r=this._y,i=this._z,o=this._w,a=o*t._w+n*t._x+r*t._y+i*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=n,this._y=r,this._z=i,this;var s=Math.sqrt(1-a*a);if(Math.abs(s)<.001)return this._w=.5*(o+this._w),this._x=.5*(n+this._x),this._y=.5*(r+this._y),this._z=.5*(i+this._z),this;var c=Math.atan2(s,a),u=Math.sin((1-e)*c)/s,l=Math.sin(e*c)/s;return this._w=o*u+this._w*l,this._x=n*u+this._x*l,this._y=r*u+this._y*l,this._z=i*u+this._z*l,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(Fe.prototype,{isVector3:!0,set:function(t,e,n){return this.x=t,this.y=e,this.z=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(){var t=new De;return function(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(t.setFromEuler(e))}}(),applyAxisAngle:function(){var t=new De;return function(e,n){return this.applyQuaternion(t.setFromAxisAngle(e,n))}}(),applyMatrix3:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*r,this.y=i[1]*e+i[4]*n+i[7]*r,this.z=i[2]*e+i[5]*n+i[8]*r,this},applyMatrix4:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements,o=1/(i[3]*e+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*r+i[12])*o,this.y=(i[1]*e+i[5]*n+i[9]*r+i[13])*o,this.z=(i[2]*e+i[6]*n+i[10]*r+i[14])*o,this},applyQuaternion:function(t){var e=this.x,n=this.y,r=this.z,i=t.x,o=t.y,a=t.z,s=t.w,c=s*e+o*r-a*n,u=s*n+a*e-i*r,l=s*r+i*n-o*e,h=-i*e-o*n-a*r;return this.x=c*s+h*-i+u*-a-l*-o,this.y=u*s+h*-o+l*-i-c*-a,this.z=l*s+h*-a+c*-o-u*-i,this},project:function(){var t=new Be;return function(e){return t.multiplyMatrices(e.projectionMatrix,t.getInverse(e.matrixWorld)),this.applyMatrix4(t)}}(),unproject:function(){var t=new Be;return function(e){return t.multiplyMatrices(e.matrixWorld,t.getInverse(e.projectionMatrix)),this.applyMatrix4(t)}}(),transformDirection:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*r,this.y=i[1]*e+i[5]*n+i[9]*r,this.z=i[2]*e+i[6]*n+i[10]*r,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(){var t=new Fe,e=new Fe;return function(n,r){return t.set(n,n,n),e.set(r,r,r),this.clamp(t,e)}}(),clampLength:function(t,e){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},cross:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)},crossVectors:function(t,e){var n=t.x,r=t.y,i=t.z,o=e.x,a=e.y,s=e.z;return this.x=r*s-i*a,this.y=i*o-n*s,this.z=n*a-r*o,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(){var t=new Fe;return function(e){return t.copy(this).projectOnVector(e),this.sub(t)}}(),reflect:function(){var t=new Fe;return function(e){return this.sub(t.copy(e).multiplyScalar(2*this.dot(e)))}}(),angleTo:function(t){var e=this.dot(t)/Math.sqrt(this.lengthSq()*t.lengthSq());return Math.acos(ke.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){var e=Math.sin(t.phi)*t.radius;return this.x=e*Math.sin(t.theta),this.y=Math.cos(t.phi)*t.radius,this.z=e*Math.cos(t.theta),this},setFromCylindrical:function(t){return this.x=t.radius*Math.sin(t.theta),this.y=t.y,this.z=t.radius*Math.cos(t.theta),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}}),Object.assign(ze.prototype,{isMatrix3:!0,set:function(t,e,n,r,i,o,a,s,c){var u=this.elements;return u[0]=t,u[1]=r,u[2]=a,u[3]=e,u[4]=i,u[5]=s,u[6]=n,u[7]=o,u[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this},setFromMatrix4:function(t){var e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this},applyToBufferAttribute:function(){var t=new Fe;return function(e){for(var n=0,r=e.count;n2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}(r)}),n.image=r.uuid}return e||(t.textures[this.uuid]=n),n},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(this.mapping===st){if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case mt:t.x=t.x-Math.floor(t.x);break;case gt:t.x=t.x<0?0:1;break;case vt:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case mt:t.y=t.y-Math.floor(t.y);break;case gt:t.y=t.y<0?0:1;break;case vt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}this.flipY&&(t.y=1-t.y)}}}),Object.defineProperty(He.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(je.prototype,{isVector4:!0,set:function(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,n=this.y,r=this.z,i=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*r+o[12]*i,this.y=o[1]*e+o[5]*n+o[9]*r+o[13]*i,this.z=o[2]*e+o[6]*n+o[10]*r+o[14]*i,this.w=o[3]*e+o[7]*n+o[11]*r+o[15]*i,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,n,r,i,o=t.elements,a=o[0],s=o[4],c=o[8],u=o[1],l=o[5],h=o[9],d=o[2],p=o[6],f=o[10];if(Math.abs(s-u)<.01&&Math.abs(c-d)<.01&&Math.abs(h-p)<.01){if(Math.abs(s+u)<.1&&Math.abs(c+d)<.1&&Math.abs(h+p)<.1&&Math.abs(a+l+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(a+1)/2,g=(l+1)/2,v=(f+1)/2,y=(s+u)/4,b=(c+d)/4,_=(h+p)/4;return m>g&&m>v?m<.01?(n=0,r=.707106781,i=.707106781):(r=y/(n=Math.sqrt(m)),i=b/n):g>v?g<.01?(n=.707106781,r=0,i=.707106781):(n=y/(r=Math.sqrt(g)),i=_/r):v<.01?(n=.707106781,r=.707106781,i=0):(n=b/(i=Math.sqrt(v)),r=_/i),this.set(n,r,i,e),this}var x=Math.sqrt((p-h)*(p-h)+(c-d)*(c-d)+(u-s)*(u-s));return Math.abs(x)<.001&&(x=1),this.x=(p-h)/x,this.y=(c-d)/x,this.z=(u-s)/x,this.w=Math.acos((a+l+f-1)/2),this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this},clampScalar:function(){var t,e;return function(n,r){return void 0===t&&(t=new je,e=new je),t.set(n,n,n,n),e.set(r,r,r,r),this.clamp(t,e)}}(),clampLength:function(t,e){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}}),Ve.prototype=Object.assign(Object.create(r.prototype),{constructor:Ve,isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),We.prototype=Object.create(Ve.prototype),We.prototype.constructor=We,We.prototype.isWebGLRenderTargetCube=!0,qe.prototype=Object.create(He.prototype),qe.prototype.constructor=qe,qe.prototype.isDataTexture=!0,Object.assign(Xe.prototype,{isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,a=-1/0,s=0,c=t.length;si&&(i=u),l>o&&(o=l),h>a&&(a=h)}return this.min.set(e,n,r),this.max.set(i,o,a),this},setFromBufferAttribute:function(t){for(var e=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,a=-1/0,s=0,c=t.count;si&&(i=u),l>o&&(o=l),h>a&&(a=h)}return this.min.set(e,n,r),this.max.set(i,o,a),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,n=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new Fe),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:function(){var t=new Fe;return function(e){return this.clampPoint(e.center,t),t.distanceToSquared(e.center)<=e.radius*e.radius}}(),intersectsPlane:function(t){var e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=t.constant&&n>=t.constant},intersectsTriangle:function(){var t=new Fe,e=new Fe,n=new Fe,r=new Fe,i=new Fe,o=new Fe,a=new Fe,s=new Fe,c=new Fe,u=new Fe;function l(r){var i,o;for(i=0,o=r.length-3;i<=o;i+=3){a.fromArray(r,i);var s=c.x*Math.abs(a.x)+c.y*Math.abs(a.y)+c.z*Math.abs(a.z),u=t.dot(a),l=e.dot(a),h=n.dot(a);if(Math.max(-Math.max(u,l,h),Math.min(u,l,h))>s)return!1}return!0}return function(a){if(this.isEmpty())return!1;this.getCenter(s),c.subVectors(this.max,s),t.subVectors(a.a,s),e.subVectors(a.b,s),n.subVectors(a.c,s),r.subVectors(e,t),i.subVectors(n,e),o.subVectors(t,n);var h=[0,-r.z,r.y,0,-i.z,i.y,0,-o.z,o.y,r.z,0,-r.x,i.z,0,-i.x,o.z,0,-o.x,-r.y,r.x,0,-i.y,i.x,0,-o.y,o.x,0];return!!l(h)&&(!!l(h=[1,0,0,0,1,0,0,0,1])&&(u.crossVectors(r,i),l(h=[u.x,u.y,u.z])))}}(),clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new Fe),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new Fe;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),getBoundingSphere:function(){var t=new Fe;return function(e){return void 0===e&&(console.warn("THREE.Box3: .getBoundingSphere() target is now required"),e=new Ye),this.getCenter(e.center),e.radius=.5*this.getSize(t).length(),e}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(){var t=[new Fe,new Fe,new Fe,new Fe,new Fe,new Fe,new Fe,new Fe];return function(e){return this.isEmpty()?this:(t[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),t[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),t[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),t[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),t[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),t[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),t[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),t[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(t),this)}}(),translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),Object.assign(Ye.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(){var t=new Xe;return function(e,n){var r=this.center;void 0!==n?r.copy(n):t.setFromPoints(e).getCenter(r);for(var i=0,o=0,a=e.length;othis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e},getBoundingBox:function(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new Xe),t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}}),Object.assign(Je.prototype,{set:function(t,e){return this.normal.copy(t),this.constant=e,this},setComponents:function(t,e,n,r){return this.normal.set(t,e,n),this.constant=r,this},setFromNormalAndCoplanarPoint:function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},setFromCoplanarPoints:function(){var t=new Fe,e=new Fe;return function(n,r,i){var o=t.subVectors(i,r).cross(e.subVectors(n,r)).normalize();return this.setFromNormalAndCoplanarPoint(o,n),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,e){return void 0===e&&(console.warn("THREE.Plane: .projectPoint() target is now required"),e=new Fe),e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)},intersectLine:function(){var t=new Fe;return function(e,n){void 0===n&&(console.warn("THREE.Plane: .intersectLine() target is now required"),n=new Fe);var r=e.delta(t),i=this.normal.dot(r);if(0===i)return 0===this.distanceToPoint(e.start)?n.copy(e.start):void 0;var o=-(e.start.dot(this.normal)+this.constant)/i;return o<0||o>1?void 0:n.copy(r).multiplyScalar(o).add(e.start)}}(),intersectsLine:function(t){var e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new Fe),t.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var t=new Fe,e=new ze;return function(n,r){var i=r||e.getNormalMatrix(n),o=this.coplanarPoint(t).applyMatrix4(n),a=this.normal.applyMatrix3(i).normalize();return this.constant=-o.dot(a),this}}(),translate:function(t){return this.constant-=t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}}),Object.assign(Ze.prototype,{set:function(t,e,n,r,i,o){var a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(r),a[4].copy(i),a[5].copy(o),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,n=0;n<6;n++)e[n].copy(t.planes[n]);return this},setFromMatrix:function(t){var e=this.planes,n=t.elements,r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],c=n[5],u=n[6],l=n[7],h=n[8],d=n[9],p=n[10],f=n[11],m=n[12],g=n[13],v=n[14],y=n[15];return e[0].setComponents(a-r,l-s,f-h,y-m).normalize(),e[1].setComponents(a+r,l+s,f+h,y+m).normalize(),e[2].setComponents(a+i,l+c,f+d,y+g).normalize(),e[3].setComponents(a-i,l-c,f-d,y-g).normalize(),e[4].setComponents(a-o,l-u,f-p,y-v).normalize(),e[5].setComponents(a+o,l+u,f+p,y+v).normalize(),this},intersectsObject:function(){var t=new Ye;return function(e){var n=e.geometry;return null===n.boundingSphere&&n.computeBoundingSphere(),t.copy(n.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSprite:function(){var t=new Ye;return function(e){return t.center.set(0,0,0),t.radius=.7071067811865476,t.applyMatrix4(e.matrixWorld),this.intersectsSphere(t)}}(),intersectsSphere:function(t){for(var e=this.planes,n=t.center,r=-t.radius,i=0;i<6;i++){if(e[i].distanceToPoint(n)0?n.min.x:n.max.x,e.x=o.normal.x>0?n.max.x:n.min.x,t.y=o.normal.y>0?n.min.y:n.max.y,e.y=o.normal.y>0?n.max.y:n.min.y,t.z=o.normal.z>0?n.min.z:n.max.z,e.z=o.normal.z>0?n.max.z:n.min.z;var a=o.distanceToPoint(t),s=o.distanceToPoint(e);if(a<0&&s<0)return!1}return!0}}(),containsPoint:function(t){for(var e=this.planes,n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}});var Qe={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif\n",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"\nvec3 transformed = vec3( position );\n",beginnormal_vertex:"\nvec3 objectNormal = vec3( normal );\n",bsdfs:"float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif\n",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\n",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n",defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.x, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract(Le);\n\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max(vRGB, 0.0), 1.0 );\n}\n",envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n",envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n",fog_vertex:"\n#ifdef USE_FOG\nfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float fogDepth;\n#endif\n",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif\n",gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n",lights_pars_begin:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n",lights_pars_maps:"#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos - halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos + halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos + halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos - halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearCoatRadiance = vec3( 0.0 );\n#endif\n",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), maxMipLevel );\n\t#ifndef STANDARD\n\t\tclearCoatRadiance += getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel );\n\t#endif\n#endif\n",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\tgl_Position.z *= gl_Position.w;\n\t#endif\n#endif\n",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n",map_particle_fragment:"#ifdef USE_MAP\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif\n",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif\n",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n",normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n#endif\n",normal_fragment_maps:"#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\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\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n",project_vertex:"vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"#if defined( DITHERING )\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif\n",dithering_pars_fragment:"#if defined( DITHERING )\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif\n",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif\n",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif\n",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n",tonemapping_pars_fragment:"#ifndef saturate\n\t#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n",uv_pars_fragment:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\n",uv_vertex:"#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n#endif\n",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldPosition;\nvoid main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\tgl_FragColor.a *= opacity;\n}\n",cube_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}\n",equirect_vert:"varying vec3 vWorldPosition;\n#include \nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}\n",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}\n",shadow_vert:"#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n"},Ke={merge:function(t){for(var e={},n=0;n>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,n){return this.r=t,this.g=e,this.b=n,this},setHSL:function(){function t(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}return function(e,n,r){if(e=ke.euclideanModulo(e,1),n=ke.clamp(n,0,1),r=ke.clamp(r,0,1),0===n)this.r=this.g=this.b=r;else{var i=r<=.5?r*(1+n):r+n-r*n,o=2*r-i;this.r=t(o,i,e+1/3),this.g=t(o,i,e),this.b=t(o,i,e-1/3)}return this}}(),setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var n;if(n=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var r,i=n[1],o=n[2];switch(i){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,e(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,e(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return e(r[5]),this.setHSL(a,s,c)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(t)){var u,l=(u=n[1]).length;if(3===l)return this.r=parseInt(u.charAt(0)+u.charAt(0),16)/255,this.g=parseInt(u.charAt(1)+u.charAt(1),16)/255,this.b=parseInt(u.charAt(2)+u.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(u.charAt(0)+u.charAt(1),16)/255,this.g=parseInt(u.charAt(2)+u.charAt(3),16)/255,this.b=parseInt(u.charAt(4)+u.charAt(5),16)/255,this}t&&t.length>0&&(void 0!==(u=$e[t])?this.setHex(u):console.warn("THREE.Color: Unknown color "+t));return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,e){return void 0===e&&(e=2),this.r=Math.pow(t.r,e),this.g=Math.pow(t.g,e),this.b=Math.pow(t.b,e),this},copyLinearToGamma:function(t,e){void 0===e&&(e=2);var n=e>0?1/e:1;return this.r=Math.pow(t.r,n),this.g=Math.pow(t.g,n),this.b=Math.pow(t.b,n),this},convertGammaToLinear:function(){var t=this.r,e=this.g,n=this.b;return this.r=t*t,this.g=e*e,this.b=n*n,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});var e,n,r=this.r,i=this.g,o=this.b,a=Math.max(r,i,o),s=Math.min(r,i,o),c=(s+a)/2;if(s===a)e=0,n=0;else{var u=a-s;switch(n=c<=.5?u/(a+s):u/(2-a-s),a){case r:e=(i-o)/u+(i1){for(var e=0;e1){for(var e=0;e0){r.children=[];for(s=0;s0&&(n.geometries=h),d.length>0&&(n.materials=d),p.length>0&&(n.textures=p),f.length>0&&(n.images=f),a.length>0&&(n.shapes=a)}return n.object=r,n;function m(t){var e=[];for(var n in t){var r=t[n];delete r.metadata,e.push(r)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var n=0;ne&&(e=t[n]);return e}pn.prototype=Object.assign(Object.create(r.prototype),{constructor:pn,isGeometry:!0,applyMatrix:function(t){for(var e=(new ze).getNormalMatrix(t),n=0,r=this.vertices.length;n0)for(d=0;d0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,n;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,n,r,i;for(n=0,r=this.faces.length;n=0;n--){var f=d[n];for(this.faces.splice(f,1),a=0,s=this.faceVertexUvs.length;a0,g=p.vertexNormals.length>0,v=1!==p.color.r||1!==p.color.g||1!==p.color.b,y=p.vertexColors.length>0,b=0;if(b=E(b=E(b=E(b=E(b=E(b=E(b=E(b=E(b,0,0),1,!0),2,!1),3,f),4,m),5,g),6,v),7,y),a.push(b),a.push(p.a,p.b,p.c),a.push(p.materialIndex),f){var _=this.faceVertexUvs[0][i];a.push(S(_[0]),S(_[1]),S(_[2]))}if(m&&a.push(M(p.normal)),g){var x=p.vertexNormals;a.push(M(x[0]),M(x[1]),M(x[2]))}if(v&&a.push(T(p.color)),y){var w=p.vertexColors;a.push(T(w[0]),T(w[1]),T(w[2]))}}function E(t,e,n){return n?t|1<0&&(t.data.colors=u),h.length>0&&(t.data.uvs=[h]),t.data.faces=a,t},clone:function(){return(new pn).copy(this)},copy:function(t){var e,n,r,i,o,a;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var s=t.vertices;for(e=0,n=s.length;e0,a=i[1]&&i[1].length>0,s=t.morphTargets,c=s.length;if(c>0){e=[];for(var u=0;u0){l=[];for(u=0;u0?1:-1,u.push(R.x,R.y,R.z),l.push(y/m),l.push(1-b/g),A+=1}}for(b=0;b65535?xn:bn)(t,1):this.index=t},addAttribute:function(t,e){return e&&e.isBufferAttribute||e&&e.isInterleavedBufferAttribute?"index"===t?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),void this.setIndex(e)):(this.attributes[t]=e,this):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),void this.addAttribute(t,new fn(arguments[1],arguments[2])))},getAttribute:function(t){return this.attributes[t]},removeAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,e,n){this.groups.push({start:t,count:e,materialIndex:void 0!==n?n:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,e){this.drawRange.start=t,this.drawRange.count=e},applyMatrix:function(t){var e=this.attributes.position;void 0!==e&&(t.applyToBufferAttribute(e),e.needsUpdate=!0);var n=this.attributes.normal;void 0!==n&&((new ze).getNormalMatrix(t).applyToBufferAttribute(n),n.needsUpdate=!0);return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(){var t=new Be;return function(e){return t.makeRotationX(e),this.applyMatrix(t),this}}(),rotateY:function(){var t=new Be;return function(e){return t.makeRotationY(e),this.applyMatrix(t),this}}(),rotateZ:function(){var t=new Be;return function(e){return t.makeRotationZ(e),this.applyMatrix(t),this}}(),translate:function(){var t=new Be;return function(e,n,r){return t.makeTranslation(e,n,r),this.applyMatrix(t),this}}(),scale:function(){var t=new Be;return function(e,n,r){return t.makeScale(e,n,r),this.applyMatrix(t),this}}(),lookAt:function(){var t=new cn;return function(e){t.lookAt(e),t.updateMatrix(),this.applyMatrix(t.matrix)}}(),center:function(){var t=new Fe;return function(){return this.computeBoundingBox(),this.boundingBox.getCenter(t).negate(),this.translate(t.x,t.y,t.z),this}}(),setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var n=new wn(3*e.vertices.length,3),r=new wn(3*e.colors.length,3);if(this.addAttribute("position",n.copyVector3sArray(e.vertices)),this.addAttribute("color",r.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var i=new wn(e.lineDistances.length,1);this.addAttribute("lineDistance",i.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},setFromPoints:function(t){for(var e=[],n=0,r=t.length;n0){var n=new Float32Array(3*t.normals.length);this.addAttribute("normal",new fn(n,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var r=new Float32Array(3*t.colors.length);this.addAttribute("color",new fn(r,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new fn(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var o=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new fn(o,2).copyVector2sArray(t.uvs2))}for(var a in this.groups=t.groups,t.morphTargets){for(var s=[],c=t.morphTargets[a],u=0,l=c.length;u0){var p=new wn(4*t.skinIndices.length,4);this.addAttribute("skinIndex",p.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var f=new wn(4*t.skinWeights.length,4);this.addAttribute("skinWeight",f.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Xe);var t=this.attributes.position;void 0!==t?this.boundingBox.setFromBufferAttribute(t):this.boundingBox.makeEmpty(),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var t=new Xe,e=new Fe;return function(){null===this.boundingSphere&&(this.boundingSphere=new Ye);var n=this.attributes.position;if(n){var r=this.boundingSphere.center;t.setFromBufferAttribute(n),t.getCenter(r);for(var i=0,o=0,a=n.count;o0&&(t.data.groups=JSON.parse(JSON.stringify(s)));var c=this.boundingSphere;return null!==c&&(t.data.boundingSphere={center:c.center.toArray(),radius:c.radius}),t},clone:function(){return(new An).copy(this)},copy:function(t){var e,n,r;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var i=t.index;null!==i&&this.setIndex(i.clone());var o=t.attributes;for(e in o){var a=o[e];this.addAttribute(e,a.clone())}var s=t.morphAttributes;for(e in s){var c=[],u=s[e];for(n=0,r=u.length;n0&&(n.alphaTest=this.alphaTest),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.morphTargets&&(n.morphTargets=!0),!0===this.skinning&&(n.skinning=!0),!1===this.visible&&(n.visible=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),e){var i=r(t.textures),o=r(t.images);i.length>0&&(n.textures=i),o.length>0&&(n.images=o)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.lights=t.lights,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.premultipliedAlpha=t.premultipliedAlpha,this.overdraw=t.overdraw,this.visible=t.visible,this.userData=JSON.parse(JSON.stringify(t.userData)),this.clipShadows=t.clipShadows,this.clipIntersection=t.clipIntersection;var e=t.clippingPlanes,n=null;if(null!==e){var r=e.length;n=new Array(r);for(var i=0;i!==r;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.shadowSide=t.shadowSide,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),In.prototype=Object.create(On.prototype),In.prototype.constructor=In,In.prototype.isMeshBasicMaterial=!0,In.prototype.copy=function(t){return On.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this},kn.prototype=Object.create(On.prototype),kn.prototype.constructor=kn,kn.prototype.isShaderMaterial=!0,kn.prototype.copy=function(t){return On.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Ke.clone(t.uniforms),this.defines=t.defines,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=t.extensions,this},kn.prototype.toJSON=function(t){var e=On.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},Object.assign(Un.prototype,{set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return void 0===e&&(console.warn("THREE.Ray: .at() target is now required"),e=new Fe),e.copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(){var t=new Fe;return function(e){return this.origin.copy(this.at(e,t)),this}}(),closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new Fe),e.subVectors(t,this.origin);var n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(){var t=new Fe;return function(e){var n=t.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(t.copy(this.direction).multiplyScalar(n).add(this.origin),t.distanceToSquared(e))}}(),distanceSqToSegment:function(){var t=new Fe,e=new Fe,n=new Fe;return function(r,i,o,a){t.copy(r).add(i).multiplyScalar(.5),e.copy(i).sub(r).normalize(),n.copy(this.origin).sub(t);var s,c,u,l,h=.5*r.distanceTo(i),d=-this.direction.dot(e),p=n.dot(this.direction),f=-n.dot(e),m=n.lengthSq(),g=Math.abs(1-d*d);if(g>0)if(c=d*p-f,l=h*g,(s=d*f-p)>=0)if(c>=-l)if(c<=l){var v=1/g;u=(s*=v)*(s+d*(c*=v)+2*p)+c*(d*s+c+2*f)+m}else c=h,u=-(s=Math.max(0,-(d*c+p)))*s+c*(c+2*f)+m;else c=-h,u=-(s=Math.max(0,-(d*c+p)))*s+c*(c+2*f)+m;else c<=-l?u=-(s=Math.max(0,-(-d*h+p)))*s+(c=s>0?-h:Math.min(Math.max(-h,-f),h))*(c+2*f)+m:c<=l?(s=0,u=(c=Math.min(Math.max(-h,-f),h))*(c+2*f)+m):u=-(s=Math.max(0,-(d*h+p)))*s+(c=s>0?h:Math.min(Math.max(-h,-f),h))*(c+2*f)+m;else c=d>0?-h:h,u=-(s=Math.max(0,-(d*c+p)))*s+c*(c+2*f)+m;return o&&o.copy(this.direction).multiplyScalar(s).add(this.origin),a&&a.copy(e).multiplyScalar(c).add(t),u}}(),intersectSphere:function(){var t=new Fe;return function(e,n){t.subVectors(e.center,this.origin);var r=t.dot(this.direction),i=t.dot(t)-r*r,o=e.radius*e.radius;if(i>o)return null;var a=Math.sqrt(o-i),s=r-a,c=r+a;return s<0&&c<0?null:s<0?this.at(c,n):this.at(s,n)}}(),intersectsSphere:function(t){return this.distanceToPoint(t.center)<=t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null},intersectPlane:function(t,e){var n=this.distanceToPlane(t);return null===n?null:this.at(n,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var n,r,i,o,a,s,c=1/this.direction.x,u=1/this.direction.y,l=1/this.direction.z,h=this.origin;return c>=0?(n=(t.min.x-h.x)*c,r=(t.max.x-h.x)*c):(n=(t.max.x-h.x)*c,r=(t.min.x-h.x)*c),u>=0?(i=(t.min.y-h.y)*u,o=(t.max.y-h.y)*u):(i=(t.max.y-h.y)*u,o=(t.min.y-h.y)*u),n>o||i>r?null:((i>n||n!=n)&&(n=i),(o=0?(a=(t.min.z-h.z)*l,s=(t.max.z-h.z)*l):(a=(t.max.z-h.z)*l,s=(t.min.z-h.z)*l),n>s||a>r?null:((a>n||n!=n)&&(n=a),(s=0?n:r,e)))},intersectsBox:function(){var t=new Fe;return function(e){return null!==this.intersectBox(e,t)}}(),intersectTriangle:function(){var t=new Fe,e=new Fe,n=new Fe,r=new Fe;return function(i,o,a,s,c){e.subVectors(o,i),n.subVectors(a,i),r.crossVectors(e,n);var u,l=this.direction.dot(r);if(l>0){if(s)return null;u=1}else{if(!(l<0))return null;u=-1,l=-l}t.subVectors(this.origin,i);var h=u*this.direction.dot(n.crossVectors(t,n));if(h<0)return null;var d=u*this.direction.dot(e.cross(t));if(d<0)return null;if(h+d>l)return null;var p=-u*t.dot(r);return p<0?null:this.at(p/l,c)}}(),applyMatrix4:function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}}),Object.assign(Bn.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return void 0===t&&(console.warn("THREE.Line3: .getCenter() target is now required"),t=new Fe),t.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return void 0===t&&(console.warn("THREE.Line3: .delta() target is now required"),t=new Fe),t.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){return void 0===e&&(console.warn("THREE.Line3: .at() target is now required"),e=new Fe),this.delta(e).multiplyScalar(t).add(this.start)},closestPointToPointParameter:function(){var t=new Fe,e=new Fe;return function(n,r){t.subVectors(n,this.start),e.subVectors(this.end,this.start);var i=e.dot(e),o=e.dot(t)/i;return r&&(o=ke.clamp(o,0,1)),o}}(),closestPointToPoint:function(t,e,n){var r=this.closestPointToPointParameter(t,e);return void 0===n&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),n=new Fe),this.delta(n).multiplyScalar(r).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}}),Object.assign(Dn,{getNormal:function(){var t=new Fe;return function(e,n,r,i){void 0===i&&(console.warn("THREE.Triangle: .getNormal() target is now required"),i=new Fe),i.subVectors(r,n),t.subVectors(e,n),i.cross(t);var o=i.lengthSq();return o>0?i.multiplyScalar(1/Math.sqrt(o)):i.set(0,0,0)}}(),getBarycoord:function(){var t=new Fe,e=new Fe,n=new Fe;return function(r,i,o,a,s){t.subVectors(a,i),e.subVectors(o,i),n.subVectors(r,i);var c=t.dot(t),u=t.dot(e),l=t.dot(n),h=e.dot(e),d=e.dot(n),p=c*h-u*u;if(void 0===s&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),s=new Fe),0===p)return s.set(-2,-1,-1);var f=1/p,m=(h*l-u*d)*f,g=(c*d-u*l)*f;return s.set(1-m-g,g,m)}}(),containsPoint:function(){var t=new Fe;return function(e,n,r,i){return Dn.getBarycoord(e,n,r,i,t),t.x>=0&&t.y>=0&&t.x+t.y<=1}}()}),Object.assign(Dn.prototype,{set:function(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this},setFromPointsAndIndices:function(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},getArea:function(){var t=new Fe,e=new Fe;return function(){return t.subVectors(this.c,this.b),e.subVectors(this.a,this.b),.5*t.cross(e).length()}}(),getMidpoint:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new Fe),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(t){return Dn.getNormal(this.a,this.b,this.c,t)},getPlane:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new Fe),t.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(t,e){return Dn.getBarycoord(t,this.a,this.b,this.c,e)},containsPoint:function(t){return Dn.containsPoint(t,this.a,this.b,this.c)},intersectsBox:function(t){return t.intersectsTriangle(this)},closestPointToPoint:function(){var t=new Je,e=[new Bn,new Bn,new Bn],n=new Fe,r=new Fe;return function(i,o){void 0===o&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),o=new Fe);var a=1/0;if(t.setFromCoplanarPoints(this.a,this.b,this.c),t.projectPoint(i,n),!0===this.containsPoint(n))o.copy(n);else{e[0].set(this.a,this.b),e[1].set(this.b,this.c),e[2].set(this.c,this.a);for(var s=0;s0){var a=i[o[0]];if(void 0!==a)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=a.length;t0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=s.length;tn.far?null:{distance:c,point:f.clone(),object:t}}function b(t,e,n,a,s,c,d,f){r.fromBufferAttribute(a,c),i.fromBufferAttribute(a,d),o.fromBufferAttribute(a,f);var g=y(t,t.material,e,n,r,i,o,p);if(g){s&&(u.fromBufferAttribute(s,c),l.fromBufferAttribute(s,d),h.fromBufferAttribute(s,f),g.uv=m(p,r,i,o,u,l,h));var v=new hn(c,d,f);Dn.getNormal(r,i,o,v.normal),g.face=v,g.faceIndex=c}return g}return function(d,f){var g,v=this.geometry,_=this.material,x=this.matrixWorld;if(void 0!==_&&(null===v.boundingSphere&&v.computeBoundingSphere(),n.copy(v.boundingSphere),n.applyMatrix4(x),!1!==d.ray.intersectsSphere(n)&&(t.getInverse(x),e.copy(d.ray).applyMatrix4(t),null===v.boundingBox||!1!==e.intersectsBox(v.boundingBox))))if(v.isBufferGeometry){var w,E,M,T,S,A=v.index,L=v.attributes.position,R=v.attributes.uv;if(null!==A)for(T=0,S=A.count;T0&&(O=B);for(var D=0,F=U.length;D0)return t;var i=e*n,o=Wn[i];if(void 0===o&&(o=new Float32Array(i),Wn[i]=o),0!==e){r.toArray(o,0);for(var a=1,s=0;a!==e;++a)s+=n,t[a].toArray(o,s)}return o}function Zn(t,e){var n=qn[e];void 0===n&&(n=new Int32Array(e),qn[e]=n);for(var r=0;r!==e;++r)n[r]=t.allocTextureUnit();return n}function Qn(t,e){t.uniform1f(this.addr,e)}function Kn(t,e){t.uniform1i(this.addr,e)}function $n(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function tr(t,e){void 0!==e.x?t.uniform3f(this.addr,e.x,e.y,e.z):void 0!==e.r?t.uniform3f(this.addr,e.r,e.g,e.b):t.uniform3fv(this.addr,e)}function er(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function nr(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function rr(t,e){void 0===e.elements?t.uniformMatrix3fv(this.addr,!1,e):(Yn.set(e.elements),t.uniformMatrix3fv(this.addr,!1,Yn))}function ir(t,e){void 0===e.elements?t.uniformMatrix4fv(this.addr,!1,e):(Xn.set(e.elements),t.uniformMatrix4fv(this.addr,!1,Xn))}function or(t,e,n){var r=n.allocTextureUnit();t.uniform1i(this.addr,r),n.setTexture2D(e||Hn,r)}function ar(t,e,n){var r=n.allocTextureUnit();t.uniform1i(this.addr,r),n.setTextureCube(e||jn,r)}function sr(t,e){t.uniform2iv(this.addr,e)}function cr(t,e){t.uniform3iv(this.addr,e)}function ur(t,e){t.uniform4iv(this.addr,e)}function lr(t,e){t.uniform1fv(this.addr,e)}function hr(t,e){t.uniform1iv(this.addr,e)}function dr(t,e){t.uniform2fv(this.addr,Jn(e,this.size,2))}function pr(t,e){t.uniform3fv(this.addr,Jn(e,this.size,3))}function fr(t,e){t.uniform4fv(this.addr,Jn(e,this.size,4))}function mr(t,e){t.uniformMatrix2fv(this.addr,!1,Jn(e,this.size,4))}function gr(t,e){t.uniformMatrix3fv(this.addr,!1,Jn(e,this.size,9))}function vr(t,e){t.uniformMatrix4fv(this.addr,!1,Jn(e,this.size,16))}function yr(t,e,n){var r=e.length,i=Zn(n,r);t.uniform1iv(this.addr,i);for(var o=0;o!==r;++o)n.setTexture2D(e[o]||Hn,i[o])}function br(t,e,n){var r=e.length,i=Zn(n,r);t.uniform1iv(this.addr,i);for(var o=0;o!==r;++o)n.setTextureCube(e[o]||jn,i[o])}function _r(t,e,n){this.id=t,this.addr=n,this.setValue=function(t){switch(t){case 5126:return Qn;case 35664:return $n;case 35665:return tr;case 35666:return er;case 35674:return nr;case 35675:return rr;case 35676:return ir;case 35678:case 36198:return or;case 35680:return ar;case 5124:case 35670:return Kn;case 35667:case 35671:return sr;case 35668:case 35672:return cr;case 35669:case 35673:return ur}}(e.type)}function xr(t,e,n){this.id=t,this.addr=n,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return lr;case 35664:return dr;case 35665:return pr;case 35666:return fr;case 35674:return mr;case 35675:return gr;case 35676:return vr;case 35678:return yr;case 35680:return br;case 5124:case 35670:return hr;case 35667:case 35671:return sr;case 35668:case 35672:return cr;case 35669:case 35673:return ur}}(e.type)}function wr(t){this.id=t,Vn.call(this)}wr.prototype.setValue=function(t,e){for(var n=this.seq,r=0,i=n.length;r!==i;++r){var o=n[r];o.setValue(t,e[o.id])}};var Er=/([\w\d_]+)(\])?(\[|\.)?/g;function Mr(t,e){t.seq.push(e),t.map[e.id]=e}function Tr(t,e,n){var r=t.name,i=r.length;for(Er.lastIndex=0;;){var o=Er.exec(r),a=Er.lastIndex,s=o[1],c="]"===o[2],u=o[3];if(c&&(s|=0),void 0===u||"["===u&&a+2===i){Mr(n,void 0===u?new _r(s,t,e):new xr(s,t,e));break}var l=n.map[s];void 0===l&&Mr(n,l=new wr(s)),n=l}}function Sr(t,e,n){Vn.call(this),this.renderer=n;for(var r=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),i=0;i/gm,function(t,e){var n=Qe[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return Ir(n)})}function kr(t){return t.replace(/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(t,e,n,r){for(var i="",o=parseInt(e);o0?t.gammaFactor:1,b=function(t,e,n){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.normalMap||e.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(t.fragDepth||e.logarithmicDepthBuffer)&&n.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",t.drawBuffers&&n.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(t.shaderTextureLOD||e.envMap)&&n.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Pr).join("\n")}(r.extensions,o,e),_=function(t){var e=[];for(var n in t){var r=t[n];!1!==r&&e.push("#define "+n+" "+r)}return e.join("\n")}(s),x=a.createProgram();r.isRawShaderMaterial?((g=[_].filter(Pr).join("\n")).length>0&&(g+="\n"),(v=[b,_].filter(Pr).join("\n")).length>0&&(v+="\n")):(g=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,_,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+y,"#define MAX_BONES "+o.maxBones,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+d:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.displacementMap&&o.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.flatShading?"#define FLAT_SHADED":"",o.skinning?"#define USE_SKINNING":"",o.useVertexTexture?"#define BONE_TEXTURE":"",o.morphTargets?"#define USE_MORPHTARGETS":"",o.morphNormals&&!1===o.flatShading?"#define USE_MORPHNORMALS":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"",o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+l:"",o.sizeAttenuation?"#define USE_SIZEATTENUATION":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Pr).join("\n"),v=[b,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+i.name,_,o.alphaTest?"#define ALPHATEST "+o.alphaTest:"","#define GAMMA_FACTOR "+y,o.useFog&&o.fog?"#define USE_FOG":"",o.useFog&&o.fogExp?"#define FOG_EXP2":"",o.map?"#define USE_MAP":"",o.envMap?"#define USE_ENVMAP":"",o.envMap?"#define "+h:"",o.envMap?"#define "+d:"",o.envMap?"#define "+m:"",o.lightMap?"#define USE_LIGHTMAP":"",o.aoMap?"#define USE_AOMAP":"",o.emissiveMap?"#define USE_EMISSIVEMAP":"",o.bumpMap?"#define USE_BUMPMAP":"",o.normalMap?"#define USE_NORMALMAP":"",o.specularMap?"#define USE_SPECULARMAP":"",o.roughnessMap?"#define USE_ROUGHNESSMAP":"",o.metalnessMap?"#define USE_METALNESSMAP":"",o.alphaMap?"#define USE_ALPHAMAP":"",o.vertexColors?"#define USE_COLOR":"",o.gradientMap?"#define USE_GRADIENTMAP":"",o.flatShading?"#define FLAT_SHADED":"",o.doubleSided?"#define DOUBLE_SIDED":"",o.flipSided?"#define FLIP_SIDED":"",o.shadowMapEnabled?"#define USE_SHADOWMAP":"",o.shadowMapEnabled?"#define "+l:"",o.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",o.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",o.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",o.logarithmicDepthBuffer&&e.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",o.envMap&&e.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",o.toneMapping!==nt?"#define TONE_MAPPING":"",o.toneMapping!==nt?Qe.tonemapping_pars_fragment:"",o.toneMapping!==nt?function(t,e){var n;switch(e){case rt:n="Linear";break;case it:n="Reinhard";break;case ot:n="Uncharted2";break;case at:n="OptimizedCineon";break;default:throw new Error("unsupported toneMapping: "+e)}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}("toneMapping",o.toneMapping):"",o.dithering?"#define DITHERING":"",o.outputEncoding||o.mapEncoding||o.envMapEncoding||o.emissiveMapEncoding?Qe.encodings_pars_fragment:"",o.mapEncoding?Cr("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?Cr("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?Cr("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?function(t,e){var n=Rr(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}("linearToOutputTexel",o.outputEncoding):"",o.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(Pr).join("\n")),c=Or(c=Nr(c=Ir(c),o),o),u=Or(u=Nr(u=Ir(u),o),o);var w=g+(c=kr(c)),E=v+(u=kr(u)),M=Ar(a,a.VERTEX_SHADER,w),T=Ar(a,a.FRAGMENT_SHADER,E);a.attachShader(x,M),a.attachShader(x,T),void 0!==r.index0AttributeName?a.bindAttribLocation(x,0,r.index0AttributeName):!0===o.morphTargets&&a.bindAttribLocation(x,0,"position"),a.linkProgram(x);var S,A,L=a.getProgramInfoLog(x).trim(),R=a.getShaderInfoLog(M).trim(),C=a.getShaderInfoLog(T).trim(),P=!0,N=!0;return!1===a.getProgramParameter(x,a.LINK_STATUS)?(P=!1,console.error("THREE.WebGLProgram: shader error: ",a.getError(),"gl.VALIDATE_STATUS",a.getProgramParameter(x,a.VALIDATE_STATUS),"gl.getProgramInfoLog",L,R,C)):""!==L?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",L):""!==R&&""!==C||(N=!1),N&&(this.diagnostics={runnable:P,material:r,programLog:L,vertexShader:{log:R,prefix:g},fragmentShader:{log:C,prefix:v}}),a.deleteShader(M),a.deleteShader(T),this.getUniforms=function(){return void 0===S&&(S=new Sr(a,x,t)),S},this.getAttributes=function(){return void 0===A&&(A=function(t,e){for(var n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),i=0;i0,maxBones:d,useVertexTexture:n.floatVertexTextures,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:r.directional.length,numPointLights:r.point.length,numSpotLights:r.spot.length,numRectAreaLights:r.rectArea.length,numHemiLights:r.hemi.length,numClippingPlanes:c,numClipIntersection:u,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&l.receiveShadow&&o.length>0,shadowMapType:t.shadowMap.type,toneMapping:t.toneMapping,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===v,flipSided:e.side===g,depthPacking:void 0!==e.depthPacking&&e.depthPacking}},this.getProgramCode=function(e,n){var r=[];if(n.shaderID?r.push(n.shaderID):(r.push(e.fragmentShader),r.push(e.vertexShader)),void 0!==e.defines)for(var i in e.defines)r.push(i),r.push(e.defines[i]);for(var a=0;a1&&n.sort(Dr),r.length>1&&r.sort(Fr)}}},t[r]=i),i},dispose:function(){t={}}}}var Gr=0;function Hr(){var t=new function(){var t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];var n;switch(e.type){case"DirectionalLight":n={direction:new Fe,color:new tn,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"SpotLight":n={position:new Fe,direction:new Fe,color:new tn,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"PointLight":n={position:new Fe,color:new tn,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new Ue,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":n={direction:new Fe,skyColor:new tn,groundColor:new tn};break;case"RectAreaLight":n={color:new tn,position:new Fe,halfWidth:new Fe,halfHeight:new Fe}}return t[e.id]=n,n}}},e={id:Gr++,hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},n=new Fe,r=new Be,i=new Be;return{setup:function(o,a,s){for(var c=0,u=0,l=0,h=0,d=0,p=0,f=0,m=0,g=s.matrixWorldInverse,v=0,y=o.length;v0:s&&s.isGeometry&&(m=s.morphTargets&&s.morphTargets.length>0)),e.isSkinnedMesh&&!1===n.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e);var g=e.isSkinnedMesh&&n.skinning,v=0;m&&(v|=u),g&&(v|=l),c=h[v]}if(t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var _=c.uuid,x=n.uuid,w=y[_];void 0===w&&(w={},y[_]=w);var E=w[x];void 0===E&&(E=c.clone(),w[x]=E),c=E}return c.visible=n.visible,c.wireframe=n.wireframe,c.side=null!=n.shadowSide?n.shadowSide:b[n.side],c.clipShadows=n.clipShadows,c.clippingPlanes=n.clippingPlanes,c.clipIntersection=n.clipIntersection,c.wireframeLinewidth=n.wireframeLinewidth,c.linewidth=n.linewidth,r&&c.isMeshDistanceMaterial&&(c.referencePosition.copy(i),c.nearDistance=o,c.farDistance=a),c}function C(n,i,o,a){if(!1!==n.visible){if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&n.castShadow&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,n.matrixWorld);var s=e.update(n),u=n.material;if(Array.isArray(u))for(var l=s.groups,h=0,d=l.length;h 0 ) {","\t\tfloat fogFactor = 0.0;","\t\tif ( fogType == 1 ) {","\t\t\tfogFactor = smoothstep( fogNear, fogFar, fogDepth );","\t\t} else {","\t\t\tconst float LOG2 = 1.442695;","\t\t\tfogFactor = exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 );","\t\t\tfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","\t\t}","\t\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );","\t}","}"].join("\n")),e.compileShader(n),e.compileShader(r),e.attachShader(t,n),e.attachShader(t,r),e.linkProgram(t),t}(),c={position:e.getAttribLocation(s,"position"),uv:e.getAttribLocation(s,"uv")},u={uvOffset:e.getUniformLocation(s,"uvOffset"),uvScale:e.getUniformLocation(s,"uvScale"),rotation:e.getUniformLocation(s,"rotation"),center:e.getUniformLocation(s,"center"),scale:e.getUniformLocation(s,"scale"),color:e.getUniformLocation(s,"color"),map:e.getUniformLocation(s,"map"),opacity:e.getUniformLocation(s,"opacity"),modelViewMatrix:e.getUniformLocation(s,"modelViewMatrix"),projectionMatrix:e.getUniformLocation(s,"projectionMatrix"),fogType:e.getUniformLocation(s,"fogType"),fogDensity:e.getUniformLocation(s,"fogDensity"),fogNear:e.getUniformLocation(s,"fogNear"),fogFar:e.getUniformLocation(s,"fogFar"),fogColor:e.getUniformLocation(s,"fogColor"),fogDepth:e.getUniformLocation(s,"fogDepth"),alphaTest:e.getUniformLocation(s,"alphaTest")};var r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");r.width=8,r.height=8;var h=r.getContext("2d");h.fillStyle="white",h.fillRect(0,0,8,8),l=new Xr(r)}function m(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:e.id-t.id}this.render=function(i,g,v){if(0!==i.length){void 0===s&&f(),n.useProgram(s),n.initAttributes(),n.enableAttribute(c.position),n.enableAttribute(c.uv),n.disableUnusedAttributes(),n.disable(e.CULL_FACE),n.enable(e.BLEND),e.bindBuffer(e.ARRAY_BUFFER,o),e.vertexAttribPointer(c.position,2,e.FLOAT,!1,16,0),e.vertexAttribPointer(c.uv,2,e.FLOAT,!1,16,8),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),e.uniformMatrix4fv(u.projectionMatrix,!1,v.projectionMatrix.elements),n.activeTexture(e.TEXTURE0),e.uniform1i(u.map,0);var y=0,b=0,_=g.fog;_?(e.uniform3f(u.fogColor,_.color.r,_.color.g,_.color.b),_.isFog?(e.uniform1f(u.fogNear,_.near),e.uniform1f(u.fogFar,_.far),e.uniform1i(u.fogType,1),y=1,b=1):_.isFogExp2&&(e.uniform1f(u.fogDensity,_.density),e.uniform1i(u.fogType,2),y=2,b=2)):(e.uniform1i(u.fogType,0),y=0,b=0);for(var x=0,w=i.length;xe||t.height>e){if("data"in t)return void console.warn("THREE.WebGLRenderer: image in DataTexture is too big ("+t.width+"x"+t.height+").");var n=e/Math.max(t.width,t.height),r=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return r.width=Math.floor(t.width*n),r.height=Math.floor(t.height*n),r.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,r.width,r.height),console.warn("THREE.WebGLRenderer: image is too big ("+t.width+"x"+t.height+"). Resized to "+r.width+"x"+r.height,t),r}return t}function h(t){return ke.isPowerOfTwo(t.width)&&ke.isPowerOfTwo(t.height)}function d(t,e){return t.generateMipmaps&&e&&t.minFilter!==yt&&t.minFilter!==xt}function p(e,n,i,o){t.generateMipmap(e),r.get(n).__maxMipLevel=Math.log2(Math.max(i,o))}function f(e){return e===yt||e===bt||e===_t?t.NEAREST:t.LINEAR}function m(e){var n=e.target;n.removeEventListener("dispose",m),function(e){var n=r.get(e);if(e.image&&n.__image__webglTextureCube)t.deleteTexture(n.__image__webglTextureCube);else{if(void 0===n.__webglInit)return;t.deleteTexture(n.__webglTexture)}r.remove(e)}(n),n.isVideoTexture&&delete u[n.id],a.memory.textures--}function g(e){var n=e.target;n.removeEventListener("dispose",g),function(e){var n=r.get(e),i=r.get(e.texture);if(!e)return;void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLRenderTargetCube)for(var o=0;o<6;o++)t.deleteFramebuffer(n.__webglFramebuffer[o]),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer[o]);else t.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer);r.remove(e.texture),r.remove(e)}(n),a.memory.textures--}function v(e,f){var g=r.get(e);if(e.isVideoTexture&&function(t){var e=t.id,n=a.render.frame;u[e]!==n&&(u[e]=n,t.update())}(e),e.version>0&&g.__version!==e.version){var v=e.image;if(void 0===v)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",e);else{if(!1!==v.complete)return void function(e,r,u){void 0===e.__webglInit&&(e.__webglInit=!0,r.addEventListener("dispose",m),e.__webglTexture=t.createTexture(),a.memory.textures++);n.activeTexture(t.TEXTURE0+u),n.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,r.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,r.unpackAlignment);var f=l(r.image,i.maxTextureSize);(function(t){return t.wrapS!==gt||t.wrapT!==gt||t.minFilter!==yt&&t.minFilter!==xt})(r)&&!1===h(f)&&(f=function(t){return t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof ImageBitmap?(void 0===s&&(s=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),s.width=ke.floorPowerOfTwo(t.width),s.height=ke.floorPowerOfTwo(t.height),s.getContext("2d").drawImage(t,0,0,s.width,s.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+t.width+"x"+t.height+"). Resized to "+s.width+"x"+s.height,t),s):t}(f));var g=h(f),v=o.convert(r.format),b=o.convert(r.type);y(t.TEXTURE_2D,r,g);var _,x=r.mipmaps;if(r.isDepthTexture){var w=t.DEPTH_COMPONENT;if(r.type===Ct){if(!c)throw new Error("Float Depth Texture only supported in WebGL2.0");w=t.DEPTH_COMPONENT32F}else c&&(w=t.DEPTH_COMPONENT16);r.format===Ht&&w===t.DEPTH_COMPONENT&&r.type!==At&&r.type!==Rt&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=At,b=o.convert(r.type)),r.format===jt&&(w=t.DEPTH_STENCIL,r.type!==kt&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=kt,b=o.convert(r.type))),n.texImage2D(t.TEXTURE_2D,0,w,f.width,f.height,0,v,b,null)}else if(r.isDataTexture)if(x.length>0&&g){for(var E=0,M=x.length;E-1?n.compressedTexImage2D(t.TEXTURE_2D,E,v,_.width,_.height,0,_.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(t.TEXTURE_2D,E,v,_.width,_.height,0,v,b,_.data);e.__maxMipLevel=x.length-1}else if(x.length>0&&g){for(var E=0,M=x.length;E1||r.get(a).__currentAnisotropy)&&(t.texParameterf(n,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function b(e,i,a,s){var c=o.convert(i.texture.format),u=o.convert(i.texture.type);n.texImage2D(s,0,c,i.width,i.height,0,c,u,null),t.bindFramebuffer(t.FRAMEBUFFER,e),t.framebufferTexture2D(t.FRAMEBUFFER,a,s,r.get(i.texture).__webglTexture,0),t.bindFramebuffer(t.FRAMEBUFFER,null)}function _(e,n){t.bindRenderbuffer(t.RENDERBUFFER,e),n.depthBuffer&&!n.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e)):n.depthBuffer&&n.stencilBuffer?(t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,n.width,n.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e)):t.renderbufferStorage(t.RENDERBUFFER,t.RGBA4,n.width,n.height),t.bindRenderbuffer(t.RENDERBUFFER,null)}function x(e){var n=r.get(e),i=!0===e.isWebGLRenderTargetCube;if(e.depthTexture){if(i)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,n){if(n&&n.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(t.FRAMEBUFFER,e),!n.depthTexture||!n.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(n.depthTexture).__webglTexture&&n.depthTexture.image.width===n.width&&n.depthTexture.image.height===n.height||(n.depthTexture.image.width=n.width,n.depthTexture.image.height=n.height,n.depthTexture.needsUpdate=!0),v(n.depthTexture,0);var i=r.get(n.depthTexture).__webglTexture;if(n.depthTexture.format===Ht)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,i,0);else{if(n.depthTexture.format!==jt)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,i,0)}}(n.__webglFramebuffer,e)}else if(i){n.__webglDepthbuffer=[];for(var o=0;o<6;o++)t.bindFramebuffer(t.FRAMEBUFFER,n.__webglFramebuffer[o]),n.__webglDepthbuffer[o]=t.createRenderbuffer(),_(n.__webglDepthbuffer[o],e)}else t.bindFramebuffer(t.FRAMEBUFFER,n.__webglFramebuffer),n.__webglDepthbuffer=t.createRenderbuffer(),_(n.__webglDepthbuffer,e);t.bindFramebuffer(t.FRAMEBUFFER,null)}this.setTexture2D=v,this.setTextureCube=function(e,s){var c=r.get(e);if(6===e.image.length)if(e.version>0&&c.__version!==e.version){c.__image__webglTextureCube||(e.addEventListener("dispose",m),c.__image__webglTextureCube=t.createTexture(),a.memory.textures++),n.activeTexture(t.TEXTURE0+s),n.bindTexture(t.TEXTURE_CUBE_MAP,c.__image__webglTextureCube),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e.flipY);for(var u=e&&e.isCompressedTexture,f=e.image[0]&&e.image[0].isDataTexture,g=[],v=0;v<6;v++)g[v]=u||f?f?e.image[v].image:e.image[v]:l(e.image[v],i.maxCubemapSize);var b=g[0],_=h(b),x=o.convert(e.format),w=o.convert(e.type);for(y(t.TEXTURE_CUBE_MAP,e,_),v=0;v<6;v++)if(u)for(var E,M=g[v].mipmaps,T=0,S=M.length;T-1?n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,T,x,E.width,E.height,0,E.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,T,x,E.width,E.height,0,x,w,E.data);else f?n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,x,g[v].width,g[v].height,0,x,w,g[v].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,x,x,w,g[v]);c.__maxMipLevel=u?M.length-1:0,d(e,_)&&p(t.TEXTURE_CUBE_MAP,e,b.width,b.height),c.__version=e.version,e.onUpdate&&e.onUpdate(e)}else n.activeTexture(t.TEXTURE0+s),n.bindTexture(t.TEXTURE_CUBE_MAP,c.__image__webglTextureCube)},this.setTextureCubeDynamic=function(e,i){n.activeTexture(t.TEXTURE0+i),n.bindTexture(t.TEXTURE_CUBE_MAP,r.get(e).__webglTexture)},this.setupRenderTarget=function(e){var i=r.get(e),o=r.get(e.texture);e.addEventListener("dispose",g),o.__webglTexture=t.createTexture(),a.memory.textures++;var s=!0===e.isWebGLRenderTargetCube,c=h(e);if(s){i.__webglFramebuffer=[];for(var u=0;u<6;u++)i.__webglFramebuffer[u]=t.createFramebuffer()}else i.__webglFramebuffer=t.createFramebuffer();if(s){for(n.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture),y(t.TEXTURE_CUBE_MAP,e.texture,c),u=0;u<6;u++)b(i.__webglFramebuffer[u],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+u);d(e.texture,c)&&p(t.TEXTURE_CUBE_MAP,e.texture,e.width,e.height),n.bindTexture(t.TEXTURE_CUBE_MAP,null)}else n.bindTexture(t.TEXTURE_2D,o.__webglTexture),y(t.TEXTURE_2D,e.texture,c),b(i.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),d(e.texture,c)&&p(t.TEXTURE_2D,e.texture,e.width,e.height),n.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&x(e)},this.updateRenderTargetMipmap=function(e){var i=e.texture;if(d(i,h(e))){var o=e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,a=r.get(i).__webglTexture;n.bindTexture(o,a),p(o,i,e.width,e.height),n.bindTexture(o,null)}}}function Zr(t,e){return{convert:function(n){var r;if(n===mt)return t.REPEAT;if(n===gt)return t.CLAMP_TO_EDGE;if(n===vt)return t.MIRRORED_REPEAT;if(n===yt)return t.NEAREST;if(n===bt)return t.NEAREST_MIPMAP_NEAREST;if(n===_t)return t.NEAREST_MIPMAP_LINEAR;if(n===xt)return t.LINEAR;if(n===wt)return t.LINEAR_MIPMAP_NEAREST;if(n===Et)return t.LINEAR_MIPMAP_LINEAR;if(n===Mt)return t.UNSIGNED_BYTE;if(n===Nt)return t.UNSIGNED_SHORT_4_4_4_4;if(n===Ot)return t.UNSIGNED_SHORT_5_5_5_1;if(n===It)return t.UNSIGNED_SHORT_5_6_5;if(n===Tt)return t.BYTE;if(n===St)return t.SHORT;if(n===At)return t.UNSIGNED_SHORT;if(n===Lt)return t.INT;if(n===Rt)return t.UNSIGNED_INT;if(n===Ct)return t.FLOAT;if(n===Pt&&null!==(r=e.get("OES_texture_half_float")))return r.HALF_FLOAT_OES;if(n===Ut)return t.ALPHA;if(n===Bt)return t.RGB;if(n===Dt)return t.RGBA;if(n===Ft)return t.LUMINANCE;if(n===zt)return t.LUMINANCE_ALPHA;if(n===Ht)return t.DEPTH_COMPONENT;if(n===jt)return t.DEPTH_STENCIL;if(n===R)return t.FUNC_ADD;if(n===C)return t.FUNC_SUBTRACT;if(n===P)return t.FUNC_REVERSE_SUBTRACT;if(n===I)return t.ZERO;if(n===k)return t.ONE;if(n===U)return t.SRC_COLOR;if(n===B)return t.ONE_MINUS_SRC_COLOR;if(n===D)return t.SRC_ALPHA;if(n===F)return t.ONE_MINUS_SRC_ALPHA;if(n===z)return t.DST_ALPHA;if(n===G)return t.ONE_MINUS_DST_ALPHA;if(n===H)return t.DST_COLOR;if(n===j)return t.ONE_MINUS_DST_COLOR;if(n===V)return t.SRC_ALPHA_SATURATE;if((n===Vt||n===Wt||n===qt||n===Xt)&&null!==(r=e.get("WEBGL_compressed_texture_s3tc"))){if(n===Vt)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Wt)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===qt)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Xt)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((n===Yt||n===Jt||n===Zt||n===Qt)&&null!==(r=e.get("WEBGL_compressed_texture_pvrtc"))){if(n===Yt)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Jt)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Zt)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Qt)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===Kt&&null!==(r=e.get("WEBGL_compressed_texture_etc1")))return r.COMPRESSED_RGB_ETC1_WEBGL;if((n===$t||n===te||n===ee||n===ne||n===re||n===ie||n===oe||n===ae||n===se||n===ce||n===ue||n===le||n===he||n===de)&&null!==(r=e.get("WEBGL_compressed_texture_astc")))return n;if((n===N||n===O)&&null!==(r=e.get("EXT_blend_minmax"))){if(n===N)return r.MIN_EXT;if(n===O)return r.MAX_EXT}return n===kt&&null!==(r=e.get("WEBGL_depth_texture"))?r.UNSIGNED_INT_24_8_WEBGL:0}}}function Qr(t,e,n,r){un.call(this),this.type="PerspectiveCamera",this.fov=void 0!==t?t:50,this.zoom=1,this.near=void 0!==n?n:.1,this.far=void 0!==r?r:2e3,this.focus=10,this.aspect=void 0!==e?e:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function Kr(t){Qr.call(this),this.cameras=t||[]}function $r(t){var e=this,n=null,r=null,i=null,o=new Be,a=new Be;"undefined"!=typeof window&&"VRFrameData"in window&&(r=new window.VRFrameData);var s=new Be,c=new De,u=new Fe,l=new Qr;l.bounds=new je(0,0,.5,1),l.layers.enable(1);var h=new Qr;h.bounds=new je(.5,0,.5,1),h.layers.enable(2);var d,p,f=new Kr([l,h]);function m(){if(null!==n&&n.isPresenting){var r=n.getEyeParameters("left"),i=r.renderWidth,o=r.renderHeight;p=t.getPixelRatio(),d=t.getSize(),t.setDrawingBufferSize(2*i,o,1)}else e.enabled&&t.setDrawingBufferSize(d.width,d.height,p)}f.layers.enable(1),f.layers.enable(2),"undefined"!=typeof window&&window.addEventListener("vrdisplaypresentchange",m,!1),this.enabled=!1,this.userHeight=1.6,this.getDevice=function(){return n},this.setDevice=function(t){void 0!==t&&(n=t)},this.setPoseTarget=function(t){void 0!==t&&(i=t)},this.getCamera=function(t){if(null===n)return t;n.depthNear=t.near,n.depthFar=t.far,n.getFrameData(r);var d=n.stageParameters;d?o.fromArray(d.sittingToStandingTransform):o.makeTranslation(0,e.userHeight,0);var p=r.pose,m=null!==i?i:t;if(m.matrix.copy(o),m.matrix.decompose(m.position,m.quaternion,m.scale),null!==p.orientation&&(c.fromArray(p.orientation),m.quaternion.multiply(c)),null!==p.position&&(c.setFromRotationMatrix(o),u.fromArray(p.position),u.applyQuaternion(c),m.position.add(u)),m.updateMatrixWorld(),!1===n.isPresenting)return t;l.near=t.near,h.near=t.near,l.far=t.far,h.far=t.far,f.matrixWorld.copy(t.matrixWorld),f.matrixWorldInverse.copy(t.matrixWorldInverse),l.matrixWorldInverse.fromArray(r.leftViewMatrix),h.matrixWorldInverse.fromArray(r.rightViewMatrix),a.getInverse(o),l.matrixWorldInverse.multiply(a),h.matrixWorldInverse.multiply(a);var g=m.parent;null!==g&&(s.getInverse(g.matrixWorld),l.matrixWorldInverse.multiply(s),h.matrixWorldInverse.multiply(s)),l.matrixWorld.getInverse(l.matrixWorldInverse),h.matrixWorld.getInverse(h.matrixWorldInverse),l.projectionMatrix.fromArray(r.leftProjectionMatrix),h.projectionMatrix.fromArray(r.rightProjectionMatrix),f.projectionMatrix.copy(l.projectionMatrix);var v=n.getLayers();if(v.length){var y=v[0];null!==y.leftBounds&&4===y.leftBounds.length&&l.bounds.fromArray(y.leftBounds),null!==y.rightBounds&&4===y.rightBounds.length&&h.bounds.fromArray(y.rightBounds)}return f},this.getStandingMatrix=function(){return o},this.submitFrame=function(){n&&n.isPresenting&&n.submitFrame()},this.dispose=function(){"undefined"!=typeof window&&window.removeEventListener("vrdisplaypresentchange",m)}}function ti(t){console.log("THREE.WebGLRenderer",i);var e=void 0!==(t=t||{}).canvas?t.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),n=void 0!==t.context?t.context:null,r=void 0!==t.alpha&&t.alpha,o=void 0===t.depth||t.depth,u=void 0===t.stencil||t.stencil,l=void 0!==t.antialias&&t.antialias,h=void 0===t.premultipliedAlpha||t.premultipliedAlpha,d=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,p=void 0!==t.powerPreference?t.powerPreference:"default",f=null,m=null;this.domElement=e,this.context=null,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.gammaFactor=2,this.gammaInput=!1,this.gammaOutput=!1,this.physicallyCorrectLights=!1,this.toneMapping=rt,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var y,b,x,w,R,C,P,N,O,I,k,U,B,D,F,z,G,H,j,V=this,$=!1,tt=null,et=null,nt=-1,it="",ot=null,at=null,st=new je,ct=new je,ut=null,lt=0,ht=e.width,dt=e.height,pt=1,ft=new je(0,0,ht,dt),mt=new je(0,0,ht,dt),gt=!1,vt=new Ze,yt=new function(){var t=this,e=null,n=0,r=!1,i=!1,o=new Je,a=new ze,s={value:null,needsUpdate:!1};function c(){s.value!==e&&(s.value=e,s.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function u(e,n,r,i){var c=null!==e?e.length:0,u=null;if(0!==c){if(u=s.value,!0!==i||null===u){var l=r+4*c,h=n.matrixWorldInverse;a.getNormalMatrix(h),(null===u||u.length0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}var o=void 0!==n.precision?n.precision:"highp",a=i(o);a!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",a,"instead."),o=a);var s=!0===n.logarithmicDepthBuffer,c=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),u=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),l=t.getParameter(t.MAX_TEXTURE_SIZE),h=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),d=t.getParameter(t.MAX_VERTEX_ATTRIBS),p=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),f=t.getParameter(t.MAX_VARYING_VECTORS),m=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),g=u>0,v=!!e.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==r)return r;var n=e.get("EXT_texture_filter_anisotropic");return r=null!==n?t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:s,maxTextures:c,maxVertexTextures:u,maxTextureSize:l,maxCubemapSize:h,maxAttributes:d,maxVertexUniforms:p,maxVaryings:f,maxFragmentUniforms:m,vertexTextures:g,floatFragmentTextures:v,floatVertexTextures:g&&v}}(y,b,t),(w=new function(t,e,n){var r=new function(){var e=!1,n=new je,r=null,i=new je(0,0,0,0);return{setMask:function(n){r===n||e||(t.colorMask(n,n,n,n),r=n)},setLocked:function(t){e=t},setClear:function(e,r,o,a,s){!0===s&&(e*=a,r*=a,o*=a),n.set(e,r,o,a),!1===i.equals(n)&&(t.clearColor(e,r,o,a),i.copy(n))},reset:function(){e=!1,r=null,i.set(-1,0,0,0)}}},i=new function(){var e=!1,n=null,r=null,i=null;return{setTest:function(e){e?et(t.DEPTH_TEST):nt(t.DEPTH_TEST)},setMask:function(r){n===r||e||(t.depthMask(r),n=r)},setFunc:function(e){if(r!==e){if(e)switch(e){case W:t.depthFunc(t.NEVER);break;case q:t.depthFunc(t.ALWAYS);break;case X:t.depthFunc(t.LESS);break;case Y:t.depthFunc(t.LEQUAL);break;case J:t.depthFunc(t.EQUAL);break;case Z:t.depthFunc(t.GEQUAL);break;case Q:t.depthFunc(t.GREATER);break;case K:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}else t.depthFunc(t.LEQUAL);r=e}},setLocked:function(t){e=t},setClear:function(e){i!==e&&(t.clearDepth(e),i=e)},reset:function(){e=!1,n=null,r=null,i=null}}},o=new function(){var e=!1,n=null,r=null,i=null,o=null,a=null,s=null,c=null,u=null;return{setTest:function(e){e?et(t.STENCIL_TEST):nt(t.STENCIL_TEST)},setMask:function(r){n===r||e||(t.stencilMask(r),n=r)},setFunc:function(e,n,a){r===e&&i===n&&o===a||(t.stencilFunc(e,n,a),r=e,i=n,o=a)},setOp:function(e,n,r){a===e&&s===n&&c===r||(t.stencilOp(e,n,r),a=e,s=n,c=r)},setLocked:function(t){e=t},setClear:function(e){u!==e&&(t.clearStencil(e),u=e)},reset:function(){e=!1,n=null,r=null,i=null,o=null,a=null,s=null,c=null,u=null}}},u=t.getParameter(t.MAX_VERTEX_ATTRIBS),l=new Uint8Array(u),h=new Uint8Array(u),d=new Uint8Array(u),p={},f=null,m=null,y=null,b=null,_=null,x=null,w=null,R=null,C=null,P=!1,N=null,O=null,I=null,k=null,U=null,B=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS),D=!1,F=0,z=t.getParameter(t.VERSION);-1!==z.indexOf("WebGL")?(F=parseFloat(/^WebGL\ ([0-9])/.exec(z)[1]),D=F>=1):-1!==z.indexOf("OpenGL ES")&&(F=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(z)[1]),D=F>=2);var G=null,H={},j=new je,V=new je;function $(e,n,r){var i=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(e,t.TEXTURE_MAG_FILTER,t.NEAREST);for(var a=0;a65535?xn:bn)(a,1),e.update(r,t.ELEMENT_ARRAY_BUFFER),i[n.id]=r,r}}}(y,N,R),I=new function(t,e){var n={};return{update:function(r){var i=e.render.frame,o=r.geometry,a=t.get(r,o);return n[a.id]!==i&&(o.isGeometry&&a.updateFromObject(r),t.update(a),n[a.id]=i),a},dispose:function(){n={}}}}(O,R),F=new function(t){var e={},n=new Float32Array(8);return{update:function(r,i,o,a){var s=r.morphTargetInfluences,c=s.length,u=e[i.id];if(void 0===u){u=[];for(var l=0;l=0){var u=i[s];if(void 0!==u){var l=u.normalized,h=u.itemSize,d=N.get(u);if(void 0===d)continue;var p=d.buffer,f=d.type,m=d.bytesPerElement;if(u.isInterleavedBufferAttribute){var g=u.data,v=g.stride,_=u.offset;g&&g.isInstancedInterleavedBuffer?(w.enableAttributeAndDivisor(c,g.meshPerAttribute),void 0===n.maxInstancedCount&&(n.maxInstancedCount=g.meshPerAttribute*g.count)):w.enableAttribute(c),y.bindBuffer(y.ARRAY_BUFFER,p),y.vertexAttribPointer(c,h,f,l,v*m,(r*v+_)*m)}else u.isInstancedBufferAttribute?(w.enableAttributeAndDivisor(c,u.meshPerAttribute),void 0===n.maxInstancedCount&&(n.maxInstancedCount=u.meshPerAttribute*u.count)):w.enableAttribute(c),y.bindBuffer(y.ARRAY_BUFFER,p),y.vertexAttribPointer(c,h,f,l,0,r*h*m)}else if(void 0!==a){var x=a[s];if(void 0!==x)switch(x.length){case 2:y.vertexAttrib2fv(c,x);break;case 3:y.vertexAttrib3fv(c,x);break;case 4:y.vertexAttrib4fv(c,x);break;default:y.vertexAttrib1fv(c,x)}}}}w.disableUnusedAttributes()}(r,s,n),null!==h&&y.bindBuffer(y.ELEMENT_ARRAY_BUFFER,l.buffer));var m=1/0;null!==h?m=h.count:void 0!==d&&(m=d.count);var g=n.drawRange.start*p,v=n.drawRange.count*p,_=null!==o?o.start*p:0,x=null!==o?o.count*p:1/0,E=Math.max(g,_),M=Math.min(m,g+v,_+x)-1,T=Math.max(0,M-E+1);if(0!==T){if(i.isMesh)if(!0===r.wireframe)w.setLineWidth(r.wireframeLinewidth*Et()),f.setMode(y.LINES);else switch(i.drawMode){case we:f.setMode(y.TRIANGLES);break;case Ee:f.setMode(y.TRIANGLE_STRIP);break;case Me:f.setMode(y.TRIANGLE_FAN)}else if(i.isLine){var S=r.linewidth;void 0===S&&(S=1),w.setLineWidth(S*Et()),i.isLineSegments?f.setMode(y.LINES):i.isLineLoop?f.setMode(y.LINE_LOOP):f.setMode(y.LINE_STRIP)}else i.isPoints&&f.setMode(y.POINTS);n&&n.isInstancedBufferGeometry?n.maxInstancedCount>0&&f.renderInstances(n,E,T):f.render(E,T)}},this.compile=function(t,e){(m=B.get(t,e)).init(),t.traverse(function(t){t.isLight&&(m.pushLight(t),t.castShadow&&m.pushShadow(t))}),m.setupLights(e),t.traverse(function(e){if(e.material)if(Array.isArray(e.material))for(var n=0;n=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(d=0;d=0&&t.numSupportedMorphNormals++}var p=r.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(r.numClippingPlanes=yt.numPlanes,r.numIntersection=yt.numIntersection,p.clippingPlanes=yt.uniform),r.fog=e,r.lightsHash=i.state.hash,t.lights&&(p.ambientLightColor.value=i.state.ambient,p.directionalLights.value=i.state.directional,p.spotLights.value=i.state.spot,p.rectAreaLights.value=i.state.rectArea,p.pointLights.value=i.state.point,p.hemisphereLights.value=i.state.hemi,p.directionalShadowMap.value=i.state.directionalShadowMap,p.directionalShadowMatrix.value=i.state.directionalShadowMatrix,p.spotShadowMap.value=i.state.spotShadowMap,p.spotShadowMatrix.value=i.state.spotShadowMatrix,p.pointShadowMap.value=i.state.pointShadowMap,p.pointShadowMatrix.value=i.state.pointShadowMatrix);var f=r.program.getUniforms(),g=Sr.seqWithValue(f.seq,p);r.uniformsList=g}function Vt(t,e,n,r){lt=0;var i=C.get(n),o=m.state.lights;if(bt&&(_t||t!==ot)){var a=t===ot&&n.id===nt;yt.setState(n.clippingPlanes,n.clipIntersection,n.clipShadows,t,i,a)}!1===n.needsUpdate&&(void 0===i.program?n.needsUpdate=!0:n.fog&&i.fog!==e?n.needsUpdate=!0:n.lights&&i.lightsHash!==o.state.hash?n.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===yt.numPlanes&&i.numIntersection===yt.numIntersection||(n.needsUpdate=!0)),n.needsUpdate&&(jt(n,e,r),n.needsUpdate=!1);var s=!1,c=!1,u=!1,l=i.program,h=l.getUniforms(),d=i.shader.uniforms;if(w.useProgram(l.program)&&(s=!0,c=!0,u=!0),n.id!==nt&&(nt=n.id,c=!0),s||t!==ot){if(h.setValue(y,"projectionMatrix",t.projectionMatrix),x.logarithmicDepthBuffer&&h.setValue(y,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),ot!==(at||t)&&(ot=at||t,c=!0,u=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.envMap){var p=h.map.cameraPosition;void 0!==p&&p.setValue(y,wt.setFromMatrixPosition(t.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.skinning)&&h.setValue(y,"viewMatrix",t.matrixWorldInverse)}if(n.skinning){h.setOptional(y,r,"bindMatrix"),h.setOptional(y,r,"bindMatrixInverse");var f=r.skeleton;if(f){var g=f.bones;if(x.floatVertexTextures){if(void 0===f.boneTexture){var v=Math.sqrt(4*g.length);v=ke.ceilPowerOfTwo(v),v=Math.max(v,4);var b=new Float32Array(v*v*4);b.set(f.boneMatrices);var _=new qe(b,v,v,Dt,Ct);_.needsUpdate=!0,f.boneMatrices=b,f.boneTexture=_,f.boneTextureSize=v}h.setValue(y,"boneTexture",f.boneTexture),h.setValue(y,"boneTextureSize",f.boneTextureSize)}else h.setOptional(y,f,"boneMatrices")}}return c&&(h.setValue(y,"toneMappingExposure",V.toneMappingExposure),h.setValue(y,"toneMappingWhitePoint",V.toneMappingWhitePoint),n.lights&&function(t,e){t.ambientLightColor.needsUpdate=e,t.directionalLights.needsUpdate=e,t.pointLights.needsUpdate=e,t.spotLights.needsUpdate=e,t.rectAreaLights.needsUpdate=e,t.hemisphereLights.needsUpdate=e}(d,u),e&&n.fog&&function(t,e){t.fogColor.value=e.color,e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}(d,e),n.isMeshBasicMaterial?Wt(d,n):n.isMeshLambertMaterial?(Wt(d,n),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(d,n)):n.isMeshPhongMaterial?(Wt(d,n),n.isMeshToonMaterial?function(t,e){qt(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(d,n):qt(d,n)):n.isMeshStandardMaterial?(Wt(d,n),n.isMeshPhysicalMaterial?function(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,Xt(t,e)}(d,n):Xt(d,n)):n.isMeshDepthMaterial?(Wt(d,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(d,n)):n.isMeshDistanceMaterial?(Wt(d,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias);t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(d,n)):n.isMeshNormalMaterial?(Wt(d,n),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale);e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale));e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(d,n)):n.isLineBasicMaterial?(function(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}(d,n),n.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(d,n)):n.isPointsMaterial?function(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*pt,t.scale.value=.5*dt,t.map.value=e.map,null!==e.map){if(!0===e.map.matrixAutoUpdate){var n=e.map.offset,r=e.map.repeat,i=e.map.rotation,o=e.map.center;e.map.matrix.setUvTransform(n.x,n.y,r.x,r.y,i,o.x,o.y)}t.uvTransform.value.copy(e.map.matrix)}}(d,n):n.isShadowMaterial&&(d.color.value=n.color,d.opacity.value=n.opacity),void 0!==d.ltc_1&&(d.ltc_1.value=en.LTC_1),void 0!==d.ltc_2&&(d.ltc_2.value=en.LTC_2),Sr.upload(y,i.uniformsList,d,V)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(Sr.upload(y,i.uniformsList,d,V),n.uniformsNeedUpdate=!1),h.setValue(y,"modelViewMatrix",r.modelViewMatrix),h.setValue(y,"normalMatrix",r.normalMatrix),h.setValue(y,"modelMatrix",r.matrixWorld),l}function Wt(t,e){var n;if(t.opacity.value=e.opacity,e.color&&(t.diffuse.value=e.color),e.emissive&&t.emissive.value.copy(e.emissive).multiplyScalar(e.emissiveIntensity),e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.specularMap&&(t.specularMap.value=e.specularMap),e.envMap&&(t.envMap.value=e.envMap,t.flipEnvMap.value=e.envMap&&e.envMap.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio,t.maxMipLevel.value=C.get(e.envMap).__maxMipLevel),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity),e.map?n=e.map:e.specularMap?n=e.specularMap:e.displacementMap?n=e.displacementMap:e.normalMap?n=e.normalMap:e.bumpMap?n=e.bumpMap:e.roughnessMap?n=e.roughnessMap:e.metalnessMap?n=e.metalnessMap:e.alphaMap?n=e.alphaMap:e.emissiveMap&&(n=e.emissiveMap),void 0!==n){if(n.isWebGLRenderTarget&&(n=n.texture),!0===n.matrixAutoUpdate){var r=n.offset,i=n.repeat,o=n.rotation,a=n.center;n.matrix.setUvTransform(r.x,r.y,i.x,i.y,o,a.x,a.y)}t.uvTransform.value.copy(n.matrix)}}function qt(t,e){t.specular.value=e.specular,t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function Xt(t,e){t.roughness.value=e.roughness,t.metalness.value=e.metalness,e.roughnessMap&&(t.roughnessMap.value=e.roughnessMap),e.metalnessMap&&(t.metalnessMap.value=e.metalnessMap),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap),e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale)),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}this.animate=function(t){null!==(Ut=t)?kt||(Ft(),kt=!0):Bt()},this.render=function(t,e,n,r){if(e&&e.isCamera){if(!$){it="",nt=-1,ot=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),At.enabled&&(e=At.getCamera(e)),(m=B.get(t,e)).init(),t.onBeforeRender(V,t,e,n),xt.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),vt.setFromMatrix(xt),_t=this.localClippingEnabled,bt=yt.init(this.clippingPlanes,_t,e),(f=U.get(t,e)).init(),function t(e,n,r){if(!1===e.visible)return;var i=e.layers.test(n.layers);if(i)if(e.isLight)m.pushLight(e),e.castShadow&&m.pushShadow(e);else if(e.isSprite)e.frustumCulled&&!vt.intersectsSprite(e)||m.pushSprite(e);else if(e.isImmediateRenderObject)r&&wt.setFromMatrixPosition(e.matrixWorld).applyMatrix4(xt),f.push(e,null,e.material,wt.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.update(),!e.frustumCulled||vt.intersectsObject(e))){r&&wt.setFromMatrixPosition(e.matrixWorld).applyMatrix4(xt);var o=I.update(e),a=e.material;if(Array.isArray(a))for(var s=o.groups,c=0,u=s.length;c=x.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+t+" texture units while this GPU supports only "+x.maxTextures),lt+=1,t},this.setTexture2D=function(){var t=!1;return function(e,n){e&&e.isWebGLRenderTarget&&(t||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),t=!0),e=e.texture),P.setTexture2D(e,n)}}(),this.setTexture=function(){var t=!1;return function(e,n){t||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),t=!0),P.setTexture2D(e,n)}}(),this.setTextureCube=function(){var t=!1;return function(e,n){e&&e.isWebGLRenderTargetCube&&(t||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."),t=!0),e=e.texture),e&&e.isCubeTexture||Array.isArray(e.image)&&6===e.image.length?P.setTextureCube(e,n):P.setTextureCubeDynamic(e,n)}}(),this.getRenderTarget=function(){return tt},this.setRenderTarget=function(t){tt=t,t&&void 0===C.get(t).__webglFramebuffer&&P.setupRenderTarget(t);var e=null,n=!1;if(t){var r=C.get(t).__webglFramebuffer;t.isWebGLRenderTargetCube?(e=r[t.activeCubeFace],n=!0):e=r,st.copy(t.viewport),ct.copy(t.scissor),ut=t.scissorTest}else st.copy(ft).multiplyScalar(pt),ct.copy(mt).multiplyScalar(pt),ut=gt;if(et!==e&&(y.bindFramebuffer(y.FRAMEBUFFER,e),et=e),w.viewport(st),w.scissor(ct),w.setScissorTest(ut),n){var i=C.get(t.texture);y.framebufferTexture2D(y.FRAMEBUFFER,y.COLOR_ATTACHMENT0,y.TEXTURE_CUBE_MAP_POSITIVE_X+t.activeCubeFace,i.__webglTexture,t.activeMipMapLevel)}},this.readRenderTargetPixels=function(t,e,n,r,i,o){if(t&&t.isWebGLRenderTarget){var a=C.get(t).__webglFramebuffer;if(a){var s=!1;a!==et&&(y.bindFramebuffer(y.FRAMEBUFFER,a),s=!0);try{var c=t.texture,u=c.format,l=c.type;if(u!==Dt&&j.convert(u)!==y.getParameter(y.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(l===Mt||j.convert(l)===y.getParameter(y.IMPLEMENTATION_COLOR_READ_TYPE)||l===Ct&&(b.get("OES_texture_float")||b.get("WEBGL_color_buffer_float"))||l===Pt&&b.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");y.checkFramebufferStatus(y.FRAMEBUFFER)===y.FRAMEBUFFER_COMPLETE?e>=0&&e<=t.width-r&&n>=0&&n<=t.height-i&&y.readPixels(e,n,r,i,j.convert(u),j.convert(l),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&y.bindFramebuffer(y.FRAMEBUFFER,et)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(t,e,n){var r=e.image.width,i=e.image.height,o=j.convert(e.format);this.setTexture2D(e,0),y.copyTexImage2D(y.TEXTURE_2D,n||0,o,t.x,t.y,r,i,0)},this.copyTextureToTexture=function(t,e,n,r){var i=e.image.width,o=e.image.height,a=j.convert(n.format),s=j.convert(n.type),c=e.isDataTexture?e.image.data:e.image;this.setTexture2D(n,0),y.texSubImage2D(y.TEXTURE_2D,r||0,t.x,t.y,i,o,a,s,c)}}function ei(t,e){this.name="",this.color=new tn(t),this.density=void 0!==e?e:25e-5}function ni(t,e,n){this.name="",this.color=new tn(t),this.near=void 0!==e?e:1,this.far=void 0!==n?n:1e3}function ri(){cn.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function ii(t){On.call(this),this.type="SpriteMaterial",this.color=new tn(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function oi(t){cn.call(this),this.type="Sprite",this.material=void 0!==t?t:new ii,this.center=new Ue(.5,.5)}function ai(){cn.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function si(t,e){if(t=t||[],this.bones=t.slice(0),this.boneMatrices=new Float32Array(16*this.bones.length),void 0===e)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[];for(var n=0,r=this.bones.length;n=0?(t(g-1e-5,m,h),d.subVectors(l,h)):(t(g+1e-5,m,h),d.subVectors(h,l)),m-1e-5>=0?(t(g,m-1e-5,h),p.subVectors(l,h)):(t(g,m+1e-5,h),p.subVectors(h,l)),u.crossVectors(d,p).normalize(),s.push(u.x,u.y,u.z),c.push(g,m)}}for(r=0;r.9&&a<.1&&(e<.2&&(o[t+0]+=1),n<.2&&(o[t+2]+=1),r<.2&&(o[t+4]+=1))}}()}(),this.addAttribute("position",new wn(i,3)),this.addAttribute("normal",new wn(i.slice(),3)),this.addAttribute("uv",new wn(o,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}function Ti(t,e){pn.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Si(t,e)),this.mergeVertices()}function Si(t,e){Mi.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,e),this.type="TetrahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Ai(t,e){pn.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Li(t,e)),this.mergeVertices()}function Li(t,e){Mi.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,e),this.type="OctahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Ri(t,e){pn.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Ci(t,e)),this.mergeVertices()}function Ci(t,e){var n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1];Mi.call(this,r,[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],t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Pi(t,e){pn.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Ni(t,e)),this.mergeVertices()}function Ni(t,e){var n=(1+Math.sqrt(5))/2,r=1/n,i=[-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,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r];Mi.call(this,i,[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,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Oi(t,e,n,r,i,o){pn.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:r,closed:i},void 0!==o&&console.warn("THREE.TubeGeometry: taper has been removed.");var a=new Ii(t,e,n,r,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}function Ii(t,e,n,r,i){An.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:r,closed:i},e=e||64,n=n||1,r=r||8,i=i||!1;var o=t.computeFrenetFrames(e,i);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;var a,s,c=new Fe,u=new Fe,l=new Ue,h=new Fe,d=[],p=[],f=[],m=[];function g(i){h=t.getPointAt(i/e,h);var a=o.normals[i],l=o.binormals[i];for(s=0;s<=r;s++){var f=s/r*Math.PI*2,m=Math.sin(f),g=-Math.cos(f);u.x=g*a.x+m*l.x,u.y=g*a.y+m*l.y,u.z=g*a.z+m*l.z,u.normalize(),p.push(u.x,u.y,u.z),c.x=h.x+n*u.x,c.y=h.y+n*u.y,c.z=h.z+n*u.z,d.push(c.x,c.y,c.z)}}!function(){for(a=0;ao)){var a=r.ray.origin.distanceTo(t);ar.far||i.push({distance:a,point:t.clone(),face:null,object:this})}}}(),clone:function(){return new this.constructor(this.material).copy(this)},copy:function(t){return cn.prototype.copy.call(this,t),void 0!==t.center&&this.center.copy(t.center),this}}),ai.prototype=Object.assign(Object.create(cn.prototype),{constructor:ai,copy:function(t){cn.prototype.copy.call(this,t,!1);for(var e=t.levels,n=0,r=e.length;n1){t.setFromMatrixPosition(n.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var i=t.distanceTo(e);r[0].object.visible=!0;for(var o=1,a=r.length;o=r[o].distance;o++)r[o-1].object.visible=!1,r[o].object.visible=!0;for(;oa))d.applyMatrix4(this.matrixWorld),(E=r.ray.origin.distanceTo(d))r.far||i.push({distance:E,point:h.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}else for(v=0,y=m.length/3-1;va))d.applyMatrix4(this.matrixWorld),(E=r.ray.origin.distanceTo(d))r.far||i.push({distance:E,point:h.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}else if(s.isGeometry){var x=s.vertices,w=x.length;for(v=0;va))d.applyMatrix4(this.matrixWorld),(E=r.ray.origin.distanceTo(d))r.far||i.push({distance:E,point:h.clone().applyMatrix4(this.matrixWorld),index:v,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),di.prototype=Object.assign(Object.create(hi.prototype),{constructor:di,isLineSegments:!0,computeLineDistances:function(){var t=new Fe,e=new Fe;return function(){var n=this.geometry;if(n.isBufferGeometry)if(null===n.index){for(var r=n.attributes.position,i=[],o=0,a=r.count;or.far)return;i.push({distance:c,distanceToRay:Math.sqrt(a),point:d.clone(),index:n,face:null,object:o})}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),gi.prototype=Object.assign(Object.create(cn.prototype),{constructor:gi,isGroup:!0}),vi.prototype=Object.assign(Object.create(He.prototype),{constructor:vi,isVideoTexture:!0,update:function(){var t=this.image;t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),yi.prototype=Object.create(He.prototype),yi.prototype.constructor=yi,yi.prototype.isCompressedTexture=!0,bi.prototype=Object.create(He.prototype),bi.prototype.constructor=bi,bi.prototype.isDepthTexture=!0,_i.prototype=Object.create(An.prototype),_i.prototype.constructor=_i,xi.prototype=Object.create(pn.prototype),xi.prototype.constructor=xi,wi.prototype=Object.create(An.prototype),wi.prototype.constructor=wi,Ei.prototype=Object.create(pn.prototype),Ei.prototype.constructor=Ei,Mi.prototype=Object.create(An.prototype),Mi.prototype.constructor=Mi,Ti.prototype=Object.create(pn.prototype),Ti.prototype.constructor=Ti,Si.prototype=Object.create(Mi.prototype),Si.prototype.constructor=Si,Ai.prototype=Object.create(pn.prototype),Ai.prototype.constructor=Ai,Li.prototype=Object.create(Mi.prototype),Li.prototype.constructor=Li,Ri.prototype=Object.create(pn.prototype),Ri.prototype.constructor=Ri,Ci.prototype=Object.create(Mi.prototype),Ci.prototype.constructor=Ci,Pi.prototype=Object.create(pn.prototype),Pi.prototype.constructor=Pi,Ni.prototype=Object.create(Mi.prototype),Ni.prototype.constructor=Ni,Oi.prototype=Object.create(pn.prototype),Oi.prototype.constructor=Oi,Ii.prototype=Object.create(An.prototype),Ii.prototype.constructor=Ii,ki.prototype=Object.create(pn.prototype),ki.prototype.constructor=ki,Ui.prototype=Object.create(An.prototype),Ui.prototype.constructor=Ui,Bi.prototype=Object.create(pn.prototype),Bi.prototype.constructor=Bi,Di.prototype=Object.create(An.prototype),Di.prototype.constructor=Di;var Fi=function(t,e,n){n=n||2;var r,i,o,a,s,c,u,l=e&&e.length,h=l?e[0]*n:t.length,d=zi(t,0,h,n,!0),p=[];if(!d)return p;if(l&&(d=function(t,e,n,r){var i,o,a,s,c,u=[];for(i=0,o=e.length;i80*n){r=o=t[0],i=a=t[1];for(var f=n;fo&&(o=s),c>a&&(a=c);u=0!==(u=Math.max(o-r,a-i))?1/u:0}return Hi(d,p,n,r,i,u),p};function zi(t,e,n,r,i){var o,a;if(i===function(t,e,n,r){for(var i=0,o=e,a=n-r;o0)for(o=e;o=e;o-=r)a=io(o,t[o],t[o+1],a);return a&&to(a,a.next)&&(oo(a),a=a.next),a}function Gi(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!to(r,r.next)&&0!==$i(r.prev,r,r.next))r=r.next;else{if(oo(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function Hi(t,e,n,r,i,o,a){if(t){!a&&o&&function(t,e,n,r){var i=t;do{null===i.z&&(i.z=Ji(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,o,a,s,c,u=1;do{for(n=t,t=null,o=null,a=0;n;){for(a++,r=n,s=0,e=0;e0||c>0&&r;)0!==s&&(0===c||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,c--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;n=r}o.nextZ=null,u*=2}while(a>1)}(i)}(t,r,i,o);for(var s,c,u=t;t.prev!==t.next;)if(s=t.prev,c=t.next,o?Vi(t,r,i,o):ji(t))e.push(s.i/n),e.push(t.i/n),e.push(c.i/n),oo(t),t=c.next,u=c.next;else if((t=c)===u){a?1===a?Hi(t=Wi(t,e,n),e,n,r,i,o,2):2===a&&qi(t,e,n,r,i,o):Hi(Gi(t),e,n,r,i,o,1);break}}}function ji(t){var e=t.prev,n=t,r=t.next;if($i(e,n,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(Qi(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&$i(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Vi(t,e,n,r){var i=t.prev,o=t,a=t.next;if($i(i,o,a)>=0)return!1;for(var s=i.xo.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,l=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,h=Ji(s,c,e,n,r),d=Ji(u,l,e,n,r),p=t.nextZ;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&Qi(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&$i(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=h;){if(p!==t.prev&&p!==t.next&&Qi(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&$i(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function Wi(t,e,n){var r=t;do{var i=r.prev,o=r.next.next;!to(i,o)&&eo(i,r,r.next,o)&&no(i,o)&&no(o,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(o.i/n),oo(r),oo(r.next),r=t=o),r=r.next}while(r!==t);return r}function qi(t,e,n,r,i,o){var a=t;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Ki(a,s)){var c=ro(a,s);return a=Gi(a,a.next),c=Gi(c,c.next),Hi(a,e,n,r,i,o),void Hi(c,e,n,r,i,o)}s=s.next}a=a.next}while(a!==t)}function Xi(t,e){return t.x-e.x}function Yi(t,e){if(e=function(t,e){var n,r=e,i=t.x,o=t.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a){if(a=s,s===i){if(o===r.y)return r;if(o===r.next.y)return r.next}n=r.x=r.x&&r.x>=l&&i!==r.x&&Qi(on.x)&&no(r,t)&&(n=r,d=c),r=r.next;return n}(t,e)){var n=ro(e,t);Gi(n,n.next)}}function Ji(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Zi(t){var e=t,n=t;do{e.x=0&&(t-a)*(r-s)-(n-a)*(e-s)>=0&&(n-a)*(o-s)-(i-a)*(r-s)>=0}function Ki(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&eo(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&no(t,e)&&no(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)}function $i(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function to(t,e){return t.x===e.x&&t.y===e.y}function eo(t,e,n,r){return!!(to(t,e)&&to(n,r)||to(t,r)&&to(n,e))||$i(t,e,n)>0!=$i(t,e,r)>0&&$i(n,r,t)>0!=$i(n,r,e)>0}function no(t,e){return $i(t.prev,t,t.next)<0?$i(t,e,t.next)>=0&&$i(t,t.prev,e)>=0:$i(t,e,t.prev)<0||$i(t,t.next,e)<0}function ro(t,e){var n=new ao(t.i,t.x,t.y),r=new ao(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function io(t,e,n,r){var i=new ao(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function oo(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function ao(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}var so={area:function(t){for(var e=t.length,n=0,r=e-1,i=0;i2&&t[e-1].equals(t[0])&&t.pop()}function uo(t,e){for(var n=0;n0)&&f.push(x,w,M),(c!==n-1||u0&&v(!0),e>0&&v(!1)),this.setIndex(u),this.addAttribute("position",new wn(l,3)),this.addAttribute("normal",new wn(h,3)),this.addAttribute("uv",new wn(d,2))}function Ao(t,e,n,r,i,o,a){To.call(this,0,t,e,n,r,i,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:o,thetaLength:a}}function Lo(t,e,n,r,i,o,a){So.call(this,0,t,e,n,r,i,o,a),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:o,thetaLength:a}}function Ro(t,e,n,r){pn.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},this.fromBufferGeometry(new Co(t,e,n,r)),this.mergeVertices()}function Co(t,e,n,r){An.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},t=t||1,e=void 0!==e?Math.max(3,e):8,n=void 0!==n?n:0,r=void 0!==r?r:2*Math.PI;var i,o,a=[],s=[],c=[],u=[],l=new Fe,h=new Ue;for(s.push(0,0,0),c.push(0,0,1),u.push(.5,.5),o=0,i=3;o<=e;o++,i+=3){var d=n+o/e*r;l.x=t*Math.cos(d),l.y=t*Math.sin(d),s.push(l.x,l.y,l.z),c.push(0,0,1),h.x=(s[i]/t+1)/2,h.y=(s[i+1]/t+1)/2,u.push(h.x,h.y)}for(i=1;i<=e;i++)a.push(i,i+1,0);this.setIndex(a),this.addAttribute("position",new wn(s,3)),this.addAttribute("normal",new wn(c,3)),this.addAttribute("uv",new wn(u,2))}lo.prototype=Object.create(pn.prototype),lo.prototype.constructor=lo,ho.prototype=Object.create(An.prototype),ho.prototype.constructor=ho,ho.prototype.getArrays=function(){var t=this.getAttribute("position"),e=t?Array.prototype.slice.call(t.array):[],n=this.getAttribute("uv"),r=n?Array.prototype.slice.call(n.array):[],i=this.index;return{position:e,uv:r,index:i?Array.prototype.slice.call(i.array):[]}},ho.prototype.addShapeList=function(t,e){var n=t.length;e.arrays=this.getArrays();for(var r=0;rNumber.EPSILON){var d=Math.sqrt(l),p=Math.sqrt(c*c+u*u),f=e.x-s/d,m=e.y+a/d,g=((n.x-u/p-f)*u-(n.y+c/p-m)*c)/(a*u-s*c),v=(r=f+a*g-t.x)*r+(i=m+s*g-t.y)*i;if(v<=2)return new Ue(r,i);o=Math.sqrt(v/2)}else{var y=!1;a>Number.EPSILON?c>Number.EPSILON&&(y=!0):a<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(u)&&(y=!0),y?(r=-s,i=a,o=Math.sqrt(l)):(r=a,i=s,o=Math.sqrt(l/2))}return new Ue(r/o,i/o)}for(var G=[],H=0,j=C.length,V=j-1,W=H+1;H=0;N--){for(I=N/y,k=g*Math.cos(I*Math.PI/2),O=v*Math.sin(I*Math.PI/2),H=0,j=C.length;H=0;){n=H,(r=H-1)<0&&(r=t.length-1);var i=0,o=x+2*y;for(i=0;i0||0===t.search(/^data\:image\/jpeg/);i.format=r?Bt:Dt,i.needsUpdate=!0,void 0!==e&&e(i)},n,r),i},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Object.assign(Ko.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,e){var n=this.getUtoTmapping(t);return this.getPoint(n,e)},getPoints:function(t){void 0===t&&(t=5);for(var e=[],n=0;n<=t;n++)e.push(this.getPoint(n/t));return e},getSpacedPoints:function(t){void 0===t&&(t=5);for(var e=[],n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,n,r=[],i=this.getPoint(0),o=0;for(r.push(0),n=1;n<=t;n++)o+=(e=this.getPoint(n/t)).distanceTo(i),r.push(o),i=e;return this.cacheArcLengths=r,r},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){var n,r=this.getLengths(),i=0,o=r.length;n=e||t*r[o-1];for(var a,s=0,c=o-1;s<=c;)if((a=r[i=Math.floor(s+(c-s)/2)]-n)<0)s=i+1;else{if(!(a>0)){c=i;break}c=i-1}if(r[i=c]===n)return i/(o-1);var u=r[i];return(i+(n-u)/(r[i+1]-u))/(o-1)},getTangent:function(t){var e=t-1e-4,n=t+1e-4;e<0&&(e=0),n>1&&(n=1);var r=this.getPoint(e);return this.getPoint(n).clone().sub(r).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var n,r,i,o=new Fe,a=[],s=[],c=[],u=new Fe,l=new Be;for(n=0;n<=t;n++)r=n/t,a[n]=this.getTangentAt(r),a[n].normalize();s[0]=new Fe,c[0]=new Fe;var h=Number.MAX_VALUE,d=Math.abs(a[0].x),p=Math.abs(a[0].y),f=Math.abs(a[0].z);for(d<=h&&(h=d,o.set(1,0,0)),p<=h&&(h=p,o.set(0,1,0)),f<=h&&o.set(0,0,1),u.crossVectors(a[0],o).normalize(),s[0].crossVectors(a[0],u),c[0].crossVectors(a[0],s[0]),n=1;n<=t;n++)s[n]=s[n-1].clone(),c[n]=c[n-1].clone(),u.crossVectors(a[n-1],a[n]),u.length()>Number.EPSILON&&(u.normalize(),i=Math.acos(ke.clamp(a[n-1].dot(a[n]),-1,1)),s[n].applyMatrix4(l.makeRotationAxis(u,i))),c[n].crossVectors(a[n],s[n]);if(!0===e)for(i=Math.acos(ke.clamp(s[0].dot(s[t]),-1,1)),i/=t,a[0].dot(u.crossVectors(s[0],s[t]))>0&&(i=-i),n=1;n<=t;n++)s[n].applyMatrix4(l.makeRotationAxis(a[n],i*n)),c[n].crossVectors(a[n],s[n]);return{tangents:a,normals:s,binormals:c}},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this},toJSON:function(){var t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t},fromJSON:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}),$o.prototype=Object.create(Ko.prototype),$o.prototype.constructor=$o,$o.prototype.isEllipseCurve=!0,$o.prototype.getPoint=function(t,e){for(var n=e||new Ue,r=2*Math.PI,i=this.aEndAngle-this.aStartAngle,o=Math.abs(i)r;)i-=r;i0?0:(Math.floor(Math.abs(l)/s.length)+1)*s.length:0===h&&l===c-1&&(l=c-2,h=1),this.closed||l>0?n=s[(l-1)%c]:(na.subVectors(s[0],s[1]).add(s[0]),n=na),r=s[l%c],i=s[(l+1)%c],this.closed||l+2r.length-2?r.length-1:o+1],l=r[o>r.length-3?r.length-1:o+2];return n.set(sa(a,s.x,c.x,u.x,l.x),sa(a,s.y,c.y,u.y,l.y)),n},ga.prototype.copy=function(t){Ko.prototype.copy.call(this,t),this.points=[];for(var e=0,n=t.points.length;e=e){var i=n[r]-e,o=this.curves[r],a=o.getLength(),s=0===a?0:1-i/a;return o.getPointAt(s)}r++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,n=0,r=this.curves.length;n1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},copy:function(t){Ko.prototype.copy.call(this,t),this.curves=[];for(var e=0,n=t.curves.length;e0){var u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);var l=c.getPoint(1);this.currentPoint.copy(l)},copy:function(t){return ya.prototype.copy.call(this,t),this.currentPoint.copy(t.currentPoint),this},toJSON:function(){var t=ya.prototype.toJSON.call(this);return t.currentPoint=this.currentPoint.toArray(),t},fromJSON:function(t){return ya.prototype.fromJSON.call(this,t),this.currentPoint.fromArray(t.currentPoint),this}}),_a.prototype=Object.assign(Object.create(ba.prototype),{constructor:_a,getPointsHoles:function(t){for(var e=[],n=0,r=this.holes.length;n=i)break t;var s=e[1];t=(i=e[--n-1]))break e}o=n,n=0}for(;n>>1;te;)--o;if(++o,0!==i||o!==r){i>=o&&(i=(o=Math.max(o,1))-1);var a=this.getValueSize();this.times=Ts.arraySlice(n,i,o),this.values=Ts.arraySlice(this.values,i*a,o*a)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);var n=this.times,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);for(var o=null,a=0;a!==i;a++){var s=n[a];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,s),t=!1;break}if(null!==o&&o>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,s,o),t=!1;break}o=s}if(void 0!==r&&Ts.isTypedArray(r)){a=0;for(var c=r.length;a!==c;++a){var u=r[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),t=!1;break}}}return t},optimize:function(){for(var t=this.times,e=this.values,n=this.getValueSize(),r=this.getInterpolation()===Ae,i=1,o=t.length-1,a=1;a0){t[i]=t[o];for(f=o*n,m=i*n,d=0;d!==n;++d)e[m+d]=e[f+d];++i}return i!==t.length&&(this.times=Ts.arraySlice(t,0,i),this.values=Ts.arraySlice(e,0,i*n)),this}}),As.prototype=Object.assign(Object.create(Ss.prototype),{constructor:As,ValueTypeName:"vector"}),Object.assign(Ls,{parse:function(t){for(var e=[],n=t.tracks,r=1/(t.fps||1),i=0,o=n.length;i!==o;++i)e.push(Ss.parse(n[i]).scale(r));return new Ls(t.name,t.duration,e)},toJSON:function(t){for(var e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e},i=0,o=n.length;i!==o;++i)e.push(Ss.toJSON(n[i]));return r},CreateFromMorphTargetSequence:function(t,e,n,r){for(var i=e.length,o=[],a=0;a1){var u=r[h=c[1]];u||(r[h]=u=[]),u.push(s)}}var l=[];for(var h in r)l.push(Ls.CreateFromMorphTargetSequence(h,r[h],e,n));return l},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var n=function(t,e,n,r,i){if(0!==n.length){var o=[],a=[];Ts.flattenJSON(n,o,a,r),0!==o.length&&i.push(new t(e,o,a))}},r=[],i=t.name||"default",o=t.length||-1,a=t.fps||30,s=t.hierarchy||[],c=0;c1?t.skinWeights[r+1]:0,s=n>2?t.skinWeights[r+2]:0,c=n>3?t.skinWeights[r+3]:0;e.skinWeights.push(new on(o,a,s,c))}if(t.skinIndices)for(r=0,i=t.skinIndices.length;r1?t.skinIndices[r+1]:0,h=n>2?t.skinIndices[r+2]:0,d=n>3?t.skinIndices[r+3]:0;e.skinIndices.push(new on(u,l,h,d))}e.bones=t.bones,e.bones&&e.bones.length>0&&(e.skinWeights.length!==e.skinIndices.length||e.skinIndices.length!==e.vertices.length)&&console.warn("When skinning, number of vertices ("+e.vertices.length+"), skinIndices ("+e.skinIndices.length+"), and skinWeights ("+e.skinWeights.length+") should match.")}(t,n),function(t,e){var n=t.scale;if(void 0!==t.morphTargets)for(var r=0,i=t.morphTargets.length;r0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');var l=e.faces,h=t.morphColors[0].colors;for(r=0,i=l.length;r0&&(e.animations=n)}(t,n),n.computeFaceNormals(),n.computeBoundingSphere(),void 0===t.materials||0===t.materials.length?{geometry:n}:{geometry:n,materials:Us.prototype.initMaterials(t.materials,e,this.crossOrigin)}}}()}),Object.assign(Fs.prototype,{load:function(t,e,n,r){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var i=this;new Ca(i.manager).load(t,function(n){var o=null;try{o=JSON.parse(n)}catch(e){return void 0!==r&&r(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}var a=o.metadata;void 0!==a&&void 0!==a.type&&"geometry"!==a.type.toLowerCase()?i.parse(o,e):console.error("THREE.ObjectLoader: Can't load "+t+". Use THREE.JSONLoader instead.")},n,r)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var n=this.parseShape(t.shapes),r=this.parseGeometries(t.geometries,n),i=this.parseImages(t.images,function(){void 0!==e&&e(s)}),o=this.parseTextures(t.textures,i),a=this.parseMaterials(t.materials,o),s=this.parseObject(t.object,r,a);return t.animations&&(s.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(s),s},parseShape:function(t){var e={};if(void 0!==t)for(var n=0,r=t.length;n0){var o=new Oa(new Aa(e));o.setCrossOrigin(this.crossOrigin);for(var a=0,s=t.length;a0?new Xi(a,s):new mr(a,s);break;case"LOD":r=new Vi;break;case"Line":r=new Ji(i(t.geometry),o(t.material),t.mode);break;case"LineLoop":r=new Qi(i(t.geometry),o(t.material));break;case"LineSegments":r=new Zi(i(t.geometry),o(t.material));break;case"PointCloud":case"Points":r=new $i(i(t.geometry),o(t.material));break;case"Sprite":r=new ji(o(t.material));break;case"Group":r=new to;break;default:r=new Rn}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(r.matrix.fromArray(t.matrix),r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.frustumCulled&&(r.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(r.renderOrder=t.renderOrder),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.children)for(var c=t.children,u=0;uNumber.EPSILON){if(u<0&&(a=e[o],c=-c,s=e[i],u=-u),t.ys.y)continue;if(t.y===a.y){if(t.x===a.x)return!0}else{var l=u*(t.x-a.x)-c*(t.y-a.y);if(0===l)return!0;if(l<0)continue;r=!r}}else{if(t.y!==a.y)continue;if(s.x<=t.x&&t.x<=a.x||a.x<=t.x&&t.x<=s.x)return!0}}return r}var i=qo.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return n(o);var a,s,c,u=[];if(1===o.length)return s=o[0],(c=new is).curves=s.curves,u.push(c),u;var l=!i(o[0].getPoints());l=t?!l:l;var h,d,p=[],f=[],m=[],g=0;f[g]=void 0,m[g]=[];for(var v=0,y=o.length;v1){for(var b=!1,_=[],x=0,w=f.length;x0&&(b||(m=p))}v=0;for(var L=f.length;v0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var o=0;o!==i;++o)t[e+o]=t[n+o]},_slerp:function(t,e,n,r){Xe.slerpFlat(t,e,t,e,t,n,r)},_lerp:function(t,e,n,r,i){for(var o=1-r,a=0;a!==i;++a){var s=e+a;t[s]=t[s]*o+t[n+a]*r}}});var fc,mc,gc,vc,yc,bc,_c,xc,wc,Ec,Mc,Tc,Sc;function Ac(t,e,n){var r=n||Lc.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}function Lc(t,e,n){this.path=e,this.parsedPath=n||Lc.parseTrackName(e),this.node=Lc.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function Rc(){this.uuid=Ve.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var t={};this._indicesByUUID=t;for(var e=0,n=arguments.length;e!==n;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var r=this;this.stats={objects:{get total(){return r._objects.length},get inUse(){return this.total-r.nCachedObjects_}},get bindingsPerObject(){return r._bindings.length}}}function Cc(t,e,n){this._mixer=t,this._clip=e,this._localRoot=n||null;for(var r=e.tracks,i=r.length,o=new Array(i),a={endingStart:Le,endingEnd:Le},s=0;s!==i;++s){var c=r[s].createInterpolant(null);o[s]=c,c.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Ee,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function Pc(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Nc(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function Oc(){Zn.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function Ic(t,e,n,r){this.data=t,this.itemSize=e,this.offset=n,this.normalized=!0===r}function kc(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}function Uc(t,e,n){kc.call(this,t,e),this.meshPerAttribute=n||1}function Bc(t,e,n){Bn.call(this,t,e),this.meshPerAttribute=n||1}function Dc(t,e,n,r){this.ray=new dr(t,e),this.near=n||0,this.far=r||1/0,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function Fc(t,e){return t.distance-e.distance}function zc(t,e,n,r){if(!1!==t.visible&&(t.raycast(e,n),!0===r))for(var i=t.children,o=0,a=i.length;oe;)--o;if(++o,0!==i||o!==r){i>=o&&(i=(o=Math.max(o,1))-1);var a=this.getValueSize();this.times=Ga.arraySlice(n,i,o),this.values=Ga.arraySlice(this.values,i*a,o*a)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);var n=this.times,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);for(var o=null,a=0;a!==i;a++){var s=n[a];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,s),t=!1;break}if(null!==o&&o>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,s,o),t=!1;break}o=s}if(void 0!==r&&Ga.isTypedArray(r)){a=0;for(var c=r.length;a!==c;++a){var u=r[a];if(isNaN(u)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,u),t=!1;break}}}return t},optimize:function(){for(var t=this.times,e=this.values,n=this.getValueSize(),r=this.getInterpolation()===ye,i=1,o=t.length-1,a=1;a0){t[i]=t[o];for(f=o*n,m=i*n,d=0;d!==n;++d)e[m+d]=e[f+d];++i}return i!==t.length&&(this.times=Ga.arraySlice(t,0,i),this.values=Ga.arraySlice(e,0,i*n)),this}}),ja.prototype=Object.assign(Object.create(Ha.prototype),{constructor:ja,ValueTypeName:"vector"}),Object.assign(Va,{parse:function(t){for(var e=[],n=t.tracks,r=1/(t.fps||1),i=0,o=n.length;i!==o;++i)e.push(Ha.parse(n[i]).scale(r));return new Va(t.name,t.duration,e)},toJSON:function(t){for(var e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e},i=0,o=n.length;i!==o;++i)e.push(Ha.toJSON(n[i]));return r},CreateFromMorphTargetSequence:function(t,e,n,r){for(var i=e.length,o=[],a=0;a1){var u=r[h=c[1]];u||(r[h]=u=[]),u.push(s)}}var l=[];for(var h in r)l.push(Va.CreateFromMorphTargetSequence(h,r[h],e,n));return l},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var n=function(t,e,n,r,i){if(0!==n.length){var o=[],a=[];Ga.flattenJSON(n,o,a,r),0!==o.length&&i.push(new t(e,o,a))}},r=[],i=t.name||"default",o=t.length||-1,a=t.fps||30,s=t.hierarchy||[],c=0;c1?t.skinWeights[r+1]:0,s=n>2?t.skinWeights[r+2]:0,c=n>3?t.skinWeights[r+3]:0;e.skinWeights.push(new je(o,a,s,c))}if(t.skinIndices)for(r=0,i=t.skinIndices.length;r1?t.skinIndices[r+1]:0,h=n>2?t.skinIndices[r+2]:0,d=n>3?t.skinIndices[r+3]:0;e.skinIndices.push(new je(u,l,h,d))}e.bones=t.bones,e.bones&&e.bones.length>0&&(e.skinWeights.length!==e.skinIndices.length||e.skinIndices.length!==e.vertices.length)&&console.warn("When skinning, number of vertices ("+e.vertices.length+"), skinIndices ("+e.skinIndices.length+"), and skinWeights ("+e.skinWeights.length+") should match.")}(t,n),function(t,e){var n=t.scale;if(void 0!==t.morphTargets)for(var r=0,i=t.morphTargets.length;r0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');var l=e.faces,h=t.morphColors[0].colors;for(r=0,i=l.length;r0&&(e.animations=n)}(t,n),n.computeFaceNormals(),n.computeBoundingSphere(),void 0===t.materials||0===t.materials.length?{geometry:n}:{geometry:n,materials:Ya.prototype.initMaterials(t.materials,e,this.crossOrigin)}}}()}),Object.assign(Qa.prototype,{load:function(t,e,n,r){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var i=this;new qo(i.manager).load(t,function(n){var o=null;try{o=JSON.parse(n)}catch(e){return void 0!==r&&r(e),void console.error("THREE:ObjectLoader: Can't parse "+t+".",e.message)}var a=o.metadata;void 0!==a&&void 0!==a.type&&"geometry"!==a.type.toLowerCase()?i.parse(o,e):console.error("THREE.ObjectLoader: Can't load "+t+". Use THREE.JSONLoader instead.")},n,r)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var n=this.parseShape(t.shapes),r=this.parseGeometries(t.geometries,n),i=this.parseImages(t.images,function(){void 0!==e&&e(s)}),o=this.parseTextures(t.textures,i),a=this.parseMaterials(t.materials,o),s=this.parseObject(t.object,r,a);return t.animations&&(s.animations=this.parseAnimations(t.animations)),void 0!==t.images&&0!==t.images.length||void 0!==e&&e(s),s},parseShape:function(t){var e={};if(void 0!==t)for(var n=0,r=t.length;n0){var o=new Jo(new jo(e));o.setCrossOrigin(this.crossOrigin);for(var a=0,s=t.length;a0?new ui(a,s):new Fn(a,s);break;case"LOD":r=new ai;break;case"Line":r=new hi(i(t.geometry),o(t.material),t.mode);break;case"LineLoop":r=new pi(i(t.geometry),o(t.material));break;case"LineSegments":r=new di(i(t.geometry),o(t.material));break;case"PointCloud":case"Points":r=new mi(i(t.geometry),o(t.material));break;case"Sprite":r=new oi(o(t.material));break;case"Group":r=new gi;break;default:r=new cn}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(r.matrix.fromArray(t.matrix),r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.frustumCulled&&(r.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(r.renderOrder=t.renderOrder),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.children)for(var c=t.children,u=0;uNumber.EPSILON){if(u<0&&(a=e[o],c=-c,s=e[i],u=-u),t.ys.y)continue;if(t.y===a.y){if(t.x===a.x)return!0}else{var l=u*(t.x-a.x)-c*(t.y-a.y);if(0===l)return!0;if(l<0)continue;r=!r}}else{if(t.y!==a.y)continue;if(s.x<=t.x&&t.x<=a.x||a.x<=t.x&&t.x<=s.x)return!0}}return r}var i=so.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return n(o);var a,s,c,u=[];if(1===o.length)return s=o[0],(c=new _a).curves=s.curves,u.push(c),u;var l=!i(o[0].getPoints());l=t?!l:l;var h,d,p=[],f=[],m=[],g=0;f[g]=void 0,m[g]=[];for(var v=0,y=o.length;v1){for(var b=!1,_=[],x=0,w=f.length;x0&&(b||(m=p))}v=0;for(var L=f.length;v0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var o=0;o!==i;++o)t[e+o]=t[n+o]},_slerp:function(t,e,n,r){De.slerpFlat(t,e,t,e,t,n,r)},_lerp:function(t,e,n,r,i){for(var o=1-r,a=0;a!==i;++a){var s=e+a;t[s]=t[s]*o+t[n+a]*r}}});var gs,vs;function ys(t,e,n){var r=n||bs.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}function bs(t,e,n){this.path=e,this.parsedPath=n||bs.parseTrackName(e),this.node=bs.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function _s(){this.uuid=ke.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var t={};this._indicesByUUID=t;for(var e=0,n=arguments.length;e!==n;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var r=this;this.stats={objects:{get total(){return r._objects.length},get inUse(){return this.total-r.nCachedObjects_}},get bindingsPerObject(){return r._bindings.length}}}function xs(t,e,n){this._mixer=t,this._clip=e,this._localRoot=n||null;for(var r=e.tracks,i=r.length,o=new Array(i),a={endingStart:be,endingEnd:be},s=0;s!==i;++s){var c=r[s].createInterpolant(null);o[s]=c,c.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=fe,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}function ws(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Es(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function Ms(){An.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function Ts(t,e,n,r){this.data=t,this.itemSize=e,this.offset=n,this.normalized=!0===r}function Ss(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}function As(t,e,n){Ss.call(this,t,e),this.meshPerAttribute=n||1}function Ls(t,e,n){fn.call(this,t,e),this.meshPerAttribute=n||1}function Rs(t,e,n,r){this.ray=new Un(t,e),this.near=n||0,this.far=r||1/0,this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}},Object.defineProperties(this.params,{PointCloud:{get:function(){return console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."),this.Points}}})}function Cs(t,e){return t.distance-e.distance}function Ps(t,e,n,r){if(!1!==t.visible&&(t.raycast(e,n),!0===r))for(var i=t.children,o=0,a=i.length;o=e){var l=e++,h=t[l];n[h.uuid]=u,t[u]=h,n[c]=l,t[l]=s;for(var d=0,p=i;d!==p;++d){var f=r[d],m=f[l],g=f[u];f[u]=m,f[l]=g}}}this.nCachedObjects_=e},uncache:function(){for(var t=this._objects,e=t.length,n=this.nCachedObjects_,r=this._indicesByUUID,i=this._bindings,o=i.length,a=0,s=arguments.length;a!==s;++a){var c=arguments[a].uuid,u=r[c];if(void 0!==u)if(delete r[c],u0)for(var c=this._interpolants,u=this._propertyBindings,l=0,h=c.length;l!==h;++l)c[l].evaluate(a),u[l].accumulate(r,s)}else this._updateWeight(t)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var n=this._weightInterpolant;if(null!==n){var r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var n=this._timeScaleInterpolant;if(null!==n)e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t;if(0===t)return e;var n=this._clip.duration,r=this.loop,i=this._loopCount;if(r===we){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=n)e=n;else{if(!(e<0))break t;e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{var o=r===Me;if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),e>=n||e<0){var a=Math.floor(e/n);e-=n*a,i+=Math.abs(a);var s=this.repetitions-i;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?n:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===s){var c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&i))return this.time=e,n-e}return this.time=e,e},_setEndings:function(t,e,n){var r=this._interpolantSettings;n?(r.endingStart=Re,r.endingEnd=Re):(r.endingStart=t?this.zeroSlopeAtStart?Re:Le:Ce,r.endingEnd=e?this.zeroSlopeAtEnd?Re:Le:Ce)},_scheduleFading:function(t,e,n){var r=this._mixer,i=r.time,o=this._weightInterpolant;null===o&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=i,s[0]=e,a[1]=i+t,s[1]=n,this}}),Pc.prototype=Object.assign(Object.create(r.prototype),{constructor:Pc,_bindAction:function(t,e){var n=t._localRoot||this._root,r=t._clip.tracks,i=r.length,o=t._propertyBindings,a=t._interpolants,s=n.uuid,c=this._bindingsByRootAndName,u=c[s];void 0===u&&(u={},c[s]=u);for(var l=0;l!==i;++l){var h=r[l],d=h.name,p=u[d];if(void 0!==p)o[l]=p;else{if(void 0!==(p=o[l])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,s,d));continue}var f=e&&e._propertyBindings[l].binding.parsedPath;++(p=new pc(Lc.create(n,d,f),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(p,s,d),o[l]=p}a[l].resultBuffer=p.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,n=t._clip.uuid,r=this._actionsByClip[n];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,n,e)}for(var i=t._propertyBindings,o=0,a=i.length;o!==a;++o){var s=i[o];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,n=0,r=e.length;n!==r;++n){var i=e[n];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&ethis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .getParameter() target is now required"),e=new We),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .clampPoint() target is now required"),e=new We),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new We;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),Wc.prototype=Object.create(Rn.prototype),Wc.prototype.constructor=Wc,Wc.prototype.isImmediateRenderObject=!0,qc.prototype=Object.create(Zi.prototype),qc.prototype.constructor=qc,qc.prototype.update=function(){var t=new Ye,e=new Ye,n=new Je;return function(){var r=["a","b","c"];this.object.updateMatrixWorld(!0),n.getNormalMatrix(this.object.matrixWorld);var i=this.object.matrixWorld,o=this.geometry.attributes.position,a=this.object.geometry;if(a&&a.isGeometry)for(var s=a.vertices,c=a.faces,u=0,l=0,h=c.length;l.99999?this.quaternion.set(0,0,0,1):t.y<-.99999?this.quaternion.set(1,0,0,0):(Sc.set(t.z,0,-t.x).normalize(),Tc=Math.acos(t.y),this.quaternion.setFromAxisAngle(Sc,Tc))}),au.prototype.setLength=function(t,e,n){void 0===e&&(e=.2*t),void 0===n&&(n=.2*e),this.line.scale.set(1,Math.max(0,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()},au.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},su.prototype=Object.create(Zi.prototype),su.prototype.constructor=su;var uu=0,lu=1;function hu(t){return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."),t}function du(t){return void 0===t&&(t=[]),console.warn("THREE.MultiMaterial has been removed. Use an Array instead."),t.isMultiMaterial=!0,t.materials=t,t.clone=function(){return t.slice()},t}function pu(t,e){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new $i(t,e)}function fu(t){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new ji(t)}function mu(t,e){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new $i(t,e)}function gu(t){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new Ki(t)}function vu(t){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new Ki(t)}function yu(t){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new Ki(t)}function bu(t,e,n){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new Ye(t,e,n)}function _u(t,e){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead."),new Bn(t,e).setDynamic(!0)}function xu(t,e){return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."),new Dn(t,e)}function wu(t,e){return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."),new Fn(t,e)}function Eu(t,e){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."),new zn(t,e)}function Mu(t,e){return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."),new Gn(t,e)}function Tu(t,e){return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."),new Hn(t,e)}function Su(t,e){return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."),new jn(t,e)}function Au(t,e){return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."),new Vn(t,e)}function Lu(t,e){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new Wn(t,e)}function Ru(t,e){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new qn(t,e)}function Cu(t){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Va.call(this,t),this.type="catmullrom",this.closed=!0}function Pu(t){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Va.call(this,t),this.type="catmullrom"}function Nu(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),Va.call(this,t),this.type="catmullrom"}function Ou(t){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new su(t)}function Iu(t,e){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new ru(t,e)}function ku(t,e){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new Zi(new ca(t.geometry),new Yi({color:void 0!==e?e:16777215}))}function Uu(t,e){return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."),new Zi(new io(t.geometry),new Yi({color:void 0!==e?e:16777215}))}function Bu(t){return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."),new Ca(t)}function Du(t){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new Na(t)}Ua.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(Ua.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},Object.assign(ns.prototype,{createPointsGeometry:function(t){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var e=new Un,n=0,r=t.length;n=0))break;s=s*r+l,a=a*r+Math.floor(s/u),s%=u}c&&(a=~a,s?s=u-s:a++);k(t,e+w,a),k(t,e+E,s)}(e,i,c,l||10):m(c,l)?g(e,i,c,l):"number"==typeof l?(k(e,i+w,c),k(e,i+E,l)):c>0?L(e,i,c):c<0?R(e,i,c):g(e,i,s,0)}(this,t,e,i,c):new O(t,e,i,c)}function I(){var t=this.buffer,e=this.offset,n=U(t,e+w),r=U(t,e+E);return h||(n|=0),n?n*u+r:r}function k(t,e,n){t[e+A]=255&n,n>>=8,t[e+S]=255&n,n>>=8,t[e+T]=255&n,n>>=8,t[e+M]=255&n}function U(t,e){return t[e+M]*l+(t[e+T]<<16)+(t[e+S]<<8)+t[e+A]}}function d(t){var e=this.buffer,r=this.offset;return n=null,!1!==t&&0===r&&8===e.length&&c(e)?e:v(e,r)}function p(e){var r=this.buffer,o=this.offset;if(n=i,!1!==e&&0===o&&8===r.length&&t.isBuffer(r))return r;var a=new i(8);return g(a,0,r,o),a}function f(t){var e=this.buffer,r=this.offset,i=e.buffer;if(n=o,!1!==t&&0===r&&i instanceof a&&8===i.byteLength)return i;var s=new o(8);return g(s,0,e,r),s.buffer}function m(t,e){var n=t&&t.length;return e|=0,n&&e+8<=n&&"string"!=typeof t[e]}function g(t,e,n,r){e|=0,r|=0;for(var i=0;i<8;i++)t[e++]=255&n[r++]}function v(t,e){return Array.prototype.slice.call(t,e,e+8)}function y(t,e,n){for(var r=e+8;r>e;)t[--r]=255&n,n/=256}function b(t,e,n){var r=e+8;for(n++;r>e;)t[--r]=255&-n^255,n/=256}function _(t,e,n){for(var r=e+8;e>1,l=-7,h=n?i-1:0,d=n?-1:1,p=t[e+h];for(h+=d,o=p&(1<<-l)-1,p>>=-l,l+=s;l>0;o=256*o+t[e+h],h+=d,l-=8);for(a=o&(1<<-l)-1,o>>=-l,l+=r;l>0;a=256*a+t[e+h],h+=d,l-=8);if(0===o)o=1-u;else{if(o===c)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,r),o-=u}return(p?-1:1)*a*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var a,s,c,u=8*o-i-1,l=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,f=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=l):(a=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-a))<1&&(a--,c*=2),(e+=a+h>=1?d/c:d*Math.pow(2,1-h))*c>=2&&(a++,c/=2),a+h>=l?(s=0,a=l):a+h>=1?(s=(e*c-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[n+p]=255&s,p+=f,s/=256,i-=8);for(a=a<0;t[n+p]=255&a,p+=f,a/=256,u-=8);t[n+p-f]|=128*m}},function(t,e,n){e.ExtBuffer=function t(e,n){if(!(this instanceof t))return new t(e,n);this.buffer=r.from(e);this.type=n};var r=n(0)},function(t,e,n){var r=n(8).ExtBuffer,i=n(39),o=n(38),a=n(2);function s(){var t=this.options;return this.encode=function(t){var e=o.getWriteType(t);return function(t,n){var r=e[typeof n];if(!r)throw new Error('Unsupported type "'+typeof n+'": '+n);r(t,n)}}(t),t&&t.preset&&i.setExtPackers(this),this}a.install({addExtPacker:function(t,e,n){n=a.filter(n);var i=e.name;if(i&&"Object"!==i){var o=this.extPackers||(this.extPackers={});o[i]=c}else{var s=this.extEncoderList||(this.extEncoderList=[]);s.unshift([e,c])}function c(e){return n&&(e=n(e)),new r(e,t)}},getExtPacker:function(t){var e=this.extPackers||(this.extPackers={}),n=t.constructor,r=n&&n.name&&e[n.name];if(r)return r;for(var i=this.extEncoderList||(this.extEncoderList=[]),o=i.length,a=0;a=e){var l=e++,h=t[l];n[h.uuid]=u,t[u]=h,n[c]=l,t[l]=s;for(var d=0,p=i;d!==p;++d){var f=r[d],m=f[l],g=f[u];f[u]=m,f[l]=g}}}this.nCachedObjects_=e},uncache:function(){for(var t=this._objects,e=t.length,n=this.nCachedObjects_,r=this._indicesByUUID,i=this._bindings,o=i.length,a=0,s=arguments.length;a!==s;++a){var c=arguments[a].uuid,u=r[c];if(void 0!==u)if(delete r[c],u0)for(var c=this._interpolants,u=this._propertyBindings,l=0,h=c.length;l!==h;++l)c[l].evaluate(a),u[l].accumulate(r,s)}else this._updateWeight(t)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var n=this._weightInterpolant;if(null!==n){var r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var n=this._timeScaleInterpolant;if(null!==n)e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t;if(0===t)return e;var n=this._clip.duration,r=this.loop,i=this._loopCount;if(r===pe){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=n)e=n;else{if(!(e<0))break t;e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{var o=r===me;if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),e>=n||e<0){var a=Math.floor(e/n);e-=n*a,i+=Math.abs(a);var s=this.repetitions-i;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?n:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===s){var c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&i))return this.time=e,n-e}return this.time=e,e},_setEndings:function(t,e,n){var r=this._interpolantSettings;n?(r.endingStart=_e,r.endingEnd=_e):(r.endingStart=t?this.zeroSlopeAtStart?_e:be:xe,r.endingEnd=e?this.zeroSlopeAtEnd?_e:be:xe)},_scheduleFading:function(t,e,n){var r=this._mixer,i=r.time,o=this._weightInterpolant;null===o&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=i,s[0]=e,a[1]=i+t,s[1]=n,this}}),ws.prototype=Object.assign(Object.create(r.prototype),{constructor:ws,_bindAction:function(t,e){var n=t._localRoot||this._root,r=t._clip.tracks,i=r.length,o=t._propertyBindings,a=t._interpolants,s=n.uuid,c=this._bindingsByRootAndName,u=c[s];void 0===u&&(u={},c[s]=u);for(var l=0;l!==i;++l){var h=r[l],d=h.name,p=u[d];if(void 0!==p)o[l]=p;else{if(void 0!==(p=o[l])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,s,d));continue}var f=e&&e._propertyBindings[l].binding.parsedPath;++(p=new ms(bs.create(n,d,f),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(p,s,d),o[l]=p}a[l].resultBuffer=p.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,n=t._clip.uuid,r=this._actionsByClip[n];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,n,e)}for(var i=t._propertyBindings,o=0,a=i.length;o!==a;++o){var s=i[o];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,n=0,r=e.length;n!==r;++n){var i=e[n];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&ethis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .getParameter() target is now required"),e=new Ue),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .clampPoint() target is now required"),e=new Ue),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(){var t=new Ue;return function(e){return t.copy(e).clamp(this.min,this.max).sub(e).length()}}(),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),Us.prototype=Object.create(cn.prototype),Us.prototype.constructor=Us,Us.prototype.isImmediateRenderObject=!0,Bs.prototype=Object.create(di.prototype),Bs.prototype.constructor=Bs,Bs.prototype.update=function(){var t=new Fe,e=new Fe,n=new ze;return function(){var r=["a","b","c"];this.object.updateMatrixWorld(!0),n.getNormalMatrix(this.object.matrixWorld);var i=this.object.matrixWorld,o=this.geometry.attributes.position,a=this.object.geometry;if(a&&a.isGeometry)for(var s=a.vertices,c=a.faces,u=0,l=0,h=c.length;l.99999?this.quaternion.set(0,0,0,1):n.y<-.99999?this.quaternion.set(1,0,0,0):(e.set(n.z,0,-n.x).normalize(),t=Math.acos(n.y),this.quaternion.setFromAxisAngle(e,t))}}(),Qs.prototype.setLength=function(t,e,n){void 0===e&&(e=.2*t),void 0===n&&(n=.2*e),this.line.scale.set(1,Math.max(0,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()},Qs.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},Ks.prototype=Object.create(di.prototype),Ks.prototype.constructor=Ks;var tc=0,ec=1;function nc(t){return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."),t}function rc(t){return void 0===t&&(t=[]),console.warn("THREE.MultiMaterial has been removed. Use an Array instead."),t.isMultiMaterial=!0,t.materials=t,t.clone=function(){return t.slice()},t}function ic(t,e){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new mi(t,e)}function oc(t){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new oi(t)}function ac(t,e){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new mi(t,e)}function sc(t){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new fi(t)}function cc(t){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new fi(t)}function uc(t){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new fi(t)}function lc(t,e,n){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new Fe(t,e,n)}function hc(t,e){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead."),new fn(t,e).setDynamic(!0)}function dc(t,e){return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."),new mn(t,e)}function pc(t,e){return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."),new gn(t,e)}function fc(t,e){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."),new vn(t,e)}function mc(t,e){return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."),new yn(t,e)}function gc(t,e){return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."),new bn(t,e)}function vc(t,e){return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."),new _n(t,e)}function yc(t,e){return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."),new xn(t,e)}function bc(t,e){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new wn(t,e)}function _c(t,e){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new En(t,e)}function xc(t){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),aa.call(this,t),this.type="catmullrom",this.closed=!0}function wc(t){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),aa.call(this,t),this.type="catmullrom"}function Ec(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),aa.call(this,t),this.type="catmullrom"}function Mc(t){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new Ks(t)}function Tc(t,e){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Ys(t,e)}function Sc(t,e){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new di(new Mo(t.geometry),new li({color:void 0!==e?e:16777215}))}function Ac(t,e){return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."),new di(new _i(t.geometry),new li({color:void 0!==e?e:16777215}))}function Lc(t){return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."),new qo(t)}function Rc(t){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new Yo(t)}Ko.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(Ko.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},Object.assign(ya.prototype,{createPointsGeometry:function(t){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var e=this.getPoints(t);return this.createGeometry(e)},createSpacedPointsGeometry:function(t){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var e=this.getSpacedPoints(t);return this.createGeometry(e)},createGeometry:function(t){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var e=new pn,n=0,r=t.length;n=0))break;s=s*r+l,a=a*r+Math.floor(s/u),s%=u}c&&(a=~a,s?s=u-s:a++);k(t,e+w,a),k(t,e+E,s)}(e,i,c,l||10):m(c,l)?g(e,i,c,l):"number"==typeof l?(k(e,i+w,c),k(e,i+E,l)):c>0?L(e,i,c):c<0?R(e,i,c):g(e,i,s,0)}(this,t,e,i,c):new O(t,e,i,c)}function I(){var t=this.buffer,e=this.offset,n=U(t,e+w),r=U(t,e+E);return h||(n|=0),n?n*u+r:r}function k(t,e,n){t[e+A]=255&n,n>>=8,t[e+S]=255&n,n>>=8,t[e+T]=255&n,n>>=8,t[e+M]=255&n}function U(t,e){return t[e+M]*l+(t[e+T]<<16)+(t[e+S]<<8)+t[e+A]}}function d(t){var e=this.buffer,r=this.offset;return n=null,!1!==t&&0===r&&8===e.length&&c(e)?e:v(e,r)}function p(e){var r=this.buffer,o=this.offset;if(n=i,!1!==e&&0===o&&8===r.length&&t.isBuffer(r))return r;var a=new i(8);return g(a,0,r,o),a}function f(t){var e=this.buffer,r=this.offset,i=e.buffer;if(n=o,!1!==t&&0===r&&i instanceof a&&8===i.byteLength)return i;var s=new o(8);return g(s,0,e,r),s.buffer}function m(t,e){var n=t&&t.length;return e|=0,n&&e+8<=n&&"string"!=typeof t[e]}function g(t,e,n,r){e|=0,r|=0;for(var i=0;i<8;i++)t[e++]=255&n[r++]}function v(t,e){return Array.prototype.slice.call(t,e,e+8)}function y(t,e,n){for(var r=e+8;r>e;)t[--r]=255&n,n/=256}function b(t,e,n){var r=e+8;for(n++;r>e;)t[--r]=255&-n^255,n/=256}function _(t,e,n){for(var r=e+8;e>1,l=-7,h=n?i-1:0,d=n?-1:1,p=t[e+h];for(h+=d,o=p&(1<<-l)-1,p>>=-l,l+=s;l>0;o=256*o+t[e+h],h+=d,l-=8);for(a=o&(1<<-l)-1,o>>=-l,l+=r;l>0;a=256*a+t[e+h],h+=d,l-=8);if(0===o)o=1-u;else{if(o===c)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,r),o-=u}return(p?-1:1)*a*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var a,s,c,u=8*o-i-1,l=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,f=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=l):(a=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-a))<1&&(a--,c*=2),(e+=a+h>=1?d/c:d*Math.pow(2,1-h))*c>=2&&(a++,c/=2),a+h>=l?(s=0,a=l):a+h>=1?(s=(e*c-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[n+p]=255&s,p+=f,s/=256,i-=8);for(a=a<0;t[n+p]=255&a,p+=f,a/=256,u-=8);t[n+p-f]|=128*m}},function(t,e,n){e.ExtBuffer=function t(e,n){if(!(this instanceof t))return new t(e,n);this.buffer=r.from(e);this.type=n};var r=n(0)},function(t,e,n){var r=n(8).ExtBuffer,i=n(39),o=n(38),a=n(2);function s(){var t=this.options;return this.encode=function(t){var e=o.getWriteType(t);return function(t,n){var r=e[typeof n];if(!r)throw new Error('Unsupported type "'+typeof n+'": '+n);r(t,n)}}(t),t&&t.preset&&i.setExtPackers(this),this}a.install({addExtPacker:function(t,e,n){n=a.filter(n);var i=e.name;if(i&&"Object"!==i){var o=this.extPackers||(this.extPackers={});o[i]=c}else{var s=this.extEncoderList||(this.extEncoderList=[]);s.unshift([e,c])}function c(e){return n&&(e=n(e)),new r(e,t)}},getExtPacker:function(t){var e=this.extPackers||(this.extPackers={}),n=t.constructor,r=n&&n.name&&e[n.name];if(r)return r;for(var i=this.extEncoderList||(this.extEncoderList=[]),o=i.length,a=0;a * @license MIT */ -var r=n(44),i=n(7),o=n(3);function a(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(t,e){if(a()=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|t}function f(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return G(t).length;default:if(r)return z(t).length;e=(""+e).toLowerCase(),r=!0}}function m(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function g(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=c.from(e,r)),c.isBuffer(e))return 0===e.length?-1:v(t,e,n,r,i);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):v(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,n,r,i){var o,a=1,s=t.length,c=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;a=2,s/=2,c/=2,n/=2}function u(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var l=-1;for(o=n;os&&(n=s-c),o=n;o>=0;o--){for(var h=!0,d=0;di&&(r=i):r=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var a=0;a>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function M(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function T(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i239?4:u>223?3:u>191?2:1;if(i+h<=n)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(o=t[i+1]))&&(c=(31&u)<<6|63&o)>127&&(l=c);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(c=(15&u)<<12|(63&o)<<6|63&a)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(c=(15&u)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),i+=h}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);var n="",r=0;for(;rthis.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,n);case"utf8":case"utf-8":return T(this,e,n);case"ascii":return A(this,e,n);case"latin1":case"binary":return L(this,e,n);case"base64":return M(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},c.prototype.compare=function(t,e,n,r,i){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,r>>>=0,i>>>=0,this===t)return 0;for(var o=i-r,a=n-e,s=Math.min(o,a),u=this.slice(r,i),l=t.slice(e,n),h=0;hi)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return y(this,t,e,n);case"utf8":case"utf-8":return b(this,t,e,n);case"ascii":return _(this,t,e,n);case"latin1":case"binary":return x(this,t,e,n);case"base64":return w(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function A(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;ir)&&(n=r);for(var i="",o=e;on)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,n,r,i,o){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function O(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-n,2);i>>8*(r?i:1-i)}function I(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-n,4);i>>8*(r?i:3-i)&255}function k(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function U(t,e,n,r,o){return o||k(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function B(t,e,n,r,o){return o||k(t,0,n,8),i.write(t,e,n,r,52,8),n+8}c.prototype.slice=function(t,e){var n,r=this.length;if(t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e0&&(i*=256);)r+=this[t+--e]*i;return r},c.prototype.readUInt8=function(t,e){return e||P(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return e||P(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return e||P(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return e||P(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return e||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||P(t,e,this.length);for(var r=this[t],i=1,o=0;++o=(i*=128)&&(r-=Math.pow(2,8*e)),r},c.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||P(t,e,this.length);for(var r=e,i=1,o=this[t+--r];r>0&&(i*=256);)o+=this[t+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},c.prototype.readInt8=function(t,e){return e||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){e||P(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(t,e){e||P(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(t,e){return e||P(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return e||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return e||P(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return e||P(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return e||P(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return e||P(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||N(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+i]=t/o&255;return e+n},c.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):O(this,t,e,!0),e+2},c.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):O(this,t,e,!1),e+2},c.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):I(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):I(this,t,e,!1),e+4},c.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);N(this,t,e,n,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+n},c.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);N(this,t,e,n,i-1,-i)}var o=n-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+n},c.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):O(this,t,e,!0),e+2},c.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):O(this,t,e,!1),e+2},c.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):I(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):I(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,n){return U(this,t,e,!0,n)},c.prototype.writeFloatBE=function(t,e,n){return U(this,t,e,!1,n)},c.prototype.writeDoubleLE=function(t,e,n){return B(this,t,e,!0,n)},c.prototype.writeDoubleBE=function(t,e,n){return B(this,t,e,!1,n)},c.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e=0;--i)t[i+e]=this[i+n];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function G(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(D,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,n,r){for(var i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}}).call(this,n(16))},function(t,e,n){e.EncodeBuffer=i;var r=n(9).preset;function i(t){if(!(this instanceof i))return new i(t);if(t&&(this.options=t,t.codec)){var e=this.codec=t.codec;e.bufferish&&(this.bufferish=e.bufferish)}}n(14).FlexEncoder.mixin(i.prototype),i.prototype.codec=r,i.prototype.write=function(t){this.codec.encode(this,t)}},function(t,e,n){e.encode=function(t,e){var n=new r(e);return n.write(t),n.read()};var r=n(18).EncodeBuffer},function(t,e,n){var r;t.exports=function t(e,n,i){function o(s,c){if(!n[s]){if(!e[s]){var u="function"==typeof r&&r;if(!c&&u)return r(s,!0);if(a)return a(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var h=n[s]={exports:{}};e[s][0].call(h.exports,function(t){var n=e[s][1][t];return o(n||t)},h,h.exports,t,e,n,i)}return n[s].exports}for(var a="function"==typeof r&&r,s=0;s0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){if(!i(e))throw TypeError("listener must be a function");var n=!1;function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var n,r,a,s;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],a=n.length,r=-1,n===e||i(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(n)){for(s=a;s-- >0;)if(n[s]===e||n[s].listener&&n[s].listener===e){r=s;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(i(n=this._events[t]))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},r.listenerCount=function(t,e){return t.listenerCount(e)}},{}],2:[function(t,e,n){var r=t("./TypedNeuQuant.js"),i=t("./LZWEncoder.js");function o(){this.page=-1,this.pages=[],this.newPage()}o.pageSize=4096,o.charMap={};for(var a=0;a<256;a++)o.charMap[a]=String.fromCharCode(a);function s(t,e){this.width=~~t,this.height=~~e,this.transparent=null,this.transIndex=0,this.repeat=-1,this.delay=0,this.image=null,this.pixels=null,this.indexedPixels=null,this.colorDepth=null,this.colorTab=null,this.neuQuant=null,this.usedEntry=new Array,this.palSize=7,this.dispose=-1,this.firstFrame=!0,this.sample=10,this.dither=!1,this.globalPalette=!1,this.out=new o}o.prototype.newPage=function(){this.pages[++this.page]=new Uint8Array(o.pageSize),this.cursor=0},o.prototype.getData=function(){for(var t="",e=0;e=o.pageSize&&this.newPage(),this.pages[this.page][this.cursor++]=t},o.prototype.writeUTFBytes=function(t){for(var e=t.length,n=0;n=0&&(this.dispose=t)},s.prototype.setRepeat=function(t){this.repeat=t},s.prototype.setTransparent=function(t){this.transparent=t},s.prototype.addFrame=function(t){this.image=t,this.colorTab=this.globalPalette&&this.globalPalette.slice?this.globalPalette:null,this.getImagePixels(),this.analyzePixels(),!0===this.globalPalette&&(this.globalPalette=this.colorTab),this.firstFrame&&(this.writeLSD(),this.writePalette(),this.repeat>=0&&this.writeNetscapeExt()),this.writeGraphicCtrlExt(),this.writeImageDesc(),this.firstFrame||this.globalPalette||this.writePalette(),this.writePixels(),this.firstFrame=!1},s.prototype.finish=function(){this.out.writeByte(59)},s.prototype.setQuality=function(t){t<1&&(t=1),this.sample=t},s.prototype.setDither=function(t){!0===t&&(t="FloydSteinberg"),this.dither=t},s.prototype.setGlobalPalette=function(t){this.globalPalette=t},s.prototype.getGlobalPalette=function(){return this.globalPalette&&this.globalPalette.slice&&this.globalPalette.slice(0)||this.globalPalette},s.prototype.writeHeader=function(){this.out.writeUTFBytes("GIF89a")},s.prototype.analyzePixels=function(){this.colorTab||(this.neuQuant=new r(this.pixels,this.sample),this.neuQuant.buildColormap(),this.colorTab=this.neuQuant.getColormap()),this.dither?this.ditherPixels(this.dither.replace("-serpentine",""),null!==this.dither.match(/-serpentine/)):this.indexPixels(),this.pixels=null,this.colorDepth=8,this.palSize=7,null!==this.transparent&&(this.transIndex=this.findClosest(this.transparent,!0))},s.prototype.indexPixels=function(t){var e=this.pixels.length/3;this.indexedPixels=new Uint8Array(e);for(var n=0,r=0;r=0&&M+l=0&&T+u>16,(65280&t)>>8,255&t,e)},s.prototype.findClosestRGB=function(t,e,n,r){if(null===this.colorTab)return-1;if(this.neuQuant&&!r)return this.neuQuant.lookupRGB(t,e,n);for(var i=0,o=16777216,a=this.colorTab.length,s=0,c=0;s=0&&(e=7&this.dispose),e<<=2,this.out.writeByte(0|e|t),this.writeShort(this.delay),this.out.writeByte(this.transIndex),this.out.writeByte(0)},s.prototype.writeImageDesc=function(){this.out.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.firstFrame||this.globalPalette?this.out.writeByte(0):this.out.writeByte(128|this.palSize)},s.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(240|this.palSize),this.out.writeByte(0),this.out.writeByte(0)},s.prototype.writeNetscapeExt=function(){this.out.writeByte(33),this.out.writeByte(255),this.out.writeByte(11),this.out.writeUTFBytes("NETSCAPE2.0"),this.out.writeByte(3),this.out.writeByte(1),this.writeShort(this.repeat),this.out.writeByte(0)},s.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);for(var t=768-this.colorTab.length,e=0;e>8&255)},s.prototype.writePixels=function(){var t=new i(this.width,this.height,this.indexedPixels,this.colorDepth);t.encode(this.out)},s.prototype.stream=function(){return this.out},e.exports=s},{"./LZWEncoder.js":3,"./TypedNeuQuant.js":4}],3:[function(t,e,n){var r=-1,i=12,o=5003,a=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];e.exports=function(t,e,n,s){var c,u,l,h,d,p,f=Math.max(2,s),m=new Uint8Array(256),g=new Int32Array(o),v=new Int32Array(o),y=0,b=0,_=!1;function x(t,e){m[u++]=t,u>=254&&M(e)}function w(t){E(o),b=d+2,_=!0,A(d,t)}function E(t){for(var e=0;e0&&(t.writeByte(u),t.writeBytes(m,0,u),u=0)}function T(t){return(1<0?c|=t<=8;)x(255&c,e),c>>=8,y-=8;if((b>l||_)&&(_?(l=T(n_bits=h),_=!1):(++n_bits,l=n_bits==i?1<0;)x(255&c,e),c>>=8,y-=8;M(e)}}this.encode=function(n){n.writeByte(f),remaining=t*e,curPixel=0,function(t,e){var n,a,s,c,f,m,y;for(h=t,_=!1,n_bits=h,l=T(n_bits),p=1+(d=1<=0){f=m-s,0===s&&(f=1);do{if((s-=f)<0&&(s+=m),g[s]===n){c=v[s];continue t}}while(g[s]>=0)}A(c,e),c=a,b<1<>l,d=c<>3,f=6,m=1<u;)c=A[p++],hu&&((s=n[d--])[0]-=c*(s[0]-r)/_,s[1]-=c*(s[1]-o)/_,s[2]-=c*(s[2]-a)/_)}function C(t,e,r){var o,c,p,f,g,v=~(1<<31),y=v,b=-1,_=b;for(o=0;o>s-a))>l,S[o]-=g,m[o]+=g<>3),t=0;t>f;for(S<=1&&(S=0),n=0;n=l&&(P-=l),n++,0===p&&(p=1),n%p==0)for(m-=m/h,(S=(_-=_/v)>>f)<=1&&(S=0),u=0;u>=a,n[t][1]>>=a,n[t][2]>>=a,n[t][3]=t}(),function(){var t,e,r,a,s,c,u=0,l=0;for(t=0;t>1,e=u+1;e>1,e=u+1;e<256;e++)p[e]=o}()},this.getColormap=function(){for(var t=[],e=[],r=0;r=0;)l=c?l=i:(l++,s<0&&(s=-s),(o=a[0]-t)<0&&(o=-o),(s+=o)=0&&(a=n[h],(s=e-a[1])>=c?h=-1:(h--,s<0&&(s=-s),(o=a[0]-t)<0&&(o=-o),(s+=o)e;0<=e?++t:--t)n.push(null);return n}.call(this),e=this.spawnWorkers(),!0===this.options.globalPalette)this.renderNextFrame();else for(t=0,n=e;0<=n?tn;0<=n?++t:--t)this.renderNextFrame();return this.emit("start"),this.emit("progress",0)},r.prototype.abort=function(){for(var t;null!=(t=this.activeWorkers.shift());)this.log("killing active worker"),t.terminate();return this.running=!1,this.emit("abort")},r.prototype.spawnWorkers=function(){var t,e,n,r;return t=Math.min(this.options.workers,this.frames.length),function(){n=[];for(var r=e=this.freeWorkers.length;e<=t?rt;e<=t?r++:r--)n.push(r);return n}.apply(this).forEach((r=this,function(t){var e;return r.log("spawning worker "+t),(e=new Worker(r.options.workerScript)).onmessage=function(t){return r.activeWorkers.splice(r.activeWorkers.indexOf(e),1),r.freeWorkers.push(e),r.frameFinished(t.data)},r.freeWorkers.push(e)})),t},r.prototype.frameFinished=function(t){var e,n;if(this.log("frame "+t.index+" finished - "+this.activeWorkers.length+" active"),this.finishedFrames++,this.emit("progress",this.finishedFrames/this.frames.length),this.imageParts[t.index]=t,!0===this.options.globalPalette&&(this.options.globalPalette=t.globalPalette,this.log("global palette analyzed"),this.frames.length>2))for(e=1,n=this.freeWorkers.length;1<=n?en;1<=n?++e:--e)this.renderNextFrame();return a.call(this.imageParts,null)>=0?this.renderNextFrame():this.finishRendering()},r.prototype.finishRendering=function(){var t,e,n,r,i,o,a,s,c,u,l,h,d,p,f,m;for(s=0,p=this.imageParts,i=0,c=p.length;i=this.frames.length))return t=this.frames[this.nextFrame++],n=this.freeWorkers.shift(),e=this.getTask(t),this.log("starting frame "+(e.index+1)+" of "+this.frames.length),this.activeWorkers.push(n),n.postMessage(e)},r.prototype.getContextData=function(t){return t.getImageData(0,0,this.options.width,this.options.height).data},r.prototype.getImageData=function(t){var e;return null==this._canvas&&(this._canvas=document.createElement("canvas"),this._canvas.width=this.options.width,this._canvas.height=this.options.height),(e=this._canvas.getContext("2d")).setFill=this.options.background,e.fillRect(0,0,this.options.width,this.options.height),e.drawImage(t,0,0),this.getContextData(e)},r.prototype.getTask=function(t){var e,n;if(e=this.frames.indexOf(t),n={index:e,last:e===this.frames.length-1,delay:t.delay,dispose:t.dispose,transparent:t.transparent,width:this.options.width,height:this.options.height,quality:this.options.quality,dither:this.options.dither,globalPalette:this.options.globalPalette,repeat:this.options.repeat,canTransfer:"chrome"===i.name},null!=t.data)n.data=t.data;else if(null!=t.context)n.data=this.getContextData(t.context);else{if(null==t.image)throw new Error("Invalid frame");n.data=this.getImageData(t.image)}return n},r.prototype.log=function(){var t;if(t=1<=arguments.length?s.call(arguments,0):[],this.options.debug)return console.log.apply(console,t)},r}(r)},{"./GIFEncoder.js":2,"./browser.coffee":5,"./gif.worker.coffee":7,events:1}],7:[function(t,e,n){var r,i;r=t("./GIFEncoder.js"),i=function(t){var e,n,i,o;return e=new r(t.width,t.height),0===t.index?e.writeHeader():e.firstFrame=!1,e.setTransparent(t.transparent),e.setDispose(t.dispose),e.setRepeat(t.repeat),e.setDelay(t.delay),e.setQuality(t.quality),e.setDither(t.dither),e.setGlobalPalette(t.globalPalette),e.addFrame(t.data),t.last&&e.finish(),!0===t.globalPalette&&(t.globalPalette=e.getGlobalPalette()),i=e.stream(),t.data=i.pages,t.cursor=i.cursor,t.pageSize=i.constructor.pageSize,t.canTransfer?(o=function(){var e,r,i,o;for(i=t.data,o=[],e=0,r=i.length;e>18&63]+t[o>>12&63]+t[o>>6&63]+t[63&o];switch(s.length%4){case 1:s+="=";break;case 2:s+="=="}return s}}(),function(){"use strict";var t,e=window.utils;t=[{field:"fileName",length:100},{field:"fileMode",length:8},{field:"uid",length:8},{field:"gid",length:8},{field:"fileSize",length:12},{field:"mtime",length:12},{field:"checksum",length:8},{field:"type",length:1},{field:"linkName",length:100},{field:"ustar",length:8},{field:"owner",length:32},{field:"group",length:32},{field:"majorNumber",length:8},{field:"minorNumber",length:8},{field:"filenamePrefix",length:155},{field:"padding",length:12}],window.header={},window.header.structure=t,window.header.format=function(n,r){var i=e.clean(512),o=0;return t.forEach(function(t){var e,r,a=n[t.field]||"";for(e=0,r=a.length;er&&(e.push({blocks:o,length:n}),o=[],n=0),o.push(t),n+=t.headerLength+t.inputLength}),e.push({blocks:o,length:n}),e.forEach(function(e){var n=new Uint8Array(e.length),r=0;e.blocks.forEach(function(t){n.set(t.header,r),r+=t.headerLength,n.set(t.input,r),r+=t.inputLength}),t.push(n)}),t.push(new Uint8Array(2*i)),new Blob(t,{type:"octet/stream"})},o.prototype.clear=function(){this.written=0,this.out=r.clean(e)},void 0!==t&&void 0!==t.exports?t.exports=o:window.Tar=o}()},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){(function(t,r){var i;!function(){if(void 0!==t&&void 0!==t.exports)var o=n(22),a=n(21),s=n(20);var c={function:!0,object:!0};function u(t){return t&&t.Object===Object?t:null}parseFloat,parseInt;var l=c[typeof e]&&e&&!e.nodeType?e:void 0,h=c[typeof t]&&t&&!t.nodeType?t:void 0,d=(h&&h.exports,u(l&&h&&"object"==typeof r&&r)),p=u(c[typeof self]&&self),f=u(c[typeof window]&&window),m=u(c[typeof this]&&this);d||f!==(m&&m.window)&&f||p||m||Function("return this")();function g(t){return String("0000000"+t).slice(-7)}"gc"in window||(window.gc=function(){}),HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(t,e,n){for(var r=atob(this.toDataURL(e,n).split(",")[1]),i=r.length,o=new Uint8Array(i),a=0;a=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|t}function f(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return G(t).length;default:if(r)return z(t).length;e=(""+e).toLowerCase(),r=!0}}function m(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function g(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=c.from(e,r)),c.isBuffer(e))return 0===e.length?-1:v(t,e,n,r,i);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):v(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,n,r,i){var o,a=1,s=t.length,c=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;a=2,s/=2,c/=2,n/=2}function u(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var l=-1;for(o=n;os&&(n=s-c),o=n;o>=0;o--){for(var h=!0,d=0;di&&(r=i):r=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var a=0;a>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function M(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function T(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i239?4:u>223?3:u>191?2:1;if(i+h<=n)switch(h){case 1:u<128&&(l=u);break;case 2:128==(192&(o=t[i+1]))&&(c=(31&u)<<6|63&o)>127&&(l=c);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(c=(15&u)<<12|(63&o)<<6|63&a)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(c=(15&u)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&c<1114112&&(l=c)}null===l?(l=65533,h=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),i+=h}return function(t){var e=t.length;if(e<=S)return String.fromCharCode.apply(String,t);var n="",r=0;for(;rthis.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,n);case"utf8":case"utf-8":return T(this,e,n);case"ascii":return A(this,e,n);case"latin1":case"binary":return L(this,e,n);case"base64":return M(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),""},c.prototype.compare=function(t,e,n,r,i){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,r>>>=0,i>>>=0,this===t)return 0;for(var o=i-r,a=n-e,s=Math.min(o,a),u=this.slice(r,i),l=t.slice(e,n),h=0;hi)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return y(this,t,e,n);case"utf8":case"utf-8":return b(this,t,e,n);case"ascii":return _(this,t,e,n);case"latin1":case"binary":return x(this,t,e,n);case"base64":return w(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var S=4096;function A(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;ir)&&(n=r);for(var i="",o=e;on)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,n,r,i,o){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function O(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-n,2);i>>8*(r?i:1-i)}function I(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-n,4);i>>8*(r?i:3-i)&255}function k(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function U(t,e,n,r,o){return o||k(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function B(t,e,n,r,o){return o||k(t,0,n,8),i.write(t,e,n,r,52,8),n+8}c.prototype.slice=function(t,e){var n,r=this.length;if(t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e0&&(i*=256);)r+=this[t+--e]*i;return r},c.prototype.readUInt8=function(t,e){return e||P(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return e||P(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return e||P(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return e||P(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return e||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||P(t,e,this.length);for(var r=this[t],i=1,o=0;++o=(i*=128)&&(r-=Math.pow(2,8*e)),r},c.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||P(t,e,this.length);for(var r=e,i=1,o=this[t+--r];r>0&&(i*=256);)o+=this[t+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},c.prototype.readInt8=function(t,e){return e||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){e||P(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(t,e){e||P(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(t,e){return e||P(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return e||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return e||P(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return e||P(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return e||P(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return e||P(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||N(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+i]=t/o&255;return e+n},c.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):O(this,t,e,!0),e+2},c.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):O(this,t,e,!1),e+2},c.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):I(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):I(this,t,e,!1),e+4},c.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);N(this,t,e,n,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+n},c.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);N(this,t,e,n,i-1,-i)}var o=n-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+n},c.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):O(this,t,e,!0),e+2},c.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):O(this,t,e,!1),e+2},c.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):I(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):I(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,n){return U(this,t,e,!0,n)},c.prototype.writeFloatBE=function(t,e,n){return U(this,t,e,!1,n)},c.prototype.writeDoubleLE=function(t,e,n){return B(this,t,e,!0,n)},c.prototype.writeDoubleBE=function(t,e,n){return B(this,t,e,!1,n)},c.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e=0;--i)t[i+e]=this[i+n];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function G(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(D,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,n,r){for(var i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}}).call(this,n(16))},function(t,e,n){e.EncodeBuffer=i;var r=n(9).preset;function i(t){if(!(this instanceof i))return new i(t);if(t&&(this.options=t,t.codec)){var e=this.codec=t.codec;e.bufferish&&(this.bufferish=e.bufferish)}}n(14).FlexEncoder.mixin(i.prototype),i.prototype.codec=r,i.prototype.write=function(t){this.codec.encode(this,t)}},function(t,e,n){e.encode=function(t,e){var n=new r(e);return n.write(t),n.read()};var r=n(18).EncodeBuffer},function(t,e,n){var r;t.exports=function t(e,n,i){function o(s,c){if(!n[s]){if(!e[s]){var u="function"==typeof r&&r;if(!c&&u)return r(s,!0);if(a)return a(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var h=n[s]={exports:{}};e[s][0].call(h.exports,function(t){var n=e[s][1][t];return o(n||t)},h,h.exports,t,e,n,i)}return n[s].exports}for(var a="function"==typeof r&&r,s=0;s0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){if(!i(e))throw TypeError("listener must be a function");var n=!1;function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var n,r,a,s;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],a=n.length,r=-1,n===e||i(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(n)){for(s=a;s-- >0;)if(n[s]===e||n[s].listener&&n[s].listener===e){r=s;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(i(n=this._events[t]))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){return this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(i(e))return 1;if(e)return e.length}return 0},r.listenerCount=function(t,e){return t.listenerCount(e)}},{}],2:[function(t,e,n){var r=t("./TypedNeuQuant.js"),i=t("./LZWEncoder.js");function o(){this.page=-1,this.pages=[],this.newPage()}o.pageSize=4096,o.charMap={};for(var a=0;a<256;a++)o.charMap[a]=String.fromCharCode(a);function s(t,e){this.width=~~t,this.height=~~e,this.transparent=null,this.transIndex=0,this.repeat=-1,this.delay=0,this.image=null,this.pixels=null,this.indexedPixels=null,this.colorDepth=null,this.colorTab=null,this.neuQuant=null,this.usedEntry=new Array,this.palSize=7,this.dispose=-1,this.firstFrame=!0,this.sample=10,this.dither=!1,this.globalPalette=!1,this.out=new o}o.prototype.newPage=function(){this.pages[++this.page]=new Uint8Array(o.pageSize),this.cursor=0},o.prototype.getData=function(){for(var t="",e=0;e=o.pageSize&&this.newPage(),this.pages[this.page][this.cursor++]=t},o.prototype.writeUTFBytes=function(t){for(var e=t.length,n=0;n=0&&(this.dispose=t)},s.prototype.setRepeat=function(t){this.repeat=t},s.prototype.setTransparent=function(t){this.transparent=t},s.prototype.addFrame=function(t){this.image=t,this.colorTab=this.globalPalette&&this.globalPalette.slice?this.globalPalette:null,this.getImagePixels(),this.analyzePixels(),!0===this.globalPalette&&(this.globalPalette=this.colorTab),this.firstFrame&&(this.writeLSD(),this.writePalette(),this.repeat>=0&&this.writeNetscapeExt()),this.writeGraphicCtrlExt(),this.writeImageDesc(),this.firstFrame||this.globalPalette||this.writePalette(),this.writePixels(),this.firstFrame=!1},s.prototype.finish=function(){this.out.writeByte(59)},s.prototype.setQuality=function(t){t<1&&(t=1),this.sample=t},s.prototype.setDither=function(t){!0===t&&(t="FloydSteinberg"),this.dither=t},s.prototype.setGlobalPalette=function(t){this.globalPalette=t},s.prototype.getGlobalPalette=function(){return this.globalPalette&&this.globalPalette.slice&&this.globalPalette.slice(0)||this.globalPalette},s.prototype.writeHeader=function(){this.out.writeUTFBytes("GIF89a")},s.prototype.analyzePixels=function(){this.colorTab||(this.neuQuant=new r(this.pixels,this.sample),this.neuQuant.buildColormap(),this.colorTab=this.neuQuant.getColormap()),this.dither?this.ditherPixels(this.dither.replace("-serpentine",""),null!==this.dither.match(/-serpentine/)):this.indexPixels(),this.pixels=null,this.colorDepth=8,this.palSize=7,null!==this.transparent&&(this.transIndex=this.findClosest(this.transparent,!0))},s.prototype.indexPixels=function(t){var e=this.pixels.length/3;this.indexedPixels=new Uint8Array(e);for(var n=0,r=0;r=0&&M+l=0&&T+u>16,(65280&t)>>8,255&t,e)},s.prototype.findClosestRGB=function(t,e,n,r){if(null===this.colorTab)return-1;if(this.neuQuant&&!r)return this.neuQuant.lookupRGB(t,e,n);for(var i=0,o=16777216,a=this.colorTab.length,s=0,c=0;s=0&&(e=7&this.dispose),e<<=2,this.out.writeByte(0|e|t),this.writeShort(this.delay),this.out.writeByte(this.transIndex),this.out.writeByte(0)},s.prototype.writeImageDesc=function(){this.out.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.firstFrame||this.globalPalette?this.out.writeByte(0):this.out.writeByte(128|this.palSize)},s.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(240|this.palSize),this.out.writeByte(0),this.out.writeByte(0)},s.prototype.writeNetscapeExt=function(){this.out.writeByte(33),this.out.writeByte(255),this.out.writeByte(11),this.out.writeUTFBytes("NETSCAPE2.0"),this.out.writeByte(3),this.out.writeByte(1),this.writeShort(this.repeat),this.out.writeByte(0)},s.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);for(var t=768-this.colorTab.length,e=0;e>8&255)},s.prototype.writePixels=function(){var t=new i(this.width,this.height,this.indexedPixels,this.colorDepth);t.encode(this.out)},s.prototype.stream=function(){return this.out},e.exports=s},{"./LZWEncoder.js":3,"./TypedNeuQuant.js":4}],3:[function(t,e,n){var r=-1,i=12,o=5003,a=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];e.exports=function(t,e,n,s){var c,u,l,h,d,p,f=Math.max(2,s),m=new Uint8Array(256),g=new Int32Array(o),v=new Int32Array(o),y=0,b=0,_=!1;function x(t,e){m[u++]=t,u>=254&&M(e)}function w(t){E(o),b=d+2,_=!0,A(d,t)}function E(t){for(var e=0;e0&&(t.writeByte(u),t.writeBytes(m,0,u),u=0)}function T(t){return(1<0?c|=t<=8;)x(255&c,e),c>>=8,y-=8;if((b>l||_)&&(_?(l=T(n_bits=h),_=!1):(++n_bits,l=n_bits==i?1<0;)x(255&c,e),c>>=8,y-=8;M(e)}}this.encode=function(n){n.writeByte(f),remaining=t*e,curPixel=0,function(t,e){var n,a,s,c,f,m,y;for(h=t,_=!1,n_bits=h,l=T(n_bits),p=1+(d=1<=0){f=m-s,0===s&&(f=1);do{if((s-=f)<0&&(s+=m),g[s]===n){c=v[s];continue t}}while(g[s]>=0)}A(c,e),c=a,b<1<>l,d=c<>3,f=6,m=1<u;)c=A[p++],hu&&((s=n[d--])[0]-=c*(s[0]-r)/_,s[1]-=c*(s[1]-o)/_,s[2]-=c*(s[2]-a)/_)}function C(t,e,r){var o,c,p,f,g,v=~(1<<31),y=v,b=-1,_=b;for(o=0;o>s-a))>l,S[o]-=g,m[o]+=g<>3),t=0;t>f;for(S<=1&&(S=0),n=0;n=l&&(P-=l),n++,0===p&&(p=1),n%p==0)for(m-=m/h,(S=(_-=_/v)>>f)<=1&&(S=0),u=0;u>=a,n[t][1]>>=a,n[t][2]>>=a,n[t][3]=t}(),function(){var t,e,r,a,s,c,u=0,l=0;for(t=0;t>1,e=u+1;e>1,e=u+1;e<256;e++)p[e]=o}()},this.getColormap=function(){for(var t=[],e=[],r=0;r=0;)l=c?l=i:(l++,s<0&&(s=-s),(o=a[0]-t)<0&&(o=-o),(s+=o)=0&&(a=n[h],(s=e-a[1])>=c?h=-1:(h--,s<0&&(s=-s),(o=a[0]-t)<0&&(o=-o),(s+=o)e;0<=e?++t:--t)n.push(null);return n}.call(this),e=this.spawnWorkers(),!0===this.options.globalPalette)this.renderNextFrame();else for(t=0,n=e;0<=n?tn;0<=n?++t:--t)this.renderNextFrame();return this.emit("start"),this.emit("progress",0)},r.prototype.abort=function(){for(var t;null!=(t=this.activeWorkers.shift());)this.log("killing active worker"),t.terminate();return this.running=!1,this.emit("abort")},r.prototype.spawnWorkers=function(){var t,e,n;return t=Math.min(this.options.workers,this.frames.length),function(){n=[];for(var r=e=this.freeWorkers.length;e<=t?rt;e<=t?r++:r--)n.push(r);return n}.apply(this).forEach(function(t){return function(e){var n;return t.log("spawning worker "+e),(n=new Worker(t.options.workerScript)).onmessage=function(e){return t.activeWorkers.splice(t.activeWorkers.indexOf(n),1),t.freeWorkers.push(n),t.frameFinished(e.data)},t.freeWorkers.push(n)}}(this)),t},r.prototype.frameFinished=function(t){var e,n;if(this.log("frame "+t.index+" finished - "+this.activeWorkers.length+" active"),this.finishedFrames++,this.emit("progress",this.finishedFrames/this.frames.length),this.imageParts[t.index]=t,!0===this.options.globalPalette&&(this.options.globalPalette=t.globalPalette,this.log("global palette analyzed"),this.frames.length>2))for(e=1,n=this.freeWorkers.length;1<=n?en;1<=n?++e:--e)this.renderNextFrame();return a.call(this.imageParts,null)>=0?this.renderNextFrame():this.finishRendering()},r.prototype.finishRendering=function(){var t,e,n,r,i,o,a,s,c,u,l,h,d,p,f,m;for(s=0,p=this.imageParts,i=0,c=p.length;i=this.frames.length))return t=this.frames[this.nextFrame++],n=this.freeWorkers.shift(),e=this.getTask(t),this.log("starting frame "+(e.index+1)+" of "+this.frames.length),this.activeWorkers.push(n),n.postMessage(e)},r.prototype.getContextData=function(t){return t.getImageData(0,0,this.options.width,this.options.height).data},r.prototype.getImageData=function(t){var e;return null==this._canvas&&(this._canvas=document.createElement("canvas"),this._canvas.width=this.options.width,this._canvas.height=this.options.height),(e=this._canvas.getContext("2d")).setFill=this.options.background,e.fillRect(0,0,this.options.width,this.options.height),e.drawImage(t,0,0),this.getContextData(e)},r.prototype.getTask=function(t){var e,n;if(e=this.frames.indexOf(t),n={index:e,last:e===this.frames.length-1,delay:t.delay,dispose:t.dispose,transparent:t.transparent,width:this.options.width,height:this.options.height,quality:this.options.quality,dither:this.options.dither,globalPalette:this.options.globalPalette,repeat:this.options.repeat,canTransfer:"chrome"===i.name},null!=t.data)n.data=t.data;else if(null!=t.context)n.data=this.getContextData(t.context);else{if(null==t.image)throw new Error("Invalid frame");n.data=this.getImageData(t.image)}return n},r.prototype.log=function(){var t;if(t=1<=arguments.length?s.call(arguments,0):[],this.options.debug)return console.log.apply(console,t)},r}(r)},{"./GIFEncoder.js":2,"./browser.coffee":5,"./gif.worker.coffee":7,events:1}],7:[function(t,e,n){var r,i;r=t("./GIFEncoder.js"),i=function(t){var e,n,i,o;return e=new r(t.width,t.height),0===t.index?e.writeHeader():e.firstFrame=!1,e.setTransparent(t.transparent),e.setDispose(t.dispose),e.setRepeat(t.repeat),e.setDelay(t.delay),e.setQuality(t.quality),e.setDither(t.dither),e.setGlobalPalette(t.globalPalette),e.addFrame(t.data),t.last&&e.finish(),!0===t.globalPalette&&(t.globalPalette=e.getGlobalPalette()),i=e.stream(),t.data=i.pages,t.cursor=i.cursor,t.pageSize=i.constructor.pageSize,t.canTransfer?(o=function(){var e,r,i,o;for(i=t.data,o=[],e=0,r=i.length;e>18&63]+t[e>>12&63]+t[e>>6&63]+t[63&e]}for(n=0,r=e.length-i;nr&&(e.push({blocks:o,length:n}),o=[],n=0),o.push(t),n+=t.headerLength+t.inputLength}),e.push({blocks:o,length:n}),e.forEach(function(e){var n=new Uint8Array(e.length),r=0;e.blocks.forEach(function(t){n.set(t.header,r),r+=t.headerLength,n.set(t.input,r),r+=t.inputLength}),t.push(n)}),t.push(new Uint8Array(2*i)),new Blob(t,{type:"octet/stream"})},o.prototype.clear=function(){this.written=0,this.out=r.clean(e)},void 0!==t&&void 0!==t.exports?t.exports=o:window.Tar=o}()},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){(function(t,r){var i;!function(){if(void 0!==t&&void 0!==t.exports)var o=n(22),a=n(21),s=n(20);var c={function:!0,object:!0};function u(t){return t&&t.Object===Object?t:null}parseFloat,parseInt;var l=c[typeof e]&&e&&!e.nodeType?e:void 0,h=c[typeof t]&&t&&!t.nodeType?t:void 0,d=(h&&h.exports,u(l&&h&&"object"==typeof r&&r)),p=u(c[typeof self]&&self),f=u(c[typeof window]&&window),m=u(c[typeof this]&&this);d||f!==(m&&m.window)&&f||p||m||Function("return this")();function g(t){return String("0000000"+t).slice(-7)}"gc"in window||(window.gc=function(){}),HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(t,e,n){for(var r=atob(this.toDataURL(e,n).split(",")[1]),i=r.length,o=new Uint8Array(i),a=0;a=u.frameLimit||u.timeLimit&&t>=u.timeLimit)&&(G(),V());var e=new Date(null);e.setSeconds(t),u.motionBlurFrames>2?y.textContent="CCapture "+u.format+" | "+d+" frames ("+p+" inter) | "+e.toISOString().substr(11,8):y.textContent="CCapture "+u.format+" | "+d+" frames | "+e.toISOString().substr(11,8)}(),W("Frame: "+d+" "+p);for(var a=0;a=l[a].triggerTime&&(H(l[a].callback),l.splice(a,1));for(a=0;a=h[a].triggerTime&&(H(h[a].callback),h[a].triggerTime+=h[a].time);f.forEach(function(t){H(t,n-v)}),f=[]}function V(t){t||(t=function(t){return a(t,c.filename+c.extension,c.mimeType),!1}),c.save(t)}function W(t){e&&console.log(t)}return{start:function(){!function(){function t(){return this._hooked||(this._hooked=!0,this._hookedTime=this.currentTime||0,this.pause(),z.push(this)),this._hookedTime+u.startTime}W("Capturer start"),r=window.Date.now(),n=r+u.startTime,o=window.performance.now(),i=o+u.startTime,window.Date.prototype.getTime=function(){return n},window.Date.now=function(){return n},window.setTimeout=function(t,e){var r={callback:t,time:e,triggerTime:n+e};return l.push(r),W("Timeout set to "+r.time),r},window.clearTimeout=function(t){for(var e=0;e2?(function(t){A.width===t.width&&A.height===t.height||(A.width=t.width,A.height=t.height,b=new Uint16Array(A.height*A.width*4),L.fillStyle="#0",L.fillRect(0,0,A.width,A.height))}(t),function(t){L.drawImage(t,0,0),S=L.getImageData(0,0,A.width,A.height);for(var e=0;e=.5*u.motionBlurFrames?function(){for(var t=S.data,e=0;e0&&this.frames.length/this.settings.framerate>=this.settings.autoSaveTime?this.save(function(t){this.filename=this.baseFilename+"-part-"+g(this.part),a(t,this.filename+this.extension,this.mimeType),this.dispose(),this.part++,this.filename=this.baseFilename+"-part-"+g(this.part),this.step()}.bind(this)):this.step()},w.prototype.save=function(t){this.videoWriter.complete().then(t)},w.prototype.dispose=function(t){this.frames=[]},E.prototype=Object.create(y.prototype),E.prototype.start=function(){this.encoder.start(this.settings)},E.prototype.add=function(t){this.encoder.add(t)},E.prototype.save=function(t){this.callback=t,this.encoder.end()},E.prototype.safeToProceed=function(){return this.encoder.safeToProceed()},M.prototype=Object.create(y.prototype),M.prototype.add=function(t){this.stream||(this.stream=t.captureStream(this.framerate),this.mediaRecorder=new MediaRecorder(this.stream),this.mediaRecorder.start(),this.mediaRecorder.ondataavailable=function(t){this.chunks.push(t.data)}.bind(this)),this.step()},M.prototype.save=function(t){this.mediaRecorder.onstop=function(e){var n=new Blob(this.chunks,{type:"video/webm"});this.chunks=[],t(n)}.bind(this),this.mediaRecorder.stop()},T.prototype=Object.create(y.prototype),T.prototype.add=function(t){this.sizeSet||(this.encoder.setOption("width",t.width),this.encoder.setOption("height",t.height),this.sizeSet=!0),this.canvas.width=t.width,this.canvas.height=t.height,this.ctx.drawImage(t,0,0),this.encoder.addFrame(this.ctx,{copy:!0,delay:this.settings.step}),this.step()},T.prototype.save=function(t){this.callback=t,this.encoder.render()},(f||p||{}).CCapture=S,void 0===(i=function(){return S}.call(e,n,e,t))||(t.exports=i)}()}).call(this,n(23)(t),n(16))},function(t,e,n){var r=n(1);r.OrbitControls=function(t,e){var n,i,o,a,s;this.object=t,this.domElement=void 0!==e?e:document,this.enabled=!0,this.target=new r.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.25,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={ORBIT:r.MOUSE.LEFT,ZOOM:r.MOUSE.MIDDLE,PAN:r.MOUSE.RIGHT},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return m.phi},this.getAzimuthalAngle=function(){return m.theta},this.saveState=function(){c.target0.copy(c.target),c.position0.copy(c.object.position),c.zoom0=c.object.zoom},this.reset=function(){c.target.copy(c.target0),c.object.position.copy(c.position0),c.object.zoom=c.zoom0,c.object.updateProjectionMatrix(),c.dispatchEvent(u),c.update(),p=d.NONE},this.update=(n=new r.Vector3,i=(new r.Quaternion).setFromUnitVectors(t.up,new r.Vector3(0,1,0)),o=i.clone().inverse(),a=new r.Vector3,s=new r.Quaternion,function(){var t=c.object.position;return n.copy(t).sub(c.target),n.applyQuaternion(i),m.setFromVector3(n),c.autoRotate&&p===d.NONE&&C(2*Math.PI/60/60*c.autoRotateSpeed),m.theta+=g.theta,m.phi+=g.phi,m.theta=Math.max(c.minAzimuthAngle,Math.min(c.maxAzimuthAngle,m.theta)),m.phi=Math.max(c.minPolarAngle,Math.min(c.maxPolarAngle,m.phi)),m.makeSafe(),m.radius*=v,m.radius=Math.max(c.minDistance,Math.min(c.maxDistance,m.radius)),c.target.add(y),n.setFromSpherical(m),n.applyQuaternion(o),t.copy(c.target).add(n),c.object.lookAt(c.target),!0===c.enableDamping?(g.theta*=1-c.dampingFactor,g.phi*=1-c.dampingFactor):g.set(0,0,0),v=1,y.set(0,0,0),!!(b||a.distanceToSquared(c.object.position)>f||8*(1-s.dot(c.object.quaternion))>f)&&(c.dispatchEvent(u),a.copy(c.object.position),s.copy(c.object.quaternion),b=!1,!0)}),this.dispose=function(){c.domElement.removeEventListener("contextmenu",q,!1),c.domElement.removeEventListener("mousedown",D,!1),c.domElement.removeEventListener("wheel",G,!1),c.domElement.removeEventListener("touchstart",j,!1),c.domElement.removeEventListener("touchend",W,!1),c.domElement.removeEventListener("touchmove",V,!1),document.removeEventListener("mousemove",F,!1),document.removeEventListener("mouseup",z,!1),window.removeEventListener("keydown",H,!1)};var c=this,u={type:"change"},l={type:"start"},h={type:"end"},d={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY:4,TOUCH_PAN:5},p=d.NONE,f=1e-6,m=new r.Spherical,g=new r.Spherical,v=1,y=new r.Vector3,b=!1,_=new r.Vector2,x=new r.Vector2,w=new r.Vector2,E=new r.Vector2,M=new r.Vector2,T=new r.Vector2,S=new r.Vector2,A=new r.Vector2,L=new r.Vector2;function R(){return Math.pow(.95,c.zoomSpeed)}function C(t){g.theta-=t}function P(t){g.phi-=t}var N,O=(N=new r.Vector3,function(t,e){N.setFromMatrixColumn(e,0),N.multiplyScalar(-t),y.add(N)}),I=function(){var t=new r.Vector3;return function(e,n){t.setFromMatrixColumn(n,1),t.multiplyScalar(e),y.add(t)}}(),k=function(){var t=new r.Vector3;return function(e,n){var r=c.domElement===document?c.domElement.body:c.domElement;if(c.object.isPerspectiveCamera){var i=c.object.position;t.copy(i).sub(c.target);var o=t.length();o*=Math.tan(c.object.fov/2*Math.PI/180),O(2*e*o/r.clientHeight,c.object.matrix),I(2*n*o/r.clientHeight,c.object.matrix)}else c.object.isOrthographicCamera?(O(e*(c.object.right-c.object.left)/c.object.zoom/r.clientWidth,c.object.matrix),I(n*(c.object.top-c.object.bottom)/c.object.zoom/r.clientHeight,c.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),c.enablePan=!1)}}();function U(t){c.object.isPerspectiveCamera?v/=t:c.object.isOrthographicCamera?(c.object.zoom=Math.max(c.minZoom,Math.min(c.maxZoom,c.object.zoom*t)),c.object.updateProjectionMatrix(),b=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),c.enableZoom=!1)}function B(t){c.object.isPerspectiveCamera?v*=t:c.object.isOrthographicCamera?(c.object.zoom=Math.max(c.minZoom,Math.min(c.maxZoom,c.object.zoom/t)),c.object.updateProjectionMatrix(),b=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),c.enableZoom=!1)}function D(t){if(!1!==c.enabled){switch(t.button){case c.mouseButtons.ORBIT:if(!1===c.enableRotate)return;!function(t){_.set(t.clientX,t.clientY)}(t),p=d.ROTATE;break;case c.mouseButtons.ZOOM:if(!1===c.enableZoom)return;!function(t){S.set(t.clientX,t.clientY)}(t),p=d.DOLLY;break;case c.mouseButtons.PAN:if(!1===c.enablePan)return;!function(t){E.set(t.clientX,t.clientY)}(t),p=d.PAN}p!==d.NONE&&(document.addEventListener("mousemove",F,!1),document.addEventListener("mouseup",z,!1),c.dispatchEvent(l))}}function F(t){if(!1!==c.enabled)switch(t.preventDefault(),p){case d.ROTATE:if(!1===c.enableRotate)return;!function(t){x.set(t.clientX,t.clientY),w.subVectors(x,_);var e=c.domElement===document?c.domElement.body:c.domElement;C(2*Math.PI*w.x/e.clientWidth*c.rotateSpeed),P(2*Math.PI*w.y/e.clientHeight*c.rotateSpeed),_.copy(x),c.update()}(t);break;case d.DOLLY:if(!1===c.enableZoom)return;!function(t){A.set(t.clientX,t.clientY),L.subVectors(A,S),L.y>0?U(R()):L.y<0&&B(R()),S.copy(A),c.update()}(t);break;case d.PAN:if(!1===c.enablePan)return;!function(t){M.set(t.clientX,t.clientY),T.subVectors(M,E),k(T.x,T.y),E.copy(M),c.update()}(t)}}function z(t){!1!==c.enabled&&(document.removeEventListener("mousemove",F,!1),document.removeEventListener("mouseup",z,!1),c.dispatchEvent(h),p=d.NONE)}function G(t){!1===c.enabled||!1===c.enableZoom||p!==d.NONE&&p!==d.ROTATE||(t.preventDefault(),t.stopPropagation(),function(t){t.deltaY<0?B(R()):t.deltaY>0&&U(R()),c.update()}(t),c.dispatchEvent(l),c.dispatchEvent(h))}function H(t){!1!==c.enabled&&!1!==c.enableKeys&&!1!==c.enablePan&&function(t){switch(t.keyCode){case c.keys.UP:k(0,c.keyPanSpeed),c.update();break;case c.keys.BOTTOM:k(0,-c.keyPanSpeed),c.update();break;case c.keys.LEFT:k(c.keyPanSpeed,0),c.update();break;case c.keys.RIGHT:k(-c.keyPanSpeed,0),c.update()}}(t)}function j(t){if(!1!==c.enabled){switch(t.touches.length){case 1:if(!1===c.enableRotate)return;!function(t){_.set(t.touches[0].pageX,t.touches[0].pageY)}(t),p=d.TOUCH_ROTATE;break;case 2:if(!1===c.enableZoom)return;!function(t){var e=t.touches[0].pageX-t.touches[1].pageX,n=t.touches[0].pageY-t.touches[1].pageY,r=Math.sqrt(e*e+n*n);S.set(0,r)}(t),p=d.TOUCH_DOLLY;break;case 3:if(!1===c.enablePan)return;!function(t){E.set(t.touches[0].pageX,t.touches[0].pageY)}(t),p=d.TOUCH_PAN;break;default:p=d.NONE}p!==d.NONE&&c.dispatchEvent(l)}}function V(t){if(!1!==c.enabled)switch(t.preventDefault(),t.stopPropagation(),t.touches.length){case 1:if(!1===c.enableRotate)return;if(p!==d.TOUCH_ROTATE)return;!function(t){x.set(t.touches[0].pageX,t.touches[0].pageY),w.subVectors(x,_);var e=c.domElement===document?c.domElement.body:c.domElement;C(2*Math.PI*w.x/e.clientWidth*c.rotateSpeed),P(2*Math.PI*w.y/e.clientHeight*c.rotateSpeed),_.copy(x),c.update()}(t);break;case 2:if(!1===c.enableZoom)return;if(p!==d.TOUCH_DOLLY)return;!function(t){var e=t.touches[0].pageX-t.touches[1].pageX,n=t.touches[0].pageY-t.touches[1].pageY,r=Math.sqrt(e*e+n*n);A.set(0,r),L.subVectors(A,S),L.y>0?B(R()):L.y<0&&U(R()),S.copy(A),c.update()}(t);break;case 3:if(!1===c.enablePan)return;if(p!==d.TOUCH_PAN)return;!function(t){M.set(t.touches[0].pageX,t.touches[0].pageY),T.subVectors(M,E),k(T.x,T.y),E.copy(M),c.update()}(t);break;default:p=d.NONE}}function W(t){!1!==c.enabled&&(c.dispatchEvent(h),p=d.NONE)}function q(t){!1!==c.enabled&&t.preventDefault()}c.domElement.addEventListener("contextmenu",q,!1),c.domElement.addEventListener("mousedown",D,!1),c.domElement.addEventListener("wheel",G,!1),c.domElement.addEventListener("touchstart",j,!1),c.domElement.addEventListener("touchend",W,!1),c.domElement.addEventListener("touchmove",V,!1),window.addEventListener("keydown",H,!1),this.update()},r.OrbitControls.prototype=Object.create(r.EventDispatcher.prototype),r.OrbitControls.prototype.constructor=r.OrbitControls,Object.defineProperties(r.OrbitControls.prototype,{center:{get:function(){return console.warn("THREE.OrbitControls: .center has been renamed to .target"),this.target}},noZoom:{get:function(){return console.warn("THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),!this.enableZoom},set:function(t){console.warn("THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),this.enableZoom=!t}},noRotate:{get:function(){return console.warn("THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),!this.enableRotate},set:function(t){console.warn("THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),this.enableRotate=!t}},noPan:{get:function(){return console.warn("THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead."),!this.enablePan},set:function(t){console.warn("THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead."),this.enablePan=!t}},noKeys:{get:function(){return console.warn("THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),!this.enableKeys},set:function(t){console.warn("THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),this.enableKeys=!t}},staticMoving:{get:function(){return console.warn("THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),!this.enableDamping},set:function(t){console.warn("THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),this.enableDamping=!t}},dynamicDampingFactor:{get:function(){return console.warn("THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.dampingFactor},set:function(t){console.warn("THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.dampingFactor=t}}})},function(t,e,n){var r=n(1);r.STLLoader=function(t){this.manager=void 0!==t?t:r.DefaultLoadingManager},r.STLLoader.prototype={constructor:r.STLLoader,load:function(t,e,n,i){var o=this,a=new r.FileLoader(o.manager);a.setPath(o.path),a.setResponseType("arraybuffer"),a.load(t,function(t){try{e(o.parse(t))}catch(t){i&&i(t)}},n,i)},setPath:function(t){return this.path=t,this},parse:function(t){function e(t,e,n){for(var r=0,i=t.length;r>5&31)/31,i=(w>>10&31)/31):(e=a,n=s,i=c)}for(var E=1;E<=3;E++){var M=y+12*E;m.push(l.getFloat32(M,!0)),m.push(l.getFloat32(M+4,!0)),m.push(l.getFloat32(M+8,!0)),g.push(b,_,x),d&&o.push(e,n,i)}}return f.addAttribute("position",new r.BufferAttribute(new Float32Array(m),3)),f.addAttribute("normal",new r.BufferAttribute(new Float32Array(g),3)),d&&(f.addAttribute("color",new r.BufferAttribute(new Float32Array(o),3)),f.hasColors=!0,f.alpha=u),f}(i):function(t){for(var e,n=new r.BufferGeometry,i=/facet([\s\S]*?)endfacet/g,o=0,a=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,s=new RegExp("vertex"+a+a+a,"g"),c=new RegExp("normal"+a+a+a,"g"),u=[],l=[],h=new r.Vector3;null!==(e=i.exec(t));){for(var d=0,p=0,f=e[0];null!==(e=c.exec(f));)h.x=parseFloat(e[1]),h.y=parseFloat(e[2]),h.z=parseFloat(e[3]),p++;for(;null!==(e=s.exec(f));)u.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])),l.push(h.x,h.y,h.z),d++;1!==p&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+o),3!==d&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+o),o++}return n.addAttribute("position",new r.Float32BufferAttribute(u,3)),n.addAttribute("normal",new r.Float32BufferAttribute(l,3)),n}("string"!=typeof(n=t)?r.LoaderUtils.decodeText(new Uint8Array(n)):n)}}},function(t,e,n){var r=n(1);r.ColladaLoader=function(t){this.manager=void 0!==t?t:r.DefaultLoadingManager},r.ColladaLoader.prototype={constructor:r.ColladaLoader,crossOrigin:"anonymous",load:function(t,e,n,i){var o=this,a=void 0===o.path?r.LoaderUtils.extractUrlBase(t):o.path,s=new r.FileLoader(o.manager);s.setPath(o.path),s.load(t,function(t){e(o.parse(t,a))},n,i)},setPath:function(t){return this.path=t,this},setResourcePath:function(t){return this.resourcePath=t,this},options:{set convertUpAxis(t){console.warn("THREE.ColladaLoader: options.convertUpAxis() has been removed. Up axis is converted automatically.")}},setCrossOrigin:function(t){return this.crossOrigin=t,this},parse:function(t,e){function n(t,e){for(var n=[],r=t.childNodes,i=0,o=r.length;i0&&e.push(new r.VectorKeyframeTrack(i+".position",o,a)),s.length>0&&e.push(new r.QuaternionKeyframeTrack(i+".quaternion",o,s)),c.length>0&&e.push(new r.VectorKeyframeTrack(i+".scale",o,c)),e}function x(t,e,n){var r,i,o,a=!0;for(i=0,o=t.length;i=0;){var r=t[e];if(null!==r.value[n])return r;e--}return null}function E(t,e,n){for(;e>>0));switch(n=n.toLowerCase()){case"tga":e=Dt;break;default:e=zt}return e}(n);if(void 0!==o){var a=o.load(n),s=t.extra;if(void 0!==s&&void 0!==s.technique&&!1===c(s.technique)){var u=s.technique;a.wrapS=u.wrapU?r.RepeatWrapping:r.ClampToEdgeWrapping,a.wrapT=u.wrapV?r.RepeatWrapping:r.ClampToEdgeWrapping,a.offset.set(u.offsetU||0,u.offsetV||0),a.repeat.set(u.repeatU||1,u.repeatV||1)}else a.wrapS=r.RepeatWrapping,a.wrapT=r.RepeatWrapping;return a}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",n),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",t.id),null}n.name=t.name;var u=o.parameters;for(var l in u){var d=u[l];switch(l){case"diffuse":d.color&&n.color.fromArray(d.color),d.texture&&(n.map=s(d.texture));break;case"specular":d.color&&n.specular&&n.specular.fromArray(d.color),d.texture&&(n.specularMap=s(d.texture));break;case"bump":d.texture&&(n.normalMap=s(d.texture));break;case"ambient":d.texture&&(n.lightMap=s(d.texture));break;case"shininess":d.float&&n.shininess&&(n.shininess=d.float);break;case"emission":d.color&&n.emissive&&n.emissive.fromArray(d.color),d.texture&&(n.emissiveMap=s(d.texture))}}var p=u.transparent,f=u.transparency;if(void 0===f&&p&&(f={float:1}),void 0===p&&f&&(p={opaque:"A_ONE",data:{color:[1,1,1,1]}}),p&&f)if(p.data.texture)n.transparent=!0;else{var m=p.data.color;switch(p.opaque){case"A_ONE":n.opacity=m[3]*f.float;break;case"RGB_ZERO":n.opacity=1-m[0]*f.float;break;case"A_ZERO":n.opacity=1-m[3]*f.float;break;case"RGB_ONE":n.opacity=m[0]*f.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',p.opaque)}n.opacity<1&&(n.transparent=!0)}return void 0!==a&&void 0!==a.technique&&1===a.technique.double_sided&&(n.side=r.DoubleSide),n}function X(t){return h(Vt.materials[t],q)}function Y(t){for(var e=0;e0?c+l:c;e.inputs[h]={id:o,offset:u},e.stride=Math.max(e.stride,u+1),"TEXCOORD"===c&&(e.hasUV=!0);break;case"vcount":e.vcount=a(i.textContent);break;case"p":e.p=a(i.textContent)}}return e}function at(t){for(var e=0,n=0,r=t.length;n0&&e0&&f.addAttribute("position",new r.Float32BufferAttribute(o.array,o.stride)),a.array.length>0&&f.addAttribute("normal",new r.Float32BufferAttribute(a.array,a.stride)),u.array.length>0&&f.addAttribute("color",new r.Float32BufferAttribute(u.array,u.stride)),s.array.length>0&&f.addAttribute("uv",new r.Float32BufferAttribute(s.array,s.stride)),c.array.length>0&&f.addAttribute("uv2",new r.Float32BufferAttribute(c.array,c.stride)),l.length>0&&f.addAttribute("skinIndex",new r.Float32BufferAttribute(l,h)),d.length>0&&f.addAttribute("skinWeight",new r.Float32BufferAttribute(d,p)),i.data=f,i.type=t[0].type,i.materialKeys=m,i}function ut(t,e,n,r){var i=t.p,o=t.stride,a=t.vcount;function s(t){for(var e=i[t+n]*u,o=e+u;e4)for(var v=1,y=p-2;v<=y;v++){f=l+o*v,m=l+o*(v+1);s(l+0*o),s(f),s(m)}l+=o*p}else for(h=0,d=i.length;h=e.limits.max&&(e.static=!0),e.middlePosition=(e.limits.min+e.limits.max)/2,e}function mt(t){for(var e={sid:t.getAttribute("sid"),name:t.getAttribute("name")||"",attachments:[],transforms:[]},n=0;ni.limits.max||eu){u=l;var n='Download of "'+t+'": '+(100*l).toFixed(2)+"%";c.onProgress("progressLoad",n,l)}}}n.isValid(o)||(o=function(e){var n='Error occurred while downloading "'+t+'"';c.logger.logError(n+": "+e),c.onProgress("error",n,-1)}),this.fileLoader.setPath(this.path),this.fileLoader.setResponseType("arraybuffer"),this.fileLoader.load(t,function(t){if(s)c.parseAsync(t,e);else{var n=new r.LoaderSupport.Callbacks;n.setCallbackOnMeshAlter(a),c._setCallbacks(n),e({detail:{loaderRootNode:c.parse(t),modelName:c.modelName,instanceNo:c.instanceNo}})}},i,o)},o.prototype.run=function(t,e){this._applyPrepData(t);var r=this._checkFiles(t.resources);n.isValid(e)&&(this.terminateWorkerOnLoad=!1,this.workerSupport=e,this.logger=e.logger);var i=this;this._loadMtl(r.mtl,function(e){i.builder.setMaterials(e),n.isValid(r.obj.content)?t.useAsync?i.parseAsync(r.obj.content,i.callbacks.onLoad):i.parse(r.obj.content):(i.setPath(r.obj.path),i.load(r.obj.name,i.callbacks.onLoad,null,null,i.callbacks.onMeshAlter,t.useAsync))},t.crossOrigin)},o.prototype._applyPrepData=function(t){r.LoaderSupport.LoaderBase.prototype._applyPrepData.call(this,t),n.isValid(t)&&this.setMaterialPerSmoothingGroup(t.materialPerSmoothingGroup)},o.prototype.parse=function(t){this.logger.logTimeStart("OBJLoader2 parse: "+this.modelName);var e=new s;e.setLogConfig(this.logger.enabled,this.logger.debug),e.setMaterialPerSmoothingGroup(this.materialPerSmoothingGroup),e.setUseIndices(this.useIndices),e.setDisregardNormals(this.disregardNormals),e.setMaterials(this.builder.getMaterials());var n=this;e.setCallbackBuilder(function(t){var e,r=n.builder.processPayload(t);for(var i in r)e=r[i],n.loaderRootNode.add(e)});if(e.setCallbackProgress(function(t,e){n.onProgress("progressParse",t,e)}),t instanceof ArrayBuffer||t instanceof Uint8Array)this.logger.logInfo("Parsing arrayBuffer..."),e.parse(t);else{if(!("string"==typeof t||t instanceof String))throw"Provided content was neither of type String nor Uint8Array! Aborting...";this.logger.logInfo("Parsing text..."),e.parseText(t)}return this.logger.logTimeEnd("OBJLoader2 parse: "+this.modelName),this.loaderRootNode},o.prototype.parseAsync=function(t,o){this.logger.logTimeStart("OBJLoader2 parseAsync: "+this.modelName);var l=this;this.workerSupport=n.verifyInput(this.workerSupport,new r.LoaderSupport.WorkerSupport(this.logger));this.workerSupport.validate(function(t,r){var o="";return o+="/**\n",o+=" * This code was constructed by OBJLoader2 buildCode.\n",o+=" */\n\n",o+=t("Validator",n),o+=r("ConsoleLogger","ConsoleLogger",i),o+=r("LoaderBase","LoaderBase",e),o+=t("Consts",a),o+=r("Parser","Parser",s),o+=r("RawMesh","RawMesh",c),o+=r("RawMeshSubGroup","RawMeshSubGroup",u)},!1),this.workerSupport.setCallbacks(function(t){var e,n=l.builder.processPayload(t);for(var r in n)e=n[r],l.loaderRootNode.add(e)},function(){o({detail:{loaderRootNode:l.loaderRootNode,modelName:l.modelName,instanceNo:l.instanceNo}}),l.logger.logTimeEnd("OBJLoader2 parseAsync: "+l.modelName)}),l.terminateWorkerOnLoad&&this.workerSupport.setTerminateRequested(!0);var h={},d=this.builder.getMaterials();for(var p in d)h[p]=p;this.workerSupport.run({params:{useAsync:!0,materialPerSmoothingGroup:this.materialPerSmoothingGroup,useIndices:this.useIndices,disregardNormals:this.disregardNormals},logger:{debug:this.logger.debug,enabled:this.logger.enabled},materials:{materials:h},data:{input:t,options:null}})};var a={CODE_LF:10,CODE_CR:13,CODE_SPACE:32,CODE_SLASH:47,STRING_LF:"\n",STRING_CR:"\r",STRING_SPACE:" ",STRING_SLASH:"/",LINE_F:"f",LINE_G:"g",LINE_L:"l",LINE_O:"o",LINE_S:"s",LINE_V:"v",LINE_VT:"vt",LINE_VN:"vn",LINE_MTLLIB:"mtllib",LINE_USEMTL:"usemtl"},s=function(){var t=r.LoaderSupport.ConsoleLogger;function e(){this.callbackProgress=null,this.callbackBuilder=null,this.materials={},this.rawMesh=null,this.useAsync=!1,this.materialPerSmoothingGroup=!1,this.useIndices=!1,this.disregardNormals=!1,this.inputObjectCount=1,this.outputObjectCount=1,this.counts={vertices:0,faces:0,doubleIndicesCount:0},this.logger=new t,this.totalBytes=0}return e.prototype.setUseAsync=function(t){this.useAsync=t},e.prototype.setMaterialPerSmoothingGroup=function(t){this.materialPerSmoothingGroup=t},e.prototype.setUseIndices=function(t){this.useIndices=t},e.prototype.setDisregardNormals=function(t){this.disregardNormals=t},e.prototype.setMaterials=function(t){this.materials=n.verifyInput(t,this.materials),this.materials=n.verifyInput(this.materials,{})},e.prototype.setCallbackBuilder=function(t){if(this.callbackBuilder=t,!n.isValid(this.callbackBuilder))throw'Unable to run as no "builder" callback is set.'},e.prototype.setCallbackProgress=function(t){this.callbackProgress=t},e.prototype.setLogConfig=function(t,e){this.logger.setEnabled(t),this.logger.setDebug(e)},e.prototype.configure=function(){if(this.rawMesh=new c(this.materialPerSmoothingGroup,this.useIndices,this.disregardNormals),this.logger.isEnabled()){var t=Object.keys(this.materials),e="OBJLoader2.Parser configuration:"+(t.length>0?"\n\tmaterialNames:\n\t\t- "+t.join("\n\t\t- "):"\n\tmaterialNames: None")+"\n\tuseAsync: "+this.useAsync+"\n\tmaterialPerSmoothingGroup: "+this.materialPerSmoothingGroup+"\n\tuseIndices: "+this.useIndices+"\n\tdisregardNormals: "+this.disregardNormals+"\n\tcallbackBuilderName: "+this.callbackBuilder.name+"\n\tcallbackProgressName: "+this.callbackProgress.name;this.logger.logInfo(e)}},e.prototype.parse=function(t){this.logger.logTimeStart("OBJLoader2.Parser.parse"),this.configure();var e=new Uint8Array(t),n=e.byteLength;this.totalBytes=n;for(var r,i=new Array(128),o=0,s=new Array(16),c=0,u="",l=0;l0&&(i[o++]=u),s[c++]=0,u="";break;case a.CODE_SLASH:u.length>0&&(i[o++]=u),s[c++]=1,u="";break;case a.CODE_LF:u.length>0&&(i[o++]=u),u="",this.processLine(i,o,s,c,l),o=0,c=0;break;case a.CODE_CR:break;default:u+=String.fromCharCode(r)}this.finalize(l),this.logger.logTimeEnd("OBJLoader2.Parser.parse")},e.prototype.parseText=function(t){this.logger.logTimeStart("OBJLoader2.Parser.parseText"),this.configure();var e=t.length;this.totalBytes=e;for(var n,r=new Array(128),i=0,o=new Array(16),s=0,c="",u=0;u0&&(r[i++]=c),o[s++]=0,c="";break;case a.STRING_SLASH:c.length>0&&(r[i++]=c),o[s++]=1,c="";break;case a.STRING_LF:c.length>0&&(r[i++]=c),c="",this.processLine(r,i,o,s,u),i=0,s=0;break;case a.STRING_CR:break;default:c+=n}this.finalize(u),this.logger.logTimeEnd("OBJLoader2.Parser.parseText")},e.prototype.processLine=function(t,e,n,r,i){if(!(e<1)){var o=function(t,e){for(var n=0,r=0;r4);break;case a.LINE_VT:this.rawMesh.pushUv(t);break;case a.LINE_VN:this.rawMesh.pushNormal(t);break;case a.LINE_F:this.rawMesh.processFaces(t,e,o(n,r));break;case a.LINE_L:this.rawMesh.processLines(t,e,o(n,r));break;case a.LINE_S:this.rawMesh.pushSmoothingGroup(t[1]),c(t,e);break;case a.LINE_G:this.processCompletedMesh(i),this.rawMesh.pushGroup(s(t,e,n)),c(t,e);break;case a.LINE_O:this.rawMesh.pushObject(s(t,e,n)),c(t,e);break;case a.LINE_MTLLIB:this.rawMesh.pushMtllib(s(t,e,n)),c(t,e);break;case a.LINE_USEMTL:this.rawMesh.pushUsemtl(s(t,e,n)),c(t,e)}}},e.prototype.createRawMeshReport=function(t,e){var n=t.createReport(e);return"Input Object number: "+e+"\n\tObject name: "+n.objectName+"\n\tGroup name: "+n.groupName+"\n\tMtllib name: "+n.mtllibName+"\n\tVertex count: "+n.vertexCount+"\n\tNormal count: "+n.normalCount+"\n\tUV count: "+n.uvCount+"\n\tSmoothingGroup count: "+n.smoothingGroupCount+"\n\tMaterial count: "+n.mtlCount+"\n\tReal RawMeshSubGroup count: "+n.subGroups},e.prototype.processCompletedMesh=function(t){var e=this.rawMesh.finalize();if(n.isValid(e)){if(this.rawMesh.colors.length>0&&this.rawMesh.colors.length!==this.rawMesh.vertices.length)throw"Vertex Colors were detected, but vertex count and color count do not match!";this.logger.isDebug()&&this.logger.logDebug(this.createRawMeshReport(this.rawMesh,this.inputObjectCount)),this.inputObjectCount++,this.buildMesh(e,t);var r=t/this.totalBytes;return this.callbackProgress("Completed [o: "+this.rawMesh.objectName+" g:"+this.rawMesh.groupName+"] Total progress: "+(100*r).toFixed(2)+"%",r),this.rawMesh.reset(this.rawMesh.smoothingGroup.splitMaterials),!0}return!1},e.prototype.finalize=function(t){if(this.logger.logInfo("Global output object count: "+this.outputObjectCount),this.processCompletedMesh(t)&&this.logger.isEnabled()){var e="Overall counts: \n\tVertices: "+this.counts.vertices+"\n\tFaces: "+this.counts.faces+"\n\tMultiple definitions: "+this.counts.doubleIndicesCount;this.logger.logInfo(e)}},e.prototype.buildMesh=function(t,e){var r=t.subGroups,i=new Float32Array(t.absoluteVertexCount);this.counts.vertices+=t.absoluteVertexCount/3,this.counts.faces+=t.faceCount,this.counts.doubleIndicesCount+=t.doubleIndicesCount;var o,a,s,c,u,l,h,d=t.absoluteIndexCount>0?new Uint32Array(t.absoluteIndexCount):null,p=t.absoluteColorCount>0?new Float32Array(t.absoluteColorCount):null,f=t.absoluteNormalCount>0?new Float32Array(t.absoluteNormalCount):null,m=t.absoluteUvCount>0?new Float32Array(t.absoluteUvCount):null,g=n.isValid(p),v=[],y=r.length>1,b=0,_=[],x=[],w=0,E=0,M=0,T=0,S=0,A=0,L=0;for(var R in r)if(r.hasOwnProperty(R)){if(l=(h=(o=r[R]).materialName)+(g?"_vertexColor":"")+(0===o.smoothingGroup?"_flat":""),c=this.materials[h],u=this.materials[l],!n.isValid(c)&&!n.isValid(u)){var C=g?"vertexColorMaterial":"defaultMaterial";c=this.materials[C],this.logger.logWarn('object_group "'+o.objectName+"_"+o.groupName+'" was defined with unresolvable material "'+h+'"! Assigning "'+C+'".'),(h=C)===l&&(u=c,l=C)}if(!n.isValid(u)){var P={materialNameOrg:h,materialName:l,materialProperties:{vertexColors:g?2:0,flatShading:0===o.smoothingGroup}},N={cmd:"materialData",materials:{materialCloneInstructions:P}};this.callbackBuilder(N),this.useAsync&&(this.materials[l]=P)}if(y?((a=_[l])||(a=b,_[l]=b,v.push(l),b++),s={start:A,count:L=this.useIndices?o.indices.length:o.vertices.length/3,index:a},x.push(s),A+=L):v.push(l),i.set(o.vertices,w),w+=o.vertices.length,d&&(d.set(o.indices,E),E+=o.indices.length),p&&(p.set(o.colors,M),M+=o.colors.length),f&&(f.set(o.normals,T),T+=o.normals.length),m&&(m.set(o.uvs,S),S+=o.uvs.length),this.logger.isDebug()){var O=n.isValid(a)?"\n\t\tmaterialIndex: "+a:"",I="Output Object no.: "+this.outputObjectCount+"\n\t\tgroupName: "+o.groupName+O+"\n\t\tmaterialName: "+o.materialName+"\n\t\tsmoothingGroup: "+o.smoothingGroup+"\n\t\tobjectName: "+o.objectName+"\n\t\t#vertices: "+o.vertices.length/3+"\n\t\t#indices: "+o.indices.length+"\n\t\t#colors: "+o.colors.length/3+"\n\t\t#uvs: "+o.uvs.length/2+"\n\t\t#normals: "+o.normals.length/3;this.logger.logDebug(I)}}this.outputObjectCount++,this.callbackBuilder({cmd:"meshData",progress:{numericalValue:e/this.totalBytes},params:{meshName:t.name},materials:{multiMaterial:y,materialNames:v,materialGroups:x},buffers:{vertices:i,indices:d,colors:p,normals:f,uvs:m}},[i.buffer],n.isValid(d)?[d.buffer]:null,n.isValid(p)?[p.buffer]:null,n.isValid(f)?[f.buffer]:null,n.isValid(m)?[m.buffer]:null)},e}(),c=function(){function t(t,e,n){this.vertices=[],this.colors=[],this.normals=[],this.uvs=[],this.useIndices=!0===e,this.disregardNormals=!0===n,this.objectName="",this.groupName="",this.activeMtlName="",this.mtllibName="",this.reset(t)}return t.prototype.reset=function(t){this.subGroups=[],this.subGroupInUse=null,this.smoothingGroup={splitMaterials:!0===t,normalized:-1,real:-1},this.pushSmoothingGroup(1),this.doubleIndicesCount=0,this.faceCount=0,this.mtlCount=0,this.smoothingGroupCount=0},t.prototype.pushVertex=function(t,e){this.vertices.push(parseFloat(t[1])),this.vertices.push(parseFloat(t[2])),this.vertices.push(parseFloat(t[3])),e&&(this.colors.push(parseFloat(t[4])),this.colors.push(parseFloat(t[5])),this.colors.push(parseFloat(t[6])))},t.prototype.pushUv=function(t){this.uvs.push(parseFloat(t[1])),this.uvs.push(parseFloat(t[2]))},t.prototype.pushNormal=function(t){this.normals.push(parseFloat(t[1])),this.normals.push(parseFloat(t[2])),this.normals.push(parseFloat(t[3]))},t.prototype.pushGroup=function(t){this.groupName=n.verifyInput(t,"")},t.prototype.pushObject=function(t){this.objectName=n.verifyInput(t,"")},t.prototype.pushMtllib=function(t){this.mtllibName=n.verifyInput(t,"")},t.prototype.pushUsemtl=function(t){this.activeMtlName!==t&&n.isValid(t)&&(this.activeMtlName=t,this.mtlCount++,this.verifyIndex())},t.prototype.pushSmoothingGroup=function(t){var e=parseInt(t);isNaN(e)&&(e="off"===t?0:1);var n=this.smoothingGroup.normalized;this.smoothingGroup.normalized=this.smoothingGroup.splitMaterials?e:0===e?0:1,this.smoothingGroup.real=e,n!==e&&(this.smoothingGroupCount++,this.verifyIndex())},t.prototype.verifyIndex=function(){var t=this.activeMtlName+"|"+this.smoothingGroup.normalized;this.subGroupInUse=this.subGroups[t],n.isValid(this.subGroupInUse)||(this.subGroupInUse=new u(this.objectName,this.groupName,this.activeMtlName,this.smoothingGroup.normalized),this.subGroups[t]=this.subGroupInUse)},t.prototype.processFaces=function(t,e,n){var r,i,o=e-1;if(0===n)for(r=2,i=o;r0?n-1:n+o.vertices.length/3),s=i.vertices;s.push(o.vertices[a++]),s.push(o.vertices[a++]),s.push(o.vertices[a]);var c=o.colors.length>0?a:null;if(null!==c){var u=i.colors;u.push(o.colors[c++]),u.push(o.colors[c++]),u.push(o.colors[c])}if(e){var l=parseInt(e),h=2*(l>0?l-1:l+o.uvs.length/2),d=i.uvs;d.push(o.uvs[h++]),d.push(o.uvs[h])}if(r){var p=parseInt(r),f=3*(p>0?p-1:p+o.normals.length/3),m=i.normals;m.push(o.normals[f++]),m.push(o.normals[f++]),m.push(o.normals[f])}};if(this.useIndices){var s=t+(e?"_"+e:"_n")+(r?"_"+r:"_n"),c=i.indexMappings[s];n.isValid(c)?this.doubleIndicesCount++:(c=i.vertices.length/3,a(),i.indexMappings[s]=c,i.indexMappingsCount++),i.indices.push(c)}else a();this.faceCount++},t.prototype.processLines=function(t,e,n){var r,i=1,o=e-1;if(o===2*n)for(r=o-2;i0){if((e=t.indices).length>0&&i>0)for(var l in e)e[l]=e[l]+i;n.push(t),r+=t.vertices.length,i+=t.indexMappingsCount,o+=t.indices.length,a+=t.colors.length,c+=t.uvs.length,s+=t.normals.length}var h=null;return n.length>0&&(h={name:""!==this.groupName?this.groupName:this.objectName,subGroups:n,absoluteVertexCount:r,absoluteIndexCount:o,absoluteColorCount:a,absoluteNormalCount:s,absoluteUvCount:c,faceCount:this.faceCount,doubleIndicesCount:this.doubleIndicesCount}),h},t.prototype.createReport=function(){return{objectName:this.objectName,groupName:this.groupName,mtllibName:this.mtllibName,vertexCount:this.vertices.length/3,normalCount:this.normals.length/3,uvCount:this.uvs.length/2,smoothingGroupCount:this.smoothingGroupCount,mtlCount:this.mtlCount,subGroups:this.subGroups.length}},t}(),u=function(){function t(t,e,n,r){this.objectName=t,this.groupName=e,this.materialName=n,this.smoothingGroup=r,this._init()}return t.prototype._init=function(){this.vertices=[],this.indexMappingsCount=0,this.indexMappings=[],this.indices=[],this.colors=[],this.uvs=[],this.normals=[]},t}();return o.prototype._checkFiles=function(t){var e,r={mtl:null,obj:null};for(var i in t)if(e=t[i],n.isValid(e.name))if(n.isValid(e.content)){if("OBJ"===e.extension){if(!(e.content instanceof Uint8Array))throw"Provided content is not of type arraybuffer! Aborting...";r.obj=e}else if("MTL"===e.extension&&n.isValid(e.name)){if(!("string"==typeof e.content||e.content instanceof String))throw"Provided content is not of type String! Aborting...";r.mtl=e}else if("ZIP"!==e.extension)throw'Unidentified resource "'+e.name+'": '+e.url}else{if(!("string"==typeof e.name||e.name instanceof String))throw"Provided file is not properly defined! Aborting...";if("OBJ"===e.extension)r.obj=e;else if("MTL"===e.extension)r.mtl=e;else if("ZIP"!==e.extension)throw'Unidentified resource "'+e.name+'": '+e.url}return r},o.prototype.loadMtl=function(t,e,n,i){var o=new r.LoaderSupport.ResourceDescriptor(t,"MTL");o.setContent(e),this._loadMtl(o,n,i)},o.prototype._loadMtl=function(t,e,i){void 0===r.MTLLoader&&console.error('"THREE.MTLLoader" is not available. "THREE.OBJLoader2" requires it for loading MTL files.'),n.isValid(t)&&this.logger.logTimeStart("Loading MTL: "+t.name);var o=[],a=this,s=function(r){var i=[];if(n.isValid(r))for(var s in r.preload(),i=r.materials)i.hasOwnProperty(s)&&(o[s]=i[s]);n.isValid(t)&&a.logger.logTimeEnd("Loading MTL: "+t.name),e(o)},c=new r.MTLLoader;if(i=n.verifyInput(i,"anonymous"),c.setCrossOrigin(i),n.isValid(t)&&(n.isValid(t.content)||n.isValid(t.url))){if(c.setPath(t.path),n.isValid(t.content))s(n.isValid(t.content)?c.parse(t.content):null);else if(n.isValid(t.url)){c.load(t.name,s,void 0,function(e){var n='Error occurred while downloading "'+t.url+'"';throw a.logger.logError(n+": "+e),n})}}else s()},o}()},function(t,e,n){var r=n(1);void 0===r.LoaderSupport&&(r.LoaderSupport={}),r.LoaderSupport.Validator={isValid:function(t){return null!==t&&void 0!==t},verifyInput:function(t,e){return null===t||void 0===t?e:t}},r.LoaderSupport.ConsoleLogger=function(){function t(t,e){this.enabled=!1!==t,this.debug=!0===e}return t.prototype.setDebug=function(t){this.debug=!0===t},t.prototype.isDebug=function(){return this.isEnabled()&&this.debug},t.prototype.setEnabled=function(t){this.enabled=!0===t},t.prototype.isEnabled=function(){return this.enabled},t.prototype.logDebug=function(t){this.enabled&&this.debug&&console.info(t)},t.prototype.logInfo=function(t){this.enabled&&console.info(t)},t.prototype.logWarn=function(t){console.warn(t)},t.prototype.logError=function(t){console.error(t)},t.prototype.logTimeStart=function(t){this.enabled&&console.time(t)},t.prototype.logTimeEnd=function(t){this.enabled&&console.timeEnd(t)},t}(),r.LoaderSupport.Callbacks=function(){var t=r.LoaderSupport.Validator;function e(){this.onProgress=null,this.onMeshAlter=null,this.onLoad=null,this.onLoadMaterials=null}return e.prototype.setCallbackOnProgress=function(e){this.onProgress=t.verifyInput(e,this.onProgress)},e.prototype.setCallbackOnMeshAlter=function(e){this.onMeshAlter=t.verifyInput(e,this.onMeshAlter)},e.prototype.setCallbackOnLoad=function(e){this.onLoad=t.verifyInput(e,this.onLoad)},e.prototype.setCallbackOnLoadMaterials=function(e){this.onLoadMaterials=t.verifyInput(e,this.onLoadMaterials)},e}(),r.LoaderSupport.LoadedMeshUserOverride=function(){function t(t,e){this.disregardMesh=!0===t,this.alteredMesh=!0===e,this.meshes=[]}return t.prototype.addMesh=function(t){this.meshes.push(t),this.alteredMesh=!0},t.prototype.isDisregardMesh=function(){return this.disregardMesh},t.prototype.providesAlteredMeshes=function(){return this.alteredMesh},t}(),r.LoaderSupport.ResourceDescriptor=function(){var t=r.LoaderSupport.Validator;function e(e,n){var r=e.split("/");r.length<2?(this.path=null,this.name=e,this.url=e):(this.path=t.verifyInput(r.slice(0,r.length-1).join("/")+"/",null),this.name=t.verifyInput(r[r.length-1],null),this.url=e),this.extension=t.verifyInput(n,"default"),this.extension=this.extension.trim(),this.content=null}return e.prototype.setContent=function(e){this.content=t.verifyInput(e,null)},e}(),r.LoaderSupport.PrepData=function(){var t=r.LoaderSupport.Validator;function e(e){this.modelName=t.verifyInput(e,""),this.resources=[],this.streamMeshesTo=null,this.materialPerSmoothingGroup=!1,this.useIndices=!1,this.disregardNormals=!1,this.callbacks=new r.LoaderSupport.Callbacks,this.crossOrigin,this.useAsync=!1}return e.prototype.setStreamMeshesTo=function(e){this.streamMeshesTo=t.verifyInput(e,null)},e.prototype.setMaterialPerSmoothingGroup=function(t){this.materialPerSmoothingGroup=!0===t},e.prototype.setUseIndices=function(t){this.useIndices=!0===t},e.prototype.setDisregardNormals=function(t){this.disregardNormals=!0===t},e.prototype.getCallbacks=function(){return this.callbacks},e.prototype.setCrossOrigin=function(t){this.crossOrigin=t},e.prototype.addResource=function(t){this.resources.push(t)},e.prototype.setUseAsync=function(t){this.useAsync=!0===t},e.prototype.clone=function(){var t=new r.LoaderSupport.PrepData(this.modelName);return t.resources=this.resources,t.streamMeshesTo=this.streamMeshesTo,t.materialPerSmoothingGroup=this.materialPerSmoothingGroup,t.useIndices=this.useIndices,t.disregardNormals=this.disregardNormals,t.callbacks=this.callbacks,t.crossOrigin=this.crossOrigin,t.useAsync=this.useAsync,t},e}(),r.LoaderSupport.Builder=function(){var t="1.1.1",e=r.LoaderSupport.Validator,n=r.LoaderSupport.ConsoleLogger;function i(i){this.logger=e.verifyInput(i,new n),this.logger.logInfo("Using THREE.LoaderSupport.Builder version: "+t),this.callbacks=new r.LoaderSupport.Callbacks,this.materials=[]}return i.prototype.setMaterials=function(t){var n={cmd:"materialData",materials:{materialCloneInstructions:null,serializedMaterials:null,runtimeMaterials:e.isValid(this.callbacks.onLoadMaterials)?this.callbacks.onLoadMaterials(t):t}};this.updateMaterials(n)},i.prototype._setCallbacks=function(t){e.isValid(t.onProgress)&&this.callbacks.setCallbackOnProgress(t.onProgress),e.isValid(t.onMeshAlter)&&this.callbacks.setCallbackOnMeshAlter(t.onMeshAlter),e.isValid(t.onLoad)&&this.callbacks.setCallbackOnLoad(t.onLoad),e.isValid(t.onLoadMaterials)&&this.callbacks.setCallbackOnLoadMaterials(t.onLoadMaterials)},i.prototype.processPayload=function(t){return"meshData"===t.cmd?this.buildMeshes(t):"materialData"===t.cmd?(this.updateMaterials(t),null):void 0},i.prototype.buildMeshes=function(t){var n,i,o,a=t.params.meshName,s=new r.BufferGeometry;s.addAttribute("position",new r.BufferAttribute(new Float32Array(t.buffers.vertices),3)),e.isValid(t.buffers.indices)&&s.setIndex(new r.BufferAttribute(new Uint32Array(t.buffers.indices),1)),e.isValid(t.buffers.colors)&&s.addAttribute("color",new r.BufferAttribute(new Float32Array(t.buffers.colors),3)),e.isValid(t.buffers.normals)?s.addAttribute("normal",new r.BufferAttribute(new Float32Array(t.buffers.normals),3)):s.computeVertexNormals(),e.isValid(t.buffers.uvs)&&s.addAttribute("uv",new r.BufferAttribute(new Float32Array(t.buffers.uvs),2));var c=t.materials.materialNames,u=t.materials.multiMaterial,l=[];for(o in c)i=c[o],n=this.materials[i],u&&l.push(n);if(u){n=l;var h,d=t.materials.materialGroups;for(o in d)h=d[o],s.addGroup(h.start,h.count,h.index)}var p,f,m,g=[],v=this.callbacks.onMeshAlter,y=!0;if(e.isValid(v)&&(f=v({detail:{meshName:a,bufferGeometry:s,material:n}}),e.isValid(f))){if(!f.isDisregardMesh()&&f.providesAlteredMeshes())for(var b in f.meshes)g.push(f.meshes[b]);y=!1}if(y&&((p=new r.Mesh(s,n)).name=a,g.push(p)),e.isValid(g)&&g.length>0){var _=[];for(var b in g)p=g[b],_[b]=p.name;m="Adding mesh(es) ("+_.length+": "+_+") from input mesh: "+a,m+=" ("+(100*t.progress.numericalValue).toFixed(2)+"%)"}else m="Not adding mesh: "+a,m+=" ("+(100*t.progress.numericalValue).toFixed(2)+"%)";var x=this.callbacks.onProgress;e.isValid(x)&&x(new CustomEvent("BuilderEvent",{detail:{type:"progress",modelName:t.params.meshName,text:m,numericalValue:t.progress.numericalValue}}));return g},i.prototype.updateMaterials=function(t){var n,i,o=t.materials.materialCloneInstructions;if(e.isValid(o)){var a=o.materialNameOrg;n=this.materials[a].clone(),i=o.materialName,n.name=i;var s=o.materialProperties;for(var c in s)n.hasOwnProperty(c)&&s.hasOwnProperty(c)&&(n[c]=s[c]);this.materials[i]=n}var u=t.materials.serializedMaterials;if(e.isValid(u)&&Object.keys(u).length>0){var l,h=new r.MaterialLoader;for(i in u)l=u[i],e.isValid(l)&&(n=h.parse(l),this.logger.logInfo('De-serialized material with name "'+i+'" will be added.'),this.materials[i]=n)}if(u=t.materials.runtimeMaterials,e.isValid(u)&&Object.keys(u).length>0)for(i in u)n=u[i],this.logger.logInfo('Material with name "'+i+'" will be added.'),this.materials[i]=n},i.prototype.getMaterialsJSON=function(){var t,e={};for(var n in this.materials)t=this.materials[n],e[n]=t.toJSON();return e},i.prototype.getMaterials=function(){return this.materials},i}(),r.LoaderSupport.LoaderBase=function(){var t=r.LoaderSupport.Validator,e=r.LoaderSupport.ConsoleLogger;function n(n,i){this.manager=t.verifyInput(n,r.DefaultLoadingManager),this.logger=t.verifyInput(i,new e),this.modelName="",this.instanceNo=0,this.path="",this.useIndices=!1,this.disregardNormals=!1,this.loaderRootNode=new r.Group,this.builder=new r.LoaderSupport.Builder(this.logger),this._createDefaultMaterials(),this.callbacks=new r.LoaderSupport.Callbacks}return n.prototype._createDefaultMaterials=function(){var t=new r.MeshStandardMaterial({color:14479871});t.name="defaultMaterial";var e=new r.MeshStandardMaterial({color:14479871});e.name="vertexColorMaterial",e.vertexColors=r.VertexColors;var n={};n[t.name]=t,n[e.name]=e,this.builder.updateMaterials({cmd:"materialData",materials:{materialCloneInstructions:null,serializedMaterials:null,runtimeMaterials:n}})},n.prototype._applyPrepData=function(e){t.isValid(e)&&(this.setModelName(e.modelName),this.setStreamMeshesTo(e.streamMeshesTo),this.builder.setMaterials(e.materials),this.setUseIndices(e.useIndices),this.setDisregardNormals(e.disregardNormals),this._setCallbacks(e.getCallbacks()))},n.prototype._setCallbacks=function(e){t.isValid(e.onProgress)&&this.callbacks.setCallbackOnProgress(e.onProgress),t.isValid(e.onMeshAlter)&&this.callbacks.setCallbackOnMeshAlter(e.onMeshAlter),t.isValid(e.onLoad)&&this.callbacks.setCallbackOnLoad(e.onLoad),t.isValid(e.onLoadMaterials)&&this.callbacks.setCallbackOnLoadMaterials(e.onLoadMaterials),this.builder._setCallbacks(this.callbacks)},n.prototype.getLogger=function(){return this.logger},n.prototype.setModelName=function(e){this.modelName=t.verifyInput(e,this.modelName)},n.prototype.setPath=function(e){this.path=t.verifyInput(e,this.path)},n.prototype.setStreamMeshesTo=function(e){this.loaderRootNode=t.verifyInput(e,this.loaderRootNode)},n.prototype.setMaterials=function(t){this.builder.setMaterials(t)},n.prototype.setUseIndices=function(t){this.useIndices=!0===t},n.prototype.setDisregardNormals=function(t){this.disregardNormals=!0===t},n.prototype.onProgress=function(e,n,r){var i=t.isValid(n)?n:"",o={detail:{type:e,modelName:this.modelName,instanceNo:this.instanceNo,text:i,numericalValue:r}};t.isValid(this.callbacks.onProgress)&&this.callbacks.onProgress(o),this.logger.logDebug(i)},n}(),r.LoaderSupport.WorkerRunnerRefImpl=function(){function t(){var t=this;self.addEventListener("message",function(e){t.processMessage(e.data)},!1)}return t.prototype.applyProperties=function(t,e){var n,r,i;for(n in e)r="set"+n.substring(0,1).toLocaleUpperCase()+n.substring(1),i=e[n],"function"==typeof t[r]?t[r](i):t.hasOwnProperty(n)&&(t[n]=i)},t.prototype.processMessage=function(t){var e=t.logger.enabled,n=t.logger.enabled;if("run"===t.cmd){var r={callbackBuilder:function(t){self.postMessage(t)},callbackProgress:function(t){e&&n&&console.debug("WorkerRunner: progress: "+t)}},i=new Parser;"function"==typeof i.setLogConfig&&i.setLogConfig(e,n),this.applyProperties(i,t.params),this.applyProperties(i,t.materials),this.applyProperties(i,r),i.workerScope=self,i.parse(t.data.input,t.data.options),e&&console.log("WorkerRunner: Run complete!"),r.callbackBuilder({cmd:"complete",msg:"WorkerRunner completed run."})}else console.error("WorkerRunner: Received unknown command: "+t.cmd)},t}(),r.LoaderSupport.WorkerSupport=function(){var t="2.0.1",e=r.LoaderSupport.Validator,n=function(){function t(t){this.logger=e.verifyInput(t,new r.LoaderSupport.ConsoleLogger),this._reset()}return t.prototype._reset=function(){this.worker=null,this.runnerImplName=null,this.callbacks={builder:null,onLoad:null},this.terminateRequested=!1,this.queuedMessage=null,this.started=!1},t.prototype.initWorker=function(t,e){this.runnerImplName=e;var n=new Blob([t],{type:"application/javascript"});this.worker=new Worker(window.URL.createObjectURL(n)),this.worker.onmessage=this._receiveWorkerMessage,this.worker.runtimeRef=this,this._postMessage()},t.prototype._receiveWorkerMessage=function(t){var e=t.data;switch(e.cmd){case"meshData":case"materialData":case"imageData":this.runtimeRef.callbacks.builder(e);break;case"complete":this.runtimeRef.queuedMessage=null,this.started=!1,this.runtimeRef.callbacks.onLoad(e.msg),this.runtimeRef.terminateRequested&&(this.runtimeRef.logger.logInfo("WorkerSupport ["+this.runtimeRef.runnerImplName+"]: Run is complete. Terminating application on request!"),this.runtimeRef._terminate());break;case"error":this.runtimeRef.logger.logError("WorkerSupport ["+this.runtimeRef.runnerImplName+"]: Reported error: "+e.msg),this.runtimeRef.queuedMessage=null,this.started=!1,this.runtimeRef.callbacks.onLoad(e.msg),this.runtimeRef.terminateRequested&&(this.runtimeRef.logger.logInfo("WorkerSupport ["+this.runtimeRef.runnerImplName+"]: Run reported error. Terminating application on request!"),this.runtimeRef._terminate());break;default:this.runtimeRef.logger.logError("WorkerSupport ["+this.runtimeRef.runnerImplName+"]: Received unknown command: "+e.cmd)}},t.prototype.setCallbacks=function(t,n){this.callbacks.builder=e.verifyInput(t,this.callbacks.builder),this.callbacks.onLoad=e.verifyInput(n,this.callbacks.onLoad)},t.prototype.run=function(t){if(e.isValid(this.queuedMessage))console.warn("Already processing message. Rejecting new run instruction");else{if(this.queuedMessage=t,this.started=!0,!e.isValid(this.callbacks.builder))throw'Unable to run as no "builder" callback is set.';if(!e.isValid(this.callbacks.onLoad))throw'Unable to run as no "onLoad" callback is set.';"run"!==t.cmd&&(t.cmd="run"),e.isValid(t.logger)?(t.logger.enabled=e.verifyInput(t.logger.enabled,!0),t.logger.debug=e.verifyInput(t.logger.debug,!1)):t.logger={enabled:!0,debug:!1},this._postMessage()}},t.prototype._postMessage=function(){e.isValid(this.queuedMessage)&&e.isValid(this.worker)&&(this.queuedMessage.data.input instanceof ArrayBuffer?this.worker.postMessage(this.queuedMessage,[this.queuedMessage.data.input]):this.worker.postMessage(this.queuedMessage))},t.prototype.setTerminateRequested=function(t){this.terminateRequested=!0===t,this.terminateRequested&&e.isValid(this.worker)&&!e.isValid(this.queuedMessage)&&this.started&&(this.logger.logInfo("Worker is terminated immediately as it is not running!"),this._terminate())},t.prototype._terminate=function(){this.worker.terminate(),this._reset()},t}();function i(i){if(this.logger=e.verifyInput(i,new r.LoaderSupport.ConsoleLogger),this.logger.logInfo("Using THREE.LoaderSupport.WorkerSupport version: "+t),void 0===window.Worker)throw"This browser does not support web workers!";if(void 0===window.Blob)throw"This browser does not support Blob!";if("function"!=typeof window.URL.createObjectURL)throw"This browser does not support Object creation from URL!";this.loaderWorker=new n(this.logger)}i.prototype.validate=function(t,n,i,s){if(!e.isValid(this.loaderWorker.worker)){this.logger.logInfo("WorkerSupport: Building worker code..."),this.logger.logTimeStart("buildWebWorkerCode"),e.isValid(s)?this.logger.logInfo('WorkerSupport: Using "'+s.name+'" as Runncer class for worker.'):(s=r.LoaderSupport.WorkerRunnerRefImpl,this.logger.logInfo('WorkerSupport: Using DEFAULT "THREE.LoaderSupport.WorkerRunnerRefImpl" as Runncer class for worker.'));var c=t(o,a);c+=a(s.name,s.name,s),c+="new "+s.name+"();\n\n";var u=this;if(e.isValid(n)&&n.length>0){var l="",h=function(t,e){if(0===e.length)u.loaderWorker.initWorker(l+c,u.logger,s.name),u.logger.logTimeEnd("buildWebWorkerCode");else{var n=new r.FileLoader;n.setPath(t),n.setResponseType("text"),n.load(e[0],function(n){l+=n,h(t,e)}),e.shift()}};h(i,n)}else this.loaderWorker.initWorker(c,this.logger,s.name),this.logger.logTimeEnd("buildWebWorkerCode")}},i.prototype.setCallbacks=function(t,e){this.loaderWorker.setCallbacks(t,e)},i.prototype.run=function(t){this.loaderWorker.run(t)},i.prototype.setTerminateRequested=function(t){this.loaderWorker.setTerminateRequested(t)};var o=function(t,e){var n,r=t+" = {\n";for(var i in e)"string"==typeof(n=e[i])||n instanceof String?r+="\t"+i+': "'+(n=(n=n.replace("\n","\\n")).replace("\r","\\r"))+'",\n':n instanceof Array?r+="\t"+i+": ["+n+"],\n":Number.isInteger(n)?r+="\t"+i+": "+n+",\n":"function"==typeof n&&(r+="\t"+i+": "+n+",\n");return r+="}\n\n"},a=function(t,e,n){var r,i=t+" = (function () {\n\n";for(var o in i=(i+="\t"+n.prototype.constructor.toString()+"\n\n").replace(n.name,e),n.prototype)"function"==typeof(r=n.prototype[o])&&(i+="\t"+e+".prototype."+o+" = "+r.toString()+";\n\n");return i+="\treturn "+e+";\n",i+="})();\n\n"};return i}(),r.LoaderSupport.WorkerDirector=function(){var t="2.1.0",e=r.LoaderSupport.Validator,n=16,i=8192;function o(o,a){if(this.logger=e.verifyInput(a,new r.LoaderSupport.ConsoleLogger),this.logger.logInfo("Using THREE.LoaderSupport.WorkerDirector version: "+t),this.maxQueueSize=i,this.maxWebWorkers=n,this.crossOrigin=null,!e.isValid(o))throw"Provided invalid classDef: "+o;this.workerDescription={classDef:o,globalCallbacks:{},workerSupports:{}},this.objectsCompleted=0,this.instructionQueue=[],this.instructionQueuePointer=0,this.callbackOnFinishedProcessing=null}return o.prototype.getMaxQueueSize=function(){return this.maxQueueSize},o.prototype.getMaxWebWorkers=function(){return this.maxWebWorkers},o.prototype.setCrossOrigin=function(t){this.crossOrigin=t},o.prototype.prepareWorkers=function(t,o,a){e.isValid(t)&&(this.workerDescription.globalCallbacks=t),this.maxQueueSize=Math.min(o,i),this.maxWebWorkers=Math.min(a,n),this.maxWebWorkers=Math.min(this.maxWebWorkers,this.maxQueueSize),this.objectsCompleted=0,this.instructionQueue=[],this.instructionQueuePointer=0;for(var s=0;s0&&this.instructionQueuePointer0},o.prototype.processQueue=function(){var t,e;for(var n in this.workerDescription.workerSupports)(e=this.workerDescription.workerSupports[n]).inUse||(this.instructionQueuePointer=0;n--)e=[t[n].apply(this,e)];return e[0]}},each:function(t,e,n){if(t)if(i&&t.forEach&&t.forEach===i)t.forEach(e,n);else if(t.length===t.length+0){var r,o=void 0;for(o=0,r=t.length;o1?a.toArray(arguments):arguments[0];return a.each(s,function(e){if(e.litmus(t))return a.each(e.conversions,function(e,n){if(c=e.read(t),!1===u&&!1!==c)return u=c,c.conversionName=n,c.conversion=e,a.BREAK}),a.BREAK}),u},h=void 0,d={hsv_to_rgb:function(t,e,n){var r=Math.floor(t/60)%6,i=t/60-Math.floor(t/60),o=n*(1-e),a=n*(1-i*e),s=n*(1-(1-i)*e),c=[[n,s,o],[a,n,o],[o,n,s],[o,a,n],[s,o,n],[n,o,a]][r];return{r:255*c[0],g:255*c[1],b:255*c[2]}},rgb_to_hsv:function(t,e,n){var r=Math.min(t,e,n),i=Math.max(t,e,n),o=i-r,a=void 0;return 0===i?{h:NaN,s:0,v:0}:(a=t===i?(e-n)/o:e===i?2+(n-t)/o:4+(t-e)/o,(a/=6)<0&&(a+=1),{h:360*a,s:o/i,v:i/255})},rgb_to_hex:function(t,e,n){var r=this.hex_with_component(0,2,t);return r=this.hex_with_component(r,1,e),r=this.hex_with_component(r,0,n)},component_from_hex:function(t,e){return t>>8*e&255},hex_with_component:function(t,e,n){return n<<(h=8*e)|t&~(255<-1?e.length-e.indexOf(".")-1:0}var P=function(t){function e(t,n,r){f(this,e);var i=y(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),o=r||{};return i.__min=o.min,i.__max=o.max,i.__step=o.step,a.isUndefined(i.__step)?0===i.initialValue?i.__impliedStep=1:i.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(i.initialValue))/Math.LN10))/10:i.__impliedStep=i.__step,i.__precision=C(i.__impliedStep),i}return v(e,w),m(e,[{key:"setValue",value:function(t){var n=t;return void 0!==this.__min&&nthis.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),g(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(t){return this.__min=t,this}},{key:"max",value:function(t){return this.__max=t,this}},{key:"step",value:function(t){return this.__step=t,this.__impliedStep=t,this.__precision=C(t),this}}]),e}();var N=function(t){function e(t,n,r){f(this,e);var i=y(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,r));i.__truncationSuspended=!1;var o=i,s=void 0;function c(){o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function u(t){var e=s-t.clientY;o.setValue(o.getValue()+e*o.__impliedStep),s=t.clientY}function l(){S.unbind(window,"mousemove",u),S.unbind(window,"mouseup",l),c()}return i.__input=document.createElement("input"),i.__input.setAttribute("type","text"),S.bind(i.__input,"change",function(){var t=parseFloat(o.__input.value);a.isNaN(t)||o.setValue(t)}),S.bind(i.__input,"blur",function(){c()}),S.bind(i.__input,"mousedown",function(t){S.bind(window,"mousemove",u),S.bind(window,"mouseup",l),s=t.clientY}),S.bind(i.__input,"keydown",function(t){13===t.keyCode&&(o.__truncationSuspended=!0,this.blur(),o.__truncationSuspended=!1,c())}),i.updateDisplay(),i.domElement.appendChild(i.__input),i}return v(e,P),m(e,[{key:"updateDisplay",value:function(){var t,n,r;return this.__input.value=this.__truncationSuspended?this.getValue():(t=this.getValue(),n=this.__precision,r=Math.pow(10,n),Math.round(t*r)/r),g(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e}();function O(t,e,n,r,i){return r+(t-e)/(n-e)*(i-r)}var I=function(t){function e(t,n,r,i,o){f(this,e);var a=y(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,{min:r,max:i,step:o})),s=a;function c(t){t.preventDefault();var e=s.__background.getBoundingClientRect();return s.setValue(O(t.clientX,e.left,e.right,s.__min,s.__max)),!1}function u(){S.unbind(window,"mousemove",c),S.unbind(window,"mouseup",u),s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}function l(t){var e=t.touches[0].clientX,n=s.__background.getBoundingClientRect();s.setValue(O(e,n.left,n.right,s.__min,s.__max))}function h(){S.unbind(window,"touchmove",l),S.unbind(window,"touchend",h),s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}return a.__background=document.createElement("div"),a.__foreground=document.createElement("div"),S.bind(a.__background,"mousedown",function(t){document.activeElement.blur(),S.bind(window,"mousemove",c),S.bind(window,"mouseup",u),c(t)}),S.bind(a.__background,"touchstart",function(t){if(1!==t.touches.length)return;S.bind(window,"touchmove",l),S.bind(window,"touchend",h),l(t)}),S.addClass(a.__background,"slider"),S.addClass(a.__foreground,"slider-fg"),a.updateDisplay(),a.__background.appendChild(a.__foreground),a.domElement.appendChild(a.__background),a}return v(e,P),m(e,[{key:"updateDisplay",value:function(){var t=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*t+"%",g(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e}(),k=function(t){function e(t,n,r){f(this,e);var i=y(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),o=i;return i.__button=document.createElement("div"),i.__button.innerHTML=void 0===r?"Fire":r,S.bind(i.__button,"click",function(t){return t.preventDefault(),o.fire(),!1}),S.addClass(i.__button,"button"),i.domElement.appendChild(i.__button),i}return v(e,w),m(e,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),e}(),U=function(t){function e(t,n){f(this,e);var r=y(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));r.__color=new b(r.getValue()),r.__temp=new b(0);var i=r;r.domElement=document.createElement("div"),S.makeSelectable(r.domElement,!1),r.__selector=document.createElement("div"),r.__selector.className="selector",r.__saturation_field=document.createElement("div"),r.__saturation_field.className="saturation-field",r.__field_knob=document.createElement("div"),r.__field_knob.className="field-knob",r.__field_knob_border="2px solid ",r.__hue_knob=document.createElement("div"),r.__hue_knob.className="hue-knob",r.__hue_field=document.createElement("div"),r.__hue_field.className="hue-field",r.__input=document.createElement("input"),r.__input.type="text",r.__input_textShadow="0 1px 1px ",S.bind(r.__input,"keydown",function(t){13===t.keyCode&&p.call(this)}),S.bind(r.__input,"blur",p),S.bind(r.__selector,"mousedown",function(){S.addClass(this,"drag").bind(window,"mouseup",function(){S.removeClass(i.__selector,"drag")})}),S.bind(r.__selector,"touchstart",function(){S.addClass(this,"drag").bind(window,"touchend",function(){S.removeClass(i.__selector,"drag")})});var o,s=document.createElement("div");function c(t){g(t),S.bind(window,"mousemove",g),S.bind(window,"touchmove",g),S.bind(window,"mouseup",h),S.bind(window,"touchend",h)}function u(t){v(t),S.bind(window,"mousemove",v),S.bind(window,"touchmove",v),S.bind(window,"mouseup",d),S.bind(window,"touchend",d)}function h(){S.unbind(window,"mousemove",g),S.unbind(window,"touchmove",g),S.unbind(window,"mouseup",h),S.unbind(window,"touchend",h),m()}function d(){S.unbind(window,"mousemove",v),S.unbind(window,"touchmove",v),S.unbind(window,"mouseup",d),S.unbind(window,"touchend",d),m()}function p(){var t=l(this.value);!1!==t?(i.__color.__state=t,i.setValue(i.__color.toOriginal())):this.value=i.__color.toString()}function m(){i.__onFinishChange&&i.__onFinishChange.call(i,i.__color.toOriginal())}function g(t){-1===t.type.indexOf("touch")&&t.preventDefault();var e=i.__saturation_field.getBoundingClientRect(),n=t.touches&&t.touches[0]||t,r=n.clientX,o=n.clientY,a=(r-e.left)/(e.right-e.left),s=1-(o-e.top)/(e.bottom-e.top);return s>1?s=1:s<0&&(s=0),a>1?a=1:a<0&&(a=0),i.__color.v=s,i.__color.s=a,i.setValue(i.__color.toOriginal()),!1}function v(t){-1===t.type.indexOf("touch")&&t.preventDefault();var e=i.__hue_field.getBoundingClientRect(),n=1-((t.touches&&t.touches[0]||t).clientY-e.top)/(e.bottom-e.top);return n>1?n=1:n<0&&(n=0),i.__color.h=360*n,i.setValue(i.__color.toOriginal()),!1}return a.extend(r.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),a.extend(r.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:r.__field_knob_border+(r.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),a.extend(r.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),a.extend(r.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),a.extend(s.style,{width:"100%",height:"100%",background:"none"}),D(s,"top","rgba(0,0,0,0)","#000"),a.extend(r.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(o=r.__hue_field).style.background="",o.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",o.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",o.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",o.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",o.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",a.extend(r.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:r.__input_textShadow+"rgba(0,0,0,0.7)"}),S.bind(r.__saturation_field,"mousedown",c),S.bind(r.__saturation_field,"touchstart",c),S.bind(r.__field_knob,"mousedown",c),S.bind(r.__field_knob,"touchstart",c),S.bind(r.__hue_field,"mousedown",u),S.bind(r.__hue_field,"touchstart",u),r.__saturation_field.appendChild(s),r.__selector.appendChild(r.__field_knob),r.__selector.appendChild(r.__saturation_field),r.__selector.appendChild(r.__hue_field),r.__hue_field.appendChild(r.__hue_knob),r.domElement.appendChild(r.__input),r.domElement.appendChild(r.__selector),r.updateDisplay(),r}return v(e,w),m(e,[{key:"updateDisplay",value:function(){var t=l(this.getValue());if(!1!==t){var e=!1;a.each(b.COMPONENTS,function(n){if(!a.isUndefined(t[n])&&!a.isUndefined(this.__color.__state[n])&&t[n]!==this.__color.__state[n])return e=!0,{}},this),e&&a.extend(this.__color.__state,t)}a.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,r=255-n;a.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,D(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),a.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+r+","+r+","+r+",.7)"})}}]),e}(),B=["-moz-","-o-","-webkit-","-ms-",""];function D(t,e,n,r){t.style.background="",a.each(B,function(i){t.style.cssText+="background: "+i+"linear-gradient("+e+", "+n+" 0%, "+r+" 100%); "})}var F=function(t,e){var n=e||document,r=document.createElement("style");r.type="text/css",r.innerHTML=t;var i=n.getElementsByTagName("head")[0];try{i.appendChild(r)}catch(t){}},z=function(t,e){var n=t[e];return a.isArray(arguments[2])||a.isObject(arguments[2])?new L(t,e,arguments[2]):a.isNumber(n)?a.isNumber(arguments[2])&&a.isNumber(arguments[3])?a.isNumber(arguments[4])?new I(t,e,arguments[2],arguments[3],arguments[4]):new I(t,e,arguments[2],arguments[3]):a.isNumber(arguments[4])?new N(t,e,{min:arguments[2],max:arguments[3],step:arguments[4]}):new N(t,e,{min:arguments[2],max:arguments[3]}):a.isString(n)?new R(t,e):a.isFunction(n)?new k(t,e,""):a.isBoolean(n)?new A(t,e):null};var G=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){setTimeout(t,1e3/60)},H=function(){function t(){f(this,t),this.backgroundElement=document.createElement("div"),a.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),S.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),a.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var e=this;S.bind(this.backgroundElement,"click",function(){e.hide()})}return m(t,[{key:"show",value:function(){var t=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),a.defer(function(){t.backgroundElement.style.opacity=1,t.domElement.style.opacity=1,t.domElement.style.webkitTransform="scale(1)"})}},{key:"hide",value:function(){var t=this,e=function e(){t.domElement.style.display="none",t.backgroundElement.style.display="none",S.unbind(t.domElement,"webkitTransitionEnd",e),S.unbind(t.domElement,"transitionend",e),S.unbind(t.domElement,"oTransitionEnd",e)};S.bind(this.domElement,"webkitTransitionEnd",e),S.bind(this.domElement,"transitionend",e),S.bind(this.domElement,"oTransitionEnd",e),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-S.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-S.getHeight(this.domElement)/2+"px"}}]),t}();F(function(t){if(t&&"undefined"!=typeof window){var e=document.createElement("style");return e.setAttribute("type","text/css"),e.innerHTML=t,document.head.appendChild(e),t}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid transparent}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n"));var j="Default",V=function(){try{return"localStorage"in window&&null!==window.localStorage}catch(t){return!1}}(),W=void 0,q=!0,X=void 0,Y=!1,J=[],Z=function t(e){var n=this,r=e||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),S.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],r=a.defaults(r,{closeOnTop:!1,autoPlace:!0,width:t.DEFAULT_WIDTH}),r=a.defaults(r,{resizable:r.autoPlace,hideable:r.autoPlace}),a.isUndefined(r.load)?r.load={preset:j}:r.preset&&(r.load.preset=r.preset),a.isUndefined(r.parent)&&r.hideable&&J.push(this),r.resizable=a.isUndefined(r.parent)&&r.resizable,r.autoPlace&&a.isUndefined(r.scrollable)&&(r.scrollable=!0);var i,o=V&&"true"===localStorage.getItem(nt(this,"isLocal")),s=void 0;if(Object.defineProperties(this,{parent:{get:function(){return r.parent}},scrollable:{get:function(){return r.scrollable}},autoPlace:{get:function(){return r.autoPlace}},closeOnTop:{get:function(){return r.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:r.load.preset},set:function(t){n.parent?n.getRoot().preset=t:r.load.preset=t,function(t){for(var e=0;e1){var r=n.__li.nextElementSibling;return n.remove(),et(t,n.object,n.property,{before:r,factoryArgs:[a.toArray(arguments)]})}if(a.isArray(e)||a.isObject(e)){var i=n.__li.nextElementSibling;return n.remove(),et(t,n.object,n.property,{before:i,factoryArgs:[e]})}},name:function(t){return n.__li.firstElementChild.firstElementChild.innerHTML=t,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof I){var r=new N(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});a.each(["updateDisplay","onChange","onFinishChange","step"],function(t){var e=n[t],i=r[t];n[t]=r[t]=function(){var t=Array.prototype.slice.call(arguments);return i.apply(r,t),e.apply(n,t)}}),S.addClass(e,"has-slider"),n.domElement.insertBefore(r.domElement,n.domElement.firstElementChild)}else if(n instanceof N){var i=function(e){if(a.isNumber(n.__min)&&a.isNumber(n.__max)){var r=n.__li.firstElementChild.firstElementChild.innerHTML,i=n.__gui.__listening.indexOf(n)>-1;n.remove();var o=et(t,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return o.name(r),i&&o.listen(),o}return e};n.min=a.compose(i,n.min),n.max=a.compose(i,n.max)}else n instanceof A?(S.bind(e,"click",function(){S.fakeEvent(n.__checkbox,"click")}),S.bind(n.__checkbox,"click",function(t){t.stopPropagation()})):n instanceof k?(S.bind(e,"click",function(){S.fakeEvent(n.__button,"click")}),S.bind(e,"mouseover",function(){S.addClass(n.__button,"hover")}),S.bind(e,"mouseout",function(){S.removeClass(n.__button,"hover")})):n instanceof U&&(S.addClass(e,"color"),n.updateDisplay=a.compose(function(t){return e.style.borderLeftColor=n.__color.toString(),t},n.updateDisplay),n.updateDisplay());n.setValue=a.compose(function(e){return t.getRoot().__preset_select&&n.isModified()&&$(t.getRoot(),!0),e},n.setValue)}(t,u,i),t.__controllers.push(i),i}function nt(t,e){return document.location.href+"."+e}function rt(t,e,n){var r=document.createElement("option");r.innerHTML=e,r.value=e,t.__preset_select.appendChild(r),n&&(t.__preset_select.selectedIndex=t.__preset_select.length-1)}function it(t,e){e.style.display=t.useLocalStorage?"block":"none"}function ot(t){var e=void 0;function n(n){return n.preventDefault(),t.width+=e-n.clientX,t.onResize(),e=n.clientX,!1}function r(){S.removeClass(t.__closeButton,Z.CLASS_DRAG),S.unbind(window,"mousemove",n),S.unbind(window,"mouseup",r)}function i(i){return i.preventDefault(),e=i.clientX,S.addClass(t.__closeButton,Z.CLASS_DRAG),S.bind(window,"mousemove",n),S.bind(window,"mouseup",r),!1}t.__resize_handle=document.createElement("div"),a.extend(t.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),S.bind(t.__resize_handle,"mousedown",i),S.bind(t.__closeButton,"mousedown",i),t.domElement.insertBefore(t.__resize_handle,t.domElement.firstElementChild)}function at(t,e){t.domElement.style.width=e+"px",t.__save_row&&t.autoPlace&&(t.__save_row.style.width=e+"px"),t.__closeButton&&(t.__closeButton.style.width=e+"px")}function st(t,e){var n={};return a.each(t.__rememberedObjects,function(r,i){var o={},s=t.__rememberedObjectIndecesToControllers[i];a.each(s,function(t,n){o[n]=e?t.initialValue:t.getValue()}),n[i]=o}),n}Z.toggleHide=function(){Y=!Y,a.each(J,function(t){t.domElement.style.display=Y?"none":""})},Z.CLASS_AUTO_PLACE="a",Z.CLASS_AUTO_PLACE_CONTAINER="ac",Z.CLASS_MAIN="main",Z.CLASS_CONTROLLER_ROW="cr",Z.CLASS_TOO_TALL="taller-than-window",Z.CLASS_CLOSED="closed",Z.CLASS_CLOSE_BUTTON="close-button",Z.CLASS_CLOSE_TOP="close-top",Z.CLASS_CLOSE_BOTTOM="close-bottom",Z.CLASS_DRAG="drag",Z.DEFAULT_WIDTH=245,Z.TEXT_CLOSED="Close Controls",Z.TEXT_OPEN="Open Controls",Z._keydownHandler=function(t){"text"===document.activeElement.type||72!==t.which&&72!==t.keyCode||Z.toggleHide()},S.bind(window,"keydown",Z._keydownHandler,!1),a.extend(Z.prototype,{add:function(t,e){return et(this,t,e,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(t,e){return et(this,t,e,{color:!0})},remove:function(t){this.__ul.removeChild(t.__li),this.__controllers.splice(this.__controllers.indexOf(t),1);var e=this;a.defer(function(){e.onResize()})},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&X.removeChild(this.domElement);var t=this;a.each(this.__folders,function(e){t.removeFolder(e)}),S.unbind(window,"keydown",Z._keydownHandler,!1),K(this)},addFolder:function(t){if(void 0!==this.__folders[t])throw new Error('You already have a folder in this GUI by the name "'+t+'"');var e={name:t,parent:this};e.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[t]&&(e.closed=this.load.folders[t].closed,e.load=this.load.folders[t]);var n=new Z(e);this.__folders[t]=n;var r=Q(this,n.domElement);return S.addClass(r,"folder"),n},removeFolder:function(t){this.__ul.removeChild(t.domElement.parentElement),delete this.__folders[t.name],this.load&&this.load.folders&&this.load.folders[t.name]&&delete this.load.folders[t.name],K(t);var e=this;a.each(t.__folders,function(e){t.removeFolder(e)}),a.defer(function(){e.onResize()})},open:function(){this.closed=!1},close:function(){this.closed=!0},onResize:function(){var t=this.getRoot();if(t.scrollable){var e=S.getOffset(t.__ul).top,n=0;a.each(t.__ul.childNodes,function(e){t.autoPlace&&e===t.__save_row||(n+=S.getHeight(e))}),window.innerHeight-e-20GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n\n
\n\n
\n\n'),this.parent)throw new Error("You can only call remember on a top level GUI.");var t=this;a.each(Array.prototype.slice.call(arguments),function(e){0===t.__rememberedObjects.length&&function(t){var e=t.__save_row=document.createElement("li");S.addClass(t.domElement,"has-save"),t.__ul.insertBefore(e,t.__ul.firstChild),S.addClass(e,"save-row");var n=document.createElement("span");n.innerHTML=" ",S.addClass(n,"button gears");var r=document.createElement("span");r.innerHTML="Save",S.addClass(r,"button"),S.addClass(r,"save");var i=document.createElement("span");i.innerHTML="New",S.addClass(i,"button"),S.addClass(i,"save-as");var o=document.createElement("span");o.innerHTML="Revert",S.addClass(o,"button"),S.addClass(o,"revert");var s=t.__preset_select=document.createElement("select");t.load&&t.load.remembered?a.each(t.load.remembered,function(e,n){rt(t,n,n===t.preset)}):rt(t,j,!1);if(S.bind(s,"change",function(){for(var e=0;e0&&(t.preset=this.preset,t.remembered||(t.remembered={}),t.remembered[this.preset]=st(this)),t.folders={},a.each(this.__folders,function(e,n){t.folders[n]=e.getSaveObject()}),t},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=st(this),$(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(t){this.load.remembered||(this.load.remembered={},this.load.remembered[j]=st(this,!0)),this.load.remembered[t]=st(this),this.preset=t,rt(this,t,!0),this.saveToLocalStorageIfPossible()},revert:function(t){a.each(this.__controllers,function(e){this.getRoot().load.remembered?tt(t||this.getRoot(),e):e.setValue(e.initialValue),e.__onFinishChange&&e.__onFinishChange.call(e,e.getValue())},this),a.each(this.__folders,function(t){t.revert(t)}),t||$(this.getRoot(),!1)},listen:function(t){var e=0===this.__listening.length;this.__listening.push(t),e&&function t(e){0!==e.length&&G.call(window,function(){t(e)});a.each(e,function(t){t.updateDisplay()})}(this.__listening)},updateDisplay:function(){a.each(this.__controllers,function(t){t.updateDisplay()}),a.each(this.__folders,function(t){t.updateDisplay()})}});var ct={color:{Color:b,math:d,interpret:l},controllers:{Controller:w,BooleanController:A,OptionController:L,StringController:R,NumberController:P,NumberControllerBox:N,NumberControllerSlider:I,FunctionController:k,ColorController:U},dom:{dom:S},gui:{GUI:Z},GUI:Z};e.default=ct},function(t,e,n){n(4),n(9),e.codec={preset:n(2).preset}},function(t,e,n){n(4),n(9),e.createCodec=n(2).createCodec},function(t,e,n){e.Decoder=o;var r=n(10),i=n(12).DecodeBuffer;function o(t){if(!(this instanceof o))return new o(t);i.call(this,t)}o.prototype=new i,r.mixin(o.prototype),o.prototype.decode=function(t){arguments.length&&this.write(t),this.flush()},o.prototype.push=function(t){this.emit("data",t)},o.prototype.end=function(t){this.decode(t),this.emit("end")}},function(t,e,n){e.Encoder=o;var r=n(10),i=n(18).EncodeBuffer;function o(t){if(!(this instanceof o))return new o(t);i.call(this,t)}o.prototype=new i,r.mixin(o.prototype),o.prototype.encode=function(t){this.write(t),this.emit("data",this.read())},o.prototype.end=function(t){arguments.length&&this.encode(t),this.flush(),this.emit("end")}},function(t,e,n){var r=n(11);function i(t){var e,n=new Array(256);for(e=0;e<=127;e++)n[e]=o(e);for(e=128;e<=143;e++)n[e]=s(e-128,t.map);for(e=144;e<=159;e++)n[e]=s(e-144,t.array);for(e=160;e<=191;e++)n[e]=s(e-160,t.str);for(n[192]=o(null),n[193]=null,n[194]=o(!1),n[195]=o(!0),n[196]=a(t.uint8,t.bin),n[197]=a(t.uint16,t.bin),n[198]=a(t.uint32,t.bin),n[199]=a(t.uint8,t.ext),n[200]=a(t.uint16,t.ext),n[201]=a(t.uint32,t.ext),n[202]=t.float32,n[203]=t.float64,n[204]=t.uint8,n[205]=t.uint16,n[206]=t.uint32,n[207]=t.uint64,n[208]=t.int8,n[209]=t.int16,n[210]=t.int32,n[211]=t.int64,n[212]=s(1,t.ext),n[213]=s(2,t.ext),n[214]=s(4,t.ext),n[215]=s(8,t.ext),n[216]=s(16,t.ext),n[217]=a(t.uint8,t.str),n[218]=a(t.uint16,t.str),n[219]=a(t.uint32,t.str),n[220]=a(t.uint16,t.array),n[221]=a(t.uint32,t.array),n[222]=a(t.uint16,t.map),n[223]=a(t.uint32,t.map),e=224;e<=255;e++)n[e]=o(e-256);return n}function o(t){return function(){return t}}function a(t,e){return function(n){var r=t(n);return e(n,r)}}function s(t,e){return function(n){return e(n,t)}}e.getReadToken=function(t){var e=r.getReadFormat(t);return t&&t.useraw?function(t){var e,n=i(t).slice();for(n[217]=n[196],n[218]=n[197],n[219]=n[198],e=160;e<=191;e++)n[e]=s(e-160,t.bin);return n}(e):i(e)}},function(t,e,n){e.setExtUnpackers=function(t){t.addExtUnpacker(14,[s,u(Error)]),t.addExtUnpacker(1,[s,u(EvalError)]),t.addExtUnpacker(2,[s,u(RangeError)]),t.addExtUnpacker(3,[s,u(ReferenceError)]),t.addExtUnpacker(4,[s,u(SyntaxError)]),t.addExtUnpacker(5,[s,u(TypeError)]),t.addExtUnpacker(6,[s,u(URIError)]),t.addExtUnpacker(10,[s,c]),t.addExtUnpacker(11,[s,l(Boolean)]),t.addExtUnpacker(12,[s,l(String)]),t.addExtUnpacker(13,[s,l(Date)]),t.addExtUnpacker(15,[s,l(Number)]),"undefined"!=typeof Uint8Array&&(t.addExtUnpacker(17,l(Int8Array)),t.addExtUnpacker(18,l(Uint8Array)),t.addExtUnpacker(19,[h,l(Int16Array)]),t.addExtUnpacker(20,[h,l(Uint16Array)]),t.addExtUnpacker(21,[h,l(Int32Array)]),t.addExtUnpacker(22,[h,l(Uint32Array)]),t.addExtUnpacker(23,[h,l(Float32Array)]),"undefined"!=typeof Float64Array&&t.addExtUnpacker(24,[h,l(Float64Array)]),"undefined"!=typeof Uint8ClampedArray&&t.addExtUnpacker(25,l(Uint8ClampedArray)),t.addExtUnpacker(26,h),t.addExtUnpacker(29,[h,l(DataView)]));i.hasBuffer&&t.addExtUnpacker(27,l(o))};var r,i=n(0),o=i.global,a={name:1,message:1,stack:1,columnNumber:1,fileName:1,lineNumber:1};function s(t){return r||(r=n(13).decode),r(t)}function c(t){return RegExp.apply(null,t)}function u(t){return function(e){var n=new t;for(var r in a)n[r]=e[r];return n}}function l(t){return function(e){return new t(e)}}function h(t){return new Uint8Array(t).buffer}},function(t,e,n){var r=n(7),i=n(5),o=i.Uint64BE,a=i.Int64BE,s=n(15).uint8,c=n(0),u=c.global,l=c.hasBuffer&&"TYPED_ARRAY_SUPPORT"in u&&!u.TYPED_ARRAY_SUPPORT,h=c.hasBuffer&&u.prototype||{};function d(){var t=s.slice();return t[196]=p(196),t[197]=f(197),t[198]=m(198),t[199]=p(199),t[200]=f(200),t[201]=m(201),t[202]=g(202,4,h.writeFloatBE||b,!0),t[203]=g(203,8,h.writeDoubleBE||_,!0),t[204]=p(204),t[205]=f(205),t[206]=m(206),t[207]=g(207,8,v),t[208]=p(208),t[209]=f(209),t[210]=m(210),t[211]=g(211,8,y),t[217]=p(217),t[218]=f(218),t[219]=m(219),t[220]=f(220),t[221]=m(221),t[222]=f(222),t[223]=m(223),t}function p(t){return function(e,n){var r=e.reserve(2),i=e.buffer;i[r++]=t,i[r]=n}}function f(t){return function(e,n){var r=e.reserve(3),i=e.buffer;i[r++]=t,i[r++]=n>>>8,i[r]=n}}function m(t){return function(e,n){var r=e.reserve(5),i=e.buffer;i[r++]=t,i[r++]=n>>>24,i[r++]=n>>>16,i[r++]=n>>>8,i[r]=n}}function g(t,e,n,r){return function(i,o){var a=i.reserve(e+1);i.buffer[a++]=t,n.call(i.buffer,o,a,r)}}function v(t,e){new o(this,e,t)}function y(t,e){new a(this,e,t)}function b(t,e){r.write(this,t,e,!1,23,4)}function _(t,e){r.write(this,t,e,!1,52,8)}e.getWriteToken=function(t){return t&&t.uint8array?((e=d())[202]=g(202,4,b),e[203]=g(203,8,_),e):l||c.hasBuffer&&t&&t.safe?function(){var t=s.slice();return t[196]=g(196,1,u.prototype.writeUInt8),t[197]=g(197,2,u.prototype.writeUInt16BE),t[198]=g(198,4,u.prototype.writeUInt32BE),t[199]=g(199,1,u.prototype.writeUInt8),t[200]=g(200,2,u.prototype.writeUInt16BE),t[201]=g(201,4,u.prototype.writeUInt32BE),t[202]=g(202,4,u.prototype.writeFloatBE),t[203]=g(203,8,u.prototype.writeDoubleBE),t[204]=g(204,1,u.prototype.writeUInt8),t[205]=g(205,2,u.prototype.writeUInt16BE),t[206]=g(206,4,u.prototype.writeUInt32BE),t[207]=g(207,8,v),t[208]=g(208,1,u.prototype.writeInt8),t[209]=g(209,2,u.prototype.writeInt16BE),t[210]=g(210,4,u.prototype.writeInt32BE),t[211]=g(211,8,y),t[217]=g(217,1,u.prototype.writeUInt8),t[218]=g(218,2,u.prototype.writeUInt16BE),t[219]=g(219,4,u.prototype.writeUInt32BE),t[220]=g(220,2,u.prototype.writeUInt16BE),t[221]=g(221,4,u.prototype.writeUInt32BE),t[222]=g(222,2,u.prototype.writeUInt16BE),t[223]=g(223,4,u.prototype.writeUInt32BE),t}():d();var e}},function(t,e,n){var r=n(3),i=n(5),o=i.Uint64BE,a=i.Int64BE,s=n(0),c=n(6),u=n(37),l=n(15).uint8,h=n(8).ExtBuffer,d="undefined"!=typeof Uint8Array,p="undefined"!=typeof Map,f=[];f[1]=212,f[2]=213,f[4]=214,f[8]=215,f[16]=216,e.getWriteType=function(t){var e=u.getWriteToken(t),n=t&&t.useraw,i=d&&t&&t.binarraybuffer,m=i?s.isArrayBuffer:s.isBuffer,g=i?function(t,e){_(t,new Uint8Array(e))}:_,v=p&&t&&t.usemap?function(t,n){if(!(n instanceof Map))return x(t,n);var r=n.size;e[r<16?128+r:r<=65535?222:223](t,r);var i=t.codec.encode;n.forEach(function(e,n,r){i(t,n),i(t,e)})}:x;return{boolean:function(t,n){e[n?195:194](t,n)},function:b,number:function(t,n){var r,i=0|n;if(n!==i)return void e[r=203](t,n);r=-32<=i&&i<=127?255&i:0<=i?i<=255?204:i<=65535?205:206:-128<=i?208:-32768<=i?209:210;e[r](t,i)},object:n?function(t,n){if(m(n))return function(t,n){var r=n.length;e[r<32?160+r:r<=65535?218:219](t,r),t.send(n)}(t,n);y(t,n)}:y,string:function(t){return function(n,r){var i=r.length,o=5+3*i;n.offset=n.reserve(o);var a=n.buffer,s=t(i),u=n.offset+s;i=c.write.call(a,r,u);var l=t(i);if(s!==l){var h=u+l-s,d=u+i;c.copy.call(a,a,h,u,d)}e[1===l?160+i:l<=3?215+l:219](n,i),n.offset+=i}}(n?function(t){return t<32?1:t<=65535?3:5}:function(t){return t<32?1:t<=255?2:t<=65535?3:5}),symbol:b,undefined:b};function y(t,n){if(null===n)return b(t,n);if(m(n))return g(t,n);if(r(n))return function(t,n){var r=n.length;e[r<16?144+r:r<=65535?220:221](t,r);for(var i=t.codec.encode,o=0;o=0;i--)t[i+e]=this[i+n];else for(i=0;i=65536?(o-=65536,i+=String.fromCharCode(55296+(o>>>10),56320+(1023&o))):i+=String.fromCharCode(o));return i},e.write=function(t,e){var n=e||(e|=0),r=t.length,i=0,o=0;for(;o>>6,this[n++]=128|63&i):i<55296||i>57343?(this[n++]=224|i>>>12,this[n++]=128|i>>>6&63,this[n++]=128|63&i):(i=65536+(i-55296<<10|t.charCodeAt(o++)-56320),this[n++]=240|i>>>18,this[n++]=128|i>>>12&63,this[n++]=128|i>>>6&63,this[n++]=128|63&i);return n-e}},function(t,e,n){var r=n(0);function i(t){return new Uint8Array(t)}(e=t.exports=r.hasArrayBuffer?i(0):[]).alloc=i,e.concat=r.concat,e.from=function(t){if(r.isView(t)){var n=t.byteOffset,i=t.byteLength;(t=t.buffer).byteLength!==i&&(t.slice?t=t.slice(n,n+i):(t=new Uint8Array(t)).byteLength!==i&&(t=Array.prototype.slice.call(t,n,n+i)))}else{if("string"==typeof t)return r.from.call(e,t);if("number"==typeof t)throw new TypeError('"value" argument must not be a number')}return new Uint8Array(t)}},function(t,e,n){var r=n(0),i=r.global;function o(t){return new i(t)}(e=t.exports=r.hasBuffer?o(0):[]).alloc=r.hasBuffer&&i.alloc||o,e.concat=r.concat,e.from=function(t){if(!r.isBuffer(t)&&r.isView(t))t=r.Uint8Array.from(t);else if(r.isArrayBuffer(t))t=new Uint8Array(t);else{if("string"==typeof t)return r.from.call(e,t);if("number"==typeof t)throw new TypeError('"value" argument must not be a number')}return i.from&&1!==i.from.length?i.from(t):new i(t)}},function(t,e,n){var r=n(0);function i(t){return new Array(t)}(e=t.exports=i(0)).alloc=i,e.concat=r.concat,e.from=function(t){if(!r.isBuffer(t)&&r.isView(t))t=r.Uint8Array.from(t);else if(r.isArrayBuffer(t))t=new Uint8Array(t);else{if("string"==typeof t)return r.from.call(e,t);if("number"==typeof t)throw new TypeError('"value" argument must not be a number')}return Array.prototype.slice.call(t)}},function(t,e,n){"use strict";e.byteLength=function(t){return 3*t.length/4-u(t)},e.toByteArray=function(t){var e,n,r,a,s,c=t.length;a=u(t),s=new o(3*c/4-a),n=a>0?c-4:c;var l=0;for(e=0;e>16&255,s[l++]=r>>8&255,s[l++]=255&r;2===a?(r=i[t.charCodeAt(e)]<<2|i[t.charCodeAt(e+1)]>>4,s[l++]=255&r):1===a&&(r=i[t.charCodeAt(e)]<<10|i[t.charCodeAt(e+1)]<<4|i[t.charCodeAt(e+2)]>>2,s[l++]=r>>8&255,s[l++]=255&r);return s},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o="",a=[],s=0,c=n-i;sc?c:s+16383));1===i?(e=t[n-1],o+=r[e>>2],o+=r[e<<4&63],o+="=="):2===i&&(e=(t[n-2]<<8)+t[n-1],o+=r[e>>10],o+=r[e>>4&63],o+=r[e<<2&63],o+="=");return a.push(o),a.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,c=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function l(t,e,n){for(var i,o,a=[],s=e;s>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e,n){(function(e){function n(t){return t&&t.isBuffer&&t}t.exports=n(void 0!==e&&e)||n(this.Buffer)||n("undefined"!=typeof window&&window.Buffer)||this.Buffer}).call(this,n(17).Buffer)},function(t,e,n){e.encode=n(19).encode,e.decode=n(13).decode,e.Encoder=n(34).Encoder,e.Decoder=n(33).Decoder,e.createCodec=n(32).createCodec,e.codec=n(31).codec},function(module,exports,__webpack_require__){var THREE=__webpack_require__(1),msgpack=__webpack_require__(46),dat=__webpack_require__(30).default;__webpack_require__(29),__webpack_require__(28),__webpack_require__(27),__webpack_require__(26),__webpack_require__(25),__webpack_require__(24);class SceneNode{constructor(t,e,n){this.object=t,this.folder=e,this.children={},this.controllers=[],this.on_update=n,this.create_controls();for(let t of this.object.children)this.add_child(t)}add_child(t){let e=this.folder.addFolder(t.name),n=new SceneNode(t,e,this.on_update);return this.children[t.name]=n,n}create_child(t){let e=new THREE.Group;return e.name=t,this.object.add(e),this.add_child(e)}find(t){if(0==t.length)return this;{let e=t[0],n=this.children[e];return void 0===n&&(n=this.create_child(e)),n.find(t.slice(1))}}create_controls(){for(let t of this.controllers)this.folder.remove(t);if(void 0!==this.vis_controller&&this.folder.domElement.removeChild(this.vis_controller.domElement),this.vis_controller=new dat.controllers.BooleanController(this.object,"visible"),this.vis_controller.onChange(()=>this.on_update()),this.folder.domElement.prepend(this.vis_controller.domElement),this.vis_controller.domElement.style.height="0",this.vis_controller.domElement.style.float="right",this.vis_controller.domElement.classList.add("meshcat-visibility-checkbox"),this.vis_controller.domElement.children[0].addEventListener("change",t=>{t.target.checked?this.folder.domElement.classList.remove("meshcat-hidden-scene-element"):this.folder.domElement.classList.add("meshcat-hidden-scene-element")}),this.object.isLight){let t=this.folder.add(this.object,"intensity").min(0).step(.01);if(t.onChange(()=>this.on_update()),this.controllers.push(t),void 0!==this.object.castShadow){let t=this.folder.add(this.object,"castShadow");t.onChange(()=>this.on_update()),this.controllers.push(t)}}if(this.object.isCamera){let t=this.folder.add(this.object,"zoom").min(0).step(.1);t.onChange(()=>{this.on_update()}),this.controllers.push(t)}}set_property(t,e){"position"===t?this.object.position.set(e[0],e[1],e[2]):"quaternion"===t?this.object.quaternion.set(e[0],e[1],e[2],e[3]):"scale"===t?this.object.scale.set(e[0],e[1],e[2]):this.object[t]=e,this.vis_controller.updateDisplay(),this.controllers.forEach(t=>t.updateDisplay())}set_transform(t){let e=new THREE.Matrix4;e.fromArray(t),e.decompose(this.object.position,this.object.quaternion,this.object.scale)}set_object(t){let e=this.object.parent;this.dispose_recursive(),this.object.parent.remove(this.object),this.object=t,e.add(t),this.create_controls()}dispose_recursive(){for(let t of Object.keys(this.children))this.children[t].dispose_recursive();dispose(this.object)}delete(t){if(0==t.length)console.error("Can't delete an empty path");else{let e=this.find(t.slice(0,t.length-1)),n=t[t.length-1],r=e.children[n];void 0!==r&&(r.dispose_recursive(),e.object.remove(r.object),remove_folders(r.folder),e.folder.removeFolder(r.folder),delete e.children[n])}}}function remove_folders(t){for(let e of Object.keys(t.__folders)){let n=t.__folders[e];remove_folders(n),dat.dom.dom.unbind(window,"resize",n.__resizeHandler),t.removeFolder(n)}}function dispose(t){t&&(t.geometry&&t.geometry.dispose(),t.material&&(t.material.map&&t.material.map.dispose(),t.material.dispose()))}function create_default_scene(){var t=new THREE.Scene;return t.name="Scene",t.rotateX(-Math.PI/2),t}function handle_special_geometry(t){if("_meshfile"!=t.type)return t;if("obj"==t.format){let e=(new THREE.OBJLoader2).parse(t.data+"\n"),n=e.children[0].geometry;n.uuid=t.uuid;let r=n.toJSON();for(let t of e.children)dispose(t);return r}if("dae"==t.format){let e=(new THREE.ColladaLoader).parse(t.data).scene.children[0].geometry;return e.uuid=t.uuid,e.toJSON()}if("stl"==t.format){let e=(new THREE.STLLoader).parse(t.data.buffer);return e.uuid=t.uuid,e.toJSON()}console.error("Unsupported mesh type:",t)}function download_data_uri(t,e){let n=document.createElement("a");n.download=t,n.href=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function download_file(t,e,n){n=n||"text/plain";let r=new Blob([e],{type:n}),i=document.createElement("a");document.body.appendChild(i),i.download=t,i.href=window.URL.createObjectURL(r),i.onclick=function(t){let e=this;setTimeout(function(){window.URL.revokeObjectURL(e.href)},1500)},i.click(),i.remove()}class Animator{constructor(t){this.viewer=t,this.folder=this.viewer.gui.addFolder("Animations"),this.mixer=new THREE.AnimationMixer,this.loader=new THREE.ObjectLoader,this.clock=new THREE.Clock,this.actions=[],this.playing=!1,this.setup_capturer("png")}setup_capturer(t){this.capturer=new CCapture({format:t,name:"meshcat_"+String(Date.now())}),this.capturer.format=t}play(){this.clock.start();for(let t of this.actions)t.play();this.playing=!0}record(){this.reset(),this.play(),this.recording=!0,this.capturer.start()}pause(){this.clock.stop(),this.playing=!1,this.recording&&(this.stop_capture(),this.save_capture())}stop_capture(){this.recording=!1,this.capturer.stop(),this.viewer.animate()}save_capture(){this.capturer.save(),"png"===this.capturer.format?alert("To convert the still frames into a video, extract the `.tar` file and run: \nffmpeg -r 60 -i %07d.png \\\n\t -vcodec libx264 \\\n\t -preset slow \\\n\t -crf 18 \\\n\t output.mp4"):"jpg"===this.capturer.format&&alert("To convert the still frames into a video, extract the `.tar` file and run: \nffmpeg -r 60 -i %07d.jpg \\\n\t -vcodec libx264 \\\n\t -preset slow \\\n\t -crf 18 \\\n\t output.mp4")}reset(){for(let t of this.actions)t.reset();this.mixer.update(0),this.setup_capturer(this.capturer.format),this.viewer.set_dirty()}clear(){remove_folders(this.folder),this.mixer.stopAllAction(),this.actions=[],this.mixer=new THREE.AnimationMixer}load(t,e){this.clear(),this.folder.open();let n=this.folder.addFolder("default");n.open(),n.add(this,"play"),n.add(this,"pause"),n.add(this,"reset"),n.add(this.mixer,"timeScale").step(.01).min(0);let r=n.addFolder("Recording");r.add(this,"record"),r.add({format:"png"},"format",["png","jpg"]).onChange(t=>{this.setup_capturer(t)}),void 0===e.play&&(e.play=!0),void 0===e.loopMode&&(e.loopMode=THREE.LoopRepeat),void 0===e.repetitions&&(e.repetitions=1),void 0===e.clampWhenFinished&&(e.clampWhenFinished=!0);for(let n of t){let t=this.viewer.scene_tree.find(n.path).object,r=this.loader.parseAnimations([n.clip])[0],i=this.mixer.clipAction(r,t);i.clampWhenFinished=e.clampWhenFinished,i.setLoop(e.loopMode,e.repetitions),this.actions.push(i)}this.reset(),e.play&&this.play()}update(){if(this.playing&&(this.mixer.update(this.clock.getDelta()),this.viewer.set_dirty(),this.actions.every(t=>t.paused))){this.pause();for(let t of this.actions)t.reset()}}after_render(){this.recording&&this.capturer.capture(this.viewer.renderer.domElement)}}function gradient_texture(t,e){let n=[e,t];var r=new Uint8Array(6);for(let t=0;t<2;t++){let e=n[t];for(let n=0;n<1;n++){let i=3*(1*t+n);for(let t=0;t<3;t++)r[i+t]=e[t]}}var i=new THREE.DataTexture(r,1,2,THREE.RGBFormat);return i.magFilter=THREE.LinearFilter,i.encoding=THREE.LinearEncoding,i.matrixAutoUpdate=!1,i.matrix.set(.5,0,.25,0,.5,.25,0,0,1),i.needsUpdate=!0,i}class Viewer{constructor(t,e){this.dom_element=t,this.renderer=new THREE.WebGLRenderer({antialias:!0,alpha:!0}),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=THREE.PCFSoftShadowMap,this.dom_element.appendChild(this.renderer.domElement),this.scene=create_default_scene(),this.show_background(),this.create_scene_tree(),this.add_default_scene_elements(),this.set_dirty(),this.create_camera(),window.onload=(t=>this.set_3d_pane_size()),window.addEventListener("resize",t=>this.set_3d_pane_size(),!1),requestAnimationFrame(()=>this.set_3d_pane_size()),(e||void 0===e)&&this.animate()}hide_background(){this.scene.background=null,this.set_dirty()}show_background(){this.scene.background=gradient_texture([135,206,250],[25,25,112]),this.set_dirty()}set_dirty(){this.needs_render=!0}create_camera(){let t=new THREE.Matrix4;t.makeRotationX(Math.PI/2),this.set_transform(["Cameras","default","rotated"],t.toArray());let e=new THREE.PerspectiveCamera(75,1,.01,100);this.set_camera(e),this.set_object(["Cameras","default","rotated"],e),e.position.set(3,1,0)}create_default_spot_light(){var t=new THREE.SpotLight(16777215,.8);return t.position.set(1.5,1.5,2),t.castShadow=!1,t.shadow.mapSize.width=1024,t.shadow.mapSize.height=1024,t.shadow.camera.near=.5,t.shadow.camera.far=50,t}add_default_scene_elements(){var t=this.create_default_spot_light();this.set_object(["Lights","SpotLight"],t),this.set_property(["Lights","SpotLight"],"visible",!1);var e=new THREE.DirectionalLight(16777215,.7);e.position.set(1.5,1.5,2),this.set_object(["Lights","DirectionalLight"],e);var n=new THREE.AmbientLight(16777215,.3);this.set_object(["Lights","AmbientLight"],n);var r=new THREE.DirectionalLight(16777215,.4);r.position.set(-10,-10,0),this.set_object(["Lights","FillLight"],r);var i=new THREE.GridHelper(20,40);i.rotateX(Math.PI/2),this.set_object(["Grid"],i);var o=new THREE.AxesHelper(.5);this.set_object(["Axes"],o)}create_scene_tree(){this.gui&&this.gui.destroy(),this.gui=new dat.GUI({autoPlace:!1}),this.dom_element.appendChild(this.gui.domElement),this.gui.domElement.style.position="absolute",this.gui.domElement.style.right=0,this.gui.domElement.style.top=0;let t=this.gui.addFolder("Scene");t.open(),this.scene_tree=new SceneNode(this.scene,t,()=>this.set_dirty());let e=this.gui.addFolder("Save / Load / Capture");e.add(this,"save_scene"),e.add(this,"load_scene"),e.add(this,"save_image");let n=this.gui.addFolder("Background");n.add(this,"hide_background"),n.add(this,"show_background"),this.animator=new Animator(this),this.gui.close()}set_3d_pane_size(t,e){void 0===t&&(t=this.dom_element.offsetWidth),void 0===e&&(e=window.innerHeight),this.camera.aspect=t/e,this.camera.updateProjectionMatrix(),this.renderer.setSize(t,e),this.set_dirty()}render(){this.controls.update(),this.camera.updateProjectionMatrix(),this.renderer.render(this.scene,this.camera),this.animator.after_render(),this.needs_render=!1}animate(){requestAnimationFrame(()=>this.animate()),this.animator.update(),this.needs_render&&this.render()}capture_image(){return this.render(),this.renderer.domElement.toDataURL()}save_image(){download_data_uri("meshcat.png",this.capture_image())}set_camera(t){this.camera=t,this.controls=new THREE.OrbitControls(t,this.dom_element),this.controls.enableKeys=!1,this.controls.addEventListener("start",()=>{this.set_dirty()}),this.controls.addEventListener("change",()=>{this.set_dirty()})}set_camera_from_json(t){(new THREE.ObjectLoader).parse(t,t=>{console.log(t),this.set_camera(t)})}set_transform(t,e){this.scene_tree.find(t).set_transform(e)}set_object(t,e){this.scene_tree.find(t.concat([""])).set_object(e)}set_object_from_json(t,e){e.geometries=e.geometries.map(handle_special_geometry),(new THREE.ObjectLoader).parse(e,e=>{"BufferGeometry"==e.geometry.type&&e.geometry.computeVertexNormals(),e.castShadow=!0,e.receiveShadow=!0,this.set_object(t,e),this.set_dirty()})}delete_path(t){0==t.length?console.error("Deleting the entire scene is not implemented"):this.scene_tree.delete(t)}set_property(t,e,n){this.scene_tree.find(t).set_property(e,n)}set_animation(t,e){e=e||{},this.animator.load(t,e)}set_control(name,callback,value,min,max,step){let handler={};if(void 0!==value){handler[name]=value;let controller=this.gui.add(handler,name,min,max,step);controller.onChange(eval(callback))}else handler[name]=eval(callback),this.gui.add(handler,name)}handle_command(t){if("set_transform"==t.type){let e=split_path(t.path);this.set_transform(e,t.matrix)}else if("delete"==t.type){let e=split_path(t.path);this.delete_path(e)}else if("set_object"==t.type){let e=split_path(t.path);this.set_object_from_json(e,t.object)}else if("set_property"==t.type){let e=split_path(t.path);this.set_property(e,t.property,t.value)}else"set_animation"==t.type?(t.animations.forEach(t=>{t.path=split_path(t.path)}),this.set_animation(t.animations,t.options)):"set_control"==t.type&&this.set_control(t.name,t.callback,t.value,t.min,t.max,t.step);this.set_dirty()}handle_command_message(t){let e=msgpack.decode(new Uint8Array(t.data));this.handle_command(e)}connect(t){void 0===t&&(t=`ws://${location.host}`),console.log(t);let e=new WebSocket(t);e.binaryType="arraybuffer",e.onmessage=(t=>this.handle_command_message(t)),e.onclose=function(t){}}save_scene(){download_file("scene.json",JSON.stringify(this.scene.toJSON()))}load_scene_from_json(t){let e=new THREE.ObjectLoader;this.scene_tree.dispose_recursive(),this.scene=e.parse(t),this.show_background(),this.create_scene_tree();let n=this.scene_tree.find(["Cameras","default","rotated",""]);n.object.isCamera?this.set_camera(n.object):this.create_camera()}handle_load_file(t){let e=t.files[0];if(!e)return;let n=new FileReader,r=this;n.onload=function(t){let e=this.result,n=JSON.parse(e);r.load_scene_from_json(n)},n.readAsText(e)}load_scene(){let t=document.createElement("input");t.type="file",document.body.appendChild(t);let e=this;t.addEventListener("change",function(){console.log(this,e),e.handle_load_file(this)},!1),t.click(),t.remove()}}function split_path(t){return t.split("/").filter(t=>t.length>0)}let style=document.createElement("style");style.appendChild(document.createTextNode("")),document.head.appendChild(style),style.sheet.insertRule("\n .meshcat-visibility-checkbox > input {\n float: right;\n }"),style.sheet.insertRule("\n .meshcat-hidden-scene-element li .meshcat-visibility-checkbox {\n opacity: 0.25;\n pointer-events: none;\n }"),style.sheet.insertRule("\n .meshcat-visibility-checkbox > input[type=checkbox] {\n height: 16px;\n width: 16px;\n display:inline-block;\n padding: 0 0 0 0px;\n }"),module.exports={Viewer:Viewer,THREE:THREE}}])}); \ No newline at end of file +function(){if("performance"in window==0&&(window.performance={}),Date.now=Date.now||function(){return(new Date).getTime()},"now"in window.performance==0){var t=Date.now();performance.timing&&performance.timing.navigationStart&&(t=performance.timing.navigationStart),window.performance.now=function(){return Date.now()-t}}}();var v=window.Date.now();function y(t){var e={};this.settings=t,this.on=function(t,n){e[t]=n},this.emit=function(t){var n=e[t];n&&n.apply(null,Array.prototype.slice.call(arguments,1))},this.filename=t.name||function(){function t(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()}(),this.extension="",this.mimeType=""}function b(t){y.call(this,t),this.extension=".tar",this.mimeType="application/x-tar",this.fileExtension="",this.tape=null,this.count=0}function _(t){b.call(this,t),this.type="image/png",this.fileExtension=".png"}function x(t){b.call(this,t),this.type="image/jpeg",this.fileExtension=".jpg",this.quality=t.quality/100||.8}function w(t){"image/webp"!==document.createElement("canvas").toDataURL("image/webp").substr(5,10)&&console.log("WebP not supported - try another export format"),y.call(this,t),this.quality=t.quality/100||.8,this.extension=".webm",this.mimeType="video/webm",this.baseFilename=this.filename,this.frames=[],this.part=1,this.videoWriter=new WebMWriter({quality:this.quality,fileWriter:null,fd:null,frameRate:t.framerate})}function E(t){y.call(this,t),t.quality=t.quality/100||.8,this.encoder=new FFMpegServer.Video(t),this.encoder.on("process",function(){this.emit("process")}.bind(this)),this.encoder.on("finished",function(t,e){var n=this.callback;n&&(this.callback=void 0,n(t,e))}.bind(this)),this.encoder.on("progress",function(t){this.settings.onProgress&&this.settings.onProgress(t)}.bind(this)),this.encoder.on("error",function(t){alert(JSON.stringify(t,null,2))}.bind(this))}function M(t){y.call(this,t),this.framerate=this.settings.framerate,this.type="video/webm",this.extension=".webm",this.stream=null,this.mediaRecorder=null,this.chunks=[]}function T(t){y.call(this,t),t.quality=31-(30*t.quality/100||10),t.workers=t.workers||4,this.extension=".gif",this.mimeType="image/gif",this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),this.sizeSet=!1,this.encoder=new s({workers:t.workers,quality:t.quality,workerScript:t.workersPath+"gif.worker.js"}),this.encoder.on("progress",function(t){this.settings.onProgress&&this.settings.onProgress(t)}.bind(this)),this.encoder.on("finished",function(t){var e=this.callback;e&&(this.callback=void 0,e(t))}.bind(this))}function S(t){var e,n,r,i,o,s,c,u=t||{},l=(new Date,[]),h=[],d=0,p=0,f=[],m=!1,g={};u.framerate=u.framerate||60,u.motionBlurFrames=2*(u.motionBlurFrames||1),e=u.verbose||!1,u.display,u.step=1e3/u.framerate,u.timeLimit=u.timeLimit||0,u.frameLimit=u.frameLimit||0,u.startTime=u.startTime||0;var y=document.createElement("div");y.style.position="absolute",y.style.left=y.style.top=0,y.style.backgroundColor="black",y.style.fontFamily="monospace",y.style.fontSize="11px",y.style.padding="5px",y.style.color="red",y.style.zIndex=1e5,u.display&&document.body.appendChild(y);var b,S,A=document.createElement("canvas"),L=A.getContext("2d");W("Step is set to "+u.step+"ms");var R={gif:T,webm:w,ffmpegserver:E,png:_,jpg:x,"webm-mediarecorder":M},C=R[u.format];if(!C)throw"Error: Incorrect or missing format: Valid formats are "+Object.keys(R).join(", ");if((c=new C(u)).step=s,c.on("process",j),c.on("progress",function(t){!function(t){var e=g[t];e&&e.apply(null,Array.prototype.slice.call(arguments,1))}("progress",t)}),"performance"in window==0&&(window.performance={}),Date.now=Date.now||function(){return(new Date).getTime()},"now"in window.performance==0){var P=Date.now();performance.timing&&performance.timing.navigationStart&&(P=performance.timing.navigationStart),window.performance.now=function(){return Date.now()-P}}var N=window.setTimeout,O=window.setInterval,I=window.clearInterval,k=window.clearTimeout,U=window.requestAnimationFrame,B=window.Date.now,D=window.performance.now,F=window.Date.prototype.getTime,z=[];function G(){m=!1,c.stop(),W("Capturer stop"),window.setTimeout=N,window.setInterval=O,window.clearInterval=I,window.clearTimeout=k,window.requestAnimationFrame=U,window.Date.prototype.getTime=F,window.Date.now=B,window.performance.now=D}function H(t,e){N(t,0,e)}function s(){H(j)}function j(){var t=1e3/u.framerate,e=(d+p/u.motionBlurFrames)*t;n=r+e,i=o+e,z.forEach(function(t){t._hookedTime=e/1e3}),function(){var t=d/u.framerate;(u.frameLimit&&d>=u.frameLimit||u.timeLimit&&t>=u.timeLimit)&&(G(),V());var e=new Date(null);e.setSeconds(t),u.motionBlurFrames>2?y.textContent="CCapture "+u.format+" | "+d+" frames ("+p+" inter) | "+e.toISOString().substr(11,8):y.textContent="CCapture "+u.format+" | "+d+" frames | "+e.toISOString().substr(11,8)}(),W("Frame: "+d+" "+p);for(var a=0;a=l[a].triggerTime&&(H(l[a].callback),l.splice(a,1));for(a=0;a=h[a].triggerTime&&(H(h[a].callback),h[a].triggerTime+=h[a].time);f.forEach(function(t){H(t,n-v)}),f=[]}function V(t){t||(t=function(t){return a(t,c.filename+c.extension,c.mimeType),!1}),c.save(t)}function W(t){e&&console.log(t)}return{start:function(){!function(){function t(){return this._hooked||(this._hooked=!0,this._hookedTime=this.currentTime||0,this.pause(),z.push(this)),this._hookedTime+u.startTime}W("Capturer start"),r=window.Date.now(),n=r+u.startTime,o=window.performance.now(),i=o+u.startTime,window.Date.prototype.getTime=function(){return n},window.Date.now=function(){return n},window.setTimeout=function(t,e){var r={callback:t,time:e,triggerTime:n+e};return l.push(r),W("Timeout set to "+r.time),r},window.clearTimeout=function(t){for(var e=0;e2?(function(t){A.width===t.width&&A.height===t.height||(A.width=t.width,A.height=t.height,b=new Uint16Array(A.height*A.width*4),L.fillStyle="#0",L.fillRect(0,0,A.width,A.height))}(t),function(t){L.drawImage(t,0,0),S=L.getImageData(0,0,A.width,A.height);for(var e=0;e=.5*u.motionBlurFrames?function(){for(var t=S.data,e=0;e0&&this.frames.length/this.settings.framerate>=this.settings.autoSaveTime?this.save(function(t){this.filename=this.baseFilename+"-part-"+g(this.part),a(t,this.filename+this.extension,this.mimeType),this.dispose(),this.part++,this.filename=this.baseFilename+"-part-"+g(this.part),this.step()}.bind(this)):this.step()},w.prototype.save=function(t){this.videoWriter.complete().then(t)},w.prototype.dispose=function(t){this.frames=[]},E.prototype=Object.create(y.prototype),E.prototype.start=function(){this.encoder.start(this.settings)},E.prototype.add=function(t){this.encoder.add(t)},E.prototype.save=function(t){this.callback=t,this.encoder.end()},E.prototype.safeToProceed=function(){return this.encoder.safeToProceed()},M.prototype=Object.create(y.prototype),M.prototype.add=function(t){this.stream||(this.stream=t.captureStream(this.framerate),this.mediaRecorder=new MediaRecorder(this.stream),this.mediaRecorder.start(),this.mediaRecorder.ondataavailable=function(t){this.chunks.push(t.data)}.bind(this)),this.step()},M.prototype.save=function(t){this.mediaRecorder.onstop=function(e){var n=new Blob(this.chunks,{type:"video/webm"});this.chunks=[],t(n)}.bind(this),this.mediaRecorder.stop()},T.prototype=Object.create(y.prototype),T.prototype.add=function(t){this.sizeSet||(this.encoder.setOption("width",t.width),this.encoder.setOption("height",t.height),this.sizeSet=!0),this.canvas.width=t.width,this.canvas.height=t.height,this.ctx.drawImage(t,0,0),this.encoder.addFrame(this.ctx,{copy:!0,delay:this.settings.step}),this.step()},T.prototype.save=function(t){this.callback=t,this.encoder.render()},(f||p||{}).CCapture=S,void 0===(i=function(){return S}.call(e,n,e,t))||(t.exports=i)}()}).call(this,n(23)(t),n(16))},function(t,e,n){var r=n(1);r.OrbitControls=function(t,e){this.object=t,this.domElement=void 0!==e?e:document,this.enabled=!0,this.target=new r.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.25,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={ORBIT:r.MOUSE.LEFT,ZOOM:r.MOUSE.MIDDLE,PAN:r.MOUSE.RIGHT},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(i),n.update(),c=s.NONE},this.update=function(){var e=new r.Vector3,o=(new r.Quaternion).setFromUnitVectors(t.up,new r.Vector3(0,1,0)),a=o.clone().inverse(),m=new r.Vector3,g=new r.Quaternion;return function(){var t=n.object.position;return e.copy(t).sub(n.target),e.applyQuaternion(o),l.setFromVector3(e),n.autoRotate&&c===s.NONE&&T(2*Math.PI/60/60*n.autoRotateSpeed),l.theta+=h.theta,l.phi+=h.phi,l.theta=Math.max(n.minAzimuthAngle,Math.min(n.maxAzimuthAngle,l.theta)),l.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,l.phi)),l.makeSafe(),l.radius*=d,l.radius=Math.max(n.minDistance,Math.min(n.maxDistance,l.radius)),n.target.add(p),e.setFromSpherical(l),e.applyQuaternion(a),t.copy(n.target).add(e),n.object.lookAt(n.target),!0===n.enableDamping?(h.theta*=1-n.dampingFactor,h.phi*=1-n.dampingFactor):h.set(0,0,0),d=1,p.set(0,0,0),!!(f||m.distanceToSquared(n.object.position)>u||8*(1-g.dot(n.object.quaternion))>u)&&(n.dispatchEvent(i),m.copy(n.object.position),g.copy(n.object.quaternion),f=!1,!0)}}(),this.dispose=function(){n.domElement.removeEventListener("contextmenu",z,!1),n.domElement.removeEventListener("mousedown",N,!1),n.domElement.removeEventListener("wheel",k,!1),n.domElement.removeEventListener("touchstart",B,!1),n.domElement.removeEventListener("touchend",F,!1),n.domElement.removeEventListener("touchmove",D,!1),document.removeEventListener("mousemove",O,!1),document.removeEventListener("mouseup",I,!1),window.removeEventListener("keydown",U,!1)};var n=this,i={type:"change"},o={type:"start"},a={type:"end"},s={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY:4,TOUCH_PAN:5},c=s.NONE,u=1e-6,l=new r.Spherical,h=new r.Spherical,d=1,p=new r.Vector3,f=!1,m=new r.Vector2,g=new r.Vector2,v=new r.Vector2,y=new r.Vector2,b=new r.Vector2,_=new r.Vector2,x=new r.Vector2,w=new r.Vector2,E=new r.Vector2;function M(){return Math.pow(.95,n.zoomSpeed)}function T(t){h.theta-=t}function S(t){h.phi-=t}var A=function(){var t=new r.Vector3;return function(e,n){t.setFromMatrixColumn(n,0),t.multiplyScalar(-e),p.add(t)}}(),L=function(){var t=new r.Vector3;return function(e,n){t.setFromMatrixColumn(n,1),t.multiplyScalar(e),p.add(t)}}(),R=function(){var t=new r.Vector3;return function(e,r){var i=n.domElement===document?n.domElement.body:n.domElement;if(n.object.isPerspectiveCamera){var o=n.object.position;t.copy(o).sub(n.target);var a=t.length();a*=Math.tan(n.object.fov/2*Math.PI/180),A(2*e*a/i.clientHeight,n.object.matrix),L(2*r*a/i.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(A(e*(n.object.right-n.object.left)/n.object.zoom/i.clientWidth,n.object.matrix),L(r*(n.object.top-n.object.bottom)/n.object.zoom/i.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}}();function C(t){n.object.isPerspectiveCamera?d/=t:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom*t)),n.object.updateProjectionMatrix(),f=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function P(t){n.object.isPerspectiveCamera?d*=t:n.object.isOrthographicCamera?(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/t)),n.object.updateProjectionMatrix(),f=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function N(t){if(!1!==n.enabled){switch(t.button){case n.mouseButtons.ORBIT:if(!1===n.enableRotate)return;!function(t){m.set(t.clientX,t.clientY)}(t),c=s.ROTATE;break;case n.mouseButtons.ZOOM:if(!1===n.enableZoom)return;!function(t){x.set(t.clientX,t.clientY)}(t),c=s.DOLLY;break;case n.mouseButtons.PAN:if(!1===n.enablePan)return;!function(t){y.set(t.clientX,t.clientY)}(t),c=s.PAN}c!==s.NONE&&(document.addEventListener("mousemove",O,!1),document.addEventListener("mouseup",I,!1),n.dispatchEvent(o))}}function O(t){if(!1!==n.enabled)switch(t.preventDefault(),c){case s.ROTATE:if(!1===n.enableRotate)return;!function(t){g.set(t.clientX,t.clientY),v.subVectors(g,m);var e=n.domElement===document?n.domElement.body:n.domElement;T(2*Math.PI*v.x/e.clientWidth*n.rotateSpeed),S(2*Math.PI*v.y/e.clientHeight*n.rotateSpeed),m.copy(g),n.update()}(t);break;case s.DOLLY:if(!1===n.enableZoom)return;!function(t){w.set(t.clientX,t.clientY),E.subVectors(w,x),E.y>0?C(M()):E.y<0&&P(M()),x.copy(w),n.update()}(t);break;case s.PAN:if(!1===n.enablePan)return;!function(t){b.set(t.clientX,t.clientY),_.subVectors(b,y),R(_.x,_.y),y.copy(b),n.update()}(t)}}function I(t){!1!==n.enabled&&(document.removeEventListener("mousemove",O,!1),document.removeEventListener("mouseup",I,!1),n.dispatchEvent(a),c=s.NONE)}function k(t){!1===n.enabled||!1===n.enableZoom||c!==s.NONE&&c!==s.ROTATE||(t.preventDefault(),t.stopPropagation(),function(t){t.deltaY<0?P(M()):t.deltaY>0&&C(M()),n.update()}(t),n.dispatchEvent(o),n.dispatchEvent(a))}function U(t){!1!==n.enabled&&!1!==n.enableKeys&&!1!==n.enablePan&&function(t){switch(t.keyCode){case n.keys.UP:R(0,n.keyPanSpeed),n.update();break;case n.keys.BOTTOM:R(0,-n.keyPanSpeed),n.update();break;case n.keys.LEFT:R(n.keyPanSpeed,0),n.update();break;case n.keys.RIGHT:R(-n.keyPanSpeed,0),n.update()}}(t)}function B(t){if(!1!==n.enabled){switch(t.touches.length){case 1:if(!1===n.enableRotate)return;!function(t){m.set(t.touches[0].pageX,t.touches[0].pageY)}(t),c=s.TOUCH_ROTATE;break;case 2:if(!1===n.enableZoom)return;!function(t){var e=t.touches[0].pageX-t.touches[1].pageX,n=t.touches[0].pageY-t.touches[1].pageY,r=Math.sqrt(e*e+n*n);x.set(0,r)}(t),c=s.TOUCH_DOLLY;break;case 3:if(!1===n.enablePan)return;!function(t){y.set(t.touches[0].pageX,t.touches[0].pageY)}(t),c=s.TOUCH_PAN;break;default:c=s.NONE}c!==s.NONE&&n.dispatchEvent(o)}}function D(t){if(!1!==n.enabled)switch(t.preventDefault(),t.stopPropagation(),t.touches.length){case 1:if(!1===n.enableRotate)return;if(c!==s.TOUCH_ROTATE)return;!function(t){g.set(t.touches[0].pageX,t.touches[0].pageY),v.subVectors(g,m);var e=n.domElement===document?n.domElement.body:n.domElement;T(2*Math.PI*v.x/e.clientWidth*n.rotateSpeed),S(2*Math.PI*v.y/e.clientHeight*n.rotateSpeed),m.copy(g),n.update()}(t);break;case 2:if(!1===n.enableZoom)return;if(c!==s.TOUCH_DOLLY)return;!function(t){var e=t.touches[0].pageX-t.touches[1].pageX,r=t.touches[0].pageY-t.touches[1].pageY,i=Math.sqrt(e*e+r*r);w.set(0,i),E.subVectors(w,x),E.y>0?P(M()):E.y<0&&C(M()),x.copy(w),n.update()}(t);break;case 3:if(!1===n.enablePan)return;if(c!==s.TOUCH_PAN)return;!function(t){b.set(t.touches[0].pageX,t.touches[0].pageY),_.subVectors(b,y),R(_.x,_.y),y.copy(b),n.update()}(t);break;default:c=s.NONE}}function F(t){!1!==n.enabled&&(n.dispatchEvent(a),c=s.NONE)}function z(t){!1!==n.enabled&&t.preventDefault()}n.domElement.addEventListener("contextmenu",z,!1),n.domElement.addEventListener("mousedown",N,!1),n.domElement.addEventListener("wheel",k,!1),n.domElement.addEventListener("touchstart",B,!1),n.domElement.addEventListener("touchend",F,!1),n.domElement.addEventListener("touchmove",D,!1),window.addEventListener("keydown",U,!1),this.update()},r.OrbitControls.prototype=Object.create(r.EventDispatcher.prototype),r.OrbitControls.prototype.constructor=r.OrbitControls,Object.defineProperties(r.OrbitControls.prototype,{center:{get:function(){return console.warn("THREE.OrbitControls: .center has been renamed to .target"),this.target}},noZoom:{get:function(){return console.warn("THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),!this.enableZoom},set:function(t){console.warn("THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),this.enableZoom=!t}},noRotate:{get:function(){return console.warn("THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),!this.enableRotate},set:function(t){console.warn("THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),this.enableRotate=!t}},noPan:{get:function(){return console.warn("THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead."),!this.enablePan},set:function(t){console.warn("THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead."),this.enablePan=!t}},noKeys:{get:function(){return console.warn("THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),!this.enableKeys},set:function(t){console.warn("THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),this.enableKeys=!t}},staticMoving:{get:function(){return console.warn("THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),!this.enableDamping},set:function(t){console.warn("THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),this.enableDamping=!t}},dynamicDampingFactor:{get:function(){return console.warn("THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.dampingFactor},set:function(t){console.warn("THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.dampingFactor=t}}})},function(t,e,n){var r=n(1);r.STLLoader=function(t){this.manager=void 0!==t?t:r.DefaultLoadingManager},r.STLLoader.prototype={constructor:r.STLLoader,load:function(t,e,n,i){var o=this,a=new r.FileLoader(o.manager);a.setPath(o.path),a.setResponseType("arraybuffer"),a.load(t,function(t){try{e(o.parse(t))}catch(t){i&&i(t)}},n,i)},setPath:function(t){return this.path=t,this},parse:function(t){function e(t,e,n){for(var r=0,i=t.length;r>5&31)/31,i=(w>>10&31)/31):(e=a,n=s,i=c)}for(var E=1;E<=3;E++){var M=y+12*E;m.push(l.getFloat32(M,!0)),m.push(l.getFloat32(M+4,!0)),m.push(l.getFloat32(M+8,!0)),g.push(b,_,x),d&&o.push(e,n,i)}}return f.addAttribute("position",new r.BufferAttribute(new Float32Array(m),3)),f.addAttribute("normal",new r.BufferAttribute(new Float32Array(g),3)),d&&(f.addAttribute("color",new r.BufferAttribute(new Float32Array(o),3)),f.hasColors=!0,f.alpha=u),f}(n):function(t){for(var e,n=new r.BufferGeometry,i=/facet([\s\S]*?)endfacet/g,o=0,a=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,s=new RegExp("vertex"+a+a+a,"g"),c=new RegExp("normal"+a+a+a,"g"),u=[],l=[],h=new r.Vector3;null!==(e=i.exec(t));){for(var d=0,p=0,f=e[0];null!==(e=c.exec(f));)h.x=parseFloat(e[1]),h.y=parseFloat(e[2]),h.z=parseFloat(e[3]),p++;for(;null!==(e=s.exec(f));)u.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])),l.push(h.x,h.y,h.z),d++;1!==p&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+o),3!==d&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+o),o++}return n.addAttribute("position",new r.Float32BufferAttribute(u,3)),n.addAttribute("normal",new r.Float32BufferAttribute(l,3)),n}(function(t){return"string"!=typeof t?r.LoaderUtils.decodeText(new Uint8Array(t)):t}(t))}}},function(t,e,n){var r=n(1);r.ColladaLoader=function(t){this.manager=void 0!==t?t:r.DefaultLoadingManager},r.ColladaLoader.prototype={constructor:r.ColladaLoader,crossOrigin:"anonymous",load:function(t,e,n,i){var o=this,a=void 0===o.path?r.LoaderUtils.extractUrlBase(t):o.path,s=new r.FileLoader(o.manager);s.setPath(o.path),s.load(t,function(t){e(o.parse(t,a))},n,i)},setPath:function(t){return this.path=t,this},setResourcePath:function(t){return this.resourcePath=t,this},options:{set convertUpAxis(t){console.warn("THREE.ColladaLoader: options.convertUpAxis() has been removed. Up axis is converted automatically.")}},setCrossOrigin:function(t){return this.crossOrigin=t,this},parse:function(t,e){function n(t,e){for(var n=[],r=t.childNodes,i=0,o=r.length;i0&&e.push(new r.VectorKeyframeTrack(i+".position",o,a)),s.length>0&&e.push(new r.QuaternionKeyframeTrack(i+".quaternion",o,s)),c.length>0&&e.push(new r.VectorKeyframeTrack(i+".scale",o,c)),e}function x(t,e,n){var r,i,o,a=!0;for(i=0,o=t.length;i=0;){var r=t[e];if(null!==r.value[n])return r;e--}return null}function E(t,e,n){for(;e>>0));switch(n=n.toLowerCase()){case"tga":e=zt;break;default:e=Ht}return e}(i);if(void 0!==o){var a=o.load(i),s=t.extra;if(void 0!==s&&void 0!==s.technique&&!1===c(s.technique)){var u=s.technique;a.wrapS=u.wrapU?r.RepeatWrapping:r.ClampToEdgeWrapping,a.wrapT=u.wrapV?r.RepeatWrapping:r.ClampToEdgeWrapping,a.offset.set(u.offsetU||0,u.offsetV||0),a.repeat.set(u.repeatU||1,u.repeatV||1)}else a.wrapS=r.RepeatWrapping,a.wrapT=r.RepeatWrapping;return a}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",i),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",t.id),null}e.name=t.name;var s=i.parameters;for(var u in s){var l=s[u];switch(u){case"diffuse":l.color&&e.color.fromArray(l.color),l.texture&&(e.map=a(l.texture));break;case"specular":l.color&&e.specular&&e.specular.fromArray(l.color),l.texture&&(e.specularMap=a(l.texture));break;case"bump":l.texture&&(e.normalMap=a(l.texture));break;case"ambient":l.texture&&(e.lightMap=a(l.texture));break;case"shininess":l.float&&e.shininess&&(e.shininess=l.float);break;case"emission":l.color&&e.emissive&&e.emissive.fromArray(l.color),l.texture&&(e.emissiveMap=a(l.texture))}}var d=s.transparent,p=s.transparency;if(void 0===p&&d&&(p={float:1}),void 0===d&&p&&(d={opaque:"A_ONE",data:{color:[1,1,1,1]}}),d&&p)if(d.data.texture)e.transparent=!0;else{var f=d.data.color;switch(d.opaque){case"A_ONE":e.opacity=f[3]*p.float;break;case"RGB_ZERO":e.opacity=1-f[0]*p.float;break;case"A_ZERO":e.opacity=1-f[3]*p.float;break;case"RGB_ONE":e.opacity=f[0]*p.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',d.opaque)}e.opacity<1&&(e.transparent=!0)}return void 0!==o&&void 0!==o.technique&&1===o.technique.double_sided&&(e.side=r.DoubleSide),e}function Y(t){return h(qt.materials[t],X)}function J(t){for(var e=0;e0?c+l:c;e.inputs[h]={id:o,offset:u},e.stride=Math.max(e.stride,u+1),"TEXCOORD"===c&&(e.hasUV=!0);break;case"vcount":e.vcount=a(i.textContent);break;case"p":e.p=a(i.textContent)}}return e}function st(t){for(var e=0,n=0,r=t.length;n0&&e0&&f.addAttribute("position",new r.Float32BufferAttribute(o.array,o.stride)),a.array.length>0&&f.addAttribute("normal",new r.Float32BufferAttribute(a.array,a.stride)),u.array.length>0&&f.addAttribute("color",new r.Float32BufferAttribute(u.array,u.stride)),s.array.length>0&&f.addAttribute("uv",new r.Float32BufferAttribute(s.array,s.stride)),c.array.length>0&&f.addAttribute("uv2",new r.Float32BufferAttribute(c.array,c.stride)),l.length>0&&f.addAttribute("skinIndex",new r.Float32BufferAttribute(l,h)),d.length>0&&f.addAttribute("skinWeight",new r.Float32BufferAttribute(d,p)),i.data=f,i.type=t[0].type,i.materialKeys=m,i}function lt(t,e,n,r){var i=t.p,o=t.stride,a=t.vcount;function s(t){for(var e=i[t+n]*u,o=e+u;e4)for(var v=1,y=p-2;v<=y;v++){f=l+o*v,m=l+o*(v+1);s(l+0*o),s(f),s(m)}l+=o*p}else for(h=0,d=i.length;h=e.limits.max&&(e.static=!0),e.middlePosition=(e.limits.min+e.limits.max)/2,e}function gt(t){for(var e={sid:t.getAttribute("sid"),name:t.getAttribute("name")||"",attachments:[],transforms:[]},n=0;ni.limits.max||eu){u=l;var n='Download of "'+t+'": '+(100*l).toFixed(2)+"%";c.onProgress("progressLoad",n,l)}}}n.isValid(o)||(o=function(e){var n='Error occurred while downloading "'+t+'"';c.logger.logError(n+": "+e),c.onProgress("error",n,-1)}),this.fileLoader.setPath(this.path),this.fileLoader.setResponseType("arraybuffer"),this.fileLoader.load(t,function(t){if(s)c.parseAsync(t,e);else{var n=new r.LoaderSupport.Callbacks;n.setCallbackOnMeshAlter(a),c._setCallbacks(n),e({detail:{loaderRootNode:c.parse(t),modelName:c.modelName,instanceNo:c.instanceNo}})}},i,o)},o.prototype.run=function(t,e){this._applyPrepData(t);var r=this._checkFiles(t.resources);n.isValid(e)&&(this.terminateWorkerOnLoad=!1,this.workerSupport=e,this.logger=e.logger);var i=this;this._loadMtl(r.mtl,function(e){i.builder.setMaterials(e),n.isValid(r.obj.content)?t.useAsync?i.parseAsync(r.obj.content,i.callbacks.onLoad):i.parse(r.obj.content):(i.setPath(r.obj.path),i.load(r.obj.name,i.callbacks.onLoad,null,null,i.callbacks.onMeshAlter,t.useAsync))},t.crossOrigin)},o.prototype._applyPrepData=function(t){r.LoaderSupport.LoaderBase.prototype._applyPrepData.call(this,t),n.isValid(t)&&this.setMaterialPerSmoothingGroup(t.materialPerSmoothingGroup)},o.prototype.parse=function(t){this.logger.logTimeStart("OBJLoader2 parse: "+this.modelName);var e=new s;e.setLogConfig(this.logger.enabled,this.logger.debug),e.setMaterialPerSmoothingGroup(this.materialPerSmoothingGroup),e.setUseIndices(this.useIndices),e.setDisregardNormals(this.disregardNormals),e.setMaterials(this.builder.getMaterials());var n=this;e.setCallbackBuilder(function(t){var e,r=n.builder.processPayload(t);for(var i in r)e=r[i],n.loaderRootNode.add(e)});if(e.setCallbackProgress(function(t,e){n.onProgress("progressParse",t,e)}),t instanceof ArrayBuffer||t instanceof Uint8Array)this.logger.logInfo("Parsing arrayBuffer..."),e.parse(t);else{if(!("string"==typeof t||t instanceof String))throw"Provided content was neither of type String nor Uint8Array! Aborting...";this.logger.logInfo("Parsing text..."),e.parseText(t)}return this.logger.logTimeEnd("OBJLoader2 parse: "+this.modelName),this.loaderRootNode},o.prototype.parseAsync=function(t,o){this.logger.logTimeStart("OBJLoader2 parseAsync: "+this.modelName);var l=this;this.workerSupport=n.verifyInput(this.workerSupport,new r.LoaderSupport.WorkerSupport(this.logger));this.workerSupport.validate(function(t,r){var o="";return o+="/**\n",o+=" * This code was constructed by OBJLoader2 buildCode.\n",o+=" */\n\n",o+=t("Validator",n),o+=r("ConsoleLogger","ConsoleLogger",i),o+=r("LoaderBase","LoaderBase",e),o+=t("Consts",a),o+=r("Parser","Parser",s),o+=r("RawMesh","RawMesh",c),o+=r("RawMeshSubGroup","RawMeshSubGroup",u)},!1),this.workerSupport.setCallbacks(function(t){var e,n=l.builder.processPayload(t);for(var r in n)e=n[r],l.loaderRootNode.add(e)},function(){o({detail:{loaderRootNode:l.loaderRootNode,modelName:l.modelName,instanceNo:l.instanceNo}}),l.logger.logTimeEnd("OBJLoader2 parseAsync: "+l.modelName)}),l.terminateWorkerOnLoad&&this.workerSupport.setTerminateRequested(!0);var h={},d=this.builder.getMaterials();for(var p in d)h[p]=p;this.workerSupport.run({params:{useAsync:!0,materialPerSmoothingGroup:this.materialPerSmoothingGroup,useIndices:this.useIndices,disregardNormals:this.disregardNormals},logger:{debug:this.logger.debug,enabled:this.logger.enabled},materials:{materials:h},data:{input:t,options:null}})};var a={CODE_LF:10,CODE_CR:13,CODE_SPACE:32,CODE_SLASH:47,STRING_LF:"\n",STRING_CR:"\r",STRING_SPACE:" ",STRING_SLASH:"/",LINE_F:"f",LINE_G:"g",LINE_L:"l",LINE_O:"o",LINE_S:"s",LINE_V:"v",LINE_VT:"vt",LINE_VN:"vn",LINE_MTLLIB:"mtllib",LINE_USEMTL:"usemtl"},s=function(){var t=r.LoaderSupport.ConsoleLogger;function e(){this.callbackProgress=null,this.callbackBuilder=null,this.materials={},this.rawMesh=null,this.useAsync=!1,this.materialPerSmoothingGroup=!1,this.useIndices=!1,this.disregardNormals=!1,this.inputObjectCount=1,this.outputObjectCount=1,this.counts={vertices:0,faces:0,doubleIndicesCount:0},this.logger=new t,this.totalBytes=0}return e.prototype.setUseAsync=function(t){this.useAsync=t},e.prototype.setMaterialPerSmoothingGroup=function(t){this.materialPerSmoothingGroup=t},e.prototype.setUseIndices=function(t){this.useIndices=t},e.prototype.setDisregardNormals=function(t){this.disregardNormals=t},e.prototype.setMaterials=function(t){this.materials=n.verifyInput(t,this.materials),this.materials=n.verifyInput(this.materials,{})},e.prototype.setCallbackBuilder=function(t){if(this.callbackBuilder=t,!n.isValid(this.callbackBuilder))throw'Unable to run as no "builder" callback is set.'},e.prototype.setCallbackProgress=function(t){this.callbackProgress=t},e.prototype.setLogConfig=function(t,e){this.logger.setEnabled(t),this.logger.setDebug(e)},e.prototype.configure=function(){if(this.rawMesh=new c(this.materialPerSmoothingGroup,this.useIndices,this.disregardNormals),this.logger.isEnabled()){var t=Object.keys(this.materials),e="OBJLoader2.Parser configuration:"+(t.length>0?"\n\tmaterialNames:\n\t\t- "+t.join("\n\t\t- "):"\n\tmaterialNames: None")+"\n\tuseAsync: "+this.useAsync+"\n\tmaterialPerSmoothingGroup: "+this.materialPerSmoothingGroup+"\n\tuseIndices: "+this.useIndices+"\n\tdisregardNormals: "+this.disregardNormals+"\n\tcallbackBuilderName: "+this.callbackBuilder.name+"\n\tcallbackProgressName: "+this.callbackProgress.name;this.logger.logInfo(e)}},e.prototype.parse=function(t){this.logger.logTimeStart("OBJLoader2.Parser.parse"),this.configure();var e=new Uint8Array(t),n=e.byteLength;this.totalBytes=n;for(var r,i=new Array(128),o=0,s=new Array(16),c=0,u="",l=0;l0&&(i[o++]=u),s[c++]=0,u="";break;case a.CODE_SLASH:u.length>0&&(i[o++]=u),s[c++]=1,u="";break;case a.CODE_LF:u.length>0&&(i[o++]=u),u="",this.processLine(i,o,s,c,l),o=0,c=0;break;case a.CODE_CR:break;default:u+=String.fromCharCode(r)}this.finalize(l),this.logger.logTimeEnd("OBJLoader2.Parser.parse")},e.prototype.parseText=function(t){this.logger.logTimeStart("OBJLoader2.Parser.parseText"),this.configure();var e=t.length;this.totalBytes=e;for(var n,r=new Array(128),i=0,o=new Array(16),s=0,c="",u=0;u0&&(r[i++]=c),o[s++]=0,c="";break;case a.STRING_SLASH:c.length>0&&(r[i++]=c),o[s++]=1,c="";break;case a.STRING_LF:c.length>0&&(r[i++]=c),c="",this.processLine(r,i,o,s,u),i=0,s=0;break;case a.STRING_CR:break;default:c+=n}this.finalize(u),this.logger.logTimeEnd("OBJLoader2.Parser.parseText")},e.prototype.processLine=function(t,e,n,r,i){if(!(e<1)){var o=function(t,e){for(var n=0,r=0;r4);break;case a.LINE_VT:this.rawMesh.pushUv(t);break;case a.LINE_VN:this.rawMesh.pushNormal(t);break;case a.LINE_F:this.rawMesh.processFaces(t,e,o(n,r));break;case a.LINE_L:this.rawMesh.processLines(t,e,o(n,r));break;case a.LINE_S:this.rawMesh.pushSmoothingGroup(t[1]),c(t,e);break;case a.LINE_G:this.processCompletedMesh(i),this.rawMesh.pushGroup(s(t,e,n)),c(t,e);break;case a.LINE_O:this.rawMesh.pushObject(s(t,e,n)),c(t,e);break;case a.LINE_MTLLIB:this.rawMesh.pushMtllib(s(t,e,n)),c(t,e);break;case a.LINE_USEMTL:this.rawMesh.pushUsemtl(s(t,e,n)),c(t,e)}}},e.prototype.createRawMeshReport=function(t,e){var n=t.createReport(e);return"Input Object number: "+e+"\n\tObject name: "+n.objectName+"\n\tGroup name: "+n.groupName+"\n\tMtllib name: "+n.mtllibName+"\n\tVertex count: "+n.vertexCount+"\n\tNormal count: "+n.normalCount+"\n\tUV count: "+n.uvCount+"\n\tSmoothingGroup count: "+n.smoothingGroupCount+"\n\tMaterial count: "+n.mtlCount+"\n\tReal RawMeshSubGroup count: "+n.subGroups},e.prototype.processCompletedMesh=function(t){var e=this.rawMesh.finalize();if(n.isValid(e)){if(this.rawMesh.colors.length>0&&this.rawMesh.colors.length!==this.rawMesh.vertices.length)throw"Vertex Colors were detected, but vertex count and color count do not match!";this.logger.isDebug()&&this.logger.logDebug(this.createRawMeshReport(this.rawMesh,this.inputObjectCount)),this.inputObjectCount++,this.buildMesh(e,t);var r=t/this.totalBytes;return this.callbackProgress("Completed [o: "+this.rawMesh.objectName+" g:"+this.rawMesh.groupName+"] Total progress: "+(100*r).toFixed(2)+"%",r),this.rawMesh.reset(this.rawMesh.smoothingGroup.splitMaterials),!0}return!1},e.prototype.finalize=function(t){if(this.logger.logInfo("Global output object count: "+this.outputObjectCount),this.processCompletedMesh(t)&&this.logger.isEnabled()){var e="Overall counts: \n\tVertices: "+this.counts.vertices+"\n\tFaces: "+this.counts.faces+"\n\tMultiple definitions: "+this.counts.doubleIndicesCount;this.logger.logInfo(e)}},e.prototype.buildMesh=function(t,e){var r=t.subGroups,i=new Float32Array(t.absoluteVertexCount);this.counts.vertices+=t.absoluteVertexCount/3,this.counts.faces+=t.faceCount,this.counts.doubleIndicesCount+=t.doubleIndicesCount;var o,a,s,c,u,l,h,d=t.absoluteIndexCount>0?new Uint32Array(t.absoluteIndexCount):null,p=t.absoluteColorCount>0?new Float32Array(t.absoluteColorCount):null,f=t.absoluteNormalCount>0?new Float32Array(t.absoluteNormalCount):null,m=t.absoluteUvCount>0?new Float32Array(t.absoluteUvCount):null,g=n.isValid(p),v=[],y=r.length>1,b=0,_=[],x=[],w=0,E=0,M=0,T=0,S=0,A=0,L=0;for(var R in r)if(r.hasOwnProperty(R)){if(l=(h=(o=r[R]).materialName)+(g?"_vertexColor":"")+(0===o.smoothingGroup?"_flat":""),c=this.materials[h],u=this.materials[l],!n.isValid(c)&&!n.isValid(u)){var C=g?"vertexColorMaterial":"defaultMaterial";c=this.materials[C],this.logger.logWarn('object_group "'+o.objectName+"_"+o.groupName+'" was defined with unresolvable material "'+h+'"! Assigning "'+C+'".'),(h=C)===l&&(u=c,l=C)}if(!n.isValid(u)){var P={materialNameOrg:h,materialName:l,materialProperties:{vertexColors:g?2:0,flatShading:0===o.smoothingGroup}},N={cmd:"materialData",materials:{materialCloneInstructions:P}};this.callbackBuilder(N),this.useAsync&&(this.materials[l]=P)}if(y?((a=_[l])||(a=b,_[l]=b,v.push(l),b++),s={start:A,count:L=this.useIndices?o.indices.length:o.vertices.length/3,index:a},x.push(s),A+=L):v.push(l),i.set(o.vertices,w),w+=o.vertices.length,d&&(d.set(o.indices,E),E+=o.indices.length),p&&(p.set(o.colors,M),M+=o.colors.length),f&&(f.set(o.normals,T),T+=o.normals.length),m&&(m.set(o.uvs,S),S+=o.uvs.length),this.logger.isDebug()){var O=n.isValid(a)?"\n\t\tmaterialIndex: "+a:"",I="Output Object no.: "+this.outputObjectCount+"\n\t\tgroupName: "+o.groupName+O+"\n\t\tmaterialName: "+o.materialName+"\n\t\tsmoothingGroup: "+o.smoothingGroup+"\n\t\tobjectName: "+o.objectName+"\n\t\t#vertices: "+o.vertices.length/3+"\n\t\t#indices: "+o.indices.length+"\n\t\t#colors: "+o.colors.length/3+"\n\t\t#uvs: "+o.uvs.length/2+"\n\t\t#normals: "+o.normals.length/3;this.logger.logDebug(I)}}this.outputObjectCount++,this.callbackBuilder({cmd:"meshData",progress:{numericalValue:e/this.totalBytes},params:{meshName:t.name},materials:{multiMaterial:y,materialNames:v,materialGroups:x},buffers:{vertices:i,indices:d,colors:p,normals:f,uvs:m}},[i.buffer],n.isValid(d)?[d.buffer]:null,n.isValid(p)?[p.buffer]:null,n.isValid(f)?[f.buffer]:null,n.isValid(m)?[m.buffer]:null)},e}(),c=function(){function t(t,e,n){this.vertices=[],this.colors=[],this.normals=[],this.uvs=[],this.useIndices=!0===e,this.disregardNormals=!0===n,this.objectName="",this.groupName="",this.activeMtlName="",this.mtllibName="",this.reset(t)}return t.prototype.reset=function(t){this.subGroups=[],this.subGroupInUse=null,this.smoothingGroup={splitMaterials:!0===t,normalized:-1,real:-1},this.pushSmoothingGroup(1),this.doubleIndicesCount=0,this.faceCount=0,this.mtlCount=0,this.smoothingGroupCount=0},t.prototype.pushVertex=function(t,e){this.vertices.push(parseFloat(t[1])),this.vertices.push(parseFloat(t[2])),this.vertices.push(parseFloat(t[3])),e&&(this.colors.push(parseFloat(t[4])),this.colors.push(parseFloat(t[5])),this.colors.push(parseFloat(t[6])))},t.prototype.pushUv=function(t){this.uvs.push(parseFloat(t[1])),this.uvs.push(parseFloat(t[2]))},t.prototype.pushNormal=function(t){this.normals.push(parseFloat(t[1])),this.normals.push(parseFloat(t[2])),this.normals.push(parseFloat(t[3]))},t.prototype.pushGroup=function(t){this.groupName=n.verifyInput(t,"")},t.prototype.pushObject=function(t){this.objectName=n.verifyInput(t,"")},t.prototype.pushMtllib=function(t){this.mtllibName=n.verifyInput(t,"")},t.prototype.pushUsemtl=function(t){this.activeMtlName!==t&&n.isValid(t)&&(this.activeMtlName=t,this.mtlCount++,this.verifyIndex())},t.prototype.pushSmoothingGroup=function(t){var e=parseInt(t);isNaN(e)&&(e="off"===t?0:1);var n=this.smoothingGroup.normalized;this.smoothingGroup.normalized=this.smoothingGroup.splitMaterials?e:0===e?0:1,this.smoothingGroup.real=e,n!==e&&(this.smoothingGroupCount++,this.verifyIndex())},t.prototype.verifyIndex=function(){var t=this.activeMtlName+"|"+this.smoothingGroup.normalized;this.subGroupInUse=this.subGroups[t],n.isValid(this.subGroupInUse)||(this.subGroupInUse=new u(this.objectName,this.groupName,this.activeMtlName,this.smoothingGroup.normalized),this.subGroups[t]=this.subGroupInUse)},t.prototype.processFaces=function(t,e,n){var r,i,o=e-1;if(0===n)for(r=2,i=o;r0?n-1:n+o.vertices.length/3),s=i.vertices;s.push(o.vertices[a++]),s.push(o.vertices[a++]),s.push(o.vertices[a]);var c=o.colors.length>0?a:null;if(null!==c){var u=i.colors;u.push(o.colors[c++]),u.push(o.colors[c++]),u.push(o.colors[c])}if(e){var l=parseInt(e),h=2*(l>0?l-1:l+o.uvs.length/2),d=i.uvs;d.push(o.uvs[h++]),d.push(o.uvs[h])}if(r){var p=parseInt(r),f=3*(p>0?p-1:p+o.normals.length/3),m=i.normals;m.push(o.normals[f++]),m.push(o.normals[f++]),m.push(o.normals[f])}};if(this.useIndices){var s=t+(e?"_"+e:"_n")+(r?"_"+r:"_n"),c=i.indexMappings[s];n.isValid(c)?this.doubleIndicesCount++:(c=i.vertices.length/3,a(),i.indexMappings[s]=c,i.indexMappingsCount++),i.indices.push(c)}else a();this.faceCount++},t.prototype.processLines=function(t,e,n){var r,i=1,o=e-1;if(o===2*n)for(r=o-2;i0){if((e=t.indices).length>0&&i>0)for(var l in e)e[l]=e[l]+i;n.push(t),r+=t.vertices.length,i+=t.indexMappingsCount,o+=t.indices.length,a+=t.colors.length,c+=t.uvs.length,s+=t.normals.length}var h=null;return n.length>0&&(h={name:""!==this.groupName?this.groupName:this.objectName,subGroups:n,absoluteVertexCount:r,absoluteIndexCount:o,absoluteColorCount:a,absoluteNormalCount:s,absoluteUvCount:c,faceCount:this.faceCount,doubleIndicesCount:this.doubleIndicesCount}),h},t.prototype.createReport=function(){return{objectName:this.objectName,groupName:this.groupName,mtllibName:this.mtllibName,vertexCount:this.vertices.length/3,normalCount:this.normals.length/3,uvCount:this.uvs.length/2,smoothingGroupCount:this.smoothingGroupCount,mtlCount:this.mtlCount,subGroups:this.subGroups.length}},t}(),u=function(){function t(t,e,n,r){this.objectName=t,this.groupName=e,this.materialName=n,this.smoothingGroup=r,this._init()}return t.prototype._init=function(){this.vertices=[],this.indexMappingsCount=0,this.indexMappings=[],this.indices=[],this.colors=[],this.uvs=[],this.normals=[]},t}();return o.prototype._checkFiles=function(t){var e,r={mtl:null,obj:null};for(var i in t)if(e=t[i],n.isValid(e.name))if(n.isValid(e.content)){if("OBJ"===e.extension){if(!(e.content instanceof Uint8Array))throw"Provided content is not of type arraybuffer! Aborting...";r.obj=e}else if("MTL"===e.extension&&n.isValid(e.name)){if(!("string"==typeof e.content||e.content instanceof String))throw"Provided content is not of type String! Aborting...";r.mtl=e}else if("ZIP"!==e.extension)throw'Unidentified resource "'+e.name+'": '+e.url}else{if(!("string"==typeof e.name||e.name instanceof String))throw"Provided file is not properly defined! Aborting...";if("OBJ"===e.extension)r.obj=e;else if("MTL"===e.extension)r.mtl=e;else if("ZIP"!==e.extension)throw'Unidentified resource "'+e.name+'": '+e.url}return r},o.prototype.loadMtl=function(t,e,n,i){var o=new r.LoaderSupport.ResourceDescriptor(t,"MTL");o.setContent(e),this._loadMtl(o,n,i)},o.prototype._loadMtl=function(t,e,i){void 0===r.MTLLoader&&console.error('"THREE.MTLLoader" is not available. "THREE.OBJLoader2" requires it for loading MTL files.'),n.isValid(t)&&this.logger.logTimeStart("Loading MTL: "+t.name);var o=[],a=this,s=function(r){var i=[];if(n.isValid(r))for(var s in r.preload(),i=r.materials)i.hasOwnProperty(s)&&(o[s]=i[s]);n.isValid(t)&&a.logger.logTimeEnd("Loading MTL: "+t.name),e(o)},c=new r.MTLLoader;if(i=n.verifyInput(i,"anonymous"),c.setCrossOrigin(i),n.isValid(t)&&(n.isValid(t.content)||n.isValid(t.url))){if(c.setPath(t.path),n.isValid(t.content))s(n.isValid(t.content)?c.parse(t.content):null);else if(n.isValid(t.url)){c.load(t.name,s,void 0,function(e){var n='Error occurred while downloading "'+t.url+'"';throw a.logger.logError(n+": "+e),n})}}else s()},o}()},function(t,e,n){var r=n(1);void 0===r.LoaderSupport&&(r.LoaderSupport={}),r.LoaderSupport.Validator={isValid:function(t){return null!==t&&void 0!==t},verifyInput:function(t,e){return null===t||void 0===t?e:t}},r.LoaderSupport.ConsoleLogger=function(){function t(t,e){this.enabled=!1!==t,this.debug=!0===e}return t.prototype.setDebug=function(t){this.debug=!0===t},t.prototype.isDebug=function(){return this.isEnabled()&&this.debug},t.prototype.setEnabled=function(t){this.enabled=!0===t},t.prototype.isEnabled=function(){return this.enabled},t.prototype.logDebug=function(t){this.enabled&&this.debug&&console.info(t)},t.prototype.logInfo=function(t){this.enabled&&console.info(t)},t.prototype.logWarn=function(t){console.warn(t)},t.prototype.logError=function(t){console.error(t)},t.prototype.logTimeStart=function(t){this.enabled&&console.time(t)},t.prototype.logTimeEnd=function(t){this.enabled&&console.timeEnd(t)},t}(),r.LoaderSupport.Callbacks=function(){var t=r.LoaderSupport.Validator;function e(){this.onProgress=null,this.onMeshAlter=null,this.onLoad=null,this.onLoadMaterials=null}return e.prototype.setCallbackOnProgress=function(e){this.onProgress=t.verifyInput(e,this.onProgress)},e.prototype.setCallbackOnMeshAlter=function(e){this.onMeshAlter=t.verifyInput(e,this.onMeshAlter)},e.prototype.setCallbackOnLoad=function(e){this.onLoad=t.verifyInput(e,this.onLoad)},e.prototype.setCallbackOnLoadMaterials=function(e){this.onLoadMaterials=t.verifyInput(e,this.onLoadMaterials)},e}(),r.LoaderSupport.LoadedMeshUserOverride=function(){function t(t,e){this.disregardMesh=!0===t,this.alteredMesh=!0===e,this.meshes=[]}return t.prototype.addMesh=function(t){this.meshes.push(t),this.alteredMesh=!0},t.prototype.isDisregardMesh=function(){return this.disregardMesh},t.prototype.providesAlteredMeshes=function(){return this.alteredMesh},t}(),r.LoaderSupport.ResourceDescriptor=function(){var t=r.LoaderSupport.Validator;function e(e,n){var r=e.split("/");r.length<2?(this.path=null,this.name=e,this.url=e):(this.path=t.verifyInput(r.slice(0,r.length-1).join("/")+"/",null),this.name=t.verifyInput(r[r.length-1],null),this.url=e),this.extension=t.verifyInput(n,"default"),this.extension=this.extension.trim(),this.content=null}return e.prototype.setContent=function(e){this.content=t.verifyInput(e,null)},e}(),r.LoaderSupport.PrepData=function(){var t=r.LoaderSupport.Validator;function e(e){this.modelName=t.verifyInput(e,""),this.resources=[],this.streamMeshesTo=null,this.materialPerSmoothingGroup=!1,this.useIndices=!1,this.disregardNormals=!1,this.callbacks=new r.LoaderSupport.Callbacks,this.crossOrigin,this.useAsync=!1}return e.prototype.setStreamMeshesTo=function(e){this.streamMeshesTo=t.verifyInput(e,null)},e.prototype.setMaterialPerSmoothingGroup=function(t){this.materialPerSmoothingGroup=!0===t},e.prototype.setUseIndices=function(t){this.useIndices=!0===t},e.prototype.setDisregardNormals=function(t){this.disregardNormals=!0===t},e.prototype.getCallbacks=function(){return this.callbacks},e.prototype.setCrossOrigin=function(t){this.crossOrigin=t},e.prototype.addResource=function(t){this.resources.push(t)},e.prototype.setUseAsync=function(t){this.useAsync=!0===t},e.prototype.clone=function(){var t=new r.LoaderSupport.PrepData(this.modelName);return t.resources=this.resources,t.streamMeshesTo=this.streamMeshesTo,t.materialPerSmoothingGroup=this.materialPerSmoothingGroup,t.useIndices=this.useIndices,t.disregardNormals=this.disregardNormals,t.callbacks=this.callbacks,t.crossOrigin=this.crossOrigin,t.useAsync=this.useAsync,t},e}(),r.LoaderSupport.Builder=function(){var t="1.1.1",e=r.LoaderSupport.Validator,n=r.LoaderSupport.ConsoleLogger;function i(i){this.logger=e.verifyInput(i,new n),this.logger.logInfo("Using THREE.LoaderSupport.Builder version: "+t),this.callbacks=new r.LoaderSupport.Callbacks,this.materials=[]}return i.prototype.setMaterials=function(t){var n={cmd:"materialData",materials:{materialCloneInstructions:null,serializedMaterials:null,runtimeMaterials:e.isValid(this.callbacks.onLoadMaterials)?this.callbacks.onLoadMaterials(t):t}};this.updateMaterials(n)},i.prototype._setCallbacks=function(t){e.isValid(t.onProgress)&&this.callbacks.setCallbackOnProgress(t.onProgress),e.isValid(t.onMeshAlter)&&this.callbacks.setCallbackOnMeshAlter(t.onMeshAlter),e.isValid(t.onLoad)&&this.callbacks.setCallbackOnLoad(t.onLoad),e.isValid(t.onLoadMaterials)&&this.callbacks.setCallbackOnLoadMaterials(t.onLoadMaterials)},i.prototype.processPayload=function(t){return"meshData"===t.cmd?this.buildMeshes(t):"materialData"===t.cmd?(this.updateMaterials(t),null):void 0},i.prototype.buildMeshes=function(t){var n,i,o,a=t.params.meshName,s=new r.BufferGeometry;s.addAttribute("position",new r.BufferAttribute(new Float32Array(t.buffers.vertices),3)),e.isValid(t.buffers.indices)&&s.setIndex(new r.BufferAttribute(new Uint32Array(t.buffers.indices),1)),e.isValid(t.buffers.colors)&&s.addAttribute("color",new r.BufferAttribute(new Float32Array(t.buffers.colors),3)),e.isValid(t.buffers.normals)?s.addAttribute("normal",new r.BufferAttribute(new Float32Array(t.buffers.normals),3)):s.computeVertexNormals(),e.isValid(t.buffers.uvs)&&s.addAttribute("uv",new r.BufferAttribute(new Float32Array(t.buffers.uvs),2));var c=t.materials.materialNames,u=t.materials.multiMaterial,l=[];for(o in c)i=c[o],n=this.materials[i],u&&l.push(n);if(u){n=l;var h,d=t.materials.materialGroups;for(o in d)h=d[o],s.addGroup(h.start,h.count,h.index)}var p,f,m,g=[],v=this.callbacks.onMeshAlter,y=!0;if(e.isValid(v)&&(f=v({detail:{meshName:a,bufferGeometry:s,material:n}}),e.isValid(f))){if(!f.isDisregardMesh()&&f.providesAlteredMeshes())for(var b in f.meshes)g.push(f.meshes[b]);y=!1}if(y&&((p=new r.Mesh(s,n)).name=a,g.push(p)),e.isValid(g)&&g.length>0){var _=[];for(var b in g)p=g[b],_[b]=p.name;m="Adding mesh(es) ("+_.length+": "+_+") from input mesh: "+a,m+=" ("+(100*t.progress.numericalValue).toFixed(2)+"%)"}else m="Not adding mesh: "+a,m+=" ("+(100*t.progress.numericalValue).toFixed(2)+"%)";var x=this.callbacks.onProgress;e.isValid(x)&&x(new CustomEvent("BuilderEvent",{detail:{type:"progress",modelName:t.params.meshName,text:m,numericalValue:t.progress.numericalValue}}));return g},i.prototype.updateMaterials=function(t){var n,i,o=t.materials.materialCloneInstructions;if(e.isValid(o)){var a=o.materialNameOrg;n=this.materials[a].clone(),i=o.materialName,n.name=i;var s=o.materialProperties;for(var c in s)n.hasOwnProperty(c)&&s.hasOwnProperty(c)&&(n[c]=s[c]);this.materials[i]=n}var u=t.materials.serializedMaterials;if(e.isValid(u)&&Object.keys(u).length>0){var l,h=new r.MaterialLoader;for(i in u)l=u[i],e.isValid(l)&&(n=h.parse(l),this.logger.logInfo('De-serialized material with name "'+i+'" will be added.'),this.materials[i]=n)}if(u=t.materials.runtimeMaterials,e.isValid(u)&&Object.keys(u).length>0)for(i in u)n=u[i],this.logger.logInfo('Material with name "'+i+'" will be added.'),this.materials[i]=n},i.prototype.getMaterialsJSON=function(){var t,e={};for(var n in this.materials)t=this.materials[n],e[n]=t.toJSON();return e},i.prototype.getMaterials=function(){return this.materials},i}(),r.LoaderSupport.LoaderBase=function(){var t=r.LoaderSupport.Validator,e=r.LoaderSupport.ConsoleLogger;function n(n,i){this.manager=t.verifyInput(n,r.DefaultLoadingManager),this.logger=t.verifyInput(i,new e),this.modelName="",this.instanceNo=0,this.path="",this.useIndices=!1,this.disregardNormals=!1,this.loaderRootNode=new r.Group,this.builder=new r.LoaderSupport.Builder(this.logger),this._createDefaultMaterials(),this.callbacks=new r.LoaderSupport.Callbacks}return n.prototype._createDefaultMaterials=function(){var t=new r.MeshStandardMaterial({color:14479871});t.name="defaultMaterial";var e=new r.MeshStandardMaterial({color:14479871});e.name="vertexColorMaterial",e.vertexColors=r.VertexColors;var n={};n[t.name]=t,n[e.name]=e,this.builder.updateMaterials({cmd:"materialData",materials:{materialCloneInstructions:null,serializedMaterials:null,runtimeMaterials:n}})},n.prototype._applyPrepData=function(e){t.isValid(e)&&(this.setModelName(e.modelName),this.setStreamMeshesTo(e.streamMeshesTo),this.builder.setMaterials(e.materials),this.setUseIndices(e.useIndices),this.setDisregardNormals(e.disregardNormals),this._setCallbacks(e.getCallbacks()))},n.prototype._setCallbacks=function(e){t.isValid(e.onProgress)&&this.callbacks.setCallbackOnProgress(e.onProgress),t.isValid(e.onMeshAlter)&&this.callbacks.setCallbackOnMeshAlter(e.onMeshAlter),t.isValid(e.onLoad)&&this.callbacks.setCallbackOnLoad(e.onLoad),t.isValid(e.onLoadMaterials)&&this.callbacks.setCallbackOnLoadMaterials(e.onLoadMaterials),this.builder._setCallbacks(this.callbacks)},n.prototype.getLogger=function(){return this.logger},n.prototype.setModelName=function(e){this.modelName=t.verifyInput(e,this.modelName)},n.prototype.setPath=function(e){this.path=t.verifyInput(e,this.path)},n.prototype.setStreamMeshesTo=function(e){this.loaderRootNode=t.verifyInput(e,this.loaderRootNode)},n.prototype.setMaterials=function(t){this.builder.setMaterials(t)},n.prototype.setUseIndices=function(t){this.useIndices=!0===t},n.prototype.setDisregardNormals=function(t){this.disregardNormals=!0===t},n.prototype.onProgress=function(e,n,r){var i=t.isValid(n)?n:"",o={detail:{type:e,modelName:this.modelName,instanceNo:this.instanceNo,text:i,numericalValue:r}};t.isValid(this.callbacks.onProgress)&&this.callbacks.onProgress(o),this.logger.logDebug(i)},n}(),r.LoaderSupport.WorkerRunnerRefImpl=function(){function t(){var t=this;self.addEventListener("message",function(e){t.processMessage(e.data)},!1)}return t.prototype.applyProperties=function(t,e){var n,r,i;for(n in e)r="set"+n.substring(0,1).toLocaleUpperCase()+n.substring(1),i=e[n],"function"==typeof t[r]?t[r](i):t.hasOwnProperty(n)&&(t[n]=i)},t.prototype.processMessage=function(t){var e=t.logger.enabled,n=t.logger.enabled;if("run"===t.cmd){var r={callbackBuilder:function(t){self.postMessage(t)},callbackProgress:function(t){e&&n&&console.debug("WorkerRunner: progress: "+t)}},i=new Parser;"function"==typeof i.setLogConfig&&i.setLogConfig(e,n),this.applyProperties(i,t.params),this.applyProperties(i,t.materials),this.applyProperties(i,r),i.workerScope=self,i.parse(t.data.input,t.data.options),e&&console.log("WorkerRunner: Run complete!"),r.callbackBuilder({cmd:"complete",msg:"WorkerRunner completed run."})}else console.error("WorkerRunner: Received unknown command: "+t.cmd)},t}(),r.LoaderSupport.WorkerSupport=function(){var t="2.0.1",e=r.LoaderSupport.Validator,n=function(){function t(t){this.logger=e.verifyInput(t,new r.LoaderSupport.ConsoleLogger),this._reset()}return t.prototype._reset=function(){this.worker=null,this.runnerImplName=null,this.callbacks={builder:null,onLoad:null},this.terminateRequested=!1,this.queuedMessage=null,this.started=!1},t.prototype.initWorker=function(t,e){this.runnerImplName=e;var n=new Blob([t],{type:"application/javascript"});this.worker=new Worker(window.URL.createObjectURL(n)),this.worker.onmessage=this._receiveWorkerMessage,this.worker.runtimeRef=this,this._postMessage()},t.prototype._receiveWorkerMessage=function(t){var e=t.data;switch(e.cmd){case"meshData":case"materialData":case"imageData":this.runtimeRef.callbacks.builder(e);break;case"complete":this.runtimeRef.queuedMessage=null,this.started=!1,this.runtimeRef.callbacks.onLoad(e.msg),this.runtimeRef.terminateRequested&&(this.runtimeRef.logger.logInfo("WorkerSupport ["+this.runtimeRef.runnerImplName+"]: Run is complete. Terminating application on request!"),this.runtimeRef._terminate());break;case"error":this.runtimeRef.logger.logError("WorkerSupport ["+this.runtimeRef.runnerImplName+"]: Reported error: "+e.msg),this.runtimeRef.queuedMessage=null,this.started=!1,this.runtimeRef.callbacks.onLoad(e.msg),this.runtimeRef.terminateRequested&&(this.runtimeRef.logger.logInfo("WorkerSupport ["+this.runtimeRef.runnerImplName+"]: Run reported error. Terminating application on request!"),this.runtimeRef._terminate());break;default:this.runtimeRef.logger.logError("WorkerSupport ["+this.runtimeRef.runnerImplName+"]: Received unknown command: "+e.cmd)}},t.prototype.setCallbacks=function(t,n){this.callbacks.builder=e.verifyInput(t,this.callbacks.builder),this.callbacks.onLoad=e.verifyInput(n,this.callbacks.onLoad)},t.prototype.run=function(t){if(e.isValid(this.queuedMessage))console.warn("Already processing message. Rejecting new run instruction");else{if(this.queuedMessage=t,this.started=!0,!e.isValid(this.callbacks.builder))throw'Unable to run as no "builder" callback is set.';if(!e.isValid(this.callbacks.onLoad))throw'Unable to run as no "onLoad" callback is set.';"run"!==t.cmd&&(t.cmd="run"),e.isValid(t.logger)?(t.logger.enabled=e.verifyInput(t.logger.enabled,!0),t.logger.debug=e.verifyInput(t.logger.debug,!1)):t.logger={enabled:!0,debug:!1},this._postMessage()}},t.prototype._postMessage=function(){e.isValid(this.queuedMessage)&&e.isValid(this.worker)&&(this.queuedMessage.data.input instanceof ArrayBuffer?this.worker.postMessage(this.queuedMessage,[this.queuedMessage.data.input]):this.worker.postMessage(this.queuedMessage))},t.prototype.setTerminateRequested=function(t){this.terminateRequested=!0===t,this.terminateRequested&&e.isValid(this.worker)&&!e.isValid(this.queuedMessage)&&this.started&&(this.logger.logInfo("Worker is terminated immediately as it is not running!"),this._terminate())},t.prototype._terminate=function(){this.worker.terminate(),this._reset()},t}();function i(i){if(this.logger=e.verifyInput(i,new r.LoaderSupport.ConsoleLogger),this.logger.logInfo("Using THREE.LoaderSupport.WorkerSupport version: "+t),void 0===window.Worker)throw"This browser does not support web workers!";if(void 0===window.Blob)throw"This browser does not support Blob!";if("function"!=typeof window.URL.createObjectURL)throw"This browser does not support Object creation from URL!";this.loaderWorker=new n(this.logger)}i.prototype.validate=function(t,n,i,s){if(!e.isValid(this.loaderWorker.worker)){this.logger.logInfo("WorkerSupport: Building worker code..."),this.logger.logTimeStart("buildWebWorkerCode"),e.isValid(s)?this.logger.logInfo('WorkerSupport: Using "'+s.name+'" as Runncer class for worker.'):(s=r.LoaderSupport.WorkerRunnerRefImpl,this.logger.logInfo('WorkerSupport: Using DEFAULT "THREE.LoaderSupport.WorkerRunnerRefImpl" as Runncer class for worker.'));var c=t(o,a);c+=a(s.name,s.name,s),c+="new "+s.name+"();\n\n";var u=this;if(e.isValid(n)&&n.length>0){var l="",h=function(t,e){if(0===e.length)u.loaderWorker.initWorker(l+c,u.logger,s.name),u.logger.logTimeEnd("buildWebWorkerCode");else{var n=new r.FileLoader;n.setPath(t),n.setResponseType("text"),n.load(e[0],function(n){l+=n,h(t,e)}),e.shift()}};h(i,n)}else this.loaderWorker.initWorker(c,this.logger,s.name),this.logger.logTimeEnd("buildWebWorkerCode")}},i.prototype.setCallbacks=function(t,e){this.loaderWorker.setCallbacks(t,e)},i.prototype.run=function(t){this.loaderWorker.run(t)},i.prototype.setTerminateRequested=function(t){this.loaderWorker.setTerminateRequested(t)};var o=function(t,e){var n,r=t+" = {\n";for(var i in e)"string"==typeof(n=e[i])||n instanceof String?r+="\t"+i+': "'+(n=(n=n.replace("\n","\\n")).replace("\r","\\r"))+'",\n':n instanceof Array?r+="\t"+i+": ["+n+"],\n":Number.isInteger(n)?r+="\t"+i+": "+n+",\n":"function"==typeof n&&(r+="\t"+i+": "+n+",\n");return r+="}\n\n"},a=function(t,e,n){var r,i=t+" = (function () {\n\n";for(var o in i=(i+="\t"+n.prototype.constructor.toString()+"\n\n").replace(n.name,e),n.prototype)"function"==typeof(r=n.prototype[o])&&(i+="\t"+e+".prototype."+o+" = "+r.toString()+";\n\n");return i+="\treturn "+e+";\n",i+="})();\n\n"};return i}(),r.LoaderSupport.WorkerDirector=function(){var t="2.1.0",e=r.LoaderSupport.Validator,n=16,i=8192;function o(o,a){if(this.logger=e.verifyInput(a,new r.LoaderSupport.ConsoleLogger),this.logger.logInfo("Using THREE.LoaderSupport.WorkerDirector version: "+t),this.maxQueueSize=i,this.maxWebWorkers=n,this.crossOrigin=null,!e.isValid(o))throw"Provided invalid classDef: "+o;this.workerDescription={classDef:o,globalCallbacks:{},workerSupports:{}},this.objectsCompleted=0,this.instructionQueue=[],this.instructionQueuePointer=0,this.callbackOnFinishedProcessing=null}return o.prototype.getMaxQueueSize=function(){return this.maxQueueSize},o.prototype.getMaxWebWorkers=function(){return this.maxWebWorkers},o.prototype.setCrossOrigin=function(t){this.crossOrigin=t},o.prototype.prepareWorkers=function(t,o,a){e.isValid(t)&&(this.workerDescription.globalCallbacks=t),this.maxQueueSize=Math.min(o,i),this.maxWebWorkers=Math.min(a,n),this.maxWebWorkers=Math.min(this.maxWebWorkers,this.maxQueueSize),this.objectsCompleted=0,this.instructionQueue=[],this.instructionQueuePointer=0;for(var s=0;s0&&this.instructionQueuePointer0},o.prototype.processQueue=function(){var t,e;for(var n in this.workerDescription.workerSupports)(e=this.workerDescription.workerSupports[n]).inUse||(this.instructionQueuePointer=0;n--)e=[t[n].apply(this,e)];return e[0]}},each:function(t,e,n){if(t)if(i&&t.forEach&&t.forEach===i)t.forEach(e,n);else if(t.length===t.length+0){var r,o=void 0;for(o=0,r=t.length;o1?a.toArray(arguments):arguments[0];return a.each(s,function(e){if(e.litmus(t))return a.each(e.conversions,function(e,n){if(c=e.read(t),!1===u&&!1!==c)return u=c,c.conversionName=n,c.conversion=e,a.BREAK}),a.BREAK}),u},h=void 0,d={hsv_to_rgb:function(t,e,n){var r=Math.floor(t/60)%6,i=t/60-Math.floor(t/60),o=n*(1-e),a=n*(1-i*e),s=n*(1-(1-i)*e),c=[[n,s,o],[a,n,o],[o,n,s],[o,a,n],[s,o,n],[n,o,a]][r];return{r:255*c[0],g:255*c[1],b:255*c[2]}},rgb_to_hsv:function(t,e,n){var r=Math.min(t,e,n),i=Math.max(t,e,n),o=i-r,a=void 0;return 0===i?{h:NaN,s:0,v:0}:(a=t===i?(e-n)/o:e===i?2+(n-t)/o:4+(t-e)/o,(a/=6)<0&&(a+=1),{h:360*a,s:o/i,v:i/255})},rgb_to_hex:function(t,e,n){var r=this.hex_with_component(0,2,t);return r=this.hex_with_component(r,1,e),r=this.hex_with_component(r,0,n)},component_from_hex:function(t,e){return t>>8*e&255},hex_with_component:function(t,e,n){return n<<(h=8*e)|t&~(255<-1?e.length-e.indexOf(".")-1:0}var P=function(t){function e(t,n,r){f(this,e);var i=y(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),o=r||{};return i.__min=o.min,i.__max=o.max,i.__step=o.step,a.isUndefined(i.__step)?0===i.initialValue?i.__impliedStep=1:i.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(i.initialValue))/Math.LN10))/10:i.__impliedStep=i.__step,i.__precision=C(i.__impliedStep),i}return v(e,w),m(e,[{key:"setValue",value:function(t){var n=t;return void 0!==this.__min&&nthis.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),g(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(t){return this.__min=t,this}},{key:"max",value:function(t){return this.__max=t,this}},{key:"step",value:function(t){return this.__step=t,this.__impliedStep=t,this.__precision=C(t),this}}]),e}();var N=function(t){function e(t,n,r){f(this,e);var i=y(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,r));i.__truncationSuspended=!1;var o=i,s=void 0;function c(){o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function u(t){var e=s-t.clientY;o.setValue(o.getValue()+e*o.__impliedStep),s=t.clientY}function l(){S.unbind(window,"mousemove",u),S.unbind(window,"mouseup",l),c()}return i.__input=document.createElement("input"),i.__input.setAttribute("type","text"),S.bind(i.__input,"change",function(){var t=parseFloat(o.__input.value);a.isNaN(t)||o.setValue(t)}),S.bind(i.__input,"blur",function(){c()}),S.bind(i.__input,"mousedown",function(t){S.bind(window,"mousemove",u),S.bind(window,"mouseup",l),s=t.clientY}),S.bind(i.__input,"keydown",function(t){13===t.keyCode&&(o.__truncationSuspended=!0,this.blur(),o.__truncationSuspended=!1,c())}),i.updateDisplay(),i.domElement.appendChild(i.__input),i}return v(e,P),m(e,[{key:"updateDisplay",value:function(){return this.__input.value=this.__truncationSuspended?this.getValue():function(t,e){var n=Math.pow(10,e);return Math.round(t*n)/n}(this.getValue(),this.__precision),g(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e}();function O(t,e,n,r,i){return r+(t-e)/(n-e)*(i-r)}var I=function(t){function e(t,n,r,i,o){f(this,e);var a=y(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,{min:r,max:i,step:o})),s=a;function c(t){t.preventDefault();var e=s.__background.getBoundingClientRect();return s.setValue(O(t.clientX,e.left,e.right,s.__min,s.__max)),!1}function u(){S.unbind(window,"mousemove",c),S.unbind(window,"mouseup",u),s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}function l(t){var e=t.touches[0].clientX,n=s.__background.getBoundingClientRect();s.setValue(O(e,n.left,n.right,s.__min,s.__max))}function h(){S.unbind(window,"touchmove",l),S.unbind(window,"touchend",h),s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}return a.__background=document.createElement("div"),a.__foreground=document.createElement("div"),S.bind(a.__background,"mousedown",function(t){document.activeElement.blur(),S.bind(window,"mousemove",c),S.bind(window,"mouseup",u),c(t)}),S.bind(a.__background,"touchstart",function(t){if(1!==t.touches.length)return;S.bind(window,"touchmove",l),S.bind(window,"touchend",h),l(t)}),S.addClass(a.__background,"slider"),S.addClass(a.__foreground,"slider-fg"),a.updateDisplay(),a.__background.appendChild(a.__foreground),a.domElement.appendChild(a.__background),a}return v(e,P),m(e,[{key:"updateDisplay",value:function(){var t=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*t+"%",g(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e}(),k=function(t){function e(t,n,r){f(this,e);var i=y(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),o=i;return i.__button=document.createElement("div"),i.__button.innerHTML=void 0===r?"Fire":r,S.bind(i.__button,"click",function(t){return t.preventDefault(),o.fire(),!1}),S.addClass(i.__button,"button"),i.domElement.appendChild(i.__button),i}return v(e,w),m(e,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),e}(),U=function(t){function e(t,n){f(this,e);var r=y(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));r.__color=new b(r.getValue()),r.__temp=new b(0);var i=r;r.domElement=document.createElement("div"),S.makeSelectable(r.domElement,!1),r.__selector=document.createElement("div"),r.__selector.className="selector",r.__saturation_field=document.createElement("div"),r.__saturation_field.className="saturation-field",r.__field_knob=document.createElement("div"),r.__field_knob.className="field-knob",r.__field_knob_border="2px solid ",r.__hue_knob=document.createElement("div"),r.__hue_knob.className="hue-knob",r.__hue_field=document.createElement("div"),r.__hue_field.className="hue-field",r.__input=document.createElement("input"),r.__input.type="text",r.__input_textShadow="0 1px 1px ",S.bind(r.__input,"keydown",function(t){13===t.keyCode&&d.call(this)}),S.bind(r.__input,"blur",d),S.bind(r.__selector,"mousedown",function(){S.addClass(this,"drag").bind(window,"mouseup",function(){S.removeClass(i.__selector,"drag")})}),S.bind(r.__selector,"touchstart",function(){S.addClass(this,"drag").bind(window,"touchend",function(){S.removeClass(i.__selector,"drag")})});var o=document.createElement("div");function s(t){m(t),S.bind(window,"mousemove",m),S.bind(window,"touchmove",m),S.bind(window,"mouseup",u),S.bind(window,"touchend",u)}function c(t){g(t),S.bind(window,"mousemove",g),S.bind(window,"touchmove",g),S.bind(window,"mouseup",h),S.bind(window,"touchend",h)}function u(){S.unbind(window,"mousemove",m),S.unbind(window,"touchmove",m),S.unbind(window,"mouseup",u),S.unbind(window,"touchend",u),p()}function h(){S.unbind(window,"mousemove",g),S.unbind(window,"touchmove",g),S.unbind(window,"mouseup",h),S.unbind(window,"touchend",h),p()}function d(){var t=l(this.value);!1!==t?(i.__color.__state=t,i.setValue(i.__color.toOriginal())):this.value=i.__color.toString()}function p(){i.__onFinishChange&&i.__onFinishChange.call(i,i.__color.toOriginal())}function m(t){-1===t.type.indexOf("touch")&&t.preventDefault();var e=i.__saturation_field.getBoundingClientRect(),n=t.touches&&t.touches[0]||t,r=n.clientX,o=n.clientY,a=(r-e.left)/(e.right-e.left),s=1-(o-e.top)/(e.bottom-e.top);return s>1?s=1:s<0&&(s=0),a>1?a=1:a<0&&(a=0),i.__color.v=s,i.__color.s=a,i.setValue(i.__color.toOriginal()),!1}function g(t){-1===t.type.indexOf("touch")&&t.preventDefault();var e=i.__hue_field.getBoundingClientRect(),n=1-((t.touches&&t.touches[0]||t).clientY-e.top)/(e.bottom-e.top);return n>1?n=1:n<0&&(n=0),i.__color.h=360*n,i.setValue(i.__color.toOriginal()),!1}return a.extend(r.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),a.extend(r.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:r.__field_knob_border+(r.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),a.extend(r.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),a.extend(r.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),a.extend(o.style,{width:"100%",height:"100%",background:"none"}),D(o,"top","rgba(0,0,0,0)","#000"),a.extend(r.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),function(t){t.style.background="",t.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",t.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",t.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",t.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",t.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"}(r.__hue_field),a.extend(r.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:r.__input_textShadow+"rgba(0,0,0,0.7)"}),S.bind(r.__saturation_field,"mousedown",s),S.bind(r.__saturation_field,"touchstart",s),S.bind(r.__field_knob,"mousedown",s),S.bind(r.__field_knob,"touchstart",s),S.bind(r.__hue_field,"mousedown",c),S.bind(r.__hue_field,"touchstart",c),r.__saturation_field.appendChild(o),r.__selector.appendChild(r.__field_knob),r.__selector.appendChild(r.__saturation_field),r.__selector.appendChild(r.__hue_field),r.__hue_field.appendChild(r.__hue_knob),r.domElement.appendChild(r.__input),r.domElement.appendChild(r.__selector),r.updateDisplay(),r}return v(e,w),m(e,[{key:"updateDisplay",value:function(){var t=l(this.getValue());if(!1!==t){var e=!1;a.each(b.COMPONENTS,function(n){if(!a.isUndefined(t[n])&&!a.isUndefined(this.__color.__state[n])&&t[n]!==this.__color.__state[n])return e=!0,{}},this),e&&a.extend(this.__color.__state,t)}a.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,r=255-n;a.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,D(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),a.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+r+","+r+","+r+",.7)"})}}]),e}(),B=["-moz-","-o-","-webkit-","-ms-",""];function D(t,e,n,r){t.style.background="",a.each(B,function(i){t.style.cssText+="background: "+i+"linear-gradient("+e+", "+n+" 0%, "+r+" 100%); "})}var F=function(t,e){var n=e||document,r=document.createElement("style");r.type="text/css",r.innerHTML=t;var i=n.getElementsByTagName("head")[0];try{i.appendChild(r)}catch(t){}},z=function(t,e){var n=t[e];return a.isArray(arguments[2])||a.isObject(arguments[2])?new L(t,e,arguments[2]):a.isNumber(n)?a.isNumber(arguments[2])&&a.isNumber(arguments[3])?a.isNumber(arguments[4])?new I(t,e,arguments[2],arguments[3],arguments[4]):new I(t,e,arguments[2],arguments[3]):a.isNumber(arguments[4])?new N(t,e,{min:arguments[2],max:arguments[3],step:arguments[4]}):new N(t,e,{min:arguments[2],max:arguments[3]}):a.isString(n)?new R(t,e):a.isFunction(n)?new k(t,e,""):a.isBoolean(n)?new A(t,e):null};var G=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){setTimeout(t,1e3/60)},H=function(){function t(){f(this,t),this.backgroundElement=document.createElement("div"),a.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),S.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),a.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var e=this;S.bind(this.backgroundElement,"click",function(){e.hide()})}return m(t,[{key:"show",value:function(){var t=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),a.defer(function(){t.backgroundElement.style.opacity=1,t.domElement.style.opacity=1,t.domElement.style.webkitTransform="scale(1)"})}},{key:"hide",value:function(){var t=this,e=function e(){t.domElement.style.display="none",t.backgroundElement.style.display="none",S.unbind(t.domElement,"webkitTransitionEnd",e),S.unbind(t.domElement,"transitionend",e),S.unbind(t.domElement,"oTransitionEnd",e)};S.bind(this.domElement,"webkitTransitionEnd",e),S.bind(this.domElement,"transitionend",e),S.bind(this.domElement,"oTransitionEnd",e),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-S.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-S.getHeight(this.domElement)/2+"px"}}]),t}();F(function(t){if(t&&"undefined"!=typeof window){var e=document.createElement("style");return e.setAttribute("type","text/css"),e.innerHTML=t,document.head.appendChild(e),t}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n"));var j="Default",V=function(){try{return!!window.localStorage}catch(t){return!1}}(),W=void 0,q=!0,X=void 0,Y=!1,J=[],Z=function t(e){var n=this,r=e||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),S.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],r=a.defaults(r,{closeOnTop:!1,autoPlace:!0,width:t.DEFAULT_WIDTH}),r=a.defaults(r,{resizable:r.autoPlace,hideable:r.autoPlace}),a.isUndefined(r.load)?r.load={preset:j}:r.preset&&(r.load.preset=r.preset),a.isUndefined(r.parent)&&r.hideable&&J.push(this),r.resizable=a.isUndefined(r.parent)&&r.resizable,r.autoPlace&&a.isUndefined(r.scrollable)&&(r.scrollable=!0);var i=V&&"true"===localStorage.getItem(nt(this,"isLocal")),o=void 0,s=void 0;if(Object.defineProperties(this,{parent:{get:function(){return r.parent}},scrollable:{get:function(){return r.scrollable}},autoPlace:{get:function(){return r.autoPlace}},closeOnTop:{get:function(){return r.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:r.load.preset},set:function(t){n.parent?n.getRoot().preset=t:r.load.preset=t,function(t){for(var e=0;e1){var r=n.__li.nextElementSibling;return n.remove(),et(t,n.object,n.property,{before:r,factoryArgs:[a.toArray(arguments)]})}if(a.isArray(e)||a.isObject(e)){var i=n.__li.nextElementSibling;return n.remove(),et(t,n.object,n.property,{before:i,factoryArgs:[e]})}},name:function(t){return n.__li.firstElementChild.firstElementChild.innerHTML=t,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof I){var r=new N(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});a.each(["updateDisplay","onChange","onFinishChange","step","min","max"],function(t){var e=n[t],i=r[t];n[t]=r[t]=function(){var t=Array.prototype.slice.call(arguments);return i.apply(r,t),e.apply(n,t)}}),S.addClass(e,"has-slider"),n.domElement.insertBefore(r.domElement,n.domElement.firstElementChild)}else if(n instanceof N){var i=function(e){if(a.isNumber(n.__min)&&a.isNumber(n.__max)){var r=n.__li.firstElementChild.firstElementChild.innerHTML,i=n.__gui.__listening.indexOf(n)>-1;n.remove();var o=et(t,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return o.name(r),i&&o.listen(),o}return e};n.min=a.compose(i,n.min),n.max=a.compose(i,n.max)}else n instanceof A?(S.bind(e,"click",function(){S.fakeEvent(n.__checkbox,"click")}),S.bind(n.__checkbox,"click",function(t){t.stopPropagation()})):n instanceof k?(S.bind(e,"click",function(){S.fakeEvent(n.__button,"click")}),S.bind(e,"mouseover",function(){S.addClass(n.__button,"hover")}),S.bind(e,"mouseout",function(){S.removeClass(n.__button,"hover")})):n instanceof U&&(S.addClass(e,"color"),n.updateDisplay=a.compose(function(t){return e.style.borderLeftColor=n.__color.toString(),t},n.updateDisplay),n.updateDisplay());n.setValue=a.compose(function(e){return t.getRoot().__preset_select&&n.isModified()&&$(t.getRoot(),!0),e},n.setValue)}(t,u,i),t.__controllers.push(i),i}function nt(t,e){return document.location.href+"."+e}function rt(t,e,n){var r=document.createElement("option");r.innerHTML=e,r.value=e,t.__preset_select.appendChild(r),n&&(t.__preset_select.selectedIndex=t.__preset_select.length-1)}function it(t,e){e.style.display=t.useLocalStorage?"block":"none"}function ot(t){var e=void 0;function n(n){return n.preventDefault(),t.width+=e-n.clientX,t.onResize(),e=n.clientX,!1}function r(){S.removeClass(t.__closeButton,Z.CLASS_DRAG),S.unbind(window,"mousemove",n),S.unbind(window,"mouseup",r)}function i(i){return i.preventDefault(),e=i.clientX,S.addClass(t.__closeButton,Z.CLASS_DRAG),S.bind(window,"mousemove",n),S.bind(window,"mouseup",r),!1}t.__resize_handle=document.createElement("div"),a.extend(t.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),S.bind(t.__resize_handle,"mousedown",i),S.bind(t.__closeButton,"mousedown",i),t.domElement.insertBefore(t.__resize_handle,t.domElement.firstElementChild)}function at(t,e){t.domElement.style.width=e+"px",t.__save_row&&t.autoPlace&&(t.__save_row.style.width=e+"px"),t.__closeButton&&(t.__closeButton.style.width=e+"px")}function st(t,e){var n={};return a.each(t.__rememberedObjects,function(r,i){var o={},s=t.__rememberedObjectIndecesToControllers[i];a.each(s,function(t,n){o[n]=e?t.initialValue:t.getValue()}),n[i]=o}),n}Z.toggleHide=function(){Y=!Y,a.each(J,function(t){t.domElement.style.display=Y?"none":""})},Z.CLASS_AUTO_PLACE="a",Z.CLASS_AUTO_PLACE_CONTAINER="ac",Z.CLASS_MAIN="main",Z.CLASS_CONTROLLER_ROW="cr",Z.CLASS_TOO_TALL="taller-than-window",Z.CLASS_CLOSED="closed",Z.CLASS_CLOSE_BUTTON="close-button",Z.CLASS_CLOSE_TOP="close-top",Z.CLASS_CLOSE_BOTTOM="close-bottom",Z.CLASS_DRAG="drag",Z.DEFAULT_WIDTH=245,Z.TEXT_CLOSED="Close Controls",Z.TEXT_OPEN="Open Controls",Z._keydownHandler=function(t){"text"===document.activeElement.type||72!==t.which&&72!==t.keyCode||Z.toggleHide()},S.bind(window,"keydown",Z._keydownHandler,!1),a.extend(Z.prototype,{add:function(t,e){return et(this,t,e,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(t,e){return et(this,t,e,{color:!0})},remove:function(t){this.__ul.removeChild(t.__li),this.__controllers.splice(this.__controllers.indexOf(t),1);var e=this;a.defer(function(){e.onResize()})},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&X.removeChild(this.domElement);var t=this;a.each(this.__folders,function(e){t.removeFolder(e)}),S.unbind(window,"keydown",Z._keydownHandler,!1),K(this)},addFolder:function(t){if(void 0!==this.__folders[t])throw new Error('You already have a folder in this GUI by the name "'+t+'"');var e={name:t,parent:this};e.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[t]&&(e.closed=this.load.folders[t].closed,e.load=this.load.folders[t]);var n=new Z(e);this.__folders[t]=n;var r=Q(this,n.domElement);return S.addClass(r,"folder"),n},removeFolder:function(t){this.__ul.removeChild(t.domElement.parentElement),delete this.__folders[t.name],this.load&&this.load.folders&&this.load.folders[t.name]&&delete this.load.folders[t.name],K(t);var e=this;a.each(t.__folders,function(e){t.removeFolder(e)}),a.defer(function(){e.onResize()})},open:function(){this.closed=!1},close:function(){this.closed=!0},onResize:function(){var t=this.getRoot();if(t.scrollable){var e=S.getOffset(t.__ul).top,n=0;a.each(t.__ul.childNodes,function(e){t.autoPlace&&e===t.__save_row||(n+=S.getHeight(e))}),window.innerHeight-e-20GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n\n
\n\n
\n\n'),this.parent)throw new Error("You can only call remember on a top level GUI.");var t=this;a.each(Array.prototype.slice.call(arguments),function(e){0===t.__rememberedObjects.length&&function(t){var e=t.__save_row=document.createElement("li");S.addClass(t.domElement,"has-save"),t.__ul.insertBefore(e,t.__ul.firstChild),S.addClass(e,"save-row");var n=document.createElement("span");n.innerHTML=" ",S.addClass(n,"button gears");var r=document.createElement("span");r.innerHTML="Save",S.addClass(r,"button"),S.addClass(r,"save");var i=document.createElement("span");i.innerHTML="New",S.addClass(i,"button"),S.addClass(i,"save-as");var o=document.createElement("span");o.innerHTML="Revert",S.addClass(o,"button"),S.addClass(o,"revert");var s=t.__preset_select=document.createElement("select");t.load&&t.load.remembered?a.each(t.load.remembered,function(e,n){rt(t,n,n===t.preset)}):rt(t,j,!1);if(S.bind(s,"change",function(){for(var e=0;e0&&(t.preset=this.preset,t.remembered||(t.remembered={}),t.remembered[this.preset]=st(this)),t.folders={},a.each(this.__folders,function(e,n){t.folders[n]=e.getSaveObject()}),t},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=st(this),$(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(t){this.load.remembered||(this.load.remembered={},this.load.remembered[j]=st(this,!0)),this.load.remembered[t]=st(this),this.preset=t,rt(this,t,!0),this.saveToLocalStorageIfPossible()},revert:function(t){a.each(this.__controllers,function(e){this.getRoot().load.remembered?tt(t||this.getRoot(),e):e.setValue(e.initialValue),e.__onFinishChange&&e.__onFinishChange.call(e,e.getValue())},this),a.each(this.__folders,function(t){t.revert(t)}),t||$(this.getRoot(),!1)},listen:function(t){var e=0===this.__listening.length;this.__listening.push(t),e&&function t(e){0!==e.length&&G.call(window,function(){t(e)});a.each(e,function(t){t.updateDisplay()})}(this.__listening)},updateDisplay:function(){a.each(this.__controllers,function(t){t.updateDisplay()}),a.each(this.__folders,function(t){t.updateDisplay()})}});var ct={Color:b,math:d,interpret:l},ut={Controller:w,BooleanController:A,OptionController:L,StringController:R,NumberController:P,NumberControllerBox:N,NumberControllerSlider:I,FunctionController:k,ColorController:U},lt={dom:S},ht={GUI:Z},dt=Z,pt={color:ct,controllers:ut,dom:lt,gui:ht,GUI:dt};e.default=pt},function(t,e,n){n(4),n(9),e.codec={preset:n(2).preset}},function(t,e,n){n(4),n(9),e.createCodec=n(2).createCodec},function(t,e,n){e.Decoder=o;var r=n(10),i=n(12).DecodeBuffer;function o(t){if(!(this instanceof o))return new o(t);i.call(this,t)}o.prototype=new i,r.mixin(o.prototype),o.prototype.decode=function(t){arguments.length&&this.write(t),this.flush()},o.prototype.push=function(t){this.emit("data",t)},o.prototype.end=function(t){this.decode(t),this.emit("end")}},function(t,e,n){e.Encoder=o;var r=n(10),i=n(18).EncodeBuffer;function o(t){if(!(this instanceof o))return new o(t);i.call(this,t)}o.prototype=new i,r.mixin(o.prototype),o.prototype.encode=function(t){this.write(t),this.emit("data",this.read())},o.prototype.end=function(t){arguments.length&&this.encode(t),this.flush(),this.emit("end")}},function(t,e,n){var r=n(11);function i(t){var e,n=new Array(256);for(e=0;e<=127;e++)n[e]=o(e);for(e=128;e<=143;e++)n[e]=s(e-128,t.map);for(e=144;e<=159;e++)n[e]=s(e-144,t.array);for(e=160;e<=191;e++)n[e]=s(e-160,t.str);for(n[192]=o(null),n[193]=null,n[194]=o(!1),n[195]=o(!0),n[196]=a(t.uint8,t.bin),n[197]=a(t.uint16,t.bin),n[198]=a(t.uint32,t.bin),n[199]=a(t.uint8,t.ext),n[200]=a(t.uint16,t.ext),n[201]=a(t.uint32,t.ext),n[202]=t.float32,n[203]=t.float64,n[204]=t.uint8,n[205]=t.uint16,n[206]=t.uint32,n[207]=t.uint64,n[208]=t.int8,n[209]=t.int16,n[210]=t.int32,n[211]=t.int64,n[212]=s(1,t.ext),n[213]=s(2,t.ext),n[214]=s(4,t.ext),n[215]=s(8,t.ext),n[216]=s(16,t.ext),n[217]=a(t.uint8,t.str),n[218]=a(t.uint16,t.str),n[219]=a(t.uint32,t.str),n[220]=a(t.uint16,t.array),n[221]=a(t.uint32,t.array),n[222]=a(t.uint16,t.map),n[223]=a(t.uint32,t.map),e=224;e<=255;e++)n[e]=o(e-256);return n}function o(t){return function(){return t}}function a(t,e){return function(n){var r=t(n);return e(n,r)}}function s(t,e){return function(n){return e(n,t)}}e.getReadToken=function(t){var e=r.getReadFormat(t);return t&&t.useraw?function(t){var e,n=i(t).slice();for(n[217]=n[196],n[218]=n[197],n[219]=n[198],e=160;e<=191;e++)n[e]=s(e-160,t.bin);return n}(e):i(e)}},function(t,e,n){e.setExtUnpackers=function(t){t.addExtUnpacker(14,[s,u(Error)]),t.addExtUnpacker(1,[s,u(EvalError)]),t.addExtUnpacker(2,[s,u(RangeError)]),t.addExtUnpacker(3,[s,u(ReferenceError)]),t.addExtUnpacker(4,[s,u(SyntaxError)]),t.addExtUnpacker(5,[s,u(TypeError)]),t.addExtUnpacker(6,[s,u(URIError)]),t.addExtUnpacker(10,[s,c]),t.addExtUnpacker(11,[s,l(Boolean)]),t.addExtUnpacker(12,[s,l(String)]),t.addExtUnpacker(13,[s,l(Date)]),t.addExtUnpacker(15,[s,l(Number)]),"undefined"!=typeof Uint8Array&&(t.addExtUnpacker(17,l(Int8Array)),t.addExtUnpacker(18,l(Uint8Array)),t.addExtUnpacker(19,[h,l(Int16Array)]),t.addExtUnpacker(20,[h,l(Uint16Array)]),t.addExtUnpacker(21,[h,l(Int32Array)]),t.addExtUnpacker(22,[h,l(Uint32Array)]),t.addExtUnpacker(23,[h,l(Float32Array)]),"undefined"!=typeof Float64Array&&t.addExtUnpacker(24,[h,l(Float64Array)]),"undefined"!=typeof Uint8ClampedArray&&t.addExtUnpacker(25,l(Uint8ClampedArray)),t.addExtUnpacker(26,h),t.addExtUnpacker(29,[h,l(DataView)]));i.hasBuffer&&t.addExtUnpacker(27,l(o))};var r,i=n(0),o=i.global,a={name:1,message:1,stack:1,columnNumber:1,fileName:1,lineNumber:1};function s(t){return r||(r=n(13).decode),r(t)}function c(t){return RegExp.apply(null,t)}function u(t){return function(e){var n=new t;for(var r in a)n[r]=e[r];return n}}function l(t){return function(e){return new t(e)}}function h(t){return new Uint8Array(t).buffer}},function(t,e,n){var r=n(7),i=n(5),o=i.Uint64BE,a=i.Int64BE,s=n(15).uint8,c=n(0),u=c.global,l=c.hasBuffer&&"TYPED_ARRAY_SUPPORT"in u&&!u.TYPED_ARRAY_SUPPORT,h=c.hasBuffer&&u.prototype||{};function d(){var t=s.slice();return t[196]=p(196),t[197]=f(197),t[198]=m(198),t[199]=p(199),t[200]=f(200),t[201]=m(201),t[202]=g(202,4,h.writeFloatBE||b,!0),t[203]=g(203,8,h.writeDoubleBE||_,!0),t[204]=p(204),t[205]=f(205),t[206]=m(206),t[207]=g(207,8,v),t[208]=p(208),t[209]=f(209),t[210]=m(210),t[211]=g(211,8,y),t[217]=p(217),t[218]=f(218),t[219]=m(219),t[220]=f(220),t[221]=m(221),t[222]=f(222),t[223]=m(223),t}function p(t){return function(e,n){var r=e.reserve(2),i=e.buffer;i[r++]=t,i[r]=n}}function f(t){return function(e,n){var r=e.reserve(3),i=e.buffer;i[r++]=t,i[r++]=n>>>8,i[r]=n}}function m(t){return function(e,n){var r=e.reserve(5),i=e.buffer;i[r++]=t,i[r++]=n>>>24,i[r++]=n>>>16,i[r++]=n>>>8,i[r]=n}}function g(t,e,n,r){return function(i,o){var a=i.reserve(e+1);i.buffer[a++]=t,n.call(i.buffer,o,a,r)}}function v(t,e){new o(this,e,t)}function y(t,e){new a(this,e,t)}function b(t,e){r.write(this,t,e,!1,23,4)}function _(t,e){r.write(this,t,e,!1,52,8)}e.getWriteToken=function(t){return t&&t.uint8array?function(){var t=d();return t[202]=g(202,4,b),t[203]=g(203,8,_),t}():l||c.hasBuffer&&t&&t.safe?function(){var t=s.slice();return t[196]=g(196,1,u.prototype.writeUInt8),t[197]=g(197,2,u.prototype.writeUInt16BE),t[198]=g(198,4,u.prototype.writeUInt32BE),t[199]=g(199,1,u.prototype.writeUInt8),t[200]=g(200,2,u.prototype.writeUInt16BE),t[201]=g(201,4,u.prototype.writeUInt32BE),t[202]=g(202,4,u.prototype.writeFloatBE),t[203]=g(203,8,u.prototype.writeDoubleBE),t[204]=g(204,1,u.prototype.writeUInt8),t[205]=g(205,2,u.prototype.writeUInt16BE),t[206]=g(206,4,u.prototype.writeUInt32BE),t[207]=g(207,8,v),t[208]=g(208,1,u.prototype.writeInt8),t[209]=g(209,2,u.prototype.writeInt16BE),t[210]=g(210,4,u.prototype.writeInt32BE),t[211]=g(211,8,y),t[217]=g(217,1,u.prototype.writeUInt8),t[218]=g(218,2,u.prototype.writeUInt16BE),t[219]=g(219,4,u.prototype.writeUInt32BE),t[220]=g(220,2,u.prototype.writeUInt16BE),t[221]=g(221,4,u.prototype.writeUInt32BE),t[222]=g(222,2,u.prototype.writeUInt16BE),t[223]=g(223,4,u.prototype.writeUInt32BE),t}():d()}},function(t,e,n){var r=n(3),i=n(5),o=i.Uint64BE,a=i.Int64BE,s=n(0),c=n(6),u=n(37),l=n(15).uint8,h=n(8).ExtBuffer,d="undefined"!=typeof Uint8Array,p="undefined"!=typeof Map,f=[];f[1]=212,f[2]=213,f[4]=214,f[8]=215,f[16]=216,e.getWriteType=function(t){var e=u.getWriteToken(t),n=t&&t.useraw,i=d&&t&&t.binarraybuffer,m=i?s.isArrayBuffer:s.isBuffer,g=i?function(t,e){_(t,new Uint8Array(e))}:_,v=p&&t&&t.usemap?function(t,n){if(!(n instanceof Map))return x(t,n);var r=n.size;e[r<16?128+r:r<=65535?222:223](t,r);var i=t.codec.encode;n.forEach(function(e,n,r){i(t,n),i(t,e)})}:x;return{boolean:function(t,n){e[n?195:194](t,n)},function:b,number:function(t,n){var r,i=0|n;if(n!==i)return void e[r=203](t,n);r=-32<=i&&i<=127?255&i:0<=i?i<=255?204:i<=65535?205:206:-128<=i?208:-32768<=i?209:210;e[r](t,i)},object:n?function(t,n){if(m(n))return function(t,n){var r=n.length;e[r<32?160+r:r<=65535?218:219](t,r),t.send(n)}(t,n);y(t,n)}:y,string:function(t){return function(n,r){var i=r.length,o=5+3*i;n.offset=n.reserve(o);var a=n.buffer,s=t(i),u=n.offset+s;i=c.write.call(a,r,u);var l=t(i);if(s!==l){var h=u+l-s,d=u+i;c.copy.call(a,a,h,u,d)}e[1===l?160+i:l<=3?215+l:219](n,i),n.offset+=i}}(n?function(t){return t<32?1:t<=65535?3:5}:function(t){return t<32?1:t<=255?2:t<=65535?3:5}),symbol:b,undefined:b};function y(t,n){if(null===n)return b(t,n);if(m(n))return g(t,n);if(r(n))return function(t,n){var r=n.length;e[r<16?144+r:r<=65535?220:221](t,r);for(var i=t.codec.encode,o=0;o=0;i--)t[i+e]=this[i+n];else for(i=0;i=65536?(o-=65536,i+=String.fromCharCode(55296+(o>>>10),56320+(1023&o))):i+=String.fromCharCode(o));return i},e.write=function(t,e){var n=e||(e|=0),r=t.length,i=0,o=0;for(;o>>6,this[n++]=128|63&i):i<55296||i>57343?(this[n++]=224|i>>>12,this[n++]=128|i>>>6&63,this[n++]=128|63&i):(i=65536+(i-55296<<10|t.charCodeAt(o++)-56320),this[n++]=240|i>>>18,this[n++]=128|i>>>12&63,this[n++]=128|i>>>6&63,this[n++]=128|63&i);return n-e}},function(t,e,n){var r=n(0);function i(t){return new Uint8Array(t)}(e=t.exports=r.hasArrayBuffer?i(0):[]).alloc=i,e.concat=r.concat,e.from=function(t){if(r.isView(t)){var n=t.byteOffset,i=t.byteLength;(t=t.buffer).byteLength!==i&&(t.slice?t=t.slice(n,n+i):(t=new Uint8Array(t)).byteLength!==i&&(t=Array.prototype.slice.call(t,n,n+i)))}else{if("string"==typeof t)return r.from.call(e,t);if("number"==typeof t)throw new TypeError('"value" argument must not be a number')}return new Uint8Array(t)}},function(t,e,n){var r=n(0),i=r.global;function o(t){return new i(t)}(e=t.exports=r.hasBuffer?o(0):[]).alloc=r.hasBuffer&&i.alloc||o,e.concat=r.concat,e.from=function(t){if(!r.isBuffer(t)&&r.isView(t))t=r.Uint8Array.from(t);else if(r.isArrayBuffer(t))t=new Uint8Array(t);else{if("string"==typeof t)return r.from.call(e,t);if("number"==typeof t)throw new TypeError('"value" argument must not be a number')}return i.from&&1!==i.from.length?i.from(t):new i(t)}},function(t,e,n){var r=n(0);function i(t){return new Array(t)}(e=t.exports=i(0)).alloc=i,e.concat=r.concat,e.from=function(t){if(!r.isBuffer(t)&&r.isView(t))t=r.Uint8Array.from(t);else if(r.isArrayBuffer(t))t=new Uint8Array(t);else{if("string"==typeof t)return r.from.call(e,t);if("number"==typeof t)throw new TypeError('"value" argument must not be a number')}return Array.prototype.slice.call(t)}},function(t,e,n){"use strict";e.byteLength=function(t){var e=u(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){for(var e,n=u(t),r=n[0],a=n[1],s=new o(function(t,e,n){return 3*(e+n)/4-n}(0,r,a)),c=0,l=a>0?r-4:r,h=0;h>16&255,s[c++]=e>>8&255,s[c++]=255&e;2===a&&(e=i[t.charCodeAt(h)]<<2|i[t.charCodeAt(h+1)]>>4,s[c++]=255&e);1===a&&(e=i[t.charCodeAt(h)]<<10|i[t.charCodeAt(h+1)]<<4|i[t.charCodeAt(h+2)]>>2,s[c++]=e>>8&255,s[c++]=255&e);return s},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=0,s=n-i;as?s:a+16383));1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return o.join("")};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,c=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function l(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t]}function h(t,e,n){for(var r,i=[],o=e;oe.width;)r--,n.font=r+"px "+t.font_face;n.fillText(t.text,e.width/2,e.height/2);let i=new THREE.CanvasTexture(e);return i.uuid=t.uuid,i}return null}function handle_special_geometry(t){if("_meshfile"==t.type){if("obj"==t.format){let e=(new THREE.OBJLoader2).parse(t.data+"\n").children[0].geometry;return e.uuid=t.uuid,e}if("dae"==t.format){let e=(new THREE.ColladaLoader).parse(t.data).scene.children[0].geometry;return e.uuid=t.uuid,e}if("stl"==t.format){let e=(new THREE.STLLoader).parse(t.data.buffer);return e.uuid=t.uuid,e}return console.error("Unsupported mesh type:",t),null}return null}__webpack_require__(29),__webpack_require__(28),__webpack_require__(27),__webpack_require__(26),__webpack_require__(25),__webpack_require__(24);class ExtensibleObjectLoader extends THREE.ObjectLoader{delegate(t,e,n,r){let i={};if(void 0===n)return i;let o=[];for(let e of n){let n=t(e);null!==n?i[n.uuid]=n:o.push(e)}return Object.assign(i,e(o,r))}parseTextures(t,e){return this.delegate(handle_special_texture,super.parseTextures,t,e)}parseGeometries(t,e){return this.delegate(handle_special_geometry,super.parseGeometries,t,e)}}class SceneNode{constructor(t,e,n){this.object=t,this.folder=e,this.children={},this.controllers=[],this.on_update=n,this.create_controls();for(let t of this.object.children)this.add_child(t)}add_child(t){let e=this.folder.addFolder(t.name),n=new SceneNode(t,e,this.on_update);return this.children[t.name]=n,n}create_child(t){let e=new THREE.Group;return e.name=t,this.object.add(e),this.add_child(e)}find(t){if(0==t.length)return this;{let e=t[0],n=this.children[e];return void 0===n&&(n=this.create_child(e)),n.find(t.slice(1))}}create_controls(){for(let t of this.controllers)this.folder.remove(t);if(void 0!==this.vis_controller&&this.folder.domElement.removeChild(this.vis_controller.domElement),this.vis_controller=new dat.controllers.BooleanController(this.object,"visible"),this.vis_controller.onChange(()=>this.on_update()),this.folder.domElement.prepend(this.vis_controller.domElement),this.vis_controller.domElement.style.height="0",this.vis_controller.domElement.style.float="right",this.vis_controller.domElement.classList.add("meshcat-visibility-checkbox"),this.vis_controller.domElement.children[0].addEventListener("change",t=>{t.target.checked?this.folder.domElement.classList.remove("meshcat-hidden-scene-element"):this.folder.domElement.classList.add("meshcat-hidden-scene-element")}),this.object.isLight){let t=this.folder.add(this.object,"intensity").min(0).step(.01);if(t.onChange(()=>this.on_update()),this.controllers.push(t),void 0!==this.object.castShadow){let t=this.folder.add(this.object,"castShadow");t.onChange(()=>this.on_update()),this.controllers.push(t)}}if(this.object.isCamera){let t=this.folder.add(this.object,"zoom").min(0).step(.1);t.onChange(()=>{this.on_update()}),this.controllers.push(t)}}set_property(t,e){"position"===t?this.object.position.set(e[0],e[1],e[2]):"quaternion"===t?this.object.quaternion.set(e[0],e[1],e[2],e[3]):"scale"===t?this.object.scale.set(e[0],e[1],e[2]):this.object[t]=e,this.vis_controller.updateDisplay(),this.controllers.forEach(t=>t.updateDisplay())}set_transform(t){let e=new THREE.Matrix4;e.fromArray(t),e.decompose(this.object.position,this.object.quaternion,this.object.scale)}set_object(t){let e=this.object.parent;this.dispose_recursive(),this.object.parent.remove(this.object),this.object=t,e.add(t),this.create_controls()}dispose_recursive(){for(let t of Object.keys(this.children))this.children[t].dispose_recursive();dispose(this.object)}delete(t){if(0==t.length)console.error("Can't delete an empty path");else{let e=this.find(t.slice(0,t.length-1)),n=t[t.length-1],r=e.children[n];void 0!==r&&(r.dispose_recursive(),e.object.remove(r.object),remove_folders(r.folder),e.folder.removeFolder(r.folder),delete e.children[n])}}}function remove_folders(t){for(let e of Object.keys(t.__folders)){let n=t.__folders[e];remove_folders(n),dat.dom.dom.unbind(window,"resize",n.__resizeHandler),t.removeFolder(n)}}function dispose(t){t&&(t.geometry&&t.geometry.dispose(),t.material&&(t.material.map&&t.material.map.dispose(),t.material.dispose()))}function create_default_scene(){var t=new THREE.Scene;return t.name="Scene",t.rotateX(-Math.PI/2),t}function download_data_uri(t,e){let n=document.createElement("a");n.download=t,n.href=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function download_file(t,e,n){n=n||"text/plain";let r=new Blob([e],{type:n}),i=document.createElement("a");document.body.appendChild(i),i.download=t,i.href=window.URL.createObjectURL(r),i.onclick=function(t){let e=this;setTimeout(function(){window.URL.revokeObjectURL(e.href)},1500)},i.click(),i.remove()}class Animator{constructor(t){this.viewer=t,this.folder=this.viewer.gui.addFolder("Animations"),this.mixer=new THREE.AnimationMixer,this.loader=new THREE.ObjectLoader,this.clock=new THREE.Clock,this.actions=[],this.playing=!1,this.setup_capturer("png")}setup_capturer(t){this.capturer=new CCapture({format:t,name:"meshcat_"+String(Date.now())}),this.capturer.format=t}play(){this.clock.start();for(let t of this.actions)t.play();this.playing=!0}record(){this.reset(),this.play(),this.recording=!0,this.capturer.start()}pause(){this.clock.stop(),this.playing=!1,this.recording&&(this.stop_capture(),this.save_capture())}stop_capture(){this.recording=!1,this.capturer.stop(),this.viewer.animate()}save_capture(){this.capturer.save(),"png"===this.capturer.format?alert("To convert the still frames into a video, extract the `.tar` file and run: \nffmpeg -r 60 -i %07d.png \\\n\t -vcodec libx264 \\\n\t -preset slow \\\n\t -crf 18 \\\n\t output.mp4"):"jpg"===this.capturer.format&&alert("To convert the still frames into a video, extract the `.tar` file and run: \nffmpeg -r 60 -i %07d.jpg \\\n\t -vcodec libx264 \\\n\t -preset slow \\\n\t -crf 18 \\\n\t output.mp4")}reset(){for(let t of this.actions)t.reset();this.mixer.update(0),this.setup_capturer(this.capturer.format),this.viewer.set_dirty()}clear(){remove_folders(this.folder),this.mixer.stopAllAction(),this.actions=[],this.mixer=new THREE.AnimationMixer}load(t,e){this.clear(),this.folder.open();let n=this.folder.addFolder("default");n.open(),n.add(this,"play"),n.add(this,"pause"),n.add(this,"reset"),n.add(this.mixer,"timeScale").step(.01).min(0);let r=n.addFolder("Recording");r.add(this,"record"),r.add({format:"png"},"format",["png","jpg"]).onChange(t=>{this.setup_capturer(t)}),void 0===e.play&&(e.play=!0),void 0===e.loopMode&&(e.loopMode=THREE.LoopRepeat),void 0===e.repetitions&&(e.repetitions=1),void 0===e.clampWhenFinished&&(e.clampWhenFinished=!0);for(let n of t){let t=this.viewer.scene_tree.find(n.path).object,r=this.loader.parseAnimations([n.clip])[0],i=this.mixer.clipAction(r,t);i.clampWhenFinished=e.clampWhenFinished,i.setLoop(e.loopMode,e.repetitions),this.actions.push(i)}this.reset(),e.play&&this.play()}update(){if(this.playing&&(this.mixer.update(this.clock.getDelta()),this.viewer.set_dirty(),this.actions.every(t=>t.paused))){this.pause();for(let t of this.actions)t.reset()}}after_render(){this.recording&&this.capturer.capture(this.viewer.renderer.domElement)}}function gradient_texture(t,e){let n=[e,t];var r=new Uint8Array(6);for(let t=0;t<2;t++){let e=n[t];for(let n=0;n<1;n++){let i=3*(1*t+n);for(let t=0;t<3;t++)r[i+t]=e[t]}}var i=new THREE.DataTexture(r,1,2,THREE.RGBFormat);return i.magFilter=THREE.LinearFilter,i.encoding=THREE.LinearEncoding,i.matrixAutoUpdate=!1,i.matrix.set(.5,0,.25,0,.5,.25,0,0,1),i.needsUpdate=!0,i}class Viewer{constructor(t,e){this.dom_element=t,this.renderer=new THREE.WebGLRenderer({antialias:!0,alpha:!0}),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=THREE.PCFSoftShadowMap,this.dom_element.appendChild(this.renderer.domElement),this.scene=create_default_scene(),this.show_background(),this.create_scene_tree(),this.add_default_scene_elements(),this.set_dirty(),this.create_camera(),window.onload=(t=>this.set_3d_pane_size()),window.addEventListener("resize",t=>this.set_3d_pane_size(),!1),requestAnimationFrame(()=>this.set_3d_pane_size()),(e||void 0===e)&&this.animate()}hide_background(){this.scene.background=null,this.set_dirty()}show_background(){this.scene.background=gradient_texture([135,206,250],[25,25,112]),this.set_dirty()}set_dirty(){this.needs_render=!0}create_camera(){let t=new THREE.Matrix4;t.makeRotationX(Math.PI/2),this.set_transform(["Cameras","default","rotated"],t.toArray());let e=new THREE.PerspectiveCamera(75,1,.01,100);this.set_camera(e),this.set_object(["Cameras","default","rotated"],e),e.position.set(3,1,0)}create_default_spot_light(){var t=new THREE.SpotLight(16777215,.8);return t.position.set(1.5,1.5,2),t.castShadow=!1,t.shadow.mapSize.width=1024,t.shadow.mapSize.height=1024,t.shadow.camera.near=.5,t.shadow.camera.far=50,t}add_default_scene_elements(){var t=this.create_default_spot_light();this.set_object(["Lights","SpotLight"],t),this.set_property(["Lights","SpotLight"],"visible",!1);var e=new THREE.DirectionalLight(16777215,.7);e.position.set(1.5,1.5,2),this.set_object(["Lights","DirectionalLight"],e);var n=new THREE.AmbientLight(16777215,.3);this.set_object(["Lights","AmbientLight"],n);var r=new THREE.DirectionalLight(16777215,.4);r.position.set(-10,-10,0),this.set_object(["Lights","FillLight"],r);var i=new THREE.GridHelper(20,40);i.rotateX(Math.PI/2),this.set_object(["Grid"],i);var o=new THREE.AxesHelper(.5);this.set_object(["Axes"],o)}create_scene_tree(){this.gui&&this.gui.destroy(),this.gui=new dat.GUI({autoPlace:!1}),this.dom_element.appendChild(this.gui.domElement),this.gui.domElement.style.position="absolute",this.gui.domElement.style.right=0,this.gui.domElement.style.top=0;let t=this.gui.addFolder("Scene");t.open(),this.scene_tree=new SceneNode(this.scene,t,()=>this.set_dirty());let e=this.gui.addFolder("Save / Load / Capture");e.add(this,"save_scene"),e.add(this,"load_scene"),e.add(this,"save_image");let n=this.gui.addFolder("Background");n.add(this,"hide_background"),n.add(this,"show_background"),this.animator=new Animator(this),this.gui.close()}set_3d_pane_size(t,e){void 0===t&&(t=this.dom_element.offsetWidth),void 0===e&&(e=window.innerHeight),this.camera.aspect=t/e,this.camera.updateProjectionMatrix(),this.renderer.setSize(t,e),this.set_dirty()}render(){this.controls.update(),this.camera.updateProjectionMatrix(),this.renderer.render(this.scene,this.camera),this.animator.after_render(),this.needs_render=!1}animate(){requestAnimationFrame(()=>this.animate()),this.animator.update(),this.needs_render&&this.render()}capture_image(){return this.render(),this.renderer.domElement.toDataURL()}save_image(){download_data_uri("meshcat.png",this.capture_image())}set_camera(t){this.camera=t,this.controls=new THREE.OrbitControls(t,this.dom_element),this.controls.enableKeys=!1,this.controls.addEventListener("start",()=>{this.set_dirty()}),this.controls.addEventListener("change",()=>{this.set_dirty()})}set_camera_from_json(t){(new ExtensibleObjectLoader).parse(t,t=>{this.set_camera(t)})}set_transform(t,e){this.scene_tree.find(t).set_transform(e)}set_object(t,e){this.scene_tree.find(t.concat([""])).set_object(e)}set_object_from_json(t,e){(new ExtensibleObjectLoader).parse(e,e=>{"BufferGeometry"==e.geometry.type&&e.geometry.computeVertexNormals(),e.castShadow=!0,e.receiveShadow=!0,this.set_object(t,e),this.set_dirty()})}delete_path(t){0==t.length?console.error("Deleting the entire scene is not implemented"):this.scene_tree.delete(t)}set_property(t,e,n){this.scene_tree.find(t).set_property(e,n)}set_animation(t,e){e=e||{},this.animator.load(t,e)}set_control(name,callback,value,min,max,step){let handler={};if(void 0!==value){handler[name]=value;let controller=this.gui.add(handler,name,min,max,step);controller.onChange(eval(callback))}else handler[name]=eval(callback),this.gui.add(handler,name)}handle_command(t){if("set_transform"==t.type){let e=split_path(t.path);this.set_transform(e,t.matrix)}else if("delete"==t.type){let e=split_path(t.path);this.delete_path(e)}else if("set_object"==t.type){let e=split_path(t.path);this.set_object_from_json(e,t.object)}else if("set_property"==t.type){let e=split_path(t.path);this.set_property(e,t.property,t.value)}else"set_animation"==t.type?(t.animations.forEach(t=>{t.path=split_path(t.path)}),this.set_animation(t.animations,t.options)):"set_control"==t.type&&this.set_control(t.name,t.callback,t.value,t.min,t.max,t.step);this.set_dirty()}handle_command_message(t){let e=msgpack.decode(new Uint8Array(t.data));this.handle_command(e)}connect(t){void 0===t&&(t=`ws://${location.host}`),console.log(t);let e=new WebSocket(t);e.binaryType="arraybuffer",e.onmessage=(t=>this.handle_command_message(t)),e.onclose=function(t){}}save_scene(){download_file("scene.json",JSON.stringify(this.scene.toJSON()))}load_scene_from_json(t){let e=new ExtensibleObjectLoader;this.scene_tree.dispose_recursive(),this.scene=e.parse(t),this.show_background(),this.create_scene_tree();let n=this.scene_tree.find(["Cameras","default","rotated",""]);n.object.isCamera?this.set_camera(n.object):this.create_camera()}handle_load_file(t){let e=t.files[0];if(!e)return;let n=new FileReader,r=this;n.onload=function(t){let e=this.result,n=JSON.parse(e);r.load_scene_from_json(n)},n.readAsText(e)}load_scene(){let t=document.createElement("input");t.type="file",document.body.appendChild(t);let e=this;t.addEventListener("change",function(){console.log(this,e),e.handle_load_file(this)},!1),t.click(),t.remove()}}function split_path(t){return t.split("/").filter(t=>t.length>0)}let style=document.createElement("style");style.appendChild(document.createTextNode("")),document.head.appendChild(style),style.sheet.insertRule("\n .meshcat-visibility-checkbox > input {\n float: right;\n }"),style.sheet.insertRule("\n .meshcat-hidden-scene-element li .meshcat-visibility-checkbox {\n opacity: 0.25;\n pointer-events: none;\n }"),style.sheet.insertRule("\n .meshcat-visibility-checkbox > input[type=checkbox] {\n height: 16px;\n width: 16px;\n display:inline-block;\n padding: 0 0 0 0px;\n }"),module.exports={Viewer:Viewer,THREE:THREE}}])}); \ No newline at end of file diff --git a/src/index.js b/src/index.js index 3cb913c..f875c37 100644 --- a/src/index.js +++ b/src/index.js @@ -8,6 +8,117 @@ require('imports-loader?THREE=three!./STLLoader.js'); require('imports-loader?THREE=three!./OrbitControls.js'); require('ccapture.js'); +// Handler for special texture types that we want to support +// in addition to whatever three.js supports. This function +// takes a json object representing a single texture, and should +// return either: +// * A new `THREE.Texture` if that json represents a special texture +// * `null` otherwise +function handle_special_texture(json) { + if (json.type == "_text") { + let canvas = document.createElement('canvas'); + // canvas width and height should be in the power of 2; otherwise although + // the page usually loads successfully, WebGL does complain/warn + canvas.width = 256; + canvas.height = 256; + let ctx = canvas.getContext('2d'); + ctx.textAlign = "center"; + let font_size = json.font_size; + // auto-resing the font_size to fit in the canvas + ctx.font = font_size + "px " + json.font_face; + while (ctx.measureText(json.text).width > canvas.width) { + font_size--; + ctx.font = font_size + "px " + json.font_face; + } + ctx.fillText(json.text, canvas.width / 2, canvas.height / 2); + let canvas_texture = new THREE.CanvasTexture(canvas); + canvas_texture.uuid = json.uuid; + return canvas_texture; + } else { + return null; + } +} + +// Handler for special geometry types that we want to support +// in addition to whatever three.js supports. This function +// takes a json object representing a single geometry, and should +// return either: +// * A new `THREE.Mesh` if that json represents a special geometry +// * `null` otherwise +function handle_special_geometry(geom) { + if (geom.type == "_meshfile") { + if (geom.format == "obj") { + let loader = new THREE.OBJLoader2(); + let obj = loader.parse(geom.data + "\n"); + let loaded_geom = obj.children[0].geometry; + loaded_geom.uuid = geom.uuid; + return loaded_geom; + } else if (geom.format == "dae") { + let loader = new THREE.ColladaLoader(); + let obj = loader.parse(geom.data); + let loaded_geom = obj.scene.children[0].geometry; + loaded_geom.uuid = geom.uuid; + return loaded_geom; + } else if (geom.format == "stl") { + let loader = new THREE.STLLoader(); + let loaded_geom = loader.parse(geom.data.buffer); + loaded_geom.uuid = geom.uuid; + return loaded_geom; + } else { + console.error("Unsupported mesh type:", geom); + return null; + } + } else { + return null; + } +} + + +// The ExtensibleObjectLoader extends the THREE.ObjectLoader +// interface, while providing some hooks for us to perform some +// custom loading for things other than three.js native JSON. +// +// We currently use this class to support some extensions to +// three.js JSON for objects which are easy to construct in +// javascript but hard to construct in Python and/or Julia. +// For example, we perform the following transformations: +// +// * Converting "_meshfile" geometries into actual meshes +// using the THREE.js native mesh loaders +// * Converting "_text" textures into text by drawing the +// requested text onto a canvas. +class ExtensibleObjectLoader extends THREE.ObjectLoader { + delegate(special_handler, base_handler, json, additional_objects) { + let result = {}; + if (json === undefined) { + return result; + } + let remaining_json = []; + for (let data of json) { + let x = special_handler(data); + if (x !== null) { + result[x.uuid] = x; + } else { + remaining_json.push(data); + } + } + return Object.assign(result, base_handler(remaining_json, additional_objects)); + } + + parseTextures(json, images) { + return this.delegate(handle_special_texture, + super.parseTextures, + json, images); + } + + parseGeometries(json, shapes) { + return this.delegate(handle_special_geometry, + super.parseGeometries, + json, shapes); + } +} + + class SceneNode { constructor(object, folder, on_update) { this.object = object; @@ -142,14 +253,6 @@ class SceneNode { } } -// function material_gui(gui, material) { -// gui.addColor(material, "color"); -// "reflectivity" in material && gui.add(material, "reflectivity"); -// "transparent" in material && gui.add(material, "transparent"); -// "opacity" in material && gui.add(material, "opacity", 0, 1, 0.01); -// "emissive" in material && gui.addColor(material, "emissive"); -// } - function remove_folders(gui) { for (let name of Object.keys(gui.__folders)) { let folder = gui.__folders[name]; @@ -182,56 +285,22 @@ function create_default_scene() { } -function handle_special_geometry(geom) { - if (geom.type == "_meshfile") { - if (geom.format == "obj") { - let loader = new THREE.OBJLoader2(); - let obj = loader.parse(geom.data + "\n"); - let loaded_geom = obj.children[0].geometry; - loaded_geom.uuid = geom.uuid; - let json = loaded_geom.toJSON(); - for (let child of obj.children) { - dispose(child); - } - return json; - } else if (geom.format == "dae") { - let loader = new THREE.ColladaLoader(); - let obj = loader.parse(geom.data); - - let loaded_geom = obj.scene.children[0].geometry; - loaded_geom.uuid = geom.uuid; - let json = loaded_geom.toJSON(); - return json; - } else if (geom.format == "stl") { - let loader = new THREE.STLLoader(); - let loaded_geom = loader.parse(geom.data.buffer); - - loaded_geom.uuid = geom.uuid; - let json = loaded_geom.toJSON(); - return json; - } else { - console.error("Unsupported mesh type:", geom); - } - } else { - return geom; - } -} - - // https://stackoverflow.com/a/15832662 function download_data_uri(name, uri) { - let link = document.createElement("a"); - link.download = name; - link.href = uri; - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); + let link = document.createElement("a"); + link.download = name; + link.href = uri; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); } // https://stackoverflow.com/a/35251739 function download_file(name, contents, mime) { mime = mime || "text/plain"; - let blob = new Blob([contents], {type: mime}); + let blob = new Blob([contents], { + type: mime + }); let link = document.createElement("a"); document.body.appendChild(link); link.download = name; @@ -341,10 +410,18 @@ class Animator { }); - if (options.play === undefined) {options.play = true} - if (options.loopMode === undefined) {options.loopMode = THREE.LoopRepeat} - if (options.repetitions === undefined) {options.repetitions = 1} - if (options.clampWhenFinished === undefined) {options.clampWhenFinished = true} + if (options.play === undefined) { + options.play = true + } + if (options.loopMode === undefined) { + options.loopMode = THREE.LoopRepeat + } + if (options.repetitions === undefined) { + options.repetitions = 1 + } + if (options.clampWhenFinished === undefined) { + options.clampWhenFinished = true + } for (let animation of animations) { let target = this.viewer.scene_tree.find(animation.path).object; @@ -392,17 +469,17 @@ function gradient_texture(top_color, bottom_color) { let width = 1; let height = 2; let size = width * height; - var data = new Uint8Array( 3 * size ); - for (let row=0; row < height; row++) { + var data = new Uint8Array(3 * size); + for (let row = 0; row < height; row++) { let color = colors[row]; - for (let col=0; col < width; col++) { + for (let col = 0; col < width; col++) { let i = 3 * (row * width + col); - for (let j=0; j < 3; j++) { + for (let j = 0; j < 3; j++) { data[i + j] = color[j]; } } } - var texture = new THREE.DataTexture( data, width, height, THREE.RGBFormat); + var texture = new THREE.DataTexture(data, width, height, THREE.RGBFormat); texture.magFilter = THREE.LinearFilter; texture.encoding = THREE.LinearEncoding; // By default, the points in our texture map to the center of @@ -411,8 +488,8 @@ function gradient_texture(top_color, bottom_color) { // to tweak the UV transform matrix texture.matrixAutoUpdate = false; texture.matrix.set(0.5, 0, 0.25, - 0, 0.5, 0.25, - 0, 0, 1); + 0, 0.5, 0.25, + 0, 0, 1); texture.needsUpdate = true return texture; } @@ -451,8 +528,8 @@ class Viewer { } show_background() { - let top_color = [135,206,250]; // lightskyblue - let bottom_color = [25,25,112]; // midnightblue + let top_color = [135, 206, 250]; // lightskyblue + let bottom_color = [25, 25, 112]; // midnightblue this.scene.background = gradient_texture(top_color, bottom_color); this.set_dirty(); } @@ -519,7 +596,9 @@ class Viewer { if (this.gui) { this.gui.destroy(); } - this.gui = new dat.GUI({autoPlace: false}); + this.gui = new dat.GUI({ + autoPlace: false + }); this.dom_element.appendChild(this.gui.domElement); this.gui.domElement.style.position = "absolute"; this.gui.domElement.style.right = 0; @@ -580,14 +659,17 @@ class Viewer { this.camera = obj; this.controls = new THREE.OrbitControls(obj, this.dom_element); this.controls.enableKeys = false; - this.controls.addEventListener('start', () => {this.set_dirty()}); - this.controls.addEventListener('change', () => {this.set_dirty()}); + this.controls.addEventListener('start', () => { + this.set_dirty() + }); + this.controls.addEventListener('change', () => { + this.set_dirty() + }); } set_camera_from_json(data) { - let loader = new THREE.ObjectLoader(); + let loader = new ExtensibleObjectLoader(); loader.parse(data, (obj) => { - console.log(obj); this.set_camera(obj); }); } @@ -601,17 +683,13 @@ class Viewer { } set_object_from_json(path, object_json) { - object_json.geometries = object_json.geometries.map(handle_special_geometry); - let loader = new THREE.ObjectLoader(); + let loader = new ExtensibleObjectLoader(); loader.parse(object_json, (obj) => { if (obj.geometry.type == "BufferGeometry") { obj.geometry.computeVertexNormals(); } obj.castShadow = true; obj.receiveShadow = true; - // if (obj.name === "") { - // obj.name = ""; - // } this.set_object(path, obj); this.set_dirty(); }); @@ -686,7 +764,7 @@ class Viewer { let connection = new WebSocket(url); connection.binaryType = "arraybuffer"; connection.onmessage = (msg) => this.handle_command_message(msg); - connection.onclose = function (evt) { + connection.onclose = function(evt) { // TODO: start trying to reconnect } } @@ -696,7 +774,7 @@ class Viewer { } load_scene_from_json(json) { - let loader = new THREE.ObjectLoader(); + let loader = new ExtensibleObjectLoader(); this.scene_tree.dispose_recursive(); this.scene = loader.parse(json); this.show_background(); @@ -768,6 +846,6 @@ style.sheet.insertRule(` module.exports = { - Viewer: Viewer, + Viewer: Viewer, THREE: THREE -}; +}; \ No newline at end of file