tinyforms/public/of-dice.js

2 lines
685 KiB
JavaScript

/*! For license information please see index.js.LICENSE.txt */
!function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},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=3)}([function(t,e,n){"use strict";function i(){}n.r(e),n.d(e,"WebGLRenderTargetCube",(function(){return tn})),n.d(e,"WebGLRenderTarget",(function(){return $e})),n.d(e,"WebGLRenderer",(function(){return Qr})),n.d(e,"ShaderLib",(function(){return Yn})),n.d(e,"UniformsLib",(function(){return Wn})),n.d(e,"UniformsUtils",(function(){return qn})),n.d(e,"ShaderChunk",(function(){return Xn})),n.d(e,"FogExp2",(function(){return Kr})),n.d(e,"Fog",(function(){return $r})),n.d(e,"Scene",(function(){return to})),n.d(e,"Sprite",(function(){return no})),n.d(e,"LOD",(function(){return io})),n.d(e,"SkinnedMesh",(function(){return ao})),n.d(e,"Skeleton",(function(){return ro})),n.d(e,"Bone",(function(){return oo})),n.d(e,"Mesh",(function(){return rr})),n.d(e,"LineSegments",(function(){return ho})),n.d(e,"LineLoop",(function(){return lo})),n.d(e,"Line",(function(){return co})),n.d(e,"Points",(function(){return po})),n.d(e,"Group",(function(){return fo})),n.d(e,"VideoTexture",(function(){return mo})),n.d(e,"DataTexture",(function(){return en})),n.d(e,"CompressedTexture",(function(){return vo})),n.d(e,"CubeTexture",(function(){return nn})),n.d(e,"CanvasTexture",(function(){return Zn})),n.d(e,"DepthTexture",(function(){return go})),n.d(e,"Texture",(function(){return Qe})),n.d(e,"CompressedTextureLoader",(function(){return ka})),n.d(e,"DataTextureLoader",(function(){return Wa})),n.d(e,"CubeTextureLoader",(function(){return Xa})),n.d(e,"TextureLoader",(function(){return Ya})),n.d(e,"ObjectLoader",(function(){return Ks})),n.d(e,"MaterialLoader",(function(){return Hs})),n.d(e,"BufferGeometryLoader",(function(){return js})),n.d(e,"DefaultLoadingManager",(function(){return Ga})),n.d(e,"LoadingManager",(function(){return Va})),n.d(e,"JSONLoader",(function(){return Qs})),n.d(e,"ImageLoader",(function(){return qa})),n.d(e,"ImageBitmapLoader",(function(){return ic})),n.d(e,"FontLoader",(function(){return sc})),n.d(e,"FileLoader",(function(){return ja})),n.d(e,"Loader",(function(){return Zs})),n.d(e,"LoaderUtils",(function(){return Js})),n.d(e,"Cache",(function(){return Ua})),n.d(e,"AudioLoader",(function(){return xc})),n.d(e,"SpotLightShadow",(function(){return bs})),n.d(e,"SpotLight",(function(){return _s})),n.d(e,"PointLight",(function(){return Ms})),n.d(e,"RectAreaLight",(function(){return As})),n.d(e,"HemisphereLight",(function(){return xs})),n.d(e,"DirectionalLightShadow",(function(){return Es})),n.d(e,"DirectionalLight",(function(){return Ss})),n.d(e,"AmbientLight",(function(){return Ts})),n.d(e,"LightShadow",(function(){return ws})),n.d(e,"Light",(function(){return ys})),n.d(e,"StereoCamera",(function(){return wc})),n.d(e,"PerspectiveCamera",(function(){return Br})),n.d(e,"OrthographicCamera",(function(){return Mi})),n.d(e,"CubeCamera",(function(){return bc})),n.d(e,"ArrayCamera",(function(){return Ir})),n.d(e,"Camera",(function(){return _i})),n.d(e,"AudioListener",(function(){return _c})),n.d(e,"PositionalAudio",(function(){return Ec})),n.d(e,"AudioContext",(function(){return yc})),n.d(e,"AudioAnalyser",(function(){return Sc})),n.d(e,"Audio",(function(){return Mc})),n.d(e,"VectorKeyframeTrack",(function(){return Vs})),n.d(e,"StringKeyframeTrack",(function(){return Rs})),n.d(e,"QuaternionKeyframeTrack",(function(){return Bs})),n.d(e,"NumberKeyframeTrack",(function(){return Ns})),n.d(e,"ColorKeyframeTrack",(function(){return Is})),n.d(e,"BooleanKeyframeTrack",(function(){return Cs})),n.d(e,"PropertyMixer",(function(){return Tc})),n.d(e,"PropertyBinding",(function(){return Vc})),n.d(e,"KeyframeTrack",(function(){return Us})),n.d(e,"AnimationUtils",(function(){return Ds})),n.d(e,"AnimationObjectGroup",(function(){return Gc})),n.d(e,"AnimationMixer",(function(){return jc})),n.d(e,"AnimationClip",(function(){return Gs})),n.d(e,"Uniform",(function(){return kc})),n.d(e,"InstancedBufferGeometry",(function(){return Wc})),n.d(e,"BufferGeometry",(function(){return Yi})),n.d(e,"Geometry",(function(){return Ai})),n.d(e,"InterleavedBufferAttribute",(function(){return qc})),n.d(e,"InstancedInterleavedBuffer",(function(){return Yc})),n.d(e,"InterleavedBuffer",(function(){return Xc})),n.d(e,"InstancedBufferAttribute",(function(){return Zc})),n.d(e,"Face3",(function(){return Ei})),n.d(e,"Object3D",(function(){return bi})),n.d(e,"Raycaster",(function(){return Jc})),n.d(e,"Layers",(function(){return mi})),n.d(e,"EventDispatcher",(function(){return i})),n.d(e,"Clock",(function(){return $c})),n.d(e,"QuaternionLinearInterpolant",(function(){return Ps})),n.d(e,"LinearInterpolant",(function(){return Fs})),n.d(e,"DiscreteInterpolant",(function(){return zs})),n.d(e,"CubicInterpolant",(function(){return Os})),n.d(e,"Interpolant",(function(){return Ls})),n.d(e,"Triangle",(function(){return ir})),n.d(e,"Math",(function(){return ke})),n.d(e,"Spherical",(function(){return th})),n.d(e,"Cylindrical",(function(){return eh})),n.d(e,"Plane",(function(){return li})),n.d(e,"Frustum",(function(){return ui})),n.d(e,"Sphere",(function(){return hi})),n.d(e,"Ray",(function(){return er})),n.d(e,"Matrix4",(function(){return qe})),n.d(e,"Matrix3",(function(){return Ze})),n.d(e,"Box3",(function(){return ci})),n.d(e,"Box2",(function(){return nh})),n.d(e,"Line3",(function(){return nr})),n.d(e,"Euler",(function(){return fi})),n.d(e,"Vector4",(function(){return Ke})),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 kn})),n.d(e,"ImmediateRenderObject",(function(){return ih})),n.d(e,"VertexNormalsHelper",(function(){return rh})),n.d(e,"SpotLightHelper",(function(){return oh})),n.d(e,"SkeletonHelper",(function(){return ah})),n.d(e,"PointLightHelper",(function(){return sh})),n.d(e,"RectAreaLightHelper",(function(){return ch})),n.d(e,"HemisphereLightHelper",(function(){return hh})),n.d(e,"GridHelper",(function(){return lh})),n.d(e,"PolarGridHelper",(function(){return uh})),n.d(e,"FaceNormalsHelper",(function(){return ph})),n.d(e,"DirectionalLightHelper",(function(){return dh})),n.d(e,"CameraHelper",(function(){return fh})),n.d(e,"BoxHelper",(function(){return mh})),n.d(e,"Box3Helper",(function(){return vh})),n.d(e,"PlaneHelper",(function(){return gh})),n.d(e,"ArrowHelper",(function(){return yh})),n.d(e,"AxesHelper",(function(){return xh})),n.d(e,"Shape",(function(){return gs})),n.d(e,"Path",(function(){return vs})),n.d(e,"ShapePath",(function(){return rc})),n.d(e,"Font",(function(){return oc})),n.d(e,"CurvePath",(function(){return ms})),n.d(e,"Curve",(function(){return Za})),n.d(e,"ShapeUtils",(function(){return oa})),n.d(e,"WebGLUtils",(function(){return zr})),n.d(e,"WireframeGeometry",(function(){return yo})),n.d(e,"ParametricGeometry",(function(){return xo})),n.d(e,"ParametricBufferGeometry",(function(){return wo})),n.d(e,"TetrahedronGeometry",(function(){return Mo})),n.d(e,"TetrahedronBufferGeometry",(function(){return Eo})),n.d(e,"OctahedronGeometry",(function(){return So})),n.d(e,"OctahedronBufferGeometry",(function(){return To})),n.d(e,"IcosahedronGeometry",(function(){return Ao})),n.d(e,"IcosahedronBufferGeometry",(function(){return Ro})),n.d(e,"DodecahedronGeometry",(function(){return Co})),n.d(e,"DodecahedronBufferGeometry",(function(){return Lo})),n.d(e,"PolyhedronGeometry",(function(){return bo})),n.d(e,"PolyhedronBufferGeometry",(function(){return _o})),n.d(e,"TubeGeometry",(function(){return Po})),n.d(e,"TubeBufferGeometry",(function(){return Bo})),n.d(e,"TorusKnotGeometry",(function(){return Io})),n.d(e,"TorusKnotBufferGeometry",(function(){return No})),n.d(e,"TorusGeometry",(function(){return Oo})),n.d(e,"TorusBufferGeometry",(function(){return Fo})),n.d(e,"TextGeometry",(function(){return la})),n.d(e,"TextBufferGeometry",(function(){return ua})),n.d(e,"SphereGeometry",(function(){return pa})),n.d(e,"SphereBufferGeometry",(function(){return da})),n.d(e,"RingGeometry",(function(){return fa})),n.d(e,"RingBufferGeometry",(function(){return ma})),n.d(e,"PlaneGeometry",(function(){return Qi})),n.d(e,"PlaneBufferGeometry",(function(){return Ki})),n.d(e,"LatheGeometry",(function(){return va})),n.d(e,"LatheBufferGeometry",(function(){return ga})),n.d(e,"ShapeGeometry",(function(){return ya})),n.d(e,"ShapeBufferGeometry",(function(){return xa})),n.d(e,"ExtrudeGeometry",(function(){return ca})),n.d(e,"ExtrudeBufferGeometry",(function(){return ha})),n.d(e,"EdgesGeometry",(function(){return ba})),n.d(e,"ConeGeometry",(function(){return Ea})),n.d(e,"ConeBufferGeometry",(function(){return Sa})),n.d(e,"CylinderGeometry",(function(){return _a})),n.d(e,"CylinderBufferGeometry",(function(){return Ma})),n.d(e,"CircleGeometry",(function(){return Ta})),n.d(e,"CircleBufferGeometry",(function(){return Aa})),n.d(e,"BoxGeometry",(function(){return Zi})),n.d(e,"BoxBufferGeometry",(function(){return Ji})),n.d(e,"ShadowMaterial",(function(){return Ca})),n.d(e,"SpriteMaterial",(function(){return eo})),n.d(e,"RawShaderMaterial",(function(){return La})),n.d(e,"ShaderMaterial",(function(){return tr})),n.d(e,"PointsMaterial",(function(){return uo})),n.d(e,"MeshPhysicalMaterial",(function(){return Ba})),n.d(e,"MeshStandardMaterial",(function(){return Pa})),n.d(e,"MeshPhongMaterial",(function(){return Ia})),n.d(e,"MeshToonMaterial",(function(){return Na})),n.d(e,"MeshNormalMaterial",(function(){return Oa})),n.d(e,"MeshLambertMaterial",(function(){return Fa})),n.d(e,"MeshDepthMaterial",(function(){return ai})),n.d(e,"MeshDistanceMaterial",(function(){return si})),n.d(e,"MeshBasicMaterial",(function(){return $i})),n.d(e,"LineDashedMaterial",(function(){return za})),n.d(e,"LineBasicMaterial",(function(){return so})),n.d(e,"Material",(function(){return oi})),n.d(e,"Float64BufferAttribute",(function(){return zi})),n.d(e,"Float32BufferAttribute",(function(){return Fi})),n.d(e,"Uint32BufferAttribute",(function(){return Oi})),n.d(e,"Int32BufferAttribute",(function(){return Ni})),n.d(e,"Uint16BufferAttribute",(function(){return Ii})),n.d(e,"Int16BufferAttribute",(function(){return Bi})),n.d(e,"Uint8ClampedBufferAttribute",(function(){return Pi})),n.d(e,"Uint8BufferAttribute",(function(){return Li})),n.d(e,"Int8BufferAttribute",(function(){return Ci})),n.d(e,"BufferAttribute",(function(){return Ri})),n.d(e,"ArcCurve",(function(){return Qa})),n.d(e,"CatmullRomCurve3",(function(){return is})),n.d(e,"CubicBezierCurve",(function(){return ss})),n.d(e,"CubicBezierCurve3",(function(){return cs})),n.d(e,"EllipseCurve",(function(){return Ja})),n.d(e,"LineCurve",(function(){return hs})),n.d(e,"LineCurve3",(function(){return ls})),n.d(e,"QuadraticBezierCurve",(function(){return us})),n.d(e,"QuadraticBezierCurve3",(function(){return ps})),n.d(e,"SplineCurve",(function(){return ds})),n.d(e,"REVISION",(function(){return d})),n.d(e,"MOUSE",(function(){return f})),n.d(e,"CullFaceNone",(function(){return m})),n.d(e,"CullFaceBack",(function(){return v})),n.d(e,"CullFaceFront",(function(){return g})),n.d(e,"CullFaceFrontBack",(function(){return y})),n.d(e,"FrontFaceDirectionCW",(function(){return x})),n.d(e,"FrontFaceDirectionCCW",(function(){return w})),n.d(e,"BasicShadowMap",(function(){return b})),n.d(e,"PCFShadowMap",(function(){return _})),n.d(e,"PCFSoftShadowMap",(function(){return M})),n.d(e,"FrontSide",(function(){return E})),n.d(e,"BackSide",(function(){return S})),n.d(e,"DoubleSide",(function(){return T})),n.d(e,"FlatShading",(function(){return A})),n.d(e,"SmoothShading",(function(){return R})),n.d(e,"NoColors",(function(){return C})),n.d(e,"FaceColors",(function(){return L})),n.d(e,"VertexColors",(function(){return P})),n.d(e,"NoBlending",(function(){return B})),n.d(e,"NormalBlending",(function(){return I})),n.d(e,"AdditiveBlending",(function(){return N})),n.d(e,"SubtractiveBlending",(function(){return O})),n.d(e,"MultiplyBlending",(function(){return F})),n.d(e,"CustomBlending",(function(){return z})),n.d(e,"AddEquation",(function(){return D})),n.d(e,"SubtractEquation",(function(){return U})),n.d(e,"ReverseSubtractEquation",(function(){return V})),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 k})),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 Z})),n.d(e,"OneMinusDstAlphaFactor",(function(){return J})),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 it})),n.d(e,"EqualDepth",(function(){return rt})),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 ht})),n.d(e,"AddOperation",(function(){return lt})),n.d(e,"NoToneMapping",(function(){return ut})),n.d(e,"LinearToneMapping",(function(){return pt})),n.d(e,"ReinhardToneMapping",(function(){return dt})),n.d(e,"Uncharted2ToneMapping",(function(){return ft})),n.d(e,"CineonToneMapping",(function(){return mt})),n.d(e,"UVMapping",(function(){return vt})),n.d(e,"CubeReflectionMapping",(function(){return gt})),n.d(e,"CubeRefractionMapping",(function(){return yt})),n.d(e,"EquirectangularReflectionMapping",(function(){return xt})),n.d(e,"EquirectangularRefractionMapping",(function(){return wt})),n.d(e,"SphericalReflectionMapping",(function(){return bt})),n.d(e,"CubeUVReflectionMapping",(function(){return _t})),n.d(e,"CubeUVRefractionMapping",(function(){return Mt})),n.d(e,"RepeatWrapping",(function(){return Et})),n.d(e,"ClampToEdgeWrapping",(function(){return St})),n.d(e,"MirroredRepeatWrapping",(function(){return Tt})),n.d(e,"NearestFilter",(function(){return At})),n.d(e,"NearestMipMapNearestFilter",(function(){return Rt})),n.d(e,"NearestMipMapLinearFilter",(function(){return Ct})),n.d(e,"LinearFilter",(function(){return Lt})),n.d(e,"LinearMipMapNearestFilter",(function(){return Pt})),n.d(e,"LinearMipMapLinearFilter",(function(){return Bt})),n.d(e,"UnsignedByteType",(function(){return It})),n.d(e,"ByteType",(function(){return Nt})),n.d(e,"ShortType",(function(){return Ot})),n.d(e,"UnsignedShortType",(function(){return Ft})),n.d(e,"IntType",(function(){return zt})),n.d(e,"UnsignedIntType",(function(){return Dt})),n.d(e,"FloatType",(function(){return Ut})),n.d(e,"HalfFloatType",(function(){return Vt})),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 kt})),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 Zt})),n.d(e,"RGBEFormat",(function(){return Jt})),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 ie})),n.d(e,"RGB_PVRTC_2BPPV1_Format",(function(){return re})),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 he})),n.d(e,"RGBA_ASTC_5x5_Format",(function(){return le})),n.d(e,"RGBA_ASTC_6x5_Format",(function(){return ue})),n.d(e,"RGBA_ASTC_6x6_Format",(function(){return pe})),n.d(e,"RGBA_ASTC_8x5_Format",(function(){return de})),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 ve})),n.d(e,"RGBA_ASTC_10x6_Format",(function(){return ge})),n.d(e,"RGBA_ASTC_10x8_Format",(function(){return ye})),n.d(e,"RGBA_ASTC_10x10_Format",(function(){return xe})),n.d(e,"RGBA_ASTC_12x10_Format",(function(){return we})),n.d(e,"RGBA_ASTC_12x12_Format",(function(){return be})),n.d(e,"LoopOnce",(function(){return _e})),n.d(e,"LoopRepeat",(function(){return Me})),n.d(e,"LoopPingPong",(function(){return Ee})),n.d(e,"InterpolateDiscrete",(function(){return Se})),n.d(e,"InterpolateLinear",(function(){return Te})),n.d(e,"InterpolateSmooth",(function(){return Ae})),n.d(e,"ZeroCurvatureEnding",(function(){return Re})),n.d(e,"ZeroSlopeEnding",(function(){return Ce})),n.d(e,"WrapAroundEnding",(function(){return Le})),n.d(e,"TrianglesDrawMode",(function(){return Pe})),n.d(e,"TriangleStripDrawMode",(function(){return Be})),n.d(e,"TriangleFanDrawMode",(function(){return Ie})),n.d(e,"LinearEncoding",(function(){return Ne})),n.d(e,"sRGBEncoding",(function(){return Oe})),n.d(e,"GammaEncoding",(function(){return Fe})),n.d(e,"RGBEEncoding",(function(){return ze})),n.d(e,"LogLuvEncoding",(function(){return De})),n.d(e,"RGBM7Encoding",(function(){return Ue})),n.d(e,"RGBM16Encoding",(function(){return Ve})),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 Zi})),n.d(e,"Face4",(function(){return wh})),n.d(e,"LineStrip",(function(){return bh})),n.d(e,"LinePieces",(function(){return _h})),n.d(e,"MeshFaceMaterial",(function(){return Mh})),n.d(e,"MultiMaterial",(function(){return Eh})),n.d(e,"PointCloud",(function(){return Sh})),n.d(e,"Particle",(function(){return Th})),n.d(e,"ParticleSystem",(function(){return Ah})),n.d(e,"PointCloudMaterial",(function(){return Rh})),n.d(e,"ParticleBasicMaterial",(function(){return Ch})),n.d(e,"ParticleSystemMaterial",(function(){return Lh})),n.d(e,"Vertex",(function(){return Ph})),n.d(e,"DynamicBufferAttribute",(function(){return Bh})),n.d(e,"Int8Attribute",(function(){return Ih})),n.d(e,"Uint8Attribute",(function(){return Nh})),n.d(e,"Uint8ClampedAttribute",(function(){return Oh})),n.d(e,"Int16Attribute",(function(){return Fh})),n.d(e,"Uint16Attribute",(function(){return zh})),n.d(e,"Int32Attribute",(function(){return Dh})),n.d(e,"Uint32Attribute",(function(){return Uh})),n.d(e,"Float32Attribute",(function(){return Vh})),n.d(e,"Float64Attribute",(function(){return Gh})),n.d(e,"ClosedSplineCurve3",(function(){return Hh})),n.d(e,"SplineCurve3",(function(){return jh})),n.d(e,"Spline",(function(){return kh})),n.d(e,"AxisHelper",(function(){return Wh})),n.d(e,"BoundingBoxHelper",(function(){return qh})),n.d(e,"EdgesHelper",(function(){return Xh})),n.d(e,"WireframeHelper",(function(){return Yh})),n.d(e,"XHRLoader",(function(){return Zh})),n.d(e,"BinaryTextureLoader",(function(){return Jh})),n.d(e,"GeometryUtils",(function(){return Qh})),n.d(e,"ImageUtils",(function(){return Kh})),n.d(e,"Projector",(function(){return $h})),n.d(e,"CanvasRenderer",(function(){return tl})),n.d(e,"SceneUtils",(function(){return el})),n.d(e,"LensFlare",(function(){return nl})),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(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var i=arguments[n];if(null!=i)for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}),Object.assign(i.prototype,{addEventListener:function(t,e){void 0===this._listeners&&(this._listeners={});var n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)},hasEventListener:function(t,e){if(void 0===this._listeners)return!1;var n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)},removeEventListener:function(t,e){if(void 0!==this._listeners){var n=this._listeners[t];if(void 0!==n){var i=n.indexOf(e);-1!==i&&n.splice(i,1)}}},dispatchEvent:function(t){if(void 0!==this._listeners){var e=this._listeners[t.type];if(void 0!==e){t.target=this;for(var n=e.slice(0),i=0,r=n.length;i<r;i++)n[i].call(this,t)}}}});var r,o,a,s,c,h,l,u,p,d="90",f={LEFT:0,MIDDLE:1,RIGHT:2},m=0,v=1,g=2,y=3,x=0,w=1,b=0,_=1,M=2,E=0,S=1,T=2,A=1,R=2,C=0,L=1,P=2,B=0,I=1,N=2,O=3,F=4,z=5,D=100,U=101,V=102,G=103,H=104,j=200,k=201,W=202,q=203,X=204,Y=205,Z=206,J=207,Q=208,K=209,$=210,tt=0,et=1,nt=2,it=3,rt=4,ot=5,at=6,st=7,ct=0,ht=1,lt=2,ut=0,pt=1,dt=2,ft=3,mt=4,vt=300,gt=301,yt=302,xt=303,wt=304,bt=305,_t=306,Mt=307,Et=1e3,St=1001,Tt=1002,At=1003,Rt=1004,Ct=1005,Lt=1006,Pt=1007,Bt=1008,It=1009,Nt=1010,Ot=1011,Ft=1012,zt=1013,Dt=1014,Ut=1015,Vt=1016,Gt=1017,Ht=1018,jt=1019,kt=1020,Wt=1021,qt=1022,Xt=1023,Yt=1024,Zt=1025,Jt=Xt,Qt=1026,Kt=1027,$t=33776,te=33777,ee=33778,ne=33779,ie=35840,re=35841,oe=35842,ae=35843,se=36196,ce=37808,he=37809,le=37810,ue=37811,pe=37812,de=37813,fe=37814,me=37815,ve=37816,ge=37817,ye=37818,xe=37819,we=37820,be=37821,_e=2200,Me=2201,Ee=2202,Se=2300,Te=2301,Ae=2302,Re=2400,Ce=2401,Le=2402,Pe=0,Be=1,Ie=2,Ne=3e3,Oe=3001,Fe=3007,ze=3002,De=3003,Ue=3004,Ve=3005,Ge=3006,He=3200,je=3201,ke={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){for(var t=[],e=0;e<256;e++)t[e]=(e<16?"0":"")+e.toString(16).toUpperCase();return function(){var e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return t[255&e]+t[e>>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&i|128]+t[i>>8&255]+"-"+t[i>>16&255]+t[i>>24&255]+t[255&r]+t[r>>8&255]+t[r>>16&255]+t[r>>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,i,r){return i+(t-e)*(r-i)/(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 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,i){this._x=t||0,this._y=e||0,this._z=n||0,this._w=void 0!==i?i:1}function Ye(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(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,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[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:(r=new We,o=new We,function(t,e){return r.set(t,t),o.set(e,e),this.clamp(r,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),i=Math.sin(e),r=this.x-t.x,o=this.y-t.y;return this.x=r*n-o*i+t.x,this.y=r*i+o*n+t.y,this}}),Object.assign(qe.prototype,{isMatrix4:!0,set:function(t,e,n,i,r,o,a,s,c,h,l,u,p,d,f,m){var v=this.elements;return v[0]=t,v[4]=e,v[8]=n,v[12]=i,v[1]=r,v[5]=o,v[9]=a,v[13]=s,v[2]=c,v[6]=h,v[10]=l,v[14]=u,v[3]=p,v[7]=d,v[11]=f,v[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new 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:(u=new Ye,function(t){var e=this.elements,n=t.elements,i=1/u.setFromMatrixColumn(t,0).length(),r=1/u.setFromMatrixColumn(t,1).length(),o=1/u.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,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,i=t.y,r=t.z,o=Math.cos(n),a=Math.sin(n),s=Math.cos(i),c=Math.sin(i),h=Math.cos(r),l=Math.sin(r);if("XYZ"===t.order){var u=o*h,p=o*l,d=a*h,f=a*l;e[0]=s*h,e[4]=-s*l,e[8]=c,e[1]=p+d*c,e[5]=u-f*c,e[9]=-a*s,e[2]=f-u*c,e[6]=d+p*c,e[10]=o*s}else if("YXZ"===t.order){var m=s*h,v=s*l,g=c*h,y=c*l;e[0]=m+y*a,e[4]=g*a-v,e[8]=o*c,e[1]=o*l,e[5]=o*h,e[9]=-a,e[2]=v*a-g,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){m=s*h,v=s*l,g=c*h,y=c*l;e[0]=m-y*a,e[4]=-o*l,e[8]=g+v*a,e[1]=v+g*a,e[5]=o*h,e[9]=y-m*a,e[2]=-o*c,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){u=o*h,p=o*l,d=a*h,f=a*l;e[0]=s*h,e[4]=d*c-p,e[8]=u*c+f,e[1]=s*l,e[5]=f*c+u,e[9]=p*c-d,e[2]=-c,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var x=o*s,w=o*c,b=a*s,_=a*c;e[0]=s*h,e[4]=_-x*l,e[8]=b*l+w,e[1]=l,e[5]=o*h,e[9]=-a*h,e[2]=-c*h,e[6]=w*l+b,e[10]=x-_*l}else if("XZY"===t.order){x=o*s,w=o*c,b=a*s,_=a*c;e[0]=s*h,e[4]=-l,e[8]=c*h,e[1]=x*l+_,e[5]=o*h,e[9]=w*l-b,e[2]=b*l-w,e[6]=a*h,e[10]=_*l+x}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,i=t._y,r=t._z,o=t._w,a=n+n,s=i+i,c=r+r,h=n*a,l=n*s,u=n*c,p=i*s,d=i*c,f=r*c,m=o*a,v=o*s,g=o*c;return e[0]=1-(p+f),e[4]=l-g,e[8]=u+v,e[1]=l+g,e[5]=1-(h+f),e[9]=d-m,e[2]=u-v,e[6]=d+m,e[10]=1-(h+p),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,h=new Ye,l=new Ye,function(t,e,n){var i=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(),h.crossVectors(l,c),i[0]=c.x,i[4]=h.x,i[8]=l.x,i[1]=c.y,i[5]=h.y,i[9]=l.y,i[2]=c.z,i[6]=h.z,i[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,i=e.elements,r=this.elements,o=n[0],a=n[4],s=n[8],c=n[12],h=n[1],l=n[5],u=n[9],p=n[13],d=n[2],f=n[6],m=n[10],v=n[14],g=n[3],y=n[7],x=n[11],w=n[15],b=i[0],_=i[4],M=i[8],E=i[12],S=i[1],T=i[5],A=i[9],R=i[13],C=i[2],L=i[6],P=i[10],B=i[14],I=i[3],N=i[7],O=i[11],F=i[15];return r[0]=o*b+a*S+s*C+c*I,r[4]=o*_+a*T+s*L+c*N,r[8]=o*M+a*A+s*P+c*O,r[12]=o*E+a*R+s*B+c*F,r[1]=h*b+l*S+u*C+p*I,r[5]=h*_+l*T+u*L+p*N,r[9]=h*M+l*A+u*P+p*O,r[13]=h*E+l*R+u*B+p*F,r[2]=d*b+f*S+m*C+v*I,r[6]=d*_+f*T+m*L+v*N,r[10]=d*M+f*A+m*P+v*O,r[14]=d*E+f*R+m*B+v*F,r[3]=g*b+y*S+x*C+w*I,r[7]=g*_+y*T+x*L+w*N,r[11]=g*M+y*A+x*P+w*O,r[15]=g*E+y*R+x*B+w*F,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,i=e.count;n<i;n++)t.x=e.getX(n),t.y=e.getY(n),t.z=e.getZ(n),t.applyMatrix4(this),e.setXYZ(n,t.x,t.y,t.z);return e}}(),determinant:function(){var t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],o=t[1],a=t[5],s=t[9],c=t[13],h=t[2],l=t[6],u=t[10],p=t[14];return t[3]*(+r*s*l-i*c*l-r*a*u+n*c*u+i*a*p-n*s*p)+t[7]*(+e*s*p-e*c*u+r*o*u-i*o*p+i*c*h-r*s*h)+t[11]*(+e*c*l-e*a*p-r*o*l+n*o*p+r*a*h-n*c*h)+t[15]*(-i*a*h-e*s*l+e*a*u+i*o*l-n*o*u+n*s*h)},transpose:function(){var t,e=this.elements;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},setPosition:function(t){var e=this.elements;return e[12]=t.x,e[13]=t.y,e[14]=t.z,this},getInverse:function(t,e){var n=this.elements,i=t.elements,r=i[0],o=i[1],a=i[2],s=i[3],c=i[4],h=i[5],l=i[6],u=i[7],p=i[8],d=i[9],f=i[10],m=i[11],v=i[12],g=i[13],y=i[14],x=i[15],w=d*y*u-g*f*u+g*l*m-h*y*m-d*l*x+h*f*x,b=v*f*u-p*y*u-v*l*m+c*y*m+p*l*x-c*f*x,_=p*g*u-v*d*u+v*h*m-c*g*m-p*h*x+c*d*x,M=v*d*l-p*g*l-v*h*f+c*g*f+p*h*y-c*d*y,E=r*w+o*b+a*_+s*M;if(0===E){var S="THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0";if(!0===e)throw new Error(S);return console.warn(S),this.identity()}var T=1/E;return n[0]=w*T,n[1]=(g*f*s-d*y*s-g*a*m+o*y*m+d*a*x-o*f*x)*T,n[2]=(h*y*s-g*l*s+g*a*u-o*y*u-h*a*x+o*l*x)*T,n[3]=(d*l*s-h*f*s-d*a*u+o*f*u+h*a*m-o*l*m)*T,n[4]=b*T,n[5]=(p*y*s-v*f*s+v*a*m-r*y*m-p*a*x+r*f*x)*T,n[6]=(v*l*s-c*y*s-v*a*u+r*y*u+c*a*x-r*l*x)*T,n[7]=(c*f*s-p*l*s+p*a*u-r*f*u-c*a*m+r*l*m)*T,n[8]=_*T,n[9]=(v*d*s-p*g*s-v*o*m+r*g*m+p*o*x-r*d*x)*T,n[10]=(c*g*s-v*h*s+v*o*u-r*g*u-c*o*x+r*h*x)*T,n[11]=(p*h*s-c*d*s-p*o*u+r*d*u+c*o*m-r*h*m)*T,n[12]=M*T,n[13]=(p*g*a-v*d*a+v*o*f-r*g*f-p*o*y+r*d*y)*T,n[14]=(v*h*a-c*g*a-v*o*l+r*g*l+c*o*y-r*h*y)*T,n[15]=(c*d*a-p*h*a+p*o*l-r*d*l-c*o*f+r*h*f)*T,this},scale:function(t){var e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this},getMaxScaleOnAxis:function(){var t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))},makeTranslation:function(t,e,n){return this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this},makeRotationX:function(t){var e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this},makeRotationY:function(t){var e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this},makeRotationZ:function(t){var e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(t,e){var n=Math.cos(e),i=Math.sin(e),r=1-n,o=t.x,a=t.y,s=t.z,c=r*o,h=r*a;return this.set(c*o+n,c*a-i*s,c*s+i*a,0,c*a+i*s,h*a+n,h*s-i*o,0,c*s-i*a,h*s+i*o,r*s*s+n,0,0,0,0,1),this},makeScale:function(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this},makeShear:function(t,e,n){return this.set(1,e,n,0,t,1,n,0,t,e,1,0,0,0,0,1),this},compose:function(t,e,n){return this.makeRotationFromQuaternion(e),this.scale(n),this.setPosition(t),this},decompose:(a=new Ye,s=new qe,function(t,e,n){var i=this.elements,r=a.set(i[0],i[1],i[2]).length(),o=a.set(i[4],i[5],i[6]).length(),c=a.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],s.copy(this);var h=1/r,l=1/o,u=1/c;return s.elements[0]*=h,s.elements[1]*=h,s.elements[2]*=h,s.elements[4]*=l,s.elements[5]*=l,s.elements[6]*=l,s.elements[8]*=u,s.elements[9]*=u,s.elements[10]*=u,e.setFromRotationMatrix(s),n.x=r,n.y=o,n.z=c,this}),makePerspective:function(t,e,n,i,r,o){void 0===o&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var a=this.elements,s=2*r/(e-t),c=2*r/(n-i),h=(e+t)/(e-t),l=(n+i)/(n-i),u=-(o+r)/(o-r),p=-2*o*r/(o-r);return a[0]=s,a[4]=0,a[8]=h,a[12]=0,a[1]=0,a[5]=c,a[9]=l,a[13]=0,a[2]=0,a[6]=0,a[10]=u,a[14]=p,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this},makeOrthographic:function(t,e,n,i,r,o){var a=this.elements,s=1/(e-t),c=1/(n-i),h=1/(o-r),l=(e+t)*s,u=(n+i)*c,p=(o+r)*h;return a[0]=2*s,a[4]=0,a[8]=0,a[12]=-l,a[1]=0,a[5]=2*c,a[9]=0,a[13]=-u,a[2]=0,a[6]=0,a[10]=-2*h,a[14]=-p,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this},equals:function(t){for(var e=this.elements,n=t.elements,i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0},fromArray:function(t,e){void 0===e&&(e=0);for(var n=0;n<16;n++)this.elements[n]=t[n+e];return this},toArray:function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}),Object.assign(Xe,{slerp:function(t,e,n,i){return n.copy(t).slerp(e,i)},slerpFlat:function(t,e,n,i,r,o,a){var s=n[i+0],c=n[i+1],h=n[i+2],l=n[i+3],u=r[o+0],p=r[o+1],d=r[o+2],f=r[o+3];if(l!==f||s!==u||c!==p||h!==d){var m=1-a,v=s*u+c*p+h*d+l*f,g=v>=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var x=Math.sqrt(y),w=Math.atan2(x,v*g);m=Math.sin(m*w)/x,a=Math.sin(a*w)/x}var b=a*g;if(s=s*m+u*b,c=c*m+p*b,h=h*m+d*b,l=l*m+f*b,m===1-a){var _=1/Math.sqrt(s*s+c*c+h*h+l*l);s*=_,c*=_,h*=_,l*=_}}t[e]=s,t[e+1]=c,t[e+2]=h,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,i){return this._x=t,this._y=e,this._z=n,this._w=i,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(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,i=t._y,r=t._z,o=t.order,a=Math.cos,s=Math.sin,c=a(n/2),h=a(i/2),l=a(r/2),u=s(n/2),p=s(i/2),d=s(r/2);return"XYZ"===o?(this._x=u*h*l+c*p*d,this._y=c*p*l-u*h*d,this._z=c*h*d+u*p*l,this._w=c*h*l-u*p*d):"YXZ"===o?(this._x=u*h*l+c*p*d,this._y=c*p*l-u*h*d,this._z=c*h*d-u*p*l,this._w=c*h*l+u*p*d):"ZXY"===o?(this._x=u*h*l-c*p*d,this._y=c*p*l+u*h*d,this._z=c*h*d+u*p*l,this._w=c*h*l-u*p*d):"ZYX"===o?(this._x=u*h*l-c*p*d,this._y=c*p*l+u*h*d,this._z=c*h*d-u*p*l,this._w=c*h*l+u*p*d):"YZX"===o?(this._x=u*h*l+c*p*d,this._y=c*p*l+u*h*d,this._z=c*h*d-u*p*l,this._w=c*h*l-u*p*d):"XZY"===o&&(this._x=u*h*l-c*p*d,this._y=c*p*l-u*h*d,this._z=c*h*d+u*p*l,this._w=c*h*l+u*p*d),!1!==e&&this.onChangeCallback(),this},setFromAxisAngle:function(t,e){var n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,n=t.elements,i=n[0],r=n[4],o=n[8],a=n[1],s=n[5],c=n[9],h=n[2],l=n[6],u=n[10],p=i+s+u;return p>0?(e=.5/Math.sqrt(p+1),this._w=.25/e,this._x=(l-c)*e,this._y=(o-h)*e,this._z=(a-r)*e):i>s&&i>u?(e=2*Math.sqrt(1+i-s-u),this._w=(l-c)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(o+h)/e):s>u?(e=2*Math.sqrt(1+s-i-u),this._w=(o-h)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(c+l)/e):(e=2*Math.sqrt(1+u-i-s),this._w=(a-r)/e,this._x=(o+h)/e,this._y=(c+l)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:function(){var t,e=new Ye;return function(n,i){return void 0===e&&(e=new Ye),(t=n.dot(i)+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,i),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,i=t._y,r=t._z,o=t._w,a=e._x,s=e._y,c=e._z,h=e._w;return this._x=n*h+o*a+i*c-r*s,this._y=i*h+o*s+r*a-n*c,this._z=r*h+o*c+n*s-i*a,this._w=o*h-n*a-i*s-r*c,this.onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var n=this._x,i=this._y,r=this._z,o=this._w,a=o*t._w+n*t._x+i*t._y+r*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=i,this._z=r,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*(i+this._y),this._z=.5*(r+this._z),this;var c=Math.atan2(s,a),h=Math.sin((1-e)*c)/s,l=Math.sin(e*c)/s;return this._w=o*h+this._w*l,this._x=n*h+this._x*l,this._y=i*h+this._y*l,this._z=r*h+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:(p=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(p.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,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this},applyMatrix4:function(t){var e=this.x,n=this.y,i=this.z,r=t.elements,o=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*o,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*o,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*o,this},applyQuaternion:function(t){var e=this.x,n=this.y,i=this.z,r=t.x,o=t.y,a=t.z,s=t.w,c=s*e+o*i-a*n,h=s*n+a*e-r*i,l=s*i+r*n-o*e,u=-r*e-o*n-a*i;return this.x=c*s+u*-r+h*-a-l*-o,this.y=h*s+u*-o+l*-r-c*-a,this.z=l*s+u*-a+c*-o-h*-r,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,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,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,i){return t.set(n,n,n),e.set(i,i,i),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,i=t.y,r=t.z,o=e.x,a=e.y,s=e.z;return this.x=i*s-r*a,this.y=r*o-n*s,this.z=n*a-i*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(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,i=this.z-t.z;return e*e+n*n+i*i},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(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,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,i,r,o,a,s,c){var h=this.elements;return h[0]=t,h[1]=i,h[2]=a,h[3]=e,h[4]=r,h[5]=s,h[6]=n,h[7]=o,h[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,i=e.count;n<i;n++)t.x=e.getX(n),t.y=e.getY(n),t.z=e.getZ(n),t.applyMatrix3(this),e.setXYZ(n,t.x,t.y,t.z);return e}}(),multiply:function(t){return this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var n=t.elements,i=e.elements,r=this.elements,o=n[0],a=n[3],s=n[6],c=n[1],h=n[4],l=n[7],u=n[2],p=n[5],d=n[8],f=i[0],m=i[3],v=i[6],g=i[1],y=i[4],x=i[7],w=i[2],b=i[5],_=i[8];return r[0]=o*f+a*g+s*w,r[3]=o*m+a*y+s*b,r[6]=o*v+a*x+s*_,r[1]=c*f+h*g+l*w,r[4]=c*m+h*y+l*b,r[7]=c*v+h*x+l*_,r[2]=u*f+p*g+d*w,r[5]=u*m+p*y+d*b,r[8]=u*v+p*x+d*_,this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this},determinant:function(){var t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],a=t[5],s=t[6],c=t[7],h=t[8];return e*o*h-e*a*c-n*r*h+n*a*s+i*r*c-i*o*s},getInverse:function(t,e){t&&t.isMatrix4&&console.error("THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument.");var n=t.elements,i=this.elements,r=n[0],o=n[1],a=n[2],s=n[3],c=n[4],h=n[5],l=n[6],u=n[7],p=n[8],d=p*c-h*u,f=h*l-p*s,m=u*s-c*l,v=r*d+o*f+a*m;if(0===v){var g="THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0";if(!0===e)throw new Error(g);return console.warn(g),this.identity()}var y=1/v;return i[0]=d*y,i[1]=(a*u-p*o)*y,i[2]=(h*o-a*c)*y,i[3]=f*y,i[4]=(p*r-a*l)*y,i[5]=(a*s-h*r)*y,i[6]=m*y,i[7]=(o*l-u*r)*y,i[8]=(c*r-o*s)*y,this},transpose:function(){var t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this},getNormalMatrix:function(t){return this.setFromMatrix4(t).getInverse(this).transpose()},transposeIntoArray:function(t){var e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this},setUvTransform:function(t,e,n,i,r,o,a){var s=Math.cos(r),c=Math.sin(r);this.set(n*s,n*c,-n*(s*o+c*a)+o+t,-i*c,i*s,-i*(-c*o+s*a)+a+e,0,0,1)},scale:function(t,e){var n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=e,n[4]*=e,n[7]*=e,this},rotate:function(t){var e=Math.cos(t),n=Math.sin(t),i=this.elements,r=i[0],o=i[3],a=i[6],s=i[1],c=i[4],h=i[7];return i[0]=e*r+n*s,i[3]=e*o+n*c,i[6]=e*a+n*h,i[1]=-n*r+e*s,i[4]=-n*o+e*c,i[7]=-n*a+e*h,this},translate:function(t,e){var n=this.elements;return n[0]+=t*n[2],n[3]+=t*n[5],n[6]+=t*n[8],n[1]+=e*n[2],n[4]+=e*n[5],n[7]+=e*n[8],this},equals:function(t){for(var e=this.elements,n=t.elements,i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0},fromArray:function(t,e){void 0===e&&(e=0);for(var n=0;n<9;n++)this.elements[n]=t[n+e];return this},toArray:function(t,e){void 0===t&&(t=[]),void 0===e&&(e=0);var n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}});var Je=0;function Qe(t,e,n,i,r,o,a,s,c,h){Object.defineProperty(this,"id",{value:Je++}),this.uuid=ke.generateUUID(),this.name="",this.image=void 0!==t?t:Qe.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:Qe.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:St,this.wrapT=void 0!==i?i:St,this.magFilter=void 0!==r?r:Lt,this.minFilter=void 0!==o?o:Bt,this.anisotropy=void 0!==c?c:1,this.format=void 0!==a?a:Xt,this.type=void 0!==s?s:It,this.offset=new We(0,0),this.repeat=new We(1,1),this.center=new We(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ze,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==h?h:Ne,this.version=0,this.onUpdate=null}function Ke(t,e,n,i){this.x=t||0,this.y=e||0,this.z=n||0,this.w=void 0!==i?i:1}function $e(t,e,n){this.uuid=ke.generateUUID(),this.width=t,this.height=e,this.scissor=new Ke(0,0,t,e),this.scissorTest=!1,this.viewport=new Ke(0,0,t,e),void 0===(n=n||{}).minFilter&&(n.minFilter=Lt),this.texture=new Qe(void 0,void 0,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0===n.stencilBuffer||n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null}function tn(t,e,n){$e.call(this,t,e,n),this.activeCubeFace=0,this.activeMipMapLevel=0}function en(t,e,n,i,r,o,a,s,c,h,l,u){Qe.call(this,null,o,a,s,c,h,i,r,l,u),this.image={data:t,width:e,height:n},this.magFilter=void 0!==c?c:At,this.minFilter=void 0!==h?h:At,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}function nn(t,e,n,i,r,o,a,s,c,h){t=void 0!==t?t:[],e=void 0!==e?e:gt,Qe.call(this,t,e,n,i,r,o,a,s,c,h),this.flipY=!1}Qe.DEFAULT_IMAGE=void 0,Qe.DEFAULT_MAPPING=vt,Qe.prototype=Object.assign(Object.create(i.prototype),{constructor:Qe,isTexture:!0,clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.name=t.name,this.image=t.image,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this},toJSON:function(t){var e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];var n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var i=this.image;void 0===i.uuid&&(i.uuid=ke.generateUUID()),e||void 0!==t.images[i.uuid]||(t.images[i.uuid]={uuid:i.uuid,url:function(t){var e;if(t instanceof HTMLCanvasElement)e=t;else{(e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")).width=t.width,e.height=t.height;var n=e.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height)}return e.width>2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}(i)}),n.image=i.uuid}return e||(t.textures[this.uuid]=n),n},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(this.mapping===vt){if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Et:t.x=t.x-Math.floor(t.x);break;case St:t.x=t.x<0?0:1;break;case Tt: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 Et:t.y=t.y-Math.floor(t.y);break;case St:t.y=t.y<0?0:1;break;case Tt: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(Qe.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Ke.prototype,{isVector4:!0,set:function(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,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,i=this.z,r=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*i+o[12]*r,this.y=o[1]*e+o[5]*n+o[9]*i+o[13]*r,this.z=o[2]*e+o[6]*n+o[10]*i+o[14]*r,this.w=o[3]*e+o[7]*n+o[11]*i+o[15]*r,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,i,r,o=t.elements,a=o[0],s=o[4],c=o[8],h=o[1],l=o[5],u=o[9],p=o[2],d=o[6],f=o[10];if(Math.abs(s-h)<.01&&Math.abs(c-p)<.01&&Math.abs(u-d)<.01){if(Math.abs(s+h)<.1&&Math.abs(c+p)<.1&&Math.abs(u+d)<.1&&Math.abs(a+l+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(a+1)/2,v=(l+1)/2,g=(f+1)/2,y=(s+h)/4,x=(c+p)/4,w=(u+d)/4;return m>v&&m>g?m<.01?(n=0,i=.707106781,r=.707106781):(i=y/(n=Math.sqrt(m)),r=x/n):v>g?v<.01?(n=.707106781,i=0,r=.707106781):(n=y/(i=Math.sqrt(v)),r=w/i):g<.01?(n=.707106781,i=.707106781,r=0):(n=x/(r=Math.sqrt(g)),i=w/r),this.set(n,i,r,e),this}var b=Math.sqrt((d-u)*(d-u)+(c-p)*(c-p)+(h-s)*(h-s));return Math.abs(b)<.001&&(b=1),this.x=(d-u)/b,this.y=(c-p)/b,this.z=(h-s)/b,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,i){return void 0===t&&(t=new Ke,e=new Ke),t.set(n,n,n,n),e.set(i,i,i,i),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}}),$e.prototype=Object.assign(Object.create(i.prototype),{constructor:$e,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"})}}),tn.prototype=Object.create($e.prototype),tn.prototype.constructor=tn,tn.prototype.isWebGLRenderTargetCube=!0,en.prototype=Object.create(Qe.prototype),en.prototype.constructor=en,en.prototype.isDataTexture=!0,nn.prototype=Object.create(Qe.prototype),nn.prototype.constructor=nn,nn.prototype.isCubeTexture=!0,Object.defineProperty(nn.prototype,"images",{get:function(){return this.image},set:function(t){this.image=t}});var rn=new Qe,on=new nn;function an(){this.seq=[],this.map={}}var sn=[],cn=[],hn=new Float32Array(16),ln=new Float32Array(9);function un(t,e,n){var i=t[0];if(i<=0||i>0)return t;var r=e*n,o=sn[r];if(void 0===o&&(o=new Float32Array(r),sn[r]=o),0!==e){i.toArray(o,0);for(var a=1,s=0;a!==e;++a)s+=n,t[a].toArray(o,s)}return o}function pn(t,e){var n=cn[e];void 0===n&&(n=new Int32Array(e),cn[e]=n);for(var i=0;i!==e;++i)n[i]=t.allocTextureUnit();return n}function dn(t,e){t.uniform1f(this.addr,e)}function fn(t,e){t.uniform1i(this.addr,e)}function mn(t,e){void 0===e.x?t.uniform2fv(this.addr,e):t.uniform2f(this.addr,e.x,e.y)}function vn(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 gn(t,e){void 0===e.x?t.uniform4fv(this.addr,e):t.uniform4f(this.addr,e.x,e.y,e.z,e.w)}function yn(t,e){t.uniformMatrix2fv(this.addr,!1,e.elements||e)}function xn(t,e){void 0===e.elements?t.uniformMatrix3fv(this.addr,!1,e):(ln.set(e.elements),t.uniformMatrix3fv(this.addr,!1,ln))}function wn(t,e){void 0===e.elements?t.uniformMatrix4fv(this.addr,!1,e):(hn.set(e.elements),t.uniformMatrix4fv(this.addr,!1,hn))}function bn(t,e,n){var i=n.allocTextureUnit();t.uniform1i(this.addr,i),n.setTexture2D(e||rn,i)}function _n(t,e,n){var i=n.allocTextureUnit();t.uniform1i(this.addr,i),n.setTextureCube(e||on,i)}function Mn(t,e){t.uniform2iv(this.addr,e)}function En(t,e){t.uniform3iv(this.addr,e)}function Sn(t,e){t.uniform4iv(this.addr,e)}function Tn(t,e){t.uniform1fv(this.addr,e)}function An(t,e){t.uniform1iv(this.addr,e)}function Rn(t,e){t.uniform2fv(this.addr,un(e,this.size,2))}function Cn(t,e){t.uniform3fv(this.addr,un(e,this.size,3))}function Ln(t,e){t.uniform4fv(this.addr,un(e,this.size,4))}function Pn(t,e){t.uniformMatrix2fv(this.addr,!1,un(e,this.size,4))}function Bn(t,e){t.uniformMatrix3fv(this.addr,!1,un(e,this.size,9))}function In(t,e){t.uniformMatrix4fv(this.addr,!1,un(e,this.size,16))}function Nn(t,e,n){var i=e.length,r=pn(n,i);t.uniform1iv(this.addr,r);for(var o=0;o!==i;++o)n.setTexture2D(e[o]||rn,r[o])}function On(t,e,n){var i=e.length,r=pn(n,i);t.uniform1iv(this.addr,r);for(var o=0;o!==i;++o)n.setTextureCube(e[o]||on,r[o])}function Fn(t,e,n){this.id=t,this.addr=n,this.setValue=function(t){switch(t){case 5126:return dn;case 35664:return mn;case 35665:return vn;case 35666:return gn;case 35674:return yn;case 35675:return xn;case 35676:return wn;case 35678:case 36198:return bn;case 35680:return _n;case 5124:case 35670:return fn;case 35667:case 35671:return Mn;case 35668:case 35672:return En;case 35669:case 35673:return Sn}}(e.type)}function zn(t,e,n){this.id=t,this.addr=n,this.size=e.size,this.setValue=function(t){switch(t){case 5126:return Tn;case 35664:return Rn;case 35665:return Cn;case 35666:return Ln;case 35674:return Pn;case 35675:return Bn;case 35676:return In;case 35678:return Nn;case 35680:return On;case 5124:case 35670:return An;case 35667:case 35671:return Mn;case 35668:case 35672:return En;case 35669:case 35673:return Sn}}(e.type)}function Dn(t){this.id=t,an.call(this)}Dn.prototype.setValue=function(t,e){for(var n=this.seq,i=0,r=n.length;i!==r;++i){var o=n[i];o.setValue(t,e[o.id])}};var Un=/([\w\d_]+)(\])?(\[|\.)?/g;function Vn(t,e){t.seq.push(e),t.map[e.id]=e}function Gn(t,e,n){var i=t.name,r=i.length;for(Un.lastIndex=0;;){var o=Un.exec(i),a=Un.lastIndex,s=o[1],c="]"===o[2],h=o[3];if(c&&(s|=0),void 0===h||"["===h&&a+2===r){Vn(n,void 0===h?new Fn(s,t,e):new zn(s,t,e));break}var l=n.map[s];void 0===l&&Vn(n,l=new Dn(s)),n=l}}function Hn(t,e,n){an.call(this),this.renderer=n;for(var i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS),r=0;r<i;++r){var o=t.getActiveUniform(e,r),a=o.name;Gn(o,t.getUniformLocation(e,a),this)}}Hn.prototype.setValue=function(t,e,n){var i=this.map[e];void 0!==i&&i.setValue(t,n,this.renderer)},Hn.prototype.setOptional=function(t,e,n){var i=e[n];void 0!==i&&this.setValue(t,n,i)},Hn.upload=function(t,e,n,i){for(var r=0,o=e.length;r!==o;++r){var a=e[r],s=n[a.id];!1!==s.needsUpdate&&a.setValue(t,s.value,i)}},Hn.seqWithValue=function(t,e){for(var n=[],i=0,r=t.length;i!==r;++i){var o=t[i];o.id in e&&n.push(o)}return n};var jn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function kn(t,e,n){return void 0===e&&void 0===n?this.set(t):this.setRGB(t,e,n)}Object.assign(kn.prototype,{isColor:!0,r:1,g:1,b:1,set:function(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this},setScalar:function(t){return this.r=t,this.g=t,this.b=t,this},setHex:function(t){return t=Math.floor(t),this.r=(t>>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,i){if(e=ke.euclideanModulo(e,1),n=ke.clamp(n,0,1),i=ke.clamp(i,0,1),0===n)this.r=this.g=this.b=i;else{var r=i<=.5?i*(1+n):i+n-i*n,o=2*i-r;this.r=t(o,r,e+1/3),this.g=t(o,r,e),this.b=t(o,r,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 i,r=n[1],o=n[2];switch(r){case"rgb":case"rgba":if(i=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(i[1],10))/255,this.g=Math.min(255,parseInt(i[2],10))/255,this.b=Math.min(255,parseInt(i[3],10))/255,e(i[5]),this;if(i=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(i[1],10))/100,this.g=Math.min(100,parseInt(i[2],10))/100,this.b=Math.min(100,parseInt(i[3],10))/100,e(i[5]),this;break;case"hsl":case"hsla":if(i=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(o)){var a=parseFloat(i[1])/360,s=parseInt(i[2],10)/100,c=parseInt(i[3],10)/100;return e(i[5]),this.setHSL(a,s,c)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(t)){var h,l=(h=n[1]).length;if(3===l)return this.r=parseInt(h.charAt(0)+h.charAt(0),16)/255,this.g=parseInt(h.charAt(1)+h.charAt(1),16)/255,this.b=parseInt(h.charAt(2)+h.charAt(2),16)/255,this;if(6===l)return this.r=parseInt(h.charAt(0)+h.charAt(1),16)/255,this.g=parseInt(h.charAt(2)+h.charAt(3),16)/255,this.b=parseInt(h.charAt(4)+h.charAt(5),16)/255,this}t&&t.length>0&&(void 0!==(h=jn[t])?this.setHex(h):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){var e,n,i=t||{h:0,s:0,l:0},r=this.r,o=this.g,a=this.b,s=Math.max(r,o,a),c=Math.min(r,o,a),h=(c+s)/2;if(c===s)e=0,n=0;else{var l=s-c;switch(n=h<=.5?l/(s+c):l/(2-s-c),s){case r:e=(o-a)/l+(o<a?6:0);break;case o:e=(a-r)/l+2;break;case a:e=(r-o)/l+4}e/=6}return i.h=e,i.s=n,i.l=h,i},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(t,e,n){var i=this.getHSL();return i.h+=t,i.s+=e,i.l+=n,this.setHSL(i.h,i.s,i.l),this},add:function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this},addColors:function(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this},addScalar:function(t){return this.r+=t,this.g+=t,this.b+=t,this},sub:function(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this},multiply:function(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this},multiplyScalar:function(t){return this.r*=t,this.g*=t,this.b*=t,this},lerp:function(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this},equals:function(t){return t.r===this.r&&t.g===this.g&&t.b===this.b},fromArray:function(t,e){return void 0===e&&(e=0),this.r=t[e],this.g=t[e+1],this.b=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t},toJSON:function(){return this.getHex()}});var Wn={common:{diffuse:{value:new kn(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Ze},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new We(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new kn(16777215)}},lights:{ambientLightColor:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new kn(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},uvTransform:{value:new Ze}}},qn={merge:function(t){for(var e={},n=0;n<t.length;n++){var i=this.clone(t[n]);for(var r in i)e[r]=i[r]}return e},clone:function(t){var e={};for(var n in t)for(var i in e[n]={},t[n]){var r=t[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture)?e[n][i]=r.clone():Array.isArray(r)?e[n][i]=r.slice():e[n][i]=r}return e}},Xn={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\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:"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#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_template:"\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#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 ( 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\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\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:"#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#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 <common>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}\n",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 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 <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n}\n",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}\n",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}\n",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldPosition;\n#include <common>\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 <common>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}\n",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}\n",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}\n",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <bsdfs>\n#include <lights_pars>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_template>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <lights_pars>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_template>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}\n",meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",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 <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment>\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 <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}\n",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <project_vertex>\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 <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <fog_fragment>\n}\n",shadow_vert:"#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n"},Yn={basic:{uniforms:qn.merge([Wn.common,Wn.specularmap,Wn.envmap,Wn.aomap,Wn.lightmap,Wn.fog]),vertexShader:Xn.meshbasic_vert,fragmentShader:Xn.meshbasic_frag},lambert:{uniforms:qn.merge([Wn.common,Wn.specularmap,Wn.envmap,Wn.aomap,Wn.lightmap,Wn.emissivemap,Wn.fog,Wn.lights,{emissive:{value:new kn(0)}}]),vertexShader:Xn.meshlambert_vert,fragmentShader:Xn.meshlambert_frag},phong:{uniforms:qn.merge([Wn.common,Wn.specularmap,Wn.envmap,Wn.aomap,Wn.lightmap,Wn.emissivemap,Wn.bumpmap,Wn.normalmap,Wn.displacementmap,Wn.gradientmap,Wn.fog,Wn.lights,{emissive:{value:new kn(0)},specular:{value:new kn(1118481)},shininess:{value:30}}]),vertexShader:Xn.meshphong_vert,fragmentShader:Xn.meshphong_frag},standard:{uniforms:qn.merge([Wn.common,Wn.envmap,Wn.aomap,Wn.lightmap,Wn.emissivemap,Wn.bumpmap,Wn.normalmap,Wn.displacementmap,Wn.roughnessmap,Wn.metalnessmap,Wn.fog,Wn.lights,{emissive:{value:new kn(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Xn.meshphysical_vert,fragmentShader:Xn.meshphysical_frag},points:{uniforms:qn.merge([Wn.points,Wn.fog]),vertexShader:Xn.points_vert,fragmentShader:Xn.points_frag},dashed:{uniforms:qn.merge([Wn.common,Wn.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Xn.linedashed_vert,fragmentShader:Xn.linedashed_frag},depth:{uniforms:qn.merge([Wn.common,Wn.displacementmap]),vertexShader:Xn.depth_vert,fragmentShader:Xn.depth_frag},normal:{uniforms:qn.merge([Wn.common,Wn.bumpmap,Wn.normalmap,Wn.displacementmap,{opacity:{value:1}}]),vertexShader:Xn.normal_vert,fragmentShader:Xn.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Xn.cube_vert,fragmentShader:Xn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Xn.equirect_vert,fragmentShader:Xn.equirect_frag},distanceRGBA:{uniforms:qn.merge([Wn.common,Wn.displacementmap,{referencePosition:{value:new Ye},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Xn.distanceRGBA_vert,fragmentShader:Xn.distanceRGBA_frag},shadow:{uniforms:qn.merge([Wn.lights,Wn.fog,{color:{value:new kn(0)},opacity:{value:1}}]),vertexShader:Xn.shadow_vert,fragmentShader:Xn.shadow_frag}};function Zn(t,e,n,i,r,o,a,s,c){Qe.call(this,t,e,n,i,r,o,a,s,c),this.needsUpdate=!0}function Jn(t,e,n,i,r){var o,a,s,c,h,l,u=new Ye,p=new Xe,d=new Ye;function f(){var t=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),n=new Uint16Array([0,1,2,0,2,3]);o=e.createBuffer(),a=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,o),e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,a),e.bufferData(e.ELEMENT_ARRAY_BUFFER,n,e.STATIC_DRAW),s=function(){var t=e.createProgram(),n=e.createShader(e.VERTEX_SHADER),i=e.createShader(e.FRAGMENT_SHADER);return e.shaderSource(n,["precision "+r.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 center;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","varying float fogDepth;","void main() {","\tvUV = uvOffset + uv * uvScale;","\tvec2 alignedPosition = ( position - center ) * scale;","\tvec2 rotatedPosition;","\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","\tvec4 mvPosition;","\tmvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","\tmvPosition.xy += rotatedPosition;","\tgl_Position = projectionMatrix * mvPosition;","\tfogDepth = - mvPosition.z;","}"].join("\n")),e.shaderSource(i,["precision "+r.precision+" float;","#define SHADER_NAME SpriteMaterial","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","varying float fogDepth;","void main() {","\tvec4 texture = texture2D( map, vUV );","\tgl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","\tif ( gl_FragColor.a < alphaTest ) discard;","\tif ( fogType > 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(i),e.attachShader(t,n),e.attachShader(t,i),e.linkProgram(t),t}(),c={position:e.getAttribLocation(s,"position"),uv:e.getAttribLocation(s,"uv")},h={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 i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");i.width=8,i.height=8;var u=i.getContext("2d");u.fillStyle="white",u.fillRect(0,0,8,8),l=new Zn(i)}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(r,v,g){if(0!==r.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(h.projectionMatrix,!1,g.projectionMatrix.elements),n.activeTexture(e.TEXTURE0),e.uniform1i(h.map,0);var y=0,x=0,w=v.fog;w?(e.uniform3f(h.fogColor,w.color.r,w.color.g,w.color.b),w.isFog?(e.uniform1f(h.fogNear,w.near),e.uniform1f(h.fogFar,w.far),e.uniform1i(h.fogType,1),y=1,x=1):w.isFogExp2&&(e.uniform1f(h.fogDensity,w.density),e.uniform1i(h.fogType,2),y=2,x=2)):(e.uniform1i(h.fogType,0),y=0,x=0);for(var b=0,_=r.length;b<_;b++){(S=r[b]).modelViewMatrix.multiplyMatrices(g.matrixWorldInverse,S.matrixWorld),S.z=-S.modelViewMatrix.elements[14]}r.sort(m);var M=[],E=[];for(b=0,_=r.length;b<_;b++){var S,T=(S=r[b]).material;if(!1!==T.visible){S.onBeforeRender(t,v,g,void 0,T,void 0),e.uniform1f(h.alphaTest,T.alphaTest),e.uniformMatrix4fv(h.modelViewMatrix,!1,S.modelViewMatrix.elements),S.matrixWorld.decompose(u,p,d),M[0]=d.x,M[1]=d.y,E[0]=S.center.x-.5,E[1]=S.center.y-.5;var A=0;v.fog&&T.fog&&(A=x),y!==A&&(e.uniform1i(h.fogType,A),y=A),null!==T.map?(e.uniform2f(h.uvOffset,T.map.offset.x,T.map.offset.y),e.uniform2f(h.uvScale,T.map.repeat.x,T.map.repeat.y)):(e.uniform2f(h.uvOffset,0,0),e.uniform2f(h.uvScale,1,1)),e.uniform1f(h.opacity,T.opacity),e.uniform3f(h.color,T.color.r,T.color.g,T.color.b),e.uniform1f(h.rotation,T.rotation),e.uniform2fv(h.center,E),e.uniform2fv(h.scale,M),n.setBlending(T.blending,T.blendEquation,T.blendSrc,T.blendDst,T.blendEquationAlpha,T.blendSrcAlpha,T.blendDstAlpha,T.premultipliedAlpha),n.buffers.depth.setTest(T.depthTest),n.buffers.depth.setMask(T.depthWrite),n.buffers.color.setMask(T.colorWrite),i.setTexture2D(T.map||l,0),e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0),S.onAfterRender(t,v,g,void 0,T,void 0)}}n.enable(e.CULL_FACE),n.reset()}}}Yn.physical={uniforms:qn.merge([Yn.standard.uniforms,{clearCoat:{value:0},clearCoatRoughness:{value:0}}]),vertexShader:Xn.meshphysical_vert,fragmentShader:Xn.meshphysical_frag},Zn.prototype=Object.create(Qe.prototype),Zn.prototype.constructor=Zn;var Qn,Kn,$n,ti,ei,ni,ii,ri=0;function oi(){Object.defineProperty(this,"id",{value:ri++}),this.uuid=ke.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.lights=!0,this.blending=I,this.side=E,this.flatShading=!1,this.vertexColors=C,this.opacity=1,this.transparent=!1,this.blendSrc=X,this.blendDst=Y,this.blendEquation=D,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=it,this.depthTest=!0,this.depthWrite=!0,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaTest=0,this.premultipliedAlpha=!1,this.overdraw=0,this.visible=!0,this.userData={},this.needsUpdate=!0}function ai(t){oi.call(this),this.type="MeshDepthMaterial",this.depthPacking=He,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.setValues(t)}function si(t){oi.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new Ye,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.lights=!1,this.setValues(t)}function ci(t,e){this.min=void 0!==t?t:new Ye(1/0,1/0,1/0),this.max=void 0!==e?e:new Ye(-1/0,-1/0,-1/0)}function hi(t,e){this.center=void 0!==t?t:new Ye,this.radius=void 0!==e?e:0}function li(t,e){this.normal=void 0!==t?t:new Ye(1,0,0),this.constant=void 0!==e?e:0}function ui(t,e,n,i,r,o){this.planes=[void 0!==t?t:new li,void 0!==e?e:new li,void 0!==n?n:new li,void 0!==i?i:new li,void 0!==r?r:new li,void 0!==o?o:new li]}function pi(t,e,n){for(var i=new ui,r=new qe,o=new We,a=new We(n,n),s=new Ye,c=new Ye,h=new Array(4),l=new Array(4),u={},p={0:S,1:E,2:T},d=[new Ye(1,0,0),new Ye(-1,0,0),new Ye(0,0,1),new Ye(0,0,-1),new Ye(0,1,0),new Ye(0,-1,0)],f=[new Ye(0,1,0),new Ye(0,1,0),new Ye(0,1,0),new Ye(0,1,0),new Ye(0,0,1),new Ye(0,0,-1)],m=[new Ke,new Ke,new Ke,new Ke,new Ke,new Ke],v=0;4!==v;++v){var g=0!=(1&v),y=0!=(2&v),x=new ai({depthPacking:je,morphTargets:g,skinning:y});h[v]=x;var w=new si({morphTargets:g,skinning:y});l[v]=w}var b=this;function M(e,n,i,r,o,a){var s=e.geometry,c=null,d=h,f=e.customDepthMaterial;if(i&&(d=l,f=e.customDistanceMaterial),f)c=f;else{var m=!1;n.morphTargets&&(s&&s.isBufferGeometry?m=s.morphAttributes&&s.morphAttributes.position&&s.morphAttributes.position.length>0: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 v=0;m&&(v|=1),e.isSkinnedMesh&&n.skinning&&(v|=2),c=d[v]}if(t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var g=c.uuid,y=n.uuid,x=u[g];void 0===x&&(x={},u[g]=x);var w=x[y];void 0===w&&(w=c.clone(),x[y]=w),c=w}return c.visible=n.visible,c.wireframe=n.wireframe,c.side=null!=n.shadowSide?n.shadowSide:p[n.side],c.clipShadows=n.clipShadows,c.clippingPlanes=n.clippingPlanes,c.clipIntersection=n.clipIntersection,c.wireframeLinewidth=n.wireframeLinewidth,c.linewidth=n.linewidth,i&&c.isMeshDistanceMaterial&&(c.referencePosition.copy(r),c.nearDistance=o,c.farDistance=a),c}function A(n,r,o,a){if(!1!==n.visible){if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&n.castShadow&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,n.matrixWorld);var s=e.update(n),h=n.material;if(Array.isArray(h))for(var l=s.groups,u=0,p=l.length;u<p;u++){var d=l[u],f=h[d.materialIndex];if(f&&f.visible){var m=M(n,f,a,c,o.near,o.far);t.renderBufferDirect(o,null,s,m,n,d)}}else if(h.visible){m=M(n,h,a,c,o.near,o.far);t.renderBufferDirect(o,null,s,m,n,null)}}for(var v=n.children,g=0,y=v.length;g<y;g++)A(v[g],r,o,a)}}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=_,this.render=function(e,n,h){if(!1!==b.enabled&&(!1!==b.autoUpdate||!1!==b.needsUpdate)&&0!==e.length){var l,u=t.context,p=t.state;p.disable(u.BLEND),p.buffers.color.setClear(1,1,1,1),p.buffers.depth.setTest(!0),p.setScissorTest(!1);for(var v=0,g=e.length;v<g;v++){var y=e[v],x=y.shadow,w=y&&y.isPointLight;if(void 0!==x){var _=x.camera;if(o.copy(x.mapSize),o.min(a),w){var M=o.x,E=o.y;m[0].set(2*M,E,M,E),m[1].set(0,E,M,E),m[2].set(3*M,E,M,E),m[3].set(M,E,M,E),m[4].set(3*M,0,M,E),m[5].set(M,0,M,E),o.x*=4,o.y*=2}if(null===x.map){var S={minFilter:At,magFilter:At,format:Xt};x.map=new $e(o.x,o.y,S),x.map.texture.name=y.name+".shadowMap",_.updateProjectionMatrix()}x.isSpotLightShadow&&x.update(y);var T=x.map,R=x.matrix;c.setFromMatrixPosition(y.matrixWorld),_.position.copy(c),w?(l=6,R.makeTranslation(-c.x,-c.y,-c.z)):(l=1,s.setFromMatrixPosition(y.target.matrixWorld),_.lookAt(s),_.updateMatrixWorld(),R.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),R.multiply(_.projectionMatrix),R.multiply(_.matrixWorldInverse)),t.setRenderTarget(T),t.clear();for(var C=0;C<l;C++){if(w){s.copy(_.position),s.add(d[C]),_.up.copy(f[C]),_.lookAt(s),_.updateMatrixWorld();var L=m[C];p.viewport(L)}r.multiplyMatrices(_.projectionMatrix,_.matrixWorldInverse),i.setFromMatrix(r),A(n,h,_,w)}}else console.warn("THREE.WebGLShadowMap:",y,"has no shadow.")}b.needsUpdate=!1}}}function di(t){var e={};return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e[t.uuid]},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);var i=e[n.uuid];i&&(t.deleteBuffer(i.buffer),delete e[n.uuid])},update:function(n,i){n.isInterleavedBufferAttribute&&(n=n.data);var r=e[n.uuid];void 0===r?e[n.uuid]=function(e,n){var i=e.array,r=e.dynamic?t.DYNAMIC_DRAW:t.STATIC_DRAW,o=t.createBuffer();t.bindBuffer(n,o),t.bufferData(n,i,r),e.onUploadCallback();var a=t.FLOAT;return i instanceof Float32Array?a=t.FLOAT:i instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):i instanceof Uint16Array?a=t.UNSIGNED_SHORT:i instanceof Int16Array?a=t.SHORT:i instanceof Uint32Array?a=t.UNSIGNED_INT:i instanceof Int32Array?a=t.INT:i instanceof Int8Array?a=t.BYTE:i instanceof Uint8Array&&(a=t.UNSIGNED_BYTE),{buffer:o,type:a,bytesPerElement:i.BYTES_PER_ELEMENT,version:e.version}}(n,i):r.version<n.version&&(!function(e,n,i){var r=n.array,o=n.updateRange;t.bindBuffer(i,e),!1===n.dynamic?t.bufferData(i,r,t.STATIC_DRAW):-1===o.count?t.bufferSubData(i,0,r):0===o.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(t.bufferSubData(i,o.offset*r.BYTES_PER_ELEMENT,r.subarray(o.offset,o.offset+o.count)),o.count=-1)}(r.buffer,n,i),r.version=n.version)}}}function fi(t,e,n,i){this._x=t||0,this._y=e||0,this._z=n||0,this._order=i||fi.DefaultOrder}function mi(){this.mask=1}oi.prototype=Object.assign(Object.create(i.prototype),{constructor:oi,isMaterial:!0,onBeforeCompile:function(){},setValues:function(t){if(void 0!==t)for(var e in t){var n=t[e];if(void 0!==n)if("shading"!==e){var i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]="overdraw"===e?Number(n):n:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}else console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===A;else console.warn("THREE.Material: '"+e+"' parameter is undefined.")}},toJSON:function(t){var e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});var n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function i(t){var e=[];for(var n in t){var i=t[n];delete i.metadata,e.push(i)}return e}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearCoat&&(n.clearCoat=this.clearCoat),void 0!==this.clearCoatRoughness&&(n.clearCoatRoughness=this.clearCoatRoughness),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,n.reflectivity=this.reflectivity),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.size&&(n.size=this.size),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==I&&(n.blending=this.blending),!0===this.flatShading&&(n.flatShading=this.flatShading),this.side!==E&&(n.side=this.side),this.vertexColors!==C&&(n.vertexColors=this.vertexColors),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,0!==this.rotation&&(n.rotation=this.rotation),1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(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 r=i(t.textures),o=i(t.images);r.length>0&&(n.textures=r),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 i=e.length;n=new Array(i);for(var r=0;r!==i;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.shadowSide=t.shadowSide,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),ai.prototype=Object.create(oi.prototype),ai.prototype.constructor=ai,ai.prototype.isMeshDepthMaterial=!0,ai.prototype.copy=function(t){return oi.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this},si.prototype=Object.create(oi.prototype),si.prototype.constructor=si,si.prototype.isMeshDistanceMaterial=!0,si.prototype.copy=function(t){return oi.prototype.copy.call(this,t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this},Object.assign(ci.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,i=1/0,r=-1/0,o=-1/0,a=-1/0,s=0,c=t.length;s<c;s+=3){var h=t[s],l=t[s+1],u=t[s+2];h<e&&(e=h),l<n&&(n=l),u<i&&(i=u),h>r&&(r=h),l>o&&(o=l),u>a&&(a=u)}return this.min.set(e,n,i),this.max.set(r,o,a),this},setFromBufferAttribute:function(t){for(var e=1/0,n=1/0,i=1/0,r=-1/0,o=-1/0,a=-1/0,s=0,c=t.count;s<c;s++){var h=t.getX(s),l=t.getY(s),u=t.getZ(s);h<e&&(e=h),l<n&&(n=l),u<i&&(i=u),h>r&&(r=h),l>o&&(o=l),u>a&&(a=u)}return this.min.set(e,n,i),this.max.set(r,o,a),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this},setFromCenterAndSize:function(){var t=new Ye;return function(e,n){var i=t.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}}(),setFromObject:function(t){return this.makeEmpty(),this.expandByObject(t)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(t){var e=t||new Ye;return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(t){var e=t||new Ye;return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},expandByObject:function(){var t,e,n,i=new Ye;function r(r){var o=r.geometry;if(void 0!==o)if(o.isGeometry){var a=o.vertices;for(e=0,n=a.length;e<n;e++)i.copy(a[e]),i.applyMatrix4(r.matrixWorld),t.expandByPoint(i)}else if(o.isBufferGeometry){var s=o.attributes.position;if(void 0!==s)for(e=0,n=s.count;e<n;e++)i.fromBufferAttribute(s,e).applyMatrix4(r.matrixWorld),t.expandByPoint(i)}}return function(e){return t=this,e.updateMatrixWorld(!0),e.traverse(r),this}}(),containsPoint:function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.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(e||new Ye).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.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)},intersectsSphere:(Kn=new Ye,function(t){return this.clampPoint(t.center,Kn),Kn.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,i=new Ye,r=new Ye,o=new Ye,a=new Ye,s=new Ye,c=new Ye,h=new Ye;function l(i){var r,o;for(r=0,o=i.length-3;r<=o;r+=3){a.fromArray(i,r);var s=c.x*Math.abs(a.x)+c.y*Math.abs(a.y)+c.z*Math.abs(a.z),h=t.dot(a),l=e.dot(a),u=n.dot(a);if(Math.max(-Math.max(h,l,u),Math.min(h,l,u))>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),i.subVectors(e,t),r.subVectors(n,e),o.subVectors(t,n);var u=[0,-i.z,i.y,0,-r.z,r.y,0,-o.z,o.y,i.z,0,-i.x,r.z,0,-r.x,o.z,0,-o.x,-i.y,i.x,0,-r.y,r.x,0,-o.y,o.x,0];return!!l(u)&&(!!l(u=[1,0,0,0,1,0,0,0,1])&&(h.crossVectors(i,r),l(u=[h.x,h.y,h.z])))}}(),clampPoint:function(t,e){return(e||new Ye).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){var n=e||new hi;return this.getCenter(n.center),n.radius=.5*this.getSize(t).length(),n}}(),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:(Qn=[new Ye,new Ye,new Ye,new Ye,new Ye,new Ye,new Ye,new Ye],function(t){return this.isEmpty()||(Qn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Qn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Qn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Qn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Qn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Qn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Qn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Qn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Qn)),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(hi.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:($n=new ci,function(t,e){var n=this.center;void 0!==e?n.copy(e):$n.setFromPoints(t).getCenter(n);for(var i=0,r=0,o=t.length;r<o;r++)i=Math.max(i,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(i),this}),clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.center.copy(t.center),this.radius=t.radius,this},empty:function(){return this.radius<=0},containsPoint:function(t){return t.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(t){return t.distanceTo(this.center)-this.radius},intersectsSphere:function(t){var e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e},intersectsBox:function(t){return t.intersectsSphere(this)},intersectsPlane:function(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius},clampPoint:function(t,e){var n=this.center.distanceToSquared(t),i=e||new Ye;return i.copy(t),n>this.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i},getBoundingBox:function(t){var e=t||new ci;return e.set(this.center,this.center),e.expandByScalar(this.radius),e},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(li.prototype,{set:function(t,e){return this.normal.copy(t),this.constant=e,this},setComponents:function(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,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,i,r){var o=t.subVectors(r,i).cross(e.subVectors(n,i)).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(e||new Ye).copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)},intersectLine:function(){var t=new Ye;return function(e,n){var i=n||new Ye,r=e.delta(t),o=this.normal.dot(r);if(0===o)return 0===this.distanceToPoint(e.start)?i.copy(e.start):void 0;var a=-(e.start.dot(this.normal)+this.constant)/o;return a<0||a>1?void 0:i.copy(r).multiplyScalar(a).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(t||new Ye).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var t=new Ye,e=new Ze;return function(n,i){var r=i||e.getNormalMatrix(n),o=this.coplanarPoint(t).applyMatrix4(n),a=this.normal.applyMatrix3(r).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(ui.prototype,{set:function(t,e,n,i,r,o){var a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(r),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,i=n[0],r=n[1],o=n[2],a=n[3],s=n[4],c=n[5],h=n[6],l=n[7],u=n[8],p=n[9],d=n[10],f=n[11],m=n[12],v=n[13],g=n[14],y=n[15];return e[0].setComponents(a-i,l-s,f-u,y-m).normalize(),e[1].setComponents(a+i,l+s,f+u,y+m).normalize(),e[2].setComponents(a+r,l+c,f+p,y+v).normalize(),e[3].setComponents(a-r,l-c,f-p,y-v).normalize(),e[4].setComponents(a-o,l-h,f-d,y-g).normalize(),e[5].setComponents(a+o,l+h,f+d,y+g).normalize(),this},intersectsObject:(ni=new hi,function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),ni.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(ni)}),intersectsSprite:function(){var t=new hi;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,i=-t.radius,r=0;r<6;r++){if(e[r].distanceToPoint(n)<i)return!1}return!0},intersectsBox:(ti=new Ye,ei=new Ye,function(t){for(var e=this.planes,n=0;n<6;n++){var i=e[n];ti.x=i.normal.x>0?t.min.x:t.max.x,ei.x=i.normal.x>0?t.max.x:t.min.x,ti.y=i.normal.y>0?t.min.y:t.max.y,ei.y=i.normal.y>0?t.max.y:t.min.y,ti.z=i.normal.z>0?t.min.z:t.max.z,ei.z=i.normal.z>0?t.max.z:t.min.z;var r=i.distanceToPoint(ti),o=i.distanceToPoint(ei);if(r<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}}),fi.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],fi.DefaultOrder="XYZ",Object.defineProperties(fi.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()}},order:{get:function(){return this._order},set:function(t){this._order=t,this.onChangeCallback()}}}),Object.assign(fi.prototype,{isEuler:!0,set:function(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._order=i||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback(),this},setFromRotationMatrix:function(t,e,n){var i=ke.clamp,r=t.elements,o=r[0],a=r[4],s=r[8],c=r[1],h=r[5],l=r[9],u=r[2],p=r[6],d=r[10];return"XYZ"===(e=e||this._order)?(this._y=Math.asin(i(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(p,h),this._z=0)):"YXZ"===e?(this._x=Math.asin(-i(l,-1,1)),Math.abs(l)<.99999?(this._y=Math.atan2(s,d),this._z=Math.atan2(c,h)):(this._y=Math.atan2(-u,o),this._z=0)):"ZXY"===e?(this._x=Math.asin(i(p,-1,1)),Math.abs(p)<.99999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-a,h)):(this._y=0,this._z=Math.atan2(c,o))):"ZYX"===e?(this._y=Math.asin(-i(u,-1,1)),Math.abs(u)<.99999?(this._x=Math.atan2(p,d),this._z=Math.atan2(c,o)):(this._x=0,this._z=Math.atan2(-a,h))):"YZX"===e?(this._z=Math.asin(i(c,-1,1)),Math.abs(c)<.99999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-u,o)):(this._x=0,this._y=Math.atan2(s,d))):"XZY"===e?(this._z=Math.asin(-i(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(p,h),this._y=Math.atan2(s,o)):(this._x=Math.atan2(-l,d),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+e),this._order=e,!1!==n&&this.onChangeCallback(),this},setFromQuaternion:function(){var t=new qe;return function(e,n,i){return t.makeRotationFromQuaternion(e),this.setFromRotationMatrix(t,n,i)}}(),setFromVector3:function(t,e){return this.set(t.x,t.y,t.z,e||this._order)},reorder:(ii=new Xe,function(t){return ii.setFromEuler(this),this.setFromQuaternion(ii,t)}),equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[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._order,t},toVector3:function(t){return t?t.set(this._x,this._y,this._z):new Ye(this._x,this._y,this._z)},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){}}),Object.assign(mi.prototype,{set:function(t){this.mask=1<<t|0},enable:function(t){this.mask|=1<<t|0},toggle:function(t){this.mask^=1<<t|0},disable:function(t){this.mask&=~(1<<t|0)},test:function(t){return 0!=(this.mask&t.mask)}});var vi,gi,yi,xi,wi=0;function bi(){Object.defineProperty(this,"id",{value:wi++}),this.uuid=ke.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=bi.DefaultUp.clone();var t=new Ye,e=new fi,n=new Xe,i=new Ye(1,1,1);e.onChange((function(){n.setFromEuler(e,!1)})),n.onChange((function(){e.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{enumerable:!0,value:t},rotation:{enumerable:!0,value:e},quaternion:{enumerable:!0,value:n},scale:{enumerable:!0,value:i},modelViewMatrix:{value:new qe},normalMatrix:{value:new Ze}}),this.matrix=new qe,this.matrixWorld=new qe,this.matrixAutoUpdate=bi.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new mi,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}function _i(){bi.call(this),this.type="Camera",this.matrixWorldInverse=new qe,this.projectionMatrix=new qe}function Mi(t,e,n,i,r,o){_i.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=void 0!==r?r:.1,this.far=void 0!==o?o:2e3,this.updateProjectionMatrix()}function Ei(t,e,n,i,r,o){this.a=t,this.b=e,this.c=n,this.normal=i&&i.isVector3?i:new Ye,this.vertexNormals=Array.isArray(i)?i:[],this.color=r&&r.isColor?r:new kn,this.vertexColors=Array.isArray(r)?r:[],this.materialIndex=void 0!==o?o:0}bi.DefaultUp=new Ye(0,1,0),bi.DefaultMatrixAutoUpdate=!0,bi.prototype=Object.assign(Object.create(i.prototype),{constructor:bi,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix:function(t){this.matrix.multiplyMatrices(t,this.matrix),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(t){return this.quaternion.premultiply(t),this},setRotationFromAxisAngle:function(t,e){this.quaternion.setFromAxisAngle(t,e)},setRotationFromEuler:function(t){this.quaternion.setFromEuler(t,!0)},setRotationFromMatrix:function(t){this.quaternion.setFromRotationMatrix(t)},setRotationFromQuaternion:function(t){this.quaternion.copy(t)},rotateOnAxis:(xi=new Xe,function(t,e){return xi.setFromAxisAngle(t,e),this.quaternion.multiply(xi),this}),rotateOnWorldAxis:function(){var t=new Xe;return function(e,n){return t.setFromAxisAngle(e,n),this.quaternion.premultiply(t),this}}(),rotateX:function(){var t=new Ye(1,0,0);return function(e){return this.rotateOnAxis(t,e)}}(),rotateY:function(){var t=new Ye(0,1,0);return function(e){return this.rotateOnAxis(t,e)}}(),rotateZ:function(){var t=new Ye(0,0,1);return function(e){return this.rotateOnAxis(t,e)}}(),translateOnAxis:function(){var t=new Ye;return function(e,n){return t.copy(e).applyQuaternion(this.quaternion),this.position.add(t.multiplyScalar(n)),this}}(),translateX:function(){var t=new Ye(1,0,0);return function(e){return this.translateOnAxis(t,e)}}(),translateY:function(){var t=new Ye(0,1,0);return function(e){return this.translateOnAxis(t,e)}}(),translateZ:function(){var t=new Ye(0,0,1);return function(e){return this.translateOnAxis(t,e)}}(),localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:(yi=new qe,function(t){return t.applyMatrix4(yi.getInverse(this.matrixWorld))}),lookAt:function(){var t=new qe,e=new Ye;return function(n,i,r){n.isVector3?e.copy(n):e.set(n,i,r),this.isCamera?t.lookAt(this.position,e,this.up):t.lookAt(e,this.position,this.up),this.quaternion.setFromRotationMatrix(t)}}(),add:function(t){if(arguments.length>1){for(var e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),t.parent=this,t.dispatchEvent({type:"added"}),this.children.push(t)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)},remove:function(t){if(arguments.length>1){for(var e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}var n=this.children.indexOf(t);return-1!==n&&(t.parent=null,t.dispatchEvent({type:"removed"}),this.children.splice(n,1)),this},getObjectById:function(t){return this.getObjectByProperty("id",t)},getObjectByName:function(t){return this.getObjectByProperty("name",t)},getObjectByProperty:function(t,e){if(this[t]===e)return this;for(var n=0,i=this.children.length;n<i;n++){var r=this.children[n].getObjectByProperty(t,e);if(void 0!==r)return r}},getWorldPosition:function(t){var e=t||new Ye;return this.updateMatrixWorld(!0),e.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:(vi=new Ye,gi=new Ye,function(t){var e=t||new Xe;return this.updateMatrixWorld(!0),this.matrixWorld.decompose(vi,e,gi),e}),getWorldRotation:function(){var t=new Xe;return function(e){var n=e||new fi;return this.getWorldQuaternion(t),n.setFromQuaternion(t,this.rotation.order,!1)}}(),getWorldScale:function(){var t=new Ye,e=new Xe;return function(n){var i=n||new Ye;return this.updateMatrixWorld(!0),this.matrixWorld.decompose(t,e,i),i}}(),getWorldDirection:function(){var t=new Xe;return function(e){var n=e||new Ye;return this.getWorldQuaternion(t),n.set(0,0,1).applyQuaternion(t)}}(),raycast:function(){},traverse:function(t){t(this);for(var e=this.children,n=0,i=e.length;n<i;n++)e[n].traverse(t)},traverseVisible:function(t){if(!1!==this.visible){t(this);for(var e=this.children,n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}},traverseAncestors:function(t){var e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);for(var e=this.children,n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)},toJSON:function(t){var e=void 0===t||"string"==typeof t,n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var i={};function r(e,n){return void 0===e[n.uuid]&&(e[n.uuid]=n.toJSON(t)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),i.matrix=this.matrix.toArray(),void 0!==this.geometry){i.geometry=r(t.geometries,this.geometry);var o=this.geometry.parameters;if(void 0!==o&&void 0!==o.shapes){var a=o.shapes;if(Array.isArray(a))for(var s=0,c=a.length;s<c;s++){var h=a[s];r(t.shapes,h)}else r(t.shapes,a)}}if(void 0!==this.material)if(Array.isArray(this.material)){var l=[];for(s=0,c=this.material.length;s<c;s++)l.push(r(t.materials,this.material[s]));i.material=l}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(s=0;s<this.children.length;s++)i.children.push(this.children[s].toJSON(t).object)}if(e){var u=m(t.geometries),p=m(t.materials),d=m(t.textures),f=m(t.images);a=m(t.shapes);u.length>0&&(n.geometries=u),p.length>0&&(n.materials=p),d.length>0&&(n.textures=d),f.length>0&&(n.images=f),a.length>0&&(n.shapes=a)}return n.object=i,n;function m(t){var e=[];for(var n in t){var i=t[n];delete i.metadata,e.push(i)}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;n<t.children.length;n++){var i=t.children[n];this.add(i.clone())}return this}}),_i.prototype=Object.assign(Object.create(bi.prototype),{constructor:_i,isCamera:!0,copy:function(t,e){return bi.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this},getWorldDirection:function(){var t=new Xe;return function(e){var n=e||new Ye;return this.getWorldQuaternion(t),n.set(0,0,-1).applyQuaternion(t)}}(),updateMatrixWorld:function(t){bi.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),Mi.prototype=Object.assign(Object.create(_i.prototype),{constructor:Mi,isOrthographicCamera:!0,copy:function(t,e){return _i.prototype.copy.call(this,t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this},setViewOffset:function(t,e,n,i,r,o){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-t,o=n+t,a=i+e,s=i-e;if(null!==this.view&&this.view.enabled){var c=this.zoom/(this.view.width/this.view.fullWidth),h=this.zoom/(this.view.height/this.view.fullHeight),l=(this.right-this.left)/this.view.width,u=(this.top-this.bottom)/this.view.height;o=(r+=l*(this.view.offsetX/c))+l*(this.view.width/c),s=(a-=u*(this.view.offsetY/h))-u*(this.view.height/h)}this.projectionMatrix.makeOrthographic(r,o,a,s,this.near,this.far)},toJSON:function(t){var e=bi.prototype.toJSON.call(this,t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}),Object.assign(Ei.prototype,{clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(var e=0,n=t.vertexNormals.length;e<n;e++)this.vertexNormals[e]=t.vertexNormals[e].clone();for(e=0,n=t.vertexColors.length;e<n;e++)this.vertexColors[e]=t.vertexColors[e].clone();return this}});var Si,Ti=0;function Ai(){Object.defineProperty(this,"id",{value:Ti+=2}),this.uuid=ke.generateUUID(),this.name="",this.type="Geometry",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.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}function Ri(t,e,n){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.uuid=ke.generateUUID(),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=!0===n,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.onUploadCallback=function(){},this.version=0}function Ci(t,e,n){Ri.call(this,new Int8Array(t),e,n)}function Li(t,e,n){Ri.call(this,new Uint8Array(t),e,n)}function Pi(t,e,n){Ri.call(this,new Uint8ClampedArray(t),e,n)}function Bi(t,e,n){Ri.call(this,new Int16Array(t),e,n)}function Ii(t,e,n){Ri.call(this,new Uint16Array(t),e,n)}function Ni(t,e,n){Ri.call(this,new Int32Array(t),e,n)}function Oi(t,e,n){Ri.call(this,new Uint32Array(t),e,n)}function Fi(t,e,n){Ri.call(this,new Float32Array(t),e,n)}function zi(t,e,n){Ri.call(this,new Float64Array(t),e,n)}function Di(){this.indices=[],this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}function Ui(t){if(0===t.length)return-1/0;for(var e=t[0],n=1,i=t.length;n<i;++n)t[n]>e&&(e=t[n]);return e}Ai.prototype=Object.assign(Object.create(i.prototype),{constructor:Ai,isGeometry:!0,applyMatrix:function(t){for(var e=(new Ze).getNormalMatrix(t),n=0,i=this.vertices.length;n<i;n++){this.vertices[n].applyMatrix4(t)}for(n=0,i=this.faces.length;n<i;n++){var r=this.faces[n];r.normal.applyMatrix3(e).normalize();for(var o=0,a=r.vertexNormals.length;o<a;o++)r.vertexNormals[o].applyMatrix3(e).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,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,i){return t.makeTranslation(e,n,i),this.applyMatrix(t),this}}(),scale:function(){var t=new qe;return function(e,n,i){return t.makeScale(e,n,i),this.applyMatrix(t),this}}(),lookAt:(Si=new bi,function(t){Si.lookAt(t),Si.updateMatrix(),this.applyMatrix(Si.matrix)}),fromBufferGeometry:function(t){var e=this,n=null!==t.index?t.index.array:void 0,i=t.attributes,r=i.position.array,o=void 0!==i.normal?i.normal.array:void 0,a=void 0!==i.color?i.color.array:void 0,s=void 0!==i.uv?i.uv.array:void 0,c=void 0!==i.uv2?i.uv2.array:void 0;void 0!==c&&(this.faceVertexUvs[1]=[]);for(var h=[],l=[],u=[],p=0,d=0;p<r.length;p+=3,d+=2)e.vertices.push(new Ye(r[p],r[p+1],r[p+2])),void 0!==o&&h.push(new Ye(o[p],o[p+1],o[p+2])),void 0!==a&&e.colors.push(new kn(a[p],a[p+1],a[p+2])),void 0!==s&&l.push(new We(s[d],s[d+1])),void 0!==c&&u.push(new We(c[d],c[d+1]));function f(t,n,i,r){var p=new Ei(t,n,i,void 0!==o?[h[t].clone(),h[n].clone(),h[i].clone()]:[],void 0!==a?[e.colors[t].clone(),e.colors[n].clone(),e.colors[i].clone()]:[],r);e.faces.push(p),void 0!==s&&e.faceVertexUvs[0].push([l[t].clone(),l[n].clone(),l[i].clone()]),void 0!==c&&e.faceVertexUvs[1].push([u[t].clone(),u[n].clone(),u[i].clone()])}var m=t.groups;if(m.length>0)for(p=0;p<m.length;p++)for(var v=m[p],g=v.start,y=(d=g,g+v.count);d<y;d+=3)void 0!==n?f(n[d],n[d+1],n[d+2],v.materialIndex):f(d,d+1,d+2,v.materialIndex);else if(void 0!==n)for(p=0;p<n.length;p+=3)f(n[p],n[p+1],n[p+2]);else for(p=0;p<r.length/3;p+=3)f(p,p+1,p+2);return this.computeFaceNormals(),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this},center:function(){this.computeBoundingBox();var t=this.boundingBox.getCenter().negate();return this.translate(t.x,t.y,t.z),t},normalize:function(){this.computeBoundingSphere();var t=this.boundingSphere.center,e=this.boundingSphere.radius,n=0===e?1:1/e,i=new qe;return i.set(n,0,0,-n*t.x,0,n,0,-n*t.y,0,0,n,-n*t.z,0,0,0,1),this.applyMatrix(i),this},computeFaceNormals:function(){for(var t=new Ye,e=new Ye,n=0,i=this.faces.length;n<i;n++){var r=this.faces[n],o=this.vertices[r.a],a=this.vertices[r.b],s=this.vertices[r.c];t.subVectors(s,a),e.subVectors(o,a),t.cross(e),t.normalize(),r.normal.copy(t)}},computeVertexNormals:function(t){var e,n,i,r,o,a;for(void 0===t&&(t=!0),a=new Array(this.vertices.length),e=0,n=this.vertices.length;e<n;e++)a[e]=new Ye;if(t){var s,c,h,l=new Ye,u=new Ye;for(i=0,r=this.faces.length;i<r;i++)o=this.faces[i],s=this.vertices[o.a],c=this.vertices[o.b],h=this.vertices[o.c],l.subVectors(h,c),u.subVectors(s,c),l.cross(u),a[o.a].add(l),a[o.b].add(l),a[o.c].add(l)}else for(this.computeFaceNormals(),i=0,r=this.faces.length;i<r;i++)a[(o=this.faces[i]).a].add(o.normal),a[o.b].add(o.normal),a[o.c].add(o.normal);for(e=0,n=this.vertices.length;e<n;e++)a[e].normalize();for(i=0,r=this.faces.length;i<r;i++){var p=(o=this.faces[i]).vertexNormals;3===p.length?(p[0].copy(a[o.a]),p[1].copy(a[o.b]),p[2].copy(a[o.c])):(p[0]=a[o.a].clone(),p[1]=a[o.b].clone(),p[2]=a[o.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,n;for(this.computeFaceNormals(),t=0,e=this.faces.length;t<e;t++){var i=(n=this.faces[t]).vertexNormals;3===i.length?(i[0].copy(n.normal),i[1].copy(n.normal),i[2].copy(n.normal)):(i[0]=n.normal.clone(),i[1]=n.normal.clone(),i[2]=n.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,n,i,r;for(n=0,i=this.faces.length;n<i;n++)for((r=this.faces[n]).__originalFaceNormal?r.__originalFaceNormal.copy(r.normal):r.__originalFaceNormal=r.normal.clone(),r.__originalVertexNormals||(r.__originalVertexNormals=[]),t=0,e=r.vertexNormals.length;t<e;t++)r.__originalVertexNormals[t]?r.__originalVertexNormals[t].copy(r.vertexNormals[t]):r.__originalVertexNormals[t]=r.vertexNormals[t].clone();var o=new Ai;for(o.faces=this.faces,t=0,e=this.morphTargets.length;t<e;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];var a=this.morphNormals[t].faceNormals,s=this.morphNormals[t].vertexNormals;for(n=0,i=this.faces.length;n<i;n++)c=new Ye,h={a:new Ye,b:new Ye,c:new Ye},a.push(c),s.push(h)}var c,h,l=this.morphNormals[t];for(o.vertices=this.morphTargets[t].vertices,o.computeFaceNormals(),o.computeVertexNormals(),n=0,i=this.faces.length;n<i;n++)r=this.faces[n],c=l.faceNormals[n],h=l.vertexNormals[n],c.copy(r.normal),h.a.copy(r.vertexNormals[0]),h.b.copy(r.vertexNormals[1]),h.c.copy(r.vertexNormals[2])}for(n=0,i=this.faces.length;n<i;n++)(r=this.faces[n]).normal=r.__originalFaceNormal,r.vertexNormals=r.__originalVertexNormals},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new ci),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new hi),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,n){if(t&&t.isGeometry){var i,r=this.vertices.length,o=this.vertices,a=t.vertices,s=this.faces,c=t.faces,h=this.faceVertexUvs[0],l=t.faceVertexUvs[0],u=this.colors,p=t.colors;void 0===n&&(n=0),void 0!==e&&(i=(new Ze).getNormalMatrix(e));for(var d=0,f=a.length;d<f;d++){var m=a[d].clone();void 0!==e&&m.applyMatrix4(e),o.push(m)}for(d=0,f=p.length;d<f;d++)u.push(p[d].clone());for(d=0,f=c.length;d<f;d++){var v,g,y,x=c[d],w=x.vertexNormals,b=x.vertexColors;(v=new Ei(x.a+r,x.b+r,x.c+r)).normal.copy(x.normal),void 0!==i&&v.normal.applyMatrix3(i).normalize();for(var _=0,M=w.length;_<M;_++)g=w[_].clone(),void 0!==i&&g.applyMatrix3(i).normalize(),v.vertexNormals.push(g);v.color.copy(x.color);for(_=0,M=b.length;_<M;_++)y=b[_],v.vertexColors.push(y.clone());v.materialIndex=x.materialIndex+n,s.push(v)}for(d=0,f=l.length;d<f;d++){var E=l[d],S=[];if(void 0!==E){for(_=0,M=E.length;_<M;_++)S.push(E[_].clone());h.push(S)}}}else console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t)},mergeMesh:function(t){t&&t.isMesh?(t.matrixAutoUpdate&&t.updateMatrix(),this.merge(t.geometry,t.matrix)):console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",t)},mergeVertices:function(){var t,e,n,i,r,o,a,s,c={},h=[],l=[],u=Math.pow(10,4);for(n=0,i=this.vertices.length;n<i;n++)t=this.vertices[n],void 0===c[e=Math.round(t.x*u)+"_"+Math.round(t.y*u)+"_"+Math.round(t.z*u)]?(c[e]=n,h.push(this.vertices[n]),l[n]=h.length-1):l[n]=l[c[e]];var p=[];for(n=0,i=this.faces.length;n<i;n++){(r=this.faces[n]).a=l[r.a],r.b=l[r.b],r.c=l[r.c],o=[r.a,r.b,r.c];for(var d=0;d<3;d++)if(o[d]===o[(d+1)%3]){p.push(n);break}}for(n=p.length-1;n>=0;n--){var f=p[n];for(this.faces.splice(f,1),a=0,s=this.faceVertexUvs.length;a<s;a++)this.faceVertexUvs[a].splice(f,1)}var m=this.vertices.length-h.length;return this.vertices=h,m},setFromPoints:function(t){this.vertices=[];for(var e=0,n=t.length;e<n;e++){var i=t[e];this.vertices.push(new Ye(i.x,i.y,i.z||0))}return this},sortFacesByMaterialIndex:function(){for(var t=this.faces,e=t.length,n=0;n<e;n++)t[n]._id=n;t.sort((function(t,e){return t.materialIndex-e.materialIndex}));var i,r,o=this.faceVertexUvs[0],a=this.faceVertexUvs[1];o&&o.length===e&&(i=[]),a&&a.length===e&&(r=[]);for(n=0;n<e;n++){var s=t[n]._id;i&&i.push(o[s]),r&&r.push(a[s])}i&&(this.faceVertexUvs[0]=i),r&&(this.faceVertexUvs[1]=r)},toJSON:function(){var t={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),void 0!==this.parameters){var e=this.parameters;for(var n in e)void 0!==e[n]&&(t[n]=e[n]);return t}for(var i=[],r=0;r<this.vertices.length;r++){var o=this.vertices[r];i.push(o.x,o.y,o.z)}var a=[],s=[],c={},h=[],l={},u=[],p={};for(r=0;r<this.faces.length;r++){var d=this.faces[r],f=void 0!==this.faceVertexUvs[0][r],m=d.normal.length()>0,v=d.vertexNormals.length>0,g=1!==d.color.r||1!==d.color.g||1!==d.color.b,y=d.vertexColors.length>0,x=0;if(x=M(x,0,0),x=M(x,1,!0),x=M(x,2,!1),x=M(x,3,f),x=M(x,4,m),x=M(x,5,v),x=M(x,6,g),x=M(x,7,y),a.push(x),a.push(d.a,d.b,d.c),a.push(d.materialIndex),f){var w=this.faceVertexUvs[0][r];a.push(T(w[0]),T(w[1]),T(w[2]))}if(m&&a.push(E(d.normal)),v){var b=d.vertexNormals;a.push(E(b[0]),E(b[1]),E(b[2]))}if(g&&a.push(S(d.color)),y){var _=d.vertexColors;a.push(S(_[0]),S(_[1]),S(_[2]))}}function M(t,e,n){return n?t|1<<e:t&~(1<<e)}function E(t){var e=t.x.toString()+t.y.toString()+t.z.toString();return void 0!==c[e]||(c[e]=s.length/3,s.push(t.x,t.y,t.z)),c[e]}function S(t){var e=t.r.toString()+t.g.toString()+t.b.toString();return void 0!==l[e]||(l[e]=h.length,h.push(t.getHex())),l[e]}function T(t){var e=t.x.toString()+t.y.toString();return void 0!==p[e]||(p[e]=u.length/2,u.push(t.x,t.y)),p[e]}return t.data={},t.data.vertices=i,t.data.normals=s,h.length>0&&(t.data.colors=h),u.length>0&&(t.data.uvs=[u]),t.data.faces=a,t},clone:function(){return(new Ai).copy(this)},copy:function(t){var e,n,i,r,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;e<n;e++)this.vertices.push(s[e].clone());var c=t.colors;for(e=0,n=c.length;e<n;e++)this.colors.push(c[e].clone());var h=t.faces;for(e=0,n=h.length;e<n;e++)this.faces.push(h[e].clone());for(e=0,n=t.faceVertexUvs.length;e<n;e++){var l=t.faceVertexUvs[e];for(void 0===this.faceVertexUvs[e]&&(this.faceVertexUvs[e]=[]),i=0,r=l.length;i<r;i++){var u=l[i],p=[];for(o=0,a=u.length;o<a;o++){var d=u[o];p.push(d.clone())}this.faceVertexUvs[e].push(p)}}var f=t.morphTargets;for(e=0,n=f.length;e<n;e++){var m={};if(m.name=f[e].name,void 0!==f[e].vertices)for(m.vertices=[],i=0,r=f[e].vertices.length;i<r;i++)m.vertices.push(f[e].vertices[i].clone());if(void 0!==f[e].normals)for(m.normals=[],i=0,r=f[e].normals.length;i<r;i++)m.normals.push(f[e].normals[i].clone());this.morphTargets.push(m)}var v=t.morphNormals;for(e=0,n=v.length;e<n;e++){var g={};if(void 0!==v[e].vertexNormals)for(g.vertexNormals=[],i=0,r=v[e].vertexNormals.length;i<r;i++){var y=v[e].vertexNormals[i],x={};x.a=y.a.clone(),x.b=y.b.clone(),x.c=y.c.clone(),g.vertexNormals.push(x)}if(void 0!==v[e].faceNormals)for(g.faceNormals=[],i=0,r=v[e].faceNormals.length;i<r;i++)g.faceNormals.push(v[e].faceNormals[i].clone());this.morphNormals.push(g)}var w=t.skinWeights;for(e=0,n=w.length;e<n;e++)this.skinWeights.push(w[e].clone());var b=t.skinIndices;for(e=0,n=b.length;e<n;e++)this.skinIndices.push(b[e].clone());var _=t.lineDistances;for(e=0,n=_.length;e<n;e++)this.lineDistances.push(_[e]);var M=t.boundingBox;null!==M&&(this.boundingBox=M.clone());var E=t.boundingSphere;return null!==E&&(this.boundingSphere=E.clone()),this.elementsNeedUpdate=t.elementsNeedUpdate,this.verticesNeedUpdate=t.verticesNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.lineDistancesNeedUpdate=t.lineDistancesNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(Ri.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Ri.prototype,{isBufferAttribute:!0,setArray:function(t){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.count=void 0!==t?t.length/this.itemSize:0,this.array=t},setDynamic:function(t){return this.dynamic=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.dynamic=t.dynamic,this},copyAt:function(t,e,n){t*=this.itemSize,n*=e.itemSize;for(var i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this},copyArray:function(t){return this.array.set(t),this},copyColorsArray:function(t){for(var e=this.array,n=0,i=0,r=t.length;i<r;i++){var o=t[i];void 0===o&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",i),o=new kn),e[n++]=o.r,e[n++]=o.g,e[n++]=o.b}return this},copyIndicesArray:function(t){for(var e=this.array,n=0,i=0,r=t.length;i<r;i++){var o=t[i];e[n++]=o.a,e[n++]=o.b,e[n++]=o.c}return this},copyVector2sArray:function(t){for(var e=this.array,n=0,i=0,r=t.length;i<r;i++){var o=t[i];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",i),o=new We),e[n++]=o.x,e[n++]=o.y}return this},copyVector3sArray:function(t){for(var e=this.array,n=0,i=0,r=t.length;i<r;i++){var o=t[i];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",i),o=new Ye),e[n++]=o.x,e[n++]=o.y,e[n++]=o.z}return this},copyVector4sArray:function(t){for(var e=this.array,n=0,i=0,r=t.length;i<r;i++){var o=t[i];void 0===o&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",i),o=new Ke),e[n++]=o.x,e[n++]=o.y,e[n++]=o.z,e[n++]=o.w}return this},set:function(t,e){return void 0===e&&(e=0),this.array.set(t,e),this},getX:function(t){return this.array[t*this.itemSize]},setX:function(t,e){return this.array[t*this.itemSize]=e,this},getY:function(t){return this.array[t*this.itemSize+1]},setY:function(t,e){return this.array[t*this.itemSize+1]=e,this},getZ:function(t){return this.array[t*this.itemSize+2]},setZ:function(t,e){return this.array[t*this.itemSize+2]=e,this},getW:function(t){return this.array[t*this.itemSize+3]},setW:function(t,e){return this.array[t*this.itemSize+3]=e,this},setXY:function(t,e,n){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this},setXYZ:function(t,e,n,i){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this},setXYZW:function(t,e,n,i,r){return t*=this.itemSize,this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this},onUpload:function(t){return this.onUploadCallback=t,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)}}),Ci.prototype=Object.create(Ri.prototype),Ci.prototype.constructor=Ci,Li.prototype=Object.create(Ri.prototype),Li.prototype.constructor=Li,Pi.prototype=Object.create(Ri.prototype),Pi.prototype.constructor=Pi,Bi.prototype=Object.create(Ri.prototype),Bi.prototype.constructor=Bi,Ii.prototype=Object.create(Ri.prototype),Ii.prototype.constructor=Ii,Ni.prototype=Object.create(Ri.prototype),Ni.prototype.constructor=Ni,Oi.prototype=Object.create(Ri.prototype),Oi.prototype.constructor=Oi,Fi.prototype=Object.create(Ri.prototype),Fi.prototype.constructor=Fi,zi.prototype=Object.create(Ri.prototype),zi.prototype.constructor=zi,Object.assign(Di.prototype,{computeGroups:function(t){for(var e,n=[],i=void 0,r=t.faces,o=0;o<r.length;o++){var a=r[o];a.materialIndex!==i&&(i=a.materialIndex,void 0!==e&&(e.count=3*o-e.start,n.push(e)),e={start:3*o,materialIndex:i})}void 0!==e&&(e.count=3*o-e.start,n.push(e)),this.groups=n},fromGeometry:function(t){var e,n=t.faces,i=t.vertices,r=t.faceVertexUvs,o=r[0]&&r[0].length>0,a=r[1]&&r[1].length>0,s=t.morphTargets,c=s.length;if(c>0){e=[];for(var h=0;h<c;h++)e[h]=[];this.morphTargets.position=e}var l,u=t.morphNormals,p=u.length;if(p>0){l=[];for(h=0;h<p;h++)l[h]=[];this.morphTargets.normal=l}var d=t.skinIndices,f=t.skinWeights,m=d.length===i.length,v=f.length===i.length;for(h=0;h<n.length;h++){var g=n[h];this.vertices.push(i[g.a],i[g.b],i[g.c]);var y=g.vertexNormals;if(3===y.length)this.normals.push(y[0],y[1],y[2]);else{var x=g.normal;this.normals.push(x,x,x)}var w,b=g.vertexColors;if(3===b.length)this.colors.push(b[0],b[1],b[2]);else{var _=g.color;this.colors.push(_,_,_)}if(!0===o)void 0!==(w=r[0][h])?this.uvs.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",h),this.uvs.push(new We,new We,new We));if(!0===a)void 0!==(w=r[1][h])?this.uvs2.push(w[0],w[1],w[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",h),this.uvs2.push(new We,new We,new We));for(var M=0;M<c;M++){var E=s[M].vertices;e[M].push(E[g.a],E[g.b],E[g.c])}for(M=0;M<p;M++){var S=u[M].vertexNormals[h];l[M].push(S.a,S.b,S.c)}m&&this.skinIndices.push(d[g.a],d[g.b],d[g.c]),v&&this.skinWeights.push(f[g.a],f[g.b],f[g.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,this}});var Vi,Gi,Hi,ji,ki,Wi,qi,Xi=1;function Yi(){Object.defineProperty(this,"id",{value:Xi+=2}),this.uuid=ke.generateUUID(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0}}function Zi(t,e,n,i,r,o){Ai.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:o},this.fromBufferGeometry(new Ji(t,e,n,i,r,o)),this.mergeVertices()}function Ji(t,e,n,i,r,o){Yi.call(this),this.type="BoxBufferGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:o};var a=this;t=t||1,e=e||1,n=n||1,i=Math.floor(i)||1,r=Math.floor(r)||1,o=Math.floor(o)||1;var s=[],c=[],h=[],l=[],u=0,p=0;function d(t,e,n,i,r,o,d,f,m,v,g){var y,x,w=o/m,b=d/v,_=o/2,M=d/2,E=f/2,S=m+1,T=v+1,A=0,R=0,C=new Ye;for(x=0;x<T;x++){var L=x*b-M;for(y=0;y<S;y++){var P=y*w-_;C[t]=P*i,C[e]=L*r,C[n]=E,c.push(C.x,C.y,C.z),C[t]=0,C[e]=0,C[n]=f>0?1:-1,h.push(C.x,C.y,C.z),l.push(y/m),l.push(1-x/v),A+=1}}for(x=0;x<v;x++)for(y=0;y<m;y++){var B=u+y+S*x,I=u+y+S*(x+1),N=u+(y+1)+S*(x+1),O=u+(y+1)+S*x;s.push(B,I,O),s.push(I,N,O),R+=6}a.addGroup(p,R,g),p+=R,u+=A}d("z","y","x",-1,-1,n,e,t,o,r,0),d("z","y","x",1,-1,n,e,-t,o,r,1),d("x","z","y",1,1,t,n,e,i,o,2),d("x","z","y",1,-1,t,n,-e,i,o,3),d("x","y","z",1,-1,t,e,n,i,r,4),d("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(s),this.addAttribute("position",new Fi(c,3)),this.addAttribute("normal",new Fi(h,3)),this.addAttribute("uv",new Fi(l,2))}function Qi(t,e,n,i){Ai.call(this),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i},this.fromBufferGeometry(new Ki(t,e,n,i)),this.mergeVertices()}function Ki(t,e,n,i){Yi.call(this),this.type="PlaneBufferGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};var r,o,a=(t=t||1)/2,s=(e=e||1)/2,c=Math.floor(n)||1,h=Math.floor(i)||1,l=c+1,u=h+1,p=t/c,d=e/h,f=[],m=[],v=[],g=[];for(o=0;o<u;o++){var y=o*d-s;for(r=0;r<l;r++){var x=r*p-a;m.push(x,-y,0),v.push(0,0,1),g.push(r/c),g.push(1-o/h)}}for(o=0;o<h;o++)for(r=0;r<c;r++){var w=r+l*o,b=r+l*(o+1),_=r+1+l*(o+1),M=r+1+l*o;f.push(w,b,M),f.push(b,_,M)}this.setIndex(f),this.addAttribute("position",new Fi(m,3)),this.addAttribute("normal",new Fi(v,3)),this.addAttribute("uv",new Fi(g,2))}function $i(t){oi.call(this),this.type="MeshBasicMaterial",this.color=new kn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ct,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.lights=!1,this.setValues(t)}function tr(t){oi.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,void 0!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}function er(t,e){this.origin=void 0!==t?t:new Ye,this.direction=void 0!==e?e:new Ye}function nr(t,e){this.start=void 0!==t?t:new Ye,this.end=void 0!==e?e:new Ye}function ir(t,e,n){this.a=void 0!==t?t:new Ye,this.b=void 0!==e?e:new Ye,this.c=void 0!==n?n:new Ye}function rr(t,e){bi.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new Yi,this.material=void 0!==e?e:new $i({color:16777215*Math.random()}),this.drawMode=Pe,this.updateMorphTargets()}function or(t,e,n,i){var r,o,a,s=new kn(0),c=0;function h(t,n){e.buffers.color.setClear(t.r,t.g,t.b,n,i)}return{getClearColor:function(){return s},setClearColor:function(t,e){s.set(t),h(s,c=void 0!==e?e:1)},getClearAlpha:function(){return c},setClearAlpha:function(t){h(s,c=t)},render:function(e,i,l,u){var p=i.background;null===p?h(s,c):p&&p.isColor&&(h(p,1),u=!0),(t.autoClear||u)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),p&&p.isCubeTexture?(void 0===a&&((a=new rr(new Ji(1,1,1),new tr({uniforms:Yn.cube.uniforms,vertexShader:Yn.cube.vertexShader,fragmentShader:Yn.cube.fragmentShader,side:S,depthTest:!0,depthWrite:!1,fog:!1}))).geometry.removeAttribute("normal"),a.geometry.removeAttribute("uv"),a.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},n.update(a.geometry)),a.material.uniforms.tCube.value=p,e.push(a,a.geometry,a.material,0,null)):p&&p.isTexture&&(void 0===r&&(r=new Mi(-1,1,1,-1,0,1),o=new rr(new Ki(2,2),new $i({depthTest:!1,depthWrite:!1,fog:!1})),n.update(o.geometry)),o.material.map=p,t.renderBufferDirect(r,null,o.geometry,o.material,o,null))}}}function ar(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.program&&e.program&&t.program!==e.program?t.program.id-e.program.id:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function sr(t,e){return t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function cr(){var t=[],e=0,n=[],i=[];return{opaque:n,transparent:i,init:function(){e=0,n.length=0,i.length=0},push:function(r,o,a,s,c){var h=t[e];void 0===h?(h={id:r.id,object:r,geometry:o,material:a,program:a.program,renderOrder:r.renderOrder,z:s,group:c},t[e]=h):(h.id=r.id,h.object=r,h.geometry=o,h.material=a,h.program=a.program,h.renderOrder=r.renderOrder,h.z=s,h.group=c),(!0===a.transparent?i:n).push(h),e++},sort:function(){n.length>1&&n.sort(ar),i.length>1&&i.sort(sr)}}}function hr(){var t={};return{get:function(e,n){var i=e.id+","+n.id,r=t[i];return void 0===r&&(r=new cr,t[i]=r),r},dispose:function(){t={}}}}function lr(t,e){return Math.abs(e[1])-Math.abs(t[1])}function ur(t){var e={},n=new Float32Array(8);return{update:function(i,r,o,a){var s=i.morphTargetInfluences,c=s.length,h=e[r.id];if(void 0===h){h=[];for(var l=0;l<c;l++)h[l]=[l,0];e[r.id]=h}var u=o.morphTargets&&r.morphAttributes.position,p=o.morphNormals&&r.morphAttributes.normal;for(l=0;l<c;l++){0!==(d=h[l])[1]&&(u&&r.removeAttribute("morphTarget"+l),p&&r.removeAttribute("morphNormal"+l))}for(l=0;l<c;l++){(d=h[l])[0]=l,d[1]=s[l]}for(h.sort(lr),l=0;l<8;l++){var d;if(d=h[l]){var f=d[0],m=d[1];if(m){u&&r.addAttribute("morphTarget"+l,u[f]),p&&r.addAttribute("morphNormal"+l,p[f]),n[l]=m;continue}}n[l]=0}a.getUniforms().setValue(t,"morphTargetInfluences",n)}}}function pr(t,e,n){var i,r,o;this.setMode=function(t){i=t},this.setIndex=function(t){r=t.type,o=t.bytesPerElement},this.render=function(e,a){t.drawElements(i,a,r,e*o),n.calls++,n.vertices+=a,i===t.TRIANGLES?n.faces+=a/3:i===t.POINTS&&(n.points+=a)},this.renderInstances=function(a,s,c){var h=e.get("ANGLE_instanced_arrays");null!==h?(h.drawElementsInstancedANGLE(i,c,r,s*o,a.maxInstancedCount),n.calls++,n.vertices+=c*a.maxInstancedCount,i===t.TRIANGLES?n.faces+=a.maxInstancedCount*c/3:i===t.POINTS&&(n.points+=a.maxInstancedCount*c)):console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.")}}function dr(t,e,n){var i;this.setMode=function(t){i=t},this.render=function(e,r){t.drawArrays(i,e,r),n.calls++,n.vertices+=r,i===t.TRIANGLES?n.faces+=r/3:i===t.POINTS&&(n.points+=r)},this.renderInstances=function(r,o,a){var s=e.get("ANGLE_instanced_arrays");if(null!==s){var c=r.attributes.position;c.isInterleavedBufferAttribute?(a=c.data.count,s.drawArraysInstancedANGLE(i,0,a,r.maxInstancedCount)):s.drawArraysInstancedANGLE(i,o,a,r.maxInstancedCount),n.calls++,n.vertices+=a*r.maxInstancedCount,i===t.TRIANGLES?n.faces+=r.maxInstancedCount*a/3:i===t.POINTS&&(n.points+=r.maxInstancedCount*a)}else console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.")}}function fr(t,e,n){var i={},r={};function o(t){var a=t.target,s=i[a.id];for(var c in null!==s.index&&e.remove(s.index),s.attributes)e.remove(s.attributes[c]);a.removeEventListener("dispose",o),delete i[a.id];var h=r[a.id];h&&(e.remove(h),delete r[a.id]),(h=r[s.id])&&(e.remove(h),delete r[s.id]),n.geometries--}return{get:function(t,e){var r=i[e.id];return r||(e.addEventListener("dispose",o),e.isBufferGeometry?r=e:e.isGeometry&&(void 0===e._bufferGeometry&&(e._bufferGeometry=(new Yi).setFromObject(t)),r=e._bufferGeometry),i[e.id]=r,n.geometries++,r)},update:function(n){var i=n.index,r=n.attributes;for(var o in null!==i&&e.update(i,t.ELEMENT_ARRAY_BUFFER),r)e.update(r[o],t.ARRAY_BUFFER);var a=n.morphAttributes;for(var o in a)for(var s=a[o],c=0,h=s.length;c<h;c++)e.update(s[c],t.ARRAY_BUFFER)},getWireframeAttribute:function(n){var i=r[n.id];if(i)return i;var o,a=[],s=n.index,c=n.attributes;if(null!==s)for(var h=0,l=(o=s.array).length;h<l;h+=3){var u=o[h+0],p=o[h+1],d=o[h+2];a.push(u,p,p,d,d,u)}else for(h=0,l=(o=c.position.array).length/3-1;h<l;h+=3){u=h+0,p=h+1,d=h+2;a.push(u,p,p,d,d,u)}return i=new(Ui(a)>65535?Oi:Ii)(a,1),e.update(i,t.ELEMENT_ARRAY_BUFFER),r[n.id]=i,i}}}function mr(t,e){var n={};return{update:function(i){var r=e.frame,o=i.geometry,a=t.get(i,o);return n[a.id]!==r&&(o.isGeometry&&a.updateFromObject(i),t.update(a),n[a.id]=r),a},dispose:function(){n={}}}}function vr(t,e,n){var i=t.createShader(e);return t.shaderSource(i,n),t.compileShader(i),!1===t.getShaderParameter(i,t.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile."),""!==t.getShaderInfoLog(i)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",e===t.VERTEX_SHADER?"vertex":"fragment",t.getShaderInfoLog(i),function(t){for(var e=t.split("\n"),n=0;n<e.length;n++)e[n]=n+1+": "+e[n];return e.join("\n")}(n)),i}Yi.prototype=Object.assign(Object.create(i.prototype),{constructor:Yi,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(t){Array.isArray(t)?this.index=new(Ui(t)>65535?Oi:Ii)(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 Ri(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 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,i){return t.makeTranslation(e,n,i),this.applyMatrix(t),this}}(),scale:function(){var t=new qe;return function(e,n,i){return t.makeScale(e,n,i),this.applyMatrix(t),this}}(),lookAt:function(){var t=new bi;return function(e){t.lookAt(e),t.updateMatrix(),this.applyMatrix(t.matrix)}}(),center:function(){this.computeBoundingBox();var t=this.boundingBox.getCenter().negate();return this.translate(t.x,t.y,t.z),t},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var n=new Fi(3*e.vertices.length,3),i=new Fi(3*e.colors.length,3);if(this.addAttribute("position",n.copyVector3sArray(e.vertices)),this.addAttribute("color",i.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var r=new Fi(e.lineDistances.length,1);this.addAttribute("lineDistance",r.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,i=t.length;n<i;n++){var r=t[n];e.push(r.x,r.y,r.z||0)}return this.addAttribute("position",new Fi(e,3)),this},updateFromObject:function(t){var e,n=t.geometry;if(t.isMesh){var i=n.__directGeometry;if(!0===n.elementsNeedUpdate&&(i=void 0,n.elementsNeedUpdate=!1),void 0===i)return this.fromGeometry(n);i.verticesNeedUpdate=n.verticesNeedUpdate,i.normalsNeedUpdate=n.normalsNeedUpdate,i.colorsNeedUpdate=n.colorsNeedUpdate,i.uvsNeedUpdate=n.uvsNeedUpdate,i.groupsNeedUpdate=n.groupsNeedUpdate,n.verticesNeedUpdate=!1,n.normalsNeedUpdate=!1,n.colorsNeedUpdate=!1,n.uvsNeedUpdate=!1,n.groupsNeedUpdate=!1,n=i}return!0===n.verticesNeedUpdate&&(void 0!==(e=this.attributes.position)&&(e.copyVector3sArray(n.vertices),e.needsUpdate=!0),n.verticesNeedUpdate=!1),!0===n.normalsNeedUpdate&&(void 0!==(e=this.attributes.normal)&&(e.copyVector3sArray(n.normals),e.needsUpdate=!0),n.normalsNeedUpdate=!1),!0===n.colorsNeedUpdate&&(void 0!==(e=this.attributes.color)&&(e.copyColorsArray(n.colors),e.needsUpdate=!0),n.colorsNeedUpdate=!1),n.uvsNeedUpdate&&(void 0!==(e=this.attributes.uv)&&(e.copyVector2sArray(n.uvs),e.needsUpdate=!0),n.uvsNeedUpdate=!1),n.lineDistancesNeedUpdate&&(void 0!==(e=this.attributes.lineDistance)&&(e.copyArray(n.lineDistances),e.needsUpdate=!0),n.lineDistancesNeedUpdate=!1),n.groupsNeedUpdate&&(n.computeGroups(t.geometry),this.groups=n.groups,n.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.__directGeometry=(new Di).fromGeometry(t),this.fromDirectGeometry(t.__directGeometry)},fromDirectGeometry:function(t){var e=new Float32Array(3*t.vertices.length);if(this.addAttribute("position",new Ri(e,3).copyVector3sArray(t.vertices)),t.normals.length>0){var n=new Float32Array(3*t.normals.length);this.addAttribute("normal",new Ri(n,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var i=new Float32Array(3*t.colors.length);this.addAttribute("color",new Ri(i,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var r=new Float32Array(2*t.uvs.length);this.addAttribute("uv",new Ri(r,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var o=new Float32Array(2*t.uvs2.length);this.addAttribute("uv2",new Ri(o,2).copyVector2sArray(t.uvs2))}if(t.indices.length>0){var a=new(Ui(t.indices)>65535?Uint32Array:Uint16Array)(3*t.indices.length);this.setIndex(new Ri(a,1).copyIndicesArray(t.indices))}for(var s in this.groups=t.groups,t.morphTargets){for(var c=[],h=t.morphTargets[s],l=0,u=h.length;l<u;l++){var p=h[l],d=new Fi(3*p.length,3);c.push(d.copyVector3sArray(p))}this.morphAttributes[s]=c}if(t.skinIndices.length>0){var f=new Fi(4*t.skinIndices.length,4);this.addAttribute("skinIndex",f.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var m=new Fi(4*t.skinWeights.length,4);this.addAttribute("skinWeight",m.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 ci);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 ci,e=new Ye;return function(){null===this.boundingSphere&&(this.boundingSphere=new hi);var n=this.attributes.position;if(n){var i=this.boundingSphere.center;t.setFromBufferAttribute(n),t.getCenter(i);for(var r=0,o=0,a=n.count;o<a;o++)e.x=n.getX(o),e.y=n.getY(o),e.z=n.getZ(o),r=Math.max(r,i.distanceToSquared(e));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}}(),computeFaceNormals:function(){},computeVertexNormals:function(){var t=this.index,e=this.attributes,n=this.groups;if(e.position){var i=e.position.array;if(void 0===e.normal)this.addAttribute("normal",new Ri(new Float32Array(i.length),3));else for(var r=e.normal.array,o=0,a=r.length;o<a;o++)r[o]=0;var s,c,h,l=e.normal.array,u=new Ye,p=new Ye,d=new Ye,f=new Ye,m=new Ye;if(t){var v=t.array;0===n.length&&this.addGroup(0,v.length);for(var g=0,y=n.length;g<y;++g){var x=n[g],w=x.start;for(o=w,a=w+x.count;o<a;o+=3)s=3*v[o+0],c=3*v[o+1],h=3*v[o+2],u.fromArray(i,s),p.fromArray(i,c),d.fromArray(i,h),f.subVectors(d,p),m.subVectors(u,p),f.cross(m),l[s]+=f.x,l[s+1]+=f.y,l[s+2]+=f.z,l[c]+=f.x,l[c+1]+=f.y,l[c+2]+=f.z,l[h]+=f.x,l[h+1]+=f.y,l[h+2]+=f.z}}else for(o=0,a=i.length;o<a;o+=9)u.fromArray(i,o),p.fromArray(i,o+3),d.fromArray(i,o+6),f.subVectors(d,p),m.subVectors(u,p),f.cross(m),l[o]=f.x,l[o+1]=f.y,l[o+2]=f.z,l[o+3]=f.x,l[o+4]=f.y,l[o+5]=f.z,l[o+6]=f.x,l[o+7]=f.y,l[o+8]=f.z;this.normalizeNormals(),e.normal.needsUpdate=!0}},merge:function(t,e){if(t&&t.isBufferGeometry){void 0===e&&(e=0);var n=this.attributes;for(var i in n)if(void 0!==t.attributes[i])for(var r=n[i].array,o=t.attributes[i],a=o.array,s=0,c=o.itemSize*e;s<a.length;s++,c++)r[c]=a[s];return this}console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",t)},normalizeNormals:function(){var t=new Ye;return function(){for(var e=this.attributes.normal,n=0,i=e.count;n<i;n++)t.x=e.getX(n),t.y=e.getY(n),t.z=e.getZ(n),t.normalize(),e.setXYZ(n,t.x,t.y,t.z)}}(),toNonIndexed:function(){if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var t=new Yi,e=this.index.array,n=this.attributes;for(var i in n){for(var r=n[i],o=r.array,a=r.itemSize,s=new o.constructor(e.length*a),c=0,h=0,l=0,u=e.length;l<u;l++){c=e[l]*a;for(var p=0;p<a;p++)s[h++]=o[c++]}t.addAttribute(i,new Ri(s,a))}return t},toJSON:function(){var t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),void 0!==this.parameters){var e=this.parameters;for(var n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};var i=this.index;if(null!==i){var r=Array.prototype.slice.call(i.array);t.data.index={type:i.array.constructor.name,array:r}}var o=this.attributes;for(var n in o){var a=o[n];r=Array.prototype.slice.call(a.array);t.data.attributes[n]={itemSize:a.itemSize,type:a.array.constructor.name,array:r,normalized:a.normalized}}var s=this.groups;s.length>0&&(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 Yi).copy(this)},copy:function(t){var e,n,i;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var r=t.index;null!==r&&this.setIndex(r.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=[],h=s[e];for(n=0,i=h.length;n<i;n++)c.push(h[n].clone());this.morphAttributes[e]=c}var l=t.groups;for(n=0,i=l.length;n<i;n++){var u=l[n];this.addGroup(u.start,u.count,u.materialIndex)}var p=t.boundingBox;null!==p&&(this.boundingBox=p.clone());var d=t.boundingSphere;return null!==d&&(this.boundingSphere=d.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Zi.prototype=Object.create(Ai.prototype),Zi.prototype.constructor=Zi,Ji.prototype=Object.create(Yi.prototype),Ji.prototype.constructor=Ji,Qi.prototype=Object.create(Ai.prototype),Qi.prototype.constructor=Qi,Ki.prototype=Object.create(Yi.prototype),Ki.prototype.constructor=Ki,$i.prototype=Object.create(oi.prototype),$i.prototype.constructor=$i,$i.prototype.isMeshBasicMaterial=!0,$i.prototype.copy=function(t){return oi.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},tr.prototype=Object.create(oi.prototype),tr.prototype.constructor=tr,tr.prototype.isShaderMaterial=!0,tr.prototype.copy=function(t){return oi.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=qn.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},tr.prototype.toJSON=function(t){var e=oi.prototype.toJSON.call(this,t);return e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e},Object.assign(er.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(e||new Ye).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){var n=e||new Ye;n.subVectors(t,this.origin);var i=n.dot(this.direction);return i<0?n.copy(this.origin):n.copy(this.direction).multiplyScalar(i).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:(Gi=new Ye,Hi=new Ye,ji=new Ye,function(t,e,n,i){Gi.copy(t).add(e).multiplyScalar(.5),Hi.copy(e).sub(t).normalize(),ji.copy(this.origin).sub(Gi);var r,o,a,s,c=.5*t.distanceTo(e),h=-this.direction.dot(Hi),l=ji.dot(this.direction),u=-ji.dot(Hi),p=ji.lengthSq(),d=Math.abs(1-h*h);if(d>0)if(o=h*l-u,s=c*d,(r=h*u-l)>=0)if(o>=-s)if(o<=s){var f=1/d;a=(r*=f)*(r+h*(o*=f)+2*l)+o*(h*r+o+2*u)+p}else o=c,a=-(r=Math.max(0,-(h*o+l)))*r+o*(o+2*u)+p;else o=-c,a=-(r=Math.max(0,-(h*o+l)))*r+o*(o+2*u)+p;else o<=-s?a=-(r=Math.max(0,-(-h*c+l)))*r+(o=r>0?-c:Math.min(Math.max(-c,-u),c))*(o+2*u)+p:o<=s?(r=0,a=(o=Math.min(Math.max(-c,-u),c))*(o+2*u)+p):a=-(r=Math.max(0,-(h*c+l)))*r+(o=r>0?c:Math.min(Math.max(-c,-u),c))*(o+2*u)+p;else o=h>0?-c:c,a=-(r=Math.max(0,-(h*o+l)))*r+o*(o+2*u)+p;return n&&n.copy(this.direction).multiplyScalar(r).add(this.origin),i&&i.copy(Hi).multiplyScalar(o).add(Gi),a}),intersectSphere:function(){var t=new Ye;return function(e,n){t.subVectors(e.center,this.origin);var i=t.dot(this.direction),r=t.dot(t)-i*i,o=e.radius*e.radius;if(r>o)return null;var a=Math.sqrt(o-r),s=i-a,c=i+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,i,r,o,a,s,c=1/this.direction.x,h=1/this.direction.y,l=1/this.direction.z,u=this.origin;return c>=0?(n=(t.min.x-u.x)*c,i=(t.max.x-u.x)*c):(n=(t.max.x-u.x)*c,i=(t.min.x-u.x)*c),h>=0?(r=(t.min.y-u.y)*h,o=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,o=(t.min.y-u.y)*h),n>o||r>i?null:((r>n||n!=n)&&(n=r),(o<i||i!=i)&&(i=o),l>=0?(a=(t.min.z-u.z)*l,s=(t.max.z-u.z)*l):(a=(t.max.z-u.z)*l,s=(t.min.z-u.z)*l),n>s||a>i?null:((a>n||n!=n)&&(n=a),(s<i||i!=i)&&(i=s),i<0?null:this.at(n>=0?n:i,e)))},intersectsBox:(Vi=new Ye,function(t){return null!==this.intersectBox(t,Vi)}),intersectTriangle:function(){var t=new Ye,e=new Ye,n=new Ye,i=new Ye;return function(r,o,a,s,c){e.subVectors(o,r),n.subVectors(a,r),i.crossVectors(e,n);var h,l=this.direction.dot(i);if(l>0){if(s)return null;h=1}else{if(!(l<0))return null;h=-1,l=-l}t.subVectors(this.origin,r);var u=h*this.direction.dot(n.crossVectors(t,n));if(u<0)return null;var p=h*this.direction.dot(e.cross(t));if(p<0)return null;if(u+p>l)return null;var d=-h*t.dot(i);return d<0?null:this.at(d/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(nr.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(t||new Ye).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return(t||new Ye).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){var n=e||new Ye;return this.delta(n).multiplyScalar(t).add(this.start)},closestPointToPointParameter:(ki=new Ye,Wi=new Ye,function(t,e){ki.subVectors(t,this.start),Wi.subVectors(this.end,this.start);var n=Wi.dot(Wi),i=Wi.dot(ki)/n;return e&&(i=ke.clamp(i,0,1)),i}),closestPointToPoint:function(t,e,n){var i=this.closestPointToPointParameter(t,e),r=n||new Ye;return this.delta(r).multiplyScalar(i).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(ir,{normal:(qi=new Ye,function(t,e,n,i){var r=i||new Ye;r.subVectors(n,e),qi.subVectors(t,e),r.cross(qi);var o=r.lengthSq();return o>0?r.multiplyScalar(1/Math.sqrt(o)):r.set(0,0,0)}),barycoordFromPoint:function(){var t=new Ye,e=new Ye,n=new Ye;return function(i,r,o,a,s){t.subVectors(a,r),e.subVectors(o,r),n.subVectors(i,r);var c=t.dot(t),h=t.dot(e),l=t.dot(n),u=e.dot(e),p=e.dot(n),d=c*u-h*h,f=s||new Ye;if(0===d)return f.set(-2,-1,-1);var m=1/d,v=(u*l-h*p)*m,g=(c*p-h*l)*m;return f.set(1-v-g,g,v)}}(),containsPoint:function(){var t=new Ye;return function(e,n,i,r){var o=ir.barycoordFromPoint(e,n,i,r,t);return o.x>=0&&o.y>=0&&o.x+o.y<=1}}()}),Object.assign(ir.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,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),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},area: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()}}(),midpoint:function(t){return(t||new Ye).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return ir.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new li).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return ir.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return ir.containsPoint(t,this.a,this.b,this.c)},intersectsBox:function(t){return t.intersectsTriangle(this)},closestPointToPoint:function(){var t=new li,e=[new nr,new nr,new nr],n=new Ye,i=new Ye;return function(r,o){var a=o||new Ye,s=1/0;if(t.setFromCoplanarPoints(this.a,this.b,this.c),t.projectPoint(r,n),!0===this.containsPoint(n))a.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 c=0;c<e.length;c++){e[c].closestPointToPoint(n,!0,i);var h=n.distanceToSquared(i);h<s&&(s=h,a.copy(i))}}return a}}(),equals:function(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}),rr.prototype=Object.assign(Object.create(bi.prototype),{constructor:rr,isMesh:!0,setDrawMode:function(t){this.drawMode=t},copy:function(t){return bi.prototype.copy.call(this,t),this.drawMode=t.drawMode,void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this},updateMorphTargets:function(){var t,e,n,i=this.geometry;if(i.isBufferGeometry){var r=i.morphAttributes,o=Object.keys(r);if(o.length>0){var a=r[o[0]];if(void 0!==a)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=a.length;t<e;t++)n=a[t].name||String(t),this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}else{var s=i.morphTargets;if(void 0!==s&&s.length>0)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=s.length;t<e;t++)n=s[t].name||String(t),this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}},raycast:function(){var t=new qe,e=new er,n=new hi,i=new Ye,r=new Ye,o=new Ye,a=new Ye,s=new Ye,c=new Ye,h=new We,l=new We,u=new We,p=new Ye,d=new Ye,f=new Ye;function m(t,e,n,i,r,o,a){return ir.barycoordFromPoint(t,e,n,i,p),r.multiplyScalar(p.x),o.multiplyScalar(p.y),a.multiplyScalar(p.z),r.add(o).add(a),r.clone()}function v(t,e,n,i,r,o,a,s){if(null===(e.side===S?i.intersectTriangle(a,o,r,!0,s):i.intersectTriangle(r,o,a,e.side!==T,s)))return null;f.copy(s),f.applyMatrix4(t.matrixWorld);var c=n.ray.origin.distanceTo(f);return c<n.near||c>n.far?null:{distance:c,point:f.clone(),object:t}}function g(t,e,n,a,s,c,p,f){i.fromBufferAttribute(a,c),r.fromBufferAttribute(a,p),o.fromBufferAttribute(a,f);var g=v(t,t.material,e,n,i,r,o,d);return g&&(s&&(h.fromBufferAttribute(s,c),l.fromBufferAttribute(s,p),u.fromBufferAttribute(s,f),g.uv=m(d,i,r,o,h,l,u)),g.face=new Ei(c,p,f,ir.normal(i,r,o)),g.faceIndex=c),g}return function(p,f){var y,x=this.geometry,w=this.material,b=this.matrixWorld;if(void 0!==w&&(null===x.boundingSphere&&x.computeBoundingSphere(),n.copy(x.boundingSphere),n.applyMatrix4(b),!1!==p.ray.intersectsSphere(n)&&(t.getInverse(b),e.copy(p.ray).applyMatrix4(t),null===x.boundingBox||!1!==e.intersectsBox(x.boundingBox))))if(x.isBufferGeometry){var _,M,E,S,T,A=x.index,R=x.attributes.position,C=x.attributes.uv;if(null!==A)for(S=0,T=A.count;S<T;S+=3)_=A.getX(S),M=A.getX(S+1),E=A.getX(S+2),(y=g(this,p,e,R,C,_,M,E))&&(y.faceIndex=Math.floor(S/3),f.push(y));else if(void 0!==R)for(S=0,T=R.count;S<T;S+=3)(y=g(this,p,e,R,C,_=S,M=S+1,E=S+2))&&(y.index=_,f.push(y))}else if(x.isGeometry){var L,P,B,I,N=Array.isArray(w),O=x.vertices,F=x.faces,z=x.faceVertexUvs[0];z.length>0&&(I=z);for(var D=0,U=F.length;D<U;D++){var V=F[D],G=N?w[V.materialIndex]:w;if(void 0!==G){if(L=O[V.a],P=O[V.b],B=O[V.c],!0===G.morphTargets){var H=x.morphTargets,j=this.morphTargetInfluences;i.set(0,0,0),r.set(0,0,0),o.set(0,0,0);for(var k=0,W=H.length;k<W;k++){var q=j[k];if(0!==q){var X=H[k].vertices;i.addScaledVector(a.subVectors(X[V.a],L),q),r.addScaledVector(s.subVectors(X[V.b],P),q),o.addScaledVector(c.subVectors(X[V.c],B),q)}}i.add(L),r.add(P),o.add(B),L=i,P=r,B=o}if(y=v(this,G,p,e,L,P,B,d)){if(I&&I[D]){var Y=I[D];h.copy(Y[0]),l.copy(Y[1]),u.copy(Y[2]),y.uv=m(d,L,P,B,h,l,u)}y.face=V,y.faceIndex=D,f.push(y)}}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var gr=0;function yr(t){switch(t){case Ne:return["Linear","( value )"];case Oe:return["sRGB","( value )"];case ze:return["RGBE","( value )"];case Ue:return["RGBM","( value, 7.0 )"];case Ve:return["RGBM","( value, 16.0 )"];case Ge:return["RGBD","( value, 256.0 )"];case Fe:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw new Error("unsupported encoding: "+t)}}function xr(t,e){var n=yr(e);return"vec4 "+t+"( vec4 value ) { return "+n[0]+"ToLinear"+n[1]+"; }"}function wr(t,e){var n;switch(e){case pt:n="Linear";break;case dt: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 ); }"}function br(t){return""!==t}function _r(t,e){return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights)}function Mr(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}function Er(t){return t.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,(function(t,e){var n=Xn[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return Er(n)}))}function Sr(t){return t.replace(/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,(function(t,e,n,i){for(var r="",o=parseInt(e);o<parseInt(n);o++)r+=i.replace(/\[ i \]/g,"[ "+o+" ]");return r}))}function Tr(t,e,n,i,r,o){var a=t.context,s=i.defines,c=r.vertexShader,h=r.fragmentShader,l="SHADOWMAP_TYPE_BASIC";o.shadowMapType===_?l="SHADOWMAP_TYPE_PCF":o.shadowMapType===M&&(l="SHADOWMAP_TYPE_PCF_SOFT");var u="ENVMAP_TYPE_CUBE",p="ENVMAP_MODE_REFLECTION",d="ENVMAP_BLENDING_MULTIPLY";if(o.envMap){switch(i.envMap.mapping){case gt:case yt:u="ENVMAP_TYPE_CUBE";break;case _t:case Mt:u="ENVMAP_TYPE_CUBE_UV";break;case xt:case wt:u="ENVMAP_TYPE_EQUIREC";break;case bt:u="ENVMAP_TYPE_SPHERE"}switch(i.envMap.mapping){case yt:case wt:p="ENVMAP_MODE_REFRACTION"}switch(i.combine){case ct:d="ENVMAP_BLENDING_MULTIPLY";break;case ht:d="ENVMAP_BLENDING_MIX";break;case lt:d="ENVMAP_BLENDING_ADD"}}var f,m,v,g,y,x=t.gammaFactor>0?t.gammaFactor:1,w=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(br).join("\n")}(i.extensions,o,e),b=function(t){var e=[];for(var n in t){var i=t[n];!1!==i&&e.push("#define "+n+" "+i)}return e.join("\n")}(s),E=a.createProgram();i.isRawShaderMaterial?((f=[b].filter(br).join("\n")).length>0&&(f+="\n"),(m=[w,b].filter(br).join("\n")).length>0&&(m+="\n")):(f=["precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+r.name,b,o.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+x,"#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 "+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.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(br).join("\n"),m=[w,"precision "+o.precision+" float;","precision "+o.precision+" int;","#define SHADER_NAME "+r.name,b,o.alphaTest?"#define ALPHATEST "+o.alphaTest:"","#define GAMMA_FACTOR "+x,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 "+u:"",o.envMap?"#define "+p:"",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.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!==ut?"#define TONE_MAPPING":"",o.toneMapping!==ut?Xn.tonemapping_pars_fragment:"",o.toneMapping!==ut?wr("toneMapping",o.toneMapping):"",o.dithering?"#define DITHERING":"",o.outputEncoding||o.mapEncoding||o.envMapEncoding||o.emissiveMapEncoding?Xn.encodings_pars_fragment:"",o.mapEncoding?xr("mapTexelToLinear",o.mapEncoding):"",o.envMapEncoding?xr("envMapTexelToLinear",o.envMapEncoding):"",o.emissiveMapEncoding?xr("emissiveMapTexelToLinear",o.emissiveMapEncoding):"",o.outputEncoding?(v="linearToOutputTexel",g=o.outputEncoding,y=yr(g),"vec4 "+v+"( vec4 value ) { return LinearTo"+y[0]+y[1]+"; }"):"",o.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(br).join("\n")),c=Mr(c=_r(c=Er(c),o),o),h=Mr(h=_r(h=Er(h),o),o);var S=f+(c=Sr(c)),T=m+(h=Sr(h)),A=vr(a,a.VERTEX_SHADER,S),R=vr(a,a.FRAGMENT_SHADER,T);a.attachShader(E,A),a.attachShader(E,R),void 0!==i.index0AttributeName?a.bindAttribLocation(E,0,i.index0AttributeName):!0===o.morphTargets&&a.bindAttribLocation(E,0,"position"),a.linkProgram(E);var C,L,P=a.getProgramInfoLog(E).trim(),B=a.getShaderInfoLog(A).trim(),I=a.getShaderInfoLog(R).trim(),N=!0,O=!0;return!1===a.getProgramParameter(E,a.LINK_STATUS)?(N=!1,console.error("THREE.WebGLProgram: shader error: ",a.getError(),"gl.VALIDATE_STATUS",a.getProgramParameter(E,a.VALIDATE_STATUS),"gl.getProgramInfoLog",P,B,I)):""!==P?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",P):""!==B&&""!==I||(O=!1),O&&(this.diagnostics={runnable:N,material:i,programLog:P,vertexShader:{log:B,prefix:f},fragmentShader:{log:I,prefix:m}}),a.deleteShader(A),a.deleteShader(R),this.getUniforms=function(){return void 0===C&&(C=new Hn(a,E,t)),C},this.getAttributes=function(){return void 0===L&&(L=function(t,e){for(var n={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),r=0;r<i;r++){var o=t.getActiveAttrib(e,r).name;n[o]=t.getAttribLocation(e,o)}return n}(a,E)),L},this.destroy=function(){a.deleteProgram(E),this.program=void 0},Object.defineProperties(this,{uniforms:{get:function(){return console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms()."),this.getUniforms()}},attributes:{get:function(){return console.warn("THREE.WebGLProgram: .attributes is now .getAttributes()."),this.getAttributes()}}}),this.id=gr++,this.code=n,this.usedTimes=1,this.program=E,this.vertexShader=A,this.fragmentShader=R,this}function Ar(t,e,n){var i=[],r={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow"},o=["precision","supportsVertexTextures","map","mapEncoding","envMap","envMapMode","envMapEncoding","lightMap","aoMap","emissiveMap","emissiveMapEncoding","bumpMap","normalMap","displacementMap","specularMap","roughnessMap","metalnessMap","gradientMap","alphaMap","combine","vertexColors","fog","useFog","fogExp","flatShading","sizeAttenuation","logarithmicDepthBuffer","skinning","maxBones","useVertexTexture","morphTargets","morphNormals","maxMorphTargets","maxMorphNormals","premultipliedAlpha","numDirLights","numPointLights","numSpotLights","numHemiLights","numRectAreaLights","shadowMapEnabled","shadowMapType","toneMapping","physicallyCorrectLights","alphaTest","doubleSided","flipSided","numClippingPlanes","numClipIntersection","depthPacking","dithering"];function a(t,e){var n;return t?t.isTexture?n=t.encoding:t.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),n=t.texture.encoding):n=Ne,n===Ne&&e&&(n=Fe),n}this.getParameters=function(e,i,o,s,c,h,l){var u=r[e.type],p=l.isSkinnedMesh?function(t){var e=t.skeleton.bones;if(n.floatVertexTextures)return 1024;var i=n.maxVertexUniforms,r=Math.floor((i-20)/4),o=Math.min(r,e.length);return o<e.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+e.length+" bones. This GPU supports "+o+"."),0):o}(l):0,d=n.precision;null!==e.precision&&(d=n.getMaxPrecision(e.precision))!==e.precision&&console.warn("THREE.WebGLProgram.getParameters:",e.precision,"not supported, using",d,"instead.");var f=t.getRenderTarget();return{shaderID:u,precision:d,supportsVertexTextures:n.vertexTextures,outputEncoding:a(f?f.texture:null,t.gammaOutput),map:!!e.map,mapEncoding:a(e.map,t.gammaInput),envMap:!!e.envMap,envMapMode:e.envMap&&e.envMap.mapping,envMapEncoding:a(e.envMap,t.gammaInput),envMapCubeUV:!!e.envMap&&(e.envMap.mapping===_t||e.envMap.mapping===Mt),lightMap:!!e.lightMap,aoMap:!!e.aoMap,emissiveMap:!!e.emissiveMap,emissiveMapEncoding:a(e.emissiveMap,t.gammaInput),bumpMap:!!e.bumpMap,normalMap:!!e.normalMap,displacementMap:!!e.displacementMap,roughnessMap:!!e.roughnessMap,metalnessMap:!!e.metalnessMap,specularMap:!!e.specularMap,alphaMap:!!e.alphaMap,gradientMap:!!e.gradientMap,combine:e.combine,vertexColors:e.vertexColors,fog:!!s,useFog:e.fog,fogExp:s&&s.isFogExp2,flatShading:e.flatShading,sizeAttenuation:e.sizeAttenuation,logarithmicDepthBuffer:n.logarithmicDepthBuffer,skinning:e.skinning&&p>0,maxBones:p,useVertexTexture:n.floatVertexTextures,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:i.directional.length,numPointLights:i.point.length,numSpotLights:i.spot.length,numRectAreaLights:i.rectArea.length,numHemiLights:i.hemi.length,numClippingPlanes:c,numClipIntersection:h,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===T,flipSided:e.side===S,depthPacking:void 0!==e.depthPacking&&e.depthPacking}},this.getProgramCode=function(e,n){var i=[];if(n.shaderID?i.push(n.shaderID):(i.push(e.fragmentShader),i.push(e.vertexShader)),void 0!==e.defines)for(var r in e.defines)i.push(r),i.push(e.defines[r]);for(var a=0;a<o.length;a++)i.push(n[o[a]]);return i.push(e.onBeforeCompile.toString()),i.push(t.gammaOutput),i.join()},this.acquireProgram=function(n,r,o,a){for(var s,c=0,h=i.length;c<h;c++){var l=i[c];if(l.code===a){++(s=l).usedTimes;break}}return void 0===s&&(s=new Tr(t,e,a,n,r,o),i.push(s)),s},this.releaseProgram=function(t){if(0==--t.usedTimes){var e=i.indexOf(t);i[e]=i[i.length-1],i.pop(),t.destroy()}},this.programs=i}function Rr(t,e,n,i,r,o,a,s){var c,h="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext,l={};function u(t,e){if(t.width>e||t.height>e){var n=e/Math.max(t.width,t.height),i=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");return i.width=Math.floor(t.width*n),i.height=Math.floor(t.height*n),i.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height),console.warn("THREE.WebGLRenderer: image is too big ("+t.width+"x"+t.height+"). Resized to "+i.width+"x"+i.height,t),i}return t}function p(t){return ke.isPowerOfTwo(t.width)&&ke.isPowerOfTwo(t.height)}function d(t,e){return t.generateMipmaps&&e&&t.minFilter!==At&&t.minFilter!==Lt}function f(e){return e===At||e===Rt||e===Ct?t.NEAREST:t.LINEAR}function m(e){var n=e.target;n.removeEventListener("dispose",m),function(e){var n=i.get(e);if(e.image&&n.__image__webglTextureCube)t.deleteTexture(n.__image__webglTextureCube);else{if(void 0===n.__webglInit)return;t.deleteTexture(n.__webglTexture)}i.remove(e)}(n),n.isVideoTexture&&delete l[n.id],a.textures--}function v(e){var n=e.target;n.removeEventListener("dispose",v),function(e){var n=i.get(e),r=i.get(e.texture);if(!e)return;void 0!==r.__webglTexture&&t.deleteTexture(r.__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);i.remove(e.texture),i.remove(e)}(n),a.textures--}function g(e,f){var v=i.get(e);if(e.isVideoTexture&&function(t){var e=t.id,n=s.frame;l[e]!==n&&(l[e]=n,t.update())}(e),e.version>0&&v.__version!==e.version){var g=e.image;if(void 0===g)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",e);else{if(!1!==g.complete)return void function(e,i,s){void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",m),e.__webglTexture=t.createTexture(),a.textures++);n.activeTexture(t.TEXTURE0+s),n.bindTexture(t.TEXTURE_2D,e.__webglTexture),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,i.unpackAlignment);var l=u(i.image,r.maxTextureSize);(function(t){return t.wrapS!==St||t.wrapT!==St||t.minFilter!==At&&t.minFilter!==Lt})(i)&&!1===p(l)&&(l=function(t){return t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof ImageBitmap?(void 0===c&&(c=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),c.width=ke.floorPowerOfTwo(t.width),c.height=ke.floorPowerOfTwo(t.height),c.getContext("2d").drawImage(t,0,0,c.width,c.height),console.warn("THREE.WebGLRenderer: image is not power of two ("+t.width+"x"+t.height+"). Resized to "+c.width+"x"+c.height,t),c):t}(l));var f=p(l),v=o.convert(i.format),g=o.convert(i.type);y(t.TEXTURE_2D,i,f);var x,w=i.mipmaps;if(i.isDepthTexture){var b=t.DEPTH_COMPONENT;if(i.type===Ut){if(!h)throw new Error("Float Depth Texture only supported in WebGL2.0");b=t.DEPTH_COMPONENT32F}else h&&(b=t.DEPTH_COMPONENT16);i.format===Qt&&b===t.DEPTH_COMPONENT&&i.type!==Ft&&i.type!==Dt&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=Ft,g=o.convert(i.type)),i.format===Kt&&(b=t.DEPTH_STENCIL,i.type!==kt&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=kt,g=o.convert(i.type))),n.texImage2D(t.TEXTURE_2D,0,b,l.width,l.height,0,v,g,null)}else if(i.isDataTexture)if(w.length>0&&f){for(var _=0,M=w.length;_<M;_++)x=w[_],n.texImage2D(t.TEXTURE_2D,_,v,x.width,x.height,0,v,g,x.data);i.generateMipmaps=!1}else n.texImage2D(t.TEXTURE_2D,0,v,l.width,l.height,0,v,g,l.data);else if(i.isCompressedTexture)for(_=0,M=w.length;_<M;_++)x=w[_],i.format!==Xt&&i.format!==qt?n.getCompressedTextureFormats().indexOf(v)>-1?n.compressedTexImage2D(t.TEXTURE_2D,_,v,x.width,x.height,0,x.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(t.TEXTURE_2D,_,v,x.width,x.height,0,v,g,x.data);else if(w.length>0&&f){for(_=0,M=w.length;_<M;_++)x=w[_],n.texImage2D(t.TEXTURE_2D,_,v,v,g,x);i.generateMipmaps=!1}else n.texImage2D(t.TEXTURE_2D,0,v,v,g,l);d(i,f)&&t.generateMipmap(t.TEXTURE_2D);e.__version=i.version,i.onUpdate&&i.onUpdate(i)}(v,e,f);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",e)}}n.activeTexture(t.TEXTURE0+f),n.bindTexture(t.TEXTURE_2D,v.__webglTexture)}function y(n,a,s){var c;if(s?(t.texParameteri(n,t.TEXTURE_WRAP_S,o.convert(a.wrapS)),t.texParameteri(n,t.TEXTURE_WRAP_T,o.convert(a.wrapT)),t.texParameteri(n,t.TEXTURE_MAG_FILTER,o.convert(a.magFilter)),t.texParameteri(n,t.TEXTURE_MIN_FILTER,o.convert(a.minFilter))):(t.texParameteri(n,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(n,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),a.wrapS===St&&a.wrapT===St||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",a),t.texParameteri(n,t.TEXTURE_MAG_FILTER,f(a.magFilter)),t.texParameteri(n,t.TEXTURE_MIN_FILTER,f(a.minFilter)),a.minFilter!==At&&a.minFilter!==Lt&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",a)),c=e.get("EXT_texture_filter_anisotropic")){if(a.type===Ut&&null===e.get("OES_texture_float_linear"))return;if(a.type===Vt&&null===e.get("OES_texture_half_float_linear"))return;(a.anisotropy>1||i.get(a).__currentAnisotropy)&&(t.texParameterf(n,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy)}}function x(e,r,a,s){var c=o.convert(r.texture.format),h=o.convert(r.texture.type);n.texImage2D(s,0,c,r.width,r.height,0,c,h,null),t.bindFramebuffer(t.FRAMEBUFFER,e),t.framebufferTexture2D(t.FRAMEBUFFER,a,s,i.get(r.texture).__webglTexture,0),t.bindFramebuffer(t.FRAMEBUFFER,null)}function w(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 b(e){var n=i.get(e),r=!0===e.isWebGLRenderTargetCube;if(e.depthTexture){if(r)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");i.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),g(n.depthTexture,0);var r=i.get(n.depthTexture).__webglTexture;if(n.depthTexture.format===Qt)t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,r,0);else{if(n.depthTexture.format!==Kt)throw new Error("Unknown depthTexture format");t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,r,0)}}(n.__webglFramebuffer,e)}else if(r){n.__webglDepthbuffer=[];for(var o=0;o<6;o++)t.bindFramebuffer(t.FRAMEBUFFER,n.__webglFramebuffer[o]),n.__webglDepthbuffer[o]=t.createRenderbuffer(),w(n.__webglDepthbuffer[o],e)}else t.bindFramebuffer(t.FRAMEBUFFER,n.__webglFramebuffer),n.__webglDepthbuffer=t.createRenderbuffer(),w(n.__webglDepthbuffer,e);t.bindFramebuffer(t.FRAMEBUFFER,null)}this.setTexture2D=g,this.setTextureCube=function(e,s){var c=i.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.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 h=e&&e.isCompressedTexture,l=e.image[0]&&e.image[0].isDataTexture,f=[],v=0;v<6;v++)f[v]=h||l?l?e.image[v].image:e.image[v]:u(e.image[v],r.maxCubemapSize);var g=p(f[0]),x=o.convert(e.format),w=o.convert(e.type);y(t.TEXTURE_CUBE_MAP,e,g);for(v=0;v<6;v++)if(h)for(var b,_=f[v].mipmaps,M=0,E=_.length;M<E;M++)b=_[M],e.format!==Xt&&e.format!==qt?n.getCompressedTextureFormats().indexOf(x)>-1?n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,M,x,b.width,b.height,0,b.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,M,x,b.width,b.height,0,x,w,b.data);else l?n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,x,f[v].width,f[v].height,0,x,w,f[v].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+v,0,x,x,w,f[v]);d(e,g)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),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,r){n.activeTexture(t.TEXTURE0+r),n.bindTexture(t.TEXTURE_CUBE_MAP,i.get(e).__webglTexture)},this.setupRenderTarget=function(e){var r=i.get(e),o=i.get(e.texture);e.addEventListener("dispose",v),o.__webglTexture=t.createTexture(),a.textures++;var s=!0===e.isWebGLRenderTargetCube,c=p(e);if(s){r.__webglFramebuffer=[];for(var h=0;h<6;h++)r.__webglFramebuffer[h]=t.createFramebuffer()}else r.__webglFramebuffer=t.createFramebuffer();if(s){n.bindTexture(t.TEXTURE_CUBE_MAP,o.__webglTexture),y(t.TEXTURE_CUBE_MAP,e.texture,c);for(h=0;h<6;h++)x(r.__webglFramebuffer[h],e,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+h);d(e.texture,c)&&t.generateMipmap(t.TEXTURE_CUBE_MAP),n.bindTexture(t.TEXTURE_CUBE_MAP,null)}else n.bindTexture(t.TEXTURE_2D,o.__webglTexture),y(t.TEXTURE_2D,e.texture,c),x(r.__webglFramebuffer,e,t.COLOR_ATTACHMENT0,t.TEXTURE_2D),d(e.texture,c)&&t.generateMipmap(t.TEXTURE_2D),n.bindTexture(t.TEXTURE_2D,null);e.depthBuffer&&b(e)},this.updateRenderTargetMipmap=function(e){var r=e.texture;if(d(r,p(e))){var o=e.isWebGLRenderTargetCube?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,a=i.get(r).__webglTexture;n.bindTexture(o,a),t.generateMipmap(o),n.bindTexture(o,null)}}}function Cr(){var t={};return{get:function(e){var n=e.uuid,i=t[n];return void 0===i&&(i={},t[n]=i),i},remove:function(e){delete t[e.uuid]},update:function(e,n,i){var r=e.uuid;t[r][n]=i},dispose:function(){t={}}}}function Lr(t,e,n){var i=new function(){var e=!1,n=new Ke,i=null,r=new Ke(0,0,0,0);return{setMask:function(n){i===n||e||(t.colorMask(n,n,n,n),i=n)},setLocked:function(t){e=t},setClear:function(e,i,o,a,s){!0===s&&(e*=a,i*=a,o*=a),n.set(e,i,o,a),!1===r.equals(n)&&(t.clearColor(e,i,o,a),r.copy(n))},reset:function(){e=!1,i=null,r.set(-1,0,0,0)}}},r=new function(){var e=!1,n=null,i=null,r=null;return{setTest:function(e){e?X(t.DEPTH_TEST):Y(t.DEPTH_TEST)},setMask:function(i){n===i||e||(t.depthMask(i),n=i)},setFunc:function(e){if(i!==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 it:t.depthFunc(t.LEQUAL);break;case rt: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);i=e}},setLocked:function(t){e=t},setClear:function(e){r!==e&&(t.clearDepth(e),r=e)},reset:function(){e=!1,n=null,i=null,r=null}}},o=new function(){var e=!1,n=null,i=null,r=null,o=null,a=null,s=null,c=null,h=null;return{setTest:function(e){e?X(t.STENCIL_TEST):Y(t.STENCIL_TEST)},setMask:function(i){n===i||e||(t.stencilMask(i),n=i)},setFunc:function(e,n,a){i===e&&r===n&&o===a||(t.stencilFunc(e,n,a),i=e,r=n,o=a)},setOp:function(e,n,i){a===e&&s===n&&c===i||(t.stencilOp(e,n,i),a=e,s=n,c=i)},setLocked:function(t){e=t},setClear:function(e){h!==e&&(t.clearStencil(e),h=e)},reset:function(){e=!1,n=null,i=null,r=null,o=null,a=null,s=null,c=null,h=null}}},a=t.getParameter(t.MAX_VERTEX_ATTRIBS),s=new Uint8Array(a),c=new Uint8Array(a),h=new Uint8Array(a),l={},u=null,p=null,d=null,f=null,y=null,x=null,w=null,b=null,_=null,M=!1,E=null,A=null,R=null,C=null,L=null,P=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS),D=!1,U=0,V=t.getParameter(t.VERSION);-1!==V.indexOf("WebGL")?(U=parseFloat(/^WebGL\ ([0-9])/.exec(V)[1]),D=U>=1):-1!==V.indexOf("OpenGL ES")&&(U=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(V)[1]),D=U>=2);var G=null,H={},j=new Ke,k=new Ke;function W(e,n,i){var r=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;a<i;a++)t.texImage2D(n+a,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,r);return o}var q={};function X(e){!0!==l[e]&&(t.enable(e),l[e]=!0)}function Y(e){!1!==l[e]&&(t.disable(e),l[e]=!1)}function Z(e,i,r,o,a,s,c,h){if(e!==B?X(t.BLEND):Y(t.BLEND),e!==z){if(e!==d||h!==M)switch(e){case N:h?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ONE,t.ONE,t.ONE)):(t.blendEquation(t.FUNC_ADD),t.blendFunc(t.SRC_ALPHA,t.ONE));break;case O:h?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ZERO,t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ONE_MINUS_SRC_ALPHA)):(t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ZERO,t.ONE_MINUS_SRC_COLOR));break;case F:h?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ZERO,t.SRC_COLOR,t.ZERO,t.SRC_ALPHA)):(t.blendEquation(t.FUNC_ADD),t.blendFunc(t.ZERO,t.SRC_COLOR));break;default:h?(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):(t.blendEquationSeparate(t.FUNC_ADD,t.FUNC_ADD),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA))}f=null,y=null,x=null,w=null,b=null,_=null}else a=a||i,s=s||r,c=c||o,i===f&&a===w||(t.blendEquationSeparate(n.convert(i),n.convert(a)),f=i,w=a),r===y&&o===x&&s===b&&c===_||(t.blendFuncSeparate(n.convert(r),n.convert(o),n.convert(s),n.convert(c)),y=r,x=o,b=s,_=c);d=e,M=h}function J(e){E!==e&&(e?t.frontFace(t.CW):t.frontFace(t.CCW),E=e)}function Q(e){e!==m?(X(t.CULL_FACE),e!==A&&(e===v?t.cullFace(t.BACK):e===g?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Y(t.CULL_FACE),A=e}function K(e,n,i){e?(X(t.POLYGON_OFFSET_FILL),C===n&&L===i||(t.polygonOffset(n,i),C=n,L=i)):Y(t.POLYGON_OFFSET_FILL)}function $(e){void 0===e&&(e=t.TEXTURE0+P-1),G!==e&&(t.activeTexture(e),G=e)}return q[t.TEXTURE_2D]=W(t.TEXTURE_2D,t.TEXTURE_2D,1),q[t.TEXTURE_CUBE_MAP]=W(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),i.setClear(0,0,0,1),r.setClear(1),o.setClear(0),X(t.DEPTH_TEST),r.setFunc(it),J(!1),Q(v),X(t.CULL_FACE),X(t.BLEND),Z(I),{buffers:{color:i,depth:r,stencil:o},initAttributes:function(){for(var t=0,e=s.length;t<e;t++)s[t]=0},enableAttribute:function(n){s[n]=1,0===c[n]&&(t.enableVertexAttribArray(n),c[n]=1),0!==h[n]&&(e.get("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(n,0),h[n]=0)},enableAttributeAndDivisor:function(n,i){s[n]=1,0===c[n]&&(t.enableVertexAttribArray(n),c[n]=1),h[n]!==i&&(e.get("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(n,i),h[n]=i)},disableUnusedAttributes:function(){for(var e=0,n=c.length;e!==n;++e)c[e]!==s[e]&&(t.disableVertexAttribArray(e),c[e]=0)},enable:X,disable:Y,getCompressedTextureFormats:function(){if(null===u&&(u=[],e.get("WEBGL_compressed_texture_pvrtc")||e.get("WEBGL_compressed_texture_s3tc")||e.get("WEBGL_compressed_texture_etc1")||e.get("WEBGL_compressed_texture_astc")))for(var n=t.getParameter(t.COMPRESSED_TEXTURE_FORMATS),i=0;i<n.length;i++)u.push(n[i]);return u},useProgram:function(e){return p!==e&&(t.useProgram(e),p=e,!0)},setBlending:Z,setMaterial:function(e,n){e.side===T?Y(t.CULL_FACE):X(t.CULL_FACE);var o=e.side===S;n&&(o=!o),J(o),!0===e.transparent?Z(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha):Z(B),r.setFunc(e.depthFunc),r.setTest(e.depthTest),r.setMask(e.depthWrite),i.setMask(e.colorWrite),K(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits)},setFlipSided:J,setCullFace:Q,setLineWidth:function(e){e!==R&&(D&&t.lineWidth(e),R=e)},setPolygonOffset:K,setScissorTest:function(e){e?X(t.SCISSOR_TEST):Y(t.SCISSOR_TEST)},activeTexture:$,bindTexture:function(e,n){null===G&&$();var i=H[G];void 0===i&&(i={type:void 0,texture:void 0},H[G]=i),i.type===e&&i.texture===n||(t.bindTexture(e,n||q[e]),i.type=e,i.texture=n)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===j.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),j.copy(e))},viewport:function(e){!1===k.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),k.copy(e))},reset:function(){for(var e=0;e<c.length;e++)1===c[e]&&(t.disableVertexAttribArray(e),c[e]=0);l={},u=null,G=null,H={},p=null,d=null,E=null,A=null,i.reset(),r.reset(),o.reset()}}}function Pr(t,e,n){var i;function r(e){if("highp"===e){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&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=r(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),h=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),l=t.getParameter(t.MAX_TEXTURE_SIZE),u=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),p=t.getParameter(t.MAX_VERTEX_ATTRIBS),d=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),f=t.getParameter(t.MAX_VARYING_VECTORS),m=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),v=h>0,g=!!e.get("OES_texture_float");return{getMaxAnisotropy:function(){if(void 0!==i)return i;var n=e.get("EXT_texture_filter_anisotropic");return i=null!==n?t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:r,precision:o,logarithmicDepthBuffer:s,maxTextures:c,maxVertexTextures:h,maxTextureSize:l,maxCubemapSize:u,maxAttributes:p,maxVertexUniforms:d,maxVaryings:f,maxFragmentUniforms:m,vertexTextures:v,floatFragmentTextures:g,floatVertexTextures:v&&g}}function Br(t,e,n,i){_i.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!==i?i:2e3,this.focus=10,this.aspect=void 0!==e?e:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}function Ir(t){Br.call(this),this.cameras=t||[]}function Nr(t){var e=this,n=null,i=null,r=null,o=new qe,a=new qe;"undefined"!=typeof window&&"VRFrameData"in window&&(i=new window.VRFrameData);var s=new qe,c=new Br;c.bounds=new Ke(0,0,.5,1),c.layers.enable(1);var h=new Br;h.bounds=new Ke(.5,0,.5,1),h.layers.enable(2);var l,u,p=new Ir([c,h]);function d(){if(null!==n&&n.isPresenting){var i=n.getEyeParameters("left"),r=i.renderWidth,o=i.renderHeight;u=t.getPixelRatio(),l=t.getSize(),t.setDrawingBufferSize(2*r,o,1)}else e.enabled&&t.setDrawingBufferSize(l.width,l.height,u)}p.layers.enable(1),p.layers.enable(2),"undefined"!=typeof window&&window.addEventListener("vrdisplaypresentchange",d,!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&&(r=t)},this.getCamera=function(t){if(null===n)return t;n.depthNear=t.near,n.depthFar=t.far,n.getFrameData(i);var l=i.pose,u=null!==r?r:t;null!==l.position?u.position.fromArray(l.position):u.position.set(0,0,0),null!==l.orientation&&u.quaternion.fromArray(l.orientation);var d=n.stageParameters;if(d?o.fromArray(d.sittingToStandingTransform):o.makeTranslation(0,e.userHeight,0),u.position.applyMatrix4(o),u.updateMatrixWorld(),!1===n.isPresenting)return t;c.near=t.near,h.near=t.near,c.far=t.far,h.far=t.far,p.matrixWorld.copy(t.matrixWorld),p.matrixWorldInverse.copy(t.matrixWorldInverse),c.matrixWorldInverse.fromArray(i.leftViewMatrix),h.matrixWorldInverse.fromArray(i.rightViewMatrix),a.getInverse(o),c.matrixWorldInverse.multiply(a),h.matrixWorldInverse.multiply(a);var f=u.parent;null!==f&&(s.getInverse(f.matrixWorld),c.matrixWorldInverse.multiply(s),h.matrixWorldInverse.multiply(s)),c.matrixWorld.getInverse(c.matrixWorldInverse),h.matrixWorld.getInverse(h.matrixWorldInverse),c.projectionMatrix.fromArray(i.leftProjectionMatrix),h.projectionMatrix.fromArray(i.rightProjectionMatrix),p.projectionMatrix.copy(c.projectionMatrix);var m=n.getLayers();if(m.length){var v=m[0];null!==v.leftBounds&&4===v.leftBounds.length&&c.bounds.fromArray(v.leftBounds),null!==v.rightBounds&&4===v.rightBounds.length&&h.bounds.fromArray(v.rightBounds)}return p},this.getStandingMatrix=function(){return o},this.submitFrame=function(){n&&n.isPresenting&&n.submitFrame()},this.dispose=function(){"undefined"!=typeof window&&window.removeEventListener("vrdisplaypresentchange",d)}}function Or(t){var e={};return{get:function(n){if(void 0!==e[n])return e[n];var i;switch(n){case"WEBGL_depth_texture":i=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"WEBGL_compressed_texture_etc1":i=t.getExtension("WEBGL_compressed_texture_etc1");break;default:i=t.getExtension(n)}return null===i&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),e[n]=i,i}}}function Fr(){var t=this,e=null,n=0,i=!1,r=!1,o=new li,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 h(e,n,i,r){var c=null!==e?e.length:0,h=null;if(0!==c){if(h=s.value,!0!==r||null===h){var l=i+4*c,u=n.matrixWorldInverse;a.getNormalMatrix(u),(null===h||h.length<l)&&(h=new Float32Array(l));for(var p=0,d=i;p!==c;++p,d+=4)o.copy(e[p]).applyMatrix4(u,a),o.normal.toArray(h,d),h[d+3]=o.constant}s.value=h,s.needsUpdate=!0}return t.numPlanes=c,h}this.uniform=s,this.numPlanes=0,this.numIntersection=0,this.init=function(t,r,o){var a=0!==t.length||r||0!==n||i;return i=r,e=h(t,o,0),n=t.length,a},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1,c()},this.setState=function(t,o,a,l,u,p){if(!i||null===t||0===t.length||r&&!a)r?h(null):c();else{var d=r?0:n,f=4*d,m=u.clippingState||null;s.value=m,m=h(t,l,f,p);for(var v=0;v!==f;++v)m[v]=e[v];u.clippingState=m,this.numIntersection=o?this.numPlanes:0,this.numPlanes+=d}}}function zr(t,e){return{convert:function(n){var i;if(n===Et)return t.REPEAT;if(n===St)return t.CLAMP_TO_EDGE;if(n===Tt)return t.MIRRORED_REPEAT;if(n===At)return t.NEAREST;if(n===Rt)return t.NEAREST_MIPMAP_NEAREST;if(n===Ct)return t.NEAREST_MIPMAP_LINEAR;if(n===Lt)return t.LINEAR;if(n===Pt)return t.LINEAR_MIPMAP_NEAREST;if(n===Bt)return t.LINEAR_MIPMAP_LINEAR;if(n===It)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===Nt)return t.BYTE;if(n===Ot)return t.SHORT;if(n===Ft)return t.UNSIGNED_SHORT;if(n===zt)return t.INT;if(n===Dt)return t.UNSIGNED_INT;if(n===Ut)return t.FLOAT;if(n===Vt&&null!==(i=e.get("OES_texture_half_float")))return i.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===Zt)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===U)return t.FUNC_SUBTRACT;if(n===V)return t.FUNC_REVERSE_SUBTRACT;if(n===j)return t.ZERO;if(n===k)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===Z)return t.DST_ALPHA;if(n===J)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!==(i=e.get("WEBGL_compressed_texture_s3tc"))){if(n===$t)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===te)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===ee)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===ne)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if((n===ie||n===re||n===oe||n===ae)&&null!==(i=e.get("WEBGL_compressed_texture_pvrtc"))){if(n===ie)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===re)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===oe)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===ae)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===se&&null!==(i=e.get("WEBGL_compressed_texture_etc1")))return i.COMPRESSED_RGB_ETC1_WEBGL;if((n===ce||n===he||n===le||n===ue||n===pe||n===de||n===fe||n===me||n===ve||n===ge||n===ye||n===xe||n===we||n===be)&&null!==(i=e.get("WEBGL_compressed_texture_astc")))return n;if((n===G||n===H)&&null!==(i=e.get("EXT_blend_minmax"))){if(n===G)return i.MIN_EXT;if(n===H)return i.MAX_EXT}return n===kt&&null!==(i=e.get("WEBGL_depth_texture"))?i.UNSIGNED_INT_24_8_WEBGL:0}}}function Dr(){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 kn,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new We};break;case"SpotLight":n={position:new Ye,direction:new Ye,color:new kn,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 kn,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 kn,groundColor:new kn};break;case"RectAreaLight":n={color:new kn,position:new Ye,halfWidth:new Ye,halfHeight:new Ye}}return t[e.id]=n,n}}}Br.prototype=Object.assign(Object.create(_i.prototype),{constructor:Br,isPerspectiveCamera:!0,copy:function(t,e){return _i.prototype.copy.call(this,t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this},setFocalLength:function(t){var e=.5*this.getFilmHeight()/t;this.fov=2*ke.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){var t=Math.tan(.5*ke.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*ke.RAD2DEG*Math.atan(Math.tan(.5*ke.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(t,e,n,i,r,o){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=this.near,e=t*Math.tan(.5*ke.DEG2RAD*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i,o=this.view;if(null!==this.view&&this.view.enabled){var a=o.fullWidth,s=o.fullHeight;r+=o.offsetX*i/a,e-=o.offsetY*n/s,i*=o.width/a,n*=o.height/s}var c=this.filmOffset;0!==c&&(r+=t*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far)},toJSON:function(t){var e=bi.prototype.toJSON.call(this,t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}),Ir.prototype=Object.assign(Object.create(Br.prototype),{constructor:Ir,isArrayCamera:!0});var Ur,Vr,Gr,Hr,jr,kr,Wr,qr,Xr=0;function Yr(){var t=new Dr,e={id:Xr++,hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},n=new Ye,i=new qe,r=new qe;return{setup:function(o,a,s){for(var c=0,h=0,l=0,u=0,p=0,d=0,f=0,m=0,v=s.matrixWorldInverse,g=0,y=o.length;g<y;g++){var x=o[g],w=x.color,b=x.intensity,_=x.distance,M=x.shadow&&x.shadow.map?x.shadow.map.texture:null;if(x.isAmbientLight)c+=w.r*b,h+=w.g*b,l+=w.b*b;else if(x.isDirectionalLight){if((S=t.get(x)).color.copy(x.color).multiplyScalar(x.intensity),S.direction.setFromMatrixPosition(x.matrixWorld),n.setFromMatrixPosition(x.target.matrixWorld),S.direction.sub(n),S.direction.transformDirection(v),S.shadow=x.castShadow,x.castShadow){var E=x.shadow;S.shadowBias=E.bias,S.shadowRadius=E.radius,S.shadowMapSize=E.mapSize}e.directionalShadowMap[u]=M,e.directionalShadowMatrix[u]=x.shadow.matrix,e.directional[u]=S,u++}else if(x.isSpotLight){if((S=t.get(x)).position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(v),S.color.copy(w).multiplyScalar(b),S.distance=_,S.direction.setFromMatrixPosition(x.matrixWorld),n.setFromMatrixPosition(x.target.matrixWorld),S.direction.sub(n),S.direction.transformDirection(v),S.coneCos=Math.cos(x.angle),S.penumbraCos=Math.cos(x.angle*(1-x.penumbra)),S.decay=0===x.distance?0:x.decay,S.shadow=x.castShadow,x.castShadow){E=x.shadow;S.shadowBias=E.bias,S.shadowRadius=E.radius,S.shadowMapSize=E.mapSize}e.spotShadowMap[d]=M,e.spotShadowMatrix[d]=x.shadow.matrix,e.spot[d]=S,d++}else if(x.isRectAreaLight){(S=t.get(x)).color.copy(w).multiplyScalar(b),S.position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(v),r.identity(),i.copy(x.matrixWorld),i.premultiply(v),r.extractRotation(i),S.halfWidth.set(.5*x.width,0,0),S.halfHeight.set(0,.5*x.height,0),S.halfWidth.applyMatrix4(r),S.halfHeight.applyMatrix4(r),e.rectArea[f]=S,f++}else if(x.isPointLight){if((S=t.get(x)).position.setFromMatrixPosition(x.matrixWorld),S.position.applyMatrix4(v),S.color.copy(x.color).multiplyScalar(x.intensity),S.distance=x.distance,S.decay=0===x.distance?0:x.decay,S.shadow=x.castShadow,x.castShadow){E=x.shadow;S.shadowBias=E.bias,S.shadowRadius=E.radius,S.shadowMapSize=E.mapSize,S.shadowCameraNear=E.camera.near,S.shadowCameraFar=E.camera.far}e.pointShadowMap[p]=M,e.pointShadowMatrix[p]=x.shadow.matrix,e.point[p]=S,p++}else if(x.isHemisphereLight){var S;(S=t.get(x)).direction.setFromMatrixPosition(x.matrixWorld),S.direction.transformDirection(v),S.direction.normalize(),S.skyColor.copy(x.color).multiplyScalar(b),S.groundColor.copy(x.groundColor).multiplyScalar(b),e.hemi[m]=S,m++}}e.ambient[0]=c,e.ambient[1]=h,e.ambient[2]=l,e.directional.length=u,e.spot.length=d,e.rectArea.length=f,e.point.length=p,e.hemi.length=m,e.hash=e.id+","+u+","+p+","+d+","+f+","+m+","+a.length},state:e}}function Zr(){var t=new Yr,e=[],n=[],i=[];return{init:function(){e.length=0,n.length=0,i.length=0},state:{lightsArray:e,shadowsArray:n,spritesArray:i,lights:t},setupLights:function(i){t.setup(e,n,i)},pushLight:function(t){e.push(t)},pushShadow:function(t){n.push(t)},pushSprite:function(t){i.push(t)}}}function Jr(){var t={};return{get:function(e,n){var i=e.id+","+n.id,r=t[i];return void 0===r&&(r=new Zr,t[i]=r),r},dispose:function(){t={}}}}function Qr(t){console.log("THREE.WebGLRenderer",d);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,i=void 0!==t.alpha&&t.alpha,r=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,h=void 0!==t.powerPreference?t.powerPreference:"default",l=null,u=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=pt,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.maxMorphTargets=8,this.maxMorphNormals=4;var p,f,m,v,g,y,x,w,b,_,M,E,S,T,A,R,L,P,B=this,I=!1,N=null,O=null,F=-1,z="",D=null,U=null,V=new Ke,G=new Ke,H=null,j=0,k=e.width,W=e.height,q=1,X=new Ke(0,0,k,W),Y=new Ke(0,0,k,W),Z=!1,J=new ui,Q=new Fr,K=!1,$=!1,tt=new qe,et=new Ye,nt={geometries:0,textures:0},it={frame:0,calls:0,vertices:0,faces:0,points:0};function rt(){return null===N?q:1}this.info={render:it,memory:nt,programs:null,autoReset:!0,reset:function(){it.frame++,it.calls=0,it.vertices=0,it.faces=0,it.points=0}};try{var ot={alpha:i,depth:r,stencil:o,antialias:a,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:h};if(e.addEventListener("webglcontextlost",ht,!1),e.addEventListener("webglcontextrestored",lt,!1),null===(p=n||e.getContext("webgl",ot)||e.getContext("experimental-webgl",ot)))throw null!==e.getContext("webgl")?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.");void 0===p.getShaderPrecisionFormat&&(p.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(t){console.error("THREE.WebGLRenderer: "+t.message)}function at(){(f=new Or(p)).get("WEBGL_depth_texture"),f.get("OES_texture_float"),f.get("OES_texture_float_linear"),f.get("OES_texture_half_float"),f.get("OES_texture_half_float_linear"),f.get("OES_standard_derivatives"),f.get("OES_element_index_uint"),f.get("ANGLE_instanced_arrays"),P=new zr(p,f),m=new Pr(p,f,t),(v=new Lr(p,f,P)).scissor(G.copy(Y).multiplyScalar(q)),v.viewport(V.copy(X).multiplyScalar(q)),g=new Cr,y=new Rr(p,f,v,g,m,P,nt,it),x=new di(p),w=new fr(p,x,nt),b=new mr(w,it),T=new ur(p),_=new Ar(B,f,m),M=new hr,E=new Jr,S=new or(B,v,w,s),A=new dr(p,f,it),R=new pr(p,f,it),L=new Jn(B,p,v,y,m),B.info.programs=_.programs,B.context=p,B.capabilities=m,B.extensions=f,B.properties=g,B.renderLists=M,B.state=v}at();var st=new Nr(B);this.vr=st;var ct=new pi(B,b,m.maxTextureSize);function ht(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),I=!0}function lt(){console.log("THREE.WebGLRenderer: Context Restored."),I=!1,at()}function ut(t){var e=t.target;e.removeEventListener("dispose",ut),function(t){dt(t),g.remove(t)}(e)}function dt(t){var e=g.get(t).program;t.program=void 0,void 0!==e&&_.releaseProgram(e)}this.shadowMap=ct,this.getContext=function(){return p},this.getContextAttributes=function(){return p.getContextAttributes()},this.forceContextLoss=function(){var t=f.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){var t=f.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return q},this.setPixelRatio=function(t){void 0!==t&&(q=t,this.setSize(k,W,!1))},this.getSize=function(){return{width:k,height:W}},this.setSize=function(t,n,i){var r=st.getDevice();r&&r.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(k=t,W=n,e.width=t*q,e.height=n*q,!1!==i&&(e.style.width=t+"px",e.style.height=n+"px"),this.setViewport(0,0,t,n))},this.getDrawingBufferSize=function(){return{width:k*q,height:W*q}},this.setDrawingBufferSize=function(t,n,i){k=t,W=n,q=i,e.width=t*i,e.height=n*i,this.setViewport(0,0,t,n)},this.getCurrentViewport=function(){return V},this.setViewport=function(t,e,n,i){X.set(t,W-e-i,n,i),v.viewport(V.copy(X).multiplyScalar(q))},this.setScissor=function(t,e,n,i){Y.set(t,W-e-i,n,i),v.scissor(G.copy(Y).multiplyScalar(q))},this.setScissorTest=function(t){v.setScissorTest(Z=t)},this.getClearColor=function(){return S.getClearColor()},this.setClearColor=function(){S.setClearColor.apply(S,arguments)},this.getClearAlpha=function(){return S.getClearAlpha()},this.setClearAlpha=function(){S.setClearAlpha.apply(S,arguments)},this.clear=function(t,e,n){var i=0;(void 0===t||t)&&(i|=p.COLOR_BUFFER_BIT),(void 0===e||e)&&(i|=p.DEPTH_BUFFER_BIT),(void 0===n||n)&&(i|=p.STENCIL_BUFFER_BIT),p.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.clearTarget=function(t,e,n,i){this.setRenderTarget(t),this.clear(e,n,i)},this.dispose=function(){e.removeEventListener("webglcontextlost",ht,!1),e.removeEventListener("webglcontextrestored",lt,!1),M.dispose(),E.dispose(),g.dispose(),b.dispose(),st.dispose(),gt()},this.renderBufferImmediate=function(t,e,n){v.initAttributes();var i=g.get(t);t.hasPositions&&!i.position&&(i.position=p.createBuffer()),t.hasNormals&&!i.normal&&(i.normal=p.createBuffer()),t.hasUvs&&!i.uv&&(i.uv=p.createBuffer()),t.hasColors&&!i.color&&(i.color=p.createBuffer());var r=e.getAttributes();if(t.hasPositions&&(p.bindBuffer(p.ARRAY_BUFFER,i.position),p.bufferData(p.ARRAY_BUFFER,t.positionArray,p.DYNAMIC_DRAW),v.enableAttribute(r.position),p.vertexAttribPointer(r.position,3,p.FLOAT,!1,0,0)),t.hasNormals){if(p.bindBuffer(p.ARRAY_BUFFER,i.normal),!n.isMeshPhongMaterial&&!n.isMeshStandardMaterial&&!n.isMeshNormalMaterial&&!0===n.flatShading)for(var o=0,a=3*t.count;o<a;o+=9){var s=t.normalArray,c=(s[o+0]+s[o+3]+s[o+6])/3,h=(s[o+1]+s[o+4]+s[o+7])/3,l=(s[o+2]+s[o+5]+s[o+8])/3;s[o+0]=c,s[o+1]=h,s[o+2]=l,s[o+3]=c,s[o+4]=h,s[o+5]=l,s[o+6]=c,s[o+7]=h,s[o+8]=l}p.bufferData(p.ARRAY_BUFFER,t.normalArray,p.DYNAMIC_DRAW),v.enableAttribute(r.normal),p.vertexAttribPointer(r.normal,3,p.FLOAT,!1,0,0)}t.hasUvs&&n.map&&(p.bindBuffer(p.ARRAY_BUFFER,i.uv),p.bufferData(p.ARRAY_BUFFER,t.uvArray,p.DYNAMIC_DRAW),v.enableAttribute(r.uv),p.vertexAttribPointer(r.uv,2,p.FLOAT,!1,0,0)),t.hasColors&&n.vertexColors!==C&&(p.bindBuffer(p.ARRAY_BUFFER,i.color),p.bufferData(p.ARRAY_BUFFER,t.colorArray,p.DYNAMIC_DRAW),v.enableAttribute(r.color),p.vertexAttribPointer(r.color,3,p.FLOAT,!1,0,0)),v.disableUnusedAttributes(),p.drawArrays(p.TRIANGLES,0,t.count),t.count=0},this.renderBufferDirect=function(t,e,n,i,r,o){var a=r.isMesh&&r.matrixWorld.determinant()<0;v.setMaterial(i,a);var s=Mt(t,e,i,r),c=n.id+"_"+s.id+"_"+(!0===i.wireframe),h=!1;c!==z&&(z=c,h=!0),r.morphTargetInfluences&&(T.update(r,n,i,s),h=!0);var l,u=n.index,d=n.attributes.position,m=1;!0===i.wireframe&&(u=w.getWireframeAttribute(n),m=2);var g=A;null!==u&&(l=x.get(u),(g=R).setIndex(l)),h&&(!function(t,e,n,i){if(n&&n.isInstancedBufferGeometry&&null===f.get("ANGLE_instanced_arrays"))return void console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");void 0===i&&(i=0);v.initAttributes();var r=n.attributes,o=e.getAttributes(),a=t.defaultAttributeValues;for(var s in o){var c=o[s];if(c>=0){var h=r[s];if(void 0!==h){var l=h.normalized,u=h.itemSize,d=x.get(h);if(void 0===d)continue;var m=d.buffer,g=d.type,y=d.bytesPerElement;if(h.isInterleavedBufferAttribute){var w=h.data,b=w.stride,_=h.offset;w&&w.isInstancedInterleavedBuffer?(v.enableAttributeAndDivisor(c,w.meshPerAttribute),void 0===n.maxInstancedCount&&(n.maxInstancedCount=w.meshPerAttribute*w.count)):v.enableAttribute(c),p.bindBuffer(p.ARRAY_BUFFER,m),p.vertexAttribPointer(c,u,g,l,b*y,(i*b+_)*y)}else h.isInstancedBufferAttribute?(v.enableAttributeAndDivisor(c,h.meshPerAttribute),void 0===n.maxInstancedCount&&(n.maxInstancedCount=h.meshPerAttribute*h.count)):v.enableAttribute(c),p.bindBuffer(p.ARRAY_BUFFER,m),p.vertexAttribPointer(c,u,g,l,0,i*u*y)}else if(void 0!==a){var M=a[s];if(void 0!==M)switch(M.length){case 2:p.vertexAttrib2fv(c,M);break;case 3:p.vertexAttrib3fv(c,M);break;case 4:p.vertexAttrib4fv(c,M);break;default:p.vertexAttrib1fv(c,M)}}}}v.disableUnusedAttributes()}(i,s,n),null!==u&&p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,l.buffer));var y=1/0;null!==u?y=u.count:void 0!==d&&(y=d.count);var b=n.drawRange.start*m,_=n.drawRange.count*m,M=null!==o?o.start*m:0,E=null!==o?o.count*m:1/0,S=Math.max(b,M),C=Math.min(y,b+_,M+E)-1,L=Math.max(0,C-S+1);if(0!==L){if(r.isMesh)if(!0===i.wireframe)v.setLineWidth(i.wireframeLinewidth*rt()),g.setMode(p.LINES);else switch(r.drawMode){case Pe:g.setMode(p.TRIANGLES);break;case Be:g.setMode(p.TRIANGLE_STRIP);break;case Ie:g.setMode(p.TRIANGLE_FAN)}else if(r.isLine){var P=i.linewidth;void 0===P&&(P=1),v.setLineWidth(P*rt()),r.isLineSegments?g.setMode(p.LINES):r.isLineLoop?g.setMode(p.LINE_LOOP):g.setMode(p.LINE_STRIP)}else r.isPoints&&g.setMode(p.POINTS);n&&n.isInstancedBufferGeometry?n.maxInstancedCount>0&&g.renderInstances(n,S,L):g.render(S,L)}},this.compile=function(t,e){(u=E.get(t,e)).init(),t.traverse((function(t){t.isLight&&(u.pushLight(t),t.castShadow&&u.pushShadow(t))})),u.setupLights(e),t.traverse((function(e){if(e.material)if(Array.isArray(e.material))for(var n=0;n<e.material.length;n++)_t(e.material[n],t.fog,e);else _t(e.material,t.fog,e)}))};var ft,mt=!1,vt=null;function gt(){mt=!1}function yt(){var t=st.getDevice();t&&t.isPresenting?t.requestAnimationFrame(xt):window.requestAnimationFrame(xt)}function xt(t){!1!==mt&&(vt(t),yt())}function wt(t,e,n,i){for(var r=0,o=t.length;r<o;r++){var a=t[r],s=a.object,c=a.geometry,h=void 0===i?a.material:i,l=a.group;if(n.isArrayCamera){U=n;for(var u=n.cameras,p=0,d=u.length;p<d;p++){var f=u[p];if(s.layers.test(f.layers)){var m=f.bounds,g=m.x*k,y=m.y*W,x=m.z*k,w=m.w*W;v.viewport(V.set(g,y,x,w).multiplyScalar(q)),bt(s,e,f,c,h,l)}}}else U=null,bt(s,e,n,c,h,l)}}function bt(t,e,n,i,r,o){if(t.onBeforeRender(B,e,n,i,r,o),u=E.get(e,U||n),t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),t.isImmediateRenderObject){var a=t.isMesh&&t.matrixWorld.determinant()<0;v.setMaterial(r,a);var s=Mt(n,e.fog,r,t);z="",function(t,e,n){t.render((function(t){B.renderBufferImmediate(t,e,n)}))}(t,s,r)}else B.renderBufferDirect(n,e.fog,i,r,t,o);t.onAfterRender(B,e,n,i,r,o),u=E.get(e,U||n)}function _t(t,e,n){var i=g.get(t),r=u.state.lights,o=u.state.shadowsArray,a=_.getParameters(t,r.state,o,e,Q.numPlanes,Q.numIntersection,n),s=_.getProgramCode(t,a),c=i.program,h=!0;if(void 0===c)t.addEventListener("dispose",ut);else if(c.code!==s)dt(t);else if(i.lightsHash!==r.state.hash)g.update(t,"lightsHash",r.state.hash),h=!1;else{if(void 0!==a.shaderID)return;h=!1}if(h){if(a.shaderID){var l=Yn[a.shaderID];i.shader={name:t.type,uniforms:qn.clone(l.uniforms),vertexShader:l.vertexShader,fragmentShader:l.fragmentShader}}else i.shader={name:t.type,uniforms:t.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader};t.onBeforeCompile(i.shader),c=_.acquireProgram(t,i.shader,a,s),i.program=c,t.program=c}var p=c.getAttributes();if(t.morphTargets){t.numSupportedMorphTargets=0;for(var d=0;d<B.maxMorphTargets;d++)p["morphTarget"+d]>=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(d=0;d<B.maxMorphNormals;d++)p["morphNormal"+d]>=0&&t.numSupportedMorphNormals++}var f=i.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(i.numClippingPlanes=Q.numPlanes,i.numIntersection=Q.numIntersection,f.clippingPlanes=Q.uniform),i.fog=e,i.lightsHash=r.state.hash,t.lights&&(f.ambientLightColor.value=r.state.ambient,f.directionalLights.value=r.state.directional,f.spotLights.value=r.state.spot,f.rectAreaLights.value=r.state.rectArea,f.pointLights.value=r.state.point,f.hemisphereLights.value=r.state.hemi,f.directionalShadowMap.value=r.state.directionalShadowMap,f.directionalShadowMatrix.value=r.state.directionalShadowMatrix,f.spotShadowMap.value=r.state.spotShadowMap,f.spotShadowMatrix.value=r.state.spotShadowMatrix,f.pointShadowMap.value=r.state.pointShadowMap,f.pointShadowMatrix.value=r.state.pointShadowMatrix);var m=i.program.getUniforms(),v=Hn.seqWithValue(m.seq,f);i.uniformsList=v}function Mt(t,e,n,i){j=0;var r=g.get(n),o=u.state.lights;if(K&&($||t!==D)){var a=t===D&&n.id===F;Q.setState(n.clippingPlanes,n.clipIntersection,n.clipShadows,t,r,a)}!1===n.needsUpdate&&(void 0===r.program||n.fog&&r.fog!==e||n.lights&&r.lightsHash!==o.state.hash?n.needsUpdate=!0:void 0===r.numClippingPlanes||r.numClippingPlanes===Q.numPlanes&&r.numIntersection===Q.numIntersection||(n.needsUpdate=!0)),n.needsUpdate&&(_t(n,e,i),n.needsUpdate=!1);var s,c,h=!1,l=!1,d=!1,f=r.program,y=f.getUniforms(),x=r.shader.uniforms;if(v.useProgram(f.program)&&(h=!0,l=!0,d=!0),n.id!==F&&(F=n.id,l=!0),h||t!==D){if(y.setValue(p,"projectionMatrix",t.projectionMatrix),m.logarithmicDepthBuffer&&y.setValue(p,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),D!==(U||t)&&(D=U||t,l=!0,d=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.envMap){var w=y.map.cameraPosition;void 0!==w&&w.setValue(p,et.setFromMatrixPosition(t.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.skinning)&&y.setValue(p,"viewMatrix",t.matrixWorldInverse)}if(n.skinning){y.setOptional(p,i,"bindMatrix"),y.setOptional(p,i,"bindMatrixInverse");var b=i.skeleton;if(b){var _=b.bones;if(m.floatVertexTextures){if(void 0===b.boneTexture){var M=Math.sqrt(4*_.length);M=ke.ceilPowerOfTwo(M),M=Math.max(M,4);var E=new Float32Array(M*M*4);E.set(b.boneMatrices);var S=new en(E,M,M,Xt,Ut);S.needsUpdate=!0,b.boneMatrices=E,b.boneTexture=S,b.boneTextureSize=M}y.setValue(p,"boneTexture",b.boneTexture),y.setValue(p,"boneTextureSize",b.boneTextureSize)}else y.setOptional(p,b,"boneMatrices")}}return l&&(y.setValue(p,"toneMappingExposure",B.toneMappingExposure),y.setValue(p,"toneMappingWhitePoint",B.toneMappingWhitePoint),n.lights&&(c=d,(s=x).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)}(x,e),n.isMeshBasicMaterial?Et(x,n):n.isMeshLambertMaterial?(Et(x,n),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(x,n)):n.isMeshPhongMaterial?(Et(x,n),n.isMeshToonMaterial?function(t,e){St(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(x,n):St(x,n)):n.isMeshStandardMaterial?(Et(x,n),n.isMeshPhysicalMaterial?function(t,e){t.clearCoat.value=e.clearCoat,t.clearCoatRoughness.value=e.clearCoatRoughness,Tt(t,e)}(x,n):Tt(x,n)):n.isMeshDepthMaterial?(Et(x,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(x,n)):n.isMeshDistanceMaterial?(Et(x,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}(x,n)):n.isMeshNormalMaterial?(Et(x,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)}(x,n)):n.isLineBasicMaterial?(function(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}(x,n),n.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(x,n)):n.isPointsMaterial?function(t,e){if(t.diffuse.value=e.color,t.opacity.value=e.opacity,t.size.value=e.size*q,t.scale.value=.5*W,t.map.value=e.map,null!==e.map){if(!0===e.map.matrixAutoUpdate){var n=e.map.offset,i=e.map.repeat,r=e.map.rotation,o=e.map.center;e.map.matrix.setUvTransform(n.x,n.y,i.x,i.y,r,o.x,o.y)}t.uvTransform.value.copy(e.map.matrix)}}(x,n):n.isShadowMaterial&&(x.color.value=n.color,x.opacity.value=n.opacity),void 0!==x.ltc_1&&(x.ltc_1.value=Wn.LTC_1),void 0!==x.ltc_2&&(x.ltc_2.value=Wn.LTC_2),Hn.upload(p,r.uniformsList,x,B)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(Hn.upload(p,r.uniformsList,x,B),n.uniformsNeedUpdate=!1),y.setValue(p,"modelViewMatrix",i.modelViewMatrix),y.setValue(p,"normalMatrix",i.normalMatrix),y.setValue(p,"modelMatrix",i.matrixWorld),f}function Et(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),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 i=n.offset,r=n.repeat,o=n.rotation,a=n.center;n.matrix.setUvTransform(i.x,i.y,r.x,r.y,o,a.x,a.y)}t.uvTransform.value.copy(n.matrix)}}function St(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 Tt(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!==(vt=t)?mt||(yt(),mt=!0):gt()},this.render=function(t,e,n,i){if(e&&e.isCamera){if(!I){z="",F=-1,D=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),st.enabled&&(e=st.getCamera(e)),(u=E.get(t,e)).init(),t.onBeforeRender(B,t,e,n),tt.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),J.setFromMatrix(tt),$=this.localClippingEnabled,K=Q.init(this.clippingPlanes,$,e),(l=M.get(t,e)).init(),function t(e,n,i){if(!1===e.visible)return;if(e.layers.test(n.layers))if(e.isLight)u.pushLight(e),e.castShadow&&u.pushShadow(e);else if(e.isSprite)e.frustumCulled&&!J.intersectsSprite(e)||u.pushSprite(e);else if(e.isImmediateRenderObject)i&&et.setFromMatrixPosition(e.matrixWorld).applyMatrix4(tt),l.push(e,null,e.material,et.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.update(),!e.frustumCulled||J.intersectsObject(e))){i&&et.setFromMatrixPosition(e.matrixWorld).applyMatrix4(tt);var r=b.update(e),o=e.material;if(Array.isArray(o))for(var a=r.groups,s=0,c=a.length;s<c;s++){var h=a[s],p=o[h.materialIndex];p&&p.visible&&l.push(e,r,p,et.z,h)}else o.visible&&l.push(e,r,o,et.z,null)}var d=e.children;for(s=0,c=d.length;s<c;s++)t(d[s],n,i)}(t,e,B.sortObjects),!0===B.sortObjects&&l.sort(),K&&Q.beginShadows();var r=u.state.shadowsArray;ct.render(r,t,e),u.setupLights(e),K&&Q.endShadows(),this.info.autoReset&&this.info.reset(),void 0===n&&(n=null),this.setRenderTarget(n),S.render(l,t,e,i);var o=l.opaque,a=l.transparent;if(t.overrideMaterial){var s=t.overrideMaterial;o.length&&wt(o,t,e,s),a.length&&wt(a,t,e,s)}else o.length&&wt(o,t,e),a.length&&wt(a,t,e);var c=u.state.spritesArray;L.render(c,t,e),n&&y.updateRenderTargetMipmap(n),v.buffers.depth.setTest(!0),v.buffers.depth.setMask(!0),v.buffers.color.setMask(!0),v.setPolygonOffset(!1),t.onAfterRender(B,t,e),st.enabled&&st.submitFrame(),l=null,u=null}}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.allocTextureUnit=function(){var t=j;return t>=m.maxTextures&&console.warn("THREE.WebGLRenderer: Trying to use "+t+" texture units while this GPU supports only "+m.maxTextures),j+=1,t},this.setTexture2D=(ft=!1,function(t,e){t&&t.isWebGLRenderTarget&&(ft||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),ft=!0),t=t.texture),y.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),y.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?y.setTextureCube(e,n):y.setTextureCubeDynamic(e,n)}}(),this.getRenderTarget=function(){return N},this.setRenderTarget=function(t){N=t,t&&void 0===g.get(t).__webglFramebuffer&&y.setupRenderTarget(t);var e=null,n=!1;if(t){var i=g.get(t).__webglFramebuffer;t.isWebGLRenderTargetCube?(e=i[t.activeCubeFace],n=!0):e=i,V.copy(t.viewport),G.copy(t.scissor),H=t.scissorTest}else V.copy(X).multiplyScalar(q),G.copy(Y).multiplyScalar(q),H=Z;if(O!==e&&(p.bindFramebuffer(p.FRAMEBUFFER,e),O=e),v.viewport(V),v.scissor(G),v.setScissorTest(H),n){var r=g.get(t.texture);p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_CUBE_MAP_POSITIVE_X+t.activeCubeFace,r.__webglTexture,t.activeMipMapLevel)}},this.readRenderTargetPixels=function(t,e,n,i,r,o){if(t&&t.isWebGLRenderTarget){var a=g.get(t).__webglFramebuffer;if(a){var s=!1;a!==O&&(p.bindFramebuffer(p.FRAMEBUFFER,a),s=!0);try{var c=t.texture,h=c.format,l=c.type;if(h!==Xt&&P.convert(h)!==p.getParameter(p.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(l===It||P.convert(l)===p.getParameter(p.IMPLEMENTATION_COLOR_READ_TYPE)||l===Ut&&(f.get("OES_texture_float")||f.get("WEBGL_color_buffer_float"))||l===Vt&&f.get("EXT_color_buffer_half_float")))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");p.checkFramebufferStatus(p.FRAMEBUFFER)===p.FRAMEBUFFER_COMPLETE?e>=0&&e<=t.width-i&&n>=0&&n<=t.height-r&&p.readPixels(e,n,i,r,P.convert(h),P.convert(l),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{s&&p.bindFramebuffer(p.FRAMEBUFFER,O)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(t,e,n){var i=e.image.width,r=e.image.height,o=P.convert(e.format);this.setTexture2D(e,0),p.copyTexImage2D(p.TEXTURE_2D,n||0,o,t.x,t.y,i,r,0)}}function Kr(t,e){this.name="",this.color=new kn(t),this.density=void 0!==e?e:25e-5}function $r(t,e,n){this.name="",this.color=new kn(t),this.near=void 0!==e?e:1,this.far=void 0!==n?n:1e3}function to(){bi.call(this),this.type="Scene",this.background=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0}function eo(t){oi.call(this),this.type="SpriteMaterial",this.color=new kn(16777215),this.map=null,this.rotation=0,this.fog=!1,this.lights=!1,this.setValues(t)}function no(t){bi.call(this),this.type="Sprite",this.material=void 0!==t?t:new eo,this.center=new We(.5,.5)}function io(){bi.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function ro(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,i=this.bones.length;n<i;n++)this.boneInverses.push(new qe)}}function oo(){bi.call(this),this.type="Bone"}function ao(t,e){rr.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new qe,this.bindMatrixInverse=new qe;var n=new ro(this.initBones());this.bind(n,this.matrixWorld),this.normalizeSkinWeights()}function so(t){oi.call(this),this.type="LineBasicMaterial",this.color=new kn(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.lights=!1,this.setValues(t)}function co(t,e,n){if(1===n)return console.warn("THREE.Line: parameter THREE.LinePieces no longer supported. Created THREE.LineSegments instead."),new ho(t,e);bi.call(this),this.type="Line",this.geometry=void 0!==t?t:new Yi,this.material=void 0!==e?e:new so({color:16777215*Math.random()})}function ho(t,e){co.call(this,t,e),this.type="LineSegments"}function lo(t,e){co.call(this,t,e),this.type="LineLoop"}function uo(t){oi.call(this),this.type="PointsMaterial",this.color=new kn(16777215),this.map=null,this.size=1,this.sizeAttenuation=!0,this.lights=!1,this.setValues(t)}function po(t,e){bi.call(this),this.type="Points",this.geometry=void 0!==t?t:new Yi,this.material=void 0!==e?e:new uo({color:16777215*Math.random()})}function fo(){bi.call(this),this.type="Group"}function mo(t,e,n,i,r,o,a,s,c){Qe.call(this,t,e,n,i,r,o,a,s,c),this.generateMipmaps=!1}function vo(t,e,n,i,r,o,a,s,c,h,l,u){Qe.call(this,null,o,a,s,c,h,i,r,l,u),this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function go(t,e,n,i,r,o,a,s,c,h){if((h=void 0!==h?h:Qt)!==Qt&&h!==Kt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&h===Qt&&(n=Ft),void 0===n&&h===Kt&&(n=kt),Qe.call(this,null,i,r,o,a,s,h,n,c),this.image={width:t,height:e},this.magFilter=void 0!==a?a:At,this.minFilter=void 0!==s?s:At,this.flipY=!1,this.generateMipmaps=!1}function yo(t){Yi.call(this),this.type="WireframeGeometry";var e,n,i,r,o,a,s,c,h,l,u=[],p=[0,0],d={},f=["a","b","c"];if(t&&t.isGeometry){var m=t.faces;for(e=0,i=m.length;e<i;e++){var v=m[e];for(n=0;n<3;n++)s=v[f[n]],c=v[f[(n+1)%3]],p[0]=Math.min(s,c),p[1]=Math.max(s,c),void 0===d[h=p[0]+","+p[1]]&&(d[h]={index1:p[0],index2:p[1]})}for(h in d)a=d[h],l=t.vertices[a.index1],u.push(l.x,l.y,l.z),l=t.vertices[a.index2],u.push(l.x,l.y,l.z)}else if(t&&t.isBufferGeometry){var g,y,x,w,b,_,M;if(l=new Ye,null!==t.index){for(g=t.attributes.position,y=t.index,0===(x=t.groups).length&&(x=[{start:0,count:y.count,materialIndex:0}]),r=0,o=x.length;r<o;++r)for(e=b=(w=x[r]).start,i=b+w.count;e<i;e+=3)for(n=0;n<3;n++)s=y.getX(e+n),c=y.getX(e+(n+1)%3),p[0]=Math.min(s,c),p[1]=Math.max(s,c),void 0===d[h=p[0]+","+p[1]]&&(d[h]={index1:p[0],index2:p[1]});for(h in d)a=d[h],l.fromBufferAttribute(g,a.index1),u.push(l.x,l.y,l.z),l.fromBufferAttribute(g,a.index2),u.push(l.x,l.y,l.z)}else for(e=0,i=(g=t.attributes.position).count/3;e<i;e++)for(n=0;n<3;n++)_=3*e+n,l.fromBufferAttribute(g,_),u.push(l.x,l.y,l.z),M=3*e+(n+1)%3,l.fromBufferAttribute(g,M),u.push(l.x,l.y,l.z)}this.addAttribute("position",new Fi(u,3))}function xo(t,e,n){Ai.call(this),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:n},this.fromBufferGeometry(new wo(t,e,n)),this.mergeVertices()}function wo(t,e,n){Yi.call(this),this.type="ParametricBufferGeometry",this.parameters={func:t,slices:e,stacks:n};var i,r,o=[],a=[],s=[],c=[],h=1e-5,l=new Ye,u=new Ye,p=new Ye,d=new Ye,f=new Ye,m=e+1;for(i=0;i<=n;i++){var v=i/n;for(r=0;r<=e;r++){var g=r/e;u=t(g,v,u),a.push(u.x,u.y,u.z),g-h>=0?(p=t(g-h,v,p),d.subVectors(u,p)):(p=t(g+h,v,p),d.subVectors(p,u)),v-h>=0?(p=t(g,v-h,p),f.subVectors(u,p)):(p=t(g,v+h,p),f.subVectors(p,u)),l.crossVectors(d,f).normalize(),s.push(l.x,l.y,l.z),c.push(g,v)}}for(i=0;i<n;i++)for(r=0;r<e;r++){var y=i*m+r,x=i*m+r+1,w=(i+1)*m+r+1,b=(i+1)*m+r;o.push(y,x,b),o.push(x,w,b)}this.setIndex(o),this.addAttribute("position",new Fi(a,3)),this.addAttribute("normal",new Fi(s,3)),this.addAttribute("uv",new Fi(c,2))}function bo(t,e,n,i){Ai.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i},this.fromBufferGeometry(new _o(t,e,n,i)),this.mergeVertices()}function _o(t,e,n,i){Yi.call(this),this.type="PolyhedronBufferGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i},n=n||1;var r=[],o=[];function a(t,e,n,i){var r,o,a=Math.pow(2,i),c=[];for(r=0;r<=a;r++){c[r]=[];var h=t.clone().lerp(n,r/a),l=e.clone().lerp(n,r/a),u=a-r;for(o=0;o<=u;o++)c[r][o]=0===o&&r===a?h:h.clone().lerp(l,o/u)}for(r=0;r<a;r++)for(o=0;o<2*(a-r)-1;o++){var p=Math.floor(o/2);o%2==0?(s(c[r][p+1]),s(c[r+1][p]),s(c[r][p])):(s(c[r][p+1]),s(c[r+1][p+1]),s(c[r+1][p]))}}function s(t){r.push(t.x,t.y,t.z)}function c(e,n){var i=3*e;n.x=t[i+0],n.y=t[i+1],n.z=t[i+2]}function h(t,e,n,i){i<0&&1===t.x&&(o[e]=t.x-1),0===n.x&&0===n.z&&(o[e]=i/2/Math.PI+.5)}function l(t){return Math.atan2(t.z,-t.x)}function u(t){return Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))}!function(t){for(var n=new Ye,i=new Ye,r=new Ye,o=0;o<e.length;o+=3)c(e[o+0],n),c(e[o+1],i),c(e[o+2],r),a(n,i,r,t)}(i=i||0),function(t){for(var e=new Ye,n=0;n<r.length;n+=3)e.x=r[n+0],e.y=r[n+1],e.z=r[n+2],e.normalize().multiplyScalar(t),r[n+0]=e.x,r[n+1]=e.y,r[n+2]=e.z}(n),function(){for(var t=new Ye,e=0;e<r.length;e+=3){t.x=r[e+0],t.y=r[e+1],t.z=r[e+2];var n=l(t)/2/Math.PI+.5,i=u(t)/Math.PI+.5;o.push(n,1-i)}(function(){for(var t=new Ye,e=new Ye,n=new Ye,i=new Ye,a=new We,s=new We,c=new We,u=0,p=0;u<r.length;u+=9,p+=6){t.set(r[u+0],r[u+1],r[u+2]),e.set(r[u+3],r[u+4],r[u+5]),n.set(r[u+6],r[u+7],r[u+8]),a.set(o[p+0],o[p+1]),s.set(o[p+2],o[p+3]),c.set(o[p+4],o[p+5]),i.copy(t).add(e).add(n).divideScalar(3);var d=l(i);h(a,p+0,t,d),h(s,p+2,e,d),h(c,p+4,n,d)}})(),function(){for(var t=0;t<o.length;t+=6){var e=o[t+0],n=o[t+2],i=o[t+4],r=Math.max(e,n,i),a=Math.min(e,n,i);r>.9&&a<.1&&(e<.2&&(o[t+0]+=1),n<.2&&(o[t+2]+=1),i<.2&&(o[t+4]+=1))}}()}(),this.addAttribute("position",new Fi(r,3)),this.addAttribute("normal",new Fi(r.slice(),3)),this.addAttribute("uv",new Fi(o,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}function Mo(t,e){Ai.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Eo(t,e)),this.mergeVertices()}function Eo(t,e){_o.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 So(t,e){Ai.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new To(t,e)),this.mergeVertices()}function To(t,e){_o.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 Ao(t,e){Ai.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Ro(t,e)),this.mergeVertices()}function Ro(t,e){var n=(1+Math.sqrt(5))/2,i=[-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];_o.call(this,i,[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 Co(t,e){Ai.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Lo(t,e)),this.mergeVertices()}function Lo(t,e){var n=(1+Math.sqrt(5))/2,i=1/n,r=[-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,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i];_o.call(this,r,[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 Po(t,e,n,i,r,o){Ai.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:i,closed:r},void 0!==o&&console.warn("THREE.TubeGeometry: taper has been removed.");var a=new Bo(t,e,n,i,r);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,this.fromBufferGeometry(a),this.mergeVertices()}function Bo(t,e,n,i,r){Yi.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:i,closed:r},e=e||64,n=n||1,i=i||8,r=r||!1;var o=t.computeFrenetFrames(e,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;var a,s,c=new Ye,h=new Ye,l=new We,u=new Ye,p=[],d=[],f=[],m=[];function v(r){u=t.getPointAt(r/e,u);var a=o.normals[r],l=o.binormals[r];for(s=0;s<=i;s++){var f=s/i*Math.PI*2,m=Math.sin(f),v=-Math.cos(f);h.x=v*a.x+m*l.x,h.y=v*a.y+m*l.y,h.z=v*a.z+m*l.z,h.normalize(),d.push(h.x,h.y,h.z),c.x=u.x+n*h.x,c.y=u.y+n*h.y,c.z=u.z+n*h.z,p.push(c.x,c.y,c.z)}}!function(){for(a=0;a<e;a++)v(a);v(!1===r?e:0),function(){for(a=0;a<=e;a++)for(s=0;s<=i;s++)l.x=a/e,l.y=s/i,f.push(l.x,l.y)}(),function(){for(s=1;s<=e;s++)for(a=1;a<=i;a++){var t=(i+1)*(s-1)+(a-1),n=(i+1)*s+(a-1),r=(i+1)*s+a,o=(i+1)*(s-1)+a;m.push(t,n,o),m.push(n,r,o)}}()}(),this.setIndex(m),this.addAttribute("position",new Fi(p,3)),this.addAttribute("normal",new Fi(d,3)),this.addAttribute("uv",new Fi(f,2))}function Io(t,e,n,i,r,o,a){Ai.call(this),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:r,q:o},void 0!==a&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead."),this.fromBufferGeometry(new No(t,e,n,i,r,o)),this.mergeVertices()}function No(t,e,n,i,r,o){Yi.call(this),this.type="TorusKnotBufferGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:r,q:o},t=t||1,e=e||.4,n=Math.floor(n)||64,i=Math.floor(i)||8,r=r||2,o=o||3;var a,s,c=[],h=[],l=[],u=[],p=new Ye,d=new Ye,f=new Ye,m=new Ye,v=new Ye,g=new Ye,y=new Ye;for(a=0;a<=n;++a){var x=a/n*r*Math.PI*2;for(A(x,r,o,t,f),A(x+.01,r,o,t,m),g.subVectors(m,f),y.addVectors(m,f),v.crossVectors(g,y),y.crossVectors(v,g),v.normalize(),y.normalize(),s=0;s<=i;++s){var w=s/i*Math.PI*2,b=-e*Math.cos(w),_=e*Math.sin(w);p.x=f.x+(b*y.x+_*v.x),p.y=f.y+(b*y.y+_*v.y),p.z=f.z+(b*y.z+_*v.z),h.push(p.x,p.y,p.z),d.subVectors(p,f).normalize(),l.push(d.x,d.y,d.z),u.push(a/n),u.push(s/i)}}for(s=1;s<=n;s++)for(a=1;a<=i;a++){var M=(i+1)*(s-1)+(a-1),E=(i+1)*s+(a-1),S=(i+1)*s+a,T=(i+1)*(s-1)+a;c.push(M,E,T),c.push(E,S,T)}function A(t,e,n,i,r){var o=Math.cos(t),a=Math.sin(t),s=n/e*t,c=Math.cos(s);r.x=i*(2+c)*.5*o,r.y=i*(2+c)*a*.5,r.z=i*Math.sin(s)*.5}this.setIndex(c),this.addAttribute("position",new Fi(h,3)),this.addAttribute("normal",new Fi(l,3)),this.addAttribute("uv",new Fi(u,2))}function Oo(t,e,n,i,r){Ai.call(this),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:i,arc:r},this.fromBufferGeometry(new Fo(t,e,n,i,r)),this.mergeVertices()}function Fo(t,e,n,i,r){Yi.call(this),this.type="TorusBufferGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:i,arc:r},t=t||1,e=e||.4,n=Math.floor(n)||8,i=Math.floor(i)||6,r=r||2*Math.PI;var o,a,s=[],c=[],h=[],l=[],u=new Ye,p=new Ye,d=new Ye;for(o=0;o<=n;o++)for(a=0;a<=i;a++){var f=a/i*r,m=o/n*Math.PI*2;p.x=(t+e*Math.cos(m))*Math.cos(f),p.y=(t+e*Math.cos(m))*Math.sin(f),p.z=e*Math.sin(m),c.push(p.x,p.y,p.z),u.x=t*Math.cos(f),u.y=t*Math.sin(f),d.subVectors(p,u).normalize(),h.push(d.x,d.y,d.z),l.push(a/i),l.push(o/n)}for(o=1;o<=n;o++)for(a=1;a<=i;a++){var v=(i+1)*o+a-1,g=(i+1)*(o-1)+a-1,y=(i+1)*(o-1)+a,x=(i+1)*o+a;s.push(v,g,x),s.push(g,y,x)}this.setIndex(s),this.addAttribute("position",new Fi(c,3)),this.addAttribute("normal",new Fi(h,3)),this.addAttribute("uv",new Fi(l,2))}Kr.prototype.isFogExp2=!0,Kr.prototype.clone=function(){return new Kr(this.color.getHex(),this.density)},Kr.prototype.toJSON=function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}},$r.prototype.isFog=!0,$r.prototype.clone=function(){return new $r(this.color.getHex(),this.near,this.far)},$r.prototype.toJSON=function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}},to.prototype=Object.assign(Object.create(bi.prototype),{constructor:to,copy:function(t,e){return bi.prototype.copy.call(this,t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this},toJSON:function(t){var e=bi.prototype.toJSON.call(this,t);return null!==this.background&&(e.object.background=this.background.toJSON(t)),null!==this.fog&&(e.object.fog=this.fog.toJSON()),e}}),eo.prototype=Object.create(oi.prototype),eo.prototype.constructor=eo,eo.prototype.isSpriteMaterial=!0,eo.prototype.copy=function(t){return oi.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.rotation=t.rotation,this},no.prototype=Object.assign(Object.create(bi.prototype),{constructor:no,isSprite:!0,raycast:(Ur=new Ye,Vr=new Ye,Gr=new Ye,function(t,e){Vr.setFromMatrixPosition(this.matrixWorld),t.ray.closestPointToPoint(Vr,Ur),Gr.setFromMatrixScale(this.matrixWorld);var n=Gr.x*Gr.y/4;if(!(Vr.distanceToSquared(Ur)>n)){var i=t.ray.origin.distanceTo(Ur);i<t.near||i>t.far||e.push({distance:i,point:Ur.clone(),face:null,object:this})}}),clone:function(){return new this.constructor(this.material).copy(this)},copy:function(t){return bi.prototype.copy.call(this,t),void 0!==t.center&&this.center.copy(t.center),this}}),io.prototype=Object.assign(Object.create(bi.prototype),{constructor:io,copy:function(t){bi.prototype.copy.call(this,t,!1);for(var e=t.levels,n=0,i=e.length;n<i;n++){var r=e[n];this.addLevel(r.object.clone(),r.distance)}return this},addLevel:function(t,e){void 0===e&&(e=0),e=Math.abs(e);for(var n=this.levels,i=0;i<n.length&&!(e<n[i].distance);i++);n.splice(i,0,{distance:e,object:t}),this.add(t)},getObjectForDistance:function(t){for(var e=this.levels,n=1,i=e.length;n<i&&!(t<e[n].distance);n++);return e[n-1].object},raycast:(Hr=new Ye,function(t,e){Hr.setFromMatrixPosition(this.matrixWorld);var n=t.ray.origin.distanceTo(Hr);this.getObjectForDistance(n).raycast(t,e)}),update:function(){var t=new Ye,e=new Ye;return function(n){var i=this.levels;if(i.length>1){t.setFromMatrixPosition(n.matrixWorld),e.setFromMatrixPosition(this.matrixWorld);var r=t.distanceTo(e);i[0].object.visible=!0;for(var o=1,a=i.length;o<a&&r>=i[o].distance;o++)i[o-1].object.visible=!1,i[o].object.visible=!0;for(;o<a;o++)i[o].object.visible=!1}}}(),toJSON:function(t){var e=bi.prototype.toJSON.call(this,t);e.object.levels=[];for(var n=this.levels,i=0,r=n.length;i<r;i++){var o=n[i];e.object.levels.push({object:o.object.uuid,distance:o.distance})}return e}}),Object.assign(ro.prototype,{calculateInverses:function(){this.boneInverses=[];for(var t=0,e=this.bones.length;t<e;t++){var n=new qe;this.bones[t]&&n.getInverse(this.bones[t].matrixWorld),this.boneInverses.push(n)}},pose:function(){var t,e,n;for(e=0,n=this.bones.length;e<n;e++)(t=this.bones[e])&&t.matrixWorld.getInverse(this.boneInverses[e]);for(e=0,n=this.bones.length;e<n;e++)(t=this.bones[e])&&(t.parent&&t.parent.isBone?(t.matrix.getInverse(t.parent.matrixWorld),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))},update:(jr=new qe,kr=new qe,function(){for(var t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture,r=0,o=t.length;r<o;r++){var a=t[r]?t[r].matrixWorld:kr;jr.multiplyMatrices(a,e[r]),jr.toArray(n,16*r)}void 0!==i&&(i.needsUpdate=!0)}),clone:function(){return new ro(this.bones,this.boneInverses)},getBoneByName:function(t){for(var e=0,n=this.bones.length;e<n;e++){var i=this.bones[e];if(i.name===t)return i}}}),oo.prototype=Object.assign(Object.create(bi.prototype),{constructor:oo,isBone:!0}),ao.prototype=Object.assign(Object.create(rr.prototype),{constructor:ao,isSkinnedMesh:!0,initBones:function(){var t,e,n,i,r=[];if(this.geometry&&void 0!==this.geometry.bones){for(n=0,i=this.geometry.bones.length;n<i;n++)e=this.geometry.bones[n],t=new oo,r.push(t),t.name=e.name,t.position.fromArray(e.pos),t.quaternion.fromArray(e.rotq),void 0!==e.scl&&t.scale.fromArray(e.scl);for(n=0,i=this.geometry.bones.length;n<i;n++)-1!==(e=this.geometry.bones[n]).parent&&null!==e.parent&&void 0!==r[e.parent]?r[e.parent].add(r[n]):this.add(r[n])}return this.updateMatrixWorld(!0),r},bind:function(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.getInverse(e)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){var t,e;if(this.geometry&&this.geometry.isGeometry)for(e=0;e<this.geometry.skinWeights.length;e++){var n=this.geometry.skinWeights[e];(t=1/n.manhattanLength())!==1/0?n.multiplyScalar(t):n.set(1,0,0,0)}else if(this.geometry&&this.geometry.isBufferGeometry){var i=new Ke,r=this.geometry.attributes.skinWeight;for(e=0;e<r.count;e++)i.x=r.getX(e),i.y=r.getY(e),i.z=r.getZ(e),i.w=r.getW(e),(t=1/i.manhattanLength())!==1/0?i.multiplyScalar(t):i.set(1,0,0,0),r.setXYZW(e,i.x,i.y,i.z,i.w)}},updateMatrixWorld:function(t){rr.prototype.updateMatrixWorld.call(this,t),"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),so.prototype=Object.create(oi.prototype),so.prototype.constructor=so,so.prototype.isLineBasicMaterial=!0,so.prototype.copy=function(t){return oi.prototype.copy.call(this,t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this},co.prototype=Object.assign(Object.create(bi.prototype),{constructor:co,isLine:!0,computeLineDistances:(Wr=new Ye,qr=new Ye,function(){var t=this.geometry;if(t.isBufferGeometry)if(null===t.index){for(var e=t.attributes.position,n=[0],i=1,r=e.count;i<r;i++)Wr.fromBufferAttribute(e,i-1),qr.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=Wr.distanceTo(qr);t.addAttribute("lineDistance",new THREE.Float32BufferAttribute(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(t.isGeometry){var o=t.vertices;for((n=t.lineDistances)[0]=0,i=1,r=o.length;i<r;i++)n[i]=n[i-1],n[i]+=o[i-1].distanceTo(o[i])}return this}),raycast:function(){var t=new qe,e=new er,n=new hi;return function(i,r){var o=i.linePrecision,a=o*o,s=this.geometry,c=this.matrixWorld;if(null===s.boundingSphere&&s.computeBoundingSphere(),n.copy(s.boundingSphere),n.applyMatrix4(c),!1!==i.ray.intersectsSphere(n)){t.getInverse(c),e.copy(i.ray).applyMatrix4(t);var h=new Ye,l=new Ye,u=new Ye,p=new Ye,d=this&&this.isLineSegments?2:1;if(s.isBufferGeometry){var f=s.index,m=s.attributes.position.array;if(null!==f)for(var v=f.array,g=0,y=v.length-1;g<y;g+=d){var x=v[g],w=v[g+1];if(h.fromArray(m,3*x),l.fromArray(m,3*w),!(e.distanceSqToSegment(h,l,p,u)>a))p.applyMatrix4(this.matrixWorld),(M=i.ray.origin.distanceTo(p))<i.near||M>i.far||r.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this})}else for(g=0,y=m.length/3-1;g<y;g+=d){if(h.fromArray(m,3*g),l.fromArray(m,3*g+3),!(e.distanceSqToSegment(h,l,p,u)>a))p.applyMatrix4(this.matrixWorld),(M=i.ray.origin.distanceTo(p))<i.near||M>i.far||r.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this})}}else if(s.isGeometry){var b=s.vertices,_=b.length;for(g=0;g<_-1;g+=d){var M;if(!(e.distanceSqToSegment(b[g],b[g+1],p,u)>a))p.applyMatrix4(this.matrixWorld),(M=i.ray.origin.distanceTo(p))<i.near||M>i.far||r.push({distance:M,point:u.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this})}}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),ho.prototype=Object.assign(Object.create(co.prototype),{constructor:ho,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 i=n.attributes.position,r=[],o=0,a=i.count;o<a;o+=2)t.fromBufferAttribute(i,o),e.fromBufferAttribute(i,o+1),r[o]=0===o?0:r[o-1],r[o+1]=r[o]+t.distanceTo(e);n.addAttribute("lineDistance",new THREE.Float32BufferAttribute(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(n.isGeometry){var s=n.vertices;for(r=n.lineDistances,o=0,a=s.length;o<a;o+=2)t.copy(s[o]),e.copy(s[o+1]),r[o]=0===o?0:r[o-1],r[o+1]=r[o]+t.distanceTo(e)}return this}}()}),lo.prototype=Object.assign(Object.create(co.prototype),{constructor:lo,isLineLoop:!0}),uo.prototype=Object.create(oi.prototype),uo.prototype.constructor=uo,uo.prototype.isPointsMaterial=!0,uo.prototype.copy=function(t){return oi.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this},po.prototype=Object.assign(Object.create(bi.prototype),{constructor:po,isPoints:!0,raycast:function(){var t=new qe,e=new er,n=new hi;return function(i,r){var o=this,a=this.geometry,s=this.matrixWorld,c=i.params.Points.threshold;if(null===a.boundingSphere&&a.computeBoundingSphere(),n.copy(a.boundingSphere),n.applyMatrix4(s),n.radius+=c,!1!==i.ray.intersectsSphere(n)){t.getInverse(s),e.copy(i.ray).applyMatrix4(t);var h=c/((this.scale.x+this.scale.y+this.scale.z)/3),l=h*h,u=new Ye;if(a.isBufferGeometry){var p=a.index,d=a.attributes.position.array;if(null!==p)for(var f=p.array,m=0,v=f.length;m<v;m++){var g=f[m];u.fromArray(d,3*g),w(u,g)}else{m=0;for(var y=d.length/3;m<y;m++)u.fromArray(d,3*m),w(u,m)}}else{var x=a.vertices;for(m=0,y=x.length;m<y;m++)w(x[m],m)}}function w(t,n){var a=e.distanceSqToPoint(t);if(a<l){var c=e.closestPointToPoint(t);c.applyMatrix4(s);var h=i.ray.origin.distanceTo(c);if(h<i.near||h>i.far)return;r.push({distance:h,distanceToRay:Math.sqrt(a),point:c.clone(),index:n,face:null,object:o})}}}}(),clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),fo.prototype=Object.assign(Object.create(bi.prototype),{constructor:fo,isGroup:!0}),mo.prototype=Object.assign(Object.create(Qe.prototype),{constructor:mo,isVideoTexture:!0,update:function(){var t=this.image;t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),vo.prototype=Object.create(Qe.prototype),vo.prototype.constructor=vo,vo.prototype.isCompressedTexture=!0,go.prototype=Object.create(Qe.prototype),go.prototype.constructor=go,go.prototype.isDepthTexture=!0,yo.prototype=Object.create(Yi.prototype),yo.prototype.constructor=yo,xo.prototype=Object.create(Ai.prototype),xo.prototype.constructor=xo,wo.prototype=Object.create(Yi.prototype),wo.prototype.constructor=wo,bo.prototype=Object.create(Ai.prototype),bo.prototype.constructor=bo,_o.prototype=Object.create(Yi.prototype),_o.prototype.constructor=_o,Mo.prototype=Object.create(Ai.prototype),Mo.prototype.constructor=Mo,Eo.prototype=Object.create(_o.prototype),Eo.prototype.constructor=Eo,So.prototype=Object.create(Ai.prototype),So.prototype.constructor=So,To.prototype=Object.create(_o.prototype),To.prototype.constructor=To,Ao.prototype=Object.create(Ai.prototype),Ao.prototype.constructor=Ao,Ro.prototype=Object.create(_o.prototype),Ro.prototype.constructor=Ro,Co.prototype=Object.create(Ai.prototype),Co.prototype.constructor=Co,Lo.prototype=Object.create(_o.prototype),Lo.prototype.constructor=Lo,Po.prototype=Object.create(Ai.prototype),Po.prototype.constructor=Po,Bo.prototype=Object.create(Yi.prototype),Bo.prototype.constructor=Bo,Io.prototype=Object.create(Ai.prototype),Io.prototype.constructor=Io,No.prototype=Object.create(Yi.prototype),No.prototype.constructor=No,Oo.prototype=Object.create(Ai.prototype),Oo.prototype.constructor=Oo,Fo.prototype=Object.create(Yi.prototype),Fo.prototype.constructor=Fo;var zo=function(t,e,n){n=n||2;var i,r,o,a,s,c,h,l=e&&e.length,u=l?e[0]*n:t.length,p=Do(t,0,u,n,!0),d=[];if(!p)return d;if(l&&(p=function(t,e,n,i){var r,o,a,s,c,h=[];for(r=0,o=e.length;r<o;r++)a=e[r]*i,s=r<o-1?e[r+1]*i:t.length,(c=Do(t,a,s,i,!1))===c.next&&(c.steiner=!0),h.push(Yo(c));for(h.sort(Wo),r=0;r<h.length;r++)qo(h[r],n),n=Uo(n,n.next);return n}(t,e,p,n)),t.length>80*n){i=o=t[0],r=a=t[1];for(var f=n;f<u;f+=n)(s=t[f])<i&&(i=s),(c=t[f+1])<r&&(r=c),s>o&&(o=s),c>a&&(a=c);h=0!==(h=Math.max(o-i,a-r))?1/h:0}return Vo(p,d,n,i,r,h),d};function Do(t,e,n,i,r){var o,a;if(r===function(t,e,n,i){for(var r=0,o=e,a=n-i;o<n;o+=i)r+=(t[a]-t[o])*(t[o+1]+t[a+1]),a=o;return r}(t,e,n,i)>0)for(o=e;o<n;o+=i)a=na(o,t[o],t[o+1],a);else for(o=n-i;o>=e;o-=i)a=na(o,t[o],t[o+1],a);return a&&Ko(a,a.next)&&(ia(a),a=a.next),a}function Uo(t,e){if(!t)return t;e||(e=t);var n,i=t;do{if(n=!1,i.steiner||!Ko(i,i.next)&&0!==Qo(i.prev,i,i.next))i=i.next;else{if(ia(i),(i=e=i.prev)===i.next)break;n=!0}}while(n||i!==e);return e}function Vo(t,e,n,i,r,o,a){if(t){!a&&o&&function(t,e,n,i){var r=t;do{null===r.z&&(r.z=Xo(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,n,i,r,o,a,s,c,h=1;do{for(n=t,t=null,o=null,a=0;n;){for(a++,i=n,s=0,e=0;e<h&&(s++,i=i.nextZ);e++);for(c=h;s>0||c>0&&i;)0!==s&&(0===c||!i||n.z<=i.z)?(r=n,n=n.nextZ,s--):(r=i,i=i.nextZ,c--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;n=i}o.nextZ=null,h*=2}while(a>1)}(r)}(t,i,r,o);for(var s,c,h=t;t.prev!==t.next;)if(s=t.prev,c=t.next,o?Ho(t,i,r,o):Go(t))e.push(s.i/n),e.push(t.i/n),e.push(c.i/n),ia(t),t=c.next,h=c.next;else if((t=c)===h){a?1===a?Vo(t=jo(t,e,n),e,n,i,r,o,2):2===a&&ko(t,e,n,i,r,o):Vo(Uo(t),e,n,i,r,o,1);break}}}function Go(t){var e=t.prev,n=t,i=t.next;if(Qo(e,n,i)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(Zo(e.x,e.y,n.x,n.y,i.x,i.y,r.x,r.y)&&Qo(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Ho(t,e,n,i){var r=t.prev,o=t,a=t.next;if(Qo(r,o,a)>=0)return!1;for(var s=r.x<o.x?r.x<a.x?r.x:a.x:o.x<a.x?o.x:a.x,c=r.y<o.y?r.y<a.y?r.y:a.y:o.y<a.y?o.y:a.y,h=r.x>o.x?r.x>a.x?r.x:a.x:o.x>a.x?o.x:a.x,l=r.y>o.y?r.y>a.y?r.y:a.y:o.y>a.y?o.y:a.y,u=Xo(s,c,e,n,i),p=Xo(h,l,e,n,i),d=t.nextZ;d&&d.z<=p;){if(d!==t.prev&&d!==t.next&&Zo(r.x,r.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Qo(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(d=t.prevZ;d&&d.z>=u;){if(d!==t.prev&&d!==t.next&&Zo(r.x,r.y,o.x,o.y,a.x,a.y,d.x,d.y)&&Qo(d.prev,d,d.next)>=0)return!1;d=d.prevZ}return!0}function jo(t,e,n){var i=t;do{var r=i.prev,o=i.next.next;!Ko(r,o)&&$o(r,i,i.next,o)&&ta(r,o)&&ta(o,r)&&(e.push(r.i/n),e.push(i.i/n),e.push(o.i/n),ia(i),ia(i.next),i=t=o),i=i.next}while(i!==t);return i}function ko(t,e,n,i,r,o){var a=t;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Jo(a,s)){var c=ea(a,s);return a=Uo(a,a.next),c=Uo(c,c.next),Vo(a,e,n,i,r,o),void Vo(c,e,n,i,r,o)}s=s.next}a=a.next}while(a!==t)}function Wo(t,e){return t.x-e.x}function qo(t,e){if(e=function(t,e){var n,i=e,r=t.x,o=t.y,a=-1/0;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){var s=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=r&&s>a){if(a=s,s===r){if(o===i.y)return i;if(o===i.next.y)return i.next}n=i.x<i.next.x?i:i.next}}i=i.next}while(i!==e);if(!n)return null;if(r===a)return n.prev;var c,h=n,l=n.x,u=n.y,p=1/0;i=n.next;for(;i!==h;)r>=i.x&&i.x>=l&&r!==i.x&&Zo(o<u?r:a,o,l,u,o<u?a:r,o,i.x,i.y)&&((c=Math.abs(o-i.y)/(r-i.x))<p||c===p&&i.x>n.x)&&ta(i,t)&&(n=i,p=c),i=i.next;return n}(t,e)){var n=ea(e,t);Uo(n,n.next)}}function Xo(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Yo(t){var e=t,n=t;do{e.x<n.x&&(n=e),e=e.next}while(e!==t);return n}function Zo(t,e,n,i,r,o,a,s){return(r-a)*(e-s)-(t-a)*(o-s)>=0&&(t-a)*(i-s)-(n-a)*(e-s)>=0&&(n-a)*(o-s)-(r-a)*(i-s)>=0}function Jo(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&&$o(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&ta(t,e)&&ta(e,t)&&function(t,e){var n=t,i=!1,r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)}function Qo(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Ko(t,e){return t.x===e.x&&t.y===e.y}function $o(t,e,n,i){return!!(Ko(t,e)&&Ko(n,i)||Ko(t,i)&&Ko(n,e))||Qo(t,e,n)>0!=Qo(t,e,i)>0&&Qo(n,i,t)>0!=Qo(n,i,e)>0}function ta(t,e){return Qo(t.prev,t,t.next)<0?Qo(t,e,t.next)>=0&&Qo(t,t.prev,e)>=0:Qo(t,e,t.prev)<0||Qo(t,t.next,e)<0}function ea(t,e){var n=new ra(t.i,t.x,t.y),i=new ra(e.i,e.x,e.y),r=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function na(t,e,n,i){var r=new ra(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function ia(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 ra(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 oa={area:function(t){for(var e=t.length,n=0,i=e-1,r=0;r<e;i=r++)n+=t[i].x*t[r].y-t[r].x*t[i].y;return.5*n},isClockWise:function(t){return oa.area(t)<0},triangulateShape:function(t,e){var n=[],i=[],r=[];aa(t),sa(n,t);var o=t.length;e.forEach(aa);for(var a=0;a<e.length;a++)i.push(o),o+=e[a].length,sa(n,e[a]);var s=zo(n,i);for(a=0;a<s.length;a+=3)r.push(s.slice(a,a+3));return r}};function aa(t){var e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function sa(t,e){for(var n=0;n<e.length;n++)t.push(e[n].x),t.push(e[n].y)}function ca(t,e){Ai.call(this),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},this.fromBufferGeometry(new ha(t,e)),this.mergeVertices()}function ha(t,e){void 0!==t&&(Yi.call(this),this.type="ExtrudeBufferGeometry",t=Array.isArray(t)?t:[t],this.addShapeList(t,e),this.computeVertexNormals())}function la(t,e){Ai.call(this),this.type="TextGeometry",this.parameters={text:t,parameters:e},this.fromBufferGeometry(new ua(t,e)),this.mergeVertices()}function ua(t,e){var n=(e=e||{}).font;if(!n||!n.isFont)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new Ai;var i=n.generateShapes(t,e.size,e.curveSegments);e.amount=void 0!==e.height?e.height:50,void 0===e.bevelThickness&&(e.bevelThickness=10),void 0===e.bevelSize&&(e.bevelSize=8),void 0===e.bevelEnabled&&(e.bevelEnabled=!1),ha.call(this,i,e),this.type="TextBufferGeometry"}function pa(t,e,n,i,r,o,a){Ai.call(this),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:o,thetaLength:a},this.fromBufferGeometry(new da(t,e,n,i,r,o,a)),this.mergeVertices()}function da(t,e,n,i,r,o,a){Yi.call(this),this.type="SphereBufferGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:o,thetaLength:a},t=t||1,e=Math.max(3,Math.floor(e)||8),n=Math.max(2,Math.floor(n)||6),i=void 0!==i?i:0,r=void 0!==r?r:2*Math.PI;var s,c,h=(o=void 0!==o?o:0)+(a=void 0!==a?a:Math.PI),l=0,u=[],p=new Ye,d=new Ye,f=[],m=[],v=[],g=[];for(c=0;c<=n;c++){var y=[],x=c/n;for(s=0;s<=e;s++){var w=s/e;p.x=-t*Math.cos(i+w*r)*Math.sin(o+x*a),p.y=t*Math.cos(o+x*a),p.z=t*Math.sin(i+w*r)*Math.sin(o+x*a),m.push(p.x,p.y,p.z),d.set(p.x,p.y,p.z).normalize(),v.push(d.x,d.y,d.z),g.push(w,1-x),y.push(l++)}u.push(y)}for(c=0;c<n;c++)for(s=0;s<e;s++){var b=u[c][s+1],_=u[c][s],M=u[c+1][s],E=u[c+1][s+1];(0!==c||o>0)&&f.push(b,_,E),(c!==n-1||h<Math.PI)&&f.push(_,M,E)}this.setIndex(f),this.addAttribute("position",new Fi(m,3)),this.addAttribute("normal",new Fi(v,3)),this.addAttribute("uv",new Fi(g,2))}function fa(t,e,n,i,r,o){Ai.call(this),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:o},this.fromBufferGeometry(new ma(t,e,n,i,r,o)),this.mergeVertices()}function ma(t,e,n,i,r,o){Yi.call(this),this.type="RingBufferGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:o},t=t||.5,e=e||1,r=void 0!==r?r:0,o=void 0!==o?o:2*Math.PI,n=void 0!==n?Math.max(3,n):8;var a,s,c,h=[],l=[],u=[],p=[],d=t,f=(e-t)/(i=void 0!==i?Math.max(1,i):1),m=new Ye,v=new We;for(s=0;s<=i;s++){for(c=0;c<=n;c++)a=r+c/n*o,m.x=d*Math.cos(a),m.y=d*Math.sin(a),l.push(m.x,m.y,m.z),u.push(0,0,1),v.x=(m.x/e+1)/2,v.y=(m.y/e+1)/2,p.push(v.x,v.y);d+=f}for(s=0;s<i;s++){var g=s*(n+1);for(c=0;c<n;c++){var y=a=c+g,x=a+n+1,w=a+n+2,b=a+1;h.push(y,x,b),h.push(x,w,b)}}this.setIndex(h),this.addAttribute("position",new Fi(l,3)),this.addAttribute("normal",new Fi(u,3)),this.addAttribute("uv",new Fi(p,2))}function va(t,e,n,i){Ai.call(this),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},this.fromBufferGeometry(new ga(t,e,n,i)),this.mergeVertices()}function ga(t,e,n,i){Yi.call(this),this.type="LatheBufferGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e)||12,n=n||0,i=i||2*Math.PI,i=ke.clamp(i,0,2*Math.PI);var r,o,a,s=[],c=[],h=[],l=1/e,u=new Ye,p=new We;for(o=0;o<=e;o++){var d=n+o*l*i,f=Math.sin(d),m=Math.cos(d);for(a=0;a<=t.length-1;a++)u.x=t[a].x*f,u.y=t[a].y,u.z=t[a].x*m,c.push(u.x,u.y,u.z),p.x=o/e,p.y=a/(t.length-1),h.push(p.x,p.y)}for(o=0;o<e;o++)for(a=0;a<t.length-1;a++){var v=r=a+o*t.length,g=r+t.length,y=r+t.length+1,x=r+1;s.push(v,g,x),s.push(g,y,x)}if(this.setIndex(s),this.addAttribute("position",new Fi(c,3)),this.addAttribute("uv",new Fi(h,2)),this.computeVertexNormals(),i===2*Math.PI){var w=this.attributes.normal.array,b=new Ye,_=new Ye,M=new Ye;for(r=e*t.length*3,o=0,a=0;o<t.length;o++,a+=3)b.x=w[a+0],b.y=w[a+1],b.z=w[a+2],_.x=w[r+a+0],_.y=w[r+a+1],_.z=w[r+a+2],M.addVectors(b,_).normalize(),w[a+0]=w[r+a+0]=M.x,w[a+1]=w[r+a+1]=M.y,w[a+2]=w[r+a+2]=M.z}}function ya(t,e){Ai.call(this),this.type="ShapeGeometry","object"==typeof e&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),e=e.curveSegments),this.parameters={shapes:t,curveSegments:e},this.fromBufferGeometry(new xa(t,e)),this.mergeVertices()}function xa(t,e){Yi.call(this),this.type="ShapeBufferGeometry",this.parameters={shapes:t,curveSegments:e},e=e||12;var n=[],i=[],r=[],o=[],a=0,s=0;if(!1===Array.isArray(t))h(t);else for(var c=0;c<t.length;c++)h(t[c]),this.addGroup(a,s,c),a+=s,s=0;function h(t){var a,c,h,l=i.length/3,u=t.extractPoints(e),p=u.shape,d=u.holes;if(!1===oa.isClockWise(p))for(p=p.reverse(),a=0,c=d.length;a<c;a++)h=d[a],!0===oa.isClockWise(h)&&(d[a]=h.reverse());var f=oa.triangulateShape(p,d);for(a=0,c=d.length;a<c;a++)h=d[a],p=p.concat(h);for(a=0,c=p.length;a<c;a++){var m=p[a];i.push(m.x,m.y,0),r.push(0,0,1),o.push(m.x,m.y)}for(a=0,c=f.length;a<c;a++){var v=f[a],g=v[0]+l,y=v[1]+l,x=v[2]+l;n.push(g,y,x),s+=3}}this.setIndex(n),this.addAttribute("position",new Fi(i,3)),this.addAttribute("normal",new Fi(r,3)),this.addAttribute("uv",new Fi(o,2))}function wa(t,e){if(e.shapes=[],Array.isArray(t))for(var n=0,i=t.length;n<i;n++){var r=t[n];e.shapes.push(r.uuid)}else e.shapes.push(t.uuid);return e}function ba(t,e){Yi.call(this),this.type="EdgesGeometry",this.parameters={thresholdAngle:e},e=void 0!==e?e:1;var n,i,r,o,a=[],s=Math.cos(ke.DEG2RAD*e),c=[0,0],h={},l=["a","b","c"];t.isBufferGeometry?(o=new Ai).fromBufferGeometry(t):o=t.clone(),o.mergeVertices(),o.computeFaceNormals();for(var u=o.vertices,p=o.faces,d=0,f=p.length;d<f;d++)for(var m=p[d],v=0;v<3;v++)n=m[l[v]],i=m[l[(v+1)%3]],c[0]=Math.min(n,i),c[1]=Math.max(n,i),void 0===h[r=c[0]+","+c[1]]?h[r]={index1:c[0],index2:c[1],face1:d,face2:void 0}:h[r].face2=d;for(r in h){var g=h[r];if(void 0===g.face2||p[g.face1].normal.dot(p[g.face2].normal)<=s){var y=u[g.index1];a.push(y.x,y.y,y.z),y=u[g.index2],a.push(y.x,y.y,y.z)}}this.addAttribute("position",new Fi(a,3))}function _a(t,e,n,i,r,o,a,s){Ai.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:s},this.fromBufferGeometry(new Ma(t,e,n,i,r,o,a,s)),this.mergeVertices()}function Ma(t,e,n,i,r,o,a,s){Yi.call(this),this.type="CylinderBufferGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:s};var c=this;t=void 0!==t?t:1,e=void 0!==e?e:1,n=n||1,i=Math.floor(i)||8,r=Math.floor(r)||1,o=void 0!==o&&o,a=void 0!==a?a:0,s=void 0!==s?s:2*Math.PI;var h=[],l=[],u=[],p=[],d=0,f=[],m=n/2,v=0;function g(n){var r,o,f,g=new We,y=new Ye,x=0,w=!0===n?t:e,b=!0===n?1:-1;for(o=d,r=1;r<=i;r++)l.push(0,m*b,0),u.push(0,b,0),p.push(.5,.5),d++;for(f=d,r=0;r<=i;r++){var _=r/i*s+a,M=Math.cos(_),E=Math.sin(_);y.x=w*E,y.y=m*b,y.z=w*M,l.push(y.x,y.y,y.z),u.push(0,b,0),g.x=.5*M+.5,g.y=.5*E*b+.5,p.push(g.x,g.y),d++}for(r=0;r<i;r++){var S=o+r,T=f+r;!0===n?h.push(T,T+1,S):h.push(T+1,T,S),x+=3}c.addGroup(v,x,!0===n?1:2),v+=x}!function(){var o,g,y=new Ye,x=new Ye,w=0,b=(e-t)/n;for(g=0;g<=r;g++){var _=[],M=g/r,E=M*(e-t)+t;for(o=0;o<=i;o++){var S=o/i,T=S*s+a,A=Math.sin(T),R=Math.cos(T);x.x=E*A,x.y=-M*n+m,x.z=E*R,l.push(x.x,x.y,x.z),y.set(A,b,R).normalize(),u.push(y.x,y.y,y.z),p.push(S,1-M),_.push(d++)}f.push(_)}for(o=0;o<i;o++)for(g=0;g<r;g++){var C=f[g][o],L=f[g+1][o],P=f[g+1][o+1],B=f[g][o+1];h.push(C,L,B),h.push(L,P,B),w+=6}c.addGroup(v,w,0),v+=w}(),!1===o&&(t>0&&g(!0),e>0&&g(!1)),this.setIndex(h),this.addAttribute("position",new Fi(l,3)),this.addAttribute("normal",new Fi(u,3)),this.addAttribute("uv",new Fi(p,2))}function Ea(t,e,n,i,r,o,a){_a.call(this,0,t,e,n,i,r,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:o,thetaLength:a}}function Sa(t,e,n,i,r,o,a){Ma.call(this,0,t,e,n,i,r,o,a),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:o,thetaLength:a}}function Ta(t,e,n,i){Ai.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},this.fromBufferGeometry(new Aa(t,e,n,i)),this.mergeVertices()}function Aa(t,e,n,i){Yi.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},t=t||1,e=void 0!==e?Math.max(3,e):8,n=void 0!==n?n:0,i=void 0!==i?i:2*Math.PI;var r,o,a=[],s=[],c=[],h=[],l=new Ye,u=new We;for(s.push(0,0,0),c.push(0,0,1),h.push(.5,.5),o=0,r=3;o<=e;o++,r+=3){var p=n+o/e*i;l.x=t*Math.cos(p),l.y=t*Math.sin(p),s.push(l.x,l.y,l.z),c.push(0,0,1),u.x=(s[r]/t+1)/2,u.y=(s[r+1]/t+1)/2,h.push(u.x,u.y)}for(r=1;r<=e;r++)a.push(r,r+1,0);this.setIndex(a),this.addAttribute("position",new Fi(s,3)),this.addAttribute("normal",new Fi(c,3)),this.addAttribute("uv",new Fi(h,2))}ca.prototype=Object.create(Ai.prototype),ca.prototype.constructor=ca,ha.prototype=Object.create(Yi.prototype),ha.prototype.constructor=ha,ha.prototype.getArrays=function(){var t=this.getAttribute("position"),e=t?Array.prototype.slice.call(t.array):[],n=this.getAttribute("uv"),i=n?Array.prototype.slice.call(n.array):[],r=this.index;return{position:e,uv:i,index:r?Array.prototype.slice.call(r.array):[]}},ha.prototype.addShapeList=function(t,e){var n=t.length;e.arrays=this.getArrays();for(var i=0;i<n;i++){var r=t[i];this.addShape(r,e)}this.setIndex(e.arrays.index),this.addAttribute("position",new Fi(e.arrays.position,3)),this.addAttribute("uv",new Fi(e.arrays.uv,2))},ha.prototype.addShape=function(t,e){var n,i,r,o,a,s,c,h,l=e.arrays?e.arrays:this.getArrays(),u=l.position,p=l.index,d=l.uv,f=[],m=void 0!==e.amount?e.amount:100,v=void 0!==e.bevelThickness?e.bevelThickness:6,g=void 0!==e.bevelSize?e.bevelSize:v-2,y=void 0!==e.bevelSegments?e.bevelSegments:3,x=void 0===e.bevelEnabled||e.bevelEnabled,w=void 0!==e.curveSegments?e.curveSegments:12,b=void 0!==e.steps?e.steps:1,_=e.extrudePath,M=!1,E=void 0!==e.UVGenerator?e.UVGenerator:ca.WorldUVGenerator;_&&(n=_.getSpacedPoints(b),M=!0,x=!1,i=void 0!==e.frames?e.frames:_.computeFrenetFrames(b,!1),r=new Ye,o=new Ye,a=new Ye),x||(y=0,v=0,g=0);var S=this,T=t.extractPoints(w),A=T.shape,R=T.holes;if(!oa.isClockWise(A))for(A=A.reverse(),c=0,h=R.length;c<h;c++)s=R[c],oa.isClockWise(s)&&(R[c]=s.reverse());var C=oa.triangulateShape(A,R),L=A;for(c=0,h=R.length;c<h;c++)s=R[c],A=A.concat(s);function P(t,e,n){return e||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().multiplyScalar(n).add(t)}var B,I,N,O,F,z,D=A.length,U=C.length;function V(t,e,n){var i,r,o,a=t.x-e.x,s=t.y-e.y,c=n.x-t.x,h=n.y-t.y,l=a*a+s*s,u=a*h-s*c;if(Math.abs(u)>Number.EPSILON){var p=Math.sqrt(l),d=Math.sqrt(c*c+h*h),f=e.x-s/p,m=e.y+a/p,v=((n.x-h/d-f)*h-(n.y+c/d-m)*c)/(a*h-s*c),g=(i=f+a*v-t.x)*i+(r=m+s*v-t.y)*r;if(g<=2)return new We(i,r);o=Math.sqrt(g/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(h)&&(y=!0),y?(i=-s,r=a,o=Math.sqrt(l)):(i=a,r=s,o=Math.sqrt(l/2))}return new We(i/o,r/o)}for(var G=[],H=0,j=L.length,k=j-1,W=H+1;H<j;H++,k++,W++)k===j&&(k=0),W===j&&(W=0),G[H]=V(L[H],L[k],L[W]);var q,X,Y=[],Z=G.concat();for(c=0,h=R.length;c<h;c++){for(s=R[c],q=[],H=0,k=(j=s.length)-1,W=H+1;H<j;H++,k++,W++)k===j&&(k=0),W===j&&(W=0),q[H]=V(s[H],s[k],s[W]);Y.push(q),Z=Z.concat(q)}for(B=0;B<y;B++){for(N=B/y,O=v*Math.cos(N*Math.PI/2),I=g*Math.sin(N*Math.PI/2),H=0,j=L.length;H<j;H++)Q((F=P(L[H],G[H],I)).x,F.y,-O);for(c=0,h=R.length;c<h;c++)for(s=R[c],q=Y[c],H=0,j=s.length;H<j;H++)Q((F=P(s[H],q[H],I)).x,F.y,-O)}for(I=g,H=0;H<D;H++)F=x?P(A[H],Z[H],I):A[H],M?(o.copy(i.normals[0]).multiplyScalar(F.x),r.copy(i.binormals[0]).multiplyScalar(F.y),a.copy(n[0]).add(o).add(r),Q(a.x,a.y,a.z)):Q(F.x,F.y,0);for(X=1;X<=b;X++)for(H=0;H<D;H++)F=x?P(A[H],Z[H],I):A[H],M?(o.copy(i.normals[X]).multiplyScalar(F.x),r.copy(i.binormals[X]).multiplyScalar(F.y),a.copy(n[X]).add(o).add(r),Q(a.x,a.y,a.z)):Q(F.x,F.y,m/b*X);for(B=y-1;B>=0;B--){for(N=B/y,O=v*Math.cos(N*Math.PI/2),I=g*Math.sin(N*Math.PI/2),H=0,j=L.length;H<j;H++)Q((F=P(L[H],G[H],I)).x,F.y,m+O);for(c=0,h=R.length;c<h;c++)for(s=R[c],q=Y[c],H=0,j=s.length;H<j;H++)F=P(s[H],q[H],I),M?Q(F.x,F.y+n[b-1].y,n[b-1].x+O):Q(F.x,F.y,m+O)}function J(t,e){var n,i;for(H=t.length;--H>=0;){n=H,(i=H-1)<0&&(i=t.length-1);var r=0,o=b+2*y;for(r=0;r<o;r++){var a=D*r,s=D*(r+1);$(e+n+a,e+i+a,e+i+s,e+n+s)}}}function Q(t,e,n){f.push(t),f.push(e),f.push(n)}function K(t,e,n){tt(t),tt(e),tt(n);var i=u.length/3,r=E.generateTopUV(S,u,i-3,i-2,i-1);et(r[0]),et(r[1]),et(r[2])}function $(t,e,n,i){tt(t),tt(e),tt(i),tt(e),tt(n),tt(i);var r=u.length/3,o=E.generateSideWallUV(S,u,r-6,r-3,r-2,r-1);et(o[0]),et(o[1]),et(o[3]),et(o[1]),et(o[2]),et(o[3])}function tt(t){p.push(u.length/3),u.push(f[3*t+0]),u.push(f[3*t+1]),u.push(f[3*t+2])}function et(t){d.push(t.x),d.push(t.y)}!function(){var t=u.length/3;if(x){var n=0,i=D*n;for(H=0;H<U;H++)K((z=C[H])[2]+i,z[1]+i,z[0]+i);for(i=D*(n=b+2*y),H=0;H<U;H++)K((z=C[H])[0]+i,z[1]+i,z[2]+i)}else{for(H=0;H<U;H++)K((z=C[H])[2],z[1],z[0]);for(H=0;H<U;H++)K((z=C[H])[0]+D*b,z[1]+D*b,z[2]+D*b)}S.addGroup(t,u.length/3-t,void 0!==e.material?e.material:0)}(),function(){var t=u.length/3,n=0;for(J(L,n),n+=L.length,c=0,h=R.length;c<h;c++)J(s=R[c],n),n+=s.length;S.addGroup(t,u.length/3-t,void 0!==e.extrudeMaterial?e.extrudeMaterial:1)}(),e.arrays||(this.setIndex(p),this.addAttribute("position",new Fi(u,3)),this.addAttribute("uv",new Fi(d,2)))},ca.WorldUVGenerator={generateTopUV:function(t,e,n,i,r){var o=e[3*n],a=e[3*n+1],s=e[3*i],c=e[3*i+1],h=e[3*r],l=e[3*r+1];return[new We(o,a),new We(s,c),new We(h,l)]},generateSideWallUV:function(t,e,n,i,r,o){var a=e[3*n],s=e[3*n+1],c=e[3*n+2],h=e[3*i],l=e[3*i+1],u=e[3*i+2],p=e[3*r],d=e[3*r+1],f=e[3*r+2],m=e[3*o],v=e[3*o+1],g=e[3*o+2];return Math.abs(s-l)<.01?[new We(a,1-c),new We(h,1-u),new We(p,1-f),new We(m,1-g)]:[new We(s,1-c),new We(l,1-u),new We(d,1-f),new We(v,1-g)]}},la.prototype=Object.create(Ai.prototype),la.prototype.constructor=la,ua.prototype=Object.create(ha.prototype),ua.prototype.constructor=ua,pa.prototype=Object.create(Ai.prototype),pa.prototype.constructor=pa,da.prototype=Object.create(Yi.prototype),da.prototype.constructor=da,fa.prototype=Object.create(Ai.prototype),fa.prototype.constructor=fa,ma.prototype=Object.create(Yi.prototype),ma.prototype.constructor=ma,va.prototype=Object.create(Ai.prototype),va.prototype.constructor=va,ga.prototype=Object.create(Yi.prototype),ga.prototype.constructor=ga,ya.prototype=Object.create(Ai.prototype),ya.prototype.constructor=ya,ya.prototype.toJSON=function(){var t=Ai.prototype.toJSON.call(this);return wa(this.parameters.shapes,t)},xa.prototype=Object.create(Yi.prototype),xa.prototype.constructor=xa,xa.prototype.toJSON=function(){var t=Yi.prototype.toJSON.call(this);return wa(this.parameters.shapes,t)},ba.prototype=Object.create(Yi.prototype),ba.prototype.constructor=ba,_a.prototype=Object.create(Ai.prototype),_a.prototype.constructor=_a,Ma.prototype=Object.create(Yi.prototype),Ma.prototype.constructor=Ma,Ea.prototype=Object.create(_a.prototype),Ea.prototype.constructor=Ea,Sa.prototype=Object.create(Ma.prototype),Sa.prototype.constructor=Sa,Ta.prototype=Object.create(Ai.prototype),Ta.prototype.constructor=Ta,Aa.prototype=Object.create(Yi.prototype),Aa.prototype.constructor=Aa;var Ra=Object.freeze({WireframeGeometry:yo,ParametricGeometry:xo,ParametricBufferGeometry:wo,TetrahedronGeometry:Mo,TetrahedronBufferGeometry:Eo,OctahedronGeometry:So,OctahedronBufferGeometry:To,IcosahedronGeometry:Ao,IcosahedronBufferGeometry:Ro,DodecahedronGeometry:Co,DodecahedronBufferGeometry:Lo,PolyhedronGeometry:bo,PolyhedronBufferGeometry:_o,TubeGeometry:Po,TubeBufferGeometry:Bo,TorusKnotGeometry:Io,TorusKnotBufferGeometry:No,TorusGeometry:Oo,TorusBufferGeometry:Fo,TextGeometry:la,TextBufferGeometry:ua,SphereGeometry:pa,SphereBufferGeometry:da,RingGeometry:fa,RingBufferGeometry:ma,PlaneGeometry:Qi,PlaneBufferGeometry:Ki,LatheGeometry:va,LatheBufferGeometry:ga,ShapeGeometry:ya,ShapeBufferGeometry:xa,ExtrudeGeometry:ca,ExtrudeBufferGeometry:ha,EdgesGeometry:ba,ConeGeometry:Ea,ConeBufferGeometry:Sa,CylinderGeometry:_a,CylinderBufferGeometry:Ma,CircleGeometry:Ta,CircleBufferGeometry:Aa,BoxGeometry:Zi,BoxBufferGeometry:Ji});function Ca(t){oi.call(this),this.type="ShadowMaterial",this.color=new kn(0),this.opacity=1,this.lights=!0,this.transparent=!0,this.setValues(t)}function La(t){tr.call(this,t),this.type="RawShaderMaterial"}function Pa(t){oi.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new kn(16777215),this.roughness=.5,this.metalness=.5,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new kn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new We(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Ba(t){Pa.call(this),this.defines={PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearCoat=0,this.clearCoatRoughness=0,this.setValues(t)}function Ia(t){oi.call(this),this.type="MeshPhongMaterial",this.color=new kn(16777215),this.specular=new kn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new kn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new We(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ct,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Na(t){Ia.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function Oa(t){oi.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new We(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Fa(t){oi.call(this),this.type="MeshLambertMaterial",this.color=new kn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new kn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ct,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function za(t){so.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}Ca.prototype=Object.create(oi.prototype),Ca.prototype.constructor=Ca,Ca.prototype.isShadowMaterial=!0,La.prototype=Object.create(tr.prototype),La.prototype.constructor=La,La.prototype.isRawShaderMaterial=!0,Pa.prototype=Object.create(oi.prototype),Pa.prototype.constructor=Pa,Pa.prototype.isMeshStandardMaterial=!0,Pa.prototype.copy=function(t){return oi.prototype.copy.call(this,t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,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.morphNormals=t.morphNormals,this},Ba.prototype=Object.create(Pa.prototype),Ba.prototype.constructor=Ba,Ba.prototype.isMeshPhysicalMaterial=!0,Ba.prototype.copy=function(t){return Pa.prototype.copy.call(this,t),this.defines={PHYSICAL:""},this.reflectivity=t.reflectivity,this.clearCoat=t.clearCoat,this.clearCoatRoughness=t.clearCoatRoughness,this},Ia.prototype=Object.create(oi.prototype),Ia.prototype.constructor=Ia,Ia.prototype.isMeshPhongMaterial=!0,Ia.prototype.copy=function(t){return oi.prototype.copy.call(this,t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,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.morphNormals=t.morphNormals,this},Na.prototype=Object.create(Ia.prototype),Na.prototype.constructor=Na,Na.prototype.isMeshToonMaterial=!0,Na.prototype.copy=function(t){return Ia.prototype.copy.call(this,t),this.gradientMap=t.gradientMap,this},Oa.prototype=Object.create(oi.prototype),Oa.prototype.constructor=Oa,Oa.prototype.isMeshNormalMaterial=!0,Oa.prototype.copy=function(t){return oi.prototype.copy.call(this,t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Fa.prototype=Object.create(oi.prototype),Fa.prototype.constructor=Fa,Fa.prototype.isMeshLambertMaterial=!0,Fa.prototype.copy=function(t){return oi.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.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,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.morphNormals=t.morphNormals,this},za.prototype=Object.create(so.prototype),za.prototype.constructor=za,za.prototype.isLineDashedMaterial=!0,za.prototype.copy=function(t){return so.prototype.copy.call(this,t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this};var Da=Object.freeze({ShadowMaterial:Ca,SpriteMaterial:eo,RawShaderMaterial:La,ShaderMaterial:tr,PointsMaterial:uo,MeshPhysicalMaterial:Ba,MeshStandardMaterial:Pa,MeshPhongMaterial:Ia,MeshToonMaterial:Na,MeshNormalMaterial:Oa,MeshLambertMaterial:Fa,MeshDepthMaterial:ai,MeshDistanceMaterial:si,MeshBasicMaterial:$i,LineDashedMaterial:za,LineBasicMaterial:so,Material:oi}),Ua={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};function Va(t,e,n){var i=this,r=!1,o=0,a=0,s=void 0;this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(t){a++,!1===r&&void 0!==i.onStart&&i.onStart(t,o,a),r=!0},this.itemEnd=function(t){o++,void 0!==i.onProgress&&i.onProgress(t,o,a),o===a&&(r=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(t){void 0!==i.onError&&i.onError(t)},this.resolveURL=function(t){return s?s(t):t},this.setURLModifier=function(t){return s=t,this}}var Ga=new Va,Ha={};function ja(t){this.manager=void 0!==t?t:Ga}function ka(t){this.manager=void 0!==t?t:Ga,this._parser=null}function Wa(t){this.manager=void 0!==t?t:Ga,this._parser=null}function qa(t){this.manager=void 0!==t?t:Ga}function Xa(t){this.manager=void 0!==t?t:Ga}function Ya(t){this.manager=void 0!==t?t:Ga}function Za(){this.type="Curve",this.arcLengthDivisions=200}function Ja(t,e,n,i,r,o,a,s){Za.call(this),this.type="EllipseCurve",this.aX=t||0,this.aY=e||0,this.xRadius=n||1,this.yRadius=i||1,this.aStartAngle=r||0,this.aEndAngle=o||2*Math.PI,this.aClockwise=a||!1,this.aRotation=s||0}function Qa(t,e,n,i,r,o){Ja.call(this,t,e,n,n,i,r,o),this.type="ArcCurve"}function Ka(){var t=0,e=0,n=0,i=0;function r(r,o,a,s){t=r,e=a,n=-3*r+3*o-2*a-s,i=2*r-2*o+a+s}return{initCatmullRom:function(t,e,n,i,o){r(e,n,o*(n-t),o*(i-e))},initNonuniformCatmullRom:function(t,e,n,i,o,a,s){var c=(e-t)/o-(n-t)/(o+a)+(n-e)/a,h=(n-e)/a-(i-e)/(a+s)+(i-n)/s;r(e,n,c*=a,h*=a)},calc:function(r){var o=r*r;return t+e*r+n*o+i*(o*r)}}}Object.assign(ja.prototype,{load:function(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);var r=this,o=Ua.get(t);if(void 0!==o)return r.manager.itemStart(t),setTimeout((function(){e&&e(o),r.manager.itemEnd(t)}),0),o;if(void 0===Ha[t]){var a=t.match(/^data:(.*?)(;base64)?,(.*)$/);if(a){var s=a[1],c=!!a[2],h=a[3];h=window.decodeURIComponent(h),c&&(h=window.atob(h));try{var l,u=(this.responseType||"").toLowerCase();switch(u){case"arraybuffer":case"blob":for(var p=new Uint8Array(h.length),d=0;d<h.length;d++)p[d]=h.charCodeAt(d);l="blob"===u?new Blob([p.buffer],{type:s}):p.buffer;break;case"document":var f=new DOMParser;l=f.parseFromString(h,s);break;case"json":l=JSON.parse(h);break;default:l=h}window.setTimeout((function(){e&&e(l),r.manager.itemEnd(t)}),0)}catch(e){window.setTimeout((function(){i&&i(e),r.manager.itemEnd(t),r.manager.itemError(t)}),0)}}else{Ha[t]=[],Ha[t].push({onLoad:e,onProgress:n,onError:i});var m=new XMLHttpRequest;for(var v in m.open("GET",t,!0),m.addEventListener("load",(function(e){var n=this.response;Ua.add(t,n);var i=Ha[t];if(delete Ha[t],200===this.status){for(var o=0,a=i.length;o<a;o++){(s=i[o]).onLoad&&s.onLoad(n)}r.manager.itemEnd(t)}else if(0===this.status){console.warn("THREE.FileLoader: HTTP Status 0 received.");for(o=0,a=i.length;o<a;o++){(s=i[o]).onLoad&&s.onLoad(n)}r.manager.itemEnd(t)}else{for(o=0,a=i.length;o<a;o++){var s;(s=i[o]).onError&&s.onError(e)}r.manager.itemEnd(t),r.manager.itemError(t)}}),!1),m.addEventListener("progress",(function(e){for(var n=Ha[t],i=0,r=n.length;i<r;i++){var o=n[i];o.onProgress&&o.onProgress(e)}}),!1),m.addEventListener("error",(function(e){var n=Ha[t];delete Ha[t];for(var i=0,o=n.length;i<o;i++){var a=n[i];a.onError&&a.onError(e)}r.manager.itemEnd(t),r.manager.itemError(t)}),!1),void 0!==this.responseType&&(m.responseType=this.responseType),void 0!==this.withCredentials&&(m.withCredentials=this.withCredentials),m.overrideMimeType&&m.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain"),this.requestHeader)m.setRequestHeader(v,this.requestHeader[v]);m.send(null)}return r.manager.itemStart(t),m}Ha[t].push({onLoad:e,onProgress:n,onError:i})},setPath:function(t){return this.path=t,this},setResponseType:function(t){return this.responseType=t,this},setWithCredentials:function(t){return this.withCredentials=t,this},setMimeType:function(t){return this.mimeType=t,this},setRequestHeader:function(t){return this.requestHeader=t,this}}),Object.assign(ka.prototype,{load:function(t,e,n,i){var r=this,o=[],a=new vo;a.image=o;var s=new ja(this.manager);function c(c){s.load(t[c],(function(t){var n=r._parser(t,!0);o[c]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},6===(h+=1)&&(1===n.mipmapCount&&(a.minFilter=Lt),a.format=n.format,a.needsUpdate=!0,e&&e(a))}),n,i)}if(s.setPath(this.path),s.setResponseType("arraybuffer"),Array.isArray(t))for(var h=0,l=0,u=t.length;l<u;++l)c(l);else s.load(t,(function(t){var n=r._parser(t,!0);if(n.isCubemap)for(var i=n.mipmaps.length/n.mipmapCount,s=0;s<i;s++){o[s]={mipmaps:[]};for(var c=0;c<n.mipmapCount;c++)o[s].mipmaps.push(n.mipmaps[s*n.mipmapCount+c]),o[s].format=n.format,o[s].width=n.width,o[s].height=n.height}else a.image.width=n.width,a.image.height=n.height,a.mipmaps=n.mipmaps;1===n.mipmapCount&&(a.minFilter=Lt),a.format=n.format,a.needsUpdate=!0,e&&e(a)}),n,i);return a},setPath:function(t){return this.path=t,this}}),Object.assign(Wa.prototype,{load:function(t,e,n,i){var r=this,o=new en,a=new ja(this.manager);return a.setResponseType("arraybuffer"),a.load(t,(function(t){var n=r._parser(t);n&&(void 0!==n.image?o.image=n.image:void 0!==n.data&&(o.image.width=n.width,o.image.height=n.height,o.image.data=n.data),o.wrapS=void 0!==n.wrapS?n.wrapS:St,o.wrapT=void 0!==n.wrapT?n.wrapT:St,o.magFilter=void 0!==n.magFilter?n.magFilter:Lt,o.minFilter=void 0!==n.minFilter?n.minFilter:Bt,o.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.format&&(o.format=n.format),void 0!==n.type&&(o.type=n.type),void 0!==n.mipmaps&&(o.mipmaps=n.mipmaps),1===n.mipmapCount&&(o.minFilter=Lt),o.needsUpdate=!0,e&&e(o,n))}),n,i),o}}),Object.assign(qa.prototype,{crossOrigin:"Anonymous",load:function(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);var r=this,o=Ua.get(t);if(void 0!==o)return r.manager.itemStart(t),setTimeout((function(){e&&e(o),r.manager.itemEnd(t)}),0),o;var a=document.createElementNS("http://www.w3.org/1999/xhtml","img");return a.addEventListener("load",(function(){Ua.add(t,this),e&&e(this),r.manager.itemEnd(t)}),!1),a.addEventListener("error",(function(e){i&&i(e),r.manager.itemEnd(t),r.manager.itemError(t)}),!1),"data:"!==t.substr(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(t),a.src=t,a},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Object.assign(Xa.prototype,{crossOrigin:"Anonymous",load:function(t,e,n,i){var r=new nn,o=new qa(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);var a=0;function s(n){o.load(t[n],(function(t){r.images[n]=t,6===++a&&(r.needsUpdate=!0,e&&e(r))}),void 0,i)}for(var c=0;c<t.length;++c)s(c);return r},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Object.assign(Ya.prototype,{crossOrigin:"Anonymous",load:function(t,e,n,i){var r=new Qe,o=new qa(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,(function(n){r.image=n;var i=t.search(/\.(jpg|jpeg)$/)>0||0===t.search(/^data\:image\/jpeg/);r.format=i?qt:Xt,r.needsUpdate=!0,void 0!==e&&e(r)}),n,i),r},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this}}),Object.assign(Za.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,i=[],r=this.getPoint(0),o=0;for(i.push(0),n=1;n<=t;n++)o+=(e=this.getPoint(n/t)).distanceTo(r),i.push(o),r=e;return this.cacheArcLengths=i,i},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){var n,i=this.getLengths(),r=0,o=i.length;n=e||t*i[o-1];for(var a,s=0,c=o-1;s<=c;)if((a=i[r=Math.floor(s+(c-s)/2)]-n)<0)s=r+1;else{if(!(a>0)){c=r;break}c=r-1}if(i[r=c]===n)return r/(o-1);var h=i[r];return(r+(n-h)/(i[r+1]-h))/(o-1)},getTangent:function(t){var e=t-1e-4,n=t+1e-4;e<0&&(e=0),n>1&&(n=1);var i=this.getPoint(e);return this.getPoint(n).clone().sub(i).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var n,i,r,o=new Ye,a=[],s=[],c=[],h=new Ye,l=new qe;for(n=0;n<=t;n++)i=n/t,a[n]=this.getTangentAt(i),a[n].normalize();s[0]=new Ye,c[0]=new Ye;var u=Number.MAX_VALUE,p=Math.abs(a[0].x),d=Math.abs(a[0].y),f=Math.abs(a[0].z);for(p<=u&&(u=p,o.set(1,0,0)),d<=u&&(u=d,o.set(0,1,0)),f<=u&&o.set(0,0,1),h.crossVectors(a[0],o).normalize(),s[0].crossVectors(a[0],h),c[0].crossVectors(a[0],s[0]),n=1;n<=t;n++)s[n]=s[n-1].clone(),c[n]=c[n-1].clone(),h.crossVectors(a[n-1],a[n]),h.length()>Number.EPSILON&&(h.normalize(),r=Math.acos(ke.clamp(a[n-1].dot(a[n]),-1,1)),s[n].applyMatrix4(l.makeRotationAxis(h,r))),c[n].crossVectors(a[n],s[n]);if(!0===e)for(r=Math.acos(ke.clamp(s[0].dot(s[t]),-1,1)),r/=t,a[0].dot(h.crossVectors(s[0],s[t]))>0&&(r=-r),n=1;n<=t;n++)s[n].applyMatrix4(l.makeRotationAxis(a[n],r*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}}),Ja.prototype=Object.create(Za.prototype),Ja.prototype.constructor=Ja,Ja.prototype.isEllipseCurve=!0,Ja.prototype.getPoint=function(t,e){for(var n=e||new We,i=2*Math.PI,r=this.aEndAngle-this.aStartAngle,o=Math.abs(r)<Number.EPSILON;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(r=o?0:i),!0!==this.aClockwise||o||(r===i?r=-i:r-=i);var a=this.aStartAngle+t*r,s=this.aX+this.xRadius*Math.cos(a),c=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){var h=Math.cos(this.aRotation),l=Math.sin(this.aRotation),u=s-this.aX,p=c-this.aY;s=u*h-p*l+this.aX,c=u*l+p*h+this.aY}return n.set(s,c)},Ja.prototype.copy=function(t){return Za.prototype.copy.call(this,t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this},Ja.prototype.toJSON=function(){var t=Za.prototype.toJSON.call(this);return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t},Ja.prototype.fromJSON=function(t){return Za.prototype.fromJSON.call(this,t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this},Qa.prototype=Object.create(Ja.prototype),Qa.prototype.constructor=Qa,Qa.prototype.isArcCurve=!0;var $a=new Ye,ts=new Ka,es=new Ka,ns=new Ka;function is(t,e,n,i){Za.call(this),this.type="CatmullRomCurve3",this.points=t||[],this.closed=e||!1,this.curveType=n||"centripetal",this.tension=i||.5}function rs(t,e,n,i,r){var o=.5*(i-e),a=.5*(r-n),s=t*t;return(2*n-2*i+o+a)*(t*s)+(-3*n+3*i-2*o-a)*s+o*t+n}function os(t,e,n,i){return function(t,e){var n=1-t;return n*n*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,n)+function(t,e){return t*t*e}(t,i)}function as(t,e,n,i,r){return function(t,e){var n=1-t;return n*n*n*e}(t,e)+function(t,e){var n=1-t;return 3*n*n*t*e}(t,n)+function(t,e){return 3*(1-t)*t*t*e}(t,i)+function(t,e){return t*t*t*e}(t,r)}function ss(t,e,n,i){Za.call(this),this.type="CubicBezierCurve",this.v0=t||new We,this.v1=e||new We,this.v2=n||new We,this.v3=i||new We}function cs(t,e,n,i){Za.call(this),this.type="CubicBezierCurve3",this.v0=t||new Ye,this.v1=e||new Ye,this.v2=n||new Ye,this.v3=i||new Ye}function hs(t,e){Za.call(this),this.type="LineCurve",this.v1=t||new We,this.v2=e||new We}function ls(t,e){Za.call(this),this.type="LineCurve3",this.v1=t||new Ye,this.v2=e||new Ye}function us(t,e,n){Za.call(this),this.type="QuadraticBezierCurve",this.v0=t||new We,this.v1=e||new We,this.v2=n||new We}function ps(t,e,n){Za.call(this),this.type="QuadraticBezierCurve3",this.v0=t||new Ye,this.v1=e||new Ye,this.v2=n||new Ye}function ds(t){Za.call(this),this.type="SplineCurve",this.points=t||[]}is.prototype=Object.create(Za.prototype),is.prototype.constructor=is,is.prototype.isCatmullRomCurve3=!0,is.prototype.getPoint=function(t,e){var n,i,r,o,a=e||new Ye,s=this.points,c=s.length,h=(c-(this.closed?0:1))*t,l=Math.floor(h),u=h-l;if(this.closed?l+=l>0?0:(Math.floor(Math.abs(l)/s.length)+1)*s.length:0===u&&l===c-1&&(l=c-2,u=1),this.closed||l>0?n=s[(l-1)%c]:($a.subVectors(s[0],s[1]).add(s[0]),n=$a),i=s[l%c],r=s[(l+1)%c],this.closed||l+2<c?o=s[(l+2)%c]:($a.subVectors(s[c-1],s[c-2]).add(s[c-1]),o=$a),"centripetal"===this.curveType||"chordal"===this.curveType){var p="chordal"===this.curveType?.5:.25,d=Math.pow(n.distanceToSquared(i),p),f=Math.pow(i.distanceToSquared(r),p),m=Math.pow(r.distanceToSquared(o),p);f<1e-4&&(f=1),d<1e-4&&(d=f),m<1e-4&&(m=f),ts.initNonuniformCatmullRom(n.x,i.x,r.x,o.x,d,f,m),es.initNonuniformCatmullRom(n.y,i.y,r.y,o.y,d,f,m),ns.initNonuniformCatmullRom(n.z,i.z,r.z,o.z,d,f,m)}else"catmullrom"===this.curveType&&(ts.initCatmullRom(n.x,i.x,r.x,o.x,this.tension),es.initCatmullRom(n.y,i.y,r.y,o.y,this.tension),ns.initCatmullRom(n.z,i.z,r.z,o.z,this.tension));return a.set(ts.calc(u),es.calc(u),ns.calc(u)),a},is.prototype.copy=function(t){Za.prototype.copy.call(this,t),this.points=[];for(var e=0,n=t.points.length;e<n;e++){var i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this},is.prototype.toJSON=function(){var t=Za.prototype.toJSON.call(this);t.points=[];for(var e=0,n=this.points.length;e<n;e++){var i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t},is.prototype.fromJSON=function(t){Za.prototype.fromJSON.call(this,t),this.points=[];for(var e=0,n=t.points.length;e<n;e++){var i=t.points[e];this.points.push((new Ye).fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this},ss.prototype=Object.create(Za.prototype),ss.prototype.constructor=ss,ss.prototype.isCubicBezierCurve=!0,ss.prototype.getPoint=function(t,e){var n=e||new We,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(as(t,i.x,r.x,o.x,a.x),as(t,i.y,r.y,o.y,a.y)),n},ss.prototype.copy=function(t){return Za.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this},ss.prototype.toJSON=function(){var t=Za.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t},ss.prototype.fromJSON=function(t){return Za.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this},cs.prototype=Object.create(Za.prototype),cs.prototype.constructor=cs,cs.prototype.isCubicBezierCurve3=!0,cs.prototype.getPoint=function(t,e){var n=e||new Ye,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(as(t,i.x,r.x,o.x,a.x),as(t,i.y,r.y,o.y,a.y),as(t,i.z,r.z,o.z,a.z)),n},cs.prototype.copy=function(t){return Za.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this},cs.prototype.toJSON=function(){var t=Za.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t},cs.prototype.fromJSON=function(t){return Za.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this},hs.prototype=Object.create(Za.prototype),hs.prototype.constructor=hs,hs.prototype.isLineCurve=!0,hs.prototype.getPoint=function(t,e){var n=e||new We;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n},hs.prototype.getPointAt=function(t,e){return this.getPoint(t,e)},hs.prototype.getTangent=function(){return this.v2.clone().sub(this.v1).normalize()},hs.prototype.copy=function(t){return Za.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this},hs.prototype.toJSON=function(){var t=Za.prototype.toJSON.call(this);return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},hs.prototype.fromJSON=function(t){return Za.prototype.fromJSON.call(this,t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},ls.prototype=Object.create(Za.prototype),ls.prototype.constructor=ls,ls.prototype.isLineCurve3=!0,ls.prototype.getPoint=function(t,e){var n=e||new Ye;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n},ls.prototype.getPointAt=function(t,e){return this.getPoint(t,e)},ls.prototype.copy=function(t){return Za.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this},ls.prototype.toJSON=function(){var t=Za.prototype.toJSON.call(this);return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},ls.prototype.fromJSON=function(t){return Za.prototype.fromJSON.call(this,t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},us.prototype=Object.create(Za.prototype),us.prototype.constructor=us,us.prototype.isQuadraticBezierCurve=!0,us.prototype.getPoint=function(t,e){var n=e||new We,i=this.v0,r=this.v1,o=this.v2;return n.set(os(t,i.x,r.x,o.x),os(t,i.y,r.y,o.y)),n},us.prototype.copy=function(t){return Za.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this},us.prototype.toJSON=function(){var t=Za.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},us.prototype.fromJSON=function(t){return Za.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},ps.prototype=Object.create(Za.prototype),ps.prototype.constructor=ps,ps.prototype.isQuadraticBezierCurve3=!0,ps.prototype.getPoint=function(t,e){var n=e||new Ye,i=this.v0,r=this.v1,o=this.v2;return n.set(os(t,i.x,r.x,o.x),os(t,i.y,r.y,o.y),os(t,i.z,r.z,o.z)),n},ps.prototype.copy=function(t){return Za.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this},ps.prototype.toJSON=function(){var t=Za.prototype.toJSON.call(this);return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t},ps.prototype.fromJSON=function(t){return Za.prototype.fromJSON.call(this,t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this},ds.prototype=Object.create(Za.prototype),ds.prototype.constructor=ds,ds.prototype.isSplineCurve=!0,ds.prototype.getPoint=function(t,e){var n=e||new We,i=this.points,r=(i.length-1)*t,o=Math.floor(r),a=r-o,s=i[0===o?o:o-1],c=i[o],h=i[o>i.length-2?i.length-1:o+1],l=i[o>i.length-3?i.length-1:o+2];return n.set(rs(a,s.x,c.x,h.x,l.x),rs(a,s.y,c.y,h.y,l.y)),n},ds.prototype.copy=function(t){Za.prototype.copy.call(this,t),this.points=[];for(var e=0,n=t.points.length;e<n;e++){var i=t.points[e];this.points.push(i.clone())}return this},ds.prototype.toJSON=function(){var t=Za.prototype.toJSON.call(this);t.points=[];for(var e=0,n=this.points.length;e<n;e++){var i=this.points[e];t.points.push(i.toArray())}return t},ds.prototype.fromJSON=function(t){Za.prototype.fromJSON.call(this,t),this.points=[];for(var e=0,n=t.points.length;e<n;e++){var i=t.points[e];this.points.push((new We).fromArray(i))}return this};var fs=Object.freeze({ArcCurve:Qa,CatmullRomCurve3:is,CubicBezierCurve:ss,CubicBezierCurve3:cs,EllipseCurve:Ja,LineCurve:hs,LineCurve3:ls,QuadraticBezierCurve:us,QuadraticBezierCurve3:ps,SplineCurve:ds});function ms(){Za.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}function vs(t){ms.call(this),this.type="Path",this.currentPoint=new We,t&&this.setFromPoints(t)}function gs(t){vs.call(this,t),this.uuid=ke.generateUUID(),this.type="Shape",this.holes=[]}function ys(t,e){bi.call(this),this.type="Light",this.color=new kn(t),this.intensity=void 0!==e?e:1,this.receiveShadow=void 0}function xs(t,e,n){ys.call(this,t,n),this.type="HemisphereLight",this.castShadow=void 0,this.position.copy(bi.DefaultUp),this.updateMatrix(),this.groundColor=new kn(e)}function ws(t){this.camera=t,this.bias=0,this.radius=1,this.mapSize=new We(512,512),this.map=null,this.matrix=new qe}function bs(){ws.call(this,new Br(50,1,.5,500))}function _s(t,e,n,i,r,o){ys.call(this,t,e),this.type="SpotLight",this.position.copy(bi.DefaultUp),this.updateMatrix(),this.target=new bi,Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(t){this.intensity=t/Math.PI}}),this.distance=void 0!==n?n:0,this.angle=void 0!==i?i:Math.PI/3,this.penumbra=void 0!==r?r:0,this.decay=void 0!==o?o:1,this.shadow=new bs}function Ms(t,e,n,i){ys.call(this,t,e),this.type="PointLight",Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(t){this.intensity=t/(4*Math.PI)}}),this.distance=void 0!==n?n:0,this.decay=void 0!==i?i:1,this.shadow=new ws(new Br(90,1,.5,500))}function Es(){ws.call(this,new Mi(-5,5,5,-5,.5,500))}function Ss(t,e){ys.call(this,t,e),this.type="DirectionalLight",this.position.copy(bi.DefaultUp),this.updateMatrix(),this.target=new bi,this.shadow=new Es}function Ts(t,e){ys.call(this,t,e),this.type="AmbientLight",this.castShadow=void 0}function As(t,e,n,i){ys.call(this,t,e),this.type="RectAreaLight",this.width=void 0!==n?n:10,this.height=void 0!==i?i:10}function Rs(t,e,n,i){Us.call(this,t,e,n,i)}function Cs(t,e,n){Us.call(this,t,e,n)}function Ls(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n}function Ps(t,e,n,i){Ls.call(this,t,e,n,i)}function Bs(t,e,n,i){Us.call(this,t,e,n,i)}function Is(t,e,n,i){Us.call(this,t,e,n,i)}function Ns(t,e,n,i){Us.call(this,t,e,n,i)}function Os(t,e,n,i){Ls.call(this,t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0}function Fs(t,e,n,i){Ls.call(this,t,e,n,i)}function zs(t,e,n,i){Ls.call(this,t,e,n,i)}ms.prototype=Object.assign(Object.create(Za.prototype),{constructor:ms,add:function(t){this.curves.push(t)},closePath:function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new hs(e,t))},getPoint:function(t){for(var e=t*this.getLength(),n=this.getCurveLengths(),i=0;i<n.length;){if(n[i]>=e){var r=n[i]-e,o=this.curves[i],a=o.getLength(),s=0===a?0:1-r/a;return o.getPointAt(s)}i++}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,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t},getSpacedPoints:function(t){void 0===t&&(t=40);for(var e=[],n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e},getPoints:function(t){t=t||12;for(var e,n=[],i=0,r=this.curves;i<r.length;i++)for(var o=r[i],a=o&&o.isEllipseCurve?2*t:o&&o.isLineCurve?1:o&&o.isSplineCurve?t*o.points.length:t,s=o.getPoints(a),c=0;c<s.length;c++){var h=s[c];e&&e.equals(h)||(n.push(h),e=h)}return this.autoClose&&n.length>1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},copy:function(t){Za.prototype.copy.call(this,t),this.curves=[];for(var e=0,n=t.curves.length;e<n;e++){var i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this},toJSON:function(){var t=Za.prototype.toJSON.call(this);t.autoClose=this.autoClose,t.curves=[];for(var e=0,n=this.curves.length;e<n;e++){var i=this.curves[e];t.curves.push(i.toJSON())}return t},fromJSON:function(t){Za.prototype.fromJSON.call(this,t),this.autoClose=t.autoClose,this.curves=[];for(var e=0,n=t.curves.length;e<n;e++){var i=t.curves[e];this.curves.push((new fs[i.type]).fromJSON(i))}return this}}),vs.prototype=Object.assign(Object.create(ms.prototype),{constructor:vs,setFromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y)},moveTo:function(t,e){this.currentPoint.set(t,e)},lineTo:function(t,e){var n=new hs(this.currentPoint.clone(),new We(t,e));this.curves.push(n),this.currentPoint.set(t,e)},quadraticCurveTo:function(t,e,n,i){var r=new us(this.currentPoint.clone(),new We(t,e),new We(n,i));this.curves.push(r),this.currentPoint.set(n,i)},bezierCurveTo:function(t,e,n,i,r,o){var a=new ss(this.currentPoint.clone(),new We(t,e),new We(n,i),new We(r,o));this.curves.push(a),this.currentPoint.set(r,o)},splineThru:function(t){var e=new ds([this.currentPoint.clone()].concat(t));this.curves.push(e),this.currentPoint.copy(t[t.length-1])},arc:function(t,e,n,i,r,o){var a=this.currentPoint.x,s=this.currentPoint.y;this.absarc(t+a,e+s,n,i,r,o)},absarc:function(t,e,n,i,r,o){this.absellipse(t,e,n,n,i,r,o)},ellipse:function(t,e,n,i,r,o,a,s){var c=this.currentPoint.x,h=this.currentPoint.y;this.absellipse(t+c,e+h,n,i,r,o,a,s)},absellipse:function(t,e,n,i,r,o,a,s){var c=new Ja(t,e,n,i,r,o,a,s);if(this.curves.length>0){var h=c.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(c);var l=c.getPoint(1);this.currentPoint.copy(l)},copy:function(t){return ms.prototype.copy.call(this,t),this.currentPoint.copy(t.currentPoint),this},toJSON:function(){var t=ms.prototype.toJSON.call(this);return t.currentPoint=this.currentPoint.toArray(),t},fromJSON:function(t){return ms.prototype.fromJSON.call(this,t),this.currentPoint.fromArray(t.currentPoint),this}}),gs.prototype=Object.assign(Object.create(vs.prototype),{constructor:gs,getPointsHoles:function(t){for(var e=[],n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e},extractPoints:function(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}},copy:function(t){vs.prototype.copy.call(this,t),this.holes=[];for(var e=0,n=t.holes.length;e<n;e++){var i=t.holes[e];this.holes.push(i.clone())}return this},toJSON:function(){var t=vs.prototype.toJSON.call(this);t.uuid=this.uuid,t.holes=[];for(var e=0,n=this.holes.length;e<n;e++){var i=this.holes[e];t.holes.push(i.toJSON())}return t},fromJSON:function(t){vs.prototype.fromJSON.call(this,t),this.uuid=t.uuid,this.holes=[];for(var e=0,n=t.holes.length;e<n;e++){var i=t.holes[e];this.holes.push((new vs).fromJSON(i))}return this}}),ys.prototype=Object.assign(Object.create(bi.prototype),{constructor:ys,isLight:!0,copy:function(t){return bi.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this},toJSON:function(t){var e=bi.prototype.toJSON.call(this,t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}),xs.prototype=Object.assign(Object.create(ys.prototype),{constructor:xs,isHemisphereLight:!0,copy:function(t){return ys.prototype.copy.call(this,t),this.groundColor.copy(t.groundColor),this}}),Object.assign(ws.prototype,{copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var t={};return 0!==this.bias&&(t.bias=this.bias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}),bs.prototype=Object.assign(Object.create(ws.prototype),{constructor:bs,isSpotLightShadow:!0,update:function(t){var e=this.camera,n=2*ke.RAD2DEG*t.angle,i=this.mapSize.width/this.mapSize.height,r=t.distance||e.far;n===e.fov&&i===e.aspect&&r===e.far||(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix())}}),_s.prototype=Object.assign(Object.create(ys.prototype),{constructor:_s,isSpotLight:!0,copy:function(t){return ys.prototype.copy.call(this,t),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Ms.prototype=Object.assign(Object.create(ys.prototype),{constructor:Ms,isPointLight:!0,copy:function(t){return ys.prototype.copy.call(this,t),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}),Es.prototype=Object.assign(Object.create(ws.prototype),{constructor:Es}),Ss.prototype=Object.assign(Object.create(ys.prototype),{constructor:Ss,isDirectionalLight:!0,copy:function(t){return ys.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}),Ts.prototype=Object.assign(Object.create(ys.prototype),{constructor:Ts,isAmbientLight:!0}),As.prototype=Object.assign(Object.create(ys.prototype),{constructor:As,isRectAreaLight:!0,copy:function(t){return ys.prototype.copy.call(this,t),this.width=t.width,this.height=t.height,this},toJSON:function(t){var e=ys.prototype.toJSON.call(this,t);return e.object.width=this.width,e.object.height=this.height,e}}),Rs.prototype=Object.assign(Object.create(Us.prototype),{constructor:Rs,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:Se,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Cs.prototype=Object.assign(Object.create(Us.prototype),{constructor:Cs,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:Se,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Object.assign(Ls.prototype,{evaluate:function(t){var e=this.parameterPositions,n=this._cachedIndex,i=e[n],r=e[n-1];t:{e:{var o;n:{i:if(!(t<i)){for(var a=n+2;;){if(void 0===i){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.afterEnd_(n-1,t,r)}if(n===a)break;if(r=i,t<(i=e[++n]))break e}o=e.length;break n}if(t>=r)break t;var s=e[1];t<s&&(n=2,r=s);for(a=n-2;;){if(void 0===r)return this._cachedIndex=0,this.beforeStart_(0,t,i);if(n===a)break;if(i=r,t>=(r=e[--n-1]))break e}o=n,n=0}for(;n<o;){var c=n+o>>>1;t<e[c]?o=c:n=c+1}if(i=e[n],void 0===(r=e[n-1]))return this._cachedIndex=0,this.beforeStart_(0,t,i);if(void 0===i)return n=e.length,this._cachedIndex=n,this.afterEnd_(n-1,r,t)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(t){for(var e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i,o=0;o!==i;++o)e[o]=n[r+o];return e},interpolate_:function(){throw new Error("call to abstract method")},intervalChanged_:function(){}}),Object.assign(Ls.prototype,{beforeStart_:Ls.prototype.copySampleValue_,afterEnd_:Ls.prototype.copySampleValue_}),Ps.prototype=Object.assign(Object.create(Ls.prototype),{constructor:Ps,interpolate_:function(t,e,n,i){for(var r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,c=(n-e)/(i-e),h=s+a;s!==h;s+=4)Xe.slerpFlat(r,0,o,s-a,o,s,c);return r}}),Bs.prototype=Object.assign(Object.create(Us.prototype),{constructor:Bs,ValueTypeName:"quaternion",DefaultInterpolation:Te,InterpolantFactoryMethodLinear:function(t){return new Ps(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),Is.prototype=Object.assign(Object.create(Us.prototype),{constructor:Is,ValueTypeName:"color"}),Ns.prototype=Object.assign(Object.create(Us.prototype),{constructor:Ns,ValueTypeName:"number"}),Os.prototype=Object.assign(Object.create(Ls.prototype),{constructor:Os,DefaultSettings_:{endingStart:Re,endingEnd:Re},intervalChanged_:function(t,e,n){var i=this.parameterPositions,r=t-2,o=t+1,a=i[r],s=i[o];if(void 0===a)switch(this.getSettings_().endingStart){case Ce:r=t,a=2*e-n;break;case Le:a=e+i[r=i.length-2]-i[r+1];break;default:r=t,a=n}if(void 0===s)switch(this.getSettings_().endingEnd){case Ce:o=t,s=2*n-e;break;case Le:o=1,s=n+i[1]-i[0];break;default:o=t-1,s=e}var c=.5*(n-e),h=this.valueSize;this._weightPrev=c/(e-a),this._weightNext=c/(s-n),this._offsetPrev=r*h,this._offsetNext=o*h},interpolate_:function(t,e,n,i){for(var r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,c=s-a,h=this._offsetPrev,l=this._offsetNext,u=this._weightPrev,p=this._weightNext,d=(n-e)/(i-e),f=d*d,m=f*d,v=-u*m+2*u*f-u*d,g=(1+u)*m+(-1.5-2*u)*f+(-.5+u)*d+1,y=(-1-p)*m+(1.5+p)*f+.5*d,x=p*m-p*f,w=0;w!==a;++w)r[w]=v*o[h+w]+g*o[c+w]+y*o[s+w]+x*o[l+w];return r}}),Fs.prototype=Object.assign(Object.create(Ls.prototype),{constructor:Fs,interpolate_:function(t,e,n,i){for(var r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,s=t*a,c=s-a,h=(n-e)/(i-e),l=1-h,u=0;u!==a;++u)r[u]=o[c+u]*l+o[s+u]*h;return r}}),zs.prototype=Object.assign(Object.create(Ls.prototype),{constructor:zs,interpolate_:function(t){return this.copySampleValue_(t-1)}});var Ds={arraySlice:function(t,e,n){return Ds.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==n?n:t.length)):t.slice(e,n)},convertArray:function(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)},getKeyframeOrder:function(t){for(var e=t.length,n=new Array(e),i=0;i!==e;++i)n[i]=i;return n.sort((function(e,n){return t[e]-t[n]})),n},sortedArray:function(t,e,n){for(var i=t.length,r=new t.constructor(i),o=0,a=0;a!==i;++o)for(var s=n[o]*e,c=0;c!==e;++c)r[a++]=t[s+c];return r},flattenJSON:function(t,e,n,i){for(var r=1,o=t[0];void 0!==o&&void 0===o[i];)o=t[r++];if(void 0!==o){var a=o[i];if(void 0!==a)if(Array.isArray(a))do{void 0!==(a=o[i])&&(e.push(o.time),n.push.apply(n,a)),o=t[r++]}while(void 0!==o);else if(void 0!==a.toArray)do{void 0!==(a=o[i])&&(e.push(o.time),a.toArray(n,n.length)),o=t[r++]}while(void 0!==o);else do{void 0!==(a=o[i])&&(e.push(o.time),n.push(a)),o=t[r++]}while(void 0!==o)}}};function Us(t,e,n,i){if(void 0===t)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===e||0===e.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Ds.convertArray(e,this.TimeBufferType),this.values=Ds.convertArray(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation),this.validate(),this.optimize()}function Vs(t,e,n,i){Us.call(this,t,e,n,i)}function Gs(t,e,n){this.name=t,this.tracks=n,this.duration=void 0!==e?e:-1,this.uuid=ke.generateUUID(),this.duration<0&&this.resetDuration(),this.optimize()}function Hs(t){this.manager=void 0!==t?t:Ga,this.textures={}}function js(t){this.manager=void 0!==t?t:Ga}Object.assign(Us,{parse:function(t){if(void 0===t.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");var e=Us._getTrackTypeForValueTypeName(t.type);if(void 0===t.times){var n=[],i=[];Ds.flattenJSON(t.keys,n,i,"value"),t.times=n,t.values=i}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)},toJSON:function(t){var e,n=t.constructor;if(void 0!==n.toJSON)e=n.toJSON(t);else{e={name:t.name,times:Ds.convertArray(t.times,Array),values:Ds.convertArray(t.values,Array)};var i=t.getInterpolation();i!==t.DefaultInterpolation&&(e.interpolation=i)}return e.type=t.ValueTypeName,e},_getTrackTypeForValueTypeName:function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ns;case"vector":case"vector2":case"vector3":case"vector4":return Vs;case"color":return Is;case"quaternion":return Bs;case"bool":case"boolean":return Cs;case"string":return Rs}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}}),Object.assign(Us.prototype,{constructor:Us,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:Te,InterpolantFactoryMethodDiscrete:function(t){return new zs(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodLinear:function(t){return new Fs(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:function(t){return new Os(this.times,this.values,this.getValueSize(),t)},setInterpolation:function(t){var e;switch(t){case Se:e=this.InterpolantFactoryMethodDiscrete;break;case Te:e=this.InterpolantFactoryMethodLinear;break;case Ae:e=this.InterpolantFactoryMethodSmooth}if(void 0!==e)this.createInterpolant=e;else{var n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(t===this.DefaultInterpolation)throw new Error(n);this.setInterpolation(this.DefaultInterpolation)}console.warn("THREE.KeyframeTrack:",n)}},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Se;case this.InterpolantFactoryMethodLinear:return Te;case this.InterpolantFactoryMethodSmooth:return Ae}},getValueSize:function(){return this.values.length/this.times.length},shift:function(t){if(0!==t)for(var e=this.times,n=0,i=e.length;n!==i;++n)e[n]+=t;return this},scale:function(t){if(1!==t)for(var e=this.times,n=0,i=e.length;n!==i;++n)e[n]*=t;return this},trim:function(t,e){for(var n=this.times,i=n.length,r=0,o=i-1;r!==i&&n[r]<t;)++r;for(;-1!==o&&n[o]>e;)--o;if(++o,0!==r||o!==i){r>=o&&(r=(o=Math.max(o,1))-1);var a=this.getValueSize();this.times=Ds.arraySlice(n,r,o),this.values=Ds.arraySlice(this.values,r*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,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);for(var o=null,a=0;a!==r;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!==i&&Ds.isTypedArray(i)){a=0;for(var c=i.length;a!==c;++a){var h=i[a];if(isNaN(h)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,h),t=!1;break}}}return t},optimize:function(){for(var t=this.times,e=this.values,n=this.getValueSize(),i=this.getInterpolation()===Ae,r=1,o=t.length-1,a=1;a<o;++a){var s=!1,c=t[a];if(c!==t[a+1]&&(1!==a||c!==c[0]))if(i)s=!0;else for(var h=a*n,l=h-n,u=h+n,p=0;p!==n;++p){var d=e[h+p];if(d!==e[l+p]||d!==e[u+p]){s=!0;break}}if(s){if(a!==r){t[r]=t[a];var f=a*n,m=r*n;for(p=0;p!==n;++p)e[m+p]=e[f+p]}++r}}if(o>0){t[r]=t[o];for(f=o*n,m=r*n,p=0;p!==n;++p)e[m+p]=e[f+p];++r}return r!==t.length&&(this.times=Ds.arraySlice(t,0,r),this.values=Ds.arraySlice(e,0,r*n)),this}}),Vs.prototype=Object.assign(Object.create(Us.prototype),{constructor:Vs,ValueTypeName:"vector"}),Object.assign(Gs,{parse:function(t){for(var e=[],n=t.tracks,i=1/(t.fps||1),r=0,o=n.length;r!==o;++r)e.push(Us.parse(n[r]).scale(i));return new Gs(t.name,t.duration,e)},toJSON:function(t){for(var e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e},r=0,o=n.length;r!==o;++r)e.push(Us.toJSON(n[r]));return i},CreateFromMorphTargetSequence:function(t,e,n,i){for(var r=e.length,o=[],a=0;a<r;a++){var s=[],c=[];s.push((a+r-1)%r,a,(a+1)%r),c.push(0,1,0);var h=Ds.getKeyframeOrder(s);s=Ds.sortedArray(s,1,h),c=Ds.sortedArray(c,1,h),i||0!==s[0]||(s.push(r),c.push(c[0])),o.push(new Ns(".morphTargetInfluences["+e[a].name+"]",s,c).scale(1/n))}return new Gs(t,-1,o)},findByName:function(t,e){var n=t;if(!Array.isArray(t)){var i=t;n=i.geometry&&i.geometry.animations||i.animations}for(var r=0;r<n.length;r++)if(n[r].name===e)return n[r];return null},CreateClipsFromMorphTargetSequences:function(t,e,n){for(var i={},r=/^([\w-]*?)([\d]+)$/,o=0,a=t.length;o<a;o++){var s=t[o],c=s.name.match(r);if(c&&c.length>1){var h=i[u=c[1]];h||(i[u]=h=[]),h.push(s)}}var l=[];for(var u in i)l.push(Gs.CreateFromMorphTargetSequence(u,i[u],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,i,r){if(0!==n.length){var o=[],a=[];Ds.flattenJSON(n,o,a,i),0!==o.length&&r.push(new t(e,o,a))}},i=[],r=t.name||"default",o=t.length||-1,a=t.fps||30,s=t.hierarchy||[],c=0;c<s.length;c++){var h=s[c].keys;if(h&&0!==h.length)if(h[0].morphTargets){for(var l={},u=0;u<h.length;u++)if(h[u].morphTargets)for(var p=0;p<h[u].morphTargets.length;p++)l[h[u].morphTargets[p]]=-1;for(var d in l){var f=[],m=[];for(p=0;p!==h[u].morphTargets.length;++p){var v=h[u];f.push(v.time),m.push(v.morphTarget===d?1:0)}i.push(new Ns(".morphTargetInfluence["+d+"]",f,m))}o=l.length*(a||1)}else{var g=".bones["+e[c].name+"]";n(Vs,g+".position",h,"pos",i),n(Bs,g+".quaternion",h,"rot",i),n(Vs,g+".scale",h,"scl",i)}}return 0===i.length?null:new Gs(r,o,i)}}),Object.assign(Gs.prototype,{resetDuration:function(){for(var t=0,e=0,n=this.tracks.length;e!==n;++e){var i=this.tracks[e];t=Math.max(t,i.times[i.times.length-1])}this.duration=t},trim:function(){for(var t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this},optimize:function(){for(var t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}}),Object.assign(Hs.prototype,{load:function(t,e,n,i){var r=this;new ja(r.manager).load(t,(function(t){e(r.parse(JSON.parse(t)))}),n,i)},setTextures:function(t){this.textures=t},parse:function(t){var e=this.textures;function n(t){return void 0===e[t]&&console.warn("THREE.MaterialLoader: Undefined texture",t),e[t]}var i=new Da[t.type];if(void 0!==t.uuid&&(i.uuid=t.uuid),void 0!==t.name&&(i.name=t.name),void 0!==t.color&&i.color.setHex(t.color),void 0!==t.roughness&&(i.roughness=t.roughness),void 0!==t.metalness&&(i.metalness=t.metalness),void 0!==t.emissive&&i.emissive.setHex(t.emissive),void 0!==t.specular&&i.specular.setHex(t.specular),void 0!==t.shininess&&(i.shininess=t.shininess),void 0!==t.clearCoat&&(i.clearCoat=t.clearCoat),void 0!==t.clearCoatRoughness&&(i.clearCoatRoughness=t.clearCoatRoughness),void 0!==t.uniforms&&(i.uniforms=t.uniforms),void 0!==t.vertexShader&&(i.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(i.fragmentShader=t.fragmentShader),void 0!==t.vertexColors&&(i.vertexColors=t.vertexColors),void 0!==t.fog&&(i.fog=t.fog),void 0!==t.flatShading&&(i.flatShading=t.flatShading),void 0!==t.blending&&(i.blending=t.blending),void 0!==t.side&&(i.side=t.side),void 0!==t.opacity&&(i.opacity=t.opacity),void 0!==t.transparent&&(i.transparent=t.transparent),void 0!==t.alphaTest&&(i.alphaTest=t.alphaTest),void 0!==t.depthTest&&(i.depthTest=t.depthTest),void 0!==t.depthWrite&&(i.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(i.colorWrite=t.colorWrite),void 0!==t.wireframe&&(i.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(i.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(i.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(i.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(i.rotation=t.rotation),1!==t.linewidth&&(i.linewidth=t.linewidth),void 0!==t.dashSize&&(i.dashSize=t.dashSize),void 0!==t.gapSize&&(i.gapSize=t.gapSize),void 0!==t.scale&&(i.scale=t.scale),void 0!==t.skinning&&(i.skinning=t.skinning),void 0!==t.morphTargets&&(i.morphTargets=t.morphTargets),void 0!==t.dithering&&(i.dithering=t.dithering),void 0!==t.visible&&(i.visible=t.visible),void 0!==t.userData&&(i.userData=t.userData),void 0!==t.shading&&(i.flatShading=1===t.shading),void 0!==t.size&&(i.size=t.size),void 0!==t.sizeAttenuation&&(i.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(i.map=n(t.map)),void 0!==t.alphaMap&&(i.alphaMap=n(t.alphaMap),i.transparent=!0),void 0!==t.bumpMap&&(i.bumpMap=n(t.bumpMap)),void 0!==t.bumpScale&&(i.bumpScale=t.bumpScale),void 0!==t.normalMap&&(i.normalMap=n(t.normalMap)),void 0!==t.normalScale){var r=t.normalScale;!1===Array.isArray(r)&&(r=[r,r]),i.normalScale=(new We).fromArray(r)}return void 0!==t.displacementMap&&(i.displacementMap=n(t.displacementMap)),void 0!==t.displacementScale&&(i.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(i.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(i.roughnessMap=n(t.roughnessMap)),void 0!==t.metalnessMap&&(i.metalnessMap=n(t.metalnessMap)),void 0!==t.emissiveMap&&(i.emissiveMap=n(t.emissiveMap)),void 0!==t.emissiveIntensity&&(i.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(i.specularMap=n(t.specularMap)),void 0!==t.envMap&&(i.envMap=n(t.envMap)),void 0!==t.reflectivity&&(i.reflectivity=t.reflectivity),void 0!==t.lightMap&&(i.lightMap=n(t.lightMap)),void 0!==t.lightMapIntensity&&(i.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(i.aoMap=n(t.aoMap)),void 0!==t.aoMapIntensity&&(i.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(i.gradientMap=n(t.gradientMap)),i}}),Object.assign(js.prototype,{load:function(t,e,n,i){var r=this;new ja(r.manager).load(t,(function(t){e(r.parse(JSON.parse(t)))}),n,i)},parse:function(t){var e=new Yi,n=t.data.index;if(void 0!==n){var i=new Ys[n.type](n.array);e.setIndex(new Ri(i,1))}var r=t.data.attributes;for(var o in r){var a=r[o];i=new Ys[a.type](a.array);e.addAttribute(o,new Ri(i,a.itemSize,a.normalized))}var s=t.data.groups||t.data.drawcalls||t.data.offsets;if(void 0!==s)for(var c=0,h=s.length;c!==h;++c){var l=s[c];e.addGroup(l.start,l.count,l.materialIndex)}var u=t.data.boundingSphere;if(void 0!==u){var p=new Ye;void 0!==u.center&&p.fromArray(u.center),e.boundingSphere=new hi(p,u.radius)}return e}});var ks,Ws,qs,Xs,Ys={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!=typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function Zs(){this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}}Zs.Handlers={handlers:[],add:function(t,e){this.handlers.push(t,e)},get:function(t){for(var e=this.handlers,n=0,i=e.length;n<i;n+=2){var r=e[n],o=e[n+1];if(r.test(t))return o}return null}},Object.assign(Zs.prototype,{crossOrigin:void 0,initMaterials:function(t,e,n){for(var i=[],r=0;r<t.length;++r)i[r]=this.createMaterial(t[r],e,n);return i},createMaterial:(ks={NoBlending:B,NormalBlending:I,AdditiveBlending:N,SubtractiveBlending:O,MultiplyBlending:F,CustomBlending:z},Ws=new kn,qs=new Ya,Xs=new Hs,function(t,e,n){var i={};function r(t,r,o,a,s){var c,h=e+t,l=Zs.Handlers.get(h);null!==l?c=l.load(h):(qs.setCrossOrigin(n),c=qs.load(h)),void 0!==r&&(c.repeat.fromArray(r),1!==r[0]&&(c.wrapS=Et),1!==r[1]&&(c.wrapT=Et)),void 0!==o&&c.offset.fromArray(o),void 0!==a&&("repeat"===a[0]&&(c.wrapS=Et),"mirror"===a[0]&&(c.wrapS=Tt),"repeat"===a[1]&&(c.wrapT=Et),"mirror"===a[1]&&(c.wrapT=Tt)),void 0!==s&&(c.anisotropy=s);var u=ke.generateUUID();return i[u]=c,u}var o={uuid:ke.generateUUID(),type:"MeshLambertMaterial"};for(var a in t){var s=t[a];switch(a){case"DbgColor":case"DbgIndex":case"opticalDensity":case"illumination":break;case"DbgName":o.name=s;break;case"blending":o.blending=ks[s];break;case"colorAmbient":case"mapAmbient":console.warn("THREE.Loader.createMaterial:",a,"is no longer supported.");break;case"colorDiffuse":o.color=Ws.fromArray(s).getHex();break;case"colorSpecular":o.specular=Ws.fromArray(s).getHex();break;case"colorEmissive":o.emissive=Ws.fromArray(s).getHex();break;case"specularCoef":o.shininess=s;break;case"shading":"basic"===s.toLowerCase()&&(o.type="MeshBasicMaterial"),"phong"===s.toLowerCase()&&(o.type="MeshPhongMaterial"),"standard"===s.toLowerCase()&&(o.type="MeshStandardMaterial");break;case"mapDiffuse":o.map=r(s,t.mapDiffuseRepeat,t.mapDiffuseOffset,t.mapDiffuseWrap,t.mapDiffuseAnisotropy);break;case"mapDiffuseRepeat":case"mapDiffuseOffset":case"mapDiffuseWrap":case"mapDiffuseAnisotropy":break;case"mapEmissive":o.emissiveMap=r(s,t.mapEmissiveRepeat,t.mapEmissiveOffset,t.mapEmissiveWrap,t.mapEmissiveAnisotropy);break;case"mapEmissiveRepeat":case"mapEmissiveOffset":case"mapEmissiveWrap":case"mapEmissiveAnisotropy":break;case"mapLight":o.lightMap=r(s,t.mapLightRepeat,t.mapLightOffset,t.mapLightWrap,t.mapLightAnisotropy);break;case"mapLightRepeat":case"mapLightOffset":case"mapLightWrap":case"mapLightAnisotropy":break;case"mapAO":o.aoMap=r(s,t.mapAORepeat,t.mapAOOffset,t.mapAOWrap,t.mapAOAnisotropy);break;case"mapAORepeat":case"mapAOOffset":case"mapAOWrap":case"mapAOAnisotropy":break;case"mapBump":o.bumpMap=r(s,t.mapBumpRepeat,t.mapBumpOffset,t.mapBumpWrap,t.mapBumpAnisotropy);break;case"mapBumpScale":o.bumpScale=s;break;case"mapBumpRepeat":case"mapBumpOffset":case"mapBumpWrap":case"mapBumpAnisotropy":break;case"mapNormal":o.normalMap=r(s,t.mapNormalRepeat,t.mapNormalOffset,t.mapNormalWrap,t.mapNormalAnisotropy);break;case"mapNormalFactor":o.normalScale=[s,s];break;case"mapNormalRepeat":case"mapNormalOffset":case"mapNormalWrap":case"mapNormalAnisotropy":break;case"mapSpecular":o.specularMap=r(s,t.mapSpecularRepeat,t.mapSpecularOffset,t.mapSpecularWrap,t.mapSpecularAnisotropy);break;case"mapSpecularRepeat":case"mapSpecularOffset":case"mapSpecularWrap":case"mapSpecularAnisotropy":break;case"mapMetalness":o.metalnessMap=r(s,t.mapMetalnessRepeat,t.mapMetalnessOffset,t.mapMetalnessWrap,t.mapMetalnessAnisotropy);break;case"mapMetalnessRepeat":case"mapMetalnessOffset":case"mapMetalnessWrap":case"mapMetalnessAnisotropy":break;case"mapRoughness":o.roughnessMap=r(s,t.mapRoughnessRepeat,t.mapRoughnessOffset,t.mapRoughnessWrap,t.mapRoughnessAnisotropy);break;case"mapRoughnessRepeat":case"mapRoughnessOffset":case"mapRoughnessWrap":case"mapRoughnessAnisotropy":break;case"mapAlpha":o.alphaMap=r(s,t.mapAlphaRepeat,t.mapAlphaOffset,t.mapAlphaWrap,t.mapAlphaAnisotropy);break;case"mapAlphaRepeat":case"mapAlphaOffset":case"mapAlphaWrap":case"mapAlphaAnisotropy":break;case"flipSided":o.side=S;break;case"doubleSided":o.side=T;break;case"transparency":console.warn("THREE.Loader.createMaterial: transparency has been renamed to opacity"),o.opacity=s;break;case"depthTest":case"depthWrite":case"colorWrite":case"opacity":case"reflectivity":case"transparent":case"visible":case"wireframe":o[a]=s;break;case"vertexColors":!0===s&&(o.vertexColors=P),"face"===s&&(o.vertexColors=L);break;default:console.error("THREE.Loader.createMaterial: Unsupported",a,s)}}return"MeshBasicMaterial"===o.type&&delete o.emissive,"MeshPhongMaterial"!==o.type&&delete o.specular,o.opacity<1&&(o.transparent=!0),Xs.setTextures(i),Xs.parse(o)})});var Js={decodeText:function(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);for(var e="",n=0,i=t.length;n<i;n++)e+=String.fromCharCode(t[n]);return decodeURIComponent(escape(e))},extractUrlBase:function(t){var e=t.split("/");return 1===e.length?"./":(e.pop(),e.join("/")+"/")}};function Qs(t){"boolean"==typeof t&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),t=void 0),this.manager=void 0!==t?t:Ga,this.withCredentials=!1}function Ks(t){this.manager=void 0!==t?t:Ga,this.texturePath=""}Object.assign(Qs.prototype,{load:function(t,e,n,i){var r=this,o=this.texturePath&&"string"==typeof this.texturePath?this.texturePath:Js.extractUrlBase(t),a=new ja(this.manager);a.setWithCredentials(this.withCredentials),a.load(t,(function(n){var i=JSON.parse(n),a=i.metadata;if(void 0!==a){var s=a.type;if(void 0!==s){if("object"===s.toLowerCase())return void console.error("THREE.JSONLoader: "+t+" should be loaded with THREE.ObjectLoader instead.");if("scene"===s.toLowerCase())return void console.error("THREE.JSONLoader: "+t+" should be loaded with THREE.SceneLoader instead.")}}var c=r.parse(i,o);e(c.geometry,c.materials)}),n,i)},setTexturePath:function(t){this.texturePath=t},parse:function(t,e){void 0!==t.data&&(t=t.data),void 0!==t.scale?t.scale=1/t.scale:t.scale=1;var n=new Ai;return function(t,e){function n(t,e){return t&1<<e}var i,r,o,a,s,c,h,l,u,p,d,f,m,v,g,y,x,w,b,_,M,E,S,T,A,R=t.faces,C=t.vertices,L=t.normals,P=t.colors,B=t.scale,I=0;if(void 0!==t.uvs){for(i=0;i<t.uvs.length;i++)t.uvs[i].length&&I++;for(i=0;i<I;i++)e.faceVertexUvs[i]=[]}for(a=0,s=C.length;a<s;)(w=new Ye).x=C[a++]*B,w.y=C[a++]*B,w.z=C[a++]*B,e.vertices.push(w);for(a=0,s=R.length;a<s;)if(d=n(p=R[a++],0),f=n(p,1),m=n(p,3),v=n(p,4),g=n(p,5),y=n(p,6),x=n(p,7),d){if((_=new Ei).a=R[a],_.b=R[a+1],_.c=R[a+3],(M=new Ei).a=R[a+1],M.b=R[a+2],M.c=R[a+3],a+=4,f&&(u=R[a++],_.materialIndex=u,M.materialIndex=u),o=e.faces.length,m)for(i=0;i<I;i++)for(T=t.uvs[i],e.faceVertexUvs[i][o]=[],e.faceVertexUvs[i][o+1]=[],r=0;r<4;r++)A=new We(T[2*(l=R[a++])],T[2*l+1]),2!==r&&e.faceVertexUvs[i][o].push(A),0!==r&&e.faceVertexUvs[i][o+1].push(A);if(v&&(h=3*R[a++],_.normal.set(L[h++],L[h++],L[h]),M.normal.copy(_.normal)),g)for(i=0;i<4;i++)h=3*R[a++],S=new Ye(L[h++],L[h++],L[h]),2!==i&&_.vertexNormals.push(S),0!==i&&M.vertexNormals.push(S);if(y&&(E=P[c=R[a++]],_.color.setHex(E),M.color.setHex(E)),x)for(i=0;i<4;i++)E=P[c=R[a++]],2!==i&&_.vertexColors.push(new kn(E)),0!==i&&M.vertexColors.push(new kn(E));e.faces.push(_),e.faces.push(M)}else{if((b=new Ei).a=R[a++],b.b=R[a++],b.c=R[a++],f&&(u=R[a++],b.materialIndex=u),o=e.faces.length,m)for(i=0;i<I;i++)for(T=t.uvs[i],e.faceVertexUvs[i][o]=[],r=0;r<3;r++)A=new We(T[2*(l=R[a++])],T[2*l+1]),e.faceVertexUvs[i][o].push(A);if(v&&(h=3*R[a++],b.normal.set(L[h++],L[h++],L[h])),g)for(i=0;i<3;i++)h=3*R[a++],S=new Ye(L[h++],L[h++],L[h]),b.vertexNormals.push(S);if(y&&(c=R[a++],b.color.setHex(P[c])),x)for(i=0;i<3;i++)c=R[a++],b.vertexColors.push(new kn(P[c]));e.faces.push(b)}}(t,n),function(t,e){var n=void 0!==t.influencesPerVertex?t.influencesPerVertex:2;if(t.skinWeights)for(var i=0,r=t.skinWeights.length;i<r;i+=n){var o=t.skinWeights[i],a=n>1?t.skinWeights[i+1]:0,s=n>2?t.skinWeights[i+2]:0,c=n>3?t.skinWeights[i+3]:0;e.skinWeights.push(new Ke(o,a,s,c))}if(t.skinIndices)for(i=0,r=t.skinIndices.length;i<r;i+=n){var h=t.skinIndices[i],l=n>1?t.skinIndices[i+1]:0,u=n>2?t.skinIndices[i+2]:0,p=n>3?t.skinIndices[i+3]:0;e.skinIndices.push(new Ke(h,l,u,p))}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 i=0,r=t.morphTargets.length;i<r;i++){e.morphTargets[i]={},e.morphTargets[i].name=t.morphTargets[i].name,e.morphTargets[i].vertices=[];for(var o=e.morphTargets[i].vertices,a=t.morphTargets[i].vertices,s=0,c=a.length;s<c;s+=3){var h=new Ye;h.x=a[s]*n,h.y=a[s+1]*n,h.z=a[s+2]*n,o.push(h)}}if(void 0!==t.morphColors&&t.morphColors.length>0){console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.');var l=e.faces,u=t.morphColors[0].colors;for(i=0,r=l.length;i<r;i++)l[i].color.fromArray(u,3*i)}}(t,n),function(t,e){var n=[],i=[];void 0!==t.animation&&i.push(t.animation),void 0!==t.animations&&(t.animations.length?i=i.concat(t.animations):i.push(t.animations));for(var r=0;r<i.length;r++){var o=Gs.parseAnimation(i[r],e.bones);o&&n.push(o)}if(e.morphTargets){var a=Gs.CreateClipsFromMorphTargetSequences(e.morphTargets,10);n=n.concat(a)}n.length>0&&(e.animations=n)}(t,n),n.computeFaceNormals(),n.computeBoundingSphere(),void 0===t.materials||0===t.materials.length?{geometry:n}:{geometry:n,materials:Zs.prototype.initMaterials(t.materials,e,this.crossOrigin)}}}),Object.assign(Ks.prototype,{load:function(t,e,n,i){""===this.texturePath&&(this.texturePath=t.substring(0,t.lastIndexOf("/")+1));var r=this;new ja(r.manager).load(t,(function(n){var o=null;try{o=JSON.parse(n)}catch(e){return void 0!==i&&i(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()?r.parse(o,e):console.error("THREE.ObjectLoader: Can't load "+t+". Use THREE.JSONLoader instead.")}),n,i)},setTexturePath:function(t){this.texturePath=t},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t,e){var n=this.parseShape(t.shapes),i=this.parseGeometries(t.geometries,n),r=this.parseImages(t.images,(function(){void 0!==e&&e(s)})),o=this.parseTextures(t.textures,r),a=this.parseMaterials(t.materials,o),s=this.parseObject(t.object,i,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,i=t.length;n<i;n++){var r=(new gs).fromJSON(t[n]);e[r.uuid]=r}return e},parseGeometries:function(t,e){var n={};if(void 0!==t)for(var i=new Qs,r=new js,o=0,a=t.length;o<a;o++){var s,c=t[o];switch(c.type){case"PlaneGeometry":case"PlaneBufferGeometry":s=new Ra[c.type](c.width,c.height,c.widthSegments,c.heightSegments);break;case"BoxGeometry":case"BoxBufferGeometry":case"CubeGeometry":s=new Ra[c.type](c.width,c.height,c.depth,c.widthSegments,c.heightSegments,c.depthSegments);break;case"CircleGeometry":case"CircleBufferGeometry":s=new Ra[c.type](c.radius,c.segments,c.thetaStart,c.thetaLength);break;case"CylinderGeometry":case"CylinderBufferGeometry":s=new Ra[c.type](c.radiusTop,c.radiusBottom,c.height,c.radialSegments,c.heightSegments,c.openEnded,c.thetaStart,c.thetaLength);break;case"ConeGeometry":case"ConeBufferGeometry":s=new Ra[c.type](c.radius,c.height,c.radialSegments,c.heightSegments,c.openEnded,c.thetaStart,c.thetaLength);break;case"SphereGeometry":case"SphereBufferGeometry":s=new Ra[c.type](c.radius,c.widthSegments,c.heightSegments,c.phiStart,c.phiLength,c.thetaStart,c.thetaLength);break;case"DodecahedronGeometry":case"DodecahedronBufferGeometry":case"IcosahedronGeometry":case"IcosahedronBufferGeometry":case"OctahedronGeometry":case"OctahedronBufferGeometry":case"TetrahedronGeometry":case"TetrahedronBufferGeometry":s=new Ra[c.type](c.radius,c.detail);break;case"RingGeometry":case"RingBufferGeometry":s=new Ra[c.type](c.innerRadius,c.outerRadius,c.thetaSegments,c.phiSegments,c.thetaStart,c.thetaLength);break;case"TorusGeometry":case"TorusBufferGeometry":s=new Ra[c.type](c.radius,c.tube,c.radialSegments,c.tubularSegments,c.arc);break;case"TorusKnotGeometry":case"TorusKnotBufferGeometry":s=new Ra[c.type](c.radius,c.tube,c.tubularSegments,c.radialSegments,c.p,c.q);break;case"LatheGeometry":case"LatheBufferGeometry":s=new Ra[c.type](c.points,c.segments,c.phiStart,c.phiLength);break;case"PolyhedronGeometry":case"PolyhedronBufferGeometry":s=new Ra[c.type](c.vertices,c.indices,c.radius,c.details);break;case"ShapeGeometry":case"ShapeBufferGeometry":var h=[];for(o=0,a=c.shapes.length;o<a;o++){var l=e[c.shapes[o]];h.push(l)}s=new Ra[c.type](h,c.curveSegments);break;case"BufferGeometry":s=r.parse(c);break;case"Geometry":s=i.parse(c,this.texturePath).geometry;break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+c.type+'"');continue}s.uuid=c.uuid,void 0!==c.name&&(s.name=c.name),n[c.uuid]=s}return n},parseMaterials:function(t,e){var n={};if(void 0!==t){var i=new Hs;i.setTextures(e);for(var r=0,o=t.length;r<o;r++){var a=t[r];if("MultiMaterial"===a.type){for(var s=[],c=0;c<a.materials.length;c++)s.push(i.parse(a.materials[c]));n[a.uuid]=s}else n[a.uuid]=i.parse(a)}}return n},parseAnimations:function(t){for(var e=[],n=0;n<t.length;n++){var i=Gs.parse(t[n]);e.push(i)}return e},parseImages:function(t,e){var n=this,i={};function r(t){return n.manager.itemStart(t),o.load(t,(function(){n.manager.itemEnd(t)}),void 0,(function(){n.manager.itemEnd(t),n.manager.itemError(t)}))}if(void 0!==t&&t.length>0){var o=new qa(new Va(e));o.setCrossOrigin(this.crossOrigin);for(var a=0,s=t.length;a<s;a++){var c=t[a],h=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c.url)?c.url:n.texturePath+c.url;i[c.uuid]=r(h)}}return i},parseTextures:function(t,e){function n(t,e){return"number"==typeof t?t:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",t),e[t])}var i={};if(void 0!==t)for(var r=0,o=t.length;r<o;r++){var a=t[r];void 0===a.image&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),void 0===e[a.image]&&console.warn("THREE.ObjectLoader: Undefined image",a.image);var s=new Qe(e[a.image]);s.needsUpdate=!0,s.uuid=a.uuid,void 0!==a.name&&(s.name=a.name),void 0!==a.mapping&&(s.mapping=n(a.mapping,tc)),void 0!==a.offset&&s.offset.fromArray(a.offset),void 0!==a.repeat&&s.repeat.fromArray(a.repeat),void 0!==a.center&&s.center.fromArray(a.center),void 0!==a.rotation&&(s.rotation=a.rotation),void 0!==a.wrap&&(s.wrapS=n(a.wrap[0],ec),s.wrapT=n(a.wrap[1],ec)),void 0!==a.minFilter&&(s.minFilter=n(a.minFilter,nc)),void 0!==a.magFilter&&(s.magFilter=n(a.magFilter,nc)),void 0!==a.anisotropy&&(s.anisotropy=a.anisotropy),void 0!==a.flipY&&(s.flipY=a.flipY),i[a.uuid]=s}return i},parseObject:function(t,e,n){var i;function r(t){return void 0===e[t]&&console.warn("THREE.ObjectLoader: Undefined geometry",t),e[t]}function o(t){if(void 0!==t){if(Array.isArray(t)){for(var e=[],i=0,r=t.length;i<r;i++){var o=t[i];void 0===n[o]&&console.warn("THREE.ObjectLoader: Undefined material",o),e.push(n[o])}return e}return void 0===n[t]&&console.warn("THREE.ObjectLoader: Undefined material",t),n[t]}}switch(t.type){case"Scene":i=new to,void 0!==t.background&&Number.isInteger(t.background)&&(i.background=new kn(t.background)),void 0!==t.fog&&("Fog"===t.fog.type?i.fog=new $r(t.fog.color,t.fog.near,t.fog.far):"FogExp2"===t.fog.type&&(i.fog=new Kr(t.fog.color,t.fog.density)));break;case"PerspectiveCamera":i=new Br(t.fov,t.aspect,t.near,t.far),void 0!==t.focus&&(i.focus=t.focus),void 0!==t.zoom&&(i.zoom=t.zoom),void 0!==t.filmGauge&&(i.filmGauge=t.filmGauge),void 0!==t.filmOffset&&(i.filmOffset=t.filmOffset),void 0!==t.view&&(i.view=Object.assign({},t.view));break;case"OrthographicCamera":i=new Mi(t.left,t.right,t.top,t.bottom,t.near,t.far);break;case"AmbientLight":i=new Ts(t.color,t.intensity);break;case"DirectionalLight":i=new Ss(t.color,t.intensity);break;case"PointLight":i=new Ms(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":i=new As(t.color,t.intensity,t.width,t.height);break;case"SpotLight":i=new _s(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay);break;case"HemisphereLight":i=new xs(t.color,t.groundColor,t.intensity);break;case"SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");case"Mesh":var a=r(t.geometry),s=o(t.material);i=a.bones&&a.bones.length>0?new ao(a,s):new rr(a,s);break;case"LOD":i=new io;break;case"Line":i=new co(r(t.geometry),o(t.material),t.mode);break;case"LineLoop":i=new lo(r(t.geometry),o(t.material));break;case"LineSegments":i=new ho(r(t.geometry),o(t.material));break;case"PointCloud":case"Points":i=new po(r(t.geometry),o(t.material));break;case"Sprite":i=new no(o(t.material));break;case"Group":i=new fo;break;default:i=new bi}if(i.uuid=t.uuid,void 0!==t.name&&(i.name=t.name),void 0!==t.matrix?(i.matrix.fromArray(t.matrix),i.matrix.decompose(i.position,i.quaternion,i.scale)):(void 0!==t.position&&i.position.fromArray(t.position),void 0!==t.rotation&&i.rotation.fromArray(t.rotation),void 0!==t.quaternion&&i.quaternion.fromArray(t.quaternion),void 0!==t.scale&&i.scale.fromArray(t.scale)),void 0!==t.castShadow&&(i.castShadow=t.castShadow),void 0!==t.receiveShadow&&(i.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(i.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(i.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&i.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(i.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(i.visible=t.visible),void 0!==t.userData&&(i.userData=t.userData),void 0!==t.children)for(var c=t.children,h=0;h<c.length;h++)i.add(this.parseObject(c[h],e,n));if("LOD"===t.type)for(var l=t.levels,u=0;u<l.length;u++){var p=l[u],d=i.getObjectByProperty("uuid",p.object);void 0!==d&&i.addLevel(d,p.distance)}return i}});var $s,tc={UVMapping:vt,CubeReflectionMapping:gt,CubeRefractionMapping:yt,EquirectangularReflectionMapping:xt,EquirectangularRefractionMapping:wt,SphericalReflectionMapping:bt,CubeUVReflectionMapping:_t,CubeUVRefractionMapping:Mt},ec={RepeatWrapping:Et,ClampToEdgeWrapping:St,MirroredRepeatWrapping:Tt},nc={NearestFilter:At,NearestMipMapNearestFilter:Rt,NearestMipMapLinearFilter:Ct,LinearFilter:Lt,LinearMipMapNearestFilter:Pt,LinearMipMapLinearFilter:Bt};function ic(t){"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.manager=void 0!==t?t:Ga,this.options=void 0}function rc(){this.type="ShapePath",this.subPaths=[],this.currentPath=null}function oc(t){this.type="Font",this.data=t}function ac(t,e,n,i,r,o){var a=o.glyphs[t]||o.glyphs["?"];if(a){var s,c,h,l,u,p,d,f,m=new rc;if(a.o)for(var v=a._cachedOutline||(a._cachedOutline=a.o.split(" ")),g=0,y=v.length;g<y;){switch(v[g++]){case"m":s=v[g++]*n+i,c=v[g++]*n+r,m.moveTo(s,c);break;case"l":s=v[g++]*n+i,c=v[g++]*n+r,m.lineTo(s,c);break;case"q":h=v[g++]*n+i,l=v[g++]*n+r,u=v[g++]*n+i,p=v[g++]*n+r,m.quadraticCurveTo(u,p,h,l);break;case"b":h=v[g++]*n+i,l=v[g++]*n+r,u=v[g++]*n+i,p=v[g++]*n+r,d=v[g++]*n+i,f=v[g++]*n+r,m.bezierCurveTo(u,p,d,f,h,l)}}return{offsetX:a.ha*n,path:m}}}function sc(t){this.manager=void 0!==t?t:Ga}ic.prototype={constructor:ic,setOptions:function(t){return this.options=t,this},load:function(t,e,n,i){void 0===t&&(t=""),void 0!==this.path&&(t=this.path+t);var r=this,o=Ua.get(t);if(void 0!==o)return r.manager.itemStart(t),setTimeout((function(){e&&e(o),r.manager.itemEnd(t)}),0),o;fetch(t).then((function(t){return t.blob()})).then((function(t){return createImageBitmap(t,r.options)})).then((function(n){Ua.add(t,n),e&&e(n),r.manager.itemEnd(t)})).catch((function(e){i&&i(e),r.manager.itemEnd(t),r.manager.itemError(t)}))},setCrossOrigin:function(){return this},setPath:function(t){return this.path=t,this}},Object.assign(rc.prototype,{moveTo:function(t,e){this.currentPath=new vs,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e)},lineTo:function(t,e){this.currentPath.lineTo(t,e)},quadraticCurveTo:function(t,e,n,i){this.currentPath.quadraticCurveTo(t,e,n,i)},bezierCurveTo:function(t,e,n,i,r,o){this.currentPath.bezierCurveTo(t,e,n,i,r,o)},splineThru:function(t){this.currentPath.splineThru(t)},toShapes:function(t,e){function n(t){for(var e=[],n=0,i=t.length;n<i;n++){var r=t[n],o=new gs;o.curves=r.curves,e.push(o)}return e}function i(t,e){for(var n=e.length,i=!1,r=n-1,o=0;o<n;r=o++){var a=e[r],s=e[o],c=s.x-a.x,h=s.y-a.y;if(Math.abs(h)>Number.EPSILON){if(h<0&&(a=e[o],c=-c,s=e[r],h=-h),t.y<a.y||t.y>s.y)continue;if(t.y===a.y){if(t.x===a.x)return!0}else{var l=h*(t.x-a.x)-c*(t.y-a.y);if(0===l)return!0;if(l<0)continue;i=!i}}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 i}var r=oa.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return n(o);var a,s,c,h=[];if(1===o.length)return s=o[0],(c=new gs).curves=s.curves,h.push(c),h;var l=!r(o[0].getPoints());l=t?!l:l;var u,p,d=[],f=[],m=[],v=0;f[v]=void 0,m[v]=[];for(var g=0,y=o.length;g<y;g++)a=r(u=(s=o[g]).getPoints()),(a=t?!a:a)?(!l&&f[v]&&v++,f[v]={s:new gs,p:u},f[v].s.curves=s.curves,l&&v++,m[v]=[]):m[v].push({h:s,p:u[0]});if(!f[0])return n(o);if(f.length>1){for(var x=!1,w=[],b=0,_=f.length;b<_;b++)d[b]=[];for(b=0,_=f.length;b<_;b++)for(var M=m[b],E=0;E<M.length;E++){for(var S=M[E],T=!0,A=0;A<f.length;A++)i(S.p,f[A].p)&&(b!==A&&w.push({froms:b,tos:A,hole:E}),T?(T=!1,d[A].push(S)):x=!0);T&&d[b].push(S)}w.length>0&&(x||(m=d))}g=0;for(var R=f.length;g<R;g++){c=f[g].s,h.push(c);for(var C=0,L=(p=m[g]).length;C<L;C++)c.holes.push(p[C].h)}return h}}),Object.assign(oc.prototype,{isFont:!0,generateShapes:function(t,e,n){void 0===e&&(e=100),void 0===n&&(n=4);for(var i=[],r=function(t,e,n,i){for(var r=String(t).split(""),o=e/i.resolution,a=(i.boundingBox.yMax-i.boundingBox.yMin+i.underlineThickness)*o,s=[],c=0,h=0,l=0;l<r.length;l++){var u=r[l];if("\n"===u)c=0,h-=a;else{var p=ac(u,n,o,c,h,i);c+=p.offsetX,s.push(p.path)}}return s}(t,e,n,this.data),o=0,a=r.length;o<a;o++)Array.prototype.push.apply(i,r[o].toShapes());return i}}),Object.assign(sc.prototype,{load:function(t,e,n,i){var r=this,o=new ja(this.manager);o.setPath(this.path),o.load(t,(function(t){var n;try{n=JSON.parse(t)}catch(e){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),n=JSON.parse(t.substring(65,t.length-2))}var i=r.parse(n);e&&e(i)}),n,i)},parse:function(t){return new oc(t)},setPath:function(t){return this.path=t,this}});var cc,hc,lc,uc,pc,dc,fc,mc,vc,gc,yc={getContext:function(){return void 0===$s&&($s=new(window.AudioContext||window.webkitAudioContext)),$s},setContext:function(t){$s=t}};function xc(t){this.manager=void 0!==t?t:Ga}function wc(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Br,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Br,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1}function bc(t,e,n){bi.call(this),this.type="CubeCamera";var i=new Br(90,1,t,e);i.up.set(0,-1,0),i.lookAt(new Ye(1,0,0)),this.add(i);var r=new Br(90,1,t,e);r.up.set(0,-1,0),r.lookAt(new Ye(-1,0,0)),this.add(r);var o=new Br(90,1,t,e);o.up.set(0,0,1),o.lookAt(new Ye(0,1,0)),this.add(o);var a=new Br(90,1,t,e);a.up.set(0,0,-1),a.lookAt(new Ye(0,-1,0)),this.add(a);var s=new Br(90,1,t,e);s.up.set(0,-1,0),s.lookAt(new Ye(0,0,1)),this.add(s);var c=new Br(90,1,t,e);c.up.set(0,-1,0),c.lookAt(new Ye(0,0,-1)),this.add(c);var h={format:qt,magFilter:Lt,minFilter:Lt};this.renderTarget=new tn(n,n,h),this.renderTarget.texture.name="CubeCamera",this.update=function(t,e){null===this.parent&&this.updateMatrixWorld();var n=this.renderTarget,h=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,n.activeCubeFace=0,t.render(e,i,n),n.activeCubeFace=1,t.render(e,r,n),n.activeCubeFace=2,t.render(e,o,n),n.activeCubeFace=3,t.render(e,a,n),n.activeCubeFace=4,t.render(e,s,n),n.texture.generateMipmaps=h,n.activeCubeFace=5,t.render(e,c,n),t.setRenderTarget(null)},this.clear=function(t,e,n,i){for(var r=this.renderTarget,o=0;o<6;o++)r.activeCubeFace=o,t.setRenderTarget(r),t.clear(e,n,i);t.setRenderTarget(null)}}function _c(){bi.call(this),this.type="AudioListener",this.context=yc.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null}function Mc(t){bi.call(this),this.type="Audio",this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.loop=!1,this.startTime=0,this.offset=0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.sourceType="empty",this.filters=[]}function Ec(t){Mc.call(this,t),this.panner=this.context.createPanner(),this.panner.connect(this.gain)}function Sc(t,e){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=void 0!==e?e:2048,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}function Tc(t,e,n){this.binding=t,this.valueSize=n;var i,r=Float64Array;switch(e){case"quaternion":i=this._slerp;break;case"string":case"bool":r=Array,i=this._select;break;default:i=this._lerp}this.buffer=new r(4*n),this._mixBufferRegion=i,this.cumulativeWeight=0,this.useCount=0,this.referenceCount=0}Object.assign(xc.prototype,{load:function(t,e,n,i){var r=new ja(this.manager);r.setResponseType("arraybuffer"),r.load(t,(function(t){yc.getContext().decodeAudioData(t,(function(t){e(t)}))}),n,i)}}),Object.assign(wc.prototype,{update:(vc=new qe,gc=new qe,function(t){if(cc!==this||hc!==t.focus||lc!==t.fov||uc!==t.aspect*this.aspect||pc!==t.near||dc!==t.far||fc!==t.zoom||mc!==this.eyeSep){cc=this,hc=t.focus,lc=t.fov,uc=t.aspect*this.aspect,pc=t.near,dc=t.far,fc=t.zoom;var e,n,i=t.projectionMatrix.clone(),r=(mc=this.eyeSep/2)*pc/hc,o=pc*Math.tan(ke.DEG2RAD*lc*.5)/fc;gc.elements[12]=-mc,vc.elements[12]=mc,e=-o*uc+r,n=o*uc+r,i.elements[0]=2*pc/(n-e),i.elements[8]=(n+e)/(n-e),this.cameraL.projectionMatrix.copy(i),e=-o*uc-r,n=o*uc-r,i.elements[0]=2*pc/(n-e),i.elements[8]=(n+e)/(n-e),this.cameraR.projectionMatrix.copy(i)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(gc),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(vc)})}),bc.prototype=Object.create(bi.prototype),bc.prototype.constructor=bc,_c.prototype=Object.assign(Object.create(bi.prototype),{constructor:_c,getInput:function(){return this.gain},removeFilter:function(){null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null)},getFilter:function(){return this.filter},setFilter:function(t){null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination)},getMasterVolume:function(){return this.gain.gain.value},setMasterVolume:function(t){this.gain.gain.value=t},updateMatrixWorld:function(){var t=new Ye,e=new Xe,n=new Ye,i=new Ye;return function(r){bi.prototype.updateMatrixWorld.call(this,r);var o=this.context.listener,a=this.up;this.matrixWorld.decompose(t,e,n),i.set(0,0,-1).applyQuaternion(e),o.positionX?(o.positionX.setValueAtTime(t.x,this.context.currentTime),o.positionY.setValueAtTime(t.y,this.context.currentTime),o.positionZ.setValueAtTime(t.z,this.context.currentTime),o.forwardX.setValueAtTime(i.x,this.context.currentTime),o.forwardY.setValueAtTime(i.y,this.context.currentTime),o.forwardZ.setValueAtTime(i.z,this.context.currentTime),o.upX.setValueAtTime(a.x,this.context.currentTime),o.upY.setValueAtTime(a.y,this.context.currentTime),o.upZ.setValueAtTime(a.z,this.context.currentTime)):(o.setPosition(t.x,t.y,t.z),o.setOrientation(i.x,i.y,i.z,a.x,a.y,a.z))}}()}),Mc.prototype=Object.assign(Object.create(bi.prototype),{constructor:Mc,getOutput:function(){return this.gain},setNodeSource:function(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this},setBuffer:function(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this},play:function(){if(!0!==this.isPlaying){if(!1!==this.hasPlaybackControl){var t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.onended=this.onEnded.bind(this),t.playbackRate.setValueAtTime(this.playbackRate,this.startTime),this.startTime=this.context.currentTime,t.start(this.startTime,this.offset),this.isPlaying=!0,this.source=t,this.connect()}console.warn("THREE.Audio: this Audio has no playback control.")}else console.warn("THREE.Audio: Audio is already playing.")},pause:function(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this.source.stop(),this.offset+=(this.context.currentTime-this.startTime)*this.playbackRate,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")},stop:function(){if(!1!==this.hasPlaybackControl)return this.source.stop(),this.offset=0,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")},connect:function(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this},disconnect:function(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this},getFilters:function(){return this.filters},setFilters:function(t){return t||(t=[]),!0===this.isPlaying?(this.disconnect(),this.filters=t,this.connect()):this.filters=t,this},getFilter:function(){return this.getFilters()[0]},setFilter:function(t){return this.setFilters(t?[t]:[])},setPlaybackRate:function(t){if(!1!==this.hasPlaybackControl)return this.playbackRate=t,!0===this.isPlaying&&this.source.playbackRate.setValueAtTime(this.playbackRate,this.context.currentTime),this;console.warn("THREE.Audio: this Audio has no playback control.")},getPlaybackRate:function(){return this.playbackRate},onEnded:function(){this.isPlaying=!1},getLoop:function(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop},setLoop:function(t){if(!1!==this.hasPlaybackControl)return this.loop=t,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")},getVolume:function(){return this.gain.gain.value},setVolume:function(t){return this.gain.gain.value=t,this}}),Ec.prototype=Object.assign(Object.create(Mc.prototype),{constructor:Ec,getOutput:function(){return this.panner},getRefDistance:function(){return this.panner.refDistance},setRefDistance:function(t){this.panner.refDistance=t},getRolloffFactor:function(){return this.panner.rolloffFactor},setRolloffFactor:function(t){this.panner.rolloffFactor=t},getDistanceModel:function(){return this.panner.distanceModel},setDistanceModel:function(t){this.panner.distanceModel=t},getMaxDistance:function(){return this.panner.maxDistance},setMaxDistance:function(t){this.panner.maxDistance=t},updateMatrixWorld:function(){var t=new Ye;return function(e){bi.prototype.updateMatrixWorld.call(this,e),t.setFromMatrixPosition(this.matrixWorld),this.panner.setPosition(t.x,t.y,t.z)}}()}),Object.assign(Sc.prototype,{getFrequencyData:function(){return this.analyser.getByteFrequencyData(this.data),this.data},getAverageFrequency:function(){for(var t=0,e=this.getFrequencyData(),n=0;n<e.length;n++)t+=e[n];return t/e.length}}),Object.assign(Tc.prototype,{accumulate:function(t,e){var n=this.buffer,i=this.valueSize,r=t*i+i,o=this.cumulativeWeight;if(0===o){for(var a=0;a!==i;++a)n[r+a]=n[a];o=e}else{var s=e/(o+=e);this._mixBufferRegion(n,r,0,s,i)}this.cumulativeWeight=o},apply:function(t){var e=this.valueSize,n=this.buffer,i=t*e+e,r=this.cumulativeWeight,o=this.binding;if(this.cumulativeWeight=0,r<1){var a=3*e;this._mixBufferRegion(n,i,a,1-r,e)}for(var s=e,c=e+e;s!==c;++s)if(n[s]!==n[s+e]){o.setValue(n,i);break}},saveOriginalState:function(){var t=this.binding,e=this.buffer,n=this.valueSize,i=3*n;t.getValue(e,i);for(var r=n,o=i;r!==o;++r)e[r]=e[i+r%n];this.cumulativeWeight=0},restoreOriginalState:function(){var t=3*this.valueSize;this.binding.setValue(this.buffer,t)},_select:function(t,e,n,i,r){if(i>=.5)for(var o=0;o!==r;++o)t[e+o]=t[n+o]},_slerp:function(t,e,n,i){Xe.slerpFlat(t,e,t,e,t,n,i)},_lerp:function(t,e,n,i,r){for(var o=1-i,a=0;a!==r;++a){var s=e+a;t[s]=t[s]*o+t[n+a]*i}}});var Ac,Rc,Cc,Lc,Pc,Bc,Ic,Nc,Oc,Fc,zc,Dc;function Uc(t,e,n){var i=n||Vc.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}function Vc(t,e,n){this.path=e,this.parsedPath=n||Vc.parseTrackName(e),this.node=Vc.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function Gc(){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 i=this;this.stats={objects:{get total(){return i._objects.length},get inUse(){return this.total-i.nCachedObjects_}},get bindingsPerObject(){return i._bindings.length}}}function Hc(t,e,n){this._mixer=t,this._clip=e,this._localRoot=n||null;for(var i=e.tracks,r=i.length,o=new Array(r),a={endingStart:Re,endingEnd:Re},s=0;s!==r;++s){var c=i[s].createInterpolant(null);o[s]=c,c.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Me,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 jc(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function kc(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function Wc(){Yi.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function qc(t,e,n,i){this.uuid=ke.generateUUID(),this.data=t,this.itemSize=e,this.offset=n,this.normalized=!0===i}function Xc(t,e){this.uuid=ke.generateUUID(),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.onUploadCallback=function(){},this.version=0}function Yc(t,e,n){Xc.call(this,t,e),this.meshPerAttribute=n||1}function Zc(t,e,n){Ri.call(this,t,e),this.meshPerAttribute=n||1}function Jc(t,e,n,i){this.ray=new er(t,e),this.near=n||0,this.far=i||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 Qc(t,e){return t.distance-e.distance}function Kc(t,e,n,i){if(!1!==t.visible&&(t.raycast(e,n),!0===i))for(var r=t.children,o=0,a=r.length;o<a;o++)Kc(r[o],e,n,!0)}function $c(t){this.autoStart=void 0===t||t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}function th(t,e,n){return this.radius=void 0!==t?t:1,this.phi=void 0!==e?e:0,this.theta=void 0!==n?n:0,this}function eh(t,e,n){return this.radius=void 0!==t?t:1,this.theta=void 0!==e?e:0,this.y=void 0!==n?n:0,this}function nh(t,e){this.min=void 0!==t?t:new We(1/0,1/0),this.max=void 0!==e?e:new We(-1/0,-1/0)}function ih(t){bi.call(this),this.material=t,this.render=function(){}}function rh(t,e,n,i){this.object=t,this.size=void 0!==e?e:1;var r=void 0!==n?n:16711680,o=void 0!==i?i:1,a=0,s=this.object.geometry;s&&s.isGeometry?a=3*s.faces.length:s&&s.isBufferGeometry&&(a=s.attributes.normal.count);var c=new Yi,h=new Fi(2*a*3,3);c.addAttribute("position",h),ho.call(this,c,new so({color:r,linewidth:o})),this.matrixAutoUpdate=!1,this.update()}function oh(t,e){bi.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e;for(var n=new Yi,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1],r=0,o=1;r<32;r++,o++){var a=r/32*Math.PI*2,s=o/32*Math.PI*2;i.push(Math.cos(a),Math.sin(a),1,Math.cos(s),Math.sin(s),1)}n.addAttribute("position",new Fi(i,3));var c=new so({fog:!1});this.cone=new ho(n,c),this.add(this.cone),this.update()}function ah(t){for(var e=function t(e){var n=[];e&&e.isBone&&n.push(e);for(var i=0;i<e.children.length;i++)n.push.apply(n,t(e.children[i]));return n}(t),n=new Yi,i=[],r=[],o=new kn(0,0,1),a=new kn(0,1,0),s=0;s<e.length;s++){var c=e[s];c.parent&&c.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),r.push(o.r,o.g,o.b),r.push(a.r,a.g,a.b))}n.addAttribute("position",new Fi(i,3)),n.addAttribute("color",new Fi(r,3));var h=new so({vertexColors:P,depthTest:!1,depthWrite:!1,transparent:!0});ho.call(this,n,h),this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1}function sh(t,e,n){this.light=t,this.light.updateMatrixWorld(),this.color=n;var i=new da(e,4,2),r=new $i({wireframe:!0,fog:!1});rr.call(this,i,r),this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}function ch(t,e){bi.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=e;var n=new so({fog:!1}),i=new Yi;i.addAttribute("position",new Ri(new Float32Array(15),3)),this.line=new co(i,n),this.add(this.line),this.update()}function hh(t,e,n){bi.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;var i=new To(e);i.rotateY(.5*Math.PI),this.material=new $i({wireframe:!0,fog:!1}),void 0===this.color&&(this.material.vertexColors=P);var r=i.getAttribute("position"),o=new Float32Array(3*r.count);i.addAttribute("color",new Ri(o,3)),this.add(new rr(i,this.material)),this.update()}function lh(t,e,n,i){t=t||10,e=e||10,n=new kn(void 0!==n?n:4473924),i=new kn(void 0!==i?i:8947848);for(var r=e/2,o=t/e,a=t/2,s=[],c=[],h=0,l=0,u=-a;h<=e;h++,u+=o){s.push(-a,0,u,a,0,u),s.push(u,0,-a,u,0,a);var p=h===r?n:i;p.toArray(c,l),l+=3,p.toArray(c,l),l+=3,p.toArray(c,l),l+=3,p.toArray(c,l),l+=3}var d=new Yi;d.addAttribute("position",new Fi(s,3)),d.addAttribute("color",new Fi(c,3));var f=new so({vertexColors:P});ho.call(this,d,f)}function uh(t,e,n,i,r,o){t=t||10,e=e||16,n=n||8,i=i||64,r=new kn(void 0!==r?r:4473924),o=new kn(void 0!==o?o:8947848);var a,s,c,h,l,u,p,d=[],f=[];for(h=0;h<=e;h++)c=h/e*(2*Math.PI),a=Math.sin(c)*t,s=Math.cos(c)*t,d.push(0,0,0),d.push(a,0,s),p=1&h?r:o,f.push(p.r,p.g,p.b),f.push(p.r,p.g,p.b);for(h=0;h<=n;h++)for(p=1&h?r:o,u=t-t/n*h,l=0;l<i;l++)c=l/i*(2*Math.PI),a=Math.sin(c)*u,s=Math.cos(c)*u,d.push(a,0,s),f.push(p.r,p.g,p.b),c=(l+1)/i*(2*Math.PI),a=Math.sin(c)*u,s=Math.cos(c)*u,d.push(a,0,s),f.push(p.r,p.g,p.b);var m=new Yi;m.addAttribute("position",new Fi(d,3)),m.addAttribute("color",new Fi(f,3));var v=new so({vertexColors:P});ho.call(this,m,v)}function ph(t,e,n,i){this.object=t,this.size=void 0!==e?e:1;var r=void 0!==n?n:16776960,o=void 0!==i?i:1,a=0,s=this.object.geometry;s&&s.isGeometry?a=s.faces.length:console.warn("THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead.");var c=new Yi,h=new Fi(2*a*3,3);c.addAttribute("position",h),ho.call(this,c,new so({color:r,linewidth:o})),this.matrixAutoUpdate=!1,this.update()}function dh(t,e,n){bi.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,void 0===e&&(e=1);var i=new Yi;i.addAttribute("position",new Fi([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));var r=new so({fog:!1});this.lightPlane=new co(i,r),this.add(this.lightPlane),(i=new Yi).addAttribute("position",new Fi([0,0,0,0,0,1],3)),this.targetLine=new co(i,r),this.add(this.targetLine),this.update()}function fh(t){var e=new Yi,n=new so({color:16777215,vertexColors:L}),i=[],r=[],o={},a=new kn(16755200),s=new kn(16711680),c=new kn(43775),h=new kn(16777215),l=new kn(3355443);function u(t,e,n){p(t,n),p(e,n)}function p(t,e){i.push(0,0,0),r.push(e.r,e.g,e.b),void 0===o[t]&&(o[t]=[]),o[t].push(i.length/3-1)}u("n1","n2",a),u("n2","n4",a),u("n4","n3",a),u("n3","n1",a),u("f1","f2",a),u("f2","f4",a),u("f4","f3",a),u("f3","f1",a),u("n1","f1",a),u("n2","f2",a),u("n3","f3",a),u("n4","f4",a),u("p","n1",s),u("p","n2",s),u("p","n3",s),u("p","n4",s),u("u1","u2",c),u("u2","u3",c),u("u3","u1",c),u("c","t",h),u("p","c",l),u("cn1","cn2",l),u("cn3","cn4",l),u("cf1","cf2",l),u("cf3","cf4",l),e.addAttribute("position",new Fi(i,3)),e.addAttribute("color",new Fi(r,3)),ho.call(this,e,n),this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update()}function mh(t,e){this.object=t,void 0===e&&(e=16776960);var n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),r=new Yi;r.setIndex(new Ri(n,1)),r.addAttribute("position",new Ri(i,3)),ho.call(this,r,new so({color:e})),this.matrixAutoUpdate=!1,this.update()}function vh(t,e){this.type="Box3Helper",this.box=t;var n=void 0!==e?e:16776960,i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Yi;r.setIndex(new Ri(i,1)),r.addAttribute("position",new Fi([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),ho.call(this,r,new so({color:n})),this.geometry.computeBoundingSphere()}function gh(t,e,n){this.type="PlaneHelper",this.plane=t,this.size=void 0===e?1:e;var i=void 0!==n?n:16776960,r=new Yi;r.addAttribute("position",new Fi([1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],3)),r.computeBoundingSphere(),co.call(this,r,new so({color:i}));var o=new Yi;o.addAttribute("position",new Fi([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3)),o.computeBoundingSphere(),this.add(new rr(o,new $i({color:i,opacity:.2,transparent:!0,depthWrite:!1})))}function yh(t,e,n,i,r,o){bi.call(this),void 0===i&&(i=16776960),void 0===n&&(n=1),void 0===r&&(r=.2*n),void 0===o&&(o=.2*r),void 0===Oc&&((Oc=new Yi).addAttribute("position",new Fi([0,0,0,0,1,0],3)),(Fc=new Ma(0,.5,1,5,1)).translate(0,-.5,0)),this.position.copy(e),this.line=new co(Oc,new so({color:i})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new rr(Fc,new $i({color:i})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(n,r,o)}function xh(t){var e=[0,0,0,t=t||1,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=new Yi;n.addAttribute("position",new Fi(e,3)),n.addAttribute("color",new Fi([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));var i=new so({vertexColors:P});ho.call(this,n,i)}function wh(t,e,n,i,r,o,a){return console.warn("THREE.Face4 has been removed. A THREE.Face3 will be created instead."),new Ei(t,e,n,r,o,a)}Object.assign(Uc.prototype,{getValue:function(t,e){this.bind();var n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(t,e)},setValue:function(t,e){for(var n=this._bindings,i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)},bind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()},unbind:function(){for(var t=this._bindings,e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}}),Object.assign(Vc,{Composite:Uc,create:function(t,e,n){return t&&t.isAnimationObjectGroup?new Vc.Composite(t,e,n):new Vc(t,e,n)},sanitizeNodeName:(Nc=new RegExp("[\\[\\]\\.:\\/]","g"),function(t){return t.replace(/\s/g,"_").replace(Nc,"")}),parseTrackName:(Ac="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",Rc=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]"),Cc=/(WCOD+)?/.source.replace("WCOD",Ac),Lc=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Pc=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Bc=new RegExp("^"+Rc+Cc+Lc+Pc+"$"),Ic=["material","materials","bones"],function(t){var e=Bc.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);var n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){var r=n.nodeName.substring(i+1);-1!==Ic.indexOf(r)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}),findNode:function(t,e){if(!e||""===e||"root"===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){var n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){var i=function(t){for(var n=0;n<t.length;n++){var r=t[n];if(r.name===e||r.uuid===e)return r;var o=i(r.children);if(o)return o}return null},r=i(t.children);if(r)return r}return null}}),Object.assign(Vc.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(t,e){t[e]=this.node[this.propertyName]},function(t,e){for(var n=this.resolvedProperty,i=0,r=n.length;i!==r;++i)t[e++]=n[i]},function(t,e){t[e]=this.resolvedProperty[this.propertyIndex]},function(t,e){this.resolvedProperty.toArray(t,e)}],SetterByBindingTypeAndVersioning:[[function(t,e){this.targetObject[this.propertyName]=t[e]},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){for(var n=this.resolvedProperty,i=0,r=n.length;i!==r;++i)n[i]=t[e++]},function(t,e){for(var n=this.resolvedProperty,i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0},function(t,e){for(var n=this.resolvedProperty,i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty[this.propertyIndex]=t[e]},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}],[function(t,e){this.resolvedProperty.fromArray(t,e)},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0},function(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(t,e){this.bind(),this.getValue(t,e)},setValue:function(t,e){this.bind(),this.setValue(t,e)},bind:function(){var t=this.node,e=this.parsedPath,n=e.objectName,i=e.propertyName,r=e.propertyIndex;if(t||(t=Vc.findNode(this.rootNode,e.nodeName)||this.rootNode,this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,t){if(n){var o=e.objectIndex;switch(n){case"materials":if(!t.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!t.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);t=t.material.materials;break;case"bones":if(!t.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);t=t.skeleton.bones;for(var a=0;a<t.length;a++)if(t[a].name===o){o=a;break}break;default:if(void 0===t[n])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);t=t[n]}if(void 0!==o){if(void 0===t[o])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);t=t[o]}}var s=t[i];if(void 0!==s){var c=this.Versioning.None;void 0!==t.needsUpdate?(c=this.Versioning.NeedsUpdate,this.targetObject=t):void 0!==t.matrixWorldNeedsUpdate&&(c=this.Versioning.MatrixWorldNeedsUpdate,this.targetObject=t);var h=this.BindingType.Direct;if(void 0!==r){if("morphTargetInfluences"===i){if(!t.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(t.geometry.isBufferGeometry){if(!t.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);for(a=0;a<this.node.geometry.morphAttributes.position.length;a++)if(t.geometry.morphAttributes.position[a].name===r){r=a;break}}else{if(!t.geometry.morphTargets)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphTargets.",this);for(a=0;a<this.node.geometry.morphTargets.length;a++)if(t.geometry.morphTargets[a].name===r){r=a;break}}}h=this.BindingType.ArrayElement,this.resolvedProperty=s,this.propertyIndex=r}else void 0!==s.fromArray&&void 0!==s.toArray?(h=this.BindingType.HasFromToArray,this.resolvedProperty=s):Array.isArray(s)?(h=this.BindingType.EntireArray,this.resolvedProperty=s):this.propertyName=i;this.getValue=this.GetterByBindingType[h],this.setValue=this.SetterByBindingTypeAndVersioning[h][c]}else{var l=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",t)}}else console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.")},unbind:function(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}),Object.assign(Vc.prototype,{_getValue_unbound:Vc.prototype.getValue,_setValue_unbound:Vc.prototype.setValue}),Object.assign(Gc.prototype,{isAnimationObjectGroup:!0,add:function(){for(var t=this._objects,e=t.length,n=this.nCachedObjects_,i=this._indicesByUUID,r=this._paths,o=this._parsedPaths,a=this._bindings,s=a.length,c=void 0,h=0,l=arguments.length;h!==l;++h){var u=arguments[h],p=u.uuid,d=i[p];if(void 0===d){d=e++,i[p]=d,t.push(u);for(var f=0,m=s;f!==m;++f)a[f].push(new Vc(u,r[f],o[f]))}else if(d<n){c=t[d];var v=--n,g=t[v];i[g.uuid]=d,t[d]=g,i[p]=v,t[v]=u;for(f=0,m=s;f!==m;++f){var y=a[f],x=y[v],w=y[d];y[d]=x,void 0===w&&(w=new Vc(u,r[f],o[f])),y[v]=w}}else t[d]!==c&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=n},remove:function(){for(var t=this._objects,e=this.nCachedObjects_,n=this._indicesByUUID,i=this._bindings,r=i.length,o=0,a=arguments.length;o!==a;++o){var s=arguments[o],c=s.uuid,h=n[c];if(void 0!==h&&h>=e){var l=e++,u=t[l];n[u.uuid]=h,t[h]=u,n[c]=l,t[l]=s;for(var p=0,d=r;p!==d;++p){var f=i[p],m=f[l],v=f[h];f[h]=m,f[l]=v}}}this.nCachedObjects_=e},uncache:function(){for(var t=this._objects,e=t.length,n=this.nCachedObjects_,i=this._indicesByUUID,r=this._bindings,o=r.length,a=0,s=arguments.length;a!==s;++a){var c=arguments[a],h=c.uuid,l=i[h];if(void 0!==l)if(delete i[h],l<n){var u=--n,p=t[u],d=t[y=--e];i[p.uuid]=l,t[l]=p,i[d.uuid]=u,t[u]=d,t.pop();for(var f=0,m=o;f!==m;++f){var v=(x=r[f])[u],g=x[y];x[l]=v,x[u]=g,x.pop()}}else{var y;i[(d=t[y=--e]).uuid]=l,t[l]=d,t.pop();for(f=0,m=o;f!==m;++f){var x;(x=r[f])[l]=x[y],x.pop()}}}this.nCachedObjects_=n},subscribe_:function(t,e){var n=this._bindingsIndicesByPath,i=n[t],r=this._bindings;if(void 0!==i)return r[i];var o=this._paths,a=this._parsedPaths,s=this._objects,c=s.length,h=this.nCachedObjects_,l=new Array(c);i=r.length,n[t]=i,o.push(t),a.push(e),r.push(l);for(var u=h,p=s.length;u!==p;++u){var d=s[u];l[u]=new Vc(d,t,e)}return l},unsubscribe_:function(t){var e=this._bindingsIndicesByPath,n=e[t];if(void 0!==n){var i=this._paths,r=this._parsedPaths,o=this._bindings,a=o.length-1,s=o[a];e[t[a]]=n,o[n]=s,o.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}}),Object.assign(Hc.prototype,{play:function(){return this._mixer._activateAction(this),this},stop:function(){return this._mixer._deactivateAction(this),this.reset()},reset:function(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()},isRunning:function(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},startAt:function(t){return this._startTime=t,this},setLoop:function(t,e){return this.loop=t,this.repetitions=e,this},setEffectiveWeight:function(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(t){return this._scheduleFading(t,0,1)},fadeOut:function(t){return this._scheduleFading(t,1,0)},crossFadeFrom:function(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){var i=this._clip.duration,r=t._clip.duration,o=r/i,a=i/r;t.warp(1,o,e),this.warp(a,1,e)}return this},crossFadeTo:function(t,e,n){return t.crossFadeFrom(this,e,n)},stopFading:function(){var t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this},setEffectiveTimeScale:function(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(t){return this.timeScale=this._clip.duration/t,this.stopWarping()},syncWith:function(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()},halt:function(t){return this.warp(this._effectiveTimeScale,0,t)},warp:function(t,e,n){var i=this._mixer,r=i.time,o=this._timeScaleInterpolant,a=this.timeScale;null===o&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);var s=o.parameterPositions,c=o.sampleValues;return s[0]=r,s[1]=r+n,c[0]=t/a,c[1]=e/a,this},stopWarping:function(){var t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||this._mixer._root},_update:function(t,e,n,i){if(this.enabled){var r=this._startTime;if(null!==r){var o=(t-r)*n;if(o<0||0===n)return;this._startTime=null,e=n*o}e*=this._updateTimeScale(t);var a=this._updateTime(e),s=this._updateWeight(t);if(s>0)for(var c=this._interpolants,h=this._propertyBindings,l=0,u=c.length;l!==u;++l)c[l].evaluate(a),h[l].accumulate(i,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 i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),0===i&&(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,i=this.loop,r=this._loopCount;if(i===_e){-1===r&&(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=i===Ee;if(-1===r&&(t>=0?(r=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,r+=Math.abs(a);var s=this.repetitions-r;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(0===s){var c=t<0;this._setEndings(c,!c,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}if(o&&1==(1&r))return this.time=e,n-e}return this.time=e,e},_setEndings:function(t,e,n){var i=this._interpolantSettings;n?(i.endingStart=Ce,i.endingEnd=Ce):(i.endingStart=t?this.zeroSlopeAtStart?Ce:Re:Le,i.endingEnd=e?this.zeroSlopeAtEnd?Ce:Re:Le)},_scheduleFading:function(t,e,n){var i=this._mixer,r=i.time,o=this._weightInterpolant;null===o&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);var a=o.parameterPositions,s=o.sampleValues;return a[0]=r,s[0]=e,a[1]=r+t,s[1]=n,this}}),jc.prototype=Object.assign(Object.create(i.prototype),{constructor:jc,_bindAction:function(t,e){var n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,o=t._propertyBindings,a=t._interpolants,s=n.uuid,c=this._bindingsByRootAndName,h=c[s];void 0===h&&(h={},c[s]=h);for(var l=0;l!==r;++l){var u=i[l],p=u.name,d=h[p];if(void 0!==d)o[l]=d;else{if(void 0!==(d=o[l])){null===d._cacheIndex&&(++d.referenceCount,this._addInactiveBinding(d,s,p));continue}var f=e&&e._propertyBindings[l].binding.parsedPath;++(d=new Tc(Vc.create(n,p,f),u.ValueTypeName,u.getValueSize())).referenceCount,this._addInactiveBinding(d,s,p),o[l]=d}a[l].resultBuffer=d.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,n=t._clip.uuid,i=this._actionsByClip[n];this._bindAction(t,i&&i.knownActions[0]),this._addInactiveAction(t,n,e)}for(var r=t._propertyBindings,o=0,a=r.length;o!==a;++o){var s=r[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,i=e.length;n!==i;++n){var r=e[n];0==--r.useCount&&(r.restoreOriginalState(),this._takeBackBinding(r))}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&&e<this._nActiveActions},_addInactiveAction:function(t,e,n){var i=this._actions,r=this._actionsByClip,o=r[e];if(void 0===o)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=o;else{var a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=i.length,i.push(t),o.actionByRoot[n]=t},_removeInactiveAction:function(t){var e=this._actions,n=e[e.length-1],i=t._cacheIndex;n._cacheIndex=i,e[i]=n,e.pop(),t._cacheIndex=null;var r=t._clip.uuid,o=this._actionsByClip,a=o[r],s=a.knownActions,c=s[s.length-1],h=t._byClipCacheIndex;c._byClipCacheIndex=h,s[h]=c,s.pop(),t._byClipCacheIndex=null,delete a.actionByRoot[(t._localRoot||this._root).uuid],0===s.length&&delete o[r],this._removeInactiveBindingsForAction(t)},_removeInactiveBindingsForAction:function(t){for(var e=t._propertyBindings,n=0,i=e.length;n!==i;++n){var r=e[n];0==--r.referenceCount&&this._removeInactiveBinding(r)}},_lendAction:function(t){var e=this._actions,n=t._cacheIndex,i=this._nActiveActions++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r},_takeBackAction:function(t){var e=this._actions,n=t._cacheIndex,i=--this._nActiveActions,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r},_addInactiveBinding:function(t,e,n){var i=this._bindingsByRootAndName,r=i[e],o=this._bindings;void 0===r&&(r={},i[e]=r),r[n]=t,t._cacheIndex=o.length,o.push(t)},_removeInactiveBinding:function(t){var e=this._bindings,n=t.binding,i=n.rootNode.uuid,r=n.path,o=this._bindingsByRootAndName,a=o[i],s=e[e.length-1],c=t._cacheIndex;s._cacheIndex=c,e[c]=s,e.pop(),delete a[r];t:{for(var h in a)break t;delete o[i]}},_lendBinding:function(t){var e=this._bindings,n=t._cacheIndex,i=this._nActiveBindings++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r},_takeBackBinding:function(t){var e=this._bindings,n=t._cacheIndex,i=--this._nActiveBindings,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r},_lendControlInterpolant:function(){var t=this._controlInterpolants,e=this._nActiveControlInterpolants++,n=t[e];return void 0===n&&((n=new Fs(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer)).__cacheIndex=e,t[e]=n),n},_takeBackControlInterpolant:function(t){var e=this._controlInterpolants,n=t.__cacheIndex,i=--this._nActiveControlInterpolants,r=e[i];t.__cacheIndex=i,e[i]=t,r.__cacheIndex=n,e[n]=r},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(t,e){var n=e||this._root,i=n.uuid,r="string"==typeof t?Gs.findByName(n,t):t,o=null!==r?r.uuid:t,a=this._actionsByClip[o],s=null;if(void 0!==a){var c=a.actionByRoot[i];if(void 0!==c)return c;s=a.knownActions[0],null===r&&(r=s._clip)}if(null===r)return null;var h=new Hc(this,r,e);return this._bindAction(h,s),this._addInactiveAction(h,o,i),h},existingAction:function(t,e){var n=e||this._root,i=n.uuid,r="string"==typeof t?Gs.findByName(n,t):t,o=r?r.uuid:t,a=this._actionsByClip[o];return void 0!==a&&a.actionByRoot[i]||null},stopAllAction:function(){var t=this._actions,e=this._nActiveActions,n=this._bindings,i=this._nActiveBindings;this._nActiveActions=0,this._nActiveBindings=0;for(var r=0;r!==e;++r)t[r].reset();for(r=0;r!==i;++r)n[r].useCount=0;return this},update:function(t){t*=this.timeScale;for(var e=this._actions,n=this._nActiveActions,i=this.time+=t,r=Math.sign(t),o=this._accuIndex^=1,a=0;a!==n;++a){e[a]._update(i,t,r,o)}var s=this._bindings,c=this._nActiveBindings;for(a=0;a!==c;++a)s[a].apply(o);return this},getRoot:function(){return this._root},uncacheClip:function(t){var e=this._actions,n=t.uuid,i=this._actionsByClip,r=i[n];if(void 0!==r){for(var o=r.knownActions,a=0,s=o.length;a!==s;++a){var c=o[a];this._deactivateAction(c);var h=c._cacheIndex,l=e[e.length-1];c._cacheIndex=null,c._byClipCacheIndex=null,l._cacheIndex=h,e[h]=l,e.pop(),this._removeInactiveBindingsForAction(c)}delete i[n]}},uncacheRoot:function(t){var e=t.uuid,n=this._actionsByClip;for(var i in n){var r=n[i].actionByRoot[e];void 0!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}var o=this._bindingsByRootAndName[e];if(void 0!==o)for(var a in o){var s=o[a];s.restoreOriginalState(),this._removeInactiveBinding(s)}},uncacheAction:function(t,e){var n=this.existingAction(t,e);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}}),kc.prototype.clone=function(){return new kc(void 0===this.value.clone?this.value:this.value.clone())},Wc.prototype=Object.assign(Object.create(Yi.prototype),{constructor:Wc,isInstancedBufferGeometry:!0,copy:function(t){return Yi.prototype.copy.call(this,t),this.maxInstancedCount=t.maxInstancedCount,this},clone:function(){return(new this.constructor).copy(this)}}),Object.defineProperties(qc.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}}),Object.assign(qc.prototype,{isInterleavedBufferAttribute:!0,setX:function(t,e){return this.data.array[t*this.data.stride+this.offset]=e,this},setY:function(t,e){return this.data.array[t*this.data.stride+this.offset+1]=e,this},setZ:function(t,e){return this.data.array[t*this.data.stride+this.offset+2]=e,this},setW:function(t,e){return this.data.array[t*this.data.stride+this.offset+3]=e,this},getX:function(t){return this.data.array[t*this.data.stride+this.offset]},getY:function(t){return this.data.array[t*this.data.stride+this.offset+1]},getZ:function(t){return this.data.array[t*this.data.stride+this.offset+2]},getW:function(t){return this.data.array[t*this.data.stride+this.offset+3]},setXY:function(t,e,n){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this},setXYZ:function(t,e,n,i){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this},setXYZW:function(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this}}),Object.defineProperty(Xc.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Xc.prototype,{isInterleavedBuffer:!0,setArray:function(t){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.count=void 0!==t?t.length/this.stride:0,this.array=t},setDynamic:function(t){return this.dynamic=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.dynamic=t.dynamic,this},copyAt:function(t,e,n){t*=this.stride,n*=e.stride;for(var i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this},set:function(t,e){return void 0===e&&(e=0),this.array.set(t,e),this},clone:function(){return(new this.constructor).copy(this)},onUpload:function(t){return this.onUploadCallback=t,this}}),Yc.prototype=Object.assign(Object.create(Xc.prototype),{constructor:Yc,isInstancedInterleavedBuffer:!0,copy:function(t){return Xc.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this}}),Zc.prototype=Object.assign(Object.create(Ri.prototype),{constructor:Zc,isInstancedBufferAttribute:!0,copy:function(t){return Ri.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this}}),Object.assign(Jc.prototype,{linePrecision:1,set:function(t,e){this.ray.set(t,e)},setFromCamera:function(t,e){e&&e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize()):e&&e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld)):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(t,e){var n=[];return Kc(t,this,n,e),n.sort(Qc),n},intersectObjects:function(t,e){var n=[];if(!1===Array.isArray(t))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),n;for(var i=0,r=t.length;i<r;i++)Kc(t[i],this,n,e);return n.sort(Qc),n}}),Object.assign($c.prototype,{start:function(){this.startTime=("undefined"==typeof performance?Date:performance).now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1,this.autoStart=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var e=("undefined"==typeof performance?Date:performance).now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}),Object.assign(th.prototype,{set:function(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this},makeSafe:function(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this},setFromVector3:function(t){return this.radius=t.length(),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t.x,t.z),this.phi=Math.acos(ke.clamp(t.y/this.radius,-1,1))),this}}),Object.assign(eh.prototype,{set:function(t,e,n){return this.radius=t,this.theta=e,this.y=n,this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this},setFromVector3:function(t){return this.radius=Math.sqrt(t.x*t.x+t.z*t.z),this.theta=Math.atan2(t.x,t.z),this.y=t.y,this}}),Object.assign(nh.prototype,{set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this},setFromCenterAndSize:function(){var t=new We;return function(e,n){var i=t.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},getCenter:function(t){var e=t||new We;return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(t){var e=t||new We;return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},containsPoint:function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.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(e||new We).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.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)},clampPoint:function(t,e){return(e||new We).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)}}),ih.prototype=Object.create(bi.prototype),ih.prototype.constructor=ih,ih.prototype.isImmediateRenderObject=!0,rh.prototype=Object.create(ho.prototype),rh.prototype.constructor=rh,rh.prototype.update=function(){var t=new Ye,e=new Ye,n=new Ze;return function(){var i=["a","b","c"];this.object.updateMatrixWorld(!0),n.getNormalMatrix(this.object.matrixWorld);var r=this.object.matrixWorld,o=this.geometry.attributes.position,a=this.object.geometry;if(a&&a.isGeometry)for(var s=a.vertices,c=a.faces,h=0,l=0,u=c.length;l<u;l++)for(var p=c[l],d=0,f=p.vertexNormals.length;d<f;d++){var m=s[p[i[d]]],v=p.vertexNormals[d];t.copy(m).applyMatrix4(r),e.copy(v).applyMatrix3(n).normalize().multiplyScalar(this.size).add(t),o.setXYZ(h,t.x,t.y,t.z),h+=1,o.setXYZ(h,e.x,e.y,e.z),h+=1}else if(a&&a.isBufferGeometry){var g=a.attributes.position,y=a.attributes.normal;for(h=0,d=0,f=g.count;d<f;d++)t.set(g.getX(d),g.getY(d),g.getZ(d)).applyMatrix4(r),e.set(y.getX(d),y.getY(d),y.getZ(d)),e.applyMatrix3(n).normalize().multiplyScalar(this.size).add(t),o.setXYZ(h,t.x,t.y,t.z),h+=1,o.setXYZ(h,e.x,e.y,e.z),h+=1}o.needsUpdate=!0}}(),oh.prototype=Object.create(bi.prototype),oh.prototype.constructor=oh,oh.prototype.dispose=function(){this.cone.geometry.dispose(),this.cone.material.dispose()},oh.prototype.update=function(){var t=new Ye,e=new Ye;return function(){this.light.updateMatrixWorld();var n=this.light.distance?this.light.distance:1e3,i=n*Math.tan(this.light.angle);this.cone.scale.set(i,i,n),t.setFromMatrixPosition(this.light.matrixWorld),e.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(e.sub(t)),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}(),ah.prototype=Object.create(ho.prototype),ah.prototype.constructor=ah,ah.prototype.updateMatrixWorld=function(){var t=new Ye,e=new qe,n=new qe;return function(i){var r=this.bones,o=this.geometry,a=o.getAttribute("position");n.getInverse(this.root.matrixWorld);for(var s=0,c=0;s<r.length;s++){var h=r[s];h.parent&&h.parent.isBone&&(e.multiplyMatrices(n,h.matrixWorld),t.setFromMatrixPosition(e),a.setXYZ(c,t.x,t.y,t.z),e.multiplyMatrices(n,h.parent.matrixWorld),t.setFromMatrixPosition(e),a.setXYZ(c+1,t.x,t.y,t.z),c+=2)}o.getAttribute("position").needsUpdate=!0,bi.prototype.updateMatrixWorld.call(this,i)}}(),sh.prototype=Object.create(rr.prototype),sh.prototype.constructor=sh,sh.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose()},sh.prototype.update=function(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)},ch.prototype=Object.create(bi.prototype),ch.prototype.constructor=ch,ch.prototype.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},ch.prototype.update=function(){var t=.5*this.light.width,e=.5*this.light.height,n=this.line.geometry.attributes.position,i=n.array;i[0]=t,i[1]=-e,i[2]=0,i[3]=t,i[4]=e,i[5]=0,i[6]=-t,i[7]=e,i[8]=0,i[9]=-t,i[10]=-e,i[11]=0,i[12]=t,i[13]=-e,i[14]=0,n.needsUpdate=!0,void 0!==this.color?this.line.material.color.set(this.color):this.line.material.color.copy(this.light.color)},hh.prototype=Object.create(bi.prototype),hh.prototype.constructor=hh,hh.prototype.dispose=function(){this.children[0].geometry.dispose(),this.children[0].material.dispose()},hh.prototype.update=function(){var t=new Ye,e=new kn,n=new kn;return function(){var i=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{var r=i.geometry.getAttribute("color");e.copy(this.light.color),n.copy(this.light.groundColor);for(var o=0,a=r.count;o<a;o++){var s=o<a/2?e:n;r.setXYZ(o,s.r,s.g,s.b)}r.needsUpdate=!0}i.lookAt(t.setFromMatrixPosition(this.light.matrixWorld).negate())}}(),lh.prototype=Object.create(ho.prototype),lh.prototype.constructor=lh,uh.prototype=Object.create(ho.prototype),uh.prototype.constructor=uh,ph.prototype=Object.create(ho.prototype),ph.prototype.constructor=ph,ph.prototype.update=function(){var t=new Ye,e=new Ye,n=new Ze;return function(){this.object.updateMatrixWorld(!0),n.getNormalMatrix(this.object.matrixWorld);for(var i=this.object.matrixWorld,r=this.geometry.attributes.position,o=this.object.geometry,a=o.vertices,s=o.faces,c=0,h=0,l=s.length;h<l;h++){var u=s[h],p=u.normal;t.copy(a[u.a]).add(a[u.b]).add(a[u.c]).divideScalar(3).applyMatrix4(i),e.copy(p).applyMatrix3(n).normalize().multiplyScalar(this.size).add(t),r.setXYZ(c,t.x,t.y,t.z),c+=1,r.setXYZ(c,e.x,e.y,e.z),c+=1}r.needsUpdate=!0}}(),dh.prototype=Object.create(bi.prototype),dh.prototype.constructor=dh,dh.prototype.dispose=function(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()},dh.prototype.update=function(){var t=new Ye,e=new Ye,n=new Ye;return function(){t.setFromMatrixPosition(this.light.matrixWorld),e.setFromMatrixPosition(this.light.target.matrixWorld),n.subVectors(e,t),this.lightPlane.lookAt(n),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(n),this.targetLine.scale.z=n.length()}}(),fh.prototype=Object.create(ho.prototype),fh.prototype.constructor=fh,fh.prototype.update=function(){var t,e,n=new Ye,i=new _i;function r(r,o,a,s){n.set(o,a,s).unproject(i);var c=e[r];if(void 0!==c)for(var h=t.getAttribute("position"),l=0,u=c.length;l<u;l++)h.setXYZ(c[l],n.x,n.y,n.z)}return function(){t=this.geometry,e=this.pointMap;i.projectionMatrix.copy(this.camera.projectionMatrix),r("c",0,0,-1),r("t",0,0,1),r("n1",-1,-1,-1),r("n2",1,-1,-1),r("n3",-1,1,-1),r("n4",1,1,-1),r("f1",-1,-1,1),r("f2",1,-1,1),r("f3",-1,1,1),r("f4",1,1,1),r("u1",.7,1.1,-1),r("u2",-.7,1.1,-1),r("u3",0,2,-1),r("cf1",-1,0,1),r("cf2",1,0,1),r("cf3",0,-1,1),r("cf4",0,1,1),r("cn1",-1,0,-1),r("cn2",1,0,-1),r("cn3",0,-1,-1),r("cn4",0,1,-1),t.getAttribute("position").needsUpdate=!0}}(),mh.prototype=Object.create(ho.prototype),mh.prototype.constructor=mh,mh.prototype.update=function(){var t=new ci;return function(e){if(void 0!==e&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&t.setFromObject(this.object),!t.isEmpty()){var n=t.min,i=t.max,r=this.geometry.attributes.position,o=r.array;o[0]=i.x,o[1]=i.y,o[2]=i.z,o[3]=n.x,o[4]=i.y,o[5]=i.z,o[6]=n.x,o[7]=n.y,o[8]=i.z,o[9]=i.x,o[10]=n.y,o[11]=i.z,o[12]=i.x,o[13]=i.y,o[14]=n.z,o[15]=n.x,o[16]=i.y,o[17]=n.z,o[18]=n.x,o[19]=n.y,o[20]=n.z,o[21]=i.x,o[22]=n.y,o[23]=n.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}}}(),mh.prototype.setFromObject=function(t){return this.object=t,this.update(),this},vh.prototype=Object.create(ho.prototype),vh.prototype.constructor=vh,vh.prototype.updateMatrixWorld=function(t){var e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),bi.prototype.updateMatrixWorld.call(this,t))},gh.prototype=Object.create(co.prototype),gh.prototype.constructor=gh,gh.prototype.updateMatrixWorld=function(t){var e=-this.plane.constant;Math.abs(e)<1e-8&&(e=1e-8),this.scale.set(.5*this.size,.5*this.size,e),this.lookAt(this.plane.normal),bi.prototype.updateMatrixWorld.call(this,t)},yh.prototype=Object.create(bi.prototype),yh.prototype.constructor=yh,yh.prototype.setDirection=(Dc=new Ye,function(t){t.y>.99999?this.quaternion.set(0,0,0,1):t.y<-.99999?this.quaternion.set(1,0,0,0):(Dc.set(t.z,0,-t.x).normalize(),zc=Math.acos(t.y),this.quaternion.setFromAxisAngle(Dc,zc))}),yh.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()},yh.prototype.setColor=function(t){this.line.material.color.copy(t),this.cone.material.color.copy(t)},xh.prototype=Object.create(ho.prototype),xh.prototype.constructor=xh;var bh=0,_h=1;function Mh(t){return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."),t}function Eh(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 Sh(t,e){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new po(t,e)}function Th(t){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new no(t)}function Ah(t,e){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new po(t,e)}function Rh(t){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new uo(t)}function Ch(t){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new uo(t)}function Lh(t){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new uo(t)}function Ph(t,e,n){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new Ye(t,e,n)}function Bh(t,e){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead."),new Ri(t,e).setDynamic(!0)}function Ih(t,e){return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."),new Ci(t,e)}function Nh(t,e){return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."),new Li(t,e)}function Oh(t,e){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."),new Pi(t,e)}function Fh(t,e){return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."),new Bi(t,e)}function zh(t,e){return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."),new Ii(t,e)}function Dh(t,e){return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."),new Ni(t,e)}function Uh(t,e){return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."),new Oi(t,e)}function Vh(t,e){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new Fi(t,e)}function Gh(t,e){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new zi(t,e)}function Hh(t){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),is.call(this,t),this.type="catmullrom",this.closed=!0}function jh(t){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),is.call(this,t),this.type="catmullrom"}function kh(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),is.call(this,t),this.type="catmullrom"}function Wh(t){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new xh(t)}function qh(t,e){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new mh(t,e)}function Xh(t,e){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new ho(new ba(t.geometry),new so({color:void 0!==e?e:16777215}))}function Yh(t,e){return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."),new ho(new yo(t.geometry),new so({color:void 0!==e?e:16777215}))}function Zh(t){return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."),new ja(t)}function Jh(t){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new Wa(t)}Za.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(Za.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},Object.assign(ms.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 Ai,n=0,i=t.length;n<i;n++){var r=t[n];e.vertices.push(new Ye(r.x,r.y,r.z||0))}return e}}),Object.assign(vs.prototype,{fromPoints:function(t){console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints()."),this.setFromPoints(t)}}),Hh.prototype=Object.create(is.prototype),jh.prototype=Object.create(is.prototype),kh.prototype=Object.create(is.prototype),Object.assign(kh.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}}),lh.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")},ah.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")},Object.assign(Zs.prototype,{extractUrlBase:function(t){return console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead."),Js.extractUrlBase(t)}}),Object.assign(nh.prototype,{center:function(t){return console.warn("THREE.Box2: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},size:function(t){return console.warn("THREE.Box2: .size() has been renamed to .getSize()."),this.getSize(t)}}),Object.assign(ci.prototype,{center:function(t){return console.warn("THREE.Box3: .center() has been renamed to .getCenter()."),this.getCenter(t)},empty:function(){return console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."),this.isEmpty()},isIntersectionBox:function(t){return console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionSphere:function(t){return console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)},size:function(t){return console.warn("THREE.Box3: .size() has been renamed to .getSize()."),this.getSize(t)}}),nr.prototype.center=function(t){return console.warn("THREE.Line3: .center() has been renamed to .getCenter()."),this.getCenter(t)},Object.assign(ke,{random16:function(){return console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead."),Math.random()},nearestPowerOfTwo:function(t){return console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo()."),ke.floorPowerOfTwo(t)},nextPowerOfTwo:function(t){return console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo()."),ke.ceilPowerOfTwo(t)}}),Object.assign(Ze.prototype,{flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},multiplyVector3:function(t){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBuffer:function(t){return console.warn("THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead."),this.applyToBufferAttribute(t)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}}),Object.assign(qe.prototype,{extractPosition:function(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)},flattenToArrayOffset:function(t,e){return console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."),this.toArray(t,e)},getPosition:function(){var t;return function(){return void 0===t&&(t=new Ye),console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead."),t.setFromMatrixColumn(this,3)}}(),setRotationFromQuaternion:function(t){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(t)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(t){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector4:function(t){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},rotateAxis:function(t){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),t.transformDirection(this)},crossVector:function(t){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBuffer:function(t){return console.warn("THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead."),this.applyToBufferAttribute(t)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(t,e,n,i,r,o){return console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead."),this.makePerspective(t,e,i,n,r,o)}}),li.prototype.isIntersectionLine=function(t){return console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."),this.intersectsLine(t)},Xe.prototype.multiplyVector3=function(t){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),t.applyQuaternion(this)},Object.assign(er.prototype,{isIntersectionBox:function(t){return console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."),this.intersectsBox(t)},isIntersectionPlane:function(t){return console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."),this.intersectsPlane(t)},isIntersectionSphere:function(t){return console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere()."),this.intersectsSphere(t)}}),Object.assign(gs.prototype,{extractAllPoints:function(t){return console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead."),this.extractPoints(t)},extrude:function(t){return console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead."),new ca(this,t)},makeGeometry:function(t){return console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead."),new ya(this,t)}}),Object.assign(We.prototype,{fromAttribute:function(t,e,n){return console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},distanceToManhattan:function(t){return console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},lengthManhattan:function(){return console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(Ye.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(t){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(t)},getScaleFromMatrix:function(t){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(t)},getColumnFromMatrix:function(t,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(e,t)},applyProjection:function(t){return console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead."),this.applyMatrix4(t)},fromAttribute:function(t,e,n){return console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},distanceToManhattan:function(t){return console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo()."),this.manhattanDistanceTo(t)},lengthManhattan:function(){return console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(Ke.prototype,{fromAttribute:function(t,e,n){return console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute()."),this.fromBufferAttribute(t,e,n)},lengthManhattan:function(){return console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength()."),this.manhattanLength()}}),Object.assign(Ai.prototype,{computeTangents:function(){console.error("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}}),Object.assign(bi.prototype,{getChildByName:function(t){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(t)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(t,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,t)}}),Object.defineProperties(bi.prototype,{eulerOrder:{get:function(){return console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order},set:function(t){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."),this.rotation.order=t}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}}),Object.defineProperties(io.prototype,{objects:{get:function(){return console.warn("THREE.LOD: .objects has been renamed to .levels."),this.levels}}}),Object.defineProperty(ro.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}}),Object.defineProperty(Za.prototype,"__arcLengthDivisions",{get:function(){return console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions},set:function(t){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions."),this.arcLengthDivisions=t}}),Br.prototype.setLens=function(t,e){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup."),void 0!==e&&(this.filmGauge=e),this.setFocalLength(t)},Object.defineProperties(ys.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(t){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov."),this.shadow.camera.fov=t}},shadowCameraLeft:{set:function(t){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."),this.shadow.camera.left=t}},shadowCameraRight:{set:function(t){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right."),this.shadow.camera.right=t}},shadowCameraTop:{set:function(t){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top."),this.shadow.camera.top=t}},shadowCameraBottom:{set:function(t){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom."),this.shadow.camera.bottom=t}},shadowCameraNear:{set:function(t){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."),this.shadow.camera.near=t}},shadowCameraFar:{set:function(t){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."),this.shadow.camera.far=t}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(t){console.warn("THREE.Light: .shadowBias is now .shadow.bias."),this.shadow.bias=t}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(t){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."),this.shadow.mapSize.width=t}},shadowMapHeight:{set:function(t){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height."),this.shadow.mapSize.height=t}}}),Object.defineProperties(Ri.prototype,{length:{get:function(){return console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead."),this.array.length}}}),Object.assign(Yi.prototype,{addIndex:function(t){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."),this.setIndex(t)},addDrawCall:function(t,e,n){void 0!==n&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset."),console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup()."),this.addGroup(t,e)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups()."),this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}}),Object.defineProperties(Yi.prototype,{drawcalls:{get:function(){return console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups."),this.groups}},offsets:{get:function(){return console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups."),this.groups}}}),Object.defineProperties(kc.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){return console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."),this}}}),Object.defineProperties(oi.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},wrapRGB:{get:function(){return console.warn("THREE.Material: .wrapRGB has been removed."),new kn}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(t){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=t===A}}}),Object.defineProperties(Ia.prototype,{metal:{get:function(){return console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."),!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}}),Object.defineProperties(tr.prototype,{derivatives:{get:function(){return console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives},set:function(t){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives."),this.extensions.derivatives=t}}}),Object.assign(Qr.prototype,{getCurrentRenderTarget:function(){return console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget()."),this.getRenderTarget()},getMaxAnisotropy:function(){return console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy()."),this.capabilities.getMaxAnisotropy()},getPrecision:function(){return console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision."),this.capabilities.precision},resetGLState:function(){return console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset()."),this.state.reset()},supportsFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' )."),this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."),this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){return console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' )."),this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' )."),this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){return console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' )."),this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){return console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' )."),this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){return console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."),this.capabilities.vertexTextures},supportsInstancedArrays:function(){return console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' )."),this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(t){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest()."),this.setScissorTest(t)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")}}),Object.defineProperties(Qr.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled."),this.shadowMap.enabled=t}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(t){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."),this.shadowMap.type=t}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties(pi.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}}),Object.defineProperties($e.prototype,{wrapS:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS."),this.texture.wrapS=t}},wrapT:{get:function(){return console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT},set:function(t){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT."),this.texture.wrapT=t}},magFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."),this.texture.magFilter=t}},minFilter:{get:function(){return console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter},set:function(t){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter."),this.texture.minFilter=t}},anisotropy:{get:function(){return console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy},set:function(t){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."),this.texture.anisotropy=t}},offset:{get:function(){return console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset},set:function(t){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset."),this.texture.offset=t}},repeat:{get:function(){return console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat},set:function(t){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat."),this.texture.repeat=t}},format:{get:function(){return console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format},set:function(t){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format."),this.texture.format=t}},type:{get:function(){return console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type},set:function(t){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."),this.texture.type=t}},generateMipmaps:{get:function(){return console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps},set:function(t){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps."),this.texture.generateMipmaps=t}}}),Object.defineProperties(Nr.prototype,{standing:{set:function(){console.warn("THREE.WebVRManager: .standing has been removed.")}}}),Mc.prototype.load=function(t){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");var e=this;return(new xc).load(t,(function(t){e.setBuffer(t)})),this},Sc.prototype.getData=function(){return console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData()."),this.getFrequencyData()},bc.prototype.updateCubeMap=function(t,e){return console.warn("THREE.CubeCamera: .updateCubeMap() is now .update()."),this.update(t,e)};var Qh={merge:function(t,e,n){var i;console.warn("THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead."),e.isMesh&&(e.matrixAutoUpdate&&e.updateMatrix(),i=e.matrix,e=e.geometry),t.merge(e,i,n)},center:function(t){return console.warn("THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead."),t.center()}},Kh={crossOrigin:void 0,loadTexture:function(t,e,n,i){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var r=new Ya;r.setCrossOrigin(this.crossOrigin);var o=r.load(t,n,void 0,i);return e&&(o.mapping=e),o},loadTextureCube:function(t,e,n,i){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");var r=new Xa;r.setCrossOrigin(this.crossOrigin);var o=r.load(t,n,void 0,i);return e&&(o.mapping=e),o},loadCompressedTexture:function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},loadCompressedTextureCube:function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")}};function $h(){console.error("THREE.Projector has been moved to /examples/js/renderers/Projector.js."),this.projectVector=function(t,e){console.warn("THREE.Projector: .projectVector() is now vector.project()."),t.project(e)},this.unprojectVector=function(t,e){console.warn("THREE.Projector: .unprojectVector() is now vector.unproject()."),t.unproject(e)},this.pickingRay=function(){console.error("THREE.Projector: .pickingRay() is now raycaster.setFromCamera().")}}function tl(){console.error("THREE.CanvasRenderer has been moved to /examples/js/renderers/CanvasRenderer.js"),this.domElement=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),this.clear=function(){},this.render=function(){},this.setClearColor=function(){},this.setSize=function(){}}var el={createMultiMaterialObject:function(){console.error("THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js")},detach:function(){console.error("THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js")},attach:function(){console.error("THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js")}};function nl(){console.error("THREE.LensFlare has been moved to /examples/js/objects/Lensflare.js")}},function(t,e,n){t.exports=function t(e,n,i){function r(a,s){if(!n[a]){if(!e[a]){if(o)return o(a,!0);throw new Error("Cannot find module '"+a+"'")}var c=n[a]={exports:{}};e[a][0].call(c.exports,(function(t){var n=e[a][1][t];return r(n||t)}),c,c.exports,t,e,n,i)}return n[a].exports}for(var o=!1,a=0;a<i.length;a++)r(i[a]);return r}({1:[function(t,e,n){e.exports={name:"cannon",version:"0.6.2",description:"A lightweight 3D physics engine written in JavaScript.",homepage:"https://github.com/schteppe/cannon.js",author:"Stefan Hedman <schteppe@gmail.com> (http://steffe.se)",keywords:["cannon.js","cannon","physics","engine","3d"],main:"./build/cannon.js",engines:{node:"*"},repository:{type:"git",url:"https://github.com/schteppe/cannon.js.git"},bugs:{url:"https://github.com/schteppe/cannon.js/issues"},licenses:[{type:"MIT"}],devDependencies:{jshint:"latest","uglify-js":"latest",nodeunit:"^0.9.0",grunt:"~0.4.0","grunt-contrib-jshint":"~0.1.1","grunt-contrib-nodeunit":"^0.4.1","grunt-contrib-concat":"~0.1.3","grunt-contrib-uglify":"^0.5.1","grunt-browserify":"^2.1.4","grunt-contrib-yuidoc":"^0.5.2",browserify:"*"},dependencies:{}}},{}],2:[function(t,e,n){e.exports={version:t("../package.json").version,AABB:t("./collision/AABB"),ArrayCollisionMatrix:t("./collision/ArrayCollisionMatrix"),Body:t("./objects/Body"),Box:t("./shapes/Box"),Broadphase:t("./collision/Broadphase"),Constraint:t("./constraints/Constraint"),ContactEquation:t("./equations/ContactEquation"),Narrowphase:t("./world/Narrowphase"),ConeTwistConstraint:t("./constraints/ConeTwistConstraint"),ContactMaterial:t("./material/ContactMaterial"),ConvexPolyhedron:t("./shapes/ConvexPolyhedron"),Cylinder:t("./shapes/Cylinder"),DistanceConstraint:t("./constraints/DistanceConstraint"),Equation:t("./equations/Equation"),EventTarget:t("./utils/EventTarget"),FrictionEquation:t("./equations/FrictionEquation"),GSSolver:t("./solver/GSSolver"),GridBroadphase:t("./collision/GridBroadphase"),Heightfield:t("./shapes/Heightfield"),HingeConstraint:t("./constraints/HingeConstraint"),LockConstraint:t("./constraints/LockConstraint"),Mat3:t("./math/Mat3"),Material:t("./material/Material"),NaiveBroadphase:t("./collision/NaiveBroadphase"),ObjectCollisionMatrix:t("./collision/ObjectCollisionMatrix"),Pool:t("./utils/Pool"),Particle:t("./shapes/Particle"),Plane:t("./shapes/Plane"),PointToPointConstraint:t("./constraints/PointToPointConstraint"),Quaternion:t("./math/Quaternion"),Ray:t("./collision/Ray"),RaycastVehicle:t("./objects/RaycastVehicle"),RaycastResult:t("./collision/RaycastResult"),RigidVehicle:t("./objects/RigidVehicle"),RotationalEquation:t("./equations/RotationalEquation"),RotationalMotorEquation:t("./equations/RotationalMotorEquation"),SAPBroadphase:t("./collision/SAPBroadphase"),SPHSystem:t("./objects/SPHSystem"),Shape:t("./shapes/Shape"),Solver:t("./solver/Solver"),Sphere:t("./shapes/Sphere"),SplitSolver:t("./solver/SplitSolver"),Spring:t("./objects/Spring"),Trimesh:t("./shapes/Trimesh"),Vec3:t("./math/Vec3"),Vec3Pool:t("./utils/Vec3Pool"),World:t("./world/World")}},{"../package.json":1,"./collision/AABB":3,"./collision/ArrayCollisionMatrix":4,"./collision/Broadphase":5,"./collision/GridBroadphase":6,"./collision/NaiveBroadphase":7,"./collision/ObjectCollisionMatrix":8,"./collision/Ray":9,"./collision/RaycastResult":10,"./collision/SAPBroadphase":11,"./constraints/ConeTwistConstraint":12,"./constraints/Constraint":13,"./constraints/DistanceConstraint":14,"./constraints/HingeConstraint":15,"./constraints/LockConstraint":16,"./constraints/PointToPointConstraint":17,"./equations/ContactEquation":19,"./equations/Equation":20,"./equations/FrictionEquation":21,"./equations/RotationalEquation":22,"./equations/RotationalMotorEquation":23,"./material/ContactMaterial":24,"./material/Material":25,"./math/Mat3":27,"./math/Quaternion":28,"./math/Vec3":30,"./objects/Body":31,"./objects/RaycastVehicle":32,"./objects/RigidVehicle":33,"./objects/SPHSystem":34,"./objects/Spring":35,"./shapes/Box":37,"./shapes/ConvexPolyhedron":38,"./shapes/Cylinder":39,"./shapes/Heightfield":40,"./shapes/Particle":41,"./shapes/Plane":42,"./shapes/Shape":43,"./shapes/Sphere":44,"./shapes/Trimesh":45,"./solver/GSSolver":46,"./solver/Solver":47,"./solver/SplitSolver":48,"./utils/EventTarget":49,"./utils/Pool":51,"./utils/Vec3Pool":54,"./world/Narrowphase":55,"./world/World":56}],3:[function(t,e,n){var i=t("../math/Vec3");function r(t){t=t||{},this.lowerBound=new i,t.lowerBound&&this.lowerBound.copy(t.lowerBound),this.upperBound=new i,t.upperBound&&this.upperBound.copy(t.upperBound)}t("../utils/Utils"),e.exports=r;var o=new i;r.prototype.setFromPoints=function(t,e,n,i){var r=this.lowerBound,a=this.upperBound,s=n;r.copy(t[0]),s&&s.vmult(r,r),a.copy(r);for(var c=1;c<t.length;c++){var h=t[c];s&&(s.vmult(h,o),h=o),h.x>a.x&&(a.x=h.x),h.x<r.x&&(r.x=h.x),h.y>a.y&&(a.y=h.y),h.y<r.y&&(r.y=h.y),h.z>a.z&&(a.z=h.z),h.z<r.z&&(r.z=h.z)}return e&&(e.vadd(r,r),e.vadd(a,a)),i&&(r.x-=i,r.y-=i,r.z-=i,a.x+=i,a.y+=i,a.z+=i),this},r.prototype.copy=function(t){return this.lowerBound.copy(t.lowerBound),this.upperBound.copy(t.upperBound),this},r.prototype.clone=function(){return(new r).copy(this)},r.prototype.extend=function(t){var e=t.lowerBound.x;this.lowerBound.x>e&&(this.lowerBound.x=e);var n=t.upperBound.x;this.upperBound.x<n&&(this.upperBound.x=n),e=t.lowerBound.y,this.lowerBound.y>e&&(this.lowerBound.y=e),n=t.upperBound.y,this.upperBound.y<n&&(this.upperBound.y=n),e=t.lowerBound.z,this.lowerBound.z>e&&(this.lowerBound.z=e),n=t.upperBound.z,this.upperBound.z<n&&(this.upperBound.z=n)},r.prototype.overlaps=function(t){var e=this.lowerBound,n=this.upperBound,i=t.lowerBound,r=t.upperBound;return(i.x<=n.x&&n.x<=r.x||e.x<=r.x&&r.x<=n.x)&&(i.y<=n.y&&n.y<=r.y||e.y<=r.y&&r.y<=n.y)&&(i.z<=n.z&&n.z<=r.z||e.z<=r.z&&r.z<=n.z)},r.prototype.contains=function(t){var e=this.lowerBound,n=this.upperBound,i=t.lowerBound,r=t.upperBound;return e.x<=i.x&&n.x>=r.x&&e.y<=i.y&&n.y>=r.y&&e.z<=i.z&&n.z>=r.z},r.prototype.getCorners=function(t,e,n,i,r,o,a,s){var c=this.lowerBound,h=this.upperBound;t.copy(c),e.set(h.x,c.y,c.z),n.set(h.x,h.y,c.z),i.set(c.x,h.y,h.z),r.set(h.x,c.y,c.z),o.set(c.x,h.y,c.z),a.set(c.x,c.y,h.z),s.copy(h)};var a=[new i,new i,new i,new i,new i,new i,new i,new i];r.prototype.toLocalFrame=function(t,e){var n=a,i=n[0],r=n[1],o=n[2],s=n[3],c=n[4],h=n[5],l=n[6],u=n[7];this.getCorners(i,r,o,s,c,h,l,u);for(var p=0;8!==p;p++){var d=n[p];t.pointToLocal(d,d)}return e.setFromPoints(n)},r.prototype.toWorldFrame=function(t,e){var n=a,i=n[0],r=n[1],o=n[2],s=n[3],c=n[4],h=n[5],l=n[6],u=n[7];this.getCorners(i,r,o,s,c,h,l,u);for(var p=0;8!==p;p++){var d=n[p];t.pointToWorld(d,d)}return e.setFromPoints(n)}},{"../math/Vec3":30,"../utils/Utils":53}],4:[function(t,e,n){function i(){this.matrix=[]}e.exports=i,i.prototype.get=function(t,e){if(t=t.index,(e=e.index)>t){var n=e;e=t,t=n}return this.matrix[(t*(t+1)>>1)+e-1]},i.prototype.set=function(t,e,n){if(t=t.index,(e=e.index)>t){var i=e;e=t,t=i}this.matrix[(t*(t+1)>>1)+e-1]=n?1:0},i.prototype.reset=function(){for(var t=0,e=this.matrix.length;t!==e;t++)this.matrix[t]=0},i.prototype.setNumObjects=function(t){this.matrix.length=t*(t-1)>>1}},{}],5:[function(t,e,n){var i=t("../objects/Body"),r=t("../math/Vec3"),o=t("../math/Quaternion");function a(){this.world=null,this.useBoundingBoxes=!1,this.dirty=!0}t("../shapes/Shape"),t("../shapes/Plane"),e.exports=a,a.prototype.collisionPairs=function(t,e,n){throw new Error("collisionPairs not implemented for this BroadPhase class!")};var s=i.STATIC|i.KINEMATIC;a.prototype.needBroadphaseCollision=function(t,e){return 0!=(t.collisionFilterGroup&e.collisionFilterMask)&&0!=(e.collisionFilterGroup&t.collisionFilterMask)&&(0==(t.type&s)&&t.sleepState!==i.SLEEPING||0==(e.type&s)&&e.sleepState!==i.SLEEPING)},a.prototype.intersectionTest=function(t,e,n,i){this.useBoundingBoxes?this.doBoundingBoxBroadphase(t,e,n,i):this.doBoundingSphereBroadphase(t,e,n,i)};var c=new r;new r,new o,new r,a.prototype.doBoundingSphereBroadphase=function(t,e,n,i){var r=c;e.position.vsub(t.position,r);var o=Math.pow(t.boundingRadius+e.boundingRadius,2);r.norm2()<o&&(n.push(t),i.push(e))},a.prototype.doBoundingBoxBroadphase=function(t,e,n,i){t.aabbNeedsUpdate&&t.computeAABB(),e.aabbNeedsUpdate&&e.computeAABB(),t.aabb.overlaps(e.aabb)&&(n.push(t),i.push(e))};var h={keys:[]},l=[],u=[];a.prototype.makePairsUnique=function(t,e){for(var n=h,i=l,r=u,o=t.length,a=0;a!==o;a++)i[a]=t[a],r[a]=e[a];for(t.length=0,e.length=0,a=0;a!==o;a++){var s=i[a].id,c=r[a].id;n[p=s<c?s+","+c:c+","+s]=a,n.keys.push(p)}for(a=0;a!==n.keys.length;a++){var p=n.keys.pop(),d=n[p];t.push(i[d]),e.push(r[d]),delete n[p]}},a.prototype.setWorld=function(t){};var p=new r;a.boundingSphereCheck=function(t,e){var n=p;return t.position.vsub(e.position,n),Math.pow(t.shape.boundingSphereRadius+e.shape.boundingSphereRadius,2)>n.norm2()},a.prototype.aabbQuery=function(t,e,n){return console.warn(".aabbQuery is not implemented in this Broadphase subclass."),[]}},{"../math/Quaternion":28,"../math/Vec3":30,"../objects/Body":31,"../shapes/Plane":42,"../shapes/Shape":43}],6:[function(t,e,n){e.exports=a;var i=t("./Broadphase"),r=t("../math/Vec3"),o=t("../shapes/Shape");function a(t,e,n,o,a){i.apply(this),this.nx=n||10,this.ny=o||10,this.nz=a||10,this.aabbMin=t||new r(100,100,100),this.aabbMax=e||new r(-100,-100,-100);var s=this.nx*this.ny*this.nz;if(s<=0)throw"GridBroadphase: Each dimension's n must be >0";this.bins=[],this.binLengths=[],this.bins.length=s,this.binLengths.length=s;for(var c=0;c<s;c++)this.bins[c]=[],this.binLengths[c]=0}a.prototype=new i,a.prototype.constructor=a;var s=new r;new r,a.prototype.collisionPairs=function(t,e,n){for(var i=t.numObjects(),r=t.bodies,a=this.aabbMax,c=this.aabbMin,h=this.nx,l=this.ny,u=this.nz,p=l*u,d=u,f=a.x,m=a.y,v=a.z,g=c.x,y=c.y,x=c.z,w=h/(f-g),b=l/(m-y),_=u/(v-x),M=(f-g)/h,E=(m-y)/l,S=(v-x)/u,T=.5*Math.sqrt(M*M+E*E+S*S),A=o.types,R=A.SPHERE,C=A.PLANE,L=(A.BOX,A.COMPOUND,A.CONVEXPOLYHEDRON,this.bins),P=this.binLengths,B=this.bins.length,I=0;I!==B;I++)P[I]=0;var N=Math.ceil;function O(t,e,n,i,r,o,a){var s=(t-g)*w|0,c=(e-y)*b|0,f=(n-x)*_|0,m=N((i-g)*w),v=N((r-y)*b),M=N((o-x)*_);s<0?s=0:s>=h&&(s=h-1),c<0?c=0:c>=l&&(c=l-1),f<0?f=0:f>=u&&(f=u-1),m<0?m=0:m>=h&&(m=h-1),v<0?v=0:v>=l&&(v=l-1),M<0?M=0:M>=u&&(M=u-1),c*=d,f*=1,m*=p,v*=d,M*=1;for(var E=s*=p;E<=m;E+=p)for(var S=c;S<=v;S+=d)for(var T=f;T<=M;T+=1){var A=E+S+T;L[A][P[A]++]=a}}for(c=Math.min,a=Math.max,I=0;I!==i;I++){var F=(et=r[I]).shape;switch(F.type){case R:var z=et.position.x,D=et.position.y,U=et.position.z,V=F.radius;O(z-V,D-V,U-V,z+V,D+V,U+V,et);break;case C:F.worldNormalNeedsUpdate&&F.computeWorldNormal(et.quaternion);var G=F.worldNormal,H=g+.5*M-et.position.x,j=y+.5*E-et.position.y,k=x+.5*S-et.position.z,W=s;W.set(H,j,k);for(var q=0,X=0;q!==h;q++,X+=p,W.y=j,W.x+=M)for(var Y=0,Z=0;Y!==l;Y++,Z+=d,W.z=k,W.y+=E)for(var J=0,Q=0;J!==u;J++,Q+=1,W.z+=S)if(W.dot(G)<T){var K=X+Z+Q;L[K][P[K]++]=et}break;default:et.aabbNeedsUpdate&&et.computeAABB(),O(et.aabb.lowerBound.x,et.aabb.lowerBound.y,et.aabb.lowerBound.z,et.aabb.upperBound.x,et.aabb.upperBound.y,et.aabb.upperBound.z,et)}}for(I=0;I!==B;I++){var $=P[I];if($>1){var tt=L[I];for(q=0;q!==$;q++){var et=tt[q];for(Y=0;Y!==q;Y++){var nt=tt[Y];this.needBroadphaseCollision(et,nt)&&this.intersectionTest(et,nt,e,n)}}}}this.makePairsUnique(e,n)}},{"../math/Vec3":30,"../shapes/Shape":43,"./Broadphase":5}],7:[function(t,e,n){e.exports=o;var i=t("./Broadphase"),r=t("./AABB");function o(){i.apply(this)}o.prototype=new i,o.prototype.constructor=o,o.prototype.collisionPairs=function(t,e,n){var i,r,o,a,s=t.bodies,c=s.length;for(i=0;i!==c;i++)for(r=0;r!==i;r++)o=s[i],a=s[r],this.needBroadphaseCollision(o,a)&&this.intersectionTest(o,a,e,n)},new r,o.prototype.aabbQuery=function(t,e,n){n=n||[];for(var i=0;i<t.bodies.length;i++){var r=t.bodies[i];r.aabbNeedsUpdate&&r.computeAABB(),r.aabb.overlaps(e)&&n.push(r)}return n}},{"./AABB":3,"./Broadphase":5}],8:[function(t,e,n){function i(){this.matrix={}}e.exports=i,i.prototype.get=function(t,e){if(t=t.id,(e=e.id)>t){var n=e;e=t,t=n}return t+"-"+e in this.matrix},i.prototype.set=function(t,e,n){if(t=t.id,(e=e.id)>t){var i=e;e=t,t=i}n?this.matrix[t+"-"+e]=!0:delete this.matrix[t+"-"+e]},i.prototype.reset=function(){this.matrix={}},i.prototype.setNumObjects=function(t){}},{}],9:[function(t,e,n){e.exports=h;var i=t("../math/Vec3"),r=t("../math/Quaternion"),o=t("../math/Transform"),a=(t("../shapes/ConvexPolyhedron"),t("../shapes/Box"),t("../collision/RaycastResult")),s=t("../shapes/Shape"),c=t("../collision/AABB");function h(t,e){this.from=t?t.clone():new i,this.to=e?e.clone():new i,this._direction=new i,this.precision=1e-4,this.checkCollisionResponse=!0,this.skipBackfaces=!1,this.collisionFilterMask=-1,this.collisionFilterGroup=-1,this.mode=h.ANY,this.result=new a,this.hasHit=!1,this.callback=function(t){}}h.prototype.constructor=h,h.CLOSEST=1,h.ANY=2,h.ALL=4;var l=new c,u=[];h.prototype.intersectWorld=function(t,e){return this.mode=e.mode||h.ANY,this.result=e.result||new a,this.skipBackfaces=!!e.skipBackfaces,this.collisionFilterMask=void 0!==e.collisionFilterMask?e.collisionFilterMask:-1,this.collisionFilterGroup=void 0!==e.collisionFilterGroup?e.collisionFilterGroup:-1,e.from&&this.from.copy(e.from),e.to&&this.to.copy(e.to),this.callback=e.callback||function(){},this.hasHit=!1,this.result.reset(),this._updateDirection(),this.getAABB(l),u.length=0,t.broadphase.aabbQuery(t,l,u),this.intersectBodies(u),this.hasHit};var p=new i,d=new i;function f(t,e,n,i){i.vsub(e,N),n.vsub(e,p),t.vsub(e,d);var r,o,a=N.dot(N),s=N.dot(p),c=N.dot(d),h=p.dot(p),l=p.dot(d);return(r=h*c-s*l)>=0&&(o=a*l-s*c)>=0&&r+o<a*h-s*s}h.pointInTriangle=f;var m=new i,v=new r;h.prototype.intersectBody=function(t,e){e&&(this.result=e,this._updateDirection());var n=this.checkCollisionResponse;if((!n||t.collisionResponse)&&0!=(this.collisionFilterGroup&t.collisionFilterMask)&&0!=(t.collisionFilterGroup&this.collisionFilterMask))for(var i=m,r=v,o=0,a=t.shapes.length;o<a;o++){var s=t.shapes[o];if((!n||s.collisionResponse)&&(t.quaternion.mult(t.shapeOrientations[o],r),t.quaternion.vmult(t.shapeOffsets[o],i),i.vadd(t.position,i),this.intersectShape(s,r,i,t),this.result._shouldStop))break}},h.prototype.intersectBodies=function(t,e){e&&(this.result=e,this._updateDirection());for(var n=0,i=t.length;!this.result._shouldStop&&n<i;n++)this.intersectBody(t[n])},h.prototype._updateDirection=function(){this.to.vsub(this.from,this._direction),this._direction.normalize()},h.prototype.intersectShape=function(t,e,n,i){if(!(function(t,e,n){n.vsub(t,N);var i=N.dot(e);return e.mult(i,O),O.vadd(t,O),n.distanceTo(O)}(this.from,this._direction,n)>t.boundingSphereRadius)){var r=this[t.type];r&&r.call(this,t,e,n,i)}},new i,new i;var g=new i,y=new i,x=new i,w=new i;new i,new a,h.prototype.intersectBox=function(t,e,n,i){return this.intersectConvex(t.convexPolyhedronRepresentation,e,n,i)},h.prototype[s.types.BOX]=h.prototype.intersectBox,h.prototype.intersectPlane=function(t,e,n,r){var o=this.from,a=this.to,s=this._direction,c=new i(0,0,1);e.vmult(c,c);var h=new i;o.vsub(n,h);var l=h.dot(c);if(a.vsub(n,h),!(l*h.dot(c)>0||o.distanceTo(a)<l)){var u=c.dot(s);if(!(Math.abs(u)<this.precision)){var p=new i,d=new i,f=new i;o.vsub(n,p);var m=-c.dot(p)/u;s.scale(m,d),o.vadd(d,f),this.reportIntersection(c,f,t,r,-1)}}},h.prototype[s.types.PLANE]=h.prototype.intersectPlane,h.prototype.getAABB=function(t){var e=this.to,n=this.from;t.lowerBound.x=Math.min(e.x,n.x),t.lowerBound.y=Math.min(e.y,n.y),t.lowerBound.z=Math.min(e.z,n.z),t.upperBound.x=Math.max(e.x,n.x),t.upperBound.y=Math.max(e.y,n.y),t.upperBound.z=Math.max(e.z,n.z)};var b={faceList:[0]};h.prototype.intersectHeightfield=function(t,e,n,r){t.data,t.elementSize;var a=new i,s=new h(this.from,this.to);o.pointToLocalFrame(n,e,s.from,s.from),o.pointToLocalFrame(n,e,s.to,s.to);var c=[],l=null,u=null,p=null,d=null,f=t.getIndexOfPosition(s.from.x,s.from.y,c,!1);if(f&&(l=c[0],u=c[1],p=c[0],d=c[1]),(f=t.getIndexOfPosition(s.to.x,s.to.y,c,!1))&&((null===l||c[0]<l)&&(l=c[0]),(null===p||c[0]>p)&&(p=c[0]),(null===u||c[1]<u)&&(u=c[1]),(null===d||c[1]>d)&&(d=c[1])),null!==l){var m=[];t.getRectMinMax(l,u,p,d,m);for(var v=l;v<=p;v++)for(var g=u;g<=d;g++){if(this.result._shouldStop)return;if(t.getConvexTrianglePillar(v,g,!1),o.pointToWorldFrame(n,e,t.pillarOffset,a),this.intersectConvex(t.pillarConvex,e,a,r,b),this.result._shouldStop)return;t.getConvexTrianglePillar(v,g,!0),o.pointToWorldFrame(n,e,t.pillarOffset,a),this.intersectConvex(t.pillarConvex,e,a,r,b)}}},h.prototype[s.types.HEIGHTFIELD]=h.prototype.intersectHeightfield;var _=new i,M=new i;h.prototype.intersectSphere=function(t,e,n,i){var r=this.from,o=this.to,a=t.radius,s=Math.pow(o.x-r.x,2)+Math.pow(o.y-r.y,2)+Math.pow(o.z-r.z,2),c=2*((o.x-r.x)*(r.x-n.x)+(o.y-r.y)*(r.y-n.y)+(o.z-r.z)*(r.z-n.z)),h=Math.pow(r.x-n.x,2)+Math.pow(r.y-n.y,2)+Math.pow(r.z-n.z,2)-Math.pow(a,2),l=Math.pow(c,2)-4*s*h,u=_,p=M;if(!(l<0))if(0===l)r.lerp(o,l,u),u.vsub(n,p),p.normalize(),this.reportIntersection(p,u,t,i,-1);else{var d=(-c-Math.sqrt(l))/(2*s),f=(-c+Math.sqrt(l))/(2*s);if(d>=0&&d<=1&&(r.lerp(o,d,u),u.vsub(n,p),p.normalize(),this.reportIntersection(p,u,t,i,-1)),this.result._shouldStop)return;f>=0&&f<=1&&(r.lerp(o,f,u),u.vsub(n,p),p.normalize(),this.reportIntersection(p,u,t,i,-1))}},h.prototype[s.types.SPHERE]=h.prototype.intersectSphere;var E=new i,S=(new i,new i,new i);h.prototype.intersectConvex=function(t,e,n,i,r){for(var o=E,a=S,s=r&&r.faceList||null,c=t.faces,h=t.vertices,l=t.faceNormals,u=this._direction,p=this.from,d=this.to,m=p.distanceTo(d),v=s?s.length:c.length,b=this.result,_=0;!b._shouldStop&&_<v;_++){var M=s?s[_]:_,T=c[M],A=l[M],R=e,C=n;a.copy(h[T[0]]),R.vmult(a,a),a.vadd(C,a),a.vsub(p,a),R.vmult(A,o);var L=u.dot(o);if(!(Math.abs(L)<this.precision)){var P=o.dot(a)/L;if(!(P<0)){u.mult(P,g),g.vadd(p,g),y.copy(h[T[0]]),R.vmult(y,y),C.vadd(y,y);for(var B=1;!b._shouldStop&&B<T.length-1;B++){x.copy(h[T[B]]),w.copy(h[T[B+1]]),R.vmult(x,x),R.vmult(w,w),C.vadd(x,x),C.vadd(w,w);var I=g.distanceTo(p);!f(g,y,x,w)&&!f(g,x,y,w)||I>m||this.reportIntersection(o,g,t,i,M)}}}}},h.prototype[s.types.CONVEXPOLYHEDRON]=h.prototype.intersectConvex;var T=new i,A=new i,R=new i,C=new i,L=new i,P=new i,B=(new c,[]),I=new o;h.prototype.intersectTrimesh=function(t,e,n,i,r){var a=T,s=B,c=I,h=S,l=A,u=R,p=C,d=P,m=L,v=(r&&r.faceList,t.indices),b=(t.vertices,t.faceNormals,this.from),_=this.to,M=this._direction;c.position.copy(n),c.quaternion.copy(e),o.vectorToLocalFrame(n,e,M,l),o.pointToLocalFrame(n,e,b,u),o.pointToLocalFrame(n,e,_,p);var E=u.distanceSquared(p);t.tree.rayQuery(this,c,s);for(var N=0,O=s.length;!this.result._shouldStop&&N!==O;N++){var F=s[N];t.getNormal(F,a),t.getVertex(v[3*F],y),y.vsub(u,h);var z=l.dot(a),D=a.dot(h)/z;if(!(D<0)){l.scale(D,g),g.vadd(u,g),t.getVertex(v[3*F+1],x),t.getVertex(v[3*F+2],w);var U=g.distanceSquared(u);!f(g,x,y,w)&&!f(g,y,x,w)||U>E||(o.vectorToWorldFrame(e,a,m),o.pointToWorldFrame(n,e,g,d),this.reportIntersection(m,d,t,i,F))}}s.length=0},h.prototype[s.types.TRIMESH]=h.prototype.intersectTrimesh,h.prototype.reportIntersection=function(t,e,n,i,r){var o=this.from,a=this.to,s=o.distanceTo(e),c=this.result;if(!(this.skipBackfaces&&t.dot(this._direction)>0))switch(c.hitFaceIndex=void 0!==r?r:-1,this.mode){case h.ALL:this.hasHit=!0,c.set(o,a,t,e,n,i,s),c.hasHit=!0,this.callback(c);break;case h.CLOSEST:(s<c.distance||!c.hasHit)&&(this.hasHit=!0,c.hasHit=!0,c.set(o,a,t,e,n,i,s));break;case h.ANY:this.hasHit=!0,c.hasHit=!0,c.set(o,a,t,e,n,i,s),c._shouldStop=!0}};var N=new i,O=new i},{"../collision/AABB":3,"../collision/RaycastResult":10,"../math/Quaternion":28,"../math/Transform":29,"../math/Vec3":30,"../shapes/Box":37,"../shapes/ConvexPolyhedron":38,"../shapes/Shape":43}],10:[function(t,e,n){var i=t("../math/Vec3");function r(){this.rayFromWorld=new i,this.rayToWorld=new i,this.hitNormalWorld=new i,this.hitPointWorld=new i,this.hasHit=!1,this.shape=null,this.body=null,this.hitFaceIndex=-1,this.distance=-1,this._shouldStop=!1}e.exports=r,r.prototype.reset=function(){this.rayFromWorld.setZero(),this.rayToWorld.setZero(),this.hitNormalWorld.setZero(),this.hitPointWorld.setZero(),this.hasHit=!1,this.shape=null,this.body=null,this.hitFaceIndex=-1,this.distance=-1,this._shouldStop=!1},r.prototype.abort=function(){this._shouldStop=!0},r.prototype.set=function(t,e,n,i,r,o,a){this.rayFromWorld.copy(t),this.rayToWorld.copy(e),this.hitNormalWorld.copy(n),this.hitPointWorld.copy(i),this.shape=r,this.body=o,this.distance=a}},{"../math/Vec3":30}],11:[function(t,e,n){t("../shapes/Shape");var i=t("../collision/Broadphase");function r(t){i.apply(this),this.axisList=[],this.world=null,this.axisIndex=0;var e=this.axisList;this._addBodyHandler=function(t){e.push(t.body)},this._removeBodyHandler=function(t){var n=e.indexOf(t.body);-1!==n&&e.splice(n,1)},t&&this.setWorld(t)}e.exports=r,r.prototype=new i,r.prototype.setWorld=function(t){this.axisList.length=0;for(var e=0;e<t.bodies.length;e++)this.axisList.push(t.bodies[e]);t.removeEventListener("addBody",this._addBodyHandler),t.removeEventListener("removeBody",this._removeBodyHandler),t.addEventListener("addBody",this._addBodyHandler),t.addEventListener("removeBody",this._removeBodyHandler),this.world=t,this.dirty=!0},r.insertionSortX=function(t){for(var e=1,n=t.length;e<n;e++){for(var i=t[e],r=e-1;r>=0&&!(t[r].aabb.lowerBound.x<=i.aabb.lowerBound.x);r--)t[r+1]=t[r];t[r+1]=i}return t},r.insertionSortY=function(t){for(var e=1,n=t.length;e<n;e++){for(var i=t[e],r=e-1;r>=0&&!(t[r].aabb.lowerBound.y<=i.aabb.lowerBound.y);r--)t[r+1]=t[r];t[r+1]=i}return t},r.insertionSortZ=function(t){for(var e=1,n=t.length;e<n;e++){for(var i=t[e],r=e-1;r>=0&&!(t[r].aabb.lowerBound.z<=i.aabb.lowerBound.z);r--)t[r+1]=t[r];t[r+1]=i}return t},r.prototype.collisionPairs=function(t,e,n){var i,o,a=this.axisList,s=a.length,c=this.axisIndex;for(this.dirty&&(this.sortList(),this.dirty=!1),i=0;i!==s;i++){var h=a[i];for(o=i+1;o<s;o++){var l=a[o];if(this.needBroadphaseCollision(h,l)){if(!r.checkBounds(h,l,c))break;this.intersectionTest(h,l,e,n)}}}},r.prototype.sortList=function(){for(var t=this.axisList,e=this.axisIndex,n=t.length,i=0;i!==n;i++){var o=t[i];o.aabbNeedsUpdate&&o.computeAABB()}0===e?r.insertionSortX(t):1===e?r.insertionSortY(t):2===e&&r.insertionSortZ(t)},r.checkBounds=function(t,e,n){var i,r;0===n?(i=t.position.x,r=e.position.x):1===n?(i=t.position.y,r=e.position.y):2===n&&(i=t.position.z,r=e.position.z);var o=t.boundingRadius,a=e.boundingRadius;return r-a<i+o},r.prototype.autoDetectAxis=function(){for(var t=0,e=0,n=0,i=0,r=0,o=0,a=this.axisList,s=a.length,c=1/s,h=0;h!==s;h++){var l=a[h],u=l.position.x;t+=u,e+=u*u;var p=l.position.y;n+=p,i+=p*p;var d=l.position.z;r+=d,o+=d*d}var f=e-t*t*c,m=i-n*n*c,v=o-r*r*c;this.axisIndex=f>m?f>v?0:2:m>v?1:2},r.prototype.aabbQuery=function(t,e,n){n=n||[],this.dirty&&(this.sortList(),this.dirty=!1);var i=this.axisIndex,r="x";1===i&&(r="y"),2===i&&(r="z");for(var o=this.axisList,a=(e.lowerBound[r],e.upperBound[r],0);a<o.length;a++){var s=o[a];s.aabbNeedsUpdate&&s.computeAABB(),s.aabb.overlaps(e)&&n.push(s)}return n}},{"../collision/Broadphase":5,"../shapes/Shape":43}],12:[function(t,e,n){e.exports=s,t("./Constraint");var i=t("./PointToPointConstraint"),r=t("../equations/ConeEquation"),o=t("../equations/RotationalEquation"),a=(t("../equations/ContactEquation"),t("../math/Vec3"));function s(t,e,n){var s=void 0!==(n=n||{}).maxForce?n.maxForce:1e6,c=n.pivotA?n.pivotA.clone():new a,h=n.pivotB?n.pivotB.clone():new a;this.axisA=n.axisA?n.axisA.clone():new a,this.axisB=n.axisB?n.axisB.clone():new a,i.call(this,t,c,e,h,s),this.collideConnected=!!n.collideConnected,this.angle=void 0!==n.angle?n.angle:0;var l=this.coneEquation=new r(t,e,n),u=this.twistEquation=new o(t,e,n);this.twistAngle=void 0!==n.twistAngle?n.twistAngle:0,l.maxForce=0,l.minForce=-s,u.maxForce=0,u.minForce=-s,this.equations.push(l,u)}s.prototype=new i,s.constructor=s,new a,new a,s.prototype.update=function(){var t=this.bodyA,e=this.bodyB,n=this.coneEquation,r=this.twistEquation;i.prototype.update.call(this),t.vectorToWorldFrame(this.axisA,n.axisA),e.vectorToWorldFrame(this.axisB,n.axisB),this.axisA.tangents(r.axisA,r.axisA),t.vectorToWorldFrame(r.axisA,r.axisA),this.axisB.tangents(r.axisB,r.axisB),e.vectorToWorldFrame(r.axisB,r.axisB),n.angle=this.angle,r.maxAngle=this.twistAngle}},{"../equations/ConeEquation":18,"../equations/ContactEquation":19,"../equations/RotationalEquation":22,"../math/Vec3":30,"./Constraint":13,"./PointToPointConstraint":17}],13:[function(t,e,n){e.exports=r;var i=t("../utils/Utils");function r(t,e,n){n=i.defaults(n,{collideConnected:!0,wakeUpBodies:!0}),this.equations=[],this.bodyA=t,this.bodyB=e,this.id=r.idCounter++,this.collideConnected=n.collideConnected,n.wakeUpBodies&&(t&&t.wakeUp(),e&&e.wakeUp())}r.prototype.update=function(){throw new Error("method update() not implmemented in this Constraint subclass!")},r.prototype.enable=function(){for(var t=this.equations,e=0;e<t.length;e++)t[e].enabled=!0},r.prototype.disable=function(){for(var t=this.equations,e=0;e<t.length;e++)t[e].enabled=!1},r.idCounter=0},{"../utils/Utils":53}],14:[function(t,e,n){e.exports=o;var i=t("./Constraint"),r=t("../equations/ContactEquation");function o(t,e,n,o){i.call(this,t,e),void 0===n&&(n=t.position.distanceTo(e.position)),void 0===o&&(o=1e6),this.distance=n;var a=this.distanceEquation=new r(t,e);this.equations.push(a),a.minForce=-o,a.maxForce=o}o.prototype=new i,o.prototype.update=function(){var t=this.bodyA,e=this.bodyB,n=this.distanceEquation,i=.5*this.distance,r=n.ni;e.position.vsub(t.position,r),r.normalize(),r.mult(i,n.ri),r.mult(-i,n.rj)}},{"../equations/ContactEquation":19,"./Constraint":13}],15:[function(t,e,n){e.exports=s,t("./Constraint");var i=t("./PointToPointConstraint"),r=t("../equations/RotationalEquation"),o=t("../equations/RotationalMotorEquation"),a=(t("../equations/ContactEquation"),t("../math/Vec3"));function s(t,e,n){var s=void 0!==(n=n||{}).maxForce?n.maxForce:1e6,c=n.pivotA?n.pivotA.clone():new a,h=n.pivotB?n.pivotB.clone():new a;i.call(this,t,c,e,h,s),(this.axisA=n.axisA?n.axisA.clone():new a(1,0,0)).normalize(),(this.axisB=n.axisB?n.axisB.clone():new a(1,0,0)).normalize();var l=this.rotationalEquation1=new r(t,e,n),u=this.rotationalEquation2=new r(t,e,n),p=this.motorEquation=new o(t,e,s);p.enabled=!1,this.equations.push(l,u,p)}s.prototype=new i,s.constructor=s,s.prototype.enableMotor=function(){this.motorEquation.enabled=!0},s.prototype.disableMotor=function(){this.motorEquation.enabled=!1},s.prototype.setMotorSpeed=function(t){this.motorEquation.targetVelocity=t},s.prototype.setMotorMaxForce=function(t){this.motorEquation.maxForce=t,this.motorEquation.minForce=-t};var c=new a,h=new a;s.prototype.update=function(){var t=this.bodyA,e=this.bodyB,n=this.motorEquation,r=this.rotationalEquation1,o=this.rotationalEquation2,a=c,s=h,l=this.axisA,u=this.axisB;i.prototype.update.call(this),t.quaternion.vmult(l,a),e.quaternion.vmult(u,s),a.tangents(r.axisA,o.axisA),r.axisB.copy(s),o.axisB.copy(s),this.motorEquation.enabled&&(t.quaternion.vmult(this.axisA,n.axisA),e.quaternion.vmult(this.axisB,n.axisB))}},{"../equations/ContactEquation":19,"../equations/RotationalEquation":22,"../equations/RotationalMotorEquation":23,"../math/Vec3":30,"./Constraint":13,"./PointToPointConstraint":17}],16:[function(t,e,n){e.exports=a,t("./Constraint");var i=t("./PointToPointConstraint"),r=t("../equations/RotationalEquation"),o=(t("../equations/RotationalMotorEquation"),t("../equations/ContactEquation"),t("../math/Vec3"));function a(t,e,n){var a=void 0!==(n=n||{}).maxForce?n.maxForce:1e6,s=new o,c=new o,h=new o;t.position.vadd(e.position,h),h.scale(.5,h),e.pointToLocalFrame(h,c),t.pointToLocalFrame(h,s),i.call(this,t,s,e,c,a);var l=this.rotationalEquation1=new r(t,e,n),u=this.rotationalEquation2=new r(t,e,n),p=this.rotationalEquation3=new r(t,e,n);this.equations.push(l,u,p)}a.prototype=new i,a.constructor=a,new o,new o,a.prototype.update=function(){var t=this.bodyA,e=this.bodyB,n=(this.motorEquation,this.rotationalEquation1),r=this.rotationalEquation2,a=this.rotationalEquation3;i.prototype.update.call(this),t.vectorToWorldFrame(o.UNIT_X,n.axisA),e.vectorToWorldFrame(o.UNIT_Y,n.axisB),t.vectorToWorldFrame(o.UNIT_Y,r.axisA),e.vectorToWorldFrame(o.UNIT_Z,r.axisB),t.vectorToWorldFrame(o.UNIT_Z,a.axisA),e.vectorToWorldFrame(o.UNIT_X,a.axisB)}},{"../equations/ContactEquation":19,"../equations/RotationalEquation":22,"../equations/RotationalMotorEquation":23,"../math/Vec3":30,"./Constraint":13,"./PointToPointConstraint":17}],17:[function(t,e,n){e.exports=a;var i=t("./Constraint"),r=t("../equations/ContactEquation"),o=t("../math/Vec3");function a(t,e,n,a,s){i.call(this,t,n),s=void 0!==s?s:1e6,this.pivotA=e?e.clone():new o,this.pivotB=a?a.clone():new o;var c=this.equationX=new r(t,n),h=this.equationY=new r(t,n),l=this.equationZ=new r(t,n);this.equations.push(c,h,l),c.minForce=h.minForce=l.minForce=-s,c.maxForce=h.maxForce=l.maxForce=s,c.ni.set(1,0,0),h.ni.set(0,1,0),l.ni.set(0,0,1)}a.prototype=new i,a.prototype.update=function(){var t=this.bodyA,e=this.bodyB,n=this.equationX,i=this.equationY,r=this.equationZ;t.quaternion.vmult(this.pivotA,n.ri),e.quaternion.vmult(this.pivotB,n.rj),i.ri.copy(n.ri),i.rj.copy(n.rj),r.ri.copy(n.ri),r.rj.copy(n.rj)}},{"../equations/ContactEquation":19,"../math/Vec3":30,"./Constraint":13}],18:[function(t,e,n){e.exports=o;var i=t("../math/Vec3"),r=(t("../math/Mat3"),t("./Equation"));function o(t,e,n){var o=void 0!==(n=n||{}).maxForce?n.maxForce:1e6;r.call(this,t,e,-o,o),this.axisA=n.axisA?n.axisA.clone():new i(1,0,0),this.axisB=n.axisB?n.axisB.clone():new i(0,1,0),this.angle=void 0!==n.angle?n.angle:0}o.prototype=new r,o.prototype.constructor=o;var a=new i,s=new i;o.prototype.computeB=function(t){var e=this.a,n=this.b,i=this.axisA,r=this.axisB,o=a,c=s,h=this.jacobianElementA,l=this.jacobianElementB;return i.cross(r,o),r.cross(i,c),h.rotational.copy(c),l.rotational.copy(o),-(Math.cos(this.angle)-i.dot(r))*e-this.computeGW()*n-t*this.computeGiMf()}},{"../math/Mat3":27,"../math/Vec3":30,"./Equation":20}],19:[function(t,e,n){e.exports=o;var i=t("./Equation"),r=t("../math/Vec3");function o(t,e,n){n=void 0!==n?n:1e6,i.call(this,t,e,0,n),this.restitution=0,this.ri=new r,this.rj=new r,this.ni=new r}t("../math/Mat3"),o.prototype=new i,o.prototype.constructor=o;var a=new r,s=new r,c=new r;o.prototype.computeB=function(t){var e=this.a,n=this.b,i=this.bi,r=this.bj,o=this.ri,h=this.rj,l=a,u=s,p=i.velocity,d=i.angularVelocity,f=(i.force,i.torque,r.velocity),m=r.angularVelocity,v=(r.force,r.torque,c),g=this.jacobianElementA,y=this.jacobianElementB,x=this.ni;o.cross(x,l),h.cross(x,u),x.negate(g.spatial),l.negate(g.rotational),y.spatial.copy(x),y.rotational.copy(u),v.copy(r.position),v.vadd(h,v),v.vsub(i.position,v),v.vsub(o,v);var w=x.dot(v),b=this.restitution+1;return-w*e-(b*f.dot(x)-b*p.dot(x)+m.dot(u)-d.dot(l))*n-t*this.computeGiMf()};var h=new r,l=new r,u=new r,p=new r,d=new r;o.prototype.getImpactVelocityAlongNormal=function(){var t=h,e=l,n=u,i=p,r=d;return this.bi.position.vadd(this.ri,n),this.bj.position.vadd(this.rj,i),this.bi.getVelocityAtWorldPoint(n,t),this.bj.getVelocityAtWorldPoint(i,e),t.vsub(e,r),this.ni.dot(r)}},{"../math/Mat3":27,"../math/Vec3":30,"./Equation":20}],20:[function(t,e,n){e.exports=o;var i=t("../math/JacobianElement"),r=t("../math/Vec3");function o(t,e,n,r){this.id=o.id++,this.minForce=void 0===n?-1e6:n,this.maxForce=void 0===r?1e6:r,this.bi=t,this.bj=e,this.a=0,this.b=0,this.eps=0,this.jacobianElementA=new i,this.jacobianElementB=new i,this.enabled=!0,this.setSpookParams(1e7,4,1/60)}o.prototype.constructor=o,o.id=0,o.prototype.setSpookParams=function(t,e,n){var i=e,r=t,o=n;this.a=4/(o*(1+4*i)),this.b=4*i/(1+4*i),this.eps=4/(o*o*r*(1+4*i))},o.prototype.computeB=function(t,e,n){var i=this.computeGW();return-this.computeGq()*t-i*e-this.computeGiMf()*n},o.prototype.computeGq=function(){var t=this.jacobianElementA,e=this.jacobianElementB,n=this.bi,i=this.bj,r=n.position,o=i.position;return t.spatial.dot(r)+e.spatial.dot(o)};var a=new r;o.prototype.computeGW=function(){var t=this.jacobianElementA,e=this.jacobianElementB,n=this.bi,i=this.bj,r=n.velocity,o=i.velocity,s=n.angularVelocity||a,c=i.angularVelocity||a;return t.multiplyVectors(r,s)+e.multiplyVectors(o,c)},o.prototype.computeGWlambda=function(){var t=this.jacobianElementA,e=this.jacobianElementB,n=this.bi,i=this.bj,r=n.vlambda,o=i.vlambda,s=n.wlambda||a,c=i.wlambda||a;return t.multiplyVectors(r,s)+e.multiplyVectors(o,c)};var s=new r,c=new r,h=new r,l=new r;o.prototype.computeGiMf=function(){var t=this.jacobianElementA,e=this.jacobianElementB,n=this.bi,i=this.bj,r=n.force,o=n.torque,a=i.force,u=i.torque,p=n.invMassSolve,d=i.invMassSolve;return n.invInertiaWorldSolve?n.invInertiaWorldSolve.vmult(o,h):h.set(0,0,0),i.invInertiaWorldSolve?i.invInertiaWorldSolve.vmult(u,l):l.set(0,0,0),r.mult(p,s),a.mult(d,c),t.multiplyVectors(s,h)+e.multiplyVectors(c,l)};var u=new r;o.prototype.computeGiMGt=function(){var t=this.jacobianElementA,e=this.jacobianElementB,n=this.bi,i=this.bj,r=n.invMassSolve,o=i.invMassSolve,a=n.invInertiaWorldSolve,s=i.invInertiaWorldSolve,c=r+o;return a&&(a.vmult(t.rotational,u),c+=u.dot(t.rotational)),s&&(s.vmult(e.rotational,u),c+=u.dot(e.rotational)),c};var p=new r;new r,new r,new r,new r,new r,o.prototype.addToWlambda=function(t){var e=this.jacobianElementA,n=this.jacobianElementB,i=this.bi,r=this.bj,o=p;e.spatial.mult(i.invMassSolve*t,o),i.vlambda.vadd(o,i.vlambda),n.spatial.mult(r.invMassSolve*t,o),r.vlambda.vadd(o,r.vlambda),i.invInertiaWorldSolve&&(i.invInertiaWorldSolve.vmult(e.rotational,o),o.mult(t,o),i.wlambda.vadd(o,i.wlambda)),r.invInertiaWorldSolve&&(r.invInertiaWorldSolve.vmult(n.rotational,o),o.mult(t,o),r.wlambda.vadd(o,r.wlambda))},o.prototype.computeC=function(){return this.computeGiMGt()+this.eps}},{"../math/JacobianElement":26,"../math/Vec3":30}],21:[function(t,e,n){e.exports=o;var i=t("./Equation"),r=t("../math/Vec3");function o(t,e,n){i.call(this,t,e,-n,n),this.ri=new r,this.rj=new r,this.t=new r}t("../math/Mat3"),o.prototype=new i,o.prototype.constructor=o;var a=new r,s=new r;o.prototype.computeB=function(t){this.a;var e=this.b,n=(this.bi,this.bj,this.ri),i=this.rj,r=a,o=s,c=this.t;n.cross(c,r),i.cross(c,o);var h=this.jacobianElementA,l=this.jacobianElementB;return c.negate(h.spatial),r.negate(h.rotational),l.spatial.copy(c),l.rotational.copy(o),-this.computeGW()*e-t*this.computeGiMf()}},{"../math/Mat3":27,"../math/Vec3":30,"./Equation":20}],22:[function(t,e,n){e.exports=o;var i=t("../math/Vec3"),r=(t("../math/Mat3"),t("./Equation"));function o(t,e,n){var o=void 0!==(n=n||{}).maxForce?n.maxForce:1e6;r.call(this,t,e,-o,o),this.axisA=n.axisA?n.axisA.clone():new i(1,0,0),this.axisB=n.axisB?n.axisB.clone():new i(0,1,0),this.maxAngle=Math.PI/2}o.prototype=new r,o.prototype.constructor=o;var a=new i,s=new i;o.prototype.computeB=function(t){var e=this.a,n=this.b,i=this.axisA,r=this.axisB,o=a,c=s,h=this.jacobianElementA,l=this.jacobianElementB;return i.cross(r,o),r.cross(i,c),h.rotational.copy(c),l.rotational.copy(o),-(Math.cos(this.maxAngle)-i.dot(r))*e-this.computeGW()*n-t*this.computeGiMf()}},{"../math/Mat3":27,"../math/Vec3":30,"./Equation":20}],23:[function(t,e,n){e.exports=o;var i=t("../math/Vec3"),r=(t("../math/Mat3"),t("./Equation"));function o(t,e,n){n=void 0!==n?n:1e6,r.call(this,t,e,-n,n),this.axisA=new i,this.axisB=new i,this.targetVelocity=0}o.prototype=new r,o.prototype.constructor=o,o.prototype.computeB=function(t){this.a;var e=this.b,n=(this.bi,this.bj,this.axisA),i=this.axisB,r=this.jacobianElementA,o=this.jacobianElementB;return r.rotational.copy(n),i.negate(o.rotational),-(this.computeGW()-this.targetVelocity)*e-t*this.computeGiMf()}},{"../math/Mat3":27,"../math/Vec3":30,"./Equation":20}],24:[function(t,e,n){var i=t("../utils/Utils");function r(t,e,n){n=i.defaults(n,{friction:.3,restitution:.3,contactEquationStiffness:1e7,contactEquationRelaxation:3,frictionEquationStiffness:1e7,frictionEquationRelaxation:3}),this.id=r.idCounter++,this.materials=[t,e],this.friction=n.friction,this.restitution=n.restitution,this.contactEquationStiffness=n.contactEquationStiffness,this.contactEquationRelaxation=n.contactEquationRelaxation,this.frictionEquationStiffness=n.frictionEquationStiffness,this.frictionEquationRelaxation=n.frictionEquationRelaxation}e.exports=r,r.idCounter=0},{"../utils/Utils":53}],25:[function(t,e,n){function i(t){var e="";"string"==typeof(t=t||{})?(e=t,t={}):"object"==typeof t&&(e=""),this.name=e,this.id=i.idCounter++,this.friction=void 0!==t.friction?t.friction:-1,this.restitution=void 0!==t.restitution?t.restitution:-1}e.exports=i,i.idCounter=0},{}],26:[function(t,e,n){e.exports=r;var i=t("./Vec3");function r(){this.spatial=new i,this.rotational=new i}r.prototype.multiplyElement=function(t){return t.spatial.dot(this.spatial)+t.rotational.dot(this.rotational)},r.prototype.multiplyVectors=function(t,e){return t.dot(this.spatial)+e.dot(this.rotational)}},{"./Vec3":30}],27:[function(t,e,n){e.exports=r;var i=t("./Vec3");function r(t){this.elements=t||[0,0,0,0,0,0,0,0,0]}r.prototype.identity=function(){var t=this.elements;t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1},r.prototype.setZero=function(){var t=this.elements;t[0]=0,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t[8]=0},r.prototype.setTrace=function(t){var e=this.elements;e[0]=t.x,e[4]=t.y,e[8]=t.z},r.prototype.getTrace=function(t){t=t||new i;var e=this.elements;t.x=e[0],t.y=e[4],t.z=e[8]},r.prototype.vmult=function(t,e){e=e||new i;var n=this.elements,r=t.x,o=t.y,a=t.z;return e.x=n[0]*r+n[1]*o+n[2]*a,e.y=n[3]*r+n[4]*o+n[5]*a,e.z=n[6]*r+n[7]*o+n[8]*a,e},r.prototype.smult=function(t){for(var e=0;e<this.elements.length;e++)this.elements[e]*=t},r.prototype.mmult=function(t,e){for(var n=e||new r,i=0;i<3;i++)for(var o=0;o<3;o++){for(var a=0,s=0;s<3;s++)a+=t.elements[i+3*s]*this.elements[s+3*o];n.elements[i+3*o]=a}return n},r.prototype.scale=function(t,e){e=e||new r;for(var n=this.elements,i=e.elements,o=0;3!==o;o++)i[3*o+0]=t.x*n[3*o+0],i[3*o+1]=t.y*n[3*o+1],i[3*o+2]=t.z*n[3*o+2];return e},r.prototype.solve=function(t,e){e=e||new i;for(var n,r=[],o=0;o<12;o++)r.push(0);for(o=0;o<3;o++)for(n=0;n<3;n++)r[o+4*n]=this.elements[o+3*n];r[3]=t.x,r[7]=t.y,r[11]=t.z;var a,s,c=3,h=c;do{if(0===r[(o=h-c)+4*o])for(n=o+1;n<h;n++)if(0!==r[o+4*n]){a=4;do{r[(s=4-a)+4*o]+=r[s+4*n]}while(--a);break}if(0!==r[o+4*o])for(n=o+1;n<h;n++){var l=r[o+4*n]/r[o+4*o];a=4;do{r[(s=4-a)+4*n]=s<=o?0:r[s+4*n]-r[s+4*o]*l}while(--a)}}while(--c);if(e.z=r[11]/r[10],e.y=(r[7]-r[6]*e.z)/r[5],e.x=(r[3]-r[2]*e.z-r[1]*e.y)/r[0],isNaN(e.x)||isNaN(e.y)||isNaN(e.z)||e.x===1/0||e.y===1/0||e.z===1/0)throw"Could not solve equation! Got x=["+e.toString()+"], b=["+t.toString()+"], A=["+this.toString()+"]";return e},r.prototype.e=function(t,e,n){if(void 0===n)return this.elements[e+3*t];this.elements[e+3*t]=n},r.prototype.copy=function(t){for(var e=0;e<t.elements.length;e++)this.elements[e]=t.elements[e];return this},r.prototype.toString=function(){for(var t="",e=0;e<9;e++)t+=this.elements[e]+",";return t},r.prototype.reverse=function(t){t=t||new r;for(var e,n=[],i=0;i<18;i++)n.push(0);for(i=0;i<3;i++)for(e=0;e<3;e++)n[i+6*e]=this.elements[i+3*e];n[3]=1,n[9]=0,n[15]=0,n[4]=0,n[10]=1,n[16]=0,n[5]=0,n[11]=0,n[17]=1;var o,a,s=3,c=s;do{if(0===n[(i=c-s)+6*i])for(e=i+1;e<c;e++)if(0!==n[i+6*e]){o=6;do{n[(a=6-o)+6*i]+=n[a+6*e]}while(--o);break}if(0!==n[i+6*i])for(e=i+1;e<c;e++){var h=n[i+6*e]/n[i+6*i];o=6;do{n[(a=6-o)+6*e]=a<=i?0:n[a+6*e]-n[a+6*i]*h}while(--o)}}while(--s);i=2;do{e=i-1;do{h=n[i+6*e]/n[i+6*i],o=6;do{n[(a=6-o)+6*e]=n[a+6*e]-n[a+6*i]*h}while(--o)}while(e--)}while(--i);i=2;do{h=1/n[i+6*i],o=6;do{n[(a=6-o)+6*i]=n[a+6*i]*h}while(--o)}while(i--);i=2;do{e=2;do{if(a=n[3+e+6*i],isNaN(a)||a===1/0)throw"Could not reverse! A=["+this.toString()+"]";t.e(i,e,a)}while(e--)}while(i--);return t},r.prototype.setRotationFromQuaternion=function(t){var e=t.x,n=t.y,i=t.z,r=t.w,o=e+e,a=n+n,s=i+i,c=e*o,h=e*a,l=e*s,u=n*a,p=n*s,d=i*s,f=r*o,m=r*a,v=r*s,g=this.elements;return g[0]=1-(u+d),g[1]=h-v,g[2]=l+m,g[3]=h+v,g[4]=1-(c+d),g[5]=p-f,g[6]=l-m,g[7]=p+f,g[8]=1-(c+u),this},r.prototype.transpose=function(t){for(var e=(t=t||new r).elements,n=this.elements,i=0;3!==i;i++)for(var o=0;3!==o;o++)e[3*i+o]=n[3*o+i];return t}},{"./Vec3":30}],28:[function(t,e,n){e.exports=r;var i=t("./Vec3");function r(t,e,n,i){this.x=void 0!==t?t:0,this.y=void 0!==e?e:0,this.z=void 0!==n?n:0,this.w=void 0!==i?i:1}r.prototype.set=function(t,e,n,i){this.x=t,this.y=e,this.z=n,this.w=i},r.prototype.toString=function(){return this.x+","+this.y+","+this.z+","+this.w},r.prototype.toArray=function(){return[this.x,this.y,this.z,this.w]},r.prototype.setFromAxisAngle=function(t,e){var n=Math.sin(.5*e);this.x=t.x*n,this.y=t.y*n,this.z=t.z*n,this.w=Math.cos(.5*e)},r.prototype.toAxisAngle=function(t){t=t||new i,this.normalize();var e=2*Math.acos(this.w),n=Math.sqrt(1-this.w*this.w);return n<.001?(t.x=this.x,t.y=this.y,t.z=this.z):(t.x=this.x/n,t.y=this.y/n,t.z=this.z/n),[t,e]};var o=new i,a=new i;r.prototype.setFromVectors=function(t,e){if(t.isAntiparallelTo(e)){var n=o,i=a;t.tangents(n,i),this.setFromAxisAngle(n,Math.PI)}else{var r=t.cross(e);this.x=r.x,this.y=r.y,this.z=r.z,this.w=Math.sqrt(Math.pow(t.norm(),2)*Math.pow(e.norm(),2))+t.dot(e),this.normalize()}};var s=new i,c=new i,h=new i;r.prototype.mult=function(t,e){e=e||new r;var n=this.w,i=s,o=c,a=h;return i.set(this.x,this.y,this.z),o.set(t.x,t.y,t.z),e.w=n*t.w-i.dot(o),i.cross(o,a),e.x=n*o.x+t.w*i.x+a.x,e.y=n*o.y+t.w*i.y+a.y,e.z=n*o.z+t.w*i.z+a.z,e},r.prototype.inverse=function(t){var e=this.x,n=this.y,i=this.z,o=this.w;t=t||new r,this.conjugate(t);var a=1/(e*e+n*n+i*i+o*o);return t.x*=a,t.y*=a,t.z*=a,t.w*=a,t},r.prototype.conjugate=function(t){return(t=t||new r).x=-this.x,t.y=-this.y,t.z=-this.z,t.w=this.w,t},r.prototype.normalize=function(){var t=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===t?(this.x=0,this.y=0,this.z=0,this.w=0):(t=1/t,this.x*=t,this.y*=t,this.z*=t,this.w*=t)},r.prototype.normalizeFast=function(){var t=(3-(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w))/2;0===t?(this.x=0,this.y=0,this.z=0,this.w=0):(this.x*=t,this.y*=t,this.z*=t,this.w*=t)},r.prototype.vmult=function(t,e){e=e||new i;var n=t.x,r=t.y,o=t.z,a=this.x,s=this.y,c=this.z,h=this.w,l=h*n+s*o-c*r,u=h*r+c*n-a*o,p=h*o+a*r-s*n,d=-a*n-s*r-c*o;return e.x=l*h+d*-a+u*-c-p*-s,e.y=u*h+d*-s+p*-a-l*-c,e.z=p*h+d*-c+l*-s-u*-a,e},r.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},r.prototype.toEuler=function(t,e){var n,i,r;e=e||"YZX";var o=this.x,a=this.y,s=this.z,c=this.w;switch(e){case"YZX":var h=o*a+s*c;if(h>.499&&(n=2*Math.atan2(o,c),i=Math.PI/2,r=0),h<-.499&&(n=-2*Math.atan2(o,c),i=-Math.PI/2,r=0),isNaN(n)){var l=o*o,u=a*a,p=s*s;n=Math.atan2(2*a*c-2*o*s,1-2*u-2*p),i=Math.asin(2*h),r=Math.atan2(2*o*c-2*a*s,1-2*l-2*p)}break;default:throw new Error("Euler order "+e+" not supported yet.")}t.y=n,t.z=i,t.x=r},r.prototype.setFromEuler=function(t,e,n,i){i=i||"XYZ";var r=Math.cos(t/2),o=Math.cos(e/2),a=Math.cos(n/2),s=Math.sin(t/2),c=Math.sin(e/2),h=Math.sin(n/2);return"XYZ"===i?(this.x=s*o*a+r*c*h,this.y=r*c*a-s*o*h,this.z=r*o*h+s*c*a,this.w=r*o*a-s*c*h):"YXZ"===i?(this.x=s*o*a+r*c*h,this.y=r*c*a-s*o*h,this.z=r*o*h-s*c*a,this.w=r*o*a+s*c*h):"ZXY"===i?(this.x=s*o*a-r*c*h,this.y=r*c*a+s*o*h,this.z=r*o*h+s*c*a,this.w=r*o*a-s*c*h):"ZYX"===i?(this.x=s*o*a-r*c*h,this.y=r*c*a+s*o*h,this.z=r*o*h-s*c*a,this.w=r*o*a+s*c*h):"YZX"===i?(this.x=s*o*a+r*c*h,this.y=r*c*a+s*o*h,this.z=r*o*h-s*c*a,this.w=r*o*a-s*c*h):"XZY"===i&&(this.x=s*o*a-r*c*h,this.y=r*c*a-s*o*h,this.z=r*o*h+s*c*a,this.w=r*o*a+s*c*h),this},r.prototype.clone=function(){return new r(this.x,this.y,this.z,this.w)}},{"./Vec3":30}],29:[function(t,e,n){var i=t("./Vec3"),r=t("./Quaternion");function o(t){t=t||{},this.position=new i,t.position&&this.position.copy(t.position),this.quaternion=new r,t.quaternion&&this.quaternion.copy(t.quaternion)}e.exports=o;var a=new r;o.pointToLocalFrame=function(t,e,n,r){return r=r||new i,n.vsub(t,r),e.conjugate(a),a.vmult(r,r),r},o.prototype.pointToLocal=function(t,e){return o.pointToLocalFrame(this.position,this.quaternion,t,e)},o.pointToWorldFrame=function(t,e,n,r){return r=r||new i,e.vmult(n,r),r.vadd(t,r),r},o.prototype.pointToWorld=function(t,e){return o.pointToWorldFrame(this.position,this.quaternion,t,e)},o.prototype.vectorToWorldFrame=function(t,e){return e=e||new i,this.quaternion.vmult(t,e),e},o.vectorToWorldFrame=function(t,e,n){return t.vmult(e,n),n},o.vectorToLocalFrame=function(t,e,n,r){return r=r||new i,e.w*=-1,e.vmult(n,r),e.w*=-1,r}},{"./Quaternion":28,"./Vec3":30}],30:[function(t,e,n){e.exports=r;var i=t("./Mat3");function r(t,e,n){this.x=t||0,this.y=e||0,this.z=n||0}r.ZERO=new r(0,0,0),r.UNIT_X=new r(1,0,0),r.UNIT_Y=new r(0,1,0),r.UNIT_Z=new r(0,0,1),r.prototype.cross=function(t,e){var n=t.x,i=t.y,o=t.z,a=this.x,s=this.y,c=this.z;return(e=e||new r).x=s*o-c*i,e.y=c*n-a*o,e.z=a*i-s*n,e},r.prototype.set=function(t,e,n){return this.x=t,this.y=e,this.z=n,this},r.prototype.setZero=function(){this.x=this.y=this.z=0},r.prototype.vadd=function(t,e){if(!e)return new r(this.x+t.x,this.y+t.y,this.z+t.z);e.x=t.x+this.x,e.y=t.y+this.y,e.z=t.z+this.z},r.prototype.vsub=function(t,e){if(!e)return new r(this.x-t.x,this.y-t.y,this.z-t.z);e.x=this.x-t.x,e.y=this.y-t.y,e.z=this.z-t.z},r.prototype.crossmat=function(){return new i([0,-this.z,this.y,this.z,0,-this.x,-this.y,this.x,0])},r.prototype.normalize=function(){var t=this.x,e=this.y,n=this.z,i=Math.sqrt(t*t+e*e+n*n);if(i>0){var r=1/i;this.x*=r,this.y*=r,this.z*=r}else this.x=0,this.y=0,this.z=0;return i},r.prototype.unit=function(t){t=t||new r;var e=this.x,n=this.y,i=this.z,o=Math.sqrt(e*e+n*n+i*i);return o>0?(o=1/o,t.x=e*o,t.y=n*o,t.z=i*o):(t.x=1,t.y=0,t.z=0),t},r.prototype.norm=function(){var t=this.x,e=this.y,n=this.z;return Math.sqrt(t*t+e*e+n*n)},r.prototype.length=r.prototype.norm,r.prototype.norm2=function(){return this.dot(this)},r.prototype.lengthSquared=r.prototype.norm2,r.prototype.distanceTo=function(t){var e=this.x,n=this.y,i=this.z,r=t.x,o=t.y,a=t.z;return Math.sqrt((r-e)*(r-e)+(o-n)*(o-n)+(a-i)*(a-i))},r.prototype.distanceSquared=function(t){var e=this.x,n=this.y,i=this.z,r=t.x,o=t.y,a=t.z;return(r-e)*(r-e)+(o-n)*(o-n)+(a-i)*(a-i)},r.prototype.mult=function(t,e){e=e||new r;var n=this.x,i=this.y,o=this.z;return e.x=t*n,e.y=t*i,e.z=t*o,e},r.prototype.scale=r.prototype.mult,r.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},r.prototype.isZero=function(){return 0===this.x&&0===this.y&&0===this.z},r.prototype.negate=function(t){return(t=t||new r).x=-this.x,t.y=-this.y,t.z=-this.z,t};var o=new r,a=new r;r.prototype.tangents=function(t,e){var n=this.norm();if(n>0){var i=o,r=1/n;i.set(this.x*r,this.y*r,this.z*r);var s=a;Math.abs(i.x)<.9?(s.set(1,0,0),i.cross(s,t)):(s.set(0,1,0),i.cross(s,t)),i.cross(t,e)}else t.set(1,0,0),e.set(0,1,0)},r.prototype.toString=function(){return this.x+","+this.y+","+this.z},r.prototype.toArray=function(){return[this.x,this.y,this.z]},r.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},r.prototype.lerp=function(t,e,n){var i=this.x,r=this.y,o=this.z;n.x=i+(t.x-i)*e,n.y=r+(t.y-r)*e,n.z=o+(t.z-o)*e},r.prototype.almostEquals=function(t,e){return void 0===e&&(e=1e-6),!(Math.abs(this.x-t.x)>e||Math.abs(this.y-t.y)>e||Math.abs(this.z-t.z)>e)},r.prototype.almostZero=function(t){return void 0===t&&(t=1e-6),!(Math.abs(this.x)>t||Math.abs(this.y)>t||Math.abs(this.z)>t)};var s=new r;r.prototype.isAntiparallelTo=function(t,e){return this.negate(s),s.almostEquals(t,e)},r.prototype.clone=function(){return new r(this.x,this.y,this.z)}},{"./Mat3":27}],31:[function(t,e,n){e.exports=h;var i=t("../utils/EventTarget"),r=(t("../shapes/Shape"),t("../math/Vec3")),o=t("../math/Mat3"),a=t("../math/Quaternion"),s=(t("../material/Material"),t("../collision/AABB")),c=t("../shapes/Box");function h(t){t=t||{},i.apply(this),this.id=h.idCounter++,this.world=null,this.preStep=null,this.postStep=null,this.vlambda=new r,this.collisionFilterGroup="number"==typeof t.collisionFilterGroup?t.collisionFilterGroup:1,this.collisionFilterMask="number"==typeof t.collisionFilterMask?t.collisionFilterMask:1,this.collisionResponse=!0,this.position=new r,t.position&&this.position.copy(t.position),this.previousPosition=new r,this.initPosition=new r,this.velocity=new r,t.velocity&&this.velocity.copy(t.velocity),this.initVelocity=new r,this.force=new r;var e="number"==typeof t.mass?t.mass:0;this.mass=e,this.invMass=e>0?1/e:0,this.material=t.material||null,this.linearDamping="number"==typeof t.linearDamping?t.linearDamping:.01,this.type=e<=0?h.STATIC:h.DYNAMIC,typeof t.type==typeof h.STATIC&&(this.type=t.type),this.allowSleep=void 0===t.allowSleep||t.allowSleep,this.sleepState=0,this.sleepSpeedLimit=void 0!==t.sleepSpeedLimit?t.sleepSpeedLimit:.1,this.sleepTimeLimit=void 0!==t.sleepTimeLimit?t.sleepTimeLimit:1,this.timeLastSleepy=0,this._wakeUpAfterNarrowphase=!1,this.torque=new r,this.quaternion=new a,t.quaternion&&this.quaternion.copy(t.quaternion),this.initQuaternion=new a,this.angularVelocity=new r,t.angularVelocity&&this.angularVelocity.copy(t.angularVelocity),this.initAngularVelocity=new r,this.interpolatedPosition=new r,this.interpolatedQuaternion=new a,this.shapes=[],this.shapeOffsets=[],this.shapeOrientations=[],this.inertia=new r,this.invInertia=new r,this.invInertiaWorld=new o,this.invMassSolve=0,this.invInertiaSolve=new r,this.invInertiaWorldSolve=new o,this.fixedRotation=void 0!==t.fixedRotation&&t.fixedRotation,this.angularDamping=void 0!==t.angularDamping?t.angularDamping:.01,this.aabb=new s,this.aabbNeedsUpdate=!0,this.wlambda=new r,t.shape&&this.addShape(t.shape),this.updateMassProperties()}h.prototype=new i,h.prototype.constructor=h,h.DYNAMIC=1,h.STATIC=2,h.KINEMATIC=4,h.AWAKE=0,h.SLEEPY=1,h.SLEEPING=2,h.idCounter=0,h.prototype.wakeUp=function(){var t=this.sleepState;this.sleepState=0,t===h.SLEEPING&&this.dispatchEvent({type:"wakeup"})},h.prototype.sleep=function(){this.sleepState=h.SLEEPING,this.velocity.set(0,0,0),this.angularVelocity.set(0,0,0)},h.sleepyEvent={type:"sleepy"},h.sleepEvent={type:"sleep"},h.prototype.sleepTick=function(t){if(this.allowSleep){var e=this.sleepState,n=this.velocity.norm2()+this.angularVelocity.norm2(),i=Math.pow(this.sleepSpeedLimit,2);e===h.AWAKE&&n<i?(this.sleepState=h.SLEEPY,this.timeLastSleepy=t,this.dispatchEvent(h.sleepyEvent)):e===h.SLEEPY&&n>i?this.wakeUp():e===h.SLEEPY&&t-this.timeLastSleepy>this.sleepTimeLimit&&(this.sleep(),this.dispatchEvent(h.sleepEvent))}},h.prototype.updateSolveMassProperties=function(){this.sleepState===h.SLEEPING||this.type===h.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve.setZero(),this.invInertiaWorldSolve.setZero()):(this.invMassSolve=this.invMass,this.invInertiaSolve.copy(this.invInertia),this.invInertiaWorldSolve.copy(this.invInertiaWorld))},h.prototype.pointToLocalFrame=function(t,e){return e=e||new r,t.vsub(this.position,e),this.quaternion.conjugate().vmult(e,e),e},h.prototype.vectorToLocalFrame=function(t,e){return e=e||new r,this.quaternion.conjugate().vmult(t,e),e},h.prototype.pointToWorldFrame=function(t,e){return e=e||new r,this.quaternion.vmult(t,e),e.vadd(this.position,e),e},h.prototype.vectorToWorldFrame=function(t,e){return e=e||new r,this.quaternion.vmult(t,e),e};var l=new r,u=new a;h.prototype.addShape=function(t,e,n){var i=new r,o=new a;return e&&i.copy(e),n&&o.copy(n),this.shapes.push(t),this.shapeOffsets.push(i),this.shapeOrientations.push(o),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0,this},h.prototype.updateBoundingRadius=function(){for(var t=this.shapes,e=this.shapeOffsets,n=t.length,i=0,r=0;r!==n;r++){var o=t[r];o.updateBoundingSphereRadius();var a=e[r].norm(),s=o.boundingSphereRadius;a+s>i&&(i=a+s)}this.boundingRadius=i};var p=new s;h.prototype.computeAABB=function(){for(var t=this.shapes,e=this.shapeOffsets,n=this.shapeOrientations,i=t.length,r=l,o=u,a=this.quaternion,s=this.aabb,c=p,h=0;h!==i;h++){var d=t[h];n[h].mult(a,o),o.vmult(e[h],r),r.vadd(this.position,r),d.calculateWorldAABB(r,o,c.lowerBound,c.upperBound),0===h?s.copy(c):s.extend(c)}this.aabbNeedsUpdate=!1};var d=new o,f=new o;new o,h.prototype.updateInertiaWorld=function(t){var e=this.invInertia;if(e.x!==e.y||e.y!==e.z||t){var n=d,i=f;n.setRotationFromQuaternion(this.quaternion),n.transpose(i),n.scale(e,n),n.mmult(i,this.invInertiaWorld)}};var m=new r,v=new r;h.prototype.applyForce=function(t,e){if(this.type===h.DYNAMIC){var n=m;e.vsub(this.position,n);var i=v;n.cross(t,i),this.force.vadd(t,this.force),this.torque.vadd(i,this.torque)}};var g=new r,y=new r;h.prototype.applyLocalForce=function(t,e){if(this.type===h.DYNAMIC){var n=g,i=y;this.vectorToWorldFrame(t,n),this.pointToWorldFrame(e,i),this.applyForce(n,i)}};var x=new r,w=new r,b=new r;h.prototype.applyImpulse=function(t,e){if(this.type===h.DYNAMIC){var n=x;e.vsub(this.position,n);var i=w;i.copy(t),i.mult(this.invMass,i),this.velocity.vadd(i,this.velocity);var r=b;n.cross(t,r),this.invInertiaWorld.vmult(r,r),this.angularVelocity.vadd(r,this.angularVelocity)}};var _=new r,M=new r;h.prototype.applyLocalImpulse=function(t,e){if(this.type===h.DYNAMIC){var n=_,i=M;this.vectorToWorldFrame(t,n),this.pointToWorldFrame(e,i),this.applyImpulse(n,i)}};var E=new r;h.prototype.updateMassProperties=function(){var t=E;this.invMass=this.mass>0?1/this.mass:0;var e=this.inertia,n=this.fixedRotation;this.computeAABB(),t.set((this.aabb.upperBound.x-this.aabb.lowerBound.x)/2,(this.aabb.upperBound.y-this.aabb.lowerBound.y)/2,(this.aabb.upperBound.z-this.aabb.lowerBound.z)/2),c.calculateInertia(t,this.mass,e),this.invInertia.set(e.x>0&&!n?1/e.x:0,e.y>0&&!n?1/e.y:0,e.z>0&&!n?1/e.z:0),this.updateInertiaWorld(!0)},h.prototype.getVelocityAtWorldPoint=function(t,e){var n=new r;return t.vsub(this.position,n),this.angularVelocity.cross(n,e),this.velocity.vadd(e,e),e}},{"../collision/AABB":3,"../material/Material":25,"../math/Mat3":27,"../math/Quaternion":28,"../math/Vec3":30,"../shapes/Box":37,"../shapes/Shape":43,"../utils/EventTarget":49}],32:[function(t,e,n){t("./Body");var i=t("../math/Vec3"),r=t("../math/Quaternion"),o=(t("../collision/RaycastResult"),t("../collision/Ray")),a=t("../objects/WheelInfo");function s(t){this.chassisBody=t.chassisBody,this.wheelInfos=[],this.sliding=!1,this.world=null,this.indexRightAxis=void 0!==t.indexRightAxis?t.indexRightAxis:1,this.indexForwardAxis=void 0!==t.indexForwardAxis?t.indexForwardAxis:0,this.indexUpAxis=void 0!==t.indexUpAxis?t.indexUpAxis:2}e.exports=s,new i,new i,new i;var c=new i,h=new i,l=new i;new o,s.prototype.addWheel=function(t){var e=new a(t=t||{}),n=this.wheelInfos.length;return this.wheelInfos.push(e),n},s.prototype.setSteeringValue=function(t,e){this.wheelInfos[e].steering=t},new i,s.prototype.applyEngineForce=function(t,e){this.wheelInfos[e].engineForce=t},s.prototype.setBrake=function(t,e){this.wheelInfos[e].brake=t},s.prototype.addToWorld=function(t){this.constraints,t.add(this.chassisBody);var e=this;this.preStepCallback=function(){e.updateVehicle(t.dt)},t.addEventListener("preStep",this.preStepCallback),this.world=t},s.prototype.getVehicleAxisWorld=function(t,e){e.set(0===t?1:0,1===t?1:0,2===t?1:0),this.chassisBody.vectorToWorldFrame(e,e)},s.prototype.updateVehicle=function(t){for(var e=this.wheelInfos,n=e.length,r=this.chassisBody,o=0;o<n;o++)this.updateWheelTransform(o);this.currentVehicleSpeedKmHour=3.6*r.velocity.norm();var a=new i;for(this.getVehicleAxisWorld(this.indexForwardAxis,a),a.dot(r.velocity)<0&&(this.currentVehicleSpeedKmHour*=-1),o=0;o<n;o++)this.castRay(e[o]);this.updateSuspension(t);var s=new i,c=new i;for(o=0;o<n;o++){var h=(d=e[o]).suspensionForce;h>d.maxSuspensionForce&&(h=d.maxSuspensionForce),d.raycastResult.hitNormalWorld.scale(h*t,s),d.raycastResult.hitPointWorld.vsub(r.position,c),r.applyImpulse(s,d.raycastResult.hitPointWorld)}this.updateFriction(t);var l=new i,u=new i,p=new i;for(o=0;o<n;o++){var d=e[o];r.getVelocityAtWorldPoint(d.chassisConnectionPointWorld,p);var f=1;switch(this.indexUpAxis){case 1:f=-1}if(d.isInContact){this.getVehicleAxisWorld(this.indexForwardAxis,u);var m=u.dot(d.raycastResult.hitNormalWorld);d.raycastResult.hitNormalWorld.scale(m,l),u.vsub(l,u);var v=u.dot(p);d.deltaRotation=f*v*t/d.radius}!d.sliding&&d.isInContact||0===d.engineForce||!d.useCustomSlidingRotationalSpeed||(d.deltaRotation=(d.engineForce>0?1:-1)*d.customSlidingRotationalSpeed*t),Math.abs(d.brake)>Math.abs(d.engineForce)&&(d.deltaRotation=0),d.rotation+=d.deltaRotation,d.deltaRotation*=.99}},s.prototype.updateSuspension=function(t){for(var e=this.chassisBody.mass,n=this.wheelInfos,i=n.length,r=0;r<i;r++){var o=n[r];if(o.isInContact){var a,s=o.suspensionRestLength-o.suspensionLength;a=o.suspensionStiffness*s*o.clippedInvContactDotSuspension;var c=o.suspensionRelativeVelocity;a-=(c<0?o.dampingCompression:o.dampingRelaxation)*c,o.suspensionForce=a*e,o.suspensionForce<0&&(o.suspensionForce=0)}else o.suspensionForce=0}},s.prototype.removeFromWorld=function(t){this.constraints,t.remove(this.chassisBody),t.removeEventListener("preStep",this.preStepCallback),this.world=null};var u=new i,p=new i;s.prototype.castRay=function(t){var e=u,n=p;this.updateWheelTransformWorld(t);var r=this.chassisBody,o=-1,a=t.suspensionRestLength+t.radius;t.directionWorld.scale(a,e);var s=t.chassisConnectionPointWorld;s.vadd(e,n);var c=t.raycastResult;c.reset();var h=r.collisionResponse;r.collisionResponse=!1,this.world.rayTest(s,n,c),r.collisionResponse=h;var l=c.body;if(t.raycastResult.groundObject=0,l){o=c.distance,t.raycastResult.hitNormalWorld=c.hitNormalWorld,t.isInContact=!0;var d=c.distance;t.suspensionLength=d-t.radius;var f=t.suspensionRestLength-t.maxSuspensionTravel,m=t.suspensionRestLength+t.maxSuspensionTravel;t.suspensionLength<f&&(t.suspensionLength=f),t.suspensionLength>m&&(t.suspensionLength=m,t.raycastResult.reset());var v=t.raycastResult.hitNormalWorld.dot(t.directionWorld),g=new i;r.getVelocityAtWorldPoint(t.raycastResult.hitPointWorld,g);var y=t.raycastResult.hitNormalWorld.dot(g);if(v>=-.1)t.suspensionRelativeVelocity=0,t.clippedInvContactDotSuspension=10;else{var x=-1/v;t.suspensionRelativeVelocity=y*x,t.clippedInvContactDotSuspension=x}}else t.suspensionLength=t.suspensionRestLength+0*t.maxSuspensionTravel,t.suspensionRelativeVelocity=0,t.directionWorld.scale(-1,t.raycastResult.hitNormalWorld),t.clippedInvContactDotSuspension=1;return o},s.prototype.updateWheelTransformWorld=function(t){t.isInContact=!1;var e=this.chassisBody;e.pointToWorldFrame(t.chassisConnectionPointLocal,t.chassisConnectionPointWorld),e.vectorToWorldFrame(t.directionLocal,t.directionWorld),e.vectorToWorldFrame(t.axleLocal,t.axleWorld)},s.prototype.updateWheelTransform=function(t){var e=c,n=h,i=l,o=this.wheelInfos[t];this.updateWheelTransformWorld(o),o.directionLocal.scale(-1,e),n.copy(o.axleLocal),e.cross(n,i),i.normalize(),n.normalize();var a=o.steering,s=new r;s.setFromAxisAngle(e,a);var u=new r;u.setFromAxisAngle(n,o.rotation);var p=o.worldTransform.quaternion;this.chassisBody.quaternion.mult(s,p),p.mult(u,p),p.normalize();var d=o.worldTransform.position;d.copy(o.directionWorld),d.scale(o.suspensionLength,d),d.vadd(o.chassisConnectionPointWorld,d)};var d=[new i(1,0,0),new i(0,1,0),new i(0,0,1)];s.prototype.getWheelTransformWorld=function(t){return this.wheelInfos[t].worldTransform};var f=new i,m=[],v=[];s.prototype.updateFriction=function(t){for(var e=f,n=this.wheelInfos,r=n.length,o=this.chassisBody,a=v,s=m,c=0;c<r;c++)p=(T=n[c]).raycastResult.body,T.sideImpulse=0,T.forwardImpulse=0,a[c]||(a[c]=new i),s[c]||(s[c]=new i);for(c=0;c<r;c++)if(p=(T=n[c]).raycastResult.body){var h=s[c];this.getWheelTransformWorld(c).vectorToWorldFrame(d[this.indexRightAxis],h);var l=T.raycastResult.hitNormalWorld,u=h.dot(l);l.scale(u,e),h.vsub(e,h),h.normalize(),l.cross(h,a[c]),a[c].normalize(),T.sideImpulse=C(o,T.raycastResult.hitPointWorld,p,T.raycastResult.hitPointWorld,h),T.sideImpulse*=1}for(this.sliding=!1,c=0;c<r;c++){var p=(T=n[c]).raycastResult.body,g=0;if(T.slipInfo=1,p){var y=T.brake?T.brake:0;g=w(o,p,T.raycastResult.hitPointWorld,a[c],y);var x=y/(g+=T.engineForce*t);T.slipInfo*=x}if(T.forwardImpulse=0,T.skidInfo=1,p){T.skidInfo=1;var b=T.suspensionForce*t*T.frictionSlip,_=b*b;T.forwardImpulse=g;var M=.5*T.forwardImpulse,E=1*T.sideImpulse,S=M*M+E*E;T.sliding=!1,S>_&&(this.sliding=!0,T.sliding=!0,x=b/Math.sqrt(S),T.skidInfo*=x)}}if(this.sliding)for(c=0;c<r;c++)0!==(T=n[c]).sideImpulse&&T.skidInfo<1&&(T.forwardImpulse*=T.skidInfo,T.sideImpulse*=T.skidInfo);for(c=0;c<r;c++){var T=n[c],A=new i;if(A.copy(T.raycastResult.hitPointWorld),0!==T.forwardImpulse){var R=new i;a[c].scale(T.forwardImpulse,R),o.applyImpulse(R,A)}if(0!==T.sideImpulse){p=T.raycastResult.body;var L=new i;L.copy(T.raycastResult.hitPointWorld);var P=new i;s[c].scale(T.sideImpulse,P),o.pointToLocalFrame(A,A),A["xyz"[this.indexUpAxis]]*=T.rollInfluence,o.pointToWorldFrame(A,A),o.applyImpulse(P,A),P.scale(-1,P),p.applyImpulse(P,L)}}};var g=new i,y=new i,x=new i;function w(t,e,n,i,r){var o=0,a=n,s=g,c=y,h=x;return t.getVelocityAtWorldPoint(a,s),e.getVelocityAtWorldPoint(a,c),s.vsub(c,h),r<(o=-i.dot(h)*(1/(S(t,n,i)+S(e,n,i))))&&(o=r),o<-r&&(o=-r),o}var b=new i,_=new i,M=new i,E=new i;function S(t,e,n){var i=b,r=_,o=M,a=E;return e.vsub(t.position,i),i.cross(n,r),t.invInertiaWorld.vmult(r,a),a.cross(i,o),t.invMass+n.dot(o)}var T=new i,A=new i,R=new i;function C(t,e,n,i,r,o){if(r.norm2()>1.1)return 0;var a=T,s=A,c=R;return t.getVelocityAtWorldPoint(e,a),n.getVelocityAtWorldPoint(i,s),a.vsub(s,c),-.2*r.dot(c)*(1/(t.invMass+n.invMass))}},{"../collision/Ray":9,"../collision/RaycastResult":10,"../math/Quaternion":28,"../math/Vec3":30,"../objects/WheelInfo":36,"./Body":31}],33:[function(t,e,n){var i=t("./Body"),r=t("../shapes/Sphere"),o=t("../shapes/Box"),a=t("../math/Vec3"),s=t("../constraints/HingeConstraint");function c(t){if(this.wheelBodies=[],this.coordinateSystem=void 0===t.coordinateSystem?new a(1,2,3):t.coordinateSystem.clone(),this.chassisBody=t.chassisBody,!this.chassisBody){var e=new o(new a(5,2,.5));this.chassisBody=new i(1,e)}this.constraints=[],this.wheelAxes=[],this.wheelForces=[]}e.exports=c,c.prototype.addWheel=function(t){var e=(t=t||{}).body;e||(e=new i(1,new r(1.2))),this.wheelBodies.push(e),this.wheelForces.push(0),new a;var n=void 0!==t.position?t.position.clone():new a,o=new a;this.chassisBody.pointToWorldFrame(n,o),e.position.set(o.x,o.y,o.z);var c=void 0!==t.axis?t.axis.clone():new a(0,1,0);this.wheelAxes.push(c);var h=new s(this.chassisBody,e,{pivotA:n,axisA:c,pivotB:a.ZERO,axisB:c,collideConnected:!1});return this.constraints.push(h),this.wheelBodies.length-1},c.prototype.setSteeringValue=function(t,e){var n=this.wheelAxes[e],i=Math.cos(t),r=Math.sin(t),o=n.x,a=n.y;this.constraints[e].axisA.set(i*o-r*a,r*o+i*a,0)},c.prototype.setMotorSpeed=function(t,e){var n=this.constraints[e];n.enableMotor(),n.motorTargetVelocity=t},c.prototype.disableMotor=function(t){this.constraints[t].disableMotor()};var h=new a;c.prototype.setWheelForce=function(t,e){this.wheelForces[e]=t},c.prototype.applyWheelForce=function(t,e){var n=this.wheelAxes[e],i=this.wheelBodies[e],r=i.torque;n.scale(t,h),i.vectorToWorldFrame(h,h),r.vadd(h,r)},c.prototype.addToWorld=function(t){for(var e=this.constraints,n=this.wheelBodies.concat([this.chassisBody]),i=0;i<n.length;i++)t.add(n[i]);for(i=0;i<e.length;i++)t.addConstraint(e[i]);t.addEventListener("preStep",this._update.bind(this))},c.prototype._update=function(){for(var t=this.wheelForces,e=0;e<t.length;e++)this.applyWheelForce(t[e],e)},c.prototype.removeFromWorld=function(t){for(var e=this.constraints,n=this.wheelBodies.concat([this.chassisBody]),i=0;i<n.length;i++)t.remove(n[i]);for(i=0;i<e.length;i++)t.removeConstraint(e[i])};var l=new a;c.prototype.getWheelSpeed=function(t){var e=this.wheelAxes[t],n=this.wheelBodies[t].angularVelocity;return this.chassisBody.vectorToWorldFrame(e,l),n.dot(l)}},{"../constraints/HingeConstraint":15,"../math/Vec3":30,"../shapes/Box":37,"../shapes/Sphere":44,"./Body":31}],34:[function(t,e,n){e.exports=r,t("../shapes/Shape");var i=t("../math/Vec3");function r(){this.particles=[],this.density=1,this.smoothingRadius=1,this.speedOfSound=1,this.viscosity=.01,this.eps=1e-6,this.pressures=[],this.densities=[],this.neighbors=[]}t("../math/Quaternion"),t("../shapes/Particle"),t("../objects/Body"),t("../material/Material"),r.prototype.add=function(t){this.particles.push(t),this.neighbors.length<this.particles.length&&this.neighbors.push([])},r.prototype.remove=function(t){var e=this.particles.indexOf(t);-1!==e&&(this.particles.splice(e,1),this.neighbors.length>this.particles.length&&this.neighbors.pop())};var o=new i;r.prototype.getNeighbors=function(t,e){for(var n=this.particles.length,i=t.id,r=this.smoothingRadius*this.smoothingRadius,a=o,s=0;s!==n;s++){var c=this.particles[s];c.position.vsub(t.position,a),i!==c.id&&a.norm2()<r&&e.push(c)}};var a=new i,s=new i,c=new i,h=new i,l=new i,u=new i;r.prototype.update=function(){for(var t=this.particles.length,e=a,n=this.speedOfSound,i=this.eps,r=0;r!==t;r++){var o=this.particles[r];(E=this.neighbors[r]).length=0,this.getNeighbors(o,E),E.push(this.particles[r]);for(var p=E.length,d=0,f=0;f!==p;f++){o.position.vsub(E[f].position,e);var m=e.norm(),v=this.w(m);d+=E[f].mass*v}this.densities[r]=d,this.pressures[r]=n*n*(this.densities[r]-this.density)}var g=s,y=c,x=h,w=l,b=u;for(r=0;r!==t;r++){var _,M,E,S=this.particles[r];for(g.set(0,0,0),y.set(0,0,0),p=(E=this.neighbors[r]).length,f=0;f!==p;f++){var T=E[f];S.position.vsub(T.position,w);var A=w.norm();_=-T.mass*(this.pressures[r]/(this.densities[r]*this.densities[r]+i)+this.pressures[f]/(this.densities[f]*this.densities[f]+i)),this.gradw(w,x),x.mult(_,x),g.vadd(x,g),T.velocity.vsub(S.velocity,b),b.mult(1/(1e-4+this.densities[r]*this.densities[f])*this.viscosity*T.mass,b),M=this.nablaw(A),b.mult(M,b),y.vadd(b,y)}y.mult(S.mass,y),g.mult(S.mass,g),S.force.vadd(y,S.force),S.force.vadd(g,S.force)}},r.prototype.w=function(t){var e=this.smoothingRadius;return 315/(64*Math.PI*Math.pow(e,9))*Math.pow(e*e-t*t,3)},r.prototype.gradw=function(t,e){var n=t.norm(),i=this.smoothingRadius;t.mult(945/(32*Math.PI*Math.pow(i,9))*Math.pow(i*i-n*n,2),e)},r.prototype.nablaw=function(t){var e=this.smoothingRadius;return 945/(32*Math.PI*Math.pow(e,9))*(e*e-t*t)*(7*t*t-3*e*e)}},{"../material/Material":25,"../math/Quaternion":28,"../math/Vec3":30,"../objects/Body":31,"../shapes/Particle":41,"../shapes/Shape":43}],35:[function(t,e,n){var i=t("../math/Vec3");function r(t,e,n){n=n||{},this.restLength="number"==typeof n.restLength?n.restLength:1,this.stiffness=n.stiffness||100,this.damping=n.damping||1,this.bodyA=t,this.bodyB=e,this.localAnchorA=new i,this.localAnchorB=new i,n.localAnchorA&&this.localAnchorA.copy(n.localAnchorA),n.localAnchorB&&this.localAnchorB.copy(n.localAnchorB),n.worldAnchorA&&this.setWorldAnchorA(n.worldAnchorA),n.worldAnchorB&&this.setWorldAnchorB(n.worldAnchorB)}e.exports=r,r.prototype.setWorldAnchorA=function(t){this.bodyA.pointToLocalFrame(t,this.localAnchorA)},r.prototype.setWorldAnchorB=function(t){this.bodyB.pointToLocalFrame(t,this.localAnchorB)},r.prototype.getWorldAnchorA=function(t){this.bodyA.pointToWorldFrame(this.localAnchorA,t)},r.prototype.getWorldAnchorB=function(t){this.bodyB.pointToWorldFrame(this.localAnchorB,t)};var o=new i,a=new i,s=new i,c=new i,h=new i,l=new i,u=new i,p=new i,d=new i,f=new i,m=new i;r.prototype.applyForce=function(){var t=this.stiffness,e=this.damping,n=this.restLength,i=this.bodyA,r=this.bodyB,v=o,g=a,y=s,x=c,w=m,b=h,_=l,M=u,E=p,S=d,T=f;this.getWorldAnchorA(b),this.getWorldAnchorB(_),b.vsub(i.position,M),_.vsub(r.position,E),_.vsub(b,v);var A=v.norm();g.copy(v),g.normalize(),r.velocity.vsub(i.velocity,y),r.angularVelocity.cross(E,w),y.vadd(w,y),i.angularVelocity.cross(M,w),y.vsub(w,y),g.mult(-t*(A-n)-e*y.dot(g),x),i.force.vsub(x,i.force),r.force.vadd(x,r.force),M.cross(x,S),E.cross(x,T),i.torque.vsub(S,i.torque),r.torque.vadd(T,r.torque)}},{"../math/Vec3":30}],36:[function(t,e,n){var i=t("../math/Vec3"),r=t("../math/Transform"),o=t("../collision/RaycastResult"),a=t("../utils/Utils");function s(t){t=a.defaults(t,{chassisConnectionPointLocal:new i,chassisConnectionPointWorld:new i,directionLocal:new i,directionWorld:new i,axleLocal:new i,axleWorld:new i,suspensionRestLength:1,suspensionMaxLength:2,radius:1,suspensionStiffness:100,dampingCompression:10,dampingRelaxation:10,frictionSlip:1e4,steering:0,rotation:0,deltaRotation:0,rollInfluence:.01,maxSuspensionForce:Number.MAX_VALUE,isFrontWheel:!0,clippedInvContactDotSuspension:1,suspensionRelativeVelocity:0,suspensionForce:0,skidInfo:0,suspensionLength:0,maxSuspensionTravel:1,useCustomSlidingRotationalSpeed:!1,customSlidingRotationalSpeed:-.1}),this.maxSuspensionTravel=t.maxSuspensionTravel,this.customSlidingRotationalSpeed=t.customSlidingRotationalSpeed,this.useCustomSlidingRotationalSpeed=t.useCustomSlidingRotationalSpeed,this.sliding=!1,this.chassisConnectionPointLocal=t.chassisConnectionPointLocal.clone(),this.chassisConnectionPointWorld=t.chassisConnectionPointWorld.clone(),this.directionLocal=t.directionLocal.clone(),this.directionWorld=t.directionWorld.clone(),this.axleLocal=t.axleLocal.clone(),this.axleWorld=t.axleWorld.clone(),this.suspensionRestLength=t.suspensionRestLength,this.suspensionMaxLength=t.suspensionMaxLength,this.radius=t.radius,this.suspensionStiffness=t.suspensionStiffness,this.dampingCompression=t.dampingCompression,this.dampingRelaxation=t.dampingRelaxation,this.frictionSlip=t.frictionSlip,this.steering=0,this.rotation=0,this.deltaRotation=0,this.rollInfluence=t.rollInfluence,this.maxSuspensionForce=t.maxSuspensionForce,this.engineForce=0,this.brake=0,this.isFrontWheel=t.isFrontWheel,this.clippedInvContactDotSuspension=1,this.suspensionRelativeVelocity=0,this.suspensionForce=0,this.skidInfo=0,this.suspensionLength=0,this.sideImpulse=0,this.forwardImpulse=0,this.raycastResult=new o,this.worldTransform=new r,this.isInContact=!1}e.exports=s;var c=new i,h=new i;c=new i,s.prototype.updateWheel=function(t){var e=this.raycastResult;if(this.isInContact){var n=e.hitNormalWorld.dot(e.directionWorld);e.hitPointWorld.vsub(t.position,h),t.getVelocityAtWorldPoint(h,c);var i=e.hitNormalWorld.dot(c);if(n>=-.1)this.suspensionRelativeVelocity=0,this.clippedInvContactDotSuspension=10;else{var r=-1/n;this.suspensionRelativeVelocity=i*r,this.clippedInvContactDotSuspension=r}}else e.suspensionLength=this.suspensionRestLength,this.suspensionRelativeVelocity=0,e.directionWorld.scale(-1,e.hitNormalWorld),this.clippedInvContactDotSuspension=1}},{"../collision/RaycastResult":10,"../math/Transform":29,"../math/Vec3":30,"../utils/Utils":53}],37:[function(t,e,n){e.exports=a;var i=t("./Shape"),r=t("../math/Vec3"),o=t("./ConvexPolyhedron");function a(t){i.call(this),this.type=i.types.BOX,this.halfExtents=t,this.convexPolyhedronRepresentation=null,this.updateConvexPolyhedronRepresentation(),this.updateBoundingSphereRadius()}a.prototype=new i,a.prototype.constructor=a,a.prototype.updateConvexPolyhedronRepresentation=function(){var t=this.halfExtents.x,e=this.halfExtents.y,n=this.halfExtents.z,i=r,a=[new i(-t,-e,-n),new i(t,-e,-n),new i(t,e,-n),new i(-t,e,-n),new i(-t,-e,n),new i(t,-e,n),new i(t,e,n),new i(-t,e,n)],s=(new i(0,0,1),new i(0,1,0),new i(1,0,0),new o(a,[[3,2,1,0],[4,5,6,7],[5,4,0,1],[2,3,7,6],[0,4,7,3],[1,2,6,5]]));this.convexPolyhedronRepresentation=s,s.material=this.material},a.prototype.calculateLocalInertia=function(t,e){return e=e||new r,a.calculateInertia(this.halfExtents,t,e),e},a.calculateInertia=function(t,e,n){var i=t;n.x=1/12*e*(2*i.y*2*i.y+2*i.z*2*i.z),n.y=1/12*e*(2*i.x*2*i.x+2*i.z*2*i.z),n.z=1/12*e*(2*i.y*2*i.y+2*i.x*2*i.x)},a.prototype.getSideNormals=function(t,e){var n=t,i=this.halfExtents;if(n[0].set(i.x,0,0),n[1].set(0,i.y,0),n[2].set(0,0,i.z),n[3].set(-i.x,0,0),n[4].set(0,-i.y,0),n[5].set(0,0,-i.z),void 0!==e)for(var r=0;r!==n.length;r++)e.vmult(n[r],n[r]);return n},a.prototype.volume=function(){return 8*this.halfExtents.x*this.halfExtents.y*this.halfExtents.z},a.prototype.updateBoundingSphereRadius=function(){this.boundingSphereRadius=this.halfExtents.norm()};var s=new r;new r,a.prototype.forEachWorldCorner=function(t,e,n){for(var i=this.halfExtents,r=[[i.x,i.y,i.z],[-i.x,i.y,i.z],[-i.x,-i.y,i.z],[-i.x,-i.y,-i.z],[i.x,-i.y,-i.z],[i.x,i.y,-i.z],[-i.x,i.y,-i.z],[i.x,-i.y,i.z]],o=0;o<r.length;o++)s.set(r[o][0],r[o][1],r[o][2]),e.vmult(s,s),t.vadd(s,s),n(s.x,s.y,s.z)};var c=[new r,new r,new r,new r,new r,new r,new r,new r];a.prototype.calculateWorldAABB=function(t,e,n,i){var r=this.halfExtents;c[0].set(r.x,r.y,r.z),c[1].set(-r.x,r.y,r.z),c[2].set(-r.x,-r.y,r.z),c[3].set(-r.x,-r.y,-r.z),c[4].set(r.x,-r.y,-r.z),c[5].set(r.x,r.y,-r.z),c[6].set(-r.x,r.y,-r.z),c[7].set(r.x,-r.y,r.z);var o=c[0];e.vmult(o,o),t.vadd(o,o),i.copy(o),n.copy(o);for(var a=1;a<8;a++){o=c[a],e.vmult(o,o),t.vadd(o,o);var s=o.x,h=o.y,l=o.z;s>i.x&&(i.x=s),h>i.y&&(i.y=h),l>i.z&&(i.z=l),s<n.x&&(n.x=s),h<n.y&&(n.y=h),l<n.z&&(n.z=l)}}},{"../math/Vec3":30,"./ConvexPolyhedron":38,"./Shape":43}],38:[function(t,e,n){e.exports=a;var i=t("./Shape"),r=t("../math/Vec3"),o=(t("../math/Quaternion"),t("../math/Transform"));function a(t,e,n){i.call(this),this.type=i.types.CONVEXPOLYHEDRON,this.vertices=t||[],this.worldVertices=[],this.worldVerticesNeedsUpdate=!0,this.faces=e||[],this.faceNormals=[],this.computeNormals(),this.worldFaceNormalsNeedsUpdate=!0,this.worldFaceNormals=[],this.uniqueEdges=[],this.uniqueAxes=n?n.slice():null,this.computeEdges(),this.updateBoundingSphereRadius()}a.prototype=new i,a.prototype.constructor=a;var s=new r;a.prototype.computeEdges=function(){var t=this.faces,e=this.vertices,n=(e.length,this.uniqueEdges);n.length=0;for(var i=s,r=0;r!==t.length;r++)for(var o=t[r],a=o.length,c=0;c!==a;c++){var h=(c+1)%a;e[o[c]].vsub(e[o[h]],i),i.normalize();for(var l=!1,u=0;u!==n.length;u++)if(n[u].almostEquals(i)||n[u].almostEquals(i)){l=!0;break}l||n.push(i.clone())}},a.prototype.computeNormals=function(){this.faceNormals.length=this.faces.length;for(var t=0;t<this.faces.length;t++){for(var e=0;e<this.faces[t].length;e++)if(!this.vertices[this.faces[t][e]])throw new Error("Vertex "+this.faces[t][e]+" not found!");var n=this.faceNormals[t]||new r;this.getFaceNormal(t,n),n.negate(n),this.faceNormals[t]=n;var i=this.vertices[this.faces[t][0]];if(n.dot(i)<0)for(console.error(".faceNormals["+t+"] = Vec3("+n.toString()+") looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule."),e=0;e<this.faces[t].length;e++)console.warn(".vertices["+this.faces[t][e]+"] = Vec3("+this.vertices[this.faces[t][e]].toString()+")")}};var c=new r,h=new r;a.computeNormal=function(t,e,n,i){e.vsub(t,h),n.vsub(e,c),c.cross(h,i),i.isZero()||i.normalize()},a.prototype.getFaceNormal=function(t,e){var n=this.faces[t],i=this.vertices[n[0]],r=this.vertices[n[1]],o=this.vertices[n[2]];return a.computeNormal(i,r,o,e)};var l=new r;a.prototype.clipAgainstHull=function(t,e,n,i,o,a,s,c,h){for(var u=l,p=-1,d=-Number.MAX_VALUE,f=0;f<n.faces.length;f++){u.copy(n.faceNormals[f]),o.vmult(u,u);var m=u.dot(a);m>d&&(d=m,p=f)}for(var v=[],g=n.faces[p],y=g.length,x=0;x<y;x++){var w=n.vertices[g[x]],b=new r;b.copy(w),o.vmult(b,b),i.vadd(b,b),v.push(b)}p>=0&&this.clipFaceAgainstHull(a,t,e,v,s,c,h)};var u=new r,p=new r,d=new r,f=new r,m=new r,v=new r;a.prototype.findSeparatingAxis=function(t,e,n,i,r,o,a,s){var c=u,h=p,l=d,g=f,y=m,x=v,w=Number.MAX_VALUE;if(this.uniqueAxes)for(_=0;_!==this.uniqueAxes.length;_++){if(n.vmult(this.uniqueAxes[_],c),!1===(S=this.testSepAxis(c,t,e,n,i,r)))return!1;S<w&&(w=S,o.copy(c))}else for(var b=a?a.length:this.faces.length,_=0;_<b;_++){var M=a?a[_]:_;if(c.copy(this.faceNormals[M]),n.vmult(c,c),!1===(S=this.testSepAxis(c,t,e,n,i,r)))return!1;S<w&&(w=S,o.copy(c))}if(t.uniqueAxes)for(_=0;_!==t.uniqueAxes.length;_++){if(r.vmult(t.uniqueAxes[_],h),!1===(S=this.testSepAxis(h,t,e,n,i,r)))return!1;S<w&&(w=S,o.copy(h))}else for(var E=s?s.length:t.faces.length,_=0;_<E;_++){var S;if(M=s?s[_]:_,h.copy(t.faceNormals[M]),r.vmult(h,h),!1===(S=this.testSepAxis(h,t,e,n,i,r)))return!1;S<w&&(w=S,o.copy(h))}for(var T=0;T!==this.uniqueEdges.length;T++){n.vmult(this.uniqueEdges[T],g);for(var A=0;A!==t.uniqueEdges.length;A++)if(r.vmult(t.uniqueEdges[A],y),g.cross(y,x),!x.almostZero()){x.normalize();var R=this.testSepAxis(x,t,e,n,i,r);if(!1===R)return!1;R<w&&(w=R,o.copy(x))}}return i.vsub(e,l),l.dot(o)>0&&o.negate(o),!0};var g=[],y=[];a.prototype.testSepAxis=function(t,e,n,i,r,o){a.project(this,t,n,i,g),a.project(e,t,r,o,y);var s=g[0],c=g[1],h=y[0],l=y[1];if(s<l||h<c)return!1;var u=s-l,p=h-c;return u<p?u:p};var x=new r,w=new r;a.prototype.calculateLocalInertia=function(t,e){this.computeLocalAABB(x,w);var n=w.x-x.x,i=w.y-x.y,r=w.z-x.z;e.x=1/12*t*(2*i*2*i+2*r*2*r),e.y=1/12*t*(2*n*2*n+2*r*2*r),e.z=1/12*t*(2*i*2*i+2*n*2*n)},a.prototype.getPlaneConstantOfFace=function(t){var e=this.faces[t],n=this.faceNormals[t],i=this.vertices[e[0]];return-n.dot(i)};var b=new r,_=new r,M=new r,E=new r,S=new r,T=new r,A=new r,R=new r;a.prototype.clipFaceAgainstHull=function(t,e,n,i,r,o,a){for(var s=b,c=_,h=M,l=E,u=S,p=T,d=A,f=R,m=i,v=[],g=-1,y=Number.MAX_VALUE,x=0;x<this.faces.length;x++){s.copy(this.faceNormals[x]),n.vmult(s,s);var w=s.dot(t);w<y&&(y=w,g=x)}if(!(g<0)){var C=this.faces[g];C.connectedFaces=[];for(var L=0;L<this.faces.length;L++)for(var P=0;P<this.faces[L].length;P++)-1!==C.indexOf(this.faces[L][P])&&L!==g&&-1===C.connectedFaces.indexOf(L)&&C.connectedFaces.push(L);m.length;for(var B=C.length,I=0;I<B;I++){var N=this.vertices[C[I]],O=this.vertices[C[(I+1)%B]];N.vsub(O,c),h.copy(c),n.vmult(h,h),e.vadd(h,h),l.copy(this.faceNormals[g]),n.vmult(l,l),e.vadd(l,l),h.cross(l,u),u.negate(u),p.copy(N),n.vmult(p,p),e.vadd(p,p),p.dot(u);var F=C.connectedFaces[I];d.copy(this.faceNormals[F]);var z=this.getPlaneConstantOfFace(F);f.copy(d),n.vmult(f,f);var D=z-f.dot(e);for(this.clipFaceAgainstPlane(m,v,f,D);m.length;)m.shift();for(;v.length;)m.push(v.shift())}for(d.copy(this.faceNormals[g]),z=this.getPlaneConstantOfFace(g),f.copy(d),n.vmult(f,f),D=z-f.dot(e),L=0;L<m.length;L++){var U=f.dot(m[L])+D;if(U<=r&&(console.log("clamped: depth="+U+" to minDist="+r),U=r),U<=o){var V=m[L];if(U<=0){var G={point:V,normal:f,depth:U};a.push(G)}}}}},a.prototype.clipFaceAgainstPlane=function(t,e,n,i){var o,a,s=t.length;if(s<2)return e;var c=t[t.length-1],h=t[0];o=n.dot(c)+i;for(var l=0;l<s;l++){if(h=t[l],a=n.dot(h)+i,o<0)if(a<0)(u=new r).copy(h),e.push(u);else{var u=new r;c.lerp(h,o/(o-a),u),e.push(u)}else a<0&&(u=new r,c.lerp(h,o/(o-a),u),e.push(u),e.push(h));c=h,o=a}return e},a.prototype.computeWorldVertices=function(t,e){for(var n=this.vertices.length;this.worldVertices.length<n;)this.worldVertices.push(new r);for(var i=this.vertices,o=this.worldVertices,a=0;a!==n;a++)e.vmult(i[a],o[a]),t.vadd(o[a],o[a]);this.worldVerticesNeedsUpdate=!1},new r,a.prototype.computeLocalAABB=function(t,e){var n=this.vertices.length,i=this.vertices;t.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),e.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var r=0;r<n;r++){var o=i[r];o.x<t.x?t.x=o.x:o.x>e.x&&(e.x=o.x),o.y<t.y?t.y=o.y:o.y>e.y&&(e.y=o.y),o.z<t.z?t.z=o.z:o.z>e.z&&(e.z=o.z)}},a.prototype.computeWorldFaceNormals=function(t){for(var e=this.faceNormals.length;this.worldFaceNormals.length<e;)this.worldFaceNormals.push(new r);for(var n=this.faceNormals,i=this.worldFaceNormals,o=0;o!==e;o++)t.vmult(n[o],i[o]);this.worldFaceNormalsNeedsUpdate=!1},a.prototype.updateBoundingSphereRadius=function(){for(var t=0,e=this.vertices,n=0,i=e.length;n!==i;n++){var r=e[n].norm2();r>t&&(t=r)}this.boundingSphereRadius=Math.sqrt(t)};var C=new r;a.prototype.calculateWorldAABB=function(t,e,n,i){for(var r,o,a,s,c,h,l=this.vertices.length,u=this.vertices,p=0;p<l;p++){C.copy(u[p]),e.vmult(C,C),t.vadd(C,C);var d=C;d.x<r||void 0===r?r=d.x:(d.x>s||void 0===s)&&(s=d.x),d.y<o||void 0===o?o=d.y:(d.y>c||void 0===c)&&(c=d.y),d.z<a||void 0===a?a=d.z:(d.z>h||void 0===h)&&(h=d.z)}n.set(r,o,a),i.set(s,c,h)},a.prototype.volume=function(){return 4*Math.PI*this.boundingSphereRadius/3},a.prototype.getAveragePointLocal=function(t){t=t||new r;for(var e=this.vertices.length,n=this.vertices,i=0;i<e;i++)t.vadd(n[i],t);return t.mult(1/e,t),t},a.prototype.transformAllPoints=function(t,e){var n=this.vertices.length,i=this.vertices;if(e){for(var r=0;r<n;r++){var o=i[r];e.vmult(o,o)}for(r=0;r<this.faceNormals.length;r++)o=this.faceNormals[r],e.vmult(o,o)}if(t)for(r=0;r<n;r++)(o=i[r]).vadd(t,o)};var L=new r,P=new r,B=new r;a.prototype.pointIsInside=function(t){var e=this.vertices.length,n=this.vertices,i=this.faces,r=this.faceNormals,o=this.faces.length,a=L;this.getAveragePointLocal(a);for(var s=0;s<o;s++){this.faces[s].length,e=r[s];var c=n[i[s][0]],h=P;t.vsub(c,h);var l=e.dot(h),u=B;a.vsub(c,u);var p=e.dot(u);if(l<0&&p>0||l>0&&p<0)return!1}return-1},new r;var I=new r,N=new r;a.project=function(t,e,n,i,r){var a=t.vertices.length,s=I,c=0,h=0,l=N,u=t.vertices;l.setZero(),o.vectorToLocalFrame(n,i,e,s),o.pointToLocalFrame(n,i,l,l);var p=l.dot(s);h=c=u[0].dot(s);for(var d=1;d<a;d++){var f=u[d].dot(s);f>c&&(c=f),f<h&&(h=f)}if((h-=p)>(c-=p)){var m=h;h=c,c=m}r[0]=c,r[1]=h}},{"../math/Quaternion":28,"../math/Transform":29,"../math/Vec3":30,"./Shape":43}],39:[function(t,e,n){e.exports=a;var i=t("./Shape"),r=t("../math/Vec3"),o=(t("../math/Quaternion"),t("./ConvexPolyhedron"));function a(t,e,n,a){var s=a,c=[],h=[],l=[],u=[],p=[],d=Math.cos,f=Math.sin;c.push(new r(e*d(0),e*f(0),.5*-n)),u.push(0),c.push(new r(t*d(0),t*f(0),.5*n)),p.push(1);for(var m=0;m<s;m++){var v=2*Math.PI/s*(m+1),g=2*Math.PI/s*(m+.5);m<s-1?(c.push(new r(e*d(v),e*f(v),.5*-n)),u.push(2*m+2),c.push(new r(t*d(v),t*f(v),.5*n)),p.push(2*m+3),l.push([2*m+2,2*m+3,2*m+1,2*m])):l.push([0,1,2*m+1,2*m]),(s%2==1||m<s/2)&&h.push(new r(d(g),f(g),0))}l.push(p),h.push(new r(0,0,1));var y=[];for(m=0;m<u.length;m++)y.push(u[u.length-m-1]);l.push(y),this.type=i.types.CONVEXPOLYHEDRON,o.call(this,c,l,h)}a.prototype=new o},{"../math/Quaternion":28,"../math/Vec3":30,"./ConvexPolyhedron":38,"./Shape":43}],40:[function(t,e,n){var i=t("./Shape"),r=t("./ConvexPolyhedron"),o=t("../math/Vec3"),a=t("../utils/Utils");function s(t,e){e=a.defaults(e,{maxValue:null,minValue:null,elementSize:1}),this.data=t,this.maxValue=e.maxValue,this.minValue=e.minValue,this.elementSize=e.elementSize,null===e.minValue&&this.updateMinValue(),null===e.maxValue&&this.updateMaxValue(),this.cacheEnabled=!0,i.call(this),this.pillarConvex=new r,this.pillarOffset=new o,this.type=i.types.HEIGHTFIELD,this.updateBoundingSphereRadius(),this._cachedPillars={}}e.exports=s,s.prototype=new i,s.prototype.update=function(){this._cachedPillars={}},s.prototype.updateMinValue=function(){for(var t=this.data,e=t[0][0],n=0;n!==t.length;n++)for(var i=0;i!==t[n].length;i++){var r=t[n][i];r<e&&(e=r)}this.minValue=e},s.prototype.updateMaxValue=function(){for(var t=this.data,e=t[0][0],n=0;n!==t.length;n++)for(var i=0;i!==t[n].length;i++){var r=t[n][i];r>e&&(e=r)}this.maxValue=e},s.prototype.setHeightValueAtIndex=function(t,e,n){this.data[t][e]=n,this.clearCachedConvexTrianglePillar(t,e,!1),t>0&&(this.clearCachedConvexTrianglePillar(t-1,e,!0),this.clearCachedConvexTrianglePillar(t-1,e,!1)),e>0&&(this.clearCachedConvexTrianglePillar(t,e-1,!0),this.clearCachedConvexTrianglePillar(t,e-1,!1)),e>0&&t>0&&this.clearCachedConvexTrianglePillar(t-1,e-1,!0)},s.prototype.getRectMinMax=function(t,e,n,i,r){r=r||[];for(var o=this.data,a=this.minValue,s=t;s<=n;s++)for(var c=e;c<=i;c++){var h=o[s][c];h>a&&(a=h)}r[0]=this.minValue,r[1]=a},s.prototype.getIndexOfPosition=function(t,e,n,i){var r=this.elementSize,o=this.data,a=Math.floor(t/r),s=Math.floor(e/r);return n[0]=a,n[1]=s,i&&(a<0&&(a=0),s<0&&(s=0),a>=o.length-1&&(a=o.length-1),s>=o[0].length-1&&(s=o[0].length-1)),!(a<0||s<0||a>=o.length-1||s>=o[0].length-1)},s.prototype.getHeightAt=function(t,e,n){var i=[];this.getIndexOfPosition(t,e,i,n);var r=[];return this.getRectMinMax(i[0],i[1]+1,i[0],i[1]+1,r),(r[0]+r[1])/2},s.prototype.getCacheConvexTrianglePillarKey=function(t,e,n){return t+"_"+e+"_"+(n?1:0)},s.prototype.getCachedConvexTrianglePillar=function(t,e,n){return this._cachedPillars[this.getCacheConvexTrianglePillarKey(t,e,n)]},s.prototype.setCachedConvexTrianglePillar=function(t,e,n,i,r){this._cachedPillars[this.getCacheConvexTrianglePillarKey(t,e,n)]={convex:i,offset:r}},s.prototype.clearCachedConvexTrianglePillar=function(t,e,n){delete this._cachedPillars[this.getCacheConvexTrianglePillarKey(t,e,n)]},s.prototype.getConvexTrianglePillar=function(t,e,n){var i=this.pillarConvex,a=this.pillarOffset;if(this.cacheEnabled){if(s=this.getCachedConvexTrianglePillar(t,e,n))return this.pillarConvex=s.convex,void(this.pillarOffset=s.offset);i=new r,a=new o,this.pillarConvex=i,this.pillarOffset=a}var s=this.data,c=this.elementSize,h=i.faces;i.vertices.length=6;for(var l=0;l<6;l++)i.vertices[l]||(i.vertices[l]=new o);for(h.length=5,l=0;l<5;l++)h[l]||(h[l]=[]);var u=i.vertices,p=(Math.min(s[t][e],s[t+1][e],s[t][e+1],s[t+1][e+1])-this.minValue)/2+this.minValue;n?(a.set((t+.75)*c,(e+.75)*c,p),u[0].set(.25*c,.25*c,s[t+1][e+1]-p),u[1].set(-.75*c,.25*c,s[t][e+1]-p),u[2].set(.25*c,-.75*c,s[t+1][e]-p),u[3].set(.25*c,.25*c,-p-1),u[4].set(-.75*c,.25*c,-p-1),u[5].set(.25*c,-.75*c,-p-1),h[0][0]=0,h[0][1]=1,h[0][2]=2,h[1][0]=5,h[1][1]=4,h[1][2]=3,h[2][0]=2,h[2][1]=5,h[2][2]=3,h[2][3]=0,h[3][0]=3,h[3][1]=4,h[3][2]=1,h[3][3]=0,h[4][0]=1,h[4][1]=4,h[4][2]=5,h[4][3]=2):(a.set((t+.25)*c,(e+.25)*c,p),u[0].set(-.25*c,-.25*c,s[t][e]-p),u[1].set(.75*c,-.25*c,s[t+1][e]-p),u[2].set(-.25*c,.75*c,s[t][e+1]-p),u[3].set(-.25*c,-.25*c,-p-1),u[4].set(.75*c,-.25*c,-p-1),u[5].set(-.25*c,.75*c,-p-1),h[0][0]=0,h[0][1]=1,h[0][2]=2,h[1][0]=5,h[1][1]=4,h[1][2]=3,h[2][0]=0,h[2][1]=2,h[2][2]=5,h[2][3]=3,h[3][0]=1,h[3][1]=0,h[3][2]=3,h[3][3]=4,h[4][0]=4,h[4][1]=5,h[4][2]=2,h[4][3]=1),i.computeNormals(),i.computeEdges(),i.updateBoundingSphereRadius(),this.setCachedConvexTrianglePillar(t,e,n,i,a)},s.prototype.calculateLocalInertia=function(t,e){return(e=e||new o).set(0,0,0),e},s.prototype.volume=function(){return Number.MAX_VALUE},s.prototype.calculateWorldAABB=function(t,e,n,i){n.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),i.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},s.prototype.updateBoundingSphereRadius=function(){var t=this.data,e=this.elementSize;this.boundingSphereRadius=new o(t.length*e,t[0].length*e,Math.max(Math.abs(this.maxValue),Math.abs(this.minValue))).norm()}},{"../math/Vec3":30,"../utils/Utils":53,"./ConvexPolyhedron":38,"./Shape":43}],41:[function(t,e,n){e.exports=o;var i=t("./Shape"),r=t("../math/Vec3");function o(){i.call(this),this.type=i.types.PARTICLE}o.prototype=new i,o.prototype.constructor=o,o.prototype.calculateLocalInertia=function(t,e){return(e=e||new r).set(0,0,0),e},o.prototype.volume=function(){return 0},o.prototype.updateBoundingSphereRadius=function(){this.boundingSphereRadius=0},o.prototype.calculateWorldAABB=function(t,e,n,i){n.copy(t),i.copy(t)}},{"../math/Vec3":30,"./Shape":43}],42:[function(t,e,n){e.exports=o;var i=t("./Shape"),r=t("../math/Vec3");function o(){i.call(this),this.type=i.types.PLANE,this.worldNormal=new r,this.worldNormalNeedsUpdate=!0,this.boundingSphereRadius=Number.MAX_VALUE}o.prototype=new i,o.prototype.constructor=o,o.prototype.computeWorldNormal=function(t){var e=this.worldNormal;e.set(0,0,1),t.vmult(e,e),this.worldNormalNeedsUpdate=!1},o.prototype.calculateLocalInertia=function(t,e){return e=e||new r},o.prototype.volume=function(){return Number.MAX_VALUE};var a=new r;o.prototype.calculateWorldAABB=function(t,e,n,i){a.set(0,0,1),e.vmult(a,a);var r=Number.MAX_VALUE;n.set(-r,-r,-r),i.set(r,r,r),1===a.x&&(i.x=t.x),1===a.y&&(i.y=t.y),1===a.z&&(i.z=t.z),-1===a.x&&(n.x=t.x),-1===a.y&&(n.y=t.y),-1===a.z&&(n.z=t.z)},o.prototype.updateBoundingSphereRadius=function(){this.boundingSphereRadius=Number.MAX_VALUE}},{"../math/Vec3":30,"./Shape":43}],43:[function(t,e,n){e.exports=i;var i=t("./Shape");function i(){this.id=i.idCounter++,this.type=0,this.boundingSphereRadius=0,this.collisionResponse=!0,this.material=null}t("../math/Vec3"),t("../math/Quaternion"),t("../material/Material"),i.prototype.constructor=i,i.prototype.updateBoundingSphereRadius=function(){throw"computeBoundingSphereRadius() not implemented for shape type "+this.type},i.prototype.volume=function(){throw"volume() not implemented for shape type "+this.type},i.prototype.calculateLocalInertia=function(t,e){throw"calculateLocalInertia() not implemented for shape type "+this.type},i.idCounter=0,i.types={SPHERE:1,PLANE:2,BOX:4,COMPOUND:8,CONVEXPOLYHEDRON:16,HEIGHTFIELD:32,PARTICLE:64,CYLINDER:128,TRIMESH:256}},{"../material/Material":25,"../math/Quaternion":28,"../math/Vec3":30,"./Shape":43}],44:[function(t,e,n){e.exports=o;var i=t("./Shape"),r=t("../math/Vec3");function o(t){if(i.call(this),this.radius=void 0!==t?Number(t):1,this.type=i.types.SPHERE,this.radius<0)throw new Error("The sphere radius cannot be negative.");this.updateBoundingSphereRadius()}o.prototype=new i,o.prototype.constructor=o,o.prototype.calculateLocalInertia=function(t,e){e=e||new r;var n=2*t*this.radius*this.radius/5;return e.x=n,e.y=n,e.z=n,e},o.prototype.volume=function(){return 4*Math.PI*this.radius/3},o.prototype.updateBoundingSphereRadius=function(){this.boundingSphereRadius=this.radius},o.prototype.calculateWorldAABB=function(t,e,n,i){for(var r=this.radius,o=["x","y","z"],a=0;a<o.length;a++){var s=o[a];n[s]=t[s]-r,i[s]=t[s]+r}}},{"../math/Vec3":30,"./Shape":43}],45:[function(t,e,n){e.exports=c;var i=t("./Shape"),r=t("../math/Vec3"),o=(t("../math/Quaternion"),t("../math/Transform")),a=t("../collision/AABB"),s=t("../utils/Octree");function c(t,e){i.call(this),this.type=i.types.TRIMESH,this.vertices=new Float32Array(t),this.indices=new Int16Array(e),this.normals=new Float32Array(e.length),this.aabb=new a,this.edges=null,this.scale=new r(1,1,1),this.tree=new s,this.updateEdges(),this.updateNormals(),this.updateAABB(),this.updateBoundingSphereRadius(),this.updateTree()}c.prototype=new i,c.prototype.constructor=c;var h=new r;c.prototype.updateTree=function(){var t=this.tree;t.reset(),t.aabb.copy(this.aabb);var e=this.scale;t.aabb.lowerBound.x*=1/e.x,t.aabb.lowerBound.y*=1/e.y,t.aabb.lowerBound.z*=1/e.z,t.aabb.upperBound.x*=1/e.x,t.aabb.upperBound.y*=1/e.y,t.aabb.upperBound.z*=1/e.z;for(var n=new a,i=new r,o=new r,s=new r,c=[i,o,s],h=0;h<this.indices.length/3;h++){var l=3*h;this._getUnscaledVertex(this.indices[l],i),this._getUnscaledVertex(this.indices[l+1],o),this._getUnscaledVertex(this.indices[l+2],s),n.setFromPoints(c),t.insert(n,h)}t.removeEmptyNodes()};var l=new a;c.prototype.getTrianglesInAABB=function(t,e){l.copy(t);var n=this.scale,i=n.x,r=n.y,o=n.z,a=l.lowerBound,s=l.upperBound;return a.x/=i,a.y/=r,a.z/=o,s.x/=i,s.y/=r,s.z/=o,this.tree.aabbQuery(l,e)},c.prototype.setScale=function(t){var e=this.scale.x===this.scale.y===this.scale.z,n=t.x===t.y===t.z;e&&n||this.updateNormals(),this.scale.copy(t),this.updateAABB(),this.updateBoundingSphereRadius()},c.prototype.updateNormals=function(){for(var t=h,e=this.normals,n=0;n<this.indices.length/3;n++){var i=3*n,r=this.indices[i],o=this.indices[i+1],a=this.indices[i+2];this.getVertex(r,m),this.getVertex(o,v),this.getVertex(a,g),c.computeNormal(v,m,g,t),e[i]=t.x,e[i+1]=t.y,e[i+2]=t.z}},c.prototype.updateEdges=function(){for(var t={},e=function(e,n){t[r<o?r+"_"+o:o+"_"+r]=!0},n=0;n<this.indices.length/3;n++){var i=3*n,r=this.indices[i],o=this.indices[i+1];this.indices[i+2],e(),e(),e()}var a=Object.keys(t);for(this.edges=new Int16Array(2*a.length),n=0;n<a.length;n++){var s=a[n].split("_");this.edges[2*n]=parseInt(s[0],10),this.edges[2*n+1]=parseInt(s[1],10)}},c.prototype.getEdgeVertex=function(t,e,n){var i=this.edges[2*t+(e?1:0)];this.getVertex(i,n)};var u=new r,p=new r;c.prototype.getEdgeVector=function(t,e){var n=u,i=p;this.getEdgeVertex(t,0,n),this.getEdgeVertex(t,1,i),i.vsub(n,e)};var d=new r,f=new r;c.computeNormal=function(t,e,n,i){e.vsub(t,f),n.vsub(e,d),d.cross(f,i),i.isZero()||i.normalize()};var m=new r,v=new r,g=new r;c.prototype.getVertex=function(t,e){var n=this.scale;return this._getUnscaledVertex(t,e),e.x*=n.x,e.y*=n.y,e.z*=n.z,e},c.prototype._getUnscaledVertex=function(t,e){var n=3*t,i=this.vertices;return e.set(i[n],i[n+1],i[n+2])},c.prototype.getWorldVertex=function(t,e,n,i){return this.getVertex(t,i),o.pointToWorldFrame(e,n,i,i),i},c.prototype.getTriangleVertices=function(t,e,n,i){var r=3*t;this.getVertex(this.indices[r],e),this.getVertex(this.indices[r+1],n),this.getVertex(this.indices[r+2],i)},c.prototype.getNormal=function(t,e){var n=3*t;return e.set(this.normals[n],this.normals[n+1],this.normals[n+2])};var y=new a;c.prototype.calculateLocalInertia=function(t,e){this.computeLocalAABB(y);var n=y.upperBound.x-y.lowerBound.x,i=y.upperBound.y-y.lowerBound.y,r=y.upperBound.z-y.lowerBound.z;return e.set(1/12*t*(2*i*2*i+2*r*2*r),1/12*t*(2*n*2*n+2*r*2*r),1/12*t*(2*i*2*i+2*n*2*n))};var x=new r;c.prototype.computeLocalAABB=function(t){var e=t.lowerBound,n=t.upperBound,i=this.vertices.length,r=(this.vertices,x);this.getVertex(0,r),e.copy(r),n.copy(r);for(var o=0;o!==i;o++)this.getVertex(o,r),r.x<e.x?e.x=r.x:r.x>n.x&&(n.x=r.x),r.y<e.y?e.y=r.y:r.y>n.y&&(n.y=r.y),r.z<e.z?e.z=r.z:r.z>n.z&&(n.z=r.z)},c.prototype.updateAABB=function(){this.computeLocalAABB(this.aabb)},c.prototype.updateBoundingSphereRadius=function(){for(var t=0,e=this.vertices,n=new r,i=0,o=e.length/3;i!==o;i++){this.getVertex(i,n);var a=n.norm2();a>t&&(t=a)}this.boundingSphereRadius=Math.sqrt(t)},new r;var w=new o,b=new a;c.prototype.calculateWorldAABB=function(t,e,n,i){var r=w,o=b;r.position=t,r.quaternion=e,this.aabb.toWorldFrame(r,o),n.copy(o.lowerBound),i.copy(o.upperBound)},c.prototype.volume=function(){return 4*Math.PI*this.boundingSphereRadius/3},c.createTorus=function(t,e,n,i,r){t=t||1,e=e||.5,n=n||8,i=i||6,r=r||2*Math.PI;for(var o=[],a=[],s=0;s<=n;s++)for(var h=0;h<=i;h++){var l=h/i*r,u=s/n*Math.PI*2,p=(t+e*Math.cos(u))*Math.cos(l),d=(t+e*Math.cos(u))*Math.sin(l),f=e*Math.sin(u);o.push(p,d,f)}for(s=1;s<=n;s++)for(h=1;h<=i;h++){var m=(i+1)*s+h-1,v=(i+1)*(s-1)+h-1,g=(i+1)*(s-1)+h,y=(i+1)*s+h;a.push(m,v,y),a.push(v,g,y)}return new c(o,a)}},{"../collision/AABB":3,"../math/Quaternion":28,"../math/Transform":29,"../math/Vec3":30,"../utils/Octree":50,"./Shape":43}],46:[function(t,e,n){e.exports=r,t("../math/Vec3"),t("../math/Quaternion");var i=t("./Solver");function r(){i.call(this),this.iterations=10,this.tolerance=1e-7}r.prototype=new i;var o=[],a=[],s=[];r.prototype.solve=function(t,e){var n,i,r,c,h,l=0,u=this.iterations,p=this.tolerance*this.tolerance,d=this.equations,f=d.length,m=e.bodies,v=m.length,g=t;if(0!==f)for(var y=0;y!==v;y++)m[y].updateSolveMassProperties();var x=a,w=s,b=o;for(x.length=f,w.length=f,b.length=f,y=0;y!==f;y++){var _=d[y];b[y]=0,w[y]=_.computeB(g),x[y]=1/_.computeC()}if(0!==f){for(y=0;y!==v;y++){var M=(T=m[y]).vlambda,E=T.wlambda;M.set(0,0,0),E&&E.set(0,0,0)}for(l=0;l!==u;l++){c=0;for(var S=0;S!==f;S++)_=d[S],n=w[S],i=x[S],(h=b[S])+(r=i*(n-_.computeGWlambda()-_.eps*h))<_.minForce?r=_.minForce-h:h+r>_.maxForce&&(r=_.maxForce-h),b[S]+=r,c+=r>0?r:-r,_.addToWlambda(r);if(c*c<p)break}for(y=0;y!==v;y++){var T,A=(T=m[y]).velocity,R=T.angularVelocity;A.vadd(T.vlambda,A),R&&R.vadd(T.wlambda,R)}}return l}},{"../math/Quaternion":28,"../math/Vec3":30,"./Solver":47}],47:[function(t,e,n){function i(){this.equations=[]}e.exports=i,i.prototype.solve=function(t,e){return 0},i.prototype.addEquation=function(t){t.enabled&&this.equations.push(t)},i.prototype.removeEquation=function(t){var e=this.equations,n=e.indexOf(t);-1!==n&&e.splice(n,1)},i.prototype.removeAllEquations=function(){this.equations.length=0}},{}],48:[function(t,e,n){e.exports=o,t("../math/Vec3"),t("../math/Quaternion");var i=t("./Solver"),r=t("../objects/Body");function o(t){for(i.call(this),this.iterations=10,this.tolerance=1e-7,this.subsolver=t,this.nodes=[],this.nodePool=[];this.nodePool.length<128;)this.nodePool.push(this.createNode())}o.prototype=new i;var a=[],s=[],c={bodies:[]},h=r.STATIC;function l(t){for(var e=t.length,n=0;n!==e;n++){var i=t[n];if(!(i.visited||i.body.type&h))return i}return!1}var u=[];function p(t,e,n,i){for(u.push(t),t.visited=!0,e(t,n,i);u.length;)for(var r,o=u.pop();r=l(o.children);)r.visited=!0,e(r,n,i),u.push(r)}function d(t,e,n){e.push(t.body);for(var i=t.eqs.length,r=0;r!==i;r++){var o=t.eqs[r];-1===n.indexOf(o)&&n.push(o)}}function f(t,e){return e.id-t.id}o.prototype.createNode=function(){return{body:null,children:[],eqs:[],visited:!1}},o.prototype.solve=function(t,e){for(var n=a,i=this.nodePool,r=e.bodies,o=this.equations,h=o.length,u=r.length,m=this.subsolver;i.length<u;)i.push(this.createNode());n.length=u;for(var v=0;v<u;v++)n[v]=i[v];for(v=0;v!==u;v++){var g=n[v];g.body=r[v],g.children.length=0,g.eqs.length=0,g.visited=!1}for(var y=0;y!==h;y++){var x=o[y],w=(v=r.indexOf(x.bi),r.indexOf(x.bj)),b=n[v],_=n[w];b.children.push(_),b.eqs.push(x),_.children.push(b),_.eqs.push(x)}var M,E=0,S=s;m.tolerance=this.tolerance,m.iterations=this.iterations;for(var T=c;M=l(n);){S.length=0,T.bodies.length=0,p(M,d,T.bodies,S);var A=S.length;for(S=S.sort(f),v=0;v!==A;v++)m.addEquation(S[v]);m.solve(t,T),m.removeAllEquations(),E++}return E}},{"../math/Quaternion":28,"../math/Vec3":30,"../objects/Body":31,"./Solver":47}],49:[function(t,e,n){var i=function(){};e.exports=i,i.prototype={constructor:i,addEventListener:function(t,e){void 0===this._listeners&&(this._listeners={});var n=this._listeners;return void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e),this},hasEventListener:function(t,e){if(void 0===this._listeners)return!1;var n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)},removeEventListener:function(t,e){if(void 0===this._listeners)return this;var n=this._listeners;if(void 0===n[t])return this;var i=n[t].indexOf(e);return-1!==i&&n[t].splice(i,1),this},dispatchEvent:function(t){if(void 0===this._listeners)return this;var e=this._listeners[t.type];if(void 0!==e){t.target=this;for(var n=0,i=e.length;n<i;n++)e[n].call(this,t)}return this}}},{}],50:[function(t,e,n){var i=t("../collision/AABB"),r=t("../math/Vec3");function o(t){t=t||{},this.root=t.root||null,this.aabb=t.aabb?t.aabb.clone():new i,this.data=[],this.children=[]}function a(t,e){(e=e||{}).root=null,e.aabb=t,o.call(this,e),this.maxDepth=void 0!==e.maxDepth?e.maxDepth:8}e.exports=a,a.prototype=new o,o.prototype.reset=function(t,e){this.children.length=this.data.length=0},o.prototype.insert=function(t,e,n){var i=this.data;if(n=n||0,!this.aabb.contains(t))return!1;var r=this.children;if(n<(this.maxDepth||this.root.maxDepth)){var o=!1;r.length||(this.subdivide(),o=!0);for(var a=0;8!==a;a++)if(r[a].insert(t,e,n+1))return!0;o&&(r.length=0)}return i.push(e),!0};var s=new r;o.prototype.subdivide=function(){var t=this.aabb,e=t.lowerBound,n=t.upperBound,a=this.children;a.push(new o({aabb:new i({lowerBound:new r(0,0,0)})}),new o({aabb:new i({lowerBound:new r(1,0,0)})}),new o({aabb:new i({lowerBound:new r(1,1,0)})}),new o({aabb:new i({lowerBound:new r(1,1,1)})}),new o({aabb:new i({lowerBound:new r(0,1,1)})}),new o({aabb:new i({lowerBound:new r(0,0,1)})}),new o({aabb:new i({lowerBound:new r(1,0,1)})}),new o({aabb:new i({lowerBound:new r(0,1,0)})})),n.vsub(e,s),s.scale(.5,s);for(var c=this.root||this,h=0;8!==h;h++){var l=a[h];l.root=c;var u=l.aabb.lowerBound;u.x*=s.x,u.y*=s.y,u.z*=s.z,u.vadd(e,u),u.vadd(s,l.aabb.upperBound)}},o.prototype.aabbQuery=function(t,e){this.data,this.children;for(var n=[this];n.length;){var i=n.pop();i.aabb.overlaps(t)&&Array.prototype.push.apply(e,i.data),Array.prototype.push.apply(n,i.children)}return e};var c=new i;o.prototype.rayQuery=function(t,e,n){return t.getAABB(c),c.toLocalFrame(e,c),this.aabbQuery(c,n),n},o.prototype.removeEmptyNodes=function(){for(var t=[this];t.length;){for(var e=t.pop(),n=e.children.length-1;n>=0;n--)e.children[n].data.length||e.children.splice(n,1);Array.prototype.push.apply(t,e.children)}}},{"../collision/AABB":3,"../math/Vec3":30}],51:[function(t,e,n){function i(){this.objects=[],this.type=Object}e.exports=i,i.prototype.release=function(){for(var t=arguments.length,e=0;e!==t;e++)this.objects.push(arguments[e])},i.prototype.get=function(){return 0===this.objects.length?this.constructObject():this.objects.pop()},i.prototype.constructObject=function(){throw new Error("constructObject() not implemented in this Pool subclass yet!")}},{}],52:[function(t,e,n){function i(){this.data={keys:[]}}e.exports=i,i.prototype.get=function(t,e){if(t>e){var n=e;e=t,t=n}return this.data[t+"-"+e]},i.prototype.set=function(t,e,n){if(t>e){var i=e;e=t,t=i}var r=t+"-"+e;this.get(t,e)||this.data.keys.push(r),this.data[r]=n},i.prototype.reset=function(){for(var t=this.data,e=t.keys;e.length>0;)delete t[e.pop()]}},{}],53:[function(t,e,n){function i(){}e.exports=i,i.defaults=function(t,e){for(var n in t=t||{},e)n in t||(t[n]=e[n]);return t}},{}],54:[function(t,e,n){e.exports=o;var i=t("../math/Vec3"),r=t("./Pool");function o(){r.call(this),this.type=i}o.prototype=new r,o.prototype.constructObject=function(){return new i}},{"../math/Vec3":30,"./Pool":51}],55:[function(t,e,n){e.exports=p;var i=t("../collision/AABB"),r=t("../shapes/Shape"),o=t("../collision/Ray"),a=t("../math/Vec3"),s=t("../math/Transform"),c=(t("../shapes/ConvexPolyhedron"),t("../math/Quaternion")),h=(t("../solver/Solver"),t("../utils/Vec3Pool")),l=t("../equations/ContactEquation"),u=t("../equations/FrictionEquation");function p(t){this.contactPointPool=[],this.frictionEquationPool=[],this.result=[],this.frictionResult=[],this.v3pool=new h,this.world=t,this.currentContactMaterial=null,this.enableFrictionReduction=!1}p.prototype.createContactEquation=function(t,e,n,i,r,o){var a;this.contactPointPool.length?((a=this.contactPointPool.pop()).bi=t,a.bj=e):a=new l(t,e),a.enabled=t.collisionResponse&&e.collisionResponse&&n.collisionResponse&&i.collisionResponse;var s=this.currentContactMaterial;a.restitution=s.restitution,a.setSpookParams(s.contactEquationStiffness,s.contactEquationRelaxation,this.world.dt);var c=n.material||t.material,h=i.material||e.material;return c&&h&&c.restitution>=0&&h.restitution>=0&&(a.restitution=c.restitution*h.restitution),a.si=r||n,a.sj=o||i,a},p.prototype.createFrictionEquationsFromContact=function(t,e){var n=t.bi,i=t.bj,r=t.si,o=t.sj,a=this.world,s=this.currentContactMaterial,c=s.friction,h=r.material||n.material,l=o.material||i.material;if(h&&l&&h.friction>=0&&l.friction>=0&&(c=h.friction*l.friction),c>0){var p=c*a.gravity.length(),d=n.invMass+i.invMass;d>0&&(d=1/d);var f=this.frictionEquationPool,m=f.length?f.pop():new u(n,i,p*d),v=f.length?f.pop():new u(n,i,p*d);return m.bi=v.bi=n,m.bj=v.bj=i,m.minForce=v.minForce=-p*d,m.maxForce=v.maxForce=p*d,m.ri.copy(t.ri),m.rj.copy(t.rj),v.ri.copy(t.ri),v.rj.copy(t.rj),t.ni.tangents(m.t,v.t),m.setSpookParams(s.frictionEquationStiffness,s.frictionEquationRelaxation,a.dt),v.setSpookParams(s.frictionEquationStiffness,s.frictionEquationRelaxation,a.dt),m.enabled=v.enabled=t.enabled,e.push(m,v),!0}return!1};var d=new a,f=new a,m=new a;p.prototype.createFrictionFromAverage=function(t){var e=this.result[this.result.length-1];if(this.createFrictionEquationsFromContact(e,this.frictionResult)&&1!==t){var n=this.frictionResult[this.frictionResult.length-2],i=this.frictionResult[this.frictionResult.length-1];d.setZero(),f.setZero(),m.setZero();for(var r=e.bi,o=(e.bj,0);o!==t;o++)(e=this.result[this.result.length-1-o]).bodyA!==r?(d.vadd(e.ni,d),f.vadd(e.ri,f),m.vadd(e.rj,m)):(d.vsub(e.ni,d),f.vadd(e.rj,f),m.vadd(e.ri,m));var a=1/t;f.scale(a,n.ri),m.scale(a,n.rj),i.ri.copy(n.ri),i.rj.copy(n.rj),d.normalize(),d.tangents(n.t,i.t)}};var v=new a,g=new a,y=new c,x=new c;p.prototype.getContacts=function(t,e,n,i,r,o,a){this.contactPointPool=r,this.frictionEquationPool=a,this.result=i,this.frictionResult=o;for(var s=y,c=x,h=v,l=g,u=0,p=t.length;u!==p;u++){var d=t[u],f=e[u],m=null;d.material&&f.material&&(m=n.getContactMaterial(d.material,f.material)||null);for(var w=0;w<d.shapes.length;w++){d.quaternion.mult(d.shapeOrientations[w],s),d.quaternion.vmult(d.shapeOffsets[w],h),h.vadd(d.position,h);for(var b=d.shapes[w],_=0;_<f.shapes.length;_++){f.quaternion.mult(f.shapeOrientations[_],c),f.quaternion.vmult(f.shapeOffsets[_],l),l.vadd(f.position,l);var M=f.shapes[_];if(!(h.distanceTo(l)>b.boundingSphereRadius+M.boundingSphereRadius)){var E=null;b.material&&M.material&&(E=n.getContactMaterial(b.material,M.material)||null),this.currentContactMaterial=E||m||n.defaultContactMaterial;var S=this[b.type|M.type];S&&(b.type<M.type?S.call(this,b,M,h,l,s,c,d,f,b,M):S.call(this,M,b,l,h,c,s,f,d,b,M))}}}}},p.prototype[r.types.BOX|r.types.BOX]=p.prototype.boxBox=function(t,e,n,i,r,o,a,s){t.convexPolyhedronRepresentation.material=t.material,e.convexPolyhedronRepresentation.material=e.material,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,this.convexConvex(t.convexPolyhedronRepresentation,e.convexPolyhedronRepresentation,n,i,r,o,a,s,t,e)},p.prototype[r.types.BOX|r.types.CONVEXPOLYHEDRON]=p.prototype.boxConvex=function(t,e,n,i,r,o,a,s){t.convexPolyhedronRepresentation.material=t.material,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,this.convexConvex(t.convexPolyhedronRepresentation,e,n,i,r,o,a,s,t,e)},p.prototype[r.types.BOX|r.types.PARTICLE]=p.prototype.boxParticle=function(t,e,n,i,r,o,a,s){t.convexPolyhedronRepresentation.material=t.material,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,this.convexParticle(t.convexPolyhedronRepresentation,e,n,i,r,o,a,s,t,e)},p.prototype[r.types.SPHERE]=p.prototype.sphereSphere=function(t,e,n,i,r,o,a,s){var c=this.createContactEquation(a,s,t,e);i.vsub(n,c.ni),c.ni.normalize(),c.ri.copy(c.ni),c.rj.copy(c.ni),c.ri.mult(t.radius,c.ri),c.rj.mult(-e.radius,c.rj),c.ri.vadd(n,c.ri),c.ri.vsub(a.position,c.ri),c.rj.vadd(i,c.rj),c.rj.vsub(s.position,c.rj),this.result.push(c),this.createFrictionEquationsFromContact(c,this.frictionResult)};var w=new a,b=new a,_=new a;p.prototype[r.types.PLANE|r.types.TRIMESH]=p.prototype.planeTrimesh=function(t,e,n,i,r,o,c,h){var l=new a,u=w;u.set(0,0,1),r.vmult(u,u);for(var p=0;p<e.vertices.length/3;p++){e.getVertex(p,l);var d=new a;d.copy(l),s.pointToWorldFrame(i,o,d,l);var f=b;if(l.vsub(n,f),u.dot(f)<=0){var m=this.createContactEquation(c,h,t,e);m.ni.copy(u);var v=_;u.scale(f.dot(u),v),l.vsub(v,v),m.ri.copy(v),m.ri.vsub(c.position,m.ri),m.rj.copy(l),m.rj.vsub(h.position,m.rj),this.result.push(m),this.createFrictionEquationsFromContact(m,this.frictionResult)}}};var M=new a,E=new a,S=(new a,new a),T=new a,A=new a,R=new a,C=new a,L=new a,P=new a,B=new a,I=new a,N=new a,O=new a,F=new i,z=[];p.prototype[r.types.SPHERE|r.types.TRIMESH]=p.prototype.sphereTrimesh=function(t,e,n,i,r,a,c,h){var l=A,u=R,p=C,d=L,f=P,m=B,v=F,g=T,y=E,x=z;s.pointToLocalFrame(i,a,n,f);var w=t.radius;v.lowerBound.set(f.x-w,f.y-w,f.z-w),v.upperBound.set(f.x+w,f.y+w,f.z+w),e.getTrianglesInAABB(v,x);for(var b=S,_=t.radius*t.radius,D=0;D<x.length;D++)for(var U=0;U<3;U++)e.getVertex(e.indices[3*x[D]+U],b),b.vsub(f,y),y.norm2()<=_&&(g.copy(b),s.pointToWorldFrame(i,a,g,b),b.vsub(n,y),(H=this.createContactEquation(c,h,t,e)).ni.copy(y),H.ni.normalize(),H.ri.copy(H.ni),H.ri.scale(t.radius,H.ri),H.ri.vadd(n,H.ri),H.ri.vsub(c.position,H.ri),H.rj.copy(b),H.rj.vsub(h.position,H.rj),this.result.push(H),this.createFrictionEquationsFromContact(H,this.frictionResult));for(D=0;D<x.length;D++)for(U=0;U<3;U++){e.getVertex(e.indices[3*x[D]+U],l),e.getVertex(e.indices[3*x[D]+(U+1)%3],u),u.vsub(l,p),f.vsub(u,m);var V=m.dot(p);f.vsub(l,m);var G=m.dot(p);if(G>0&&V<0&&(f.vsub(l,m),d.copy(p),d.normalize(),G=m.dot(d),d.scale(G,m),m.vadd(l,m),(Y=m.distanceTo(f))<t.radius)){var H=this.createContactEquation(c,h,t,e);m.vsub(f,H.ni),H.ni.normalize(),H.ni.scale(t.radius,H.ri),s.pointToWorldFrame(i,a,m,m),m.vsub(h.position,H.rj),s.vectorToWorldFrame(a,H.ni,H.ni),s.vectorToWorldFrame(a,H.ri,H.ri),this.result.push(H),this.createFrictionEquationsFromContact(H,this.frictionResult)}}for(var j=I,k=N,W=O,q=M,X=(D=0,x.length);D!==X;D++){e.getTriangleVertices(x[D],j,k,W),e.getNormal(x[D],q),f.vsub(j,m);var Y=m.dot(q);q.scale(Y,m),f.vsub(m,m),Y=m.distanceTo(f),o.pointInTriangle(m,j,k,W)&&Y<t.radius&&(H=this.createContactEquation(c,h,t,e),m.vsub(f,H.ni),H.ni.normalize(),H.ni.scale(t.radius,H.ri),s.pointToWorldFrame(i,a,m,m),m.vsub(h.position,H.rj),s.vectorToWorldFrame(a,H.ni,H.ni),s.vectorToWorldFrame(a,H.ri,H.ri),this.result.push(H),this.createFrictionEquationsFromContact(H,this.frictionResult))}x.length=0};var D=new a,U=new a;p.prototype[r.types.SPHERE|r.types.PLANE]=p.prototype.spherePlane=function(t,e,n,i,r,o,a,s){var c=this.createContactEquation(a,s,t,e);if(c.ni.set(0,0,1),o.vmult(c.ni,c.ni),c.ni.negate(c.ni),c.ni.normalize(),c.ni.mult(t.radius,c.ri),n.vsub(i,D),c.ni.mult(c.ni.dot(D),U),D.vsub(U,c.rj),-D.dot(c.ni)<=t.radius){var h=c.ri,l=c.rj;h.vadd(n,h),h.vsub(a.position,h),l.vadd(i,l),l.vsub(s.position,l),this.result.push(c),this.createFrictionEquationsFromContact(c,this.frictionResult)}};var V=new a,G=new a,H=new a;function j(t,e,n){for(var i=null,r=t.length,o=0;o!==r;o++){var a=t[o],s=V;t[(o+1)%r].vsub(a,s);var c=G;s.cross(e,c);var h=H;n.vsub(a,h);var l=c.dot(h);if(!(null===i||l>0&&!0===i||l<=0&&!1===i))return!1;null===i&&(i=l>0)}return!0}var k=new a,W=new a,q=new a,X=new a,Y=[new a,new a,new a,new a,new a,new a],Z=new a,J=new a,Q=new a,K=new a;p.prototype[r.types.SPHERE|r.types.BOX]=p.prototype.sphereBox=function(t,e,n,i,r,o,a,s){var c=this.v3pool,h=Y;n.vsub(i,k),e.getSideNormals(h,o);for(var l=t.radius,u=!1,p=J,d=Q,f=K,m=null,v=0,g=0,y=0,x=null,w=0,b=h.length;w!==b&&!1===u;w++){var _=W;_.copy(h[w]);var M=_.norm();_.normalize();var E=k.dot(_);if(E<M+l&&E>0){var S=q,T=X;S.copy(h[(w+1)%3]),T.copy(h[(w+2)%3]);var A=S.norm(),R=T.norm();S.normalize(),T.normalize();var C=k.dot(S),L=k.dot(T);if(C<A&&C>-A&&L<R&&L>-R){var P=Math.abs(E-M-l);(null===x||P<x)&&(x=P,g=C,y=L,m=M,p.copy(_),d.copy(S),f.copy(T),v++)}}}if(v){u=!0;var B=this.createContactEquation(a,s,t,e);p.mult(-l,B.ri),B.ni.copy(p),B.ni.negate(B.ni),p.mult(m,p),d.mult(g,d),p.vadd(d,p),f.mult(y,f),p.vadd(f,B.rj),B.ri.vadd(n,B.ri),B.ri.vsub(a.position,B.ri),B.rj.vadd(i,B.rj),B.rj.vsub(s.position,B.rj),this.result.push(B),this.createFrictionEquationsFromContact(B,this.frictionResult)}for(var I=c.get(),N=Z,O=0;2!==O&&!u;O++)for(var F=0;2!==F&&!u;F++)for(var z=0;2!==z&&!u;z++)I.set(0,0,0),O?I.vadd(h[0],I):I.vsub(h[0],I),F?I.vadd(h[1],I):I.vsub(h[1],I),z?I.vadd(h[2],I):I.vsub(h[2],I),i.vadd(I,N),N.vsub(n,N),N.norm2()<l*l&&(u=!0,(B=this.createContactEquation(a,s,t,e)).ri.copy(N),B.ri.normalize(),B.ni.copy(B.ri),B.ri.mult(l,B.ri),B.rj.copy(I),B.ri.vadd(n,B.ri),B.ri.vsub(a.position,B.ri),B.rj.vadd(i,B.rj),B.rj.vsub(s.position,B.rj),this.result.push(B),this.createFrictionEquationsFromContact(B,this.frictionResult));c.release(I),I=null;var D=c.get(),U=c.get(),V=(B=c.get(),c.get()),G=(P=c.get(),h.length);for(O=0;O!==G&&!u;O++)for(F=0;F!==G&&!u;F++)if(O%3!=F%3){h[F].cross(h[O],D),D.normalize(),h[O].vadd(h[F],U),B.copy(n),B.vsub(U,B),B.vsub(i,B);var H=B.dot(D);for(D.mult(H,V),z=0;z===O%3||z===F%3;)z++;P.copy(n),P.vsub(V,P),P.vsub(U,P),P.vsub(i,P);var j=Math.abs(H),$=P.norm();if(j<h[z].norm()&&$<l){u=!0;var tt=this.createContactEquation(a,s,t,e);U.vadd(V,tt.rj),tt.rj.copy(tt.rj),P.negate(tt.ni),tt.ni.normalize(),tt.ri.copy(tt.rj),tt.ri.vadd(i,tt.ri),tt.ri.vsub(n,tt.ri),tt.ri.normalize(),tt.ri.mult(l,tt.ri),tt.ri.vadd(n,tt.ri),tt.ri.vsub(a.position,tt.ri),tt.rj.vadd(i,tt.rj),tt.rj.vsub(s.position,tt.rj),this.result.push(tt),this.createFrictionEquationsFromContact(tt,this.frictionResult)}}c.release(D,U,B,V,P)};var $=new a,tt=new a,et=new a,nt=new a,it=new a,rt=new a,ot=new a,at=new a,st=new a,ct=new a;p.prototype[r.types.SPHERE|r.types.CONVEXPOLYHEDRON]=p.prototype.sphereConvex=function(t,e,n,i,r,o,a,s){var c=this.v3pool;n.vsub(i,$);for(var h=e.faceNormals,l=e.faces,u=e.vertices,p=t.radius,d=0;d!==u.length;d++){var f=u[d],m=it;o.vmult(f,m),i.vadd(m,m);var v=nt;if(m.vsub(n,v),v.norm2()<p*p)return g=!0,(P=this.createContactEquation(a,s,t,e)).ri.copy(v),P.ri.normalize(),P.ni.copy(P.ri),P.ri.mult(p,P.ri),m.vsub(i,P.rj),P.ri.vadd(n,P.ri),P.ri.vsub(a.position,P.ri),P.rj.vadd(i,P.rj),P.rj.vsub(s.position,P.rj),this.result.push(P),void this.createFrictionEquationsFromContact(P,this.frictionResult)}for(var g=!1,y=(d=0,l.length);d!==y&&!1===g;d++){var x=h[d],w=l[d],b=rt;o.vmult(x,b);var _=ot;o.vmult(u[w[0]],_),_.vadd(i,_);var M=at;b.mult(-p,M),n.vadd(M,M);var E=st;M.vsub(_,E);var S=E.dot(b),T=ct;if(n.vsub(_,T),S<0&&T.dot(b)>0){for(var A=[],R=0,C=w.length;R!==C;R++){var L=c.get();o.vmult(u[w[R]],L),i.vadd(L,L),A.push(L)}if(j(A,b,n)){g=!0;var P=this.createContactEquation(a,s,t,e);b.mult(-p,P.ri),b.negate(P.ni);var B=c.get();b.mult(-S,B);var I=c.get();b.mult(-p,I),n.vsub(i,P.rj),P.rj.vadd(I,P.rj),P.rj.vadd(B,P.rj),P.rj.vadd(i,P.rj),P.rj.vsub(s.position,P.rj),P.ri.vadd(n,P.ri),P.ri.vsub(a.position,P.ri),c.release(B),c.release(I),this.result.push(P),this.createFrictionEquationsFromContact(P,this.frictionResult),R=0;for(var N=A.length;R!==N;R++)c.release(A[R]);return}for(R=0;R!==w.length;R++){var O=c.get(),F=c.get();o.vmult(u[w[(R+1)%w.length]],O),o.vmult(u[w[(R+2)%w.length]],F),i.vadd(O,O),i.vadd(F,F);var z=tt;F.vsub(O,z);var D=et;z.unit(D);var U=c.get(),V=c.get();n.vsub(O,V);var G=V.dot(D);D.mult(G,U),U.vadd(O,U);var H=c.get();if(U.vsub(n,H),G>0&&G*G<z.norm2()&&H.norm2()<p*p){for(P=this.createContactEquation(a,s,t,e),U.vsub(i,P.rj),U.vsub(n,P.ni),P.ni.normalize(),P.ni.mult(p,P.ri),P.rj.vadd(i,P.rj),P.rj.vsub(s.position,P.rj),P.ri.vadd(n,P.ri),P.ri.vsub(a.position,P.ri),this.result.push(P),this.createFrictionEquationsFromContact(P,this.frictionResult),R=0,N=A.length;R!==N;R++)c.release(A[R]);return c.release(O),c.release(F),c.release(U),c.release(H),void c.release(V)}c.release(O),c.release(F),c.release(U),c.release(H),c.release(V)}for(R=0,N=A.length;R!==N;R++)c.release(A[R])}}},new a,new a,p.prototype[r.types.PLANE|r.types.BOX]=p.prototype.planeBox=function(t,e,n,i,r,o,a,s){e.convexPolyhedronRepresentation.material=e.material,e.convexPolyhedronRepresentation.collisionResponse=e.collisionResponse,this.planeConvex(t,e.convexPolyhedronRepresentation,n,i,r,o,a,s)};var ht=new a,lt=new a,ut=new a,pt=new a;p.prototype[r.types.PLANE|r.types.CONVEXPOLYHEDRON]=p.prototype.planeConvex=function(t,e,n,i,r,o,a,s){var c=ht,h=lt;h.set(0,0,1),r.vmult(h,h);for(var l=0,u=ut,p=0;p!==e.vertices.length;p++)if(c.copy(e.vertices[p]),o.vmult(c,c),i.vadd(c,c),c.vsub(n,u),h.dot(u)<=0){var d=this.createContactEquation(a,s,t,e),f=pt;h.mult(h.dot(u),f),c.vsub(f,f),f.vsub(n,d.ri),d.ni.copy(h),c.vsub(i,d.rj),d.ri.vadd(n,d.ri),d.ri.vsub(a.position,d.ri),d.rj.vadd(i,d.rj),d.rj.vsub(s.position,d.rj),this.result.push(d),l++,this.enableFrictionReduction||this.createFrictionEquationsFromContact(d,this.frictionResult)}this.enableFrictionReduction&&l&&this.createFrictionFromAverage(l)};var dt=new a,ft=new a;p.prototype[r.types.CONVEXPOLYHEDRON]=p.prototype.convexConvex=function(t,e,n,i,r,o,a,s,c,h,l,u){var p=dt;if(!(n.distanceTo(i)>t.boundingSphereRadius+e.boundingSphereRadius)&&t.findSeparatingAxis(e,n,r,i,o,p,l,u)){var d=[],f=ft;t.clipAgainstHull(n,r,e,i,o,p,-100,100,d);for(var m=0,v=0;v!==d.length;v++){var g=this.createContactEquation(a,s,t,e,c,h),y=g.ri,x=g.rj;p.negate(g.ni),d[v].normal.negate(f),f.mult(d[v].depth,f),d[v].point.vadd(f,y),x.copy(d[v].point),y.vsub(n,y),x.vsub(i,x),y.vadd(n,y),y.vsub(a.position,y),x.vadd(i,x),x.vsub(s.position,x),this.result.push(g),m++,this.enableFrictionReduction||this.createFrictionEquationsFromContact(g,this.frictionResult)}this.enableFrictionReduction&&m&&this.createFrictionFromAverage(m)}};var mt=new a,vt=new a,gt=new a;p.prototype[r.types.PLANE|r.types.PARTICLE]=p.prototype.planeParticle=function(t,e,n,i,r,o,a,s){var c=mt;c.set(0,0,1),a.quaternion.vmult(c,c);var h=vt;if(i.vsub(a.position,h),c.dot(h)<=0){var l=this.createContactEquation(s,a,e,t);l.ni.copy(c),l.ni.negate(l.ni),l.ri.set(0,0,0);var u=gt;c.mult(c.dot(i),u),i.vsub(u,u),l.rj.copy(u),this.result.push(l),this.createFrictionEquationsFromContact(l,this.frictionResult)}};var yt=new a;p.prototype[r.types.PARTICLE|r.types.SPHERE]=p.prototype.sphereParticle=function(t,e,n,i,r,o,a,s){var c=yt;if(c.set(0,0,1),i.vsub(n,c),c.norm2()<=t.radius*t.radius){var h=this.createContactEquation(s,a,e,t);c.normalize(),h.rj.copy(c),h.rj.mult(t.radius,h.rj),h.ni.copy(c),h.ni.negate(h.ni),h.ri.set(0,0,0),this.result.push(h),this.createFrictionEquationsFromContact(h,this.frictionResult)}};var xt=new c,wt=new a,bt=(new a,new a),_t=new a,Mt=new a;p.prototype[r.types.PARTICLE|r.types.CONVEXPOLYHEDRON]=p.prototype.convexParticle=function(t,e,n,i,r,o,a,s){var c=-1,h=bt,l=Mt,u=null,p=wt;if(p.copy(i),p.vsub(n,p),r.conjugate(xt),xt.vmult(p,p),t.pointIsInside(p)){t.worldVerticesNeedsUpdate&&t.computeWorldVertices(n,r),t.worldFaceNormalsNeedsUpdate&&t.computeWorldFaceNormals(r);for(var d=0,f=t.faces.length;d!==f;d++){var m=[t.worldVertices[t.faces[d][0]]],v=t.worldFaceNormals[d];i.vsub(m[0],_t);var g=-v.dot(_t);(null===u||Math.abs(g)<Math.abs(u))&&(u=g,c=d,h.copy(v))}if(-1!==c){var y=this.createContactEquation(s,a,e,t);h.mult(u,l),l.vadd(i,l),l.vsub(n,l),y.rj.copy(l),h.negate(y.ni),y.ri.set(0,0,0);var x=y.ri,w=y.rj;x.vadd(i,x),x.vsub(s.position,x),w.vadd(n,w),w.vsub(a.position,w),this.result.push(y),this.createFrictionEquationsFromContact(y,this.frictionResult)}else console.warn("Point found inside convex, but did not find penetrating face!")}},p.prototype[r.types.BOX|r.types.HEIGHTFIELD]=p.prototype.boxHeightfield=function(t,e,n,i,r,o,a,s){t.convexPolyhedronRepresentation.material=t.material,t.convexPolyhedronRepresentation.collisionResponse=t.collisionResponse,this.convexHeightfield(t.convexPolyhedronRepresentation,e,n,i,r,o,a,s)};var Et=new a,St=new a,Tt=[0];p.prototype[r.types.CONVEXPOLYHEDRON|r.types.HEIGHTFIELD]=p.prototype.convexHeightfield=function(t,e,n,i,r,o,a,c){var h=e.data,l=e.elementSize,u=t.boundingSphereRadius,p=St,d=Tt,f=Et;s.pointToLocalFrame(i,o,n,f);var m=Math.floor((f.x-u)/l)-1,v=Math.ceil((f.x+u)/l)+1,g=Math.floor((f.y-u)/l)-1,y=Math.ceil((f.y+u)/l)+1;if(!(v<0||y<0||m>h.length||g>h[0].length)){m<0&&(m=0),v<0&&(v=0),g<0&&(g=0),y<0&&(y=0),m>=h.length&&(m=h.length-1),v>=h.length&&(v=h.length-1),y>=h[0].length&&(y=h[0].length-1),g>=h[0].length&&(g=h[0].length-1);var x=[];e.getRectMinMax(m,g,v,y,x);var w=x[0],b=x[1];if(!(f.z-u>b||f.z+u<w))for(var _=m;_<v;_++)for(var M=g;M<y;M++)e.getConvexTrianglePillar(_,M,!1),s.pointToWorldFrame(i,o,e.pillarOffset,p),n.distanceTo(p)<e.pillarConvex.boundingSphereRadius+t.boundingSphereRadius&&this.convexConvex(t,e.pillarConvex,n,p,r,o,a,c,null,null,d,null),e.getConvexTrianglePillar(_,M,!0),s.pointToWorldFrame(i,o,e.pillarOffset,p),n.distanceTo(p)<e.pillarConvex.boundingSphereRadius+t.boundingSphereRadius&&this.convexConvex(t,e.pillarConvex,n,p,r,o,a,c,null,null,d,null)}};var At=new a,Rt=new a;p.prototype[r.types.SPHERE|r.types.HEIGHTFIELD]=p.prototype.sphereHeightfield=function(t,e,n,i,r,o,a,c){var h=e.data,l=t.radius,u=e.elementSize,p=Rt,d=At;s.pointToLocalFrame(i,o,n,d);var f=Math.floor((d.x-l)/u)-1,m=Math.ceil((d.x+l)/u)+1,v=Math.floor((d.y-l)/u)-1,g=Math.ceil((d.y+l)/u)+1;if(!(m<0||g<0||f>h.length||g>h[0].length)){f<0&&(f=0),m<0&&(m=0),v<0&&(v=0),g<0&&(g=0),f>=h.length&&(f=h.length-1),m>=h.length&&(m=h.length-1),g>=h[0].length&&(g=h[0].length-1),v>=h[0].length&&(v=h[0].length-1);var y=[];e.getRectMinMax(f,v,m,g,y);var x=y[0],w=y[1];if(!(d.z-l>w||d.z+l<x))for(var b=this.result,_=f;_<m;_++)for(var M=v;M<g;M++){var E=b.length;if(e.getConvexTrianglePillar(_,M,!1),s.pointToWorldFrame(i,o,e.pillarOffset,p),n.distanceTo(p)<e.pillarConvex.boundingSphereRadius+t.boundingSphereRadius&&this.sphereConvex(t,e.pillarConvex,n,p,r,o,a,c),e.getConvexTrianglePillar(_,M,!0),s.pointToWorldFrame(i,o,e.pillarOffset,p),n.distanceTo(p)<e.pillarConvex.boundingSphereRadius+t.boundingSphereRadius&&this.sphereConvex(t,e.pillarConvex,n,p,r,o,a,c),b.length-E>2)return}}}},{"../collision/AABB":3,"../collision/Ray":9,"../equations/ContactEquation":19,"../equations/FrictionEquation":21,"../math/Quaternion":28,"../math/Transform":29,"../math/Vec3":30,"../shapes/ConvexPolyhedron":38,"../shapes/Shape":43,"../solver/Solver":47,"../utils/Vec3Pool":54}],56:[function(t,e,n){e.exports=y;var i=t("../shapes/Shape"),r=t("../math/Vec3"),o=t("../math/Quaternion"),a=t("../solver/GSSolver"),s=(t("../utils/Vec3Pool"),t("../equations/ContactEquation"),t("../equations/FrictionEquation"),t("./Narrowphase")),c=t("../utils/EventTarget"),h=t("../collision/ArrayCollisionMatrix"),l=t("../material/Material"),u=t("../material/ContactMaterial"),p=t("../objects/Body"),d=t("../utils/TupleDictionary"),f=t("../collision/RaycastResult"),m=t("../collision/AABB"),v=t("../collision/Ray"),g=t("../collision/NaiveBroadphase");function y(){c.apply(this),this.dt=-1,this.allowSleep=!1,this.contacts=[],this.frictionEquations=[],this.quatNormalizeSkip=0,this.quatNormalizeFast=!1,this.time=0,this.stepnumber=0,this.default_dt=1/60,this.nextId=0,this.gravity=new r,this.broadphase=new g,this.bodies=[],this.solver=new a,this.constraints=[],this.narrowphase=new s(this),this.collisionMatrix=new h,this.collisionMatrixPrevious=new h,this.materials=[],this.contactmaterials=[],this.contactMaterialTable=new d,this.defaultMaterial=new l("default"),this.defaultContactMaterial=new u(this.defaultMaterial,this.defaultMaterial,{friction:.3,restitution:0}),this.doProfiling=!1,this.profile={solve:0,makeContactConstraints:0,broadphase:0,integrate:0,narrowphase:0},this.subsystems=[],this.addBodyEvent={type:"addBody",body:null},this.removeBodyEvent={type:"removeBody",body:null}}y.prototype=new c,new m;var x=new v;if(y.prototype.getContactMaterial=function(t,e){return this.contactMaterialTable.get(t.id,e.id)},y.prototype.numObjects=function(){return this.bodies.length},y.prototype.collisionMatrixTick=function(){var t=this.collisionMatrixPrevious;this.collisionMatrixPrevious=this.collisionMatrix,this.collisionMatrix=t,this.collisionMatrix.reset()},y.prototype.add=y.prototype.addBody=function(t){-1===this.bodies.indexOf(t)&&(t.index=this.bodies.length,this.bodies.push(t),t.world=this,t.initPosition.copy(t.position),t.initVelocity.copy(t.velocity),t.timeLastSleepy=this.time,t instanceof p&&(t.initAngularVelocity.copy(t.angularVelocity),t.initQuaternion.copy(t.quaternion)),this.collisionMatrix.setNumObjects(this.bodies.length),this.addBodyEvent.body=t,this.dispatchEvent(this.addBodyEvent))},y.prototype.addConstraint=function(t){this.constraints.push(t)},y.prototype.removeConstraint=function(t){var e=this.constraints.indexOf(t);-1!==e&&this.constraints.splice(e,1)},y.prototype.rayTest=function(t,e,n){n instanceof f?this.raycastClosest(t,e,{skipBackfaces:!0},n):this.raycastAll(t,e,{skipBackfaces:!0},n)},y.prototype.raycastAll=function(t,e,n,i){return n.mode=v.ALL,n.from=t,n.to=e,n.callback=i,x.intersectWorld(this,n)},y.prototype.raycastAny=function(t,e,n,i){return n.mode=v.ANY,n.from=t,n.to=e,n.result=i,x.intersectWorld(this,n)},y.prototype.raycastClosest=function(t,e,n,i){return n.mode=v.CLOSEST,n.from=t,n.to=e,n.result=i,x.intersectWorld(this,n)},y.prototype.remove=function(t){t.world=null;var e=this.bodies.length-1,n=this.bodies,i=n.indexOf(t);if(-1!==i){n.splice(i,1);for(var r=0;r!==n.length;r++)n[r].index=r;this.collisionMatrix.setNumObjects(e),this.removeBodyEvent.body=t,this.dispatchEvent(this.removeBodyEvent)}},y.prototype.removeBody=y.prototype.remove,y.prototype.addMaterial=function(t){this.materials.push(t)},y.prototype.addContactMaterial=function(t){this.contactmaterials.push(t),this.contactMaterialTable.set(t.materials[0].id,t.materials[1].id,t)},"undefined"==typeof performance&&(performance={}),!performance.now){var w=Date.now();performance.timing&&performance.timing.navigationStart&&(w=performance.timing.navigationStart),performance.now=function(){return Date.now()-w}}var b=new r;y.prototype.step=function(t,e,n){if(n=n||10,0===(e=e||0))this.internalStep(t),this.time+=t;else{var i=Math.floor((this.time+e)/t)-Math.floor(this.time/t);i=Math.min(i,n);for(var r=performance.now(),o=0;o!==i&&(this.internalStep(t),!(performance.now()-r>1e3*t));o++);this.time+=e;for(var a=this.time%t/t,s=b,c=this.bodies,h=0;h!==c.length;h++){var l=c[h];l.type!==p.STATIC&&l.sleepState!==p.SLEEPING?(l.position.vsub(l.previousPosition,s),s.scale(a,s),l.position.vadd(s,l.interpolatedPosition)):(l.interpolatedPosition.copy(l.position),l.interpolatedQuaternion.copy(l.quaternion))}}};var _={type:"postStep"},M={type:"preStep"},E={type:"collide",body:null,contact:null},S=[],T=[],A=[],R=[],C=(new r,new r,new r,new r,new r,new r,new r,new r,new r,new o,new o),L=new o,P=new r;y.prototype.internalStep=function(t){this.dt=t;var e,n=this.contacts,r=A,o=R,a=this.numObjects(),s=this.bodies,c=this.solver,h=this.gravity,l=this.doProfiling,u=this.profile,d=p.DYNAMIC,f=this.constraints,m=T,v=(h.norm(),h.x),g=h.y,y=h.z,x=0;for(l&&(e=performance.now()),x=0;x!==a;x++)if((V=s[x]).type&d){var w=V.force,b=V.mass;w.x+=b*v,w.y+=b*g,w.z+=b*y}x=0;for(var B=this.subsystems.length;x!==B;x++)this.subsystems[x].update();l&&(e=performance.now()),r.length=0,o.length=0,this.broadphase.collisionPairs(this,r,o),l&&(u.broadphase=performance.now()-e);var I=f.length;for(x=0;x!==I;x++)if(!(H=f[x]).collideConnected)for(var N=r.length-1;N>=0;N-=1)(H.bodyA===r[N]&&H.bodyB===o[N]||H.bodyB===r[N]&&H.bodyA===o[N])&&(r.splice(N,1),o.splice(N,1));this.collisionMatrixTick(),l&&(e=performance.now());var O=S,F=n.length;for(x=0;x!==F;x++)O.push(n[x]);n.length=0;var z=this.frictionEquations.length;for(x=0;x!==z;x++)m.push(this.frictionEquations[x]);for(this.frictionEquations.length=0,this.narrowphase.getContacts(r,o,this,n,O,this.frictionEquations,m),l&&(u.narrowphase=performance.now()-e),l&&(e=performance.now()),x=0;x<this.frictionEquations.length;x++)c.addEquation(this.frictionEquations[x]);for(var D=n.length,U=0;U!==D;U++){var V=(H=n[U]).bi,G=H.bj;H.si,H.sj,(V.material&&G.material&&this.getContactMaterial(V.material,G.material)||this.defaultContactMaterial).friction,V.material&&G.material&&(V.material.friction>=0&&G.material.friction>=0&&(V.material.friction,G.material.friction),V.material.restitution>=0&&G.material.restitution>=0&&(H.restitution=V.material.restitution*G.material.restitution)),c.addEquation(H),V.allowSleep&&V.type===p.DYNAMIC&&V.sleepState===p.SLEEPING&&G.sleepState===p.AWAKE&&G.type!==p.STATIC&&G.velocity.norm2()+G.angularVelocity.norm2()>=2*Math.pow(G.sleepSpeedLimit,2)&&(V._wakeUpAfterNarrowphase=!0),G.allowSleep&&G.type===p.DYNAMIC&&G.sleepState===p.SLEEPING&&V.sleepState===p.AWAKE&&V.type!==p.STATIC&&V.velocity.norm2()+V.angularVelocity.norm2()>=2*Math.pow(V.sleepSpeedLimit,2)&&(G._wakeUpAfterNarrowphase=!0),this.collisionMatrix.set(V,G,!0),this.collisionMatrixPrevious.get(V,G)||(E.body=G,E.contact=H,V.dispatchEvent(E),E.body=V,G.dispatchEvent(E))}for(l&&(u.makeContactConstraints=performance.now()-e,e=performance.now()),x=0;x!==a;x++)(V=s[x])._wakeUpAfterNarrowphase&&(V.wakeUp(),V._wakeUpAfterNarrowphase=!1);for(I=f.length,x=0;x!==I;x++){var H;(H=f[x]).update(),N=0;for(var j=H.equations.length;N!==j;N++){var k=H.equations[N];c.addEquation(k)}}c.solve(t,this),l&&(u.solve=performance.now()-e),c.removeAllEquations();var W=Math.pow;for(x=0;x!==a;x++)if((V=s[x]).type&d){var q=W(1-V.linearDamping,t),X=V.velocity;X.mult(q,X);var Y=V.angularVelocity;if(Y){var Z=W(1-V.angularDamping,t);Y.mult(Z,Y)}}for(this.dispatchEvent(M),x=0;x!==a;x++)(V=s[x]).preStep&&V.preStep.call(V);l&&(e=performance.now());var J=C,Q=L,K=this.stepnumber,$=p.DYNAMIC|p.KINEMATIC,tt=K%(this.quatNormalizeSkip+1)==0,et=this.quatNormalizeFast,nt=.5*t;for(i.types.PLANE,i.types.CONVEXPOLYHEDRON,x=0;x!==a;x++){var it=s[x],rt=it.force,ot=it.torque;if(it.type&$&&it.sleepState!==p.SLEEPING){var at=it.velocity,st=it.angularVelocity,ct=it.position,ht=it.quaternion,lt=it.invMass,ut=it.invInertiaWorld;at.x+=rt.x*lt*t,at.y+=rt.y*lt*t,at.z+=rt.z*lt*t,it.angularVelocity&&(ut.vmult(ot,P),P.mult(t,P),P.vadd(st,st)),ct.x+=at.x*t,ct.y+=at.y*t,ct.z+=at.z*t,it.angularVelocity&&(J.set(st.x,st.y,st.z,0),J.mult(ht,Q),ht.x+=nt*Q.x,ht.y+=nt*Q.y,ht.z+=nt*Q.z,ht.w+=nt*Q.w,tt&&(et?ht.normalizeFast():ht.normalize())),it.aabb&&(it.aabbNeedsUpdate=!0),it.updateInertiaWorld&&it.updateInertiaWorld()}}for(this.clearForces(),this.broadphase.dirty=!0,l&&(u.integrate=performance.now()-e),this.time+=t,this.stepnumber+=1,this.dispatchEvent(_),x=0;x!==a;x++){var pt=(V=s[x]).postStep;pt&&pt.call(V)}if(this.allowSleep)for(x=0;x!==a;x++)s[x].sleepTick(this.time)},y.prototype.clearForces=function(){for(var t=this.bodies,e=t.length,n=0;n!==e;n++){var i=t[n];i.force,i.torque,i.force.set(0,0,0),i.torque.set(0,0,0)}}},{"../collision/AABB":3,"../collision/ArrayCollisionMatrix":4,"../collision/NaiveBroadphase":7,"../collision/Ray":9,"../collision/RaycastResult":10,"../equations/ContactEquation":19,"../equations/FrictionEquation":21,"../material/ContactMaterial":24,"../material/Material":25,"../math/Quaternion":28,"../math/Vec3":30,"../objects/Body":31,"../shapes/Shape":43,"../solver/GSSolver":46,"../utils/EventTarget":49,"../utils/TupleDictionary":52,"../utils/Vec3Pool":54,"./Narrowphase":55}]},{},[2])(2)},function(t,e,n){"use strict";(function(t){n.d(e,"a",(function(){return h})),n.d(e,"b",(function(){return p}));var i=n(1),r=n(0);class o{constructor(t){t=this.setDefaults(t,{size:100,fontColor:"#000000",backColor:"#ffffff"}),this.object=null,this.size=t.size,this.invertUpside=!1,this.materialOptions={specular:1515554,color:15790320,shininess:40,shading:r.FlatShading},this.labelColor=t.fontColor,this.diceColor=t.backColor}setDefaults(t,e){t=t||{};for(let n in e)e.hasOwnProperty(n)&&(n in t||(t[n]=e[n]));return t}emulateThrow(t){let e=0,n=()=>{this.isFinished()?(e++,50===e&&(p.world.removeEventListener("postStep",n),t(this.getUpsideValue()))):e=0,p.world.step(p.world.dt)};p.world.addEventListener("postStep",n)}isFinished(){let t=this.object.body.angularVelocity,e=this.object.body.velocity;return Math.abs(t.x)<1&&Math.abs(t.y)<1&&Math.abs(t.z)<1&&Math.abs(e.x)<1&&Math.abs(e.y)<1&&Math.abs(e.z)<1}getUpsideValue(){let t,e=new r.Vector3(0,this.invertUpside?-1:1),n=2*Math.PI;for(let i=0;i<this.object.geometry.faces.length;++i){let r=this.object.geometry.faces[i];if(0===r.materialIndex)continue;let o=r.normal.clone().applyQuaternion(this.object.body.quaternion).angleTo(e);o<n&&(n=o,t=r)}return t.materialIndex-1}getCurrentVectors(){return{position:this.object.body.position.clone(),quaternion:this.object.body.quaternion.clone(),velocity:this.object.body.velocity.clone(),angularVelocity:this.object.body.angularVelocity.clone()}}setVectors(t){this.object.body.position=t.position,this.object.body.quaternion=t.quaternion,this.object.body.velocity=t.velocity,this.object.body.angularVelocity=t.angularVelocity}shiftUpperValue(t){let e=this.object.geometry.clone(),n=this.getUpsideValue();for(let i=0,r=e.faces.length;i<r;++i){let r=e.faces[i].materialIndex;if(0!==r){for(r+=t-n-1;r>this.values;)r-=this.values;for(;r<1;)r+=this.values;e.faces[i].materialIndex=r+1}}this.object.geometry=e}getChamferGeometry(t,e,n){let i=[],o=[],a=new Array(t.length);for(let e=0;e<t.length;++e)a[e]=[];for(let s=0;s<e.length;++s){let c=e[s],h=c.length-1,l=new r.Vector3,u=new Array(h);for(let e=0;e<h;++e){let n=t[c[e]].clone();l.add(n),a[c[e]].push(u[e]=i.push(n)-1)}l.divideScalar(h);for(let t=0;t<h;++t){let e=i[u[t]];e.subVectors(e,l).multiplyScalar(n).addVectors(e,l)}u.push(c[h]),o.push(u)}for(let t=0;t<e.length-1;++t)for(let n=t+1;n<e.length;++n){let i=[],r=-1;for(let o=0;o<e[t].length-1;++o){let a=e[n].indexOf(e[t][o]);a>=0&&a<e[n].length-1&&(r>=0&&o!==r+1?i.unshift([t,o],[n,a]):i.push([t,o],[n,a]),r=o)}4===i.length&&o.push([o[i[0][0]][i[0][1]],o[i[1][0]][i[1][1]],o[i[3][0]][i[3][1]],o[i[2][0]][i[2][1]],-1])}for(let t=0;t<a.length;++t){let n=a[t],i=[n[0]],r=n.length-1;for(;r;){for(let t=e.length;t<o.length;++t){let e=o[t].indexOf(i[i.length-1]);if(e>=0&&e<4){-1==--e&&(e=3);let r=o[t][e];if(n.indexOf(r)>=0){i.push(r);break}}}--r}i.push(-1),o.push(i)}return{vectors:i,faces:o}}makeGeometry(t,e,n,i,o){let a=new r.Geometry;for(let e=0;e<t.length;++e){let i=t[e].multiplyScalar(n);i.index=a.vertices.push(i)-1}for(let t=0;t<e.length;++t){let n=e[t],s=n.length-1,c=2*Math.PI/s;for(let t=0;t<s-2;++t)a.faces.push(new r.Face3(n[0],n[t+1],n[t+2],[a.vertices[n[0]],a.vertices[n[t+1]],a.vertices[n[t+2]]],0,n[s]+1)),a.faceVertexUvs[0].push([new r.Vector2((Math.cos(o)+1+i)/2/(1+i),(Math.sin(o)+1+i)/2/(1+i)),new r.Vector2((Math.cos(c*(t+1)+o)+1+i)/2/(1+i),(Math.sin(c*(t+1)+o)+1+i)/2/(1+i)),new r.Vector2((Math.cos(c*(t+2)+o)+1+i)/2/(1+i),(Math.sin(c*(t+2)+o)+1+i)/2/(1+i))])}return a.computeFaceNormals(),a.boundingSphere=new r.Sphere(new r.Vector3,n),a}createShape(t,e,n){let r=new Array(t.length),o=new Array(e.length);for(let e=0;e<t.length;++e){let o=t[e];r[e]=new i.Vec3(o.x*n,o.y*n,o.z*n)}for(let t=0;t<e.length;++t)o[t]=e[t].slice(0,e[t].length-1);return new i.ConvexPolyhedron(r,o)}getGeometry(){let t=this.size*this.scaleFactor,e=new Array(this.vertices.length);for(let t=0;t<this.vertices.length;++t)e[t]=(new r.Vector3).fromArray(this.vertices[t]).normalize();let n=this.getChamferGeometry(e,this.faces,this.chamfer),i=this.makeGeometry(n.vectors,n.faces,t,this.tab,this.af);return i.cannon_shape=this.createShape(e,this.faces,t),i}calculateTextureSize(t){return Math.max(128,Math.pow(2,Math.floor(Math.log(t)/Math.log(2))))}createTextTexture(t,e,n){let i=document.createElement("canvas"),o=i.getContext("2d"),a=2*this.calculateTextureSize(this.size/2+this.size*this.textMargin);i.width=i.height=a,o.font=a/(1+2*this.textMargin)+"pt Arial",o.fillStyle=n,o.fillRect(0,0,i.width,i.height),o.textAlign="center",o.textBaseline="middle",o.fillStyle=e,o.fillText(t,i.width/2,i.height/2);let s=new r.Texture(i);return s.needsUpdate=!0,s}getMaterials(){let t=[];for(let e=0;e<this.faceTexts.length;++e){let n=null;n=this.customTextTextureFunction?this.customTextTextureFunction(this.faceTexts[e],this.labelColor,this.diceColor):this.createTextTexture(this.faceTexts[e],this.labelColor,this.diceColor),t.push(new r.MeshPhongMaterial(Object.assign({},this.materialOptions,{map:n})))}return t}getObject(){return this.object}create(){if(!p.world)throw new Error("You must call DiceManager.setWorld(world) first.");return this.object=new r.Mesh(this.getGeometry(),new r.MultiMaterial(this.getMaterials())),this.object.reveiceShadow=!0,this.object.castShadow=!0,this.object.diceObject=this,this.object.body=new i.Body({mass:this.mass,shape:this.object.geometry.cannon_shape,material:p.diceBodyMaterial}),this.object.body.linearDamping=.1,this.object.body.angularDamping=.1,p.world.add(this.object.body),this.object}updateMeshFromBody(){this.simulationRunning||(this.object.position.copy(this.object.body.position),this.object.quaternion.copy(this.object.body.quaternion))}updateBodyFromMesh(){this.object.body.position.copy(this.object.position),this.object.body.quaternion.copy(this.object.quaternion)}}class a extends o{constructor(t){super(t),this.tab=-.1,this.af=7*Math.PI/6,this.chamfer=.96,this.vertices=[[1,1,1],[-1,-1,1],[-1,1,-1],[1,-1,-1]],this.faces=[[1,0,2,1],[0,1,3,2],[0,3,2,3],[1,2,3,4]],this.scaleFactor=1.2,this.values=4,this.faceTexts=[[],["0","0","0"],["2","4","3"],["1","3","4"],["2","1","4"],["1","2","3"]],this.customTextTextureFunction=function(t,e,n){let i=document.createElement("canvas"),o=i.getContext("2d"),a=2*this.calculateTextureSize(this.size/2+2*this.size);i.width=i.height=a,o.font=a/5+"pt Arial",o.fillStyle=n,o.fillRect(0,0,i.width,i.height),o.textAlign="center",o.textBaseline="middle",o.fillStyle=e;for(let e in t)o.fillText(t[e],i.width/2,i.height/2-.3*a),o.translate(i.width/2,i.height/2),o.rotate(2*Math.PI/3),o.translate(-i.width/2,-i.height/2);let s=new r.Texture(i);return s.needsUpdate=!0,s},this.mass=300,this.inertia=5,this.invertUpside=!0,this.create()}}class s extends o{constructor(t){super(t),this.tab=.1,this.af=Math.PI/4,this.chamfer=.96,this.vertices=[[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1],[-1,-1,1],[1,-1,1],[1,1,1],[-1,1,1]],this.faces=[[0,3,2,1,1],[1,2,6,5,2],[0,1,5,4,3],[3,7,6,2,4],[0,4,7,3,5],[4,5,6,7,6]],this.scaleFactor=.9,this.values=6,this.faceTexts=[" ","0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20"],this.textMargin=1,this.mass=300,this.inertia=13,this.create()}}class c extends o{constructor(t){super(t),this.tab=0,this.af=-Math.PI/4/2,this.chamfer=.965,this.vertices=[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]],this.faces=[[0,2,4,1],[0,4,3,2],[0,3,5,3],[0,5,2,4],[1,3,4,5],[1,4,2,6],[1,2,5,7],[1,5,3,8]],this.scaleFactor=1,this.values=8,this.faceTexts=[" ","0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20"],this.textMargin=1.2,this.mass=340,this.inertia=10,this.create()}}class h extends o{constructor(t){super(t),this.tab=0,this.af=6*Math.PI/5,this.chamfer=.945,this.vertices=[],this.faces=[[5,7,11,0],[4,2,10,1],[1,3,11,2],[0,8,10,3],[7,9,11,4],[8,6,10,5],[9,1,11,6],[2,0,10,7],[3,5,11,8],[6,4,10,9],[1,0,2,-1],[1,2,3,-1],[3,2,4,-1],[3,4,5,-1],[5,4,6,-1],[5,6,7,-1],[7,6,8,-1],[7,8,9,-1],[9,8,0,-1],[9,0,1,-1]];for(let t=0,e=0;t<10;++t,e+=2*Math.PI/10)this.vertices.push([Math.cos(e),Math.sin(e),.105*(t%2?1:-1)]);this.vertices.push([0,0,-1]),this.vertices.push([0,0,1]),this.scaleFactor=.9,this.values=10,this.faceTexts=[" ","0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20"],this.textMargin=1,this.mass=350,this.inertia=9,this.create()}}class l extends o{constructor(t){super(t);let e=(1+Math.sqrt(5))/2,n=1/e;this.tab=.2,this.af=-Math.PI/4/2,this.chamfer=.968,this.vertices=[[0,n,e],[0,n,-e],[0,-n,e],[0,-n,-e],[e,0,n],[e,0,-n],[-e,0,n],[-e,0,-n],[n,e,0],[n,-e,0],[-n,e,0],[-n,-e,0],[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]],this.faces=[[2,14,4,12,0,1],[15,9,11,19,3,2],[16,10,17,7,6,3],[6,7,19,11,18,4],[6,18,2,0,16,5],[18,11,9,14,2,6],[1,17,10,8,13,7],[1,13,5,15,3,8],[13,8,12,4,5,9],[5,4,14,9,15,10],[0,12,8,10,16,11],[3,19,7,17,1,12]],this.scaleFactor=.9,this.values=12,this.faceTexts=[" ","0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20"],this.textMargin=1,this.mass=350,this.inertia=8,this.create()}}class u extends o{constructor(t){super(t);let e=(1+Math.sqrt(5))/2;this.tab=-.2,this.af=-Math.PI/4/2,this.chamfer=.955,this.vertices=[[-1,e,0],[1,e,0],[-1,-e,0],[1,-e,0],[0,-1,e],[0,1,e],[0,-1,-e],[0,1,-e],[e,0,-1],[e,0,1],[-e,0,-1],[-e,0,1]],this.faces=[[0,11,5,1],[0,5,1,2],[0,1,7,3],[0,7,10,4],[0,10,11,5],[1,5,9,6],[5,11,4,7],[11,10,2,8],[10,7,6,9],[7,1,8,10],[3,9,4,11],[3,4,2,12],[3,2,6,13],[3,6,8,14],[3,8,9,15],[4,9,5,16],[2,4,11,17],[6,2,10,18],[8,6,7,19],[9,8,1,20]],this.scaleFactor=1,this.values=20,this.faceTexts=[" ","0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20"],this.textMargin=1,this.mass=400,this.inertia=6,this.create()}}const p=new class{constructor(){this.world=null}setWorld(t){this.world=t,this.diceBodyMaterial=new i.Material,this.floorBodyMaterial=new i.Material,this.barrierBodyMaterial=new i.Material,t.addContactMaterial(new i.ContactMaterial(this.floorBodyMaterial,this.diceBodyMaterial,{friction:.01,restitution:.5})),t.addContactMaterial(new i.ContactMaterial(this.barrierBodyMaterial,this.diceBodyMaterial,{friction:0,restitution:1})),t.addContactMaterial(new i.ContactMaterial(this.diceBodyMaterial,this.diceBodyMaterial,{friction:0,restitution:.5}))}prepareValues(t){if(this.throwRunning)throw new Error("Cannot start another throw. Please wait, till the current throw is finished.");for(let e=0;e<t.length;e++)if(t[e].value<1||t[e].dice.values<t[e].value)throw new Error("Cannot throw die to value "+t[e].value+", because it has only "+t[e].dice.values+" sides.");this.throwRunning=!0;for(let e=0;e<t.length;e++)t[e].dice.simulationRunning=!0,t[e].vectors=t[e].dice.getCurrentVectors(),t[e].stableCount=0;let e=()=>{let n=!0;for(let e=0;e<t.length;e++)t[e].dice.isFinished()?t[e].stableCount++:t[e].stableCount=0,t[e].stableCount<50&&(n=!1);if(n){console.log("all stable"),p.world.removeEventListener("postStep",e);for(let e=0;e<t.length;e++)t[e].dice.shiftUpperValue(t[e].value),t[e].dice.setVectors(t[e].vectors),t[e].dice.simulationRunning=!1;this.throwRunning=!1}else p.world.step(p.world.dt)};this.world.addEventListener("postStep",e)}};"function"==typeof define&&n(5)?define((function(){return{DiceManager:p,DiceD4:a,DiceD6:s,DiceD8:c,DiceD10:h,DiceD12:l,DiceD20:u}})):void 0!==t.exports?t.exports={DiceManager:p,DiceD4:a,DiceD6:s,DiceD8:c,DiceD10:h,DiceD12:l,DiceD20:u}:window.Dice={DiceManager:p,DiceD4:a,DiceD6:s,DiceD8:c,DiceD10:h,DiceD12:l,DiceD20:u}}).call(this,n(4)(t))},function(t,e,n){t.exports=n(7)},function(t,e){t.exports=function(t){if(!t.webpackPolyfill){var e=Object.create(t);e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),Object.defineProperty(e,"exports",{enumerable:!0}),e.webpackPolyfill=1}return e}},function(t,e){(function(e){t.exports=e}).call(this,{})},function(t,e){t.exports=function(t){function e(e,n){var i,r,o,a,s;this.object=e,this.domElement=void 0!==n?n:document,this.enabled=!0,this.target=new t.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:t.MOUSE.LEFT,ZOOM:t.MOUSE.MIDDLE,PAN:t.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.reset=function(){c.target.copy(c.target0),c.object.position.copy(c.position0),c.object.zoom=c.zoom0,c.object.updateProjectionMatrix(),c.dispatchEvent(h),c.update(),d=p.NONE},this.update=(i=new t.Vector3,r=(new t.Quaternion).setFromUnitVectors(e.up,new t.Vector3(0,1,0)),o=r.clone().inverse(),a=new t.Vector3,s=new t.Quaternion,function(){var t=c.object.position;return i.copy(t).sub(c.target),i.applyQuaternion(r),m.setFromVector3(i),c.autoRotate&&d===p.NONE&&L(2*Math.PI/60/60*c.autoRotateSpeed),m.theta+=v.theta,m.phi+=v.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*=g,m.radius=Math.max(c.minDistance,Math.min(c.maxDistance,m.radius)),c.target.add(y),i.setFromSpherical(m),i.applyQuaternion(o),t.copy(c.target).add(i),c.object.lookAt(c.target),!0===c.enableDamping?(v.theta*=1-c.dampingFactor,v.phi*=1-c.dampingFactor):v.set(0,0,0),g=1,y.set(0,0,0),!!(x||a.distanceToSquared(c.object.position)>f||8*(1-s.dot(c.object.quaternion))>f)&&(c.dispatchEvent(h),a.copy(c.object.position),s.copy(c.object.quaternion),x=!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",k,!1),document.removeEventListener("mousemove",U,!1),document.removeEventListener("mouseup",V,!1),window.removeEventListener("keydown",H,!1)};var c=this,h={type:"change"},l={type:"start"},u={type:"end"},p={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY:4,TOUCH_PAN:5},d=p.NONE,f=1e-6,m=new t.Spherical,v=new t.Spherical,g=1,y=new t.Vector3,x=!1,w=new t.Vector2,b=new t.Vector2,_=new t.Vector2,M=new t.Vector2,E=new t.Vector2,S=new t.Vector2,T=new t.Vector2,A=new t.Vector2,R=new t.Vector2;function C(){return Math.pow(.95,c.zoomSpeed)}function L(t){v.theta-=t}function P(t){v.phi-=t}var B,I=(B=new t.Vector3,function(t,e){B.setFromMatrixColumn(e,0),B.multiplyScalar(-t),y.add(B)}),N=function(){var e=new t.Vector3;return function(t,n){e.setFromMatrixColumn(n,1),e.multiplyScalar(t),y.add(e)}}(),O=function(){var e=new t.Vector3;return function(n,i){var r=c.domElement===document?c.domElement.body:c.domElement;if(c.object instanceof t.PerspectiveCamera){var o=c.object.position;e.copy(o).sub(c.target);var a=e.length();a*=Math.tan(c.object.fov/2*Math.PI/180),I(2*n*a/r.clientHeight,c.object.matrix),N(2*i*a/r.clientHeight,c.object.matrix)}else c.object instanceof t.OrthographicCamera?(I(n*(c.object.right-c.object.left)/c.object.zoom/r.clientWidth,c.object.matrix),N(i*(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 F(e){c.object instanceof t.PerspectiveCamera?g/=e:c.object instanceof t.OrthographicCamera?(c.object.zoom=Math.max(c.minZoom,Math.min(c.maxZoom,c.object.zoom*e)),c.object.updateProjectionMatrix(),x=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),c.enableZoom=!1)}function z(e){c.object instanceof t.PerspectiveCamera?g*=e:c.object instanceof t.OrthographicCamera?(c.object.zoom=Math.max(c.minZoom,Math.min(c.maxZoom,c.object.zoom/e)),c.object.updateProjectionMatrix(),x=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),c.enableZoom=!1)}function D(t){if(!1!==c.enabled){if(t.preventDefault(),t.button===c.mouseButtons.ORBIT){if(!1===c.enableRotate)return;!function(t){w.set(t.clientX,t.clientY)}(t),d=p.ROTATE}else if(t.button===c.mouseButtons.ZOOM){if(!1===c.enableZoom)return;!function(t){T.set(t.clientX,t.clientY)}(t),d=p.DOLLY}else if(t.button===c.mouseButtons.PAN){if(!1===c.enablePan)return;!function(t){M.set(t.clientX,t.clientY)}(t),d=p.PAN}d!==p.NONE&&(document.addEventListener("mousemove",U,!1),document.addEventListener("mouseup",V,!1),c.dispatchEvent(l))}}function U(t){if(!1!==c.enabled)if(t.preventDefault(),d===p.ROTATE){if(!1===c.enableRotate)return;!function(t){b.set(t.clientX,t.clientY),_.subVectors(b,w);var e=c.domElement===document?c.domElement.body:c.domElement;L(2*Math.PI*_.x/e.clientWidth*c.rotateSpeed),P(2*Math.PI*_.y/e.clientHeight*c.rotateSpeed),w.copy(b),c.update()}(t)}else if(d===p.DOLLY){if(!1===c.enableZoom)return;!function(t){A.set(t.clientX,t.clientY),R.subVectors(A,T),R.y>0?F(C()):R.y<0&&z(C()),T.copy(A),c.update()}(t)}else if(d===p.PAN){if(!1===c.enablePan)return;!function(t){E.set(t.clientX,t.clientY),S.subVectors(E,M),O(S.x,S.y),M.copy(E),c.update()}(t)}}function V(t){!1!==c.enabled&&(document.removeEventListener("mousemove",U,!1),document.removeEventListener("mouseup",V,!1),c.dispatchEvent(u),d=p.NONE)}function G(t){!1===c.enabled||!1===c.enableZoom||d!==p.NONE&&d!==p.ROTATE||(t.preventDefault(),t.stopPropagation(),function(t){t.deltaY<0?z(C()):t.deltaY>0&&F(C()),c.update()}(t),c.dispatchEvent(l),c.dispatchEvent(u))}function H(t){!1!==c.enabled&&!1!==c.enableKeys&&!1!==c.enablePan&&function(t){switch(t.keyCode){case c.keys.UP:O(0,c.keyPanSpeed),c.update();break;case c.keys.BOTTOM:O(0,-c.keyPanSpeed),c.update();break;case c.keys.LEFT:O(c.keyPanSpeed,0),c.update();break;case c.keys.RIGHT:O(-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){w.set(t.touches[0].pageX,t.touches[0].pageY)}(t),d=p.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,i=Math.sqrt(e*e+n*n);T.set(0,i)}(t),d=p.TOUCH_DOLLY;break;case 3:if(!1===c.enablePan)return;!function(t){M.set(t.touches[0].pageX,t.touches[0].pageY)}(t),d=p.TOUCH_PAN;break;default:d=p.NONE}d!==p.NONE&&c.dispatchEvent(l)}}function k(t){if(!1!==c.enabled)switch(t.preventDefault(),t.stopPropagation(),t.touches.length){case 1:if(!1===c.enableRotate)return;if(d!==p.TOUCH_ROTATE)return;!function(t){b.set(t.touches[0].pageX,t.touches[0].pageY),_.subVectors(b,w);var e=c.domElement===document?c.domElement.body:c.domElement;L(2*Math.PI*_.x/e.clientWidth*c.rotateSpeed),P(2*Math.PI*_.y/e.clientHeight*c.rotateSpeed),w.copy(b),c.update()}(t);break;case 2:if(!1===c.enableZoom)return;if(d!==p.TOUCH_DOLLY)return;!function(t){var e=t.touches[0].pageX-t.touches[1].pageX,n=t.touches[0].pageY-t.touches[1].pageY,i=Math.sqrt(e*e+n*n);A.set(0,i),R.subVectors(A,T),R.y>0?z(C()):R.y<0&&F(C()),T.copy(A),c.update()}(t);break;case 3:if(!1===c.enablePan)return;if(d!==p.TOUCH_PAN)return;!function(t){E.set(t.touches[0].pageX,t.touches[0].pageY),S.subVectors(E,M),O(S.x,S.y),M.copy(E),c.update()}(t);break;default:d=p.NONE}}function W(t){!1!==c.enabled&&(c.dispatchEvent(u),d=p.NONE)}function q(t){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",k,!1),window.addEventListener("keydown",H,!1),this.update()}return e.prototype=Object.create(t.EventDispatcher.prototype),e.prototype.constructor=e,Object.defineProperties(e.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}}}),e}},function(t,e,n){"use strict";n.r(e);var i=n(1),r=n(0),o=n(2);function a(t){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function s(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function c(t,e,n){return(c="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=p(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(n):r.value}})(t,e,n||t)}function h(t,e){return(h=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function l(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,i=p(t);if(e){var r=p(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return u(this,n)}}function u(t,e){return!e||"object"!==a(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function p(t){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var d=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&h(t,e)}(o,t);var e,n,i,r=l(o);function o(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,o),(e=r.call(this,t)).faceTexts=[" ","1","2","3","4","5","6.","7","8","9.","10","11","12","13","14","15","16","17","18","19","20"],e.create(),e}return e=o,(n=[{key:"getUpsideValue",value:function(){return c(p(o.prototype),"getUpsideValue",this).call(this)+1}}])&&s(e.prototype,n),i&&s(e,i),o}(o.a);window.OrbitControls=n(6)(r),window.rollingDice=function(t){this.stableCheckCounter=0,this.scene=new r.Scene,this.SCREEN_WIDTH=window.innerWidth,this.SCREEN_HEIGHT=window.innerHeight;var e=this.SCREEN_WIDTH/this.SCREEN_HEIGHT;this.camera=new r.PerspectiveCamera(30,e,.01,2e3),this.scene.add(this.camera),this.camera.position.set(0,90,30),this.renderer=new r.WebGLRenderer({antialias:!0,alpha:!0}),this.renderer.setSize(this.SCREEN_WIDTH,this.SCREEN_HEIGHT),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=r.PCFSoftShadowMap,this.container=document.getElementById(t),this.renderer.setSize(this.SCREEN_WIDTH,this.SCREEN_HEIGHT),this.canvas=this.renderer.domElement,this.canvas.id="dice-canvas",this.container.appendChild(this.canvas),this.controls=new OrbitControls(this.camera,this.canvas),this.controls.enabled=!1;var n=new r.AmbientLight("#ffffff",.3);this.scene.add(n);var a=new r.DirectionalLight("#ffffff",.5);a.position.x=-1e3,a.position.y=1e3,a.position.z=1e3,this.scene.add(a);var s=new r.SpotLight(15720405,1.3);s.position.y=100,s.target.position.set(0,0,0),s.castShadow=!0,s.shadow.camera.near=50,s.shadow.camera.far=110,s.shadow.mapSize.width=1024,s.shadow.mapSize.height=1024,this.scene.add(s),this.scene.fog=new r.FogExp2(10066431,0),this.world=new i.World,this.world.gravity.set(0,-589.2,-15),this.world.broadphase=new i.NaiveBroadphase,this.world.solver.iterations=16,o.b.setWorld(this.world);var c=new i.Body({mass:0,shape:new i.Plane,material:o.b.floorBodyMaterial});c.quaternion.setFromAxisAngle(new i.Vec3(1,0,0),-Math.PI/2),this.world.add(c),this.dice=new d({size:4,backColor:"#000",fontColor:"#fff"}),this.scene.add(this.dice.getObject())},window.rollingDice.prototype.show=function(){this.dice.getObject().position.x=60,this.dice.getObject().position.y=15,this.dice.getObject().position.z=5,this.start()},window.rollingDice.prototype.randomDiceThrow=function(t){this.finishedCallback=t;var e=20*Math.random();this.dice.getObject().position.x=60,this.dice.getObject().position.y=15,this.dice.getObject().position.z=5;var n=5*Math.random();this.dice.getObject().body.velocity.set(-95+n,37+e,0),this.dice.getObject().body.angularVelocity.set(30*Math.random()-10,30*Math.random()-5,5),this.dice.updateBodyFromMesh(),this.start()},window.rollingDice.prototype.start=function(){this.stopRendering=!1,requestAnimationFrame(this.animate.bind(this))},window.rollingDice.prototype.stop=function(){this.stopRendering=!0},window.rollingDice.prototype.animate=function(){this.updatePhysics(),this.render(),this.update(),this.stopRendering||requestAnimationFrame(this.animate.bind(this))},window.rollingDice.prototype.updatePhysics=function(){this.world.step(1/60),this.dice.updateMeshFromBody(),this.checkProgress()},window.rollingDice.prototype.update=function(){this.controls.update()},window.rollingDice.prototype.render=function(){this.renderer.render(this.scene,this.camera)},window.rollingDice.prototype.checkProgress=function(){this.dice.isFinished()?(this.stableCheckCounter++,10===this.stableCheckCounter&&(this.diceResult=this.dice.getUpsideValue(),this.finishedCallback&&(this.finishedCallback(this.diceResult),this.stop()))):this.stableCheckCounter=0}}]);