From 79300225d70972159b4609416e05698e5e047ecd Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Wed, 18 Dec 2019 20:37:42 -0500 Subject: [PATCH 1/9] prototypes and experiments --- .gitignore | 3 ++ dragdrop/package-lock.json | 25 ++++++++++++++++ example/dist/bundle.js | 26 ++++++++++++---- example/package-lock.json | 24 +++++++++++++++ scenemanager/package-lock.json | 55 ++++++++++++++++++++++++++++------ 5 files changed, 119 insertions(+), 14 deletions(-) create mode 100644 dragdrop/package-lock.json diff --git a/.gitignore b/.gitignore index a9ee439..f54b77b 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,6 @@ typings/ # andrew's virtual environment andrewsvenv/ + +# secrets secrets are no fun ;) +bricked_experiments/ diff --git a/dragdrop/package-lock.json b/dragdrop/package-lock.json new file mode 100644 index 0000000..2cb9b10 --- /dev/null +++ b/dragdrop/package-lock.json @@ -0,0 +1,25 @@ +{ + "name": "dragdrop", + "version": "0.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/node": { + "version": "12.12.20", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.20.tgz", + "integrity": "sha512-VAe+DiwpnC/g448uN+/3gRl4th0BTdrR9gSLIOHA+SUQskaYZQDOHG7xmjiE7JUhjbXnbXytf6Ih+/pA6CtMFQ==", + "dev": true + }, + "three": { + "version": "0.110.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.110.0.tgz", + "integrity": "sha512-wlurH8XBO9Sd5VIw8nBa+taLR20kqaI4e9FiuMh6tqK8eOS2q2R+ZoUyufbyDTVTHhs8GiTbv0r2CMLkwerFJg==" + }, + "typescript": { + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.3.tgz", + "integrity": "sha512-Mcr/Qk7hXqFBXMN7p7Lusj1ktCBydylfQM/FZCk5glCNQJrCUKPkMHdo9R0MTFWsC/4kPFvDS0fDPvukfCkFsw==", + "dev": true + } + } +} diff --git a/example/dist/bundle.js b/example/dist/bundle.js index 24df8c3..676d3c5 100644 --- a/example/dist/bundle.js +++ b/example/dist/bundle.js @@ -1,8 +1,24 @@ -!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){"use strict";n.r(t),n.d(t,"ACESFilmicToneMapping",(function(){return ce})),n.d(t,"AddEquation",(function(){return C})),n.d(t,"AddOperation",(function(){return ne})),n.d(t,"AdditiveBlending",(function(){return S})),n.d(t,"AlphaFormat",(function(){return Ve})),n.d(t,"AlwaysDepth",(function(){return q})),n.d(t,"AlwaysStencilFunc",(function(){return on})),n.d(t,"AmbientLight",(function(){return Qu})),n.d(t,"AmbientLightProbe",(function(){return gh})),n.d(t,"AnimationClip",(function(){return tu})),n.d(t,"AnimationLoader",(function(){return lu})),n.d(t,"AnimationMixer",(function(){return qh})),n.d(t,"AnimationObjectGroup",(function(){return Wh})),n.d(t,"AnimationUtils",(function(){return Vl})),n.d(t,"ArcCurve",(function(){return gu})),n.d(t,"ArrayCamera",(function(){return fs})),n.d(t,"ArrowHelper",(function(){return qd})),n.d(t,"Audio",(function(){return Th})),n.d(t,"AudioAnalyser",(function(){return Ih})),n.d(t,"AudioContext",(function(){return dh})),n.d(t,"AudioListener",(function(){return Sh})),n.d(t,"AudioLoader",(function(){return ph})),n.d(t,"AxesHelper",(function(){return Qd})),n.d(t,"AxisHelper",(function(){return xp})),n.d(t,"BackSide",(function(){return g})),n.d(t,"BasicDepthPacking",(function(){return zt})),n.d(t,"BasicShadowMap",(function(){return d})),n.d(t,"BinaryTextureLoader",(function(){return Ep})),n.d(t,"Bone",(function(){return Qs})),n.d(t,"BooleanKeyframeTrack",(function(){return Ql})),n.d(t,"BoundingBoxHelper",(function(){return bp})),n.d(t,"Box2",(function(){return nd})),n.d(t,"Box3",(function(){return Ar})),n.d(t,"Box3Helper",(function(){return Vd})),n.d(t,"BoxBufferGeometry",(function(){return Yi})),n.d(t,"BoxGeometry",(function(){return Qi})),n.d(t,"BoxHelper",(function(){return Hd})),n.d(t,"BufferAttribute",(function(){return ri})),n.d(t,"BufferGeometry",(function(){return wi})),n.d(t,"BufferGeometryLoader",(function(){return eh})),n.d(t,"ByteType",(function(){return Pe})),n.d(t,"Cache",(function(){return ru})),n.d(t,"Camera",(function(){return na})),n.d(t,"CameraHelper",(function(){return Gd})),n.d(t,"CanvasRenderer",(function(){return Tp})),n.d(t,"CanvasTexture",(function(){return vc})),n.d(t,"CatmullRomCurve3",(function(){return _u})),n.d(t,"CineonToneMapping",(function(){return se})),n.d(t,"CircleBufferGeometry",(function(){return Rl})),n.d(t,"CircleGeometry",(function(){return Ll})),n.d(t,"ClampToEdgeWrapping",(function(){return ye})),n.d(t,"Clock",(function(){return bh})),n.d(t,"ClosedSplineCurve3",(function(){return gp})),n.d(t,"Color",(function(){return Yr})),n.d(t,"ColorKeyframeTrack",(function(){return Yl})),n.d(t,"CompressedTexture",(function(){return mc})),n.d(t,"CompressedTextureLoader",(function(){return uu})),n.d(t,"ConeBufferGeometry",(function(){return Tl})),n.d(t,"ConeGeometry",(function(){return Sl})),n.d(t,"CubeCamera",(function(){return oa})),n.d(t,"CubeGeometry",(function(){return Qi})),n.d(t,"CubeReflectionMapping",(function(){return ue})),n.d(t,"CubeRefractionMapping",(function(){return he})),n.d(t,"CubeTexture",(function(){return Ca})),n.d(t,"CubeTextureLoader",(function(){return pu})),n.d(t,"CubeUVReflectionMapping",(function(){return me})),n.d(t,"CubeUVRefractionMapping",(function(){return ve})),n.d(t,"CubicBezierCurve",(function(){return Tu})),n.d(t,"CubicBezierCurve3",(function(){return Lu})),n.d(t,"CubicInterpolant",(function(){return jl})),n.d(t,"CullFaceBack",(function(){return s})),n.d(t,"CullFaceFront",(function(){return c})),n.d(t,"CullFaceFrontBack",(function(){return l})),n.d(t,"CullFaceNone",(function(){return o})),n.d(t,"Curve",(function(){return mu})),n.d(t,"CurvePath",(function(){return Nu})),n.d(t,"CustomBlending",(function(){return R})),n.d(t,"CylinderBufferGeometry",(function(){return El})),n.d(t,"CylinderGeometry",(function(){return Ml})),n.d(t,"Cylindrical",(function(){return ed})),n.d(t,"DataTexture",(function(){return ca})),n.d(t,"DataTexture2DArray",(function(){return Pa})),n.d(t,"DataTexture3D",(function(){return Da})),n.d(t,"DataTextureLoader",(function(){return hu})),n.d(t,"DecrementStencilOp",(function(){return Qt})),n.d(t,"DecrementWrapStencilOp",(function(){return Zt})),n.d(t,"DefaultLoadingManager",(function(){return au})),n.d(t,"DepthFormat",(function(){return Qe})),n.d(t,"DepthStencilFormat",(function(){return Ye})),n.d(t,"DepthTexture",(function(){return gc})),n.d(t,"DirectionalLight",(function(){return qu})),n.d(t,"DirectionalLightHelper",(function(){return Nd})),n.d(t,"DirectionalLightShadow",(function(){return Xu})),n.d(t,"DiscreteInterpolant",(function(){return Xl})),n.d(t,"DodecahedronBufferGeometry",(function(){return Cc})),n.d(t,"DodecahedronGeometry",(function(){return Rc})),n.d(t,"DoubleSide",(function(){return y})),n.d(t,"DstAlphaFactor",(function(){return H})),n.d(t,"DstColorFactor",(function(){return k})),n.d(t,"DynamicBufferAttribute",(function(){return sp})),n.d(t,"DynamicCopyUsage",(function(){return fn})),n.d(t,"DynamicDrawUsage",(function(){return cn})),n.d(t,"DynamicReadUsage",(function(){return hn})),n.d(t,"EdgesGeometry",(function(){return _l})),n.d(t,"EdgesHelper",(function(){return wp})),n.d(t,"EllipseCurve",(function(){return vu})),n.d(t,"EqualDepth",(function(){return Z})),n.d(t,"EqualStencilFunc",(function(){return en})),n.d(t,"EquirectangularReflectionMapping",(function(){return de})),n.d(t,"EquirectangularRefractionMapping",(function(){return pe})),n.d(t,"Euler",(function(){return jn})),n.d(t,"EventDispatcher",(function(){return vn})),n.d(t,"ExtrudeBufferGeometry",(function(){return ll})),n.d(t,"ExtrudeGeometry",(function(){return cl})),n.d(t,"Face3",(function(){return $r})),n.d(t,"Face4",(function(){return Yd})),n.d(t,"FaceColors",(function(){return w})),n.d(t,"FaceNormalsHelper",(function(){return Pd})),n.d(t,"FileLoader",(function(){return cu})),n.d(t,"FlatShading",(function(){return A})),n.d(t,"Float32Attribute",(function(){return mp})),n.d(t,"Float32BufferAttribute",(function(){return hi})),n.d(t,"Float64Attribute",(function(){return vp})),n.d(t,"Float64BufferAttribute",(function(){return di})),n.d(t,"FloatType",(function(){return Be})),n.d(t,"Fog",(function(){return _s})),n.d(t,"FogExp2",(function(){return ws})),n.d(t,"Font",(function(){return lh})),n.d(t,"FontLoader",(function(){return hh})),n.d(t,"FrontFaceDirectionCCW",(function(){return h})),n.d(t,"FrontFaceDirectionCW",(function(){return u})),n.d(t,"FrontSide",(function(){return v})),n.d(t,"Frustum",(function(){return ha})),n.d(t,"GammaEncoding",(function(){return Ot})),n.d(t,"Geometry",(function(){return qi})),n.d(t,"GeometryUtils",(function(){return Sp})),n.d(t,"GreaterDepth",(function(){return K})),n.d(t,"GreaterEqualDepth",(function(){return J})),n.d(t,"GreaterEqualStencilFunc",(function(){return an})),n.d(t,"GreaterStencilFunc",(function(){return nn})),n.d(t,"GridHelper",(function(){return Ed})),n.d(t,"Group",(function(){return ps})),n.d(t,"HalfFloatType",(function(){return Fe})),n.d(t,"HemisphereLight",(function(){return Uu})),n.d(t,"HemisphereLightHelper",(function(){return _d})),n.d(t,"HemisphereLightProbe",(function(){return vh})),n.d(t,"IcosahedronBufferGeometry",(function(){return Lc})),n.d(t,"IcosahedronGeometry",(function(){return Tc})),n.d(t,"ImageBitmapLoader",(function(){return sh})),n.d(t,"ImageLoader",(function(){return du})),n.d(t,"ImageUtils",(function(){return Ln})),n.d(t,"ImmediateRenderObject",(function(){return od})),n.d(t,"IncrementStencilOp",(function(){return qt})),n.d(t,"IncrementWrapStencilOp",(function(){return Yt})),n.d(t,"InstancedBufferAttribute",(function(){return $u})),n.d(t,"InstancedBufferGeometry",(function(){return Ku})),n.d(t,"InstancedInterleavedBuffer",(function(){return Yh})),n.d(t,"InstancedMesh",(function(){return Ys})),n.d(t,"Int16Attribute",(function(){return hp})),n.d(t,"Int16BufferAttribute",(function(){return si})),n.d(t,"Int32Attribute",(function(){return pp})),n.d(t,"Int32BufferAttribute",(function(){return li})),n.d(t,"Int8Attribute",(function(){return cp})),n.d(t,"Int8BufferAttribute",(function(){return ii})),n.d(t,"IntType",(function(){return Oe})),n.d(t,"InterleavedBuffer",(function(){return Ms})),n.d(t,"InterleavedBufferAttribute",(function(){return Es})),n.d(t,"Interpolant",(function(){return kl})),n.d(t,"InterpolateDiscrete",(function(){return _t})),n.d(t,"InterpolateLinear",(function(){return Mt})),n.d(t,"InterpolateSmooth",(function(){return Et})),n.d(t,"InvertStencilOp",(function(){return Jt})),n.d(t,"JSONLoader",(function(){return Lp})),n.d(t,"KeepStencilOp",(function(){return Wt})),n.d(t,"KeyframeTrack",(function(){return ql})),n.d(t,"LOD",(function(){return ks})),n.d(t,"LatheBufferGeometry",(function(){return Al})),n.d(t,"LatheGeometry",(function(){return yl})),n.d(t,"Layers",(function(){return Wn})),n.d(t,"LensFlare",(function(){return Cp})),n.d(t,"LessDepth",(function(){return Q})),n.d(t,"LessEqualDepth",(function(){return Y})),n.d(t,"LessEqualStencilFunc",(function(){return tn})),n.d(t,"LessStencilFunc",(function(){return $t})),n.d(t,"Light",(function(){return Gu})),n.d(t,"LightProbe",(function(){return mh})),n.d(t,"LightProbeHelper",(function(){return Md})),n.d(t,"LightShadow",(function(){return zu})),n.d(t,"Line",(function(){return nc})),n.d(t,"Line3",(function(){return ad})),n.d(t,"LineBasicMaterial",(function(){return Zs})),n.d(t,"LineCurve",(function(){return Ru})),n.d(t,"LineCurve3",(function(){return Cu})),n.d(t,"LineDashedMaterial",(function(){return zl})),n.d(t,"LineLoop",(function(){return oc})),n.d(t,"LinePieces",(function(){return Jd})),n.d(t,"LineSegments",(function(){return ac})),n.d(t,"LineStrip",(function(){return Zd})),n.d(t,"LinearEncoding",(function(){return Dt})),n.d(t,"LinearFilter",(function(){return Ee})),n.d(t,"LinearInterpolant",(function(){return Wl})),n.d(t,"LinearMipMapLinearFilter",(function(){return Re})),n.d(t,"LinearMipMapNearestFilter",(function(){return Te})),n.d(t,"LinearMipmapLinearFilter",(function(){return Le})),n.d(t,"LinearMipmapNearestFilter",(function(){return Se})),n.d(t,"LinearToneMapping",(function(){return ie})),n.d(t,"Loader",(function(){return ou})),n.d(t,"LoaderUtils",(function(){return Ju})),n.d(t,"LoadingManager",(function(){return iu})),n.d(t,"LogLuvEncoding",(function(){return Bt})),n.d(t,"LoopOnce",(function(){return xt})),n.d(t,"LoopPingPong",(function(){return wt})),n.d(t,"LoopRepeat",(function(){return bt})),n.d(t,"LuminanceAlphaFormat",(function(){return Xe})),n.d(t,"LuminanceFormat",(function(){return We})),n.d(t,"MOUSE",(function(){return i})),n.d(t,"Material",(function(){return ti})),n.d(t,"MaterialLoader",(function(){return Zu})),n.d(t,"Math",(function(){return An})),n.d(t,"Matrix3",(function(){return Tn})),n.d(t,"Matrix4",(function(){return Hn})),n.d(t,"MaxEquation",(function(){return O})),n.d(t,"Mesh",(function(){return zi})),n.d(t,"MeshBasicMaterial",(function(){return ni})),n.d(t,"MeshDepthMaterial",(function(){return rs})),n.d(t,"MeshDistanceMaterial",(function(){return is})),n.d(t,"MeshFaceMaterial",(function(){return Kd})),n.d(t,"MeshLambertMaterial",(function(){return Gl})),n.d(t,"MeshMatcapMaterial",(function(){return Ul})),n.d(t,"MeshNormalMaterial",(function(){return Fl})),n.d(t,"MeshPhongMaterial",(function(){return Nl})),n.d(t,"MeshPhysicalMaterial",(function(){return Ol})),n.d(t,"MeshStandardMaterial",(function(){return Il})),n.d(t,"MeshToonMaterial",(function(){return Bl})),n.d(t,"MinEquation",(function(){return I})),n.d(t,"MirroredRepeatWrapping",(function(){return Ae})),n.d(t,"MixOperation",(function(){return te})),n.d(t,"MultiMaterial",(function(){return $d})),n.d(t,"MultiplyBlending",(function(){return L})),n.d(t,"MultiplyOperation",(function(){return ee})),n.d(t,"NearestFilter",(function(){return xe})),n.d(t,"NearestMipMapLinearFilter",(function(){return Me})),n.d(t,"NearestMipMapNearestFilter",(function(){return we})),n.d(t,"NearestMipmapLinearFilter",(function(){return _e})),n.d(t,"NearestMipmapNearestFilter",(function(){return be})),n.d(t,"NeverDepth",(function(){return X})),n.d(t,"NeverStencilFunc",(function(){return Kt})),n.d(t,"NoBlending",(function(){return M})),n.d(t,"NoColors",(function(){return b})),n.d(t,"NoToneMapping",(function(){return re})),n.d(t,"NormalBlending",(function(){return E})),n.d(t,"NotEqualDepth",(function(){return $})),n.d(t,"NotEqualStencilFunc",(function(){return rn})),n.d(t,"NumberKeyframeTrack",(function(){return Zl})),n.d(t,"Object3D",(function(){return ar})),n.d(t,"ObjectLoader",(function(){return nh})),n.d(t,"ObjectSpaceNormalMap",(function(){return kt})),n.d(t,"OctahedronBufferGeometry",(function(){return Sc})),n.d(t,"OctahedronGeometry",(function(){return Ec})),n.d(t,"OneFactor",(function(){return B})),n.d(t,"OneMinusDstAlphaFactor",(function(){return V})),n.d(t,"OneMinusDstColorFactor",(function(){return j})),n.d(t,"OneMinusSrcAlphaFactor",(function(){return z})),n.d(t,"OneMinusSrcColorFactor",(function(){return G})),n.d(t,"OrthographicCamera",(function(){return Wu})),n.d(t,"PCFShadowMap",(function(){return p})),n.d(t,"PCFSoftShadowMap",(function(){return f})),n.d(t,"ParametricBufferGeometry",(function(){return xc})),n.d(t,"ParametricGeometry",(function(){return Ac})),n.d(t,"Particle",(function(){return tp})),n.d(t,"ParticleBasicMaterial",(function(){return ip})),n.d(t,"ParticleSystem",(function(){return np})),n.d(t,"ParticleSystemMaterial",(function(){return ap})),n.d(t,"Path",(function(){return Bu})),n.d(t,"PerspectiveCamera",(function(){return ra})),n.d(t,"Plane",(function(){return Or})),n.d(t,"PlaneBufferGeometry",(function(){return ya})),n.d(t,"PlaneGeometry",(function(){return ga})),n.d(t,"PlaneHelper",(function(){return kd})),n.d(t,"PointCloud",(function(){return ep})),n.d(t,"PointCloudMaterial",(function(){return rp})),n.d(t,"PointLight",(function(){return ju})),n.d(t,"PointLightHelper",(function(){return yd})),n.d(t,"Points",(function(){return dc})),n.d(t,"PointsMaterial",(function(){return sc})),n.d(t,"PolarGridHelper",(function(){return Sd})),n.d(t,"PolyhedronBufferGeometry",(function(){return wc})),n.d(t,"PolyhedronGeometry",(function(){return bc})),n.d(t,"PositionalAudio",(function(){return Dh})),n.d(t,"PositionalAudioHelper",(function(){return Td})),n.d(t,"PropertyBinding",(function(){return jh})),n.d(t,"PropertyMixer",(function(){return Oh})),n.d(t,"QuadraticBezierCurve",(function(){return Pu})),n.d(t,"QuadraticBezierCurve3",(function(){return Du})),n.d(t,"Quaternion",(function(){return bn})),n.d(t,"QuaternionKeyframeTrack",(function(){return Kl})),n.d(t,"QuaternionLinearInterpolant",(function(){return Jl})),n.d(t,"REVISION",(function(){return r})),n.d(t,"RGBADepthPacking",(function(){return Ht})),n.d(t,"RGBAFormat",(function(){return je})),n.d(t,"RGBA_ASTC_10x10_Format",(function(){return gt})),n.d(t,"RGBA_ASTC_10x5_Format",(function(){return ft})),n.d(t,"RGBA_ASTC_10x6_Format",(function(){return mt})),n.d(t,"RGBA_ASTC_10x8_Format",(function(){return vt})),n.d(t,"RGBA_ASTC_12x10_Format",(function(){return yt})),n.d(t,"RGBA_ASTC_12x12_Format",(function(){return At})),n.d(t,"RGBA_ASTC_4x4_Format",(function(){return ot})),n.d(t,"RGBA_ASTC_5x4_Format",(function(){return st})),n.d(t,"RGBA_ASTC_5x5_Format",(function(){return ct})),n.d(t,"RGBA_ASTC_6x5_Format",(function(){return lt})),n.d(t,"RGBA_ASTC_6x6_Format",(function(){return ut})),n.d(t,"RGBA_ASTC_8x5_Format",(function(){return ht})),n.d(t,"RGBA_ASTC_8x6_Format",(function(){return dt})),n.d(t,"RGBA_ASTC_8x8_Format",(function(){return pt})),n.d(t,"RGBA_PVRTC_2BPPV1_Format",(function(){return it})),n.d(t,"RGBA_PVRTC_4BPPV1_Format",(function(){return rt})),n.d(t,"RGBA_S3TC_DXT1_Format",(function(){return Ke})),n.d(t,"RGBA_S3TC_DXT3_Format",(function(){return $e})),n.d(t,"RGBA_S3TC_DXT5_Format",(function(){return et})),n.d(t,"RGBDEncoding",(function(){return Ut})),n.d(t,"RGBEEncoding",(function(){return Nt})),n.d(t,"RGBEFormat",(function(){return qe})),n.d(t,"RGBFormat",(function(){return ke})),n.d(t,"RGBM16Encoding",(function(){return Gt})),n.d(t,"RGBM7Encoding",(function(){return Ft})),n.d(t,"RGB_ETC1_Format",(function(){return at})),n.d(t,"RGB_PVRTC_2BPPV1_Format",(function(){return nt})),n.d(t,"RGB_PVRTC_4BPPV1_Format",(function(){return tt})),n.d(t,"RGB_S3TC_DXT1_Format",(function(){return Je})),n.d(t,"RawShaderMaterial",(function(){return Dl})),n.d(t,"Ray",(function(){return Cr})),n.d(t,"Raycaster",(function(){return Zh})),n.d(t,"RectAreaLight",(function(){return Yu})),n.d(t,"RectAreaLightHelper",(function(){return Ad})),n.d(t,"RedFormat",(function(){return Ze})),n.d(t,"ReinhardToneMapping",(function(){return ae})),n.d(t,"RepeatWrapping",(function(){return ge})),n.d(t,"ReplaceStencilOp",(function(){return Xt})),n.d(t,"ReverseSubtractEquation",(function(){return D})),n.d(t,"RingBufferGeometry",(function(){return gl})),n.d(t,"RingGeometry",(function(){return vl})),n.d(t,"Scene",(function(){return or})),n.d(t,"SceneUtils",(function(){return Rp})),n.d(t,"ShaderChunk",(function(){return da})),n.d(t,"ShaderLib",(function(){return fa})),n.d(t,"ShaderMaterial",(function(){return ta})),n.d(t,"ShadowMaterial",(function(){return Pl})),n.d(t,"Shape",(function(){return Fu})),n.d(t,"ShapeBufferGeometry",(function(){return bl})),n.d(t,"ShapeGeometry",(function(){return xl})),n.d(t,"ShapePath",(function(){return ch})),n.d(t,"ShapeUtils",(function(){return al})),n.d(t,"ShortType",(function(){return De})),n.d(t,"Skeleton",(function(){return qs})),n.d(t,"SkeletonHelper",(function(){return gd})),n.d(t,"SkinnedMesh",(function(){return js})),n.d(t,"SmoothShading",(function(){return x})),n.d(t,"Sphere",(function(){return wr})),n.d(t,"SphereBufferGeometry",(function(){return ml})),n.d(t,"SphereGeometry",(function(){return fl})),n.d(t,"Spherical",(function(){return $h})),n.d(t,"SphericalHarmonics3",(function(){return fh})),n.d(t,"SphericalReflectionMapping",(function(){return fe})),n.d(t,"Spline",(function(){return Ap})),n.d(t,"SplineCurve",(function(){return Iu})),n.d(t,"SplineCurve3",(function(){return yp})),n.d(t,"SpotLight",(function(){return Vu})),n.d(t,"SpotLightHelper",(function(){return pd})),n.d(t,"SpotLightShadow",(function(){return Hu})),n.d(t,"Sprite",(function(){return Us})),n.d(t,"SpriteMaterial",(function(){return Ss})),n.d(t,"SrcAlphaFactor",(function(){return U})),n.d(t,"SrcAlphaSaturateFactor",(function(){return W})),n.d(t,"SrcColorFactor",(function(){return F})),n.d(t,"StaticCopyUsage",(function(){return pn})),n.d(t,"StaticDrawUsage",(function(){return sn})),n.d(t,"StaticReadUsage",(function(){return un})),n.d(t,"StereoCamera",(function(){return xh})),n.d(t,"StreamCopyUsage",(function(){return mn})),n.d(t,"StreamDrawUsage",(function(){return ln})),n.d(t,"StreamReadUsage",(function(){return dn})),n.d(t,"StringKeyframeTrack",(function(){return $l})),n.d(t,"SubtractEquation",(function(){return P})),n.d(t,"SubtractiveBlending",(function(){return T})),n.d(t,"TOUCH",(function(){return a})),n.d(t,"TangentSpaceNormalMap",(function(){return Vt})),n.d(t,"TetrahedronBufferGeometry",(function(){return Mc})),n.d(t,"TetrahedronGeometry",(function(){return _c})),n.d(t,"TextBufferGeometry",(function(){return pl})),n.d(t,"TextGeometry",(function(){return dl})),n.d(t,"Texture",(function(){return Cn})),n.d(t,"TextureLoader",(function(){return fu})),n.d(t,"TorusBufferGeometry",(function(){return Bc})),n.d(t,"TorusGeometry",(function(){return Nc})),n.d(t,"TorusKnotBufferGeometry",(function(){return Oc})),n.d(t,"TorusKnotGeometry",(function(){return Ic})),n.d(t,"Triangle",(function(){return Wr})),n.d(t,"TriangleFanDrawMode",(function(){return Pt})),n.d(t,"TriangleStripDrawMode",(function(){return Ct})),n.d(t,"TrianglesDrawMode",(function(){return Rt})),n.d(t,"TubeBufferGeometry",(function(){return Dc})),n.d(t,"TubeGeometry",(function(){return Pc})),n.d(t,"UVMapping",(function(){return le})),n.d(t,"Uint16Attribute",(function(){return dp})),n.d(t,"Uint16BufferAttribute",(function(){return ci})),n.d(t,"Uint32Attribute",(function(){return fp})),n.d(t,"Uint32BufferAttribute",(function(){return ui})),n.d(t,"Uint8Attribute",(function(){return lp})),n.d(t,"Uint8BufferAttribute",(function(){return ai})),n.d(t,"Uint8ClampedAttribute",(function(){return up})),n.d(t,"Uint8ClampedBufferAttribute",(function(){return oi})),n.d(t,"Uncharted2ToneMapping",(function(){return oe})),n.d(t,"Uniform",(function(){return Qh})),n.d(t,"UniformsLib",(function(){return pa})),n.d(t,"UniformsUtils",(function(){return Ki})),n.d(t,"UnsignedByteType",(function(){return Ce})),n.d(t,"UnsignedInt248Type",(function(){return He})),n.d(t,"UnsignedIntType",(function(){return Ne})),n.d(t,"UnsignedShort4444Type",(function(){return Ge})),n.d(t,"UnsignedShort5551Type",(function(){return Ue})),n.d(t,"UnsignedShort565Type",(function(){return ze})),n.d(t,"UnsignedShortType",(function(){return Ie})),n.d(t,"VSMShadowMap",(function(){return m})),n.d(t,"Vector2",(function(){return xn})),n.d(t,"Vector3",(function(){return Mn})),n.d(t,"Vector4",(function(){return Pn})),n.d(t,"VectorKeyframeTrack",(function(){return eu})),n.d(t,"Vertex",(function(){return op})),n.d(t,"VertexColors",(function(){return _})),n.d(t,"VertexNormalsHelper",(function(){return hd})),n.d(t,"VideoTexture",(function(){return fc})),n.d(t,"WebGLMultisampleRenderTarget",(function(){return In})),n.d(t,"WebGLRenderTarget",(function(){return Dn})),n.d(t,"WebGLRenderTargetCube",(function(){return sa})),n.d(t,"WebGLRenderer",(function(){return bs})),n.d(t,"WebGLUtils",(function(){return us})),n.d(t,"WireframeGeometry",(function(){return yc})),n.d(t,"WireframeHelper",(function(){return _p})),n.d(t,"WrapAroundEnding",(function(){return Lt})),n.d(t,"XHRLoader",(function(){return Mp})),n.d(t,"ZeroCurvatureEnding",(function(){return St})),n.d(t,"ZeroFactor",(function(){return N})),n.d(t,"ZeroSlopeEnding",(function(){return Tt})),n.d(t,"ZeroStencilOp",(function(){return jt})),n.d(t,"sRGBEncoding",(function(){return It})),void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52)),void 0===Number.isInteger&&(Number.isInteger=function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}),void 0===Math.sign&&(Math.sign=function(e){return e<0?-1:e>0?1:+e}),"name"in Function.prototype==!1&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}}),void 0===Object.assign&&(Object.assign=function(e){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),n=1;n>8&255]+gn[e>>16&255]+gn[e>>24&255]+"-"+gn[255&t]+gn[t>>8&255]+"-"+gn[t>>16&15|64]+gn[t>>24&255]+"-"+gn[63&n|128]+gn[n>>8&255]+"-"+gn[n>>16&255]+gn[n>>24&255]+gn[255&r]+gn[r>>8&255]+gn[r>>16&255]+gn[r>>24&255]).toUpperCase()},clamp:function(e,t,n){return Math.max(t,Math.min(n,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)},lerp:function(e,t,n){return(1-n)*e+n*t},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*An.DEG2RAD},radToDeg:function(e){return e*An.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}};function xn(e,t){this.x=e||0,this.y=t||0}function bn(e,t,n,r){this._x=e||0,this._y=t||0,this._z=n||0,this._w=void 0!==r?r:1}Object.defineProperties(xn.prototype,{width:{get:function(){return this.x},set:function(e){this.x=e}},height:{get:function(){return this.y},set:function(e){this.y=e}}}),Object.assign(xn.prototype,{isVector2:!0,set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},applyMatrix3:function(e){var t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this},clampLength:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},cross:function(e){return this.x*e.y-this.y*e.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var e=Math.atan2(this.y,this.x);return e<0&&(e+=2*Math.PI),e},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,n=this.y-e.y;return t*t+n*n},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromBufferAttribute:function(e,t,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){var n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}}),Object.assign(bn,{slerp:function(e,t,n,r){return n.copy(e).slerp(t,r)},slerpFlat:function(e,t,n,r,i,a,o){var s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],h=i[a+0],d=i[a+1],p=i[a+2],f=i[a+3];if(u!==f||s!==h||c!==d||l!==p){var m=1-o,v=s*h+c*d+l*p+u*f,g=v>=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var A=Math.sqrt(y),x=Math.atan2(A,v*g);m=Math.sin(m*x)/A,o=Math.sin(o*x)/A}var b=o*g;if(s=s*m+h*b,c=c*m+d*b,l=l*m+p*b,u=u*m+f*b,m===1-o){var w=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=w,c*=w,l*=w,u*=w}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}}),Object.defineProperties(bn.prototype,{x:{get:function(){return this._x},set:function(e){this._x=e,this._onChangeCallback()}},y:{get:function(){return this._y},set:function(e){this._y=e,this._onChangeCallback()}},z:{get:function(){return this._z},set:function(e){this._z=e,this._onChangeCallback()}},w:{get:function(){return this._w},set:function(e){this._w=e,this._onChangeCallback()}}}),Object.assign(bn.prototype,{isQuaternion:!0,set:function(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this},setFromEuler:function(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=e._x,r=e._y,i=e._z,a=e.order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),h=s(n/2),d=s(r/2),p=s(i/2);return"XYZ"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u-h*d*p):"YXZ"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u+h*d*p):"ZXY"===a?(this._x=h*l*u-c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u-h*d*p):"ZYX"===a?(this._x=h*l*u-c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u+h*d*p):"YZX"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u-h*d*p):"XZY"===a&&(this._x=h*l*u-c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u+h*d*p),!1!==t&&this._onChangeCallback(),this},setFromAxisAngle:function(e,t){var n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this},setFromRotationMatrix:function(e){var t,n=e.elements,r=n[0],i=n[4],a=n[8],o=n[1],s=n[5],c=n[9],l=n[2],u=n[6],h=n[10],d=r+s+h;return d>0?(t=.5/Math.sqrt(d+1),this._w=.25/t,this._x=(u-c)*t,this._y=(a-l)*t,this._z=(o-i)*t):r>s&&r>h?(t=2*Math.sqrt(1+r-s-h),this._w=(u-c)/t,this._x=.25*t,this._y=(i+o)/t,this._z=(a+l)/t):s>h?(t=2*Math.sqrt(1+s-r-h),this._w=(a-l)/t,this._x=(i+o)/t,this._y=.25*t,this._z=(c+u)/t):(t=2*Math.sqrt(1+h-r-s),this._w=(o-i)/t,this._x=(a+l)/t,this._y=(c+u)/t,this._z=.25*t),this._onChangeCallback(),this},setFromUnitVectors:function(e,t){var n=e.dot(t)+1;return n<1e-6?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()},angleTo:function(e){return 2*Math.acos(Math.abs(An.clamp(this.dot(e),-1,1)))},rotateTowards:function(e,t){var n=this.angleTo(e);if(0===n)return this;var r=Math.min(1,t/n);return this.slerp(e,r),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;var s=1-o*o;if(s<=Number.EPSILON){var c=1-t;return this._w=c*a+t*this._w,this._x=c*n+t*this._x,this._y=c*r+t*this._y,this._z=c*i+t*this._z,this.normalize(),this._onChangeCallback(),this}var l=Math.sqrt(s),u=Math.atan2(l,o),h=Math.sin((1-t)*u)/l,d=Math.sin(t*u)/l;return this._w=a*h+this._w*d,this._x=n*h+this._x*d,this._y=r*h+this._y*d,this._z=i*h+this._z*d,this._onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},_onChange:function(e){return this._onChangeCallback=e,this},_onChangeCallback:function(){}});var wn=new Mn,_n=new bn;function Mn(e,t,n){this.x=e||0,this.y=t||0,this.z=n||0}Object.assign(Mn.prototype,{isVector3:!0,set:function(e,t,n){return this.x=e,this.y=t,this.z=n,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:function(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(_n.setFromEuler(e))},applyAxisAngle:function(e,t){return this.applyQuaternion(_n.setFromAxisAngle(e,t))},applyMatrix3:function(e){var t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this},applyMatrix4:function(e){var t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this},applyQuaternion:function(e){var t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=s*t+a*r-o*n,l=s*n+o*t-i*r,u=s*r+i*n-a*t,h=-i*t-a*n-o*r;return this.x=c*s+h*-i+l*-o-u*-a,this.y=l*s+h*-a+u*-i-c*-o,this.z=u*s+h*-o+c*-a-l*-i,this},project:function(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)},unproject:function(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)},transformDirection:function(e){var t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this},clampLength:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},cross:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)},crossVectors:function(e,t){var n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this},projectOnVector:function(e){var t=e.dot(this)/e.lengthSq();return this.copy(e).multiplyScalar(t)},projectOnPlane:function(e){return wn.copy(this).projectOnVector(e),this.sub(wn)},reflect:function(e){return this.sub(wn.copy(e).multiplyScalar(2*this.dot(e)))},angleTo:function(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());0===t&&console.error("THREE.Vector3: angleTo() can't handle zero length vectors.");var n=this.dot(e)/t;return Math.acos(An.clamp(n,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r},manhattanDistanceTo:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)},setFromSphericalCoords:function(e,t,n){var r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this},setFromCylindrical:function(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)},setFromCylindricalCoords:function(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this},setFromMatrixPosition:function(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this},setFromMatrixColumn:function(e,t){return this.fromArray(e.elements,4*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromBufferAttribute:function(e,t,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}});var En,Sn=new Mn;function Tn(){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.assign(Tn.prototype,{isMatrix3:!0,set:function(e,t,n,r,i,a,o,s,c){var l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this},setFromMatrix4:function(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},applyToBufferAttribute:function(e){for(var t=0,n=e.count;t2048||t.height>2048?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}},Rn=0;function Cn(e,t,n,r,i,a,o,s,c,l){Object.defineProperty(this,"id",{value:Rn++}),this.uuid=An.generateUUID(),this.name="",this.image=void 0!==e?e:Cn.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==t?t:Cn.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:ye,this.wrapT=void 0!==r?r:ye,this.magFilter=void 0!==i?i:Ee,this.minFilter=void 0!==a?a:Le,this.anisotropy=void 0!==c?c:1,this.format=void 0!==o?o:je,this.type=void 0!==s?s:Ce,this.offset=new xn(0,0),this.repeat=new xn(1,1),this.center=new xn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Tn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==l?l:Dt,this.version=0,this.onUpdate=null}function Pn(e,t,n,r){this.x=e||0,this.y=t||0,this.z=n||0,this.w=void 0!==r?r:1}function Dn(e,t,n){this.width=e,this.height=t,this.scissor=new Pn(0,0,e,t),this.scissorTest=!1,this.viewport=new Pn(0,0,e,t),n=n||{},this.texture=new Cn(void 0,void 0,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.image={},this.texture.image.width=e,this.texture.image.height=t,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:Ee,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 In(e,t,n){Dn.call(this,e,t,n),this.samples=4}Cn.DEFAULT_IMAGE=void 0,Cn.DEFAULT_MAPPING=le,Cn.prototype=Object.assign(Object.create(vn.prototype),{constructor:Cn,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.name=e.name,this.image=e.image,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this},toJSON:function(e){var t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];var n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var r=this.image;if(void 0===r.uuid&&(r.uuid=An.generateUUID()),!t&&void 0===e.images[r.uuid]){var i;if(Array.isArray(r)){i=[];for(var a=0,o=r.length;a1)switch(this.wrapS){case ge:e.x=e.x-Math.floor(e.x);break;case ye:e.x=e.x<0?0:1;break;case Ae:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case ge:e.y=e.y-Math.floor(e.y);break;case ye:e.y=e.y<0?0:1;break;case Ae:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}}),Object.defineProperty(Cn.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.defineProperties(Pn.prototype,{width:{get:function(){return this.z},set:function(e){this.z=e}},height:{get:function(){return this.w},set:function(e){this.w=e}}}),Object.assign(Pn.prototype,{isVector4:!0,set:function(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},applyMatrix4:function(e){var t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,n,r,i,a=e.elements,o=a[0],s=a[4],c=a[8],l=a[1],u=a[5],h=a[9],d=a[2],p=a[6],f=a[10];if(Math.abs(s-l)<.01&&Math.abs(c-d)<.01&&Math.abs(h-p)<.01){if(Math.abs(s+l)<.1&&Math.abs(c+d)<.1&&Math.abs(h+p)<.1&&Math.abs(o+u+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;var m=(o+1)/2,v=(u+1)/2,g=(f+1)/2,y=(s+l)/4,A=(c+d)/4,x=(h+p)/4;return m>v&&m>g?m<.01?(n=0,r=.707106781,i=.707106781):(r=y/(n=Math.sqrt(m)),i=A/n):v>g?v<.01?(n=.707106781,r=0,i=.707106781):(n=y/(r=Math.sqrt(v)),i=x/r):g<.01?(n=.707106781,r=.707106781,i=0):(n=A/(i=Math.sqrt(g)),r=x/i),this.set(n,r,i,t),this}var b=Math.sqrt((p-h)*(p-h)+(c-d)*(c-d)+(l-s)*(l-s));return Math.abs(b)<.001&&(b=1),this.x=(p-h)/b,this.y=(c-d)/b,this.z=(l-s)/b,this.w=Math.acos((o+u+f-1)/2),this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this},clampScalar:function(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this},clampLength:function(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(e){return this.normalize().multiplyScalar(e)},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this},lerpVectors:function(e,t,n){return this.subVectors(t,e).multiplyScalar(n).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e},fromBufferAttribute:function(e,t,n){return void 0!==n&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}}),Dn.prototype=Object.assign(Object.create(vn.prototype),{constructor:Dn,isWebGLRenderTarget:!0,setSize:function(e,t){this.width===e&&this.height===t||(this.width=e,this.height=t,this.texture.image.width=e,this.texture.image.height=t,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.width=e.width,this.height=e.height,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.depthTexture=e.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),In.prototype=Object.assign(Object.create(Dn.prototype),{constructor:In,isWebGLMultisampleRenderTarget:!0,copy:function(e){return Dn.prototype.copy.call(this,e),this.samples=e.samples,this}});var On=new Mn,Nn=new Hn,Bn=new Mn(0,0,0),Fn=new Mn(1,1,1),Gn=new Mn,Un=new Mn,zn=new Mn;function Hn(){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.")}Object.assign(Hn.prototype,{isMatrix4:!0,set:function(e,t,n,r,i,a,o,s,c,l,u,h,d,p,f,m){var v=this.elements;return v[0]=e,v[4]=t,v[8]=n,v[12]=r,v[1]=i,v[5]=a,v[9]=o,v[13]=s,v[2]=c,v[6]=l,v[10]=u,v[14]=h,v[3]=d,v[7]=p,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 Hn).fromArray(this.elements)},copy:function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this},copyPosition:function(e){var t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this},extractBasis:function(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this},extractRotation:function(e){var t=this.elements,n=e.elements,r=1/On.setFromMatrixColumn(e,0).length(),i=1/On.setFromMatrixColumn(e,1).length(),a=1/On.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromEuler:function(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if("XYZ"===e.order){var h=a*l,d=a*u,p=o*l,f=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=d+p*c,t[5]=h-f*c,t[9]=-o*s,t[2]=f-h*c,t[6]=p+d*c,t[10]=a*s}else if("YXZ"===e.order){var m=s*l,v=s*u,g=c*l,y=c*u;t[0]=m+y*o,t[4]=g*o-v,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=v*o-g,t[6]=y+m*o,t[10]=a*s}else if("ZXY"===e.order){m=s*l,v=s*u,g=c*l,y=c*u;t[0]=m-y*o,t[4]=-a*u,t[8]=g+v*o,t[1]=v+g*o,t[5]=a*l,t[9]=y-m*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if("ZYX"===e.order){h=a*l,d=a*u,p=o*l,f=o*u;t[0]=s*l,t[4]=p*c-d,t[8]=h*c+f,t[1]=s*u,t[5]=f*c+h,t[9]=d*c-p,t[2]=-c,t[6]=o*s,t[10]=a*s}else if("YZX"===e.order){var A=a*s,x=a*c,b=o*s,w=o*c;t[0]=s*l,t[4]=w-A*u,t[8]=b*u+x,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=x*u+b,t[10]=A-w*u}else if("XZY"===e.order){A=a*s,x=a*c,b=o*s,w=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=A*u+w,t[5]=a*l,t[9]=x*u-b,t[2]=b*u-x,t[6]=o*l,t[10]=w*u+A}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(e){return this.compose(Bn,e,Fn)},lookAt:function(e,t,n){var r=this.elements;return zn.subVectors(e,t),0===zn.lengthSq()&&(zn.z=1),zn.normalize(),Gn.crossVectors(n,zn),0===Gn.lengthSq()&&(1===Math.abs(n.z)?zn.x+=1e-4:zn.z+=1e-4,zn.normalize(),Gn.crossVectors(n,zn)),Gn.normalize(),Un.crossVectors(zn,Gn),r[0]=Gn.x,r[4]=Un.x,r[8]=zn.x,r[1]=Gn.y,r[5]=Un.y,r[9]=zn.y,r[2]=Gn.z,r[6]=Un.z,r[10]=zn.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],v=n[14],g=n[3],y=n[7],A=n[11],x=n[15],b=r[0],w=r[4],_=r[8],M=r[12],E=r[1],S=r[5],T=r[9],L=r[13],R=r[2],C=r[6],P=r[10],D=r[14],I=r[3],O=r[7],N=r[11],B=r[15];return i[0]=a*b+o*E+s*R+c*I,i[4]=a*w+o*S+s*C+c*O,i[8]=a*_+o*T+s*P+c*N,i[12]=a*M+o*L+s*D+c*B,i[1]=l*b+u*E+h*R+d*I,i[5]=l*w+u*S+h*C+d*O,i[9]=l*_+u*T+h*P+d*N,i[13]=l*M+u*L+h*D+d*B,i[2]=p*b+f*E+m*R+v*I,i[6]=p*w+f*S+m*C+v*O,i[10]=p*_+f*T+m*P+v*N,i[14]=p*M+f*L+m*D+v*B,i[3]=g*b+y*E+A*R+x*I,i[7]=g*w+y*S+A*C+x*O,i[11]=g*_+y*T+A*P+x*N,i[15]=g*M+y*L+A*D+x*B,this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},applyToBufferAttribute:function(e){for(var t=0,n=e.count;t1){for(var t=0;t1){for(var t=0;t0){r.children=[];for(s=0;s0&&(n.geometries=h),d.length>0&&(n.materials=d),p.length>0&&(n.textures=p),f.length>0&&(n.images=f),o.length>0&&(n.shapes=o)}return n.object=r,n;function m(e){var t=[];for(var n in e){var r=e[n];delete r.metadata,t.push(r)}return t}},clone:function(e){return(new this.constructor).copy(this,e)},copy:function(e,t){if(void 0===t&&(t=!0),this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(var n=0;ns)return!1}return!0}Object.assign(Ar.prototype,{isBox3:!0,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){for(var t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,c=e.length;si&&(i=l),u>a&&(a=u),h>o&&(o=h)}return this.min.set(t,n,r),this.max.set(i,a,o),this},setFromBufferAttribute:function(e){for(var t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,c=e.count;si&&(i=l),u>a&&(a=u),h>o&&(o=h)}return this.min.set(t,n,r),this.max.set(i,a,o),this},setFromPoints:function(e){this.makeEmpty();for(var t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},getParameter:function(e,t){return void 0===t&&(console.warn("THREE.Box3: .getParameter() target is now required"),t=new Mn),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},intersectsSphere:function(e){return this.clampPoint(e.center,cr),cr.distanceToSquared(e.center)<=e.radius*e.radius},intersectsPlane:function(e){var t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant},intersectsTriangle:function(e){if(this.isEmpty())return!1;this.getCenter(mr),vr.subVectors(this.max,mr),lr.subVectors(e.a,mr),ur.subVectors(e.b,mr),hr.subVectors(e.c,mr),dr.subVectors(ur,lr),pr.subVectors(hr,ur),fr.subVectors(lr,hr);var t=[0,-dr.z,dr.y,0,-pr.z,pr.y,0,-fr.z,fr.y,dr.z,0,-dr.x,pr.z,0,-pr.x,fr.z,0,-fr.x,-dr.y,dr.x,0,-pr.y,pr.x,0,-fr.y,fr.x,0];return!!xr(t,lr,ur,hr,vr)&&(!!xr(t=[1,0,0,0,1,0,0,0,1],lr,ur,hr,vr)&&(gr.crossVectors(dr,pr),xr(t=[gr.x,gr.y,gr.z],lr,ur,hr,vr)))},clampPoint:function(e,t){return void 0===t&&(console.warn("THREE.Box3: .clampPoint() target is now required"),t=new Mn),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){return cr.copy(e).clamp(this.min,this.max).sub(e).length()},getBoundingSphere:function(e){return void 0===e&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(e.center),e.radius=.5*this.getSize(cr).length(),e},intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(e){return this.isEmpty()?this:(sr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),sr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),sr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),sr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),sr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),sr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),sr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),sr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(sr),this)},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}});var br=new Ar;function wr(e,t){this.center=void 0!==e?e:new Mn,this.radius=void 0!==t?t:0}Object.assign(wr.prototype,{set:function(e,t){return this.center.copy(e),this.radius=t,this},setFromPoints:function(e,t){var n=this.center;void 0!==t?n.copy(t):br.setFromPoints(e).getCenter(n);for(var r=0,i=0,a=e.length;ithis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t},getBoundingBox:function(e){return void 0===e&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),e=new Ar),e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}});var _r=new Mn,Mr=new Mn,Er=new Mn,Sr=new Mn,Tr=new Mn,Lr=new Mn,Rr=new Mn;function Cr(e,t){this.origin=void 0!==e?e:new Mn,this.direction=void 0!==t?t:new Mn}Object.assign(Cr.prototype,{set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){return void 0===t&&(console.warn("THREE.Ray: .at() target is now required"),t=new Mn),t.copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(e){return this.origin.copy(this.at(e,_r)),this},closestPointToPoint:function(e,t){void 0===t&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),t=new Mn),t.subVectors(e,this.origin);var n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(e){var t=_r.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(_r.copy(this.direction).multiplyScalar(t).add(this.origin),_r.distanceToSquared(e))},distanceSqToSegment:function(e,t,n,r){Mr.copy(e).add(t).multiplyScalar(.5),Er.copy(t).sub(e).normalize(),Sr.copy(this.origin).sub(Mr);var i,a,o,s,c=.5*e.distanceTo(t),l=-this.direction.dot(Er),u=Sr.dot(this.direction),h=-Sr.dot(Er),d=Sr.lengthSq(),p=Math.abs(1-l*l);if(p>0)if(a=l*u-h,s=c*p,(i=l*h-u)>=0)if(a>=-s)if(a<=s){var f=1/p;o=(i*=f)*(i+l*(a*=f)+2*u)+a*(l*i+a+2*h)+d}else a=c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;else a=-c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;else a<=-s?o=-(i=Math.max(0,-(-l*c+u)))*i+(a=i>0?-c:Math.min(Math.max(-c,-h),c))*(a+2*h)+d:a<=s?(i=0,o=(a=Math.min(Math.max(-c,-h),c))*(a+2*h)+d):o=-(i=Math.max(0,-(l*c+u)))*i+(a=i>0?c:Math.min(Math.max(-c,-h),c))*(a+2*h)+d;else a=l>0?-c:c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;return n&&n.copy(this.direction).multiplyScalar(i).add(this.origin),r&&r.copy(Er).multiplyScalar(a).add(Mr),o},intersectSphere:function(e,t){_r.subVectors(e.center,this.origin);var n=_r.dot(this.direction),r=_r.dot(_r)-n*n,i=e.radius*e.radius;if(r>i)return null;var a=Math.sqrt(i-r),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,t):this.at(o,t)},intersectsSphere:function(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null},intersectPlane:function(e,t){var n=this.distanceToPlane(e);return null===n?null:this.at(n,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0},intersectBox:function(e,t){var n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,h=this.origin;return c>=0?(n=(e.min.x-h.x)*c,r=(e.max.x-h.x)*c):(n=(e.max.x-h.x)*c,r=(e.min.x-h.x)*c),l>=0?(i=(e.min.y-h.y)*l,a=(e.max.y-h.y)*l):(i=(e.max.y-h.y)*l,a=(e.min.y-h.y)*l),n>a||i>r?null:((i>n||n!=n)&&(n=i),(a=0?(o=(e.min.z-h.z)*u,s=(e.max.z-h.z)*u):(o=(e.max.z-h.z)*u,s=(e.min.z-h.z)*u),n>s||o>r?null:((o>n||n!=n)&&(n=o),(s=0?n:r,t)))},intersectsBox:function(e){return null!==this.intersectBox(e,_r)},intersectTriangle:function(e,t,n,r,i){Tr.subVectors(t,e),Lr.subVectors(n,e),Rr.crossVectors(Tr,Lr);var a,o=this.direction.dot(Rr);if(o>0){if(r)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Sr.subVectors(this.origin,e);var s=a*this.direction.dot(Lr.crossVectors(Sr,Lr));if(s<0)return null;var c=a*this.direction.dot(Tr.cross(Sr));if(c<0)return null;if(s+c>o)return null;var l=-a*Sr.dot(Rr);return l<0?null:this.at(l/o,i)},applyMatrix4:function(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}});var Pr=new Mn,Dr=new Mn,Ir=new Tn;function Or(e,t){this.normal=void 0!==e?e:new Mn(1,0,0),this.constant=void 0!==t?t:0}Object.assign(Or.prototype,{isPlane:!0,set:function(e,t){return this.normal.copy(e),this.constant=t,this},setComponents:function(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this},setFromNormalAndCoplanarPoint:function(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this},setFromCoplanarPoints:function(e,t,n){var r=Pr.subVectors(n,t).cross(Dr.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.normal.copy(e.normal),this.constant=e.constant,this},normalize:function(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(e){return this.normal.dot(e)+this.constant},distanceToSphere:function(e){return this.distanceToPoint(e.center)-e.radius},projectPoint:function(e,t){return void 0===t&&(console.warn("THREE.Plane: .projectPoint() target is now required"),t=new Mn),t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)},intersectLine:function(e,t){void 0===t&&(console.warn("THREE.Plane: .intersectLine() target is now required"),t=new Mn);var n=e.delta(Pr),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(e.start)?t.copy(e.start):void 0;var i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?void 0:t.copy(n).multiplyScalar(i).add(e.start)},intersectsLine:function(e){var t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return void 0===e&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),e=new Mn),e.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(e,t){var n=t||Ir.getNormalMatrix(e),r=this.coplanarPoint(Pr).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this},translate:function(e){return this.constant-=e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}});var Nr=new Mn,Br=new Mn,Fr=new Mn,Gr=new Mn,Ur=new Mn,zr=new Mn,Hr=new Mn,Vr=new Mn,kr=new Mn,jr=new Mn;function Wr(e,t,n){this.a=void 0!==e?e:new Mn,this.b=void 0!==t?t:new Mn,this.c=void 0!==n?n:new Mn}Object.assign(Wr,{getNormal:function(e,t,n,r){void 0===r&&(console.warn("THREE.Triangle: .getNormal() target is now required"),r=new Mn),r.subVectors(n,t),Nr.subVectors(e,t),r.cross(Nr);var i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)},getBarycoord:function(e,t,n,r,i){Nr.subVectors(r,t),Br.subVectors(n,t),Fr.subVectors(e,t);var a=Nr.dot(Nr),o=Nr.dot(Br),s=Nr.dot(Fr),c=Br.dot(Br),l=Br.dot(Fr),u=a*c-o*o;if(void 0===i&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),i=new Mn),0===u)return i.set(-2,-1,-1);var h=1/u,d=(c*s-o*l)*h,p=(a*l-o*s)*h;return i.set(1-d-p,p,d)},containsPoint:function(e,t,n,r){return Wr.getBarycoord(e,t,n,r,Gr),Gr.x>=0&&Gr.y>=0&&Gr.x+Gr.y<=1},getUV:function(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Gr),s.set(0,0),s.addScaledVector(i,Gr.x),s.addScaledVector(a,Gr.y),s.addScaledVector(o,Gr.z),s},isFrontFacing:function(e,t,n,r){return Nr.subVectors(n,t),Br.subVectors(e,t),Nr.cross(Br).dot(r)<0}}),Object.assign(Wr.prototype,{set:function(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this},setFromPointsAndIndices:function(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},getArea:function(){return Nr.subVectors(this.c,this.b),Br.subVectors(this.a,this.b),.5*Nr.cross(Br).length()},getMidpoint:function(e){return void 0===e&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),e=new Mn),e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(e){return Wr.getNormal(this.a,this.b,this.c,e)},getPlane:function(e){return void 0===e&&(console.warn("THREE.Triangle: .getPlane() target is now required"),e=new Or),e.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(e,t){return Wr.getBarycoord(e,this.a,this.b,this.c,t)},getUV:function(e,t,n,r,i){return Wr.getUV(e,this.a,this.b,this.c,t,n,r,i)},containsPoint:function(e){return Wr.containsPoint(e,this.a,this.b,this.c)},isFrontFacing:function(e){return Wr.isFrontFacing(this.a,this.b,this.c,e)},intersectsBox:function(e){return e.intersectsTriangle(this)},closestPointToPoint:function(e,t){void 0===t&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),t=new Mn);var n,r,i=this.a,a=this.b,o=this.c;Ur.subVectors(a,i),zr.subVectors(o,i),Vr.subVectors(e,i);var s=Ur.dot(Vr),c=zr.dot(Vr);if(s<=0&&c<=0)return t.copy(i);kr.subVectors(e,a);var l=Ur.dot(kr),u=zr.dot(kr);if(l>=0&&u<=l)return t.copy(a);var h=s*u-l*c;if(h<=0&&s>=0&&l<=0)return n=s/(s-l),t.copy(i).addScaledVector(Ur,n);jr.subVectors(e,o);var d=Ur.dot(jr),p=zr.dot(jr);if(p>=0&&d<=p)return t.copy(o);var f=d*c-s*p;if(f<=0&&c>=0&&p<=0)return r=c/(c-p),t.copy(i).addScaledVector(zr,r);var m=l*p-d*u;if(m<=0&&u-l>=0&&d-p>=0)return Hr.subVectors(o,a),r=(u-l)/(u-l+(d-p)),t.copy(a).addScaledVector(Hr,r);var v=1/(m+f+h);return n=f*v,r=h*v,t.copy(i).addScaledVector(Ur,n).addScaledVector(zr,r)},equals:function(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}});var Xr={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},qr={h:0,s:0,l:0},Qr={h:0,s:0,l:0};function Yr(e,t,n){return void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}function Zr(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}function Jr(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Kr(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}function $r(e,t,n,r,i,a){this.a=e,this.b=t,this.c=n,this.normal=r&&r.isVector3?r:new Mn,this.vertexNormals=Array.isArray(r)?r:[],this.color=i&&i.isColor?i:new Yr,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=void 0!==a?a:0}Object.assign(Yr.prototype,{isColor:!0,r:1,g:1,b:1,set:function(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this},setScalar:function(e){return this.r=e,this.g=e,this.b=e,this},setHex:function(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,n){return this.r=e,this.g=t,this.b=n,this},setHSL:function(e,t,n){if(e=An.euclideanModulo(e,1),t=An.clamp(t,0,1),n=An.clamp(n,0,1),0===t)this.r=this.g=this.b=n;else{var r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Zr(i,r,e+1/3),this.g=Zr(i,r,e),this.b=Zr(i,r,e-1/3)}return this},setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var n;if(n=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var r,i=n[1],a=n[2];switch(i){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,t(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,t(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return t(r[5]),this.setHSL(o,s,c)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(e)){var l=n[1],u=l.length;if(3===u)return this.r=parseInt(l.charAt(0)+l.charAt(0),16)/255,this.g=parseInt(l.charAt(1)+l.charAt(1),16)/255,this.b=parseInt(l.charAt(2)+l.charAt(2),16)/255,this;if(6===u)return this.r=parseInt(l.charAt(0)+l.charAt(1),16)/255,this.g=parseInt(l.charAt(2)+l.charAt(3),16)/255,this.b=parseInt(l.charAt(4)+l.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this},setColorName:function(e){var t=Xr[e];return void 0!==t?this.setHex(t):console.warn("THREE.Color: Unknown color "+e),this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);var n=t>0?1/t:1;return this.r=Math.pow(e.r,n),this.g=Math.pow(e.g,n),this.b=Math.pow(e.b,n),this},convertGammaToLinear:function(e){return this.copyGammaToLinear(this,e),this},convertLinearToGamma:function(e){return this.copyLinearToGamma(this,e),this},copySRGBToLinear:function(e){return this.r=Jr(e.r),this.g=Jr(e.g),this.b=Jr(e.b),this},copyLinearToSRGB:function(e){return this.r=Kr(e.r),this.g=Kr(e.g),this.b=Kr(e.b),this},convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){void 0===e&&(console.warn("THREE.Color: .getHSL() target is now required"),e={h:0,s:0,l:0});var t,n,r=this.r,i=this.g,a=this.b,o=Math.max(r,i,a),s=Math.min(r,i,a),c=(s+o)/2;if(s===o)t=0,n=0;else{var l=o-s;switch(n=c<=.5?l/(o+s):l/(2-o-s),o){case r:t=(i-a)/l+(it&&(t=e[n]);return t}ti.prototype=Object.assign(Object.create(vn.prototype),{constructor:ti,isMaterial:!0,onBeforeCompile:function(){},setValues:function(e){if(void 0!==e)for(var t in e){var n=e[t];if(void 0!==n)if("shading"!==t){var r=this[t];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n:console.warn("THREE."+this.type+": '"+t+"' 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: '"+t+"' parameter is undefined.")}},toJSON:function(e){var t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});var n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function r(e){var t=[];for(var n in e){var r=e[n];delete r.metadata,t.push(r)}return t}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.sheen&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&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.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,n.reflectivity=this.reflectivity,n.refractionRatio=this.refractionRatio,void 0!==this.combine&&(n.combine=this.combine),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity)),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.size&&(n.size=this.size),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==E&&(n.blending=this.blending),!0===this.flatShading&&(n.flatShading=this.flatShading),this.side!==v&&(n.side=this.side),this.vertexColors!==b&&(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,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&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.morphNormals&&(n.morphNormals=!0),!0===this.skinning&&(n.skinning=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t){var i=r(e.textures),a=r(e.images);i.length>0&&(n.textures=i),a.length>0&&(n.images=a)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.flatShading=e.flatShading,this.vertexTangents=e.vertexTangents,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;var t=e.clippingPlanes,n=null;if(null!==t){var r=t.length;n=new Array(r);for(var i=0;i!==r;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),ni.prototype=Object.create(ti.prototype),ni.prototype.constructor=ni,ni.prototype.isMeshBasicMaterial=!0,ni.prototype.copy=function(e){return ti.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this},Object.defineProperty(ri.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(ri.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this},copyAt:function(e,t,n){e*=this.itemSize,n*=t.itemSize;for(var r=0,i=this.itemSize;r0,o=i[1]&&i[1].length>0,s=e.morphTargets,c=s.length;if(c>0){t=[];for(var l=0;l0){u=[];for(l=0;l0&&0===n.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(l=0;l65535?ui:ci)(e,1):this.index=e},getAttribute:function(e){return this.attributes[e]},setAttribute:function(e,t){return this.attributes[e]=t,this},deleteAttribute:function(e){return delete this.attributes[e],this},addGroup:function(e,t,n){this.groups.push({start:e,count:t,materialIndex:void 0!==n?n:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(e,t){this.drawRange.start=e,this.drawRange.count=t},applyMatrix:function(e){var t=this.attributes.position;void 0!==t&&(e.applyToBufferAttribute(t),t.needsUpdate=!0);var n=this.attributes.normal;void 0!==n&&((new Tn).getNormalMatrix(e).applyToBufferAttribute(n),n.needsUpdate=!0);var r=this.attributes.tangent;void 0!==r&&((new Tn).getNormalMatrix(e).applyToBufferAttribute(r),r.needsUpdate=!0);return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(e){return vi.makeRotationX(e),this.applyMatrix(vi),this},rotateY:function(e){return vi.makeRotationY(e),this.applyMatrix(vi),this},rotateZ:function(e){return vi.makeRotationZ(e),this.applyMatrix(vi),this},translate:function(e,t,n){return vi.makeTranslation(e,t,n),this.applyMatrix(vi),this},scale:function(e,t,n){return vi.makeScale(e,t,n),this.applyMatrix(vi),this},lookAt:function(e){return gi.lookAt(e),gi.updateMatrix(),this.applyMatrix(gi.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(yi).negate(),this.translate(yi.x,yi.y,yi.z),this},setFromObject:function(e){var t=e.geometry;if(e.isPoints||e.isLine){var n=new hi(3*t.vertices.length,3),r=new hi(3*t.colors.length,3);if(this.setAttribute("position",n.copyVector3sArray(t.vertices)),this.setAttribute("color",r.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){var i=new hi(t.lineDistances.length,1);this.setAttribute("lineDistance",i.copyArray(t.lineDistances))}null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone())}else e.isMesh&&t&&t.isGeometry&&this.fromGeometry(t);return this},setFromPoints:function(e){for(var t=[],n=0,r=e.length;n0){var n=new Float32Array(3*e.normals.length);this.setAttribute("normal",new ri(n,3).copyVector3sArray(e.normals))}if(e.colors.length>0){var r=new Float32Array(3*e.colors.length);this.setAttribute("color",new ri(r,3).copyColorsArray(e.colors))}if(e.uvs.length>0){var i=new Float32Array(2*e.uvs.length);this.setAttribute("uv",new ri(i,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){var a=new Float32Array(2*e.uvs2.length);this.setAttribute("uv2",new ri(a,2).copyVector2sArray(e.uvs2))}for(var o in this.groups=e.groups,e.morphTargets){for(var s=[],c=e.morphTargets[o],l=0,u=c.length;l0){var p=new hi(4*e.skinIndices.length,4);this.setAttribute("skinIndex",p.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){var f=new hi(4*e.skinWeights.length,4);this.setAttribute("skinWeight",f.copyVector4sArray(e.skinWeights))}return null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new Ar);var e=this.attributes.position,t=this.morphAttributes.position;if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(var n=0,r=t.length;n0&&(e.userData=this.userData),void 0!==this.parameters){var t=this.parameters;for(var n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};var r=this.index;null!==r&&(e.data.index={type:r.array.constructor.name,array:Array.prototype.slice.call(r.array)});var i=this.attributes;for(var n in i){var a=(d=i[n]).toJSON();""!==d.name&&(a.name=d.name),e.data.attributes[n]=a}var o={},s=!1;for(var n in this.morphAttributes){for(var c=this.morphAttributes[n],l=[],u=0,h=c.length;u0&&(o[n]=l,s=!0)}s&&(e.data.morphAttributes=o);var p=this.groups;p.length>0&&(e.data.groups=JSON.parse(JSON.stringify(p)));var f=this.boundingSphere;return null!==f&&(e.data.boundingSphere={center:f.center.toArray(),radius:f.radius}),e},clone:function(){return(new wi).copy(this)},copy:function(e){var t,n,r;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var i=e.index;null!==i&&this.setIndex(i.clone());var a=e.attributes;for(t in a){var o=a[t];this.setAttribute(t,o.clone())}var s=e.morphAttributes;for(t in s){var c=[],l=s[t];for(n=0,r=l.length;nn.far?null:{distance:c,point:Ui.clone(),object:e}}function Vi(e,t,n,r,i,a,o,s,c,l,u){Si.fromBufferAttribute(i,c),Ti.fromBufferAttribute(i,l),Li.fromBufferAttribute(i,u);var h=e.morphTargetInfluences;if(t.morphTargets&&a&&h){Di.set(0,0,0),Ii.set(0,0,0),Oi.set(0,0,0);for(var d=0,p=a.length;d0){var o=i[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=o.length;e0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(e,t){var n,r=this.geometry,i=this.material,a=this.matrixWorld;if(void 0!==i&&(null===r.boundingSphere&&r.computeBoundingSphere(),Ei.copy(r.boundingSphere),Ei.applyMatrix4(a),!1!==e.ray.intersectsSphere(Ei)&&(_i.getInverse(a),Mi.copy(e.ray).applyMatrix4(_i),null===r.boundingBox||!1!==Mi.intersectsBox(r.boundingBox))))if(this.drawMode===Rt){if(r.isBufferGeometry){var o,s,c,l,u,h,d,p,f,m=r.index,v=r.attributes.position,g=r.morphAttributes.position,y=r.attributes.uv,A=r.attributes.uv2,x=r.groups,b=r.drawRange;if(null!==m)if(Array.isArray(i))for(l=0,h=x.length;l0&&(E=R);for(var C=0,P=L.length;C0)for(l=0;l0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var e,t,n;for(this.computeFaceNormals(),e=0,t=this.faces.length;e0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var e,t,n,r,i;for(n=0,r=this.faces.length;n=0;n--){var f=d[n];for(this.faces.splice(f,1),o=0,s=this.faceVertexUvs.length;o0,v=p.vertexNormals.length>0,g=1!==p.color.r||1!==p.color.g||1!==p.color.b,y=p.vertexColors.length>0,A=0;if(A=_(A,0,0),A=_(A,1,!0),A=_(A,2,!1),A=_(A,3,f),A=_(A,4,m),A=_(A,5,v),A=_(A,6,g),A=_(A,7,y),o.push(A),o.push(p.a,p.b,p.c),o.push(p.materialIndex),f){var x=this.faceVertexUvs[0][i];o.push(S(x[0]),S(x[1]),S(x[2]))}if(m&&o.push(M(p.normal)),v){var b=p.vertexNormals;o.push(M(b[0]),M(b[1]),M(b[2]))}if(g&&o.push(E(p.color)),y){var w=p.vertexColors;o.push(E(w[0]),E(w[1]),E(w[2]))}}function _(e,t,n){return n?e|1<0&&(e.data.colors=l),h.length>0&&(e.data.uvs=[h]),e.data.faces=o,e},clone:function(){return(new qi).copy(this)},copy:function(e){var t,n,r,i,a,o;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;var s=e.vertices;for(t=0,n=s.length;t0?1:-1,l.push(R.x,R.y,R.z),u.push(y/m),u.push(1-A/v),T+=1}}for(A=0;A0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;var i={};for(var a in this.extensions)!0===this.extensions[a]&&(i[a]=!0);return Object.keys(i).length>0&&(t.extensions=i),t},na.prototype=Object.assign(Object.create(ar.prototype),{constructor:na,isCamera:!0,copy:function(e,t){return ar.prototype.copy.call(this,e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this},getWorldDirection:function(e){void 0===e&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),e=new Mn),this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()},updateMatrixWorld:function(e){ar.prototype.updateMatrixWorld.call(this,e),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),ra.prototype=Object.assign(Object.create(na.prototype),{constructor:ra,isPerspectiveCamera:!0,copy:function(e,t){return na.prototype.copy.call(this,e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this},setFocalLength:function(e){var t=.5*this.getFilmHeight()/e;this.fov=2*An.RAD2DEG*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){var e=Math.tan(.5*An.DEG2RAD*this.fov);return.5*this.getFilmHeight()/e},getEffectiveFOV:function(){return 2*An.RAD2DEG*Math.atan(Math.tan(.5*An.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(e,t,n,r,i,a){this.aspect=e/t,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=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var e=this.near,t=e*Math.tan(.5*An.DEG2RAD*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(null!==this.view&&this.view.enabled){var o=a.fullWidth,s=a.fullHeight;i+=a.offsetX*r/o,t-=a.offsetY*n/s,r*=a.width/o,n*=a.height/s}var c=this.filmOffset;0!==c&&(i+=e*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(e){var t=ar.prototype.toJSON.call(this,e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}});var ia=90,aa=1;function oa(e,t,n,r){ar.call(this),this.type="CubeCamera";var i=new ra(ia,aa,e,t);i.up.set(0,-1,0),i.lookAt(new Mn(1,0,0)),this.add(i);var a=new ra(ia,aa,e,t);a.up.set(0,-1,0),a.lookAt(new Mn(-1,0,0)),this.add(a);var o=new ra(ia,aa,e,t);o.up.set(0,0,1),o.lookAt(new Mn(0,1,0)),this.add(o);var s=new ra(ia,aa,e,t);s.up.set(0,0,-1),s.lookAt(new Mn(0,-1,0)),this.add(s);var c=new ra(ia,aa,e,t);c.up.set(0,-1,0),c.lookAt(new Mn(0,0,1)),this.add(c);var l=new ra(ia,aa,e,t);l.up.set(0,-1,0),l.lookAt(new Mn(0,0,-1)),this.add(l),r=r||{format:ke,magFilter:Ee,minFilter:Ee},this.renderTarget=new sa(n,n,r),this.renderTarget.texture.name="CubeCamera",this.update=function(e,t){null===this.parent&&this.updateMatrixWorld();var n=e.getRenderTarget(),r=this.renderTarget,u=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0),e.render(t,i),e.setRenderTarget(r,1),e.render(t,a),e.setRenderTarget(r,2),e.render(t,o),e.setRenderTarget(r,3),e.render(t,s),e.setRenderTarget(r,4),e.render(t,c),r.texture.generateMipmaps=u,e.setRenderTarget(r,5),e.render(t,l),e.setRenderTarget(n)},this.clear=function(e,t,n,r){for(var i=e.getRenderTarget(),a=this.renderTarget,o=0;o<6;o++)e.setRenderTarget(a,o),e.clear(t,n,r);e.setRenderTarget(i)}}function sa(e,t,n){Dn.call(this,e,t,n)}function ca(e,t,n,r,i,a,o,s,c,l,u,h){Cn.call(this,null,a,o,s,c,l,r,i,u,h),this.image={data:e||null,width:t||1,height:n||1},this.magFilter=void 0!==c?c:xe,this.minFilter=void 0!==l?l:xe,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}oa.prototype=Object.create(ar.prototype),oa.prototype.constructor=oa,sa.prototype=Object.create(Dn.prototype),sa.prototype.constructor=sa,sa.prototype.isWebGLRenderTargetCube=!0,sa.prototype.fromEquirectangularTexture=function(e,t){this.texture.type=t.type,this.texture.format=t.format,this.texture.encoding=t.encoding;var n=new or,r={uniforms:{tEquirect:{value:null}},vertexShader:["varying vec3 vWorldDirection;","vec3 transformDirection( in vec3 dir, in mat4 matrix ) {","\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );","}","void main() {","\tvWorldDirection = transformDirection( position, modelMatrix );","\t#include ","\t#include ","}"].join("\n"),fragmentShader:["uniform sampler2D tEquirect;","varying vec3 vWorldDirection;","#define RECIPROCAL_PI 0.31830988618","#define RECIPROCAL_PI2 0.15915494","void main() {","\tvec3 direction = normalize( vWorldDirection );","\tvec2 sampleUV;","\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;","\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;","\tgl_FragColor = texture2D( tEquirect, sampleUV );","}"].join("\n")},i=new ta({type:"CubemapFromEquirect",uniforms:Zi(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:g,blending:M});i.uniforms.tEquirect.value=t;var a=new zi(new Yi(5,5,5),i);n.add(a);var o=new oa(1,10,1);return o.renderTarget=this,o.renderTarget.texture.name="CubeCameraTexture",o.update(e,n),a.geometry.dispose(),a.material.dispose(),this},ca.prototype=Object.create(Cn.prototype),ca.prototype.constructor=ca,ca.prototype.isDataTexture=!0;var la=new wr,ua=new Mn;function ha(e,t,n,r,i,a){this.planes=[void 0!==e?e:new Or,void 0!==t?t:new Or,void 0!==n?n:new Or,void 0!==r?r:new Or,void 0!==i?i:new Or,void 0!==a?a:new Or]}Object.assign(ha.prototype,{set:function(e,t,n,r,i,a){var o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){for(var t=this.planes,n=0;n<6;n++)t[n].copy(e.planes[n]);return this},setFromMatrix:function(e){var t=this.planes,n=e.elements,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7],h=n[8],d=n[9],p=n[10],f=n[11],m=n[12],v=n[13],g=n[14],y=n[15];return t[0].setComponents(o-r,u-s,f-h,y-m).normalize(),t[1].setComponents(o+r,u+s,f+h,y+m).normalize(),t[2].setComponents(o+i,u+c,f+d,y+v).normalize(),t[3].setComponents(o-i,u-c,f-d,y-v).normalize(),t[4].setComponents(o-a,u-l,f-p,y-g).normalize(),t[5].setComponents(o+a,u+l,f+p,y+g).normalize(),this},intersectsObject:function(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),la.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(la)},intersectsSprite:function(e){return la.center.set(0,0,0),la.radius=.7071067811865476,la.applyMatrix4(e.matrixWorld),this.intersectsSphere(la)},intersectsSphere:function(e){for(var t=this.planes,n=e.center,r=-e.radius,i=0;i<6;i++){if(t[i].distanceToPoint(n)0?e.max.x:e.min.x,ua.y=r.normal.y>0?e.max.y:e.min.y,ua.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(ua)<0)return!1}return!0},containsPoint:function(e){for(var t=this.planes,n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}});var da={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",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",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",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#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\ttransformedNormal = mat3( instanceMatrix ) * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = normalMatrix * objectTangent;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_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",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, roughness );\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",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) { \n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",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",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",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif",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 = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\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\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\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",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",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)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = saturate( clearcoat );\tmaterial.clearcoatRoughness = clamp( clearcoatRoughness, 0.04, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 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#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? 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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? 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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? 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 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",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",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",normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, normalScale, normalMap );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec2 normalScale, in sampler2D normalMap ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy *= normalScale;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tbool frontFacing = dot( cross( S, T ), N ) > 0.0;\n\t\t\tmapN.xy *= ( float( frontFacing ) * 2.0 - 1.0 );\n\t\t#else\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, clearcoatNormal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = clearcoatNormalScale * mapN.xy;\n\t\tclearcoatNormal = normalize( vTBN * mapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatNormalScale, clearcoatNormalMap );\n\t#endif\n#endif",clearcoat_normalmap_pars_fragment:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 encodeHalfRGBA ( vec2 v ) {\n\tvec4 encoded = vec4( 0.0 );\n\tconst vec2 offset = vec2( 1.0 / 255.0, 0.0 );\n\tencoded.xy = vec2( v.x, fract( v.x * 255.0 ) );\n\tencoded.xy = encoded.xy - ( encoded.yy * offset );\n\tencoded.zw = vec2( v.y, fract( v.y * 255.0 ) );\n\tencoded.zw = encoded.zw - ( encoded.ww * offset );\n\treturn encoded;\n}\nvec2 decodeHalfRGBA( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn decodeHalfRGBA( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat 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 ) + 0.5 ) * texelSize;\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\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat 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#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? 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}",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 highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",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",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",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\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\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 = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}",shadow_vert:"#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"},pa={common:{diffuse:{value:new Yr(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Tn},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},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 xn(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 Yr(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{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 Yr(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Tn}},sprite:{diffuse:{value:new Yr(15658734)},opacity:{value:1},center:{value:new xn(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Tn}}},fa={basic:{uniforms:Ji([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.fog]),vertexShader:da.meshbasic_vert,fragmentShader:da.meshbasic_frag},lambert:{uniforms:Ji([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.fog,pa.lights,{emissive:{value:new Yr(0)}}]),vertexShader:da.meshlambert_vert,fragmentShader:da.meshlambert_frag},phong:{uniforms:Ji([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.gradientmap,pa.fog,pa.lights,{emissive:{value:new Yr(0)},specular:{value:new Yr(1118481)},shininess:{value:30}}]),vertexShader:da.meshphong_vert,fragmentShader:da.meshphong_frag},standard:{uniforms:Ji([pa.common,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.roughnessmap,pa.metalnessmap,pa.fog,pa.lights,{emissive:{value:new Yr(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:da.meshphysical_vert,fragmentShader:da.meshphysical_frag},matcap:{uniforms:Ji([pa.common,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.fog,{matcap:{value:null}}]),vertexShader:da.meshmatcap_vert,fragmentShader:da.meshmatcap_frag},points:{uniforms:Ji([pa.points,pa.fog]),vertexShader:da.points_vert,fragmentShader:da.points_frag},dashed:{uniforms:Ji([pa.common,pa.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:da.linedashed_vert,fragmentShader:da.linedashed_frag},depth:{uniforms:Ji([pa.common,pa.displacementmap]),vertexShader:da.depth_vert,fragmentShader:da.depth_frag},normal:{uniforms:Ji([pa.common,pa.bumpmap,pa.normalmap,pa.displacementmap,{opacity:{value:1}}]),vertexShader:da.normal_vert,fragmentShader:da.normal_frag},sprite:{uniforms:Ji([pa.sprite,pa.fog]),vertexShader:da.sprite_vert,fragmentShader:da.sprite_frag},background:{uniforms:{uvTransform:{value:new Tn},t2D:{value:null}},vertexShader:da.background_vert,fragmentShader:da.background_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:da.cube_vert,fragmentShader:da.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:da.equirect_vert,fragmentShader:da.equirect_frag},distanceRGBA:{uniforms:Ji([pa.common,pa.displacementmap,{referencePosition:{value:new Mn},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:da.distanceRGBA_vert,fragmentShader:da.distanceRGBA_frag},shadow:{uniforms:Ji([pa.lights,pa.fog,{color:{value:new Yr(0)},opacity:{value:1}}]),vertexShader:da.shadow_vert,fragmentShader:da.shadow_frag}};function ma(){var e=null,t=!1,n=null;function r(i,a){!1!==t&&(n(i,a),e.requestAnimationFrame(r))}return{start:function(){!0!==t&&null!==n&&(e.requestAnimationFrame(r),t=!0)},stop:function(){t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function va(e){var t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);var r=t.get(n);r&&(e.deleteBuffer(r.buffer),t.delete(n))},update:function(n,r){n.isInterleavedBufferAttribute&&(n=n.data);var i=t.get(n);void 0===i?t.set(n,function(t,n){var r=t.array,i=t.usage,a=e.createBuffer();e.bindBuffer(n,a),e.bufferData(n,r,i),t.onUploadCallback();var o=5126;return r instanceof Float32Array?o=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?o=5123:r instanceof Int16Array?o=5122:r instanceof Uint32Array?o=5125:r instanceof Int32Array?o=5124:r instanceof Int8Array?o=5120:r instanceof Uint8Array&&(o=5121),{buffer:a,type:o,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version}}(n,r)):i.version0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}var a="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext,o=void 0!==n.precision?n.precision:"highp",s=i(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);var c=!0===n.logarithmicDepthBuffer,l=e.getParameter(34930),u=e.getParameter(35660),h=e.getParameter(3379),d=e.getParameter(34076),p=e.getParameter(34921),f=e.getParameter(36347),m=e.getParameter(36348),v=e.getParameter(36349),g=u>0,y=a||!!t.get("OES_texture_float");return{isWebGL2:a,getMaxAnisotropy:function(){if(void 0!==r)return r;var n=t.get("EXT_texture_filter_anisotropic");return r=null!==n?e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:c,maxTextures:l,maxVertexTextures:u,maxTextureSize:h,maxCubemapSize:d,maxAttributes:p,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:v,vertexTextures:g,floatFragmentTextures:y,floatVertexTextures:g&&y,maxSamples:a?e.getParameter(36183):0}}function wa(){var e=this,t=null,n=0,r=!1,i=!1,a=new Or,o=new Tn,s={value:null,needsUpdate:!1};function c(){s.value!==t&&(s.value=t,s.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function l(t,n,r,i){var c=null!==t?t.length:0,l=null;if(0!==c){if(l=s.value,!0!==i||null===l){var u=r+4*c,h=n.matrixWorldInverse;o.getNormalMatrix(h),(null===l||l.length65535?ui:ci)(n,1);p.version=o,t.update(p,34963);var f=i.get(e);f&&t.remove(f),i.set(e,p)}return{get:function(e,t){var i=r.get(t);return i||(t.addEventListener("dispose",a),t.isBufferGeometry?i=t:t.isGeometry&&(void 0===t._bufferGeometry&&(t._bufferGeometry=(new wi).setFromObject(e)),i=t._bufferGeometry),r.set(t,i),n.memory.geometries++,i)},update:function(e){var n=e.index,r=e.attributes;for(var i in null!==n&&t.update(n,34963),r)t.update(r[i],34962);var a=e.morphAttributes;for(var i in a)for(var o=a[i],s=0,c=o.length;s0)return e;var i=t*n,a=Fa[i];if(void 0===a&&(a=new Float32Array(i),Fa[i]=a),0!==t){r.toArray(a,0);for(var o=1,s=0;o!==t;++o)s+=n,e[o].toArray(a,s)}return a}function ka(e,t){if(e.length!==t.length)return!1;for(var n=0,r=e.length;n/gm;function Go(e){return e.replace(Fo,Uo)}function Uo(e,t){var n=da[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return Go(n)}var zo=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;function Ho(e){return e.replace(zo,Vo)}function Vo(e,t,n,r){for(var i="",a=parseInt(t);a0?e.gammaFactor:1,_=a.isWebGL2?"":function(e,t,n){return[(e=e||{}).derivatives||t.envMapCubeUV||t.bumpMap||t.tangentSpaceNormalMap||t.clearcoatNormalMap||t.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(e.fragDepth||t.logarithmicDepthBuffer)&&n.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",e.drawBuffers&&n.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(e.shaderTextureLOD||t.envMap)&&n.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Oo).join("\n")}(r.extensions,a,t),M=function(e){var t=[];for(var n in e){var r=e[n];!1!==r&&t.push("#define "+n+" "+r)}return t.join("\n")}(d),E=h.createProgram(),S=a.numMultiviewViews;if(r.isRawShaderMaterial?((o=[M].filter(Oo).join("\n")).length>0&&(o+="\n"),(s=[_,M].filter(Oo).join("\n")).length>0&&(s+="\n")):(o=[ko(a),"#define SHADER_NAME "+i.name,M,a.instancing?"#define USE_INSTANCING":"",a.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+w,"#define MAX_BONES "+a.maxBones,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp2?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+x:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.normalMap&&a.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",a.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",a.displacementMap&&a.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.vertexTangents?"#define USE_TANGENT":"",a.vertexColors?"#define USE_COLOR":"",a.vertexUvs?"#define USE_UV":"",a.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",a.flatShading?"#define FLAT_SHADED":"",a.skinning?"#define USE_SKINNING":"",a.useVertexTexture?"#define BONE_TEXTURE":"",a.morphTargets?"#define USE_MORPHTARGETS":"",a.morphNormals&&!1===a.flatShading?"#define USE_MORPHNORMALS":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+y:"",a.sizeAttenuation?"#define USE_SIZEATTENUATION":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(a.isWebGL2||t.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Oo).join("\n"),s=[_,ko(a),"#define SHADER_NAME "+i.name,M,a.alphaTest?"#define ALPHATEST "+a.alphaTest+(a.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+w,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp2?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.matcap?"#define USE_MATCAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+A:"",a.envMap?"#define "+x:"",a.envMap?"#define "+b:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.normalMap&&a.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",a.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.sheen?"#define USE_SHEEN":"",a.vertexTangents?"#define USE_TANGENT":"",a.vertexColors?"#define USE_COLOR":"",a.vertexUvs?"#define USE_UV":"",a.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",a.gradientMap?"#define USE_GRADIENTMAP":"",a.flatShading?"#define FLAT_SHADED":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+y:"",a.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",a.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(a.isWebGL2||t.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",(r.extensions&&r.extensions.shaderTextureLOD||a.envMap)&&(a.isWebGL2||t.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",a.toneMapping!==re?"#define TONE_MAPPING":"",a.toneMapping!==re?da.tonemapping_pars_fragment:"",a.toneMapping!==re?Io("toneMapping",a.toneMapping):"",a.dithering?"#define DITHERING":"",a.outputEncoding||a.mapEncoding||a.matcapEncoding||a.envMapEncoding||a.emissiveMapEncoding?da.encodings_pars_fragment:"",a.mapEncoding?Do("mapTexelToLinear",a.mapEncoding):"",a.matcapEncoding?Do("matcapTexelToLinear",a.matcapEncoding):"",a.envMapEncoding?Do("envMapTexelToLinear",a.envMapEncoding):"",a.emissiveMapEncoding?Do("emissiveMapTexelToLinear",a.emissiveMapEncoding):"",a.outputEncoding?(c="linearToOutputTexel",l=a.outputEncoding,u=Co(l),"vec4 "+c+"( vec4 value ) { return LinearTo"+u[0]+u[1]+"; }"):"",a.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(Oo).join("\n")),v=Bo(v=No(v=Go(v),a),a),g=Bo(g=No(g=Go(g),a),a),v=Ho(v),g=Ho(g),a.isWebGL2&&!r.isRawShaderMaterial){var T=!1,L=/^\s*#version\s+300\s+es\s*\n/;r.isShaderMaterial&&null!==v.match(L)&&null!==g.match(L)&&(T=!0,v=v.replace(L,""),g=g.replace(L,"")),o=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+o,s=["#version 300 es\n","#define varying in",T?"":"out highp vec4 pc_fragColor;",T?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+s,S>0&&(o=(o=o.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","layout(num_views = "+S+") in;","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join("\n"),["uniform mat4 modelViewMatrices["+S+"];","uniform mat4 projectionMatrices["+S+"];","uniform mat4 viewMatrices["+S+"];","uniform mat3 normalMatrices["+S+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join("\n")),s=(s=s.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+S+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join("\n")))}var R,C,P=s+g,D=Lo(h,35633,o+v),I=Lo(h,35632,P);if(h.attachShader(E,D),h.attachShader(E,I),void 0!==r.index0AttributeName?h.bindAttribLocation(E,0,r.index0AttributeName):!0===a.morphTargets&&h.bindAttribLocation(E,0,"position"),h.linkProgram(E),e.debug.checkShaderErrors){var O=h.getProgramInfoLog(E).trim(),N=h.getShaderInfoLog(D).trim(),B=h.getShaderInfoLog(I).trim(),F=!0,G=!0;if(!1===h.getProgramParameter(E,35714)){F=!1;var U=Po(h,D,"vertex"),z=Po(h,I,"fragment");console.error("THREE.WebGLProgram: shader error: ",h.getError(),"35715",h.getProgramParameter(E,35715),"gl.getProgramInfoLog",O,U,z)}else""!==O?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",O):""!==N&&""!==B||(G=!1);G&&(this.diagnostics={runnable:F,material:r,programLog:O,vertexShader:{log:N,prefix:o},fragmentShader:{log:B,prefix:s}})}return h.deleteShader(D),h.deleteShader(I),this.getUniforms=function(){return void 0===R&&(R=new To(h,E)),R},this.getAttributes=function(){return void 0===C&&(C=function(e,t){for(var n={},r=e.getProgramParameter(t,35721),i=0;i0,maxBones:x,useVertexTexture:o,morphTargets:t.morphTargets,morphNormals:t.morphNormals,maxMorphTargets:e.maxMorphTargets,maxMorphNormals:e.maxMorphNormals,numDirLights:r.directional.length,numPointLights:r.point.length,numSpotLights:r.spot.length,numRectAreaLights:r.rectArea.length,numHemiLights:r.hemi.length,numDirLightShadows:r.directionalShadowMap.length,numPointLightShadows:r.pointShadowMap.length,numSpotLightShadows:r.spotShadowMap.length,numClippingPlanes:f,numClipIntersection:m,dithering:t.dithering,shadowMapEnabled:e.shadowMap.enabled&&h.length>0,shadowMapType:e.shadowMap.type,toneMapping:t.toneMapped?e.toneMapping:re,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:t.premultipliedAlpha,alphaTest:t.alphaTest,doubleSided:t.side===y,flipSided:t.side===g,depthPacking:void 0!==t.depthPacking&&t.depthPacking}},this.getProgramCacheKey=function(t,n){var r=[];if(n.shaderID?r.push(n.shaderID):(r.push(t.fragmentShader),r.push(t.vertexShader)),void 0!==t.defines)for(var i in t.defines)r.push(i),r.push(t.defines[i]);for(var a=0;a1&&n.sort(qo),r.length>1&&r.sort(Qo)}}}function Zo(){var e=new WeakMap;function t(n){var r=n.target;r.removeEventListener("dispose",t),e.delete(r)}return{get:function(n,r){var i,a=e.get(n);return void 0===a?(i=new Yo,e.set(n,new WeakMap),e.get(n).set(r,i),n.addEventListener("dispose",t)):void 0===(i=a.get(r))&&(i=new Yo,a.set(r,i)),i},dispose:function(){e=new WeakMap}}}function Jo(){var e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];var n;switch(t.type){case"DirectionalLight":n={direction:new Mn,color:new Yr,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new xn};break;case"SpotLight":n={position:new Mn,direction:new Mn,color:new Yr,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new xn};break;case"PointLight":n={position:new Mn,color:new Yr,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new xn,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":n={direction:new Mn,skyColor:new Yr,groundColor:new Yr};break;case"RectAreaLight":n={color:new Yr,position:new Mn,halfWidth:new Mn,halfHeight:new Mn}}return e[t.id]=n,n}}}var Ko=0;function $o(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function es(){for(var e=new Jo,t={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},n=0;n<9;n++)t.probe.push(new Mn);var r=new Mn,i=new Hn,a=new Hn;return{setup:function(n,o,s){for(var c=0,l=0,u=0,h=0;h<9;h++)t.probe[h].set(0,0,0);var d=0,p=0,f=0,m=0,v=0,g=0,y=0,A=0,x=s.matrixWorldInverse;n.sort($o),h=0;for(var b=n.length;h0:!0===s.isGeometry&&(p=s.morphTargets&&s.morphTargets.length>0));var f=!1;!0===t.isSkinnedMesh&&(!0===n.skinning?f=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",t)),c=h(p,f,!0===t.isInstancedMesh)}else c=d;if(e.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var v=c.uuid,g=n.uuid,y=l[v];void 0===y&&(y={},l[v]=y);var A=y[g];void 0===A&&(A=c.clone(),y[g]=A),c=A}return c.visible=n.visible,c.wireframe=n.wireframe,c.side=o===m?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],c.clipShadows=n.clipShadows,c.clippingPlanes=n.clippingPlanes,c.clipIntersection=n.clipIntersection,c.wireframeLinewidth=n.wireframeLinewidth,c.linewidth=n.linewidth,!0===r.isPointLight&&!0===c.isMeshDistanceMaterial&&(c.referencePosition.setFromMatrixPosition(r.matrixWorld),c.nearDistance=i,c.farDistance=a),c}function S(n,i,a,o,s){if(!1!==n.visible){if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===m)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);var c=t.update(n),l=n.material;if(Array.isArray(l))for(var u=c.groups,h=0,d=u.length;hn||i.y>n)&&(console.warn("THREE.WebGLShadowMap:",v,"has shadow exceeding max texture size, reducing"),i.x>n&&(a.x=Math.floor(n/y.x),i.x=a.x*y.x,g.mapSize.x=a.x),i.y>n&&(a.y=Math.floor(n/y.y),i.y=a.y*y.y,g.mapSize.y=a.y)),null===g.map&&!g.isPointLightShadow&&this.type===m){var A={minFilter:Ee,magFilter:Ee,format:je};g.map=new Dn(i.x,i.y,A),g.map.texture.name=v.name+".shadowMap",g.mapPass=new Dn(i.x,i.y,A),g.camera.updateProjectionMatrix()}if(null===g.map){A={minFilter:xe,magFilter:xe,format:je};g.map=new Dn(i.x,i.y,A),g.map.texture.name=v.name+".shadowMap",g.camera.updateProjectionMatrix()}e.setRenderTarget(g.map),e.clear();for(var w=g.getViewportCount(),_=0;_=1):-1!==he.indexOf("OpenGL ES")&&(ue=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(he)[1]),le=ue>=2);var de=null,pe={},fe=new Pn,me=new Pn;function ve(t,n,r){var i=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(var o=0;or||e.height>r)&&(i=r/Math.max(e.width,e.height)),i<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){var a=t?An.floorPowerOfTwo:Math.floor,o=a(i*e.width),c=a(i*e.height);void 0===s&&(s=m(o,c));var l=n?m(o,c):s;return l.width=o,l.height=c,l.getContext("2d").drawImage(e,0,0,o,c),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+o+"x"+c+")."),l}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function g(e){return An.isPowerOfTwo(e.width)&&An.isPowerOfTwo(e.height)}function y(e,t){return e.generateMipmaps&&t&&e.minFilter!==xe&&e.minFilter!==Ee}function A(t,n,i,a){e.generateMipmap(t),r.get(n).__maxMipLevel=Math.log(Math.max(i,a))*Math.LOG2E}function x(e,n){if(!1===c)return e;var r=e;return 6403===e&&(5126===n&&(r=33326),5131===n&&(r=33325),5121===n&&(r=33321)),6407===e&&(5126===n&&(r=34837),5131===n&&(r=34843),5121===n&&(r=32849)),6408===e&&(5126===n&&(r=34836),5131===n&&(r=34842),5121===n&&(r=32856)),33325===r||33326===r||34842===r||34836===r?t.get("EXT_color_buffer_float"):34843!==r&&34837!==r||console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead."),r}function b(e){return e===xe||e===be||e===_e?9728:9729}function w(t){var n=t.target;n.removeEventListener("dispose",w),function(t){var n=r.get(t);if(void 0===n.__webglInit)return;e.deleteTexture(n.__webglTexture),r.remove(t)}(n),n.isVideoTexture&&p.delete(n),o.memory.textures--}function _(t){var n=t.target;n.removeEventListener("dispose",_),function(t){var n=r.get(t),i=r.get(t.texture);if(!t)return;void 0!==i.__webglTexture&&e.deleteTexture(i.__webglTexture);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLRenderTargetCube)for(var a=0;a<6;a++)e.deleteFramebuffer(n.__webglFramebuffer[a]),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[a]);else e.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer);if(t.isWebGLMultiviewRenderTarget){e.deleteTexture(n.__webglColorTexture),e.deleteTexture(n.__webglDepthStencilTexture),o.memory.textures-=2;a=0;for(var s=n.__webglViewFramebuffers.length;a0&&i.__version!==e.version){var a=e.image;if(void 0===a)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==a.complete)return void D(i,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+t),n.bindTexture(3553,i.__webglTexture)}function S(t,i){if(6===t.image.length){var o=r.get(t);if(t.version>0&&o.__version!==t.version){P(o,t),n.activeTexture(33984+i),n.bindTexture(34067,o.__webglTexture),e.pixelStorei(37440,t.flipY);for(var s=t&&t.isCompressedTexture,l=t.image[0]&&t.image[0].isDataTexture,h=[],d=0;d<6;d++)h[d]=s||l?l?t.image[d].image:t.image[d]:v(t.image[d],!1,!0,u);var p,f=h[0],m=g(f)||c,b=a.convert(t.format),w=a.convert(t.type),_=x(b,w);if(C(34067,t,m),s){for(d=0;d<6;d++){p=h[d].mipmaps;for(var M=0;M1||r.get(a).__currentAnisotropy)&&(e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function P(t,n){void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",w),t.__webglTexture=e.createTexture(),o.memory.textures++)}function D(t,r,i){var o=3553;r.isDataTexture2DArray&&(o=35866),r.isDataTexture3D&&(o=32879),P(t,r),n.activeTexture(33984+i),n.bindTexture(o,t.__webglTexture),e.pixelStorei(37440,r.flipY),e.pixelStorei(37441,r.premultiplyAlpha),e.pixelStorei(3317,r.unpackAlignment);var s=function(e){return!c&&(e.wrapS!==ye||e.wrapT!==ye||e.minFilter!==xe&&e.minFilter!==Ee)}(r)&&!1===g(r.image),l=v(r.image,s,!1,h),u=g(l)||c,d=a.convert(r.format),p=a.convert(r.type),f=x(d,p);C(o,r,u);var m,b=r.mipmaps;if(r.isDepthTexture){if(f=6402,r.type===Be){if(!1===c)throw new Error("Float Depth Texture only supported in WebGL2.0");f=36012}else c&&(f=33189);r.format===Qe&&6402===f&&r.type!==Ie&&r.type!==Ne&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Ie,p=a.convert(r.type)),r.format===Ye&&(f=34041,r.type!==He&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=He,p=a.convert(r.type))),n.texImage2D(3553,0,f,l.width,l.height,0,d,p,null)}else if(r.isDataTexture)if(b.length>0&&u){for(var w=0,_=b.length;w<_;w++)m=b[w],n.texImage2D(3553,w,f,m.width,m.height,0,d,p,m.data);r.generateMipmaps=!1,t.__maxMipLevel=b.length-1}else n.texImage2D(3553,0,f,l.width,l.height,0,d,p,l.data),t.__maxMipLevel=0;else if(r.isCompressedTexture){for(w=0,_=b.length;w<_;w++)m=b[w],r.format!==je&&r.format!==ke?null!==d?n.compressedTexImage2D(3553,w,f,m.width,m.height,0,m.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texImage2D(3553,w,f,m.width,m.height,0,d,p,m.data);t.__maxMipLevel=b.length-1}else if(r.isDataTexture2DArray)n.texImage3D(35866,0,f,l.width,l.height,l.depth,0,d,p,l.data),t.__maxMipLevel=0;else if(r.isDataTexture3D)n.texImage3D(32879,0,f,l.width,l.height,l.depth,0,d,p,l.data),t.__maxMipLevel=0;else if(b.length>0&&u){for(w=0,_=b.length;w<_;w++)m=b[w],n.texImage2D(3553,w,f,d,p,m);r.generateMipmaps=!1,t.__maxMipLevel=b.length-1}else n.texImage2D(3553,0,f,d,p,l),t.__maxMipLevel=0;y(r,u)&&A(3553,r,l.width,l.height),t.__version=r.version,r.onUpdate&&r.onUpdate(r)}function I(t,i,o,s){var c=a.convert(i.texture.format),l=a.convert(i.texture.type),u=x(c,l);n.texImage2D(s,0,u,i.width,i.height,0,c,l,null),e.bindFramebuffer(36160,t),e.framebufferTexture2D(36160,o,s,r.get(i.texture).__webglTexture,0),e.bindFramebuffer(36160,null)}function O(t,n,r){if(e.bindRenderbuffer(36161,t),n.depthBuffer&&!n.stencilBuffer){if(r){var i=B(n);e.renderbufferStorageMultisample(36161,i,33189,n.width,n.height)}else e.renderbufferStorage(36161,33189,n.width,n.height);e.framebufferRenderbuffer(36160,36096,36161,t)}else if(n.depthBuffer&&n.stencilBuffer){if(r){i=B(n);e.renderbufferStorageMultisample(36161,i,35056,n.width,n.height)}else e.renderbufferStorage(36161,34041,n.width,n.height);e.framebufferRenderbuffer(36160,33306,36161,t)}else{var o=x(a.convert(n.texture.format),a.convert(n.texture.type));if(r){i=B(n);e.renderbufferStorageMultisample(36161,i,o,n.width,n.height)}else e.renderbufferStorage(36161,o,n.width,n.height)}e.bindRenderbuffer(36161,null)}function N(t){var n=r.get(t),i=!0===t.isWebGLRenderTargetCube;if(t.depthTexture){if(i)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,n){if(n&&n.isWebGLRenderTargetCube)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(36160,t),!n.depthTexture||!n.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(n.depthTexture).__webglTexture&&n.depthTexture.image.width===n.width&&n.depthTexture.image.height===n.height||(n.depthTexture.image.width=n.width,n.depthTexture.image.height=n.height,n.depthTexture.needsUpdate=!0),E(n.depthTexture,0);var i=r.get(n.depthTexture).__webglTexture;if(n.depthTexture.format===Qe)e.framebufferTexture2D(36160,36096,3553,i,0);else{if(n.depthTexture.format!==Ye)throw new Error("Unknown depthTexture format");e.framebufferTexture2D(36160,33306,3553,i,0)}}(n.__webglFramebuffer,t)}else if(i){n.__webglDepthbuffer=[];for(var a=0;a<6;a++)e.bindFramebuffer(36160,n.__webglFramebuffer[a]),n.__webglDepthbuffer[a]=e.createRenderbuffer(),O(n.__webglDepthbuffer[a],t)}else e.bindFramebuffer(36160,n.__webglFramebuffer),n.__webglDepthbuffer=e.createRenderbuffer(),O(n.__webglDepthbuffer,t);e.bindFramebuffer(36160,null)}function B(e){return c&&e.isWebGLMultisampleRenderTarget?Math.min(d,e.samples):0}var F=!1,G=!1;this.allocateTextureUnit=function(){var e=M;return e>=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),M+=1,e},this.resetTextureUnits=function(){M=0},this.setTexture2D=E,this.setTexture2DArray=function(e,t){var i=r.get(e);e.version>0&&i.__version!==e.version?D(i,e,t):(n.activeTexture(33984+t),n.bindTexture(35866,i.__webglTexture))},this.setTexture3D=function(e,t){var i=r.get(e);e.version>0&&i.__version!==e.version?D(i,e,t):(n.activeTexture(33984+t),n.bindTexture(32879,i.__webglTexture))},this.setTextureCube=S,this.setTextureCubeDynamic=T,this.setupRenderTarget=function(i){var s=r.get(i),l=r.get(i.texture);i.addEventListener("dispose",_),l.__webglTexture=e.createTexture(),o.memory.textures++;var u=!0===i.isWebGLRenderTargetCube,h=!0===i.isWebGLMultisampleRenderTarget,d=!0===i.isWebGLMultiviewRenderTarget,p=g(i)||c;if(u){s.__webglFramebuffer=[];for(var f=0;f<6;f++)s.__webglFramebuffer[f]=e.createFramebuffer()}else if(s.__webglFramebuffer=e.createFramebuffer(),h)if(c){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,s.__webglColorRenderbuffer);var m=x(a.convert(i.texture.format),a.convert(i.texture.type)),v=B(i);e.renderbufferStorageMultisample(36161,v,m,i.width,i.height),e.bindFramebuffer(36160,s.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064,36161,s.__webglColorRenderbuffer),e.bindRenderbuffer(36161,null),i.depthBuffer&&(s.__webglDepthRenderbuffer=e.createRenderbuffer(),O(s.__webglDepthRenderbuffer,i,!0)),e.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");else if(d){var b=i.width,w=i.height,M=i.numViews;e.bindFramebuffer(36160,s.__webglFramebuffer);var E=t.get("OVR_multiview2");o.memory.textures+=2;var S=e.createTexture();e.bindTexture(35866,S),e.texParameteri(35866,10240,9728),e.texParameteri(35866,10241,9728),e.texImage3D(35866,0,32856,b,w,M,0,6408,5121,null),E.framebufferTextureMultiviewOVR(36160,36064,S,0,0,M);var T=e.createTexture();e.bindTexture(35866,T),e.texParameteri(35866,10240,9728),e.texParameteri(35866,10241,9728),e.texImage3D(35866,0,35056,b,w,M,0,34041,34042,null),E.framebufferTextureMultiviewOVR(36160,33306,T,0,0,M);var L=new Array(M);for(f=0;fd)return!1;for(var n=1,r=t.length;n=0){var l=i[s];if(void 0!==l){var u=l.normalized,h=l.itemSize;if(void 0===(_=b.get(l)))continue;var d=_.buffer,g=_.type,y=_.bytesPerElement;if(l.isInterleavedBufferAttribute){var A=l.data,x=A.stride,w=l.offset;A&&A.isInstancedInterleavedBuffer?(v.enableAttributeAndDivisor(c,A.meshPerAttribute),void 0===t.maxInstancedCount&&(t.maxInstancedCount=A.meshPerAttribute*A.count)):v.enableAttribute(c),p.bindBuffer(34962,d),p.vertexAttribPointer(c,h,g,u,x*y,w*y)}else l.isInstancedBufferAttribute?(v.enableAttributeAndDivisor(c,l.meshPerAttribute),void 0===t.maxInstancedCount&&(t.maxInstancedCount=l.meshPerAttribute*l.count)):v.enableAttribute(c),p.bindBuffer(34962,d),p.vertexAttribPointer(c,h,g,u,0,0)}else if("instanceMatrix"===s){var _;if(void 0===(_=b.get(e.instanceMatrix)))continue;d=_.buffer,g=_.type;v.enableAttributeAndDivisor(c+0,1),v.enableAttributeAndDivisor(c+1,1),v.enableAttributeAndDivisor(c+2,1),v.enableAttributeAndDivisor(c+3,1),p.bindBuffer(34962,d),p.vertexAttribPointer(c+0,4,g,!1,64,0),p.vertexAttribPointer(c+1,4,g,!1,64,16),p.vertexAttribPointer(c+2,4,g,!1,64,32),p.vertexAttribPointer(c+3,4,g,!1,64,48)}else if(void 0!==o){var M=o[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,n,r,s),null!==u&&p.bindBuffer(34963,l.buffer));var y=1/0;null!==u?y=u.count:void 0!==h&&(y=h.count);var A=n.drawRange.start*d,x=n.drawRange.count*d,_=null!==a?a.start*d:0,M=null!==a?a.count*d:1/0,E=Math.max(A,_),S=Math.min(y,A+x,_+M)-1,T=Math.max(0,S-E+1);if(0!==T){if(i.isMesh)if(!0===r.wireframe)v.setLineWidth(r.wireframeLinewidth*ae()),g.setMode(1);else switch(i.drawMode){case Rt:g.setMode(4);break;case Ct:g.setMode(5);break;case Pt:g.setMode(6)}else if(i.isLine){var P=r.linewidth;void 0===P&&(P=1),v.setLineWidth(P*ae()),i.isLineSegments?g.setMode(1):i.isLineLoop?g.setMode(2):g.setMode(3)}else i.isPoints?g.setMode(0):i.isSprite&&g.setMode(4);i.isInstancedMesh?g.renderInstances(n,E,T,i.count):n.isInstancedBufferGeometry?g.renderInstances(n,E,T,n.maxInstancedCount):g.render(E,T)}},this.compile=function(e,t){(d=S.get(e,t)).init(),e.traverse((function(e){e.isLight&&(d.pushLight(e),e.castShadow&&d.pushShadow(e))})),d.setupLights(t),e.traverse((function(t){if(t.material)if(Array.isArray(t.material))for(var n=0;n=0&&e.numSupportedMorphTargets++}if(e.morphNormals){e.numSupportedMorphNormals=0;for(f=0;f=0&&e.numSupportedMorphNormals++}var m=r.shader.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(r.numClippingPlanes=$.numPlanes,r.numIntersection=$.numIntersection,m.clippingPlanes=$.uniform),r.fog=t,r.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),r.lightsStateVersion=o,r.needsLights&&(m.ambientLightColor.value=i.state.ambient,m.lightProbe.value=i.state.probe,m.directionalLights.value=i.state.directional,m.spotLights.value=i.state.spot,m.rectAreaLights.value=i.state.rectArea,m.pointLights.value=i.state.point,m.hemisphereLights.value=i.state.hemi,m.directionalShadowMap.value=i.state.directionalShadowMap,m.directionalShadowMatrix.value=i.state.directionalShadowMatrix,m.spotShadowMap.value=i.state.spotShadowMap,m.spotShadowMatrix.value=i.state.spotShadowMatrix,m.pointShadowMap.value=i.state.pointShadowMap,m.pointShadowMatrix.value=i.state.pointShadowMatrix);var v=r.program.getUniforms(),g=To.seqWithValue(v.seq,m);r.uniformsList=g}function be(e,t,n,r){x.resetTextureUnits();var i=A.get(n),a=d.state.lights;if(ee&&(te||e!==H)){var o=e===H&&n.id===U;$.setState(n.clippingPlanes,n.clipIntersection,n.clipShadows,e,i,o)}!1===n.needsUpdate&&(void 0===i.program?n.needsUpdate=!0:n.fog&&i.fog!==t?n.needsUpdate=!0:i.needsLights&&i.lightsStateVersion!==a.state.version?n.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===$.numPlanes&&i.numIntersection===$.numIntersection||(n.needsUpdate=!0)),n.needsUpdate&&(xe(n,t,r),n.needsUpdate=!1);var s,c,l=!1,u=!1,h=!1,f=i.program,y=f.getUniforms(),b=i.shader.uniforms;if(v.useProgram(f.program)&&(l=!0,u=!0,h=!0),n.id!==U&&(U=n.id,u=!0),l||H!==e){if(f.numMultiviewViews>0?le.updateCameraProjectionMatricesUniform(e,y):y.setValue(p,"projectionMatrix",e.projectionMatrix),m.logarithmicDepthBuffer&&y.setValue(p,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),H!==e&&(H=e,u=!0,h=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.envMap){var w=y.map.cameraPosition;void 0!==w&&w.setValue(p,re.setFromMatrixPosition(e.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&y.setValue(p,"isOrthographic",!0===e.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.skinning)&&(f.numMultiviewViews>0?le.updateCameraViewMatricesUniform(e,y):y.setValue(p,"viewMatrix",e.matrixWorldInverse))}if(n.skinning){y.setOptional(p,r,"bindMatrix"),y.setOptional(p,r,"bindMatrixInverse");var _=r.skeleton;if(_){var M=_.bones;if(m.floatVertexTextures){if(void 0===_.boneTexture){var E=Math.sqrt(4*M.length);E=An.ceilPowerOfTwo(E),E=Math.max(E,4);var S=new Float32Array(E*E*4);S.set(_.boneMatrices);var T=new ca(S,E,E,je,Be);_.boneMatrices=S,_.boneTexture=T,_.boneTextureSize=E}y.setValue(p,"boneTexture",_.boneTexture,x),y.setValue(p,"boneTextureSize",_.boneTextureSize)}else y.setOptional(p,_,"boneMatrices")}}return(u||i.receiveShadow!==r.receiveShadow)&&(i.receiveShadow=r.receiveShadow,y.setValue(p,"receiveShadow",r.receiveShadow)),u&&(y.setValue(p,"toneMappingExposure",D.toneMappingExposure),y.setValue(p,"toneMappingWhitePoint",D.toneMappingWhitePoint),i.needsLights&&(c=h,(s=b).ambientLightColor.needsUpdate=c,s.lightProbe.needsUpdate=c,s.directionalLights.needsUpdate=c,s.pointLights.needsUpdate=c,s.spotLights.needsUpdate=c,s.rectAreaLights.needsUpdate=c,s.hemisphereLights.needsUpdate=c),t&&n.fog&&function(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)}(b,t),n.isMeshBasicMaterial?we(b,n):n.isMeshLambertMaterial?(we(b,n),function(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}(b,n)):n.isMeshPhongMaterial?(we(b,n),n.isMeshToonMaterial?function(e,t){_e(e,t),t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(b,n):_e(b,n)):n.isMeshStandardMaterial?(we(b,n),n.isMeshPhysicalMaterial?function(e,t){Me(e,t),e.reflectivity.value=t.reflectivity,e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.sheen&&e.sheen.value.copy(t.sheen);t.clearcoatNormalMap&&(e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),e.clearcoatNormalMap.value=t.clearcoatNormalMap,t.side===g&&e.clearcoatNormalScale.value.negate());e.transparency.value=t.transparency}(b,n):Me(b,n)):n.isMeshMatcapMaterial?(we(b,n),function(e,t){t.matcap&&(e.matcap.value=t.matcap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===g&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===g&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(b,n)):n.isMeshDepthMaterial?(we(b,n),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(b,n)):n.isMeshDistanceMaterial?(we(b,n),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias);e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}(b,n)):n.isMeshNormalMaterial?(we(b,n),function(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===g&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===g&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(b,n)):n.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}(b,n),n.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(b,n)):n.isPointsMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*Q,e.scale.value=.5*q,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);var n;t.map?n=t.map:t.alphaMap&&(n=t.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}(b,n):n.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);var n;t.map?n=t.map:t.alphaMap&&(n=t.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}(b,n):n.isShadowMaterial&&(b.color.value.copy(n.color),b.opacity.value=n.opacity),void 0!==b.ltc_1&&(b.ltc_1.value=pa.LTC_1),void 0!==b.ltc_2&&(b.ltc_2.value=pa.LTC_2),To.upload(p,i.uniformsList,b,x),n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(To.upload(p,i.uniformsList,b,x),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&y.setValue(p,"center",r.center),f.numMultiviewViews>0?le.updateObjectMatricesUniforms(r,e,y):(y.setValue(p,"modelViewMatrix",r.modelViewMatrix),y.setValue(p,"normalMatrix",r.normalMatrix)),y.setValue(p,"modelMatrix",r.matrixWorld),f}function we(e,t){var n;e.opacity.value=t.opacity,t.color&&e.diffuse.value.copy(t.color),t.emissive&&e.emissive.value.copy(t.emissive).multiplyScalar(t.emissiveIntensity),t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.specularMap&&(e.specularMap.value=t.specularMap),t.envMap&&(e.envMap.value=t.envMap,e.flipEnvMap.value=t.envMap.isCubeTexture?-1:1,e.reflectivity.value=t.reflectivity,e.refractionRatio.value=t.refractionRatio,e.maxMipLevel.value=A.get(t.envMap).__maxMipLevel),t.lightMap&&(e.lightMap.value=t.lightMap,e.lightMapIntensity.value=t.lightMapIntensity),t.aoMap&&(e.aoMap.value=t.aoMap,e.aoMapIntensity.value=t.aoMapIntensity),t.map?n=t.map:t.specularMap?n=t.specularMap:t.displacementMap?n=t.displacementMap:t.normalMap?n=t.normalMap:t.bumpMap?n=t.bumpMap:t.roughnessMap?n=t.roughnessMap:t.metalnessMap?n=t.metalnessMap:t.alphaMap?n=t.alphaMap:t.emissiveMap&&(n=t.emissiveMap),void 0!==n&&(n.isWebGLRenderTarget&&(n=n.texture),!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}function _e(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===g&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===g&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}function Me(e,t){e.roughness.value=t.roughness,e.metalness.value=t.metalness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap),t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap),t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,t.side===g&&(e.bumpScale.value*=-1)),t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),t.side===g&&e.normalScale.value.negate()),t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}ve.setAnimationLoop((function(e){ce.isPresenting()||me&&me(e)})),"undefined"!=typeof window&&ve.setContext(window),this.setAnimationLoop=function(e){me=e,ce.setAnimationLoop(e),ve.start()},this.render=function(e,t){var n,r;if(void 0!==arguments[2]&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),n=arguments[2]),void 0!==arguments[3]&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),r=arguments[3]),t&&t.isCamera){if(!I){z.geometry=null,z.program=null,z.wireframe=!1,U=-1,H=null,!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),ce.enabled&&(t=ce.getCamera(t)),(d=S.get(e,t)).init(),e.onBeforeRender(D,e,t,n||F),ne.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),K.setFromMatrix(ne),te=this.localClippingEnabled,ee=$.init(this.clippingPlanes,te,t),(h=E.get(e,t)).init(),ge(e,t,0,D.sortObjects),!0===D.sortObjects&&h.sort(),ee&&$.beginShadows();var i=d.state.shadowsArray;ue.render(i,e,t),d.setupLights(t),ee&&$.endShadows(),this.info.autoReset&&this.info.reset(),void 0!==n&&this.setRenderTarget(n),ce.enabled&&le.isAvailable()&&le.attachCamera(t),T.render(h,e,t,r);var a=h.opaque,o=h.transparent;if(e.overrideMaterial){var s=e.overrideMaterial;a.length&&ye(a,e,t,s),o.length&&ye(o,e,t,s)}else a.length&&ye(a,e,t),o.length&&ye(o,e,t);e.onAfterRender(D,e,t),null!==F&&(x.updateRenderTargetMipmap(F),x.updateMultisampleRenderTarget(F)),v.buffers.depth.setTest(!0),v.buffers.depth.setMask(!0),v.buffers.color.setMask(!0),v.setPolygonOffset(!1),ce.enabled&&(le.isAvailable()&&le.detachCamera(t),ce.submitFrame()),h=null,d=null}}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.setFramebuffer=function(e){O!==e&&null===F&&p.bindFramebuffer(36160,e),O=e},this.getActiveCubeFace=function(){return N},this.getActiveMipmapLevel=function(){return B},this.getRenderTarget=function(){return F},this.setRenderTarget=function(e,t,n){F=e,N=t,B=n,e&&void 0===A.get(e).__webglFramebuffer&&x.setupRenderTarget(e);var r=O,i=!1;if(e){var a=A.get(e).__webglFramebuffer;e.isWebGLRenderTargetCube?(r=a[t||0],i=!0):r=e.isWebGLMultisampleRenderTarget?A.get(e).__webglMultisampledFramebuffer:a,k.copy(e.viewport),j.copy(e.scissor),W=e.scissorTest}else k.copy(Y).multiplyScalar(Q).floor(),j.copy(Z).multiplyScalar(Q).floor(),W=J;if(G!==r&&(p.bindFramebuffer(36160,r),G=r),v.viewport(k),v.scissor(j),v.setScissorTest(W),i){var o=A.get(e.texture);p.framebufferTexture2D(36160,36064,34069+(t||0),o.__webglTexture,n||0)}},this.readRenderTargetPixels=function(e,t,n,r,i,a,o){if(e&&e.isWebGLRenderTarget){var s=A.get(e).__webglFramebuffer;if(e.isWebGLRenderTargetCube&&void 0!==o&&(s=s[o]),s){var c=!1;s!==G&&(p.bindFramebuffer(36160,s),c=!0);try{var l=e.texture,u=l.format,h=l.type;if(u!==je&&P.convert(u)!==p.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(h===Ce||P.convert(h)===p.getParameter(35738)||h===Be&&(m.isWebGL2||f.get("OES_texture_float")||f.get("WEBGL_color_buffer_float"))||h===Fe&&(m.isWebGL2?f.get("EXT_color_buffer_float"):f.get("EXT_color_buffer_half_float"))))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===p.checkFramebufferStatus(36160)?t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&p.readPixels(t,n,r,i,P.convert(u),P.convert(h),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{c&&p.bindFramebuffer(36160,G)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(e,t,n){void 0===n&&(n=0);var r=Math.pow(2,-n),i=Math.floor(t.image.width*r),a=Math.floor(t.image.height*r),o=P.convert(t.format);x.setTexture2D(t,0),p.copyTexImage2D(3553,n,o,e.x,e.y,i,a,0),v.unbindTexture()},this.copyTextureToTexture=function(e,t,n,r){var i=t.image.width,a=t.image.height,o=P.convert(n.format),s=P.convert(n.type);x.setTexture2D(n,0),t.isDataTexture?p.texSubImage2D(3553,r||0,e.x,e.y,i,a,o,s,t.image.data):p.texSubImage2D(3553,r||0,e.x,e.y,o,s,t.image),v.unbindTexture()},this.initTexture=function(e){x.setTexture2D(e,0),v.unbindTexture()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function ws(e,t){this.name="",this.color=new Yr(e),this.density=void 0!==t?t:25e-5}function _s(e,t,n){this.name="",this.color=new Yr(e),this.near=void 0!==t?t:1,this.far=void 0!==n?n:1e3}function Ms(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=sn,this.updateRange={offset:0,count:-1},this.version=0}function Es(e,t,n,r){this.data=e,this.itemSize=t,this.offset=n,this.normalized=!0===r}function Ss(e){ti.call(this),this.type="SpriteMaterial",this.color=new Yr(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(e)}Object.assign(As.prototype,vn.prototype),Object.assign(xs.prototype,vn.prototype),Object.assign(ws.prototype,{isFogExp2:!0,clone:function(){return new ws(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}),Object.assign(_s.prototype,{isFog:!0,clone:function(){return new _s(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}),Object.defineProperty(Ms.prototype,"needsUpdate",{set:function(e){!0===e&&this.version++}}),Object.assign(Ms.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(e){return this.usage=e,this},copy:function(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this},copyAt:function(e,t,n){e*=this.stride,n*=t.stride;for(var r=0,i=this.stride;re.far||t.push({distance:s,point:Ts.clone(),uv:Wr.getUV(Ts,Is,Os,Ns,Bs,Fs,Gs,new xn),face:null,object:this})}},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(e){return ar.prototype.copy.call(this,e),void 0!==e.center&&this.center.copy(e.center),this}});var Hs=new Mn,Vs=new Mn;function ks(){ar.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}function js(e,t){e&&e.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),zi.call(this,e,t),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Hn,this.bindMatrixInverse=new Hn}ks.prototype=Object.assign(Object.create(ar.prototype),{constructor:ks,isLOD:!0,copy:function(e){ar.prototype.copy.call(this,e,!1);for(var t=e.levels,n=0,r=t.length;n1){Hs.setFromMatrixPosition(e.matrixWorld),Vs.setFromMatrixPosition(this.matrixWorld);var n=Hs.distanceTo(Vs);t[0].object.visible=!0;for(var r=1,i=t.length;r=t[r].distance;r++)t[r-1].object.visible=!1,t[r].object.visible=!0;for(;ro))u.applyMatrix4(this.matrixWorld),(b=e.ray.origin.distanceTo(u))e.far||t.push({distance:b,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}else for(m=0,v=p.length/3-1;mo))u.applyMatrix4(this.matrixWorld),(b=e.ray.origin.distanceTo(u))e.far||t.push({distance:b,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}else if(r.isGeometry){var A=r.vertices,x=A.length;for(m=0;mo))u.applyMatrix4(this.matrixWorld),(b=e.ray.origin.distanceTo(u))e.far||t.push({distance:b,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var rc=new Mn,ic=new Mn;function ac(e,t){nc.call(this,e,t),this.type="LineSegments"}function oc(e,t){nc.call(this,e,t),this.type="LineLoop"}function sc(e){ti.call(this),this.type="PointsMaterial",this.color=new Yr(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(e)}ac.prototype=Object.assign(Object.create(nc.prototype),{constructor:ac,isLineSegments:!0,computeLineDistances:function(){var e=this.geometry;if(e.isBufferGeometry)if(null===e.index){for(var t=e.attributes.position,n=[],r=0,i=t.count;ri.far)return;a.push({distance:l,distanceToRay:Math.sqrt(s),point:c,index:t,face:null,object:o})}}function fc(e,t,n,r,i,a,o,s,c){Cn.call(this,e,t,n,r,i,a,o,s,c),this.format=void 0!==o?o:ke,this.minFilter=void 0!==a?a:Ee,this.magFilter=void 0!==i?i:Ee,this.generateMipmaps=!1}function mc(e,t,n,r,i,a,o,s,c,l,u,h){Cn.call(this,null,a,o,s,c,l,r,i,u,h),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}function vc(e,t,n,r,i,a,o,s,c){Cn.call(this,e,t,n,r,i,a,o,s,c),this.needsUpdate=!0}function gc(e,t,n,r,i,a,o,s,c,l){if((l=void 0!==l?l:Qe)!==Qe&&l!==Ye)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&l===Qe&&(n=Ie),void 0===n&&l===Ye&&(n=He),Cn.call(this,null,r,i,a,o,s,l,n,c),this.image={width:e,height:t},this.magFilter=void 0!==o?o:xe,this.minFilter=void 0!==s?s:xe,this.flipY=!1,this.generateMipmaps=!1}function yc(e){wi.call(this),this.type="WireframeGeometry";var t,n,r,i,a,o,s,c,l,u,h=[],d=[0,0],p={},f=["a","b","c"];if(e&&e.isGeometry){var m=e.faces;for(t=0,r=m.length;t=0?(e(v-1e-5,m,h),d.subVectors(u,h)):(e(v+1e-5,m,h),d.subVectors(h,u)),m-1e-5>=0?(e(v,m-1e-5,h),p.subVectors(u,h)):(e(v,m+1e-5,h),p.subVectors(h,u)),l.crossVectors(d,p).normalize(),s.push(l.x,l.y,l.z),c.push(v,m)}}for(r=0;r.9&&o<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),r<.2&&(a[e+4]+=1))}}()}(),this.setAttribute("position",new hi(i,3)),this.setAttribute("normal",new hi(i.slice(),3)),this.setAttribute("uv",new hi(a,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}function _c(e,t){qi.call(this),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Mc(e,t)),this.mergeVertices()}function Mc(e,t){wc.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],e,t),this.type="TetrahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Ec(e,t){qi.call(this),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Sc(e,t)),this.mergeVertices()}function Sc(e,t){wc.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],e,t),this.type="OctahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Tc(e,t){qi.call(this),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Lc(e,t)),this.mergeVertices()}function Lc(e,t){var n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1];wc.call(this,r,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Rc(e,t){qi.call(this),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t},this.fromBufferGeometry(new Cc(e,t)),this.mergeVertices()}function Cc(e,t){var n=(1+Math.sqrt(5))/2,r=1/n,i=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r];wc.call(this,i,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronBufferGeometry",this.parameters={radius:e,detail:t}}function Pc(e,t,n,r,i,a){qi.call(this),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:i},void 0!==a&&console.warn("THREE.TubeGeometry: taper has been removed.");var o=new Dc(e,t,n,r,i);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals,this.fromBufferGeometry(o),this.mergeVertices()}function Dc(e,t,n,r,i){wi.call(this),this.type="TubeBufferGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:i},t=t||64,n=n||1,r=r||8,i=i||!1;var a=e.computeFrenetFrames(t,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;var o,s,c=new Mn,l=new Mn,u=new xn,h=new Mn,d=[],p=[],f=[],m=[];function v(i){h=e.getPointAt(i/t,h);var o=a.normals[i],u=a.binormals[i];for(s=0;s<=r;s++){var f=s/r*Math.PI*2,m=Math.sin(f),v=-Math.cos(f);l.x=v*o.x+m*u.x,l.y=v*o.y+m*u.y,l.z=v*o.z+m*u.z,l.normalize(),p.push(l.x,l.y,l.z),c.x=h.x+n*l.x,c.y=h.y+n*l.y,c.z=h.z+n*l.z,d.push(c.x,c.y,c.z)}}!function(){for(o=0;o0){var o=i[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},e=0,t=o.length;e0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),fc.prototype=Object.assign(Object.create(Cn.prototype),{constructor:fc,isVideoTexture:!0,update:function(){var e=this.image;e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),mc.prototype=Object.create(Cn.prototype),mc.prototype.constructor=mc,mc.prototype.isCompressedTexture=!0,vc.prototype=Object.create(Cn.prototype),vc.prototype.constructor=vc,vc.prototype.isCanvasTexture=!0,gc.prototype=Object.create(Cn.prototype),gc.prototype.constructor=gc,gc.prototype.isDepthTexture=!0,yc.prototype=Object.create(wi.prototype),yc.prototype.constructor=yc,Ac.prototype=Object.create(qi.prototype),Ac.prototype.constructor=Ac,xc.prototype=Object.create(wi.prototype),xc.prototype.constructor=xc,bc.prototype=Object.create(qi.prototype),bc.prototype.constructor=bc,wc.prototype=Object.create(wi.prototype),wc.prototype.constructor=wc,_c.prototype=Object.create(qi.prototype),_c.prototype.constructor=_c,Mc.prototype=Object.create(wc.prototype),Mc.prototype.constructor=Mc,Ec.prototype=Object.create(qi.prototype),Ec.prototype.constructor=Ec,Sc.prototype=Object.create(wc.prototype),Sc.prototype.constructor=Sc,Tc.prototype=Object.create(qi.prototype),Tc.prototype.constructor=Tc,Lc.prototype=Object.create(wc.prototype),Lc.prototype.constructor=Lc,Rc.prototype=Object.create(qi.prototype),Rc.prototype.constructor=Rc,Cc.prototype=Object.create(wc.prototype),Cc.prototype.constructor=Cc,Pc.prototype=Object.create(qi.prototype),Pc.prototype.constructor=Pc,Dc.prototype=Object.create(wi.prototype),Dc.prototype.constructor=Dc,Dc.prototype.toJSON=function(){var e=wi.prototype.toJSON.call(this);return e.path=this.parameters.path.toJSON(),e},Ic.prototype=Object.create(qi.prototype),Ic.prototype.constructor=Ic,Oc.prototype=Object.create(wi.prototype),Oc.prototype.constructor=Oc,Nc.prototype=Object.create(qi.prototype),Nc.prototype.constructor=Nc,Bc.prototype=Object.create(wi.prototype),Bc.prototype.constructor=Bc;var Fc=function(e,t,n){n=n||2;var r,i,a,o,s,c,l,u=t&&t.length,h=u?t[0]*n:e.length,d=Gc(e,0,h,n,!0),p=[];if(!d||d.next===d.prev)return p;if(u&&(d=function(e,t,n,r){var i,a,o,s,c,l=[];for(i=0,a=t.length;i80*n){r=a=e[0],i=o=e[1];for(var f=n;fa&&(a=s),c>o&&(o=c);l=0!==(l=Math.max(a-r,o-i))?1/l:0}return zc(d,p,n,r,i,l),p};function Gc(e,t,n,r,i){var a,o;if(i===function(e,t,n,r){for(var i=0,a=t,o=n-r;a0)for(a=t;a=t;a-=r)o=nl(a,e[a],e[a+1],o);return o&&Kc(o,o.next)&&(rl(o),o=o.next),o}function Uc(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!Kc(r,r.next)&&0!==Jc(r.prev,r,r.next))r=r.next;else{if(rl(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function zc(e,t,n,r,i,a,o){if(e){!o&&a&&function(e,t,n,r){var i=e;do{null===i.z&&(i.z=qc(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,r,i,a,o,s,c,l=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,r=n,s=0,t=0;t0||c>0&&r;)0!==s&&(0===c||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1)}(i)}(e,r,i,a);for(var s,c,l=e;e.prev!==e.next;)if(s=e.prev,c=e.next,a?Vc(e,r,i,a):Hc(e))t.push(s.i/n),t.push(e.i/n),t.push(c.i/n),rl(e),e=c.next,l=c.next;else if((e=c)===l){o?1===o?zc(e=kc(e,t,n),t,n,r,i,a,2):2===o&&jc(e,t,n,r,i,a):zc(Uc(e),t,n,r,i,a,1);break}}}function Hc(e){var t=e.prev,n=e,r=e.next;if(Jc(t,n,r)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(Yc(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Jc(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Vc(e,t,n,r){var i=e.prev,a=e,o=e.next;if(Jc(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,u=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,h=qc(s,c,t,n,r),d=qc(l,u,t,n,r),p=e.prevZ,f=e.nextZ;p&&p.z>=h&&f&&f.z<=d;){if(p!==e.prev&&p!==e.next&&Yc(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Jc(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==e.prev&&f!==e.next&&Yc(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Jc(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=h;){if(p!==e.prev&&p!==e.next&&Yc(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Jc(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==e.prev&&f!==e.next&&Yc(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Jc(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function kc(e,t,n){var r=e;do{var i=r.prev,a=r.next.next;!Kc(i,a)&&$c(i,r,r.next,a)&&el(i,a)&&el(a,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(a.i/n),rl(r),rl(r.next),r=e=a),r=r.next}while(r!==e);return r}function jc(e,t,n,r,i,a){var o=e;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&Zc(o,s)){var c=tl(o,s);return o=Uc(o,o.next),c=Uc(c,c.next),zc(o,t,n,r,i,a),void zc(c,t,n,r,i,a)}s=s.next}o=o.next}while(o!==e)}function Wc(e,t){return e.x-t.x}function Xc(e,t){if(t=function(e,t){var n,r=t,i=e.x,a=e.y,o=-1/0;do{if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){var s=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>o){if(o=s,s===i){if(a===r.y)return r;if(a===r.next.y)return r.next}n=r.x=r.x&&r.x>=u&&i!==r.x&&Yc(an.x)&&el(r,e)&&(n=r,d=c),r=r.next;return n}(e,t)){var n=tl(t,e);Uc(n,n.next)}}function qc(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Qc(e){var t=e,n=e;do{(t.x=0&&(e-o)*(r-s)-(n-o)*(t-s)>=0&&(n-o)*(a-s)-(i-o)*(r-s)>=0}function Zc(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&$c(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&el(e,t)&&el(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)}function Jc(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Kc(e,t){return e.x===t.x&&e.y===t.y}function $c(e,t,n,r){return!!(Kc(e,n)&&Kc(t,r)||Kc(e,r)&&Kc(n,t))||Jc(e,t,n)>0!=Jc(e,t,r)>0&&Jc(n,r,e)>0!=Jc(n,r,t)>0}function el(e,t){return Jc(e.prev,e,e.next)<0?Jc(e,t,e.next)>=0&&Jc(e,e.prev,t)>=0:Jc(e,t,e.prev)<0||Jc(e,e.next,t)<0}function tl(e,t){var n=new il(e.i,e.x,e.y),r=new il(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function nl(e,t,n,r){var i=new il(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function rl(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function il(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}var al={area:function(e){for(var t=e.length,n=0,r=t-1,i=0;i2&&e[t-1].equals(e[0])&&e.pop()}function sl(e,t){for(var n=0;nNumber.EPSILON){var d=Math.sqrt(u),p=Math.sqrt(c*c+l*l),f=t.x-s/d,m=t.y+o/d,v=((n.x-l/p-f)*l-(n.y+c/p-m)*c)/(o*l-s*c),g=(r=f+o*v-e.x)*r+(i=m+s*v-e.y)*i;if(g<=2)return new xn(r,i);a=Math.sqrt(g/2)}else{var y=!1;o>Number.EPSILON?c>Number.EPSILON&&(y=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(l)&&(y=!0),y?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new xn(r/a,i/a)}for(var z=[],H=0,V=R.length,k=V-1,j=H+1;H=0;P--){for(I=P/p,O=u*Math.cos(I*Math.PI/2),D=h*Math.sin(I*Math.PI/2)+d,H=0,V=R.length;H=0;){n=H,(r=H-1)<0&&(r=e.length-1);var i=0,a=s+2*p;for(i=0;i0)&&f.push(w,_,E),(c!==n-1||l0&&g(!0),t>0&&g(!1)),this.setIndex(l),this.setAttribute("position",new hi(u,3)),this.setAttribute("normal",new hi(h,3)),this.setAttribute("uv",new hi(d,2))}function Sl(e,t,n,r,i,a,o){Ml.call(this,0,e,t,n,r,i,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}function Tl(e,t,n,r,i,a,o){El.call(this,0,e,t,n,r,i,a,o),this.type="ConeBufferGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}function Ll(e,t,n,r){qi.call(this),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},this.fromBufferGeometry(new Rl(e,t,n,r)),this.mergeVertices()}function Rl(e,t,n,r){wi.call(this),this.type="CircleBufferGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},e=e||1,t=void 0!==t?Math.max(3,t):8,n=void 0!==n?n:0,r=void 0!==r?r:2*Math.PI;var i,a,o=[],s=[],c=[],l=[],u=new Mn,h=new xn;for(s.push(0,0,0),c.push(0,0,1),l.push(.5,.5),a=0,i=3;a<=t;a++,i+=3){var d=n+a/t*r;u.x=e*Math.cos(d),u.y=e*Math.sin(d),s.push(u.x,u.y,u.z),c.push(0,0,1),h.x=(s[i]/e+1)/2,h.y=(s[i+1]/e+1)/2,l.push(h.x,h.y)}for(i=1;i<=t;i++)o.push(i,i+1,0);this.setIndex(o),this.setAttribute("position",new hi(s,3)),this.setAttribute("normal",new hi(c,3)),this.setAttribute("uv",new hi(l,2))}dl.prototype=Object.create(qi.prototype),dl.prototype.constructor=dl,pl.prototype=Object.create(ll.prototype),pl.prototype.constructor=pl,fl.prototype=Object.create(qi.prototype),fl.prototype.constructor=fl,ml.prototype=Object.create(wi.prototype),ml.prototype.constructor=ml,vl.prototype=Object.create(qi.prototype),vl.prototype.constructor=vl,gl.prototype=Object.create(wi.prototype),gl.prototype.constructor=gl,yl.prototype=Object.create(qi.prototype),yl.prototype.constructor=yl,Al.prototype=Object.create(wi.prototype),Al.prototype.constructor=Al,xl.prototype=Object.create(qi.prototype),xl.prototype.constructor=xl,xl.prototype.toJSON=function(){var e=qi.prototype.toJSON.call(this);return wl(this.parameters.shapes,e)},bl.prototype=Object.create(wi.prototype),bl.prototype.constructor=bl,bl.prototype.toJSON=function(){var e=wi.prototype.toJSON.call(this);return wl(this.parameters.shapes,e)},_l.prototype=Object.create(wi.prototype),_l.prototype.constructor=_l,Ml.prototype=Object.create(qi.prototype),Ml.prototype.constructor=Ml,El.prototype=Object.create(wi.prototype),El.prototype.constructor=El,Sl.prototype=Object.create(Ml.prototype),Sl.prototype.constructor=Sl,Tl.prototype=Object.create(El.prototype),Tl.prototype.constructor=Tl,Ll.prototype=Object.create(qi.prototype),Ll.prototype.constructor=Ll,Rl.prototype=Object.create(wi.prototype),Rl.prototype.constructor=Rl;var Cl=Object.freeze({__proto__:null,WireframeGeometry:yc,ParametricGeometry:Ac,ParametricBufferGeometry:xc,TetrahedronGeometry:_c,TetrahedronBufferGeometry:Mc,OctahedronGeometry:Ec,OctahedronBufferGeometry:Sc,IcosahedronGeometry:Tc,IcosahedronBufferGeometry:Lc,DodecahedronGeometry:Rc,DodecahedronBufferGeometry:Cc,PolyhedronGeometry:bc,PolyhedronBufferGeometry:wc,TubeGeometry:Pc,TubeBufferGeometry:Dc,TorusKnotGeometry:Ic,TorusKnotBufferGeometry:Oc,TorusGeometry:Nc,TorusBufferGeometry:Bc,TextGeometry:dl,TextBufferGeometry:pl,SphereGeometry:fl,SphereBufferGeometry:ml,RingGeometry:vl,RingBufferGeometry:gl,PlaneGeometry:ga,PlaneBufferGeometry:ya,LatheGeometry:yl,LatheBufferGeometry:Al,ShapeGeometry:xl,ShapeBufferGeometry:bl,ExtrudeGeometry:cl,ExtrudeBufferGeometry:ll,EdgesGeometry:_l,ConeGeometry:Sl,ConeBufferGeometry:Tl,CylinderGeometry:Ml,CylinderBufferGeometry:El,CircleGeometry:Ll,CircleBufferGeometry:Rl,BoxGeometry:Qi,BoxBufferGeometry:Yi});function Pl(e){ti.call(this),this.type="ShadowMaterial",this.color=new Yr(0),this.transparent=!0,this.setValues(e)}function Dl(e){ta.call(this,e),this.type="RawShaderMaterial"}function Il(e){ti.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Yr(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 Yr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Vt,this.normalScale=new xn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Ol(e){Il.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearcoat=0,this.clearcoatRoughness=0,this.sheen=null,this.clearcoatNormalScale=new xn(1,1),this.clearcoatNormalMap=null,this.transparency=0,this.setValues(e)}function Nl(e){ti.call(this),this.type="MeshPhongMaterial",this.color=new Yr(16777215),this.specular=new Yr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Vt,this.normalScale=new xn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ee,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Bl(e){Nl.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(e)}function Fl(e){ti.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Vt,this.normalScale=new xn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Gl(e){ti.call(this),this.type="MeshLambertMaterial",this.color=new Yr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=ee,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function Ul(e){ti.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Yr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Vt,this.normalScale=new xn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(e)}function zl(e){Zs.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}Pl.prototype=Object.create(ti.prototype),Pl.prototype.constructor=Pl,Pl.prototype.isShadowMaterial=!0,Pl.prototype.copy=function(e){return ti.prototype.copy.call(this,e),this.color.copy(e.color),this},Dl.prototype=Object.create(ta.prototype),Dl.prototype.constructor=Dl,Dl.prototype.isRawShaderMaterial=!0,Il.prototype=Object.create(ti.prototype),Il.prototype.constructor=Il,Il.prototype.isMeshStandardMaterial=!0,Il.prototype.copy=function(e){return ti.prototype.copy.call(this,e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},Ol.prototype=Object.create(Il.prototype),Ol.prototype.constructor=Ol,Ol.prototype.isMeshPhysicalMaterial=!0,Ol.prototype.copy=function(e){return Il.prototype.copy.call(this,e),this.defines={STANDARD:"",PHYSICAL:""},this.reflectivity=e.reflectivity,this.clearcoat=e.clearcoat,this.clearcoatRoughness=e.clearcoatRoughness,e.sheen?this.sheen=(this.sheen||new Yr).copy(e.sheen):this.sheen=null,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.transparency=e.transparency,this},Nl.prototype=Object.create(ti.prototype),Nl.prototype.constructor=Nl,Nl.prototype.isMeshPhongMaterial=!0,Nl.prototype.copy=function(e){return ti.prototype.copy.call(this,e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},Bl.prototype=Object.create(Nl.prototype),Bl.prototype.constructor=Bl,Bl.prototype.isMeshToonMaterial=!0,Bl.prototype.copy=function(e){return Nl.prototype.copy.call(this,e),this.gradientMap=e.gradientMap,this},Fl.prototype=Object.create(ti.prototype),Fl.prototype.constructor=Fl,Fl.prototype.isMeshNormalMaterial=!0,Fl.prototype.copy=function(e){return ti.prototype.copy.call(this,e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},Gl.prototype=Object.create(ti.prototype),Gl.prototype.constructor=Gl,Gl.prototype.isMeshLambertMaterial=!0,Gl.prototype.copy=function(e){return ti.prototype.copy.call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},Ul.prototype=Object.create(ti.prototype),Ul.prototype.constructor=Ul,Ul.prototype.isMeshMatcapMaterial=!0,Ul.prototype.copy=function(e){return ti.prototype.copy.call(this,e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.skinning=e.skinning,this.morphTargets=e.morphTargets,this.morphNormals=e.morphNormals,this},zl.prototype=Object.create(Zs.prototype),zl.prototype.constructor=zl,zl.prototype.isLineDashedMaterial=!0,zl.prototype.copy=function(e){return Zs.prototype.copy.call(this,e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this};var Hl=Object.freeze({__proto__:null,ShadowMaterial:Pl,SpriteMaterial:Ss,RawShaderMaterial:Dl,ShaderMaterial:ta,PointsMaterial:sc,MeshPhysicalMaterial:Ol,MeshStandardMaterial:Il,MeshPhongMaterial:Nl,MeshToonMaterial:Bl,MeshNormalMaterial:Fl,MeshLambertMaterial:Gl,MeshDepthMaterial:rs,MeshDistanceMaterial:is,MeshBasicMaterial:ni,MeshMatcapMaterial:Ul,LineDashedMaterial:zl,LineBasicMaterial:Zs,Material:ti}),Vl={arraySlice:function(e,t,n){return Vl.isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)},convertArray:function(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)},isTypedArray:function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)},getKeyframeOrder:function(e){for(var t=e.length,n=new Array(t),r=0;r!==t;++r)n[r]=r;return n.sort((function(t,n){return e[t]-e[n]})),n},sortedArray:function(e,t,n){for(var r=e.length,i=new e.constructor(r),a=0,o=0;o!==r;++a)for(var s=n[a]*t,c=0;c!==t;++c)i[o++]=e[s+c];return i},flattenJSON:function(e,t,n,r){for(var i=1,a=e[0];void 0!==a&&void 0===a[r];)a=e[i++];if(void 0!==a){var o=a[r];if(void 0!==o)if(Array.isArray(o))do{void 0!==(o=a[r])&&(t.push(a.time),n.push.apply(n,o)),a=e[i++]}while(void 0!==a);else if(void 0!==o.toArray)do{void 0!==(o=a[r])&&(t.push(a.time),o.toArray(n,n.length)),a=e[i++]}while(void 0!==a);else do{void 0!==(o=a[r])&&(t.push(a.time),n.push(o)),a=e[i++]}while(void 0!==a)}},subclip:function(e,t,n,r,i){i=i||30;var a=e.clone();a.name=t;for(var o=[],s=0;s=r)){u.push(c.times[d]);for(var f=0;fa.tracks[s].times[0]&&(m=a.tracks[s].times[0]);for(s=0;s=i)break e;var s=t[1];e=(i=t[--n-1]))break t}a=n,n=0}for(;n>>1;e0?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>8&255]+gn[t>>16&255]+gn[t>>24&255]+"-"+gn[255&e]+gn[e>>8&255]+"-"+gn[e>>16&15|64]+gn[e>>24&255]+"-"+gn[63&n|128]+gn[n>>8&255]+"-"+gn[n>>16&255]+gn[n>>24&255]+gn[255&r]+gn[r>>8&255]+gn[r>>16&255]+gn[r>>24&255]).toUpperCase()},clamp:function(t,e,n){return Math.max(e,Math.min(n,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)},lerp:function(t,e,n){return(1-n)*t+n*e},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*xn.DEG2RAD},radToDeg:function(t){return t*xn.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 bn(t,e){this.x=t||0,this.y=e||0}function wn(t,e,n,r){this._x=t||0,this._y=e||0,this._z=n||0,this._w=void 0!==r?r:1}Object.defineProperties(bn.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(bn.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},applyMatrix3:function(t){var e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this},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},cross:function(t){return this.x*t.y-this.y*t.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,n=this.y-t.y;return e*e+n*n},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var n=Math.cos(e),r=Math.sin(e),i=this.x-t.x,a=this.y-t.y;return this.x=i*n-a*r+t.x,this.y=i*r+a*n+t.y,this}}),Object.assign(wn,{slerp:function(t,e,n,r){return n.copy(t).slerp(e,r)},slerpFlat:function(t,e,n,r,i,a,o){var s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],h=i[a+0],d=i[a+1],p=i[a+2],f=i[a+3];if(u!==f||s!==h||c!==d||l!==p){var m=1-o,v=s*h+c*d+l*p+u*f,g=v>=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var x=Math.sqrt(y),b=Math.atan2(x,v*g);m=Math.sin(m*b)/x,o=Math.sin(o*b)/x}var w=o*g;if(s=s*m+h*w,c=c*m+d*w,l=l*m+p*w,u=u*m+f*w,m===1-o){var _=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=_,c*=_,l*=_,u*=_}}t[e]=s,t[e+1]=c,t[e+2]=l,t[e+3]=u}}),Object.defineProperties(wn.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(wn.prototype,{isQuaternion:!0,set:function(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=t._x,r=t._y,i=t._z,a=t.order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),h=s(n/2),d=s(r/2),p=s(i/2);return"XYZ"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u-h*d*p):"YXZ"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u+h*d*p):"ZXY"===a?(this._x=h*l*u-c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u-h*d*p):"ZYX"===a?(this._x=h*l*u-c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u+h*d*p):"YZX"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u-h*d*p):"XZY"===a&&(this._x=h*l*u-c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u+h*d*p),!1!==e&&this._onChangeCallback(),this},setFromAxisAngle:function(t,e){var n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this},setFromRotationMatrix:function(t){var e,n=t.elements,r=n[0],i=n[4],a=n[8],o=n[1],s=n[5],c=n[9],l=n[2],u=n[6],h=n[10],d=r+s+h;return d>0?(e=.5/Math.sqrt(d+1),this._w=.25/e,this._x=(u-c)*e,this._y=(a-l)*e,this._z=(o-i)*e):r>s&&r>h?(e=2*Math.sqrt(1+r-s-h),this._w=(u-c)/e,this._x=.25*e,this._y=(i+o)/e,this._z=(a+l)/e):s>h?(e=2*Math.sqrt(1+s-r-h),this._w=(a-l)/e,this._x=(i+o)/e,this._y=.25*e,this._z=(c+u)/e):(e=2*Math.sqrt(1+h-r-s),this._w=(o-i)/e,this._x=(a+l)/e,this._y=(c+u)/e,this._z=.25*e),this._onChangeCallback(),this},setFromUnitVectors:function(t,e){var n=t.dot(e)+1;return n<1e-6?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()},angleTo:function(t){return 2*Math.acos(Math.abs(xn.clamp(this.dot(t),-1,1)))},rotateTowards:function(t,e){var n=this.angleTo(t);if(0===n)return this;var r=Math.min(1,e/n);return this.slerp(t,r),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var n=t._x,r=t._y,i=t._z,a=t._w,o=e._x,s=e._y,c=e._z,l=e._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var n=this._x,r=this._y,i=this._z,a=this._w,o=a*t._w+n*t._x+r*t._y+i*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;var s=1-o*o;if(s<=Number.EPSILON){var c=1-e;return this._w=c*a+e*this._w,this._x=c*n+e*this._x,this._y=c*r+e*this._y,this._z=c*i+e*this._z,this.normalize(),this._onChangeCallback(),this}var l=Math.sqrt(s),u=Math.atan2(l,o),h=Math.sin((1-e)*u)/l,d=Math.sin(e*u)/l;return this._w=a*h+this._w*d,this._x=n*h+this._x*d,this._y=r*h+this._y*d,this._z=i*h+this._z*d,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(){}});var _n=new Sn,Mn=new wn;function Sn(t,e,n){this.x=t||0,this.y=e||0,this.z=n||0}Object.assign(Sn.prototype,{isVector3:!0,set:function(t,e,n){return this.x=t,this.y=e,this.z=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Mn.setFromEuler(t))},applyAxisAngle:function(t,e){return this.applyQuaternion(Mn.setFromAxisAngle(t,e))},applyMatrix3:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*r,this.y=i[1]*e+i[4]*n+i[7]*r,this.z=i[2]*e+i[5]*n+i[8]*r,this},applyMatrix4:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements,a=1/(i[3]*e+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*e+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*e+i[6]*n+i[10]*r+i[14])*a,this},applyQuaternion:function(t){var e=this.x,n=this.y,r=this.z,i=t.x,a=t.y,o=t.z,s=t.w,c=s*e+a*r-o*n,l=s*n+o*e-i*r,u=s*r+i*n-a*e,h=-i*e-a*n-o*r;return this.x=c*s+h*-i+l*-o-u*-a,this.y=l*s+h*-a+u*-i-c*-o,this.z=u*s+h*-o+c*-a-l*-i,this},project:function(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)},unproject:function(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)},transformDirection:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*r,this.y=i[1]*e+i[5]*n+i[9]*r,this.z=i[2]*e+i[6]*n+i[10]*r,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this},clampLength:function(t,e){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},cross:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)},crossVectors:function(t,e){var n=t.x,r=t.y,i=t.z,a=e.x,o=e.y,s=e.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(t){return _n.copy(this).projectOnVector(t),this.sub(_n)},reflect:function(t){return this.sub(_n.copy(t).multiplyScalar(2*this.dot(t)))},angleTo:function(t){var e=Math.sqrt(this.lengthSq()*t.lengthSq());0===e&&console.error("THREE.Vector3: angleTo() can't handle zero length vectors.");var n=this.dot(t)/e;return Math.acos(xn.clamp(n,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)},setFromSphericalCoords:function(t,e,n){var r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this},setFromCylindrical:function(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)},setFromCylindricalCoords:function(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}});var En,An=new Sn;function Tn(){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.assign(Tn.prototype,{isMatrix3:!0,set:function(t,e,n,r,i,a,o,s,c){var l=this.elements;return l[0]=t,l[1]=r,l[2]=o,l[3]=e,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(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(t){for(var e=0,n=t.count;e2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}},Rn=0;function Pn(t,e,n,r,i,a,o,s,c,l){Object.defineProperty(this,"id",{value:Rn++}),this.uuid=xn.generateUUID(),this.name="",this.image=void 0!==t?t:Pn.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:Pn.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:yt,this.wrapT=void 0!==r?r:yt,this.magFilter=void 0!==i?i:Et,this.minFilter=void 0!==a?a:Lt,this.anisotropy=void 0!==c?c:1,this.format=void 0!==o?o:jt,this.type=void 0!==s?s:Pt,this.offset=new bn(0,0),this.repeat=new bn(1,1),this.center=new bn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Tn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==l?l:Oe,this.version=0,this.onUpdate=null}function Cn(t,e,n,r){this.x=t||0,this.y=e||0,this.z=n||0,this.w=void 0!==r?r:1}function On(t,e,n){this.width=t,this.height=e,this.scissor=new Cn(0,0,t,e),this.scissorTest=!1,this.viewport=new Cn(0,0,t,e),n=n||{},this.texture=new Pn(void 0,void 0,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.image={},this.texture.image.width=t,this.texture.image.height=e,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:Et,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 Dn(t,e,n){On.call(this,t,e,n),this.samples=4}Pn.DEFAULT_IMAGE=void 0,Pn.DEFAULT_MAPPING=lt,Pn.prototype=Object.assign(Object.create(vn.prototype),{constructor:Pn,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(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],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var r=this.image;if(void 0===r.uuid&&(r.uuid=xn.generateUUID()),!e&&void 0===t.images[r.uuid]){var i;if(Array.isArray(r)){i=[];for(var a=0,o=r.length;a1)switch(this.wrapS){case gt:t.x=t.x-Math.floor(t.x);break;case yt:t.x=t.x<0?0:1;break;case xt: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 gt:t.y=t.y-Math.floor(t.y);break;case yt:t.y=t.y<0?0:1;break;case xt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}}),Object.defineProperty(Pn.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.defineProperties(Cn.prototype,{width:{get:function(){return this.z},set:function(t){this.z=t}},height:{get:function(){return this.w},set:function(t){this.w=t}}}),Object.assign(Cn.prototype,{isVector4:!0,set:function(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,n=this.y,r=this.z,i=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*e+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*e+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*e+a[7]*n+a[11]*r+a[15]*i,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,n,r,i,a=t.elements,o=a[0],s=a[4],c=a[8],l=a[1],u=a[5],h=a[9],d=a[2],p=a[6],f=a[10];if(Math.abs(s-l)<.01&&Math.abs(c-d)<.01&&Math.abs(h-p)<.01){if(Math.abs(s+l)<.1&&Math.abs(c+d)<.1&&Math.abs(h+p)<.1&&Math.abs(o+u+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(o+1)/2,v=(u+1)/2,g=(f+1)/2,y=(s+l)/4,x=(c+d)/4,b=(h+p)/4;return m>v&&m>g?m<.01?(n=0,r=.707106781,i=.707106781):(r=y/(n=Math.sqrt(m)),i=x/n):v>g?v<.01?(n=.707106781,r=0,i=.707106781):(n=y/(r=Math.sqrt(v)),i=b/r):g<.01?(n=.707106781,r=.707106781,i=0):(n=x/(i=Math.sqrt(g)),r=b/i),this.set(n,r,i,e),this}var w=Math.sqrt((p-h)*(p-h)+(c-d)*(c-d)+(l-s)*(l-s));return Math.abs(w)<.001&&(w=1),this.x=(p-h)/w,this.y=(c-d)/w,this.z=(l-s)/w,this.w=Math.acos((o+u+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(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this},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}}),On.prototype=Object.assign(Object.create(vn.prototype),{constructor:On,isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.texture.image.width=t,this.texture.image.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"})}}),Dn.prototype=Object.assign(Object.create(On.prototype),{constructor:Dn,isWebGLMultisampleRenderTarget:!0,copy:function(t){return On.prototype.copy.call(this,t),this.samples=t.samples,this}});var In=new Sn,Nn=new Hn,Bn=new Sn(0,0,0),Fn=new Sn(1,1,1),zn=new Sn,Un=new Sn,Gn=new Sn;function Hn(){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.")}Object.assign(Hn.prototype,{isMatrix4:!0,set:function(t,e,n,r,i,a,o,s,c,l,u,h,d,p,f,m){var v=this.elements;return v[0]=t,v[4]=e,v[8]=n,v[12]=r,v[1]=i,v[5]=a,v[9]=o,v[13]=s,v[2]=c,v[6]=l,v[10]=u,v[14]=h,v[3]=d,v[7]=p,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 Hn).fromArray(this.elements)},copy:function(t){var e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this},copyPosition:function(t){var e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this},extractBasis:function(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this},extractRotation:function(t){var e=this.elements,n=t.elements,r=1/In.setFromMatrixColumn(t,0).length(),i=1/In.setFromMatrixColumn(t,1).length(),a=1/In.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*i,e[5]=n[5]*i,e[6]=n[6]*i,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,n=t.x,r=t.y,i=t.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){var h=a*l,d=a*u,p=o*l,f=o*u;e[0]=s*l,e[4]=-s*u,e[8]=c,e[1]=d+p*c,e[5]=h-f*c,e[9]=-o*s,e[2]=f-h*c,e[6]=p+d*c,e[10]=a*s}else if("YXZ"===t.order){var m=s*l,v=s*u,g=c*l,y=c*u;e[0]=m+y*o,e[4]=g*o-v,e[8]=a*c,e[1]=a*u,e[5]=a*l,e[9]=-o,e[2]=v*o-g,e[6]=y+m*o,e[10]=a*s}else if("ZXY"===t.order){m=s*l,v=s*u,g=c*l,y=c*u;e[0]=m-y*o,e[4]=-a*u,e[8]=g+v*o,e[1]=v+g*o,e[5]=a*l,e[9]=y-m*o,e[2]=-a*c,e[6]=o,e[10]=a*s}else if("ZYX"===t.order){h=a*l,d=a*u,p=o*l,f=o*u;e[0]=s*l,e[4]=p*c-d,e[8]=h*c+f,e[1]=s*u,e[5]=f*c+h,e[9]=d*c-p,e[2]=-c,e[6]=o*s,e[10]=a*s}else if("YZX"===t.order){var x=a*s,b=a*c,w=o*s,_=o*c;e[0]=s*l,e[4]=_-x*u,e[8]=w*u+b,e[1]=u,e[5]=a*l,e[9]=-o*l,e[2]=-c*l,e[6]=b*u+w,e[10]=x-_*u}else if("XZY"===t.order){x=a*s,b=a*c,w=o*s,_=o*c;e[0]=s*l,e[4]=-u,e[8]=c*l,e[1]=x*u+_,e[5]=a*l,e[9]=b*u-w,e[2]=w*u-b,e[6]=o*l,e[10]=_*u+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){return this.compose(Bn,t,Fn)},lookAt:function(t,e,n){var r=this.elements;return Gn.subVectors(t,e),0===Gn.lengthSq()&&(Gn.z=1),Gn.normalize(),zn.crossVectors(n,Gn),0===zn.lengthSq()&&(1===Math.abs(n.z)?Gn.x+=1e-4:Gn.z+=1e-4,Gn.normalize(),zn.crossVectors(n,Gn)),zn.normalize(),Un.crossVectors(Gn,zn),r[0]=zn.x,r[4]=Un.x,r[8]=Gn.x,r[1]=zn.y,r[5]=Un.y,r[9]=Gn.y,r[2]=zn.z,r[6]=Un.z,r[10]=Gn.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var n=t.elements,r=e.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],v=n[14],g=n[3],y=n[7],x=n[11],b=n[15],w=r[0],_=r[4],M=r[8],S=r[12],E=r[1],A=r[5],T=r[9],L=r[13],R=r[2],P=r[6],C=r[10],O=r[14],D=r[3],I=r[7],N=r[11],B=r[15];return i[0]=a*w+o*E+s*R+c*D,i[4]=a*_+o*A+s*P+c*I,i[8]=a*M+o*T+s*C+c*N,i[12]=a*S+o*L+s*O+c*B,i[1]=l*w+u*E+h*R+d*D,i[5]=l*_+u*A+h*P+d*I,i[9]=l*M+u*T+h*C+d*N,i[13]=l*S+u*L+h*O+d*B,i[2]=p*w+f*E+m*R+v*D,i[6]=p*_+f*A+m*P+v*I,i[10]=p*M+f*T+m*C+v*N,i[14]=p*S+f*L+m*O+v*B,i[3]=g*w+y*E+x*R+b*D,i[7]=g*_+y*A+x*P+b*I,i[11]=g*M+y*T+x*C+b*N,i[15]=g*S+y*L+x*O+b*B,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(t){for(var e=0,n=t.count;e1){for(var e=0;e1){for(var e=0;e0){r.children=[];for(s=0;s0&&(n.geometries=h),d.length>0&&(n.materials=d),p.length>0&&(n.textures=p),f.length>0&&(n.images=f),o.length>0&&(n.shapes=o)}return n.object=r,n;function m(t){var e=[];for(var n in t){var r=t[n];delete r.metadata,e.push(r)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var n=0;ns)return!1}return!0}Object.assign(xr.prototype,{isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,c=t.length;si&&(i=l),u>a&&(a=u),h>o&&(o=h)}return this.min.set(e,n,r),this.max.set(i,a,o),this},setFromBufferAttribute:function(t){for(var e=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,c=t.count;si&&(i=l),u>a&&(a=u),h>o&&(o=h)}return this.min.set(e,n,r),this.max.set(i,a,o),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,n=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new Sn),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:function(t){return this.clampPoint(t.center,cr),cr.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(t){if(this.isEmpty())return!1;this.getCenter(mr),vr.subVectors(this.max,mr),lr.subVectors(t.a,mr),ur.subVectors(t.b,mr),hr.subVectors(t.c,mr),dr.subVectors(ur,lr),pr.subVectors(hr,ur),fr.subVectors(lr,hr);var e=[0,-dr.z,dr.y,0,-pr.z,pr.y,0,-fr.z,fr.y,dr.z,0,-dr.x,pr.z,0,-pr.x,fr.z,0,-fr.x,-dr.y,dr.x,0,-pr.y,pr.x,0,-fr.y,fr.x,0];return!!br(e,lr,ur,hr,vr)&&(!!br(e=[1,0,0,0,1,0,0,0,1],lr,ur,hr,vr)&&(gr.crossVectors(dr,pr),br(e=[gr.x,gr.y,gr.z],lr,ur,hr,vr)))},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new Sn),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return cr.copy(t).clamp(this.min,this.max).sub(t).length()},getBoundingSphere:function(t){return void 0===t&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=.5*this.getSize(cr).length(),t},intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(t){return this.isEmpty()?this:(sr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),sr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),sr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),sr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),sr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),sr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),sr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),sr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(sr),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)}});var wr=new xr;function _r(t,e){this.center=void 0!==t?t:new Sn,this.radius=void 0!==e?e:0}Object.assign(_r.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(t,e){var n=this.center;void 0!==e?n.copy(e):wr.setFromPoints(t).getCenter(n);for(var r=0,i=0,a=t.length;ithis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e},getBoundingBox:function(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new xr),t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}});var Mr=new Sn,Sr=new Sn,Er=new Sn,Ar=new Sn,Tr=new Sn,Lr=new Sn,Rr=new Sn;function Pr(t,e){this.origin=void 0!==t?t:new Sn,this.direction=void 0!==e?e:new Sn}Object.assign(Pr.prototype,{set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return void 0===e&&(console.warn("THREE.Ray: .at() target is now required"),e=new Sn),e.copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(t){return this.origin.copy(this.at(t,Mr)),this},closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new Sn),e.subVectors(t,this.origin);var n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(t){var e=Mr.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Mr.copy(this.direction).multiplyScalar(e).add(this.origin),Mr.distanceToSquared(t))},distanceSqToSegment:function(t,e,n,r){Sr.copy(t).add(e).multiplyScalar(.5),Er.copy(e).sub(t).normalize(),Ar.copy(this.origin).sub(Sr);var i,a,o,s,c=.5*t.distanceTo(e),l=-this.direction.dot(Er),u=Ar.dot(this.direction),h=-Ar.dot(Er),d=Ar.lengthSq(),p=Math.abs(1-l*l);if(p>0)if(a=l*u-h,s=c*p,(i=l*h-u)>=0)if(a>=-s)if(a<=s){var f=1/p;o=(i*=f)*(i+l*(a*=f)+2*u)+a*(l*i+a+2*h)+d}else a=c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;else a=-c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;else a<=-s?o=-(i=Math.max(0,-(-l*c+u)))*i+(a=i>0?-c:Math.min(Math.max(-c,-h),c))*(a+2*h)+d:a<=s?(i=0,o=(a=Math.min(Math.max(-c,-h),c))*(a+2*h)+d):o=-(i=Math.max(0,-(l*c+u)))*i+(a=i>0?c:Math.min(Math.max(-c,-h),c))*(a+2*h)+d;else a=l>0?-c:c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;return n&&n.copy(this.direction).multiplyScalar(i).add(this.origin),r&&r.copy(Er).multiplyScalar(a).add(Sr),o},intersectSphere:function(t,e){Mr.subVectors(t.center,this.origin);var n=Mr.dot(this.direction),r=Mr.dot(Mr)-n*n,i=t.radius*t.radius;if(r>i)return null;var a=Math.sqrt(i-r),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,e):this.at(o,e)},intersectsSphere:function(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null},intersectPlane:function(t,e){var n=this.distanceToPlane(t);return null===n?null:this.at(n,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,h=this.origin;return c>=0?(n=(t.min.x-h.x)*c,r=(t.max.x-h.x)*c):(n=(t.max.x-h.x)*c,r=(t.min.x-h.x)*c),l>=0?(i=(t.min.y-h.y)*l,a=(t.max.y-h.y)*l):(i=(t.max.y-h.y)*l,a=(t.min.y-h.y)*l),n>a||i>r?null:((i>n||n!=n)&&(n=i),(a=0?(o=(t.min.z-h.z)*u,s=(t.max.z-h.z)*u):(o=(t.max.z-h.z)*u,s=(t.min.z-h.z)*u),n>s||o>r?null:((o>n||n!=n)&&(n=o),(s=0?n:r,e)))},intersectsBox:function(t){return null!==this.intersectBox(t,Mr)},intersectTriangle:function(t,e,n,r,i){Tr.subVectors(e,t),Lr.subVectors(n,t),Rr.crossVectors(Tr,Lr);var a,o=this.direction.dot(Rr);if(o>0){if(r)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Ar.subVectors(this.origin,t);var s=a*this.direction.dot(Lr.crossVectors(Ar,Lr));if(s<0)return null;var c=a*this.direction.dot(Tr.cross(Ar));if(c<0)return null;if(s+c>o)return null;var l=-a*Ar.dot(Rr);return l<0?null:this.at(l/o,i)},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)}});var Cr=new Sn,Or=new Sn,Dr=new Tn;function Ir(t,e){this.normal=void 0!==t?t:new Sn(1,0,0),this.constant=void 0!==e?e:0}Object.assign(Ir.prototype,{isPlane:!0,set:function(t,e){return this.normal.copy(t),this.constant=e,this},setComponents:function(t,e,n,r){return this.normal.set(t,e,n),this.constant=r,this},setFromNormalAndCoplanarPoint:function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},setFromCoplanarPoints:function(t,e,n){var r=Cr.subVectors(n,e).cross(Or.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,e){return void 0===e&&(console.warn("THREE.Plane: .projectPoint() target is now required"),e=new Sn),e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)},intersectLine:function(t,e){void 0===e&&(console.warn("THREE.Plane: .intersectLine() target is now required"),e=new Sn);var n=t.delta(Cr),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(t.start)?e.copy(t.start):void 0;var i=-(t.start.dot(this.normal)+this.constant)/r;return i<0||i>1?void 0:e.copy(n).multiplyScalar(i).add(t.start)},intersectsLine:function(t){var e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new Sn),t.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(t,e){var n=e||Dr.getNormalMatrix(t),r=this.coplanarPoint(Cr).applyMatrix4(t),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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}});var Nr=new Sn,Br=new Sn,Fr=new Sn,zr=new Sn,Ur=new Sn,Gr=new Sn,Hr=new Sn,Vr=new Sn,kr=new Sn,jr=new Sn;function Wr(t,e,n){this.a=void 0!==t?t:new Sn,this.b=void 0!==e?e:new Sn,this.c=void 0!==n?n:new Sn}Object.assign(Wr,{getNormal:function(t,e,n,r){void 0===r&&(console.warn("THREE.Triangle: .getNormal() target is now required"),r=new Sn),r.subVectors(n,e),Nr.subVectors(t,e),r.cross(Nr);var i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)},getBarycoord:function(t,e,n,r,i){Nr.subVectors(r,e),Br.subVectors(n,e),Fr.subVectors(t,e);var a=Nr.dot(Nr),o=Nr.dot(Br),s=Nr.dot(Fr),c=Br.dot(Br),l=Br.dot(Fr),u=a*c-o*o;if(void 0===i&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),i=new Sn),0===u)return i.set(-2,-1,-1);var h=1/u,d=(c*s-o*l)*h,p=(a*l-o*s)*h;return i.set(1-d-p,p,d)},containsPoint:function(t,e,n,r){return Wr.getBarycoord(t,e,n,r,zr),zr.x>=0&&zr.y>=0&&zr.x+zr.y<=1},getUV:function(t,e,n,r,i,a,o,s){return this.getBarycoord(t,e,n,r,zr),s.set(0,0),s.addScaledVector(i,zr.x),s.addScaledVector(a,zr.y),s.addScaledVector(o,zr.z),s},isFrontFacing:function(t,e,n,r){return Nr.subVectors(n,e),Br.subVectors(t,e),Nr.cross(Br).dot(r)<0}}),Object.assign(Wr.prototype,{set:function(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this},setFromPointsAndIndices:function(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},getArea:function(){return Nr.subVectors(this.c,this.b),Br.subVectors(this.a,this.b),.5*Nr.cross(Br).length()},getMidpoint:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new Sn),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(t){return Wr.getNormal(this.a,this.b,this.c,t)},getPlane:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new Ir),t.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(t,e){return Wr.getBarycoord(t,this.a,this.b,this.c,e)},getUV:function(t,e,n,r,i){return Wr.getUV(t,this.a,this.b,this.c,e,n,r,i)},containsPoint:function(t){return Wr.containsPoint(t,this.a,this.b,this.c)},isFrontFacing:function(t){return Wr.isFrontFacing(this.a,this.b,this.c,t)},intersectsBox:function(t){return t.intersectsTriangle(this)},closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),e=new Sn);var n,r,i=this.a,a=this.b,o=this.c;Ur.subVectors(a,i),Gr.subVectors(o,i),Vr.subVectors(t,i);var s=Ur.dot(Vr),c=Gr.dot(Vr);if(s<=0&&c<=0)return e.copy(i);kr.subVectors(t,a);var l=Ur.dot(kr),u=Gr.dot(kr);if(l>=0&&u<=l)return e.copy(a);var h=s*u-l*c;if(h<=0&&s>=0&&l<=0)return n=s/(s-l),e.copy(i).addScaledVector(Ur,n);jr.subVectors(t,o);var d=Ur.dot(jr),p=Gr.dot(jr);if(p>=0&&d<=p)return e.copy(o);var f=d*c-s*p;if(f<=0&&c>=0&&p<=0)return r=c/(c-p),e.copy(i).addScaledVector(Gr,r);var m=l*p-d*u;if(m<=0&&u-l>=0&&d-p>=0)return Hr.subVectors(o,a),r=(u-l)/(u-l+(d-p)),e.copy(a).addScaledVector(Hr,r);var v=1/(m+f+h);return n=f*v,r=h*v,e.copy(i).addScaledVector(Ur,n).addScaledVector(Gr,r)},equals:function(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}});var qr={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},Xr={h:0,s:0,l:0},Yr={h:0,s:0,l:0};function Zr(t,e,n){return void 0===e&&void 0===n?this.set(t):this.setRGB(t,e,n)}function Jr(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}function Qr(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Kr(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}function $r(t,e,n,r,i,a){this.a=t,this.b=e,this.c=n,this.normal=r&&r.isVector3?r:new Sn,this.vertexNormals=Array.isArray(r)?r:[],this.color=i&&i.isColor?i:new Zr,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=void 0!==a?a:0}Object.assign(Zr.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(t,e,n){if(t=xn.euclideanModulo(t,1),e=xn.clamp(e,0,1),n=xn.clamp(n,0,1),0===e)this.r=this.g=this.b=n;else{var r=n<=.5?n*(1+e):n+e-n*e,i=2*n-r;this.r=Jr(i,r,t+1/3),this.g=Jr(i,r,t),this.b=Jr(i,r,t-1/3)}return this},setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var n;if(n=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var r,i=n[1],a=n[2];switch(i){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,e(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,e(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return e(r[5]),this.setHSL(o,s,c)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(t)){var l=n[1],u=l.length;if(3===u)return this.r=parseInt(l.charAt(0)+l.charAt(0),16)/255,this.g=parseInt(l.charAt(1)+l.charAt(1),16)/255,this.b=parseInt(l.charAt(2)+l.charAt(2),16)/255,this;if(6===u)return this.r=parseInt(l.charAt(0)+l.charAt(1),16)/255,this.g=parseInt(l.charAt(2)+l.charAt(3),16)/255,this.b=parseInt(l.charAt(4)+l.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this},setColorName:function(t){var e=qr[t];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),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(t){return this.copyGammaToLinear(this,t),this},convertLinearToGamma:function(t){return this.copyLinearToGamma(this,t),this},copySRGBToLinear:function(t){return this.r=Qr(t.r),this.g=Qr(t.g),this.b=Qr(t.b),this},copyLinearToSRGB:function(t){return this.r=Kr(t.r),this.g=Kr(t.g),this.b=Kr(t.b),this},convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});var e,n,r=this.r,i=this.g,a=this.b,o=Math.max(r,i,a),s=Math.min(r,i,a),c=(s+o)/2;if(s===o)e=0,n=0;else{var l=o-s;switch(n=c<=.5?l/(o+s):l/(2-o-s),o){case r:e=(i-a)/l+(ie&&(e=t[n]);return e}ei.prototype=Object.assign(Object.create(vn.prototype),{constructor:ei,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 r=this[e];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=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===x;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 r(t){var e=[];for(var n in t){var r=t[n];delete r.metadata,e.push(r)}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.sheen&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&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.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.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.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),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.normalMapType=this.normalMapType,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,n.refractionRatio=this.refractionRatio,void 0!==this.combine&&(n.combine=this.combine),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity)),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!==E&&(n.blending=this.blending),!0===this.flatShading&&(n.flatShading=this.flatShading),this.side!==v&&(n.side=this.side),this.vertexColors!==w&&(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,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&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.morphNormals&&(n.morphNormals=!0),!0===this.skinning&&(n.skinning=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),e){var i=r(t.textures),a=r(t.images);i.length>0&&(n.textures=i),a.length>0&&(n.images=a)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexTangents=t.vertexTangents,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.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;var e=t.clippingPlanes,n=null;if(null!==e){var r=e.length;n=new Array(r);for(var i=0;i!==r;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,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.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),ni.prototype=Object.create(ei.prototype),ni.prototype.constructor=ni,ni.prototype.isMeshBasicMaterial=!0,ni.prototype.copy=function(t){return ei.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},Object.defineProperty(ri.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(ri.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.itemSize,n*=e.itemSize;for(var r=0,i=this.itemSize;r0,o=i[1]&&i[1].length>0,s=t.morphTargets,c=s.length;if(c>0){e=[];for(var l=0;l0){u=[];for(l=0;l0&&0===n.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(l=0;l65535?ui:ci)(t,1):this.index=t},getAttribute:function(t){return this.attributes[t]},setAttribute:function(t,e){return this.attributes[t]=e,this},deleteAttribute: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 Tn).getNormalMatrix(t).applyToBufferAttribute(n),n.needsUpdate=!0);var r=this.attributes.tangent;void 0!==r&&((new Tn).getNormalMatrix(t).applyToBufferAttribute(r),r.needsUpdate=!0);return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(t){return vi.makeRotationX(t),this.applyMatrix(vi),this},rotateY:function(t){return vi.makeRotationY(t),this.applyMatrix(vi),this},rotateZ:function(t){return vi.makeRotationZ(t),this.applyMatrix(vi),this},translate:function(t,e,n){return vi.makeTranslation(t,e,n),this.applyMatrix(vi),this},scale:function(t,e,n){return vi.makeScale(t,e,n),this.applyMatrix(vi),this},lookAt:function(t){return gi.lookAt(t),gi.updateMatrix(),this.applyMatrix(gi.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(yi).negate(),this.translate(yi.x,yi.y,yi.z),this},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var n=new hi(3*e.vertices.length,3),r=new hi(3*e.colors.length,3);if(this.setAttribute("position",n.copyVector3sArray(e.vertices)),this.setAttribute("color",r.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var i=new hi(e.lineDistances.length,1);this.setAttribute("lineDistance",i.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},setFromPoints:function(t){for(var e=[],n=0,r=t.length;n0){var n=new Float32Array(3*t.normals.length);this.setAttribute("normal",new ri(n,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var r=new Float32Array(3*t.colors.length);this.setAttribute("color",new ri(r,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.setAttribute("uv",new ri(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var a=new Float32Array(2*t.uvs2.length);this.setAttribute("uv2",new ri(a,2).copyVector2sArray(t.uvs2))}for(var o in this.groups=t.groups,t.morphTargets){for(var s=[],c=t.morphTargets[o],l=0,u=c.length;l0){var p=new hi(4*t.skinIndices.length,4);this.setAttribute("skinIndex",p.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var f=new hi(4*t.skinWeights.length,4);this.setAttribute("skinWeight",f.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new xr);var t=this.attributes.position,e=this.morphAttributes.position;if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(var n=0,r=e.length;n0&&(t.userData=this.userData),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 r=this.index;null!==r&&(t.data.index={type:r.array.constructor.name,array:Array.prototype.slice.call(r.array)});var i=this.attributes;for(var n in i){var a=(d=i[n]).toJSON();""!==d.name&&(a.name=d.name),t.data.attributes[n]=a}var o={},s=!1;for(var n in this.morphAttributes){for(var c=this.morphAttributes[n],l=[],u=0,h=c.length;u0&&(o[n]=l,s=!0)}s&&(t.data.morphAttributes=o);var p=this.groups;p.length>0&&(t.data.groups=JSON.parse(JSON.stringify(p)));var f=this.boundingSphere;return null!==f&&(t.data.boundingSphere={center:f.center.toArray(),radius:f.radius}),t},clone:function(){return(new _i).copy(this)},copy:function(t){var e,n,r;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var i=t.index;null!==i&&this.setIndex(i.clone());var a=t.attributes;for(e in a){var o=a[e];this.setAttribute(e,o.clone())}var s=t.morphAttributes;for(e in s){var c=[],l=s[e];for(n=0,r=l.length;nn.far?null:{distance:c,point:Ui.clone(),object:t}}function Vi(t,e,n,r,i,a,o,s,c,l,u){Ai.fromBufferAttribute(i,c),Ti.fromBufferAttribute(i,l),Li.fromBufferAttribute(i,u);var h=t.morphTargetInfluences;if(e.morphTargets&&a&&h){Oi.set(0,0,0),Di.set(0,0,0),Ii.set(0,0,0);for(var d=0,p=a.length;d0){var o=i[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=o.length;t0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(t,e){var n,r=this.geometry,i=this.material,a=this.matrixWorld;if(void 0!==i&&(null===r.boundingSphere&&r.computeBoundingSphere(),Ei.copy(r.boundingSphere),Ei.applyMatrix4(a),!1!==t.ray.intersectsSphere(Ei)&&(Mi.getInverse(a),Si.copy(t.ray).applyMatrix4(Mi),null===r.boundingBox||!1!==Si.intersectsBox(r.boundingBox))))if(this.drawMode===Re){if(r.isBufferGeometry){var o,s,c,l,u,h,d,p,f,m=r.index,v=r.attributes.position,g=r.morphAttributes.position,y=r.attributes.uv,x=r.attributes.uv2,b=r.groups,w=r.drawRange;if(null!==m)if(Array.isArray(i))for(l=0,h=b.length;l0&&(E=R);for(var P=0,C=L.length;P0)for(l=0;l0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,n;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,n,r,i;for(n=0,r=this.faces.length;n=0;n--){var f=d[n];for(this.faces.splice(f,1),o=0,s=this.faceVertexUvs.length;o0,v=p.vertexNormals.length>0,g=1!==p.color.r||1!==p.color.g||1!==p.color.b,y=p.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),o.push(x),o.push(p.a,p.b,p.c),o.push(p.materialIndex),f){var b=this.faceVertexUvs[0][i];o.push(A(b[0]),A(b[1]),A(b[2]))}if(m&&o.push(S(p.normal)),v){var w=p.vertexNormals;o.push(S(w[0]),S(w[1]),S(w[2]))}if(g&&o.push(E(p.color)),y){var _=p.vertexColors;o.push(E(_[0]),E(_[1]),E(_[2]))}}function M(t,e,n){return n?t|1<0&&(t.data.colors=l),h.length>0&&(t.data.uvs=[h]),t.data.faces=o,t},clone:function(){return(new Xi).copy(this)},copy:function(t){var e,n,r,i,a,o;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var s=t.vertices;for(e=0,n=s.length;e0?1:-1,l.push(R.x,R.y,R.z),u.push(y/m),u.push(1-x/v),T+=1}}for(x=0;x0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;var i={};for(var a in this.extensions)!0===this.extensions[a]&&(i[a]=!0);return Object.keys(i).length>0&&(e.extensions=i),e},na.prototype=Object.assign(Object.create(ar.prototype),{constructor:na,isCamera:!0,copy:function(t,e){return ar.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new Sn),this.updateMatrixWorld(!0);var e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()},updateMatrixWorld:function(t){ar.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),ra.prototype=Object.assign(Object.create(na.prototype),{constructor:ra,isPerspectiveCamera:!0,copy:function(t,e){return na.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*xn.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){var t=Math.tan(.5*xn.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*xn.RAD2DEG*Math.atan(Math.tan(.5*xn.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,r,i,a){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=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=this.near,e=t*Math.tan(.5*xn.DEG2RAD*this.fov)/this.zoom,n=2*e,r=this.aspect*n,i=-.5*r,a=this.view;if(null!==this.view&&this.view.enabled){var o=a.fullWidth,s=a.fullHeight;i+=a.offsetX*r/o,e-=a.offsetY*n/s,r*=a.width/o,n*=a.height/s}var c=this.filmOffset;0!==c&&(i+=t*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,e,e-n,t,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(t){var e=ar.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}});var ia=90,aa=1;function oa(t,e,n,r){ar.call(this),this.type="CubeCamera";var i=new ra(ia,aa,t,e);i.up.set(0,-1,0),i.lookAt(new Sn(1,0,0)),this.add(i);var a=new ra(ia,aa,t,e);a.up.set(0,-1,0),a.lookAt(new Sn(-1,0,0)),this.add(a);var o=new ra(ia,aa,t,e);o.up.set(0,0,1),o.lookAt(new Sn(0,1,0)),this.add(o);var s=new ra(ia,aa,t,e);s.up.set(0,0,-1),s.lookAt(new Sn(0,-1,0)),this.add(s);var c=new ra(ia,aa,t,e);c.up.set(0,-1,0),c.lookAt(new Sn(0,0,1)),this.add(c);var l=new ra(ia,aa,t,e);l.up.set(0,-1,0),l.lookAt(new Sn(0,0,-1)),this.add(l),r=r||{format:kt,magFilter:Et,minFilter:Et},this.renderTarget=new sa(n,n,r),this.renderTarget.texture.name="CubeCamera",this.update=function(t,e){null===this.parent&&this.updateMatrixWorld();var n=t.getRenderTarget(),r=this.renderTarget,u=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,t.setRenderTarget(r,0),t.render(e,i),t.setRenderTarget(r,1),t.render(e,a),t.setRenderTarget(r,2),t.render(e,o),t.setRenderTarget(r,3),t.render(e,s),t.setRenderTarget(r,4),t.render(e,c),r.texture.generateMipmaps=u,t.setRenderTarget(r,5),t.render(e,l),t.setRenderTarget(n)},this.clear=function(t,e,n,r){for(var i=t.getRenderTarget(),a=this.renderTarget,o=0;o<6;o++)t.setRenderTarget(a,o),t.clear(e,n,r);t.setRenderTarget(i)}}function sa(t,e,n){On.call(this,t,e,n)}function ca(t,e,n,r,i,a,o,s,c,l,u,h){Pn.call(this,null,a,o,s,c,l,r,i,u,h),this.image={data:t||null,width:e||1,height:n||1},this.magFilter=void 0!==c?c:bt,this.minFilter=void 0!==l?l:bt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}oa.prototype=Object.create(ar.prototype),oa.prototype.constructor=oa,sa.prototype=Object.create(On.prototype),sa.prototype.constructor=sa,sa.prototype.isWebGLRenderTargetCube=!0,sa.prototype.fromEquirectangularTexture=function(t,e){this.texture.type=e.type,this.texture.format=e.format,this.texture.encoding=e.encoding;var n=new or,r={uniforms:{tEquirect:{value:null}},vertexShader:["varying vec3 vWorldDirection;","vec3 transformDirection( in vec3 dir, in mat4 matrix ) {","\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );","}","void main() {","\tvWorldDirection = transformDirection( position, modelMatrix );","\t#include ","\t#include ","}"].join("\n"),fragmentShader:["uniform sampler2D tEquirect;","varying vec3 vWorldDirection;","#define RECIPROCAL_PI 0.31830988618","#define RECIPROCAL_PI2 0.15915494","void main() {","\tvec3 direction = normalize( vWorldDirection );","\tvec2 sampleUV;","\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;","\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;","\tgl_FragColor = texture2D( tEquirect, sampleUV );","}"].join("\n")},i=new ea({type:"CubemapFromEquirect",uniforms:Ji(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:g,blending:S});i.uniforms.tEquirect.value=e;var a=new Gi(new Zi(5,5,5),i);n.add(a);var o=new oa(1,10,1);return o.renderTarget=this,o.renderTarget.texture.name="CubeCameraTexture",o.update(t,n),a.geometry.dispose(),a.material.dispose(),this},ca.prototype=Object.create(Pn.prototype),ca.prototype.constructor=ca,ca.prototype.isDataTexture=!0;var la=new _r,ua=new Sn;function ha(t,e,n,r,i,a){this.planes=[void 0!==t?t:new Ir,void 0!==e?e:new Ir,void 0!==n?n:new Ir,void 0!==r?r:new Ir,void 0!==i?i:new Ir,void 0!==a?a:new Ir]}Object.assign(ha.prototype,{set:function(t,e,n,r,i,a){var o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,n=0;n<6;n++)e[n].copy(t.planes[n]);return this},setFromMatrix:function(t){var e=this.planes,n=t.elements,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7],h=n[8],d=n[9],p=n[10],f=n[11],m=n[12],v=n[13],g=n[14],y=n[15];return e[0].setComponents(o-r,u-s,f-h,y-m).normalize(),e[1].setComponents(o+r,u+s,f+h,y+m).normalize(),e[2].setComponents(o+i,u+c,f+d,y+v).normalize(),e[3].setComponents(o-i,u-c,f-d,y-v).normalize(),e[4].setComponents(o-a,u-l,f-p,y-g).normalize(),e[5].setComponents(o+a,u+l,f+p,y+g).normalize(),this},intersectsObject:function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),la.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(la)},intersectsSprite:function(t){return la.center.set(0,0,0),la.radius=.7071067811865476,la.applyMatrix4(t.matrixWorld),this.intersectsSphere(la)},intersectsSphere:function(t){for(var e=this.planes,n=t.center,r=-t.radius,i=0;i<6;i++){if(e[i].distanceToPoint(n)0?t.max.x:t.min.x,ua.y=r.normal.y>0?t.max.y:t.min.y,ua.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(ua)<0)return!1}return!0},containsPoint:function(t){for(var e=this.planes,n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}});var da={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",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",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",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#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\ttransformedNormal = mat3( instanceMatrix ) * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = normalMatrix * objectTangent;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_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",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, roughness );\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",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) { \n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",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",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",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif",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 = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\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\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\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",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",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)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = saturate( clearcoat );\tmaterial.clearcoatRoughness = clamp( clearcoatRoughness, 0.04, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 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#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? 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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? 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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? 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 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",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",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",normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, normalScale, normalMap );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec2 normalScale, in sampler2D normalMap ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy *= normalScale;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tbool frontFacing = dot( cross( S, T ), N ) > 0.0;\n\t\t\tmapN.xy *= ( float( frontFacing ) * 2.0 - 1.0 );\n\t\t#else\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, clearcoatNormal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = clearcoatNormalScale * mapN.xy;\n\t\tclearcoatNormal = normalize( vTBN * mapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatNormalScale, clearcoatNormalMap );\n\t#endif\n#endif",clearcoat_normalmap_pars_fragment:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 encodeHalfRGBA ( vec2 v ) {\n\tvec4 encoded = vec4( 0.0 );\n\tconst vec2 offset = vec2( 1.0 / 255.0, 0.0 );\n\tencoded.xy = vec2( v.x, fract( v.x * 255.0 ) );\n\tencoded.xy = encoded.xy - ( encoded.yy * offset );\n\tencoded.zw = vec2( v.y, fract( v.y * 255.0 ) );\n\tencoded.zw = encoded.zw - ( encoded.ww * offset );\n\treturn encoded;\n}\nvec2 decodeHalfRGBA( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn decodeHalfRGBA( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat 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 ) + 0.5 ) * texelSize;\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\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat 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#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? 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}",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 highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",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",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",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\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\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 = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}",shadow_vert:"#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"},pa={common:{diffuse:{value:new Zr(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Tn},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},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 bn(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 Zr(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{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 Zr(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Tn}},sprite:{diffuse:{value:new Zr(15658734)},opacity:{value:1},center:{value:new bn(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Tn}}},fa={basic:{uniforms:Qi([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.fog]),vertexShader:da.meshbasic_vert,fragmentShader:da.meshbasic_frag},lambert:{uniforms:Qi([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.fog,pa.lights,{emissive:{value:new Zr(0)}}]),vertexShader:da.meshlambert_vert,fragmentShader:da.meshlambert_frag},phong:{uniforms:Qi([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.gradientmap,pa.fog,pa.lights,{emissive:{value:new Zr(0)},specular:{value:new Zr(1118481)},shininess:{value:30}}]),vertexShader:da.meshphong_vert,fragmentShader:da.meshphong_frag},standard:{uniforms:Qi([pa.common,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.roughnessmap,pa.metalnessmap,pa.fog,pa.lights,{emissive:{value:new Zr(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:da.meshphysical_vert,fragmentShader:da.meshphysical_frag},matcap:{uniforms:Qi([pa.common,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.fog,{matcap:{value:null}}]),vertexShader:da.meshmatcap_vert,fragmentShader:da.meshmatcap_frag},points:{uniforms:Qi([pa.points,pa.fog]),vertexShader:da.points_vert,fragmentShader:da.points_frag},dashed:{uniforms:Qi([pa.common,pa.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:da.linedashed_vert,fragmentShader:da.linedashed_frag},depth:{uniforms:Qi([pa.common,pa.displacementmap]),vertexShader:da.depth_vert,fragmentShader:da.depth_frag},normal:{uniforms:Qi([pa.common,pa.bumpmap,pa.normalmap,pa.displacementmap,{opacity:{value:1}}]),vertexShader:da.normal_vert,fragmentShader:da.normal_frag},sprite:{uniforms:Qi([pa.sprite,pa.fog]),vertexShader:da.sprite_vert,fragmentShader:da.sprite_frag},background:{uniforms:{uvTransform:{value:new Tn},t2D:{value:null}},vertexShader:da.background_vert,fragmentShader:da.background_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:da.cube_vert,fragmentShader:da.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:da.equirect_vert,fragmentShader:da.equirect_frag},distanceRGBA:{uniforms:Qi([pa.common,pa.displacementmap,{referencePosition:{value:new Sn},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:da.distanceRGBA_vert,fragmentShader:da.distanceRGBA_frag},shadow:{uniforms:Qi([pa.lights,pa.fog,{color:{value:new Zr(0)},opacity:{value:1}}]),vertexShader:da.shadow_vert,fragmentShader:da.shadow_frag}};function ma(){var t=null,e=!1,n=null;function r(i,a){!1!==e&&(n(i,a),t.requestAnimationFrame(r))}return{start:function(){!0!==e&&null!==n&&(t.requestAnimationFrame(r),e=!0)},stop:function(){e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function va(t){var e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);var r=e.get(n);r&&(t.deleteBuffer(r.buffer),e.delete(n))},update:function(n,r){n.isInterleavedBufferAttribute&&(n=n.data);var i=e.get(n);void 0===i?e.set(n,function(e,n){var r=e.array,i=e.usage,a=t.createBuffer();t.bindBuffer(n,a),t.bufferData(n,r,i),e.onUploadCallback();var o=5126;return r instanceof Float32Array?o=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?o=5123:r instanceof Int16Array?o=5122:r instanceof Uint32Array?o=5125:r instanceof Int32Array?o=5124:r instanceof Int8Array?o=5120:r instanceof Uint8Array&&(o=5121),{buffer:a,type:o,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version}}(n,r)):i.version0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}var a="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext,o=void 0!==n.precision?n.precision:"highp",s=i(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);var c=!0===n.logarithmicDepthBuffer,l=t.getParameter(34930),u=t.getParameter(35660),h=t.getParameter(3379),d=t.getParameter(34076),p=t.getParameter(34921),f=t.getParameter(36347),m=t.getParameter(36348),v=t.getParameter(36349),g=u>0,y=a||!!e.get("OES_texture_float");return{isWebGL2:a,getMaxAnisotropy:function(){if(void 0!==r)return r;var n=e.get("EXT_texture_filter_anisotropic");return r=null!==n?t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:c,maxTextures:l,maxVertexTextures:u,maxTextureSize:h,maxCubemapSize:d,maxAttributes:p,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:v,vertexTextures:g,floatFragmentTextures:y,floatVertexTextures:g&&y,maxSamples:a?t.getParameter(36183):0}}function _a(){var t=this,e=null,n=0,r=!1,i=!1,a=new Ir,o=new Tn,s={value:null,needsUpdate:!1};function c(){s.value!==e&&(s.value=e,s.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function l(e,n,r,i){var c=null!==e?e.length:0,l=null;if(0!==c){if(l=s.value,!0!==i||null===l){var u=r+4*c,h=n.matrixWorldInverse;o.getNormalMatrix(h),(null===l||l.length65535?ui:ci)(n,1);p.version=o,e.update(p,34963);var f=i.get(t);f&&e.remove(f),i.set(t,p)}return{get:function(t,e){var i=r.get(e);return i||(e.addEventListener("dispose",a),e.isBufferGeometry?i=e:e.isGeometry&&(void 0===e._bufferGeometry&&(e._bufferGeometry=(new _i).setFromObject(t)),i=e._bufferGeometry),r.set(e,i),n.memory.geometries++,i)},update:function(t){var n=t.index,r=t.attributes;for(var i in null!==n&&e.update(n,34963),r)e.update(r[i],34962);var a=t.morphAttributes;for(var i in a)for(var o=a[i],s=0,c=o.length;s0)return t;var i=e*n,a=Fa[i];if(void 0===a&&(a=new Float32Array(i),Fa[i]=a),0!==e){r.toArray(a,0);for(var o=1,s=0;o!==e;++o)s+=n,t[o].toArray(a,s)}return a}function ka(t,e){if(t.length!==e.length)return!1;for(var n=0,r=t.length;n/gm;function zo(t){return t.replace(Fo,Uo)}function Uo(t,e){var n=da[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return zo(n)}var Go=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;function Ho(t){return t.replace(Go,Vo)}function Vo(t,e,n,r){for(var i="",a=parseInt(e);a0?t.gammaFactor:1,M=a.isWebGL2?"":function(t,e,n){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||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(Io).join("\n")}(r.extensions,a,e),S=function(t){var e=[];for(var n in t){var r=t[n];!1!==r&&e.push("#define "+n+" "+r)}return e.join("\n")}(d),E=h.createProgram(),A=a.numMultiviewViews;if(r.isRawShaderMaterial?((o=[S].filter(Io).join("\n")).length>0&&(o+="\n"),(s=[M,S].filter(Io).join("\n")).length>0&&(s+="\n")):(o=[ko(a),"#define SHADER_NAME "+i.name,S,a.instancing?"#define USE_INSTANCING":"",a.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+_,"#define MAX_BONES "+a.maxBones,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp2?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+b:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.normalMap&&a.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",a.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",a.displacementMap&&a.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.vertexTangents?"#define USE_TANGENT":"",a.vertexColors?"#define USE_COLOR":"",a.vertexUvs?"#define USE_UV":"",a.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",a.flatShading?"#define FLAT_SHADED":"",a.skinning?"#define USE_SKINNING":"",a.useVertexTexture?"#define BONE_TEXTURE":"",a.morphTargets?"#define USE_MORPHTARGETS":"",a.morphNormals&&!1===a.flatShading?"#define USE_MORPHNORMALS":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+y:"",a.sizeAttenuation?"#define USE_SIZEATTENUATION":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(a.isWebGL2||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;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Io).join("\n"),s=[M,ko(a),"#define SHADER_NAME "+i.name,S,a.alphaTest?"#define ALPHATEST "+a.alphaTest+(a.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+_,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp2?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.matcap?"#define USE_MATCAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+x:"",a.envMap?"#define "+b:"",a.envMap?"#define "+w:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.normalMap&&a.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",a.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.sheen?"#define USE_SHEEN":"",a.vertexTangents?"#define USE_TANGENT":"",a.vertexColors?"#define USE_COLOR":"",a.vertexUvs?"#define USE_UV":"",a.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",a.gradientMap?"#define USE_GRADIENTMAP":"",a.flatShading?"#define FLAT_SHADED":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+y:"",a.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",a.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(a.isWebGL2||e.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",(r.extensions&&r.extensions.shaderTextureLOD||a.envMap)&&(a.isWebGL2||e.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",a.toneMapping!==rt?"#define TONE_MAPPING":"",a.toneMapping!==rt?da.tonemapping_pars_fragment:"",a.toneMapping!==rt?Do("toneMapping",a.toneMapping):"",a.dithering?"#define DITHERING":"",a.outputEncoding||a.mapEncoding||a.matcapEncoding||a.envMapEncoding||a.emissiveMapEncoding?da.encodings_pars_fragment:"",a.mapEncoding?Oo("mapTexelToLinear",a.mapEncoding):"",a.matcapEncoding?Oo("matcapTexelToLinear",a.matcapEncoding):"",a.envMapEncoding?Oo("envMapTexelToLinear",a.envMapEncoding):"",a.emissiveMapEncoding?Oo("emissiveMapTexelToLinear",a.emissiveMapEncoding):"",a.outputEncoding?(c="linearToOutputTexel",l=a.outputEncoding,u=Po(l),"vec4 "+c+"( vec4 value ) { return LinearTo"+u[0]+u[1]+"; }"):"",a.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(Io).join("\n")),v=Bo(v=No(v=zo(v),a),a),g=Bo(g=No(g=zo(g),a),a),v=Ho(v),g=Ho(g),a.isWebGL2&&!r.isRawShaderMaterial){var T=!1,L=/^\s*#version\s+300\s+es\s*\n/;r.isShaderMaterial&&null!==v.match(L)&&null!==g.match(L)&&(T=!0,v=v.replace(L,""),g=g.replace(L,"")),o=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+o,s=["#version 300 es\n","#define varying in",T?"":"out highp vec4 pc_fragColor;",T?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+s,A>0&&(o=(o=o.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","layout(num_views = "+A+") in;","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join("\n"),["uniform mat4 modelViewMatrices["+A+"];","uniform mat4 projectionMatrices["+A+"];","uniform mat4 viewMatrices["+A+"];","uniform mat3 normalMatrices["+A+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join("\n")),s=(s=s.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+A+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join("\n")))}var R,P,C=s+g,O=Lo(h,35633,o+v),D=Lo(h,35632,C);if(h.attachShader(E,O),h.attachShader(E,D),void 0!==r.index0AttributeName?h.bindAttribLocation(E,0,r.index0AttributeName):!0===a.morphTargets&&h.bindAttribLocation(E,0,"position"),h.linkProgram(E),t.debug.checkShaderErrors){var I=h.getProgramInfoLog(E).trim(),N=h.getShaderInfoLog(O).trim(),B=h.getShaderInfoLog(D).trim(),F=!0,z=!0;if(!1===h.getProgramParameter(E,35714)){F=!1;var U=Co(h,O,"vertex"),G=Co(h,D,"fragment");console.error("THREE.WebGLProgram: shader error: ",h.getError(),"35715",h.getProgramParameter(E,35715),"gl.getProgramInfoLog",I,U,G)}else""!==I?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",I):""!==N&&""!==B||(z=!1);z&&(this.diagnostics={runnable:F,material:r,programLog:I,vertexShader:{log:N,prefix:o},fragmentShader:{log:B,prefix:s}})}return h.deleteShader(O),h.deleteShader(D),this.getUniforms=function(){return void 0===R&&(R=new To(h,E)),R},this.getAttributes=function(){return void 0===P&&(P=function(t,e){for(var n={},r=t.getProgramParameter(e,35721),i=0;i0,maxBones:b,useVertexTexture:o,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:r.directional.length,numPointLights:r.point.length,numSpotLights:r.spot.length,numRectAreaLights:r.rectArea.length,numHemiLights:r.hemi.length,numDirLightShadows:r.directionalShadowMap.length,numPointLightShadows:r.pointShadowMap.length,numSpotLightShadows:r.spotShadowMap.length,numClippingPlanes:f,numClipIntersection:m,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.length>0,shadowMapType:t.shadowMap.type,toneMapping:e.toneMapped?t.toneMapping:rt,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===y,flipSided:e.side===g,depthPacking:void 0!==e.depthPacking&&e.depthPacking}},this.getProgramCacheKey=function(e,n){var r=[];if(n.shaderID?r.push(n.shaderID):(r.push(e.fragmentShader),r.push(e.vertexShader)),void 0!==e.defines)for(var i in e.defines)r.push(i),r.push(e.defines[i]);for(var a=0;a1&&n.sort(Xo),r.length>1&&r.sort(Yo)}}}function Jo(){var t=new WeakMap;function e(n){var r=n.target;r.removeEventListener("dispose",e),t.delete(r)}return{get:function(n,r){var i,a=t.get(n);return void 0===a?(i=new Zo,t.set(n,new WeakMap),t.get(n).set(r,i),n.addEventListener("dispose",e)):void 0===(i=a.get(r))&&(i=new Zo,a.set(r,i)),i},dispose:function(){t=new WeakMap}}}function Qo(){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 Sn,color:new Zr,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new bn};break;case"SpotLight":n={position:new Sn,direction:new Sn,color:new Zr,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new bn};break;case"PointLight":n={position:new Sn,color:new Zr,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new bn,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":n={direction:new Sn,skyColor:new Zr,groundColor:new Zr};break;case"RectAreaLight":n={color:new Zr,position:new Sn,halfWidth:new Sn,halfHeight:new Sn}}return t[e.id]=n,n}}}var Ko=0;function $o(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function ts(){for(var t=new Qo,e={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},n=0;n<9;n++)e.probe.push(new Sn);var r=new Sn,i=new Hn,a=new Hn;return{setup:function(n,o,s){for(var c=0,l=0,u=0,h=0;h<9;h++)e.probe[h].set(0,0,0);var d=0,p=0,f=0,m=0,v=0,g=0,y=0,x=0,b=s.matrixWorldInverse;n.sort($o),h=0;for(var w=n.length;h0:!0===s.isGeometry&&(p=s.morphTargets&&s.morphTargets.length>0));var f=!1;!0===e.isSkinnedMesh&&(!0===n.skinning?f=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e)),c=h(p,f,!0===e.isInstancedMesh)}else c=d;if(t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var v=c.uuid,g=n.uuid,y=l[v];void 0===y&&(y={},l[v]=y);var x=y[g];void 0===x&&(x=c.clone(),y[g]=x),c=x}return c.visible=n.visible,c.wireframe=n.wireframe,c.side=o===m?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],c.clipShadows=n.clipShadows,c.clippingPlanes=n.clippingPlanes,c.clipIntersection=n.clipIntersection,c.wireframeLinewidth=n.wireframeLinewidth,c.linewidth=n.linewidth,!0===r.isPointLight&&!0===c.isMeshDistanceMaterial&&(c.referencePosition.setFromMatrixPosition(r.matrixWorld),c.nearDistance=i,c.farDistance=a),c}function A(n,i,a,o,s){if(!1!==n.visible){if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===m)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);var c=e.update(n),l=n.material;if(Array.isArray(l))for(var u=c.groups,h=0,d=u.length;hn||i.y>n)&&(console.warn("THREE.WebGLShadowMap:",v,"has shadow exceeding max texture size, reducing"),i.x>n&&(a.x=Math.floor(n/y.x),i.x=a.x*y.x,g.mapSize.x=a.x),i.y>n&&(a.y=Math.floor(n/y.y),i.y=a.y*y.y,g.mapSize.y=a.y)),null===g.map&&!g.isPointLightShadow&&this.type===m){var x={minFilter:Et,magFilter:Et,format:jt};g.map=new On(i.x,i.y,x),g.map.texture.name=v.name+".shadowMap",g.mapPass=new On(i.x,i.y,x),g.camera.updateProjectionMatrix()}if(null===g.map){x={minFilter:bt,magFilter:bt,format:jt};g.map=new On(i.x,i.y,x),g.map.texture.name=v.name+".shadowMap",g.camera.updateProjectionMatrix()}t.setRenderTarget(g.map),t.clear();for(var _=g.getViewportCount(),M=0;M<_;M++){var E=g.getViewport(M);o.set(a.x*E.x,a.y*E.y,a.x*E.z,a.y*E.w),d.viewport(o),g.updateMatrices(v,M),r=g.getFrustum(),A(s,c,g.camera,v,this.type)}g.isPointLightShadow||this.type!==m||w(g,c)}else console.warn("THREE.WebGLShadowMap:",v,"has no shadow.")}b.needsUpdate=!1,t.setRenderTarget(l,u,h)}}}function cs(t,e,n){var r=n.isWebGL2;var i=new function(){var e=!1,n=new Cn,r=null,i=new Cn(0,0,0,0);return{setMask:function(n){r===n||e||(t.colorMask(n,n,n,n),r=n)},setLocked:function(t){e=t},setClear:function(e,r,a,o,s){!0===s&&(e*=o,r*=o,a*=o),n.set(e,r,a,o),!1===i.equals(n)&&(t.clearColor(e,r,a,o),i.copy(n))},reset:function(){e=!1,r=null,i.set(-1,0,0,0)}}},a=new function(){var e=!1,n=null,r=null,i=null;return{setTest:function(t){t?xt(2929):bt(2929)},setMask:function(r){n===r||e||(t.depthMask(r),n=r)},setFunc:function(e){if(r!==e){if(e)switch(e){case q:t.depthFunc(512);break;case X:t.depthFunc(519);break;case Y:t.depthFunc(513);break;case Z:t.depthFunc(515);break;case J:t.depthFunc(514);break;case Q:t.depthFunc(518);break;case K:t.depthFunc(516);break;case $:t.depthFunc(517);break;default:t.depthFunc(515)}else t.depthFunc(515);r=e}},setLocked:function(t){e=t},setClear:function(e){i!==e&&(t.clearDepth(e),i=e)},reset:function(){e=!1,n=null,r=null,i=null}}},l=new function(){var e=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null;return{setTest:function(t){e||(t?xt(2960):bt(2960))},setMask:function(r){n===r||e||(t.stencilMask(r),n=r)},setFunc:function(e,n,o){r===e&&i===n&&a===o||(t.stencilFunc(e,n,o),r=e,i=n,a=o)},setOp:function(e,n,r){o===e&&s===n&&c===r||(t.stencilOp(e,n,r),o=e,s=n,c=r)},setLocked:function(t){e=t},setClear:function(e){l!==e&&(t.clearStencil(e),l=e)},reset:function(){e=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null}}},u=t.getParameter(34921),h=new Uint8Array(u),d=new Uint8Array(u),p=new Uint8Array(u),f={},m=null,v=null,x=null,b=null,w=null,_=null,M=null,tt=null,et=null,nt=!1,rt=null,it=null,at=null,ot=null,st=null,ct=t.getParameter(35661),lt=!1,ut=0,ht=t.getParameter(7938);-1!==ht.indexOf("WebGL")?(ut=parseFloat(/^WebGL\ ([0-9])/.exec(ht)[1]),lt=ut>=1):-1!==ht.indexOf("OpenGL ES")&&(ut=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(ht)[1]),lt=ut>=2);var dt=null,pt={},ft=new Cn,mt=new Cn;function vt(e,n,r){var i=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(var o=0;or||t.height>r)&&(i=r/Math.max(t.width,t.height)),i<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){var a=e?xn.floorPowerOfTwo:Math.floor,o=a(i*t.width),c=a(i*t.height);void 0===s&&(s=m(o,c));var l=n?m(o,c):s;return l.width=o,l.height=c,l.getContext("2d").drawImage(t,0,0,o,c),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+o+"x"+c+")."),l}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function g(t){return xn.isPowerOfTwo(t.width)&&xn.isPowerOfTwo(t.height)}function y(t,e){return t.generateMipmaps&&e&&t.minFilter!==bt&&t.minFilter!==Et}function x(e,n,i,a){t.generateMipmap(e),r.get(n).__maxMipLevel=Math.log(Math.max(i,a))*Math.LOG2E}function b(t,n){if(!1===c)return t;var r=t;return 6403===t&&(5126===n&&(r=33326),5131===n&&(r=33325),5121===n&&(r=33321)),6407===t&&(5126===n&&(r=34837),5131===n&&(r=34843),5121===n&&(r=32849)),6408===t&&(5126===n&&(r=34836),5131===n&&(r=34842),5121===n&&(r=32856)),33325===r||33326===r||34842===r||34836===r?e.get("EXT_color_buffer_float"):34843!==r&&34837!==r||console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead."),r}function w(t){return t===bt||t===wt||t===Mt?9728:9729}function _(e){var n=e.target;n.removeEventListener("dispose",_),function(e){var n=r.get(e);if(void 0===n.__webglInit)return;t.deleteTexture(n.__webglTexture),r.remove(e)}(n),n.isVideoTexture&&p.delete(n),o.memory.textures--}function M(e){var n=e.target;n.removeEventListener("dispose",M),function(e){var n=r.get(e),i=r.get(e.texture);if(!e)return;void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLRenderTargetCube)for(var a=0;a<6;a++)t.deleteFramebuffer(n.__webglFramebuffer[a]),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer[a]);else t.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer);if(e.isWebGLMultiviewRenderTarget){t.deleteTexture(n.__webglColorTexture),t.deleteTexture(n.__webglDepthStencilTexture),o.memory.textures-=2;a=0;for(var s=n.__webglViewFramebuffers.length;a0&&i.__version!==t.version){var a=t.image;if(void 0===a)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==a.complete)return void O(i,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+e),n.bindTexture(3553,i.__webglTexture)}function A(e,i){if(6===e.image.length){var o=r.get(e);if(e.version>0&&o.__version!==e.version){C(o,e),n.activeTexture(33984+i),n.bindTexture(34067,o.__webglTexture),t.pixelStorei(37440,e.flipY);for(var s=e&&e.isCompressedTexture,l=e.image[0]&&e.image[0].isDataTexture,h=[],d=0;d<6;d++)h[d]=s||l?l?e.image[d].image:e.image[d]:v(e.image[d],!1,!0,u);var p,f=h[0],m=g(f)||c,w=a.convert(e.format),_=a.convert(e.type),M=b(w,_);if(P(34067,e,m),s){for(d=0;d<6;d++){p=h[d].mipmaps;for(var S=0;S1||r.get(a).__currentAnisotropy)&&(t.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function C(e,n){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",_),e.__webglTexture=t.createTexture(),o.memory.textures++)}function O(e,r,i){var o=3553;r.isDataTexture2DArray&&(o=35866),r.isDataTexture3D&&(o=32879),C(e,r),n.activeTexture(33984+i),n.bindTexture(o,e.__webglTexture),t.pixelStorei(37440,r.flipY),t.pixelStorei(37441,r.premultiplyAlpha),t.pixelStorei(3317,r.unpackAlignment);var s=function(t){return!c&&(t.wrapS!==yt||t.wrapT!==yt||t.minFilter!==bt&&t.minFilter!==Et)}(r)&&!1===g(r.image),l=v(r.image,s,!1,h),u=g(l)||c,d=a.convert(r.format),p=a.convert(r.type),f=b(d,p);P(o,r,u);var m,w=r.mipmaps;if(r.isDepthTexture){if(f=6402,r.type===Bt){if(!1===c)throw new Error("Float Depth Texture only supported in WebGL2.0");f=36012}else c&&(f=33189);r.format===Yt&&6402===f&&r.type!==Dt&&r.type!==Nt&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Dt,p=a.convert(r.type)),r.format===Zt&&(f=34041,r.type!==Ht&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=Ht,p=a.convert(r.type))),n.texImage2D(3553,0,f,l.width,l.height,0,d,p,null)}else if(r.isDataTexture)if(w.length>0&&u){for(var _=0,M=w.length;_0&&u){for(_=0,M=w.length;_=l&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+l),S+=1,t},this.resetTextureUnits=function(){S=0},this.setTexture2D=E,this.setTexture2DArray=function(t,e){var i=r.get(t);t.version>0&&i.__version!==t.version?O(i,t,e):(n.activeTexture(33984+e),n.bindTexture(35866,i.__webglTexture))},this.setTexture3D=function(t,e){var i=r.get(t);t.version>0&&i.__version!==t.version?O(i,t,e):(n.activeTexture(33984+e),n.bindTexture(32879,i.__webglTexture))},this.setTextureCube=A,this.setTextureCubeDynamic=T,this.setupRenderTarget=function(i){var s=r.get(i),l=r.get(i.texture);i.addEventListener("dispose",M),l.__webglTexture=t.createTexture(),o.memory.textures++;var u=!0===i.isWebGLRenderTargetCube,h=!0===i.isWebGLMultisampleRenderTarget,d=!0===i.isWebGLMultiviewRenderTarget,p=g(i)||c;if(u){s.__webglFramebuffer=[];for(var f=0;f<6;f++)s.__webglFramebuffer[f]=t.createFramebuffer()}else if(s.__webglFramebuffer=t.createFramebuffer(),h)if(c){s.__webglMultisampledFramebuffer=t.createFramebuffer(),s.__webglColorRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,s.__webglColorRenderbuffer);var m=b(a.convert(i.texture.format),a.convert(i.texture.type)),v=B(i);t.renderbufferStorageMultisample(36161,v,m,i.width,i.height),t.bindFramebuffer(36160,s.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(36160,36064,36161,s.__webglColorRenderbuffer),t.bindRenderbuffer(36161,null),i.depthBuffer&&(s.__webglDepthRenderbuffer=t.createRenderbuffer(),I(s.__webglDepthRenderbuffer,i,!0)),t.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");else if(d){var w=i.width,_=i.height,S=i.numViews;t.bindFramebuffer(36160,s.__webglFramebuffer);var E=e.get("OVR_multiview2");o.memory.textures+=2;var A=t.createTexture();t.bindTexture(35866,A),t.texParameteri(35866,10240,9728),t.texParameteri(35866,10241,9728),t.texImage3D(35866,0,32856,w,_,S,0,6408,5121,null),E.framebufferTextureMultiviewOVR(36160,36064,A,0,0,S);var T=t.createTexture();t.bindTexture(35866,T),t.texParameteri(35866,10240,9728),t.texParameteri(35866,10241,9728),t.texImage3D(35866,0,35056,w,_,S,0,34041,34042,null),E.framebufferTextureMultiviewOVR(36160,33306,T,0,0,S);var L=new Array(S);for(f=0;fd)return!1;for(var n=1,r=e.length;n=0){var l=i[s];if(void 0!==l){var u=l.normalized,h=l.itemSize;if(void 0===(M=w.get(l)))continue;var d=M.buffer,g=M.type,y=M.bytesPerElement;if(l.isInterleavedBufferAttribute){var x=l.data,b=x.stride,_=l.offset;x&&x.isInstancedInterleavedBuffer?(v.enableAttributeAndDivisor(c,x.meshPerAttribute),void 0===e.maxInstancedCount&&(e.maxInstancedCount=x.meshPerAttribute*x.count)):v.enableAttribute(c),p.bindBuffer(34962,d),p.vertexAttribPointer(c,h,g,u,b*y,_*y)}else l.isInstancedBufferAttribute?(v.enableAttributeAndDivisor(c,l.meshPerAttribute),void 0===e.maxInstancedCount&&(e.maxInstancedCount=l.meshPerAttribute*l.count)):v.enableAttribute(c),p.bindBuffer(34962,d),p.vertexAttribPointer(c,h,g,u,0,0)}else if("instanceMatrix"===s){var M;if(void 0===(M=w.get(t.instanceMatrix)))continue;d=M.buffer,g=M.type;v.enableAttributeAndDivisor(c+0,1),v.enableAttributeAndDivisor(c+1,1),v.enableAttributeAndDivisor(c+2,1),v.enableAttributeAndDivisor(c+3,1),p.bindBuffer(34962,d),p.vertexAttribPointer(c+0,4,g,!1,64,0),p.vertexAttribPointer(c+1,4,g,!1,64,16),p.vertexAttribPointer(c+2,4,g,!1,64,32),p.vertexAttribPointer(c+3,4,g,!1,64,48)}else if(void 0!==o){var S=o[s];if(void 0!==S)switch(S.length){case 2:p.vertexAttrib2fv(c,S);break;case 3:p.vertexAttrib3fv(c,S);break;case 4:p.vertexAttrib4fv(c,S);break;default:p.vertexAttrib1fv(c,S)}}}}v.disableUnusedAttributes()}(i,n,r,s),null!==u&&p.bindBuffer(34963,l.buffer));var y=1/0;null!==u?y=u.count:void 0!==h&&(y=h.count);var x=n.drawRange.start*d,b=n.drawRange.count*d,M=null!==a?a.start*d:0,S=null!==a?a.count*d:1/0,E=Math.max(x,M),A=Math.min(y,x+b,M+S)-1,T=Math.max(0,A-E+1);if(0!==T){if(i.isMesh)if(!0===r.wireframe)v.setLineWidth(r.wireframeLinewidth*at()),g.setMode(1);else switch(i.drawMode){case Re:g.setMode(4);break;case Pe:g.setMode(5);break;case Ce:g.setMode(6)}else if(i.isLine){var C=r.linewidth;void 0===C&&(C=1),v.setLineWidth(C*at()),i.isLineSegments?g.setMode(1):i.isLineLoop?g.setMode(2):g.setMode(3)}else i.isPoints?g.setMode(0):i.isSprite&&g.setMode(4);i.isInstancedMesh?g.renderInstances(n,E,T,i.count):n.isInstancedBufferGeometry?g.renderInstances(n,E,T,n.maxInstancedCount):g.render(E,T)}},this.compile=function(t,e){(d=A.get(t,e)).init(),t.traverse((function(t){t.isLight&&(d.pushLight(t),t.castShadow&&d.pushShadow(t))})),d.setupLights(e),t.traverse((function(e){if(e.material)if(Array.isArray(e.material))for(var n=0;n=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(f=0;f=0&&t.numSupportedMorphNormals++}var m=r.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(r.numClippingPlanes=$.numPlanes,r.numIntersection=$.numIntersection,m.clippingPlanes=$.uniform),r.fog=e,r.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),r.lightsStateVersion=o,r.needsLights&&(m.ambientLightColor.value=i.state.ambient,m.lightProbe.value=i.state.probe,m.directionalLights.value=i.state.directional,m.spotLights.value=i.state.spot,m.rectAreaLights.value=i.state.rectArea,m.pointLights.value=i.state.point,m.hemisphereLights.value=i.state.hemi,m.directionalShadowMap.value=i.state.directionalShadowMap,m.directionalShadowMatrix.value=i.state.directionalShadowMatrix,m.spotShadowMap.value=i.state.spotShadowMap,m.spotShadowMatrix.value=i.state.spotShadowMatrix,m.pointShadowMap.value=i.state.pointShadowMap,m.pointShadowMatrix.value=i.state.pointShadowMatrix);var v=r.program.getUniforms(),g=To.seqWithValue(v.seq,m);r.uniformsList=g}function wt(t,e,n,r){b.resetTextureUnits();var i=x.get(n),a=d.state.lights;if(tt&&(et||t!==H)){var o=t===H&&n.id===U;$.setState(n.clippingPlanes,n.clipIntersection,n.clipShadows,t,i,o)}!1===n.needsUpdate&&(void 0===i.program?n.needsUpdate=!0:n.fog&&i.fog!==e?n.needsUpdate=!0:i.needsLights&&i.lightsStateVersion!==a.state.version?n.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===$.numPlanes&&i.numIntersection===$.numIntersection||(n.needsUpdate=!0)),n.needsUpdate&&(bt(n,e,r),n.needsUpdate=!1);var s,c,l=!1,u=!1,h=!1,f=i.program,y=f.getUniforms(),w=i.shader.uniforms;if(v.useProgram(f.program)&&(l=!0,u=!0,h=!0),n.id!==U&&(U=n.id,u=!0),l||H!==t){if(f.numMultiviewViews>0?lt.updateCameraProjectionMatricesUniform(t,y):y.setValue(p,"projectionMatrix",t.projectionMatrix),m.logarithmicDepthBuffer&&y.setValue(p,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),H!==t&&(H=t,u=!0,h=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.envMap){var _=y.map.cameraPosition;void 0!==_&&_.setValue(p,rt.setFromMatrixPosition(t.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&y.setValue(p,"isOrthographic",!0===t.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.skinning)&&(f.numMultiviewViews>0?lt.updateCameraViewMatricesUniform(t,y):y.setValue(p,"viewMatrix",t.matrixWorldInverse))}if(n.skinning){y.setOptional(p,r,"bindMatrix"),y.setOptional(p,r,"bindMatrixInverse");var M=r.skeleton;if(M){var S=M.bones;if(m.floatVertexTextures){if(void 0===M.boneTexture){var E=Math.sqrt(4*S.length);E=xn.ceilPowerOfTwo(E),E=Math.max(E,4);var A=new Float32Array(E*E*4);A.set(M.boneMatrices);var T=new ca(A,E,E,jt,Bt);M.boneMatrices=A,M.boneTexture=T,M.boneTextureSize=E}y.setValue(p,"boneTexture",M.boneTexture,b),y.setValue(p,"boneTextureSize",M.boneTextureSize)}else y.setOptional(p,M,"boneMatrices")}}return(u||i.receiveShadow!==r.receiveShadow)&&(i.receiveShadow=r.receiveShadow,y.setValue(p,"receiveShadow",r.receiveShadow)),u&&(y.setValue(p,"toneMappingExposure",O.toneMappingExposure),y.setValue(p,"toneMappingWhitePoint",O.toneMappingWhitePoint),i.needsLights&&(c=h,(s=w).ambientLightColor.needsUpdate=c,s.lightProbe.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.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}(w,e),n.isMeshBasicMaterial?_t(w,n):n.isMeshLambertMaterial?(_t(w,n),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(w,n)):n.isMeshPhongMaterial?(_t(w,n),n.isMeshToonMaterial?function(t,e){Mt(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(w,n):Mt(w,n)):n.isMeshStandardMaterial?(_t(w,n),n.isMeshPhysicalMaterial?function(t,e){St(t,e),t.reflectivity.value=e.reflectivity,t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.sheen&&t.sheen.value.copy(e.sheen);e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,e.side===g&&t.clearcoatNormalScale.value.negate());t.transparency.value=e.transparency}(w,n):St(w,n)):n.isMeshMatcapMaterial?(_t(w,n),function(t,e){e.matcap&&(t.matcap.value=e.matcap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===g&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,n)):n.isMeshDepthMaterial?(_t(w,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,n)):n.isMeshDistanceMaterial?(_t(w,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}(w,n)):n.isMeshNormalMaterial?(_t(w,n),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===g&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,n)):n.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(w,n),n.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(w,n)):n.isPointsMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*Y,t.scale.value=.5*X,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);var n;e.map?n=e.map:e.alphaMap&&(n=e.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}(w,n):n.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);var n;e.map?n=e.map:e.alphaMap&&(n=e.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}(w,n):n.isShadowMaterial&&(w.color.value.copy(n.color),w.opacity.value=n.opacity),void 0!==w.ltc_1&&(w.ltc_1.value=pa.LTC_1),void 0!==w.ltc_2&&(w.ltc_2.value=pa.LTC_2),To.upload(p,i.uniformsList,w,b),n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(To.upload(p,i.uniformsList,w,b),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&y.setValue(p,"center",r.center),f.numMultiviewViews>0?lt.updateObjectMatricesUniforms(r,t,y):(y.setValue(p,"modelViewMatrix",r.modelViewMatrix),y.setValue(p,"normalMatrix",r.normalMatrix)),y.setValue(p,"modelMatrix",r.matrixWorld),f}function _t(t,e){var n;t.opacity.value=e.opacity,e.color&&t.diffuse.value.copy(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.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio,t.maxMipLevel.value=x.get(e.envMap).__maxMipLevel),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity),e.map?n=e.map:e.specularMap?n=e.specularMap:e.displacementMap?n=e.displacementMap:e.normalMap?n=e.normalMap:e.bumpMap?n=e.bumpMap:e.roughnessMap?n=e.roughnessMap:e.metalnessMap?n=e.metalnessMap:e.alphaMap?n=e.alphaMap:e.emissiveMap&&(n=e.emissiveMap),void 0!==n&&(n.isWebGLRenderTarget&&(n=n.texture),!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}function Mt(t,e){t.specular.value.copy(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.side===g&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function St(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.side===g&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}vt.setAnimationLoop((function(t){ct.isPresenting()||mt&&mt(t)})),"undefined"!=typeof window&&vt.setContext(window),this.setAnimationLoop=function(t){mt=t,ct.setAnimationLoop(t),vt.start()},this.render=function(t,e){var n,r;if(void 0!==arguments[2]&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),n=arguments[2]),void 0!==arguments[3]&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),r=arguments[3]),e&&e.isCamera){if(!D){G.geometry=null,G.program=null,G.wireframe=!1,U=-1,H=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),ct.enabled&&(e=ct.getCamera(e)),(d=A.get(t,e)).init(),t.onBeforeRender(O,t,e,n||F),nt.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),K.setFromMatrix(nt),et=this.localClippingEnabled,tt=$.init(this.clippingPlanes,et,e),(h=E.get(t,e)).init(),gt(t,e,0,O.sortObjects),!0===O.sortObjects&&h.sort(),tt&&$.beginShadows();var i=d.state.shadowsArray;ut.render(i,t,e),d.setupLights(e),tt&&$.endShadows(),this.info.autoReset&&this.info.reset(),void 0!==n&&this.setRenderTarget(n),ct.enabled&<.isAvailable()&<.attachCamera(e),T.render(h,t,e,r);var a=h.opaque,o=h.transparent;if(t.overrideMaterial){var s=t.overrideMaterial;a.length&&yt(a,t,e,s),o.length&&yt(o,t,e,s)}else a.length&&yt(a,t,e),o.length&&yt(o,t,e);t.onAfterRender(O,t,e),null!==F&&(b.updateRenderTargetMipmap(F),b.updateMultisampleRenderTarget(F)),v.buffers.depth.setTest(!0),v.buffers.depth.setMask(!0),v.buffers.color.setMask(!0),v.setPolygonOffset(!1),ct.enabled&&(lt.isAvailable()&<.detachCamera(e),ct.submitFrame()),h=null,d=null}}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.setFramebuffer=function(t){I!==t&&null===F&&p.bindFramebuffer(36160,t),I=t},this.getActiveCubeFace=function(){return N},this.getActiveMipmapLevel=function(){return B},this.getRenderTarget=function(){return F},this.setRenderTarget=function(t,e,n){F=t,N=e,B=n,t&&void 0===x.get(t).__webglFramebuffer&&b.setupRenderTarget(t);var r=I,i=!1;if(t){var a=x.get(t).__webglFramebuffer;t.isWebGLRenderTargetCube?(r=a[e||0],i=!0):r=t.isWebGLMultisampleRenderTarget?x.get(t).__webglMultisampledFramebuffer:a,k.copy(t.viewport),j.copy(t.scissor),W=t.scissorTest}else k.copy(Z).multiplyScalar(Y).floor(),j.copy(J).multiplyScalar(Y).floor(),W=Q;if(z!==r&&(p.bindFramebuffer(36160,r),z=r),v.viewport(k),v.scissor(j),v.setScissorTest(W),i){var o=x.get(t.texture);p.framebufferTexture2D(36160,36064,34069+(e||0),o.__webglTexture,n||0)}},this.readRenderTargetPixels=function(t,e,n,r,i,a,o){if(t&&t.isWebGLRenderTarget){var s=x.get(t).__webglFramebuffer;if(t.isWebGLRenderTargetCube&&void 0!==o&&(s=s[o]),s){var c=!1;s!==z&&(p.bindFramebuffer(36160,s),c=!0);try{var l=t.texture,u=l.format,h=l.type;if(u!==jt&&C.convert(u)!==p.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(h===Pt||C.convert(h)===p.getParameter(35738)||h===Bt&&(m.isWebGL2||f.get("OES_texture_float")||f.get("WEBGL_color_buffer_float"))||h===Ft&&(m.isWebGL2?f.get("EXT_color_buffer_float"):f.get("EXT_color_buffer_half_float"))))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===p.checkFramebufferStatus(36160)?e>=0&&e<=t.width-r&&n>=0&&n<=t.height-i&&p.readPixels(e,n,r,i,C.convert(u),C.convert(h),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{c&&p.bindFramebuffer(36160,z)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(t,e,n){void 0===n&&(n=0);var r=Math.pow(2,-n),i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=C.convert(e.format);b.setTexture2D(e,0),p.copyTexImage2D(3553,n,o,t.x,t.y,i,a,0),v.unbindTexture()},this.copyTextureToTexture=function(t,e,n,r){var i=e.image.width,a=e.image.height,o=C.convert(n.format),s=C.convert(n.type);b.setTexture2D(n,0),e.isDataTexture?p.texSubImage2D(3553,r||0,t.x,t.y,i,a,o,s,e.image.data):p.texSubImage2D(3553,r||0,t.x,t.y,o,s,e.image),v.unbindTexture()},this.initTexture=function(t){b.setTexture2D(t,0),v.unbindTexture()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function _s(t,e){this.name="",this.color=new Zr(t),this.density=void 0!==e?e:25e-5}function Ms(t,e,n){this.name="",this.color=new Zr(t),this.near=void 0!==e?e:1,this.far=void 0!==n?n:1e3}function Ss(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=sn,this.updateRange={offset:0,count:-1},this.version=0}function Es(t,e,n,r){this.data=t,this.itemSize=e,this.offset=n,this.normalized=!0===r}function As(t){ei.call(this),this.type="SpriteMaterial",this.color=new Zr(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(t)}Object.assign(xs.prototype,vn.prototype),Object.assign(bs.prototype,vn.prototype),Object.assign(_s.prototype,{isFogExp2:!0,clone:function(){return new _s(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}),Object.assign(Ms.prototype,{isFog:!0,clone:function(){return new Ms(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}),Object.defineProperty(Ss.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Ss.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.stride,n*=e.stride;for(var r=0,i=this.stride;rt.far||e.push({distance:s,point:Ts.clone(),uv:Wr.getUV(Ts,Ds,Is,Ns,Bs,Fs,zs,new bn),face:null,object:this})}},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(t){return ar.prototype.copy.call(this,t),void 0!==t.center&&this.center.copy(t.center),this}});var Hs=new Sn,Vs=new Sn;function ks(){ar.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}function js(t,e){t&&t.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),Gi.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Hn,this.bindMatrixInverse=new Hn}ks.prototype=Object.assign(Object.create(ar.prototype),{constructor:ks,isLOD:!0,copy:function(t){ar.prototype.copy.call(this,t,!1);for(var e=t.levels,n=0,r=e.length;n1){Hs.setFromMatrixPosition(t.matrixWorld),Vs.setFromMatrixPosition(this.matrixWorld);var n=Hs.distanceTo(Vs);e[0].object.visible=!0;for(var r=1,i=e.length;r=e[r].distance;r++)e[r-1].object.visible=!1,e[r].object.visible=!0;for(;ro))u.applyMatrix4(this.matrixWorld),(w=t.ray.origin.distanceTo(u))t.far||e.push({distance:w,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}else for(m=0,v=p.length/3-1;mo))u.applyMatrix4(this.matrixWorld),(w=t.ray.origin.distanceTo(u))t.far||e.push({distance:w,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}else if(r.isGeometry){var x=r.vertices,b=x.length;for(m=0;mo))u.applyMatrix4(this.matrixWorld),(w=t.ray.origin.distanceTo(u))t.far||e.push({distance:w,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var rc=new Sn,ic=new Sn;function ac(t,e){nc.call(this,t,e),this.type="LineSegments"}function oc(t,e){nc.call(this,t,e),this.type="LineLoop"}function sc(t){ei.call(this),this.type="PointsMaterial",this.color=new Zr(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(t)}ac.prototype=Object.assign(Object.create(nc.prototype),{constructor:ac,isLineSegments:!0,computeLineDistances:function(){var t=this.geometry;if(t.isBufferGeometry)if(null===t.index){for(var e=t.attributes.position,n=[],r=0,i=e.count;ri.far)return;a.push({distance:l,distanceToRay:Math.sqrt(s),point:c,index:e,face:null,object:o})}}function fc(t,e,n,r,i,a,o,s,c){Pn.call(this,t,e,n,r,i,a,o,s,c),this.format=void 0!==o?o:kt,this.minFilter=void 0!==a?a:Et,this.magFilter=void 0!==i?i:Et,this.generateMipmaps=!1}function mc(t,e,n,r,i,a,o,s,c,l,u,h){Pn.call(this,null,a,o,s,c,l,r,i,u,h),this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function vc(t,e,n,r,i,a,o,s,c){Pn.call(this,t,e,n,r,i,a,o,s,c),this.needsUpdate=!0}function gc(t,e,n,r,i,a,o,s,c,l){if((l=void 0!==l?l:Yt)!==Yt&&l!==Zt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&l===Yt&&(n=Dt),void 0===n&&l===Zt&&(n=Ht),Pn.call(this,null,r,i,a,o,s,l,n,c),this.image={width:t,height:e},this.magFilter=void 0!==o?o:bt,this.minFilter=void 0!==s?s:bt,this.flipY=!1,this.generateMipmaps=!1}function yc(t){_i.call(this),this.type="WireframeGeometry";var e,n,r,i,a,o,s,c,l,u,h=[],d=[0,0],p={},f=["a","b","c"];if(t&&t.isGeometry){var m=t.faces;for(e=0,r=m.length;e=0?(t(v-1e-5,m,h),d.subVectors(u,h)):(t(v+1e-5,m,h),d.subVectors(h,u)),m-1e-5>=0?(t(v,m-1e-5,h),p.subVectors(u,h)):(t(v,m+1e-5,h),p.subVectors(h,u)),l.crossVectors(d,p).normalize(),s.push(l.x,l.y,l.z),c.push(v,m)}}for(r=0;r.9&&o<.1&&(e<.2&&(a[t+0]+=1),n<.2&&(a[t+2]+=1),r<.2&&(a[t+4]+=1))}}()}(),this.setAttribute("position",new hi(i,3)),this.setAttribute("normal",new hi(i.slice(),3)),this.setAttribute("uv",new hi(a,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}function Mc(t,e){Xi.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Sc(t,e)),this.mergeVertices()}function Sc(t,e){_c.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 Ec(t,e){Xi.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Ac(t,e)),this.mergeVertices()}function Ac(t,e){_c.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 Tc(t,e){Xi.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Lc(t,e)),this.mergeVertices()}function Lc(t,e){var n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1];_c.call(this,r,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Rc(t,e){Xi.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Pc(t,e)),this.mergeVertices()}function Pc(t,e){var n=(1+Math.sqrt(5))/2,r=1/n,i=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r];_c.call(this,i,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Cc(t,e,n,r,i,a){Xi.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:r,closed:i},void 0!==a&&console.warn("THREE.TubeGeometry: taper has been removed.");var o=new Oc(t,e,n,r,i);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals,this.fromBufferGeometry(o),this.mergeVertices()}function Oc(t,e,n,r,i){_i.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:r,closed:i},e=e||64,n=n||1,r=r||8,i=i||!1;var a=t.computeFrenetFrames(e,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;var o,s,c=new Sn,l=new Sn,u=new bn,h=new Sn,d=[],p=[],f=[],m=[];function v(i){h=t.getPointAt(i/e,h);var o=a.normals[i],u=a.binormals[i];for(s=0;s<=r;s++){var f=s/r*Math.PI*2,m=Math.sin(f),v=-Math.cos(f);l.x=v*o.x+m*u.x,l.y=v*o.y+m*u.y,l.z=v*o.z+m*u.z,l.normalize(),p.push(l.x,l.y,l.z),c.x=h.x+n*l.x,c.y=h.y+n*l.y,c.z=h.z+n*l.z,d.push(c.x,c.y,c.z)}}!function(){for(o=0;o0){var o=i[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=o.length;t0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),fc.prototype=Object.assign(Object.create(Pn.prototype),{constructor:fc,isVideoTexture:!0,update:function(){var t=this.image;t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),mc.prototype=Object.create(Pn.prototype),mc.prototype.constructor=mc,mc.prototype.isCompressedTexture=!0,vc.prototype=Object.create(Pn.prototype),vc.prototype.constructor=vc,vc.prototype.isCanvasTexture=!0,gc.prototype=Object.create(Pn.prototype),gc.prototype.constructor=gc,gc.prototype.isDepthTexture=!0,yc.prototype=Object.create(_i.prototype),yc.prototype.constructor=yc,xc.prototype=Object.create(Xi.prototype),xc.prototype.constructor=xc,bc.prototype=Object.create(_i.prototype),bc.prototype.constructor=bc,wc.prototype=Object.create(Xi.prototype),wc.prototype.constructor=wc,_c.prototype=Object.create(_i.prototype),_c.prototype.constructor=_c,Mc.prototype=Object.create(Xi.prototype),Mc.prototype.constructor=Mc,Sc.prototype=Object.create(_c.prototype),Sc.prototype.constructor=Sc,Ec.prototype=Object.create(Xi.prototype),Ec.prototype.constructor=Ec,Ac.prototype=Object.create(_c.prototype),Ac.prototype.constructor=Ac,Tc.prototype=Object.create(Xi.prototype),Tc.prototype.constructor=Tc,Lc.prototype=Object.create(_c.prototype),Lc.prototype.constructor=Lc,Rc.prototype=Object.create(Xi.prototype),Rc.prototype.constructor=Rc,Pc.prototype=Object.create(_c.prototype),Pc.prototype.constructor=Pc,Cc.prototype=Object.create(Xi.prototype),Cc.prototype.constructor=Cc,Oc.prototype=Object.create(_i.prototype),Oc.prototype.constructor=Oc,Oc.prototype.toJSON=function(){var t=_i.prototype.toJSON.call(this);return t.path=this.parameters.path.toJSON(),t},Dc.prototype=Object.create(Xi.prototype),Dc.prototype.constructor=Dc,Ic.prototype=Object.create(_i.prototype),Ic.prototype.constructor=Ic,Nc.prototype=Object.create(Xi.prototype),Nc.prototype.constructor=Nc,Bc.prototype=Object.create(_i.prototype),Bc.prototype.constructor=Bc;var Fc=function(t,e,n){n=n||2;var r,i,a,o,s,c,l,u=e&&e.length,h=u?e[0]*n:t.length,d=zc(t,0,h,n,!0),p=[];if(!d||d.next===d.prev)return p;if(u&&(d=function(t,e,n,r){var i,a,o,s,c,l=[];for(i=0,a=e.length;i80*n){r=a=t[0],i=o=t[1];for(var f=n;fa&&(a=s),c>o&&(o=c);l=0!==(l=Math.max(a-r,o-i))?1/l:0}return Gc(d,p,n,r,i,l),p};function zc(t,e,n,r,i){var a,o;if(i===function(t,e,n,r){for(var i=0,a=e,o=n-r;a0)for(a=e;a=e;a-=r)o=nl(a,t[a],t[a+1],o);return o&&Kc(o,o.next)&&(rl(o),o=o.next),o}function Uc(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!Kc(r,r.next)&&0!==Qc(r.prev,r,r.next))r=r.next;else{if(rl(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function Gc(t,e,n,r,i,a,o){if(t){!o&&a&&function(t,e,n,r){var i=t;do{null===i.z&&(i.z=Xc(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,a,o,s,c,l=1;do{for(n=t,t=null,a=null,o=0;n;){for(o++,r=n,s=0,e=0;e0||c>0&&r;)0!==s&&(0===c||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,c--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1)}(i)}(t,r,i,a);for(var s,c,l=t;t.prev!==t.next;)if(s=t.prev,c=t.next,a?Vc(t,r,i,a):Hc(t))e.push(s.i/n),e.push(t.i/n),e.push(c.i/n),rl(t),t=c.next,l=c.next;else if((t=c)===l){o?1===o?Gc(t=kc(t,e,n),e,n,r,i,a,2):2===o&&jc(t,e,n,r,i,a):Gc(Uc(t),e,n,r,i,a,1);break}}}function Hc(t){var e=t.prev,n=t,r=t.next;if(Qc(e,n,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(Zc(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Qc(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Vc(t,e,n,r){var i=t.prev,a=t,o=t.next;if(Qc(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,u=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,h=Xc(s,c,e,n,r),d=Xc(l,u,e,n,r),p=t.prevZ,f=t.nextZ;p&&p.z>=h&&f&&f.z<=d;){if(p!==t.prev&&p!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Qc(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==t.prev&&f!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Qc(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=h;){if(p!==t.prev&&p!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Qc(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==t.prev&&f!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Qc(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function kc(t,e,n){var r=t;do{var i=r.prev,a=r.next.next;!Kc(i,a)&&$c(i,r,r.next,a)&&tl(i,a)&&tl(a,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(a.i/n),rl(r),rl(r.next),r=t=a),r=r.next}while(r!==t);return r}function jc(t,e,n,r,i,a){var o=t;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&Jc(o,s)){var c=el(o,s);return o=Uc(o,o.next),c=Uc(c,c.next),Gc(o,e,n,r,i,a),void Gc(c,e,n,r,i,a)}s=s.next}o=o.next}while(o!==t)}function Wc(t,e){return t.x-e.x}function qc(t,e){if(e=function(t,e){var n,r=e,i=t.x,a=t.y,o=-1/0;do{if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){var s=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>o){if(o=s,s===i){if(a===r.y)return r;if(a===r.next.y)return r.next}n=r.x=r.x&&r.x>=u&&i!==r.x&&Zc(an.x)&&tl(r,t)&&(n=r,d=c),r=r.next;return n}(t,e)){var n=el(e,t);Uc(n,n.next)}}function Xc(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Yc(t){var e=t,n=t;do{(e.x=0&&(t-o)*(r-s)-(n-o)*(e-s)>=0&&(n-o)*(a-s)-(i-o)*(r-s)>=0}function Jc(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&&$c(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&tl(t,e)&&tl(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)}function Qc(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Kc(t,e){return t.x===e.x&&t.y===e.y}function $c(t,e,n,r){return!!(Kc(t,n)&&Kc(e,r)||Kc(t,r)&&Kc(n,e))||Qc(t,e,n)>0!=Qc(t,e,r)>0&&Qc(n,r,t)>0!=Qc(n,r,e)>0}function tl(t,e){return Qc(t.prev,t,t.next)<0?Qc(t,e,t.next)>=0&&Qc(t,t.prev,e)>=0:Qc(t,e,t.prev)<0||Qc(t,t.next,e)<0}function el(t,e){var n=new il(t.i,t.x,t.y),r=new il(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function nl(t,e,n,r){var i=new il(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function rl(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 il(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 al={area:function(t){for(var e=t.length,n=0,r=e-1,i=0;i2&&t[e-1].equals(t[0])&&t.pop()}function sl(t,e){for(var n=0;nNumber.EPSILON){var d=Math.sqrt(u),p=Math.sqrt(c*c+l*l),f=e.x-s/d,m=e.y+o/d,v=((n.x-l/p-f)*l-(n.y+c/p-m)*c)/(o*l-s*c),g=(r=f+o*v-t.x)*r+(i=m+s*v-t.y)*i;if(g<=2)return new bn(r,i);a=Math.sqrt(g/2)}else{var y=!1;o>Number.EPSILON?c>Number.EPSILON&&(y=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(l)&&(y=!0),y?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new bn(r/a,i/a)}for(var G=[],H=0,V=R.length,k=V-1,j=H+1;H=0;C--){for(D=C/p,I=u*Math.cos(D*Math.PI/2),O=h*Math.sin(D*Math.PI/2)+d,H=0,V=R.length;H=0;){n=H,(r=H-1)<0&&(r=t.length-1);var i=0,a=s+2*p;for(i=0;i0)&&f.push(_,M,E),(c!==n-1||l0&&g(!0),e>0&&g(!1)),this.setIndex(l),this.setAttribute("position",new hi(u,3)),this.setAttribute("normal",new hi(h,3)),this.setAttribute("uv",new hi(d,2))}function Al(t,e,n,r,i,a,o){Sl.call(this,0,t,e,n,r,i,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}function Tl(t,e,n,r,i,a,o){El.call(this,0,t,e,n,r,i,a,o),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}function Ll(t,e,n,r){Xi.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},this.fromBufferGeometry(new Rl(t,e,n,r)),this.mergeVertices()}function Rl(t,e,n,r){_i.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},t=t||1,e=void 0!==e?Math.max(3,e):8,n=void 0!==n?n:0,r=void 0!==r?r:2*Math.PI;var i,a,o=[],s=[],c=[],l=[],u=new Sn,h=new bn;for(s.push(0,0,0),c.push(0,0,1),l.push(.5,.5),a=0,i=3;a<=e;a++,i+=3){var d=n+a/e*r;u.x=t*Math.cos(d),u.y=t*Math.sin(d),s.push(u.x,u.y,u.z),c.push(0,0,1),h.x=(s[i]/t+1)/2,h.y=(s[i+1]/t+1)/2,l.push(h.x,h.y)}for(i=1;i<=e;i++)o.push(i,i+1,0);this.setIndex(o),this.setAttribute("position",new hi(s,3)),this.setAttribute("normal",new hi(c,3)),this.setAttribute("uv",new hi(l,2))}dl.prototype=Object.create(Xi.prototype),dl.prototype.constructor=dl,pl.prototype=Object.create(ll.prototype),pl.prototype.constructor=pl,fl.prototype=Object.create(Xi.prototype),fl.prototype.constructor=fl,ml.prototype=Object.create(_i.prototype),ml.prototype.constructor=ml,vl.prototype=Object.create(Xi.prototype),vl.prototype.constructor=vl,gl.prototype=Object.create(_i.prototype),gl.prototype.constructor=gl,yl.prototype=Object.create(Xi.prototype),yl.prototype.constructor=yl,xl.prototype=Object.create(_i.prototype),xl.prototype.constructor=xl,bl.prototype=Object.create(Xi.prototype),bl.prototype.constructor=bl,bl.prototype.toJSON=function(){var t=Xi.prototype.toJSON.call(this);return _l(this.parameters.shapes,t)},wl.prototype=Object.create(_i.prototype),wl.prototype.constructor=wl,wl.prototype.toJSON=function(){var t=_i.prototype.toJSON.call(this);return _l(this.parameters.shapes,t)},Ml.prototype=Object.create(_i.prototype),Ml.prototype.constructor=Ml,Sl.prototype=Object.create(Xi.prototype),Sl.prototype.constructor=Sl,El.prototype=Object.create(_i.prototype),El.prototype.constructor=El,Al.prototype=Object.create(Sl.prototype),Al.prototype.constructor=Al,Tl.prototype=Object.create(El.prototype),Tl.prototype.constructor=Tl,Ll.prototype=Object.create(Xi.prototype),Ll.prototype.constructor=Ll,Rl.prototype=Object.create(_i.prototype),Rl.prototype.constructor=Rl;var Pl=Object.freeze({__proto__:null,WireframeGeometry:yc,ParametricGeometry:xc,ParametricBufferGeometry:bc,TetrahedronGeometry:Mc,TetrahedronBufferGeometry:Sc,OctahedronGeometry:Ec,OctahedronBufferGeometry:Ac,IcosahedronGeometry:Tc,IcosahedronBufferGeometry:Lc,DodecahedronGeometry:Rc,DodecahedronBufferGeometry:Pc,PolyhedronGeometry:wc,PolyhedronBufferGeometry:_c,TubeGeometry:Cc,TubeBufferGeometry:Oc,TorusKnotGeometry:Dc,TorusKnotBufferGeometry:Ic,TorusGeometry:Nc,TorusBufferGeometry:Bc,TextGeometry:dl,TextBufferGeometry:pl,SphereGeometry:fl,SphereBufferGeometry:ml,RingGeometry:vl,RingBufferGeometry:gl,PlaneGeometry:ga,PlaneBufferGeometry:ya,LatheGeometry:yl,LatheBufferGeometry:xl,ShapeGeometry:bl,ShapeBufferGeometry:wl,ExtrudeGeometry:cl,ExtrudeBufferGeometry:ll,EdgesGeometry:Ml,ConeGeometry:Al,ConeBufferGeometry:Tl,CylinderGeometry:Sl,CylinderBufferGeometry:El,CircleGeometry:Ll,CircleBufferGeometry:Rl,BoxGeometry:Yi,BoxBufferGeometry:Zi});function Cl(t){ei.call(this),this.type="ShadowMaterial",this.color=new Zr(0),this.transparent=!0,this.setValues(t)}function Ol(t){ea.call(this,t),this.type="RawShaderMaterial"}function Dl(t){ei.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Zr(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 Zr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(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 Il(t){Dl.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearcoat=0,this.clearcoatRoughness=0,this.sheen=null,this.clearcoatNormalScale=new bn(1,1),this.clearcoatNormalMap=null,this.transparency=0,this.setValues(t)}function Nl(t){ei.call(this),this.type="MeshPhongMaterial",this.color=new Zr(16777215),this.specular=new Zr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Zr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=tt,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 Bl(t){Nl.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function Fl(t){ei.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function zl(t){ei.call(this),this.type="MeshLambertMaterial",this.color=new Zr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Zr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=tt,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 Ul(t){ei.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Zr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Gl(t){Js.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}Cl.prototype=Object.create(ei.prototype),Cl.prototype.constructor=Cl,Cl.prototype.isShadowMaterial=!0,Cl.prototype.copy=function(t){return ei.prototype.copy.call(this,t),this.color.copy(t.color),this},Ol.prototype=Object.create(ea.prototype),Ol.prototype.constructor=Ol,Ol.prototype.isRawShaderMaterial=!0,Dl.prototype=Object.create(ei.prototype),Dl.prototype.constructor=Dl,Dl.prototype.isMeshStandardMaterial=!0,Dl.prototype.copy=function(t){return ei.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.normalMapType=t.normalMapType,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},Il.prototype=Object.create(Dl.prototype),Il.prototype.constructor=Il,Il.prototype.isMeshPhysicalMaterial=!0,Il.prototype.copy=function(t){return Dl.prototype.copy.call(this,t),this.defines={STANDARD:"",PHYSICAL:""},this.reflectivity=t.reflectivity,this.clearcoat=t.clearcoat,this.clearcoatRoughness=t.clearcoatRoughness,t.sheen?this.sheen=(this.sheen||new Zr).copy(t.sheen):this.sheen=null,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.transparency=t.transparency,this},Nl.prototype=Object.create(ei.prototype),Nl.prototype.constructor=Nl,Nl.prototype.isMeshPhongMaterial=!0,Nl.prototype.copy=function(t){return ei.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.normalMapType=t.normalMapType,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},Bl.prototype=Object.create(Nl.prototype),Bl.prototype.constructor=Bl,Bl.prototype.isMeshToonMaterial=!0,Bl.prototype.copy=function(t){return Nl.prototype.copy.call(this,t),this.gradientMap=t.gradientMap,this},Fl.prototype=Object.create(ei.prototype),Fl.prototype.constructor=Fl,Fl.prototype.isMeshNormalMaterial=!0,Fl.prototype.copy=function(t){return ei.prototype.copy.call(this,t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,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},zl.prototype=Object.create(ei.prototype),zl.prototype.constructor=zl,zl.prototype.isMeshLambertMaterial=!0,zl.prototype.copy=function(t){return ei.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},Ul.prototype=Object.create(ei.prototype),Ul.prototype.constructor=Ul,Ul.prototype.isMeshMatcapMaterial=!0,Ul.prototype.copy=function(t){return ei.prototype.copy.call(this,t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Gl.prototype=Object.create(Js.prototype),Gl.prototype.constructor=Gl,Gl.prototype.isLineDashedMaterial=!0,Gl.prototype.copy=function(t){return Js.prototype.copy.call(this,t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this};var Hl=Object.freeze({__proto__:null,ShadowMaterial:Cl,SpriteMaterial:As,RawShaderMaterial:Ol,ShaderMaterial:ea,PointsMaterial:sc,MeshPhysicalMaterial:Il,MeshStandardMaterial:Dl,MeshPhongMaterial:Nl,MeshToonMaterial:Bl,MeshNormalMaterial:Fl,MeshLambertMaterial:zl,MeshDepthMaterial:rs,MeshDistanceMaterial:is,MeshBasicMaterial:ni,MeshMatcapMaterial:Ul,LineDashedMaterial:Gl,LineBasicMaterial:Js,Material:ei}),Vl={arraySlice:function(t,e,n){return Vl.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),r=0;r!==e;++r)n[r]=r;return n.sort((function(e,n){return t[e]-t[n]})),n},sortedArray:function(t,e,n){for(var r=t.length,i=new t.constructor(r),a=0,o=0;o!==r;++a)for(var s=n[a]*e,c=0;c!==e;++c)i[o++]=t[s+c];return i},flattenJSON:function(t,e,n,r){for(var i=1,a=t[0];void 0!==a&&void 0===a[r];)a=t[i++];if(void 0!==a){var o=a[r];if(void 0!==o)if(Array.isArray(o))do{void 0!==(o=a[r])&&(e.push(a.time),n.push.apply(n,o)),a=t[i++]}while(void 0!==a);else if(void 0!==o.toArray)do{void 0!==(o=a[r])&&(e.push(a.time),o.toArray(n,n.length)),a=t[i++]}while(void 0!==a);else do{void 0!==(o=a[r])&&(e.push(a.time),n.push(o)),a=t[i++]}while(void 0!==a)}},subclip:function(t,e,n,r,i){i=i||30;var a=t.clone();a.name=e;for(var o=[],s=0;s=r)){u.push(c.times[d]);for(var f=0;fa.tracks[s].times[0]&&(m=a.tracks[s].times[0]);for(s=0;s=i)break t;var s=e[1];t=(i=e[--n-1]))break e}a=n,n=0}for(;n>>1;tt;)--a;if(++a,0!==i||a!==r){i>=a&&(i=(a=Math.max(a,1))-1);var o=this.getValueSize();this.times=Vl.arraySlice(n,i,a),this.values=Vl.arraySlice(this.values,i*o,a*o)}return this},validate:function(){var e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);var n=this.times,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);for(var a=null,o=0;o!==i;o++){var s=n[o];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,s),e=!1;break}if(null!==a&&a>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,s,a),e=!1;break}a=s}if(void 0!==r&&Vl.isTypedArray(r)){o=0;for(var c=r.length;o!==c;++o){var l=r[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),e=!1;break}}}return e},optimize:function(){for(var e=this.times,t=this.values,n=this.getValueSize(),r=this.getInterpolation()===Et,i=1,a=e.length-1,o=1;o0){e[i]=e[a];for(f=a*n,m=i*n,d=0;d!==n;++d)t[m+d]=t[f+d];++i}return i!==e.length&&(this.times=Vl.arraySlice(e,0,i),this.values=Vl.arraySlice(t,0,i*n)),this},clone:function(){var e=Vl.arraySlice(this.times,0),t=Vl.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}),Ql.prototype=Object.assign(Object.create(ql.prototype),{constructor:Ql,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:_t,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Yl.prototype=Object.assign(Object.create(ql.prototype),{constructor:Yl,ValueTypeName:"color"}),Zl.prototype=Object.assign(Object.create(ql.prototype),{constructor:Zl,ValueTypeName:"number"}),Jl.prototype=Object.assign(Object.create(kl.prototype),{constructor:Jl,interpolate_:function(e,t,n,r){for(var i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=e*o,c=(n-t)/(r-t),l=s+o;s!==l;s+=4)bn.slerpFlat(i,0,a,s-o,a,s,c);return i}}),Kl.prototype=Object.assign(Object.create(ql.prototype),{constructor:Kl,ValueTypeName:"quaternion",DefaultInterpolation:Mt,InterpolantFactoryMethodLinear:function(e){return new Jl(this.times,this.values,this.getValueSize(),e)},InterpolantFactoryMethodSmooth:void 0}),$l.prototype=Object.assign(Object.create(ql.prototype),{constructor:$l,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:_t,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),eu.prototype=Object.assign(Object.create(ql.prototype),{constructor:eu,ValueTypeName:"vector"}),Object.assign(tu,{parse:function(e){for(var t=[],n=e.tracks,r=1/(e.fps||1),i=0,a=n.length;i!==a;++i)t.push(nu(n[i]).scale(r));return new tu(e.name,e.duration,t)},toJSON:function(e){for(var t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid},i=0,a=n.length;i!==a;++i)t.push(ql.toJSON(n[i]));return r},CreateFromMorphTargetSequence:function(e,t,n,r){for(var i=t.length,a=[],o=0;o1){var l=r[h=c[1]];l||(r[h]=l=[]),l.push(s)}}var u=[];for(var h in r)u.push(tu.CreateFromMorphTargetSequence(h,r[h],t,n));return u},parseAnimation:function(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var n=function(e,t,n,r,i){if(0!==n.length){var a=[],o=[];Vl.flattenJSON(n,a,o,r),0!==a.length&&i.push(new e(t,a,o))}},r=[],i=e.name||"default",a=e.length||-1,o=e.fps||30,s=e.hierarchy||[],c=0;c0||0===e.search(/^data\:image\/jpeg/);i.format=r?ke:je,i.needsUpdate=!0,void 0!==t&&t(i)}),n,r),i}}),Object.assign(mu.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(e,t){var n=this.getUtoTmapping(e);return this.getPoint(n,t)},getPoints:function(e){void 0===e&&(e=5);for(var t=[],n=0;n<=e;n++)t.push(this.getPoint(n/e));return t},getSpacedPoints:function(e){void 0===e&&(e=5);for(var t=[],n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t},getLength:function(){var e=this.getLengths();return e[e.length-1]},getLengths:function(e){if(void 0===e&&(e=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,n,r=[],i=this.getPoint(0),a=0;for(r.push(0),n=1;n<=e;n++)a+=(t=this.getPoint(n/e)).distanceTo(i),r.push(a),i=t;return this.cacheArcLengths=r,r},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(e,t){var n,r=this.getLengths(),i=0,a=r.length;n=t||e*r[a-1];for(var o,s=0,c=a-1;s<=c;)if((o=r[i=Math.floor(s+(c-s)/2)]-n)<0)s=i+1;else{if(!(o>0)){c=i;break}c=i-1}if(r[i=c]===n)return i/(a-1);var l=r[i];return(i+(n-l)/(r[i+1]-l))/(a-1)},getTangent:function(e){var t=e-1e-4,n=e+1e-4;t<0&&(t=0),n>1&&(n=1);var r=this.getPoint(t);return this.getPoint(n).clone().sub(r).normalize()},getTangentAt:function(e){var t=this.getUtoTmapping(e);return this.getTangent(t)},computeFrenetFrames:function(e,t){var n,r,i,a=new Mn,o=[],s=[],c=[],l=new Mn,u=new Hn;for(n=0;n<=e;n++)r=n/e,o[n]=this.getTangentAt(r),o[n].normalize();s[0]=new Mn,c[0]=new Mn;var h=Number.MAX_VALUE,d=Math.abs(o[0].x),p=Math.abs(o[0].y),f=Math.abs(o[0].z);for(d<=h&&(h=d,a.set(1,0,0)),p<=h&&(h=p,a.set(0,1,0)),f<=h&&a.set(0,0,1),l.crossVectors(o[0],a).normalize(),s[0].crossVectors(o[0],l),c[0].crossVectors(o[0],s[0]),n=1;n<=e;n++)s[n]=s[n-1].clone(),c[n]=c[n-1].clone(),l.crossVectors(o[n-1],o[n]),l.length()>Number.EPSILON&&(l.normalize(),i=Math.acos(An.clamp(o[n-1].dot(o[n]),-1,1)),s[n].applyMatrix4(u.makeRotationAxis(l,i))),c[n].crossVectors(o[n],s[n]);if(!0===t)for(i=Math.acos(An.clamp(s[0].dot(s[e]),-1,1)),i/=e,o[0].dot(l.crossVectors(s[0],s[e]))>0&&(i=-i),n=1;n<=e;n++)s[n].applyMatrix4(u.makeRotationAxis(o[n],i*n)),c[n].crossVectors(o[n],s[n]);return{tangents:o,normals:s,binormals:c}},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this},toJSON:function(){var e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e},fromJSON:function(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}),vu.prototype=Object.create(mu.prototype),vu.prototype.constructor=vu,vu.prototype.isEllipseCurve=!0,vu.prototype.getPoint=function(e,t){for(var n=t||new xn,r=2*Math.PI,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)r;)i-=r;i0?0:(Math.floor(Math.abs(u)/c)+1)*c:0===h&&u===c-1&&(u=c-2,h=1),this.closed||u>0?n=s[(u-1)%c]:(Au.subVectors(s[0],s[1]).add(s[0]),n=Au),r=s[u%c],i=s[(u+1)%c],this.closed||u+2r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(Mu(o,s.x,c.x,l.x,u.x),Mu(o,s.y,c.y,l.y,u.y)),n},Iu.prototype.copy=function(e){mu.prototype.copy.call(this,e),this.points=[];for(var t=0,n=e.points.length;t=t){var i=n[r]-t,a=this.curves[r],o=a.getLength(),s=0===o?0:1-i/o;return a.getPointAt(s)}r++}return null},getLength:function(){var e=this.getCurveLengths();return e[e.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],t=0,n=0,r=this.curves.length;n1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},copy:function(e){mu.prototype.copy.call(this,e),this.curves=[];for(var t=0,n=e.curves.length;t0){var l=c.getPoint(0);l.equals(this.currentPoint)||this.lineTo(l.x,l.y)}this.curves.push(c);var u=c.getPoint(1);return this.currentPoint.copy(u),this},copy:function(e){return Nu.prototype.copy.call(this,e),this.currentPoint.copy(e.currentPoint),this},toJSON:function(){var e=Nu.prototype.toJSON.call(this);return e.currentPoint=this.currentPoint.toArray(),e},fromJSON:function(e){return Nu.prototype.fromJSON.call(this,e),this.currentPoint.fromArray(e.currentPoint),this}}),Fu.prototype=Object.assign(Object.create(Bu.prototype),{constructor:Fu,getPointsHoles:function(e){for(var t=[],n=0,r=this.holes.length;n0){var a=new du(new iu(t));a.setCrossOrigin(this.crossOrigin);for(var o=0,s=e.length;o0?new js(o,s):new zi(o,s);break;case"InstancedMesh":o=i(e.geometry),s=a(e.material);var c=e.count,l=e.instanceMatrix;(r=new Ys(o,s,c)).instanceMatrix=new ri(new Float32Array(l.array),16);break;case"LOD":r=new ks;break;case"Line":r=new nc(i(e.geometry),a(e.material),e.mode);break;case"LineLoop":r=new oc(i(e.geometry),a(e.material));break;case"LineSegments":r=new ac(i(e.geometry),a(e.material));break;case"PointCloud":case"Points":r=new dc(i(e.geometry),a(e.material));break;case"Sprite":r=new Us(a(e.material));break;case"Group":r=new ps;break;default:r=new ar}if(r.uuid=e.uuid,void 0!==e.name&&(r.name=e.name),void 0!==e.matrix?(r.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(r.matrixAutoUpdate=e.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==e.position&&r.position.fromArray(e.position),void 0!==e.rotation&&r.rotation.fromArray(e.rotation),void 0!==e.quaternion&&r.quaternion.fromArray(e.quaternion),void 0!==e.scale&&r.scale.fromArray(e.scale)),void 0!==e.castShadow&&(r.castShadow=e.castShadow),void 0!==e.receiveShadow&&(r.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(r.shadow.bias=e.shadow.bias),void 0!==e.shadow.radius&&(r.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&r.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(r.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(r.visible=e.visible),void 0!==e.frustumCulled&&(r.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(r.renderOrder=e.renderOrder),void 0!==e.userData&&(r.userData=e.userData),void 0!==e.layers&&(r.layers.mask=e.layers),void 0!==e.drawMode&&r.setDrawMode(e.drawMode),void 0!==e.children)for(var u=e.children,h=0;hNumber.EPSILON){if(l<0&&(o=t[a],c=-c,s=t[i],l=-l),e.ys.y)continue;if(e.y===o.y){if(e.x===o.x)return!0}else{var u=l*(e.x-o.x)-c*(e.y-o.y);if(0===u)return!0;if(u<0)continue;r=!r}}else{if(e.y!==o.y)continue;if(s.x<=e.x&&e.x<=o.x||o.x<=e.x&&e.x<=s.x)return!0}}return r}var i=al.isClockWise,a=this.subPaths;if(0===a.length)return[];if(!0===t)return n(a);var o,s,c,l=[];if(1===a.length)return s=a[0],(c=new Fu).curves=s.curves,l.push(c),l;var u=!i(a[0].getPoints());u=e?!u:u;var h,d,p=[],f=[],m=[],v=0;f[v]=void 0,m[v]=[];for(var g=0,y=a.length;g1){for(var A=!1,x=[],b=0,w=f.length;b0&&(A||(m=p))}g=0;for(var L=f.length;g0){this.source.connect(this.filters[0]);for(var e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(var e=1,t=this.filters.length;e=.5)for(var a=0;a!==i;++a)e[t+a]=e[n+a]},_slerp:function(e,t,n,r){bn.slerpFlat(e,t,e,t,e,n,r)},_lerp:function(e,t,n,r,i){for(var a=1-r,o=0;o!==i;++o){var s=t+o;e[s]=e[s]*a+e[n+o]*r}}});var Nh=new RegExp("[\\[\\]\\.:\\/]","g"),Bh="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",Fh=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]"),Gh=/(WCOD+)?/.source.replace("WCOD",Bh),Uh=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),zh=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Hh=new RegExp("^"+Fh+Gh+Uh+zh+"$"),Vh=["material","materials","bones"];function kh(e,t,n){var r=n||jh.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}function jh(e,t,n){this.path=t,this.parsedPath=n||jh.parseTrackName(t),this.node=jh.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e}function Wh(){this.uuid=An.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(var t=0,n=arguments.length;t!==n;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var r=this;this.stats={objects:{get total(){return r._objects.length},get inUse(){return this.total-r.nCachedObjects_}},get bindingsPerObject(){return r._bindings.length}}}function Xh(e,t,n){this._mixer=e,this._clip=t,this._localRoot=n||null;for(var r=t.tracks,i=r.length,a=new Array(i),o={endingStart:St,endingEnd:St},s=0;s!==i;++s){var c=r[s].createInterpolant(null);a[s]=c,c.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=bt,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 qh(e){this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Qh(e){"string"==typeof e&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}function Yh(e,t,n){Ms.call(this,e,t),this.meshPerAttribute=n||1}function Zh(e,t,n,r){this.ray=new Cr(e,t),this.near=n||0,this.far=r||1/0,this.camera=null,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 Jh(e,t){return e.distance-t.distance}function Kh(e,t,n,r){if(!1!==e.visible&&(e.raycast(t,n),!0===r))for(var i=e.children,a=0,o=i.length;ae;)--a;if(++a,0!==i||a!==r){i>=a&&(i=(a=Math.max(a,1))-1);var o=this.getValueSize();this.times=Vl.arraySlice(n,i,a),this.values=Vl.arraySlice(this.values,i*o,a*o)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);var n=this.times,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);for(var a=null,o=0;o!==i;o++){var s=n[o];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,s),t=!1;break}if(null!==a&&a>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,s,a),t=!1;break}a=s}if(void 0!==r&&Vl.isTypedArray(r)){o=0;for(var c=r.length;o!==c;++o){var l=r[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}}return t},optimize:function(){for(var t=this.times,e=this.values,n=this.getValueSize(),r=this.getInterpolation()===Ee,i=1,a=t.length-1,o=1;o0){t[i]=t[a];for(f=a*n,m=i*n,d=0;d!==n;++d)e[m+d]=e[f+d];++i}return i!==t.length&&(this.times=Vl.arraySlice(t,0,i),this.values=Vl.arraySlice(e,0,i*n)),this},clone:function(){var t=Vl.arraySlice(this.times,0),e=Vl.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}),Yl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Yl,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:Me,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Zl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Zl,ValueTypeName:"color"}),Jl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Jl,ValueTypeName:"number"}),Ql.prototype=Object.assign(Object.create(kl.prototype),{constructor:Ql,interpolate_:function(t,e,n,r){for(var i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=t*o,c=(n-e)/(r-e),l=s+o;s!==l;s+=4)wn.slerpFlat(i,0,a,s-o,a,s,c);return i}}),Kl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Kl,ValueTypeName:"quaternion",DefaultInterpolation:Se,InterpolantFactoryMethodLinear:function(t){return new Ql(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),$l.prototype=Object.assign(Object.create(Xl.prototype),{constructor:$l,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:Me,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),tu.prototype=Object.assign(Object.create(Xl.prototype),{constructor:tu,ValueTypeName:"vector"}),Object.assign(eu,{parse:function(t){for(var e=[],n=t.tracks,r=1/(t.fps||1),i=0,a=n.length;i!==a;++i)e.push(nu(n[i]).scale(r));return new eu(t.name,t.duration,e)},toJSON:function(t){for(var e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid},i=0,a=n.length;i!==a;++i)e.push(Xl.toJSON(n[i]));return r},CreateFromMorphTargetSequence:function(t,e,n,r){for(var i=e.length,a=[],o=0;o1){var l=r[h=c[1]];l||(r[h]=l=[]),l.push(s)}}var u=[];for(var h in r)u.push(eu.CreateFromMorphTargetSequence(h,r[h],e,n));return u},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var n=function(t,e,n,r,i){if(0!==n.length){var a=[],o=[];Vl.flattenJSON(n,a,o,r),0!==a.length&&i.push(new t(e,a,o))}},r=[],i=t.name||"default",a=t.length||-1,o=t.fps||30,s=t.hierarchy||[],c=0;c0||0===t.search(/^data\:image\/jpeg/);i.format=r?kt:jt,i.needsUpdate=!0,void 0!==e&&e(i)}),n,r),i}}),Object.assign(mu.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,e){var n=this.getUtoTmapping(t);return this.getPoint(n,e)},getPoints:function(t){void 0===t&&(t=5);for(var e=[],n=0;n<=t;n++)e.push(this.getPoint(n/t));return e},getSpacedPoints:function(t){void 0===t&&(t=5);for(var e=[],n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,n,r=[],i=this.getPoint(0),a=0;for(r.push(0),n=1;n<=t;n++)a+=(e=this.getPoint(n/t)).distanceTo(i),r.push(a),i=e;return this.cacheArcLengths=r,r},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){var n,r=this.getLengths(),i=0,a=r.length;n=e||t*r[a-1];for(var o,s=0,c=a-1;s<=c;)if((o=r[i=Math.floor(s+(c-s)/2)]-n)<0)s=i+1;else{if(!(o>0)){c=i;break}c=i-1}if(r[i=c]===n)return i/(a-1);var l=r[i];return(i+(n-l)/(r[i+1]-l))/(a-1)},getTangent:function(t){var e=t-1e-4,n=t+1e-4;e<0&&(e=0),n>1&&(n=1);var r=this.getPoint(e);return this.getPoint(n).clone().sub(r).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var n,r,i,a=new Sn,o=[],s=[],c=[],l=new Sn,u=new Hn;for(n=0;n<=t;n++)r=n/t,o[n]=this.getTangentAt(r),o[n].normalize();s[0]=new Sn,c[0]=new Sn;var h=Number.MAX_VALUE,d=Math.abs(o[0].x),p=Math.abs(o[0].y),f=Math.abs(o[0].z);for(d<=h&&(h=d,a.set(1,0,0)),p<=h&&(h=p,a.set(0,1,0)),f<=h&&a.set(0,0,1),l.crossVectors(o[0],a).normalize(),s[0].crossVectors(o[0],l),c[0].crossVectors(o[0],s[0]),n=1;n<=t;n++)s[n]=s[n-1].clone(),c[n]=c[n-1].clone(),l.crossVectors(o[n-1],o[n]),l.length()>Number.EPSILON&&(l.normalize(),i=Math.acos(xn.clamp(o[n-1].dot(o[n]),-1,1)),s[n].applyMatrix4(u.makeRotationAxis(l,i))),c[n].crossVectors(o[n],s[n]);if(!0===e)for(i=Math.acos(xn.clamp(s[0].dot(s[t]),-1,1)),i/=t,o[0].dot(l.crossVectors(s[0],s[t]))>0&&(i=-i),n=1;n<=t;n++)s[n].applyMatrix4(u.makeRotationAxis(o[n],i*n)),c[n].crossVectors(o[n],s[n]);return{tangents:o,normals:s,binormals:c}},clone:function(){return(new this.constructor).copy(this)},copy:function(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}}),vu.prototype=Object.create(mu.prototype),vu.prototype.constructor=vu,vu.prototype.isEllipseCurve=!0,vu.prototype.getPoint=function(t,e){for(var n=e||new bn,r=2*Math.PI,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)r;)i-=r;i0?0:(Math.floor(Math.abs(u)/c)+1)*c:0===h&&u===c-1&&(u=c-2,h=1),this.closed||u>0?n=s[(u-1)%c]:(xu.subVectors(s[0],s[1]).add(s[0]),n=xu),r=s[u%c],i=s[(u+1)%c],this.closed||u+2r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(Su(o,s.x,c.x,l.x,u.x),Su(o,s.y,c.y,l.y,u.y)),n},Du.prototype.copy=function(t){mu.prototype.copy.call(this,t),this.points=[];for(var e=0,n=t.points.length;e=e){var i=n[r]-e,a=this.curves[r],o=a.getLength(),s=0===o?0:1-i/o;return a.getPointAt(s)}r++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,n=0,r=this.curves.length;n1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},copy:function(t){mu.prototype.copy.call(this,t),this.curves=[];for(var e=0,n=t.curves.length;e0){var l=c.getPoint(0);l.equals(this.currentPoint)||this.lineTo(l.x,l.y)}this.curves.push(c);var u=c.getPoint(1);return this.currentPoint.copy(u),this},copy:function(t){return Nu.prototype.copy.call(this,t),this.currentPoint.copy(t.currentPoint),this},toJSON:function(){var t=Nu.prototype.toJSON.call(this);return t.currentPoint=this.currentPoint.toArray(),t},fromJSON:function(t){return Nu.prototype.fromJSON.call(this,t),this.currentPoint.fromArray(t.currentPoint),this}}),Fu.prototype=Object.assign(Object.create(Bu.prototype),{constructor:Fu,getPointsHoles:function(t){for(var e=[],n=0,r=this.holes.length;n0){var a=new du(new iu(e));a.setCrossOrigin(this.crossOrigin);for(var o=0,s=t.length;o0?new js(o,s):new Gi(o,s);break;case"InstancedMesh":o=i(t.geometry),s=a(t.material);var c=t.count,l=t.instanceMatrix;(r=new Zs(o,s,c)).instanceMatrix=new ri(new Float32Array(l.array),16);break;case"LOD":r=new ks;break;case"Line":r=new nc(i(t.geometry),a(t.material),t.mode);break;case"LineLoop":r=new oc(i(t.geometry),a(t.material));break;case"LineSegments":r=new ac(i(t.geometry),a(t.material));break;case"PointCloud":case"Points":r=new dc(i(t.geometry),a(t.material));break;case"Sprite":r=new Us(a(t.material));break;case"Group":r=new ps;break;default:r=new ar}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(r.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(r.matrixAutoUpdate=t.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.frustumCulled&&(r.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(r.renderOrder=t.renderOrder),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.layers&&(r.layers.mask=t.layers),void 0!==t.drawMode&&r.setDrawMode(t.drawMode),void 0!==t.children)for(var u=t.children,h=0;hNumber.EPSILON){if(l<0&&(o=e[a],c=-c,s=e[i],l=-l),t.ys.y)continue;if(t.y===o.y){if(t.x===o.x)return!0}else{var u=l*(t.x-o.x)-c*(t.y-o.y);if(0===u)return!0;if(u<0)continue;r=!r}}else{if(t.y!==o.y)continue;if(s.x<=t.x&&t.x<=o.x||o.x<=t.x&&t.x<=s.x)return!0}}return r}var i=al.isClockWise,a=this.subPaths;if(0===a.length)return[];if(!0===e)return n(a);var o,s,c,l=[];if(1===a.length)return s=a[0],(c=new Fu).curves=s.curves,l.push(c),l;var u=!i(a[0].getPoints());u=t?!u:u;var h,d,p=[],f=[],m=[],v=0;f[v]=void 0,m[v]=[];for(var g=0,y=a.length;g1){for(var x=!1,b=[],w=0,_=f.length;w<_;w++)p[w]=[];for(w=0,_=f.length;w<_;w++)for(var M=m[w],S=0;S0&&(x||(m=p))}g=0;for(var L=f.length;g0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var a=0;a!==i;++a)t[e+a]=t[n+a]},_slerp:function(t,e,n,r){wn.slerpFlat(t,e,t,e,t,n,r)},_lerp:function(t,e,n,r,i){for(var a=1-r,o=0;o!==i;++o){var s=e+o;t[s]=t[s]*a+t[n+o]*r}}});var Nh=new RegExp("[\\[\\]\\.:\\/]","g"),Bh="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",Fh=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]"),zh=/(WCOD+)?/.source.replace("WCOD",Bh),Uh=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Gh=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Hh=new RegExp("^"+Fh+zh+Uh+Gh+"$"),Vh=["material","materials","bones"];function kh(t,e,n){var r=n||jh.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}function jh(t,e,n){this.path=e,this.parsedPath=n||jh.parseTrackName(e),this.node=jh.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function Wh(){this.uuid=xn.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var t={};this._indicesByUUID=t;for(var e=0,n=arguments.length;e!==n;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var r=this;this.stats={objects:{get total(){return r._objects.length},get inUse(){return this.total-r.nCachedObjects_}},get bindingsPerObject(){return r._bindings.length}}}function qh(t,e,n){this._mixer=t,this._clip=e,this._localRoot=n||null;for(var r=e.tracks,i=r.length,a=new Array(i),o={endingStart:Ae,endingEnd:Ae},s=0;s!==i;++s){var c=r[s].createInterpolant(null);a[s]=c,c.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=we,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 Xh(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Yh(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function Zh(t,e,n){Ss.call(this,t,e),this.meshPerAttribute=n||1}function Jh(t,e,n,r){this.ray=new Pr(t,e),this.near=n||0,this.far=r||1/0,this.camera=null,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 Qh(t,e){return t.distance-e.distance}function Kh(t,e,n,r){if(!1!==t.visible&&(t.raycast(e,n),!0===r))for(var i=t.children,a=0,o=i.length;a=t){var u=t++,h=e[u];n[h.uuid]=l,e[l]=h,n[c]=u,e[u]=s;for(var d=0,p=i;d!==p;++d){var f=r[d],m=f[u],v=f[l];f[l]=m,f[u]=v}}}this.nCachedObjects_=t},uncache:function(){for(var e=this._objects,t=e.length,n=this.nCachedObjects_,r=this._indicesByUUID,i=this._bindings,a=i.length,o=0,s=arguments.length;o!==s;++o){var c=arguments[o],l=c.uuid,u=r[l];if(void 0!==u)if(delete r[l],u0)for(var c=this._interpolants,l=this._propertyBindings,u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulate(r,s)}else this._updateWeight(e)},_updateWeight:function(e){var t=0;if(this.enabled){t=this.weight;var n=this._weightInterpolant;if(null!==n){var r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=t,t},_updateTimeScale:function(e){var t=0;if(!this.paused){t=this.timeScale;var n=this._timeScaleInterpolant;if(null!==n)t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}return this._effectiveTimeScale=t,t},_updateTime:function(e){var t=this.time+e,n=this._clip.duration,r=this.loop,i=this._loopCount,a=r===wt;if(0===e)return-1===i?t:a&&1==(1&i)?n-t:t;if(r===xt){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(t>=n)t=n;else{if(!(t<0)){this.time=t;break e}t=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=t,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===i&&(e>=0?(i=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),t>=n||t<0){var o=Math.floor(t/n);t-=n*o,i+=Math.abs(o);var s=this.repetitions-i;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,t=e>0?n:0,this.time=t,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===s){var c=e<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=t,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=t;if(a&&1==(1&i))return n-t}return t},_setEndings:function(e,t,n){var r=this._interpolantSettings;n?(r.endingStart=Tt,r.endingEnd=Tt):(r.endingStart=e?this.zeroSlopeAtStart?Tt:St:Lt,r.endingEnd=t?this.zeroSlopeAtEnd?Tt:St:Lt)},_scheduleFading:function(e,t,n){var r=this._mixer,i=r.time,a=this._weightInterpolant;null===a&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=t,o[1]=i+e,s[1]=n,this}}),qh.prototype=Object.assign(Object.create(vn.prototype),{constructor:qh,_bindAction:function(e,t){var n=e._localRoot||this._root,r=e._clip.tracks,i=r.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,c=this._bindingsByRootAndName,l=c[s];void 0===l&&(l={},c[s]=l);for(var u=0;u!==i;++u){var h=r[u],d=h.name,p=l[d];if(void 0!==p)a[u]=p;else{if(void 0!==(p=a[u])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,s,d));continue}var f=t&&t._propertyBindings[u].binding.parsedPath;++(p=new Oh(jh.create(n,d,f),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(p,s,d),a[u]=p}o[u].resultBuffer=p.buffer}},_activateAction:function(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t)}for(var i=e._propertyBindings,a=0,o=i.length;a!==o;++a){var s=i[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}},_deactivateAction:function(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,n=0,r=t.length;n!==r;++n){var i=t[n];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(e)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}},_isActiveAction:function(e){var t=e._cacheIndex;return null!==t&&tthis.max.x||e.ythis.max.y)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y},getParameter:function(e,t){return void 0===t&&(console.warn("THREE.Box2: .getParameter() target is now required"),t=new xn),t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)},clampPoint:function(e,t){return void 0===t&&(console.warn("THREE.Box2: .clampPoint() target is now required"),t=new xn),t.copy(e).clamp(this.min,this.max)},distanceToPoint:function(e){return td.copy(e).clamp(this.min,this.max).sub(e).length()},intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}});var rd=new Mn,id=new Mn;function ad(e,t){this.start=void 0!==e?e:new Mn,this.end=void 0!==t?t:new Mn}function od(e){ar.call(this),this.material=e,this.render=function(){}}Object.assign(ad.prototype,{set:function(e,t){return this.start.copy(e),this.end.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.start.copy(e.start),this.end.copy(e.end),this},getCenter:function(e){return void 0===e&&(console.warn("THREE.Line3: .getCenter() target is now required"),e=new Mn),e.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(e){return void 0===e&&(console.warn("THREE.Line3: .delta() target is now required"),e=new Mn),e.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(e,t){return void 0===t&&(console.warn("THREE.Line3: .at() target is now required"),t=new Mn),this.delta(t).multiplyScalar(e).add(this.start)},closestPointToPointParameter:function(e,t){rd.subVectors(e,this.start),id.subVectors(this.end,this.start);var n=id.dot(id),r=id.dot(rd)/n;return t&&(r=An.clamp(r,0,1)),r},closestPointToPoint:function(e,t,n){var r=this.closestPointToPointParameter(e,t);return void 0===n&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),n=new Mn),this.delta(n).multiplyScalar(r).add(this.start)},applyMatrix4:function(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this},equals:function(e){return e.start.equals(this.start)&&e.end.equals(this.end)}}),od.prototype=Object.create(ar.prototype),od.prototype.constructor=od,od.prototype.isImmediateRenderObject=!0;var sd=new Mn,cd=new Mn,ld=new Tn,ud=["a","b","c"];function hd(e,t,n,r){this.object=e,this.size=void 0!==t?t:1;var i=void 0!==n?n:16711680,a=void 0!==r?r:1,o=0,s=this.object.geometry;s&&s.isGeometry?o=3*s.faces.length:s&&s.isBufferGeometry&&(o=s.attributes.normal.count);var c=new wi,l=new hi(2*o*3,3);c.setAttribute("position",l),ac.call(this,c,new Zs({color:i,linewidth:a})),this.matrixAutoUpdate=!1,this.update()}hd.prototype=Object.create(ac.prototype),hd.prototype.constructor=hd,hd.prototype.update=function(){this.object.updateMatrixWorld(!0),ld.getNormalMatrix(this.object.matrixWorld);var e=this.object.matrixWorld,t=this.geometry.attributes.position,n=this.object.geometry;if(n&&n.isGeometry)for(var r=n.vertices,i=n.faces,a=0,o=0,s=i.length;o1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}},Ad.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()};var xd=new Mn,bd=new Yr,wd=new Yr;function _d(e,t,n){ar.call(this),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;var r=new Sc(t);r.rotateY(.5*Math.PI),this.material=new ni({wireframe:!0,fog:!1}),void 0===this.color&&(this.material.vertexColors=_);var i=r.getAttribute("position"),a=new Float32Array(3*i.count);r.setAttribute("color",new ri(a,3)),this.add(new zi(r,this.material)),this.update()}function Md(e,t){this.lightProbe=e,this.size=t;var n={GAMMA_OUTPUT:""},r=new ta({defines:n,uniforms:{sh:{value:this.lightProbe.sh.coefficients},intensity:{value:this.lightProbe.intensity}},vertexShader:["varying vec3 vNormal;","void main() {","\tvNormal = normalize( normalMatrix * normal );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#define RECIPROCAL_PI 0.318309886","vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {","\t// matrix is assumed to be orthogonal","\treturn normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );","}","vec3 linearToOutput( in vec3 a ) {","\t#ifdef GAMMA_OUTPUT","\t\treturn pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );","\t#else","\t\treturn a;","\t#endif","}","// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf","vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {","\t// normal is assumed to have unit length","\tfloat x = normal.x, y = normal.y, z = normal.z;","\t// band 0","\tvec3 result = shCoefficients[ 0 ] * 0.886227;","\t// band 1","\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;","\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;","\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;","\t// band 2","\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;","\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;","\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );","\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;","\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );","\treturn result;","}","uniform vec3 sh[ 9 ]; // sh coefficients","uniform float intensity; // light probe intensity","varying vec3 vNormal;","void main() {","\tvec3 normal = normalize( vNormal );","\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );","\tvec3 irradiance = shGetIrradianceAt( worldNormal, sh );","\tvec3 outgoingLight = RECIPROCAL_PI * irradiance * intensity;","\toutgoingLight = linearToOutput( outgoingLight );","\tgl_FragColor = vec4( outgoingLight, 1.0 );","}"].join("\n")}),i=new ml(1,32,16);zi.call(this,i,r),this.onBeforeRender()}function Ed(e,t,n,r){e=e||10,t=t||10,n=new Yr(void 0!==n?n:4473924),r=new Yr(void 0!==r?r:8947848);for(var i=t/2,a=e/t,o=e/2,s=[],c=[],l=0,u=0,h=-o;l<=t;l++,h+=a){s.push(-o,0,h,o,0,h),s.push(h,0,-o,h,0,o);var d=l===i?n:r;d.toArray(c,u),u+=3,d.toArray(c,u),u+=3,d.toArray(c,u),u+=3,d.toArray(c,u),u+=3}var p=new wi;p.setAttribute("position",new hi(s,3)),p.setAttribute("color",new hi(c,3));var f=new Zs({vertexColors:_});ac.call(this,p,f)}function Sd(e,t,n,r,i,a){e=e||10,t=t||16,n=n||8,r=r||64,i=new Yr(void 0!==i?i:4473924),a=new Yr(void 0!==a?a:8947848);var o,s,c,l,u,h,d,p=[],f=[];for(l=0;l<=t;l++)c=l/t*(2*Math.PI),o=Math.sin(c)*e,s=Math.cos(c)*e,p.push(0,0,0),p.push(o,0,s),d=1&l?i:a,f.push(d.r,d.g,d.b),f.push(d.r,d.g,d.b);for(l=0;l<=n;l++)for(d=1&l?i:a,h=e-e/n*l,u=0;u.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Xd.set(e.z,0,-e.x).normalize();var t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Xd,t)}},qd.prototype.setLength=function(e,t,n){void 0===t&&(t=.2*e),void 0===n&&(n=.2*t),this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()},qd.prototype.setColor=function(e){this.line.material.color.set(e),this.cone.material.color.set(e)},qd.prototype.copy=function(e){return ar.prototype.copy.call(this,e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this},qd.prototype.clone=function(){return(new this.constructor).copy(this)},Qd.prototype=Object.create(ac.prototype),Qd.prototype.constructor=Qd;var Zd=0,Jd=1;function Kd(e){return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."),e}function $d(e){return void 0===e&&(e=[]),console.warn("THREE.MultiMaterial has been removed. Use an Array instead."),e.isMultiMaterial=!0,e.materials=e,e.clone=function(){return e.slice()},e}function ep(e,t){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new dc(e,t)}function tp(e){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new Us(e)}function np(e,t){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new dc(e,t)}function rp(e){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new sc(e)}function ip(e){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new sc(e)}function ap(e){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new sc(e)}function op(e,t,n){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new Mn(e,t,n)}function sp(e,t){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead."),new ri(e,t).setDynamic(!0)}function cp(e,t){return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."),new ii(e,t)}function lp(e,t){return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."),new ai(e,t)}function up(e,t){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."),new oi(e,t)}function hp(e,t){return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."),new si(e,t)}function dp(e,t){return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."),new ci(e,t)}function pp(e,t){return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."),new li(e,t)}function fp(e,t){return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."),new ui(e,t)}function mp(e,t){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new hi(e,t)}function vp(e,t){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new di(e,t)}function gp(e){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),_u.call(this,e),this.type="catmullrom",this.closed=!0}function yp(e){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),_u.call(this,e),this.type="catmullrom"}function Ap(e){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),_u.call(this,e),this.type="catmullrom"}function xp(e){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new Qd(e)}function bp(e,t){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Hd(e,t)}function wp(e,t){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new ac(new _l(e.geometry),new Zs({color:void 0!==t?t:16777215}))}function _p(e,t){return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."),new ac(new yc(e.geometry),new Zs({color:void 0!==t?t:16777215}))}function Mp(e){return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."),new cu(e)}function Ep(e){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new hu(e)}mu.create=function(e,t){return console.log("THREE.Curve.create() has been deprecated"),e.prototype=Object.create(mu.prototype),e.prototype.constructor=e,e.prototype.getPoint=t,e},Object.assign(Nu.prototype,{createPointsGeometry:function(e){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var t=this.getPoints(e);return this.createGeometry(t)},createSpacedPointsGeometry:function(e){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");var t=this.getSpacedPoints(e);return this.createGeometry(t)},createGeometry:function(e){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var t=new qi,n=0,r=e.length;n0&&i[i.length-1])&&(6===a[0]||2===a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])&&(6===a[0]||2===a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0){var o=r[0],s=new i.Matrix4;s.getInverse(e.matrixWorld);var c=o.object;c.matrix.premultiply(s),c.matrix.decompose(c.position,c.quaternion,c.scale),e.add(c),e.userData.selected=c}}),!1),document.body.addEventListener("mouseup",(function(){if(void 0!==e.userData.selected){var n=e.userData.selected;n.matrix.premultiply(e.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale),e.remove(n),t.add(n),e.userData.selected=void 0}}),!1)}},function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=e){var u=e++,h=t[u];n[h.uuid]=l,t[l]=h,n[c]=u,t[u]=s;for(var d=0,p=i;d!==p;++d){var f=r[d],m=f[u],v=f[l];f[l]=m,f[u]=v}}}this.nCachedObjects_=e},uncache:function(){for(var t=this._objects,e=t.length,n=this.nCachedObjects_,r=this._indicesByUUID,i=this._bindings,a=i.length,o=0,s=arguments.length;o!==s;++o){var c=arguments[o],l=c.uuid,u=r[l];if(void 0!==u)if(delete r[l],u0)for(var c=this._interpolants,l=this._propertyBindings,u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulate(r,s)}else this._updateWeight(t)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var n=this._weightInterpolant;if(null!==n){var r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var n=this._timeScaleInterpolant;if(null!==n)e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t,n=this._clip.duration,r=this.loop,i=this._loopCount,a=r===_e;if(0===t)return-1===i?e:a&&1==(1&i)?n-e:e;if(r===be){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=n)e=n;else{if(!(e<0)){this.time=e;break t}e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=e,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),e>=n||e<0){var o=Math.floor(e/n);e-=n*o,i+=Math.abs(o);var s=this.repetitions-i;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?n:0,this.time=e,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===s){var c=t<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=e;if(a&&1==(1&i))return n-e}return e},_setEndings:function(t,e,n){var r=this._interpolantSettings;n?(r.endingStart=Te,r.endingEnd=Te):(r.endingStart=t?this.zeroSlopeAtStart?Te:Ae:Le,r.endingEnd=e?this.zeroSlopeAtEnd?Te:Ae:Le)},_scheduleFading:function(t,e,n){var r=this._mixer,i=r.time,a=this._weightInterpolant;null===a&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=e,o[1]=i+t,s[1]=n,this}}),Xh.prototype=Object.assign(Object.create(vn.prototype),{constructor:Xh,_bindAction:function(t,e){var n=t._localRoot||this._root,r=t._clip.tracks,i=r.length,a=t._propertyBindings,o=t._interpolants,s=n.uuid,c=this._bindingsByRootAndName,l=c[s];void 0===l&&(l={},c[s]=l);for(var u=0;u!==i;++u){var h=r[u],d=h.name,p=l[d];if(void 0!==p)a[u]=p;else{if(void 0!==(p=a[u])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,s,d));continue}var f=e&&e._propertyBindings[u].binding.parsedPath;++(p=new Ih(jh.create(n,d,f),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(p,s,d),a[u]=p}o[u].resultBuffer=p.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,n=t._clip.uuid,r=this._actionsByClip[n];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,n,e)}for(var i=t._propertyBindings,a=0,o=i.length;a!==o;++a){var s=i[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,n=0,r=e.length;n!==r;++n){var i=e[n];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&ethis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .getParameter() target is now required"),e=new bn),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .clampPoint() target is now required"),e=new bn),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return ed.copy(t).clamp(this.min,this.max).sub(t).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)}});var rd=new Sn,id=new Sn;function ad(t,e){this.start=void 0!==t?t:new Sn,this.end=void 0!==e?e:new Sn}function od(t){ar.call(this),this.material=t,this.render=function(){}}Object.assign(ad.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return void 0===t&&(console.warn("THREE.Line3: .getCenter() target is now required"),t=new Sn),t.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return void 0===t&&(console.warn("THREE.Line3: .delta() target is now required"),t=new Sn),t.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){return void 0===e&&(console.warn("THREE.Line3: .at() target is now required"),e=new Sn),this.delta(e).multiplyScalar(t).add(this.start)},closestPointToPointParameter:function(t,e){rd.subVectors(t,this.start),id.subVectors(this.end,this.start);var n=id.dot(id),r=id.dot(rd)/n;return e&&(r=xn.clamp(r,0,1)),r},closestPointToPoint:function(t,e,n){var r=this.closestPointToPointParameter(t,e);return void 0===n&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),n=new Sn),this.delta(n).multiplyScalar(r).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}}),od.prototype=Object.create(ar.prototype),od.prototype.constructor=od,od.prototype.isImmediateRenderObject=!0;var sd=new Sn,cd=new Sn,ld=new Tn,ud=["a","b","c"];function hd(t,e,n,r){this.object=t,this.size=void 0!==e?e:1;var i=void 0!==n?n:16711680,a=void 0!==r?r:1,o=0,s=this.object.geometry;s&&s.isGeometry?o=3*s.faces.length:s&&s.isBufferGeometry&&(o=s.attributes.normal.count);var c=new _i,l=new hi(2*o*3,3);c.setAttribute("position",l),ac.call(this,c,new Js({color:i,linewidth:a})),this.matrixAutoUpdate=!1,this.update()}hd.prototype=Object.create(ac.prototype),hd.prototype.constructor=hd,hd.prototype.update=function(){this.object.updateMatrixWorld(!0),ld.getNormalMatrix(this.object.matrixWorld);var t=this.object.matrixWorld,e=this.geometry.attributes.position,n=this.object.geometry;if(n&&n.isGeometry)for(var r=n.vertices,i=n.faces,a=0,o=0,s=i.length;o1&&t.multiplyScalar(1/e),this.children[0].material.color.copy(this.material.color)}},xd.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()};var bd=new Sn,wd=new Zr,_d=new Zr;function Md(t,e,n){ar.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;var r=new Ac(e);r.rotateY(.5*Math.PI),this.material=new ni({wireframe:!0,fog:!1}),void 0===this.color&&(this.material.vertexColors=M);var i=r.getAttribute("position"),a=new Float32Array(3*i.count);r.setAttribute("color",new ri(a,3)),this.add(new Gi(r,this.material)),this.update()}function Sd(t,e){this.lightProbe=t,this.size=e;var n={GAMMA_OUTPUT:""},r=new ea({defines:n,uniforms:{sh:{value:this.lightProbe.sh.coefficients},intensity:{value:this.lightProbe.intensity}},vertexShader:["varying vec3 vNormal;","void main() {","\tvNormal = normalize( normalMatrix * normal );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#define RECIPROCAL_PI 0.318309886","vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {","\t// matrix is assumed to be orthogonal","\treturn normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );","}","vec3 linearToOutput( in vec3 a ) {","\t#ifdef GAMMA_OUTPUT","\t\treturn pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );","\t#else","\t\treturn a;","\t#endif","}","// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf","vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {","\t// normal is assumed to have unit length","\tfloat x = normal.x, y = normal.y, z = normal.z;","\t// band 0","\tvec3 result = shCoefficients[ 0 ] * 0.886227;","\t// band 1","\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;","\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;","\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;","\t// band 2","\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;","\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;","\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );","\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;","\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );","\treturn result;","}","uniform vec3 sh[ 9 ]; // sh coefficients","uniform float intensity; // light probe intensity","varying vec3 vNormal;","void main() {","\tvec3 normal = normalize( vNormal );","\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );","\tvec3 irradiance = shGetIrradianceAt( worldNormal, sh );","\tvec3 outgoingLight = RECIPROCAL_PI * irradiance * intensity;","\toutgoingLight = linearToOutput( outgoingLight );","\tgl_FragColor = vec4( outgoingLight, 1.0 );","}"].join("\n")}),i=new ml(1,32,16);Gi.call(this,i,r),this.onBeforeRender()}function Ed(t,e,n,r){t=t||10,e=e||10,n=new Zr(void 0!==n?n:4473924),r=new Zr(void 0!==r?r:8947848);for(var i=e/2,a=t/e,o=t/2,s=[],c=[],l=0,u=0,h=-o;l<=e;l++,h+=a){s.push(-o,0,h,o,0,h),s.push(h,0,-o,h,0,o);var d=l===i?n:r;d.toArray(c,u),u+=3,d.toArray(c,u),u+=3,d.toArray(c,u),u+=3,d.toArray(c,u),u+=3}var p=new _i;p.setAttribute("position",new hi(s,3)),p.setAttribute("color",new hi(c,3));var f=new Js({vertexColors:M});ac.call(this,p,f)}function Ad(t,e,n,r,i,a){t=t||10,e=e||16,n=n||8,r=r||64,i=new Zr(void 0!==i?i:4473924),a=new Zr(void 0!==a?a:8947848);var o,s,c,l,u,h,d,p=[],f=[];for(l=0;l<=e;l++)c=l/e*(2*Math.PI),o=Math.sin(c)*t,s=Math.cos(c)*t,p.push(0,0,0),p.push(o,0,s),d=1&l?i:a,f.push(d.r,d.g,d.b),f.push(d.r,d.g,d.b);for(l=0;l<=n;l++)for(d=1&l?i:a,h=t-t/n*l,u=0;u.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{qd.set(t.z,0,-t.x).normalize();var e=Math.acos(t.y);this.quaternion.setFromAxisAngle(qd,e)}},Xd.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(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()},Xd.prototype.setColor=function(t){this.line.material.color.set(t),this.cone.material.color.set(t)},Xd.prototype.copy=function(t){return ar.prototype.copy.call(this,t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this},Xd.prototype.clone=function(){return(new this.constructor).copy(this)},Yd.prototype=Object.create(ac.prototype),Yd.prototype.constructor=Yd;var Jd=0,Qd=1;function Kd(t){return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."),t}function $d(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 tp(t,e){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new dc(t,e)}function ep(t){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new Us(t)}function np(t,e){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new dc(t,e)}function rp(t){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new sc(t)}function ip(t){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new sc(t)}function ap(t){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new sc(t)}function op(t,e,n){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new Sn(t,e,n)}function sp(t,e){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead."),new ri(t,e).setDynamic(!0)}function cp(t,e){return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."),new ii(t,e)}function lp(t,e){return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."),new ai(t,e)}function up(t,e){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."),new oi(t,e)}function hp(t,e){return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."),new si(t,e)}function dp(t,e){return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."),new ci(t,e)}function pp(t,e){return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."),new li(t,e)}function fp(t,e){return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."),new ui(t,e)}function mp(t,e){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new hi(t,e)}function vp(t,e){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new di(t,e)}function gp(t){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Mu.call(this,t),this.type="catmullrom",this.closed=!0}function yp(t){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Mu.call(this,t),this.type="catmullrom"}function xp(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),Mu.call(this,t),this.type="catmullrom"}function bp(t){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new Yd(t)}function wp(t,e){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Hd(t,e)}function _p(t,e){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new ac(new Ml(t.geometry),new Js({color:void 0!==e?e:16777215}))}function Mp(t,e){return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."),new ac(new yc(t.geometry),new Js({color:void 0!==e?e:16777215}))}function Sp(t){return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."),new cu(t)}function Ep(t){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new hu(t)}mu.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(mu.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},Object.assign(Nu.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 Xi,n=0,r=t.length;n0?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>8&255]+gn[t>>16&255]+gn[t>>24&255]+"-"+gn[255&e]+gn[e>>8&255]+"-"+gn[e>>16&15|64]+gn[e>>24&255]+"-"+gn[63&n|128]+gn[n>>8&255]+"-"+gn[n>>16&255]+gn[n>>24&255]+gn[255&r]+gn[r>>8&255]+gn[r>>16&255]+gn[r>>24&255]).toUpperCase()},clamp:function(t,e,n){return Math.max(e,Math.min(n,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)},lerp:function(t,e,n){return(1-n)*t+n*e},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*xn.DEG2RAD},radToDeg:function(t){return t*xn.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 bn(t,e){this.x=t||0,this.y=e||0}function wn(t,e,n,r){this._x=t||0,this._y=e||0,this._z=n||0,this._w=void 0!==r?r:1}Object.defineProperties(bn.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(bn.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},applyMatrix3:function(t){var e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this},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},cross:function(t){return this.x*t.y-this.y*t.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,n=this.y-t.y;return e*e+n*n},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var n=Math.cos(e),r=Math.sin(e),i=this.x-t.x,a=this.y-t.y;return this.x=i*n-a*r+t.x,this.y=i*r+a*n+t.y,this}}),Object.assign(wn,{slerp:function(t,e,n,r){return n.copy(t).slerp(e,r)},slerpFlat:function(t,e,n,r,i,a,o){var s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],h=i[a+0],d=i[a+1],p=i[a+2],f=i[a+3];if(u!==f||s!==h||c!==d||l!==p){var m=1-o,v=s*h+c*d+l*p+u*f,g=v>=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var x=Math.sqrt(y),b=Math.atan2(x,v*g);m=Math.sin(m*b)/x,o=Math.sin(o*b)/x}var w=o*g;if(s=s*m+h*w,c=c*m+d*w,l=l*m+p*w,u=u*m+f*w,m===1-o){var _=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=_,c*=_,l*=_,u*=_}}t[e]=s,t[e+1]=c,t[e+2]=l,t[e+3]=u}}),Object.defineProperties(wn.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(wn.prototype,{isQuaternion:!0,set:function(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=t._x,r=t._y,i=t._z,a=t.order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),h=s(n/2),d=s(r/2),p=s(i/2);return"XYZ"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u-h*d*p):"YXZ"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u+h*d*p):"ZXY"===a?(this._x=h*l*u-c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u-h*d*p):"ZYX"===a?(this._x=h*l*u-c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u+h*d*p):"YZX"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u-h*d*p):"XZY"===a&&(this._x=h*l*u-c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u+h*d*p),!1!==e&&this._onChangeCallback(),this},setFromAxisAngle:function(t,e){var n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this},setFromRotationMatrix:function(t){var e,n=t.elements,r=n[0],i=n[4],a=n[8],o=n[1],s=n[5],c=n[9],l=n[2],u=n[6],h=n[10],d=r+s+h;return d>0?(e=.5/Math.sqrt(d+1),this._w=.25/e,this._x=(u-c)*e,this._y=(a-l)*e,this._z=(o-i)*e):r>s&&r>h?(e=2*Math.sqrt(1+r-s-h),this._w=(u-c)/e,this._x=.25*e,this._y=(i+o)/e,this._z=(a+l)/e):s>h?(e=2*Math.sqrt(1+s-r-h),this._w=(a-l)/e,this._x=(i+o)/e,this._y=.25*e,this._z=(c+u)/e):(e=2*Math.sqrt(1+h-r-s),this._w=(o-i)/e,this._x=(a+l)/e,this._y=(c+u)/e,this._z=.25*e),this._onChangeCallback(),this},setFromUnitVectors:function(t,e){var n=t.dot(e)+1;return n<1e-6?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()},angleTo:function(t){return 2*Math.acos(Math.abs(xn.clamp(this.dot(t),-1,1)))},rotateTowards:function(t,e){var n=this.angleTo(t);if(0===n)return this;var r=Math.min(1,e/n);return this.slerp(t,r),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var n=t._x,r=t._y,i=t._z,a=t._w,o=e._x,s=e._y,c=e._z,l=e._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var n=this._x,r=this._y,i=this._z,a=this._w,o=a*t._w+n*t._x+r*t._y+i*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;var s=1-o*o;if(s<=Number.EPSILON){var c=1-e;return this._w=c*a+e*this._w,this._x=c*n+e*this._x,this._y=c*r+e*this._y,this._z=c*i+e*this._z,this.normalize(),this._onChangeCallback(),this}var l=Math.sqrt(s),u=Math.atan2(l,o),h=Math.sin((1-e)*u)/l,d=Math.sin(e*u)/l;return this._w=a*h+this._w*d,this._x=n*h+this._x*d,this._y=r*h+this._y*d,this._z=i*h+this._z*d,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(){}});var _n=new Sn,Mn=new wn;function Sn(t,e,n){this.x=t||0,this.y=e||0,this.z=n||0}Object.assign(Sn.prototype,{isVector3:!0,set:function(t,e,n){return this.x=t,this.y=e,this.z=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Mn.setFromEuler(t))},applyAxisAngle:function(t,e){return this.applyQuaternion(Mn.setFromAxisAngle(t,e))},applyMatrix3:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*r,this.y=i[1]*e+i[4]*n+i[7]*r,this.z=i[2]*e+i[5]*n+i[8]*r,this},applyMatrix4:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements,a=1/(i[3]*e+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*e+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*e+i[6]*n+i[10]*r+i[14])*a,this},applyQuaternion:function(t){var e=this.x,n=this.y,r=this.z,i=t.x,a=t.y,o=t.z,s=t.w,c=s*e+a*r-o*n,l=s*n+o*e-i*r,u=s*r+i*n-a*e,h=-i*e-a*n-o*r;return this.x=c*s+h*-i+l*-o-u*-a,this.y=l*s+h*-a+u*-i-c*-o,this.z=u*s+h*-o+c*-a-l*-i,this},project:function(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)},unproject:function(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)},transformDirection:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*r,this.y=i[1]*e+i[5]*n+i[9]*r,this.z=i[2]*e+i[6]*n+i[10]*r,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this},clampLength:function(t,e){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},cross:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)},crossVectors:function(t,e){var n=t.x,r=t.y,i=t.z,a=e.x,o=e.y,s=e.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(t){return _n.copy(this).projectOnVector(t),this.sub(_n)},reflect:function(t){return this.sub(_n.copy(t).multiplyScalar(2*this.dot(t)))},angleTo:function(t){var e=Math.sqrt(this.lengthSq()*t.lengthSq());0===e&&console.error("THREE.Vector3: angleTo() can't handle zero length vectors.");var n=this.dot(t)/e;return Math.acos(xn.clamp(n,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)},setFromSphericalCoords:function(t,e,n){var r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this},setFromCylindrical:function(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)},setFromCylindricalCoords:function(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}});var En,An=new Sn;function Tn(){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.assign(Tn.prototype,{isMatrix3:!0,set:function(t,e,n,r,i,a,o,s,c){var l=this.elements;return l[0]=t,l[1]=r,l[2]=o,l[3]=e,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(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(t){for(var e=0,n=t.count;e2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}},Rn=0;function Pn(t,e,n,r,i,a,o,s,c,l){Object.defineProperty(this,"id",{value:Rn++}),this.uuid=xn.generateUUID(),this.name="",this.image=void 0!==t?t:Pn.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:Pn.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:yt,this.wrapT=void 0!==r?r:yt,this.magFilter=void 0!==i?i:Et,this.minFilter=void 0!==a?a:Lt,this.anisotropy=void 0!==c?c:1,this.format=void 0!==o?o:jt,this.type=void 0!==s?s:Pt,this.offset=new bn(0,0),this.repeat=new bn(1,1),this.center=new bn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Tn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==l?l:Oe,this.version=0,this.onUpdate=null}function Cn(t,e,n,r){this.x=t||0,this.y=e||0,this.z=n||0,this.w=void 0!==r?r:1}function On(t,e,n){this.width=t,this.height=e,this.scissor=new Cn(0,0,t,e),this.scissorTest=!1,this.viewport=new Cn(0,0,t,e),n=n||{},this.texture=new Pn(void 0,void 0,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.image={},this.texture.image.width=t,this.texture.image.height=e,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:Et,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 Dn(t,e,n){On.call(this,t,e,n),this.samples=4}Pn.DEFAULT_IMAGE=void 0,Pn.DEFAULT_MAPPING=lt,Pn.prototype=Object.assign(Object.create(vn.prototype),{constructor:Pn,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(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],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var r=this.image;if(void 0===r.uuid&&(r.uuid=xn.generateUUID()),!e&&void 0===t.images[r.uuid]){var i;if(Array.isArray(r)){i=[];for(var a=0,o=r.length;a1)switch(this.wrapS){case gt:t.x=t.x-Math.floor(t.x);break;case yt:t.x=t.x<0?0:1;break;case xt: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 gt:t.y=t.y-Math.floor(t.y);break;case yt:t.y=t.y<0?0:1;break;case xt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}}),Object.defineProperty(Pn.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.defineProperties(Cn.prototype,{width:{get:function(){return this.z},set:function(t){this.z=t}},height:{get:function(){return this.w},set:function(t){this.w=t}}}),Object.assign(Cn.prototype,{isVector4:!0,set:function(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,n=this.y,r=this.z,i=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*e+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*e+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*e+a[7]*n+a[11]*r+a[15]*i,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,n,r,i,a=t.elements,o=a[0],s=a[4],c=a[8],l=a[1],u=a[5],h=a[9],d=a[2],p=a[6],f=a[10];if(Math.abs(s-l)<.01&&Math.abs(c-d)<.01&&Math.abs(h-p)<.01){if(Math.abs(s+l)<.1&&Math.abs(c+d)<.1&&Math.abs(h+p)<.1&&Math.abs(o+u+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(o+1)/2,v=(u+1)/2,g=(f+1)/2,y=(s+l)/4,x=(c+d)/4,b=(h+p)/4;return m>v&&m>g?m<.01?(n=0,r=.707106781,i=.707106781):(r=y/(n=Math.sqrt(m)),i=x/n):v>g?v<.01?(n=.707106781,r=0,i=.707106781):(n=y/(r=Math.sqrt(v)),i=b/r):g<.01?(n=.707106781,r=.707106781,i=0):(n=x/(i=Math.sqrt(g)),r=b/i),this.set(n,r,i,e),this}var w=Math.sqrt((p-h)*(p-h)+(c-d)*(c-d)+(l-s)*(l-s));return Math.abs(w)<.001&&(w=1),this.x=(p-h)/w,this.y=(c-d)/w,this.z=(l-s)/w,this.w=Math.acos((o+u+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(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this},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}}),On.prototype=Object.assign(Object.create(vn.prototype),{constructor:On,isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.texture.image.width=t,this.texture.image.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"})}}),Dn.prototype=Object.assign(Object.create(On.prototype),{constructor:Dn,isWebGLMultisampleRenderTarget:!0,copy:function(t){return On.prototype.copy.call(this,t),this.samples=t.samples,this}});var In=new Sn,Nn=new Hn,Bn=new Sn(0,0,0),Fn=new Sn(1,1,1),zn=new Sn,Un=new Sn,Gn=new Sn;function Hn(){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.")}Object.assign(Hn.prototype,{isMatrix4:!0,set:function(t,e,n,r,i,a,o,s,c,l,u,h,d,p,f,m){var v=this.elements;return v[0]=t,v[4]=e,v[8]=n,v[12]=r,v[1]=i,v[5]=a,v[9]=o,v[13]=s,v[2]=c,v[6]=l,v[10]=u,v[14]=h,v[3]=d,v[7]=p,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 Hn).fromArray(this.elements)},copy:function(t){var e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this},copyPosition:function(t){var e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this},extractBasis:function(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this},extractRotation:function(t){var e=this.elements,n=t.elements,r=1/In.setFromMatrixColumn(t,0).length(),i=1/In.setFromMatrixColumn(t,1).length(),a=1/In.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*i,e[5]=n[5]*i,e[6]=n[6]*i,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,n=t.x,r=t.y,i=t.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){var h=a*l,d=a*u,p=o*l,f=o*u;e[0]=s*l,e[4]=-s*u,e[8]=c,e[1]=d+p*c,e[5]=h-f*c,e[9]=-o*s,e[2]=f-h*c,e[6]=p+d*c,e[10]=a*s}else if("YXZ"===t.order){var m=s*l,v=s*u,g=c*l,y=c*u;e[0]=m+y*o,e[4]=g*o-v,e[8]=a*c,e[1]=a*u,e[5]=a*l,e[9]=-o,e[2]=v*o-g,e[6]=y+m*o,e[10]=a*s}else if("ZXY"===t.order){m=s*l,v=s*u,g=c*l,y=c*u;e[0]=m-y*o,e[4]=-a*u,e[8]=g+v*o,e[1]=v+g*o,e[5]=a*l,e[9]=y-m*o,e[2]=-a*c,e[6]=o,e[10]=a*s}else if("ZYX"===t.order){h=a*l,d=a*u,p=o*l,f=o*u;e[0]=s*l,e[4]=p*c-d,e[8]=h*c+f,e[1]=s*u,e[5]=f*c+h,e[9]=d*c-p,e[2]=-c,e[6]=o*s,e[10]=a*s}else if("YZX"===t.order){var x=a*s,b=a*c,w=o*s,_=o*c;e[0]=s*l,e[4]=_-x*u,e[8]=w*u+b,e[1]=u,e[5]=a*l,e[9]=-o*l,e[2]=-c*l,e[6]=b*u+w,e[10]=x-_*u}else if("XZY"===t.order){x=a*s,b=a*c,w=o*s,_=o*c;e[0]=s*l,e[4]=-u,e[8]=c*l,e[1]=x*u+_,e[5]=a*l,e[9]=b*u-w,e[2]=w*u-b,e[6]=o*l,e[10]=_*u+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){return this.compose(Bn,t,Fn)},lookAt:function(t,e,n){var r=this.elements;return Gn.subVectors(t,e),0===Gn.lengthSq()&&(Gn.z=1),Gn.normalize(),zn.crossVectors(n,Gn),0===zn.lengthSq()&&(1===Math.abs(n.z)?Gn.x+=1e-4:Gn.z+=1e-4,Gn.normalize(),zn.crossVectors(n,Gn)),zn.normalize(),Un.crossVectors(Gn,zn),r[0]=zn.x,r[4]=Un.x,r[8]=Gn.x,r[1]=zn.y,r[5]=Un.y,r[9]=Gn.y,r[2]=zn.z,r[6]=Un.z,r[10]=Gn.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var n=t.elements,r=e.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],v=n[14],g=n[3],y=n[7],x=n[11],b=n[15],w=r[0],_=r[4],M=r[8],S=r[12],E=r[1],A=r[5],T=r[9],L=r[13],R=r[2],P=r[6],C=r[10],O=r[14],D=r[3],I=r[7],N=r[11],B=r[15];return i[0]=a*w+o*E+s*R+c*D,i[4]=a*_+o*A+s*P+c*I,i[8]=a*M+o*T+s*C+c*N,i[12]=a*S+o*L+s*O+c*B,i[1]=l*w+u*E+h*R+d*D,i[5]=l*_+u*A+h*P+d*I,i[9]=l*M+u*T+h*C+d*N,i[13]=l*S+u*L+h*O+d*B,i[2]=p*w+f*E+m*R+v*D,i[6]=p*_+f*A+m*P+v*I,i[10]=p*M+f*T+m*C+v*N,i[14]=p*S+f*L+m*O+v*B,i[3]=g*w+y*E+x*R+b*D,i[7]=g*_+y*A+x*P+b*I,i[11]=g*M+y*T+x*C+b*N,i[15]=g*S+y*L+x*O+b*B,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(t){for(var e=0,n=t.count;e1){for(var e=0;e1){for(var e=0;e0){r.children=[];for(s=0;s0&&(n.geometries=h),d.length>0&&(n.materials=d),p.length>0&&(n.textures=p),f.length>0&&(n.images=f),o.length>0&&(n.shapes=o)}return n.object=r,n;function m(t){var e=[];for(var n in t){var r=t[n];delete r.metadata,e.push(r)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var n=0;ns)return!1}return!0}Object.assign(xr.prototype,{isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,c=t.length;si&&(i=l),u>a&&(a=u),h>o&&(o=h)}return this.min.set(e,n,r),this.max.set(i,a,o),this},setFromBufferAttribute:function(t){for(var e=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,c=t.count;si&&(i=l),u>a&&(a=u),h>o&&(o=h)}return this.min.set(e,n,r),this.max.set(i,a,o),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,n=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new Sn),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:function(t){return this.clampPoint(t.center,cr),cr.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(t){if(this.isEmpty())return!1;this.getCenter(mr),vr.subVectors(this.max,mr),lr.subVectors(t.a,mr),ur.subVectors(t.b,mr),hr.subVectors(t.c,mr),dr.subVectors(ur,lr),pr.subVectors(hr,ur),fr.subVectors(lr,hr);var e=[0,-dr.z,dr.y,0,-pr.z,pr.y,0,-fr.z,fr.y,dr.z,0,-dr.x,pr.z,0,-pr.x,fr.z,0,-fr.x,-dr.y,dr.x,0,-pr.y,pr.x,0,-fr.y,fr.x,0];return!!br(e,lr,ur,hr,vr)&&(!!br(e=[1,0,0,0,1,0,0,0,1],lr,ur,hr,vr)&&(gr.crossVectors(dr,pr),br(e=[gr.x,gr.y,gr.z],lr,ur,hr,vr)))},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new Sn),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return cr.copy(t).clamp(this.min,this.max).sub(t).length()},getBoundingSphere:function(t){return void 0===t&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=.5*this.getSize(cr).length(),t},intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(t){return this.isEmpty()?this:(sr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),sr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),sr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),sr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),sr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),sr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),sr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),sr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(sr),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)}});var wr=new xr;function _r(t,e){this.center=void 0!==t?t:new Sn,this.radius=void 0!==e?e:0}Object.assign(_r.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(t,e){var n=this.center;void 0!==e?n.copy(e):wr.setFromPoints(t).getCenter(n);for(var r=0,i=0,a=t.length;ithis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e},getBoundingBox:function(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new xr),t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}});var Mr=new Sn,Sr=new Sn,Er=new Sn,Ar=new Sn,Tr=new Sn,Lr=new Sn,Rr=new Sn;function Pr(t,e){this.origin=void 0!==t?t:new Sn,this.direction=void 0!==e?e:new Sn}Object.assign(Pr.prototype,{set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return void 0===e&&(console.warn("THREE.Ray: .at() target is now required"),e=new Sn),e.copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(t){return this.origin.copy(this.at(t,Mr)),this},closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new Sn),e.subVectors(t,this.origin);var n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(t){var e=Mr.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Mr.copy(this.direction).multiplyScalar(e).add(this.origin),Mr.distanceToSquared(t))},distanceSqToSegment:function(t,e,n,r){Sr.copy(t).add(e).multiplyScalar(.5),Er.copy(e).sub(t).normalize(),Ar.copy(this.origin).sub(Sr);var i,a,o,s,c=.5*t.distanceTo(e),l=-this.direction.dot(Er),u=Ar.dot(this.direction),h=-Ar.dot(Er),d=Ar.lengthSq(),p=Math.abs(1-l*l);if(p>0)if(a=l*u-h,s=c*p,(i=l*h-u)>=0)if(a>=-s)if(a<=s){var f=1/p;o=(i*=f)*(i+l*(a*=f)+2*u)+a*(l*i+a+2*h)+d}else a=c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;else a=-c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;else a<=-s?o=-(i=Math.max(0,-(-l*c+u)))*i+(a=i>0?-c:Math.min(Math.max(-c,-h),c))*(a+2*h)+d:a<=s?(i=0,o=(a=Math.min(Math.max(-c,-h),c))*(a+2*h)+d):o=-(i=Math.max(0,-(l*c+u)))*i+(a=i>0?c:Math.min(Math.max(-c,-h),c))*(a+2*h)+d;else a=l>0?-c:c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;return n&&n.copy(this.direction).multiplyScalar(i).add(this.origin),r&&r.copy(Er).multiplyScalar(a).add(Sr),o},intersectSphere:function(t,e){Mr.subVectors(t.center,this.origin);var n=Mr.dot(this.direction),r=Mr.dot(Mr)-n*n,i=t.radius*t.radius;if(r>i)return null;var a=Math.sqrt(i-r),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,e):this.at(o,e)},intersectsSphere:function(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null},intersectPlane:function(t,e){var n=this.distanceToPlane(t);return null===n?null:this.at(n,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,h=this.origin;return c>=0?(n=(t.min.x-h.x)*c,r=(t.max.x-h.x)*c):(n=(t.max.x-h.x)*c,r=(t.min.x-h.x)*c),l>=0?(i=(t.min.y-h.y)*l,a=(t.max.y-h.y)*l):(i=(t.max.y-h.y)*l,a=(t.min.y-h.y)*l),n>a||i>r?null:((i>n||n!=n)&&(n=i),(a=0?(o=(t.min.z-h.z)*u,s=(t.max.z-h.z)*u):(o=(t.max.z-h.z)*u,s=(t.min.z-h.z)*u),n>s||o>r?null:((o>n||n!=n)&&(n=o),(s=0?n:r,e)))},intersectsBox:function(t){return null!==this.intersectBox(t,Mr)},intersectTriangle:function(t,e,n,r,i){Tr.subVectors(e,t),Lr.subVectors(n,t),Rr.crossVectors(Tr,Lr);var a,o=this.direction.dot(Rr);if(o>0){if(r)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Ar.subVectors(this.origin,t);var s=a*this.direction.dot(Lr.crossVectors(Ar,Lr));if(s<0)return null;var c=a*this.direction.dot(Tr.cross(Ar));if(c<0)return null;if(s+c>o)return null;var l=-a*Ar.dot(Rr);return l<0?null:this.at(l/o,i)},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)}});var Cr=new Sn,Or=new Sn,Dr=new Tn;function Ir(t,e){this.normal=void 0!==t?t:new Sn(1,0,0),this.constant=void 0!==e?e:0}Object.assign(Ir.prototype,{isPlane:!0,set:function(t,e){return this.normal.copy(t),this.constant=e,this},setComponents:function(t,e,n,r){return this.normal.set(t,e,n),this.constant=r,this},setFromNormalAndCoplanarPoint:function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},setFromCoplanarPoints:function(t,e,n){var r=Cr.subVectors(n,e).cross(Or.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,e){return void 0===e&&(console.warn("THREE.Plane: .projectPoint() target is now required"),e=new Sn),e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)},intersectLine:function(t,e){void 0===e&&(console.warn("THREE.Plane: .intersectLine() target is now required"),e=new Sn);var n=t.delta(Cr),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(t.start)?e.copy(t.start):void 0;var i=-(t.start.dot(this.normal)+this.constant)/r;return i<0||i>1?void 0:e.copy(n).multiplyScalar(i).add(t.start)},intersectsLine:function(t){var e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new Sn),t.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(t,e){var n=e||Dr.getNormalMatrix(t),r=this.coplanarPoint(Cr).applyMatrix4(t),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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}});var Nr=new Sn,Br=new Sn,Fr=new Sn,zr=new Sn,Ur=new Sn,Gr=new Sn,Hr=new Sn,Vr=new Sn,kr=new Sn,jr=new Sn;function Wr(t,e,n){this.a=void 0!==t?t:new Sn,this.b=void 0!==e?e:new Sn,this.c=void 0!==n?n:new Sn}Object.assign(Wr,{getNormal:function(t,e,n,r){void 0===r&&(console.warn("THREE.Triangle: .getNormal() target is now required"),r=new Sn),r.subVectors(n,e),Nr.subVectors(t,e),r.cross(Nr);var i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)},getBarycoord:function(t,e,n,r,i){Nr.subVectors(r,e),Br.subVectors(n,e),Fr.subVectors(t,e);var a=Nr.dot(Nr),o=Nr.dot(Br),s=Nr.dot(Fr),c=Br.dot(Br),l=Br.dot(Fr),u=a*c-o*o;if(void 0===i&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),i=new Sn),0===u)return i.set(-2,-1,-1);var h=1/u,d=(c*s-o*l)*h,p=(a*l-o*s)*h;return i.set(1-d-p,p,d)},containsPoint:function(t,e,n,r){return Wr.getBarycoord(t,e,n,r,zr),zr.x>=0&&zr.y>=0&&zr.x+zr.y<=1},getUV:function(t,e,n,r,i,a,o,s){return this.getBarycoord(t,e,n,r,zr),s.set(0,0),s.addScaledVector(i,zr.x),s.addScaledVector(a,zr.y),s.addScaledVector(o,zr.z),s},isFrontFacing:function(t,e,n,r){return Nr.subVectors(n,e),Br.subVectors(t,e),Nr.cross(Br).dot(r)<0}}),Object.assign(Wr.prototype,{set:function(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this},setFromPointsAndIndices:function(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},getArea:function(){return Nr.subVectors(this.c,this.b),Br.subVectors(this.a,this.b),.5*Nr.cross(Br).length()},getMidpoint:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new Sn),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(t){return Wr.getNormal(this.a,this.b,this.c,t)},getPlane:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new Ir),t.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(t,e){return Wr.getBarycoord(t,this.a,this.b,this.c,e)},getUV:function(t,e,n,r,i){return Wr.getUV(t,this.a,this.b,this.c,e,n,r,i)},containsPoint:function(t){return Wr.containsPoint(t,this.a,this.b,this.c)},isFrontFacing:function(t){return Wr.isFrontFacing(this.a,this.b,this.c,t)},intersectsBox:function(t){return t.intersectsTriangle(this)},closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),e=new Sn);var n,r,i=this.a,a=this.b,o=this.c;Ur.subVectors(a,i),Gr.subVectors(o,i),Vr.subVectors(t,i);var s=Ur.dot(Vr),c=Gr.dot(Vr);if(s<=0&&c<=0)return e.copy(i);kr.subVectors(t,a);var l=Ur.dot(kr),u=Gr.dot(kr);if(l>=0&&u<=l)return e.copy(a);var h=s*u-l*c;if(h<=0&&s>=0&&l<=0)return n=s/(s-l),e.copy(i).addScaledVector(Ur,n);jr.subVectors(t,o);var d=Ur.dot(jr),p=Gr.dot(jr);if(p>=0&&d<=p)return e.copy(o);var f=d*c-s*p;if(f<=0&&c>=0&&p<=0)return r=c/(c-p),e.copy(i).addScaledVector(Gr,r);var m=l*p-d*u;if(m<=0&&u-l>=0&&d-p>=0)return Hr.subVectors(o,a),r=(u-l)/(u-l+(d-p)),e.copy(a).addScaledVector(Hr,r);var v=1/(m+f+h);return n=f*v,r=h*v,e.copy(i).addScaledVector(Ur,n).addScaledVector(Gr,r)},equals:function(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}});var qr={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},Xr={h:0,s:0,l:0},Yr={h:0,s:0,l:0};function Zr(t,e,n){return void 0===e&&void 0===n?this.set(t):this.setRGB(t,e,n)}function Jr(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}function Qr(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Kr(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}function $r(t,e,n,r,i,a){this.a=t,this.b=e,this.c=n,this.normal=r&&r.isVector3?r:new Sn,this.vertexNormals=Array.isArray(r)?r:[],this.color=i&&i.isColor?i:new Zr,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=void 0!==a?a:0}Object.assign(Zr.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(t,e,n){if(t=xn.euclideanModulo(t,1),e=xn.clamp(e,0,1),n=xn.clamp(n,0,1),0===e)this.r=this.g=this.b=n;else{var r=n<=.5?n*(1+e):n+e-n*e,i=2*n-r;this.r=Jr(i,r,t+1/3),this.g=Jr(i,r,t),this.b=Jr(i,r,t-1/3)}return this},setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var n;if(n=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var r,i=n[1],a=n[2];switch(i){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,e(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,e(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return e(r[5]),this.setHSL(o,s,c)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(t)){var l=n[1],u=l.length;if(3===u)return this.r=parseInt(l.charAt(0)+l.charAt(0),16)/255,this.g=parseInt(l.charAt(1)+l.charAt(1),16)/255,this.b=parseInt(l.charAt(2)+l.charAt(2),16)/255,this;if(6===u)return this.r=parseInt(l.charAt(0)+l.charAt(1),16)/255,this.g=parseInt(l.charAt(2)+l.charAt(3),16)/255,this.b=parseInt(l.charAt(4)+l.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this},setColorName:function(t){var e=qr[t];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),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(t){return this.copyGammaToLinear(this,t),this},convertLinearToGamma:function(t){return this.copyLinearToGamma(this,t),this},copySRGBToLinear:function(t){return this.r=Qr(t.r),this.g=Qr(t.g),this.b=Qr(t.b),this},copyLinearToSRGB:function(t){return this.r=Kr(t.r),this.g=Kr(t.g),this.b=Kr(t.b),this},convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});var e,n,r=this.r,i=this.g,a=this.b,o=Math.max(r,i,a),s=Math.min(r,i,a),c=(s+o)/2;if(s===o)e=0,n=0;else{var l=o-s;switch(n=c<=.5?l/(o+s):l/(2-o-s),o){case r:e=(i-a)/l+(ie&&(e=t[n]);return e}ei.prototype=Object.assign(Object.create(vn.prototype),{constructor:ei,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 r=this[e];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=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===x;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 r(t){var e=[];for(var n in t){var r=t[n];delete r.metadata,e.push(r)}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.sheen&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&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.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.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.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),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.normalMapType=this.normalMapType,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,n.refractionRatio=this.refractionRatio,void 0!==this.combine&&(n.combine=this.combine),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity)),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!==E&&(n.blending=this.blending),!0===this.flatShading&&(n.flatShading=this.flatShading),this.side!==v&&(n.side=this.side),this.vertexColors!==w&&(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,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&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.morphNormals&&(n.morphNormals=!0),!0===this.skinning&&(n.skinning=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),e){var i=r(t.textures),a=r(t.images);i.length>0&&(n.textures=i),a.length>0&&(n.images=a)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexTangents=t.vertexTangents,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.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;var e=t.clippingPlanes,n=null;if(null!==e){var r=e.length;n=new Array(r);for(var i=0;i!==r;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,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.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),ni.prototype=Object.create(ei.prototype),ni.prototype.constructor=ni,ni.prototype.isMeshBasicMaterial=!0,ni.prototype.copy=function(t){return ei.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},Object.defineProperty(ri.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(ri.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.itemSize,n*=e.itemSize;for(var r=0,i=this.itemSize;r0,o=i[1]&&i[1].length>0,s=t.morphTargets,c=s.length;if(c>0){e=[];for(var l=0;l0){u=[];for(l=0;l0&&0===n.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(l=0;l65535?ui:ci)(t,1):this.index=t},getAttribute:function(t){return this.attributes[t]},setAttribute:function(t,e){return this.attributes[t]=e,this},deleteAttribute: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 Tn).getNormalMatrix(t).applyToBufferAttribute(n),n.needsUpdate=!0);var r=this.attributes.tangent;void 0!==r&&((new Tn).getNormalMatrix(t).applyToBufferAttribute(r),r.needsUpdate=!0);return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(t){return vi.makeRotationX(t),this.applyMatrix(vi),this},rotateY:function(t){return vi.makeRotationY(t),this.applyMatrix(vi),this},rotateZ:function(t){return vi.makeRotationZ(t),this.applyMatrix(vi),this},translate:function(t,e,n){return vi.makeTranslation(t,e,n),this.applyMatrix(vi),this},scale:function(t,e,n){return vi.makeScale(t,e,n),this.applyMatrix(vi),this},lookAt:function(t){return gi.lookAt(t),gi.updateMatrix(),this.applyMatrix(gi.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(yi).negate(),this.translate(yi.x,yi.y,yi.z),this},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var n=new hi(3*e.vertices.length,3),r=new hi(3*e.colors.length,3);if(this.setAttribute("position",n.copyVector3sArray(e.vertices)),this.setAttribute("color",r.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var i=new hi(e.lineDistances.length,1);this.setAttribute("lineDistance",i.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},setFromPoints:function(t){for(var e=[],n=0,r=t.length;n0){var n=new Float32Array(3*t.normals.length);this.setAttribute("normal",new ri(n,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var r=new Float32Array(3*t.colors.length);this.setAttribute("color",new ri(r,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.setAttribute("uv",new ri(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var a=new Float32Array(2*t.uvs2.length);this.setAttribute("uv2",new ri(a,2).copyVector2sArray(t.uvs2))}for(var o in this.groups=t.groups,t.morphTargets){for(var s=[],c=t.morphTargets[o],l=0,u=c.length;l0){var p=new hi(4*t.skinIndices.length,4);this.setAttribute("skinIndex",p.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var f=new hi(4*t.skinWeights.length,4);this.setAttribute("skinWeight",f.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new xr);var t=this.attributes.position,e=this.morphAttributes.position;if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(var n=0,r=e.length;n0&&(t.userData=this.userData),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 r=this.index;null!==r&&(t.data.index={type:r.array.constructor.name,array:Array.prototype.slice.call(r.array)});var i=this.attributes;for(var n in i){var a=(d=i[n]).toJSON();""!==d.name&&(a.name=d.name),t.data.attributes[n]=a}var o={},s=!1;for(var n in this.morphAttributes){for(var c=this.morphAttributes[n],l=[],u=0,h=c.length;u0&&(o[n]=l,s=!0)}s&&(t.data.morphAttributes=o);var p=this.groups;p.length>0&&(t.data.groups=JSON.parse(JSON.stringify(p)));var f=this.boundingSphere;return null!==f&&(t.data.boundingSphere={center:f.center.toArray(),radius:f.radius}),t},clone:function(){return(new _i).copy(this)},copy:function(t){var e,n,r;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var i=t.index;null!==i&&this.setIndex(i.clone());var a=t.attributes;for(e in a){var o=a[e];this.setAttribute(e,o.clone())}var s=t.morphAttributes;for(e in s){var c=[],l=s[e];for(n=0,r=l.length;nn.far?null:{distance:c,point:Ui.clone(),object:t}}function Vi(t,e,n,r,i,a,o,s,c,l,u){Ai.fromBufferAttribute(i,c),Ti.fromBufferAttribute(i,l),Li.fromBufferAttribute(i,u);var h=t.morphTargetInfluences;if(e.morphTargets&&a&&h){Oi.set(0,0,0),Di.set(0,0,0),Ii.set(0,0,0);for(var d=0,p=a.length;d0){var o=i[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=o.length;t0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(t,e){var n,r=this.geometry,i=this.material,a=this.matrixWorld;if(void 0!==i&&(null===r.boundingSphere&&r.computeBoundingSphere(),Ei.copy(r.boundingSphere),Ei.applyMatrix4(a),!1!==t.ray.intersectsSphere(Ei)&&(Mi.getInverse(a),Si.copy(t.ray).applyMatrix4(Mi),null===r.boundingBox||!1!==Si.intersectsBox(r.boundingBox))))if(this.drawMode===Re){if(r.isBufferGeometry){var o,s,c,l,u,h,d,p,f,m=r.index,v=r.attributes.position,g=r.morphAttributes.position,y=r.attributes.uv,x=r.attributes.uv2,b=r.groups,w=r.drawRange;if(null!==m)if(Array.isArray(i))for(l=0,h=b.length;l0&&(E=R);for(var P=0,C=L.length;P0)for(l=0;l0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,n;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,n,r,i;for(n=0,r=this.faces.length;n=0;n--){var f=d[n];for(this.faces.splice(f,1),o=0,s=this.faceVertexUvs.length;o0,v=p.vertexNormals.length>0,g=1!==p.color.r||1!==p.color.g||1!==p.color.b,y=p.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),o.push(x),o.push(p.a,p.b,p.c),o.push(p.materialIndex),f){var b=this.faceVertexUvs[0][i];o.push(A(b[0]),A(b[1]),A(b[2]))}if(m&&o.push(S(p.normal)),v){var w=p.vertexNormals;o.push(S(w[0]),S(w[1]),S(w[2]))}if(g&&o.push(E(p.color)),y){var _=p.vertexColors;o.push(E(_[0]),E(_[1]),E(_[2]))}}function M(t,e,n){return n?t|1<0&&(t.data.colors=l),h.length>0&&(t.data.uvs=[h]),t.data.faces=o,t},clone:function(){return(new Xi).copy(this)},copy:function(t){var e,n,r,i,a,o;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var s=t.vertices;for(e=0,n=s.length;e0?1:-1,l.push(R.x,R.y,R.z),u.push(y/m),u.push(1-x/v),T+=1}}for(x=0;x0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;var i={};for(var a in this.extensions)!0===this.extensions[a]&&(i[a]=!0);return Object.keys(i).length>0&&(e.extensions=i),e},na.prototype=Object.assign(Object.create(ar.prototype),{constructor:na,isCamera:!0,copy:function(t,e){return ar.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new Sn),this.updateMatrixWorld(!0);var e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()},updateMatrixWorld:function(t){ar.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),ra.prototype=Object.assign(Object.create(na.prototype),{constructor:ra,isPerspectiveCamera:!0,copy:function(t,e){return na.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*xn.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){var t=Math.tan(.5*xn.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*xn.RAD2DEG*Math.atan(Math.tan(.5*xn.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,r,i,a){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=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=this.near,e=t*Math.tan(.5*xn.DEG2RAD*this.fov)/this.zoom,n=2*e,r=this.aspect*n,i=-.5*r,a=this.view;if(null!==this.view&&this.view.enabled){var o=a.fullWidth,s=a.fullHeight;i+=a.offsetX*r/o,e-=a.offsetY*n/s,r*=a.width/o,n*=a.height/s}var c=this.filmOffset;0!==c&&(i+=t*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,e,e-n,t,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(t){var e=ar.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}});var ia=90,aa=1;function oa(t,e,n,r){ar.call(this),this.type="CubeCamera";var i=new ra(ia,aa,t,e);i.up.set(0,-1,0),i.lookAt(new Sn(1,0,0)),this.add(i);var a=new ra(ia,aa,t,e);a.up.set(0,-1,0),a.lookAt(new Sn(-1,0,0)),this.add(a);var o=new ra(ia,aa,t,e);o.up.set(0,0,1),o.lookAt(new Sn(0,1,0)),this.add(o);var s=new ra(ia,aa,t,e);s.up.set(0,0,-1),s.lookAt(new Sn(0,-1,0)),this.add(s);var c=new ra(ia,aa,t,e);c.up.set(0,-1,0),c.lookAt(new Sn(0,0,1)),this.add(c);var l=new ra(ia,aa,t,e);l.up.set(0,-1,0),l.lookAt(new Sn(0,0,-1)),this.add(l),r=r||{format:kt,magFilter:Et,minFilter:Et},this.renderTarget=new sa(n,n,r),this.renderTarget.texture.name="CubeCamera",this.update=function(t,e){null===this.parent&&this.updateMatrixWorld();var n=t.getRenderTarget(),r=this.renderTarget,u=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,t.setRenderTarget(r,0),t.render(e,i),t.setRenderTarget(r,1),t.render(e,a),t.setRenderTarget(r,2),t.render(e,o),t.setRenderTarget(r,3),t.render(e,s),t.setRenderTarget(r,4),t.render(e,c),r.texture.generateMipmaps=u,t.setRenderTarget(r,5),t.render(e,l),t.setRenderTarget(n)},this.clear=function(t,e,n,r){for(var i=t.getRenderTarget(),a=this.renderTarget,o=0;o<6;o++)t.setRenderTarget(a,o),t.clear(e,n,r);t.setRenderTarget(i)}}function sa(t,e,n){On.call(this,t,e,n)}function ca(t,e,n,r,i,a,o,s,c,l,u,h){Pn.call(this,null,a,o,s,c,l,r,i,u,h),this.image={data:t||null,width:e||1,height:n||1},this.magFilter=void 0!==c?c:bt,this.minFilter=void 0!==l?l:bt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}oa.prototype=Object.create(ar.prototype),oa.prototype.constructor=oa,sa.prototype=Object.create(On.prototype),sa.prototype.constructor=sa,sa.prototype.isWebGLRenderTargetCube=!0,sa.prototype.fromEquirectangularTexture=function(t,e){this.texture.type=e.type,this.texture.format=e.format,this.texture.encoding=e.encoding;var n=new or,r={uniforms:{tEquirect:{value:null}},vertexShader:["varying vec3 vWorldDirection;","vec3 transformDirection( in vec3 dir, in mat4 matrix ) {","\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );","}","void main() {","\tvWorldDirection = transformDirection( position, modelMatrix );","\t#include ","\t#include ","}"].join("\n"),fragmentShader:["uniform sampler2D tEquirect;","varying vec3 vWorldDirection;","#define RECIPROCAL_PI 0.31830988618","#define RECIPROCAL_PI2 0.15915494","void main() {","\tvec3 direction = normalize( vWorldDirection );","\tvec2 sampleUV;","\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;","\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;","\tgl_FragColor = texture2D( tEquirect, sampleUV );","}"].join("\n")},i=new ea({type:"CubemapFromEquirect",uniforms:Ji(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:g,blending:S});i.uniforms.tEquirect.value=e;var a=new Gi(new Zi(5,5,5),i);n.add(a);var o=new oa(1,10,1);return o.renderTarget=this,o.renderTarget.texture.name="CubeCameraTexture",o.update(t,n),a.geometry.dispose(),a.material.dispose(),this},ca.prototype=Object.create(Pn.prototype),ca.prototype.constructor=ca,ca.prototype.isDataTexture=!0;var la=new _r,ua=new Sn;function ha(t,e,n,r,i,a){this.planes=[void 0!==t?t:new Ir,void 0!==e?e:new Ir,void 0!==n?n:new Ir,void 0!==r?r:new Ir,void 0!==i?i:new Ir,void 0!==a?a:new Ir]}Object.assign(ha.prototype,{set:function(t,e,n,r,i,a){var o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,n=0;n<6;n++)e[n].copy(t.planes[n]);return this},setFromMatrix:function(t){var e=this.planes,n=t.elements,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7],h=n[8],d=n[9],p=n[10],f=n[11],m=n[12],v=n[13],g=n[14],y=n[15];return e[0].setComponents(o-r,u-s,f-h,y-m).normalize(),e[1].setComponents(o+r,u+s,f+h,y+m).normalize(),e[2].setComponents(o+i,u+c,f+d,y+v).normalize(),e[3].setComponents(o-i,u-c,f-d,y-v).normalize(),e[4].setComponents(o-a,u-l,f-p,y-g).normalize(),e[5].setComponents(o+a,u+l,f+p,y+g).normalize(),this},intersectsObject:function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),la.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(la)},intersectsSprite:function(t){return la.center.set(0,0,0),la.radius=.7071067811865476,la.applyMatrix4(t.matrixWorld),this.intersectsSphere(la)},intersectsSphere:function(t){for(var e=this.planes,n=t.center,r=-t.radius,i=0;i<6;i++){if(e[i].distanceToPoint(n)0?t.max.x:t.min.x,ua.y=r.normal.y>0?t.max.y:t.min.y,ua.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(ua)<0)return!1}return!0},containsPoint:function(t){for(var e=this.planes,n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}});var da={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",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",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",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#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\ttransformedNormal = mat3( instanceMatrix ) * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = normalMatrix * objectTangent;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_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",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, roughness );\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",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) { \n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",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",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",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif",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 = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\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\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\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",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",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)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = saturate( clearcoat );\tmaterial.clearcoatRoughness = clamp( clearcoatRoughness, 0.04, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 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#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? 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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? 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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? 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 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",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",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",normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, normalScale, normalMap );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec2 normalScale, in sampler2D normalMap ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy *= normalScale;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tbool frontFacing = dot( cross( S, T ), N ) > 0.0;\n\t\t\tmapN.xy *= ( float( frontFacing ) * 2.0 - 1.0 );\n\t\t#else\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, clearcoatNormal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = clearcoatNormalScale * mapN.xy;\n\t\tclearcoatNormal = normalize( vTBN * mapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatNormalScale, clearcoatNormalMap );\n\t#endif\n#endif",clearcoat_normalmap_pars_fragment:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 encodeHalfRGBA ( vec2 v ) {\n\tvec4 encoded = vec4( 0.0 );\n\tconst vec2 offset = vec2( 1.0 / 255.0, 0.0 );\n\tencoded.xy = vec2( v.x, fract( v.x * 255.0 ) );\n\tencoded.xy = encoded.xy - ( encoded.yy * offset );\n\tencoded.zw = vec2( v.y, fract( v.y * 255.0 ) );\n\tencoded.zw = encoded.zw - ( encoded.ww * offset );\n\treturn encoded;\n}\nvec2 decodeHalfRGBA( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn decodeHalfRGBA( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat 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 ) + 0.5 ) * texelSize;\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\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat 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#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? 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}",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 highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",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",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",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\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\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 = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}",shadow_vert:"#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"},pa={common:{diffuse:{value:new Zr(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Tn},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},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 bn(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 Zr(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{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 Zr(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Tn}},sprite:{diffuse:{value:new Zr(15658734)},opacity:{value:1},center:{value:new bn(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Tn}}},fa={basic:{uniforms:Qi([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.fog]),vertexShader:da.meshbasic_vert,fragmentShader:da.meshbasic_frag},lambert:{uniforms:Qi([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.fog,pa.lights,{emissive:{value:new Zr(0)}}]),vertexShader:da.meshlambert_vert,fragmentShader:da.meshlambert_frag},phong:{uniforms:Qi([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.gradientmap,pa.fog,pa.lights,{emissive:{value:new Zr(0)},specular:{value:new Zr(1118481)},shininess:{value:30}}]),vertexShader:da.meshphong_vert,fragmentShader:da.meshphong_frag},standard:{uniforms:Qi([pa.common,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.roughnessmap,pa.metalnessmap,pa.fog,pa.lights,{emissive:{value:new Zr(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:da.meshphysical_vert,fragmentShader:da.meshphysical_frag},matcap:{uniforms:Qi([pa.common,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.fog,{matcap:{value:null}}]),vertexShader:da.meshmatcap_vert,fragmentShader:da.meshmatcap_frag},points:{uniforms:Qi([pa.points,pa.fog]),vertexShader:da.points_vert,fragmentShader:da.points_frag},dashed:{uniforms:Qi([pa.common,pa.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:da.linedashed_vert,fragmentShader:da.linedashed_frag},depth:{uniforms:Qi([pa.common,pa.displacementmap]),vertexShader:da.depth_vert,fragmentShader:da.depth_frag},normal:{uniforms:Qi([pa.common,pa.bumpmap,pa.normalmap,pa.displacementmap,{opacity:{value:1}}]),vertexShader:da.normal_vert,fragmentShader:da.normal_frag},sprite:{uniforms:Qi([pa.sprite,pa.fog]),vertexShader:da.sprite_vert,fragmentShader:da.sprite_frag},background:{uniforms:{uvTransform:{value:new Tn},t2D:{value:null}},vertexShader:da.background_vert,fragmentShader:da.background_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:da.cube_vert,fragmentShader:da.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:da.equirect_vert,fragmentShader:da.equirect_frag},distanceRGBA:{uniforms:Qi([pa.common,pa.displacementmap,{referencePosition:{value:new Sn},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:da.distanceRGBA_vert,fragmentShader:da.distanceRGBA_frag},shadow:{uniforms:Qi([pa.lights,pa.fog,{color:{value:new Zr(0)},opacity:{value:1}}]),vertexShader:da.shadow_vert,fragmentShader:da.shadow_frag}};function ma(){var t=null,e=!1,n=null;function r(i,a){!1!==e&&(n(i,a),t.requestAnimationFrame(r))}return{start:function(){!0!==e&&null!==n&&(t.requestAnimationFrame(r),e=!0)},stop:function(){e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function va(t){var e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);var r=e.get(n);r&&(t.deleteBuffer(r.buffer),e.delete(n))},update:function(n,r){n.isInterleavedBufferAttribute&&(n=n.data);var i=e.get(n);void 0===i?e.set(n,function(e,n){var r=e.array,i=e.usage,a=t.createBuffer();t.bindBuffer(n,a),t.bufferData(n,r,i),e.onUploadCallback();var o=5126;return r instanceof Float32Array?o=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?o=5123:r instanceof Int16Array?o=5122:r instanceof Uint32Array?o=5125:r instanceof Int32Array?o=5124:r instanceof Int8Array?o=5120:r instanceof Uint8Array&&(o=5121),{buffer:a,type:o,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version}}(n,r)):i.version0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}var a="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext,o=void 0!==n.precision?n.precision:"highp",s=i(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);var c=!0===n.logarithmicDepthBuffer,l=t.getParameter(34930),u=t.getParameter(35660),h=t.getParameter(3379),d=t.getParameter(34076),p=t.getParameter(34921),f=t.getParameter(36347),m=t.getParameter(36348),v=t.getParameter(36349),g=u>0,y=a||!!e.get("OES_texture_float");return{isWebGL2:a,getMaxAnisotropy:function(){if(void 0!==r)return r;var n=e.get("EXT_texture_filter_anisotropic");return r=null!==n?t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:c,maxTextures:l,maxVertexTextures:u,maxTextureSize:h,maxCubemapSize:d,maxAttributes:p,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:v,vertexTextures:g,floatFragmentTextures:y,floatVertexTextures:g&&y,maxSamples:a?t.getParameter(36183):0}}function _a(){var t=this,e=null,n=0,r=!1,i=!1,a=new Ir,o=new Tn,s={value:null,needsUpdate:!1};function c(){s.value!==e&&(s.value=e,s.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function l(e,n,r,i){var c=null!==e?e.length:0,l=null;if(0!==c){if(l=s.value,!0!==i||null===l){var u=r+4*c,h=n.matrixWorldInverse;o.getNormalMatrix(h),(null===l||l.length65535?ui:ci)(n,1);p.version=o,e.update(p,34963);var f=i.get(t);f&&e.remove(f),i.set(t,p)}return{get:function(t,e){var i=r.get(e);return i||(e.addEventListener("dispose",a),e.isBufferGeometry?i=e:e.isGeometry&&(void 0===e._bufferGeometry&&(e._bufferGeometry=(new _i).setFromObject(t)),i=e._bufferGeometry),r.set(e,i),n.memory.geometries++,i)},update:function(t){var n=t.index,r=t.attributes;for(var i in null!==n&&e.update(n,34963),r)e.update(r[i],34962);var a=t.morphAttributes;for(var i in a)for(var o=a[i],s=0,c=o.length;s0)return t;var i=e*n,a=Fa[i];if(void 0===a&&(a=new Float32Array(i),Fa[i]=a),0!==e){r.toArray(a,0);for(var o=1,s=0;o!==e;++o)s+=n,t[o].toArray(a,s)}return a}function ka(t,e){if(t.length!==e.length)return!1;for(var n=0,r=t.length;n/gm;function zo(t){return t.replace(Fo,Uo)}function Uo(t,e){var n=da[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return zo(n)}var Go=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;function Ho(t){return t.replace(Go,Vo)}function Vo(t,e,n,r){for(var i="",a=parseInt(e);a0?t.gammaFactor:1,M=a.isWebGL2?"":function(t,e,n){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||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(Io).join("\n")}(r.extensions,a,e),S=function(t){var e=[];for(var n in t){var r=t[n];!1!==r&&e.push("#define "+n+" "+r)}return e.join("\n")}(d),E=h.createProgram(),A=a.numMultiviewViews;if(r.isRawShaderMaterial?((o=[S].filter(Io).join("\n")).length>0&&(o+="\n"),(s=[M,S].filter(Io).join("\n")).length>0&&(s+="\n")):(o=[ko(a),"#define SHADER_NAME "+i.name,S,a.instancing?"#define USE_INSTANCING":"",a.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+_,"#define MAX_BONES "+a.maxBones,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp2?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+b:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.normalMap&&a.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",a.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",a.displacementMap&&a.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.vertexTangents?"#define USE_TANGENT":"",a.vertexColors?"#define USE_COLOR":"",a.vertexUvs?"#define USE_UV":"",a.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",a.flatShading?"#define FLAT_SHADED":"",a.skinning?"#define USE_SKINNING":"",a.useVertexTexture?"#define BONE_TEXTURE":"",a.morphTargets?"#define USE_MORPHTARGETS":"",a.morphNormals&&!1===a.flatShading?"#define USE_MORPHNORMALS":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+y:"",a.sizeAttenuation?"#define USE_SIZEATTENUATION":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(a.isWebGL2||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;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Io).join("\n"),s=[M,ko(a),"#define SHADER_NAME "+i.name,S,a.alphaTest?"#define ALPHATEST "+a.alphaTest+(a.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+_,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp2?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.matcap?"#define USE_MATCAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+x:"",a.envMap?"#define "+b:"",a.envMap?"#define "+w:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.normalMap&&a.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",a.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.sheen?"#define USE_SHEEN":"",a.vertexTangents?"#define USE_TANGENT":"",a.vertexColors?"#define USE_COLOR":"",a.vertexUvs?"#define USE_UV":"",a.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",a.gradientMap?"#define USE_GRADIENTMAP":"",a.flatShading?"#define FLAT_SHADED":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+y:"",a.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",a.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(a.isWebGL2||e.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",(r.extensions&&r.extensions.shaderTextureLOD||a.envMap)&&(a.isWebGL2||e.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",a.toneMapping!==rt?"#define TONE_MAPPING":"",a.toneMapping!==rt?da.tonemapping_pars_fragment:"",a.toneMapping!==rt?Do("toneMapping",a.toneMapping):"",a.dithering?"#define DITHERING":"",a.outputEncoding||a.mapEncoding||a.matcapEncoding||a.envMapEncoding||a.emissiveMapEncoding?da.encodings_pars_fragment:"",a.mapEncoding?Oo("mapTexelToLinear",a.mapEncoding):"",a.matcapEncoding?Oo("matcapTexelToLinear",a.matcapEncoding):"",a.envMapEncoding?Oo("envMapTexelToLinear",a.envMapEncoding):"",a.emissiveMapEncoding?Oo("emissiveMapTexelToLinear",a.emissiveMapEncoding):"",a.outputEncoding?(c="linearToOutputTexel",l=a.outputEncoding,u=Po(l),"vec4 "+c+"( vec4 value ) { return LinearTo"+u[0]+u[1]+"; }"):"",a.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(Io).join("\n")),v=Bo(v=No(v=zo(v),a),a),g=Bo(g=No(g=zo(g),a),a),v=Ho(v),g=Ho(g),a.isWebGL2&&!r.isRawShaderMaterial){var T=!1,L=/^\s*#version\s+300\s+es\s*\n/;r.isShaderMaterial&&null!==v.match(L)&&null!==g.match(L)&&(T=!0,v=v.replace(L,""),g=g.replace(L,"")),o=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+o,s=["#version 300 es\n","#define varying in",T?"":"out highp vec4 pc_fragColor;",T?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+s,A>0&&(o=(o=o.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","layout(num_views = "+A+") in;","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join("\n"),["uniform mat4 modelViewMatrices["+A+"];","uniform mat4 projectionMatrices["+A+"];","uniform mat4 viewMatrices["+A+"];","uniform mat3 normalMatrices["+A+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join("\n")),s=(s=s.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+A+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join("\n")))}var R,P,C=s+g,O=Lo(h,35633,o+v),D=Lo(h,35632,C);if(h.attachShader(E,O),h.attachShader(E,D),void 0!==r.index0AttributeName?h.bindAttribLocation(E,0,r.index0AttributeName):!0===a.morphTargets&&h.bindAttribLocation(E,0,"position"),h.linkProgram(E),t.debug.checkShaderErrors){var I=h.getProgramInfoLog(E).trim(),N=h.getShaderInfoLog(O).trim(),B=h.getShaderInfoLog(D).trim(),F=!0,z=!0;if(!1===h.getProgramParameter(E,35714)){F=!1;var U=Co(h,O,"vertex"),G=Co(h,D,"fragment");console.error("THREE.WebGLProgram: shader error: ",h.getError(),"35715",h.getProgramParameter(E,35715),"gl.getProgramInfoLog",I,U,G)}else""!==I?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",I):""!==N&&""!==B||(z=!1);z&&(this.diagnostics={runnable:F,material:r,programLog:I,vertexShader:{log:N,prefix:o},fragmentShader:{log:B,prefix:s}})}return h.deleteShader(O),h.deleteShader(D),this.getUniforms=function(){return void 0===R&&(R=new To(h,E)),R},this.getAttributes=function(){return void 0===P&&(P=function(t,e){for(var n={},r=t.getProgramParameter(e,35721),i=0;i0,maxBones:b,useVertexTexture:o,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:r.directional.length,numPointLights:r.point.length,numSpotLights:r.spot.length,numRectAreaLights:r.rectArea.length,numHemiLights:r.hemi.length,numDirLightShadows:r.directionalShadowMap.length,numPointLightShadows:r.pointShadowMap.length,numSpotLightShadows:r.spotShadowMap.length,numClippingPlanes:f,numClipIntersection:m,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.length>0,shadowMapType:t.shadowMap.type,toneMapping:e.toneMapped?t.toneMapping:rt,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===y,flipSided:e.side===g,depthPacking:void 0!==e.depthPacking&&e.depthPacking}},this.getProgramCacheKey=function(e,n){var r=[];if(n.shaderID?r.push(n.shaderID):(r.push(e.fragmentShader),r.push(e.vertexShader)),void 0!==e.defines)for(var i in e.defines)r.push(i),r.push(e.defines[i]);for(var a=0;a1&&n.sort(Xo),r.length>1&&r.sort(Yo)}}}function Jo(){var t=new WeakMap;function e(n){var r=n.target;r.removeEventListener("dispose",e),t.delete(r)}return{get:function(n,r){var i,a=t.get(n);return void 0===a?(i=new Zo,t.set(n,new WeakMap),t.get(n).set(r,i),n.addEventListener("dispose",e)):void 0===(i=a.get(r))&&(i=new Zo,a.set(r,i)),i},dispose:function(){t=new WeakMap}}}function Qo(){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 Sn,color:new Zr,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new bn};break;case"SpotLight":n={position:new Sn,direction:new Sn,color:new Zr,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new bn};break;case"PointLight":n={position:new Sn,color:new Zr,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new bn,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":n={direction:new Sn,skyColor:new Zr,groundColor:new Zr};break;case"RectAreaLight":n={color:new Zr,position:new Sn,halfWidth:new Sn,halfHeight:new Sn}}return t[e.id]=n,n}}}var Ko=0;function $o(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function ts(){for(var t=new Qo,e={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},n=0;n<9;n++)e.probe.push(new Sn);var r=new Sn,i=new Hn,a=new Hn;return{setup:function(n,o,s){for(var c=0,l=0,u=0,h=0;h<9;h++)e.probe[h].set(0,0,0);var d=0,p=0,f=0,m=0,v=0,g=0,y=0,x=0,b=s.matrixWorldInverse;n.sort($o),h=0;for(var w=n.length;h0:!0===s.isGeometry&&(p=s.morphTargets&&s.morphTargets.length>0));var f=!1;!0===e.isSkinnedMesh&&(!0===n.skinning?f=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e)),c=h(p,f,!0===e.isInstancedMesh)}else c=d;if(t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var v=c.uuid,g=n.uuid,y=l[v];void 0===y&&(y={},l[v]=y);var x=y[g];void 0===x&&(x=c.clone(),y[g]=x),c=x}return c.visible=n.visible,c.wireframe=n.wireframe,c.side=o===m?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],c.clipShadows=n.clipShadows,c.clippingPlanes=n.clippingPlanes,c.clipIntersection=n.clipIntersection,c.wireframeLinewidth=n.wireframeLinewidth,c.linewidth=n.linewidth,!0===r.isPointLight&&!0===c.isMeshDistanceMaterial&&(c.referencePosition.setFromMatrixPosition(r.matrixWorld),c.nearDistance=i,c.farDistance=a),c}function A(n,i,a,o,s){if(!1!==n.visible){if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===m)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);var c=e.update(n),l=n.material;if(Array.isArray(l))for(var u=c.groups,h=0,d=u.length;hn||i.y>n)&&(console.warn("THREE.WebGLShadowMap:",v,"has shadow exceeding max texture size, reducing"),i.x>n&&(a.x=Math.floor(n/y.x),i.x=a.x*y.x,g.mapSize.x=a.x),i.y>n&&(a.y=Math.floor(n/y.y),i.y=a.y*y.y,g.mapSize.y=a.y)),null===g.map&&!g.isPointLightShadow&&this.type===m){var x={minFilter:Et,magFilter:Et,format:jt};g.map=new On(i.x,i.y,x),g.map.texture.name=v.name+".shadowMap",g.mapPass=new On(i.x,i.y,x),g.camera.updateProjectionMatrix()}if(null===g.map){x={minFilter:bt,magFilter:bt,format:jt};g.map=new On(i.x,i.y,x),g.map.texture.name=v.name+".shadowMap",g.camera.updateProjectionMatrix()}t.setRenderTarget(g.map),t.clear();for(var _=g.getViewportCount(),M=0;M<_;M++){var E=g.getViewport(M);o.set(a.x*E.x,a.y*E.y,a.x*E.z,a.y*E.w),d.viewport(o),g.updateMatrices(v,M),r=g.getFrustum(),A(s,c,g.camera,v,this.type)}g.isPointLightShadow||this.type!==m||w(g,c)}else console.warn("THREE.WebGLShadowMap:",v,"has no shadow.")}b.needsUpdate=!1,t.setRenderTarget(l,u,h)}}}function cs(t,e,n){var r=n.isWebGL2;var i=new function(){var e=!1,n=new Cn,r=null,i=new Cn(0,0,0,0);return{setMask:function(n){r===n||e||(t.colorMask(n,n,n,n),r=n)},setLocked:function(t){e=t},setClear:function(e,r,a,o,s){!0===s&&(e*=o,r*=o,a*=o),n.set(e,r,a,o),!1===i.equals(n)&&(t.clearColor(e,r,a,o),i.copy(n))},reset:function(){e=!1,r=null,i.set(-1,0,0,0)}}},a=new function(){var e=!1,n=null,r=null,i=null;return{setTest:function(t){t?xt(2929):bt(2929)},setMask:function(r){n===r||e||(t.depthMask(r),n=r)},setFunc:function(e){if(r!==e){if(e)switch(e){case q:t.depthFunc(512);break;case X:t.depthFunc(519);break;case Y:t.depthFunc(513);break;case Z:t.depthFunc(515);break;case J:t.depthFunc(514);break;case Q:t.depthFunc(518);break;case K:t.depthFunc(516);break;case $:t.depthFunc(517);break;default:t.depthFunc(515)}else t.depthFunc(515);r=e}},setLocked:function(t){e=t},setClear:function(e){i!==e&&(t.clearDepth(e),i=e)},reset:function(){e=!1,n=null,r=null,i=null}}},l=new function(){var e=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null;return{setTest:function(t){e||(t?xt(2960):bt(2960))},setMask:function(r){n===r||e||(t.stencilMask(r),n=r)},setFunc:function(e,n,o){r===e&&i===n&&a===o||(t.stencilFunc(e,n,o),r=e,i=n,a=o)},setOp:function(e,n,r){o===e&&s===n&&c===r||(t.stencilOp(e,n,r),o=e,s=n,c=r)},setLocked:function(t){e=t},setClear:function(e){l!==e&&(t.clearStencil(e),l=e)},reset:function(){e=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null}}},u=t.getParameter(34921),h=new Uint8Array(u),d=new Uint8Array(u),p=new Uint8Array(u),f={},m=null,v=null,x=null,b=null,w=null,_=null,M=null,tt=null,et=null,nt=!1,rt=null,it=null,at=null,ot=null,st=null,ct=t.getParameter(35661),lt=!1,ut=0,ht=t.getParameter(7938);-1!==ht.indexOf("WebGL")?(ut=parseFloat(/^WebGL\ ([0-9])/.exec(ht)[1]),lt=ut>=1):-1!==ht.indexOf("OpenGL ES")&&(ut=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(ht)[1]),lt=ut>=2);var dt=null,pt={},ft=new Cn,mt=new Cn;function vt(e,n,r){var i=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(var o=0;or||t.height>r)&&(i=r/Math.max(t.width,t.height)),i<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){var a=e?xn.floorPowerOfTwo:Math.floor,o=a(i*t.width),c=a(i*t.height);void 0===s&&(s=m(o,c));var l=n?m(o,c):s;return l.width=o,l.height=c,l.getContext("2d").drawImage(t,0,0,o,c),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+o+"x"+c+")."),l}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function g(t){return xn.isPowerOfTwo(t.width)&&xn.isPowerOfTwo(t.height)}function y(t,e){return t.generateMipmaps&&e&&t.minFilter!==bt&&t.minFilter!==Et}function x(e,n,i,a){t.generateMipmap(e),r.get(n).__maxMipLevel=Math.log(Math.max(i,a))*Math.LOG2E}function b(t,n){if(!1===c)return t;var r=t;return 6403===t&&(5126===n&&(r=33326),5131===n&&(r=33325),5121===n&&(r=33321)),6407===t&&(5126===n&&(r=34837),5131===n&&(r=34843),5121===n&&(r=32849)),6408===t&&(5126===n&&(r=34836),5131===n&&(r=34842),5121===n&&(r=32856)),33325===r||33326===r||34842===r||34836===r?e.get("EXT_color_buffer_float"):34843!==r&&34837!==r||console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead."),r}function w(t){return t===bt||t===wt||t===Mt?9728:9729}function _(e){var n=e.target;n.removeEventListener("dispose",_),function(e){var n=r.get(e);if(void 0===n.__webglInit)return;t.deleteTexture(n.__webglTexture),r.remove(e)}(n),n.isVideoTexture&&p.delete(n),o.memory.textures--}function M(e){var n=e.target;n.removeEventListener("dispose",M),function(e){var n=r.get(e),i=r.get(e.texture);if(!e)return;void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLRenderTargetCube)for(var a=0;a<6;a++)t.deleteFramebuffer(n.__webglFramebuffer[a]),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer[a]);else t.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer);if(e.isWebGLMultiviewRenderTarget){t.deleteTexture(n.__webglColorTexture),t.deleteTexture(n.__webglDepthStencilTexture),o.memory.textures-=2;a=0;for(var s=n.__webglViewFramebuffers.length;a0&&i.__version!==t.version){var a=t.image;if(void 0===a)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==a.complete)return void O(i,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+e),n.bindTexture(3553,i.__webglTexture)}function A(e,i){if(6===e.image.length){var o=r.get(e);if(e.version>0&&o.__version!==e.version){C(o,e),n.activeTexture(33984+i),n.bindTexture(34067,o.__webglTexture),t.pixelStorei(37440,e.flipY);for(var s=e&&e.isCompressedTexture,l=e.image[0]&&e.image[0].isDataTexture,h=[],d=0;d<6;d++)h[d]=s||l?l?e.image[d].image:e.image[d]:v(e.image[d],!1,!0,u);var p,f=h[0],m=g(f)||c,w=a.convert(e.format),_=a.convert(e.type),M=b(w,_);if(P(34067,e,m),s){for(d=0;d<6;d++){p=h[d].mipmaps;for(var S=0;S1||r.get(a).__currentAnisotropy)&&(t.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function C(e,n){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",_),e.__webglTexture=t.createTexture(),o.memory.textures++)}function O(e,r,i){var o=3553;r.isDataTexture2DArray&&(o=35866),r.isDataTexture3D&&(o=32879),C(e,r),n.activeTexture(33984+i),n.bindTexture(o,e.__webglTexture),t.pixelStorei(37440,r.flipY),t.pixelStorei(37441,r.premultiplyAlpha),t.pixelStorei(3317,r.unpackAlignment);var s=function(t){return!c&&(t.wrapS!==yt||t.wrapT!==yt||t.minFilter!==bt&&t.minFilter!==Et)}(r)&&!1===g(r.image),l=v(r.image,s,!1,h),u=g(l)||c,d=a.convert(r.format),p=a.convert(r.type),f=b(d,p);P(o,r,u);var m,w=r.mipmaps;if(r.isDepthTexture){if(f=6402,r.type===Bt){if(!1===c)throw new Error("Float Depth Texture only supported in WebGL2.0");f=36012}else c&&(f=33189);r.format===Yt&&6402===f&&r.type!==Dt&&r.type!==Nt&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Dt,p=a.convert(r.type)),r.format===Zt&&(f=34041,r.type!==Ht&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=Ht,p=a.convert(r.type))),n.texImage2D(3553,0,f,l.width,l.height,0,d,p,null)}else if(r.isDataTexture)if(w.length>0&&u){for(var _=0,M=w.length;_0&&u){for(_=0,M=w.length;_=l&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+l),S+=1,t},this.resetTextureUnits=function(){S=0},this.setTexture2D=E,this.setTexture2DArray=function(t,e){var i=r.get(t);t.version>0&&i.__version!==t.version?O(i,t,e):(n.activeTexture(33984+e),n.bindTexture(35866,i.__webglTexture))},this.setTexture3D=function(t,e){var i=r.get(t);t.version>0&&i.__version!==t.version?O(i,t,e):(n.activeTexture(33984+e),n.bindTexture(32879,i.__webglTexture))},this.setTextureCube=A,this.setTextureCubeDynamic=T,this.setupRenderTarget=function(i){var s=r.get(i),l=r.get(i.texture);i.addEventListener("dispose",M),l.__webglTexture=t.createTexture(),o.memory.textures++;var u=!0===i.isWebGLRenderTargetCube,h=!0===i.isWebGLMultisampleRenderTarget,d=!0===i.isWebGLMultiviewRenderTarget,p=g(i)||c;if(u){s.__webglFramebuffer=[];for(var f=0;f<6;f++)s.__webglFramebuffer[f]=t.createFramebuffer()}else if(s.__webglFramebuffer=t.createFramebuffer(),h)if(c){s.__webglMultisampledFramebuffer=t.createFramebuffer(),s.__webglColorRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,s.__webglColorRenderbuffer);var m=b(a.convert(i.texture.format),a.convert(i.texture.type)),v=B(i);t.renderbufferStorageMultisample(36161,v,m,i.width,i.height),t.bindFramebuffer(36160,s.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(36160,36064,36161,s.__webglColorRenderbuffer),t.bindRenderbuffer(36161,null),i.depthBuffer&&(s.__webglDepthRenderbuffer=t.createRenderbuffer(),I(s.__webglDepthRenderbuffer,i,!0)),t.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");else if(d){var w=i.width,_=i.height,S=i.numViews;t.bindFramebuffer(36160,s.__webglFramebuffer);var E=e.get("OVR_multiview2");o.memory.textures+=2;var A=t.createTexture();t.bindTexture(35866,A),t.texParameteri(35866,10240,9728),t.texParameteri(35866,10241,9728),t.texImage3D(35866,0,32856,w,_,S,0,6408,5121,null),E.framebufferTextureMultiviewOVR(36160,36064,A,0,0,S);var T=t.createTexture();t.bindTexture(35866,T),t.texParameteri(35866,10240,9728),t.texParameteri(35866,10241,9728),t.texImage3D(35866,0,35056,w,_,S,0,34041,34042,null),E.framebufferTextureMultiviewOVR(36160,33306,T,0,0,S);var L=new Array(S);for(f=0;fd)return!1;for(var n=1,r=e.length;n=0){var l=i[s];if(void 0!==l){var u=l.normalized,h=l.itemSize;if(void 0===(M=w.get(l)))continue;var d=M.buffer,g=M.type,y=M.bytesPerElement;if(l.isInterleavedBufferAttribute){var x=l.data,b=x.stride,_=l.offset;x&&x.isInstancedInterleavedBuffer?(v.enableAttributeAndDivisor(c,x.meshPerAttribute),void 0===e.maxInstancedCount&&(e.maxInstancedCount=x.meshPerAttribute*x.count)):v.enableAttribute(c),p.bindBuffer(34962,d),p.vertexAttribPointer(c,h,g,u,b*y,_*y)}else l.isInstancedBufferAttribute?(v.enableAttributeAndDivisor(c,l.meshPerAttribute),void 0===e.maxInstancedCount&&(e.maxInstancedCount=l.meshPerAttribute*l.count)):v.enableAttribute(c),p.bindBuffer(34962,d),p.vertexAttribPointer(c,h,g,u,0,0)}else if("instanceMatrix"===s){var M;if(void 0===(M=w.get(t.instanceMatrix)))continue;d=M.buffer,g=M.type;v.enableAttributeAndDivisor(c+0,1),v.enableAttributeAndDivisor(c+1,1),v.enableAttributeAndDivisor(c+2,1),v.enableAttributeAndDivisor(c+3,1),p.bindBuffer(34962,d),p.vertexAttribPointer(c+0,4,g,!1,64,0),p.vertexAttribPointer(c+1,4,g,!1,64,16),p.vertexAttribPointer(c+2,4,g,!1,64,32),p.vertexAttribPointer(c+3,4,g,!1,64,48)}else if(void 0!==o){var S=o[s];if(void 0!==S)switch(S.length){case 2:p.vertexAttrib2fv(c,S);break;case 3:p.vertexAttrib3fv(c,S);break;case 4:p.vertexAttrib4fv(c,S);break;default:p.vertexAttrib1fv(c,S)}}}}v.disableUnusedAttributes()}(i,n,r,s),null!==u&&p.bindBuffer(34963,l.buffer));var y=1/0;null!==u?y=u.count:void 0!==h&&(y=h.count);var x=n.drawRange.start*d,b=n.drawRange.count*d,M=null!==a?a.start*d:0,S=null!==a?a.count*d:1/0,E=Math.max(x,M),A=Math.min(y,x+b,M+S)-1,T=Math.max(0,A-E+1);if(0!==T){if(i.isMesh)if(!0===r.wireframe)v.setLineWidth(r.wireframeLinewidth*at()),g.setMode(1);else switch(i.drawMode){case Re:g.setMode(4);break;case Pe:g.setMode(5);break;case Ce:g.setMode(6)}else if(i.isLine){var C=r.linewidth;void 0===C&&(C=1),v.setLineWidth(C*at()),i.isLineSegments?g.setMode(1):i.isLineLoop?g.setMode(2):g.setMode(3)}else i.isPoints?g.setMode(0):i.isSprite&&g.setMode(4);i.isInstancedMesh?g.renderInstances(n,E,T,i.count):n.isInstancedBufferGeometry?g.renderInstances(n,E,T,n.maxInstancedCount):g.render(E,T)}},this.compile=function(t,e){(d=A.get(t,e)).init(),t.traverse((function(t){t.isLight&&(d.pushLight(t),t.castShadow&&d.pushShadow(t))})),d.setupLights(e),t.traverse((function(e){if(e.material)if(Array.isArray(e.material))for(var n=0;n=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(f=0;f=0&&t.numSupportedMorphNormals++}var m=r.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(r.numClippingPlanes=$.numPlanes,r.numIntersection=$.numIntersection,m.clippingPlanes=$.uniform),r.fog=e,r.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),r.lightsStateVersion=o,r.needsLights&&(m.ambientLightColor.value=i.state.ambient,m.lightProbe.value=i.state.probe,m.directionalLights.value=i.state.directional,m.spotLights.value=i.state.spot,m.rectAreaLights.value=i.state.rectArea,m.pointLights.value=i.state.point,m.hemisphereLights.value=i.state.hemi,m.directionalShadowMap.value=i.state.directionalShadowMap,m.directionalShadowMatrix.value=i.state.directionalShadowMatrix,m.spotShadowMap.value=i.state.spotShadowMap,m.spotShadowMatrix.value=i.state.spotShadowMatrix,m.pointShadowMap.value=i.state.pointShadowMap,m.pointShadowMatrix.value=i.state.pointShadowMatrix);var v=r.program.getUniforms(),g=To.seqWithValue(v.seq,m);r.uniformsList=g}function wt(t,e,n,r){b.resetTextureUnits();var i=x.get(n),a=d.state.lights;if(tt&&(et||t!==H)){var o=t===H&&n.id===U;$.setState(n.clippingPlanes,n.clipIntersection,n.clipShadows,t,i,o)}!1===n.needsUpdate&&(void 0===i.program?n.needsUpdate=!0:n.fog&&i.fog!==e?n.needsUpdate=!0:i.needsLights&&i.lightsStateVersion!==a.state.version?n.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===$.numPlanes&&i.numIntersection===$.numIntersection||(n.needsUpdate=!0)),n.needsUpdate&&(bt(n,e,r),n.needsUpdate=!1);var s,c,l=!1,u=!1,h=!1,f=i.program,y=f.getUniforms(),w=i.shader.uniforms;if(v.useProgram(f.program)&&(l=!0,u=!0,h=!0),n.id!==U&&(U=n.id,u=!0),l||H!==t){if(f.numMultiviewViews>0?lt.updateCameraProjectionMatricesUniform(t,y):y.setValue(p,"projectionMatrix",t.projectionMatrix),m.logarithmicDepthBuffer&&y.setValue(p,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),H!==t&&(H=t,u=!0,h=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.envMap){var _=y.map.cameraPosition;void 0!==_&&_.setValue(p,rt.setFromMatrixPosition(t.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&y.setValue(p,"isOrthographic",!0===t.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.skinning)&&(f.numMultiviewViews>0?lt.updateCameraViewMatricesUniform(t,y):y.setValue(p,"viewMatrix",t.matrixWorldInverse))}if(n.skinning){y.setOptional(p,r,"bindMatrix"),y.setOptional(p,r,"bindMatrixInverse");var M=r.skeleton;if(M){var S=M.bones;if(m.floatVertexTextures){if(void 0===M.boneTexture){var E=Math.sqrt(4*S.length);E=xn.ceilPowerOfTwo(E),E=Math.max(E,4);var A=new Float32Array(E*E*4);A.set(M.boneMatrices);var T=new ca(A,E,E,jt,Bt);M.boneMatrices=A,M.boneTexture=T,M.boneTextureSize=E}y.setValue(p,"boneTexture",M.boneTexture,b),y.setValue(p,"boneTextureSize",M.boneTextureSize)}else y.setOptional(p,M,"boneMatrices")}}return(u||i.receiveShadow!==r.receiveShadow)&&(i.receiveShadow=r.receiveShadow,y.setValue(p,"receiveShadow",r.receiveShadow)),u&&(y.setValue(p,"toneMappingExposure",O.toneMappingExposure),y.setValue(p,"toneMappingWhitePoint",O.toneMappingWhitePoint),i.needsLights&&(c=h,(s=w).ambientLightColor.needsUpdate=c,s.lightProbe.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.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}(w,e),n.isMeshBasicMaterial?_t(w,n):n.isMeshLambertMaterial?(_t(w,n),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(w,n)):n.isMeshPhongMaterial?(_t(w,n),n.isMeshToonMaterial?function(t,e){Mt(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(w,n):Mt(w,n)):n.isMeshStandardMaterial?(_t(w,n),n.isMeshPhysicalMaterial?function(t,e){St(t,e),t.reflectivity.value=e.reflectivity,t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.sheen&&t.sheen.value.copy(e.sheen);e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,e.side===g&&t.clearcoatNormalScale.value.negate());t.transparency.value=e.transparency}(w,n):St(w,n)):n.isMeshMatcapMaterial?(_t(w,n),function(t,e){e.matcap&&(t.matcap.value=e.matcap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===g&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,n)):n.isMeshDepthMaterial?(_t(w,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,n)):n.isMeshDistanceMaterial?(_t(w,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}(w,n)):n.isMeshNormalMaterial?(_t(w,n),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===g&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,n)):n.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(w,n),n.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(w,n)):n.isPointsMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*Y,t.scale.value=.5*X,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);var n;e.map?n=e.map:e.alphaMap&&(n=e.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}(w,n):n.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);var n;e.map?n=e.map:e.alphaMap&&(n=e.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}(w,n):n.isShadowMaterial&&(w.color.value.copy(n.color),w.opacity.value=n.opacity),void 0!==w.ltc_1&&(w.ltc_1.value=pa.LTC_1),void 0!==w.ltc_2&&(w.ltc_2.value=pa.LTC_2),To.upload(p,i.uniformsList,w,b),n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(To.upload(p,i.uniformsList,w,b),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&y.setValue(p,"center",r.center),f.numMultiviewViews>0?lt.updateObjectMatricesUniforms(r,t,y):(y.setValue(p,"modelViewMatrix",r.modelViewMatrix),y.setValue(p,"normalMatrix",r.normalMatrix)),y.setValue(p,"modelMatrix",r.matrixWorld),f}function _t(t,e){var n;t.opacity.value=e.opacity,e.color&&t.diffuse.value.copy(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.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio,t.maxMipLevel.value=x.get(e.envMap).__maxMipLevel),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity),e.map?n=e.map:e.specularMap?n=e.specularMap:e.displacementMap?n=e.displacementMap:e.normalMap?n=e.normalMap:e.bumpMap?n=e.bumpMap:e.roughnessMap?n=e.roughnessMap:e.metalnessMap?n=e.metalnessMap:e.alphaMap?n=e.alphaMap:e.emissiveMap&&(n=e.emissiveMap),void 0!==n&&(n.isWebGLRenderTarget&&(n=n.texture),!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}function Mt(t,e){t.specular.value.copy(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.side===g&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function St(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.side===g&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}vt.setAnimationLoop((function(t){ct.isPresenting()||mt&&mt(t)})),"undefined"!=typeof window&&vt.setContext(window),this.setAnimationLoop=function(t){mt=t,ct.setAnimationLoop(t),vt.start()},this.render=function(t,e){var n,r;if(void 0!==arguments[2]&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),n=arguments[2]),void 0!==arguments[3]&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),r=arguments[3]),e&&e.isCamera){if(!D){G.geometry=null,G.program=null,G.wireframe=!1,U=-1,H=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),ct.enabled&&(e=ct.getCamera(e)),(d=A.get(t,e)).init(),t.onBeforeRender(O,t,e,n||F),nt.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),K.setFromMatrix(nt),et=this.localClippingEnabled,tt=$.init(this.clippingPlanes,et,e),(h=E.get(t,e)).init(),gt(t,e,0,O.sortObjects),!0===O.sortObjects&&h.sort(),tt&&$.beginShadows();var i=d.state.shadowsArray;ut.render(i,t,e),d.setupLights(e),tt&&$.endShadows(),this.info.autoReset&&this.info.reset(),void 0!==n&&this.setRenderTarget(n),ct.enabled&<.isAvailable()&<.attachCamera(e),T.render(h,t,e,r);var a=h.opaque,o=h.transparent;if(t.overrideMaterial){var s=t.overrideMaterial;a.length&&yt(a,t,e,s),o.length&&yt(o,t,e,s)}else a.length&&yt(a,t,e),o.length&&yt(o,t,e);t.onAfterRender(O,t,e),null!==F&&(b.updateRenderTargetMipmap(F),b.updateMultisampleRenderTarget(F)),v.buffers.depth.setTest(!0),v.buffers.depth.setMask(!0),v.buffers.color.setMask(!0),v.setPolygonOffset(!1),ct.enabled&&(lt.isAvailable()&<.detachCamera(e),ct.submitFrame()),h=null,d=null}}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.setFramebuffer=function(t){I!==t&&null===F&&p.bindFramebuffer(36160,t),I=t},this.getActiveCubeFace=function(){return N},this.getActiveMipmapLevel=function(){return B},this.getRenderTarget=function(){return F},this.setRenderTarget=function(t,e,n){F=t,N=e,B=n,t&&void 0===x.get(t).__webglFramebuffer&&b.setupRenderTarget(t);var r=I,i=!1;if(t){var a=x.get(t).__webglFramebuffer;t.isWebGLRenderTargetCube?(r=a[e||0],i=!0):r=t.isWebGLMultisampleRenderTarget?x.get(t).__webglMultisampledFramebuffer:a,k.copy(t.viewport),j.copy(t.scissor),W=t.scissorTest}else k.copy(Z).multiplyScalar(Y).floor(),j.copy(J).multiplyScalar(Y).floor(),W=Q;if(z!==r&&(p.bindFramebuffer(36160,r),z=r),v.viewport(k),v.scissor(j),v.setScissorTest(W),i){var o=x.get(t.texture);p.framebufferTexture2D(36160,36064,34069+(e||0),o.__webglTexture,n||0)}},this.readRenderTargetPixels=function(t,e,n,r,i,a,o){if(t&&t.isWebGLRenderTarget){var s=x.get(t).__webglFramebuffer;if(t.isWebGLRenderTargetCube&&void 0!==o&&(s=s[o]),s){var c=!1;s!==z&&(p.bindFramebuffer(36160,s),c=!0);try{var l=t.texture,u=l.format,h=l.type;if(u!==jt&&C.convert(u)!==p.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(h===Pt||C.convert(h)===p.getParameter(35738)||h===Bt&&(m.isWebGL2||f.get("OES_texture_float")||f.get("WEBGL_color_buffer_float"))||h===Ft&&(m.isWebGL2?f.get("EXT_color_buffer_float"):f.get("EXT_color_buffer_half_float"))))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===p.checkFramebufferStatus(36160)?e>=0&&e<=t.width-r&&n>=0&&n<=t.height-i&&p.readPixels(e,n,r,i,C.convert(u),C.convert(h),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{c&&p.bindFramebuffer(36160,z)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(t,e,n){void 0===n&&(n=0);var r=Math.pow(2,-n),i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=C.convert(e.format);b.setTexture2D(e,0),p.copyTexImage2D(3553,n,o,t.x,t.y,i,a,0),v.unbindTexture()},this.copyTextureToTexture=function(t,e,n,r){var i=e.image.width,a=e.image.height,o=C.convert(n.format),s=C.convert(n.type);b.setTexture2D(n,0),e.isDataTexture?p.texSubImage2D(3553,r||0,t.x,t.y,i,a,o,s,e.image.data):p.texSubImage2D(3553,r||0,t.x,t.y,o,s,e.image),v.unbindTexture()},this.initTexture=function(t){b.setTexture2D(t,0),v.unbindTexture()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function _s(t,e){this.name="",this.color=new Zr(t),this.density=void 0!==e?e:25e-5}function Ms(t,e,n){this.name="",this.color=new Zr(t),this.near=void 0!==e?e:1,this.far=void 0!==n?n:1e3}function Ss(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=sn,this.updateRange={offset:0,count:-1},this.version=0}function Es(t,e,n,r){this.data=t,this.itemSize=e,this.offset=n,this.normalized=!0===r}function As(t){ei.call(this),this.type="SpriteMaterial",this.color=new Zr(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(t)}Object.assign(xs.prototype,vn.prototype),Object.assign(bs.prototype,vn.prototype),Object.assign(_s.prototype,{isFogExp2:!0,clone:function(){return new _s(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}),Object.assign(Ms.prototype,{isFog:!0,clone:function(){return new Ms(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}),Object.defineProperty(Ss.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Ss.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.stride,n*=e.stride;for(var r=0,i=this.stride;rt.far||e.push({distance:s,point:Ts.clone(),uv:Wr.getUV(Ts,Ds,Is,Ns,Bs,Fs,zs,new bn),face:null,object:this})}},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(t){return ar.prototype.copy.call(this,t),void 0!==t.center&&this.center.copy(t.center),this}});var Hs=new Sn,Vs=new Sn;function ks(){ar.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}function js(t,e){t&&t.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),Gi.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Hn,this.bindMatrixInverse=new Hn}ks.prototype=Object.assign(Object.create(ar.prototype),{constructor:ks,isLOD:!0,copy:function(t){ar.prototype.copy.call(this,t,!1);for(var e=t.levels,n=0,r=e.length;n1){Hs.setFromMatrixPosition(t.matrixWorld),Vs.setFromMatrixPosition(this.matrixWorld);var n=Hs.distanceTo(Vs);e[0].object.visible=!0;for(var r=1,i=e.length;r=e[r].distance;r++)e[r-1].object.visible=!1,e[r].object.visible=!0;for(;ro))u.applyMatrix4(this.matrixWorld),(w=t.ray.origin.distanceTo(u))t.far||e.push({distance:w,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}else for(m=0,v=p.length/3-1;mo))u.applyMatrix4(this.matrixWorld),(w=t.ray.origin.distanceTo(u))t.far||e.push({distance:w,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}else if(r.isGeometry){var x=r.vertices,b=x.length;for(m=0;mo))u.applyMatrix4(this.matrixWorld),(w=t.ray.origin.distanceTo(u))t.far||e.push({distance:w,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var rc=new Sn,ic=new Sn;function ac(t,e){nc.call(this,t,e),this.type="LineSegments"}function oc(t,e){nc.call(this,t,e),this.type="LineLoop"}function sc(t){ei.call(this),this.type="PointsMaterial",this.color=new Zr(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(t)}ac.prototype=Object.assign(Object.create(nc.prototype),{constructor:ac,isLineSegments:!0,computeLineDistances:function(){var t=this.geometry;if(t.isBufferGeometry)if(null===t.index){for(var e=t.attributes.position,n=[],r=0,i=e.count;ri.far)return;a.push({distance:l,distanceToRay:Math.sqrt(s),point:c,index:e,face:null,object:o})}}function fc(t,e,n,r,i,a,o,s,c){Pn.call(this,t,e,n,r,i,a,o,s,c),this.format=void 0!==o?o:kt,this.minFilter=void 0!==a?a:Et,this.magFilter=void 0!==i?i:Et,this.generateMipmaps=!1}function mc(t,e,n,r,i,a,o,s,c,l,u,h){Pn.call(this,null,a,o,s,c,l,r,i,u,h),this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function vc(t,e,n,r,i,a,o,s,c){Pn.call(this,t,e,n,r,i,a,o,s,c),this.needsUpdate=!0}function gc(t,e,n,r,i,a,o,s,c,l){if((l=void 0!==l?l:Yt)!==Yt&&l!==Zt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&l===Yt&&(n=Dt),void 0===n&&l===Zt&&(n=Ht),Pn.call(this,null,r,i,a,o,s,l,n,c),this.image={width:t,height:e},this.magFilter=void 0!==o?o:bt,this.minFilter=void 0!==s?s:bt,this.flipY=!1,this.generateMipmaps=!1}function yc(t){_i.call(this),this.type="WireframeGeometry";var e,n,r,i,a,o,s,c,l,u,h=[],d=[0,0],p={},f=["a","b","c"];if(t&&t.isGeometry){var m=t.faces;for(e=0,r=m.length;e=0?(t(v-1e-5,m,h),d.subVectors(u,h)):(t(v+1e-5,m,h),d.subVectors(h,u)),m-1e-5>=0?(t(v,m-1e-5,h),p.subVectors(u,h)):(t(v,m+1e-5,h),p.subVectors(h,u)),l.crossVectors(d,p).normalize(),s.push(l.x,l.y,l.z),c.push(v,m)}}for(r=0;r.9&&o<.1&&(e<.2&&(a[t+0]+=1),n<.2&&(a[t+2]+=1),r<.2&&(a[t+4]+=1))}}()}(),this.setAttribute("position",new hi(i,3)),this.setAttribute("normal",new hi(i.slice(),3)),this.setAttribute("uv",new hi(a,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}function Mc(t,e){Xi.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Sc(t,e)),this.mergeVertices()}function Sc(t,e){_c.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 Ec(t,e){Xi.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Ac(t,e)),this.mergeVertices()}function Ac(t,e){_c.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 Tc(t,e){Xi.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Lc(t,e)),this.mergeVertices()}function Lc(t,e){var n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1];_c.call(this,r,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Rc(t,e){Xi.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Pc(t,e)),this.mergeVertices()}function Pc(t,e){var n=(1+Math.sqrt(5))/2,r=1/n,i=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r];_c.call(this,i,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Cc(t,e,n,r,i,a){Xi.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:r,closed:i},void 0!==a&&console.warn("THREE.TubeGeometry: taper has been removed.");var o=new Oc(t,e,n,r,i);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals,this.fromBufferGeometry(o),this.mergeVertices()}function Oc(t,e,n,r,i){_i.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:r,closed:i},e=e||64,n=n||1,r=r||8,i=i||!1;var a=t.computeFrenetFrames(e,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;var o,s,c=new Sn,l=new Sn,u=new bn,h=new Sn,d=[],p=[],f=[],m=[];function v(i){h=t.getPointAt(i/e,h);var o=a.normals[i],u=a.binormals[i];for(s=0;s<=r;s++){var f=s/r*Math.PI*2,m=Math.sin(f),v=-Math.cos(f);l.x=v*o.x+m*u.x,l.y=v*o.y+m*u.y,l.z=v*o.z+m*u.z,l.normalize(),p.push(l.x,l.y,l.z),c.x=h.x+n*l.x,c.y=h.y+n*l.y,c.z=h.z+n*l.z,d.push(c.x,c.y,c.z)}}!function(){for(o=0;o0){var o=i[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=o.length;t0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),fc.prototype=Object.assign(Object.create(Pn.prototype),{constructor:fc,isVideoTexture:!0,update:function(){var t=this.image;t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),mc.prototype=Object.create(Pn.prototype),mc.prototype.constructor=mc,mc.prototype.isCompressedTexture=!0,vc.prototype=Object.create(Pn.prototype),vc.prototype.constructor=vc,vc.prototype.isCanvasTexture=!0,gc.prototype=Object.create(Pn.prototype),gc.prototype.constructor=gc,gc.prototype.isDepthTexture=!0,yc.prototype=Object.create(_i.prototype),yc.prototype.constructor=yc,xc.prototype=Object.create(Xi.prototype),xc.prototype.constructor=xc,bc.prototype=Object.create(_i.prototype),bc.prototype.constructor=bc,wc.prototype=Object.create(Xi.prototype),wc.prototype.constructor=wc,_c.prototype=Object.create(_i.prototype),_c.prototype.constructor=_c,Mc.prototype=Object.create(Xi.prototype),Mc.prototype.constructor=Mc,Sc.prototype=Object.create(_c.prototype),Sc.prototype.constructor=Sc,Ec.prototype=Object.create(Xi.prototype),Ec.prototype.constructor=Ec,Ac.prototype=Object.create(_c.prototype),Ac.prototype.constructor=Ac,Tc.prototype=Object.create(Xi.prototype),Tc.prototype.constructor=Tc,Lc.prototype=Object.create(_c.prototype),Lc.prototype.constructor=Lc,Rc.prototype=Object.create(Xi.prototype),Rc.prototype.constructor=Rc,Pc.prototype=Object.create(_c.prototype),Pc.prototype.constructor=Pc,Cc.prototype=Object.create(Xi.prototype),Cc.prototype.constructor=Cc,Oc.prototype=Object.create(_i.prototype),Oc.prototype.constructor=Oc,Oc.prototype.toJSON=function(){var t=_i.prototype.toJSON.call(this);return t.path=this.parameters.path.toJSON(),t},Dc.prototype=Object.create(Xi.prototype),Dc.prototype.constructor=Dc,Ic.prototype=Object.create(_i.prototype),Ic.prototype.constructor=Ic,Nc.prototype=Object.create(Xi.prototype),Nc.prototype.constructor=Nc,Bc.prototype=Object.create(_i.prototype),Bc.prototype.constructor=Bc;var Fc=function(t,e,n){n=n||2;var r,i,a,o,s,c,l,u=e&&e.length,h=u?e[0]*n:t.length,d=zc(t,0,h,n,!0),p=[];if(!d||d.next===d.prev)return p;if(u&&(d=function(t,e,n,r){var i,a,o,s,c,l=[];for(i=0,a=e.length;i80*n){r=a=t[0],i=o=t[1];for(var f=n;fa&&(a=s),c>o&&(o=c);l=0!==(l=Math.max(a-r,o-i))?1/l:0}return Gc(d,p,n,r,i,l),p};function zc(t,e,n,r,i){var a,o;if(i===function(t,e,n,r){for(var i=0,a=e,o=n-r;a0)for(a=e;a=e;a-=r)o=nl(a,t[a],t[a+1],o);return o&&Kc(o,o.next)&&(rl(o),o=o.next),o}function Uc(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!Kc(r,r.next)&&0!==Qc(r.prev,r,r.next))r=r.next;else{if(rl(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function Gc(t,e,n,r,i,a,o){if(t){!o&&a&&function(t,e,n,r){var i=t;do{null===i.z&&(i.z=Xc(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,a,o,s,c,l=1;do{for(n=t,t=null,a=null,o=0;n;){for(o++,r=n,s=0,e=0;e0||c>0&&r;)0!==s&&(0===c||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,c--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1)}(i)}(t,r,i,a);for(var s,c,l=t;t.prev!==t.next;)if(s=t.prev,c=t.next,a?Vc(t,r,i,a):Hc(t))e.push(s.i/n),e.push(t.i/n),e.push(c.i/n),rl(t),t=c.next,l=c.next;else if((t=c)===l){o?1===o?Gc(t=kc(t,e,n),e,n,r,i,a,2):2===o&&jc(t,e,n,r,i,a):Gc(Uc(t),e,n,r,i,a,1);break}}}function Hc(t){var e=t.prev,n=t,r=t.next;if(Qc(e,n,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(Zc(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Qc(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Vc(t,e,n,r){var i=t.prev,a=t,o=t.next;if(Qc(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,u=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,h=Xc(s,c,e,n,r),d=Xc(l,u,e,n,r),p=t.prevZ,f=t.nextZ;p&&p.z>=h&&f&&f.z<=d;){if(p!==t.prev&&p!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Qc(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==t.prev&&f!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Qc(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=h;){if(p!==t.prev&&p!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Qc(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==t.prev&&f!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Qc(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function kc(t,e,n){var r=t;do{var i=r.prev,a=r.next.next;!Kc(i,a)&&$c(i,r,r.next,a)&&tl(i,a)&&tl(a,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(a.i/n),rl(r),rl(r.next),r=t=a),r=r.next}while(r!==t);return r}function jc(t,e,n,r,i,a){var o=t;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&Jc(o,s)){var c=el(o,s);return o=Uc(o,o.next),c=Uc(c,c.next),Gc(o,e,n,r,i,a),void Gc(c,e,n,r,i,a)}s=s.next}o=o.next}while(o!==t)}function Wc(t,e){return t.x-e.x}function qc(t,e){if(e=function(t,e){var n,r=e,i=t.x,a=t.y,o=-1/0;do{if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){var s=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>o){if(o=s,s===i){if(a===r.y)return r;if(a===r.next.y)return r.next}n=r.x=r.x&&r.x>=u&&i!==r.x&&Zc(an.x)&&tl(r,t)&&(n=r,d=c),r=r.next;return n}(t,e)){var n=el(e,t);Uc(n,n.next)}}function Xc(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Yc(t){var e=t,n=t;do{(e.x=0&&(t-o)*(r-s)-(n-o)*(e-s)>=0&&(n-o)*(a-s)-(i-o)*(r-s)>=0}function Jc(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&&$c(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&tl(t,e)&&tl(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)}function Qc(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Kc(t,e){return t.x===e.x&&t.y===e.y}function $c(t,e,n,r){return!!(Kc(t,n)&&Kc(e,r)||Kc(t,r)&&Kc(n,e))||Qc(t,e,n)>0!=Qc(t,e,r)>0&&Qc(n,r,t)>0!=Qc(n,r,e)>0}function tl(t,e){return Qc(t.prev,t,t.next)<0?Qc(t,e,t.next)>=0&&Qc(t,t.prev,e)>=0:Qc(t,e,t.prev)<0||Qc(t,t.next,e)<0}function el(t,e){var n=new il(t.i,t.x,t.y),r=new il(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function nl(t,e,n,r){var i=new il(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function rl(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 il(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 al={area:function(t){for(var e=t.length,n=0,r=e-1,i=0;i2&&t[e-1].equals(t[0])&&t.pop()}function sl(t,e){for(var n=0;nNumber.EPSILON){var d=Math.sqrt(u),p=Math.sqrt(c*c+l*l),f=e.x-s/d,m=e.y+o/d,v=((n.x-l/p-f)*l-(n.y+c/p-m)*c)/(o*l-s*c),g=(r=f+o*v-t.x)*r+(i=m+s*v-t.y)*i;if(g<=2)return new bn(r,i);a=Math.sqrt(g/2)}else{var y=!1;o>Number.EPSILON?c>Number.EPSILON&&(y=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(l)&&(y=!0),y?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new bn(r/a,i/a)}for(var G=[],H=0,V=R.length,k=V-1,j=H+1;H=0;C--){for(D=C/p,I=u*Math.cos(D*Math.PI/2),O=h*Math.sin(D*Math.PI/2)+d,H=0,V=R.length;H=0;){n=H,(r=H-1)<0&&(r=t.length-1);var i=0,a=s+2*p;for(i=0;i0)&&f.push(_,M,E),(c!==n-1||l0&&g(!0),e>0&&g(!1)),this.setIndex(l),this.setAttribute("position",new hi(u,3)),this.setAttribute("normal",new hi(h,3)),this.setAttribute("uv",new hi(d,2))}function Al(t,e,n,r,i,a,o){Sl.call(this,0,t,e,n,r,i,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}function Tl(t,e,n,r,i,a,o){El.call(this,0,t,e,n,r,i,a,o),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}function Ll(t,e,n,r){Xi.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},this.fromBufferGeometry(new Rl(t,e,n,r)),this.mergeVertices()}function Rl(t,e,n,r){_i.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},t=t||1,e=void 0!==e?Math.max(3,e):8,n=void 0!==n?n:0,r=void 0!==r?r:2*Math.PI;var i,a,o=[],s=[],c=[],l=[],u=new Sn,h=new bn;for(s.push(0,0,0),c.push(0,0,1),l.push(.5,.5),a=0,i=3;a<=e;a++,i+=3){var d=n+a/e*r;u.x=t*Math.cos(d),u.y=t*Math.sin(d),s.push(u.x,u.y,u.z),c.push(0,0,1),h.x=(s[i]/t+1)/2,h.y=(s[i+1]/t+1)/2,l.push(h.x,h.y)}for(i=1;i<=e;i++)o.push(i,i+1,0);this.setIndex(o),this.setAttribute("position",new hi(s,3)),this.setAttribute("normal",new hi(c,3)),this.setAttribute("uv",new hi(l,2))}dl.prototype=Object.create(Xi.prototype),dl.prototype.constructor=dl,pl.prototype=Object.create(ll.prototype),pl.prototype.constructor=pl,fl.prototype=Object.create(Xi.prototype),fl.prototype.constructor=fl,ml.prototype=Object.create(_i.prototype),ml.prototype.constructor=ml,vl.prototype=Object.create(Xi.prototype),vl.prototype.constructor=vl,gl.prototype=Object.create(_i.prototype),gl.prototype.constructor=gl,yl.prototype=Object.create(Xi.prototype),yl.prototype.constructor=yl,xl.prototype=Object.create(_i.prototype),xl.prototype.constructor=xl,bl.prototype=Object.create(Xi.prototype),bl.prototype.constructor=bl,bl.prototype.toJSON=function(){var t=Xi.prototype.toJSON.call(this);return _l(this.parameters.shapes,t)},wl.prototype=Object.create(_i.prototype),wl.prototype.constructor=wl,wl.prototype.toJSON=function(){var t=_i.prototype.toJSON.call(this);return _l(this.parameters.shapes,t)},Ml.prototype=Object.create(_i.prototype),Ml.prototype.constructor=Ml,Sl.prototype=Object.create(Xi.prototype),Sl.prototype.constructor=Sl,El.prototype=Object.create(_i.prototype),El.prototype.constructor=El,Al.prototype=Object.create(Sl.prototype),Al.prototype.constructor=Al,Tl.prototype=Object.create(El.prototype),Tl.prototype.constructor=Tl,Ll.prototype=Object.create(Xi.prototype),Ll.prototype.constructor=Ll,Rl.prototype=Object.create(_i.prototype),Rl.prototype.constructor=Rl;var Pl=Object.freeze({__proto__:null,WireframeGeometry:yc,ParametricGeometry:xc,ParametricBufferGeometry:bc,TetrahedronGeometry:Mc,TetrahedronBufferGeometry:Sc,OctahedronGeometry:Ec,OctahedronBufferGeometry:Ac,IcosahedronGeometry:Tc,IcosahedronBufferGeometry:Lc,DodecahedronGeometry:Rc,DodecahedronBufferGeometry:Pc,PolyhedronGeometry:wc,PolyhedronBufferGeometry:_c,TubeGeometry:Cc,TubeBufferGeometry:Oc,TorusKnotGeometry:Dc,TorusKnotBufferGeometry:Ic,TorusGeometry:Nc,TorusBufferGeometry:Bc,TextGeometry:dl,TextBufferGeometry:pl,SphereGeometry:fl,SphereBufferGeometry:ml,RingGeometry:vl,RingBufferGeometry:gl,PlaneGeometry:ga,PlaneBufferGeometry:ya,LatheGeometry:yl,LatheBufferGeometry:xl,ShapeGeometry:bl,ShapeBufferGeometry:wl,ExtrudeGeometry:cl,ExtrudeBufferGeometry:ll,EdgesGeometry:Ml,ConeGeometry:Al,ConeBufferGeometry:Tl,CylinderGeometry:Sl,CylinderBufferGeometry:El,CircleGeometry:Ll,CircleBufferGeometry:Rl,BoxGeometry:Yi,BoxBufferGeometry:Zi});function Cl(t){ei.call(this),this.type="ShadowMaterial",this.color=new Zr(0),this.transparent=!0,this.setValues(t)}function Ol(t){ea.call(this,t),this.type="RawShaderMaterial"}function Dl(t){ei.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Zr(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 Zr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(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 Il(t){Dl.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearcoat=0,this.clearcoatRoughness=0,this.sheen=null,this.clearcoatNormalScale=new bn(1,1),this.clearcoatNormalMap=null,this.transparency=0,this.setValues(t)}function Nl(t){ei.call(this),this.type="MeshPhongMaterial",this.color=new Zr(16777215),this.specular=new Zr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Zr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=tt,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 Bl(t){Nl.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function Fl(t){ei.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function zl(t){ei.call(this),this.type="MeshLambertMaterial",this.color=new Zr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Zr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=tt,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 Ul(t){ei.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Zr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Gl(t){Js.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}Cl.prototype=Object.create(ei.prototype),Cl.prototype.constructor=Cl,Cl.prototype.isShadowMaterial=!0,Cl.prototype.copy=function(t){return ei.prototype.copy.call(this,t),this.color.copy(t.color),this},Ol.prototype=Object.create(ea.prototype),Ol.prototype.constructor=Ol,Ol.prototype.isRawShaderMaterial=!0,Dl.prototype=Object.create(ei.prototype),Dl.prototype.constructor=Dl,Dl.prototype.isMeshStandardMaterial=!0,Dl.prototype.copy=function(t){return ei.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.normalMapType=t.normalMapType,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},Il.prototype=Object.create(Dl.prototype),Il.prototype.constructor=Il,Il.prototype.isMeshPhysicalMaterial=!0,Il.prototype.copy=function(t){return Dl.prototype.copy.call(this,t),this.defines={STANDARD:"",PHYSICAL:""},this.reflectivity=t.reflectivity,this.clearcoat=t.clearcoat,this.clearcoatRoughness=t.clearcoatRoughness,t.sheen?this.sheen=(this.sheen||new Zr).copy(t.sheen):this.sheen=null,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.transparency=t.transparency,this},Nl.prototype=Object.create(ei.prototype),Nl.prototype.constructor=Nl,Nl.prototype.isMeshPhongMaterial=!0,Nl.prototype.copy=function(t){return ei.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.normalMapType=t.normalMapType,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},Bl.prototype=Object.create(Nl.prototype),Bl.prototype.constructor=Bl,Bl.prototype.isMeshToonMaterial=!0,Bl.prototype.copy=function(t){return Nl.prototype.copy.call(this,t),this.gradientMap=t.gradientMap,this},Fl.prototype=Object.create(ei.prototype),Fl.prototype.constructor=Fl,Fl.prototype.isMeshNormalMaterial=!0,Fl.prototype.copy=function(t){return ei.prototype.copy.call(this,t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,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},zl.prototype=Object.create(ei.prototype),zl.prototype.constructor=zl,zl.prototype.isMeshLambertMaterial=!0,zl.prototype.copy=function(t){return ei.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},Ul.prototype=Object.create(ei.prototype),Ul.prototype.constructor=Ul,Ul.prototype.isMeshMatcapMaterial=!0,Ul.prototype.copy=function(t){return ei.prototype.copy.call(this,t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Gl.prototype=Object.create(Js.prototype),Gl.prototype.constructor=Gl,Gl.prototype.isLineDashedMaterial=!0,Gl.prototype.copy=function(t){return Js.prototype.copy.call(this,t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this};var Hl=Object.freeze({__proto__:null,ShadowMaterial:Cl,SpriteMaterial:As,RawShaderMaterial:Ol,ShaderMaterial:ea,PointsMaterial:sc,MeshPhysicalMaterial:Il,MeshStandardMaterial:Dl,MeshPhongMaterial:Nl,MeshToonMaterial:Bl,MeshNormalMaterial:Fl,MeshLambertMaterial:zl,MeshDepthMaterial:rs,MeshDistanceMaterial:is,MeshBasicMaterial:ni,MeshMatcapMaterial:Ul,LineDashedMaterial:Gl,LineBasicMaterial:Js,Material:ei}),Vl={arraySlice:function(t,e,n){return Vl.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),r=0;r!==e;++r)n[r]=r;return n.sort((function(e,n){return t[e]-t[n]})),n},sortedArray:function(t,e,n){for(var r=t.length,i=new t.constructor(r),a=0,o=0;o!==r;++a)for(var s=n[a]*e,c=0;c!==e;++c)i[o++]=t[s+c];return i},flattenJSON:function(t,e,n,r){for(var i=1,a=t[0];void 0!==a&&void 0===a[r];)a=t[i++];if(void 0!==a){var o=a[r];if(void 0!==o)if(Array.isArray(o))do{void 0!==(o=a[r])&&(e.push(a.time),n.push.apply(n,o)),a=t[i++]}while(void 0!==a);else if(void 0!==o.toArray)do{void 0!==(o=a[r])&&(e.push(a.time),o.toArray(n,n.length)),a=t[i++]}while(void 0!==a);else do{void 0!==(o=a[r])&&(e.push(a.time),n.push(o)),a=t[i++]}while(void 0!==a)}},subclip:function(t,e,n,r,i){i=i||30;var a=t.clone();a.name=e;for(var o=[],s=0;s=r)){u.push(c.times[d]);for(var f=0;fa.tracks[s].times[0]&&(m=a.tracks[s].times[0]);for(s=0;s=i)break t;var s=e[1];t=(i=e[--n-1]))break e}a=n,n=0}for(;n>>1;te;)--a;if(++a,0!==i||a!==r){i>=a&&(i=(a=Math.max(a,1))-1);var o=this.getValueSize();this.times=Vl.arraySlice(n,i,a),this.values=Vl.arraySlice(this.values,i*o,a*o)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);var n=this.times,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);for(var a=null,o=0;o!==i;o++){var s=n[o];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,s),t=!1;break}if(null!==a&&a>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,s,a),t=!1;break}a=s}if(void 0!==r&&Vl.isTypedArray(r)){o=0;for(var c=r.length;o!==c;++o){var l=r[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}}return t},optimize:function(){for(var t=this.times,e=this.values,n=this.getValueSize(),r=this.getInterpolation()===Ee,i=1,a=t.length-1,o=1;o0){t[i]=t[a];for(f=a*n,m=i*n,d=0;d!==n;++d)e[m+d]=e[f+d];++i}return i!==t.length&&(this.times=Vl.arraySlice(t,0,i),this.values=Vl.arraySlice(e,0,i*n)),this},clone:function(){var t=Vl.arraySlice(this.times,0),e=Vl.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}),Yl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Yl,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:Me,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Zl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Zl,ValueTypeName:"color"}),Jl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Jl,ValueTypeName:"number"}),Ql.prototype=Object.assign(Object.create(kl.prototype),{constructor:Ql,interpolate_:function(t,e,n,r){for(var i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=t*o,c=(n-e)/(r-e),l=s+o;s!==l;s+=4)wn.slerpFlat(i,0,a,s-o,a,s,c);return i}}),Kl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Kl,ValueTypeName:"quaternion",DefaultInterpolation:Se,InterpolantFactoryMethodLinear:function(t){return new Ql(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),$l.prototype=Object.assign(Object.create(Xl.prototype),{constructor:$l,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:Me,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),tu.prototype=Object.assign(Object.create(Xl.prototype),{constructor:tu,ValueTypeName:"vector"}),Object.assign(eu,{parse:function(t){for(var e=[],n=t.tracks,r=1/(t.fps||1),i=0,a=n.length;i!==a;++i)e.push(nu(n[i]).scale(r));return new eu(t.name,t.duration,e)},toJSON:function(t){for(var e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid},i=0,a=n.length;i!==a;++i)e.push(Xl.toJSON(n[i]));return r},CreateFromMorphTargetSequence:function(t,e,n,r){for(var i=e.length,a=[],o=0;o1){var l=r[h=c[1]];l||(r[h]=l=[]),l.push(s)}}var u=[];for(var h in r)u.push(eu.CreateFromMorphTargetSequence(h,r[h],e,n));return u},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var n=function(t,e,n,r,i){if(0!==n.length){var a=[],o=[];Vl.flattenJSON(n,a,o,r),0!==a.length&&i.push(new t(e,a,o))}},r=[],i=t.name||"default",a=t.length||-1,o=t.fps||30,s=t.hierarchy||[],c=0;c0||0===t.search(/^data\:image\/jpeg/);i.format=r?kt:jt,i.needsUpdate=!0,void 0!==e&&e(i)}),n,r),i}}),Object.assign(mu.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,e){var n=this.getUtoTmapping(t);return this.getPoint(n,e)},getPoints:function(t){void 0===t&&(t=5);for(var e=[],n=0;n<=t;n++)e.push(this.getPoint(n/t));return e},getSpacedPoints:function(t){void 0===t&&(t=5);for(var e=[],n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,n,r=[],i=this.getPoint(0),a=0;for(r.push(0),n=1;n<=t;n++)a+=(e=this.getPoint(n/t)).distanceTo(i),r.push(a),i=e;return this.cacheArcLengths=r,r},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){var n,r=this.getLengths(),i=0,a=r.length;n=e||t*r[a-1];for(var o,s=0,c=a-1;s<=c;)if((o=r[i=Math.floor(s+(c-s)/2)]-n)<0)s=i+1;else{if(!(o>0)){c=i;break}c=i-1}if(r[i=c]===n)return i/(a-1);var l=r[i];return(i+(n-l)/(r[i+1]-l))/(a-1)},getTangent:function(t){var e=t-1e-4,n=t+1e-4;e<0&&(e=0),n>1&&(n=1);var r=this.getPoint(e);return this.getPoint(n).clone().sub(r).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var n,r,i,a=new Sn,o=[],s=[],c=[],l=new Sn,u=new Hn;for(n=0;n<=t;n++)r=n/t,o[n]=this.getTangentAt(r),o[n].normalize();s[0]=new Sn,c[0]=new Sn;var h=Number.MAX_VALUE,d=Math.abs(o[0].x),p=Math.abs(o[0].y),f=Math.abs(o[0].z);for(d<=h&&(h=d,a.set(1,0,0)),p<=h&&(h=p,a.set(0,1,0)),f<=h&&a.set(0,0,1),l.crossVectors(o[0],a).normalize(),s[0].crossVectors(o[0],l),c[0].crossVectors(o[0],s[0]),n=1;n<=t;n++)s[n]=s[n-1].clone(),c[n]=c[n-1].clone(),l.crossVectors(o[n-1],o[n]),l.length()>Number.EPSILON&&(l.normalize(),i=Math.acos(xn.clamp(o[n-1].dot(o[n]),-1,1)),s[n].applyMatrix4(u.makeRotationAxis(l,i))),c[n].crossVectors(o[n],s[n]);if(!0===e)for(i=Math.acos(xn.clamp(s[0].dot(s[t]),-1,1)),i/=t,o[0].dot(l.crossVectors(s[0],s[t]))>0&&(i=-i),n=1;n<=t;n++)s[n].applyMatrix4(u.makeRotationAxis(o[n],i*n)),c[n].crossVectors(o[n],s[n]);return{tangents:o,normals:s,binormals:c}},clone:function(){return(new this.constructor).copy(this)},copy:function(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}}),vu.prototype=Object.create(mu.prototype),vu.prototype.constructor=vu,vu.prototype.isEllipseCurve=!0,vu.prototype.getPoint=function(t,e){for(var n=e||new bn,r=2*Math.PI,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)r;)i-=r;i0?0:(Math.floor(Math.abs(u)/c)+1)*c:0===h&&u===c-1&&(u=c-2,h=1),this.closed||u>0?n=s[(u-1)%c]:(xu.subVectors(s[0],s[1]).add(s[0]),n=xu),r=s[u%c],i=s[(u+1)%c],this.closed||u+2r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(Su(o,s.x,c.x,l.x,u.x),Su(o,s.y,c.y,l.y,u.y)),n},Du.prototype.copy=function(t){mu.prototype.copy.call(this,t),this.points=[];for(var e=0,n=t.points.length;e=e){var i=n[r]-e,a=this.curves[r],o=a.getLength(),s=0===o?0:1-i/o;return a.getPointAt(s)}r++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,n=0,r=this.curves.length;n1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},copy:function(t){mu.prototype.copy.call(this,t),this.curves=[];for(var e=0,n=t.curves.length;e0){var l=c.getPoint(0);l.equals(this.currentPoint)||this.lineTo(l.x,l.y)}this.curves.push(c);var u=c.getPoint(1);return this.currentPoint.copy(u),this},copy:function(t){return Nu.prototype.copy.call(this,t),this.currentPoint.copy(t.currentPoint),this},toJSON:function(){var t=Nu.prototype.toJSON.call(this);return t.currentPoint=this.currentPoint.toArray(),t},fromJSON:function(t){return Nu.prototype.fromJSON.call(this,t),this.currentPoint.fromArray(t.currentPoint),this}}),Fu.prototype=Object.assign(Object.create(Bu.prototype),{constructor:Fu,getPointsHoles:function(t){for(var e=[],n=0,r=this.holes.length;n0){var a=new du(new iu(e));a.setCrossOrigin(this.crossOrigin);for(var o=0,s=t.length;o0?new js(o,s):new Gi(o,s);break;case"InstancedMesh":o=i(t.geometry),s=a(t.material);var c=t.count,l=t.instanceMatrix;(r=new Zs(o,s,c)).instanceMatrix=new ri(new Float32Array(l.array),16);break;case"LOD":r=new ks;break;case"Line":r=new nc(i(t.geometry),a(t.material),t.mode);break;case"LineLoop":r=new oc(i(t.geometry),a(t.material));break;case"LineSegments":r=new ac(i(t.geometry),a(t.material));break;case"PointCloud":case"Points":r=new dc(i(t.geometry),a(t.material));break;case"Sprite":r=new Us(a(t.material));break;case"Group":r=new ps;break;default:r=new ar}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(r.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(r.matrixAutoUpdate=t.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.frustumCulled&&(r.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(r.renderOrder=t.renderOrder),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.layers&&(r.layers.mask=t.layers),void 0!==t.drawMode&&r.setDrawMode(t.drawMode),void 0!==t.children)for(var u=t.children,h=0;hNumber.EPSILON){if(l<0&&(o=e[a],c=-c,s=e[i],l=-l),t.ys.y)continue;if(t.y===o.y){if(t.x===o.x)return!0}else{var u=l*(t.x-o.x)-c*(t.y-o.y);if(0===u)return!0;if(u<0)continue;r=!r}}else{if(t.y!==o.y)continue;if(s.x<=t.x&&t.x<=o.x||o.x<=t.x&&t.x<=s.x)return!0}}return r}var i=al.isClockWise,a=this.subPaths;if(0===a.length)return[];if(!0===e)return n(a);var o,s,c,l=[];if(1===a.length)return s=a[0],(c=new Fu).curves=s.curves,l.push(c),l;var u=!i(a[0].getPoints());u=t?!u:u;var h,d,p=[],f=[],m=[],v=0;f[v]=void 0,m[v]=[];for(var g=0,y=a.length;g1){for(var x=!1,b=[],w=0,_=f.length;w<_;w++)p[w]=[];for(w=0,_=f.length;w<_;w++)for(var M=m[w],S=0;S0&&(x||(m=p))}g=0;for(var L=f.length;g0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var a=0;a!==i;++a)t[e+a]=t[n+a]},_slerp:function(t,e,n,r){wn.slerpFlat(t,e,t,e,t,n,r)},_lerp:function(t,e,n,r,i){for(var a=1-r,o=0;o!==i;++o){var s=e+o;t[s]=t[s]*a+t[n+o]*r}}});var Nh=new RegExp("[\\[\\]\\.:\\/]","g"),Bh="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",Fh=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]"),zh=/(WCOD+)?/.source.replace("WCOD",Bh),Uh=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Gh=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Hh=new RegExp("^"+Fh+zh+Uh+Gh+"$"),Vh=["material","materials","bones"];function kh(t,e,n){var r=n||jh.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}function jh(t,e,n){this.path=e,this.parsedPath=n||jh.parseTrackName(e),this.node=jh.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function Wh(){this.uuid=xn.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var t={};this._indicesByUUID=t;for(var e=0,n=arguments.length;e!==n;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var r=this;this.stats={objects:{get total(){return r._objects.length},get inUse(){return this.total-r.nCachedObjects_}},get bindingsPerObject(){return r._bindings.length}}}function qh(t,e,n){this._mixer=t,this._clip=e,this._localRoot=n||null;for(var r=e.tracks,i=r.length,a=new Array(i),o={endingStart:Ae,endingEnd:Ae},s=0;s!==i;++s){var c=r[s].createInterpolant(null);a[s]=c,c.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=we,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 Xh(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Yh(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function Zh(t,e,n){Ss.call(this,t,e),this.meshPerAttribute=n||1}function Jh(t,e,n,r){this.ray=new Pr(t,e),this.near=n||0,this.far=r||1/0,this.camera=null,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 Qh(t,e){return t.distance-e.distance}function Kh(t,e,n,r){if(!1!==t.visible&&(t.raycast(e,n),!0===r))for(var i=t.children,a=0,o=i.length;a=e){var u=e++,h=t[u];n[h.uuid]=l,t[l]=h,n[c]=u,t[u]=s;for(var d=0,p=i;d!==p;++d){var f=r[d],m=f[u],v=f[l];f[l]=m,f[u]=v}}}this.nCachedObjects_=e},uncache:function(){for(var t=this._objects,e=t.length,n=this.nCachedObjects_,r=this._indicesByUUID,i=this._bindings,a=i.length,o=0,s=arguments.length;o!==s;++o){var c=arguments[o],l=c.uuid,u=r[l];if(void 0!==u)if(delete r[l],u0)for(var c=this._interpolants,l=this._propertyBindings,u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulate(r,s)}else this._updateWeight(t)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var n=this._weightInterpolant;if(null!==n){var r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var n=this._timeScaleInterpolant;if(null!==n)e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t,n=this._clip.duration,r=this.loop,i=this._loopCount,a=r===_e;if(0===t)return-1===i?e:a&&1==(1&i)?n-e:e;if(r===be){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=n)e=n;else{if(!(e<0)){this.time=e;break t}e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=e,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),e>=n||e<0){var o=Math.floor(e/n);e-=n*o,i+=Math.abs(o);var s=this.repetitions-i;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?n:0,this.time=e,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===s){var c=t<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=e;if(a&&1==(1&i))return n-e}return e},_setEndings:function(t,e,n){var r=this._interpolantSettings;n?(r.endingStart=Te,r.endingEnd=Te):(r.endingStart=t?this.zeroSlopeAtStart?Te:Ae:Le,r.endingEnd=e?this.zeroSlopeAtEnd?Te:Ae:Le)},_scheduleFading:function(t,e,n){var r=this._mixer,i=r.time,a=this._weightInterpolant;null===a&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=e,o[1]=i+t,s[1]=n,this}}),Xh.prototype=Object.assign(Object.create(vn.prototype),{constructor:Xh,_bindAction:function(t,e){var n=t._localRoot||this._root,r=t._clip.tracks,i=r.length,a=t._propertyBindings,o=t._interpolants,s=n.uuid,c=this._bindingsByRootAndName,l=c[s];void 0===l&&(l={},c[s]=l);for(var u=0;u!==i;++u){var h=r[u],d=h.name,p=l[d];if(void 0!==p)a[u]=p;else{if(void 0!==(p=a[u])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,s,d));continue}var f=e&&e._propertyBindings[u].binding.parsedPath;++(p=new Ih(jh.create(n,d,f),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(p,s,d),a[u]=p}o[u].resultBuffer=p.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,n=t._clip.uuid,r=this._actionsByClip[n];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,n,e)}for(var i=t._propertyBindings,a=0,o=i.length;a!==o;++a){var s=i[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,n=0,r=e.length;n!==r;++n){var i=e[n];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&ethis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .getParameter() target is now required"),e=new bn),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .clampPoint() target is now required"),e=new bn),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return ed.copy(t).clamp(this.min,this.max).sub(t).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)}});var rd=new Sn,id=new Sn;function ad(t,e){this.start=void 0!==t?t:new Sn,this.end=void 0!==e?e:new Sn}function od(t){ar.call(this),this.material=t,this.render=function(){}}Object.assign(ad.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return void 0===t&&(console.warn("THREE.Line3: .getCenter() target is now required"),t=new Sn),t.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return void 0===t&&(console.warn("THREE.Line3: .delta() target is now required"),t=new Sn),t.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){return void 0===e&&(console.warn("THREE.Line3: .at() target is now required"),e=new Sn),this.delta(e).multiplyScalar(t).add(this.start)},closestPointToPointParameter:function(t,e){rd.subVectors(t,this.start),id.subVectors(this.end,this.start);var n=id.dot(id),r=id.dot(rd)/n;return e&&(r=xn.clamp(r,0,1)),r},closestPointToPoint:function(t,e,n){var r=this.closestPointToPointParameter(t,e);return void 0===n&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),n=new Sn),this.delta(n).multiplyScalar(r).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}}),od.prototype=Object.create(ar.prototype),od.prototype.constructor=od,od.prototype.isImmediateRenderObject=!0;var sd=new Sn,cd=new Sn,ld=new Tn,ud=["a","b","c"];function hd(t,e,n,r){this.object=t,this.size=void 0!==e?e:1;var i=void 0!==n?n:16711680,a=void 0!==r?r:1,o=0,s=this.object.geometry;s&&s.isGeometry?o=3*s.faces.length:s&&s.isBufferGeometry&&(o=s.attributes.normal.count);var c=new _i,l=new hi(2*o*3,3);c.setAttribute("position",l),ac.call(this,c,new Js({color:i,linewidth:a})),this.matrixAutoUpdate=!1,this.update()}hd.prototype=Object.create(ac.prototype),hd.prototype.constructor=hd,hd.prototype.update=function(){this.object.updateMatrixWorld(!0),ld.getNormalMatrix(this.object.matrixWorld);var t=this.object.matrixWorld,e=this.geometry.attributes.position,n=this.object.geometry;if(n&&n.isGeometry)for(var r=n.vertices,i=n.faces,a=0,o=0,s=i.length;o1&&t.multiplyScalar(1/e),this.children[0].material.color.copy(this.material.color)}},xd.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()};var bd=new Sn,wd=new Zr,_d=new Zr;function Md(t,e,n){ar.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;var r=new Ac(e);r.rotateY(.5*Math.PI),this.material=new ni({wireframe:!0,fog:!1}),void 0===this.color&&(this.material.vertexColors=M);var i=r.getAttribute("position"),a=new Float32Array(3*i.count);r.setAttribute("color",new ri(a,3)),this.add(new Gi(r,this.material)),this.update()}function Sd(t,e){this.lightProbe=t,this.size=e;var n={GAMMA_OUTPUT:""},r=new ea({defines:n,uniforms:{sh:{value:this.lightProbe.sh.coefficients},intensity:{value:this.lightProbe.intensity}},vertexShader:["varying vec3 vNormal;","void main() {","\tvNormal = normalize( normalMatrix * normal );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#define RECIPROCAL_PI 0.318309886","vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {","\t// matrix is assumed to be orthogonal","\treturn normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );","}","vec3 linearToOutput( in vec3 a ) {","\t#ifdef GAMMA_OUTPUT","\t\treturn pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );","\t#else","\t\treturn a;","\t#endif","}","// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf","vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {","\t// normal is assumed to have unit length","\tfloat x = normal.x, y = normal.y, z = normal.z;","\t// band 0","\tvec3 result = shCoefficients[ 0 ] * 0.886227;","\t// band 1","\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;","\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;","\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;","\t// band 2","\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;","\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;","\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );","\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;","\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );","\treturn result;","}","uniform vec3 sh[ 9 ]; // sh coefficients","uniform float intensity; // light probe intensity","varying vec3 vNormal;","void main() {","\tvec3 normal = normalize( vNormal );","\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );","\tvec3 irradiance = shGetIrradianceAt( worldNormal, sh );","\tvec3 outgoingLight = RECIPROCAL_PI * irradiance * intensity;","\toutgoingLight = linearToOutput( outgoingLight );","\tgl_FragColor = vec4( outgoingLight, 1.0 );","}"].join("\n")}),i=new ml(1,32,16);Gi.call(this,i,r),this.onBeforeRender()}function Ed(t,e,n,r){t=t||10,e=e||10,n=new Zr(void 0!==n?n:4473924),r=new Zr(void 0!==r?r:8947848);for(var i=e/2,a=t/e,o=t/2,s=[],c=[],l=0,u=0,h=-o;l<=e;l++,h+=a){s.push(-o,0,h,o,0,h),s.push(h,0,-o,h,0,o);var d=l===i?n:r;d.toArray(c,u),u+=3,d.toArray(c,u),u+=3,d.toArray(c,u),u+=3,d.toArray(c,u),u+=3}var p=new _i;p.setAttribute("position",new hi(s,3)),p.setAttribute("color",new hi(c,3));var f=new Js({vertexColors:M});ac.call(this,p,f)}function Ad(t,e,n,r,i,a){t=t||10,e=e||16,n=n||8,r=r||64,i=new Zr(void 0!==i?i:4473924),a=new Zr(void 0!==a?a:8947848);var o,s,c,l,u,h,d,p=[],f=[];for(l=0;l<=e;l++)c=l/e*(2*Math.PI),o=Math.sin(c)*t,s=Math.cos(c)*t,p.push(0,0,0),p.push(o,0,s),d=1&l?i:a,f.push(d.r,d.g,d.b),f.push(d.r,d.g,d.b);for(l=0;l<=n;l++)for(d=1&l?i:a,h=t-t/n*l,u=0;u.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{qd.set(t.z,0,-t.x).normalize();var e=Math.acos(t.y);this.quaternion.setFromAxisAngle(qd,e)}},Xd.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(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()},Xd.prototype.setColor=function(t){this.line.material.color.set(t),this.cone.material.color.set(t)},Xd.prototype.copy=function(t){return ar.prototype.copy.call(this,t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this},Xd.prototype.clone=function(){return(new this.constructor).copy(this)},Yd.prototype=Object.create(ac.prototype),Yd.prototype.constructor=Yd;var Jd=0,Qd=1;function Kd(t){return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."),t}function $d(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 tp(t,e){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new dc(t,e)}function ep(t){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new Us(t)}function np(t,e){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new dc(t,e)}function rp(t){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new sc(t)}function ip(t){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new sc(t)}function ap(t){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new sc(t)}function op(t,e,n){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new Sn(t,e,n)}function sp(t,e){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead."),new ri(t,e).setDynamic(!0)}function cp(t,e){return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."),new ii(t,e)}function lp(t,e){return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."),new ai(t,e)}function up(t,e){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."),new oi(t,e)}function hp(t,e){return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."),new si(t,e)}function dp(t,e){return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."),new ci(t,e)}function pp(t,e){return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."),new li(t,e)}function fp(t,e){return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."),new ui(t,e)}function mp(t,e){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new hi(t,e)}function vp(t,e){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new di(t,e)}function gp(t){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Mu.call(this,t),this.type="catmullrom",this.closed=!0}function yp(t){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Mu.call(this,t),this.type="catmullrom"}function xp(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),Mu.call(this,t),this.type="catmullrom"}function bp(t){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new Yd(t)}function wp(t,e){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Hd(t,e)}function _p(t,e){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new ac(new Ml(t.geometry),new Js({color:void 0!==e?e:16777215}))}function Mp(t,e){return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."),new ac(new yc(t.geometry),new Js({color:void 0!==e?e:16777215}))}function Sp(t){return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."),new cu(t)}function Ep(t){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new hu(t)}mu.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(mu.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},Object.assign(Nu.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 Xi,n=0,r=t.length;n0&&i[i.length-1])&&(6===a[0]||2===a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]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>8&255]+gn[t>>16&255]+gn[t>>24&255]+"-"+gn[255&e]+gn[e>>8&255]+"-"+gn[e>>16&15|64]+gn[e>>24&255]+"-"+gn[63&n|128]+gn[n>>8&255]+"-"+gn[n>>16&255]+gn[n>>24&255]+gn[255&r]+gn[r>>8&255]+gn[r>>16&255]+gn[r>>24&255]).toUpperCase()},clamp:function(t,e,n){return Math.max(e,Math.min(n,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)},lerp:function(t,e,n){return(1-n)*t+n*e},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*xn.DEG2RAD},radToDeg:function(t){return t*xn.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 bn(t,e){this.x=t||0,this.y=e||0}function wn(t,e,n,r){this._x=t||0,this._y=e||0,this._z=n||0,this._w=void 0!==r?r:1}Object.defineProperties(bn.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(bn.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},applyMatrix3:function(t){var e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this},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},cross:function(t){return this.x*t.y-this.y*t.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,n=this.y-t.y;return e*e+n*n},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var n=Math.cos(e),r=Math.sin(e),i=this.x-t.x,a=this.y-t.y;return this.x=i*n-a*r+t.x,this.y=i*r+a*n+t.y,this}}),Object.assign(wn,{slerp:function(t,e,n,r){return n.copy(t).slerp(e,r)},slerpFlat:function(t,e,n,r,i,a,o){var s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],h=i[a+0],d=i[a+1],p=i[a+2],f=i[a+3];if(u!==f||s!==h||c!==d||l!==p){var m=1-o,v=s*h+c*d+l*p+u*f,g=v>=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var x=Math.sqrt(y),b=Math.atan2(x,v*g);m=Math.sin(m*b)/x,o=Math.sin(o*b)/x}var w=o*g;if(s=s*m+h*w,c=c*m+d*w,l=l*m+p*w,u=u*m+f*w,m===1-o){var _=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=_,c*=_,l*=_,u*=_}}t[e]=s,t[e+1]=c,t[e+2]=l,t[e+3]=u}}),Object.defineProperties(wn.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(wn.prototype,{isQuaternion:!0,set:function(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=t._x,r=t._y,i=t._z,a=t.order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),h=s(n/2),d=s(r/2),p=s(i/2);return"XYZ"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u-h*d*p):"YXZ"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u+h*d*p):"ZXY"===a?(this._x=h*l*u-c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u-h*d*p):"ZYX"===a?(this._x=h*l*u-c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u+h*d*p):"YZX"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u-h*d*p):"XZY"===a&&(this._x=h*l*u-c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u+h*d*p),!1!==e&&this._onChangeCallback(),this},setFromAxisAngle:function(t,e){var n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this},setFromRotationMatrix:function(t){var e,n=t.elements,r=n[0],i=n[4],a=n[8],o=n[1],s=n[5],c=n[9],l=n[2],u=n[6],h=n[10],d=r+s+h;return d>0?(e=.5/Math.sqrt(d+1),this._w=.25/e,this._x=(u-c)*e,this._y=(a-l)*e,this._z=(o-i)*e):r>s&&r>h?(e=2*Math.sqrt(1+r-s-h),this._w=(u-c)/e,this._x=.25*e,this._y=(i+o)/e,this._z=(a+l)/e):s>h?(e=2*Math.sqrt(1+s-r-h),this._w=(a-l)/e,this._x=(i+o)/e,this._y=.25*e,this._z=(c+u)/e):(e=2*Math.sqrt(1+h-r-s),this._w=(o-i)/e,this._x=(a+l)/e,this._y=(c+u)/e,this._z=.25*e),this._onChangeCallback(),this},setFromUnitVectors:function(t,e){var n=t.dot(e)+1;return n<1e-6?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()},angleTo:function(t){return 2*Math.acos(Math.abs(xn.clamp(this.dot(t),-1,1)))},rotateTowards:function(t,e){var n=this.angleTo(t);if(0===n)return this;var r=Math.min(1,e/n);return this.slerp(t,r),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var n=t._x,r=t._y,i=t._z,a=t._w,o=e._x,s=e._y,c=e._z,l=e._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var n=this._x,r=this._y,i=this._z,a=this._w,o=a*t._w+n*t._x+r*t._y+i*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;var s=1-o*o;if(s<=Number.EPSILON){var c=1-e;return this._w=c*a+e*this._w,this._x=c*n+e*this._x,this._y=c*r+e*this._y,this._z=c*i+e*this._z,this.normalize(),this._onChangeCallback(),this}var l=Math.sqrt(s),u=Math.atan2(l,o),h=Math.sin((1-e)*u)/l,d=Math.sin(e*u)/l;return this._w=a*h+this._w*d,this._x=n*h+this._x*d,this._y=r*h+this._y*d,this._z=i*h+this._z*d,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(){}});var _n=new Sn,Mn=new wn;function Sn(t,e,n){this.x=t||0,this.y=e||0,this.z=n||0}Object.assign(Sn.prototype,{isVector3:!0,set:function(t,e,n){return this.x=t,this.y=e,this.z=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Mn.setFromEuler(t))},applyAxisAngle:function(t,e){return this.applyQuaternion(Mn.setFromAxisAngle(t,e))},applyMatrix3:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*r,this.y=i[1]*e+i[4]*n+i[7]*r,this.z=i[2]*e+i[5]*n+i[8]*r,this},applyMatrix4:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements,a=1/(i[3]*e+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*e+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*e+i[6]*n+i[10]*r+i[14])*a,this},applyQuaternion:function(t){var e=this.x,n=this.y,r=this.z,i=t.x,a=t.y,o=t.z,s=t.w,c=s*e+a*r-o*n,l=s*n+o*e-i*r,u=s*r+i*n-a*e,h=-i*e-a*n-o*r;return this.x=c*s+h*-i+l*-o-u*-a,this.y=l*s+h*-a+u*-i-c*-o,this.z=u*s+h*-o+c*-a-l*-i,this},project:function(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)},unproject:function(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)},transformDirection:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*r,this.y=i[1]*e+i[5]*n+i[9]*r,this.z=i[2]*e+i[6]*n+i[10]*r,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this},clampLength:function(t,e){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},cross:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)},crossVectors:function(t,e){var n=t.x,r=t.y,i=t.z,a=e.x,o=e.y,s=e.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(t){return _n.copy(this).projectOnVector(t),this.sub(_n)},reflect:function(t){return this.sub(_n.copy(t).multiplyScalar(2*this.dot(t)))},angleTo:function(t){var e=Math.sqrt(this.lengthSq()*t.lengthSq());0===e&&console.error("THREE.Vector3: angleTo() can't handle zero length vectors.");var n=this.dot(t)/e;return Math.acos(xn.clamp(n,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)},setFromSphericalCoords:function(t,e,n){var r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this},setFromCylindrical:function(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)},setFromCylindricalCoords:function(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}});var En,An=new Sn;function Tn(){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.assign(Tn.prototype,{isMatrix3:!0,set:function(t,e,n,r,i,a,o,s,c){var l=this.elements;return l[0]=t,l[1]=r,l[2]=o,l[3]=e,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(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(t){for(var e=0,n=t.count;e2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}},Rn=0;function Pn(t,e,n,r,i,a,o,s,c,l){Object.defineProperty(this,"id",{value:Rn++}),this.uuid=xn.generateUUID(),this.name="",this.image=void 0!==t?t:Pn.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:Pn.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:yt,this.wrapT=void 0!==r?r:yt,this.magFilter=void 0!==i?i:Et,this.minFilter=void 0!==a?a:Lt,this.anisotropy=void 0!==c?c:1,this.format=void 0!==o?o:jt,this.type=void 0!==s?s:Pt,this.offset=new bn(0,0),this.repeat=new bn(1,1),this.center=new bn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Tn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==l?l:Oe,this.version=0,this.onUpdate=null}function Cn(t,e,n,r){this.x=t||0,this.y=e||0,this.z=n||0,this.w=void 0!==r?r:1}function On(t,e,n){this.width=t,this.height=e,this.scissor=new Cn(0,0,t,e),this.scissorTest=!1,this.viewport=new Cn(0,0,t,e),n=n||{},this.texture=new Pn(void 0,void 0,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.image={},this.texture.image.width=t,this.texture.image.height=e,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:Et,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 Dn(t,e,n){On.call(this,t,e,n),this.samples=4}Pn.DEFAULT_IMAGE=void 0,Pn.DEFAULT_MAPPING=lt,Pn.prototype=Object.assign(Object.create(vn.prototype),{constructor:Pn,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(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],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var r=this.image;if(void 0===r.uuid&&(r.uuid=xn.generateUUID()),!e&&void 0===t.images[r.uuid]){var i;if(Array.isArray(r)){i=[];for(var a=0,o=r.length;a1)switch(this.wrapS){case gt:t.x=t.x-Math.floor(t.x);break;case yt:t.x=t.x<0?0:1;break;case xt: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 gt:t.y=t.y-Math.floor(t.y);break;case yt:t.y=t.y<0?0:1;break;case xt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}}),Object.defineProperty(Pn.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.defineProperties(Cn.prototype,{width:{get:function(){return this.z},set:function(t){this.z=t}},height:{get:function(){return this.w},set:function(t){this.w=t}}}),Object.assign(Cn.prototype,{isVector4:!0,set:function(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,n=this.y,r=this.z,i=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*e+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*e+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*e+a[7]*n+a[11]*r+a[15]*i,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,n,r,i,a=t.elements,o=a[0],s=a[4],c=a[8],l=a[1],u=a[5],h=a[9],d=a[2],p=a[6],f=a[10];if(Math.abs(s-l)<.01&&Math.abs(c-d)<.01&&Math.abs(h-p)<.01){if(Math.abs(s+l)<.1&&Math.abs(c+d)<.1&&Math.abs(h+p)<.1&&Math.abs(o+u+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(o+1)/2,v=(u+1)/2,g=(f+1)/2,y=(s+l)/4,x=(c+d)/4,b=(h+p)/4;return m>v&&m>g?m<.01?(n=0,r=.707106781,i=.707106781):(r=y/(n=Math.sqrt(m)),i=x/n):v>g?v<.01?(n=.707106781,r=0,i=.707106781):(n=y/(r=Math.sqrt(v)),i=b/r):g<.01?(n=.707106781,r=.707106781,i=0):(n=x/(i=Math.sqrt(g)),r=b/i),this.set(n,r,i,e),this}var w=Math.sqrt((p-h)*(p-h)+(c-d)*(c-d)+(l-s)*(l-s));return Math.abs(w)<.001&&(w=1),this.x=(p-h)/w,this.y=(c-d)/w,this.z=(l-s)/w,this.w=Math.acos((o+u+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(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this},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}}),On.prototype=Object.assign(Object.create(vn.prototype),{constructor:On,isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.texture.image.width=t,this.texture.image.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"})}}),Dn.prototype=Object.assign(Object.create(On.prototype),{constructor:Dn,isWebGLMultisampleRenderTarget:!0,copy:function(t){return On.prototype.copy.call(this,t),this.samples=t.samples,this}});var In=new Sn,Nn=new Hn,Bn=new Sn(0,0,0),Fn=new Sn(1,1,1),zn=new Sn,Un=new Sn,Gn=new Sn;function Hn(){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.")}Object.assign(Hn.prototype,{isMatrix4:!0,set:function(t,e,n,r,i,a,o,s,c,l,u,h,d,p,f,m){var v=this.elements;return v[0]=t,v[4]=e,v[8]=n,v[12]=r,v[1]=i,v[5]=a,v[9]=o,v[13]=s,v[2]=c,v[6]=l,v[10]=u,v[14]=h,v[3]=d,v[7]=p,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 Hn).fromArray(this.elements)},copy:function(t){var e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this},copyPosition:function(t){var e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this},extractBasis:function(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this},extractRotation:function(t){var e=this.elements,n=t.elements,r=1/In.setFromMatrixColumn(t,0).length(),i=1/In.setFromMatrixColumn(t,1).length(),a=1/In.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*i,e[5]=n[5]*i,e[6]=n[6]*i,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,n=t.x,r=t.y,i=t.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){var h=a*l,d=a*u,p=o*l,f=o*u;e[0]=s*l,e[4]=-s*u,e[8]=c,e[1]=d+p*c,e[5]=h-f*c,e[9]=-o*s,e[2]=f-h*c,e[6]=p+d*c,e[10]=a*s}else if("YXZ"===t.order){var m=s*l,v=s*u,g=c*l,y=c*u;e[0]=m+y*o,e[4]=g*o-v,e[8]=a*c,e[1]=a*u,e[5]=a*l,e[9]=-o,e[2]=v*o-g,e[6]=y+m*o,e[10]=a*s}else if("ZXY"===t.order){m=s*l,v=s*u,g=c*l,y=c*u;e[0]=m-y*o,e[4]=-a*u,e[8]=g+v*o,e[1]=v+g*o,e[5]=a*l,e[9]=y-m*o,e[2]=-a*c,e[6]=o,e[10]=a*s}else if("ZYX"===t.order){h=a*l,d=a*u,p=o*l,f=o*u;e[0]=s*l,e[4]=p*c-d,e[8]=h*c+f,e[1]=s*u,e[5]=f*c+h,e[9]=d*c-p,e[2]=-c,e[6]=o*s,e[10]=a*s}else if("YZX"===t.order){var x=a*s,b=a*c,w=o*s,_=o*c;e[0]=s*l,e[4]=_-x*u,e[8]=w*u+b,e[1]=u,e[5]=a*l,e[9]=-o*l,e[2]=-c*l,e[6]=b*u+w,e[10]=x-_*u}else if("XZY"===t.order){x=a*s,b=a*c,w=o*s,_=o*c;e[0]=s*l,e[4]=-u,e[8]=c*l,e[1]=x*u+_,e[5]=a*l,e[9]=b*u-w,e[2]=w*u-b,e[6]=o*l,e[10]=_*u+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){return this.compose(Bn,t,Fn)},lookAt:function(t,e,n){var r=this.elements;return Gn.subVectors(t,e),0===Gn.lengthSq()&&(Gn.z=1),Gn.normalize(),zn.crossVectors(n,Gn),0===zn.lengthSq()&&(1===Math.abs(n.z)?Gn.x+=1e-4:Gn.z+=1e-4,Gn.normalize(),zn.crossVectors(n,Gn)),zn.normalize(),Un.crossVectors(Gn,zn),r[0]=zn.x,r[4]=Un.x,r[8]=Gn.x,r[1]=zn.y,r[5]=Un.y,r[9]=Gn.y,r[2]=zn.z,r[6]=Un.z,r[10]=Gn.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var n=t.elements,r=e.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],v=n[14],g=n[3],y=n[7],x=n[11],b=n[15],w=r[0],_=r[4],M=r[8],S=r[12],E=r[1],A=r[5],T=r[9],L=r[13],R=r[2],P=r[6],C=r[10],O=r[14],D=r[3],I=r[7],N=r[11],B=r[15];return i[0]=a*w+o*E+s*R+c*D,i[4]=a*_+o*A+s*P+c*I,i[8]=a*M+o*T+s*C+c*N,i[12]=a*S+o*L+s*O+c*B,i[1]=l*w+u*E+h*R+d*D,i[5]=l*_+u*A+h*P+d*I,i[9]=l*M+u*T+h*C+d*N,i[13]=l*S+u*L+h*O+d*B,i[2]=p*w+f*E+m*R+v*D,i[6]=p*_+f*A+m*P+v*I,i[10]=p*M+f*T+m*C+v*N,i[14]=p*S+f*L+m*O+v*B,i[3]=g*w+y*E+x*R+b*D,i[7]=g*_+y*A+x*P+b*I,i[11]=g*M+y*T+x*C+b*N,i[15]=g*S+y*L+x*O+b*B,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(t){for(var e=0,n=t.count;e1){for(var e=0;e1){for(var e=0;e0){r.children=[];for(s=0;s0&&(n.geometries=h),d.length>0&&(n.materials=d),p.length>0&&(n.textures=p),f.length>0&&(n.images=f),o.length>0&&(n.shapes=o)}return n.object=r,n;function m(t){var e=[];for(var n in t){var r=t[n];delete r.metadata,e.push(r)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var n=0;ns)return!1}return!0}Object.assign(xr.prototype,{isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,c=t.length;si&&(i=l),u>a&&(a=u),h>o&&(o=h)}return this.min.set(e,n,r),this.max.set(i,a,o),this},setFromBufferAttribute:function(t){for(var e=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,c=t.count;si&&(i=l),u>a&&(a=u),h>o&&(o=h)}return this.min.set(e,n,r),this.max.set(i,a,o),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,n=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new Sn),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:function(t){return this.clampPoint(t.center,cr),cr.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(t){if(this.isEmpty())return!1;this.getCenter(mr),vr.subVectors(this.max,mr),lr.subVectors(t.a,mr),ur.subVectors(t.b,mr),hr.subVectors(t.c,mr),dr.subVectors(ur,lr),pr.subVectors(hr,ur),fr.subVectors(lr,hr);var e=[0,-dr.z,dr.y,0,-pr.z,pr.y,0,-fr.z,fr.y,dr.z,0,-dr.x,pr.z,0,-pr.x,fr.z,0,-fr.x,-dr.y,dr.x,0,-pr.y,pr.x,0,-fr.y,fr.x,0];return!!br(e,lr,ur,hr,vr)&&(!!br(e=[1,0,0,0,1,0,0,0,1],lr,ur,hr,vr)&&(gr.crossVectors(dr,pr),br(e=[gr.x,gr.y,gr.z],lr,ur,hr,vr)))},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new Sn),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return cr.copy(t).clamp(this.min,this.max).sub(t).length()},getBoundingSphere:function(t){return void 0===t&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=.5*this.getSize(cr).length(),t},intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(t){return this.isEmpty()?this:(sr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),sr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),sr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),sr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),sr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),sr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),sr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),sr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(sr),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)}});var wr=new xr;function _r(t,e){this.center=void 0!==t?t:new Sn,this.radius=void 0!==e?e:0}Object.assign(_r.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(t,e){var n=this.center;void 0!==e?n.copy(e):wr.setFromPoints(t).getCenter(n);for(var r=0,i=0,a=t.length;ithis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e},getBoundingBox:function(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new xr),t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}});var Mr=new Sn,Sr=new Sn,Er=new Sn,Ar=new Sn,Tr=new Sn,Lr=new Sn,Rr=new Sn;function Pr(t,e){this.origin=void 0!==t?t:new Sn,this.direction=void 0!==e?e:new Sn}Object.assign(Pr.prototype,{set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return void 0===e&&(console.warn("THREE.Ray: .at() target is now required"),e=new Sn),e.copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(t){return this.origin.copy(this.at(t,Mr)),this},closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new Sn),e.subVectors(t,this.origin);var n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(t){var e=Mr.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Mr.copy(this.direction).multiplyScalar(e).add(this.origin),Mr.distanceToSquared(t))},distanceSqToSegment:function(t,e,n,r){Sr.copy(t).add(e).multiplyScalar(.5),Er.copy(e).sub(t).normalize(),Ar.copy(this.origin).sub(Sr);var i,a,o,s,c=.5*t.distanceTo(e),l=-this.direction.dot(Er),u=Ar.dot(this.direction),h=-Ar.dot(Er),d=Ar.lengthSq(),p=Math.abs(1-l*l);if(p>0)if(a=l*u-h,s=c*p,(i=l*h-u)>=0)if(a>=-s)if(a<=s){var f=1/p;o=(i*=f)*(i+l*(a*=f)+2*u)+a*(l*i+a+2*h)+d}else a=c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;else a=-c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;else a<=-s?o=-(i=Math.max(0,-(-l*c+u)))*i+(a=i>0?-c:Math.min(Math.max(-c,-h),c))*(a+2*h)+d:a<=s?(i=0,o=(a=Math.min(Math.max(-c,-h),c))*(a+2*h)+d):o=-(i=Math.max(0,-(l*c+u)))*i+(a=i>0?c:Math.min(Math.max(-c,-h),c))*(a+2*h)+d;else a=l>0?-c:c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;return n&&n.copy(this.direction).multiplyScalar(i).add(this.origin),r&&r.copy(Er).multiplyScalar(a).add(Sr),o},intersectSphere:function(t,e){Mr.subVectors(t.center,this.origin);var n=Mr.dot(this.direction),r=Mr.dot(Mr)-n*n,i=t.radius*t.radius;if(r>i)return null;var a=Math.sqrt(i-r),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,e):this.at(o,e)},intersectsSphere:function(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null},intersectPlane:function(t,e){var n=this.distanceToPlane(t);return null===n?null:this.at(n,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,h=this.origin;return c>=0?(n=(t.min.x-h.x)*c,r=(t.max.x-h.x)*c):(n=(t.max.x-h.x)*c,r=(t.min.x-h.x)*c),l>=0?(i=(t.min.y-h.y)*l,a=(t.max.y-h.y)*l):(i=(t.max.y-h.y)*l,a=(t.min.y-h.y)*l),n>a||i>r?null:((i>n||n!=n)&&(n=i),(a=0?(o=(t.min.z-h.z)*u,s=(t.max.z-h.z)*u):(o=(t.max.z-h.z)*u,s=(t.min.z-h.z)*u),n>s||o>r?null:((o>n||n!=n)&&(n=o),(s=0?n:r,e)))},intersectsBox:function(t){return null!==this.intersectBox(t,Mr)},intersectTriangle:function(t,e,n,r,i){Tr.subVectors(e,t),Lr.subVectors(n,t),Rr.crossVectors(Tr,Lr);var a,o=this.direction.dot(Rr);if(o>0){if(r)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Ar.subVectors(this.origin,t);var s=a*this.direction.dot(Lr.crossVectors(Ar,Lr));if(s<0)return null;var c=a*this.direction.dot(Tr.cross(Ar));if(c<0)return null;if(s+c>o)return null;var l=-a*Ar.dot(Rr);return l<0?null:this.at(l/o,i)},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)}});var Cr=new Sn,Or=new Sn,Dr=new Tn;function Ir(t,e){this.normal=void 0!==t?t:new Sn(1,0,0),this.constant=void 0!==e?e:0}Object.assign(Ir.prototype,{isPlane:!0,set:function(t,e){return this.normal.copy(t),this.constant=e,this},setComponents:function(t,e,n,r){return this.normal.set(t,e,n),this.constant=r,this},setFromNormalAndCoplanarPoint:function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},setFromCoplanarPoints:function(t,e,n){var r=Cr.subVectors(n,e).cross(Or.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,e){return void 0===e&&(console.warn("THREE.Plane: .projectPoint() target is now required"),e=new Sn),e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)},intersectLine:function(t,e){void 0===e&&(console.warn("THREE.Plane: .intersectLine() target is now required"),e=new Sn);var n=t.delta(Cr),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(t.start)?e.copy(t.start):void 0;var i=-(t.start.dot(this.normal)+this.constant)/r;return i<0||i>1?void 0:e.copy(n).multiplyScalar(i).add(t.start)},intersectsLine:function(t){var e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new Sn),t.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(t,e){var n=e||Dr.getNormalMatrix(t),r=this.coplanarPoint(Cr).applyMatrix4(t),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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}});var Nr=new Sn,Br=new Sn,Fr=new Sn,zr=new Sn,Ur=new Sn,Gr=new Sn,Hr=new Sn,Vr=new Sn,kr=new Sn,jr=new Sn;function Wr(t,e,n){this.a=void 0!==t?t:new Sn,this.b=void 0!==e?e:new Sn,this.c=void 0!==n?n:new Sn}Object.assign(Wr,{getNormal:function(t,e,n,r){void 0===r&&(console.warn("THREE.Triangle: .getNormal() target is now required"),r=new Sn),r.subVectors(n,e),Nr.subVectors(t,e),r.cross(Nr);var i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)},getBarycoord:function(t,e,n,r,i){Nr.subVectors(r,e),Br.subVectors(n,e),Fr.subVectors(t,e);var a=Nr.dot(Nr),o=Nr.dot(Br),s=Nr.dot(Fr),c=Br.dot(Br),l=Br.dot(Fr),u=a*c-o*o;if(void 0===i&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),i=new Sn),0===u)return i.set(-2,-1,-1);var h=1/u,d=(c*s-o*l)*h,p=(a*l-o*s)*h;return i.set(1-d-p,p,d)},containsPoint:function(t,e,n,r){return Wr.getBarycoord(t,e,n,r,zr),zr.x>=0&&zr.y>=0&&zr.x+zr.y<=1},getUV:function(t,e,n,r,i,a,o,s){return this.getBarycoord(t,e,n,r,zr),s.set(0,0),s.addScaledVector(i,zr.x),s.addScaledVector(a,zr.y),s.addScaledVector(o,zr.z),s},isFrontFacing:function(t,e,n,r){return Nr.subVectors(n,e),Br.subVectors(t,e),Nr.cross(Br).dot(r)<0}}),Object.assign(Wr.prototype,{set:function(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this},setFromPointsAndIndices:function(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},getArea:function(){return Nr.subVectors(this.c,this.b),Br.subVectors(this.a,this.b),.5*Nr.cross(Br).length()},getMidpoint:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new Sn),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(t){return Wr.getNormal(this.a,this.b,this.c,t)},getPlane:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new Ir),t.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(t,e){return Wr.getBarycoord(t,this.a,this.b,this.c,e)},getUV:function(t,e,n,r,i){return Wr.getUV(t,this.a,this.b,this.c,e,n,r,i)},containsPoint:function(t){return Wr.containsPoint(t,this.a,this.b,this.c)},isFrontFacing:function(t){return Wr.isFrontFacing(this.a,this.b,this.c,t)},intersectsBox:function(t){return t.intersectsTriangle(this)},closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),e=new Sn);var n,r,i=this.a,a=this.b,o=this.c;Ur.subVectors(a,i),Gr.subVectors(o,i),Vr.subVectors(t,i);var s=Ur.dot(Vr),c=Gr.dot(Vr);if(s<=0&&c<=0)return e.copy(i);kr.subVectors(t,a);var l=Ur.dot(kr),u=Gr.dot(kr);if(l>=0&&u<=l)return e.copy(a);var h=s*u-l*c;if(h<=0&&s>=0&&l<=0)return n=s/(s-l),e.copy(i).addScaledVector(Ur,n);jr.subVectors(t,o);var d=Ur.dot(jr),p=Gr.dot(jr);if(p>=0&&d<=p)return e.copy(o);var f=d*c-s*p;if(f<=0&&c>=0&&p<=0)return r=c/(c-p),e.copy(i).addScaledVector(Gr,r);var m=l*p-d*u;if(m<=0&&u-l>=0&&d-p>=0)return Hr.subVectors(o,a),r=(u-l)/(u-l+(d-p)),e.copy(a).addScaledVector(Hr,r);var v=1/(m+f+h);return n=f*v,r=h*v,e.copy(i).addScaledVector(Ur,n).addScaledVector(Gr,r)},equals:function(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}});var qr={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},Xr={h:0,s:0,l:0},Yr={h:0,s:0,l:0};function Zr(t,e,n){return void 0===e&&void 0===n?this.set(t):this.setRGB(t,e,n)}function Jr(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}function Qr(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Kr(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}function $r(t,e,n,r,i,a){this.a=t,this.b=e,this.c=n,this.normal=r&&r.isVector3?r:new Sn,this.vertexNormals=Array.isArray(r)?r:[],this.color=i&&i.isColor?i:new Zr,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=void 0!==a?a:0}Object.assign(Zr.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(t,e,n){if(t=xn.euclideanModulo(t,1),e=xn.clamp(e,0,1),n=xn.clamp(n,0,1),0===e)this.r=this.g=this.b=n;else{var r=n<=.5?n*(1+e):n+e-n*e,i=2*n-r;this.r=Jr(i,r,t+1/3),this.g=Jr(i,r,t),this.b=Jr(i,r,t-1/3)}return this},setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var n;if(n=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var r,i=n[1],a=n[2];switch(i){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,e(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,e(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return e(r[5]),this.setHSL(o,s,c)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(t)){var l=n[1],u=l.length;if(3===u)return this.r=parseInt(l.charAt(0)+l.charAt(0),16)/255,this.g=parseInt(l.charAt(1)+l.charAt(1),16)/255,this.b=parseInt(l.charAt(2)+l.charAt(2),16)/255,this;if(6===u)return this.r=parseInt(l.charAt(0)+l.charAt(1),16)/255,this.g=parseInt(l.charAt(2)+l.charAt(3),16)/255,this.b=parseInt(l.charAt(4)+l.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this},setColorName:function(t){var e=qr[t];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),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(t){return this.copyGammaToLinear(this,t),this},convertLinearToGamma:function(t){return this.copyLinearToGamma(this,t),this},copySRGBToLinear:function(t){return this.r=Qr(t.r),this.g=Qr(t.g),this.b=Qr(t.b),this},copyLinearToSRGB:function(t){return this.r=Kr(t.r),this.g=Kr(t.g),this.b=Kr(t.b),this},convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});var e,n,r=this.r,i=this.g,a=this.b,o=Math.max(r,i,a),s=Math.min(r,i,a),c=(s+o)/2;if(s===o)e=0,n=0;else{var l=o-s;switch(n=c<=.5?l/(o+s):l/(2-o-s),o){case r:e=(i-a)/l+(ie&&(e=t[n]);return e}ei.prototype=Object.assign(Object.create(vn.prototype),{constructor:ei,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 r=this[e];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=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===x;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 r(t){var e=[];for(var n in t){var r=t[n];delete r.metadata,e.push(r)}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.sheen&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&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.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.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.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),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.normalMapType=this.normalMapType,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,n.refractionRatio=this.refractionRatio,void 0!==this.combine&&(n.combine=this.combine),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity)),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!==E&&(n.blending=this.blending),!0===this.flatShading&&(n.flatShading=this.flatShading),this.side!==v&&(n.side=this.side),this.vertexColors!==w&&(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,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&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.morphNormals&&(n.morphNormals=!0),!0===this.skinning&&(n.skinning=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),e){var i=r(t.textures),a=r(t.images);i.length>0&&(n.textures=i),a.length>0&&(n.images=a)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexTangents=t.vertexTangents,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.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;var e=t.clippingPlanes,n=null;if(null!==e){var r=e.length;n=new Array(r);for(var i=0;i!==r;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,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.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),ni.prototype=Object.create(ei.prototype),ni.prototype.constructor=ni,ni.prototype.isMeshBasicMaterial=!0,ni.prototype.copy=function(t){return ei.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},Object.defineProperty(ri.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(ri.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.itemSize,n*=e.itemSize;for(var r=0,i=this.itemSize;r0,o=i[1]&&i[1].length>0,s=t.morphTargets,c=s.length;if(c>0){e=[];for(var l=0;l0){u=[];for(l=0;l0&&0===n.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(l=0;l65535?ui:ci)(t,1):this.index=t},getAttribute:function(t){return this.attributes[t]},setAttribute:function(t,e){return this.attributes[t]=e,this},deleteAttribute: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 Tn).getNormalMatrix(t).applyToBufferAttribute(n),n.needsUpdate=!0);var r=this.attributes.tangent;void 0!==r&&((new Tn).getNormalMatrix(t).applyToBufferAttribute(r),r.needsUpdate=!0);return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(t){return vi.makeRotationX(t),this.applyMatrix(vi),this},rotateY:function(t){return vi.makeRotationY(t),this.applyMatrix(vi),this},rotateZ:function(t){return vi.makeRotationZ(t),this.applyMatrix(vi),this},translate:function(t,e,n){return vi.makeTranslation(t,e,n),this.applyMatrix(vi),this},scale:function(t,e,n){return vi.makeScale(t,e,n),this.applyMatrix(vi),this},lookAt:function(t){return gi.lookAt(t),gi.updateMatrix(),this.applyMatrix(gi.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(yi).negate(),this.translate(yi.x,yi.y,yi.z),this},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var n=new hi(3*e.vertices.length,3),r=new hi(3*e.colors.length,3);if(this.setAttribute("position",n.copyVector3sArray(e.vertices)),this.setAttribute("color",r.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var i=new hi(e.lineDistances.length,1);this.setAttribute("lineDistance",i.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},setFromPoints:function(t){for(var e=[],n=0,r=t.length;n0){var n=new Float32Array(3*t.normals.length);this.setAttribute("normal",new ri(n,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var r=new Float32Array(3*t.colors.length);this.setAttribute("color",new ri(r,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.setAttribute("uv",new ri(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var a=new Float32Array(2*t.uvs2.length);this.setAttribute("uv2",new ri(a,2).copyVector2sArray(t.uvs2))}for(var o in this.groups=t.groups,t.morphTargets){for(var s=[],c=t.morphTargets[o],l=0,u=c.length;l0){var p=new hi(4*t.skinIndices.length,4);this.setAttribute("skinIndex",p.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var f=new hi(4*t.skinWeights.length,4);this.setAttribute("skinWeight",f.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new xr);var t=this.attributes.position,e=this.morphAttributes.position;if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(var n=0,r=e.length;n0&&(t.userData=this.userData),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 r=this.index;null!==r&&(t.data.index={type:r.array.constructor.name,array:Array.prototype.slice.call(r.array)});var i=this.attributes;for(var n in i){var a=(d=i[n]).toJSON();""!==d.name&&(a.name=d.name),t.data.attributes[n]=a}var o={},s=!1;for(var n in this.morphAttributes){for(var c=this.morphAttributes[n],l=[],u=0,h=c.length;u0&&(o[n]=l,s=!0)}s&&(t.data.morphAttributes=o);var p=this.groups;p.length>0&&(t.data.groups=JSON.parse(JSON.stringify(p)));var f=this.boundingSphere;return null!==f&&(t.data.boundingSphere={center:f.center.toArray(),radius:f.radius}),t},clone:function(){return(new _i).copy(this)},copy:function(t){var e,n,r;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var i=t.index;null!==i&&this.setIndex(i.clone());var a=t.attributes;for(e in a){var o=a[e];this.setAttribute(e,o.clone())}var s=t.morphAttributes;for(e in s){var c=[],l=s[e];for(n=0,r=l.length;nn.far?null:{distance:c,point:Ui.clone(),object:t}}function Vi(t,e,n,r,i,a,o,s,c,l,u){Ai.fromBufferAttribute(i,c),Ti.fromBufferAttribute(i,l),Li.fromBufferAttribute(i,u);var h=t.morphTargetInfluences;if(e.morphTargets&&a&&h){Oi.set(0,0,0),Di.set(0,0,0),Ii.set(0,0,0);for(var d=0,p=a.length;d0){var o=i[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=o.length;t0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(t,e){var n,r=this.geometry,i=this.material,a=this.matrixWorld;if(void 0!==i&&(null===r.boundingSphere&&r.computeBoundingSphere(),Ei.copy(r.boundingSphere),Ei.applyMatrix4(a),!1!==t.ray.intersectsSphere(Ei)&&(Mi.getInverse(a),Si.copy(t.ray).applyMatrix4(Mi),null===r.boundingBox||!1!==Si.intersectsBox(r.boundingBox))))if(this.drawMode===Re){if(r.isBufferGeometry){var o,s,c,l,u,h,d,p,f,m=r.index,v=r.attributes.position,g=r.morphAttributes.position,y=r.attributes.uv,x=r.attributes.uv2,b=r.groups,w=r.drawRange;if(null!==m)if(Array.isArray(i))for(l=0,h=b.length;l0&&(E=R);for(var P=0,C=L.length;P0)for(l=0;l0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,n;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,n,r,i;for(n=0,r=this.faces.length;n=0;n--){var f=d[n];for(this.faces.splice(f,1),o=0,s=this.faceVertexUvs.length;o0,v=p.vertexNormals.length>0,g=1!==p.color.r||1!==p.color.g||1!==p.color.b,y=p.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),o.push(x),o.push(p.a,p.b,p.c),o.push(p.materialIndex),f){var b=this.faceVertexUvs[0][i];o.push(A(b[0]),A(b[1]),A(b[2]))}if(m&&o.push(S(p.normal)),v){var w=p.vertexNormals;o.push(S(w[0]),S(w[1]),S(w[2]))}if(g&&o.push(E(p.color)),y){var _=p.vertexColors;o.push(E(_[0]),E(_[1]),E(_[2]))}}function M(t,e,n){return n?t|1<0&&(t.data.colors=l),h.length>0&&(t.data.uvs=[h]),t.data.faces=o,t},clone:function(){return(new Xi).copy(this)},copy:function(t){var e,n,r,i,a,o;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var s=t.vertices;for(e=0,n=s.length;e0?1:-1,l.push(R.x,R.y,R.z),u.push(y/m),u.push(1-x/v),T+=1}}for(x=0;x0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;var i={};for(var a in this.extensions)!0===this.extensions[a]&&(i[a]=!0);return Object.keys(i).length>0&&(e.extensions=i),e},na.prototype=Object.assign(Object.create(ar.prototype),{constructor:na,isCamera:!0,copy:function(t,e){return ar.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new Sn),this.updateMatrixWorld(!0);var e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()},updateMatrixWorld:function(t){ar.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),ra.prototype=Object.assign(Object.create(na.prototype),{constructor:ra,isPerspectiveCamera:!0,copy:function(t,e){return na.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*xn.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){var t=Math.tan(.5*xn.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*xn.RAD2DEG*Math.atan(Math.tan(.5*xn.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,r,i,a){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=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=this.near,e=t*Math.tan(.5*xn.DEG2RAD*this.fov)/this.zoom,n=2*e,r=this.aspect*n,i=-.5*r,a=this.view;if(null!==this.view&&this.view.enabled){var o=a.fullWidth,s=a.fullHeight;i+=a.offsetX*r/o,e-=a.offsetY*n/s,r*=a.width/o,n*=a.height/s}var c=this.filmOffset;0!==c&&(i+=t*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,e,e-n,t,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(t){var e=ar.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}});var ia=90,aa=1;function oa(t,e,n,r){ar.call(this),this.type="CubeCamera";var i=new ra(ia,aa,t,e);i.up.set(0,-1,0),i.lookAt(new Sn(1,0,0)),this.add(i);var a=new ra(ia,aa,t,e);a.up.set(0,-1,0),a.lookAt(new Sn(-1,0,0)),this.add(a);var o=new ra(ia,aa,t,e);o.up.set(0,0,1),o.lookAt(new Sn(0,1,0)),this.add(o);var s=new ra(ia,aa,t,e);s.up.set(0,0,-1),s.lookAt(new Sn(0,-1,0)),this.add(s);var c=new ra(ia,aa,t,e);c.up.set(0,-1,0),c.lookAt(new Sn(0,0,1)),this.add(c);var l=new ra(ia,aa,t,e);l.up.set(0,-1,0),l.lookAt(new Sn(0,0,-1)),this.add(l),r=r||{format:kt,magFilter:Et,minFilter:Et},this.renderTarget=new sa(n,n,r),this.renderTarget.texture.name="CubeCamera",this.update=function(t,e){null===this.parent&&this.updateMatrixWorld();var n=t.getRenderTarget(),r=this.renderTarget,u=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,t.setRenderTarget(r,0),t.render(e,i),t.setRenderTarget(r,1),t.render(e,a),t.setRenderTarget(r,2),t.render(e,o),t.setRenderTarget(r,3),t.render(e,s),t.setRenderTarget(r,4),t.render(e,c),r.texture.generateMipmaps=u,t.setRenderTarget(r,5),t.render(e,l),t.setRenderTarget(n)},this.clear=function(t,e,n,r){for(var i=t.getRenderTarget(),a=this.renderTarget,o=0;o<6;o++)t.setRenderTarget(a,o),t.clear(e,n,r);t.setRenderTarget(i)}}function sa(t,e,n){On.call(this,t,e,n)}function ca(t,e,n,r,i,a,o,s,c,l,u,h){Pn.call(this,null,a,o,s,c,l,r,i,u,h),this.image={data:t||null,width:e||1,height:n||1},this.magFilter=void 0!==c?c:bt,this.minFilter=void 0!==l?l:bt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}oa.prototype=Object.create(ar.prototype),oa.prototype.constructor=oa,sa.prototype=Object.create(On.prototype),sa.prototype.constructor=sa,sa.prototype.isWebGLRenderTargetCube=!0,sa.prototype.fromEquirectangularTexture=function(t,e){this.texture.type=e.type,this.texture.format=e.format,this.texture.encoding=e.encoding;var n=new or,r={uniforms:{tEquirect:{value:null}},vertexShader:["varying vec3 vWorldDirection;","vec3 transformDirection( in vec3 dir, in mat4 matrix ) {","\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );","}","void main() {","\tvWorldDirection = transformDirection( position, modelMatrix );","\t#include ","\t#include ","}"].join("\n"),fragmentShader:["uniform sampler2D tEquirect;","varying vec3 vWorldDirection;","#define RECIPROCAL_PI 0.31830988618","#define RECIPROCAL_PI2 0.15915494","void main() {","\tvec3 direction = normalize( vWorldDirection );","\tvec2 sampleUV;","\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;","\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;","\tgl_FragColor = texture2D( tEquirect, sampleUV );","}"].join("\n")},i=new ea({type:"CubemapFromEquirect",uniforms:Ji(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:g,blending:S});i.uniforms.tEquirect.value=e;var a=new Gi(new Zi(5,5,5),i);n.add(a);var o=new oa(1,10,1);return o.renderTarget=this,o.renderTarget.texture.name="CubeCameraTexture",o.update(t,n),a.geometry.dispose(),a.material.dispose(),this},ca.prototype=Object.create(Pn.prototype),ca.prototype.constructor=ca,ca.prototype.isDataTexture=!0;var la=new _r,ua=new Sn;function ha(t,e,n,r,i,a){this.planes=[void 0!==t?t:new Ir,void 0!==e?e:new Ir,void 0!==n?n:new Ir,void 0!==r?r:new Ir,void 0!==i?i:new Ir,void 0!==a?a:new Ir]}Object.assign(ha.prototype,{set:function(t,e,n,r,i,a){var o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,n=0;n<6;n++)e[n].copy(t.planes[n]);return this},setFromMatrix:function(t){var e=this.planes,n=t.elements,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7],h=n[8],d=n[9],p=n[10],f=n[11],m=n[12],v=n[13],g=n[14],y=n[15];return e[0].setComponents(o-r,u-s,f-h,y-m).normalize(),e[1].setComponents(o+r,u+s,f+h,y+m).normalize(),e[2].setComponents(o+i,u+c,f+d,y+v).normalize(),e[3].setComponents(o-i,u-c,f-d,y-v).normalize(),e[4].setComponents(o-a,u-l,f-p,y-g).normalize(),e[5].setComponents(o+a,u+l,f+p,y+g).normalize(),this},intersectsObject:function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),la.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(la)},intersectsSprite:function(t){return la.center.set(0,0,0),la.radius=.7071067811865476,la.applyMatrix4(t.matrixWorld),this.intersectsSphere(la)},intersectsSphere:function(t){for(var e=this.planes,n=t.center,r=-t.radius,i=0;i<6;i++){if(e[i].distanceToPoint(n)0?t.max.x:t.min.x,ua.y=r.normal.y>0?t.max.y:t.min.y,ua.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(ua)<0)return!1}return!0},containsPoint:function(t){for(var e=this.planes,n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}});var da={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",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",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",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#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\ttransformedNormal = mat3( instanceMatrix ) * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = normalMatrix * objectTangent;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_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",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, roughness );\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",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) { \n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",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",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",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif",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 = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\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\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\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",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",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)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = saturate( clearcoat );\tmaterial.clearcoatRoughness = clamp( clearcoatRoughness, 0.04, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 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#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? 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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? 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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? 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 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",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",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",normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, normalScale, normalMap );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec2 normalScale, in sampler2D normalMap ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy *= normalScale;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tbool frontFacing = dot( cross( S, T ), N ) > 0.0;\n\t\t\tmapN.xy *= ( float( frontFacing ) * 2.0 - 1.0 );\n\t\t#else\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, clearcoatNormal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = clearcoatNormalScale * mapN.xy;\n\t\tclearcoatNormal = normalize( vTBN * mapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatNormalScale, clearcoatNormalMap );\n\t#endif\n#endif",clearcoat_normalmap_pars_fragment:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 encodeHalfRGBA ( vec2 v ) {\n\tvec4 encoded = vec4( 0.0 );\n\tconst vec2 offset = vec2( 1.0 / 255.0, 0.0 );\n\tencoded.xy = vec2( v.x, fract( v.x * 255.0 ) );\n\tencoded.xy = encoded.xy - ( encoded.yy * offset );\n\tencoded.zw = vec2( v.y, fract( v.y * 255.0 ) );\n\tencoded.zw = encoded.zw - ( encoded.ww * offset );\n\treturn encoded;\n}\nvec2 decodeHalfRGBA( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn decodeHalfRGBA( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat 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 ) + 0.5 ) * texelSize;\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\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat 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#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? 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}",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 highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",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",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",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\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\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 = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}",shadow_vert:"#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"},pa={common:{diffuse:{value:new Zr(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Tn},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},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 bn(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 Zr(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{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 Zr(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Tn}},sprite:{diffuse:{value:new Zr(15658734)},opacity:{value:1},center:{value:new bn(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Tn}}},fa={basic:{uniforms:Qi([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.fog]),vertexShader:da.meshbasic_vert,fragmentShader:da.meshbasic_frag},lambert:{uniforms:Qi([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.fog,pa.lights,{emissive:{value:new Zr(0)}}]),vertexShader:da.meshlambert_vert,fragmentShader:da.meshlambert_frag},phong:{uniforms:Qi([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.gradientmap,pa.fog,pa.lights,{emissive:{value:new Zr(0)},specular:{value:new Zr(1118481)},shininess:{value:30}}]),vertexShader:da.meshphong_vert,fragmentShader:da.meshphong_frag},standard:{uniforms:Qi([pa.common,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.roughnessmap,pa.metalnessmap,pa.fog,pa.lights,{emissive:{value:new Zr(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:da.meshphysical_vert,fragmentShader:da.meshphysical_frag},matcap:{uniforms:Qi([pa.common,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.fog,{matcap:{value:null}}]),vertexShader:da.meshmatcap_vert,fragmentShader:da.meshmatcap_frag},points:{uniforms:Qi([pa.points,pa.fog]),vertexShader:da.points_vert,fragmentShader:da.points_frag},dashed:{uniforms:Qi([pa.common,pa.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:da.linedashed_vert,fragmentShader:da.linedashed_frag},depth:{uniforms:Qi([pa.common,pa.displacementmap]),vertexShader:da.depth_vert,fragmentShader:da.depth_frag},normal:{uniforms:Qi([pa.common,pa.bumpmap,pa.normalmap,pa.displacementmap,{opacity:{value:1}}]),vertexShader:da.normal_vert,fragmentShader:da.normal_frag},sprite:{uniforms:Qi([pa.sprite,pa.fog]),vertexShader:da.sprite_vert,fragmentShader:da.sprite_frag},background:{uniforms:{uvTransform:{value:new Tn},t2D:{value:null}},vertexShader:da.background_vert,fragmentShader:da.background_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:da.cube_vert,fragmentShader:da.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:da.equirect_vert,fragmentShader:da.equirect_frag},distanceRGBA:{uniforms:Qi([pa.common,pa.displacementmap,{referencePosition:{value:new Sn},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:da.distanceRGBA_vert,fragmentShader:da.distanceRGBA_frag},shadow:{uniforms:Qi([pa.lights,pa.fog,{color:{value:new Zr(0)},opacity:{value:1}}]),vertexShader:da.shadow_vert,fragmentShader:da.shadow_frag}};function ma(){var t=null,e=!1,n=null;function r(i,a){!1!==e&&(n(i,a),t.requestAnimationFrame(r))}return{start:function(){!0!==e&&null!==n&&(t.requestAnimationFrame(r),e=!0)},stop:function(){e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function va(t){var e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);var r=e.get(n);r&&(t.deleteBuffer(r.buffer),e.delete(n))},update:function(n,r){n.isInterleavedBufferAttribute&&(n=n.data);var i=e.get(n);void 0===i?e.set(n,function(e,n){var r=e.array,i=e.usage,a=t.createBuffer();t.bindBuffer(n,a),t.bufferData(n,r,i),e.onUploadCallback();var o=5126;return r instanceof Float32Array?o=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?o=5123:r instanceof Int16Array?o=5122:r instanceof Uint32Array?o=5125:r instanceof Int32Array?o=5124:r instanceof Int8Array?o=5120:r instanceof Uint8Array&&(o=5121),{buffer:a,type:o,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version}}(n,r)):i.version0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}var a="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext,o=void 0!==n.precision?n.precision:"highp",s=i(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);var c=!0===n.logarithmicDepthBuffer,l=t.getParameter(34930),u=t.getParameter(35660),h=t.getParameter(3379),d=t.getParameter(34076),p=t.getParameter(34921),f=t.getParameter(36347),m=t.getParameter(36348),v=t.getParameter(36349),g=u>0,y=a||!!e.get("OES_texture_float");return{isWebGL2:a,getMaxAnisotropy:function(){if(void 0!==r)return r;var n=e.get("EXT_texture_filter_anisotropic");return r=null!==n?t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:c,maxTextures:l,maxVertexTextures:u,maxTextureSize:h,maxCubemapSize:d,maxAttributes:p,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:v,vertexTextures:g,floatFragmentTextures:y,floatVertexTextures:g&&y,maxSamples:a?t.getParameter(36183):0}}function _a(){var t=this,e=null,n=0,r=!1,i=!1,a=new Ir,o=new Tn,s={value:null,needsUpdate:!1};function c(){s.value!==e&&(s.value=e,s.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function l(e,n,r,i){var c=null!==e?e.length:0,l=null;if(0!==c){if(l=s.value,!0!==i||null===l){var u=r+4*c,h=n.matrixWorldInverse;o.getNormalMatrix(h),(null===l||l.length65535?ui:ci)(n,1);p.version=o,e.update(p,34963);var f=i.get(t);f&&e.remove(f),i.set(t,p)}return{get:function(t,e){var i=r.get(e);return i||(e.addEventListener("dispose",a),e.isBufferGeometry?i=e:e.isGeometry&&(void 0===e._bufferGeometry&&(e._bufferGeometry=(new _i).setFromObject(t)),i=e._bufferGeometry),r.set(e,i),n.memory.geometries++,i)},update:function(t){var n=t.index,r=t.attributes;for(var i in null!==n&&e.update(n,34963),r)e.update(r[i],34962);var a=t.morphAttributes;for(var i in a)for(var o=a[i],s=0,c=o.length;s0)return t;var i=e*n,a=Fa[i];if(void 0===a&&(a=new Float32Array(i),Fa[i]=a),0!==e){r.toArray(a,0);for(var o=1,s=0;o!==e;++o)s+=n,t[o].toArray(a,s)}return a}function ka(t,e){if(t.length!==e.length)return!1;for(var n=0,r=t.length;n/gm;function zo(t){return t.replace(Fo,Uo)}function Uo(t,e){var n=da[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return zo(n)}var Go=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;function Ho(t){return t.replace(Go,Vo)}function Vo(t,e,n,r){for(var i="",a=parseInt(e);a0?t.gammaFactor:1,M=a.isWebGL2?"":function(t,e,n){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||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(Io).join("\n")}(r.extensions,a,e),S=function(t){var e=[];for(var n in t){var r=t[n];!1!==r&&e.push("#define "+n+" "+r)}return e.join("\n")}(d),E=h.createProgram(),A=a.numMultiviewViews;if(r.isRawShaderMaterial?((o=[S].filter(Io).join("\n")).length>0&&(o+="\n"),(s=[M,S].filter(Io).join("\n")).length>0&&(s+="\n")):(o=[ko(a),"#define SHADER_NAME "+i.name,S,a.instancing?"#define USE_INSTANCING":"",a.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+_,"#define MAX_BONES "+a.maxBones,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp2?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+b:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.normalMap&&a.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",a.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",a.displacementMap&&a.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.vertexTangents?"#define USE_TANGENT":"",a.vertexColors?"#define USE_COLOR":"",a.vertexUvs?"#define USE_UV":"",a.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",a.flatShading?"#define FLAT_SHADED":"",a.skinning?"#define USE_SKINNING":"",a.useVertexTexture?"#define BONE_TEXTURE":"",a.morphTargets?"#define USE_MORPHTARGETS":"",a.morphNormals&&!1===a.flatShading?"#define USE_MORPHNORMALS":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+y:"",a.sizeAttenuation?"#define USE_SIZEATTENUATION":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(a.isWebGL2||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;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Io).join("\n"),s=[M,ko(a),"#define SHADER_NAME "+i.name,S,a.alphaTest?"#define ALPHATEST "+a.alphaTest+(a.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+_,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp2?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.matcap?"#define USE_MATCAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+x:"",a.envMap?"#define "+b:"",a.envMap?"#define "+w:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.normalMap&&a.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",a.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.sheen?"#define USE_SHEEN":"",a.vertexTangents?"#define USE_TANGENT":"",a.vertexColors?"#define USE_COLOR":"",a.vertexUvs?"#define USE_UV":"",a.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",a.gradientMap?"#define USE_GRADIENTMAP":"",a.flatShading?"#define FLAT_SHADED":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+y:"",a.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",a.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(a.isWebGL2||e.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",(r.extensions&&r.extensions.shaderTextureLOD||a.envMap)&&(a.isWebGL2||e.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",a.toneMapping!==rt?"#define TONE_MAPPING":"",a.toneMapping!==rt?da.tonemapping_pars_fragment:"",a.toneMapping!==rt?Do("toneMapping",a.toneMapping):"",a.dithering?"#define DITHERING":"",a.outputEncoding||a.mapEncoding||a.matcapEncoding||a.envMapEncoding||a.emissiveMapEncoding?da.encodings_pars_fragment:"",a.mapEncoding?Oo("mapTexelToLinear",a.mapEncoding):"",a.matcapEncoding?Oo("matcapTexelToLinear",a.matcapEncoding):"",a.envMapEncoding?Oo("envMapTexelToLinear",a.envMapEncoding):"",a.emissiveMapEncoding?Oo("emissiveMapTexelToLinear",a.emissiveMapEncoding):"",a.outputEncoding?(c="linearToOutputTexel",l=a.outputEncoding,u=Po(l),"vec4 "+c+"( vec4 value ) { return LinearTo"+u[0]+u[1]+"; }"):"",a.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(Io).join("\n")),v=Bo(v=No(v=zo(v),a),a),g=Bo(g=No(g=zo(g),a),a),v=Ho(v),g=Ho(g),a.isWebGL2&&!r.isRawShaderMaterial){var T=!1,L=/^\s*#version\s+300\s+es\s*\n/;r.isShaderMaterial&&null!==v.match(L)&&null!==g.match(L)&&(T=!0,v=v.replace(L,""),g=g.replace(L,"")),o=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+o,s=["#version 300 es\n","#define varying in",T?"":"out highp vec4 pc_fragColor;",T?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+s,A>0&&(o=(o=o.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","layout(num_views = "+A+") in;","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join("\n"),["uniform mat4 modelViewMatrices["+A+"];","uniform mat4 projectionMatrices["+A+"];","uniform mat4 viewMatrices["+A+"];","uniform mat3 normalMatrices["+A+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join("\n")),s=(s=s.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+A+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join("\n")))}var R,P,C=s+g,O=Lo(h,35633,o+v),D=Lo(h,35632,C);if(h.attachShader(E,O),h.attachShader(E,D),void 0!==r.index0AttributeName?h.bindAttribLocation(E,0,r.index0AttributeName):!0===a.morphTargets&&h.bindAttribLocation(E,0,"position"),h.linkProgram(E),t.debug.checkShaderErrors){var I=h.getProgramInfoLog(E).trim(),N=h.getShaderInfoLog(O).trim(),B=h.getShaderInfoLog(D).trim(),F=!0,z=!0;if(!1===h.getProgramParameter(E,35714)){F=!1;var U=Co(h,O,"vertex"),G=Co(h,D,"fragment");console.error("THREE.WebGLProgram: shader error: ",h.getError(),"35715",h.getProgramParameter(E,35715),"gl.getProgramInfoLog",I,U,G)}else""!==I?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",I):""!==N&&""!==B||(z=!1);z&&(this.diagnostics={runnable:F,material:r,programLog:I,vertexShader:{log:N,prefix:o},fragmentShader:{log:B,prefix:s}})}return h.deleteShader(O),h.deleteShader(D),this.getUniforms=function(){return void 0===R&&(R=new To(h,E)),R},this.getAttributes=function(){return void 0===P&&(P=function(t,e){for(var n={},r=t.getProgramParameter(e,35721),i=0;i0,maxBones:b,useVertexTexture:o,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:r.directional.length,numPointLights:r.point.length,numSpotLights:r.spot.length,numRectAreaLights:r.rectArea.length,numHemiLights:r.hemi.length,numDirLightShadows:r.directionalShadowMap.length,numPointLightShadows:r.pointShadowMap.length,numSpotLightShadows:r.spotShadowMap.length,numClippingPlanes:f,numClipIntersection:m,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.length>0,shadowMapType:t.shadowMap.type,toneMapping:e.toneMapped?t.toneMapping:rt,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===y,flipSided:e.side===g,depthPacking:void 0!==e.depthPacking&&e.depthPacking}},this.getProgramCacheKey=function(e,n){var r=[];if(n.shaderID?r.push(n.shaderID):(r.push(e.fragmentShader),r.push(e.vertexShader)),void 0!==e.defines)for(var i in e.defines)r.push(i),r.push(e.defines[i]);for(var a=0;a1&&n.sort(Xo),r.length>1&&r.sort(Yo)}}}function Jo(){var t=new WeakMap;function e(n){var r=n.target;r.removeEventListener("dispose",e),t.delete(r)}return{get:function(n,r){var i,a=t.get(n);return void 0===a?(i=new Zo,t.set(n,new WeakMap),t.get(n).set(r,i),n.addEventListener("dispose",e)):void 0===(i=a.get(r))&&(i=new Zo,a.set(r,i)),i},dispose:function(){t=new WeakMap}}}function Qo(){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 Sn,color:new Zr,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new bn};break;case"SpotLight":n={position:new Sn,direction:new Sn,color:new Zr,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new bn};break;case"PointLight":n={position:new Sn,color:new Zr,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new bn,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":n={direction:new Sn,skyColor:new Zr,groundColor:new Zr};break;case"RectAreaLight":n={color:new Zr,position:new Sn,halfWidth:new Sn,halfHeight:new Sn}}return t[e.id]=n,n}}}var Ko=0;function $o(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function ts(){for(var t=new Qo,e={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},n=0;n<9;n++)e.probe.push(new Sn);var r=new Sn,i=new Hn,a=new Hn;return{setup:function(n,o,s){for(var c=0,l=0,u=0,h=0;h<9;h++)e.probe[h].set(0,0,0);var d=0,p=0,f=0,m=0,v=0,g=0,y=0,x=0,b=s.matrixWorldInverse;n.sort($o),h=0;for(var w=n.length;h0:!0===s.isGeometry&&(p=s.morphTargets&&s.morphTargets.length>0));var f=!1;!0===e.isSkinnedMesh&&(!0===n.skinning?f=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e)),c=h(p,f,!0===e.isInstancedMesh)}else c=d;if(t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var v=c.uuid,g=n.uuid,y=l[v];void 0===y&&(y={},l[v]=y);var x=y[g];void 0===x&&(x=c.clone(),y[g]=x),c=x}return c.visible=n.visible,c.wireframe=n.wireframe,c.side=o===m?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],c.clipShadows=n.clipShadows,c.clippingPlanes=n.clippingPlanes,c.clipIntersection=n.clipIntersection,c.wireframeLinewidth=n.wireframeLinewidth,c.linewidth=n.linewidth,!0===r.isPointLight&&!0===c.isMeshDistanceMaterial&&(c.referencePosition.setFromMatrixPosition(r.matrixWorld),c.nearDistance=i,c.farDistance=a),c}function A(n,i,a,o,s){if(!1!==n.visible){if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===m)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);var c=e.update(n),l=n.material;if(Array.isArray(l))for(var u=c.groups,h=0,d=u.length;hn||i.y>n)&&(console.warn("THREE.WebGLShadowMap:",v,"has shadow exceeding max texture size, reducing"),i.x>n&&(a.x=Math.floor(n/y.x),i.x=a.x*y.x,g.mapSize.x=a.x),i.y>n&&(a.y=Math.floor(n/y.y),i.y=a.y*y.y,g.mapSize.y=a.y)),null===g.map&&!g.isPointLightShadow&&this.type===m){var x={minFilter:Et,magFilter:Et,format:jt};g.map=new On(i.x,i.y,x),g.map.texture.name=v.name+".shadowMap",g.mapPass=new On(i.x,i.y,x),g.camera.updateProjectionMatrix()}if(null===g.map){x={minFilter:bt,magFilter:bt,format:jt};g.map=new On(i.x,i.y,x),g.map.texture.name=v.name+".shadowMap",g.camera.updateProjectionMatrix()}t.setRenderTarget(g.map),t.clear();for(var _=g.getViewportCount(),M=0;M<_;M++){var E=g.getViewport(M);o.set(a.x*E.x,a.y*E.y,a.x*E.z,a.y*E.w),d.viewport(o),g.updateMatrices(v,M),r=g.getFrustum(),A(s,c,g.camera,v,this.type)}g.isPointLightShadow||this.type!==m||w(g,c)}else console.warn("THREE.WebGLShadowMap:",v,"has no shadow.")}b.needsUpdate=!1,t.setRenderTarget(l,u,h)}}}function cs(t,e,n){var r=n.isWebGL2;var i=new function(){var e=!1,n=new Cn,r=null,i=new Cn(0,0,0,0);return{setMask:function(n){r===n||e||(t.colorMask(n,n,n,n),r=n)},setLocked:function(t){e=t},setClear:function(e,r,a,o,s){!0===s&&(e*=o,r*=o,a*=o),n.set(e,r,a,o),!1===i.equals(n)&&(t.clearColor(e,r,a,o),i.copy(n))},reset:function(){e=!1,r=null,i.set(-1,0,0,0)}}},a=new function(){var e=!1,n=null,r=null,i=null;return{setTest:function(t){t?xt(2929):bt(2929)},setMask:function(r){n===r||e||(t.depthMask(r),n=r)},setFunc:function(e){if(r!==e){if(e)switch(e){case q:t.depthFunc(512);break;case X:t.depthFunc(519);break;case Y:t.depthFunc(513);break;case Z:t.depthFunc(515);break;case J:t.depthFunc(514);break;case Q:t.depthFunc(518);break;case K:t.depthFunc(516);break;case $:t.depthFunc(517);break;default:t.depthFunc(515)}else t.depthFunc(515);r=e}},setLocked:function(t){e=t},setClear:function(e){i!==e&&(t.clearDepth(e),i=e)},reset:function(){e=!1,n=null,r=null,i=null}}},l=new function(){var e=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null;return{setTest:function(t){e||(t?xt(2960):bt(2960))},setMask:function(r){n===r||e||(t.stencilMask(r),n=r)},setFunc:function(e,n,o){r===e&&i===n&&a===o||(t.stencilFunc(e,n,o),r=e,i=n,a=o)},setOp:function(e,n,r){o===e&&s===n&&c===r||(t.stencilOp(e,n,r),o=e,s=n,c=r)},setLocked:function(t){e=t},setClear:function(e){l!==e&&(t.clearStencil(e),l=e)},reset:function(){e=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null}}},u=t.getParameter(34921),h=new Uint8Array(u),d=new Uint8Array(u),p=new Uint8Array(u),f={},m=null,v=null,x=null,b=null,w=null,_=null,M=null,tt=null,et=null,nt=!1,rt=null,it=null,at=null,ot=null,st=null,ct=t.getParameter(35661),lt=!1,ut=0,ht=t.getParameter(7938);-1!==ht.indexOf("WebGL")?(ut=parseFloat(/^WebGL\ ([0-9])/.exec(ht)[1]),lt=ut>=1):-1!==ht.indexOf("OpenGL ES")&&(ut=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(ht)[1]),lt=ut>=2);var dt=null,pt={},ft=new Cn,mt=new Cn;function vt(e,n,r){var i=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(var o=0;or||t.height>r)&&(i=r/Math.max(t.width,t.height)),i<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){var a=e?xn.floorPowerOfTwo:Math.floor,o=a(i*t.width),c=a(i*t.height);void 0===s&&(s=m(o,c));var l=n?m(o,c):s;return l.width=o,l.height=c,l.getContext("2d").drawImage(t,0,0,o,c),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+o+"x"+c+")."),l}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function g(t){return xn.isPowerOfTwo(t.width)&&xn.isPowerOfTwo(t.height)}function y(t,e){return t.generateMipmaps&&e&&t.minFilter!==bt&&t.minFilter!==Et}function x(e,n,i,a){t.generateMipmap(e),r.get(n).__maxMipLevel=Math.log(Math.max(i,a))*Math.LOG2E}function b(t,n){if(!1===c)return t;var r=t;return 6403===t&&(5126===n&&(r=33326),5131===n&&(r=33325),5121===n&&(r=33321)),6407===t&&(5126===n&&(r=34837),5131===n&&(r=34843),5121===n&&(r=32849)),6408===t&&(5126===n&&(r=34836),5131===n&&(r=34842),5121===n&&(r=32856)),33325===r||33326===r||34842===r||34836===r?e.get("EXT_color_buffer_float"):34843!==r&&34837!==r||console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead."),r}function w(t){return t===bt||t===wt||t===Mt?9728:9729}function _(e){var n=e.target;n.removeEventListener("dispose",_),function(e){var n=r.get(e);if(void 0===n.__webglInit)return;t.deleteTexture(n.__webglTexture),r.remove(e)}(n),n.isVideoTexture&&p.delete(n),o.memory.textures--}function M(e){var n=e.target;n.removeEventListener("dispose",M),function(e){var n=r.get(e),i=r.get(e.texture);if(!e)return;void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLRenderTargetCube)for(var a=0;a<6;a++)t.deleteFramebuffer(n.__webglFramebuffer[a]),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer[a]);else t.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer);if(e.isWebGLMultiviewRenderTarget){t.deleteTexture(n.__webglColorTexture),t.deleteTexture(n.__webglDepthStencilTexture),o.memory.textures-=2;a=0;for(var s=n.__webglViewFramebuffers.length;a0&&i.__version!==t.version){var a=t.image;if(void 0===a)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==a.complete)return void O(i,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+e),n.bindTexture(3553,i.__webglTexture)}function A(e,i){if(6===e.image.length){var o=r.get(e);if(e.version>0&&o.__version!==e.version){C(o,e),n.activeTexture(33984+i),n.bindTexture(34067,o.__webglTexture),t.pixelStorei(37440,e.flipY);for(var s=e&&e.isCompressedTexture,l=e.image[0]&&e.image[0].isDataTexture,h=[],d=0;d<6;d++)h[d]=s||l?l?e.image[d].image:e.image[d]:v(e.image[d],!1,!0,u);var p,f=h[0],m=g(f)||c,w=a.convert(e.format),_=a.convert(e.type),M=b(w,_);if(P(34067,e,m),s){for(d=0;d<6;d++){p=h[d].mipmaps;for(var S=0;S1||r.get(a).__currentAnisotropy)&&(t.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function C(e,n){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",_),e.__webglTexture=t.createTexture(),o.memory.textures++)}function O(e,r,i){var o=3553;r.isDataTexture2DArray&&(o=35866),r.isDataTexture3D&&(o=32879),C(e,r),n.activeTexture(33984+i),n.bindTexture(o,e.__webglTexture),t.pixelStorei(37440,r.flipY),t.pixelStorei(37441,r.premultiplyAlpha),t.pixelStorei(3317,r.unpackAlignment);var s=function(t){return!c&&(t.wrapS!==yt||t.wrapT!==yt||t.minFilter!==bt&&t.minFilter!==Et)}(r)&&!1===g(r.image),l=v(r.image,s,!1,h),u=g(l)||c,d=a.convert(r.format),p=a.convert(r.type),f=b(d,p);P(o,r,u);var m,w=r.mipmaps;if(r.isDepthTexture){if(f=6402,r.type===Bt){if(!1===c)throw new Error("Float Depth Texture only supported in WebGL2.0");f=36012}else c&&(f=33189);r.format===Yt&&6402===f&&r.type!==Dt&&r.type!==Nt&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Dt,p=a.convert(r.type)),r.format===Zt&&(f=34041,r.type!==Ht&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=Ht,p=a.convert(r.type))),n.texImage2D(3553,0,f,l.width,l.height,0,d,p,null)}else if(r.isDataTexture)if(w.length>0&&u){for(var _=0,M=w.length;_0&&u){for(_=0,M=w.length;_=l&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+l),S+=1,t},this.resetTextureUnits=function(){S=0},this.setTexture2D=E,this.setTexture2DArray=function(t,e){var i=r.get(t);t.version>0&&i.__version!==t.version?O(i,t,e):(n.activeTexture(33984+e),n.bindTexture(35866,i.__webglTexture))},this.setTexture3D=function(t,e){var i=r.get(t);t.version>0&&i.__version!==t.version?O(i,t,e):(n.activeTexture(33984+e),n.bindTexture(32879,i.__webglTexture))},this.setTextureCube=A,this.setTextureCubeDynamic=T,this.setupRenderTarget=function(i){var s=r.get(i),l=r.get(i.texture);i.addEventListener("dispose",M),l.__webglTexture=t.createTexture(),o.memory.textures++;var u=!0===i.isWebGLRenderTargetCube,h=!0===i.isWebGLMultisampleRenderTarget,d=!0===i.isWebGLMultiviewRenderTarget,p=g(i)||c;if(u){s.__webglFramebuffer=[];for(var f=0;f<6;f++)s.__webglFramebuffer[f]=t.createFramebuffer()}else if(s.__webglFramebuffer=t.createFramebuffer(),h)if(c){s.__webglMultisampledFramebuffer=t.createFramebuffer(),s.__webglColorRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,s.__webglColorRenderbuffer);var m=b(a.convert(i.texture.format),a.convert(i.texture.type)),v=B(i);t.renderbufferStorageMultisample(36161,v,m,i.width,i.height),t.bindFramebuffer(36160,s.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(36160,36064,36161,s.__webglColorRenderbuffer),t.bindRenderbuffer(36161,null),i.depthBuffer&&(s.__webglDepthRenderbuffer=t.createRenderbuffer(),I(s.__webglDepthRenderbuffer,i,!0)),t.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");else if(d){var w=i.width,_=i.height,S=i.numViews;t.bindFramebuffer(36160,s.__webglFramebuffer);var E=e.get("OVR_multiview2");o.memory.textures+=2;var A=t.createTexture();t.bindTexture(35866,A),t.texParameteri(35866,10240,9728),t.texParameteri(35866,10241,9728),t.texImage3D(35866,0,32856,w,_,S,0,6408,5121,null),E.framebufferTextureMultiviewOVR(36160,36064,A,0,0,S);var T=t.createTexture();t.bindTexture(35866,T),t.texParameteri(35866,10240,9728),t.texParameteri(35866,10241,9728),t.texImage3D(35866,0,35056,w,_,S,0,34041,34042,null),E.framebufferTextureMultiviewOVR(36160,33306,T,0,0,S);var L=new Array(S);for(f=0;fd)return!1;for(var n=1,r=e.length;n=0){var l=i[s];if(void 0!==l){var u=l.normalized,h=l.itemSize;if(void 0===(M=w.get(l)))continue;var d=M.buffer,g=M.type,y=M.bytesPerElement;if(l.isInterleavedBufferAttribute){var x=l.data,b=x.stride,_=l.offset;x&&x.isInstancedInterleavedBuffer?(v.enableAttributeAndDivisor(c,x.meshPerAttribute),void 0===e.maxInstancedCount&&(e.maxInstancedCount=x.meshPerAttribute*x.count)):v.enableAttribute(c),p.bindBuffer(34962,d),p.vertexAttribPointer(c,h,g,u,b*y,_*y)}else l.isInstancedBufferAttribute?(v.enableAttributeAndDivisor(c,l.meshPerAttribute),void 0===e.maxInstancedCount&&(e.maxInstancedCount=l.meshPerAttribute*l.count)):v.enableAttribute(c),p.bindBuffer(34962,d),p.vertexAttribPointer(c,h,g,u,0,0)}else if("instanceMatrix"===s){var M;if(void 0===(M=w.get(t.instanceMatrix)))continue;d=M.buffer,g=M.type;v.enableAttributeAndDivisor(c+0,1),v.enableAttributeAndDivisor(c+1,1),v.enableAttributeAndDivisor(c+2,1),v.enableAttributeAndDivisor(c+3,1),p.bindBuffer(34962,d),p.vertexAttribPointer(c+0,4,g,!1,64,0),p.vertexAttribPointer(c+1,4,g,!1,64,16),p.vertexAttribPointer(c+2,4,g,!1,64,32),p.vertexAttribPointer(c+3,4,g,!1,64,48)}else if(void 0!==o){var S=o[s];if(void 0!==S)switch(S.length){case 2:p.vertexAttrib2fv(c,S);break;case 3:p.vertexAttrib3fv(c,S);break;case 4:p.vertexAttrib4fv(c,S);break;default:p.vertexAttrib1fv(c,S)}}}}v.disableUnusedAttributes()}(i,n,r,s),null!==u&&p.bindBuffer(34963,l.buffer));var y=1/0;null!==u?y=u.count:void 0!==h&&(y=h.count);var x=n.drawRange.start*d,b=n.drawRange.count*d,M=null!==a?a.start*d:0,S=null!==a?a.count*d:1/0,E=Math.max(x,M),A=Math.min(y,x+b,M+S)-1,T=Math.max(0,A-E+1);if(0!==T){if(i.isMesh)if(!0===r.wireframe)v.setLineWidth(r.wireframeLinewidth*at()),g.setMode(1);else switch(i.drawMode){case Re:g.setMode(4);break;case Pe:g.setMode(5);break;case Ce:g.setMode(6)}else if(i.isLine){var C=r.linewidth;void 0===C&&(C=1),v.setLineWidth(C*at()),i.isLineSegments?g.setMode(1):i.isLineLoop?g.setMode(2):g.setMode(3)}else i.isPoints?g.setMode(0):i.isSprite&&g.setMode(4);i.isInstancedMesh?g.renderInstances(n,E,T,i.count):n.isInstancedBufferGeometry?g.renderInstances(n,E,T,n.maxInstancedCount):g.render(E,T)}},this.compile=function(t,e){(d=A.get(t,e)).init(),t.traverse((function(t){t.isLight&&(d.pushLight(t),t.castShadow&&d.pushShadow(t))})),d.setupLights(e),t.traverse((function(e){if(e.material)if(Array.isArray(e.material))for(var n=0;n=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(f=0;f=0&&t.numSupportedMorphNormals++}var m=r.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(r.numClippingPlanes=$.numPlanes,r.numIntersection=$.numIntersection,m.clippingPlanes=$.uniform),r.fog=e,r.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),r.lightsStateVersion=o,r.needsLights&&(m.ambientLightColor.value=i.state.ambient,m.lightProbe.value=i.state.probe,m.directionalLights.value=i.state.directional,m.spotLights.value=i.state.spot,m.rectAreaLights.value=i.state.rectArea,m.pointLights.value=i.state.point,m.hemisphereLights.value=i.state.hemi,m.directionalShadowMap.value=i.state.directionalShadowMap,m.directionalShadowMatrix.value=i.state.directionalShadowMatrix,m.spotShadowMap.value=i.state.spotShadowMap,m.spotShadowMatrix.value=i.state.spotShadowMatrix,m.pointShadowMap.value=i.state.pointShadowMap,m.pointShadowMatrix.value=i.state.pointShadowMatrix);var v=r.program.getUniforms(),g=To.seqWithValue(v.seq,m);r.uniformsList=g}function wt(t,e,n,r){b.resetTextureUnits();var i=x.get(n),a=d.state.lights;if(tt&&(et||t!==H)){var o=t===H&&n.id===U;$.setState(n.clippingPlanes,n.clipIntersection,n.clipShadows,t,i,o)}!1===n.needsUpdate&&(void 0===i.program?n.needsUpdate=!0:n.fog&&i.fog!==e?n.needsUpdate=!0:i.needsLights&&i.lightsStateVersion!==a.state.version?n.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===$.numPlanes&&i.numIntersection===$.numIntersection||(n.needsUpdate=!0)),n.needsUpdate&&(bt(n,e,r),n.needsUpdate=!1);var s,c,l=!1,u=!1,h=!1,f=i.program,y=f.getUniforms(),w=i.shader.uniforms;if(v.useProgram(f.program)&&(l=!0,u=!0,h=!0),n.id!==U&&(U=n.id,u=!0),l||H!==t){if(f.numMultiviewViews>0?lt.updateCameraProjectionMatricesUniform(t,y):y.setValue(p,"projectionMatrix",t.projectionMatrix),m.logarithmicDepthBuffer&&y.setValue(p,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),H!==t&&(H=t,u=!0,h=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.envMap){var _=y.map.cameraPosition;void 0!==_&&_.setValue(p,rt.setFromMatrixPosition(t.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&y.setValue(p,"isOrthographic",!0===t.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.skinning)&&(f.numMultiviewViews>0?lt.updateCameraViewMatricesUniform(t,y):y.setValue(p,"viewMatrix",t.matrixWorldInverse))}if(n.skinning){y.setOptional(p,r,"bindMatrix"),y.setOptional(p,r,"bindMatrixInverse");var M=r.skeleton;if(M){var S=M.bones;if(m.floatVertexTextures){if(void 0===M.boneTexture){var E=Math.sqrt(4*S.length);E=xn.ceilPowerOfTwo(E),E=Math.max(E,4);var A=new Float32Array(E*E*4);A.set(M.boneMatrices);var T=new ca(A,E,E,jt,Bt);M.boneMatrices=A,M.boneTexture=T,M.boneTextureSize=E}y.setValue(p,"boneTexture",M.boneTexture,b),y.setValue(p,"boneTextureSize",M.boneTextureSize)}else y.setOptional(p,M,"boneMatrices")}}return(u||i.receiveShadow!==r.receiveShadow)&&(i.receiveShadow=r.receiveShadow,y.setValue(p,"receiveShadow",r.receiveShadow)),u&&(y.setValue(p,"toneMappingExposure",O.toneMappingExposure),y.setValue(p,"toneMappingWhitePoint",O.toneMappingWhitePoint),i.needsLights&&(c=h,(s=w).ambientLightColor.needsUpdate=c,s.lightProbe.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.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}(w,e),n.isMeshBasicMaterial?_t(w,n):n.isMeshLambertMaterial?(_t(w,n),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(w,n)):n.isMeshPhongMaterial?(_t(w,n),n.isMeshToonMaterial?function(t,e){Mt(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(w,n):Mt(w,n)):n.isMeshStandardMaterial?(_t(w,n),n.isMeshPhysicalMaterial?function(t,e){St(t,e),t.reflectivity.value=e.reflectivity,t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.sheen&&t.sheen.value.copy(e.sheen);e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,e.side===g&&t.clearcoatNormalScale.value.negate());t.transparency.value=e.transparency}(w,n):St(w,n)):n.isMeshMatcapMaterial?(_t(w,n),function(t,e){e.matcap&&(t.matcap.value=e.matcap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===g&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,n)):n.isMeshDepthMaterial?(_t(w,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,n)):n.isMeshDistanceMaterial?(_t(w,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}(w,n)):n.isMeshNormalMaterial?(_t(w,n),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===g&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,n)):n.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(w,n),n.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(w,n)):n.isPointsMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*Y,t.scale.value=.5*X,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);var n;e.map?n=e.map:e.alphaMap&&(n=e.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}(w,n):n.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);var n;e.map?n=e.map:e.alphaMap&&(n=e.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}(w,n):n.isShadowMaterial&&(w.color.value.copy(n.color),w.opacity.value=n.opacity),void 0!==w.ltc_1&&(w.ltc_1.value=pa.LTC_1),void 0!==w.ltc_2&&(w.ltc_2.value=pa.LTC_2),To.upload(p,i.uniformsList,w,b),n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(To.upload(p,i.uniformsList,w,b),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&y.setValue(p,"center",r.center),f.numMultiviewViews>0?lt.updateObjectMatricesUniforms(r,t,y):(y.setValue(p,"modelViewMatrix",r.modelViewMatrix),y.setValue(p,"normalMatrix",r.normalMatrix)),y.setValue(p,"modelMatrix",r.matrixWorld),f}function _t(t,e){var n;t.opacity.value=e.opacity,e.color&&t.diffuse.value.copy(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.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio,t.maxMipLevel.value=x.get(e.envMap).__maxMipLevel),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity),e.map?n=e.map:e.specularMap?n=e.specularMap:e.displacementMap?n=e.displacementMap:e.normalMap?n=e.normalMap:e.bumpMap?n=e.bumpMap:e.roughnessMap?n=e.roughnessMap:e.metalnessMap?n=e.metalnessMap:e.alphaMap?n=e.alphaMap:e.emissiveMap&&(n=e.emissiveMap),void 0!==n&&(n.isWebGLRenderTarget&&(n=n.texture),!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}function Mt(t,e){t.specular.value.copy(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.side===g&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function St(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.side===g&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}vt.setAnimationLoop((function(t){ct.isPresenting()||mt&&mt(t)})),"undefined"!=typeof window&&vt.setContext(window),this.setAnimationLoop=function(t){mt=t,ct.setAnimationLoop(t),vt.start()},this.render=function(t,e){var n,r;if(void 0!==arguments[2]&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),n=arguments[2]),void 0!==arguments[3]&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),r=arguments[3]),e&&e.isCamera){if(!D){G.geometry=null,G.program=null,G.wireframe=!1,U=-1,H=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),ct.enabled&&(e=ct.getCamera(e)),(d=A.get(t,e)).init(),t.onBeforeRender(O,t,e,n||F),nt.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),K.setFromMatrix(nt),et=this.localClippingEnabled,tt=$.init(this.clippingPlanes,et,e),(h=E.get(t,e)).init(),gt(t,e,0,O.sortObjects),!0===O.sortObjects&&h.sort(),tt&&$.beginShadows();var i=d.state.shadowsArray;ut.render(i,t,e),d.setupLights(e),tt&&$.endShadows(),this.info.autoReset&&this.info.reset(),void 0!==n&&this.setRenderTarget(n),ct.enabled&<.isAvailable()&<.attachCamera(e),T.render(h,t,e,r);var a=h.opaque,o=h.transparent;if(t.overrideMaterial){var s=t.overrideMaterial;a.length&&yt(a,t,e,s),o.length&&yt(o,t,e,s)}else a.length&&yt(a,t,e),o.length&&yt(o,t,e);t.onAfterRender(O,t,e),null!==F&&(b.updateRenderTargetMipmap(F),b.updateMultisampleRenderTarget(F)),v.buffers.depth.setTest(!0),v.buffers.depth.setMask(!0),v.buffers.color.setMask(!0),v.setPolygonOffset(!1),ct.enabled&&(lt.isAvailable()&<.detachCamera(e),ct.submitFrame()),h=null,d=null}}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.setFramebuffer=function(t){I!==t&&null===F&&p.bindFramebuffer(36160,t),I=t},this.getActiveCubeFace=function(){return N},this.getActiveMipmapLevel=function(){return B},this.getRenderTarget=function(){return F},this.setRenderTarget=function(t,e,n){F=t,N=e,B=n,t&&void 0===x.get(t).__webglFramebuffer&&b.setupRenderTarget(t);var r=I,i=!1;if(t){var a=x.get(t).__webglFramebuffer;t.isWebGLRenderTargetCube?(r=a[e||0],i=!0):r=t.isWebGLMultisampleRenderTarget?x.get(t).__webglMultisampledFramebuffer:a,k.copy(t.viewport),j.copy(t.scissor),W=t.scissorTest}else k.copy(Z).multiplyScalar(Y).floor(),j.copy(J).multiplyScalar(Y).floor(),W=Q;if(z!==r&&(p.bindFramebuffer(36160,r),z=r),v.viewport(k),v.scissor(j),v.setScissorTest(W),i){var o=x.get(t.texture);p.framebufferTexture2D(36160,36064,34069+(e||0),o.__webglTexture,n||0)}},this.readRenderTargetPixels=function(t,e,n,r,i,a,o){if(t&&t.isWebGLRenderTarget){var s=x.get(t).__webglFramebuffer;if(t.isWebGLRenderTargetCube&&void 0!==o&&(s=s[o]),s){var c=!1;s!==z&&(p.bindFramebuffer(36160,s),c=!0);try{var l=t.texture,u=l.format,h=l.type;if(u!==jt&&C.convert(u)!==p.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(h===Pt||C.convert(h)===p.getParameter(35738)||h===Bt&&(m.isWebGL2||f.get("OES_texture_float")||f.get("WEBGL_color_buffer_float"))||h===Ft&&(m.isWebGL2?f.get("EXT_color_buffer_float"):f.get("EXT_color_buffer_half_float"))))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===p.checkFramebufferStatus(36160)?e>=0&&e<=t.width-r&&n>=0&&n<=t.height-i&&p.readPixels(e,n,r,i,C.convert(u),C.convert(h),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{c&&p.bindFramebuffer(36160,z)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(t,e,n){void 0===n&&(n=0);var r=Math.pow(2,-n),i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=C.convert(e.format);b.setTexture2D(e,0),p.copyTexImage2D(3553,n,o,t.x,t.y,i,a,0),v.unbindTexture()},this.copyTextureToTexture=function(t,e,n,r){var i=e.image.width,a=e.image.height,o=C.convert(n.format),s=C.convert(n.type);b.setTexture2D(n,0),e.isDataTexture?p.texSubImage2D(3553,r||0,t.x,t.y,i,a,o,s,e.image.data):p.texSubImage2D(3553,r||0,t.x,t.y,o,s,e.image),v.unbindTexture()},this.initTexture=function(t){b.setTexture2D(t,0),v.unbindTexture()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function _s(t,e){this.name="",this.color=new Zr(t),this.density=void 0!==e?e:25e-5}function Ms(t,e,n){this.name="",this.color=new Zr(t),this.near=void 0!==e?e:1,this.far=void 0!==n?n:1e3}function Ss(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=sn,this.updateRange={offset:0,count:-1},this.version=0}function Es(t,e,n,r){this.data=t,this.itemSize=e,this.offset=n,this.normalized=!0===r}function As(t){ei.call(this),this.type="SpriteMaterial",this.color=new Zr(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(t)}Object.assign(xs.prototype,vn.prototype),Object.assign(bs.prototype,vn.prototype),Object.assign(_s.prototype,{isFogExp2:!0,clone:function(){return new _s(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}),Object.assign(Ms.prototype,{isFog:!0,clone:function(){return new Ms(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}),Object.defineProperty(Ss.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Ss.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.stride,n*=e.stride;for(var r=0,i=this.stride;rt.far||e.push({distance:s,point:Ts.clone(),uv:Wr.getUV(Ts,Ds,Is,Ns,Bs,Fs,zs,new bn),face:null,object:this})}},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(t){return ar.prototype.copy.call(this,t),void 0!==t.center&&this.center.copy(t.center),this}});var Hs=new Sn,Vs=new Sn;function ks(){ar.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}function js(t,e){t&&t.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),Gi.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Hn,this.bindMatrixInverse=new Hn}ks.prototype=Object.assign(Object.create(ar.prototype),{constructor:ks,isLOD:!0,copy:function(t){ar.prototype.copy.call(this,t,!1);for(var e=t.levels,n=0,r=e.length;n1){Hs.setFromMatrixPosition(t.matrixWorld),Vs.setFromMatrixPosition(this.matrixWorld);var n=Hs.distanceTo(Vs);e[0].object.visible=!0;for(var r=1,i=e.length;r=e[r].distance;r++)e[r-1].object.visible=!1,e[r].object.visible=!0;for(;ro))u.applyMatrix4(this.matrixWorld),(w=t.ray.origin.distanceTo(u))t.far||e.push({distance:w,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}else for(m=0,v=p.length/3-1;mo))u.applyMatrix4(this.matrixWorld),(w=t.ray.origin.distanceTo(u))t.far||e.push({distance:w,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}else if(r.isGeometry){var x=r.vertices,b=x.length;for(m=0;mo))u.applyMatrix4(this.matrixWorld),(w=t.ray.origin.distanceTo(u))t.far||e.push({distance:w,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var rc=new Sn,ic=new Sn;function ac(t,e){nc.call(this,t,e),this.type="LineSegments"}function oc(t,e){nc.call(this,t,e),this.type="LineLoop"}function sc(t){ei.call(this),this.type="PointsMaterial",this.color=new Zr(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(t)}ac.prototype=Object.assign(Object.create(nc.prototype),{constructor:ac,isLineSegments:!0,computeLineDistances:function(){var t=this.geometry;if(t.isBufferGeometry)if(null===t.index){for(var e=t.attributes.position,n=[],r=0,i=e.count;ri.far)return;a.push({distance:l,distanceToRay:Math.sqrt(s),point:c,index:e,face:null,object:o})}}function fc(t,e,n,r,i,a,o,s,c){Pn.call(this,t,e,n,r,i,a,o,s,c),this.format=void 0!==o?o:kt,this.minFilter=void 0!==a?a:Et,this.magFilter=void 0!==i?i:Et,this.generateMipmaps=!1}function mc(t,e,n,r,i,a,o,s,c,l,u,h){Pn.call(this,null,a,o,s,c,l,r,i,u,h),this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function vc(t,e,n,r,i,a,o,s,c){Pn.call(this,t,e,n,r,i,a,o,s,c),this.needsUpdate=!0}function gc(t,e,n,r,i,a,o,s,c,l){if((l=void 0!==l?l:Yt)!==Yt&&l!==Zt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&l===Yt&&(n=Dt),void 0===n&&l===Zt&&(n=Ht),Pn.call(this,null,r,i,a,o,s,l,n,c),this.image={width:t,height:e},this.magFilter=void 0!==o?o:bt,this.minFilter=void 0!==s?s:bt,this.flipY=!1,this.generateMipmaps=!1}function yc(t){_i.call(this),this.type="WireframeGeometry";var e,n,r,i,a,o,s,c,l,u,h=[],d=[0,0],p={},f=["a","b","c"];if(t&&t.isGeometry){var m=t.faces;for(e=0,r=m.length;e=0?(t(v-1e-5,m,h),d.subVectors(u,h)):(t(v+1e-5,m,h),d.subVectors(h,u)),m-1e-5>=0?(t(v,m-1e-5,h),p.subVectors(u,h)):(t(v,m+1e-5,h),p.subVectors(h,u)),l.crossVectors(d,p).normalize(),s.push(l.x,l.y,l.z),c.push(v,m)}}for(r=0;r.9&&o<.1&&(e<.2&&(a[t+0]+=1),n<.2&&(a[t+2]+=1),r<.2&&(a[t+4]+=1))}}()}(),this.setAttribute("position",new hi(i,3)),this.setAttribute("normal",new hi(i.slice(),3)),this.setAttribute("uv",new hi(a,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}function Mc(t,e){Xi.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Sc(t,e)),this.mergeVertices()}function Sc(t,e){_c.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 Ec(t,e){Xi.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Ac(t,e)),this.mergeVertices()}function Ac(t,e){_c.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 Tc(t,e){Xi.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Lc(t,e)),this.mergeVertices()}function Lc(t,e){var n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1];_c.call(this,r,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Rc(t,e){Xi.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Pc(t,e)),this.mergeVertices()}function Pc(t,e){var n=(1+Math.sqrt(5))/2,r=1/n,i=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r];_c.call(this,i,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Cc(t,e,n,r,i,a){Xi.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:r,closed:i},void 0!==a&&console.warn("THREE.TubeGeometry: taper has been removed.");var o=new Oc(t,e,n,r,i);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals,this.fromBufferGeometry(o),this.mergeVertices()}function Oc(t,e,n,r,i){_i.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:r,closed:i},e=e||64,n=n||1,r=r||8,i=i||!1;var a=t.computeFrenetFrames(e,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;var o,s,c=new Sn,l=new Sn,u=new bn,h=new Sn,d=[],p=[],f=[],m=[];function v(i){h=t.getPointAt(i/e,h);var o=a.normals[i],u=a.binormals[i];for(s=0;s<=r;s++){var f=s/r*Math.PI*2,m=Math.sin(f),v=-Math.cos(f);l.x=v*o.x+m*u.x,l.y=v*o.y+m*u.y,l.z=v*o.z+m*u.z,l.normalize(),p.push(l.x,l.y,l.z),c.x=h.x+n*l.x,c.y=h.y+n*l.y,c.z=h.z+n*l.z,d.push(c.x,c.y,c.z)}}!function(){for(o=0;o0){var o=i[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=o.length;t0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),fc.prototype=Object.assign(Object.create(Pn.prototype),{constructor:fc,isVideoTexture:!0,update:function(){var t=this.image;t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),mc.prototype=Object.create(Pn.prototype),mc.prototype.constructor=mc,mc.prototype.isCompressedTexture=!0,vc.prototype=Object.create(Pn.prototype),vc.prototype.constructor=vc,vc.prototype.isCanvasTexture=!0,gc.prototype=Object.create(Pn.prototype),gc.prototype.constructor=gc,gc.prototype.isDepthTexture=!0,yc.prototype=Object.create(_i.prototype),yc.prototype.constructor=yc,xc.prototype=Object.create(Xi.prototype),xc.prototype.constructor=xc,bc.prototype=Object.create(_i.prototype),bc.prototype.constructor=bc,wc.prototype=Object.create(Xi.prototype),wc.prototype.constructor=wc,_c.prototype=Object.create(_i.prototype),_c.prototype.constructor=_c,Mc.prototype=Object.create(Xi.prototype),Mc.prototype.constructor=Mc,Sc.prototype=Object.create(_c.prototype),Sc.prototype.constructor=Sc,Ec.prototype=Object.create(Xi.prototype),Ec.prototype.constructor=Ec,Ac.prototype=Object.create(_c.prototype),Ac.prototype.constructor=Ac,Tc.prototype=Object.create(Xi.prototype),Tc.prototype.constructor=Tc,Lc.prototype=Object.create(_c.prototype),Lc.prototype.constructor=Lc,Rc.prototype=Object.create(Xi.prototype),Rc.prototype.constructor=Rc,Pc.prototype=Object.create(_c.prototype),Pc.prototype.constructor=Pc,Cc.prototype=Object.create(Xi.prototype),Cc.prototype.constructor=Cc,Oc.prototype=Object.create(_i.prototype),Oc.prototype.constructor=Oc,Oc.prototype.toJSON=function(){var t=_i.prototype.toJSON.call(this);return t.path=this.parameters.path.toJSON(),t},Dc.prototype=Object.create(Xi.prototype),Dc.prototype.constructor=Dc,Ic.prototype=Object.create(_i.prototype),Ic.prototype.constructor=Ic,Nc.prototype=Object.create(Xi.prototype),Nc.prototype.constructor=Nc,Bc.prototype=Object.create(_i.prototype),Bc.prototype.constructor=Bc;var Fc=function(t,e,n){n=n||2;var r,i,a,o,s,c,l,u=e&&e.length,h=u?e[0]*n:t.length,d=zc(t,0,h,n,!0),p=[];if(!d||d.next===d.prev)return p;if(u&&(d=function(t,e,n,r){var i,a,o,s,c,l=[];for(i=0,a=e.length;i80*n){r=a=t[0],i=o=t[1];for(var f=n;fa&&(a=s),c>o&&(o=c);l=0!==(l=Math.max(a-r,o-i))?1/l:0}return Gc(d,p,n,r,i,l),p};function zc(t,e,n,r,i){var a,o;if(i===function(t,e,n,r){for(var i=0,a=e,o=n-r;a0)for(a=e;a=e;a-=r)o=nl(a,t[a],t[a+1],o);return o&&Kc(o,o.next)&&(rl(o),o=o.next),o}function Uc(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!Kc(r,r.next)&&0!==Qc(r.prev,r,r.next))r=r.next;else{if(rl(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function Gc(t,e,n,r,i,a,o){if(t){!o&&a&&function(t,e,n,r){var i=t;do{null===i.z&&(i.z=Xc(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,a,o,s,c,l=1;do{for(n=t,t=null,a=null,o=0;n;){for(o++,r=n,s=0,e=0;e0||c>0&&r;)0!==s&&(0===c||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,c--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1)}(i)}(t,r,i,a);for(var s,c,l=t;t.prev!==t.next;)if(s=t.prev,c=t.next,a?Vc(t,r,i,a):Hc(t))e.push(s.i/n),e.push(t.i/n),e.push(c.i/n),rl(t),t=c.next,l=c.next;else if((t=c)===l){o?1===o?Gc(t=kc(t,e,n),e,n,r,i,a,2):2===o&&jc(t,e,n,r,i,a):Gc(Uc(t),e,n,r,i,a,1);break}}}function Hc(t){var e=t.prev,n=t,r=t.next;if(Qc(e,n,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(Zc(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Qc(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Vc(t,e,n,r){var i=t.prev,a=t,o=t.next;if(Qc(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,u=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,h=Xc(s,c,e,n,r),d=Xc(l,u,e,n,r),p=t.prevZ,f=t.nextZ;p&&p.z>=h&&f&&f.z<=d;){if(p!==t.prev&&p!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Qc(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==t.prev&&f!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Qc(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=h;){if(p!==t.prev&&p!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Qc(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==t.prev&&f!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Qc(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function kc(t,e,n){var r=t;do{var i=r.prev,a=r.next.next;!Kc(i,a)&&$c(i,r,r.next,a)&&tl(i,a)&&tl(a,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(a.i/n),rl(r),rl(r.next),r=t=a),r=r.next}while(r!==t);return r}function jc(t,e,n,r,i,a){var o=t;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&Jc(o,s)){var c=el(o,s);return o=Uc(o,o.next),c=Uc(c,c.next),Gc(o,e,n,r,i,a),void Gc(c,e,n,r,i,a)}s=s.next}o=o.next}while(o!==t)}function Wc(t,e){return t.x-e.x}function qc(t,e){if(e=function(t,e){var n,r=e,i=t.x,a=t.y,o=-1/0;do{if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){var s=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>o){if(o=s,s===i){if(a===r.y)return r;if(a===r.next.y)return r.next}n=r.x=r.x&&r.x>=u&&i!==r.x&&Zc(an.x)&&tl(r,t)&&(n=r,d=c),r=r.next;return n}(t,e)){var n=el(e,t);Uc(n,n.next)}}function Xc(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Yc(t){var e=t,n=t;do{(e.x=0&&(t-o)*(r-s)-(n-o)*(e-s)>=0&&(n-o)*(a-s)-(i-o)*(r-s)>=0}function Jc(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&&$c(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&tl(t,e)&&tl(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)}function Qc(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Kc(t,e){return t.x===e.x&&t.y===e.y}function $c(t,e,n,r){return!!(Kc(t,n)&&Kc(e,r)||Kc(t,r)&&Kc(n,e))||Qc(t,e,n)>0!=Qc(t,e,r)>0&&Qc(n,r,t)>0!=Qc(n,r,e)>0}function tl(t,e){return Qc(t.prev,t,t.next)<0?Qc(t,e,t.next)>=0&&Qc(t,t.prev,e)>=0:Qc(t,e,t.prev)<0||Qc(t,t.next,e)<0}function el(t,e){var n=new il(t.i,t.x,t.y),r=new il(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function nl(t,e,n,r){var i=new il(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function rl(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 il(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 al={area:function(t){for(var e=t.length,n=0,r=e-1,i=0;i2&&t[e-1].equals(t[0])&&t.pop()}function sl(t,e){for(var n=0;nNumber.EPSILON){var d=Math.sqrt(u),p=Math.sqrt(c*c+l*l),f=e.x-s/d,m=e.y+o/d,v=((n.x-l/p-f)*l-(n.y+c/p-m)*c)/(o*l-s*c),g=(r=f+o*v-t.x)*r+(i=m+s*v-t.y)*i;if(g<=2)return new bn(r,i);a=Math.sqrt(g/2)}else{var y=!1;o>Number.EPSILON?c>Number.EPSILON&&(y=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(l)&&(y=!0),y?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new bn(r/a,i/a)}for(var G=[],H=0,V=R.length,k=V-1,j=H+1;H=0;C--){for(D=C/p,I=u*Math.cos(D*Math.PI/2),O=h*Math.sin(D*Math.PI/2)+d,H=0,V=R.length;H=0;){n=H,(r=H-1)<0&&(r=t.length-1);var i=0,a=s+2*p;for(i=0;i0)&&f.push(_,M,E),(c!==n-1||l0&&g(!0),e>0&&g(!1)),this.setIndex(l),this.setAttribute("position",new hi(u,3)),this.setAttribute("normal",new hi(h,3)),this.setAttribute("uv",new hi(d,2))}function Al(t,e,n,r,i,a,o){Sl.call(this,0,t,e,n,r,i,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}function Tl(t,e,n,r,i,a,o){El.call(this,0,t,e,n,r,i,a,o),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}function Ll(t,e,n,r){Xi.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},this.fromBufferGeometry(new Rl(t,e,n,r)),this.mergeVertices()}function Rl(t,e,n,r){_i.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},t=t||1,e=void 0!==e?Math.max(3,e):8,n=void 0!==n?n:0,r=void 0!==r?r:2*Math.PI;var i,a,o=[],s=[],c=[],l=[],u=new Sn,h=new bn;for(s.push(0,0,0),c.push(0,0,1),l.push(.5,.5),a=0,i=3;a<=e;a++,i+=3){var d=n+a/e*r;u.x=t*Math.cos(d),u.y=t*Math.sin(d),s.push(u.x,u.y,u.z),c.push(0,0,1),h.x=(s[i]/t+1)/2,h.y=(s[i+1]/t+1)/2,l.push(h.x,h.y)}for(i=1;i<=e;i++)o.push(i,i+1,0);this.setIndex(o),this.setAttribute("position",new hi(s,3)),this.setAttribute("normal",new hi(c,3)),this.setAttribute("uv",new hi(l,2))}dl.prototype=Object.create(Xi.prototype),dl.prototype.constructor=dl,pl.prototype=Object.create(ll.prototype),pl.prototype.constructor=pl,fl.prototype=Object.create(Xi.prototype),fl.prototype.constructor=fl,ml.prototype=Object.create(_i.prototype),ml.prototype.constructor=ml,vl.prototype=Object.create(Xi.prototype),vl.prototype.constructor=vl,gl.prototype=Object.create(_i.prototype),gl.prototype.constructor=gl,yl.prototype=Object.create(Xi.prototype),yl.prototype.constructor=yl,xl.prototype=Object.create(_i.prototype),xl.prototype.constructor=xl,bl.prototype=Object.create(Xi.prototype),bl.prototype.constructor=bl,bl.prototype.toJSON=function(){var t=Xi.prototype.toJSON.call(this);return _l(this.parameters.shapes,t)},wl.prototype=Object.create(_i.prototype),wl.prototype.constructor=wl,wl.prototype.toJSON=function(){var t=_i.prototype.toJSON.call(this);return _l(this.parameters.shapes,t)},Ml.prototype=Object.create(_i.prototype),Ml.prototype.constructor=Ml,Sl.prototype=Object.create(Xi.prototype),Sl.prototype.constructor=Sl,El.prototype=Object.create(_i.prototype),El.prototype.constructor=El,Al.prototype=Object.create(Sl.prototype),Al.prototype.constructor=Al,Tl.prototype=Object.create(El.prototype),Tl.prototype.constructor=Tl,Ll.prototype=Object.create(Xi.prototype),Ll.prototype.constructor=Ll,Rl.prototype=Object.create(_i.prototype),Rl.prototype.constructor=Rl;var Pl=Object.freeze({__proto__:null,WireframeGeometry:yc,ParametricGeometry:xc,ParametricBufferGeometry:bc,TetrahedronGeometry:Mc,TetrahedronBufferGeometry:Sc,OctahedronGeometry:Ec,OctahedronBufferGeometry:Ac,IcosahedronGeometry:Tc,IcosahedronBufferGeometry:Lc,DodecahedronGeometry:Rc,DodecahedronBufferGeometry:Pc,PolyhedronGeometry:wc,PolyhedronBufferGeometry:_c,TubeGeometry:Cc,TubeBufferGeometry:Oc,TorusKnotGeometry:Dc,TorusKnotBufferGeometry:Ic,TorusGeometry:Nc,TorusBufferGeometry:Bc,TextGeometry:dl,TextBufferGeometry:pl,SphereGeometry:fl,SphereBufferGeometry:ml,RingGeometry:vl,RingBufferGeometry:gl,PlaneGeometry:ga,PlaneBufferGeometry:ya,LatheGeometry:yl,LatheBufferGeometry:xl,ShapeGeometry:bl,ShapeBufferGeometry:wl,ExtrudeGeometry:cl,ExtrudeBufferGeometry:ll,EdgesGeometry:Ml,ConeGeometry:Al,ConeBufferGeometry:Tl,CylinderGeometry:Sl,CylinderBufferGeometry:El,CircleGeometry:Ll,CircleBufferGeometry:Rl,BoxGeometry:Yi,BoxBufferGeometry:Zi});function Cl(t){ei.call(this),this.type="ShadowMaterial",this.color=new Zr(0),this.transparent=!0,this.setValues(t)}function Ol(t){ea.call(this,t),this.type="RawShaderMaterial"}function Dl(t){ei.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Zr(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 Zr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(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 Il(t){Dl.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearcoat=0,this.clearcoatRoughness=0,this.sheen=null,this.clearcoatNormalScale=new bn(1,1),this.clearcoatNormalMap=null,this.transparency=0,this.setValues(t)}function Nl(t){ei.call(this),this.type="MeshPhongMaterial",this.color=new Zr(16777215),this.specular=new Zr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Zr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=tt,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 Bl(t){Nl.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function Fl(t){ei.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function zl(t){ei.call(this),this.type="MeshLambertMaterial",this.color=new Zr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Zr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=tt,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 Ul(t){ei.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Zr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Gl(t){Js.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}Cl.prototype=Object.create(ei.prototype),Cl.prototype.constructor=Cl,Cl.prototype.isShadowMaterial=!0,Cl.prototype.copy=function(t){return ei.prototype.copy.call(this,t),this.color.copy(t.color),this},Ol.prototype=Object.create(ea.prototype),Ol.prototype.constructor=Ol,Ol.prototype.isRawShaderMaterial=!0,Dl.prototype=Object.create(ei.prototype),Dl.prototype.constructor=Dl,Dl.prototype.isMeshStandardMaterial=!0,Dl.prototype.copy=function(t){return ei.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.normalMapType=t.normalMapType,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},Il.prototype=Object.create(Dl.prototype),Il.prototype.constructor=Il,Il.prototype.isMeshPhysicalMaterial=!0,Il.prototype.copy=function(t){return Dl.prototype.copy.call(this,t),this.defines={STANDARD:"",PHYSICAL:""},this.reflectivity=t.reflectivity,this.clearcoat=t.clearcoat,this.clearcoatRoughness=t.clearcoatRoughness,t.sheen?this.sheen=(this.sheen||new Zr).copy(t.sheen):this.sheen=null,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.transparency=t.transparency,this},Nl.prototype=Object.create(ei.prototype),Nl.prototype.constructor=Nl,Nl.prototype.isMeshPhongMaterial=!0,Nl.prototype.copy=function(t){return ei.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.normalMapType=t.normalMapType,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},Bl.prototype=Object.create(Nl.prototype),Bl.prototype.constructor=Bl,Bl.prototype.isMeshToonMaterial=!0,Bl.prototype.copy=function(t){return Nl.prototype.copy.call(this,t),this.gradientMap=t.gradientMap,this},Fl.prototype=Object.create(ei.prototype),Fl.prototype.constructor=Fl,Fl.prototype.isMeshNormalMaterial=!0,Fl.prototype.copy=function(t){return ei.prototype.copy.call(this,t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,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},zl.prototype=Object.create(ei.prototype),zl.prototype.constructor=zl,zl.prototype.isMeshLambertMaterial=!0,zl.prototype.copy=function(t){return ei.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},Ul.prototype=Object.create(ei.prototype),Ul.prototype.constructor=Ul,Ul.prototype.isMeshMatcapMaterial=!0,Ul.prototype.copy=function(t){return ei.prototype.copy.call(this,t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Gl.prototype=Object.create(Js.prototype),Gl.prototype.constructor=Gl,Gl.prototype.isLineDashedMaterial=!0,Gl.prototype.copy=function(t){return Js.prototype.copy.call(this,t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this};var Hl=Object.freeze({__proto__:null,ShadowMaterial:Cl,SpriteMaterial:As,RawShaderMaterial:Ol,ShaderMaterial:ea,PointsMaterial:sc,MeshPhysicalMaterial:Il,MeshStandardMaterial:Dl,MeshPhongMaterial:Nl,MeshToonMaterial:Bl,MeshNormalMaterial:Fl,MeshLambertMaterial:zl,MeshDepthMaterial:rs,MeshDistanceMaterial:is,MeshBasicMaterial:ni,MeshMatcapMaterial:Ul,LineDashedMaterial:Gl,LineBasicMaterial:Js,Material:ei}),Vl={arraySlice:function(t,e,n){return Vl.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),r=0;r!==e;++r)n[r]=r;return n.sort((function(e,n){return t[e]-t[n]})),n},sortedArray:function(t,e,n){for(var r=t.length,i=new t.constructor(r),a=0,o=0;o!==r;++a)for(var s=n[a]*e,c=0;c!==e;++c)i[o++]=t[s+c];return i},flattenJSON:function(t,e,n,r){for(var i=1,a=t[0];void 0!==a&&void 0===a[r];)a=t[i++];if(void 0!==a){var o=a[r];if(void 0!==o)if(Array.isArray(o))do{void 0!==(o=a[r])&&(e.push(a.time),n.push.apply(n,o)),a=t[i++]}while(void 0!==a);else if(void 0!==o.toArray)do{void 0!==(o=a[r])&&(e.push(a.time),o.toArray(n,n.length)),a=t[i++]}while(void 0!==a);else do{void 0!==(o=a[r])&&(e.push(a.time),n.push(o)),a=t[i++]}while(void 0!==a)}},subclip:function(t,e,n,r,i){i=i||30;var a=t.clone();a.name=e;for(var o=[],s=0;s=r)){u.push(c.times[d]);for(var f=0;fa.tracks[s].times[0]&&(m=a.tracks[s].times[0]);for(s=0;s=i)break t;var s=e[1];t=(i=e[--n-1]))break e}a=n,n=0}for(;n>>1;te;)--a;if(++a,0!==i||a!==r){i>=a&&(i=(a=Math.max(a,1))-1);var o=this.getValueSize();this.times=Vl.arraySlice(n,i,a),this.values=Vl.arraySlice(this.values,i*o,a*o)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);var n=this.times,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);for(var a=null,o=0;o!==i;o++){var s=n[o];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,s),t=!1;break}if(null!==a&&a>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,s,a),t=!1;break}a=s}if(void 0!==r&&Vl.isTypedArray(r)){o=0;for(var c=r.length;o!==c;++o){var l=r[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}}return t},optimize:function(){for(var t=this.times,e=this.values,n=this.getValueSize(),r=this.getInterpolation()===Ee,i=1,a=t.length-1,o=1;o0){t[i]=t[a];for(f=a*n,m=i*n,d=0;d!==n;++d)e[m+d]=e[f+d];++i}return i!==t.length&&(this.times=Vl.arraySlice(t,0,i),this.values=Vl.arraySlice(e,0,i*n)),this},clone:function(){var t=Vl.arraySlice(this.times,0),e=Vl.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}),Yl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Yl,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:Me,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Zl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Zl,ValueTypeName:"color"}),Jl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Jl,ValueTypeName:"number"}),Ql.prototype=Object.assign(Object.create(kl.prototype),{constructor:Ql,interpolate_:function(t,e,n,r){for(var i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=t*o,c=(n-e)/(r-e),l=s+o;s!==l;s+=4)wn.slerpFlat(i,0,a,s-o,a,s,c);return i}}),Kl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Kl,ValueTypeName:"quaternion",DefaultInterpolation:Se,InterpolantFactoryMethodLinear:function(t){return new Ql(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),$l.prototype=Object.assign(Object.create(Xl.prototype),{constructor:$l,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:Me,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),tu.prototype=Object.assign(Object.create(Xl.prototype),{constructor:tu,ValueTypeName:"vector"}),Object.assign(eu,{parse:function(t){for(var e=[],n=t.tracks,r=1/(t.fps||1),i=0,a=n.length;i!==a;++i)e.push(nu(n[i]).scale(r));return new eu(t.name,t.duration,e)},toJSON:function(t){for(var e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid},i=0,a=n.length;i!==a;++i)e.push(Xl.toJSON(n[i]));return r},CreateFromMorphTargetSequence:function(t,e,n,r){for(var i=e.length,a=[],o=0;o1){var l=r[h=c[1]];l||(r[h]=l=[]),l.push(s)}}var u=[];for(var h in r)u.push(eu.CreateFromMorphTargetSequence(h,r[h],e,n));return u},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var n=function(t,e,n,r,i){if(0!==n.length){var a=[],o=[];Vl.flattenJSON(n,a,o,r),0!==a.length&&i.push(new t(e,a,o))}},r=[],i=t.name||"default",a=t.length||-1,o=t.fps||30,s=t.hierarchy||[],c=0;c0||0===t.search(/^data\:image\/jpeg/);i.format=r?kt:jt,i.needsUpdate=!0,void 0!==e&&e(i)}),n,r),i}}),Object.assign(mu.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,e){var n=this.getUtoTmapping(t);return this.getPoint(n,e)},getPoints:function(t){void 0===t&&(t=5);for(var e=[],n=0;n<=t;n++)e.push(this.getPoint(n/t));return e},getSpacedPoints:function(t){void 0===t&&(t=5);for(var e=[],n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,n,r=[],i=this.getPoint(0),a=0;for(r.push(0),n=1;n<=t;n++)a+=(e=this.getPoint(n/t)).distanceTo(i),r.push(a),i=e;return this.cacheArcLengths=r,r},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){var n,r=this.getLengths(),i=0,a=r.length;n=e||t*r[a-1];for(var o,s=0,c=a-1;s<=c;)if((o=r[i=Math.floor(s+(c-s)/2)]-n)<0)s=i+1;else{if(!(o>0)){c=i;break}c=i-1}if(r[i=c]===n)return i/(a-1);var l=r[i];return(i+(n-l)/(r[i+1]-l))/(a-1)},getTangent:function(t){var e=t-1e-4,n=t+1e-4;e<0&&(e=0),n>1&&(n=1);var r=this.getPoint(e);return this.getPoint(n).clone().sub(r).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var n,r,i,a=new Sn,o=[],s=[],c=[],l=new Sn,u=new Hn;for(n=0;n<=t;n++)r=n/t,o[n]=this.getTangentAt(r),o[n].normalize();s[0]=new Sn,c[0]=new Sn;var h=Number.MAX_VALUE,d=Math.abs(o[0].x),p=Math.abs(o[0].y),f=Math.abs(o[0].z);for(d<=h&&(h=d,a.set(1,0,0)),p<=h&&(h=p,a.set(0,1,0)),f<=h&&a.set(0,0,1),l.crossVectors(o[0],a).normalize(),s[0].crossVectors(o[0],l),c[0].crossVectors(o[0],s[0]),n=1;n<=t;n++)s[n]=s[n-1].clone(),c[n]=c[n-1].clone(),l.crossVectors(o[n-1],o[n]),l.length()>Number.EPSILON&&(l.normalize(),i=Math.acos(xn.clamp(o[n-1].dot(o[n]),-1,1)),s[n].applyMatrix4(u.makeRotationAxis(l,i))),c[n].crossVectors(o[n],s[n]);if(!0===e)for(i=Math.acos(xn.clamp(s[0].dot(s[t]),-1,1)),i/=t,o[0].dot(l.crossVectors(s[0],s[t]))>0&&(i=-i),n=1;n<=t;n++)s[n].applyMatrix4(u.makeRotationAxis(o[n],i*n)),c[n].crossVectors(o[n],s[n]);return{tangents:o,normals:s,binormals:c}},clone:function(){return(new this.constructor).copy(this)},copy:function(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}}),vu.prototype=Object.create(mu.prototype),vu.prototype.constructor=vu,vu.prototype.isEllipseCurve=!0,vu.prototype.getPoint=function(t,e){for(var n=e||new bn,r=2*Math.PI,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)r;)i-=r;i0?0:(Math.floor(Math.abs(u)/c)+1)*c:0===h&&u===c-1&&(u=c-2,h=1),this.closed||u>0?n=s[(u-1)%c]:(xu.subVectors(s[0],s[1]).add(s[0]),n=xu),r=s[u%c],i=s[(u+1)%c],this.closed||u+2r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(Su(o,s.x,c.x,l.x,u.x),Su(o,s.y,c.y,l.y,u.y)),n},Du.prototype.copy=function(t){mu.prototype.copy.call(this,t),this.points=[];for(var e=0,n=t.points.length;e=e){var i=n[r]-e,a=this.curves[r],o=a.getLength(),s=0===o?0:1-i/o;return a.getPointAt(s)}r++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,n=0,r=this.curves.length;n1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},copy:function(t){mu.prototype.copy.call(this,t),this.curves=[];for(var e=0,n=t.curves.length;e0){var l=c.getPoint(0);l.equals(this.currentPoint)||this.lineTo(l.x,l.y)}this.curves.push(c);var u=c.getPoint(1);return this.currentPoint.copy(u),this},copy:function(t){return Nu.prototype.copy.call(this,t),this.currentPoint.copy(t.currentPoint),this},toJSON:function(){var t=Nu.prototype.toJSON.call(this);return t.currentPoint=this.currentPoint.toArray(),t},fromJSON:function(t){return Nu.prototype.fromJSON.call(this,t),this.currentPoint.fromArray(t.currentPoint),this}}),Fu.prototype=Object.assign(Object.create(Bu.prototype),{constructor:Fu,getPointsHoles:function(t){for(var e=[],n=0,r=this.holes.length;n0){var a=new du(new iu(e));a.setCrossOrigin(this.crossOrigin);for(var o=0,s=t.length;o0?new js(o,s):new Gi(o,s);break;case"InstancedMesh":o=i(t.geometry),s=a(t.material);var c=t.count,l=t.instanceMatrix;(r=new Zs(o,s,c)).instanceMatrix=new ri(new Float32Array(l.array),16);break;case"LOD":r=new ks;break;case"Line":r=new nc(i(t.geometry),a(t.material),t.mode);break;case"LineLoop":r=new oc(i(t.geometry),a(t.material));break;case"LineSegments":r=new ac(i(t.geometry),a(t.material));break;case"PointCloud":case"Points":r=new dc(i(t.geometry),a(t.material));break;case"Sprite":r=new Us(a(t.material));break;case"Group":r=new ps;break;default:r=new ar}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(r.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(r.matrixAutoUpdate=t.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.frustumCulled&&(r.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(r.renderOrder=t.renderOrder),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.layers&&(r.layers.mask=t.layers),void 0!==t.drawMode&&r.setDrawMode(t.drawMode),void 0!==t.children)for(var u=t.children,h=0;hNumber.EPSILON){if(l<0&&(o=e[a],c=-c,s=e[i],l=-l),t.ys.y)continue;if(t.y===o.y){if(t.x===o.x)return!0}else{var u=l*(t.x-o.x)-c*(t.y-o.y);if(0===u)return!0;if(u<0)continue;r=!r}}else{if(t.y!==o.y)continue;if(s.x<=t.x&&t.x<=o.x||o.x<=t.x&&t.x<=s.x)return!0}}return r}var i=al.isClockWise,a=this.subPaths;if(0===a.length)return[];if(!0===e)return n(a);var o,s,c,l=[];if(1===a.length)return s=a[0],(c=new Fu).curves=s.curves,l.push(c),l;var u=!i(a[0].getPoints());u=t?!u:u;var h,d,p=[],f=[],m=[],v=0;f[v]=void 0,m[v]=[];for(var g=0,y=a.length;g1){for(var x=!1,b=[],w=0,_=f.length;w<_;w++)p[w]=[];for(w=0,_=f.length;w<_;w++)for(var M=m[w],S=0;S0&&(x||(m=p))}g=0;for(var L=f.length;g0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var a=0;a!==i;++a)t[e+a]=t[n+a]},_slerp:function(t,e,n,r){wn.slerpFlat(t,e,t,e,t,n,r)},_lerp:function(t,e,n,r,i){for(var a=1-r,o=0;o!==i;++o){var s=e+o;t[s]=t[s]*a+t[n+o]*r}}});var Nh=new RegExp("[\\[\\]\\.:\\/]","g"),Bh="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",Fh=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]"),zh=/(WCOD+)?/.source.replace("WCOD",Bh),Uh=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Gh=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Hh=new RegExp("^"+Fh+zh+Uh+Gh+"$"),Vh=["material","materials","bones"];function kh(t,e,n){var r=n||jh.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}function jh(t,e,n){this.path=e,this.parsedPath=n||jh.parseTrackName(e),this.node=jh.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function Wh(){this.uuid=xn.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var t={};this._indicesByUUID=t;for(var e=0,n=arguments.length;e!==n;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var r=this;this.stats={objects:{get total(){return r._objects.length},get inUse(){return this.total-r.nCachedObjects_}},get bindingsPerObject(){return r._bindings.length}}}function qh(t,e,n){this._mixer=t,this._clip=e,this._localRoot=n||null;for(var r=e.tracks,i=r.length,a=new Array(i),o={endingStart:Ae,endingEnd:Ae},s=0;s!==i;++s){var c=r[s].createInterpolant(null);a[s]=c,c.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=we,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 Xh(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Yh(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function Zh(t,e,n){Ss.call(this,t,e),this.meshPerAttribute=n||1}function Jh(t,e,n,r){this.ray=new Pr(t,e),this.near=n||0,this.far=r||1/0,this.camera=null,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 Qh(t,e){return t.distance-e.distance}function Kh(t,e,n,r){if(!1!==t.visible&&(t.raycast(e,n),!0===r))for(var i=t.children,a=0,o=i.length;a=e){var u=e++,h=t[u];n[h.uuid]=l,t[l]=h,n[c]=u,t[u]=s;for(var d=0,p=i;d!==p;++d){var f=r[d],m=f[u],v=f[l];f[l]=m,f[u]=v}}}this.nCachedObjects_=e},uncache:function(){for(var t=this._objects,e=t.length,n=this.nCachedObjects_,r=this._indicesByUUID,i=this._bindings,a=i.length,o=0,s=arguments.length;o!==s;++o){var c=arguments[o],l=c.uuid,u=r[l];if(void 0!==u)if(delete r[l],u0)for(var c=this._interpolants,l=this._propertyBindings,u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulate(r,s)}else this._updateWeight(t)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var n=this._weightInterpolant;if(null!==n){var r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var n=this._timeScaleInterpolant;if(null!==n)e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t,n=this._clip.duration,r=this.loop,i=this._loopCount,a=r===_e;if(0===t)return-1===i?e:a&&1==(1&i)?n-e:e;if(r===be){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=n)e=n;else{if(!(e<0)){this.time=e;break t}e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=e,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),e>=n||e<0){var o=Math.floor(e/n);e-=n*o,i+=Math.abs(o);var s=this.repetitions-i;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?n:0,this.time=e,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===s){var c=t<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=e;if(a&&1==(1&i))return n-e}return e},_setEndings:function(t,e,n){var r=this._interpolantSettings;n?(r.endingStart=Te,r.endingEnd=Te):(r.endingStart=t?this.zeroSlopeAtStart?Te:Ae:Le,r.endingEnd=e?this.zeroSlopeAtEnd?Te:Ae:Le)},_scheduleFading:function(t,e,n){var r=this._mixer,i=r.time,a=this._weightInterpolant;null===a&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=e,o[1]=i+t,s[1]=n,this}}),Xh.prototype=Object.assign(Object.create(vn.prototype),{constructor:Xh,_bindAction:function(t,e){var n=t._localRoot||this._root,r=t._clip.tracks,i=r.length,a=t._propertyBindings,o=t._interpolants,s=n.uuid,c=this._bindingsByRootAndName,l=c[s];void 0===l&&(l={},c[s]=l);for(var u=0;u!==i;++u){var h=r[u],d=h.name,p=l[d];if(void 0!==p)a[u]=p;else{if(void 0!==(p=a[u])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,s,d));continue}var f=e&&e._propertyBindings[u].binding.parsedPath;++(p=new Ih(jh.create(n,d,f),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(p,s,d),a[u]=p}o[u].resultBuffer=p.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,n=t._clip.uuid,r=this._actionsByClip[n];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,n,e)}for(var i=t._propertyBindings,a=0,o=i.length;a!==o;++a){var s=i[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,n=0,r=e.length;n!==r;++n){var i=e[n];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&ethis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .getParameter() target is now required"),e=new bn),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .clampPoint() target is now required"),e=new bn),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return ed.copy(t).clamp(this.min,this.max).sub(t).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)}});var rd=new Sn,id=new Sn;function ad(t,e){this.start=void 0!==t?t:new Sn,this.end=void 0!==e?e:new Sn}function od(t){ar.call(this),this.material=t,this.render=function(){}}Object.assign(ad.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return void 0===t&&(console.warn("THREE.Line3: .getCenter() target is now required"),t=new Sn),t.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return void 0===t&&(console.warn("THREE.Line3: .delta() target is now required"),t=new Sn),t.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){return void 0===e&&(console.warn("THREE.Line3: .at() target is now required"),e=new Sn),this.delta(e).multiplyScalar(t).add(this.start)},closestPointToPointParameter:function(t,e){rd.subVectors(t,this.start),id.subVectors(this.end,this.start);var n=id.dot(id),r=id.dot(rd)/n;return e&&(r=xn.clamp(r,0,1)),r},closestPointToPoint:function(t,e,n){var r=this.closestPointToPointParameter(t,e);return void 0===n&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),n=new Sn),this.delta(n).multiplyScalar(r).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}}),od.prototype=Object.create(ar.prototype),od.prototype.constructor=od,od.prototype.isImmediateRenderObject=!0;var sd=new Sn,cd=new Sn,ld=new Tn,ud=["a","b","c"];function hd(t,e,n,r){this.object=t,this.size=void 0!==e?e:1;var i=void 0!==n?n:16711680,a=void 0!==r?r:1,o=0,s=this.object.geometry;s&&s.isGeometry?o=3*s.faces.length:s&&s.isBufferGeometry&&(o=s.attributes.normal.count);var c=new _i,l=new hi(2*o*3,3);c.setAttribute("position",l),ac.call(this,c,new Js({color:i,linewidth:a})),this.matrixAutoUpdate=!1,this.update()}hd.prototype=Object.create(ac.prototype),hd.prototype.constructor=hd,hd.prototype.update=function(){this.object.updateMatrixWorld(!0),ld.getNormalMatrix(this.object.matrixWorld);var t=this.object.matrixWorld,e=this.geometry.attributes.position,n=this.object.geometry;if(n&&n.isGeometry)for(var r=n.vertices,i=n.faces,a=0,o=0,s=i.length;o1&&t.multiplyScalar(1/e),this.children[0].material.color.copy(this.material.color)}},xd.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()};var bd=new Sn,wd=new Zr,_d=new Zr;function Md(t,e,n){ar.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;var r=new Ac(e);r.rotateY(.5*Math.PI),this.material=new ni({wireframe:!0,fog:!1}),void 0===this.color&&(this.material.vertexColors=M);var i=r.getAttribute("position"),a=new Float32Array(3*i.count);r.setAttribute("color",new ri(a,3)),this.add(new Gi(r,this.material)),this.update()}function Sd(t,e){this.lightProbe=t,this.size=e;var n={GAMMA_OUTPUT:""},r=new ea({defines:n,uniforms:{sh:{value:this.lightProbe.sh.coefficients},intensity:{value:this.lightProbe.intensity}},vertexShader:["varying vec3 vNormal;","void main() {","\tvNormal = normalize( normalMatrix * normal );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#define RECIPROCAL_PI 0.318309886","vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {","\t// matrix is assumed to be orthogonal","\treturn normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );","}","vec3 linearToOutput( in vec3 a ) {","\t#ifdef GAMMA_OUTPUT","\t\treturn pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );","\t#else","\t\treturn a;","\t#endif","}","// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf","vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {","\t// normal is assumed to have unit length","\tfloat x = normal.x, y = normal.y, z = normal.z;","\t// band 0","\tvec3 result = shCoefficients[ 0 ] * 0.886227;","\t// band 1","\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;","\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;","\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;","\t// band 2","\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;","\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;","\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );","\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;","\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );","\treturn result;","}","uniform vec3 sh[ 9 ]; // sh coefficients","uniform float intensity; // light probe intensity","varying vec3 vNormal;","void main() {","\tvec3 normal = normalize( vNormal );","\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );","\tvec3 irradiance = shGetIrradianceAt( worldNormal, sh );","\tvec3 outgoingLight = RECIPROCAL_PI * irradiance * intensity;","\toutgoingLight = linearToOutput( outgoingLight );","\tgl_FragColor = vec4( outgoingLight, 1.0 );","}"].join("\n")}),i=new ml(1,32,16);Gi.call(this,i,r),this.onBeforeRender()}function Ed(t,e,n,r){t=t||10,e=e||10,n=new Zr(void 0!==n?n:4473924),r=new Zr(void 0!==r?r:8947848);for(var i=e/2,a=t/e,o=t/2,s=[],c=[],l=0,u=0,h=-o;l<=e;l++,h+=a){s.push(-o,0,h,o,0,h),s.push(h,0,-o,h,0,o);var d=l===i?n:r;d.toArray(c,u),u+=3,d.toArray(c,u),u+=3,d.toArray(c,u),u+=3,d.toArray(c,u),u+=3}var p=new _i;p.setAttribute("position",new hi(s,3)),p.setAttribute("color",new hi(c,3));var f=new Js({vertexColors:M});ac.call(this,p,f)}function Ad(t,e,n,r,i,a){t=t||10,e=e||16,n=n||8,r=r||64,i=new Zr(void 0!==i?i:4473924),a=new Zr(void 0!==a?a:8947848);var o,s,c,l,u,h,d,p=[],f=[];for(l=0;l<=e;l++)c=l/e*(2*Math.PI),o=Math.sin(c)*t,s=Math.cos(c)*t,p.push(0,0,0),p.push(o,0,s),d=1&l?i:a,f.push(d.r,d.g,d.b),f.push(d.r,d.g,d.b);for(l=0;l<=n;l++)for(d=1&l?i:a,h=t-t/n*l,u=0;u.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{qd.set(t.z,0,-t.x).normalize();var e=Math.acos(t.y);this.quaternion.setFromAxisAngle(qd,e)}},Xd.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(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()},Xd.prototype.setColor=function(t){this.line.material.color.set(t),this.cone.material.color.set(t)},Xd.prototype.copy=function(t){return ar.prototype.copy.call(this,t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this},Xd.prototype.clone=function(){return(new this.constructor).copy(this)},Yd.prototype=Object.create(ac.prototype),Yd.prototype.constructor=Yd;var Jd=0,Qd=1;function Kd(t){return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."),t}function $d(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 tp(t,e){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new dc(t,e)}function ep(t){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new Us(t)}function np(t,e){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new dc(t,e)}function rp(t){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new sc(t)}function ip(t){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new sc(t)}function ap(t){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new sc(t)}function op(t,e,n){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new Sn(t,e,n)}function sp(t,e){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead."),new ri(t,e).setDynamic(!0)}function cp(t,e){return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."),new ii(t,e)}function lp(t,e){return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."),new ai(t,e)}function up(t,e){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."),new oi(t,e)}function hp(t,e){return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."),new si(t,e)}function dp(t,e){return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."),new ci(t,e)}function pp(t,e){return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."),new li(t,e)}function fp(t,e){return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."),new ui(t,e)}function mp(t,e){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new hi(t,e)}function vp(t,e){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new di(t,e)}function gp(t){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Mu.call(this,t),this.type="catmullrom",this.closed=!0}function yp(t){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Mu.call(this,t),this.type="catmullrom"}function xp(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),Mu.call(this,t),this.type="catmullrom"}function bp(t){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new Yd(t)}function wp(t,e){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Hd(t,e)}function _p(t,e){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new ac(new Ml(t.geometry),new Js({color:void 0!==e?e:16777215}))}function Mp(t,e){return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."),new ac(new yc(t.geometry),new Js({color:void 0!==e?e:16777215}))}function Sp(t){return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."),new cu(t)}function Ep(t){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new hu(t)}mu.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(mu.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},Object.assign(Nu.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 Xi,n=0,r=t.length;n0&&i[i.length-1])&&(6===a[0]||2===a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]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>8&255]+gn[t>>16&255]+gn[t>>24&255]+"-"+gn[255&e]+gn[e>>8&255]+"-"+gn[e>>16&15|64]+gn[e>>24&255]+"-"+gn[63&n|128]+gn[n>>8&255]+"-"+gn[n>>16&255]+gn[n>>24&255]+gn[255&r]+gn[r>>8&255]+gn[r>>16&255]+gn[r>>24&255]).toUpperCase()},clamp:function(t,e,n){return Math.max(e,Math.min(n,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)},lerp:function(t,e,n){return(1-n)*t+n*e},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*xn.DEG2RAD},radToDeg:function(t){return t*xn.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 bn(t,e){this.x=t||0,this.y=e||0}function wn(t,e,n,r){this._x=t||0,this._y=e||0,this._z=n||0,this._w=void 0!==r?r:1}Object.defineProperties(bn.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(bn.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},applyMatrix3:function(t){var e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this},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},cross:function(t){return this.x*t.y-this.y*t.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,n=this.y-t.y;return e*e+n*n},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var n=Math.cos(e),r=Math.sin(e),i=this.x-t.x,a=this.y-t.y;return this.x=i*n-a*r+t.x,this.y=i*r+a*n+t.y,this}}),Object.assign(wn,{slerp:function(t,e,n,r){return n.copy(t).slerp(e,r)},slerpFlat:function(t,e,n,r,i,a,o){var s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],h=i[a+0],d=i[a+1],p=i[a+2],f=i[a+3];if(u!==f||s!==h||c!==d||l!==p){var m=1-o,v=s*h+c*d+l*p+u*f,g=v>=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var x=Math.sqrt(y),b=Math.atan2(x,v*g);m=Math.sin(m*b)/x,o=Math.sin(o*b)/x}var w=o*g;if(s=s*m+h*w,c=c*m+d*w,l=l*m+p*w,u=u*m+f*w,m===1-o){var _=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=_,c*=_,l*=_,u*=_}}t[e]=s,t[e+1]=c,t[e+2]=l,t[e+3]=u}}),Object.defineProperties(wn.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(wn.prototype,{isQuaternion:!0,set:function(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=t._x,r=t._y,i=t._z,a=t.order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),h=s(n/2),d=s(r/2),p=s(i/2);return"XYZ"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u-h*d*p):"YXZ"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u+h*d*p):"ZXY"===a?(this._x=h*l*u-c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u-h*d*p):"ZYX"===a?(this._x=h*l*u-c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u+h*d*p):"YZX"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u-h*d*p):"XZY"===a&&(this._x=h*l*u-c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u+h*d*p),!1!==e&&this._onChangeCallback(),this},setFromAxisAngle:function(t,e){var n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this},setFromRotationMatrix:function(t){var e,n=t.elements,r=n[0],i=n[4],a=n[8],o=n[1],s=n[5],c=n[9],l=n[2],u=n[6],h=n[10],d=r+s+h;return d>0?(e=.5/Math.sqrt(d+1),this._w=.25/e,this._x=(u-c)*e,this._y=(a-l)*e,this._z=(o-i)*e):r>s&&r>h?(e=2*Math.sqrt(1+r-s-h),this._w=(u-c)/e,this._x=.25*e,this._y=(i+o)/e,this._z=(a+l)/e):s>h?(e=2*Math.sqrt(1+s-r-h),this._w=(a-l)/e,this._x=(i+o)/e,this._y=.25*e,this._z=(c+u)/e):(e=2*Math.sqrt(1+h-r-s),this._w=(o-i)/e,this._x=(a+l)/e,this._y=(c+u)/e,this._z=.25*e),this._onChangeCallback(),this},setFromUnitVectors:function(t,e){var n=t.dot(e)+1;return n<1e-6?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()},angleTo:function(t){return 2*Math.acos(Math.abs(xn.clamp(this.dot(t),-1,1)))},rotateTowards:function(t,e){var n=this.angleTo(t);if(0===n)return this;var r=Math.min(1,e/n);return this.slerp(t,r),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var n=t._x,r=t._y,i=t._z,a=t._w,o=e._x,s=e._y,c=e._z,l=e._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var n=this._x,r=this._y,i=this._z,a=this._w,o=a*t._w+n*t._x+r*t._y+i*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;var s=1-o*o;if(s<=Number.EPSILON){var c=1-e;return this._w=c*a+e*this._w,this._x=c*n+e*this._x,this._y=c*r+e*this._y,this._z=c*i+e*this._z,this.normalize(),this._onChangeCallback(),this}var l=Math.sqrt(s),u=Math.atan2(l,o),h=Math.sin((1-e)*u)/l,d=Math.sin(e*u)/l;return this._w=a*h+this._w*d,this._x=n*h+this._x*d,this._y=r*h+this._y*d,this._z=i*h+this._z*d,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(){}});var _n=new Sn,Mn=new wn;function Sn(t,e,n){this.x=t||0,this.y=e||0,this.z=n||0}Object.assign(Sn.prototype,{isVector3:!0,set:function(t,e,n){return this.x=t,this.y=e,this.z=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Mn.setFromEuler(t))},applyAxisAngle:function(t,e){return this.applyQuaternion(Mn.setFromAxisAngle(t,e))},applyMatrix3:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*r,this.y=i[1]*e+i[4]*n+i[7]*r,this.z=i[2]*e+i[5]*n+i[8]*r,this},applyMatrix4:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements,a=1/(i[3]*e+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*e+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*e+i[6]*n+i[10]*r+i[14])*a,this},applyQuaternion:function(t){var e=this.x,n=this.y,r=this.z,i=t.x,a=t.y,o=t.z,s=t.w,c=s*e+a*r-o*n,l=s*n+o*e-i*r,u=s*r+i*n-a*e,h=-i*e-a*n-o*r;return this.x=c*s+h*-i+l*-o-u*-a,this.y=l*s+h*-a+u*-i-c*-o,this.z=u*s+h*-o+c*-a-l*-i,this},project:function(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)},unproject:function(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)},transformDirection:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*r,this.y=i[1]*e+i[5]*n+i[9]*r,this.z=i[2]*e+i[6]*n+i[10]*r,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this},clampLength:function(t,e){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},cross:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)},crossVectors:function(t,e){var n=t.x,r=t.y,i=t.z,a=e.x,o=e.y,s=e.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(t){return _n.copy(this).projectOnVector(t),this.sub(_n)},reflect:function(t){return this.sub(_n.copy(t).multiplyScalar(2*this.dot(t)))},angleTo:function(t){var e=Math.sqrt(this.lengthSq()*t.lengthSq());0===e&&console.error("THREE.Vector3: angleTo() can't handle zero length vectors.");var n=this.dot(t)/e;return Math.acos(xn.clamp(n,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)},setFromSphericalCoords:function(t,e,n){var r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this},setFromCylindrical:function(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)},setFromCylindricalCoords:function(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}});var En,An=new Sn;function Tn(){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.assign(Tn.prototype,{isMatrix3:!0,set:function(t,e,n,r,i,a,o,s,c){var l=this.elements;return l[0]=t,l[1]=r,l[2]=o,l[3]=e,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(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(t){for(var e=0,n=t.count;e2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}},Rn=0;function Pn(t,e,n,r,i,a,o,s,c,l){Object.defineProperty(this,"id",{value:Rn++}),this.uuid=xn.generateUUID(),this.name="",this.image=void 0!==t?t:Pn.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:Pn.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:yt,this.wrapT=void 0!==r?r:yt,this.magFilter=void 0!==i?i:Et,this.minFilter=void 0!==a?a:Lt,this.anisotropy=void 0!==c?c:1,this.format=void 0!==o?o:jt,this.type=void 0!==s?s:Pt,this.offset=new bn(0,0),this.repeat=new bn(1,1),this.center=new bn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Tn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==l?l:Oe,this.version=0,this.onUpdate=null}function Cn(t,e,n,r){this.x=t||0,this.y=e||0,this.z=n||0,this.w=void 0!==r?r:1}function On(t,e,n){this.width=t,this.height=e,this.scissor=new Cn(0,0,t,e),this.scissorTest=!1,this.viewport=new Cn(0,0,t,e),n=n||{},this.texture=new Pn(void 0,void 0,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.image={},this.texture.image.width=t,this.texture.image.height=e,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:Et,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 Dn(t,e,n){On.call(this,t,e,n),this.samples=4}Pn.DEFAULT_IMAGE=void 0,Pn.DEFAULT_MAPPING=lt,Pn.prototype=Object.assign(Object.create(vn.prototype),{constructor:Pn,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(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],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var r=this.image;if(void 0===r.uuid&&(r.uuid=xn.generateUUID()),!e&&void 0===t.images[r.uuid]){var i;if(Array.isArray(r)){i=[];for(var a=0,o=r.length;a1)switch(this.wrapS){case gt:t.x=t.x-Math.floor(t.x);break;case yt:t.x=t.x<0?0:1;break;case xt: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 gt:t.y=t.y-Math.floor(t.y);break;case yt:t.y=t.y<0?0:1;break;case xt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}}),Object.defineProperty(Pn.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.defineProperties(Cn.prototype,{width:{get:function(){return this.z},set:function(t){this.z=t}},height:{get:function(){return this.w},set:function(t){this.w=t}}}),Object.assign(Cn.prototype,{isVector4:!0,set:function(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,n=this.y,r=this.z,i=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*e+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*e+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*e+a[7]*n+a[11]*r+a[15]*i,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,n,r,i,a=t.elements,o=a[0],s=a[4],c=a[8],l=a[1],u=a[5],h=a[9],d=a[2],p=a[6],f=a[10];if(Math.abs(s-l)<.01&&Math.abs(c-d)<.01&&Math.abs(h-p)<.01){if(Math.abs(s+l)<.1&&Math.abs(c+d)<.1&&Math.abs(h+p)<.1&&Math.abs(o+u+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(o+1)/2,v=(u+1)/2,g=(f+1)/2,y=(s+l)/4,x=(c+d)/4,b=(h+p)/4;return m>v&&m>g?m<.01?(n=0,r=.707106781,i=.707106781):(r=y/(n=Math.sqrt(m)),i=x/n):v>g?v<.01?(n=.707106781,r=0,i=.707106781):(n=y/(r=Math.sqrt(v)),i=b/r):g<.01?(n=.707106781,r=.707106781,i=0):(n=x/(i=Math.sqrt(g)),r=b/i),this.set(n,r,i,e),this}var w=Math.sqrt((p-h)*(p-h)+(c-d)*(c-d)+(l-s)*(l-s));return Math.abs(w)<.001&&(w=1),this.x=(p-h)/w,this.y=(c-d)/w,this.z=(l-s)/w,this.w=Math.acos((o+u+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(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this},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}}),On.prototype=Object.assign(Object.create(vn.prototype),{constructor:On,isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.texture.image.width=t,this.texture.image.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"})}}),Dn.prototype=Object.assign(Object.create(On.prototype),{constructor:Dn,isWebGLMultisampleRenderTarget:!0,copy:function(t){return On.prototype.copy.call(this,t),this.samples=t.samples,this}});var In=new Sn,Nn=new Hn,Bn=new Sn(0,0,0),Fn=new Sn(1,1,1),zn=new Sn,Un=new Sn,Gn=new Sn;function Hn(){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.")}Object.assign(Hn.prototype,{isMatrix4:!0,set:function(t,e,n,r,i,a,o,s,c,l,u,h,d,p,f,m){var v=this.elements;return v[0]=t,v[4]=e,v[8]=n,v[12]=r,v[1]=i,v[5]=a,v[9]=o,v[13]=s,v[2]=c,v[6]=l,v[10]=u,v[14]=h,v[3]=d,v[7]=p,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 Hn).fromArray(this.elements)},copy:function(t){var e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this},copyPosition:function(t){var e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this},extractBasis:function(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this},extractRotation:function(t){var e=this.elements,n=t.elements,r=1/In.setFromMatrixColumn(t,0).length(),i=1/In.setFromMatrixColumn(t,1).length(),a=1/In.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*i,e[5]=n[5]*i,e[6]=n[6]*i,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,n=t.x,r=t.y,i=t.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){var h=a*l,d=a*u,p=o*l,f=o*u;e[0]=s*l,e[4]=-s*u,e[8]=c,e[1]=d+p*c,e[5]=h-f*c,e[9]=-o*s,e[2]=f-h*c,e[6]=p+d*c,e[10]=a*s}else if("YXZ"===t.order){var m=s*l,v=s*u,g=c*l,y=c*u;e[0]=m+y*o,e[4]=g*o-v,e[8]=a*c,e[1]=a*u,e[5]=a*l,e[9]=-o,e[2]=v*o-g,e[6]=y+m*o,e[10]=a*s}else if("ZXY"===t.order){m=s*l,v=s*u,g=c*l,y=c*u;e[0]=m-y*o,e[4]=-a*u,e[8]=g+v*o,e[1]=v+g*o,e[5]=a*l,e[9]=y-m*o,e[2]=-a*c,e[6]=o,e[10]=a*s}else if("ZYX"===t.order){h=a*l,d=a*u,p=o*l,f=o*u;e[0]=s*l,e[4]=p*c-d,e[8]=h*c+f,e[1]=s*u,e[5]=f*c+h,e[9]=d*c-p,e[2]=-c,e[6]=o*s,e[10]=a*s}else if("YZX"===t.order){var x=a*s,b=a*c,w=o*s,_=o*c;e[0]=s*l,e[4]=_-x*u,e[8]=w*u+b,e[1]=u,e[5]=a*l,e[9]=-o*l,e[2]=-c*l,e[6]=b*u+w,e[10]=x-_*u}else if("XZY"===t.order){x=a*s,b=a*c,w=o*s,_=o*c;e[0]=s*l,e[4]=-u,e[8]=c*l,e[1]=x*u+_,e[5]=a*l,e[9]=b*u-w,e[2]=w*u-b,e[6]=o*l,e[10]=_*u+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){return this.compose(Bn,t,Fn)},lookAt:function(t,e,n){var r=this.elements;return Gn.subVectors(t,e),0===Gn.lengthSq()&&(Gn.z=1),Gn.normalize(),zn.crossVectors(n,Gn),0===zn.lengthSq()&&(1===Math.abs(n.z)?Gn.x+=1e-4:Gn.z+=1e-4,Gn.normalize(),zn.crossVectors(n,Gn)),zn.normalize(),Un.crossVectors(Gn,zn),r[0]=zn.x,r[4]=Un.x,r[8]=Gn.x,r[1]=zn.y,r[5]=Un.y,r[9]=Gn.y,r[2]=zn.z,r[6]=Un.z,r[10]=Gn.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var n=t.elements,r=e.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],v=n[14],g=n[3],y=n[7],x=n[11],b=n[15],w=r[0],_=r[4],M=r[8],S=r[12],E=r[1],A=r[5],T=r[9],L=r[13],R=r[2],P=r[6],C=r[10],O=r[14],D=r[3],I=r[7],N=r[11],B=r[15];return i[0]=a*w+o*E+s*R+c*D,i[4]=a*_+o*A+s*P+c*I,i[8]=a*M+o*T+s*C+c*N,i[12]=a*S+o*L+s*O+c*B,i[1]=l*w+u*E+h*R+d*D,i[5]=l*_+u*A+h*P+d*I,i[9]=l*M+u*T+h*C+d*N,i[13]=l*S+u*L+h*O+d*B,i[2]=p*w+f*E+m*R+v*D,i[6]=p*_+f*A+m*P+v*I,i[10]=p*M+f*T+m*C+v*N,i[14]=p*S+f*L+m*O+v*B,i[3]=g*w+y*E+x*R+b*D,i[7]=g*_+y*A+x*P+b*I,i[11]=g*M+y*T+x*C+b*N,i[15]=g*S+y*L+x*O+b*B,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(t){for(var e=0,n=t.count;e1){for(var e=0;e1){for(var e=0;e0){r.children=[];for(s=0;s0&&(n.geometries=h),d.length>0&&(n.materials=d),p.length>0&&(n.textures=p),f.length>0&&(n.images=f),o.length>0&&(n.shapes=o)}return n.object=r,n;function m(t){var e=[];for(var n in t){var r=t[n];delete r.metadata,e.push(r)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var n=0;ns)return!1}return!0}Object.assign(xr.prototype,{isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,c=t.length;si&&(i=l),u>a&&(a=u),h>o&&(o=h)}return this.min.set(e,n,r),this.max.set(i,a,o),this},setFromBufferAttribute:function(t){for(var e=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,c=t.count;si&&(i=l),u>a&&(a=u),h>o&&(o=h)}return this.min.set(e,n,r),this.max.set(i,a,o),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,n=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new Sn),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:function(t){return this.clampPoint(t.center,cr),cr.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(t){if(this.isEmpty())return!1;this.getCenter(mr),vr.subVectors(this.max,mr),lr.subVectors(t.a,mr),ur.subVectors(t.b,mr),hr.subVectors(t.c,mr),dr.subVectors(ur,lr),pr.subVectors(hr,ur),fr.subVectors(lr,hr);var e=[0,-dr.z,dr.y,0,-pr.z,pr.y,0,-fr.z,fr.y,dr.z,0,-dr.x,pr.z,0,-pr.x,fr.z,0,-fr.x,-dr.y,dr.x,0,-pr.y,pr.x,0,-fr.y,fr.x,0];return!!br(e,lr,ur,hr,vr)&&(!!br(e=[1,0,0,0,1,0,0,0,1],lr,ur,hr,vr)&&(gr.crossVectors(dr,pr),br(e=[gr.x,gr.y,gr.z],lr,ur,hr,vr)))},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new Sn),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return cr.copy(t).clamp(this.min,this.max).sub(t).length()},getBoundingSphere:function(t){return void 0===t&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=.5*this.getSize(cr).length(),t},intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(t){return this.isEmpty()?this:(sr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),sr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),sr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),sr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),sr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),sr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),sr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),sr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(sr),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)}});var wr=new xr;function _r(t,e){this.center=void 0!==t?t:new Sn,this.radius=void 0!==e?e:0}Object.assign(_r.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(t,e){var n=this.center;void 0!==e?n.copy(e):wr.setFromPoints(t).getCenter(n);for(var r=0,i=0,a=t.length;ithis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e},getBoundingBox:function(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new xr),t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}});var Mr=new Sn,Sr=new Sn,Er=new Sn,Ar=new Sn,Tr=new Sn,Lr=new Sn,Rr=new Sn;function Pr(t,e){this.origin=void 0!==t?t:new Sn,this.direction=void 0!==e?e:new Sn}Object.assign(Pr.prototype,{set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return void 0===e&&(console.warn("THREE.Ray: .at() target is now required"),e=new Sn),e.copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(t){return this.origin.copy(this.at(t,Mr)),this},closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new Sn),e.subVectors(t,this.origin);var n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(t){var e=Mr.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Mr.copy(this.direction).multiplyScalar(e).add(this.origin),Mr.distanceToSquared(t))},distanceSqToSegment:function(t,e,n,r){Sr.copy(t).add(e).multiplyScalar(.5),Er.copy(e).sub(t).normalize(),Ar.copy(this.origin).sub(Sr);var i,a,o,s,c=.5*t.distanceTo(e),l=-this.direction.dot(Er),u=Ar.dot(this.direction),h=-Ar.dot(Er),d=Ar.lengthSq(),p=Math.abs(1-l*l);if(p>0)if(a=l*u-h,s=c*p,(i=l*h-u)>=0)if(a>=-s)if(a<=s){var f=1/p;o=(i*=f)*(i+l*(a*=f)+2*u)+a*(l*i+a+2*h)+d}else a=c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;else a=-c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;else a<=-s?o=-(i=Math.max(0,-(-l*c+u)))*i+(a=i>0?-c:Math.min(Math.max(-c,-h),c))*(a+2*h)+d:a<=s?(i=0,o=(a=Math.min(Math.max(-c,-h),c))*(a+2*h)+d):o=-(i=Math.max(0,-(l*c+u)))*i+(a=i>0?c:Math.min(Math.max(-c,-h),c))*(a+2*h)+d;else a=l>0?-c:c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;return n&&n.copy(this.direction).multiplyScalar(i).add(this.origin),r&&r.copy(Er).multiplyScalar(a).add(Sr),o},intersectSphere:function(t,e){Mr.subVectors(t.center,this.origin);var n=Mr.dot(this.direction),r=Mr.dot(Mr)-n*n,i=t.radius*t.radius;if(r>i)return null;var a=Math.sqrt(i-r),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,e):this.at(o,e)},intersectsSphere:function(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null},intersectPlane:function(t,e){var n=this.distanceToPlane(t);return null===n?null:this.at(n,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,h=this.origin;return c>=0?(n=(t.min.x-h.x)*c,r=(t.max.x-h.x)*c):(n=(t.max.x-h.x)*c,r=(t.min.x-h.x)*c),l>=0?(i=(t.min.y-h.y)*l,a=(t.max.y-h.y)*l):(i=(t.max.y-h.y)*l,a=(t.min.y-h.y)*l),n>a||i>r?null:((i>n||n!=n)&&(n=i),(a=0?(o=(t.min.z-h.z)*u,s=(t.max.z-h.z)*u):(o=(t.max.z-h.z)*u,s=(t.min.z-h.z)*u),n>s||o>r?null:((o>n||n!=n)&&(n=o),(s=0?n:r,e)))},intersectsBox:function(t){return null!==this.intersectBox(t,Mr)},intersectTriangle:function(t,e,n,r,i){Tr.subVectors(e,t),Lr.subVectors(n,t),Rr.crossVectors(Tr,Lr);var a,o=this.direction.dot(Rr);if(o>0){if(r)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Ar.subVectors(this.origin,t);var s=a*this.direction.dot(Lr.crossVectors(Ar,Lr));if(s<0)return null;var c=a*this.direction.dot(Tr.cross(Ar));if(c<0)return null;if(s+c>o)return null;var l=-a*Ar.dot(Rr);return l<0?null:this.at(l/o,i)},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)}});var Cr=new Sn,Or=new Sn,Dr=new Tn;function Ir(t,e){this.normal=void 0!==t?t:new Sn(1,0,0),this.constant=void 0!==e?e:0}Object.assign(Ir.prototype,{isPlane:!0,set:function(t,e){return this.normal.copy(t),this.constant=e,this},setComponents:function(t,e,n,r){return this.normal.set(t,e,n),this.constant=r,this},setFromNormalAndCoplanarPoint:function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},setFromCoplanarPoints:function(t,e,n){var r=Cr.subVectors(n,e).cross(Or.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,e){return void 0===e&&(console.warn("THREE.Plane: .projectPoint() target is now required"),e=new Sn),e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)},intersectLine:function(t,e){void 0===e&&(console.warn("THREE.Plane: .intersectLine() target is now required"),e=new Sn);var n=t.delta(Cr),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(t.start)?e.copy(t.start):void 0;var i=-(t.start.dot(this.normal)+this.constant)/r;return i<0||i>1?void 0:e.copy(n).multiplyScalar(i).add(t.start)},intersectsLine:function(t){var e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new Sn),t.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(t,e){var n=e||Dr.getNormalMatrix(t),r=this.coplanarPoint(Cr).applyMatrix4(t),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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}});var Nr=new Sn,Br=new Sn,Fr=new Sn,zr=new Sn,Ur=new Sn,Gr=new Sn,Hr=new Sn,Vr=new Sn,kr=new Sn,jr=new Sn;function Wr(t,e,n){this.a=void 0!==t?t:new Sn,this.b=void 0!==e?e:new Sn,this.c=void 0!==n?n:new Sn}Object.assign(Wr,{getNormal:function(t,e,n,r){void 0===r&&(console.warn("THREE.Triangle: .getNormal() target is now required"),r=new Sn),r.subVectors(n,e),Nr.subVectors(t,e),r.cross(Nr);var i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)},getBarycoord:function(t,e,n,r,i){Nr.subVectors(r,e),Br.subVectors(n,e),Fr.subVectors(t,e);var a=Nr.dot(Nr),o=Nr.dot(Br),s=Nr.dot(Fr),c=Br.dot(Br),l=Br.dot(Fr),u=a*c-o*o;if(void 0===i&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),i=new Sn),0===u)return i.set(-2,-1,-1);var h=1/u,d=(c*s-o*l)*h,p=(a*l-o*s)*h;return i.set(1-d-p,p,d)},containsPoint:function(t,e,n,r){return Wr.getBarycoord(t,e,n,r,zr),zr.x>=0&&zr.y>=0&&zr.x+zr.y<=1},getUV:function(t,e,n,r,i,a,o,s){return this.getBarycoord(t,e,n,r,zr),s.set(0,0),s.addScaledVector(i,zr.x),s.addScaledVector(a,zr.y),s.addScaledVector(o,zr.z),s},isFrontFacing:function(t,e,n,r){return Nr.subVectors(n,e),Br.subVectors(t,e),Nr.cross(Br).dot(r)<0}}),Object.assign(Wr.prototype,{set:function(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this},setFromPointsAndIndices:function(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},getArea:function(){return Nr.subVectors(this.c,this.b),Br.subVectors(this.a,this.b),.5*Nr.cross(Br).length()},getMidpoint:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new Sn),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(t){return Wr.getNormal(this.a,this.b,this.c,t)},getPlane:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new Ir),t.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(t,e){return Wr.getBarycoord(t,this.a,this.b,this.c,e)},getUV:function(t,e,n,r,i){return Wr.getUV(t,this.a,this.b,this.c,e,n,r,i)},containsPoint:function(t){return Wr.containsPoint(t,this.a,this.b,this.c)},isFrontFacing:function(t){return Wr.isFrontFacing(this.a,this.b,this.c,t)},intersectsBox:function(t){return t.intersectsTriangle(this)},closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),e=new Sn);var n,r,i=this.a,a=this.b,o=this.c;Ur.subVectors(a,i),Gr.subVectors(o,i),Vr.subVectors(t,i);var s=Ur.dot(Vr),c=Gr.dot(Vr);if(s<=0&&c<=0)return e.copy(i);kr.subVectors(t,a);var l=Ur.dot(kr),u=Gr.dot(kr);if(l>=0&&u<=l)return e.copy(a);var h=s*u-l*c;if(h<=0&&s>=0&&l<=0)return n=s/(s-l),e.copy(i).addScaledVector(Ur,n);jr.subVectors(t,o);var d=Ur.dot(jr),p=Gr.dot(jr);if(p>=0&&d<=p)return e.copy(o);var f=d*c-s*p;if(f<=0&&c>=0&&p<=0)return r=c/(c-p),e.copy(i).addScaledVector(Gr,r);var m=l*p-d*u;if(m<=0&&u-l>=0&&d-p>=0)return Hr.subVectors(o,a),r=(u-l)/(u-l+(d-p)),e.copy(a).addScaledVector(Hr,r);var v=1/(m+f+h);return n=f*v,r=h*v,e.copy(i).addScaledVector(Ur,n).addScaledVector(Gr,r)},equals:function(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}});var qr={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},Xr={h:0,s:0,l:0},Yr={h:0,s:0,l:0};function Zr(t,e,n){return void 0===e&&void 0===n?this.set(t):this.setRGB(t,e,n)}function Jr(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}function Qr(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Kr(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}function $r(t,e,n,r,i,a){this.a=t,this.b=e,this.c=n,this.normal=r&&r.isVector3?r:new Sn,this.vertexNormals=Array.isArray(r)?r:[],this.color=i&&i.isColor?i:new Zr,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=void 0!==a?a:0}Object.assign(Zr.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(t,e,n){if(t=xn.euclideanModulo(t,1),e=xn.clamp(e,0,1),n=xn.clamp(n,0,1),0===e)this.r=this.g=this.b=n;else{var r=n<=.5?n*(1+e):n+e-n*e,i=2*n-r;this.r=Jr(i,r,t+1/3),this.g=Jr(i,r,t),this.b=Jr(i,r,t-1/3)}return this},setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var n;if(n=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var r,i=n[1],a=n[2];switch(i){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,e(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,e(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return e(r[5]),this.setHSL(o,s,c)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(t)){var l=n[1],u=l.length;if(3===u)return this.r=parseInt(l.charAt(0)+l.charAt(0),16)/255,this.g=parseInt(l.charAt(1)+l.charAt(1),16)/255,this.b=parseInt(l.charAt(2)+l.charAt(2),16)/255,this;if(6===u)return this.r=parseInt(l.charAt(0)+l.charAt(1),16)/255,this.g=parseInt(l.charAt(2)+l.charAt(3),16)/255,this.b=parseInt(l.charAt(4)+l.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this},setColorName:function(t){var e=qr[t];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),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(t){return this.copyGammaToLinear(this,t),this},convertLinearToGamma:function(t){return this.copyLinearToGamma(this,t),this},copySRGBToLinear:function(t){return this.r=Qr(t.r),this.g=Qr(t.g),this.b=Qr(t.b),this},copyLinearToSRGB:function(t){return this.r=Kr(t.r),this.g=Kr(t.g),this.b=Kr(t.b),this},convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});var e,n,r=this.r,i=this.g,a=this.b,o=Math.max(r,i,a),s=Math.min(r,i,a),c=(s+o)/2;if(s===o)e=0,n=0;else{var l=o-s;switch(n=c<=.5?l/(o+s):l/(2-o-s),o){case r:e=(i-a)/l+(ie&&(e=t[n]);return e}ei.prototype=Object.assign(Object.create(vn.prototype),{constructor:ei,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 r=this[e];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=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===x;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 r(t){var e=[];for(var n in t){var r=t[n];delete r.metadata,e.push(r)}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.sheen&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&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.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.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.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),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.normalMapType=this.normalMapType,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,n.refractionRatio=this.refractionRatio,void 0!==this.combine&&(n.combine=this.combine),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity)),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!==E&&(n.blending=this.blending),!0===this.flatShading&&(n.flatShading=this.flatShading),this.side!==v&&(n.side=this.side),this.vertexColors!==w&&(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,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&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.morphNormals&&(n.morphNormals=!0),!0===this.skinning&&(n.skinning=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),e){var i=r(t.textures),a=r(t.images);i.length>0&&(n.textures=i),a.length>0&&(n.images=a)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexTangents=t.vertexTangents,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.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;var e=t.clippingPlanes,n=null;if(null!==e){var r=e.length;n=new Array(r);for(var i=0;i!==r;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,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.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),ni.prototype=Object.create(ei.prototype),ni.prototype.constructor=ni,ni.prototype.isMeshBasicMaterial=!0,ni.prototype.copy=function(t){return ei.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},Object.defineProperty(ri.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(ri.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.itemSize,n*=e.itemSize;for(var r=0,i=this.itemSize;r0,o=i[1]&&i[1].length>0,s=t.morphTargets,c=s.length;if(c>0){e=[];for(var l=0;l0){u=[];for(l=0;l0&&0===n.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(l=0;l65535?ui:ci)(t,1):this.index=t},getAttribute:function(t){return this.attributes[t]},setAttribute:function(t,e){return this.attributes[t]=e,this},deleteAttribute: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 Tn).getNormalMatrix(t).applyToBufferAttribute(n),n.needsUpdate=!0);var r=this.attributes.tangent;void 0!==r&&((new Tn).getNormalMatrix(t).applyToBufferAttribute(r),r.needsUpdate=!0);return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(t){return vi.makeRotationX(t),this.applyMatrix(vi),this},rotateY:function(t){return vi.makeRotationY(t),this.applyMatrix(vi),this},rotateZ:function(t){return vi.makeRotationZ(t),this.applyMatrix(vi),this},translate:function(t,e,n){return vi.makeTranslation(t,e,n),this.applyMatrix(vi),this},scale:function(t,e,n){return vi.makeScale(t,e,n),this.applyMatrix(vi),this},lookAt:function(t){return gi.lookAt(t),gi.updateMatrix(),this.applyMatrix(gi.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(yi).negate(),this.translate(yi.x,yi.y,yi.z),this},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var n=new hi(3*e.vertices.length,3),r=new hi(3*e.colors.length,3);if(this.setAttribute("position",n.copyVector3sArray(e.vertices)),this.setAttribute("color",r.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var i=new hi(e.lineDistances.length,1);this.setAttribute("lineDistance",i.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},setFromPoints:function(t){for(var e=[],n=0,r=t.length;n0){var n=new Float32Array(3*t.normals.length);this.setAttribute("normal",new ri(n,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var r=new Float32Array(3*t.colors.length);this.setAttribute("color",new ri(r,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.setAttribute("uv",new ri(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var a=new Float32Array(2*t.uvs2.length);this.setAttribute("uv2",new ri(a,2).copyVector2sArray(t.uvs2))}for(var o in this.groups=t.groups,t.morphTargets){for(var s=[],c=t.morphTargets[o],l=0,u=c.length;l0){var p=new hi(4*t.skinIndices.length,4);this.setAttribute("skinIndex",p.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var f=new hi(4*t.skinWeights.length,4);this.setAttribute("skinWeight",f.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new xr);var t=this.attributes.position,e=this.morphAttributes.position;if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(var n=0,r=e.length;n0&&(t.userData=this.userData),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 r=this.index;null!==r&&(t.data.index={type:r.array.constructor.name,array:Array.prototype.slice.call(r.array)});var i=this.attributes;for(var n in i){var a=(d=i[n]).toJSON();""!==d.name&&(a.name=d.name),t.data.attributes[n]=a}var o={},s=!1;for(var n in this.morphAttributes){for(var c=this.morphAttributes[n],l=[],u=0,h=c.length;u0&&(o[n]=l,s=!0)}s&&(t.data.morphAttributes=o);var p=this.groups;p.length>0&&(t.data.groups=JSON.parse(JSON.stringify(p)));var f=this.boundingSphere;return null!==f&&(t.data.boundingSphere={center:f.center.toArray(),radius:f.radius}),t},clone:function(){return(new _i).copy(this)},copy:function(t){var e,n,r;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var i=t.index;null!==i&&this.setIndex(i.clone());var a=t.attributes;for(e in a){var o=a[e];this.setAttribute(e,o.clone())}var s=t.morphAttributes;for(e in s){var c=[],l=s[e];for(n=0,r=l.length;nn.far?null:{distance:c,point:Ui.clone(),object:t}}function Vi(t,e,n,r,i,a,o,s,c,l,u){Ai.fromBufferAttribute(i,c),Ti.fromBufferAttribute(i,l),Li.fromBufferAttribute(i,u);var h=t.morphTargetInfluences;if(e.morphTargets&&a&&h){Oi.set(0,0,0),Di.set(0,0,0),Ii.set(0,0,0);for(var d=0,p=a.length;d0){var o=i[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=o.length;t0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(t,e){var n,r=this.geometry,i=this.material,a=this.matrixWorld;if(void 0!==i&&(null===r.boundingSphere&&r.computeBoundingSphere(),Ei.copy(r.boundingSphere),Ei.applyMatrix4(a),!1!==t.ray.intersectsSphere(Ei)&&(Mi.getInverse(a),Si.copy(t.ray).applyMatrix4(Mi),null===r.boundingBox||!1!==Si.intersectsBox(r.boundingBox))))if(this.drawMode===Re){if(r.isBufferGeometry){var o,s,c,l,u,h,d,p,f,m=r.index,v=r.attributes.position,g=r.morphAttributes.position,y=r.attributes.uv,x=r.attributes.uv2,b=r.groups,w=r.drawRange;if(null!==m)if(Array.isArray(i))for(l=0,h=b.length;l0&&(E=R);for(var P=0,C=L.length;P0)for(l=0;l0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,n;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,n,r,i;for(n=0,r=this.faces.length;n=0;n--){var f=d[n];for(this.faces.splice(f,1),o=0,s=this.faceVertexUvs.length;o0,v=p.vertexNormals.length>0,g=1!==p.color.r||1!==p.color.g||1!==p.color.b,y=p.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),o.push(x),o.push(p.a,p.b,p.c),o.push(p.materialIndex),f){var b=this.faceVertexUvs[0][i];o.push(A(b[0]),A(b[1]),A(b[2]))}if(m&&o.push(S(p.normal)),v){var w=p.vertexNormals;o.push(S(w[0]),S(w[1]),S(w[2]))}if(g&&o.push(E(p.color)),y){var _=p.vertexColors;o.push(E(_[0]),E(_[1]),E(_[2]))}}function M(t,e,n){return n?t|1<0&&(t.data.colors=l),h.length>0&&(t.data.uvs=[h]),t.data.faces=o,t},clone:function(){return(new Xi).copy(this)},copy:function(t){var e,n,r,i,a,o;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var s=t.vertices;for(e=0,n=s.length;e0?1:-1,l.push(R.x,R.y,R.z),u.push(y/m),u.push(1-x/v),T+=1}}for(x=0;x0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;var i={};for(var a in this.extensions)!0===this.extensions[a]&&(i[a]=!0);return Object.keys(i).length>0&&(e.extensions=i),e},na.prototype=Object.assign(Object.create(ar.prototype),{constructor:na,isCamera:!0,copy:function(t,e){return ar.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new Sn),this.updateMatrixWorld(!0);var e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()},updateMatrixWorld:function(t){ar.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),ra.prototype=Object.assign(Object.create(na.prototype),{constructor:ra,isPerspectiveCamera:!0,copy:function(t,e){return na.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*xn.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){var t=Math.tan(.5*xn.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*xn.RAD2DEG*Math.atan(Math.tan(.5*xn.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,r,i,a){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=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=this.near,e=t*Math.tan(.5*xn.DEG2RAD*this.fov)/this.zoom,n=2*e,r=this.aspect*n,i=-.5*r,a=this.view;if(null!==this.view&&this.view.enabled){var o=a.fullWidth,s=a.fullHeight;i+=a.offsetX*r/o,e-=a.offsetY*n/s,r*=a.width/o,n*=a.height/s}var c=this.filmOffset;0!==c&&(i+=t*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,e,e-n,t,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(t){var e=ar.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}});var ia=90,aa=1;function oa(t,e,n,r){ar.call(this),this.type="CubeCamera";var i=new ra(ia,aa,t,e);i.up.set(0,-1,0),i.lookAt(new Sn(1,0,0)),this.add(i);var a=new ra(ia,aa,t,e);a.up.set(0,-1,0),a.lookAt(new Sn(-1,0,0)),this.add(a);var o=new ra(ia,aa,t,e);o.up.set(0,0,1),o.lookAt(new Sn(0,1,0)),this.add(o);var s=new ra(ia,aa,t,e);s.up.set(0,0,-1),s.lookAt(new Sn(0,-1,0)),this.add(s);var c=new ra(ia,aa,t,e);c.up.set(0,-1,0),c.lookAt(new Sn(0,0,1)),this.add(c);var l=new ra(ia,aa,t,e);l.up.set(0,-1,0),l.lookAt(new Sn(0,0,-1)),this.add(l),r=r||{format:kt,magFilter:Et,minFilter:Et},this.renderTarget=new sa(n,n,r),this.renderTarget.texture.name="CubeCamera",this.update=function(t,e){null===this.parent&&this.updateMatrixWorld();var n=t.getRenderTarget(),r=this.renderTarget,u=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,t.setRenderTarget(r,0),t.render(e,i),t.setRenderTarget(r,1),t.render(e,a),t.setRenderTarget(r,2),t.render(e,o),t.setRenderTarget(r,3),t.render(e,s),t.setRenderTarget(r,4),t.render(e,c),r.texture.generateMipmaps=u,t.setRenderTarget(r,5),t.render(e,l),t.setRenderTarget(n)},this.clear=function(t,e,n,r){for(var i=t.getRenderTarget(),a=this.renderTarget,o=0;o<6;o++)t.setRenderTarget(a,o),t.clear(e,n,r);t.setRenderTarget(i)}}function sa(t,e,n){On.call(this,t,e,n)}function ca(t,e,n,r,i,a,o,s,c,l,u,h){Pn.call(this,null,a,o,s,c,l,r,i,u,h),this.image={data:t||null,width:e||1,height:n||1},this.magFilter=void 0!==c?c:bt,this.minFilter=void 0!==l?l:bt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}oa.prototype=Object.create(ar.prototype),oa.prototype.constructor=oa,sa.prototype=Object.create(On.prototype),sa.prototype.constructor=sa,sa.prototype.isWebGLRenderTargetCube=!0,sa.prototype.fromEquirectangularTexture=function(t,e){this.texture.type=e.type,this.texture.format=e.format,this.texture.encoding=e.encoding;var n=new or,r={uniforms:{tEquirect:{value:null}},vertexShader:["varying vec3 vWorldDirection;","vec3 transformDirection( in vec3 dir, in mat4 matrix ) {","\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );","}","void main() {","\tvWorldDirection = transformDirection( position, modelMatrix );","\t#include ","\t#include ","}"].join("\n"),fragmentShader:["uniform sampler2D tEquirect;","varying vec3 vWorldDirection;","#define RECIPROCAL_PI 0.31830988618","#define RECIPROCAL_PI2 0.15915494","void main() {","\tvec3 direction = normalize( vWorldDirection );","\tvec2 sampleUV;","\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;","\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;","\tgl_FragColor = texture2D( tEquirect, sampleUV );","}"].join("\n")},i=new ea({type:"CubemapFromEquirect",uniforms:Ji(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:g,blending:S});i.uniforms.tEquirect.value=e;var a=new Gi(new Zi(5,5,5),i);n.add(a);var o=new oa(1,10,1);return o.renderTarget=this,o.renderTarget.texture.name="CubeCameraTexture",o.update(t,n),a.geometry.dispose(),a.material.dispose(),this},ca.prototype=Object.create(Pn.prototype),ca.prototype.constructor=ca,ca.prototype.isDataTexture=!0;var la=new _r,ua=new Sn;function ha(t,e,n,r,i,a){this.planes=[void 0!==t?t:new Ir,void 0!==e?e:new Ir,void 0!==n?n:new Ir,void 0!==r?r:new Ir,void 0!==i?i:new Ir,void 0!==a?a:new Ir]}Object.assign(ha.prototype,{set:function(t,e,n,r,i,a){var o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,n=0;n<6;n++)e[n].copy(t.planes[n]);return this},setFromMatrix:function(t){var e=this.planes,n=t.elements,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7],h=n[8],d=n[9],p=n[10],f=n[11],m=n[12],v=n[13],g=n[14],y=n[15];return e[0].setComponents(o-r,u-s,f-h,y-m).normalize(),e[1].setComponents(o+r,u+s,f+h,y+m).normalize(),e[2].setComponents(o+i,u+c,f+d,y+v).normalize(),e[3].setComponents(o-i,u-c,f-d,y-v).normalize(),e[4].setComponents(o-a,u-l,f-p,y-g).normalize(),e[5].setComponents(o+a,u+l,f+p,y+g).normalize(),this},intersectsObject:function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),la.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(la)},intersectsSprite:function(t){return la.center.set(0,0,0),la.radius=.7071067811865476,la.applyMatrix4(t.matrixWorld),this.intersectsSphere(la)},intersectsSphere:function(t){for(var e=this.planes,n=t.center,r=-t.radius,i=0;i<6;i++){if(e[i].distanceToPoint(n)0?t.max.x:t.min.x,ua.y=r.normal.y>0?t.max.y:t.min.y,ua.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(ua)<0)return!1}return!0},containsPoint:function(t){for(var e=this.planes,n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}});var da={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",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",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",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#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\ttransformedNormal = mat3( instanceMatrix ) * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = normalMatrix * objectTangent;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_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",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, roughness );\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",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) { \n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",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",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",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif",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 = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\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\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\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",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",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)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = saturate( clearcoat );\tmaterial.clearcoatRoughness = clamp( clearcoatRoughness, 0.04, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 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#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? 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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? 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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? 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 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",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",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",normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, normalScale, normalMap );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec2 normalScale, in sampler2D normalMap ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy *= normalScale;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tbool frontFacing = dot( cross( S, T ), N ) > 0.0;\n\t\t\tmapN.xy *= ( float( frontFacing ) * 2.0 - 1.0 );\n\t\t#else\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, clearcoatNormal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = clearcoatNormalScale * mapN.xy;\n\t\tclearcoatNormal = normalize( vTBN * mapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatNormalScale, clearcoatNormalMap );\n\t#endif\n#endif",clearcoat_normalmap_pars_fragment:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 encodeHalfRGBA ( vec2 v ) {\n\tvec4 encoded = vec4( 0.0 );\n\tconst vec2 offset = vec2( 1.0 / 255.0, 0.0 );\n\tencoded.xy = vec2( v.x, fract( v.x * 255.0 ) );\n\tencoded.xy = encoded.xy - ( encoded.yy * offset );\n\tencoded.zw = vec2( v.y, fract( v.y * 255.0 ) );\n\tencoded.zw = encoded.zw - ( encoded.ww * offset );\n\treturn encoded;\n}\nvec2 decodeHalfRGBA( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn decodeHalfRGBA( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat 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 ) + 0.5 ) * texelSize;\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\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat 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#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? 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}",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 highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",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",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",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\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\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 = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}",shadow_vert:"#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"},pa={common:{diffuse:{value:new Zr(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Tn},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},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 bn(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 Zr(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{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 Zr(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Tn}},sprite:{diffuse:{value:new Zr(15658734)},opacity:{value:1},center:{value:new bn(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Tn}}},fa={basic:{uniforms:Qi([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.fog]),vertexShader:da.meshbasic_vert,fragmentShader:da.meshbasic_frag},lambert:{uniforms:Qi([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.fog,pa.lights,{emissive:{value:new Zr(0)}}]),vertexShader:da.meshlambert_vert,fragmentShader:da.meshlambert_frag},phong:{uniforms:Qi([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.gradientmap,pa.fog,pa.lights,{emissive:{value:new Zr(0)},specular:{value:new Zr(1118481)},shininess:{value:30}}]),vertexShader:da.meshphong_vert,fragmentShader:da.meshphong_frag},standard:{uniforms:Qi([pa.common,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.roughnessmap,pa.metalnessmap,pa.fog,pa.lights,{emissive:{value:new Zr(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:da.meshphysical_vert,fragmentShader:da.meshphysical_frag},matcap:{uniforms:Qi([pa.common,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.fog,{matcap:{value:null}}]),vertexShader:da.meshmatcap_vert,fragmentShader:da.meshmatcap_frag},points:{uniforms:Qi([pa.points,pa.fog]),vertexShader:da.points_vert,fragmentShader:da.points_frag},dashed:{uniforms:Qi([pa.common,pa.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:da.linedashed_vert,fragmentShader:da.linedashed_frag},depth:{uniforms:Qi([pa.common,pa.displacementmap]),vertexShader:da.depth_vert,fragmentShader:da.depth_frag},normal:{uniforms:Qi([pa.common,pa.bumpmap,pa.normalmap,pa.displacementmap,{opacity:{value:1}}]),vertexShader:da.normal_vert,fragmentShader:da.normal_frag},sprite:{uniforms:Qi([pa.sprite,pa.fog]),vertexShader:da.sprite_vert,fragmentShader:da.sprite_frag},background:{uniforms:{uvTransform:{value:new Tn},t2D:{value:null}},vertexShader:da.background_vert,fragmentShader:da.background_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:da.cube_vert,fragmentShader:da.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:da.equirect_vert,fragmentShader:da.equirect_frag},distanceRGBA:{uniforms:Qi([pa.common,pa.displacementmap,{referencePosition:{value:new Sn},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:da.distanceRGBA_vert,fragmentShader:da.distanceRGBA_frag},shadow:{uniforms:Qi([pa.lights,pa.fog,{color:{value:new Zr(0)},opacity:{value:1}}]),vertexShader:da.shadow_vert,fragmentShader:da.shadow_frag}};function ma(){var t=null,e=!1,n=null;function r(i,a){!1!==e&&(n(i,a),t.requestAnimationFrame(r))}return{start:function(){!0!==e&&null!==n&&(t.requestAnimationFrame(r),e=!0)},stop:function(){e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function va(t){var e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);var r=e.get(n);r&&(t.deleteBuffer(r.buffer),e.delete(n))},update:function(n,r){n.isInterleavedBufferAttribute&&(n=n.data);var i=e.get(n);void 0===i?e.set(n,function(e,n){var r=e.array,i=e.usage,a=t.createBuffer();t.bindBuffer(n,a),t.bufferData(n,r,i),e.onUploadCallback();var o=5126;return r instanceof Float32Array?o=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?o=5123:r instanceof Int16Array?o=5122:r instanceof Uint32Array?o=5125:r instanceof Int32Array?o=5124:r instanceof Int8Array?o=5120:r instanceof Uint8Array&&(o=5121),{buffer:a,type:o,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version}}(n,r)):i.version0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}var a="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext,o=void 0!==n.precision?n.precision:"highp",s=i(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);var c=!0===n.logarithmicDepthBuffer,l=t.getParameter(34930),u=t.getParameter(35660),h=t.getParameter(3379),d=t.getParameter(34076),p=t.getParameter(34921),f=t.getParameter(36347),m=t.getParameter(36348),v=t.getParameter(36349),g=u>0,y=a||!!e.get("OES_texture_float");return{isWebGL2:a,getMaxAnisotropy:function(){if(void 0!==r)return r;var n=e.get("EXT_texture_filter_anisotropic");return r=null!==n?t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:c,maxTextures:l,maxVertexTextures:u,maxTextureSize:h,maxCubemapSize:d,maxAttributes:p,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:v,vertexTextures:g,floatFragmentTextures:y,floatVertexTextures:g&&y,maxSamples:a?t.getParameter(36183):0}}function _a(){var t=this,e=null,n=0,r=!1,i=!1,a=new Ir,o=new Tn,s={value:null,needsUpdate:!1};function c(){s.value!==e&&(s.value=e,s.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function l(e,n,r,i){var c=null!==e?e.length:0,l=null;if(0!==c){if(l=s.value,!0!==i||null===l){var u=r+4*c,h=n.matrixWorldInverse;o.getNormalMatrix(h),(null===l||l.length65535?ui:ci)(n,1);p.version=o,e.update(p,34963);var f=i.get(t);f&&e.remove(f),i.set(t,p)}return{get:function(t,e){var i=r.get(e);return i||(e.addEventListener("dispose",a),e.isBufferGeometry?i=e:e.isGeometry&&(void 0===e._bufferGeometry&&(e._bufferGeometry=(new _i).setFromObject(t)),i=e._bufferGeometry),r.set(e,i),n.memory.geometries++,i)},update:function(t){var n=t.index,r=t.attributes;for(var i in null!==n&&e.update(n,34963),r)e.update(r[i],34962);var a=t.morphAttributes;for(var i in a)for(var o=a[i],s=0,c=o.length;s0)return t;var i=e*n,a=Fa[i];if(void 0===a&&(a=new Float32Array(i),Fa[i]=a),0!==e){r.toArray(a,0);for(var o=1,s=0;o!==e;++o)s+=n,t[o].toArray(a,s)}return a}function ka(t,e){if(t.length!==e.length)return!1;for(var n=0,r=t.length;n/gm;function zo(t){return t.replace(Fo,Uo)}function Uo(t,e){var n=da[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return zo(n)}var Go=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;function Ho(t){return t.replace(Go,Vo)}function Vo(t,e,n,r){for(var i="",a=parseInt(e);a0?t.gammaFactor:1,M=a.isWebGL2?"":function(t,e,n){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||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(Io).join("\n")}(r.extensions,a,e),S=function(t){var e=[];for(var n in t){var r=t[n];!1!==r&&e.push("#define "+n+" "+r)}return e.join("\n")}(d),E=h.createProgram(),A=a.numMultiviewViews;if(r.isRawShaderMaterial?((o=[S].filter(Io).join("\n")).length>0&&(o+="\n"),(s=[M,S].filter(Io).join("\n")).length>0&&(s+="\n")):(o=[ko(a),"#define SHADER_NAME "+i.name,S,a.instancing?"#define USE_INSTANCING":"",a.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+_,"#define MAX_BONES "+a.maxBones,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp2?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+b:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.normalMap&&a.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",a.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",a.displacementMap&&a.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.vertexTangents?"#define USE_TANGENT":"",a.vertexColors?"#define USE_COLOR":"",a.vertexUvs?"#define USE_UV":"",a.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",a.flatShading?"#define FLAT_SHADED":"",a.skinning?"#define USE_SKINNING":"",a.useVertexTexture?"#define BONE_TEXTURE":"",a.morphTargets?"#define USE_MORPHTARGETS":"",a.morphNormals&&!1===a.flatShading?"#define USE_MORPHNORMALS":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+y:"",a.sizeAttenuation?"#define USE_SIZEATTENUATION":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(a.isWebGL2||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;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Io).join("\n"),s=[M,ko(a),"#define SHADER_NAME "+i.name,S,a.alphaTest?"#define ALPHATEST "+a.alphaTest+(a.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+_,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp2?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.matcap?"#define USE_MATCAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+x:"",a.envMap?"#define "+b:"",a.envMap?"#define "+w:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.normalMap&&a.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",a.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.sheen?"#define USE_SHEEN":"",a.vertexTangents?"#define USE_TANGENT":"",a.vertexColors?"#define USE_COLOR":"",a.vertexUvs?"#define USE_UV":"",a.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",a.gradientMap?"#define USE_GRADIENTMAP":"",a.flatShading?"#define FLAT_SHADED":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+y:"",a.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",a.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(a.isWebGL2||e.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",(r.extensions&&r.extensions.shaderTextureLOD||a.envMap)&&(a.isWebGL2||e.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",a.toneMapping!==rt?"#define TONE_MAPPING":"",a.toneMapping!==rt?da.tonemapping_pars_fragment:"",a.toneMapping!==rt?Do("toneMapping",a.toneMapping):"",a.dithering?"#define DITHERING":"",a.outputEncoding||a.mapEncoding||a.matcapEncoding||a.envMapEncoding||a.emissiveMapEncoding?da.encodings_pars_fragment:"",a.mapEncoding?Oo("mapTexelToLinear",a.mapEncoding):"",a.matcapEncoding?Oo("matcapTexelToLinear",a.matcapEncoding):"",a.envMapEncoding?Oo("envMapTexelToLinear",a.envMapEncoding):"",a.emissiveMapEncoding?Oo("emissiveMapTexelToLinear",a.emissiveMapEncoding):"",a.outputEncoding?(c="linearToOutputTexel",l=a.outputEncoding,u=Po(l),"vec4 "+c+"( vec4 value ) { return LinearTo"+u[0]+u[1]+"; }"):"",a.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(Io).join("\n")),v=Bo(v=No(v=zo(v),a),a),g=Bo(g=No(g=zo(g),a),a),v=Ho(v),g=Ho(g),a.isWebGL2&&!r.isRawShaderMaterial){var T=!1,L=/^\s*#version\s+300\s+es\s*\n/;r.isShaderMaterial&&null!==v.match(L)&&null!==g.match(L)&&(T=!0,v=v.replace(L,""),g=g.replace(L,"")),o=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+o,s=["#version 300 es\n","#define varying in",T?"":"out highp vec4 pc_fragColor;",T?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+s,A>0&&(o=(o=o.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","layout(num_views = "+A+") in;","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join("\n"),["uniform mat4 modelViewMatrices["+A+"];","uniform mat4 projectionMatrices["+A+"];","uniform mat4 viewMatrices["+A+"];","uniform mat3 normalMatrices["+A+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join("\n")),s=(s=s.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+A+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join("\n")))}var R,P,C=s+g,O=Lo(h,35633,o+v),D=Lo(h,35632,C);if(h.attachShader(E,O),h.attachShader(E,D),void 0!==r.index0AttributeName?h.bindAttribLocation(E,0,r.index0AttributeName):!0===a.morphTargets&&h.bindAttribLocation(E,0,"position"),h.linkProgram(E),t.debug.checkShaderErrors){var I=h.getProgramInfoLog(E).trim(),N=h.getShaderInfoLog(O).trim(),B=h.getShaderInfoLog(D).trim(),F=!0,z=!0;if(!1===h.getProgramParameter(E,35714)){F=!1;var U=Co(h,O,"vertex"),G=Co(h,D,"fragment");console.error("THREE.WebGLProgram: shader error: ",h.getError(),"35715",h.getProgramParameter(E,35715),"gl.getProgramInfoLog",I,U,G)}else""!==I?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",I):""!==N&&""!==B||(z=!1);z&&(this.diagnostics={runnable:F,material:r,programLog:I,vertexShader:{log:N,prefix:o},fragmentShader:{log:B,prefix:s}})}return h.deleteShader(O),h.deleteShader(D),this.getUniforms=function(){return void 0===R&&(R=new To(h,E)),R},this.getAttributes=function(){return void 0===P&&(P=function(t,e){for(var n={},r=t.getProgramParameter(e,35721),i=0;i0,maxBones:b,useVertexTexture:o,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:r.directional.length,numPointLights:r.point.length,numSpotLights:r.spot.length,numRectAreaLights:r.rectArea.length,numHemiLights:r.hemi.length,numDirLightShadows:r.directionalShadowMap.length,numPointLightShadows:r.pointShadowMap.length,numSpotLightShadows:r.spotShadowMap.length,numClippingPlanes:f,numClipIntersection:m,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.length>0,shadowMapType:t.shadowMap.type,toneMapping:e.toneMapped?t.toneMapping:rt,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===y,flipSided:e.side===g,depthPacking:void 0!==e.depthPacking&&e.depthPacking}},this.getProgramCacheKey=function(e,n){var r=[];if(n.shaderID?r.push(n.shaderID):(r.push(e.fragmentShader),r.push(e.vertexShader)),void 0!==e.defines)for(var i in e.defines)r.push(i),r.push(e.defines[i]);for(var a=0;a1&&n.sort(Xo),r.length>1&&r.sort(Yo)}}}function Jo(){var t=new WeakMap;function e(n){var r=n.target;r.removeEventListener("dispose",e),t.delete(r)}return{get:function(n,r){var i,a=t.get(n);return void 0===a?(i=new Zo,t.set(n,new WeakMap),t.get(n).set(r,i),n.addEventListener("dispose",e)):void 0===(i=a.get(r))&&(i=new Zo,a.set(r,i)),i},dispose:function(){t=new WeakMap}}}function Qo(){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 Sn,color:new Zr,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new bn};break;case"SpotLight":n={position:new Sn,direction:new Sn,color:new Zr,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new bn};break;case"PointLight":n={position:new Sn,color:new Zr,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new bn,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":n={direction:new Sn,skyColor:new Zr,groundColor:new Zr};break;case"RectAreaLight":n={color:new Zr,position:new Sn,halfWidth:new Sn,halfHeight:new Sn}}return t[e.id]=n,n}}}var Ko=0;function $o(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function ts(){for(var t=new Qo,e={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},n=0;n<9;n++)e.probe.push(new Sn);var r=new Sn,i=new Hn,a=new Hn;return{setup:function(n,o,s){for(var c=0,l=0,u=0,h=0;h<9;h++)e.probe[h].set(0,0,0);var d=0,p=0,f=0,m=0,v=0,g=0,y=0,x=0,b=s.matrixWorldInverse;n.sort($o),h=0;for(var w=n.length;h0:!0===s.isGeometry&&(p=s.morphTargets&&s.morphTargets.length>0));var f=!1;!0===e.isSkinnedMesh&&(!0===n.skinning?f=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e)),c=h(p,f,!0===e.isInstancedMesh)}else c=d;if(t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var v=c.uuid,g=n.uuid,y=l[v];void 0===y&&(y={},l[v]=y);var x=y[g];void 0===x&&(x=c.clone(),y[g]=x),c=x}return c.visible=n.visible,c.wireframe=n.wireframe,c.side=o===m?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],c.clipShadows=n.clipShadows,c.clippingPlanes=n.clippingPlanes,c.clipIntersection=n.clipIntersection,c.wireframeLinewidth=n.wireframeLinewidth,c.linewidth=n.linewidth,!0===r.isPointLight&&!0===c.isMeshDistanceMaterial&&(c.referencePosition.setFromMatrixPosition(r.matrixWorld),c.nearDistance=i,c.farDistance=a),c}function A(n,i,a,o,s){if(!1!==n.visible){if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===m)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);var c=e.update(n),l=n.material;if(Array.isArray(l))for(var u=c.groups,h=0,d=u.length;hn||i.y>n)&&(console.warn("THREE.WebGLShadowMap:",v,"has shadow exceeding max texture size, reducing"),i.x>n&&(a.x=Math.floor(n/y.x),i.x=a.x*y.x,g.mapSize.x=a.x),i.y>n&&(a.y=Math.floor(n/y.y),i.y=a.y*y.y,g.mapSize.y=a.y)),null===g.map&&!g.isPointLightShadow&&this.type===m){var x={minFilter:Et,magFilter:Et,format:jt};g.map=new On(i.x,i.y,x),g.map.texture.name=v.name+".shadowMap",g.mapPass=new On(i.x,i.y,x),g.camera.updateProjectionMatrix()}if(null===g.map){x={minFilter:bt,magFilter:bt,format:jt};g.map=new On(i.x,i.y,x),g.map.texture.name=v.name+".shadowMap",g.camera.updateProjectionMatrix()}t.setRenderTarget(g.map),t.clear();for(var _=g.getViewportCount(),M=0;M<_;M++){var E=g.getViewport(M);o.set(a.x*E.x,a.y*E.y,a.x*E.z,a.y*E.w),d.viewport(o),g.updateMatrices(v,M),r=g.getFrustum(),A(s,c,g.camera,v,this.type)}g.isPointLightShadow||this.type!==m||w(g,c)}else console.warn("THREE.WebGLShadowMap:",v,"has no shadow.")}b.needsUpdate=!1,t.setRenderTarget(l,u,h)}}}function cs(t,e,n){var r=n.isWebGL2;var i=new function(){var e=!1,n=new Cn,r=null,i=new Cn(0,0,0,0);return{setMask:function(n){r===n||e||(t.colorMask(n,n,n,n),r=n)},setLocked:function(t){e=t},setClear:function(e,r,a,o,s){!0===s&&(e*=o,r*=o,a*=o),n.set(e,r,a,o),!1===i.equals(n)&&(t.clearColor(e,r,a,o),i.copy(n))},reset:function(){e=!1,r=null,i.set(-1,0,0,0)}}},a=new function(){var e=!1,n=null,r=null,i=null;return{setTest:function(t){t?xt(2929):bt(2929)},setMask:function(r){n===r||e||(t.depthMask(r),n=r)},setFunc:function(e){if(r!==e){if(e)switch(e){case q:t.depthFunc(512);break;case X:t.depthFunc(519);break;case Y:t.depthFunc(513);break;case Z:t.depthFunc(515);break;case J:t.depthFunc(514);break;case Q:t.depthFunc(518);break;case K:t.depthFunc(516);break;case $:t.depthFunc(517);break;default:t.depthFunc(515)}else t.depthFunc(515);r=e}},setLocked:function(t){e=t},setClear:function(e){i!==e&&(t.clearDepth(e),i=e)},reset:function(){e=!1,n=null,r=null,i=null}}},l=new function(){var e=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null;return{setTest:function(t){e||(t?xt(2960):bt(2960))},setMask:function(r){n===r||e||(t.stencilMask(r),n=r)},setFunc:function(e,n,o){r===e&&i===n&&a===o||(t.stencilFunc(e,n,o),r=e,i=n,a=o)},setOp:function(e,n,r){o===e&&s===n&&c===r||(t.stencilOp(e,n,r),o=e,s=n,c=r)},setLocked:function(t){e=t},setClear:function(e){l!==e&&(t.clearStencil(e),l=e)},reset:function(){e=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null}}},u=t.getParameter(34921),h=new Uint8Array(u),d=new Uint8Array(u),p=new Uint8Array(u),f={},m=null,v=null,x=null,b=null,w=null,_=null,M=null,tt=null,et=null,nt=!1,rt=null,it=null,at=null,ot=null,st=null,ct=t.getParameter(35661),lt=!1,ut=0,ht=t.getParameter(7938);-1!==ht.indexOf("WebGL")?(ut=parseFloat(/^WebGL\ ([0-9])/.exec(ht)[1]),lt=ut>=1):-1!==ht.indexOf("OpenGL ES")&&(ut=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(ht)[1]),lt=ut>=2);var dt=null,pt={},ft=new Cn,mt=new Cn;function vt(e,n,r){var i=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(var o=0;or||t.height>r)&&(i=r/Math.max(t.width,t.height)),i<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){var a=e?xn.floorPowerOfTwo:Math.floor,o=a(i*t.width),c=a(i*t.height);void 0===s&&(s=m(o,c));var l=n?m(o,c):s;return l.width=o,l.height=c,l.getContext("2d").drawImage(t,0,0,o,c),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+o+"x"+c+")."),l}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function g(t){return xn.isPowerOfTwo(t.width)&&xn.isPowerOfTwo(t.height)}function y(t,e){return t.generateMipmaps&&e&&t.minFilter!==bt&&t.minFilter!==Et}function x(e,n,i,a){t.generateMipmap(e),r.get(n).__maxMipLevel=Math.log(Math.max(i,a))*Math.LOG2E}function b(t,n){if(!1===c)return t;var r=t;return 6403===t&&(5126===n&&(r=33326),5131===n&&(r=33325),5121===n&&(r=33321)),6407===t&&(5126===n&&(r=34837),5131===n&&(r=34843),5121===n&&(r=32849)),6408===t&&(5126===n&&(r=34836),5131===n&&(r=34842),5121===n&&(r=32856)),33325===r||33326===r||34842===r||34836===r?e.get("EXT_color_buffer_float"):34843!==r&&34837!==r||console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead."),r}function w(t){return t===bt||t===wt||t===Mt?9728:9729}function _(e){var n=e.target;n.removeEventListener("dispose",_),function(e){var n=r.get(e);if(void 0===n.__webglInit)return;t.deleteTexture(n.__webglTexture),r.remove(e)}(n),n.isVideoTexture&&p.delete(n),o.memory.textures--}function M(e){var n=e.target;n.removeEventListener("dispose",M),function(e){var n=r.get(e),i=r.get(e.texture);if(!e)return;void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLRenderTargetCube)for(var a=0;a<6;a++)t.deleteFramebuffer(n.__webglFramebuffer[a]),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer[a]);else t.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer);if(e.isWebGLMultiviewRenderTarget){t.deleteTexture(n.__webglColorTexture),t.deleteTexture(n.__webglDepthStencilTexture),o.memory.textures-=2;a=0;for(var s=n.__webglViewFramebuffers.length;a0&&i.__version!==t.version){var a=t.image;if(void 0===a)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==a.complete)return void O(i,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+e),n.bindTexture(3553,i.__webglTexture)}function A(e,i){if(6===e.image.length){var o=r.get(e);if(e.version>0&&o.__version!==e.version){C(o,e),n.activeTexture(33984+i),n.bindTexture(34067,o.__webglTexture),t.pixelStorei(37440,e.flipY);for(var s=e&&e.isCompressedTexture,l=e.image[0]&&e.image[0].isDataTexture,h=[],d=0;d<6;d++)h[d]=s||l?l?e.image[d].image:e.image[d]:v(e.image[d],!1,!0,u);var p,f=h[0],m=g(f)||c,w=a.convert(e.format),_=a.convert(e.type),M=b(w,_);if(P(34067,e,m),s){for(d=0;d<6;d++){p=h[d].mipmaps;for(var S=0;S1||r.get(a).__currentAnisotropy)&&(t.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function C(e,n){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",_),e.__webglTexture=t.createTexture(),o.memory.textures++)}function O(e,r,i){var o=3553;r.isDataTexture2DArray&&(o=35866),r.isDataTexture3D&&(o=32879),C(e,r),n.activeTexture(33984+i),n.bindTexture(o,e.__webglTexture),t.pixelStorei(37440,r.flipY),t.pixelStorei(37441,r.premultiplyAlpha),t.pixelStorei(3317,r.unpackAlignment);var s=function(t){return!c&&(t.wrapS!==yt||t.wrapT!==yt||t.minFilter!==bt&&t.minFilter!==Et)}(r)&&!1===g(r.image),l=v(r.image,s,!1,h),u=g(l)||c,d=a.convert(r.format),p=a.convert(r.type),f=b(d,p);P(o,r,u);var m,w=r.mipmaps;if(r.isDepthTexture){if(f=6402,r.type===Bt){if(!1===c)throw new Error("Float Depth Texture only supported in WebGL2.0");f=36012}else c&&(f=33189);r.format===Yt&&6402===f&&r.type!==Dt&&r.type!==Nt&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Dt,p=a.convert(r.type)),r.format===Zt&&(f=34041,r.type!==Ht&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=Ht,p=a.convert(r.type))),n.texImage2D(3553,0,f,l.width,l.height,0,d,p,null)}else if(r.isDataTexture)if(w.length>0&&u){for(var _=0,M=w.length;_0&&u){for(_=0,M=w.length;_=l&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+l),S+=1,t},this.resetTextureUnits=function(){S=0},this.setTexture2D=E,this.setTexture2DArray=function(t,e){var i=r.get(t);t.version>0&&i.__version!==t.version?O(i,t,e):(n.activeTexture(33984+e),n.bindTexture(35866,i.__webglTexture))},this.setTexture3D=function(t,e){var i=r.get(t);t.version>0&&i.__version!==t.version?O(i,t,e):(n.activeTexture(33984+e),n.bindTexture(32879,i.__webglTexture))},this.setTextureCube=A,this.setTextureCubeDynamic=T,this.setupRenderTarget=function(i){var s=r.get(i),l=r.get(i.texture);i.addEventListener("dispose",M),l.__webglTexture=t.createTexture(),o.memory.textures++;var u=!0===i.isWebGLRenderTargetCube,h=!0===i.isWebGLMultisampleRenderTarget,d=!0===i.isWebGLMultiviewRenderTarget,p=g(i)||c;if(u){s.__webglFramebuffer=[];for(var f=0;f<6;f++)s.__webglFramebuffer[f]=t.createFramebuffer()}else if(s.__webglFramebuffer=t.createFramebuffer(),h)if(c){s.__webglMultisampledFramebuffer=t.createFramebuffer(),s.__webglColorRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,s.__webglColorRenderbuffer);var m=b(a.convert(i.texture.format),a.convert(i.texture.type)),v=B(i);t.renderbufferStorageMultisample(36161,v,m,i.width,i.height),t.bindFramebuffer(36160,s.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(36160,36064,36161,s.__webglColorRenderbuffer),t.bindRenderbuffer(36161,null),i.depthBuffer&&(s.__webglDepthRenderbuffer=t.createRenderbuffer(),I(s.__webglDepthRenderbuffer,i,!0)),t.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");else if(d){var w=i.width,_=i.height,S=i.numViews;t.bindFramebuffer(36160,s.__webglFramebuffer);var E=e.get("OVR_multiview2");o.memory.textures+=2;var A=t.createTexture();t.bindTexture(35866,A),t.texParameteri(35866,10240,9728),t.texParameteri(35866,10241,9728),t.texImage3D(35866,0,32856,w,_,S,0,6408,5121,null),E.framebufferTextureMultiviewOVR(36160,36064,A,0,0,S);var T=t.createTexture();t.bindTexture(35866,T),t.texParameteri(35866,10240,9728),t.texParameteri(35866,10241,9728),t.texImage3D(35866,0,35056,w,_,S,0,34041,34042,null),E.framebufferTextureMultiviewOVR(36160,33306,T,0,0,S);var L=new Array(S);for(f=0;fd)return!1;for(var n=1,r=e.length;n=0){var l=i[s];if(void 0!==l){var u=l.normalized,h=l.itemSize;if(void 0===(M=w.get(l)))continue;var d=M.buffer,g=M.type,y=M.bytesPerElement;if(l.isInterleavedBufferAttribute){var x=l.data,b=x.stride,_=l.offset;x&&x.isInstancedInterleavedBuffer?(v.enableAttributeAndDivisor(c,x.meshPerAttribute),void 0===e.maxInstancedCount&&(e.maxInstancedCount=x.meshPerAttribute*x.count)):v.enableAttribute(c),p.bindBuffer(34962,d),p.vertexAttribPointer(c,h,g,u,b*y,_*y)}else l.isInstancedBufferAttribute?(v.enableAttributeAndDivisor(c,l.meshPerAttribute),void 0===e.maxInstancedCount&&(e.maxInstancedCount=l.meshPerAttribute*l.count)):v.enableAttribute(c),p.bindBuffer(34962,d),p.vertexAttribPointer(c,h,g,u,0,0)}else if("instanceMatrix"===s){var M;if(void 0===(M=w.get(t.instanceMatrix)))continue;d=M.buffer,g=M.type;v.enableAttributeAndDivisor(c+0,1),v.enableAttributeAndDivisor(c+1,1),v.enableAttributeAndDivisor(c+2,1),v.enableAttributeAndDivisor(c+3,1),p.bindBuffer(34962,d),p.vertexAttribPointer(c+0,4,g,!1,64,0),p.vertexAttribPointer(c+1,4,g,!1,64,16),p.vertexAttribPointer(c+2,4,g,!1,64,32),p.vertexAttribPointer(c+3,4,g,!1,64,48)}else if(void 0!==o){var S=o[s];if(void 0!==S)switch(S.length){case 2:p.vertexAttrib2fv(c,S);break;case 3:p.vertexAttrib3fv(c,S);break;case 4:p.vertexAttrib4fv(c,S);break;default:p.vertexAttrib1fv(c,S)}}}}v.disableUnusedAttributes()}(i,n,r,s),null!==u&&p.bindBuffer(34963,l.buffer));var y=1/0;null!==u?y=u.count:void 0!==h&&(y=h.count);var x=n.drawRange.start*d,b=n.drawRange.count*d,M=null!==a?a.start*d:0,S=null!==a?a.count*d:1/0,E=Math.max(x,M),A=Math.min(y,x+b,M+S)-1,T=Math.max(0,A-E+1);if(0!==T){if(i.isMesh)if(!0===r.wireframe)v.setLineWidth(r.wireframeLinewidth*at()),g.setMode(1);else switch(i.drawMode){case Re:g.setMode(4);break;case Pe:g.setMode(5);break;case Ce:g.setMode(6)}else if(i.isLine){var C=r.linewidth;void 0===C&&(C=1),v.setLineWidth(C*at()),i.isLineSegments?g.setMode(1):i.isLineLoop?g.setMode(2):g.setMode(3)}else i.isPoints?g.setMode(0):i.isSprite&&g.setMode(4);i.isInstancedMesh?g.renderInstances(n,E,T,i.count):n.isInstancedBufferGeometry?g.renderInstances(n,E,T,n.maxInstancedCount):g.render(E,T)}},this.compile=function(t,e){(d=A.get(t,e)).init(),t.traverse((function(t){t.isLight&&(d.pushLight(t),t.castShadow&&d.pushShadow(t))})),d.setupLights(e),t.traverse((function(e){if(e.material)if(Array.isArray(e.material))for(var n=0;n=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(f=0;f=0&&t.numSupportedMorphNormals++}var m=r.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(r.numClippingPlanes=$.numPlanes,r.numIntersection=$.numIntersection,m.clippingPlanes=$.uniform),r.fog=e,r.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),r.lightsStateVersion=o,r.needsLights&&(m.ambientLightColor.value=i.state.ambient,m.lightProbe.value=i.state.probe,m.directionalLights.value=i.state.directional,m.spotLights.value=i.state.spot,m.rectAreaLights.value=i.state.rectArea,m.pointLights.value=i.state.point,m.hemisphereLights.value=i.state.hemi,m.directionalShadowMap.value=i.state.directionalShadowMap,m.directionalShadowMatrix.value=i.state.directionalShadowMatrix,m.spotShadowMap.value=i.state.spotShadowMap,m.spotShadowMatrix.value=i.state.spotShadowMatrix,m.pointShadowMap.value=i.state.pointShadowMap,m.pointShadowMatrix.value=i.state.pointShadowMatrix);var v=r.program.getUniforms(),g=To.seqWithValue(v.seq,m);r.uniformsList=g}function wt(t,e,n,r){b.resetTextureUnits();var i=x.get(n),a=d.state.lights;if(tt&&(et||t!==H)){var o=t===H&&n.id===U;$.setState(n.clippingPlanes,n.clipIntersection,n.clipShadows,t,i,o)}!1===n.needsUpdate&&(void 0===i.program?n.needsUpdate=!0:n.fog&&i.fog!==e?n.needsUpdate=!0:i.needsLights&&i.lightsStateVersion!==a.state.version?n.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===$.numPlanes&&i.numIntersection===$.numIntersection||(n.needsUpdate=!0)),n.needsUpdate&&(bt(n,e,r),n.needsUpdate=!1);var s,c,l=!1,u=!1,h=!1,f=i.program,y=f.getUniforms(),w=i.shader.uniforms;if(v.useProgram(f.program)&&(l=!0,u=!0,h=!0),n.id!==U&&(U=n.id,u=!0),l||H!==t){if(f.numMultiviewViews>0?lt.updateCameraProjectionMatricesUniform(t,y):y.setValue(p,"projectionMatrix",t.projectionMatrix),m.logarithmicDepthBuffer&&y.setValue(p,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),H!==t&&(H=t,u=!0,h=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.envMap){var _=y.map.cameraPosition;void 0!==_&&_.setValue(p,rt.setFromMatrixPosition(t.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&y.setValue(p,"isOrthographic",!0===t.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.skinning)&&(f.numMultiviewViews>0?lt.updateCameraViewMatricesUniform(t,y):y.setValue(p,"viewMatrix",t.matrixWorldInverse))}if(n.skinning){y.setOptional(p,r,"bindMatrix"),y.setOptional(p,r,"bindMatrixInverse");var M=r.skeleton;if(M){var S=M.bones;if(m.floatVertexTextures){if(void 0===M.boneTexture){var E=Math.sqrt(4*S.length);E=xn.ceilPowerOfTwo(E),E=Math.max(E,4);var A=new Float32Array(E*E*4);A.set(M.boneMatrices);var T=new ca(A,E,E,jt,Bt);M.boneMatrices=A,M.boneTexture=T,M.boneTextureSize=E}y.setValue(p,"boneTexture",M.boneTexture,b),y.setValue(p,"boneTextureSize",M.boneTextureSize)}else y.setOptional(p,M,"boneMatrices")}}return(u||i.receiveShadow!==r.receiveShadow)&&(i.receiveShadow=r.receiveShadow,y.setValue(p,"receiveShadow",r.receiveShadow)),u&&(y.setValue(p,"toneMappingExposure",O.toneMappingExposure),y.setValue(p,"toneMappingWhitePoint",O.toneMappingWhitePoint),i.needsLights&&(c=h,(s=w).ambientLightColor.needsUpdate=c,s.lightProbe.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.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}(w,e),n.isMeshBasicMaterial?_t(w,n):n.isMeshLambertMaterial?(_t(w,n),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(w,n)):n.isMeshPhongMaterial?(_t(w,n),n.isMeshToonMaterial?function(t,e){Mt(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(w,n):Mt(w,n)):n.isMeshStandardMaterial?(_t(w,n),n.isMeshPhysicalMaterial?function(t,e){St(t,e),t.reflectivity.value=e.reflectivity,t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.sheen&&t.sheen.value.copy(e.sheen);e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,e.side===g&&t.clearcoatNormalScale.value.negate());t.transparency.value=e.transparency}(w,n):St(w,n)):n.isMeshMatcapMaterial?(_t(w,n),function(t,e){e.matcap&&(t.matcap.value=e.matcap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===g&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,n)):n.isMeshDepthMaterial?(_t(w,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,n)):n.isMeshDistanceMaterial?(_t(w,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}(w,n)):n.isMeshNormalMaterial?(_t(w,n),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===g&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,n)):n.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(w,n),n.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(w,n)):n.isPointsMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*Y,t.scale.value=.5*X,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);var n;e.map?n=e.map:e.alphaMap&&(n=e.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}(w,n):n.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);var n;e.map?n=e.map:e.alphaMap&&(n=e.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}(w,n):n.isShadowMaterial&&(w.color.value.copy(n.color),w.opacity.value=n.opacity),void 0!==w.ltc_1&&(w.ltc_1.value=pa.LTC_1),void 0!==w.ltc_2&&(w.ltc_2.value=pa.LTC_2),To.upload(p,i.uniformsList,w,b),n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(To.upload(p,i.uniformsList,w,b),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&y.setValue(p,"center",r.center),f.numMultiviewViews>0?lt.updateObjectMatricesUniforms(r,t,y):(y.setValue(p,"modelViewMatrix",r.modelViewMatrix),y.setValue(p,"normalMatrix",r.normalMatrix)),y.setValue(p,"modelMatrix",r.matrixWorld),f}function _t(t,e){var n;t.opacity.value=e.opacity,e.color&&t.diffuse.value.copy(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.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio,t.maxMipLevel.value=x.get(e.envMap).__maxMipLevel),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity),e.map?n=e.map:e.specularMap?n=e.specularMap:e.displacementMap?n=e.displacementMap:e.normalMap?n=e.normalMap:e.bumpMap?n=e.bumpMap:e.roughnessMap?n=e.roughnessMap:e.metalnessMap?n=e.metalnessMap:e.alphaMap?n=e.alphaMap:e.emissiveMap&&(n=e.emissiveMap),void 0!==n&&(n.isWebGLRenderTarget&&(n=n.texture),!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}function Mt(t,e){t.specular.value.copy(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.side===g&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function St(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.side===g&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}vt.setAnimationLoop((function(t){ct.isPresenting()||mt&&mt(t)})),"undefined"!=typeof window&&vt.setContext(window),this.setAnimationLoop=function(t){mt=t,ct.setAnimationLoop(t),vt.start()},this.render=function(t,e){var n,r;if(void 0!==arguments[2]&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),n=arguments[2]),void 0!==arguments[3]&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),r=arguments[3]),e&&e.isCamera){if(!D){G.geometry=null,G.program=null,G.wireframe=!1,U=-1,H=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),ct.enabled&&(e=ct.getCamera(e)),(d=A.get(t,e)).init(),t.onBeforeRender(O,t,e,n||F),nt.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),K.setFromMatrix(nt),et=this.localClippingEnabled,tt=$.init(this.clippingPlanes,et,e),(h=E.get(t,e)).init(),gt(t,e,0,O.sortObjects),!0===O.sortObjects&&h.sort(),tt&&$.beginShadows();var i=d.state.shadowsArray;ut.render(i,t,e),d.setupLights(e),tt&&$.endShadows(),this.info.autoReset&&this.info.reset(),void 0!==n&&this.setRenderTarget(n),ct.enabled&<.isAvailable()&<.attachCamera(e),T.render(h,t,e,r);var a=h.opaque,o=h.transparent;if(t.overrideMaterial){var s=t.overrideMaterial;a.length&&yt(a,t,e,s),o.length&&yt(o,t,e,s)}else a.length&&yt(a,t,e),o.length&&yt(o,t,e);t.onAfterRender(O,t,e),null!==F&&(b.updateRenderTargetMipmap(F),b.updateMultisampleRenderTarget(F)),v.buffers.depth.setTest(!0),v.buffers.depth.setMask(!0),v.buffers.color.setMask(!0),v.setPolygonOffset(!1),ct.enabled&&(lt.isAvailable()&<.detachCamera(e),ct.submitFrame()),h=null,d=null}}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.setFramebuffer=function(t){I!==t&&null===F&&p.bindFramebuffer(36160,t),I=t},this.getActiveCubeFace=function(){return N},this.getActiveMipmapLevel=function(){return B},this.getRenderTarget=function(){return F},this.setRenderTarget=function(t,e,n){F=t,N=e,B=n,t&&void 0===x.get(t).__webglFramebuffer&&b.setupRenderTarget(t);var r=I,i=!1;if(t){var a=x.get(t).__webglFramebuffer;t.isWebGLRenderTargetCube?(r=a[e||0],i=!0):r=t.isWebGLMultisampleRenderTarget?x.get(t).__webglMultisampledFramebuffer:a,k.copy(t.viewport),j.copy(t.scissor),W=t.scissorTest}else k.copy(Z).multiplyScalar(Y).floor(),j.copy(J).multiplyScalar(Y).floor(),W=Q;if(z!==r&&(p.bindFramebuffer(36160,r),z=r),v.viewport(k),v.scissor(j),v.setScissorTest(W),i){var o=x.get(t.texture);p.framebufferTexture2D(36160,36064,34069+(e||0),o.__webglTexture,n||0)}},this.readRenderTargetPixels=function(t,e,n,r,i,a,o){if(t&&t.isWebGLRenderTarget){var s=x.get(t).__webglFramebuffer;if(t.isWebGLRenderTargetCube&&void 0!==o&&(s=s[o]),s){var c=!1;s!==z&&(p.bindFramebuffer(36160,s),c=!0);try{var l=t.texture,u=l.format,h=l.type;if(u!==jt&&C.convert(u)!==p.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(h===Pt||C.convert(h)===p.getParameter(35738)||h===Bt&&(m.isWebGL2||f.get("OES_texture_float")||f.get("WEBGL_color_buffer_float"))||h===Ft&&(m.isWebGL2?f.get("EXT_color_buffer_float"):f.get("EXT_color_buffer_half_float"))))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===p.checkFramebufferStatus(36160)?e>=0&&e<=t.width-r&&n>=0&&n<=t.height-i&&p.readPixels(e,n,r,i,C.convert(u),C.convert(h),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{c&&p.bindFramebuffer(36160,z)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(t,e,n){void 0===n&&(n=0);var r=Math.pow(2,-n),i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=C.convert(e.format);b.setTexture2D(e,0),p.copyTexImage2D(3553,n,o,t.x,t.y,i,a,0),v.unbindTexture()},this.copyTextureToTexture=function(t,e,n,r){var i=e.image.width,a=e.image.height,o=C.convert(n.format),s=C.convert(n.type);b.setTexture2D(n,0),e.isDataTexture?p.texSubImage2D(3553,r||0,t.x,t.y,i,a,o,s,e.image.data):p.texSubImage2D(3553,r||0,t.x,t.y,o,s,e.image),v.unbindTexture()},this.initTexture=function(t){b.setTexture2D(t,0),v.unbindTexture()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function _s(t,e){this.name="",this.color=new Zr(t),this.density=void 0!==e?e:25e-5}function Ms(t,e,n){this.name="",this.color=new Zr(t),this.near=void 0!==e?e:1,this.far=void 0!==n?n:1e3}function Ss(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=sn,this.updateRange={offset:0,count:-1},this.version=0}function Es(t,e,n,r){this.data=t,this.itemSize=e,this.offset=n,this.normalized=!0===r}function As(t){ei.call(this),this.type="SpriteMaterial",this.color=new Zr(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(t)}Object.assign(xs.prototype,vn.prototype),Object.assign(bs.prototype,vn.prototype),Object.assign(_s.prototype,{isFogExp2:!0,clone:function(){return new _s(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}),Object.assign(Ms.prototype,{isFog:!0,clone:function(){return new Ms(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}),Object.defineProperty(Ss.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Ss.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.stride,n*=e.stride;for(var r=0,i=this.stride;rt.far||e.push({distance:s,point:Ts.clone(),uv:Wr.getUV(Ts,Ds,Is,Ns,Bs,Fs,zs,new bn),face:null,object:this})}},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(t){return ar.prototype.copy.call(this,t),void 0!==t.center&&this.center.copy(t.center),this}});var Hs=new Sn,Vs=new Sn;function ks(){ar.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}function js(t,e){t&&t.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),Gi.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Hn,this.bindMatrixInverse=new Hn}ks.prototype=Object.assign(Object.create(ar.prototype),{constructor:ks,isLOD:!0,copy:function(t){ar.prototype.copy.call(this,t,!1);for(var e=t.levels,n=0,r=e.length;n1){Hs.setFromMatrixPosition(t.matrixWorld),Vs.setFromMatrixPosition(this.matrixWorld);var n=Hs.distanceTo(Vs);e[0].object.visible=!0;for(var r=1,i=e.length;r=e[r].distance;r++)e[r-1].object.visible=!1,e[r].object.visible=!0;for(;ro))u.applyMatrix4(this.matrixWorld),(w=t.ray.origin.distanceTo(u))t.far||e.push({distance:w,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}else for(m=0,v=p.length/3-1;mo))u.applyMatrix4(this.matrixWorld),(w=t.ray.origin.distanceTo(u))t.far||e.push({distance:w,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}else if(r.isGeometry){var x=r.vertices,b=x.length;for(m=0;mo))u.applyMatrix4(this.matrixWorld),(w=t.ray.origin.distanceTo(u))t.far||e.push({distance:w,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var rc=new Sn,ic=new Sn;function ac(t,e){nc.call(this,t,e),this.type="LineSegments"}function oc(t,e){nc.call(this,t,e),this.type="LineLoop"}function sc(t){ei.call(this),this.type="PointsMaterial",this.color=new Zr(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(t)}ac.prototype=Object.assign(Object.create(nc.prototype),{constructor:ac,isLineSegments:!0,computeLineDistances:function(){var t=this.geometry;if(t.isBufferGeometry)if(null===t.index){for(var e=t.attributes.position,n=[],r=0,i=e.count;ri.far)return;a.push({distance:l,distanceToRay:Math.sqrt(s),point:c,index:e,face:null,object:o})}}function fc(t,e,n,r,i,a,o,s,c){Pn.call(this,t,e,n,r,i,a,o,s,c),this.format=void 0!==o?o:kt,this.minFilter=void 0!==a?a:Et,this.magFilter=void 0!==i?i:Et,this.generateMipmaps=!1}function mc(t,e,n,r,i,a,o,s,c,l,u,h){Pn.call(this,null,a,o,s,c,l,r,i,u,h),this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function vc(t,e,n,r,i,a,o,s,c){Pn.call(this,t,e,n,r,i,a,o,s,c),this.needsUpdate=!0}function gc(t,e,n,r,i,a,o,s,c,l){if((l=void 0!==l?l:Yt)!==Yt&&l!==Zt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&l===Yt&&(n=Dt),void 0===n&&l===Zt&&(n=Ht),Pn.call(this,null,r,i,a,o,s,l,n,c),this.image={width:t,height:e},this.magFilter=void 0!==o?o:bt,this.minFilter=void 0!==s?s:bt,this.flipY=!1,this.generateMipmaps=!1}function yc(t){_i.call(this),this.type="WireframeGeometry";var e,n,r,i,a,o,s,c,l,u,h=[],d=[0,0],p={},f=["a","b","c"];if(t&&t.isGeometry){var m=t.faces;for(e=0,r=m.length;e=0?(t(v-1e-5,m,h),d.subVectors(u,h)):(t(v+1e-5,m,h),d.subVectors(h,u)),m-1e-5>=0?(t(v,m-1e-5,h),p.subVectors(u,h)):(t(v,m+1e-5,h),p.subVectors(h,u)),l.crossVectors(d,p).normalize(),s.push(l.x,l.y,l.z),c.push(v,m)}}for(r=0;r.9&&o<.1&&(e<.2&&(a[t+0]+=1),n<.2&&(a[t+2]+=1),r<.2&&(a[t+4]+=1))}}()}(),this.setAttribute("position",new hi(i,3)),this.setAttribute("normal",new hi(i.slice(),3)),this.setAttribute("uv",new hi(a,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}function Mc(t,e){Xi.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Sc(t,e)),this.mergeVertices()}function Sc(t,e){_c.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 Ec(t,e){Xi.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Ac(t,e)),this.mergeVertices()}function Ac(t,e){_c.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 Tc(t,e){Xi.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Lc(t,e)),this.mergeVertices()}function Lc(t,e){var n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1];_c.call(this,r,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Rc(t,e){Xi.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Pc(t,e)),this.mergeVertices()}function Pc(t,e){var n=(1+Math.sqrt(5))/2,r=1/n,i=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r];_c.call(this,i,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Cc(t,e,n,r,i,a){Xi.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:r,closed:i},void 0!==a&&console.warn("THREE.TubeGeometry: taper has been removed.");var o=new Oc(t,e,n,r,i);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals,this.fromBufferGeometry(o),this.mergeVertices()}function Oc(t,e,n,r,i){_i.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:r,closed:i},e=e||64,n=n||1,r=r||8,i=i||!1;var a=t.computeFrenetFrames(e,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;var o,s,c=new Sn,l=new Sn,u=new bn,h=new Sn,d=[],p=[],f=[],m=[];function v(i){h=t.getPointAt(i/e,h);var o=a.normals[i],u=a.binormals[i];for(s=0;s<=r;s++){var f=s/r*Math.PI*2,m=Math.sin(f),v=-Math.cos(f);l.x=v*o.x+m*u.x,l.y=v*o.y+m*u.y,l.z=v*o.z+m*u.z,l.normalize(),p.push(l.x,l.y,l.z),c.x=h.x+n*l.x,c.y=h.y+n*l.y,c.z=h.z+n*l.z,d.push(c.x,c.y,c.z)}}!function(){for(o=0;o0){var o=i[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=o.length;t0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),fc.prototype=Object.assign(Object.create(Pn.prototype),{constructor:fc,isVideoTexture:!0,update:function(){var t=this.image;t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),mc.prototype=Object.create(Pn.prototype),mc.prototype.constructor=mc,mc.prototype.isCompressedTexture=!0,vc.prototype=Object.create(Pn.prototype),vc.prototype.constructor=vc,vc.prototype.isCanvasTexture=!0,gc.prototype=Object.create(Pn.prototype),gc.prototype.constructor=gc,gc.prototype.isDepthTexture=!0,yc.prototype=Object.create(_i.prototype),yc.prototype.constructor=yc,xc.prototype=Object.create(Xi.prototype),xc.prototype.constructor=xc,bc.prototype=Object.create(_i.prototype),bc.prototype.constructor=bc,wc.prototype=Object.create(Xi.prototype),wc.prototype.constructor=wc,_c.prototype=Object.create(_i.prototype),_c.prototype.constructor=_c,Mc.prototype=Object.create(Xi.prototype),Mc.prototype.constructor=Mc,Sc.prototype=Object.create(_c.prototype),Sc.prototype.constructor=Sc,Ec.prototype=Object.create(Xi.prototype),Ec.prototype.constructor=Ec,Ac.prototype=Object.create(_c.prototype),Ac.prototype.constructor=Ac,Tc.prototype=Object.create(Xi.prototype),Tc.prototype.constructor=Tc,Lc.prototype=Object.create(_c.prototype),Lc.prototype.constructor=Lc,Rc.prototype=Object.create(Xi.prototype),Rc.prototype.constructor=Rc,Pc.prototype=Object.create(_c.prototype),Pc.prototype.constructor=Pc,Cc.prototype=Object.create(Xi.prototype),Cc.prototype.constructor=Cc,Oc.prototype=Object.create(_i.prototype),Oc.prototype.constructor=Oc,Oc.prototype.toJSON=function(){var t=_i.prototype.toJSON.call(this);return t.path=this.parameters.path.toJSON(),t},Dc.prototype=Object.create(Xi.prototype),Dc.prototype.constructor=Dc,Ic.prototype=Object.create(_i.prototype),Ic.prototype.constructor=Ic,Nc.prototype=Object.create(Xi.prototype),Nc.prototype.constructor=Nc,Bc.prototype=Object.create(_i.prototype),Bc.prototype.constructor=Bc;var Fc=function(t,e,n){n=n||2;var r,i,a,o,s,c,l,u=e&&e.length,h=u?e[0]*n:t.length,d=zc(t,0,h,n,!0),p=[];if(!d||d.next===d.prev)return p;if(u&&(d=function(t,e,n,r){var i,a,o,s,c,l=[];for(i=0,a=e.length;i80*n){r=a=t[0],i=o=t[1];for(var f=n;fa&&(a=s),c>o&&(o=c);l=0!==(l=Math.max(a-r,o-i))?1/l:0}return Gc(d,p,n,r,i,l),p};function zc(t,e,n,r,i){var a,o;if(i===function(t,e,n,r){for(var i=0,a=e,o=n-r;a0)for(a=e;a=e;a-=r)o=nl(a,t[a],t[a+1],o);return o&&Kc(o,o.next)&&(rl(o),o=o.next),o}function Uc(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!Kc(r,r.next)&&0!==Qc(r.prev,r,r.next))r=r.next;else{if(rl(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function Gc(t,e,n,r,i,a,o){if(t){!o&&a&&function(t,e,n,r){var i=t;do{null===i.z&&(i.z=Xc(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,a,o,s,c,l=1;do{for(n=t,t=null,a=null,o=0;n;){for(o++,r=n,s=0,e=0;e0||c>0&&r;)0!==s&&(0===c||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,c--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1)}(i)}(t,r,i,a);for(var s,c,l=t;t.prev!==t.next;)if(s=t.prev,c=t.next,a?Vc(t,r,i,a):Hc(t))e.push(s.i/n),e.push(t.i/n),e.push(c.i/n),rl(t),t=c.next,l=c.next;else if((t=c)===l){o?1===o?Gc(t=kc(t,e,n),e,n,r,i,a,2):2===o&&jc(t,e,n,r,i,a):Gc(Uc(t),e,n,r,i,a,1);break}}}function Hc(t){var e=t.prev,n=t,r=t.next;if(Qc(e,n,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(Zc(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Qc(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Vc(t,e,n,r){var i=t.prev,a=t,o=t.next;if(Qc(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,u=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,h=Xc(s,c,e,n,r),d=Xc(l,u,e,n,r),p=t.prevZ,f=t.nextZ;p&&p.z>=h&&f&&f.z<=d;){if(p!==t.prev&&p!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Qc(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==t.prev&&f!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Qc(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=h;){if(p!==t.prev&&p!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Qc(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==t.prev&&f!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Qc(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function kc(t,e,n){var r=t;do{var i=r.prev,a=r.next.next;!Kc(i,a)&&$c(i,r,r.next,a)&&tl(i,a)&&tl(a,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(a.i/n),rl(r),rl(r.next),r=t=a),r=r.next}while(r!==t);return r}function jc(t,e,n,r,i,a){var o=t;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&Jc(o,s)){var c=el(o,s);return o=Uc(o,o.next),c=Uc(c,c.next),Gc(o,e,n,r,i,a),void Gc(c,e,n,r,i,a)}s=s.next}o=o.next}while(o!==t)}function Wc(t,e){return t.x-e.x}function qc(t,e){if(e=function(t,e){var n,r=e,i=t.x,a=t.y,o=-1/0;do{if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){var s=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>o){if(o=s,s===i){if(a===r.y)return r;if(a===r.next.y)return r.next}n=r.x=r.x&&r.x>=u&&i!==r.x&&Zc(an.x)&&tl(r,t)&&(n=r,d=c),r=r.next;return n}(t,e)){var n=el(e,t);Uc(n,n.next)}}function Xc(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Yc(t){var e=t,n=t;do{(e.x=0&&(t-o)*(r-s)-(n-o)*(e-s)>=0&&(n-o)*(a-s)-(i-o)*(r-s)>=0}function Jc(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&&$c(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&tl(t,e)&&tl(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)}function Qc(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Kc(t,e){return t.x===e.x&&t.y===e.y}function $c(t,e,n,r){return!!(Kc(t,n)&&Kc(e,r)||Kc(t,r)&&Kc(n,e))||Qc(t,e,n)>0!=Qc(t,e,r)>0&&Qc(n,r,t)>0!=Qc(n,r,e)>0}function tl(t,e){return Qc(t.prev,t,t.next)<0?Qc(t,e,t.next)>=0&&Qc(t,t.prev,e)>=0:Qc(t,e,t.prev)<0||Qc(t,t.next,e)<0}function el(t,e){var n=new il(t.i,t.x,t.y),r=new il(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function nl(t,e,n,r){var i=new il(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function rl(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 il(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 al={area:function(t){for(var e=t.length,n=0,r=e-1,i=0;i2&&t[e-1].equals(t[0])&&t.pop()}function sl(t,e){for(var n=0;nNumber.EPSILON){var d=Math.sqrt(u),p=Math.sqrt(c*c+l*l),f=e.x-s/d,m=e.y+o/d,v=((n.x-l/p-f)*l-(n.y+c/p-m)*c)/(o*l-s*c),g=(r=f+o*v-t.x)*r+(i=m+s*v-t.y)*i;if(g<=2)return new bn(r,i);a=Math.sqrt(g/2)}else{var y=!1;o>Number.EPSILON?c>Number.EPSILON&&(y=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(l)&&(y=!0),y?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new bn(r/a,i/a)}for(var G=[],H=0,V=R.length,k=V-1,j=H+1;H=0;C--){for(D=C/p,I=u*Math.cos(D*Math.PI/2),O=h*Math.sin(D*Math.PI/2)+d,H=0,V=R.length;H=0;){n=H,(r=H-1)<0&&(r=t.length-1);var i=0,a=s+2*p;for(i=0;i0)&&f.push(_,M,E),(c!==n-1||l0&&g(!0),e>0&&g(!1)),this.setIndex(l),this.setAttribute("position",new hi(u,3)),this.setAttribute("normal",new hi(h,3)),this.setAttribute("uv",new hi(d,2))}function Al(t,e,n,r,i,a,o){Sl.call(this,0,t,e,n,r,i,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}function Tl(t,e,n,r,i,a,o){El.call(this,0,t,e,n,r,i,a,o),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}function Ll(t,e,n,r){Xi.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},this.fromBufferGeometry(new Rl(t,e,n,r)),this.mergeVertices()}function Rl(t,e,n,r){_i.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},t=t||1,e=void 0!==e?Math.max(3,e):8,n=void 0!==n?n:0,r=void 0!==r?r:2*Math.PI;var i,a,o=[],s=[],c=[],l=[],u=new Sn,h=new bn;for(s.push(0,0,0),c.push(0,0,1),l.push(.5,.5),a=0,i=3;a<=e;a++,i+=3){var d=n+a/e*r;u.x=t*Math.cos(d),u.y=t*Math.sin(d),s.push(u.x,u.y,u.z),c.push(0,0,1),h.x=(s[i]/t+1)/2,h.y=(s[i+1]/t+1)/2,l.push(h.x,h.y)}for(i=1;i<=e;i++)o.push(i,i+1,0);this.setIndex(o),this.setAttribute("position",new hi(s,3)),this.setAttribute("normal",new hi(c,3)),this.setAttribute("uv",new hi(l,2))}dl.prototype=Object.create(Xi.prototype),dl.prototype.constructor=dl,pl.prototype=Object.create(ll.prototype),pl.prototype.constructor=pl,fl.prototype=Object.create(Xi.prototype),fl.prototype.constructor=fl,ml.prototype=Object.create(_i.prototype),ml.prototype.constructor=ml,vl.prototype=Object.create(Xi.prototype),vl.prototype.constructor=vl,gl.prototype=Object.create(_i.prototype),gl.prototype.constructor=gl,yl.prototype=Object.create(Xi.prototype),yl.prototype.constructor=yl,xl.prototype=Object.create(_i.prototype),xl.prototype.constructor=xl,bl.prototype=Object.create(Xi.prototype),bl.prototype.constructor=bl,bl.prototype.toJSON=function(){var t=Xi.prototype.toJSON.call(this);return _l(this.parameters.shapes,t)},wl.prototype=Object.create(_i.prototype),wl.prototype.constructor=wl,wl.prototype.toJSON=function(){var t=_i.prototype.toJSON.call(this);return _l(this.parameters.shapes,t)},Ml.prototype=Object.create(_i.prototype),Ml.prototype.constructor=Ml,Sl.prototype=Object.create(Xi.prototype),Sl.prototype.constructor=Sl,El.prototype=Object.create(_i.prototype),El.prototype.constructor=El,Al.prototype=Object.create(Sl.prototype),Al.prototype.constructor=Al,Tl.prototype=Object.create(El.prototype),Tl.prototype.constructor=Tl,Ll.prototype=Object.create(Xi.prototype),Ll.prototype.constructor=Ll,Rl.prototype=Object.create(_i.prototype),Rl.prototype.constructor=Rl;var Pl=Object.freeze({__proto__:null,WireframeGeometry:yc,ParametricGeometry:xc,ParametricBufferGeometry:bc,TetrahedronGeometry:Mc,TetrahedronBufferGeometry:Sc,OctahedronGeometry:Ec,OctahedronBufferGeometry:Ac,IcosahedronGeometry:Tc,IcosahedronBufferGeometry:Lc,DodecahedronGeometry:Rc,DodecahedronBufferGeometry:Pc,PolyhedronGeometry:wc,PolyhedronBufferGeometry:_c,TubeGeometry:Cc,TubeBufferGeometry:Oc,TorusKnotGeometry:Dc,TorusKnotBufferGeometry:Ic,TorusGeometry:Nc,TorusBufferGeometry:Bc,TextGeometry:dl,TextBufferGeometry:pl,SphereGeometry:fl,SphereBufferGeometry:ml,RingGeometry:vl,RingBufferGeometry:gl,PlaneGeometry:ga,PlaneBufferGeometry:ya,LatheGeometry:yl,LatheBufferGeometry:xl,ShapeGeometry:bl,ShapeBufferGeometry:wl,ExtrudeGeometry:cl,ExtrudeBufferGeometry:ll,EdgesGeometry:Ml,ConeGeometry:Al,ConeBufferGeometry:Tl,CylinderGeometry:Sl,CylinderBufferGeometry:El,CircleGeometry:Ll,CircleBufferGeometry:Rl,BoxGeometry:Yi,BoxBufferGeometry:Zi});function Cl(t){ei.call(this),this.type="ShadowMaterial",this.color=new Zr(0),this.transparent=!0,this.setValues(t)}function Ol(t){ea.call(this,t),this.type="RawShaderMaterial"}function Dl(t){ei.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Zr(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 Zr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(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 Il(t){Dl.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearcoat=0,this.clearcoatRoughness=0,this.sheen=null,this.clearcoatNormalScale=new bn(1,1),this.clearcoatNormalMap=null,this.transparency=0,this.setValues(t)}function Nl(t){ei.call(this),this.type="MeshPhongMaterial",this.color=new Zr(16777215),this.specular=new Zr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Zr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=tt,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 Bl(t){Nl.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function Fl(t){ei.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function zl(t){ei.call(this),this.type="MeshLambertMaterial",this.color=new Zr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Zr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=tt,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 Ul(t){ei.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Zr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Gl(t){Js.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}Cl.prototype=Object.create(ei.prototype),Cl.prototype.constructor=Cl,Cl.prototype.isShadowMaterial=!0,Cl.prototype.copy=function(t){return ei.prototype.copy.call(this,t),this.color.copy(t.color),this},Ol.prototype=Object.create(ea.prototype),Ol.prototype.constructor=Ol,Ol.prototype.isRawShaderMaterial=!0,Dl.prototype=Object.create(ei.prototype),Dl.prototype.constructor=Dl,Dl.prototype.isMeshStandardMaterial=!0,Dl.prototype.copy=function(t){return ei.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.normalMapType=t.normalMapType,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},Il.prototype=Object.create(Dl.prototype),Il.prototype.constructor=Il,Il.prototype.isMeshPhysicalMaterial=!0,Il.prototype.copy=function(t){return Dl.prototype.copy.call(this,t),this.defines={STANDARD:"",PHYSICAL:""},this.reflectivity=t.reflectivity,this.clearcoat=t.clearcoat,this.clearcoatRoughness=t.clearcoatRoughness,t.sheen?this.sheen=(this.sheen||new Zr).copy(t.sheen):this.sheen=null,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.transparency=t.transparency,this},Nl.prototype=Object.create(ei.prototype),Nl.prototype.constructor=Nl,Nl.prototype.isMeshPhongMaterial=!0,Nl.prototype.copy=function(t){return ei.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.normalMapType=t.normalMapType,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},Bl.prototype=Object.create(Nl.prototype),Bl.prototype.constructor=Bl,Bl.prototype.isMeshToonMaterial=!0,Bl.prototype.copy=function(t){return Nl.prototype.copy.call(this,t),this.gradientMap=t.gradientMap,this},Fl.prototype=Object.create(ei.prototype),Fl.prototype.constructor=Fl,Fl.prototype.isMeshNormalMaterial=!0,Fl.prototype.copy=function(t){return ei.prototype.copy.call(this,t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,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},zl.prototype=Object.create(ei.prototype),zl.prototype.constructor=zl,zl.prototype.isMeshLambertMaterial=!0,zl.prototype.copy=function(t){return ei.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},Ul.prototype=Object.create(ei.prototype),Ul.prototype.constructor=Ul,Ul.prototype.isMeshMatcapMaterial=!0,Ul.prototype.copy=function(t){return ei.prototype.copy.call(this,t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Gl.prototype=Object.create(Js.prototype),Gl.prototype.constructor=Gl,Gl.prototype.isLineDashedMaterial=!0,Gl.prototype.copy=function(t){return Js.prototype.copy.call(this,t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this};var Hl=Object.freeze({__proto__:null,ShadowMaterial:Cl,SpriteMaterial:As,RawShaderMaterial:Ol,ShaderMaterial:ea,PointsMaterial:sc,MeshPhysicalMaterial:Il,MeshStandardMaterial:Dl,MeshPhongMaterial:Nl,MeshToonMaterial:Bl,MeshNormalMaterial:Fl,MeshLambertMaterial:zl,MeshDepthMaterial:rs,MeshDistanceMaterial:is,MeshBasicMaterial:ni,MeshMatcapMaterial:Ul,LineDashedMaterial:Gl,LineBasicMaterial:Js,Material:ei}),Vl={arraySlice:function(t,e,n){return Vl.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),r=0;r!==e;++r)n[r]=r;return n.sort((function(e,n){return t[e]-t[n]})),n},sortedArray:function(t,e,n){for(var r=t.length,i=new t.constructor(r),a=0,o=0;o!==r;++a)for(var s=n[a]*e,c=0;c!==e;++c)i[o++]=t[s+c];return i},flattenJSON:function(t,e,n,r){for(var i=1,a=t[0];void 0!==a&&void 0===a[r];)a=t[i++];if(void 0!==a){var o=a[r];if(void 0!==o)if(Array.isArray(o))do{void 0!==(o=a[r])&&(e.push(a.time),n.push.apply(n,o)),a=t[i++]}while(void 0!==a);else if(void 0!==o.toArray)do{void 0!==(o=a[r])&&(e.push(a.time),o.toArray(n,n.length)),a=t[i++]}while(void 0!==a);else do{void 0!==(o=a[r])&&(e.push(a.time),n.push(o)),a=t[i++]}while(void 0!==a)}},subclip:function(t,e,n,r,i){i=i||30;var a=t.clone();a.name=e;for(var o=[],s=0;s=r)){u.push(c.times[d]);for(var f=0;fa.tracks[s].times[0]&&(m=a.tracks[s].times[0]);for(s=0;s=i)break t;var s=e[1];t=(i=e[--n-1]))break e}a=n,n=0}for(;n>>1;te;)--a;if(++a,0!==i||a!==r){i>=a&&(i=(a=Math.max(a,1))-1);var o=this.getValueSize();this.times=Vl.arraySlice(n,i,a),this.values=Vl.arraySlice(this.values,i*o,a*o)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);var n=this.times,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);for(var a=null,o=0;o!==i;o++){var s=n[o];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,s),t=!1;break}if(null!==a&&a>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,s,a),t=!1;break}a=s}if(void 0!==r&&Vl.isTypedArray(r)){o=0;for(var c=r.length;o!==c;++o){var l=r[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}}return t},optimize:function(){for(var t=this.times,e=this.values,n=this.getValueSize(),r=this.getInterpolation()===Ee,i=1,a=t.length-1,o=1;o0){t[i]=t[a];for(f=a*n,m=i*n,d=0;d!==n;++d)e[m+d]=e[f+d];++i}return i!==t.length&&(this.times=Vl.arraySlice(t,0,i),this.values=Vl.arraySlice(e,0,i*n)),this},clone:function(){var t=Vl.arraySlice(this.times,0),e=Vl.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}),Yl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Yl,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:Me,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Zl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Zl,ValueTypeName:"color"}),Jl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Jl,ValueTypeName:"number"}),Ql.prototype=Object.assign(Object.create(kl.prototype),{constructor:Ql,interpolate_:function(t,e,n,r){for(var i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=t*o,c=(n-e)/(r-e),l=s+o;s!==l;s+=4)wn.slerpFlat(i,0,a,s-o,a,s,c);return i}}),Kl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Kl,ValueTypeName:"quaternion",DefaultInterpolation:Se,InterpolantFactoryMethodLinear:function(t){return new Ql(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),$l.prototype=Object.assign(Object.create(Xl.prototype),{constructor:$l,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:Me,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),tu.prototype=Object.assign(Object.create(Xl.prototype),{constructor:tu,ValueTypeName:"vector"}),Object.assign(eu,{parse:function(t){for(var e=[],n=t.tracks,r=1/(t.fps||1),i=0,a=n.length;i!==a;++i)e.push(nu(n[i]).scale(r));return new eu(t.name,t.duration,e)},toJSON:function(t){for(var e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid},i=0,a=n.length;i!==a;++i)e.push(Xl.toJSON(n[i]));return r},CreateFromMorphTargetSequence:function(t,e,n,r){for(var i=e.length,a=[],o=0;o1){var l=r[h=c[1]];l||(r[h]=l=[]),l.push(s)}}var u=[];for(var h in r)u.push(eu.CreateFromMorphTargetSequence(h,r[h],e,n));return u},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var n=function(t,e,n,r,i){if(0!==n.length){var a=[],o=[];Vl.flattenJSON(n,a,o,r),0!==a.length&&i.push(new t(e,a,o))}},r=[],i=t.name||"default",a=t.length||-1,o=t.fps||30,s=t.hierarchy||[],c=0;c0||0===t.search(/^data\:image\/jpeg/);i.format=r?kt:jt,i.needsUpdate=!0,void 0!==e&&e(i)}),n,r),i}}),Object.assign(mu.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,e){var n=this.getUtoTmapping(t);return this.getPoint(n,e)},getPoints:function(t){void 0===t&&(t=5);for(var e=[],n=0;n<=t;n++)e.push(this.getPoint(n/t));return e},getSpacedPoints:function(t){void 0===t&&(t=5);for(var e=[],n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,n,r=[],i=this.getPoint(0),a=0;for(r.push(0),n=1;n<=t;n++)a+=(e=this.getPoint(n/t)).distanceTo(i),r.push(a),i=e;return this.cacheArcLengths=r,r},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){var n,r=this.getLengths(),i=0,a=r.length;n=e||t*r[a-1];for(var o,s=0,c=a-1;s<=c;)if((o=r[i=Math.floor(s+(c-s)/2)]-n)<0)s=i+1;else{if(!(o>0)){c=i;break}c=i-1}if(r[i=c]===n)return i/(a-1);var l=r[i];return(i+(n-l)/(r[i+1]-l))/(a-1)},getTangent:function(t){var e=t-1e-4,n=t+1e-4;e<0&&(e=0),n>1&&(n=1);var r=this.getPoint(e);return this.getPoint(n).clone().sub(r).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var n,r,i,a=new Sn,o=[],s=[],c=[],l=new Sn,u=new Hn;for(n=0;n<=t;n++)r=n/t,o[n]=this.getTangentAt(r),o[n].normalize();s[0]=new Sn,c[0]=new Sn;var h=Number.MAX_VALUE,d=Math.abs(o[0].x),p=Math.abs(o[0].y),f=Math.abs(o[0].z);for(d<=h&&(h=d,a.set(1,0,0)),p<=h&&(h=p,a.set(0,1,0)),f<=h&&a.set(0,0,1),l.crossVectors(o[0],a).normalize(),s[0].crossVectors(o[0],l),c[0].crossVectors(o[0],s[0]),n=1;n<=t;n++)s[n]=s[n-1].clone(),c[n]=c[n-1].clone(),l.crossVectors(o[n-1],o[n]),l.length()>Number.EPSILON&&(l.normalize(),i=Math.acos(xn.clamp(o[n-1].dot(o[n]),-1,1)),s[n].applyMatrix4(u.makeRotationAxis(l,i))),c[n].crossVectors(o[n],s[n]);if(!0===e)for(i=Math.acos(xn.clamp(s[0].dot(s[t]),-1,1)),i/=t,o[0].dot(l.crossVectors(s[0],s[t]))>0&&(i=-i),n=1;n<=t;n++)s[n].applyMatrix4(u.makeRotationAxis(o[n],i*n)),c[n].crossVectors(o[n],s[n]);return{tangents:o,normals:s,binormals:c}},clone:function(){return(new this.constructor).copy(this)},copy:function(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}}),vu.prototype=Object.create(mu.prototype),vu.prototype.constructor=vu,vu.prototype.isEllipseCurve=!0,vu.prototype.getPoint=function(t,e){for(var n=e||new bn,r=2*Math.PI,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)r;)i-=r;i0?0:(Math.floor(Math.abs(u)/c)+1)*c:0===h&&u===c-1&&(u=c-2,h=1),this.closed||u>0?n=s[(u-1)%c]:(xu.subVectors(s[0],s[1]).add(s[0]),n=xu),r=s[u%c],i=s[(u+1)%c],this.closed||u+2r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(Su(o,s.x,c.x,l.x,u.x),Su(o,s.y,c.y,l.y,u.y)),n},Du.prototype.copy=function(t){mu.prototype.copy.call(this,t),this.points=[];for(var e=0,n=t.points.length;e=e){var i=n[r]-e,a=this.curves[r],o=a.getLength(),s=0===o?0:1-i/o;return a.getPointAt(s)}r++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,n=0,r=this.curves.length;n1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},copy:function(t){mu.prototype.copy.call(this,t),this.curves=[];for(var e=0,n=t.curves.length;e0){var l=c.getPoint(0);l.equals(this.currentPoint)||this.lineTo(l.x,l.y)}this.curves.push(c);var u=c.getPoint(1);return this.currentPoint.copy(u),this},copy:function(t){return Nu.prototype.copy.call(this,t),this.currentPoint.copy(t.currentPoint),this},toJSON:function(){var t=Nu.prototype.toJSON.call(this);return t.currentPoint=this.currentPoint.toArray(),t},fromJSON:function(t){return Nu.prototype.fromJSON.call(this,t),this.currentPoint.fromArray(t.currentPoint),this}}),Fu.prototype=Object.assign(Object.create(Bu.prototype),{constructor:Fu,getPointsHoles:function(t){for(var e=[],n=0,r=this.holes.length;n0){var a=new du(new iu(e));a.setCrossOrigin(this.crossOrigin);for(var o=0,s=t.length;o0?new js(o,s):new Gi(o,s);break;case"InstancedMesh":o=i(t.geometry),s=a(t.material);var c=t.count,l=t.instanceMatrix;(r=new Zs(o,s,c)).instanceMatrix=new ri(new Float32Array(l.array),16);break;case"LOD":r=new ks;break;case"Line":r=new nc(i(t.geometry),a(t.material),t.mode);break;case"LineLoop":r=new oc(i(t.geometry),a(t.material));break;case"LineSegments":r=new ac(i(t.geometry),a(t.material));break;case"PointCloud":case"Points":r=new dc(i(t.geometry),a(t.material));break;case"Sprite":r=new Us(a(t.material));break;case"Group":r=new ps;break;default:r=new ar}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(r.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(r.matrixAutoUpdate=t.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.frustumCulled&&(r.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(r.renderOrder=t.renderOrder),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.layers&&(r.layers.mask=t.layers),void 0!==t.drawMode&&r.setDrawMode(t.drawMode),void 0!==t.children)for(var u=t.children,h=0;hNumber.EPSILON){if(l<0&&(o=e[a],c=-c,s=e[i],l=-l),t.ys.y)continue;if(t.y===o.y){if(t.x===o.x)return!0}else{var u=l*(t.x-o.x)-c*(t.y-o.y);if(0===u)return!0;if(u<0)continue;r=!r}}else{if(t.y!==o.y)continue;if(s.x<=t.x&&t.x<=o.x||o.x<=t.x&&t.x<=s.x)return!0}}return r}var i=al.isClockWise,a=this.subPaths;if(0===a.length)return[];if(!0===e)return n(a);var o,s,c,l=[];if(1===a.length)return s=a[0],(c=new Fu).curves=s.curves,l.push(c),l;var u=!i(a[0].getPoints());u=t?!u:u;var h,d,p=[],f=[],m=[],v=0;f[v]=void 0,m[v]=[];for(var g=0,y=a.length;g1){for(var x=!1,b=[],w=0,_=f.length;w<_;w++)p[w]=[];for(w=0,_=f.length;w<_;w++)for(var M=m[w],S=0;S0&&(x||(m=p))}g=0;for(var L=f.length;g0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var a=0;a!==i;++a)t[e+a]=t[n+a]},_slerp:function(t,e,n,r){wn.slerpFlat(t,e,t,e,t,n,r)},_lerp:function(t,e,n,r,i){for(var a=1-r,o=0;o!==i;++o){var s=e+o;t[s]=t[s]*a+t[n+o]*r}}});var Nh=new RegExp("[\\[\\]\\.:\\/]","g"),Bh="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",Fh=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]"),zh=/(WCOD+)?/.source.replace("WCOD",Bh),Uh=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Gh=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Hh=new RegExp("^"+Fh+zh+Uh+Gh+"$"),Vh=["material","materials","bones"];function kh(t,e,n){var r=n||jh.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}function jh(t,e,n){this.path=e,this.parsedPath=n||jh.parseTrackName(e),this.node=jh.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function Wh(){this.uuid=xn.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var t={};this._indicesByUUID=t;for(var e=0,n=arguments.length;e!==n;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var r=this;this.stats={objects:{get total(){return r._objects.length},get inUse(){return this.total-r.nCachedObjects_}},get bindingsPerObject(){return r._bindings.length}}}function qh(t,e,n){this._mixer=t,this._clip=e,this._localRoot=n||null;for(var r=e.tracks,i=r.length,a=new Array(i),o={endingStart:Ae,endingEnd:Ae},s=0;s!==i;++s){var c=r[s].createInterpolant(null);a[s]=c,c.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=we,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 Xh(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Yh(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function Zh(t,e,n){Ss.call(this,t,e),this.meshPerAttribute=n||1}function Jh(t,e,n,r){this.ray=new Pr(t,e),this.near=n||0,this.far=r||1/0,this.camera=null,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 Qh(t,e){return t.distance-e.distance}function Kh(t,e,n,r){if(!1!==t.visible&&(t.raycast(e,n),!0===r))for(var i=t.children,a=0,o=i.length;a=e){var u=e++,h=t[u];n[h.uuid]=l,t[l]=h,n[c]=u,t[u]=s;for(var d=0,p=i;d!==p;++d){var f=r[d],m=f[u],v=f[l];f[l]=m,f[u]=v}}}this.nCachedObjects_=e},uncache:function(){for(var t=this._objects,e=t.length,n=this.nCachedObjects_,r=this._indicesByUUID,i=this._bindings,a=i.length,o=0,s=arguments.length;o!==s;++o){var c=arguments[o],l=c.uuid,u=r[l];if(void 0!==u)if(delete r[l],u0)for(var c=this._interpolants,l=this._propertyBindings,u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulate(r,s)}else this._updateWeight(t)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var n=this._weightInterpolant;if(null!==n){var r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var n=this._timeScaleInterpolant;if(null!==n)e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t,n=this._clip.duration,r=this.loop,i=this._loopCount,a=r===_e;if(0===t)return-1===i?e:a&&1==(1&i)?n-e:e;if(r===be){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=n)e=n;else{if(!(e<0)){this.time=e;break t}e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=e,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),e>=n||e<0){var o=Math.floor(e/n);e-=n*o,i+=Math.abs(o);var s=this.repetitions-i;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?n:0,this.time=e,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===s){var c=t<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=e;if(a&&1==(1&i))return n-e}return e},_setEndings:function(t,e,n){var r=this._interpolantSettings;n?(r.endingStart=Te,r.endingEnd=Te):(r.endingStart=t?this.zeroSlopeAtStart?Te:Ae:Le,r.endingEnd=e?this.zeroSlopeAtEnd?Te:Ae:Le)},_scheduleFading:function(t,e,n){var r=this._mixer,i=r.time,a=this._weightInterpolant;null===a&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=e,o[1]=i+t,s[1]=n,this}}),Xh.prototype=Object.assign(Object.create(vn.prototype),{constructor:Xh,_bindAction:function(t,e){var n=t._localRoot||this._root,r=t._clip.tracks,i=r.length,a=t._propertyBindings,o=t._interpolants,s=n.uuid,c=this._bindingsByRootAndName,l=c[s];void 0===l&&(l={},c[s]=l);for(var u=0;u!==i;++u){var h=r[u],d=h.name,p=l[d];if(void 0!==p)a[u]=p;else{if(void 0!==(p=a[u])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,s,d));continue}var f=e&&e._propertyBindings[u].binding.parsedPath;++(p=new Ih(jh.create(n,d,f),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(p,s,d),a[u]=p}o[u].resultBuffer=p.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,n=t._clip.uuid,r=this._actionsByClip[n];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,n,e)}for(var i=t._propertyBindings,a=0,o=i.length;a!==o;++a){var s=i[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,n=0,r=e.length;n!==r;++n){var i=e[n];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&ethis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .getParameter() target is now required"),e=new bn),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .clampPoint() target is now required"),e=new bn),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return ed.copy(t).clamp(this.min,this.max).sub(t).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)}});var rd=new Sn,id=new Sn;function ad(t,e){this.start=void 0!==t?t:new Sn,this.end=void 0!==e?e:new Sn}function od(t){ar.call(this),this.material=t,this.render=function(){}}Object.assign(ad.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return void 0===t&&(console.warn("THREE.Line3: .getCenter() target is now required"),t=new Sn),t.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return void 0===t&&(console.warn("THREE.Line3: .delta() target is now required"),t=new Sn),t.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){return void 0===e&&(console.warn("THREE.Line3: .at() target is now required"),e=new Sn),this.delta(e).multiplyScalar(t).add(this.start)},closestPointToPointParameter:function(t,e){rd.subVectors(t,this.start),id.subVectors(this.end,this.start);var n=id.dot(id),r=id.dot(rd)/n;return e&&(r=xn.clamp(r,0,1)),r},closestPointToPoint:function(t,e,n){var r=this.closestPointToPointParameter(t,e);return void 0===n&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),n=new Sn),this.delta(n).multiplyScalar(r).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}}),od.prototype=Object.create(ar.prototype),od.prototype.constructor=od,od.prototype.isImmediateRenderObject=!0;var sd=new Sn,cd=new Sn,ld=new Tn,ud=["a","b","c"];function hd(t,e,n,r){this.object=t,this.size=void 0!==e?e:1;var i=void 0!==n?n:16711680,a=void 0!==r?r:1,o=0,s=this.object.geometry;s&&s.isGeometry?o=3*s.faces.length:s&&s.isBufferGeometry&&(o=s.attributes.normal.count);var c=new _i,l=new hi(2*o*3,3);c.setAttribute("position",l),ac.call(this,c,new Js({color:i,linewidth:a})),this.matrixAutoUpdate=!1,this.update()}hd.prototype=Object.create(ac.prototype),hd.prototype.constructor=hd,hd.prototype.update=function(){this.object.updateMatrixWorld(!0),ld.getNormalMatrix(this.object.matrixWorld);var t=this.object.matrixWorld,e=this.geometry.attributes.position,n=this.object.geometry;if(n&&n.isGeometry)for(var r=n.vertices,i=n.faces,a=0,o=0,s=i.length;o1&&t.multiplyScalar(1/e),this.children[0].material.color.copy(this.material.color)}},xd.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()};var bd=new Sn,wd=new Zr,_d=new Zr;function Md(t,e,n){ar.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;var r=new Ac(e);r.rotateY(.5*Math.PI),this.material=new ni({wireframe:!0,fog:!1}),void 0===this.color&&(this.material.vertexColors=M);var i=r.getAttribute("position"),a=new Float32Array(3*i.count);r.setAttribute("color",new ri(a,3)),this.add(new Gi(r,this.material)),this.update()}function Sd(t,e){this.lightProbe=t,this.size=e;var n={GAMMA_OUTPUT:""},r=new ea({defines:n,uniforms:{sh:{value:this.lightProbe.sh.coefficients},intensity:{value:this.lightProbe.intensity}},vertexShader:["varying vec3 vNormal;","void main() {","\tvNormal = normalize( normalMatrix * normal );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#define RECIPROCAL_PI 0.318309886","vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {","\t// matrix is assumed to be orthogonal","\treturn normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );","}","vec3 linearToOutput( in vec3 a ) {","\t#ifdef GAMMA_OUTPUT","\t\treturn pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );","\t#else","\t\treturn a;","\t#endif","}","// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf","vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {","\t// normal is assumed to have unit length","\tfloat x = normal.x, y = normal.y, z = normal.z;","\t// band 0","\tvec3 result = shCoefficients[ 0 ] * 0.886227;","\t// band 1","\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;","\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;","\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;","\t// band 2","\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;","\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;","\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );","\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;","\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );","\treturn result;","}","uniform vec3 sh[ 9 ]; // sh coefficients","uniform float intensity; // light probe intensity","varying vec3 vNormal;","void main() {","\tvec3 normal = normalize( vNormal );","\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );","\tvec3 irradiance = shGetIrradianceAt( worldNormal, sh );","\tvec3 outgoingLight = RECIPROCAL_PI * irradiance * intensity;","\toutgoingLight = linearToOutput( outgoingLight );","\tgl_FragColor = vec4( outgoingLight, 1.0 );","}"].join("\n")}),i=new ml(1,32,16);Gi.call(this,i,r),this.onBeforeRender()}function Ed(t,e,n,r){t=t||10,e=e||10,n=new Zr(void 0!==n?n:4473924),r=new Zr(void 0!==r?r:8947848);for(var i=e/2,a=t/e,o=t/2,s=[],c=[],l=0,u=0,h=-o;l<=e;l++,h+=a){s.push(-o,0,h,o,0,h),s.push(h,0,-o,h,0,o);var d=l===i?n:r;d.toArray(c,u),u+=3,d.toArray(c,u),u+=3,d.toArray(c,u),u+=3,d.toArray(c,u),u+=3}var p=new _i;p.setAttribute("position",new hi(s,3)),p.setAttribute("color",new hi(c,3));var f=new Js({vertexColors:M});ac.call(this,p,f)}function Ad(t,e,n,r,i,a){t=t||10,e=e||16,n=n||8,r=r||64,i=new Zr(void 0!==i?i:4473924),a=new Zr(void 0!==a?a:8947848);var o,s,c,l,u,h,d,p=[],f=[];for(l=0;l<=e;l++)c=l/e*(2*Math.PI),o=Math.sin(c)*t,s=Math.cos(c)*t,p.push(0,0,0),p.push(o,0,s),d=1&l?i:a,f.push(d.r,d.g,d.b),f.push(d.r,d.g,d.b);for(l=0;l<=n;l++)for(d=1&l?i:a,h=t-t/n*l,u=0;u.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{qd.set(t.z,0,-t.x).normalize();var e=Math.acos(t.y);this.quaternion.setFromAxisAngle(qd,e)}},Xd.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(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()},Xd.prototype.setColor=function(t){this.line.material.color.set(t),this.cone.material.color.set(t)},Xd.prototype.copy=function(t){return ar.prototype.copy.call(this,t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this},Xd.prototype.clone=function(){return(new this.constructor).copy(this)},Yd.prototype=Object.create(ac.prototype),Yd.prototype.constructor=Yd;var Jd=0,Qd=1;function Kd(t){return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."),t}function $d(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 tp(t,e){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new dc(t,e)}function ep(t){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new Us(t)}function np(t,e){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new dc(t,e)}function rp(t){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new sc(t)}function ip(t){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new sc(t)}function ap(t){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new sc(t)}function op(t,e,n){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new Sn(t,e,n)}function sp(t,e){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead."),new ri(t,e).setDynamic(!0)}function cp(t,e){return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."),new ii(t,e)}function lp(t,e){return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."),new ai(t,e)}function up(t,e){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."),new oi(t,e)}function hp(t,e){return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."),new si(t,e)}function dp(t,e){return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."),new ci(t,e)}function pp(t,e){return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."),new li(t,e)}function fp(t,e){return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."),new ui(t,e)}function mp(t,e){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new hi(t,e)}function vp(t,e){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new di(t,e)}function gp(t){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Mu.call(this,t),this.type="catmullrom",this.closed=!0}function yp(t){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Mu.call(this,t),this.type="catmullrom"}function xp(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),Mu.call(this,t),this.type="catmullrom"}function bp(t){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new Yd(t)}function wp(t,e){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Hd(t,e)}function _p(t,e){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new ac(new Ml(t.geometry),new Js({color:void 0!==e?e:16777215}))}function Mp(t,e){return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."),new ac(new yc(t.geometry),new Js({color:void 0!==e?e:16777215}))}function Sp(t){return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."),new cu(t)}function Ep(t){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new hu(t)}mu.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(mu.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},Object.assign(Nu.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 Xi,n=0,r=t.length;n0){var o=r[0],s=new i.Matrix4;s.getInverse(t.matrixWorld);var c=o.object;c.matrix.premultiply(s),c.matrix.decompose(c.position,c.quaternion,c.scale),t.add(c),t.userData.selected=c}}),!1),document.body.addEventListener("mouseup",(function(){if(void 0!==t.userData.selected){var n=t.userData.selected;n.matrix.premultiply(t.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale),t.remove(n),e.add(n),t.userData.selected=void 0}}),!1)}},function(t,e,n){"use strict";n.r(e),n.d(e,"ACESFilmicToneMapping",(function(){return ct})),n.d(e,"AddEquation",(function(){return P})),n.d(e,"AddOperation",(function(){return nt})),n.d(e,"AdditiveBlending",(function(){return A})),n.d(e,"AlphaFormat",(function(){return Vt})),n.d(e,"AlwaysDepth",(function(){return X})),n.d(e,"AlwaysStencilFunc",(function(){return on})),n.d(e,"AmbientLight",(function(){return Yu})),n.d(e,"AmbientLightProbe",(function(){return gh})),n.d(e,"AnimationClip",(function(){return eu})),n.d(e,"AnimationLoader",(function(){return lu})),n.d(e,"AnimationMixer",(function(){return Xh})),n.d(e,"AnimationObjectGroup",(function(){return Wh})),n.d(e,"AnimationUtils",(function(){return Vl})),n.d(e,"ArcCurve",(function(){return gu})),n.d(e,"ArrayCamera",(function(){return fs})),n.d(e,"ArrowHelper",(function(){return Xd})),n.d(e,"Audio",(function(){return Th})),n.d(e,"AudioAnalyser",(function(){return Dh})),n.d(e,"AudioContext",(function(){return dh})),n.d(e,"AudioListener",(function(){return Ah})),n.d(e,"AudioLoader",(function(){return ph})),n.d(e,"AxesHelper",(function(){return Yd})),n.d(e,"AxisHelper",(function(){return bp})),n.d(e,"BackSide",(function(){return g})),n.d(e,"BasicDepthPacking",(function(){return Ge})),n.d(e,"BasicShadowMap",(function(){return d})),n.d(e,"BinaryTextureLoader",(function(){return Ep})),n.d(e,"Bone",(function(){return Ys})),n.d(e,"BooleanKeyframeTrack",(function(){return Yl})),n.d(e,"BoundingBoxHelper",(function(){return wp})),n.d(e,"Box2",(function(){return nd})),n.d(e,"Box3",(function(){return xr})),n.d(e,"Box3Helper",(function(){return Vd})),n.d(e,"BoxBufferGeometry",(function(){return Zi})),n.d(e,"BoxGeometry",(function(){return Yi})),n.d(e,"BoxHelper",(function(){return Hd})),n.d(e,"BufferAttribute",(function(){return ri})),n.d(e,"BufferGeometry",(function(){return _i})),n.d(e,"BufferGeometryLoader",(function(){return th})),n.d(e,"ByteType",(function(){return Ct})),n.d(e,"Cache",(function(){return ru})),n.d(e,"Camera",(function(){return na})),n.d(e,"CameraHelper",(function(){return zd})),n.d(e,"CanvasRenderer",(function(){return Tp})),n.d(e,"CanvasTexture",(function(){return vc})),n.d(e,"CatmullRomCurve3",(function(){return Mu})),n.d(e,"CineonToneMapping",(function(){return st})),n.d(e,"CircleBufferGeometry",(function(){return Rl})),n.d(e,"CircleGeometry",(function(){return Ll})),n.d(e,"ClampToEdgeWrapping",(function(){return yt})),n.d(e,"Clock",(function(){return wh})),n.d(e,"ClosedSplineCurve3",(function(){return gp})),n.d(e,"Color",(function(){return Zr})),n.d(e,"ColorKeyframeTrack",(function(){return Zl})),n.d(e,"CompressedTexture",(function(){return mc})),n.d(e,"CompressedTextureLoader",(function(){return uu})),n.d(e,"ConeBufferGeometry",(function(){return Tl})),n.d(e,"ConeGeometry",(function(){return Al})),n.d(e,"CubeCamera",(function(){return oa})),n.d(e,"CubeGeometry",(function(){return Yi})),n.d(e,"CubeReflectionMapping",(function(){return ut})),n.d(e,"CubeRefractionMapping",(function(){return ht})),n.d(e,"CubeTexture",(function(){return Pa})),n.d(e,"CubeTextureLoader",(function(){return pu})),n.d(e,"CubeUVReflectionMapping",(function(){return mt})),n.d(e,"CubeUVRefractionMapping",(function(){return vt})),n.d(e,"CubicBezierCurve",(function(){return Tu})),n.d(e,"CubicBezierCurve3",(function(){return Lu})),n.d(e,"CubicInterpolant",(function(){return jl})),n.d(e,"CullFaceBack",(function(){return s})),n.d(e,"CullFaceFront",(function(){return c})),n.d(e,"CullFaceFrontBack",(function(){return l})),n.d(e,"CullFaceNone",(function(){return o})),n.d(e,"Curve",(function(){return mu})),n.d(e,"CurvePath",(function(){return Nu})),n.d(e,"CustomBlending",(function(){return R})),n.d(e,"CylinderBufferGeometry",(function(){return El})),n.d(e,"CylinderGeometry",(function(){return Sl})),n.d(e,"Cylindrical",(function(){return td})),n.d(e,"DataTexture",(function(){return ca})),n.d(e,"DataTexture2DArray",(function(){return Ca})),n.d(e,"DataTexture3D",(function(){return Oa})),n.d(e,"DataTextureLoader",(function(){return hu})),n.d(e,"DecrementStencilOp",(function(){return Ye})),n.d(e,"DecrementWrapStencilOp",(function(){return Je})),n.d(e,"DefaultLoadingManager",(function(){return au})),n.d(e,"DepthFormat",(function(){return Yt})),n.d(e,"DepthStencilFormat",(function(){return Zt})),n.d(e,"DepthTexture",(function(){return gc})),n.d(e,"DirectionalLight",(function(){return Xu})),n.d(e,"DirectionalLightHelper",(function(){return Nd})),n.d(e,"DirectionalLightShadow",(function(){return qu})),n.d(e,"DiscreteInterpolant",(function(){return ql})),n.d(e,"DodecahedronBufferGeometry",(function(){return Pc})),n.d(e,"DodecahedronGeometry",(function(){return Rc})),n.d(e,"DoubleSide",(function(){return y})),n.d(e,"DstAlphaFactor",(function(){return H})),n.d(e,"DstColorFactor",(function(){return k})),n.d(e,"DynamicBufferAttribute",(function(){return sp})),n.d(e,"DynamicCopyUsage",(function(){return fn})),n.d(e,"DynamicDrawUsage",(function(){return cn})),n.d(e,"DynamicReadUsage",(function(){return hn})),n.d(e,"EdgesGeometry",(function(){return Ml})),n.d(e,"EdgesHelper",(function(){return _p})),n.d(e,"EllipseCurve",(function(){return vu})),n.d(e,"EqualDepth",(function(){return J})),n.d(e,"EqualStencilFunc",(function(){return tn})),n.d(e,"EquirectangularReflectionMapping",(function(){return dt})),n.d(e,"EquirectangularRefractionMapping",(function(){return pt})),n.d(e,"Euler",(function(){return jn})),n.d(e,"EventDispatcher",(function(){return vn})),n.d(e,"ExtrudeBufferGeometry",(function(){return ll})),n.d(e,"ExtrudeGeometry",(function(){return cl})),n.d(e,"Face3",(function(){return $r})),n.d(e,"Face4",(function(){return Zd})),n.d(e,"FaceColors",(function(){return _})),n.d(e,"FaceNormalsHelper",(function(){return Cd})),n.d(e,"FileLoader",(function(){return cu})),n.d(e,"FlatShading",(function(){return x})),n.d(e,"Float32Attribute",(function(){return mp})),n.d(e,"Float32BufferAttribute",(function(){return hi})),n.d(e,"Float64Attribute",(function(){return vp})),n.d(e,"Float64BufferAttribute",(function(){return di})),n.d(e,"FloatType",(function(){return Bt})),n.d(e,"Fog",(function(){return Ms})),n.d(e,"FogExp2",(function(){return _s})),n.d(e,"Font",(function(){return lh})),n.d(e,"FontLoader",(function(){return hh})),n.d(e,"FrontFaceDirectionCCW",(function(){return h})),n.d(e,"FrontFaceDirectionCW",(function(){return u})),n.d(e,"FrontSide",(function(){return v})),n.d(e,"Frustum",(function(){return ha})),n.d(e,"GammaEncoding",(function(){return Ie})),n.d(e,"Geometry",(function(){return Xi})),n.d(e,"GeometryUtils",(function(){return Ap})),n.d(e,"GreaterDepth",(function(){return K})),n.d(e,"GreaterEqualDepth",(function(){return Q})),n.d(e,"GreaterEqualStencilFunc",(function(){return an})),n.d(e,"GreaterStencilFunc",(function(){return nn})),n.d(e,"GridHelper",(function(){return Ed})),n.d(e,"Group",(function(){return ps})),n.d(e,"HalfFloatType",(function(){return Ft})),n.d(e,"HemisphereLight",(function(){return Uu})),n.d(e,"HemisphereLightHelper",(function(){return Md})),n.d(e,"HemisphereLightProbe",(function(){return vh})),n.d(e,"IcosahedronBufferGeometry",(function(){return Lc})),n.d(e,"IcosahedronGeometry",(function(){return Tc})),n.d(e,"ImageBitmapLoader",(function(){return sh})),n.d(e,"ImageLoader",(function(){return du})),n.d(e,"ImageUtils",(function(){return Ln})),n.d(e,"ImmediateRenderObject",(function(){return od})),n.d(e,"IncrementStencilOp",(function(){return Xe})),n.d(e,"IncrementWrapStencilOp",(function(){return Ze})),n.d(e,"InstancedBufferAttribute",(function(){return $u})),n.d(e,"InstancedBufferGeometry",(function(){return Ku})),n.d(e,"InstancedInterleavedBuffer",(function(){return Zh})),n.d(e,"InstancedMesh",(function(){return Zs})),n.d(e,"Int16Attribute",(function(){return hp})),n.d(e,"Int16BufferAttribute",(function(){return si})),n.d(e,"Int32Attribute",(function(){return pp})),n.d(e,"Int32BufferAttribute",(function(){return li})),n.d(e,"Int8Attribute",(function(){return cp})),n.d(e,"Int8BufferAttribute",(function(){return ii})),n.d(e,"IntType",(function(){return It})),n.d(e,"InterleavedBuffer",(function(){return Ss})),n.d(e,"InterleavedBufferAttribute",(function(){return Es})),n.d(e,"Interpolant",(function(){return kl})),n.d(e,"InterpolateDiscrete",(function(){return Me})),n.d(e,"InterpolateLinear",(function(){return Se})),n.d(e,"InterpolateSmooth",(function(){return Ee})),n.d(e,"InvertStencilOp",(function(){return Qe})),n.d(e,"JSONLoader",(function(){return Lp})),n.d(e,"KeepStencilOp",(function(){return We})),n.d(e,"KeyframeTrack",(function(){return Xl})),n.d(e,"LOD",(function(){return ks})),n.d(e,"LatheBufferGeometry",(function(){return xl})),n.d(e,"LatheGeometry",(function(){return yl})),n.d(e,"Layers",(function(){return Wn})),n.d(e,"LensFlare",(function(){return Pp})),n.d(e,"LessDepth",(function(){return Y})),n.d(e,"LessEqualDepth",(function(){return Z})),n.d(e,"LessEqualStencilFunc",(function(){return en})),n.d(e,"LessStencilFunc",(function(){return $e})),n.d(e,"Light",(function(){return zu})),n.d(e,"LightProbe",(function(){return mh})),n.d(e,"LightProbeHelper",(function(){return Sd})),n.d(e,"LightShadow",(function(){return Gu})),n.d(e,"Line",(function(){return nc})),n.d(e,"Line3",(function(){return ad})),n.d(e,"LineBasicMaterial",(function(){return Js})),n.d(e,"LineCurve",(function(){return Ru})),n.d(e,"LineCurve3",(function(){return Pu})),n.d(e,"LineDashedMaterial",(function(){return Gl})),n.d(e,"LineLoop",(function(){return oc})),n.d(e,"LinePieces",(function(){return Qd})),n.d(e,"LineSegments",(function(){return ac})),n.d(e,"LineStrip",(function(){return Jd})),n.d(e,"LinearEncoding",(function(){return Oe})),n.d(e,"LinearFilter",(function(){return Et})),n.d(e,"LinearInterpolant",(function(){return Wl})),n.d(e,"LinearMipMapLinearFilter",(function(){return Rt})),n.d(e,"LinearMipMapNearestFilter",(function(){return Tt})),n.d(e,"LinearMipmapLinearFilter",(function(){return Lt})),n.d(e,"LinearMipmapNearestFilter",(function(){return At})),n.d(e,"LinearToneMapping",(function(){return it})),n.d(e,"Loader",(function(){return ou})),n.d(e,"LoaderUtils",(function(){return Qu})),n.d(e,"LoadingManager",(function(){return iu})),n.d(e,"LogLuvEncoding",(function(){return Be})),n.d(e,"LoopOnce",(function(){return be})),n.d(e,"LoopPingPong",(function(){return _e})),n.d(e,"LoopRepeat",(function(){return we})),n.d(e,"LuminanceAlphaFormat",(function(){return qt})),n.d(e,"LuminanceFormat",(function(){return Wt})),n.d(e,"MOUSE",(function(){return i})),n.d(e,"Material",(function(){return ei})),n.d(e,"MaterialLoader",(function(){return Ju})),n.d(e,"Math",(function(){return xn})),n.d(e,"Matrix3",(function(){return Tn})),n.d(e,"Matrix4",(function(){return Hn})),n.d(e,"MaxEquation",(function(){return I})),n.d(e,"Mesh",(function(){return Gi})),n.d(e,"MeshBasicMaterial",(function(){return ni})),n.d(e,"MeshDepthMaterial",(function(){return rs})),n.d(e,"MeshDistanceMaterial",(function(){return is})),n.d(e,"MeshFaceMaterial",(function(){return Kd})),n.d(e,"MeshLambertMaterial",(function(){return zl})),n.d(e,"MeshMatcapMaterial",(function(){return Ul})),n.d(e,"MeshNormalMaterial",(function(){return Fl})),n.d(e,"MeshPhongMaterial",(function(){return Nl})),n.d(e,"MeshPhysicalMaterial",(function(){return Il})),n.d(e,"MeshStandardMaterial",(function(){return Dl})),n.d(e,"MeshToonMaterial",(function(){return Bl})),n.d(e,"MinEquation",(function(){return D})),n.d(e,"MirroredRepeatWrapping",(function(){return xt})),n.d(e,"MixOperation",(function(){return et})),n.d(e,"MultiMaterial",(function(){return $d})),n.d(e,"MultiplyBlending",(function(){return L})),n.d(e,"MultiplyOperation",(function(){return tt})),n.d(e,"NearestFilter",(function(){return bt})),n.d(e,"NearestMipMapLinearFilter",(function(){return St})),n.d(e,"NearestMipMapNearestFilter",(function(){return _t})),n.d(e,"NearestMipmapLinearFilter",(function(){return Mt})),n.d(e,"NearestMipmapNearestFilter",(function(){return wt})),n.d(e,"NeverDepth",(function(){return q})),n.d(e,"NeverStencilFunc",(function(){return Ke})),n.d(e,"NoBlending",(function(){return S})),n.d(e,"NoColors",(function(){return w})),n.d(e,"NoToneMapping",(function(){return rt})),n.d(e,"NormalBlending",(function(){return E})),n.d(e,"NotEqualDepth",(function(){return $})),n.d(e,"NotEqualStencilFunc",(function(){return rn})),n.d(e,"NumberKeyframeTrack",(function(){return Jl})),n.d(e,"Object3D",(function(){return ar})),n.d(e,"ObjectLoader",(function(){return nh})),n.d(e,"ObjectSpaceNormalMap",(function(){return ke})),n.d(e,"OctahedronBufferGeometry",(function(){return Ac})),n.d(e,"OctahedronGeometry",(function(){return Ec})),n.d(e,"OneFactor",(function(){return B})),n.d(e,"OneMinusDstAlphaFactor",(function(){return V})),n.d(e,"OneMinusDstColorFactor",(function(){return j})),n.d(e,"OneMinusSrcAlphaFactor",(function(){return G})),n.d(e,"OneMinusSrcColorFactor",(function(){return z})),n.d(e,"OrthographicCamera",(function(){return Wu})),n.d(e,"PCFShadowMap",(function(){return p})),n.d(e,"PCFSoftShadowMap",(function(){return f})),n.d(e,"ParametricBufferGeometry",(function(){return bc})),n.d(e,"ParametricGeometry",(function(){return xc})),n.d(e,"Particle",(function(){return ep})),n.d(e,"ParticleBasicMaterial",(function(){return ip})),n.d(e,"ParticleSystem",(function(){return np})),n.d(e,"ParticleSystemMaterial",(function(){return ap})),n.d(e,"Path",(function(){return Bu})),n.d(e,"PerspectiveCamera",(function(){return ra})),n.d(e,"Plane",(function(){return Ir})),n.d(e,"PlaneBufferGeometry",(function(){return ya})),n.d(e,"PlaneGeometry",(function(){return ga})),n.d(e,"PlaneHelper",(function(){return kd})),n.d(e,"PointCloud",(function(){return tp})),n.d(e,"PointCloudMaterial",(function(){return rp})),n.d(e,"PointLight",(function(){return ju})),n.d(e,"PointLightHelper",(function(){return yd})),n.d(e,"Points",(function(){return dc})),n.d(e,"PointsMaterial",(function(){return sc})),n.d(e,"PolarGridHelper",(function(){return Ad})),n.d(e,"PolyhedronBufferGeometry",(function(){return _c})),n.d(e,"PolyhedronGeometry",(function(){return wc})),n.d(e,"PositionalAudio",(function(){return Oh})),n.d(e,"PositionalAudioHelper",(function(){return Td})),n.d(e,"PropertyBinding",(function(){return jh})),n.d(e,"PropertyMixer",(function(){return Ih})),n.d(e,"QuadraticBezierCurve",(function(){return Cu})),n.d(e,"QuadraticBezierCurve3",(function(){return Ou})),n.d(e,"Quaternion",(function(){return wn})),n.d(e,"QuaternionKeyframeTrack",(function(){return Kl})),n.d(e,"QuaternionLinearInterpolant",(function(){return Ql})),n.d(e,"REVISION",(function(){return r})),n.d(e,"RGBADepthPacking",(function(){return He})),n.d(e,"RGBAFormat",(function(){return jt})),n.d(e,"RGBA_ASTC_10x10_Format",(function(){return ge})),n.d(e,"RGBA_ASTC_10x5_Format",(function(){return fe})),n.d(e,"RGBA_ASTC_10x6_Format",(function(){return me})),n.d(e,"RGBA_ASTC_10x8_Format",(function(){return ve})),n.d(e,"RGBA_ASTC_12x10_Format",(function(){return ye})),n.d(e,"RGBA_ASTC_12x12_Format",(function(){return xe})),n.d(e,"RGBA_ASTC_4x4_Format",(function(){return oe})),n.d(e,"RGBA_ASTC_5x4_Format",(function(){return se})),n.d(e,"RGBA_ASTC_5x5_Format",(function(){return ce})),n.d(e,"RGBA_ASTC_6x5_Format",(function(){return le})),n.d(e,"RGBA_ASTC_6x6_Format",(function(){return ue})),n.d(e,"RGBA_ASTC_8x5_Format",(function(){return he})),n.d(e,"RGBA_ASTC_8x6_Format",(function(){return de})),n.d(e,"RGBA_ASTC_8x8_Format",(function(){return pe})),n.d(e,"RGBA_PVRTC_2BPPV1_Format",(function(){return ie})),n.d(e,"RGBA_PVRTC_4BPPV1_Format",(function(){return re})),n.d(e,"RGBA_S3TC_DXT1_Format",(function(){return Kt})),n.d(e,"RGBA_S3TC_DXT3_Format",(function(){return $t})),n.d(e,"RGBA_S3TC_DXT5_Format",(function(){return te})),n.d(e,"RGBDEncoding",(function(){return Ue})),n.d(e,"RGBEEncoding",(function(){return Ne})),n.d(e,"RGBEFormat",(function(){return Xt})),n.d(e,"RGBFormat",(function(){return kt})),n.d(e,"RGBM16Encoding",(function(){return ze})),n.d(e,"RGBM7Encoding",(function(){return Fe})),n.d(e,"RGB_ETC1_Format",(function(){return ae})),n.d(e,"RGB_PVRTC_2BPPV1_Format",(function(){return ne})),n.d(e,"RGB_PVRTC_4BPPV1_Format",(function(){return ee})),n.d(e,"RGB_S3TC_DXT1_Format",(function(){return Qt})),n.d(e,"RawShaderMaterial",(function(){return Ol})),n.d(e,"Ray",(function(){return Pr})),n.d(e,"Raycaster",(function(){return Jh})),n.d(e,"RectAreaLight",(function(){return Zu})),n.d(e,"RectAreaLightHelper",(function(){return xd})),n.d(e,"RedFormat",(function(){return Jt})),n.d(e,"ReinhardToneMapping",(function(){return at})),n.d(e,"RepeatWrapping",(function(){return gt})),n.d(e,"ReplaceStencilOp",(function(){return qe})),n.d(e,"ReverseSubtractEquation",(function(){return O})),n.d(e,"RingBufferGeometry",(function(){return gl})),n.d(e,"RingGeometry",(function(){return vl})),n.d(e,"Scene",(function(){return or})),n.d(e,"SceneUtils",(function(){return Rp})),n.d(e,"ShaderChunk",(function(){return da})),n.d(e,"ShaderLib",(function(){return fa})),n.d(e,"ShaderMaterial",(function(){return ea})),n.d(e,"ShadowMaterial",(function(){return Cl})),n.d(e,"Shape",(function(){return Fu})),n.d(e,"ShapeBufferGeometry",(function(){return wl})),n.d(e,"ShapeGeometry",(function(){return bl})),n.d(e,"ShapePath",(function(){return ch})),n.d(e,"ShapeUtils",(function(){return al})),n.d(e,"ShortType",(function(){return Ot})),n.d(e,"Skeleton",(function(){return Xs})),n.d(e,"SkeletonHelper",(function(){return gd})),n.d(e,"SkinnedMesh",(function(){return js})),n.d(e,"SmoothShading",(function(){return b})),n.d(e,"Sphere",(function(){return _r})),n.d(e,"SphereBufferGeometry",(function(){return ml})),n.d(e,"SphereGeometry",(function(){return fl})),n.d(e,"Spherical",(function(){return $h})),n.d(e,"SphericalHarmonics3",(function(){return fh})),n.d(e,"SphericalReflectionMapping",(function(){return ft})),n.d(e,"Spline",(function(){return xp})),n.d(e,"SplineCurve",(function(){return Du})),n.d(e,"SplineCurve3",(function(){return yp})),n.d(e,"SpotLight",(function(){return Vu})),n.d(e,"SpotLightHelper",(function(){return pd})),n.d(e,"SpotLightShadow",(function(){return Hu})),n.d(e,"Sprite",(function(){return Us})),n.d(e,"SpriteMaterial",(function(){return As})),n.d(e,"SrcAlphaFactor",(function(){return U})),n.d(e,"SrcAlphaSaturateFactor",(function(){return W})),n.d(e,"SrcColorFactor",(function(){return F})),n.d(e,"StaticCopyUsage",(function(){return pn})),n.d(e,"StaticDrawUsage",(function(){return sn})),n.d(e,"StaticReadUsage",(function(){return un})),n.d(e,"StereoCamera",(function(){return bh})),n.d(e,"StreamCopyUsage",(function(){return mn})),n.d(e,"StreamDrawUsage",(function(){return ln})),n.d(e,"StreamReadUsage",(function(){return dn})),n.d(e,"StringKeyframeTrack",(function(){return $l})),n.d(e,"SubtractEquation",(function(){return C})),n.d(e,"SubtractiveBlending",(function(){return T})),n.d(e,"TOUCH",(function(){return a})),n.d(e,"TangentSpaceNormalMap",(function(){return Ve})),n.d(e,"TetrahedronBufferGeometry",(function(){return Sc})),n.d(e,"TetrahedronGeometry",(function(){return Mc})),n.d(e,"TextBufferGeometry",(function(){return pl})),n.d(e,"TextGeometry",(function(){return dl})),n.d(e,"Texture",(function(){return Pn})),n.d(e,"TextureLoader",(function(){return fu})),n.d(e,"TorusBufferGeometry",(function(){return Bc})),n.d(e,"TorusGeometry",(function(){return Nc})),n.d(e,"TorusKnotBufferGeometry",(function(){return Ic})),n.d(e,"TorusKnotGeometry",(function(){return Dc})),n.d(e,"Triangle",(function(){return Wr})),n.d(e,"TriangleFanDrawMode",(function(){return Ce})),n.d(e,"TriangleStripDrawMode",(function(){return Pe})),n.d(e,"TrianglesDrawMode",(function(){return Re})),n.d(e,"TubeBufferGeometry",(function(){return Oc})),n.d(e,"TubeGeometry",(function(){return Cc})),n.d(e,"UVMapping",(function(){return lt})),n.d(e,"Uint16Attribute",(function(){return dp})),n.d(e,"Uint16BufferAttribute",(function(){return ci})),n.d(e,"Uint32Attribute",(function(){return fp})),n.d(e,"Uint32BufferAttribute",(function(){return ui})),n.d(e,"Uint8Attribute",(function(){return lp})),n.d(e,"Uint8BufferAttribute",(function(){return ai})),n.d(e,"Uint8ClampedAttribute",(function(){return up})),n.d(e,"Uint8ClampedBufferAttribute",(function(){return oi})),n.d(e,"Uncharted2ToneMapping",(function(){return ot})),n.d(e,"Uniform",(function(){return Yh})),n.d(e,"UniformsLib",(function(){return pa})),n.d(e,"UniformsUtils",(function(){return Ki})),n.d(e,"UnsignedByteType",(function(){return Pt})),n.d(e,"UnsignedInt248Type",(function(){return Ht})),n.d(e,"UnsignedIntType",(function(){return Nt})),n.d(e,"UnsignedShort4444Type",(function(){return zt})),n.d(e,"UnsignedShort5551Type",(function(){return Ut})),n.d(e,"UnsignedShort565Type",(function(){return Gt})),n.d(e,"UnsignedShortType",(function(){return Dt})),n.d(e,"VSMShadowMap",(function(){return m})),n.d(e,"Vector2",(function(){return bn})),n.d(e,"Vector3",(function(){return Sn})),n.d(e,"Vector4",(function(){return Cn})),n.d(e,"VectorKeyframeTrack",(function(){return tu})),n.d(e,"Vertex",(function(){return op})),n.d(e,"VertexColors",(function(){return M})),n.d(e,"VertexNormalsHelper",(function(){return hd})),n.d(e,"VideoTexture",(function(){return fc})),n.d(e,"WebGLMultisampleRenderTarget",(function(){return Dn})),n.d(e,"WebGLRenderTarget",(function(){return On})),n.d(e,"WebGLRenderTargetCube",(function(){return sa})),n.d(e,"WebGLRenderer",(function(){return ws})),n.d(e,"WebGLUtils",(function(){return us})),n.d(e,"WireframeGeometry",(function(){return yc})),n.d(e,"WireframeHelper",(function(){return Mp})),n.d(e,"WrapAroundEnding",(function(){return Le})),n.d(e,"XHRLoader",(function(){return Sp})),n.d(e,"ZeroCurvatureEnding",(function(){return Ae})),n.d(e,"ZeroFactor",(function(){return N})),n.d(e,"ZeroSlopeEnding",(function(){return Te})),n.d(e,"ZeroStencilOp",(function(){return je})),n.d(e,"sRGBEncoding",(function(){return De})),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>8&255]+gn[t>>16&255]+gn[t>>24&255]+"-"+gn[255&e]+gn[e>>8&255]+"-"+gn[e>>16&15|64]+gn[e>>24&255]+"-"+gn[63&n|128]+gn[n>>8&255]+"-"+gn[n>>16&255]+gn[n>>24&255]+gn[255&r]+gn[r>>8&255]+gn[r>>16&255]+gn[r>>24&255]).toUpperCase()},clamp:function(t,e,n){return Math.max(e,Math.min(n,t))},euclideanModulo:function(t,e){return(t%e+e)%e},mapLinear:function(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)},lerp:function(t,e,n){return(1-n)*t+n*e},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*xn.DEG2RAD},radToDeg:function(t){return t*xn.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 bn(t,e){this.x=t||0,this.y=e||0}function wn(t,e,n,r){this._x=t||0,this._y=e||0,this._z=n||0,this._w=void 0!==r?r:1}Object.defineProperties(bn.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(bn.prototype,{isVector2:!0,set:function(t,e){return this.x=t,this.y=e,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},applyMatrix3:function(t){var e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this},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},cross:function(t){return this.x*t.y-this.y*t.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var t=Math.atan2(this.y,this.x);return t<0&&(t+=2*Math.PI),t},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,n=this.y-t.y;return e*e+n*n},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this},rotateAround:function(t,e){var n=Math.cos(e),r=Math.sin(e),i=this.x-t.x,a=this.y-t.y;return this.x=i*n-a*r+t.x,this.y=i*r+a*n+t.y,this}}),Object.assign(wn,{slerp:function(t,e,n,r){return n.copy(t).slerp(e,r)},slerpFlat:function(t,e,n,r,i,a,o){var s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],h=i[a+0],d=i[a+1],p=i[a+2],f=i[a+3];if(u!==f||s!==h||c!==d||l!==p){var m=1-o,v=s*h+c*d+l*p+u*f,g=v>=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var x=Math.sqrt(y),b=Math.atan2(x,v*g);m=Math.sin(m*b)/x,o=Math.sin(o*b)/x}var w=o*g;if(s=s*m+h*w,c=c*m+d*w,l=l*m+p*w,u=u*m+f*w,m===1-o){var _=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=_,c*=_,l*=_,u*=_}}t[e]=s,t[e+1]=c,t[e+2]=l,t[e+3]=u}}),Object.defineProperties(wn.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(wn.prototype,{isQuaternion:!0,set:function(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this},setFromEuler:function(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=t._x,r=t._y,i=t._z,a=t.order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),h=s(n/2),d=s(r/2),p=s(i/2);return"XYZ"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u-h*d*p):"YXZ"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u+h*d*p):"ZXY"===a?(this._x=h*l*u-c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u-h*d*p):"ZYX"===a?(this._x=h*l*u-c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u+h*d*p):"YZX"===a?(this._x=h*l*u+c*d*p,this._y=c*d*u+h*l*p,this._z=c*l*p-h*d*u,this._w=c*l*u-h*d*p):"XZY"===a&&(this._x=h*l*u-c*d*p,this._y=c*d*u-h*l*p,this._z=c*l*p+h*d*u,this._w=c*l*u+h*d*p),!1!==e&&this._onChangeCallback(),this},setFromAxisAngle:function(t,e){var n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this},setFromRotationMatrix:function(t){var e,n=t.elements,r=n[0],i=n[4],a=n[8],o=n[1],s=n[5],c=n[9],l=n[2],u=n[6],h=n[10],d=r+s+h;return d>0?(e=.5/Math.sqrt(d+1),this._w=.25/e,this._x=(u-c)*e,this._y=(a-l)*e,this._z=(o-i)*e):r>s&&r>h?(e=2*Math.sqrt(1+r-s-h),this._w=(u-c)/e,this._x=.25*e,this._y=(i+o)/e,this._z=(a+l)/e):s>h?(e=2*Math.sqrt(1+s-r-h),this._w=(a-l)/e,this._x=(i+o)/e,this._y=.25*e,this._z=(c+u)/e):(e=2*Math.sqrt(1+h-r-s),this._w=(o-i)/e,this._x=(a+l)/e,this._y=(c+u)/e,this._z=.25*e),this._onChangeCallback(),this},setFromUnitVectors:function(t,e){var n=t.dot(e)+1;return n<1e-6?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()},angleTo:function(t){return 2*Math.acos(Math.abs(xn.clamp(this.dot(t),-1,1)))},rotateTowards:function(t,e){var n=this.angleTo(t);if(0===n)return this;var r=Math.min(1,e/n);return this.slerp(t,r),this},inverse:function(){return this.conjugate()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,e){var n=t._x,r=t._y,i=t._z,a=t._w,o=e._x,s=e._y,c=e._z,l=e._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var n=this._x,r=this._y,i=this._z,a=this._w,o=a*t._w+n*t._x+r*t._y+i*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;var s=1-o*o;if(s<=Number.EPSILON){var c=1-e;return this._w=c*a+e*this._w,this._x=c*n+e*this._x,this._y=c*r+e*this._y,this._z=c*i+e*this._z,this.normalize(),this._onChangeCallback(),this}var l=Math.sqrt(s),u=Math.atan2(l,o),h=Math.sin((1-e)*u)/l,d=Math.sin(e*u)/l;return this._w=a*h+this._w*d,this._x=n*h+this._x*d,this._y=r*h+this._y*d,this._z=i*h+this._z*d,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(){}});var _n=new Sn,Mn=new wn;function Sn(t,e,n){this.x=t||0,this.y=e||0,this.z=n||0}Object.assign(Sn.prototype,{isVector3:!0,set:function(t,e,n){return this.x=t,this.y=e,this.z=n,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Mn.setFromEuler(t))},applyAxisAngle:function(t,e){return this.applyQuaternion(Mn.setFromAxisAngle(t,e))},applyMatrix3:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*r,this.y=i[1]*e+i[4]*n+i[7]*r,this.z=i[2]*e+i[5]*n+i[8]*r,this},applyMatrix4:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements,a=1/(i[3]*e+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*e+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*e+i[6]*n+i[10]*r+i[14])*a,this},applyQuaternion:function(t){var e=this.x,n=this.y,r=this.z,i=t.x,a=t.y,o=t.z,s=t.w,c=s*e+a*r-o*n,l=s*n+o*e-i*r,u=s*r+i*n-a*e,h=-i*e-a*n-o*r;return this.x=c*s+h*-i+l*-o-u*-a,this.y=l*s+h*-a+u*-i-c*-o,this.z=u*s+h*-o+c*-a-l*-i,this},project:function(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)},unproject:function(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)},transformDirection:function(t){var e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*r,this.y=i[1]*e+i[5]*n+i[9]*r,this.z=i[2]*e+i[6]*n+i[10]*r,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},clamp:function(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this},clampScalar:function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this},clampLength:function(t,e){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},lerpVectors:function(t,e,n){return this.subVectors(e,t).multiplyScalar(n).add(t)},cross:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)},crossVectors:function(t,e){var n=t.x,r=t.y,i=t.z,a=e.x,o=e.y,s=e.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this},projectOnVector:function(t){var e=t.dot(this)/t.lengthSq();return this.copy(t).multiplyScalar(e)},projectOnPlane:function(t){return _n.copy(this).projectOnVector(t),this.sub(_n)},reflect:function(t){return this.sub(_n.copy(t).multiplyScalar(2*this.dot(t)))},angleTo:function(t){var e=Math.sqrt(this.lengthSq()*t.lengthSq());0===e&&console.error("THREE.Vector3: angleTo() can't handle zero length vectors.");var n=this.dot(t)/e;return Math.acos(xn.clamp(n,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)},setFromSphericalCoords:function(t,e,n){var r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this},setFromCylindrical:function(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)},setFromCylindricalCoords:function(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this},setFromMatrixPosition:function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},setFromMatrixScale:function(t){var e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this},setFromMatrixColumn:function(t,e){return this.fromArray(t.elements,4*e)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},fromBufferAttribute:function(t,e,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}});var En,An=new Sn;function Tn(){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.assign(Tn.prototype,{isMatrix3:!0,set:function(t,e,n,r,i,a,o,s,c){var l=this.elements;return l[0]=t,l[1]=r,l[2]=o,l[3]=e,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(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(t){for(var e=0,n=t.count;e2048||e.height>2048?e.toDataURL("image/jpeg",.6):e.toDataURL("image/png")}},Rn=0;function Pn(t,e,n,r,i,a,o,s,c,l){Object.defineProperty(this,"id",{value:Rn++}),this.uuid=xn.generateUUID(),this.name="",this.image=void 0!==t?t:Pn.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:Pn.DEFAULT_MAPPING,this.wrapS=void 0!==n?n:yt,this.wrapT=void 0!==r?r:yt,this.magFilter=void 0!==i?i:Et,this.minFilter=void 0!==a?a:Lt,this.anisotropy=void 0!==c?c:1,this.format=void 0!==o?o:jt,this.type=void 0!==s?s:Pt,this.offset=new bn(0,0),this.repeat=new bn(1,1),this.center=new bn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Tn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==l?l:Oe,this.version=0,this.onUpdate=null}function Cn(t,e,n,r){this.x=t||0,this.y=e||0,this.z=n||0,this.w=void 0!==r?r:1}function On(t,e,n){this.width=t,this.height=e,this.scissor=new Cn(0,0,t,e),this.scissorTest=!1,this.viewport=new Cn(0,0,t,e),n=n||{},this.texture=new Pn(void 0,void 0,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.image={},this.texture.image.width=t,this.texture.image.height=e,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:Et,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 Dn(t,e,n){On.call(this,t,e,n),this.samples=4}Pn.DEFAULT_IMAGE=void 0,Pn.DEFAULT_MAPPING=lt,Pn.prototype=Object.assign(Object.create(vn.prototype),{constructor:Pn,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(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],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){var r=this.image;if(void 0===r.uuid&&(r.uuid=xn.generateUUID()),!e&&void 0===t.images[r.uuid]){var i;if(Array.isArray(r)){i=[];for(var a=0,o=r.length;a1)switch(this.wrapS){case gt:t.x=t.x-Math.floor(t.x);break;case yt:t.x=t.x<0?0:1;break;case xt: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 gt:t.y=t.y-Math.floor(t.y);break;case yt:t.y=t.y<0?0:1;break;case xt:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}}),Object.defineProperty(Pn.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.defineProperties(Cn.prototype,{width:{get:function(){return this.z},set:function(t){this.z=t}},height:{get:function(){return this.w},set:function(t){this.w=t}}}),Object.assign(Cn.prototype,{isVector4:!0,set:function(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},addScaledVector:function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,n=this.y,r=this.z,i=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*e+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*e+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*e+a[7]*n+a[11]*r+a[15]*i,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,n,r,i,a=t.elements,o=a[0],s=a[4],c=a[8],l=a[1],u=a[5],h=a[9],d=a[2],p=a[6],f=a[10];if(Math.abs(s-l)<.01&&Math.abs(c-d)<.01&&Math.abs(h-p)<.01){if(Math.abs(s+l)<.1&&Math.abs(c+d)<.1&&Math.abs(h+p)<.1&&Math.abs(o+u+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(o+1)/2,v=(u+1)/2,g=(f+1)/2,y=(s+l)/4,x=(c+d)/4,b=(h+p)/4;return m>v&&m>g?m<.01?(n=0,r=.707106781,i=.707106781):(r=y/(n=Math.sqrt(m)),i=x/n):v>g?v<.01?(n=.707106781,r=0,i=.707106781):(n=y/(r=Math.sqrt(v)),i=b/r):g<.01?(n=.707106781,r=.707106781,i=0):(n=x/(i=Math.sqrt(g)),r=b/i),this.set(n,r,i,e),this}var w=Math.sqrt((p-h)*(p-h)+(c-d)*(c-d)+(l-s)*(l-s));return Math.abs(w)<.001&&(w=1),this.x=(p-h)/w,this.y=(c-d)/w,this.z=(l-s)/w,this.w=Math.acos((o+u+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(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this},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}}),On.prototype=Object.assign(Object.create(vn.prototype),{constructor:On,isWebGLRenderTarget:!0,setSize:function(t,e){this.width===t&&this.height===e||(this.width=t,this.height=e,this.texture.image.width=t,this.texture.image.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"})}}),Dn.prototype=Object.assign(Object.create(On.prototype),{constructor:Dn,isWebGLMultisampleRenderTarget:!0,copy:function(t){return On.prototype.copy.call(this,t),this.samples=t.samples,this}});var In=new Sn,Nn=new Hn,Bn=new Sn(0,0,0),Fn=new Sn(1,1,1),zn=new Sn,Un=new Sn,Gn=new Sn;function Hn(){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.")}Object.assign(Hn.prototype,{isMatrix4:!0,set:function(t,e,n,r,i,a,o,s,c,l,u,h,d,p,f,m){var v=this.elements;return v[0]=t,v[4]=e,v[8]=n,v[12]=r,v[1]=i,v[5]=a,v[9]=o,v[13]=s,v[2]=c,v[6]=l,v[10]=u,v[14]=h,v[3]=d,v[7]=p,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 Hn).fromArray(this.elements)},copy:function(t){var e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this},copyPosition:function(t){var e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this},extractBasis:function(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this},makeBasis:function(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this},extractRotation:function(t){var e=this.elements,n=t.elements,r=1/In.setFromMatrixColumn(t,0).length(),i=1/In.setFromMatrixColumn(t,1).length(),a=1/In.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*i,e[5]=n[5]*i,e[6]=n[6]*i,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,n=t.x,r=t.y,i=t.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){var h=a*l,d=a*u,p=o*l,f=o*u;e[0]=s*l,e[4]=-s*u,e[8]=c,e[1]=d+p*c,e[5]=h-f*c,e[9]=-o*s,e[2]=f-h*c,e[6]=p+d*c,e[10]=a*s}else if("YXZ"===t.order){var m=s*l,v=s*u,g=c*l,y=c*u;e[0]=m+y*o,e[4]=g*o-v,e[8]=a*c,e[1]=a*u,e[5]=a*l,e[9]=-o,e[2]=v*o-g,e[6]=y+m*o,e[10]=a*s}else if("ZXY"===t.order){m=s*l,v=s*u,g=c*l,y=c*u;e[0]=m-y*o,e[4]=-a*u,e[8]=g+v*o,e[1]=v+g*o,e[5]=a*l,e[9]=y-m*o,e[2]=-a*c,e[6]=o,e[10]=a*s}else if("ZYX"===t.order){h=a*l,d=a*u,p=o*l,f=o*u;e[0]=s*l,e[4]=p*c-d,e[8]=h*c+f,e[1]=s*u,e[5]=f*c+h,e[9]=d*c-p,e[2]=-c,e[6]=o*s,e[10]=a*s}else if("YZX"===t.order){var x=a*s,b=a*c,w=o*s,_=o*c;e[0]=s*l,e[4]=_-x*u,e[8]=w*u+b,e[1]=u,e[5]=a*l,e[9]=-o*l,e[2]=-c*l,e[6]=b*u+w,e[10]=x-_*u}else if("XZY"===t.order){x=a*s,b=a*c,w=o*s,_=o*c;e[0]=s*l,e[4]=-u,e[8]=c*l,e[1]=x*u+_,e[5]=a*l,e[9]=b*u-w,e[2]=w*u-b,e[6]=o*l,e[10]=_*u+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){return this.compose(Bn,t,Fn)},lookAt:function(t,e,n){var r=this.elements;return Gn.subVectors(t,e),0===Gn.lengthSq()&&(Gn.z=1),Gn.normalize(),zn.crossVectors(n,Gn),0===zn.lengthSq()&&(1===Math.abs(n.z)?Gn.x+=1e-4:Gn.z+=1e-4,Gn.normalize(),zn.crossVectors(n,Gn)),zn.normalize(),Un.crossVectors(Gn,zn),r[0]=zn.x,r[4]=Un.x,r[8]=Gn.x,r[1]=zn.y,r[5]=Un.y,r[9]=Gn.y,r[2]=zn.z,r[6]=Un.z,r[10]=Gn.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,e){var n=t.elements,r=e.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],v=n[14],g=n[3],y=n[7],x=n[11],b=n[15],w=r[0],_=r[4],M=r[8],S=r[12],E=r[1],A=r[5],T=r[9],L=r[13],R=r[2],P=r[6],C=r[10],O=r[14],D=r[3],I=r[7],N=r[11],B=r[15];return i[0]=a*w+o*E+s*R+c*D,i[4]=a*_+o*A+s*P+c*I,i[8]=a*M+o*T+s*C+c*N,i[12]=a*S+o*L+s*O+c*B,i[1]=l*w+u*E+h*R+d*D,i[5]=l*_+u*A+h*P+d*I,i[9]=l*M+u*T+h*C+d*N,i[13]=l*S+u*L+h*O+d*B,i[2]=p*w+f*E+m*R+v*D,i[6]=p*_+f*A+m*P+v*I,i[10]=p*M+f*T+m*C+v*N,i[14]=p*S+f*L+m*O+v*B,i[3]=g*w+y*E+x*R+b*D,i[7]=g*_+y*A+x*P+b*I,i[11]=g*M+y*T+x*C+b*N,i[15]=g*S+y*L+x*O+b*B,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(t){for(var e=0,n=t.count;e1){for(var e=0;e1){for(var e=0;e0){r.children=[];for(s=0;s0&&(n.geometries=h),d.length>0&&(n.materials=d),p.length>0&&(n.textures=p),f.length>0&&(n.images=f),o.length>0&&(n.shapes=o)}return n.object=r,n;function m(t){var e=[];for(var n in t){var r=t[n];delete r.metadata,e.push(r)}return e}},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,e){if(void 0===e&&(e=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(var n=0;ns)return!1}return!0}Object.assign(xr.prototype,{isBox3:!0,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromArray:function(t){for(var e=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,c=t.length;si&&(i=l),u>a&&(a=u),h>o&&(o=h)}return this.min.set(e,n,r),this.max.set(i,a,o),this},setFromBufferAttribute:function(t){for(var e=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,c=t.count;si&&(i=l),u>a&&(a=u),h>o&&(o=h)}return this.min.set(e,n,r),this.max.set(i,a,o),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,n=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .getParameter() target is now required"),e=new Sn),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)},intersectsSphere:function(t){return this.clampPoint(t.center,cr),cr.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(t){if(this.isEmpty())return!1;this.getCenter(mr),vr.subVectors(this.max,mr),lr.subVectors(t.a,mr),ur.subVectors(t.b,mr),hr.subVectors(t.c,mr),dr.subVectors(ur,lr),pr.subVectors(hr,ur),fr.subVectors(lr,hr);var e=[0,-dr.z,dr.y,0,-pr.z,pr.y,0,-fr.z,fr.y,dr.z,0,-dr.x,pr.z,0,-pr.x,fr.z,0,-fr.x,-dr.y,dr.x,0,-pr.y,pr.x,0,-fr.y,fr.x,0];return!!br(e,lr,ur,hr,vr)&&(!!br(e=[1,0,0,0,1,0,0,0,1],lr,ur,hr,vr)&&(gr.crossVectors(dr,pr),br(e=[gr.x,gr.y,gr.z],lr,ur,hr,vr)))},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box3: .clampPoint() target is now required"),e=new Sn),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return cr.copy(t).clamp(this.min,this.max).sub(t).length()},getBoundingSphere:function(t){return void 0===t&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=.5*this.getSize(cr).length(),t},intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(t){return this.isEmpty()?this:(sr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),sr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),sr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),sr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),sr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),sr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),sr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),sr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(sr),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)}});var wr=new xr;function _r(t,e){this.center=void 0!==t?t:new Sn,this.radius=void 0!==e?e:0}Object.assign(_r.prototype,{set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:function(t,e){var n=this.center;void 0!==e?n.copy(e):wr.setFromPoints(t).getCenter(n);for(var r=0,i=0,a=t.length;ithis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e},getBoundingBox:function(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new xr),t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}});var Mr=new Sn,Sr=new Sn,Er=new Sn,Ar=new Sn,Tr=new Sn,Lr=new Sn,Rr=new Sn;function Pr(t,e){this.origin=void 0!==t?t:new Sn,this.direction=void 0!==e?e:new Sn}Object.assign(Pr.prototype,{set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return void 0===e&&(console.warn("THREE.Ray: .at() target is now required"),e=new Sn),e.copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(t){return this.origin.copy(this.at(t,Mr)),this},closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),e=new Sn),e.subVectors(t,this.origin);var n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(t){var e=Mr.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Mr.copy(this.direction).multiplyScalar(e).add(this.origin),Mr.distanceToSquared(t))},distanceSqToSegment:function(t,e,n,r){Sr.copy(t).add(e).multiplyScalar(.5),Er.copy(e).sub(t).normalize(),Ar.copy(this.origin).sub(Sr);var i,a,o,s,c=.5*t.distanceTo(e),l=-this.direction.dot(Er),u=Ar.dot(this.direction),h=-Ar.dot(Er),d=Ar.lengthSq(),p=Math.abs(1-l*l);if(p>0)if(a=l*u-h,s=c*p,(i=l*h-u)>=0)if(a>=-s)if(a<=s){var f=1/p;o=(i*=f)*(i+l*(a*=f)+2*u)+a*(l*i+a+2*h)+d}else a=c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;else a=-c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;else a<=-s?o=-(i=Math.max(0,-(-l*c+u)))*i+(a=i>0?-c:Math.min(Math.max(-c,-h),c))*(a+2*h)+d:a<=s?(i=0,o=(a=Math.min(Math.max(-c,-h),c))*(a+2*h)+d):o=-(i=Math.max(0,-(l*c+u)))*i+(a=i>0?c:Math.min(Math.max(-c,-h),c))*(a+2*h)+d;else a=l>0?-c:c,o=-(i=Math.max(0,-(l*a+u)))*i+a*(a+2*h)+d;return n&&n.copy(this.direction).multiplyScalar(i).add(this.origin),r&&r.copy(Er).multiplyScalar(a).add(Sr),o},intersectSphere:function(t,e){Mr.subVectors(t.center,this.origin);var n=Mr.dot(this.direction),r=Mr.dot(Mr)-n*n,i=t.radius*t.radius;if(r>i)return null;var a=Math.sqrt(i-r),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,e):this.at(o,e)},intersectsSphere:function(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;var n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null},intersectPlane:function(t,e){var n=this.distanceToPlane(t);return null===n?null:this.at(n,e)},intersectsPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},intersectBox:function(t,e){var n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,h=this.origin;return c>=0?(n=(t.min.x-h.x)*c,r=(t.max.x-h.x)*c):(n=(t.max.x-h.x)*c,r=(t.min.x-h.x)*c),l>=0?(i=(t.min.y-h.y)*l,a=(t.max.y-h.y)*l):(i=(t.max.y-h.y)*l,a=(t.min.y-h.y)*l),n>a||i>r?null:((i>n||n!=n)&&(n=i),(a=0?(o=(t.min.z-h.z)*u,s=(t.max.z-h.z)*u):(o=(t.max.z-h.z)*u,s=(t.min.z-h.z)*u),n>s||o>r?null:((o>n||n!=n)&&(n=o),(s=0?n:r,e)))},intersectsBox:function(t){return null!==this.intersectBox(t,Mr)},intersectTriangle:function(t,e,n,r,i){Tr.subVectors(e,t),Lr.subVectors(n,t),Rr.crossVectors(Tr,Lr);var a,o=this.direction.dot(Rr);if(o>0){if(r)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Ar.subVectors(this.origin,t);var s=a*this.direction.dot(Lr.crossVectors(Ar,Lr));if(s<0)return null;var c=a*this.direction.dot(Tr.cross(Ar));if(c<0)return null;if(s+c>o)return null;var l=-a*Ar.dot(Rr);return l<0?null:this.at(l/o,i)},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)}});var Cr=new Sn,Or=new Sn,Dr=new Tn;function Ir(t,e){this.normal=void 0!==t?t:new Sn(1,0,0),this.constant=void 0!==e?e:0}Object.assign(Ir.prototype,{isPlane:!0,set:function(t,e){return this.normal.copy(t),this.constant=e,this},setComponents:function(t,e,n,r){return this.normal.set(t,e,n),this.constant=r,this},setFromNormalAndCoplanarPoint:function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},setFromCoplanarPoints:function(t,e,n){var r=Cr.subVectors(n,e).cross(Or.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,e){return void 0===e&&(console.warn("THREE.Plane: .projectPoint() target is now required"),e=new Sn),e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)},intersectLine:function(t,e){void 0===e&&(console.warn("THREE.Plane: .intersectLine() target is now required"),e=new Sn);var n=t.delta(Cr),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(t.start)?e.copy(t.start):void 0;var i=-(t.start.dot(this.normal)+this.constant)/r;return i<0||i>1?void 0:e.copy(n).multiplyScalar(i).add(t.start)},intersectsLine:function(t){var e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new Sn),t.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(t,e){var n=e||Dr.getNormalMatrix(t),r=this.coplanarPoint(Cr).applyMatrix4(t),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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}});var Nr=new Sn,Br=new Sn,Fr=new Sn,zr=new Sn,Ur=new Sn,Gr=new Sn,Hr=new Sn,Vr=new Sn,kr=new Sn,jr=new Sn;function Wr(t,e,n){this.a=void 0!==t?t:new Sn,this.b=void 0!==e?e:new Sn,this.c=void 0!==n?n:new Sn}Object.assign(Wr,{getNormal:function(t,e,n,r){void 0===r&&(console.warn("THREE.Triangle: .getNormal() target is now required"),r=new Sn),r.subVectors(n,e),Nr.subVectors(t,e),r.cross(Nr);var i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)},getBarycoord:function(t,e,n,r,i){Nr.subVectors(r,e),Br.subVectors(n,e),Fr.subVectors(t,e);var a=Nr.dot(Nr),o=Nr.dot(Br),s=Nr.dot(Fr),c=Br.dot(Br),l=Br.dot(Fr),u=a*c-o*o;if(void 0===i&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),i=new Sn),0===u)return i.set(-2,-1,-1);var h=1/u,d=(c*s-o*l)*h,p=(a*l-o*s)*h;return i.set(1-d-p,p,d)},containsPoint:function(t,e,n,r){return Wr.getBarycoord(t,e,n,r,zr),zr.x>=0&&zr.y>=0&&zr.x+zr.y<=1},getUV:function(t,e,n,r,i,a,o,s){return this.getBarycoord(t,e,n,r,zr),s.set(0,0),s.addScaledVector(i,zr.x),s.addScaledVector(a,zr.y),s.addScaledVector(o,zr.z),s},isFrontFacing:function(t,e,n,r){return Nr.subVectors(n,e),Br.subVectors(t,e),Nr.cross(Br).dot(r)<0}}),Object.assign(Wr.prototype,{set:function(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this},setFromPointsAndIndices:function(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},getArea:function(){return Nr.subVectors(this.c,this.b),Br.subVectors(this.a,this.b),.5*Nr.cross(Br).length()},getMidpoint:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new Sn),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(t){return Wr.getNormal(this.a,this.b,this.c,t)},getPlane:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new Ir),t.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(t,e){return Wr.getBarycoord(t,this.a,this.b,this.c,e)},getUV:function(t,e,n,r,i){return Wr.getUV(t,this.a,this.b,this.c,e,n,r,i)},containsPoint:function(t){return Wr.containsPoint(t,this.a,this.b,this.c)},isFrontFacing:function(t){return Wr.isFrontFacing(this.a,this.b,this.c,t)},intersectsBox:function(t){return t.intersectsTriangle(this)},closestPointToPoint:function(t,e){void 0===e&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),e=new Sn);var n,r,i=this.a,a=this.b,o=this.c;Ur.subVectors(a,i),Gr.subVectors(o,i),Vr.subVectors(t,i);var s=Ur.dot(Vr),c=Gr.dot(Vr);if(s<=0&&c<=0)return e.copy(i);kr.subVectors(t,a);var l=Ur.dot(kr),u=Gr.dot(kr);if(l>=0&&u<=l)return e.copy(a);var h=s*u-l*c;if(h<=0&&s>=0&&l<=0)return n=s/(s-l),e.copy(i).addScaledVector(Ur,n);jr.subVectors(t,o);var d=Ur.dot(jr),p=Gr.dot(jr);if(p>=0&&d<=p)return e.copy(o);var f=d*c-s*p;if(f<=0&&c>=0&&p<=0)return r=c/(c-p),e.copy(i).addScaledVector(Gr,r);var m=l*p-d*u;if(m<=0&&u-l>=0&&d-p>=0)return Hr.subVectors(o,a),r=(u-l)/(u-l+(d-p)),e.copy(a).addScaledVector(Hr,r);var v=1/(m+f+h);return n=f*v,r=h*v,e.copy(i).addScaledVector(Ur,n).addScaledVector(Gr,r)},equals:function(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}});var qr={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},Xr={h:0,s:0,l:0},Yr={h:0,s:0,l:0};function Zr(t,e,n){return void 0===e&&void 0===n?this.set(t):this.setRGB(t,e,n)}function Jr(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}function Qr(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Kr(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}function $r(t,e,n,r,i,a){this.a=t,this.b=e,this.c=n,this.normal=r&&r.isVector3?r:new Sn,this.vertexNormals=Array.isArray(r)?r:[],this.color=i&&i.isColor?i:new Zr,this.vertexColors=Array.isArray(i)?i:[],this.materialIndex=void 0!==a?a:0}Object.assign(Zr.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(t,e,n){if(t=xn.euclideanModulo(t,1),e=xn.clamp(e,0,1),n=xn.clamp(n,0,1),0===e)this.r=this.g=this.b=n;else{var r=n<=.5?n*(1+e):n+e-n*e,i=2*n-r;this.r=Jr(i,r,t+1/3),this.g=Jr(i,r,t),this.b=Jr(i,r,t-1/3)}return this},setStyle:function(t){function e(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}var n;if(n=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(t)){var r,i=n[1],a=n[2];switch(i){case"rgb":case"rgba":if(r=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,e(r[5]),this;if(r=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,e(r[5]),this;break;case"hsl":case"hsla":if(r=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,c=parseInt(r[3],10)/100;return e(r[5]),this.setHSL(o,s,c)}}}else if(n=/^\#([A-Fa-f0-9]+)$/.exec(t)){var l=n[1],u=l.length;if(3===u)return this.r=parseInt(l.charAt(0)+l.charAt(0),16)/255,this.g=parseInt(l.charAt(1)+l.charAt(1),16)/255,this.b=parseInt(l.charAt(2)+l.charAt(2),16)/255,this;if(6===u)return this.r=parseInt(l.charAt(0)+l.charAt(1),16)/255,this.g=parseInt(l.charAt(2)+l.charAt(3),16)/255,this.b=parseInt(l.charAt(4)+l.charAt(5),16)/255,this}return t&&t.length>0?this.setColorName(t):this},setColorName:function(t){var e=qr[t];return void 0!==e?this.setHex(e):console.warn("THREE.Color: Unknown color "+t),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(t){return this.copyGammaToLinear(this,t),this},convertLinearToGamma:function(t){return this.copyLinearToGamma(this,t),this},copySRGBToLinear:function(t){return this.r=Qr(t.r),this.g=Qr(t.g),this.b=Qr(t.b),this},copyLinearToSRGB:function(t){return this.r=Kr(t.r),this.g=Kr(t.g),this.b=Kr(t.b),this},convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});var e,n,r=this.r,i=this.g,a=this.b,o=Math.max(r,i,a),s=Math.min(r,i,a),c=(s+o)/2;if(s===o)e=0,n=0;else{var l=o-s;switch(n=c<=.5?l/(o+s):l/(2-o-s),o){case r:e=(i-a)/l+(ie&&(e=t[n]);return e}ei.prototype=Object.assign(Object.create(vn.prototype),{constructor:ei,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 r=this[e];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=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===x;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 r(t){var e=[];for(var n in t){var r=t[n];delete r.metadata,e.push(r)}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.sheen&&this.sheen.isColor&&(n.sheen=this.sheen.getHex()),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&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.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.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.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),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.normalMapType=this.normalMapType,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,n.refractionRatio=this.refractionRatio,void 0!==this.combine&&(n.combine=this.combine),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity)),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!==E&&(n.blending=this.blending),!0===this.flatShading&&(n.flatShading=this.flatShading),this.side!==v&&(n.side=this.side),this.vertexColors!==w&&(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,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&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.morphNormals&&(n.morphNormals=!0),!0===this.skinning&&(n.skinning=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),e){var i=r(t.textures),a=r(t.images);i.length>0&&(n.textures=i),a.length>0&&(n.images=a)}return n},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,this.vertexTangents=t.vertexTangents,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.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;var e=t.clippingPlanes,n=null;if(null!==e){var r=e.length;n=new Array(r);for(var i=0;i!==r;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,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.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),ni.prototype=Object.create(ei.prototype),ni.prototype.constructor=ni,ni.prototype.isMeshBasicMaterial=!0,ni.prototype.copy=function(t){return ei.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},Object.defineProperty(ri.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(ri.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.itemSize,n*=e.itemSize;for(var r=0,i=this.itemSize;r0,o=i[1]&&i[1].length>0,s=t.morphTargets,c=s.length;if(c>0){e=[];for(var l=0;l0){u=[];for(l=0;l0&&0===n.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(l=0;l65535?ui:ci)(t,1):this.index=t},getAttribute:function(t){return this.attributes[t]},setAttribute:function(t,e){return this.attributes[t]=e,this},deleteAttribute: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 Tn).getNormalMatrix(t).applyToBufferAttribute(n),n.needsUpdate=!0);var r=this.attributes.tangent;void 0!==r&&((new Tn).getNormalMatrix(t).applyToBufferAttribute(r),r.needsUpdate=!0);return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(t){return vi.makeRotationX(t),this.applyMatrix(vi),this},rotateY:function(t){return vi.makeRotationY(t),this.applyMatrix(vi),this},rotateZ:function(t){return vi.makeRotationZ(t),this.applyMatrix(vi),this},translate:function(t,e,n){return vi.makeTranslation(t,e,n),this.applyMatrix(vi),this},scale:function(t,e,n){return vi.makeScale(t,e,n),this.applyMatrix(vi),this},lookAt:function(t){return gi.lookAt(t),gi.updateMatrix(),this.applyMatrix(gi.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(yi).negate(),this.translate(yi.x,yi.y,yi.z),this},setFromObject:function(t){var e=t.geometry;if(t.isPoints||t.isLine){var n=new hi(3*e.vertices.length,3),r=new hi(3*e.colors.length,3);if(this.setAttribute("position",n.copyVector3sArray(e.vertices)),this.setAttribute("color",r.copyColorsArray(e.colors)),e.lineDistances&&e.lineDistances.length===e.vertices.length){var i=new hi(e.lineDistances.length,1);this.setAttribute("lineDistance",i.copyArray(e.lineDistances))}null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone())}else t.isMesh&&e&&e.isGeometry&&this.fromGeometry(e);return this},setFromPoints:function(t){for(var e=[],n=0,r=t.length;n0){var n=new Float32Array(3*t.normals.length);this.setAttribute("normal",new ri(n,3).copyVector3sArray(t.normals))}if(t.colors.length>0){var r=new Float32Array(3*t.colors.length);this.setAttribute("color",new ri(r,3).copyColorsArray(t.colors))}if(t.uvs.length>0){var i=new Float32Array(2*t.uvs.length);this.setAttribute("uv",new ri(i,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){var a=new Float32Array(2*t.uvs2.length);this.setAttribute("uv2",new ri(a,2).copyVector2sArray(t.uvs2))}for(var o in this.groups=t.groups,t.morphTargets){for(var s=[],c=t.morphTargets[o],l=0,u=c.length;l0){var p=new hi(4*t.skinIndices.length,4);this.setAttribute("skinIndex",p.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){var f=new hi(4*t.skinWeights.length,4);this.setAttribute("skinWeight",f.copyVector4sArray(t.skinWeights))}return null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new xr);var t=this.attributes.position,e=this.morphAttributes.position;if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(var n=0,r=e.length;n0&&(t.userData=this.userData),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 r=this.index;null!==r&&(t.data.index={type:r.array.constructor.name,array:Array.prototype.slice.call(r.array)});var i=this.attributes;for(var n in i){var a=(d=i[n]).toJSON();""!==d.name&&(a.name=d.name),t.data.attributes[n]=a}var o={},s=!1;for(var n in this.morphAttributes){for(var c=this.morphAttributes[n],l=[],u=0,h=c.length;u0&&(o[n]=l,s=!0)}s&&(t.data.morphAttributes=o);var p=this.groups;p.length>0&&(t.data.groups=JSON.parse(JSON.stringify(p)));var f=this.boundingSphere;return null!==f&&(t.data.boundingSphere={center:f.center.toArray(),radius:f.radius}),t},clone:function(){return(new _i).copy(this)},copy:function(t){var e,n,r;this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var i=t.index;null!==i&&this.setIndex(i.clone());var a=t.attributes;for(e in a){var o=a[e];this.setAttribute(e,o.clone())}var s=t.morphAttributes;for(e in s){var c=[],l=s[e];for(n=0,r=l.length;nn.far?null:{distance:c,point:Ui.clone(),object:t}}function Vi(t,e,n,r,i,a,o,s,c,l,u){Ai.fromBufferAttribute(i,c),Ti.fromBufferAttribute(i,l),Li.fromBufferAttribute(i,u);var h=t.morphTargetInfluences;if(e.morphTargets&&a&&h){Oi.set(0,0,0),Di.set(0,0,0),Ii.set(0,0,0);for(var d=0,p=a.length;d0){var o=i[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=o.length;t0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(t,e){var n,r=this.geometry,i=this.material,a=this.matrixWorld;if(void 0!==i&&(null===r.boundingSphere&&r.computeBoundingSphere(),Ei.copy(r.boundingSphere),Ei.applyMatrix4(a),!1!==t.ray.intersectsSphere(Ei)&&(Mi.getInverse(a),Si.copy(t.ray).applyMatrix4(Mi),null===r.boundingBox||!1!==Si.intersectsBox(r.boundingBox))))if(this.drawMode===Re){if(r.isBufferGeometry){var o,s,c,l,u,h,d,p,f,m=r.index,v=r.attributes.position,g=r.morphAttributes.position,y=r.attributes.uv,x=r.attributes.uv2,b=r.groups,w=r.drawRange;if(null!==m)if(Array.isArray(i))for(l=0,h=b.length;l0&&(E=R);for(var P=0,C=L.length;P0)for(l=0;l0&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,e,n;for(this.computeFaceNormals(),t=0,e=this.faces.length;t0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,e,n,r,i;for(n=0,r=this.faces.length;n=0;n--){var f=d[n];for(this.faces.splice(f,1),o=0,s=this.faceVertexUvs.length;o0,v=p.vertexNormals.length>0,g=1!==p.color.r||1!==p.color.g||1!==p.color.b,y=p.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),o.push(x),o.push(p.a,p.b,p.c),o.push(p.materialIndex),f){var b=this.faceVertexUvs[0][i];o.push(A(b[0]),A(b[1]),A(b[2]))}if(m&&o.push(S(p.normal)),v){var w=p.vertexNormals;o.push(S(w[0]),S(w[1]),S(w[2]))}if(g&&o.push(E(p.color)),y){var _=p.vertexColors;o.push(E(_[0]),E(_[1]),E(_[2]))}}function M(t,e,n){return n?t|1<0&&(t.data.colors=l),h.length>0&&(t.data.uvs=[h]),t.data.faces=o,t},clone:function(){return(new Xi).copy(this)},copy:function(t){var e,n,r,i,a,o;this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=t.name;var s=t.vertices;for(e=0,n=s.length;e0?1:-1,l.push(R.x,R.y,R.z),u.push(y/m),u.push(1-x/v),T+=1}}for(x=0;x0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;var i={};for(var a in this.extensions)!0===this.extensions[a]&&(i[a]=!0);return Object.keys(i).length>0&&(e.extensions=i),e},na.prototype=Object.assign(Object.create(ar.prototype),{constructor:na,isCamera:!0,copy:function(t,e){return ar.prototype.copy.call(this,t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new Sn),this.updateMatrixWorld(!0);var e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()},updateMatrixWorld:function(t){ar.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),ra.prototype=Object.assign(Object.create(na.prototype),{constructor:ra,isPerspectiveCamera:!0,copy:function(t,e){return na.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*xn.RAD2DEG*Math.atan(e),this.updateProjectionMatrix()},getFocalLength:function(){var t=Math.tan(.5*xn.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*xn.RAD2DEG*Math.atan(Math.tan(.5*xn.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,r,i,a){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=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=this.near,e=t*Math.tan(.5*xn.DEG2RAD*this.fov)/this.zoom,n=2*e,r=this.aspect*n,i=-.5*r,a=this.view;if(null!==this.view&&this.view.enabled){var o=a.fullWidth,s=a.fullHeight;i+=a.offsetX*r/o,e-=a.offsetY*n/s,r*=a.width/o,n*=a.height/s}var c=this.filmOffset;0!==c&&(i+=t*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,e,e-n,t,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(t){var e=ar.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}});var ia=90,aa=1;function oa(t,e,n,r){ar.call(this),this.type="CubeCamera";var i=new ra(ia,aa,t,e);i.up.set(0,-1,0),i.lookAt(new Sn(1,0,0)),this.add(i);var a=new ra(ia,aa,t,e);a.up.set(0,-1,0),a.lookAt(new Sn(-1,0,0)),this.add(a);var o=new ra(ia,aa,t,e);o.up.set(0,0,1),o.lookAt(new Sn(0,1,0)),this.add(o);var s=new ra(ia,aa,t,e);s.up.set(0,0,-1),s.lookAt(new Sn(0,-1,0)),this.add(s);var c=new ra(ia,aa,t,e);c.up.set(0,-1,0),c.lookAt(new Sn(0,0,1)),this.add(c);var l=new ra(ia,aa,t,e);l.up.set(0,-1,0),l.lookAt(new Sn(0,0,-1)),this.add(l),r=r||{format:kt,magFilter:Et,minFilter:Et},this.renderTarget=new sa(n,n,r),this.renderTarget.texture.name="CubeCamera",this.update=function(t,e){null===this.parent&&this.updateMatrixWorld();var n=t.getRenderTarget(),r=this.renderTarget,u=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,t.setRenderTarget(r,0),t.render(e,i),t.setRenderTarget(r,1),t.render(e,a),t.setRenderTarget(r,2),t.render(e,o),t.setRenderTarget(r,3),t.render(e,s),t.setRenderTarget(r,4),t.render(e,c),r.texture.generateMipmaps=u,t.setRenderTarget(r,5),t.render(e,l),t.setRenderTarget(n)},this.clear=function(t,e,n,r){for(var i=t.getRenderTarget(),a=this.renderTarget,o=0;o<6;o++)t.setRenderTarget(a,o),t.clear(e,n,r);t.setRenderTarget(i)}}function sa(t,e,n){On.call(this,t,e,n)}function ca(t,e,n,r,i,a,o,s,c,l,u,h){Pn.call(this,null,a,o,s,c,l,r,i,u,h),this.image={data:t||null,width:e||1,height:n||1},this.magFilter=void 0!==c?c:bt,this.minFilter=void 0!==l?l:bt,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}oa.prototype=Object.create(ar.prototype),oa.prototype.constructor=oa,sa.prototype=Object.create(On.prototype),sa.prototype.constructor=sa,sa.prototype.isWebGLRenderTargetCube=!0,sa.prototype.fromEquirectangularTexture=function(t,e){this.texture.type=e.type,this.texture.format=e.format,this.texture.encoding=e.encoding;var n=new or,r={uniforms:{tEquirect:{value:null}},vertexShader:["varying vec3 vWorldDirection;","vec3 transformDirection( in vec3 dir, in mat4 matrix ) {","\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );","}","void main() {","\tvWorldDirection = transformDirection( position, modelMatrix );","\t#include ","\t#include ","}"].join("\n"),fragmentShader:["uniform sampler2D tEquirect;","varying vec3 vWorldDirection;","#define RECIPROCAL_PI 0.31830988618","#define RECIPROCAL_PI2 0.15915494","void main() {","\tvec3 direction = normalize( vWorldDirection );","\tvec2 sampleUV;","\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;","\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;","\tgl_FragColor = texture2D( tEquirect, sampleUV );","}"].join("\n")},i=new ea({type:"CubemapFromEquirect",uniforms:Ji(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:g,blending:S});i.uniforms.tEquirect.value=e;var a=new Gi(new Zi(5,5,5),i);n.add(a);var o=new oa(1,10,1);return o.renderTarget=this,o.renderTarget.texture.name="CubeCameraTexture",o.update(t,n),a.geometry.dispose(),a.material.dispose(),this},ca.prototype=Object.create(Pn.prototype),ca.prototype.constructor=ca,ca.prototype.isDataTexture=!0;var la=new _r,ua=new Sn;function ha(t,e,n,r,i,a){this.planes=[void 0!==t?t:new Ir,void 0!==e?e:new Ir,void 0!==n?n:new Ir,void 0!==r?r:new Ir,void 0!==i?i:new Ir,void 0!==a?a:new Ir]}Object.assign(ha.prototype,{set:function(t,e,n,r,i,a){var o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var e=this.planes,n=0;n<6;n++)e[n].copy(t.planes[n]);return this},setFromMatrix:function(t){var e=this.planes,n=t.elements,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],c=n[5],l=n[6],u=n[7],h=n[8],d=n[9],p=n[10],f=n[11],m=n[12],v=n[13],g=n[14],y=n[15];return e[0].setComponents(o-r,u-s,f-h,y-m).normalize(),e[1].setComponents(o+r,u+s,f+h,y+m).normalize(),e[2].setComponents(o+i,u+c,f+d,y+v).normalize(),e[3].setComponents(o-i,u-c,f-d,y-v).normalize(),e[4].setComponents(o-a,u-l,f-p,y-g).normalize(),e[5].setComponents(o+a,u+l,f+p,y+g).normalize(),this},intersectsObject:function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),la.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(la)},intersectsSprite:function(t){return la.center.set(0,0,0),la.radius=.7071067811865476,la.applyMatrix4(t.matrixWorld),this.intersectsSphere(la)},intersectsSphere:function(t){for(var e=this.planes,n=t.center,r=-t.radius,i=0;i<6;i++){if(e[i].distanceToPoint(n)0?t.max.x:t.min.x,ua.y=r.normal.y>0?t.max.y:t.min.y,ua.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(ua)<0)return!1}return!0},containsPoint:function(t){for(var e=this.planes,n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}});var da={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",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",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif",color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",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#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\ttransformedNormal = mat3( instanceMatrix ) * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = normalMatrix * objectTangent;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_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",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, roughness );\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",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) { \n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",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",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",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif",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 = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\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\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\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",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",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)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = saturate( clearcoat );\tmaterial.clearcoatRoughness = clamp( clearcoatRoughness, 0.04, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 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#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? 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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? 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#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? 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 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",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",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",normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, normalScale, normalMap );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec2 normalScale, in sampler2D normalMap ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy *= normalScale;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tbool frontFacing = dot( cross( S, T ), N ) > 0.0;\n\t\t\tmapN.xy *= ( float( frontFacing ) * 2.0 - 1.0 );\n\t\t#else\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, clearcoatNormal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = clearcoatNormalScale * mapN.xy;\n\t\tclearcoatNormal = normalize( vTBN * mapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatNormalScale, clearcoatNormalMap );\n\t#endif\n#endif",clearcoat_normalmap_pars_fragment:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 encodeHalfRGBA ( vec2 v ) {\n\tvec4 encoded = vec4( 0.0 );\n\tconst vec2 offset = vec2( 1.0 / 255.0, 0.0 );\n\tencoded.xy = vec2( v.x, fract( v.x * 255.0 ) );\n\tencoded.xy = encoded.xy - ( encoded.yy * offset );\n\tencoded.zw = vec2( v.y, fract( v.y * 255.0 ) );\n\tencoded.zw = encoded.zw - ( encoded.ww * offset );\n\treturn encoded;\n}\nvec2 decodeHalfRGBA( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn decodeHalfRGBA( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat 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 ) + 0.5 ) * texelSize;\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\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat 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#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? 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}",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 highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",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",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",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\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\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 = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n}",shadow_vert:"#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}"},pa={common:{diffuse:{value:new Zr(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Tn},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},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 bn(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 Zr(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{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 Zr(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Tn}},sprite:{diffuse:{value:new Zr(15658734)},opacity:{value:1},center:{value:new bn(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Tn}}},fa={basic:{uniforms:Qi([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.fog]),vertexShader:da.meshbasic_vert,fragmentShader:da.meshbasic_frag},lambert:{uniforms:Qi([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.fog,pa.lights,{emissive:{value:new Zr(0)}}]),vertexShader:da.meshlambert_vert,fragmentShader:da.meshlambert_frag},phong:{uniforms:Qi([pa.common,pa.specularmap,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.gradientmap,pa.fog,pa.lights,{emissive:{value:new Zr(0)},specular:{value:new Zr(1118481)},shininess:{value:30}}]),vertexShader:da.meshphong_vert,fragmentShader:da.meshphong_frag},standard:{uniforms:Qi([pa.common,pa.envmap,pa.aomap,pa.lightmap,pa.emissivemap,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.roughnessmap,pa.metalnessmap,pa.fog,pa.lights,{emissive:{value:new Zr(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:da.meshphysical_vert,fragmentShader:da.meshphysical_frag},matcap:{uniforms:Qi([pa.common,pa.bumpmap,pa.normalmap,pa.displacementmap,pa.fog,{matcap:{value:null}}]),vertexShader:da.meshmatcap_vert,fragmentShader:da.meshmatcap_frag},points:{uniforms:Qi([pa.points,pa.fog]),vertexShader:da.points_vert,fragmentShader:da.points_frag},dashed:{uniforms:Qi([pa.common,pa.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:da.linedashed_vert,fragmentShader:da.linedashed_frag},depth:{uniforms:Qi([pa.common,pa.displacementmap]),vertexShader:da.depth_vert,fragmentShader:da.depth_frag},normal:{uniforms:Qi([pa.common,pa.bumpmap,pa.normalmap,pa.displacementmap,{opacity:{value:1}}]),vertexShader:da.normal_vert,fragmentShader:da.normal_frag},sprite:{uniforms:Qi([pa.sprite,pa.fog]),vertexShader:da.sprite_vert,fragmentShader:da.sprite_frag},background:{uniforms:{uvTransform:{value:new Tn},t2D:{value:null}},vertexShader:da.background_vert,fragmentShader:da.background_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:da.cube_vert,fragmentShader:da.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:da.equirect_vert,fragmentShader:da.equirect_frag},distanceRGBA:{uniforms:Qi([pa.common,pa.displacementmap,{referencePosition:{value:new Sn},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:da.distanceRGBA_vert,fragmentShader:da.distanceRGBA_frag},shadow:{uniforms:Qi([pa.lights,pa.fog,{color:{value:new Zr(0)},opacity:{value:1}}]),vertexShader:da.shadow_vert,fragmentShader:da.shadow_frag}};function ma(){var t=null,e=!1,n=null;function r(i,a){!1!==e&&(n(i,a),t.requestAnimationFrame(r))}return{start:function(){!0!==e&&null!==n&&(t.requestAnimationFrame(r),e=!0)},stop:function(){e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function va(t){var e=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),e.get(t)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);var r=e.get(n);r&&(t.deleteBuffer(r.buffer),e.delete(n))},update:function(n,r){n.isInterleavedBufferAttribute&&(n=n.data);var i=e.get(n);void 0===i?e.set(n,function(e,n){var r=e.array,i=e.usage,a=t.createBuffer();t.bindBuffer(n,a),t.bufferData(n,r,i),e.onUploadCallback();var o=5126;return r instanceof Float32Array?o=5126:r instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):r instanceof Uint16Array?o=5123:r instanceof Int16Array?o=5122:r instanceof Uint32Array?o=5125:r instanceof Int32Array?o=5124:r instanceof Int8Array?o=5120:r instanceof Uint8Array&&(o=5121),{buffer:a,type:o,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version}}(n,r)):i.version0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}var a="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext,o=void 0!==n.precision?n.precision:"highp",s=i(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);var c=!0===n.logarithmicDepthBuffer,l=t.getParameter(34930),u=t.getParameter(35660),h=t.getParameter(3379),d=t.getParameter(34076),p=t.getParameter(34921),f=t.getParameter(36347),m=t.getParameter(36348),v=t.getParameter(36349),g=u>0,y=a||!!e.get("OES_texture_float");return{isWebGL2:a,getMaxAnisotropy:function(){if(void 0!==r)return r;var n=e.get("EXT_texture_filter_anisotropic");return r=null!==n?t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:c,maxTextures:l,maxVertexTextures:u,maxTextureSize:h,maxCubemapSize:d,maxAttributes:p,maxVertexUniforms:f,maxVaryings:m,maxFragmentUniforms:v,vertexTextures:g,floatFragmentTextures:y,floatVertexTextures:g&&y,maxSamples:a?t.getParameter(36183):0}}function _a(){var t=this,e=null,n=0,r=!1,i=!1,a=new Ir,o=new Tn,s={value:null,needsUpdate:!1};function c(){s.value!==e&&(s.value=e,s.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function l(e,n,r,i){var c=null!==e?e.length:0,l=null;if(0!==c){if(l=s.value,!0!==i||null===l){var u=r+4*c,h=n.matrixWorldInverse;o.getNormalMatrix(h),(null===l||l.length65535?ui:ci)(n,1);p.version=o,e.update(p,34963);var f=i.get(t);f&&e.remove(f),i.set(t,p)}return{get:function(t,e){var i=r.get(e);return i||(e.addEventListener("dispose",a),e.isBufferGeometry?i=e:e.isGeometry&&(void 0===e._bufferGeometry&&(e._bufferGeometry=(new _i).setFromObject(t)),i=e._bufferGeometry),r.set(e,i),n.memory.geometries++,i)},update:function(t){var n=t.index,r=t.attributes;for(var i in null!==n&&e.update(n,34963),r)e.update(r[i],34962);var a=t.morphAttributes;for(var i in a)for(var o=a[i],s=0,c=o.length;s0)return t;var i=e*n,a=Fa[i];if(void 0===a&&(a=new Float32Array(i),Fa[i]=a),0!==e){r.toArray(a,0);for(var o=1,s=0;o!==e;++o)s+=n,t[o].toArray(a,s)}return a}function ka(t,e){if(t.length!==e.length)return!1;for(var n=0,r=t.length;n/gm;function zo(t){return t.replace(Fo,Uo)}function Uo(t,e){var n=da[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return zo(n)}var Go=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g;function Ho(t){return t.replace(Go,Vo)}function Vo(t,e,n,r){for(var i="",a=parseInt(e);a0?t.gammaFactor:1,M=a.isWebGL2?"":function(t,e,n){return[(t=t||{}).derivatives||e.envMapCubeUV||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||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(Io).join("\n")}(r.extensions,a,e),S=function(t){var e=[];for(var n in t){var r=t[n];!1!==r&&e.push("#define "+n+" "+r)}return e.join("\n")}(d),E=h.createProgram(),A=a.numMultiviewViews;if(r.isRawShaderMaterial?((o=[S].filter(Io).join("\n")).length>0&&(o+="\n"),(s=[M,S].filter(Io).join("\n")).length>0&&(s+="\n")):(o=[ko(a),"#define SHADER_NAME "+i.name,S,a.instancing?"#define USE_INSTANCING":"",a.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+_,"#define MAX_BONES "+a.maxBones,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp2?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+b:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.normalMap&&a.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",a.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",a.displacementMap&&a.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.vertexTangents?"#define USE_TANGENT":"",a.vertexColors?"#define USE_COLOR":"",a.vertexUvs?"#define USE_UV":"",a.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",a.flatShading?"#define FLAT_SHADED":"",a.skinning?"#define USE_SKINNING":"",a.useVertexTexture?"#define BONE_TEXTURE":"",a.morphTargets?"#define USE_MORPHTARGETS":"",a.morphNormals&&!1===a.flatShading?"#define USE_MORPHNORMALS":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+y:"",a.sizeAttenuation?"#define USE_SIZEATTENUATION":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(a.isWebGL2||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;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Io).join("\n"),s=[M,ko(a),"#define SHADER_NAME "+i.name,S,a.alphaTest?"#define ALPHATEST "+a.alphaTest+(a.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+_,a.useFog&&a.fog?"#define USE_FOG":"",a.useFog&&a.fogExp2?"#define FOG_EXP2":"",a.map?"#define USE_MAP":"",a.matcap?"#define USE_MATCAP":"",a.envMap?"#define USE_ENVMAP":"",a.envMap?"#define "+x:"",a.envMap?"#define "+b:"",a.envMap?"#define "+w:"",a.lightMap?"#define USE_LIGHTMAP":"",a.aoMap?"#define USE_AOMAP":"",a.emissiveMap?"#define USE_EMISSIVEMAP":"",a.bumpMap?"#define USE_BUMPMAP":"",a.normalMap?"#define USE_NORMALMAP":"",a.normalMap&&a.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",a.normalMap&&a.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",a.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",a.specularMap?"#define USE_SPECULARMAP":"",a.roughnessMap?"#define USE_ROUGHNESSMAP":"",a.metalnessMap?"#define USE_METALNESSMAP":"",a.alphaMap?"#define USE_ALPHAMAP":"",a.sheen?"#define USE_SHEEN":"",a.vertexTangents?"#define USE_TANGENT":"",a.vertexColors?"#define USE_COLOR":"",a.vertexUvs?"#define USE_UV":"",a.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",a.gradientMap?"#define USE_GRADIENTMAP":"",a.flatShading?"#define FLAT_SHADED":"",a.doubleSided?"#define DOUBLE_SIDED":"",a.flipSided?"#define FLIP_SIDED":"",a.shadowMapEnabled?"#define USE_SHADOWMAP":"",a.shadowMapEnabled?"#define "+y:"",a.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",a.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",a.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",a.logarithmicDepthBuffer&&(a.isWebGL2||e.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",(r.extensions&&r.extensions.shaderTextureLOD||a.envMap)&&(a.isWebGL2||e.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",a.toneMapping!==rt?"#define TONE_MAPPING":"",a.toneMapping!==rt?da.tonemapping_pars_fragment:"",a.toneMapping!==rt?Do("toneMapping",a.toneMapping):"",a.dithering?"#define DITHERING":"",a.outputEncoding||a.mapEncoding||a.matcapEncoding||a.envMapEncoding||a.emissiveMapEncoding?da.encodings_pars_fragment:"",a.mapEncoding?Oo("mapTexelToLinear",a.mapEncoding):"",a.matcapEncoding?Oo("matcapTexelToLinear",a.matcapEncoding):"",a.envMapEncoding?Oo("envMapTexelToLinear",a.envMapEncoding):"",a.emissiveMapEncoding?Oo("emissiveMapTexelToLinear",a.emissiveMapEncoding):"",a.outputEncoding?(c="linearToOutputTexel",l=a.outputEncoding,u=Po(l),"vec4 "+c+"( vec4 value ) { return LinearTo"+u[0]+u[1]+"; }"):"",a.depthPacking?"#define DEPTH_PACKING "+r.depthPacking:"","\n"].filter(Io).join("\n")),v=Bo(v=No(v=zo(v),a),a),g=Bo(g=No(g=zo(g),a),a),v=Ho(v),g=Ho(g),a.isWebGL2&&!r.isRawShaderMaterial){var T=!1,L=/^\s*#version\s+300\s+es\s*\n/;r.isShaderMaterial&&null!==v.match(L)&&null!==g.match(L)&&(T=!0,v=v.replace(L,""),g=g.replace(L,"")),o=["#version 300 es\n","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+o,s=["#version 300 es\n","#define varying in",T?"":"out highp vec4 pc_fragColor;",T?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+s,A>0&&(o=(o=o.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","layout(num_views = "+A+") in;","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace(["uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;"].join("\n"),["uniform mat4 modelViewMatrices["+A+"];","uniform mat4 projectionMatrices["+A+"];","uniform mat4 viewMatrices["+A+"];","uniform mat3 normalMatrices["+A+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]","#define projectionMatrix projectionMatrices[VIEW_ID]","#define viewMatrix viewMatrices[VIEW_ID]","#define normalMatrix normalMatrices[VIEW_ID]"].join("\n")),s=(s=s.replace("#version 300 es\n",["#version 300 es\n","#extension GL_OVR_multiview2 : require","#define VIEW_ID gl_ViewID_OVR"].join("\n"))).replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+A+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join("\n")))}var R,P,C=s+g,O=Lo(h,35633,o+v),D=Lo(h,35632,C);if(h.attachShader(E,O),h.attachShader(E,D),void 0!==r.index0AttributeName?h.bindAttribLocation(E,0,r.index0AttributeName):!0===a.morphTargets&&h.bindAttribLocation(E,0,"position"),h.linkProgram(E),t.debug.checkShaderErrors){var I=h.getProgramInfoLog(E).trim(),N=h.getShaderInfoLog(O).trim(),B=h.getShaderInfoLog(D).trim(),F=!0,z=!0;if(!1===h.getProgramParameter(E,35714)){F=!1;var U=Co(h,O,"vertex"),G=Co(h,D,"fragment");console.error("THREE.WebGLProgram: shader error: ",h.getError(),"35715",h.getProgramParameter(E,35715),"gl.getProgramInfoLog",I,U,G)}else""!==I?console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",I):""!==N&&""!==B||(z=!1);z&&(this.diagnostics={runnable:F,material:r,programLog:I,vertexShader:{log:N,prefix:o},fragmentShader:{log:B,prefix:s}})}return h.deleteShader(O),h.deleteShader(D),this.getUniforms=function(){return void 0===R&&(R=new To(h,E)),R},this.getAttributes=function(){return void 0===P&&(P=function(t,e){for(var n={},r=t.getProgramParameter(e,35721),i=0;i0,maxBones:b,useVertexTexture:o,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:t.maxMorphTargets,maxMorphNormals:t.maxMorphNormals,numDirLights:r.directional.length,numPointLights:r.point.length,numSpotLights:r.spot.length,numRectAreaLights:r.rectArea.length,numHemiLights:r.hemi.length,numDirLightShadows:r.directionalShadowMap.length,numPointLightShadows:r.pointShadowMap.length,numSpotLightShadows:r.spotShadowMap.length,numClippingPlanes:f,numClipIntersection:m,dithering:e.dithering,shadowMapEnabled:t.shadowMap.enabled&&h.length>0,shadowMapType:t.shadowMap.type,toneMapping:e.toneMapped?t.toneMapping:rt,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===y,flipSided:e.side===g,depthPacking:void 0!==e.depthPacking&&e.depthPacking}},this.getProgramCacheKey=function(e,n){var r=[];if(n.shaderID?r.push(n.shaderID):(r.push(e.fragmentShader),r.push(e.vertexShader)),void 0!==e.defines)for(var i in e.defines)r.push(i),r.push(e.defines[i]);for(var a=0;a1&&n.sort(Xo),r.length>1&&r.sort(Yo)}}}function Jo(){var t=new WeakMap;function e(n){var r=n.target;r.removeEventListener("dispose",e),t.delete(r)}return{get:function(n,r){var i,a=t.get(n);return void 0===a?(i=new Zo,t.set(n,new WeakMap),t.get(n).set(r,i),n.addEventListener("dispose",e)):void 0===(i=a.get(r))&&(i=new Zo,a.set(r,i)),i},dispose:function(){t=new WeakMap}}}function Qo(){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 Sn,color:new Zr,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new bn};break;case"SpotLight":n={position:new Sn,direction:new Sn,color:new Zr,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new bn};break;case"PointLight":n={position:new Sn,color:new Zr,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new bn,shadowCameraNear:1,shadowCameraFar:1e3};break;case"HemisphereLight":n={direction:new Sn,skyColor:new Zr,groundColor:new Zr};break;case"RectAreaLight":n={color:new Zr,position:new Sn,halfWidth:new Sn,halfHeight:new Sn}}return t[e.id]=n,n}}}var Ko=0;function $o(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function ts(){for(var t=new Qo,e={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},n=0;n<9;n++)e.probe.push(new Sn);var r=new Sn,i=new Hn,a=new Hn;return{setup:function(n,o,s){for(var c=0,l=0,u=0,h=0;h<9;h++)e.probe[h].set(0,0,0);var d=0,p=0,f=0,m=0,v=0,g=0,y=0,x=0,b=s.matrixWorldInverse;n.sort($o),h=0;for(var w=n.length;h0:!0===s.isGeometry&&(p=s.morphTargets&&s.morphTargets.length>0));var f=!1;!0===e.isSkinnedMesh&&(!0===n.skinning?f=!0:console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",e)),c=h(p,f,!0===e.isInstancedMesh)}else c=d;if(t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length){var v=c.uuid,g=n.uuid,y=l[v];void 0===y&&(y={},l[v]=y);var x=y[g];void 0===x&&(x=c.clone(),y[g]=x),c=x}return c.visible=n.visible,c.wireframe=n.wireframe,c.side=o===m?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],c.clipShadows=n.clipShadows,c.clippingPlanes=n.clippingPlanes,c.clipIntersection=n.clipIntersection,c.wireframeLinewidth=n.wireframeLinewidth,c.linewidth=n.linewidth,!0===r.isPointLight&&!0===c.isMeshDistanceMaterial&&(c.referencePosition.setFromMatrixPosition(r.matrixWorld),c.nearDistance=i,c.farDistance=a),c}function A(n,i,a,o,s){if(!1!==n.visible){if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===m)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);var c=e.update(n),l=n.material;if(Array.isArray(l))for(var u=c.groups,h=0,d=u.length;hn||i.y>n)&&(console.warn("THREE.WebGLShadowMap:",v,"has shadow exceeding max texture size, reducing"),i.x>n&&(a.x=Math.floor(n/y.x),i.x=a.x*y.x,g.mapSize.x=a.x),i.y>n&&(a.y=Math.floor(n/y.y),i.y=a.y*y.y,g.mapSize.y=a.y)),null===g.map&&!g.isPointLightShadow&&this.type===m){var x={minFilter:Et,magFilter:Et,format:jt};g.map=new On(i.x,i.y,x),g.map.texture.name=v.name+".shadowMap",g.mapPass=new On(i.x,i.y,x),g.camera.updateProjectionMatrix()}if(null===g.map){x={minFilter:bt,magFilter:bt,format:jt};g.map=new On(i.x,i.y,x),g.map.texture.name=v.name+".shadowMap",g.camera.updateProjectionMatrix()}t.setRenderTarget(g.map),t.clear();for(var _=g.getViewportCount(),M=0;M<_;M++){var E=g.getViewport(M);o.set(a.x*E.x,a.y*E.y,a.x*E.z,a.y*E.w),d.viewport(o),g.updateMatrices(v,M),r=g.getFrustum(),A(s,c,g.camera,v,this.type)}g.isPointLightShadow||this.type!==m||w(g,c)}else console.warn("THREE.WebGLShadowMap:",v,"has no shadow.")}b.needsUpdate=!1,t.setRenderTarget(l,u,h)}}}function cs(t,e,n){var r=n.isWebGL2;var i=new function(){var e=!1,n=new Cn,r=null,i=new Cn(0,0,0,0);return{setMask:function(n){r===n||e||(t.colorMask(n,n,n,n),r=n)},setLocked:function(t){e=t},setClear:function(e,r,a,o,s){!0===s&&(e*=o,r*=o,a*=o),n.set(e,r,a,o),!1===i.equals(n)&&(t.clearColor(e,r,a,o),i.copy(n))},reset:function(){e=!1,r=null,i.set(-1,0,0,0)}}},a=new function(){var e=!1,n=null,r=null,i=null;return{setTest:function(t){t?xt(2929):bt(2929)},setMask:function(r){n===r||e||(t.depthMask(r),n=r)},setFunc:function(e){if(r!==e){if(e)switch(e){case q:t.depthFunc(512);break;case X:t.depthFunc(519);break;case Y:t.depthFunc(513);break;case Z:t.depthFunc(515);break;case J:t.depthFunc(514);break;case Q:t.depthFunc(518);break;case K:t.depthFunc(516);break;case $:t.depthFunc(517);break;default:t.depthFunc(515)}else t.depthFunc(515);r=e}},setLocked:function(t){e=t},setClear:function(e){i!==e&&(t.clearDepth(e),i=e)},reset:function(){e=!1,n=null,r=null,i=null}}},l=new function(){var e=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null;return{setTest:function(t){e||(t?xt(2960):bt(2960))},setMask:function(r){n===r||e||(t.stencilMask(r),n=r)},setFunc:function(e,n,o){r===e&&i===n&&a===o||(t.stencilFunc(e,n,o),r=e,i=n,a=o)},setOp:function(e,n,r){o===e&&s===n&&c===r||(t.stencilOp(e,n,r),o=e,s=n,c=r)},setLocked:function(t){e=t},setClear:function(e){l!==e&&(t.clearStencil(e),l=e)},reset:function(){e=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null}}},u=t.getParameter(34921),h=new Uint8Array(u),d=new Uint8Array(u),p=new Uint8Array(u),f={},m=null,v=null,x=null,b=null,w=null,_=null,M=null,tt=null,et=null,nt=!1,rt=null,it=null,at=null,ot=null,st=null,ct=t.getParameter(35661),lt=!1,ut=0,ht=t.getParameter(7938);-1!==ht.indexOf("WebGL")?(ut=parseFloat(/^WebGL\ ([0-9])/.exec(ht)[1]),lt=ut>=1):-1!==ht.indexOf("OpenGL ES")&&(ut=parseFloat(/^OpenGL\ ES\ ([0-9])/.exec(ht)[1]),lt=ut>=2);var dt=null,pt={},ft=new Cn,mt=new Cn;function vt(e,n,r){var i=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(var o=0;or||t.height>r)&&(i=r/Math.max(t.width,t.height)),i<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){var a=e?xn.floorPowerOfTwo:Math.floor,o=a(i*t.width),c=a(i*t.height);void 0===s&&(s=m(o,c));var l=n?m(o,c):s;return l.width=o,l.height=c,l.getContext("2d").drawImage(t,0,0,o,c),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+o+"x"+c+")."),l}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function g(t){return xn.isPowerOfTwo(t.width)&&xn.isPowerOfTwo(t.height)}function y(t,e){return t.generateMipmaps&&e&&t.minFilter!==bt&&t.minFilter!==Et}function x(e,n,i,a){t.generateMipmap(e),r.get(n).__maxMipLevel=Math.log(Math.max(i,a))*Math.LOG2E}function b(t,n){if(!1===c)return t;var r=t;return 6403===t&&(5126===n&&(r=33326),5131===n&&(r=33325),5121===n&&(r=33321)),6407===t&&(5126===n&&(r=34837),5131===n&&(r=34843),5121===n&&(r=32849)),6408===t&&(5126===n&&(r=34836),5131===n&&(r=34842),5121===n&&(r=32856)),33325===r||33326===r||34842===r||34836===r?e.get("EXT_color_buffer_float"):34843!==r&&34837!==r||console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead."),r}function w(t){return t===bt||t===wt||t===Mt?9728:9729}function _(e){var n=e.target;n.removeEventListener("dispose",_),function(e){var n=r.get(e);if(void 0===n.__webglInit)return;t.deleteTexture(n.__webglTexture),r.remove(e)}(n),n.isVideoTexture&&p.delete(n),o.memory.textures--}function M(e){var n=e.target;n.removeEventListener("dispose",M),function(e){var n=r.get(e),i=r.get(e.texture);if(!e)return;void 0!==i.__webglTexture&&t.deleteTexture(i.__webglTexture);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLRenderTargetCube)for(var a=0;a<6;a++)t.deleteFramebuffer(n.__webglFramebuffer[a]),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer[a]);else t.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&t.deleteRenderbuffer(n.__webglDepthbuffer);if(e.isWebGLMultiviewRenderTarget){t.deleteTexture(n.__webglColorTexture),t.deleteTexture(n.__webglDepthStencilTexture),o.memory.textures-=2;a=0;for(var s=n.__webglViewFramebuffers.length;a0&&i.__version!==t.version){var a=t.image;if(void 0===a)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==a.complete)return void O(i,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+e),n.bindTexture(3553,i.__webglTexture)}function A(e,i){if(6===e.image.length){var o=r.get(e);if(e.version>0&&o.__version!==e.version){C(o,e),n.activeTexture(33984+i),n.bindTexture(34067,o.__webglTexture),t.pixelStorei(37440,e.flipY);for(var s=e&&e.isCompressedTexture,l=e.image[0]&&e.image[0].isDataTexture,h=[],d=0;d<6;d++)h[d]=s||l?l?e.image[d].image:e.image[d]:v(e.image[d],!1,!0,u);var p,f=h[0],m=g(f)||c,w=a.convert(e.format),_=a.convert(e.type),M=b(w,_);if(P(34067,e,m),s){for(d=0;d<6;d++){p=h[d].mipmaps;for(var S=0;S1||r.get(a).__currentAnisotropy)&&(t.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function C(e,n){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",_),e.__webglTexture=t.createTexture(),o.memory.textures++)}function O(e,r,i){var o=3553;r.isDataTexture2DArray&&(o=35866),r.isDataTexture3D&&(o=32879),C(e,r),n.activeTexture(33984+i),n.bindTexture(o,e.__webglTexture),t.pixelStorei(37440,r.flipY),t.pixelStorei(37441,r.premultiplyAlpha),t.pixelStorei(3317,r.unpackAlignment);var s=function(t){return!c&&(t.wrapS!==yt||t.wrapT!==yt||t.minFilter!==bt&&t.minFilter!==Et)}(r)&&!1===g(r.image),l=v(r.image,s,!1,h),u=g(l)||c,d=a.convert(r.format),p=a.convert(r.type),f=b(d,p);P(o,r,u);var m,w=r.mipmaps;if(r.isDepthTexture){if(f=6402,r.type===Bt){if(!1===c)throw new Error("Float Depth Texture only supported in WebGL2.0");f=36012}else c&&(f=33189);r.format===Yt&&6402===f&&r.type!==Dt&&r.type!==Nt&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Dt,p=a.convert(r.type)),r.format===Zt&&(f=34041,r.type!==Ht&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=Ht,p=a.convert(r.type))),n.texImage2D(3553,0,f,l.width,l.height,0,d,p,null)}else if(r.isDataTexture)if(w.length>0&&u){for(var _=0,M=w.length;_0&&u){for(_=0,M=w.length;_=l&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+l),S+=1,t},this.resetTextureUnits=function(){S=0},this.setTexture2D=E,this.setTexture2DArray=function(t,e){var i=r.get(t);t.version>0&&i.__version!==t.version?O(i,t,e):(n.activeTexture(33984+e),n.bindTexture(35866,i.__webglTexture))},this.setTexture3D=function(t,e){var i=r.get(t);t.version>0&&i.__version!==t.version?O(i,t,e):(n.activeTexture(33984+e),n.bindTexture(32879,i.__webglTexture))},this.setTextureCube=A,this.setTextureCubeDynamic=T,this.setupRenderTarget=function(i){var s=r.get(i),l=r.get(i.texture);i.addEventListener("dispose",M),l.__webglTexture=t.createTexture(),o.memory.textures++;var u=!0===i.isWebGLRenderTargetCube,h=!0===i.isWebGLMultisampleRenderTarget,d=!0===i.isWebGLMultiviewRenderTarget,p=g(i)||c;if(u){s.__webglFramebuffer=[];for(var f=0;f<6;f++)s.__webglFramebuffer[f]=t.createFramebuffer()}else if(s.__webglFramebuffer=t.createFramebuffer(),h)if(c){s.__webglMultisampledFramebuffer=t.createFramebuffer(),s.__webglColorRenderbuffer=t.createRenderbuffer(),t.bindRenderbuffer(36161,s.__webglColorRenderbuffer);var m=b(a.convert(i.texture.format),a.convert(i.texture.type)),v=B(i);t.renderbufferStorageMultisample(36161,v,m,i.width,i.height),t.bindFramebuffer(36160,s.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(36160,36064,36161,s.__webglColorRenderbuffer),t.bindRenderbuffer(36161,null),i.depthBuffer&&(s.__webglDepthRenderbuffer=t.createRenderbuffer(),I(s.__webglDepthRenderbuffer,i,!0)),t.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");else if(d){var w=i.width,_=i.height,S=i.numViews;t.bindFramebuffer(36160,s.__webglFramebuffer);var E=e.get("OVR_multiview2");o.memory.textures+=2;var A=t.createTexture();t.bindTexture(35866,A),t.texParameteri(35866,10240,9728),t.texParameteri(35866,10241,9728),t.texImage3D(35866,0,32856,w,_,S,0,6408,5121,null),E.framebufferTextureMultiviewOVR(36160,36064,A,0,0,S);var T=t.createTexture();t.bindTexture(35866,T),t.texParameteri(35866,10240,9728),t.texParameteri(35866,10241,9728),t.texImage3D(35866,0,35056,w,_,S,0,34041,34042,null),E.framebufferTextureMultiviewOVR(36160,33306,T,0,0,S);var L=new Array(S);for(f=0;fd)return!1;for(var n=1,r=e.length;n=0){var l=i[s];if(void 0!==l){var u=l.normalized,h=l.itemSize;if(void 0===(M=w.get(l)))continue;var d=M.buffer,g=M.type,y=M.bytesPerElement;if(l.isInterleavedBufferAttribute){var x=l.data,b=x.stride,_=l.offset;x&&x.isInstancedInterleavedBuffer?(v.enableAttributeAndDivisor(c,x.meshPerAttribute),void 0===e.maxInstancedCount&&(e.maxInstancedCount=x.meshPerAttribute*x.count)):v.enableAttribute(c),p.bindBuffer(34962,d),p.vertexAttribPointer(c,h,g,u,b*y,_*y)}else l.isInstancedBufferAttribute?(v.enableAttributeAndDivisor(c,l.meshPerAttribute),void 0===e.maxInstancedCount&&(e.maxInstancedCount=l.meshPerAttribute*l.count)):v.enableAttribute(c),p.bindBuffer(34962,d),p.vertexAttribPointer(c,h,g,u,0,0)}else if("instanceMatrix"===s){var M;if(void 0===(M=w.get(t.instanceMatrix)))continue;d=M.buffer,g=M.type;v.enableAttributeAndDivisor(c+0,1),v.enableAttributeAndDivisor(c+1,1),v.enableAttributeAndDivisor(c+2,1),v.enableAttributeAndDivisor(c+3,1),p.bindBuffer(34962,d),p.vertexAttribPointer(c+0,4,g,!1,64,0),p.vertexAttribPointer(c+1,4,g,!1,64,16),p.vertexAttribPointer(c+2,4,g,!1,64,32),p.vertexAttribPointer(c+3,4,g,!1,64,48)}else if(void 0!==o){var S=o[s];if(void 0!==S)switch(S.length){case 2:p.vertexAttrib2fv(c,S);break;case 3:p.vertexAttrib3fv(c,S);break;case 4:p.vertexAttrib4fv(c,S);break;default:p.vertexAttrib1fv(c,S)}}}}v.disableUnusedAttributes()}(i,n,r,s),null!==u&&p.bindBuffer(34963,l.buffer));var y=1/0;null!==u?y=u.count:void 0!==h&&(y=h.count);var x=n.drawRange.start*d,b=n.drawRange.count*d,M=null!==a?a.start*d:0,S=null!==a?a.count*d:1/0,E=Math.max(x,M),A=Math.min(y,x+b,M+S)-1,T=Math.max(0,A-E+1);if(0!==T){if(i.isMesh)if(!0===r.wireframe)v.setLineWidth(r.wireframeLinewidth*at()),g.setMode(1);else switch(i.drawMode){case Re:g.setMode(4);break;case Pe:g.setMode(5);break;case Ce:g.setMode(6)}else if(i.isLine){var C=r.linewidth;void 0===C&&(C=1),v.setLineWidth(C*at()),i.isLineSegments?g.setMode(1):i.isLineLoop?g.setMode(2):g.setMode(3)}else i.isPoints?g.setMode(0):i.isSprite&&g.setMode(4);i.isInstancedMesh?g.renderInstances(n,E,T,i.count):n.isInstancedBufferGeometry?g.renderInstances(n,E,T,n.maxInstancedCount):g.render(E,T)}},this.compile=function(t,e){(d=A.get(t,e)).init(),t.traverse((function(t){t.isLight&&(d.pushLight(t),t.castShadow&&d.pushShadow(t))})),d.setupLights(e),t.traverse((function(e){if(e.material)if(Array.isArray(e.material))for(var n=0;n=0&&t.numSupportedMorphTargets++}if(t.morphNormals){t.numSupportedMorphNormals=0;for(f=0;f=0&&t.numSupportedMorphNormals++}var m=r.shader.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(r.numClippingPlanes=$.numPlanes,r.numIntersection=$.numIntersection,m.clippingPlanes=$.uniform),r.fog=e,r.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),r.lightsStateVersion=o,r.needsLights&&(m.ambientLightColor.value=i.state.ambient,m.lightProbe.value=i.state.probe,m.directionalLights.value=i.state.directional,m.spotLights.value=i.state.spot,m.rectAreaLights.value=i.state.rectArea,m.pointLights.value=i.state.point,m.hemisphereLights.value=i.state.hemi,m.directionalShadowMap.value=i.state.directionalShadowMap,m.directionalShadowMatrix.value=i.state.directionalShadowMatrix,m.spotShadowMap.value=i.state.spotShadowMap,m.spotShadowMatrix.value=i.state.spotShadowMatrix,m.pointShadowMap.value=i.state.pointShadowMap,m.pointShadowMatrix.value=i.state.pointShadowMatrix);var v=r.program.getUniforms(),g=To.seqWithValue(v.seq,m);r.uniformsList=g}function wt(t,e,n,r){b.resetTextureUnits();var i=x.get(n),a=d.state.lights;if(tt&&(et||t!==H)){var o=t===H&&n.id===U;$.setState(n.clippingPlanes,n.clipIntersection,n.clipShadows,t,i,o)}!1===n.needsUpdate&&(void 0===i.program?n.needsUpdate=!0:n.fog&&i.fog!==e?n.needsUpdate=!0:i.needsLights&&i.lightsStateVersion!==a.state.version?n.needsUpdate=!0:void 0===i.numClippingPlanes||i.numClippingPlanes===$.numPlanes&&i.numIntersection===$.numIntersection||(n.needsUpdate=!0)),n.needsUpdate&&(bt(n,e,r),n.needsUpdate=!1);var s,c,l=!1,u=!1,h=!1,f=i.program,y=f.getUniforms(),w=i.shader.uniforms;if(v.useProgram(f.program)&&(l=!0,u=!0,h=!0),n.id!==U&&(U=n.id,u=!0),l||H!==t){if(f.numMultiviewViews>0?lt.updateCameraProjectionMatricesUniform(t,y):y.setValue(p,"projectionMatrix",t.projectionMatrix),m.logarithmicDepthBuffer&&y.setValue(p,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),H!==t&&(H=t,u=!0,h=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshStandardMaterial||n.envMap){var _=y.map.cameraPosition;void 0!==_&&_.setValue(p,rt.setFromMatrixPosition(t.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&y.setValue(p,"isOrthographic",!0===t.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.skinning)&&(f.numMultiviewViews>0?lt.updateCameraViewMatricesUniform(t,y):y.setValue(p,"viewMatrix",t.matrixWorldInverse))}if(n.skinning){y.setOptional(p,r,"bindMatrix"),y.setOptional(p,r,"bindMatrixInverse");var M=r.skeleton;if(M){var S=M.bones;if(m.floatVertexTextures){if(void 0===M.boneTexture){var E=Math.sqrt(4*S.length);E=xn.ceilPowerOfTwo(E),E=Math.max(E,4);var A=new Float32Array(E*E*4);A.set(M.boneMatrices);var T=new ca(A,E,E,jt,Bt);M.boneMatrices=A,M.boneTexture=T,M.boneTextureSize=E}y.setValue(p,"boneTexture",M.boneTexture,b),y.setValue(p,"boneTextureSize",M.boneTextureSize)}else y.setOptional(p,M,"boneMatrices")}}return(u||i.receiveShadow!==r.receiveShadow)&&(i.receiveShadow=r.receiveShadow,y.setValue(p,"receiveShadow",r.receiveShadow)),u&&(y.setValue(p,"toneMappingExposure",O.toneMappingExposure),y.setValue(p,"toneMappingWhitePoint",O.toneMappingWhitePoint),i.needsLights&&(c=h,(s=w).ambientLightColor.needsUpdate=c,s.lightProbe.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.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)}(w,e),n.isMeshBasicMaterial?_t(w,n):n.isMeshLambertMaterial?(_t(w,n),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(w,n)):n.isMeshPhongMaterial?(_t(w,n),n.isMeshToonMaterial?function(t,e){Mt(t,e),e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(w,n):Mt(w,n)):n.isMeshStandardMaterial?(_t(w,n),n.isMeshPhysicalMaterial?function(t,e){St(t,e),t.reflectivity.value=e.reflectivity,t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.sheen&&t.sheen.value.copy(e.sheen);e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,e.side===g&&t.clearcoatNormalScale.value.negate());t.transparency.value=e.transparency}(w,n):St(w,n)):n.isMeshMatcapMaterial?(_t(w,n),function(t,e){e.matcap&&(t.matcap.value=e.matcap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===g&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,n)):n.isMeshDepthMaterial?(_t(w,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,n)):n.isMeshDistanceMaterial?(_t(w,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}(w,n)):n.isMeshNormalMaterial?(_t(w,n),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,e.side===g&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(w,n)):n.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(w,n),n.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(w,n)):n.isPointsMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*Y,t.scale.value=.5*X,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);var n;e.map?n=e.map:e.alphaMap&&(n=e.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}(w,n):n.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);var n;e.map?n=e.map:e.alphaMap&&(n=e.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}(w,n):n.isShadowMaterial&&(w.color.value.copy(n.color),w.opacity.value=n.opacity),void 0!==w.ltc_1&&(w.ltc_1.value=pa.LTC_1),void 0!==w.ltc_2&&(w.ltc_2.value=pa.LTC_2),To.upload(p,i.uniformsList,w,b),n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(To.upload(p,i.uniformsList,w,b),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&y.setValue(p,"center",r.center),f.numMultiviewViews>0?lt.updateObjectMatricesUniforms(r,t,y):(y.setValue(p,"modelViewMatrix",r.modelViewMatrix),y.setValue(p,"normalMatrix",r.normalMatrix)),y.setValue(p,"modelMatrix",r.matrixWorld),f}function _t(t,e){var n;t.opacity.value=e.opacity,e.color&&t.diffuse.value.copy(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.isCubeTexture?-1:1,t.reflectivity.value=e.reflectivity,t.refractionRatio.value=e.refractionRatio,t.maxMipLevel.value=x.get(e.envMap).__maxMipLevel),e.lightMap&&(t.lightMap.value=e.lightMap,t.lightMapIntensity.value=e.lightMapIntensity),e.aoMap&&(t.aoMap.value=e.aoMap,t.aoMapIntensity.value=e.aoMapIntensity),e.map?n=e.map:e.specularMap?n=e.specularMap:e.displacementMap?n=e.displacementMap:e.normalMap?n=e.normalMap:e.bumpMap?n=e.bumpMap:e.roughnessMap?n=e.roughnessMap:e.metalnessMap?n=e.metalnessMap:e.alphaMap?n=e.alphaMap:e.emissiveMap&&(n=e.emissiveMap),void 0!==n&&(n.isWebGLRenderTarget&&(n=n.texture),!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}function Mt(t,e){t.specular.value.copy(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.side===g&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}function St(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.side===g&&(t.bumpScale.value*=-1)),e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),e.side===g&&t.normalScale.value.negate()),e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias),e.envMap&&(t.envMapIntensity.value=e.envMapIntensity)}vt.setAnimationLoop((function(t){ct.isPresenting()||mt&&mt(t)})),"undefined"!=typeof window&&vt.setContext(window),this.setAnimationLoop=function(t){mt=t,ct.setAnimationLoop(t),vt.start()},this.render=function(t,e){var n,r;if(void 0!==arguments[2]&&(console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead."),n=arguments[2]),void 0!==arguments[3]&&(console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead."),r=arguments[3]),e&&e.isCamera){if(!D){G.geometry=null,G.program=null,G.wireframe=!1,U=-1,H=null,!0===t.autoUpdate&&t.updateMatrixWorld(),null===e.parent&&e.updateMatrixWorld(),ct.enabled&&(e=ct.getCamera(e)),(d=A.get(t,e)).init(),t.onBeforeRender(O,t,e,n||F),nt.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),K.setFromMatrix(nt),et=this.localClippingEnabled,tt=$.init(this.clippingPlanes,et,e),(h=E.get(t,e)).init(),gt(t,e,0,O.sortObjects),!0===O.sortObjects&&h.sort(),tt&&$.beginShadows();var i=d.state.shadowsArray;ut.render(i,t,e),d.setupLights(e),tt&&$.endShadows(),this.info.autoReset&&this.info.reset(),void 0!==n&&this.setRenderTarget(n),ct.enabled&<.isAvailable()&<.attachCamera(e),T.render(h,t,e,r);var a=h.opaque,o=h.transparent;if(t.overrideMaterial){var s=t.overrideMaterial;a.length&&yt(a,t,e,s),o.length&&yt(o,t,e,s)}else a.length&&yt(a,t,e),o.length&&yt(o,t,e);t.onAfterRender(O,t,e),null!==F&&(b.updateRenderTargetMipmap(F),b.updateMultisampleRenderTarget(F)),v.buffers.depth.setTest(!0),v.buffers.depth.setMask(!0),v.buffers.color.setMask(!0),v.setPolygonOffset(!1),ct.enabled&&(lt.isAvailable()&<.detachCamera(e),ct.submitFrame()),h=null,d=null}}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.setFramebuffer=function(t){I!==t&&null===F&&p.bindFramebuffer(36160,t),I=t},this.getActiveCubeFace=function(){return N},this.getActiveMipmapLevel=function(){return B},this.getRenderTarget=function(){return F},this.setRenderTarget=function(t,e,n){F=t,N=e,B=n,t&&void 0===x.get(t).__webglFramebuffer&&b.setupRenderTarget(t);var r=I,i=!1;if(t){var a=x.get(t).__webglFramebuffer;t.isWebGLRenderTargetCube?(r=a[e||0],i=!0):r=t.isWebGLMultisampleRenderTarget?x.get(t).__webglMultisampledFramebuffer:a,k.copy(t.viewport),j.copy(t.scissor),W=t.scissorTest}else k.copy(Z).multiplyScalar(Y).floor(),j.copy(J).multiplyScalar(Y).floor(),W=Q;if(z!==r&&(p.bindFramebuffer(36160,r),z=r),v.viewport(k),v.scissor(j),v.setScissorTest(W),i){var o=x.get(t.texture);p.framebufferTexture2D(36160,36064,34069+(e||0),o.__webglTexture,n||0)}},this.readRenderTargetPixels=function(t,e,n,r,i,a,o){if(t&&t.isWebGLRenderTarget){var s=x.get(t).__webglFramebuffer;if(t.isWebGLRenderTargetCube&&void 0!==o&&(s=s[o]),s){var c=!1;s!==z&&(p.bindFramebuffer(36160,s),c=!0);try{var l=t.texture,u=l.format,h=l.type;if(u!==jt&&C.convert(u)!==p.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");if(!(h===Pt||C.convert(h)===p.getParameter(35738)||h===Bt&&(m.isWebGL2||f.get("OES_texture_float")||f.get("WEBGL_color_buffer_float"))||h===Ft&&(m.isWebGL2?f.get("EXT_color_buffer_float"):f.get("EXT_color_buffer_half_float"))))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===p.checkFramebufferStatus(36160)?e>=0&&e<=t.width-r&&n>=0&&n<=t.height-i&&p.readPixels(e,n,r,i,C.convert(u),C.convert(h),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{c&&p.bindFramebuffer(36160,z)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(t,e,n){void 0===n&&(n=0);var r=Math.pow(2,-n),i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=C.convert(e.format);b.setTexture2D(e,0),p.copyTexImage2D(3553,n,o,t.x,t.y,i,a,0),v.unbindTexture()},this.copyTextureToTexture=function(t,e,n,r){var i=e.image.width,a=e.image.height,o=C.convert(n.format),s=C.convert(n.type);b.setTexture2D(n,0),e.isDataTexture?p.texSubImage2D(3553,r||0,t.x,t.y,i,a,o,s,e.image.data):p.texSubImage2D(3553,r||0,t.x,t.y,o,s,e.image),v.unbindTexture()},this.initTexture=function(t){b.setTexture2D(t,0),v.unbindTexture()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function _s(t,e){this.name="",this.color=new Zr(t),this.density=void 0!==e?e:25e-5}function Ms(t,e,n){this.name="",this.color=new Zr(t),this.near=void 0!==e?e:1,this.far=void 0!==n?n:1e3}function Ss(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=sn,this.updateRange={offset:0,count:-1},this.version=0}function Es(t,e,n,r){this.data=t,this.itemSize=e,this.offset=n,this.normalized=!0===r}function As(t){ei.call(this),this.type="SpriteMaterial",this.color=new Zr(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(t)}Object.assign(xs.prototype,vn.prototype),Object.assign(bs.prototype,vn.prototype),Object.assign(_s.prototype,{isFogExp2:!0,clone:function(){return new _s(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}),Object.assign(Ms.prototype,{isFog:!0,clone:function(){return new Ms(this.color,this.near,this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}),Object.defineProperty(Ss.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(Ss.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this},copyAt:function(t,e,n){t*=this.stride,n*=e.stride;for(var r=0,i=this.stride;rt.far||e.push({distance:s,point:Ts.clone(),uv:Wr.getUV(Ts,Ds,Is,Ns,Bs,Fs,zs,new bn),face:null,object:this})}},clone:function(){return new this.constructor(this.material).copy(this)},copy:function(t){return ar.prototype.copy.call(this,t),void 0!==t.center&&this.center.copy(t.center),this}});var Hs=new Sn,Vs=new Sn;function ks(){ar.call(this),this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}function js(t,e){t&&t.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead."),Gi.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new Hn,this.bindMatrixInverse=new Hn}ks.prototype=Object.assign(Object.create(ar.prototype),{constructor:ks,isLOD:!0,copy:function(t){ar.prototype.copy.call(this,t,!1);for(var e=t.levels,n=0,r=e.length;n1){Hs.setFromMatrixPosition(t.matrixWorld),Vs.setFromMatrixPosition(this.matrixWorld);var n=Hs.distanceTo(Vs);e[0].object.visible=!0;for(var r=1,i=e.length;r=e[r].distance;r++)e[r-1].object.visible=!1,e[r].object.visible=!0;for(;ro))u.applyMatrix4(this.matrixWorld),(w=t.ray.origin.distanceTo(u))t.far||e.push({distance:w,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}else for(m=0,v=p.length/3-1;mo))u.applyMatrix4(this.matrixWorld),(w=t.ray.origin.distanceTo(u))t.far||e.push({distance:w,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}else if(r.isGeometry){var x=r.vertices,b=x.length;for(m=0;mo))u.applyMatrix4(this.matrixWorld),(w=t.ray.origin.distanceTo(u))t.far||e.push({distance:w,point:l.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var rc=new Sn,ic=new Sn;function ac(t,e){nc.call(this,t,e),this.type="LineSegments"}function oc(t,e){nc.call(this,t,e),this.type="LineLoop"}function sc(t){ei.call(this),this.type="PointsMaterial",this.color=new Zr(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(t)}ac.prototype=Object.assign(Object.create(nc.prototype),{constructor:ac,isLineSegments:!0,computeLineDistances:function(){var t=this.geometry;if(t.isBufferGeometry)if(null===t.index){for(var e=t.attributes.position,n=[],r=0,i=e.count;ri.far)return;a.push({distance:l,distanceToRay:Math.sqrt(s),point:c,index:e,face:null,object:o})}}function fc(t,e,n,r,i,a,o,s,c){Pn.call(this,t,e,n,r,i,a,o,s,c),this.format=void 0!==o?o:kt,this.minFilter=void 0!==a?a:Et,this.magFilter=void 0!==i?i:Et,this.generateMipmaps=!1}function mc(t,e,n,r,i,a,o,s,c,l,u,h){Pn.call(this,null,a,o,s,c,l,r,i,u,h),this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}function vc(t,e,n,r,i,a,o,s,c){Pn.call(this,t,e,n,r,i,a,o,s,c),this.needsUpdate=!0}function gc(t,e,n,r,i,a,o,s,c,l){if((l=void 0!==l?l:Yt)!==Yt&&l!==Zt)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&l===Yt&&(n=Dt),void 0===n&&l===Zt&&(n=Ht),Pn.call(this,null,r,i,a,o,s,l,n,c),this.image={width:t,height:e},this.magFilter=void 0!==o?o:bt,this.minFilter=void 0!==s?s:bt,this.flipY=!1,this.generateMipmaps=!1}function yc(t){_i.call(this),this.type="WireframeGeometry";var e,n,r,i,a,o,s,c,l,u,h=[],d=[0,0],p={},f=["a","b","c"];if(t&&t.isGeometry){var m=t.faces;for(e=0,r=m.length;e=0?(t(v-1e-5,m,h),d.subVectors(u,h)):(t(v+1e-5,m,h),d.subVectors(h,u)),m-1e-5>=0?(t(v,m-1e-5,h),p.subVectors(u,h)):(t(v,m+1e-5,h),p.subVectors(h,u)),l.crossVectors(d,p).normalize(),s.push(l.x,l.y,l.z),c.push(v,m)}}for(r=0;r.9&&o<.1&&(e<.2&&(a[t+0]+=1),n<.2&&(a[t+2]+=1),r<.2&&(a[t+4]+=1))}}()}(),this.setAttribute("position",new hi(i,3)),this.setAttribute("normal",new hi(i.slice(),3)),this.setAttribute("uv",new hi(a,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}function Mc(t,e){Xi.call(this),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Sc(t,e)),this.mergeVertices()}function Sc(t,e){_c.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 Ec(t,e){Xi.call(this),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Ac(t,e)),this.mergeVertices()}function Ac(t,e){_c.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 Tc(t,e){Xi.call(this),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Lc(t,e)),this.mergeVertices()}function Lc(t,e){var n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1];_c.call(this,r,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,e),this.type="IcosahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Rc(t,e){Xi.call(this),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e},this.fromBufferGeometry(new Pc(t,e)),this.mergeVertices()}function Pc(t,e){var n=(1+Math.sqrt(5))/2,r=1/n,i=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r];_c.call(this,i,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronBufferGeometry",this.parameters={radius:t,detail:e}}function Cc(t,e,n,r,i,a){Xi.call(this),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:r,closed:i},void 0!==a&&console.warn("THREE.TubeGeometry: taper has been removed.");var o=new Oc(t,e,n,r,i);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals,this.fromBufferGeometry(o),this.mergeVertices()}function Oc(t,e,n,r,i){_i.call(this),this.type="TubeBufferGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:r,closed:i},e=e||64,n=n||1,r=r||8,i=i||!1;var a=t.computeFrenetFrames(e,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;var o,s,c=new Sn,l=new Sn,u=new bn,h=new Sn,d=[],p=[],f=[],m=[];function v(i){h=t.getPointAt(i/e,h);var o=a.normals[i],u=a.binormals[i];for(s=0;s<=r;s++){var f=s/r*Math.PI*2,m=Math.sin(f),v=-Math.cos(f);l.x=v*o.x+m*u.x,l.y=v*o.y+m*u.y,l.z=v*o.z+m*u.z,l.normalize(),p.push(l.x,l.y,l.z),c.x=h.x+n*l.x,c.y=h.y+n*l.y,c.z=h.z+n*l.z,d.push(c.x,c.y,c.z)}}!function(){for(o=0;o0){var o=i[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,e=o.length;t0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}}),fc.prototype=Object.assign(Object.create(Pn.prototype),{constructor:fc,isVideoTexture:!0,update:function(){var t=this.image;t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}),mc.prototype=Object.create(Pn.prototype),mc.prototype.constructor=mc,mc.prototype.isCompressedTexture=!0,vc.prototype=Object.create(Pn.prototype),vc.prototype.constructor=vc,vc.prototype.isCanvasTexture=!0,gc.prototype=Object.create(Pn.prototype),gc.prototype.constructor=gc,gc.prototype.isDepthTexture=!0,yc.prototype=Object.create(_i.prototype),yc.prototype.constructor=yc,xc.prototype=Object.create(Xi.prototype),xc.prototype.constructor=xc,bc.prototype=Object.create(_i.prototype),bc.prototype.constructor=bc,wc.prototype=Object.create(Xi.prototype),wc.prototype.constructor=wc,_c.prototype=Object.create(_i.prototype),_c.prototype.constructor=_c,Mc.prototype=Object.create(Xi.prototype),Mc.prototype.constructor=Mc,Sc.prototype=Object.create(_c.prototype),Sc.prototype.constructor=Sc,Ec.prototype=Object.create(Xi.prototype),Ec.prototype.constructor=Ec,Ac.prototype=Object.create(_c.prototype),Ac.prototype.constructor=Ac,Tc.prototype=Object.create(Xi.prototype),Tc.prototype.constructor=Tc,Lc.prototype=Object.create(_c.prototype),Lc.prototype.constructor=Lc,Rc.prototype=Object.create(Xi.prototype),Rc.prototype.constructor=Rc,Pc.prototype=Object.create(_c.prototype),Pc.prototype.constructor=Pc,Cc.prototype=Object.create(Xi.prototype),Cc.prototype.constructor=Cc,Oc.prototype=Object.create(_i.prototype),Oc.prototype.constructor=Oc,Oc.prototype.toJSON=function(){var t=_i.prototype.toJSON.call(this);return t.path=this.parameters.path.toJSON(),t},Dc.prototype=Object.create(Xi.prototype),Dc.prototype.constructor=Dc,Ic.prototype=Object.create(_i.prototype),Ic.prototype.constructor=Ic,Nc.prototype=Object.create(Xi.prototype),Nc.prototype.constructor=Nc,Bc.prototype=Object.create(_i.prototype),Bc.prototype.constructor=Bc;var Fc=function(t,e,n){n=n||2;var r,i,a,o,s,c,l,u=e&&e.length,h=u?e[0]*n:t.length,d=zc(t,0,h,n,!0),p=[];if(!d||d.next===d.prev)return p;if(u&&(d=function(t,e,n,r){var i,a,o,s,c,l=[];for(i=0,a=e.length;i80*n){r=a=t[0],i=o=t[1];for(var f=n;fa&&(a=s),c>o&&(o=c);l=0!==(l=Math.max(a-r,o-i))?1/l:0}return Gc(d,p,n,r,i,l),p};function zc(t,e,n,r,i){var a,o;if(i===function(t,e,n,r){for(var i=0,a=e,o=n-r;a0)for(a=e;a=e;a-=r)o=nl(a,t[a],t[a+1],o);return o&&Kc(o,o.next)&&(rl(o),o=o.next),o}function Uc(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!Kc(r,r.next)&&0!==Qc(r.prev,r,r.next))r=r.next;else{if(rl(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function Gc(t,e,n,r,i,a,o){if(t){!o&&a&&function(t,e,n,r){var i=t;do{null===i.z&&(i.z=Xc(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,a,o,s,c,l=1;do{for(n=t,t=null,a=null,o=0;n;){for(o++,r=n,s=0,e=0;e0||c>0&&r;)0!==s&&(0===c||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,c--),a?a.nextZ=i:t=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1)}(i)}(t,r,i,a);for(var s,c,l=t;t.prev!==t.next;)if(s=t.prev,c=t.next,a?Vc(t,r,i,a):Hc(t))e.push(s.i/n),e.push(t.i/n),e.push(c.i/n),rl(t),t=c.next,l=c.next;else if((t=c)===l){o?1===o?Gc(t=kc(t,e,n),e,n,r,i,a,2):2===o&&jc(t,e,n,r,i,a):Gc(Uc(t),e,n,r,i,a,1);break}}}function Hc(t){var e=t.prev,n=t,r=t.next;if(Qc(e,n,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(Zc(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Qc(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function Vc(t,e,n,r){var i=t.prev,a=t,o=t.next;if(Qc(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,u=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,h=Xc(s,c,e,n,r),d=Xc(l,u,e,n,r),p=t.prevZ,f=t.nextZ;p&&p.z>=h&&f&&f.z<=d;){if(p!==t.prev&&p!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Qc(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==t.prev&&f!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Qc(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=h;){if(p!==t.prev&&p!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&Qc(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==t.prev&&f!==t.next&&Zc(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&Qc(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function kc(t,e,n){var r=t;do{var i=r.prev,a=r.next.next;!Kc(i,a)&&$c(i,r,r.next,a)&&tl(i,a)&&tl(a,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(a.i/n),rl(r),rl(r.next),r=t=a),r=r.next}while(r!==t);return r}function jc(t,e,n,r,i,a){var o=t;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&Jc(o,s)){var c=el(o,s);return o=Uc(o,o.next),c=Uc(c,c.next),Gc(o,e,n,r,i,a),void Gc(c,e,n,r,i,a)}s=s.next}o=o.next}while(o!==t)}function Wc(t,e){return t.x-e.x}function qc(t,e){if(e=function(t,e){var n,r=e,i=t.x,a=t.y,o=-1/0;do{if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){var s=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>o){if(o=s,s===i){if(a===r.y)return r;if(a===r.next.y)return r.next}n=r.x=r.x&&r.x>=u&&i!==r.x&&Zc(an.x)&&tl(r,t)&&(n=r,d=c),r=r.next;return n}(t,e)){var n=el(e,t);Uc(n,n.next)}}function Xc(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Yc(t){var e=t,n=t;do{(e.x=0&&(t-o)*(r-s)-(n-o)*(e-s)>=0&&(n-o)*(a-s)-(i-o)*(r-s)>=0}function Jc(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&&$c(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&tl(t,e)&&tl(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,a=(t.y+e.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)}function Qc(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Kc(t,e){return t.x===e.x&&t.y===e.y}function $c(t,e,n,r){return!!(Kc(t,n)&&Kc(e,r)||Kc(t,r)&&Kc(n,e))||Qc(t,e,n)>0!=Qc(t,e,r)>0&&Qc(n,r,t)>0!=Qc(n,r,e)>0}function tl(t,e){return Qc(t.prev,t,t.next)<0?Qc(t,e,t.next)>=0&&Qc(t,t.prev,e)>=0:Qc(t,e,t.prev)<0||Qc(t,t.next,e)<0}function el(t,e){var n=new il(t.i,t.x,t.y),r=new il(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function nl(t,e,n,r){var i=new il(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function rl(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 il(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 al={area:function(t){for(var e=t.length,n=0,r=e-1,i=0;i2&&t[e-1].equals(t[0])&&t.pop()}function sl(t,e){for(var n=0;nNumber.EPSILON){var d=Math.sqrt(u),p=Math.sqrt(c*c+l*l),f=e.x-s/d,m=e.y+o/d,v=((n.x-l/p-f)*l-(n.y+c/p-m)*c)/(o*l-s*c),g=(r=f+o*v-t.x)*r+(i=m+s*v-t.y)*i;if(g<=2)return new bn(r,i);a=Math.sqrt(g/2)}else{var y=!1;o>Number.EPSILON?c>Number.EPSILON&&(y=!0):o<-Number.EPSILON?c<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(l)&&(y=!0),y?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new bn(r/a,i/a)}for(var G=[],H=0,V=R.length,k=V-1,j=H+1;H=0;C--){for(D=C/p,I=u*Math.cos(D*Math.PI/2),O=h*Math.sin(D*Math.PI/2)+d,H=0,V=R.length;H=0;){n=H,(r=H-1)<0&&(r=t.length-1);var i=0,a=s+2*p;for(i=0;i0)&&f.push(_,M,E),(c!==n-1||l0&&g(!0),e>0&&g(!1)),this.setIndex(l),this.setAttribute("position",new hi(u,3)),this.setAttribute("normal",new hi(h,3)),this.setAttribute("uv",new hi(d,2))}function Al(t,e,n,r,i,a,o){Sl.call(this,0,t,e,n,r,i,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}function Tl(t,e,n,r,i,a,o){El.call(this,0,t,e,n,r,i,a,o),this.type="ConeBufferGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:r,openEnded:i,thetaStart:a,thetaLength:o}}function Ll(t,e,n,r){Xi.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},this.fromBufferGeometry(new Rl(t,e,n,r)),this.mergeVertices()}function Rl(t,e,n,r){_i.call(this),this.type="CircleBufferGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},t=t||1,e=void 0!==e?Math.max(3,e):8,n=void 0!==n?n:0,r=void 0!==r?r:2*Math.PI;var i,a,o=[],s=[],c=[],l=[],u=new Sn,h=new bn;for(s.push(0,0,0),c.push(0,0,1),l.push(.5,.5),a=0,i=3;a<=e;a++,i+=3){var d=n+a/e*r;u.x=t*Math.cos(d),u.y=t*Math.sin(d),s.push(u.x,u.y,u.z),c.push(0,0,1),h.x=(s[i]/t+1)/2,h.y=(s[i+1]/t+1)/2,l.push(h.x,h.y)}for(i=1;i<=e;i++)o.push(i,i+1,0);this.setIndex(o),this.setAttribute("position",new hi(s,3)),this.setAttribute("normal",new hi(c,3)),this.setAttribute("uv",new hi(l,2))}dl.prototype=Object.create(Xi.prototype),dl.prototype.constructor=dl,pl.prototype=Object.create(ll.prototype),pl.prototype.constructor=pl,fl.prototype=Object.create(Xi.prototype),fl.prototype.constructor=fl,ml.prototype=Object.create(_i.prototype),ml.prototype.constructor=ml,vl.prototype=Object.create(Xi.prototype),vl.prototype.constructor=vl,gl.prototype=Object.create(_i.prototype),gl.prototype.constructor=gl,yl.prototype=Object.create(Xi.prototype),yl.prototype.constructor=yl,xl.prototype=Object.create(_i.prototype),xl.prototype.constructor=xl,bl.prototype=Object.create(Xi.prototype),bl.prototype.constructor=bl,bl.prototype.toJSON=function(){var t=Xi.prototype.toJSON.call(this);return _l(this.parameters.shapes,t)},wl.prototype=Object.create(_i.prototype),wl.prototype.constructor=wl,wl.prototype.toJSON=function(){var t=_i.prototype.toJSON.call(this);return _l(this.parameters.shapes,t)},Ml.prototype=Object.create(_i.prototype),Ml.prototype.constructor=Ml,Sl.prototype=Object.create(Xi.prototype),Sl.prototype.constructor=Sl,El.prototype=Object.create(_i.prototype),El.prototype.constructor=El,Al.prototype=Object.create(Sl.prototype),Al.prototype.constructor=Al,Tl.prototype=Object.create(El.prototype),Tl.prototype.constructor=Tl,Ll.prototype=Object.create(Xi.prototype),Ll.prototype.constructor=Ll,Rl.prototype=Object.create(_i.prototype),Rl.prototype.constructor=Rl;var Pl=Object.freeze({__proto__:null,WireframeGeometry:yc,ParametricGeometry:xc,ParametricBufferGeometry:bc,TetrahedronGeometry:Mc,TetrahedronBufferGeometry:Sc,OctahedronGeometry:Ec,OctahedronBufferGeometry:Ac,IcosahedronGeometry:Tc,IcosahedronBufferGeometry:Lc,DodecahedronGeometry:Rc,DodecahedronBufferGeometry:Pc,PolyhedronGeometry:wc,PolyhedronBufferGeometry:_c,TubeGeometry:Cc,TubeBufferGeometry:Oc,TorusKnotGeometry:Dc,TorusKnotBufferGeometry:Ic,TorusGeometry:Nc,TorusBufferGeometry:Bc,TextGeometry:dl,TextBufferGeometry:pl,SphereGeometry:fl,SphereBufferGeometry:ml,RingGeometry:vl,RingBufferGeometry:gl,PlaneGeometry:ga,PlaneBufferGeometry:ya,LatheGeometry:yl,LatheBufferGeometry:xl,ShapeGeometry:bl,ShapeBufferGeometry:wl,ExtrudeGeometry:cl,ExtrudeBufferGeometry:ll,EdgesGeometry:Ml,ConeGeometry:Al,ConeBufferGeometry:Tl,CylinderGeometry:Sl,CylinderBufferGeometry:El,CircleGeometry:Ll,CircleBufferGeometry:Rl,BoxGeometry:Yi,BoxBufferGeometry:Zi});function Cl(t){ei.call(this),this.type="ShadowMaterial",this.color=new Zr(0),this.transparent=!0,this.setValues(t)}function Ol(t){ea.call(this,t),this.type="RawShaderMaterial"}function Dl(t){ei.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Zr(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 Zr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(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 Il(t){Dl.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.reflectivity=.5,this.clearcoat=0,this.clearcoatRoughness=0,this.sheen=null,this.clearcoatNormalScale=new bn(1,1),this.clearcoatNormalMap=null,this.transparency=0,this.setValues(t)}function Nl(t){ei.call(this),this.type="MeshPhongMaterial",this.color=new Zr(16777215),this.specular=new Zr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Zr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=tt,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 Bl(t){Nl.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.gradientMap=null,this.setValues(t)}function Fl(t){ei.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function zl(t){ei.call(this),this.type="MeshLambertMaterial",this.color=new Zr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Zr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=tt,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 Ul(t){ei.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Zr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ve,this.normalScale=new bn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Gl(t){Js.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}Cl.prototype=Object.create(ei.prototype),Cl.prototype.constructor=Cl,Cl.prototype.isShadowMaterial=!0,Cl.prototype.copy=function(t){return ei.prototype.copy.call(this,t),this.color.copy(t.color),this},Ol.prototype=Object.create(ea.prototype),Ol.prototype.constructor=Ol,Ol.prototype.isRawShaderMaterial=!0,Dl.prototype=Object.create(ei.prototype),Dl.prototype.constructor=Dl,Dl.prototype.isMeshStandardMaterial=!0,Dl.prototype.copy=function(t){return ei.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.normalMapType=t.normalMapType,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},Il.prototype=Object.create(Dl.prototype),Il.prototype.constructor=Il,Il.prototype.isMeshPhysicalMaterial=!0,Il.prototype.copy=function(t){return Dl.prototype.copy.call(this,t),this.defines={STANDARD:"",PHYSICAL:""},this.reflectivity=t.reflectivity,this.clearcoat=t.clearcoat,this.clearcoatRoughness=t.clearcoatRoughness,t.sheen?this.sheen=(this.sheen||new Zr).copy(t.sheen):this.sheen=null,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.transparency=t.transparency,this},Nl.prototype=Object.create(ei.prototype),Nl.prototype.constructor=Nl,Nl.prototype.isMeshPhongMaterial=!0,Nl.prototype.copy=function(t){return ei.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.normalMapType=t.normalMapType,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},Bl.prototype=Object.create(Nl.prototype),Bl.prototype.constructor=Bl,Bl.prototype.isMeshToonMaterial=!0,Bl.prototype.copy=function(t){return Nl.prototype.copy.call(this,t),this.gradientMap=t.gradientMap,this},Fl.prototype=Object.create(ei.prototype),Fl.prototype.constructor=Fl,Fl.prototype.isMeshNormalMaterial=!0,Fl.prototype.copy=function(t){return ei.prototype.copy.call(this,t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,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},zl.prototype=Object.create(ei.prototype),zl.prototype.constructor=zl,zl.prototype.isMeshLambertMaterial=!0,zl.prototype.copy=function(t){return ei.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},Ul.prototype=Object.create(ei.prototype),Ul.prototype.constructor=Ul,Ul.prototype.isMeshMatcapMaterial=!0,Ul.prototype.copy=function(t){return ei.prototype.copy.call(this,t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},Gl.prototype=Object.create(Js.prototype),Gl.prototype.constructor=Gl,Gl.prototype.isLineDashedMaterial=!0,Gl.prototype.copy=function(t){return Js.prototype.copy.call(this,t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this};var Hl=Object.freeze({__proto__:null,ShadowMaterial:Cl,SpriteMaterial:As,RawShaderMaterial:Ol,ShaderMaterial:ea,PointsMaterial:sc,MeshPhysicalMaterial:Il,MeshStandardMaterial:Dl,MeshPhongMaterial:Nl,MeshToonMaterial:Bl,MeshNormalMaterial:Fl,MeshLambertMaterial:zl,MeshDepthMaterial:rs,MeshDistanceMaterial:is,MeshBasicMaterial:ni,MeshMatcapMaterial:Ul,LineDashedMaterial:Gl,LineBasicMaterial:Js,Material:ei}),Vl={arraySlice:function(t,e,n){return Vl.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),r=0;r!==e;++r)n[r]=r;return n.sort((function(e,n){return t[e]-t[n]})),n},sortedArray:function(t,e,n){for(var r=t.length,i=new t.constructor(r),a=0,o=0;o!==r;++a)for(var s=n[a]*e,c=0;c!==e;++c)i[o++]=t[s+c];return i},flattenJSON:function(t,e,n,r){for(var i=1,a=t[0];void 0!==a&&void 0===a[r];)a=t[i++];if(void 0!==a){var o=a[r];if(void 0!==o)if(Array.isArray(o))do{void 0!==(o=a[r])&&(e.push(a.time),n.push.apply(n,o)),a=t[i++]}while(void 0!==a);else if(void 0!==o.toArray)do{void 0!==(o=a[r])&&(e.push(a.time),o.toArray(n,n.length)),a=t[i++]}while(void 0!==a);else do{void 0!==(o=a[r])&&(e.push(a.time),n.push(o)),a=t[i++]}while(void 0!==a)}},subclip:function(t,e,n,r,i){i=i||30;var a=t.clone();a.name=e;for(var o=[],s=0;s=r)){u.push(c.times[d]);for(var f=0;fa.tracks[s].times[0]&&(m=a.tracks[s].times[0]);for(s=0;s=i)break t;var s=e[1];t=(i=e[--n-1]))break e}a=n,n=0}for(;n>>1;te;)--a;if(++a,0!==i||a!==r){i>=a&&(i=(a=Math.max(a,1))-1);var o=this.getValueSize();this.times=Vl.arraySlice(n,i,a),this.values=Vl.arraySlice(this.values,i*o,a*o)}return this},validate:function(){var t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);var n=this.times,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);for(var a=null,o=0;o!==i;o++){var s=n[o];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,s),t=!1;break}if(null!==a&&a>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,s,a),t=!1;break}a=s}if(void 0!==r&&Vl.isTypedArray(r)){o=0;for(var c=r.length;o!==c;++o){var l=r[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}}return t},optimize:function(){for(var t=this.times,e=this.values,n=this.getValueSize(),r=this.getInterpolation()===Ee,i=1,a=t.length-1,o=1;o0){t[i]=t[a];for(f=a*n,m=i*n,d=0;d!==n;++d)e[m+d]=e[f+d];++i}return i!==t.length&&(this.times=Vl.arraySlice(t,0,i),this.values=Vl.arraySlice(e,0,i*n)),this},clone:function(){var t=Vl.arraySlice(this.times,0),e=Vl.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}),Yl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Yl,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:Me,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),Zl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Zl,ValueTypeName:"color"}),Jl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Jl,ValueTypeName:"number"}),Ql.prototype=Object.assign(Object.create(kl.prototype),{constructor:Ql,interpolate_:function(t,e,n,r){for(var i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=t*o,c=(n-e)/(r-e),l=s+o;s!==l;s+=4)wn.slerpFlat(i,0,a,s-o,a,s,c);return i}}),Kl.prototype=Object.assign(Object.create(Xl.prototype),{constructor:Kl,ValueTypeName:"quaternion",DefaultInterpolation:Se,InterpolantFactoryMethodLinear:function(t){return new Ql(this.times,this.values,this.getValueSize(),t)},InterpolantFactoryMethodSmooth:void 0}),$l.prototype=Object.assign(Object.create(Xl.prototype),{constructor:$l,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:Me,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0}),tu.prototype=Object.assign(Object.create(Xl.prototype),{constructor:tu,ValueTypeName:"vector"}),Object.assign(eu,{parse:function(t){for(var e=[],n=t.tracks,r=1/(t.fps||1),i=0,a=n.length;i!==a;++i)e.push(nu(n[i]).scale(r));return new eu(t.name,t.duration,e)},toJSON:function(t){for(var e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid},i=0,a=n.length;i!==a;++i)e.push(Xl.toJSON(n[i]));return r},CreateFromMorphTargetSequence:function(t,e,n,r){for(var i=e.length,a=[],o=0;o1){var l=r[h=c[1]];l||(r[h]=l=[]),l.push(s)}}var u=[];for(var h in r)u.push(eu.CreateFromMorphTargetSequence(h,r[h],e,n));return u},parseAnimation:function(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var n=function(t,e,n,r,i){if(0!==n.length){var a=[],o=[];Vl.flattenJSON(n,a,o,r),0!==a.length&&i.push(new t(e,a,o))}},r=[],i=t.name||"default",a=t.length||-1,o=t.fps||30,s=t.hierarchy||[],c=0;c0||0===t.search(/^data\:image\/jpeg/);i.format=r?kt:jt,i.needsUpdate=!0,void 0!==e&&e(i)}),n,r),i}}),Object.assign(mu.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,e){var n=this.getUtoTmapping(t);return this.getPoint(n,e)},getPoints:function(t){void 0===t&&(t=5);for(var e=[],n=0;n<=t;n++)e.push(this.getPoint(n/t));return e},getSpacedPoints:function(t){void 0===t&&(t=5);for(var e=[],n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,n,r=[],i=this.getPoint(0),a=0;for(r.push(0),n=1;n<=t;n++)a+=(e=this.getPoint(n/t)).distanceTo(i),r.push(a),i=e;return this.cacheArcLengths=r,r},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,e){var n,r=this.getLengths(),i=0,a=r.length;n=e||t*r[a-1];for(var o,s=0,c=a-1;s<=c;)if((o=r[i=Math.floor(s+(c-s)/2)]-n)<0)s=i+1;else{if(!(o>0)){c=i;break}c=i-1}if(r[i=c]===n)return i/(a-1);var l=r[i];return(i+(n-l)/(r[i+1]-l))/(a-1)},getTangent:function(t){var e=t-1e-4,n=t+1e-4;e<0&&(e=0),n>1&&(n=1);var r=this.getPoint(e);return this.getPoint(n).clone().sub(r).normalize()},getTangentAt:function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},computeFrenetFrames:function(t,e){var n,r,i,a=new Sn,o=[],s=[],c=[],l=new Sn,u=new Hn;for(n=0;n<=t;n++)r=n/t,o[n]=this.getTangentAt(r),o[n].normalize();s[0]=new Sn,c[0]=new Sn;var h=Number.MAX_VALUE,d=Math.abs(o[0].x),p=Math.abs(o[0].y),f=Math.abs(o[0].z);for(d<=h&&(h=d,a.set(1,0,0)),p<=h&&(h=p,a.set(0,1,0)),f<=h&&a.set(0,0,1),l.crossVectors(o[0],a).normalize(),s[0].crossVectors(o[0],l),c[0].crossVectors(o[0],s[0]),n=1;n<=t;n++)s[n]=s[n-1].clone(),c[n]=c[n-1].clone(),l.crossVectors(o[n-1],o[n]),l.length()>Number.EPSILON&&(l.normalize(),i=Math.acos(xn.clamp(o[n-1].dot(o[n]),-1,1)),s[n].applyMatrix4(u.makeRotationAxis(l,i))),c[n].crossVectors(o[n],s[n]);if(!0===e)for(i=Math.acos(xn.clamp(s[0].dot(s[t]),-1,1)),i/=t,o[0].dot(l.crossVectors(s[0],s[t]))>0&&(i=-i),n=1;n<=t;n++)s[n].applyMatrix4(u.makeRotationAxis(o[n],i*n)),c[n].crossVectors(o[n],s[n]);return{tangents:o,normals:s,binormals:c}},clone:function(){return(new this.constructor).copy(this)},copy:function(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}}),vu.prototype=Object.create(mu.prototype),vu.prototype.constructor=vu,vu.prototype.isEllipseCurve=!0,vu.prototype.getPoint=function(t,e){for(var n=e||new bn,r=2*Math.PI,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)r;)i-=r;i0?0:(Math.floor(Math.abs(u)/c)+1)*c:0===h&&u===c-1&&(u=c-2,h=1),this.closed||u>0?n=s[(u-1)%c]:(xu.subVectors(s[0],s[1]).add(s[0]),n=xu),r=s[u%c],i=s[(u+1)%c],this.closed||u+2r.length-2?r.length-1:a+1],u=r[a>r.length-3?r.length-1:a+2];return n.set(Su(o,s.x,c.x,l.x,u.x),Su(o,s.y,c.y,l.y,u.y)),n},Du.prototype.copy=function(t){mu.prototype.copy.call(this,t),this.points=[];for(var e=0,n=t.points.length;e=e){var i=n[r]-e,a=this.curves[r],o=a.getLength(),s=0===o?0:1-i/o;return a.getPointAt(s)}r++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],e=0,n=0,r=this.curves.length;n1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n},copy:function(t){mu.prototype.copy.call(this,t),this.curves=[];for(var e=0,n=t.curves.length;e0){var l=c.getPoint(0);l.equals(this.currentPoint)||this.lineTo(l.x,l.y)}this.curves.push(c);var u=c.getPoint(1);return this.currentPoint.copy(u),this},copy:function(t){return Nu.prototype.copy.call(this,t),this.currentPoint.copy(t.currentPoint),this},toJSON:function(){var t=Nu.prototype.toJSON.call(this);return t.currentPoint=this.currentPoint.toArray(),t},fromJSON:function(t){return Nu.prototype.fromJSON.call(this,t),this.currentPoint.fromArray(t.currentPoint),this}}),Fu.prototype=Object.assign(Object.create(Bu.prototype),{constructor:Fu,getPointsHoles:function(t){for(var e=[],n=0,r=this.holes.length;n0){var a=new du(new iu(e));a.setCrossOrigin(this.crossOrigin);for(var o=0,s=t.length;o0?new js(o,s):new Gi(o,s);break;case"InstancedMesh":o=i(t.geometry),s=a(t.material);var c=t.count,l=t.instanceMatrix;(r=new Zs(o,s,c)).instanceMatrix=new ri(new Float32Array(l.array),16);break;case"LOD":r=new ks;break;case"Line":r=new nc(i(t.geometry),a(t.material),t.mode);break;case"LineLoop":r=new oc(i(t.geometry),a(t.material));break;case"LineSegments":r=new ac(i(t.geometry),a(t.material));break;case"PointCloud":case"Points":r=new dc(i(t.geometry),a(t.material));break;case"Sprite":r=new Us(a(t.material));break;case"Group":r=new ps;break;default:r=new ar}if(r.uuid=t.uuid,void 0!==t.name&&(r.name=t.name),void 0!==t.matrix?(r.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(r.matrixAutoUpdate=t.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==t.position&&r.position.fromArray(t.position),void 0!==t.rotation&&r.rotation.fromArray(t.rotation),void 0!==t.quaternion&&r.quaternion.fromArray(t.quaternion),void 0!==t.scale&&r.scale.fromArray(t.scale)),void 0!==t.castShadow&&(r.castShadow=t.castShadow),void 0!==t.receiveShadow&&(r.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.bias&&(r.shadow.bias=t.shadow.bias),void 0!==t.shadow.radius&&(r.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&r.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(r.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.frustumCulled&&(r.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(r.renderOrder=t.renderOrder),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.layers&&(r.layers.mask=t.layers),void 0!==t.drawMode&&r.setDrawMode(t.drawMode),void 0!==t.children)for(var u=t.children,h=0;hNumber.EPSILON){if(l<0&&(o=e[a],c=-c,s=e[i],l=-l),t.ys.y)continue;if(t.y===o.y){if(t.x===o.x)return!0}else{var u=l*(t.x-o.x)-c*(t.y-o.y);if(0===u)return!0;if(u<0)continue;r=!r}}else{if(t.y!==o.y)continue;if(s.x<=t.x&&t.x<=o.x||o.x<=t.x&&t.x<=s.x)return!0}}return r}var i=al.isClockWise,a=this.subPaths;if(0===a.length)return[];if(!0===e)return n(a);var o,s,c,l=[];if(1===a.length)return s=a[0],(c=new Fu).curves=s.curves,l.push(c),l;var u=!i(a[0].getPoints());u=t?!u:u;var h,d,p=[],f=[],m=[],v=0;f[v]=void 0,m[v]=[];for(var g=0,y=a.length;g1){for(var x=!1,b=[],w=0,_=f.length;w<_;w++)p[w]=[];for(w=0,_=f.length;w<_;w++)for(var M=m[w],S=0;S0&&(x||(m=p))}g=0;for(var L=f.length;g0){this.source.connect(this.filters[0]);for(var t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(var t=1,e=this.filters.length;t=.5)for(var a=0;a!==i;++a)t[e+a]=t[n+a]},_slerp:function(t,e,n,r){wn.slerpFlat(t,e,t,e,t,n,r)},_lerp:function(t,e,n,r,i){for(var a=1-r,o=0;o!==i;++o){var s=e+o;t[s]=t[s]*a+t[n+o]*r}}});var Nh=new RegExp("[\\[\\]\\.:\\/]","g"),Bh="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",Fh=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]"),zh=/(WCOD+)?/.source.replace("WCOD",Bh),Uh=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Gh=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Hh=new RegExp("^"+Fh+zh+Uh+Gh+"$"),Vh=["material","materials","bones"];function kh(t,e,n){var r=n||jh.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,r)}function jh(t,e,n){this.path=e,this.parsedPath=n||jh.parseTrackName(e),this.node=jh.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t}function Wh(){this.uuid=xn.generateUUID(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var t={};this._indicesByUUID=t;for(var e=0,n=arguments.length;e!==n;++e)t[arguments[e].uuid]=e;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};var r=this;this.stats={objects:{get total(){return r._objects.length},get inUse(){return this.total-r.nCachedObjects_}},get bindingsPerObject(){return r._bindings.length}}}function qh(t,e,n){this._mixer=t,this._clip=e,this._localRoot=n||null;for(var r=e.tracks,i=r.length,a=new Array(i),o={endingStart:Ae,endingEnd:Ae},s=0;s!==i;++s){var c=r[s].createInterpolant(null);a[s]=c,c.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=new Array(i),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=we,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 Xh(t){this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}function Yh(t){"string"==typeof t&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),t=arguments[1]),this.value=t}function Zh(t,e,n){Ss.call(this,t,e),this.meshPerAttribute=n||1}function Jh(t,e,n,r){this.ray=new Pr(t,e),this.near=n||0,this.far=r||1/0,this.camera=null,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 Qh(t,e){return t.distance-e.distance}function Kh(t,e,n,r){if(!1!==t.visible&&(t.raycast(e,n),!0===r))for(var i=t.children,a=0,o=i.length;a=e){var u=e++,h=t[u];n[h.uuid]=l,t[l]=h,n[c]=u,t[u]=s;for(var d=0,p=i;d!==p;++d){var f=r[d],m=f[u],v=f[l];f[l]=m,f[u]=v}}}this.nCachedObjects_=e},uncache:function(){for(var t=this._objects,e=t.length,n=this.nCachedObjects_,r=this._indicesByUUID,i=this._bindings,a=i.length,o=0,s=arguments.length;o!==s;++o){var c=arguments[o],l=c.uuid,u=r[l];if(void 0!==u)if(delete r[l],u0)for(var c=this._interpolants,l=this._propertyBindings,u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulate(r,s)}else this._updateWeight(t)},_updateWeight:function(t){var e=0;if(this.enabled){e=this.weight;var n=this._weightInterpolant;if(null!==n){var r=n.evaluate(t)[0];e*=r,t>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=e,e},_updateTimeScale:function(t){var e=0;if(!this.paused){e=this.timeScale;var n=this._timeScaleInterpolant;if(null!==n)e*=n.evaluate(t)[0],t>n.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e)}return this._effectiveTimeScale=e,e},_updateTime:function(t){var e=this.time+t,n=this._clip.duration,r=this.loop,i=this._loopCount,a=r===_e;if(0===t)return-1===i?e:a&&1==(1&i)?n-e:e;if(r===be){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(e>=n)e=n;else{if(!(e<0)){this.time=e;break t}e=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=e,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===i&&(t>=0?(i=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),e>=n||e<0){var o=Math.floor(e/n);e-=n*o,i+=Math.abs(o);var s=this.repetitions-i;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,e=t>0?n:0,this.time=e,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===s){var c=t<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=e;if(a&&1==(1&i))return n-e}return e},_setEndings:function(t,e,n){var r=this._interpolantSettings;n?(r.endingStart=Te,r.endingEnd=Te):(r.endingStart=t?this.zeroSlopeAtStart?Te:Ae:Le,r.endingEnd=e?this.zeroSlopeAtEnd?Te:Ae:Le)},_scheduleFading:function(t,e,n){var r=this._mixer,i=r.time,a=this._weightInterpolant;null===a&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=e,o[1]=i+t,s[1]=n,this}}),Xh.prototype=Object.assign(Object.create(vn.prototype),{constructor:Xh,_bindAction:function(t,e){var n=t._localRoot||this._root,r=t._clip.tracks,i=r.length,a=t._propertyBindings,o=t._interpolants,s=n.uuid,c=this._bindingsByRootAndName,l=c[s];void 0===l&&(l={},c[s]=l);for(var u=0;u!==i;++u){var h=r[u],d=h.name,p=l[d];if(void 0!==p)a[u]=p;else{if(void 0!==(p=a[u])){null===p._cacheIndex&&(++p.referenceCount,this._addInactiveBinding(p,s,d));continue}var f=e&&e._propertyBindings[u].binding.parsedPath;++(p=new Ih(jh.create(n,d,f),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(p,s,d),a[u]=p}o[u].resultBuffer=p.buffer}},_activateAction:function(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){var e=(t._localRoot||this._root).uuid,n=t._clip.uuid,r=this._actionsByClip[n];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,n,e)}for(var i=t._propertyBindings,a=0,o=i.length;a!==o;++a){var s=i[a];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}},_deactivateAction:function(t){if(this._isActiveAction(t)){for(var e=t._propertyBindings,n=0,r=e.length;n!==r;++n){var i=e[n];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}},_initMemoryManager:function(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}},_isActiveAction:function(t){var e=t._cacheIndex;return null!==e&&ethis.max.x||t.ythis.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .getParameter() target is now required"),e=new bn),e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)},clampPoint:function(t,e){return void 0===e&&(console.warn("THREE.Box2: .clampPoint() target is now required"),e=new bn),e.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return ed.copy(t).clamp(this.min,this.max).sub(t).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)}});var rd=new Sn,id=new Sn;function ad(t,e){this.start=void 0!==t?t:new Sn,this.end=void 0!==e?e:new Sn}function od(t){ar.call(this),this.material=t,this.render=function(){}}Object.assign(ad.prototype,{set:function(t,e){return this.start.copy(t),this.end.copy(e),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},getCenter:function(t){return void 0===t&&(console.warn("THREE.Line3: .getCenter() target is now required"),t=new Sn),t.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return void 0===t&&(console.warn("THREE.Line3: .delta() target is now required"),t=new Sn),t.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){return void 0===e&&(console.warn("THREE.Line3: .at() target is now required"),e=new Sn),this.delta(e).multiplyScalar(t).add(this.start)},closestPointToPointParameter:function(t,e){rd.subVectors(t,this.start),id.subVectors(this.end,this.start);var n=id.dot(id),r=id.dot(rd)/n;return e&&(r=xn.clamp(r,0,1)),r},closestPointToPoint:function(t,e,n){var r=this.closestPointToPointParameter(t,e);return void 0===n&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),n=new Sn),this.delta(n).multiplyScalar(r).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)}}),od.prototype=Object.create(ar.prototype),od.prototype.constructor=od,od.prototype.isImmediateRenderObject=!0;var sd=new Sn,cd=new Sn,ld=new Tn,ud=["a","b","c"];function hd(t,e,n,r){this.object=t,this.size=void 0!==e?e:1;var i=void 0!==n?n:16711680,a=void 0!==r?r:1,o=0,s=this.object.geometry;s&&s.isGeometry?o=3*s.faces.length:s&&s.isBufferGeometry&&(o=s.attributes.normal.count);var c=new _i,l=new hi(2*o*3,3);c.setAttribute("position",l),ac.call(this,c,new Js({color:i,linewidth:a})),this.matrixAutoUpdate=!1,this.update()}hd.prototype=Object.create(ac.prototype),hd.prototype.constructor=hd,hd.prototype.update=function(){this.object.updateMatrixWorld(!0),ld.getNormalMatrix(this.object.matrixWorld);var t=this.object.matrixWorld,e=this.geometry.attributes.position,n=this.object.geometry;if(n&&n.isGeometry)for(var r=n.vertices,i=n.faces,a=0,o=0,s=i.length;o1&&t.multiplyScalar(1/e),this.children[0].material.color.copy(this.material.color)}},xd.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()};var bd=new Sn,wd=new Zr,_d=new Zr;function Md(t,e,n){ar.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;var r=new Ac(e);r.rotateY(.5*Math.PI),this.material=new ni({wireframe:!0,fog:!1}),void 0===this.color&&(this.material.vertexColors=M);var i=r.getAttribute("position"),a=new Float32Array(3*i.count);r.setAttribute("color",new ri(a,3)),this.add(new Gi(r,this.material)),this.update()}function Sd(t,e){this.lightProbe=t,this.size=e;var n={GAMMA_OUTPUT:""},r=new ea({defines:n,uniforms:{sh:{value:this.lightProbe.sh.coefficients},intensity:{value:this.lightProbe.intensity}},vertexShader:["varying vec3 vNormal;","void main() {","\tvNormal = normalize( normalMatrix * normal );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#define RECIPROCAL_PI 0.318309886","vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {","\t// matrix is assumed to be orthogonal","\treturn normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );","}","vec3 linearToOutput( in vec3 a ) {","\t#ifdef GAMMA_OUTPUT","\t\treturn pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );","\t#else","\t\treturn a;","\t#endif","}","// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf","vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {","\t// normal is assumed to have unit length","\tfloat x = normal.x, y = normal.y, z = normal.z;","\t// band 0","\tvec3 result = shCoefficients[ 0 ] * 0.886227;","\t// band 1","\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;","\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;","\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;","\t// band 2","\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;","\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;","\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );","\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;","\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );","\treturn result;","}","uniform vec3 sh[ 9 ]; // sh coefficients","uniform float intensity; // light probe intensity","varying vec3 vNormal;","void main() {","\tvec3 normal = normalize( vNormal );","\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );","\tvec3 irradiance = shGetIrradianceAt( worldNormal, sh );","\tvec3 outgoingLight = RECIPROCAL_PI * irradiance * intensity;","\toutgoingLight = linearToOutput( outgoingLight );","\tgl_FragColor = vec4( outgoingLight, 1.0 );","}"].join("\n")}),i=new ml(1,32,16);Gi.call(this,i,r),this.onBeforeRender()}function Ed(t,e,n,r){t=t||10,e=e||10,n=new Zr(void 0!==n?n:4473924),r=new Zr(void 0!==r?r:8947848);for(var i=e/2,a=t/e,o=t/2,s=[],c=[],l=0,u=0,h=-o;l<=e;l++,h+=a){s.push(-o,0,h,o,0,h),s.push(h,0,-o,h,0,o);var d=l===i?n:r;d.toArray(c,u),u+=3,d.toArray(c,u),u+=3,d.toArray(c,u),u+=3,d.toArray(c,u),u+=3}var p=new _i;p.setAttribute("position",new hi(s,3)),p.setAttribute("color",new hi(c,3));var f=new Js({vertexColors:M});ac.call(this,p,f)}function Ad(t,e,n,r,i,a){t=t||10,e=e||16,n=n||8,r=r||64,i=new Zr(void 0!==i?i:4473924),a=new Zr(void 0!==a?a:8947848);var o,s,c,l,u,h,d,p=[],f=[];for(l=0;l<=e;l++)c=l/e*(2*Math.PI),o=Math.sin(c)*t,s=Math.cos(c)*t,p.push(0,0,0),p.push(o,0,s),d=1&l?i:a,f.push(d.r,d.g,d.b),f.push(d.r,d.g,d.b);for(l=0;l<=n;l++)for(d=1&l?i:a,h=t-t/n*l,u=0;u.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{qd.set(t.z,0,-t.x).normalize();var e=Math.acos(t.y);this.quaternion.setFromAxisAngle(qd,e)}},Xd.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(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()},Xd.prototype.setColor=function(t){this.line.material.color.set(t),this.cone.material.color.set(t)},Xd.prototype.copy=function(t){return ar.prototype.copy.call(this,t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this},Xd.prototype.clone=function(){return(new this.constructor).copy(this)},Yd.prototype=Object.create(ac.prototype),Yd.prototype.constructor=Yd;var Jd=0,Qd=1;function Kd(t){return console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead."),t}function $d(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 tp(t,e){return console.warn("THREE.PointCloud has been renamed to THREE.Points."),new dc(t,e)}function ep(t){return console.warn("THREE.Particle has been renamed to THREE.Sprite."),new Us(t)}function np(t,e){return console.warn("THREE.ParticleSystem has been renamed to THREE.Points."),new dc(t,e)}function rp(t){return console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial."),new sc(t)}function ip(t){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial."),new sc(t)}function ap(t){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial."),new sc(t)}function op(t,e,n){return console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead."),new Sn(t,e,n)}function sp(t,e){return console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead."),new ri(t,e).setDynamic(!0)}function cp(t,e){return console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead."),new ii(t,e)}function lp(t,e){return console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead."),new ai(t,e)}function up(t,e){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead."),new oi(t,e)}function hp(t,e){return console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead."),new si(t,e)}function dp(t,e){return console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead."),new ci(t,e)}function pp(t,e){return console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead."),new li(t,e)}function fp(t,e){return console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead."),new ui(t,e)}function mp(t,e){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new hi(t,e)}function vp(t,e){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new di(t,e)}function gp(t){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Mu.call(this,t),this.type="catmullrom",this.closed=!0}function yp(t){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead."),Mu.call(this,t),this.type="catmullrom"}function xp(t){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead."),Mu.call(this,t),this.type="catmullrom"}function bp(t){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new Yd(t)}function wp(t,e){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Hd(t,e)}function _p(t,e){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new ac(new Ml(t.geometry),new Js({color:void 0!==e?e:16777215}))}function Mp(t,e){return console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead."),new ac(new yc(t.geometry),new Js({color:void 0!==e?e:16777215}))}function Sp(t){return console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader."),new cu(t)}function Ep(t){return console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader."),new hu(t)}mu.create=function(t,e){return console.log("THREE.Curve.create() has been deprecated"),t.prototype=Object.create(mu.prototype),t.prototype.constructor=t,t.prototype.getPoint=e,t},Object.assign(Nu.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 Xi,n=0,r=t.length;n0&&i[i.length-1])&&(6===a[0]||2===a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]e.TEXTURE31){console.error("TEXTURE_BINDING_2D or TEXTURE_BINDING_CUBE_MAP must be followed by a valid texture unit"),r.push(null,null);break}i||(i=e.getParameter(e.ACTIVE_TEXTURE)),e.activeTexture(c),r.push(e.getParameter(o),null);break;case e.ACTIVE_TEXTURE:i=e.getParameter(e.ACTIVE_TEXTURE),r.push(null);break;default:r.push(e.getParameter(o))}for(n(e),a=0;ae.TEXTURE31)break;e.activeTexture(c),e.bindTexture(e.TEXTURE_2D,s);break;case e.TEXTURE_BINDING_CUBE_MAP:var c;if((c=t[++a])e.TEXTURE31)break;e.activeTexture(c),e.bindTexture(e.TEXTURE_CUBE_MAP,s);break;case e.VIEWPORT:e.viewport(s[0],s[1],s[2],s[3]);break;case e.BLEND:case e.CULL_FACE:case e.DEPTH_TEST:case e.SCISSOR_TEST:case e.STENCIL_TEST:s?e.enable(o):e.disable(o);break;default:console.log("No GL restore behavior for 0x"+o.toString(16))}i&&e.activeTexture(i)}}else n(e)},L=["attribute vec2 position;","attribute vec3 texCoord;","varying vec2 vTexCoord;","uniform vec4 viewportOffsetScale[2];","void main() {"," vec4 viewport = viewportOffsetScale[int(texCoord.z)];"," vTexCoord = (texCoord.xy * viewport.zw) + viewport.xy;"," gl_Position = vec4( position, 1.0, 1.0 );","}"].join("\n"),R=["precision mediump float;","uniform sampler2D diffuse;","varying vec2 vTexCoord;","void main() {"," gl_FragColor = texture2D(diffuse, vTexCoord);","}"].join("\n");function C(e,t,n,r){this.gl=e,this.cardboardUI=t,this.bufferScale=n,this.dirtySubmitFrameBindings=r,this.ctxAttribs=e.getContextAttributes(),this.meshWidth=20,this.meshHeight=20,this.bufferWidth=e.drawingBufferWidth,this.bufferHeight=e.drawingBufferHeight,this.realBindFramebuffer=e.bindFramebuffer,this.realEnable=e.enable,this.realDisable=e.disable,this.realColorMask=e.colorMask,this.realClearColor=e.clearColor,this.realViewport=e.viewport,c()||(this.realCanvasWidth=Object.getOwnPropertyDescriptor(e.canvas.__proto__,"width"),this.realCanvasHeight=Object.getOwnPropertyDescriptor(e.canvas.__proto__,"height")),this.isPatched=!1,this.lastBoundFramebuffer=null,this.cullFace=!1,this.depthTest=!1,this.blend=!1,this.scissorTest=!1,this.stencilTest=!1,this.viewport=[0,0,0,0],this.colorMask=[!0,!0,!0,!0],this.clearColor=[0,0,0,0],this.attribs={position:0,texCoord:1},this.program=y(e,L,R,this.attribs),this.uniforms=A(e,this.program),this.viewportOffsetScale=new Float32Array(8),this.setTextureBounds(),this.vertexBuffer=e.createBuffer(),this.indexBuffer=e.createBuffer(),this.indexCount=0,this.renderTarget=e.createTexture(),this.framebuffer=e.createFramebuffer(),this.depthStencilBuffer=null,this.depthBuffer=null,this.stencilBuffer=null,this.ctxAttribs.depth&&this.ctxAttribs.stencil?this.depthStencilBuffer=e.createRenderbuffer():this.ctxAttribs.depth?this.depthBuffer=e.createRenderbuffer():this.ctxAttribs.stencil&&(this.stencilBuffer=e.createRenderbuffer()),this.patch(),this.onResize()}C.prototype.destroy=function(){var e=this.gl;this.unpatch(),e.deleteProgram(this.program),e.deleteBuffer(this.vertexBuffer),e.deleteBuffer(this.indexBuffer),e.deleteTexture(this.renderTarget),e.deleteFramebuffer(this.framebuffer),this.depthStencilBuffer&&e.deleteRenderbuffer(this.depthStencilBuffer),this.depthBuffer&&e.deleteRenderbuffer(this.depthBuffer),this.stencilBuffer&&e.deleteRenderbuffer(this.stencilBuffer),this.cardboardUI&&this.cardboardUI.destroy()},C.prototype.onResize=function(){var e=this.gl,t=this,n=[e.RENDERBUFFER_BINDING,e.TEXTURE_BINDING_2D,e.TEXTURE0];T(e,n,(function(e){t.realBindFramebuffer.call(e,e.FRAMEBUFFER,null),t.scissorTest&&t.realDisable.call(e,e.SCISSOR_TEST),t.realColorMask.call(e,!0,!0,!0,!0),t.realViewport.call(e,0,0,e.drawingBufferWidth,e.drawingBufferHeight),t.realClearColor.call(e,0,0,0,1),e.clear(e.COLOR_BUFFER_BIT),t.realBindFramebuffer.call(e,e.FRAMEBUFFER,t.framebuffer),e.bindTexture(e.TEXTURE_2D,t.renderTarget),e.texImage2D(e.TEXTURE_2D,0,t.ctxAttribs.alpha?e.RGBA:e.RGB,t.bufferWidth,t.bufferHeight,0,t.ctxAttribs.alpha?e.RGBA:e.RGB,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t.renderTarget,0),t.ctxAttribs.depth&&t.ctxAttribs.stencil?(e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilBuffer),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,t.bufferWidth,t.bufferHeight),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t.depthStencilBuffer)):t.ctxAttribs.depth?(e.bindRenderbuffer(e.RENDERBUFFER,t.depthBuffer),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,t.bufferWidth,t.bufferHeight),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t.depthBuffer)):t.ctxAttribs.stencil&&(e.bindRenderbuffer(e.RENDERBUFFER,t.stencilBuffer),e.renderbufferStorage(e.RENDERBUFFER,e.STENCIL_INDEX8,t.bufferWidth,t.bufferHeight),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.STENCIL_ATTACHMENT,e.RENDERBUFFER,t.stencilBuffer)),!e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer incomplete!"),t.realBindFramebuffer.call(e,e.FRAMEBUFFER,t.lastBoundFramebuffer),t.scissorTest&&t.realEnable.call(e,e.SCISSOR_TEST),t.realColorMask.apply(e,t.colorMask),t.realViewport.apply(e,t.viewport),t.realClearColor.apply(e,t.clearColor)})),this.cardboardUI&&this.cardboardUI.onResize()},C.prototype.patch=function(){if(!this.isPatched){var e=this,t=this.gl.canvas,n=this.gl;c()||(t.width=m()*this.bufferScale,t.height=v()*this.bufferScale,Object.defineProperty(t,"width",{configurable:!0,enumerable:!0,get:function(){return e.bufferWidth},set:function(n){e.bufferWidth=n,e.realCanvasWidth.set.call(t,n),e.onResize()}}),Object.defineProperty(t,"height",{configurable:!0,enumerable:!0,get:function(){return e.bufferHeight},set:function(n){e.bufferHeight=n,e.realCanvasHeight.set.call(t,n),e.onResize()}})),this.lastBoundFramebuffer=n.getParameter(n.FRAMEBUFFER_BINDING),null==this.lastBoundFramebuffer&&(this.lastBoundFramebuffer=this.framebuffer,this.gl.bindFramebuffer(n.FRAMEBUFFER,this.framebuffer)),this.gl.bindFramebuffer=function(t,r){e.lastBoundFramebuffer=r||e.framebuffer,e.realBindFramebuffer.call(n,t,e.lastBoundFramebuffer)},this.cullFace=n.getParameter(n.CULL_FACE),this.depthTest=n.getParameter(n.DEPTH_TEST),this.blend=n.getParameter(n.BLEND),this.scissorTest=n.getParameter(n.SCISSOR_TEST),this.stencilTest=n.getParameter(n.STENCIL_TEST),n.enable=function(t){switch(t){case n.CULL_FACE:e.cullFace=!0;break;case n.DEPTH_TEST:e.depthTest=!0;break;case n.BLEND:e.blend=!0;break;case n.SCISSOR_TEST:e.scissorTest=!0;break;case n.STENCIL_TEST:e.stencilTest=!0}e.realEnable.call(n,t)},n.disable=function(t){switch(t){case n.CULL_FACE:e.cullFace=!1;break;case n.DEPTH_TEST:e.depthTest=!1;break;case n.BLEND:e.blend=!1;break;case n.SCISSOR_TEST:e.scissorTest=!1;break;case n.STENCIL_TEST:e.stencilTest=!1}e.realDisable.call(n,t)},this.colorMask=n.getParameter(n.COLOR_WRITEMASK),n.colorMask=function(t,r,i,a){e.colorMask[0]=t,e.colorMask[1]=r,e.colorMask[2]=i,e.colorMask[3]=a,e.realColorMask.call(n,t,r,i,a)},this.clearColor=n.getParameter(n.COLOR_CLEAR_VALUE),n.clearColor=function(t,r,i,a){e.clearColor[0]=t,e.clearColor[1]=r,e.clearColor[2]=i,e.clearColor[3]=a,e.realClearColor.call(n,t,r,i,a)},this.viewport=n.getParameter(n.VIEWPORT),n.viewport=function(t,r,i,a){e.viewport[0]=t,e.viewport[1]=r,e.viewport[2]=i,e.viewport[3]=a,e.realViewport.call(n,t,r,i,a)},this.isPatched=!0,w(t)}},C.prototype.unpatch=function(){if(this.isPatched){var e=this.gl,t=this.gl.canvas;c()||(Object.defineProperty(t,"width",this.realCanvasWidth),Object.defineProperty(t,"height",this.realCanvasHeight)),t.width=this.bufferWidth,t.height=this.bufferHeight,e.bindFramebuffer=this.realBindFramebuffer,e.enable=this.realEnable,e.disable=this.realDisable,e.colorMask=this.realColorMask,e.clearColor=this.realClearColor,e.viewport=this.realViewport,this.lastBoundFramebuffer==this.framebuffer&&e.bindFramebuffer(e.FRAMEBUFFER,null),this.isPatched=!1,setTimeout((function(){w(t)}),1)}},C.prototype.setTextureBounds=function(e,t){e||(e=[0,0,.5,1]),t||(t=[.5,0,.5,1]),this.viewportOffsetScale[0]=e[0],this.viewportOffsetScale[1]=e[1],this.viewportOffsetScale[2]=e[2],this.viewportOffsetScale[3]=e[3],this.viewportOffsetScale[4]=t[0],this.viewportOffsetScale[5]=t[1],this.viewportOffsetScale[6]=t[2],this.viewportOffsetScale[7]=t[3]},C.prototype.submitFrame=function(){var e=this.gl,t=this,n=[];if(this.dirtySubmitFrameBindings||n.push(e.CURRENT_PROGRAM,e.ARRAY_BUFFER_BINDING,e.ELEMENT_ARRAY_BUFFER_BINDING,e.TEXTURE_BINDING_2D,e.TEXTURE0),T(e,n,(function(e){t.realBindFramebuffer.call(e,e.FRAMEBUFFER,null),t.cullFace&&t.realDisable.call(e,e.CULL_FACE),t.depthTest&&t.realDisable.call(e,e.DEPTH_TEST),t.blend&&t.realDisable.call(e,e.BLEND),t.scissorTest&&t.realDisable.call(e,e.SCISSOR_TEST),t.stencilTest&&t.realDisable.call(e,e.STENCIL_TEST),t.realColorMask.call(e,!0,!0,!0,!0),t.realViewport.call(e,0,0,e.drawingBufferWidth,e.drawingBufferHeight),(t.ctxAttribs.alpha||c())&&(t.realClearColor.call(e,0,0,0,1),e.clear(e.COLOR_BUFFER_BIT)),e.useProgram(t.program),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.indexBuffer),e.bindBuffer(e.ARRAY_BUFFER,t.vertexBuffer),e.enableVertexAttribArray(t.attribs.position),e.enableVertexAttribArray(t.attribs.texCoord),e.vertexAttribPointer(t.attribs.position,2,e.FLOAT,!1,20,0),e.vertexAttribPointer(t.attribs.texCoord,3,e.FLOAT,!1,20,8),e.activeTexture(e.TEXTURE0),e.uniform1i(t.uniforms.diffuse,0),e.bindTexture(e.TEXTURE_2D,t.renderTarget),e.uniform4fv(t.uniforms.viewportOffsetScale,t.viewportOffsetScale),e.drawElements(e.TRIANGLES,t.indexCount,e.UNSIGNED_SHORT,0),t.cardboardUI&&t.cardboardUI.renderNoState(),t.realBindFramebuffer.call(t.gl,e.FRAMEBUFFER,t.framebuffer),t.ctxAttribs.preserveDrawingBuffer||(t.realClearColor.call(e,0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)),t.dirtySubmitFrameBindings||t.realBindFramebuffer.call(e,e.FRAMEBUFFER,t.lastBoundFramebuffer),t.cullFace&&t.realEnable.call(e,e.CULL_FACE),t.depthTest&&t.realEnable.call(e,e.DEPTH_TEST),t.blend&&t.realEnable.call(e,e.BLEND),t.scissorTest&&t.realEnable.call(e,e.SCISSOR_TEST),t.stencilTest&&t.realEnable.call(e,e.STENCIL_TEST),t.realColorMask.apply(e,t.colorMask),t.realViewport.apply(e,t.viewport),!t.ctxAttribs.alpha&&t.ctxAttribs.preserveDrawingBuffer||t.realClearColor.apply(e,t.clearColor)})),c()){var r=e.canvas;r.width==t.bufferWidth&&r.height==t.bufferHeight||(t.bufferWidth=r.width,t.bufferHeight=r.height,t.onResize())}},C.prototype.updateDeviceInfo=function(e){var t=this.gl,n=this,r=[t.ARRAY_BUFFER_BINDING,t.ELEMENT_ARRAY_BUFFER_BINDING];T(t,r,(function(t){var r=n.computeMeshVertices_(n.meshWidth,n.meshHeight,e);if(t.bindBuffer(t.ARRAY_BUFFER,n.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,r,t.STATIC_DRAW),!n.indexCount){var i=n.computeMeshIndices_(n.meshWidth,n.meshHeight);t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,i,t.STATIC_DRAW),n.indexCount=i.length}}))},C.prototype.computeMeshVertices_=function(e,t,n){for(var r=new Float32Array(2*e*t*5),i=n.getLeftEyeVisibleTanAngles(),a=n.getLeftEyeNoLensTanAngles(),o=n.getLeftEyeVisibleScreenRect(a),c=0,l=0;l<2;l++){for(var u=0;ui-42&&r.clientXn.clientHeight-42?e(r):r.clientX<42&&r.clientY<42&&t(r)},n.addEventListener("click",this.listener,!1)},N.prototype.onResize=function(){var e=this.gl,t=this,n=[e.ARRAY_BUFFER_BINDING];T(e,n,(function(e){var n=[],r=e.drawingBufferWidth/2,i=Math.max(screen.width,screen.height)*window.devicePixelRatio,a=e.drawingBufferWidth/i*window.devicePixelRatio,o=4*a/2,s=42*a,c=28*a/2,l=14*a;function u(e,t){var i=(90-e)*I,a=Math.cos(i),o=Math.sin(i);n.push(O*a*c+r,O*o*c+c),n.push(t*a*c+r,t*o*c+c)}n.push(r-o,s),n.push(r-o,e.drawingBufferHeight),n.push(r+o,s),n.push(r+o,e.drawingBufferHeight),t.gearOffset=n.length/2;for(var h=0;h<=6;h++){var d=60*h;u(d,1),u(d+12,1),u(d+20,.75),u(d+40,.75),u(d+48,1)}function p(t,r){n.push(l+t,e.drawingBufferHeight-l-r)}t.gearVertexCount=n.length/2-t.gearOffset,t.arrowOffset=n.length/2;var f=o/Math.sin(45*I);p(0,c),p(c,0),p(c+f,f),p(f,c+f),p(f,c-f),p(0,c),p(c,2*c),p(c+f,2*c-f),p(f,c-f),p(0,c),p(f,c-o),p(28*a,c-o),p(f,c+o),p(28*a,c+o),t.arrowVertexCount=n.length/2-t.arrowOffset,e.bindBuffer(e.ARRAY_BUFFER,t.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,new Float32Array(n),e.STATIC_DRAW)}))},N.prototype.render=function(){var e=this.gl,t=this,n=[e.CULL_FACE,e.DEPTH_TEST,e.BLEND,e.SCISSOR_TEST,e.STENCIL_TEST,e.COLOR_WRITEMASK,e.VIEWPORT,e.CURRENT_PROGRAM,e.ARRAY_BUFFER_BINDING];T(e,n,(function(e){e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.BLEND),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.colorMask(!0,!0,!0,!0),e.viewport(0,0,e.drawingBufferWidth,e.drawingBufferHeight),t.renderNoState()}))},N.prototype.renderNoState=function(){var e,t,n,r,i,a,o,s,c,l,u=this.gl;u.useProgram(this.program),u.bindBuffer(u.ARRAY_BUFFER,this.vertexBuffer),u.enableVertexAttribArray(this.attribs.position),u.vertexAttribPointer(this.attribs.position,2,u.FLOAT,!1,8,0),u.uniform4f(this.uniforms.color,1,1,1,1),e=this.projMat,t=0,n=u.drawingBufferWidth,r=0,i=u.drawingBufferHeight,s=1/(t-n),c=1/(r-i),l=1/((a=.1)-(o=1024)),e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*c,e[14]=(o+a)*l,e[15]=1,u.uniformMatrix4fv(this.uniforms.projectionMat,!1,this.projMat),u.drawArrays(u.TRIANGLE_STRIP,0,4),u.drawArrays(u.TRIANGLE_STRIP,this.gearOffset,this.gearVertexCount),u.drawArrays(u.TRIANGLE_STRIP,this.arrowOffset,this.arrowVertexCount)},B.prototype.distortInverse=function(e){for(var t=0,n=1,r=e-this.distort(t);Math.abs(n-t)>1e-4;){var i=e-this.distort(n),a=n-i*((n-t)/(i-r));t=n,n=a,r=i}return n},B.prototype.distort=function(e){for(var t=e*e,n=0,r=0;r=1)return this.w=a,this.x=n,this.y=r,this.z=i,this;var s=Math.acos(o),c=Math.sqrt(1-o*o);if(Math.abs(c)<.001)return this.w=.5*(a+this.w),this.x=.5*(n+this.x),this.y=.5*(r+this.y),this.z=.5*(i+this.z),this;var l=Math.sin((1-t)*s)/c,u=Math.sin(t*s)/c;return this.w=a*l+this.w*u,this.x=n*l+this.x*u,this.y=r*l+this.y*u,this.z=i*l+this.z*u,this},setFromUnitVectors:function(e,t){return void 0===z&&(z=new U),(H=e.dot(t)+1)<1e-6?(H=0,Math.abs(e.x)>Math.abs(e.z)?z.set(-e.y,e.x,0):z.set(0,-e.z,e.y)):z.crossVectors(e,t),this.x=z.x,this.y=z.y,this.z=z.z,this.w=H,this.normalize(),this}};var j=new k({widthMeters:.11,heightMeters:.062,bevelMeters:.004}),W=new k({widthMeters:.1038,heightMeters:.0584,bevelMeters:.004}),X={CardboardV1:new Q({id:"CardboardV1",label:"Cardboard I/O 2014",fov:40,interLensDistance:.06,baselineLensDistance:.035,screenLensDistance:.042,distortionCoefficients:[.441,.156],inverseCoefficients:[-.4410035,.42756155,-.4804439,.5460139,-.58821183,.5733938,-.48303202,.33299083,-.17573841,.0651772,-.01488963,.001559834]}),CardboardV2:new Q({id:"CardboardV2",label:"Cardboard I/O 2015",fov:60,interLensDistance:.064,baselineLensDistance:.035,screenLensDistance:.039,distortionCoefficients:[.34,.55],inverseCoefficients:[-.33836704,-.18162185,.862655,-1.2462051,1.0560602,-.58208317,.21609078,-.05444823,.009177956,-.0009904169,6183535e-11,-16981803e-13]})};function q(e,t){this.viewer=X.CardboardV2,this.updateDeviceParams(e),this.distortion=new B(this.viewer.distortionCoefficients);for(var n=0;n=200&&n.status<=299?(r.dpdb=JSON.parse(n.response),r.recalculateDeviceParams_()):console.error("Error loading online DPDB!")})),n.send()}}function J(e){this.xdpi=e.xdpi,this.ydpi=e.ydpi,this.bevelMm=e.bevelMm}function K(e,t){this.set(e,t)}function $(e,t){this.kFilter=e,this.isDebug=t,this.currentAccelMeasurement=new K,this.currentGyroMeasurement=new K,this.previousGyroMeasurement=new K,c()?this.filterQ=new V(-1,0,0,1):this.filterQ=new V(1,0,0,1),this.previousFilterQ=new V,this.previousFilterQ.copy(this.filterQ),this.accelQ=new V,this.isOrientationInitialized=!1,this.estimatedGravity=new U,this.measuredGravity=new U,this.gyroIntegralQ=new V}function ee(e,t){this.predictionTimeS=e,this.isDebug=t,this.previousQ=new V,this.previousTimestampS=null,this.deltaQ=new V,this.outQ=new V}function te(e,t,n,r){this.yawOnly=n,this.accelerometer=new U,this.gyroscope=new U,this.filter=new $(e,r),this.posePredictor=new ee(t,r),this.isFirefoxAndroid=u(),this.isIOS=c();var i=h();this.isDeviceMotionInRadians=!this.isIOS&&i&&i<66,this.isWithoutDeviceMotion=d(),this.filterToWorldQ=new V,c()?this.filterToWorldQ.setFromAxisAngle(new U(1,0,0),Math.PI/2):this.filterToWorldQ.setFromAxisAngle(new U(1,0,0),-Math.PI/2),this.inverseWorldToScreenQ=new V,this.worldToScreenQ=new V,this.originalPoseAdjustQ=new V,this.originalPoseAdjustQ.setFromAxisAngle(new U(0,0,1),-window.orientation*Math.PI/180),this.setScreenTransform_(),f()&&this.filterToWorldQ.multiply(this.inverseWorldToScreenQ),this.resetQ=new V,this.orientationOut_=new Float32Array(4),this.start()}Z.prototype.getDeviceParams=function(){return this.deviceParams},Z.prototype.recalculateDeviceParams_=function(){var e=this.calcDeviceParams_();e?(this.deviceParams=e,this.onDeviceParamsUpdated&&this.onDeviceParamsUpdated(this.deviceParams)):console.error("Failed to recalculate device parameters.")},Z.prototype.calcDeviceParams_=function(){var e=this.dpdb;if(!e)return console.error("DPDB not available."),null;if(1!=e.format)return console.error("DPDB has unexpected format version."),null;if(!e.devices||!e.devices.length)return console.error("DPDB does not have a devices section."),null;var t=navigator.userAgent||navigator.vendor||window.opera,n=m(),r=v();if(!e.devices)return console.error("DPDB has no devices section."),null;for(var i=0;i1||this.run_(),this.previousGyroMeasurement.copy(this.currentGyroMeasurement)},$.prototype.run_=function(){if(!this.isOrientationInitialized)return this.accelQ=this.accelToQuaternion_(this.currentAccelMeasurement.sample),this.previousFilterQ.copy(this.accelQ),void(this.isOrientationInitialized=!0);var e=this.currentGyroMeasurement.timestampS-this.previousGyroMeasurement.timestampS,t=this.gyroToQuaternionDelta_(this.currentGyroMeasurement.sample,e);this.gyroIntegralQ.multiply(t),this.filterQ.copy(this.previousFilterQ),this.filterQ.multiply(t);var n=new V;n.copy(this.filterQ),n.inverse(),this.estimatedGravity.set(0,0,-1),this.estimatedGravity.applyQuaternion(n),this.estimatedGravity.normalize(),this.measuredGravity.copy(this.currentAccelMeasurement.sample),this.measuredGravity.normalize();var r,i=new V;i.setFromUnitVectors(this.estimatedGravity,this.measuredGravity),i.inverse(),this.isDebug&&console.log("Delta: %d deg, G_est: (%s, %s, %s), G_meas: (%s, %s, %s)",G*((r=i).w>1?(console.warn("getQuaternionAngle: w > 1"),0):2*Math.acos(r.w)),this.estimatedGravity.x.toFixed(1),this.estimatedGravity.y.toFixed(1),this.estimatedGravity.z.toFixed(1),this.measuredGravity.x.toFixed(1),this.measuredGravity.y.toFixed(1),this.measuredGravity.z.toFixed(1));var a=new V;a.copy(this.filterQ),a.multiply(i),this.filterQ.slerp(a,1-this.kFilter),this.previousFilterQ.copy(this.filterQ)},$.prototype.getOrientation=function(){return this.filterQ},$.prototype.accelToQuaternion_=function(e){var t=new U;t.copy(e),t.normalize();var n=new V;return n.setFromUnitVectors(new U(0,0,-1),t),n.inverse(),n},$.prototype.gyroToQuaternionDelta_=function(e,t){var n=new V,r=new U;return r.copy(e),r.normalize(),n.setFromAxisAngle(r,e.length()*t),n},ee.prototype.getPrediction=function(e,t,n){if(!this.previousTimestampS)return this.previousQ.copy(e),this.previousTimestampS=n,e;var r=new U;r.copy(t),r.normalize();var i=t.length();if(i<20*F)return this.isDebug&&console.log("Moving slowly, at %s deg/s: no prediction",(G*i).toFixed(1)),this.outQ.copy(e),this.previousQ.copy(e),this.outQ;var a=i*this.predictionTimeS;return this.deltaQ.setFromAxisAngle(r,a),this.outQ.copy(this.previousQ),this.outQ.multiply(this.deltaQ),this.previousQ.copy(e),this.previousTimestampS=n,this.outQ},te.prototype.getPosition=function(){return null},te.prototype.getOrientation=function(){var e=void 0;if(this.isWithoutDeviceMotion&&this._deviceOrientationQ)return this.deviceOrientationFixQ=this.deviceOrientationFixQ||(n=(new V).setFromAxisAngle(new U(0,0,-1),0),r=new V,-90===window.orientation?r.setFromAxisAngle(new U(0,1,0),Math.PI/-2):r.setFromAxisAngle(new U(0,1,0),Math.PI/2),n.multiply(r)),this.deviceOrientationFilterToWorldQ=this.deviceOrientationFilterToWorldQ||((t=new V).setFromAxisAngle(new U(1,0,0),-Math.PI/2),t),e=this._deviceOrientationQ,(i=new V).copy(e),i.multiply(this.deviceOrientationFilterToWorldQ),i.multiply(this.resetQ),i.multiply(this.worldToScreenQ),i.multiplyQuaternions(this.deviceOrientationFixQ,i),this.yawOnly&&(i.x=0,i.z=0,i.normalize()),this.orientationOut_[0]=i.x,this.orientationOut_[1]=i.y,this.orientationOut_[2]=i.z,this.orientationOut_[3]=i.w,this.orientationOut_;var t,n,r,i,a=this.filter.getOrientation();return e=this.posePredictor.getPrediction(a,this.gyroscope,this.previousTimestampS),(i=new V).copy(this.filterToWorldQ),i.multiply(this.resetQ),i.multiply(e),i.multiply(this.worldToScreenQ),this.yawOnly&&(i.x=0,i.z=0,i.normalize()),this.orientationOut_[0]=i.x,this.orientationOut_[1]=i.y,this.orientationOut_[2]=i.z,this.orientationOut_[3]=i.w,this.orientationOut_},te.prototype.resetPose=function(){this.resetQ.copy(this.filter.getOrientation()),this.resetQ.x=0,this.resetQ.y=0,this.resetQ.z*=-1,this.resetQ.normalize(),f()&&this.resetQ.multiply(this.inverseWorldToScreenQ),this.resetQ.multiply(this.originalPoseAdjustQ)},te.prototype.onDeviceOrientation_=function(e){this._deviceOrientationQ=this._deviceOrientationQ||new V;var t=e.alpha,n=e.beta,r=e.gamma;t=(t||0)*Math.PI/180,n=(n||0)*Math.PI/180,r=(r||0)*Math.PI/180,this._deviceOrientationQ.setFromEulerYXZ(n,t,-r)},te.prototype.onDeviceMotion_=function(e){this.updateDeviceMotion_(e)},te.prototype.updateDeviceMotion_=function(e){var t=e.accelerationIncludingGravity,n=e.rotationRate,r=e.timeStamp/1e3,i=r-this.previousTimestampS;return i<0?(E("fusion-pose-sensor:invalid:non-monotonic","Invalid timestamps detected: non-monotonic timestamp from devicemotion"),void(this.previousTimestampS=r)):i<=.001||i>1?(E("fusion-pose-sensor:invalid:outside-threshold","Invalid timestamps detected: Timestamp from devicemotion outside expected range."),void(this.previousTimestampS=r)):(this.accelerometer.set(-t.x,-t.y,-t.z),p()?this.gyroscope.set(-n.beta,n.alpha,n.gamma):this.gyroscope.set(n.alpha,n.beta,n.gamma),this.isDeviceMotionInRadians||this.gyroscope.multiplyScalar(Math.PI/180),this.filter.addAccelMeasurement(this.accelerometer,r),this.filter.addGyroMeasurement(this.gyroscope,r),void(this.previousTimestampS=r))},te.prototype.onOrientationChange_=function(e){this.setScreenTransform_()},te.prototype.onMessage_=function(e){var t=e.data;t&&t.type&&"devicemotion"===t.type.toLowerCase()&&this.updateDeviceMotion_(t.deviceMotionEvent)},te.prototype.setScreenTransform_=function(){switch(this.worldToScreenQ.set(0,0,0,1),window.orientation){case 0:break;case 90:this.worldToScreenQ.setFromAxisAngle(new U(0,0,1),-Math.PI/2);break;case-90:this.worldToScreenQ.setFromAxisAngle(new U(0,0,1),Math.PI/2)}this.inverseWorldToScreenQ.copy(this.worldToScreenQ),this.inverseWorldToScreenQ.inverse()},te.prototype.start=function(){var e,t,n;this.onDeviceMotionCallback_=this.onDeviceMotion_.bind(this),this.onOrientationChangeCallback_=this.onOrientationChange_.bind(this),this.onMessageCallback_=this.onMessage_.bind(this),this.onDeviceOrientationCallback_=this.onDeviceOrientation_.bind(this),c()&&(e=window.self!==window.top,t=M(document.referrer),n=M(window.location.href),e&&t!==n)&&window.addEventListener("message",this.onMessageCallback_),window.addEventListener("orientationchange",this.onOrientationChangeCallback_),this.isWithoutDeviceMotion?window.addEventListener("deviceorientation",this.onDeviceOrientationCallback_):window.addEventListener("devicemotion",this.onDeviceMotionCallback_)},te.prototype.stop=function(){window.removeEventListener("devicemotion",this.onDeviceMotionCallback_),window.removeEventListener("deviceorientation",this.onDeviceOrientationCallback_),window.removeEventListener("orientationchange",this.onOrientationChangeCallback_),window.removeEventListener("message",this.onMessageCallback_)};var ne=new U(1,0,0),re=new U(0,0,1),ie=new V;ie.setFromAxisAngle(ne,-Math.PI/2),ie.multiply((new V).setFromAxisAngle(re,Math.PI/2));var ae=function(){function e(t){i(this,e),this.config=t,this.sensor=null,this.fusionSensor=null,this._out=new Float32Array(4),this.api=null,this.errors=[],this._sensorQ=new V,this._outQ=new V,this._onSensorRead=this._onSensorRead.bind(this),this._onSensorError=this._onSensorError.bind(this),this.init()}return a(e,[{key:"init",value:function(){var e=null;try{(e=new RelativeOrientationSensor({frequency:60,referenceFrame:"screen"})).addEventListener("error",this._onSensorError)}catch(e){this.errors.push(e),"SecurityError"===e.name?(console.error("Cannot construct sensors due to the Feature Policy"),console.warn('Attempting to fall back using "devicemotion"; however this will fail in the future without correct permissions.'),this.useDeviceMotion()):"ReferenceError"===e.name?this.useDeviceMotion():console.error(e)}e&&(this.api="sensor",this.sensor=e,this.sensor.addEventListener("reading",this._onSensorRead),this.sensor.start())}},{key:"useDeviceMotion",value:function(){this.api="devicemotion",this.fusionSensor=new te(this.config.K_FILTER,this.config.PREDICTION_TIME_S,this.config.YAW_ONLY,this.config.DEBUG),this.sensor&&(this.sensor.removeEventListener("reading",this._onSensorRead),this.sensor.removeEventListener("error",this._onSensorError),this.sensor=null)}},{key:"getOrientation",value:function(){if(this.fusionSensor)return this.fusionSensor.getOrientation();if(!this.sensor||!this.sensor.quaternion)return this._out[0]=this._out[1]=this._out[2]=0,this._out[3]=1,this._out;var e=this.sensor.quaternion;this._sensorQ.set(e[0],e[1],e[2],e[3]);var t=this._outQ;return t.copy(ie),t.multiply(this._sensorQ),this.config.YAW_ONLY&&(t.x=t.z=0,t.normalize()),this._out[0]=t.x,this._out[1]=t.y,this._out[2]=t.z,this._out[3]=t.w,this._out}},{key:"_onSensorError",value:function(e){this.errors.push(e.error),"NotAllowedError"===e.error.name?console.error("Permission to access sensor was denied"):"NotReadableError"===e.error.name?console.error("Sensor could not be read"):console.error(e.error),this.useDeviceMotion()}},{key:"_onSensorRead",value:function(){}}]),e}();function oe(){this.loadIcon_();var e=document.createElement("div");(a=e.style).position="fixed",a.top=0,a.right=0,a.bottom=0,a.left=0,a.backgroundColor="gray",a.fontFamily="sans-serif",a.zIndex=1e6;var t=document.createElement("img");t.src=this.icon,(a=t.style).marginLeft="25%",a.marginTop="25%",a.width="50%",e.appendChild(t);var n=document.createElement("div");(a=n.style).textAlign="center",a.fontSize="16px",a.lineHeight="24px",a.margin="24px 25%",a.width="50%",n.innerHTML="Place your phone into your Cardboard viewer.",e.appendChild(n);var r=document.createElement("div");(a=r.style).backgroundColor="#CFD8DC",a.position="fixed",a.bottom=0,a.width="100%",a.height="48px",a.padding="14px 24px",a.boxSizing="border-box",a.color="#656A6B",e.appendChild(r);var i=document.createElement("div");i.style.float="left",i.innerHTML="No Cardboard viewer?";var a,o=document.createElement("a");o.href="https://www.google.com/get/cardboard/get-cardboard/",o.innerHTML="get one",o.target="_blank",(a=o.style).float="right",a.fontWeight=600,a.textTransform="uppercase",a.borderLeft="1px solid gray",a.paddingLeft="24px",a.textDecoration="none",a.color="#656A6B",r.appendChild(i),r.appendChild(o),this.overlay=e,this.text=n,this.hide()}oe.prototype.show=function(e){e||this.overlay.parentElement?e&&(this.overlay.parentElement&&this.overlay.parentElement!=e&&this.overlay.parentElement.removeChild(this.overlay),e.appendChild(this.overlay)):document.body.appendChild(this.overlay),this.overlay.style.display="block";var t=this.overlay.querySelector("img").style;f()?(t.width="20%",t.marginLeft="40%",t.marginTop="3%"):(t.width="50%",t.marginLeft="25%",t.marginTop="25%")},oe.prototype.hide=function(){this.overlay.style.display="none"},oe.prototype.showTemporarily=function(e,t){this.show(t),this.timer=setTimeout(this.hide.bind(this),e)},oe.prototype.disableShowTemporarily=function(){clearTimeout(this.timer)},oe.prototype.update=function(){this.disableShowTemporarily(),!f()&&x()?this.show():this.hide()},oe.prototype.loadIcon_=function(){this.icon="data:image/svg+xml,"+encodeURIComponent("")};var se="CardboardV1",ce="WEBVR_CARDBOARD_VIEWER";function le(e){try{this.selectedKey=localStorage.getItem(ce)}catch(e){console.error("Failed to load viewer profile: %s",e)}this.selectedKey||(this.selectedKey=e||se),this.dialog=this.createDialog_(q.Viewers),this.root=null,this.onChangeCallbacks_=[]}le.prototype.show=function(e){this.root=e,e.appendChild(this.dialog),this.dialog.querySelector("#"+this.selectedKey).checked=!0,this.dialog.style.display="block"},le.prototype.hide=function(){this.root&&this.root.contains(this.dialog)&&this.root.removeChild(this.dialog),this.dialog.style.display="none"},le.prototype.getCurrentViewer=function(){return q.Viewers[this.selectedKey]},le.prototype.getSelectedKey_=function(){var e=this.dialog.querySelector("input[name=field]:checked");return e?e.id:null},le.prototype.onChange=function(e){this.onChangeCallbacks_.push(e)},le.prototype.fireOnChange_=function(e){for(var t=0;t.5&&(this.noSleepVideo.currentTime=Math.random())}.bind(this)))}return r(e,[{key:"enable",value:function(){a?(this.disable(),this.noSleepTimer=window.setInterval((function(){window.location.href="/",window.setTimeout(window.stop,0)}),15e3)):this.noSleepVideo.play()}},{key:"disable",value:function(){a?this.noSleepTimer&&(window.clearInterval(this.noSleepTimer),this.noSleepTimer=null):this.noSleepVideo.pause()}}]),e}();e.exports=o},function(e,t,n){e.exports="data:video/mp4;base64,AAAAIGZ0eXBtcDQyAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAACKBtZGF0AAAC8wYF///v3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE0MiByMjQ3OSBkZDc5YTYxIC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAxNCAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTEgcmVmPTEgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MToweDExMSBtZT1oZXggc3VibWU9MiBwc3k9MSBwc3lfcmQ9MS4wMDowLjAwIG1peGVkX3JlZj0wIG1lX3JhbmdlPTE2IGNocm9tYV9tZT0xIHRyZWxsaXM9MCA4eDhkY3Q9MCBjcW09MCBkZWFkem9uZT0yMSwxMSBmYXN0X3Bza2lwPTEgY2hyb21hX3FwX29mZnNldD0wIHRocmVhZHM9NiBsb29rYWhlYWRfdGhyZWFkcz0xIHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFjZWQ9MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYWluZWRfaW50cmE9MCBiZnJhbWVzPTMgYl9weXJhbWlkPTIgYl9hZGFwdD0xIGJfYmlhcz0wIGRpcmVjdD0xIHdlaWdodGI9MSBvcGVuX2dvcD0wIHdlaWdodHA9MSBrZXlpbnQ9MzAwIGtleWludF9taW49MzAgc2NlbmVjdXQ9NDAgaW50cmFfcmVmcmVzaD0wIHJjX2xvb2thaGVhZD0xMCByYz1jcmYgbWJ0cmVlPTEgY3JmPTIwLjAgcWNvbXA9MC42MCBxcG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IHZidl9tYXhyYXRlPTIwMDAwIHZidl9idWZzaXplPTI1MDAwIGNyZl9tYXg9MC4wIG5hbF9ocmQ9bm9uZSBmaWxsZXI9MCBpcF9yYXRpbz0xLjQwIGFxPTE6MS4wMACAAAAAOWWIhAA3//p+C7v8tDDSTjf97w55i3SbRPO4ZY+hkjD5hbkAkL3zpJ6h/LR1CAABzgB1kqqzUorlhQAAAAxBmiQYhn/+qZYADLgAAAAJQZ5CQhX/AAj5IQADQGgcIQADQGgcAAAACQGeYUQn/wALKCEAA0BoHAAAAAkBnmNEJ/8ACykhAANAaBwhAANAaBwAAAANQZpoNExDP/6plgAMuSEAA0BoHAAAAAtBnoZFESwr/wAI+SEAA0BoHCEAA0BoHAAAAAkBnqVEJ/8ACykhAANAaBwAAAAJAZ6nRCf/AAsoIQADQGgcIQADQGgcAAAADUGarDRMQz/+qZYADLghAANAaBwAAAALQZ7KRRUsK/8ACPkhAANAaBwAAAAJAZ7pRCf/AAsoIQADQGgcIQADQGgcAAAACQGe60Qn/wALKCEAA0BoHAAAAA1BmvA0TEM//qmWAAy5IQADQGgcIQADQGgcAAAAC0GfDkUVLCv/AAj5IQADQGgcAAAACQGfLUQn/wALKSEAA0BoHCEAA0BoHAAAAAkBny9EJ/8ACyghAANAaBwAAAANQZs0NExDP/6plgAMuCEAA0BoHAAAAAtBn1JFFSwr/wAI+SEAA0BoHCEAA0BoHAAAAAkBn3FEJ/8ACyghAANAaBwAAAAJAZ9zRCf/AAsoIQADQGgcIQADQGgcAAAADUGbeDRMQz/+qZYADLkhAANAaBwAAAALQZ+WRRUsK/8ACPghAANAaBwhAANAaBwAAAAJAZ+1RCf/AAspIQADQGgcAAAACQGft0Qn/wALKSEAA0BoHCEAA0BoHAAAAA1Bm7w0TEM//qmWAAy4IQADQGgcAAAAC0Gf2kUVLCv/AAj5IQADQGgcAAAACQGf+UQn/wALKCEAA0BoHCEAA0BoHAAAAAkBn/tEJ/8ACykhAANAaBwAAAANQZvgNExDP/6plgAMuSEAA0BoHCEAA0BoHAAAAAtBnh5FFSwr/wAI+CEAA0BoHAAAAAkBnj1EJ/8ACyghAANAaBwhAANAaBwAAAAJAZ4/RCf/AAspIQADQGgcAAAADUGaJDRMQz/+qZYADLghAANAaBwAAAALQZ5CRRUsK/8ACPkhAANAaBwhAANAaBwAAAAJAZ5hRCf/AAsoIQADQGgcAAAACQGeY0Qn/wALKSEAA0BoHCEAA0BoHAAAAA1Bmmg0TEM//qmWAAy5IQADQGgcAAAAC0GehkUVLCv/AAj5IQADQGgcIQADQGgcAAAACQGepUQn/wALKSEAA0BoHAAAAAkBnqdEJ/8ACyghAANAaBwAAAANQZqsNExDP/6plgAMuCEAA0BoHCEAA0BoHAAAAAtBnspFFSwr/wAI+SEAA0BoHAAAAAkBnulEJ/8ACyghAANAaBwhAANAaBwAAAAJAZ7rRCf/AAsoIQADQGgcAAAADUGa8DRMQz/+qZYADLkhAANAaBwhAANAaBwAAAALQZ8ORRUsK/8ACPkhAANAaBwAAAAJAZ8tRCf/AAspIQADQGgcIQADQGgcAAAACQGfL0Qn/wALKCEAA0BoHAAAAA1BmzQ0TEM//qmWAAy4IQADQGgcAAAAC0GfUkUVLCv/AAj5IQADQGgcIQADQGgcAAAACQGfcUQn/wALKCEAA0BoHAAAAAkBn3NEJ/8ACyghAANAaBwhAANAaBwAAAANQZt4NExC//6plgAMuSEAA0BoHAAAAAtBn5ZFFSwr/wAI+CEAA0BoHCEAA0BoHAAAAAkBn7VEJ/8ACykhAANAaBwAAAAJAZ+3RCf/AAspIQADQGgcAAAADUGbuzRMQn/+nhAAYsAhAANAaBwhAANAaBwAAAAJQZ/aQhP/AAspIQADQGgcAAAACQGf+UQn/wALKCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHAAACiFtb292AAAAbG12aGQAAAAA1YCCX9WAgl8AAAPoAAAH/AABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAGGlvZHMAAAAAEICAgAcAT////v7/AAAF+XRyYWsAAABcdGtoZAAAAAPVgIJf1YCCXwAAAAEAAAAAAAAH0AAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAygAAAMoAAAAAACRlZHRzAAAAHGVsc3QAAAAAAAAAAQAAB9AAABdwAAEAAAAABXFtZGlhAAAAIG1kaGQAAAAA1YCCX9WAgl8AAV+QAAK/IFXEAAAAAAAtaGRscgAAAAAAAAAAdmlkZQAAAAAAAAAAAAAAAFZpZGVvSGFuZGxlcgAAAAUcbWluZgAAABR2bWhkAAAAAQAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAAE3HN0YmwAAACYc3RzZAAAAAAAAAABAAAAiGF2YzEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAygDKAEgAAABIAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY//8AAAAyYXZjQwFNQCj/4QAbZ01AKOyho3ySTUBAQFAAAAMAEAAr8gDxgxlgAQAEaO+G8gAAABhzdHRzAAAAAAAAAAEAAAA8AAALuAAAABRzdHNzAAAAAAAAAAEAAAABAAAB8GN0dHMAAAAAAAAAPAAAAAEAABdwAAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAAC7gAAAAAQAAF3AAAAABAAAAAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAEEc3RzegAAAAAAAAAAAAAAPAAAAzQAAAAQAAAADQAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAANAAAADQAAAQBzdGNvAAAAAAAAADwAAAAwAAADZAAAA3QAAAONAAADoAAAA7kAAAPQAAAD6wAAA/4AAAQXAAAELgAABEMAAARcAAAEbwAABIwAAAShAAAEugAABM0AAATkAAAE/wAABRIAAAUrAAAFQgAABV0AAAVwAAAFiQAABaAAAAW1AAAFzgAABeEAAAX+AAAGEwAABiwAAAY/AAAGVgAABnEAAAaEAAAGnQAABrQAAAbPAAAG4gAABvUAAAcSAAAHJwAAB0AAAAdTAAAHcAAAB4UAAAeeAAAHsQAAB8gAAAfjAAAH9gAACA8AAAgmAAAIQQAACFQAAAhnAAAIhAAACJcAAAMsdHJhawAAAFx0a2hkAAAAA9WAgl/VgIJfAAAAAgAAAAAAAAf8AAAAAAAAAAAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAACsm1kaWEAAAAgbWRoZAAAAADVgIJf1YCCXwAArEQAAWAAVcQAAAAAACdoZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU3RlcmVvAAAAAmNtaW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAidzdGJsAAAAZ3N0c2QAAAAAAAAAAQAAAFdtcDRhAAAAAAAAAAEAAAAAAAAAAAACABAAAAAArEQAAAAAADNlc2RzAAAAAAOAgIAiAAIABICAgBRAFQAAAAADDUAAAAAABYCAgAISEAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAABYAAAEAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAAUc3RzegAAAAAAAAAGAAAAWAAAAXBzdGNvAAAAAAAAAFgAAAOBAAADhwAAA5oAAAOtAAADswAAA8oAAAPfAAAD5QAAA/gAAAQLAAAEEQAABCgAAAQ9AAAEUAAABFYAAARpAAAEgAAABIYAAASbAAAErgAABLQAAATHAAAE3gAABPMAAAT5AAAFDAAABR8AAAUlAAAFPAAABVEAAAVXAAAFagAABX0AAAWDAAAFmgAABa8AAAXCAAAFyAAABdsAAAXyAAAF+AAABg0AAAYgAAAGJgAABjkAAAZQAAAGZQAABmsAAAZ+AAAGkQAABpcAAAauAAAGwwAABskAAAbcAAAG7wAABwYAAAcMAAAHIQAABzQAAAc6AAAHTQAAB2QAAAdqAAAHfwAAB5IAAAeYAAAHqwAAB8IAAAfXAAAH3QAAB/AAAAgDAAAICQAACCAAAAg1AAAIOwAACE4AAAhhAAAIeAAACH4AAAiRAAAIpAAACKoAAAiwAAAItgAACLwAAAjCAAAAFnVkdGEAAAAObmFtZVN0ZXJlbwAAAHB1ZHRhAAAAaG1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAAO2lsc3QAAAAzqXRvbwAAACtkYXRhAAAAAQAAAABIYW5kQnJha2UgMC4xMC4yIDIwMTUwNjExMDA="}])}))})))&&ue.__esModule&&Object.prototype.hasOwnProperty.call(ue,"default")?ue.default:ue,de=1e3,pe=[0,0,.5,1],fe=[.5,0,.5,1],me=window.requestAnimationFrame,ve=window.cancelAnimationFrame;function ge(e){Object.defineProperties(this,{hasPosition:{writable:!1,enumerable:!0,value:e.hasPosition},hasExternalDisplay:{writable:!1,enumerable:!0,value:e.hasExternalDisplay},canPresent:{writable:!1,enumerable:!0,value:e.canPresent},maxLayers:{writable:!1,enumerable:!0,value:e.maxLayers},hasOrientation:{enumerable:!0,get:function(){return S("VRDisplayCapabilities.prototype.hasOrientation","VRDisplay.prototype.getFrameData"),e.hasOrientation}}})}function ye(e){var t=!("wakelock"in(e=e||{}))||e.wakelock;this.isPolyfilled=!0,this.displayId=de++,this.displayName="",this.depthNear=.01,this.depthFar=1e4,this.isPresenting=!1,Object.defineProperty(this,"isConnected",{get:function(){return S("VRDisplay.prototype.isConnected","VRDisplayCapabilities.prototype.hasExternalDisplay"),!1}}),this.capabilities=new ge({hasPosition:!1,hasOrientation:!1,hasExternalDisplay:!1,canPresent:!1,maxLayers:1}),this.stageParameters=null,this.waitingForPresent_=!1,this.layer_=null,this.originalParent_=null,this.fullscreenElement_=null,this.fullscreenWrapper_=null,this.fullscreenElementCachedStyle_=null,this.fullscreenEventTarget_=null,this.fullscreenChangeHandler_=null,this.fullscreenErrorHandler_=null,t&&x()&&(this.wakelock_=new he)}ye.prototype.getFrameData=function(e){return _(e,this._getPose(),this)},ye.prototype.getPose=function(){return S("VRDisplay.prototype.getPose","VRDisplay.prototype.getFrameData"),this._getPose()},ye.prototype.resetPose=function(){return S("VRDisplay.prototype.resetPose"),this._resetPose()},ye.prototype.getImmediatePose=function(){return S("VRDisplay.prototype.getImmediatePose","VRDisplay.prototype.getFrameData"),this._getPose()},ye.prototype.requestAnimationFrame=function(e){return me(e)},ye.prototype.cancelAnimationFrame=function(e){return ve(e)},ye.prototype.wrapForFullscreen=function(e){if(c())return e;if(!this.fullscreenWrapper_){this.fullscreenWrapper_=document.createElement("div");var t=["height: "+Math.min(screen.height,screen.width)+"px !important","top: 0 !important","left: 0 !important","right: 0 !important","border: 0","margin: 0","padding: 0","z-index: 999999 !important","position: fixed"];this.fullscreenWrapper_.setAttribute("style",t.join("; ")+";"),this.fullscreenWrapper_.classList.add("webvr-polyfill-fullscreen-wrapper")}if(this.fullscreenElement_==e)return this.fullscreenWrapper_;if(this.fullscreenElement_&&(this.originalParent_?this.originalParent_.appendChild(this.fullscreenElement_):this.fullscreenElement_.parentElement.removeChild(this.fullscreenElement_)),this.fullscreenElement_=e,this.originalParent_=e.parentElement,this.originalParent_||document.body.appendChild(e),!this.fullscreenWrapper_.parentElement){var n=this.fullscreenElement_.parentElement;n.insertBefore(this.fullscreenWrapper_,this.fullscreenElement_),n.removeChild(this.fullscreenElement_)}this.fullscreenWrapper_.insertBefore(this.fullscreenElement_,this.fullscreenWrapper_.firstChild),this.fullscreenElementCachedStyle_=this.fullscreenElement_.getAttribute("style");var r=this;return function(){if(r.fullscreenElement_){var e=["position: absolute","top: 0","left: 0","width: "+Math.max(screen.width,screen.height)+"px","height: "+Math.min(screen.height,screen.width)+"px","border: 0","margin: 0","padding: 0"];r.fullscreenElement_.setAttribute("style",e.join("; ")+";")}}(),this.fullscreenWrapper_},ye.prototype.removeFullscreenWrapper=function(){if(this.fullscreenElement_){var e=this.fullscreenElement_;this.fullscreenElementCachedStyle_?e.setAttribute("style",this.fullscreenElementCachedStyle_):e.removeAttribute("style"),this.fullscreenElement_=null,this.fullscreenElementCachedStyle_=null;var t=this.fullscreenWrapper_.parentElement;return this.fullscreenWrapper_.removeChild(e),this.originalParent_===t?t.insertBefore(e,this.fullscreenWrapper_):this.originalParent_&&this.originalParent_.appendChild(e),t.removeChild(this.fullscreenWrapper_),e}},ye.prototype.requestPresent=function(e){var t=this.isPresenting,n=this;return e instanceof Array||(S("VRDisplay.prototype.requestPresent with non-array argument","an array of VRLayers as the first argument"),e=[e]),new Promise((function(r,i){if(n.capabilities.canPresent)if(0==e.length||e.length>n.capabilities.maxLayers)i(new Error("Invalid number of layers."));else{var a=e[0];if(a.source){var o=a.leftBounds||pe,s=a.rightBounds||fe;if(t){var u=n.layer_;u.source!==a.source&&(u.source=a.source);for(var h=0;h<4;h++)u.leftBounds[h]=o[h],u.rightBounds[h]=s[h];return n.wrapForFullscreen(n.layer_.source),n.updatePresent_(),void r()}if(n.layer_={predistorted:a.predistorted,source:a.source,leftBounds:o.slice(0),rightBounds:s.slice(0)},n.waitingForPresent_=!1,n.layer_&&n.layer_.source){var d=n.wrapForFullscreen(n.layer_.source);n.addFullscreenListeners_(d,(function(){var e=document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement;n.isPresenting=d===e,n.isPresenting?(screen.orientation&&screen.orientation.lock&&screen.orientation.lock("landscape-primary").catch((function(e){console.error("screen.orientation.lock() failed due to",e.message)})),n.waitingForPresent_=!1,n.beginPresent_(),r()):(screen.orientation&&screen.orientation.unlock&&screen.orientation.unlock(),n.removeFullscreenWrapper(),n.disableWakeLock(),n.endPresent_(),n.removeFullscreenListeners_()),n.fireVRDisplayPresentChange_()}),(function(){n.waitingForPresent_&&(n.removeFullscreenWrapper(),n.removeFullscreenListeners_(),n.disableWakeLock(),n.waitingForPresent_=!1,n.isPresenting=!1,i(new Error("Unable to present.")))})),function(e){if(l())return!1;if(e.requestFullscreen)e.requestFullscreen();else if(e.webkitRequestFullscreen)e.webkitRequestFullscreen();else if(e.mozRequestFullScreen)e.mozRequestFullScreen();else{if(!e.msRequestFullscreen)return!1;e.msRequestFullscreen()}return!0}(d)?(n.enableWakeLock(),n.waitingForPresent_=!0):(c()||l())&&(n.enableWakeLock(),n.isPresenting=!0,n.beginPresent_(),n.fireVRDisplayPresentChange_(),r())}n.waitingForPresent_||c()||(g(),i(new Error("Unable to present.")))}else r()}else i(new Error("VRDisplay is not capable of presenting."))}))},ye.prototype.exitPresent=function(){var e=this.isPresenting,t=this;return this.isPresenting=!1,this.layer_=null,this.disableWakeLock(),new Promise((function(n,r){e?(!g()&&c()&&(t.endPresent_(),t.fireVRDisplayPresentChange_()),l()&&(t.removeFullscreenWrapper(),t.removeFullscreenListeners_(),t.endPresent_(),t.fireVRDisplayPresentChange_()),n()):r(new Error("Was not presenting to VRDisplay."))}))},ye.prototype.getLayers=function(){return this.layer_?[this.layer_]:[]},ye.prototype.fireVRDisplayPresentChange_=function(){var e=new CustomEvent("vrdisplaypresentchange",{detail:{display:this}});window.dispatchEvent(e)},ye.prototype.fireVRDisplayConnect_=function(){var e=new CustomEvent("vrdisplayconnect",{detail:{display:this}});window.dispatchEvent(e)},ye.prototype.addFullscreenListeners_=function(e,t,n){this.removeFullscreenListeners_(),this.fullscreenEventTarget_=e,this.fullscreenChangeHandler_=t,this.fullscreenErrorHandler_=n,t&&(document.fullscreenEnabled?e.addEventListener("fullscreenchange",t,!1):document.webkitFullscreenEnabled?e.addEventListener("webkitfullscreenchange",t,!1):document.mozFullScreenEnabled?document.addEventListener("mozfullscreenchange",t,!1):document.msFullscreenEnabled&&e.addEventListener("msfullscreenchange",t,!1)),n&&(document.fullscreenEnabled?e.addEventListener("fullscreenerror",n,!1):document.webkitFullscreenEnabled?e.addEventListener("webkitfullscreenerror",n,!1):document.mozFullScreenEnabled?document.addEventListener("mozfullscreenerror",n,!1):document.msFullscreenEnabled&&e.addEventListener("msfullscreenerror",n,!1))},ye.prototype.removeFullscreenListeners_=function(){if(this.fullscreenEventTarget_){var e=this.fullscreenEventTarget_;if(this.fullscreenChangeHandler_){var t=this.fullscreenChangeHandler_;e.removeEventListener("fullscreenchange",t,!1),e.removeEventListener("webkitfullscreenchange",t,!1),document.removeEventListener("mozfullscreenchange",t,!1),e.removeEventListener("msfullscreenchange",t,!1)}if(this.fullscreenErrorHandler_){var n=this.fullscreenErrorHandler_;e.removeEventListener("fullscreenerror",n,!1),e.removeEventListener("webkitfullscreenerror",n,!1),document.removeEventListener("mozfullscreenerror",n,!1),e.removeEventListener("msfullscreenerror",n,!1)}this.fullscreenEventTarget_=null,this.fullscreenChangeHandler_=null,this.fullscreenErrorHandler_=null}},ye.prototype.enableWakeLock=function(){this.wakelock_&&this.wakelock_.enable()},ye.prototype.disableWakeLock=function(){this.wakelock_&&this.wakelock_.disable()},ye.prototype.beginPresent_=function(){},ye.prototype.endPresent_=function(){},ye.prototype.submitFrame=function(e){},ye.prototype.getEyeParameters=function(e){return null};var Ae={ADDITIONAL_VIEWERS:[],DEFAULT_VIEWER:"",MOBILE_WAKE_LOCK:!0,DEBUG:!1,DPDB_URL:"https://dpdb.webvr.rocks/dpdb.json",K_FILTER:.98,PREDICTION_TIME_S:.04,CARDBOARD_UI_DISABLED:!1,ROTATE_INSTRUCTIONS_DISABLED:!1,YAW_ONLY:!1,BUFFER_SCALE:.5,DIRTY_SUBMIT_FRAME_BINDINGS:!1},xe="left",be="right";function we(e){var t=b({},Ae);e=b(t,e||{}),ye.call(this,{wakelock:e.MOBILE_WAKE_LOCK}),this.config=e,this.displayName="Cardboard VRDisplay",this.capabilities=new ge({hasPosition:!1,hasOrientation:!0,hasExternalDisplay:!1,canPresent:!0,maxLayers:1}),this.stageParameters=null,this.bufferScale_=this.config.BUFFER_SCALE,this.poseSensor_=new ae(this.config),this.distorter_=null,this.cardboardUI_=null,this.dpdb_=new Z(this.config.DPDB_URL,this.onDeviceParamsUpdated_.bind(this)),this.deviceInfo_=new q(this.dpdb_.getDeviceParams(),e.ADDITIONAL_VIEWERS),this.viewerSelector_=new le(e.DEFAULT_VIEWER),this.viewerSelector_.onChange(this.onViewerChanged_.bind(this)),this.deviceInfo_.setViewer(this.viewerSelector_.getCurrentViewer()),this.config.ROTATE_INSTRUCTIONS_DISABLED||(this.rotateInstructions_=new oe),c()&&window.addEventListener("resize",this.onResize_.bind(this))}return we.prototype=Object.create(ye.prototype),we.prototype._getPose=function(){return{position:null,orientation:this.poseSensor_.getOrientation(),linearVelocity:null,linearAcceleration:null,angularVelocity:null,angularAcceleration:null}},we.prototype._resetPose=function(){this.poseSensor_.resetPose&&this.poseSensor_.resetPose()},we.prototype._getFieldOfView=function(e){var t;if(e==xe)t=this.deviceInfo_.getFieldOfViewLeftEye();else{if(e!=be)return console.error("Invalid eye provided: %s",e),null;t=this.deviceInfo_.getFieldOfViewRightEye()}return t},we.prototype._getEyeOffset=function(e){var t;if(e==xe)t=[.5*-this.deviceInfo_.viewer.interLensDistance,0,0];else{if(e!=be)return console.error("Invalid eye provided: %s",e),null;t=[.5*this.deviceInfo_.viewer.interLensDistance,0,0]}return t},we.prototype.getEyeParameters=function(e){var t=this._getEyeOffset(e),n=this._getFieldOfView(e),r={offset:t,renderWidth:.5*this.deviceInfo_.device.width*this.bufferScale_,renderHeight:this.deviceInfo_.device.height*this.bufferScale_};return Object.defineProperty(r,"fieldOfView",{enumerable:!0,get:function(){return S("VRFieldOfView","VRFrameData's projection matrices"),n}}),r},we.prototype.onDeviceParamsUpdated_=function(e){this.config.DEBUG&&console.log("DPDB reported that device params were updated."),this.deviceInfo_.updateDeviceParams(e),this.distorter_&&this.distorter_.updateDeviceInfo(this.deviceInfo_)},we.prototype.updateBounds_=function(){this.layer_&&this.distorter_&&(this.layer_.leftBounds||this.layer_.rightBounds)&&this.distorter_.setTextureBounds(this.layer_.leftBounds,this.layer_.rightBounds)},we.prototype.beginPresent_=function(){var e=this.layer_.source.getContext("webgl");e||(e=this.layer_.source.getContext("experimental-webgl")),e||(e=this.layer_.source.getContext("webgl2")),e&&(this.layer_.predistorted?this.config.CARDBOARD_UI_DISABLED||(e.canvas.width=m()*this.bufferScale_,e.canvas.height=v()*this.bufferScale_,this.cardboardUI_=new N(e)):(this.config.CARDBOARD_UI_DISABLED||(this.cardboardUI_=new N(e)),this.distorter_=new C(e,this.cardboardUI_,this.config.BUFFER_SCALE,this.config.DIRTY_SUBMIT_FRAME_BINDINGS),this.distorter_.updateDeviceInfo(this.deviceInfo_)),this.cardboardUI_&&this.cardboardUI_.listen(function(e){this.viewerSelector_.show(this.layer_.source.parentElement),e.stopPropagation(),e.preventDefault()}.bind(this),function(e){this.exitPresent(),e.stopPropagation(),e.preventDefault()}.bind(this)),this.rotateInstructions_&&(f()&&x()?this.rotateInstructions_.showTemporarily(3e3,this.layer_.source.parentElement):this.rotateInstructions_.update()),this.orientationHandler=this.onOrientationChange_.bind(this),window.addEventListener("orientationchange",this.orientationHandler),this.vrdisplaypresentchangeHandler=this.updateBounds_.bind(this),window.addEventListener("vrdisplaypresentchange",this.vrdisplaypresentchangeHandler),this.fireVRDisplayDeviceParamsChange_())},we.prototype.endPresent_=function(){this.distorter_&&(this.distorter_.destroy(),this.distorter_=null),this.cardboardUI_&&(this.cardboardUI_.destroy(),this.cardboardUI_=null),this.rotateInstructions_&&this.rotateInstructions_.hide(),this.viewerSelector_.hide(),window.removeEventListener("orientationchange",this.orientationHandler),window.removeEventListener("vrdisplaypresentchange",this.vrdisplaypresentchangeHandler)},we.prototype.updatePresent_=function(){this.endPresent_(),this.beginPresent_()},we.prototype.submitFrame=function(e){if(this.distorter_)this.updateBounds_(),this.distorter_.submitFrame();else if(this.cardboardUI_&&this.layer_){var t=this.layer_.source.getContext("webgl");t||(t=this.layer_.source.getContext("experimental-webgl")),t||(t=this.layer_.source.getContext("webgl2"));var n=t.canvas;n.width==this.lastWidth&&n.height==this.lastHeight||this.cardboardUI_.onResize(),this.lastWidth=n.width,this.lastHeight=n.height,this.cardboardUI_.render()}},we.prototype.onOrientationChange_=function(e){this.viewerSelector_.hide(),this.rotateInstructions_&&this.rotateInstructions_.update(),this.onResize_()},we.prototype.onResize_=function(e){if(this.layer_){var t=this.layer_.source.getContext("webgl");t||(t=this.layer_.source.getContext("experimental-webgl")),t||(t=this.layer_.source.getContext("webgl2")),t.canvas.setAttribute("style",["position: absolute","top: 0","left: 0","width: 100vw","height: 100vh","border: 0","margin: 0","padding: 0px","box-sizing: content-box"].join("; ")+";"),w(t.canvas)}},we.prototype.onViewerChanged_=function(e){this.deviceInfo_.setViewer(e),this.distorter_&&this.distorter_.updateDeviceInfo(this.deviceInfo_),this.fireVRDisplayDeviceParamsChange_()},we.prototype.fireVRDisplayDeviceParamsChange_=function(){var e=new CustomEvent("vrdisplaydeviceparamschange",{detail:{vrdisplay:this,deviceInfo:this.deviceInfo_}});window.dispatchEvent(e)},we.VRFrameData=function(){this.leftProjectionMatrix=new Float32Array(16),this.leftViewMatrix=new Float32Array(16),this.rightProjectionMatrix=new Float32Array(16),this.rightViewMatrix=new Float32Array(16),this.pose=null},we.VRDisplay=ye,we}()})),s=(e=o)&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e,c={ADDITIONAL_VIEWERS:[],DEFAULT_VIEWER:"",PROVIDE_MOBILE_VRDISPLAY:!0,MOBILE_WAKE_LOCK:!0,DEBUG:!1,DPDB_URL:"https://dpdb.webvr.rocks/dpdb.json",K_FILTER:.98,PREDICTION_TIME_S:.04,CARDBOARD_UI_DISABLED:!1,ROTATE_INSTRUCTIONS_DISABLED:!1,YAW_ONLY:!1,BUFFER_SCALE:.5,DIRTY_SUBMIT_FRAME_BINDINGS:!1};function l(e){this.config=a(a({},c),e),this.polyfillDisplays=[],this.enabled=!1,this.hasNative="getVRDisplays"in navigator,this.native={},this.native.getVRDisplays=navigator.getVRDisplays,this.native.VRFrameData=window.VRFrameData,this.native.VRDisplay=window.VRDisplay,(!this.hasNative||this.config.PROVIDE_MOBILE_VRDISPLAY&&r())&&(this.enable(),this.getVRDisplays().then((function(e){e&&e[0]&&e[0].fireVRDisplayConnect_&&e[0].fireVRDisplayConnect_()})))}l.prototype.getPolyfillDisplays=function(){if(this._polyfillDisplaysPopulated)return this.polyfillDisplays;if(r()){var e=new s({ADDITIONAL_VIEWERS:this.config.ADDITIONAL_VIEWERS,DEFAULT_VIEWER:this.config.DEFAULT_VIEWER,MOBILE_WAKE_LOCK:this.config.MOBILE_WAKE_LOCK,DEBUG:this.config.DEBUG,DPDB_URL:this.config.DPDB_URL,CARDBOARD_UI_DISABLED:this.config.CARDBOARD_UI_DISABLED,K_FILTER:this.config.K_FILTER,PREDICTION_TIME_S:this.config.PREDICTION_TIME_S,ROTATE_INSTRUCTIONS_DISABLED:this.config.ROTATE_INSTRUCTIONS_DISABLED,YAW_ONLY:this.config.YAW_ONLY,BUFFER_SCALE:this.config.BUFFER_SCALE,DIRTY_SUBMIT_FRAME_BINDINGS:this.config.DIRTY_SUBMIT_FRAME_BINDINGS});this.polyfillDisplays.push(e)}return this._polyfillDisplaysPopulated=!0,this.polyfillDisplays},l.prototype.enable=function(){if(this.enabled=!0,this.hasNative&&this.native.VRFrameData){var e=this.native.VRFrameData,t=new this.native.VRFrameData,n=this.native.VRDisplay.prototype.getFrameData;window.VRDisplay.prototype.getFrameData=function(r){r instanceof e?n.call(this,r):(n.call(this,t),r.pose=t.pose,i(t.leftProjectionMatrix,r.leftProjectionMatrix),i(t.rightProjectionMatrix,r.rightProjectionMatrix),i(t.leftViewMatrix,r.leftViewMatrix),i(t.rightViewMatrix,r.rightViewMatrix))}}navigator.getVRDisplays=this.getVRDisplays.bind(this),window.VRDisplay=s.VRDisplay,window.VRFrameData=s.VRFrameData},l.prototype.getVRDisplays=function(){var e=this;return this.config,this.hasNative?this.native.getVRDisplays.call(navigator).then((function(t){return t.length>0?t:e.getPolyfillDisplays()})):Promise.resolve(this.getPolyfillDisplays())},l.version="0.10.10",l.VRFrameData=s.VRFrameData,l.VRDisplay=s.VRDisplay;var u=Object.freeze({default:l}),h=u&&l||u;return void 0!==n&&n.window&&(n.document||(n.document=n.window.document),n.navigator||(n.navigator=n.window.navigator)),h},e.exports=n()}).call(this,n(8))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=n(0);function i(e,t){for(var n=0;n0?i.vrDisplay=e[0]:n&&n("VR input not available.")})).catch((function(){console.warn("VRControls: Unable to get VR Displays")})),this.scale=1,this.standing=!1,this.userHeight=1.6}var t,n,a;return t=e,(n=[{key:"getVRDisplay",value:function(){return this.vrDisplay}},{key:"setVRDisplay",value:function(e){this.vrDisplay=e}},{key:"getVRDisplays",value:function(){return console.warn("VRControls: getVRDisplays() is being deprecated."),this.vrDisplays}},{key:"getStandingMatrix",value:function(){return this.standingMatrix}},{key:"update",value:function(){var e,t=this.camera;this.vrDisplay&&(this.vrDisplay.getFrameData?(this.vrDisplay.getFrameData(this.frameData),e=this.frameData.pose):this.vrDisplay.getPose&&(e=this.vrDisplay.getPose()),null!==e.orientation&&t.quaternion.fromArray(e.orientation),null!==e.position?t.position.fromArray(e.position):t.position.set(0,0,0),this.standing&&(this.vrDisplay.stageParameters?(t.updateMatrix(),this.standingMatrix.fromArray(this.vrDisplay.stageParameters.sittingToStandingTransform),t.applyMatrix(this.standingMatrix)):t.position.setY(t.position.y+this.userHeight)),t.position.multiplyScalar(this.scale))}},{key:"dispose",value:function(){this.vrDisplay=null}}])&&i(t.prototype,n),a&&i(t,a),e}();t.default=a}]); \ No newline at end of file +t.exports=function(){var t,e,r,i=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=function(){function t(t,e){for(var n=0;nt.TEXTURE31){console.error("TEXTURE_BINDING_2D or TEXTURE_BINDING_CUBE_MAP must be followed by a valid texture unit"),r.push(null,null);break}i||(i=t.getParameter(t.ACTIVE_TEXTURE)),t.activeTexture(c),r.push(t.getParameter(o),null);break;case t.ACTIVE_TEXTURE:i=t.getParameter(t.ACTIVE_TEXTURE),r.push(null);break;default:r.push(t.getParameter(o))}for(n(t),a=0;at.TEXTURE31)break;t.activeTexture(c),t.bindTexture(t.TEXTURE_2D,s);break;case t.TEXTURE_BINDING_CUBE_MAP:var c;if((c=e[++a])t.TEXTURE31)break;t.activeTexture(c),t.bindTexture(t.TEXTURE_CUBE_MAP,s);break;case t.VIEWPORT:t.viewport(s[0],s[1],s[2],s[3]);break;case t.BLEND:case t.CULL_FACE:case t.DEPTH_TEST:case t.SCISSOR_TEST:case t.STENCIL_TEST:s?t.enable(o):t.disable(o);break;default:console.log("No GL restore behavior for 0x"+o.toString(16))}i&&t.activeTexture(i)}}else n(t)},L=["attribute vec2 position;","attribute vec3 texCoord;","varying vec2 vTexCoord;","uniform vec4 viewportOffsetScale[2];","void main() {"," vec4 viewport = viewportOffsetScale[int(texCoord.z)];"," vTexCoord = (texCoord.xy * viewport.zw) + viewport.xy;"," gl_Position = vec4( position, 1.0, 1.0 );","}"].join("\n"),R=["precision mediump float;","uniform sampler2D diffuse;","varying vec2 vTexCoord;","void main() {"," gl_FragColor = texture2D(diffuse, vTexCoord);","}"].join("\n");function P(t,e,n,r){this.gl=t,this.cardboardUI=e,this.bufferScale=n,this.dirtySubmitFrameBindings=r,this.ctxAttribs=t.getContextAttributes(),this.meshWidth=20,this.meshHeight=20,this.bufferWidth=t.drawingBufferWidth,this.bufferHeight=t.drawingBufferHeight,this.realBindFramebuffer=t.bindFramebuffer,this.realEnable=t.enable,this.realDisable=t.disable,this.realColorMask=t.colorMask,this.realClearColor=t.clearColor,this.realViewport=t.viewport,c()||(this.realCanvasWidth=Object.getOwnPropertyDescriptor(t.canvas.__proto__,"width"),this.realCanvasHeight=Object.getOwnPropertyDescriptor(t.canvas.__proto__,"height")),this.isPatched=!1,this.lastBoundFramebuffer=null,this.cullFace=!1,this.depthTest=!1,this.blend=!1,this.scissorTest=!1,this.stencilTest=!1,this.viewport=[0,0,0,0],this.colorMask=[!0,!0,!0,!0],this.clearColor=[0,0,0,0],this.attribs={position:0,texCoord:1},this.program=y(t,L,R,this.attribs),this.uniforms=x(t,this.program),this.viewportOffsetScale=new Float32Array(8),this.setTextureBounds(),this.vertexBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),this.indexCount=0,this.renderTarget=t.createTexture(),this.framebuffer=t.createFramebuffer(),this.depthStencilBuffer=null,this.depthBuffer=null,this.stencilBuffer=null,this.ctxAttribs.depth&&this.ctxAttribs.stencil?this.depthStencilBuffer=t.createRenderbuffer():this.ctxAttribs.depth?this.depthBuffer=t.createRenderbuffer():this.ctxAttribs.stencil&&(this.stencilBuffer=t.createRenderbuffer()),this.patch(),this.onResize()}P.prototype.destroy=function(){var t=this.gl;this.unpatch(),t.deleteProgram(this.program),t.deleteBuffer(this.vertexBuffer),t.deleteBuffer(this.indexBuffer),t.deleteTexture(this.renderTarget),t.deleteFramebuffer(this.framebuffer),this.depthStencilBuffer&&t.deleteRenderbuffer(this.depthStencilBuffer),this.depthBuffer&&t.deleteRenderbuffer(this.depthBuffer),this.stencilBuffer&&t.deleteRenderbuffer(this.stencilBuffer),this.cardboardUI&&this.cardboardUI.destroy()},P.prototype.onResize=function(){var t=this.gl,e=this,n=[t.RENDERBUFFER_BINDING,t.TEXTURE_BINDING_2D,t.TEXTURE0];T(t,n,(function(t){e.realBindFramebuffer.call(t,t.FRAMEBUFFER,null),e.scissorTest&&e.realDisable.call(t,t.SCISSOR_TEST),e.realColorMask.call(t,!0,!0,!0,!0),e.realViewport.call(t,0,0,t.drawingBufferWidth,t.drawingBufferHeight),e.realClearColor.call(t,0,0,0,1),t.clear(t.COLOR_BUFFER_BIT),e.realBindFramebuffer.call(t,t.FRAMEBUFFER,e.framebuffer),t.bindTexture(t.TEXTURE_2D,e.renderTarget),t.texImage2D(t.TEXTURE_2D,0,e.ctxAttribs.alpha?t.RGBA:t.RGB,e.bufferWidth,e.bufferHeight,0,e.ctxAttribs.alpha?t.RGBA:t.RGB,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e.renderTarget,0),e.ctxAttribs.depth&&e.ctxAttribs.stencil?(t.bindRenderbuffer(t.RENDERBUFFER,e.depthStencilBuffer),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,e.bufferWidth,e.bufferHeight),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e.depthStencilBuffer)):e.ctxAttribs.depth?(t.bindRenderbuffer(t.RENDERBUFFER,e.depthBuffer),t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_COMPONENT16,e.bufferWidth,e.bufferHeight),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e.depthBuffer)):e.ctxAttribs.stencil&&(t.bindRenderbuffer(t.RENDERBUFFER,e.stencilBuffer),t.renderbufferStorage(t.RENDERBUFFER,t.STENCIL_INDEX8,e.bufferWidth,e.bufferHeight),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.STENCIL_ATTACHMENT,t.RENDERBUFFER,e.stencilBuffer)),!t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer incomplete!"),e.realBindFramebuffer.call(t,t.FRAMEBUFFER,e.lastBoundFramebuffer),e.scissorTest&&e.realEnable.call(t,t.SCISSOR_TEST),e.realColorMask.apply(t,e.colorMask),e.realViewport.apply(t,e.viewport),e.realClearColor.apply(t,e.clearColor)})),this.cardboardUI&&this.cardboardUI.onResize()},P.prototype.patch=function(){if(!this.isPatched){var t=this,e=this.gl.canvas,n=this.gl;c()||(e.width=m()*this.bufferScale,e.height=v()*this.bufferScale,Object.defineProperty(e,"width",{configurable:!0,enumerable:!0,get:function(){return t.bufferWidth},set:function(n){t.bufferWidth=n,t.realCanvasWidth.set.call(e,n),t.onResize()}}),Object.defineProperty(e,"height",{configurable:!0,enumerable:!0,get:function(){return t.bufferHeight},set:function(n){t.bufferHeight=n,t.realCanvasHeight.set.call(e,n),t.onResize()}})),this.lastBoundFramebuffer=n.getParameter(n.FRAMEBUFFER_BINDING),null==this.lastBoundFramebuffer&&(this.lastBoundFramebuffer=this.framebuffer,this.gl.bindFramebuffer(n.FRAMEBUFFER,this.framebuffer)),this.gl.bindFramebuffer=function(e,r){t.lastBoundFramebuffer=r||t.framebuffer,t.realBindFramebuffer.call(n,e,t.lastBoundFramebuffer)},this.cullFace=n.getParameter(n.CULL_FACE),this.depthTest=n.getParameter(n.DEPTH_TEST),this.blend=n.getParameter(n.BLEND),this.scissorTest=n.getParameter(n.SCISSOR_TEST),this.stencilTest=n.getParameter(n.STENCIL_TEST),n.enable=function(e){switch(e){case n.CULL_FACE:t.cullFace=!0;break;case n.DEPTH_TEST:t.depthTest=!0;break;case n.BLEND:t.blend=!0;break;case n.SCISSOR_TEST:t.scissorTest=!0;break;case n.STENCIL_TEST:t.stencilTest=!0}t.realEnable.call(n,e)},n.disable=function(e){switch(e){case n.CULL_FACE:t.cullFace=!1;break;case n.DEPTH_TEST:t.depthTest=!1;break;case n.BLEND:t.blend=!1;break;case n.SCISSOR_TEST:t.scissorTest=!1;break;case n.STENCIL_TEST:t.stencilTest=!1}t.realDisable.call(n,e)},this.colorMask=n.getParameter(n.COLOR_WRITEMASK),n.colorMask=function(e,r,i,a){t.colorMask[0]=e,t.colorMask[1]=r,t.colorMask[2]=i,t.colorMask[3]=a,t.realColorMask.call(n,e,r,i,a)},this.clearColor=n.getParameter(n.COLOR_CLEAR_VALUE),n.clearColor=function(e,r,i,a){t.clearColor[0]=e,t.clearColor[1]=r,t.clearColor[2]=i,t.clearColor[3]=a,t.realClearColor.call(n,e,r,i,a)},this.viewport=n.getParameter(n.VIEWPORT),n.viewport=function(e,r,i,a){t.viewport[0]=e,t.viewport[1]=r,t.viewport[2]=i,t.viewport[3]=a,t.realViewport.call(n,e,r,i,a)},this.isPatched=!0,_(e)}},P.prototype.unpatch=function(){if(this.isPatched){var t=this.gl,e=this.gl.canvas;c()||(Object.defineProperty(e,"width",this.realCanvasWidth),Object.defineProperty(e,"height",this.realCanvasHeight)),e.width=this.bufferWidth,e.height=this.bufferHeight,t.bindFramebuffer=this.realBindFramebuffer,t.enable=this.realEnable,t.disable=this.realDisable,t.colorMask=this.realColorMask,t.clearColor=this.realClearColor,t.viewport=this.realViewport,this.lastBoundFramebuffer==this.framebuffer&&t.bindFramebuffer(t.FRAMEBUFFER,null),this.isPatched=!1,setTimeout((function(){_(e)}),1)}},P.prototype.setTextureBounds=function(t,e){t||(t=[0,0,.5,1]),e||(e=[.5,0,.5,1]),this.viewportOffsetScale[0]=t[0],this.viewportOffsetScale[1]=t[1],this.viewportOffsetScale[2]=t[2],this.viewportOffsetScale[3]=t[3],this.viewportOffsetScale[4]=e[0],this.viewportOffsetScale[5]=e[1],this.viewportOffsetScale[6]=e[2],this.viewportOffsetScale[7]=e[3]},P.prototype.submitFrame=function(){var t=this.gl,e=this,n=[];if(this.dirtySubmitFrameBindings||n.push(t.CURRENT_PROGRAM,t.ARRAY_BUFFER_BINDING,t.ELEMENT_ARRAY_BUFFER_BINDING,t.TEXTURE_BINDING_2D,t.TEXTURE0),T(t,n,(function(t){e.realBindFramebuffer.call(t,t.FRAMEBUFFER,null),e.cullFace&&e.realDisable.call(t,t.CULL_FACE),e.depthTest&&e.realDisable.call(t,t.DEPTH_TEST),e.blend&&e.realDisable.call(t,t.BLEND),e.scissorTest&&e.realDisable.call(t,t.SCISSOR_TEST),e.stencilTest&&e.realDisable.call(t,t.STENCIL_TEST),e.realColorMask.call(t,!0,!0,!0,!0),e.realViewport.call(t,0,0,t.drawingBufferWidth,t.drawingBufferHeight),(e.ctxAttribs.alpha||c())&&(e.realClearColor.call(t,0,0,0,1),t.clear(t.COLOR_BUFFER_BIT)),t.useProgram(e.program),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.indexBuffer),t.bindBuffer(t.ARRAY_BUFFER,e.vertexBuffer),t.enableVertexAttribArray(e.attribs.position),t.enableVertexAttribArray(e.attribs.texCoord),t.vertexAttribPointer(e.attribs.position,2,t.FLOAT,!1,20,0),t.vertexAttribPointer(e.attribs.texCoord,3,t.FLOAT,!1,20,8),t.activeTexture(t.TEXTURE0),t.uniform1i(e.uniforms.diffuse,0),t.bindTexture(t.TEXTURE_2D,e.renderTarget),t.uniform4fv(e.uniforms.viewportOffsetScale,e.viewportOffsetScale),t.drawElements(t.TRIANGLES,e.indexCount,t.UNSIGNED_SHORT,0),e.cardboardUI&&e.cardboardUI.renderNoState(),e.realBindFramebuffer.call(e.gl,t.FRAMEBUFFER,e.framebuffer),e.ctxAttribs.preserveDrawingBuffer||(e.realClearColor.call(t,0,0,0,0),t.clear(t.COLOR_BUFFER_BIT)),e.dirtySubmitFrameBindings||e.realBindFramebuffer.call(t,t.FRAMEBUFFER,e.lastBoundFramebuffer),e.cullFace&&e.realEnable.call(t,t.CULL_FACE),e.depthTest&&e.realEnable.call(t,t.DEPTH_TEST),e.blend&&e.realEnable.call(t,t.BLEND),e.scissorTest&&e.realEnable.call(t,t.SCISSOR_TEST),e.stencilTest&&e.realEnable.call(t,t.STENCIL_TEST),e.realColorMask.apply(t,e.colorMask),e.realViewport.apply(t,e.viewport),!e.ctxAttribs.alpha&&e.ctxAttribs.preserveDrawingBuffer||e.realClearColor.apply(t,e.clearColor)})),c()){var r=t.canvas;r.width==e.bufferWidth&&r.height==e.bufferHeight||(e.bufferWidth=r.width,e.bufferHeight=r.height,e.onResize())}},P.prototype.updateDeviceInfo=function(t){var e=this.gl,n=this,r=[e.ARRAY_BUFFER_BINDING,e.ELEMENT_ARRAY_BUFFER_BINDING];T(e,r,(function(e){var r=n.computeMeshVertices_(n.meshWidth,n.meshHeight,t);if(e.bindBuffer(e.ARRAY_BUFFER,n.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,r,e.STATIC_DRAW),!n.indexCount){var i=n.computeMeshIndices_(n.meshWidth,n.meshHeight);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,i,e.STATIC_DRAW),n.indexCount=i.length}}))},P.prototype.computeMeshVertices_=function(t,e,n){for(var r=new Float32Array(2*t*e*5),i=n.getLeftEyeVisibleTanAngles(),a=n.getLeftEyeNoLensTanAngles(),o=n.getLeftEyeVisibleScreenRect(a),c=0,l=0;l<2;l++){for(var u=0;ui-42&&r.clientXn.clientHeight-42?t(r):r.clientX<42&&r.clientY<42&&e(r)},n.addEventListener("click",this.listener,!1)},N.prototype.onResize=function(){var t=this.gl,e=this,n=[t.ARRAY_BUFFER_BINDING];T(t,n,(function(t){var n=[],r=t.drawingBufferWidth/2,i=Math.max(screen.width,screen.height)*window.devicePixelRatio,a=t.drawingBufferWidth/i*window.devicePixelRatio,o=4*a/2,s=42*a,c=28*a/2,l=14*a;function u(t,e){var i=(90-t)*D,a=Math.cos(i),o=Math.sin(i);n.push(I*a*c+r,I*o*c+c),n.push(e*a*c+r,e*o*c+c)}n.push(r-o,s),n.push(r-o,t.drawingBufferHeight),n.push(r+o,s),n.push(r+o,t.drawingBufferHeight),e.gearOffset=n.length/2;for(var h=0;h<=6;h++){var d=60*h;u(d,1),u(d+12,1),u(d+20,.75),u(d+40,.75),u(d+48,1)}function p(e,r){n.push(l+e,t.drawingBufferHeight-l-r)}e.gearVertexCount=n.length/2-e.gearOffset,e.arrowOffset=n.length/2;var f=o/Math.sin(45*D);p(0,c),p(c,0),p(c+f,f),p(f,c+f),p(f,c-f),p(0,c),p(c,2*c),p(c+f,2*c-f),p(f,c-f),p(0,c),p(f,c-o),p(28*a,c-o),p(f,c+o),p(28*a,c+o),e.arrowVertexCount=n.length/2-e.arrowOffset,t.bindBuffer(t.ARRAY_BUFFER,e.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(n),t.STATIC_DRAW)}))},N.prototype.render=function(){var t=this.gl,e=this,n=[t.CULL_FACE,t.DEPTH_TEST,t.BLEND,t.SCISSOR_TEST,t.STENCIL_TEST,t.COLOR_WRITEMASK,t.VIEWPORT,t.CURRENT_PROGRAM,t.ARRAY_BUFFER_BINDING];T(t,n,(function(t){t.disable(t.CULL_FACE),t.disable(t.DEPTH_TEST),t.disable(t.BLEND),t.disable(t.SCISSOR_TEST),t.disable(t.STENCIL_TEST),t.colorMask(!0,!0,!0,!0),t.viewport(0,0,t.drawingBufferWidth,t.drawingBufferHeight),e.renderNoState()}))},N.prototype.renderNoState=function(){var t,e,n,r,i,a,o,s,c,l,u=this.gl;u.useProgram(this.program),u.bindBuffer(u.ARRAY_BUFFER,this.vertexBuffer),u.enableVertexAttribArray(this.attribs.position),u.vertexAttribPointer(this.attribs.position,2,u.FLOAT,!1,8,0),u.uniform4f(this.uniforms.color,1,1,1,1),t=this.projMat,e=0,n=u.drawingBufferWidth,r=0,i=u.drawingBufferHeight,s=1/(e-n),c=1/(r-i),l=1/((a=.1)-(o=1024)),t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+n)*s,t[13]=(i+r)*c,t[14]=(o+a)*l,t[15]=1,u.uniformMatrix4fv(this.uniforms.projectionMat,!1,this.projMat),u.drawArrays(u.TRIANGLE_STRIP,0,4),u.drawArrays(u.TRIANGLE_STRIP,this.gearOffset,this.gearVertexCount),u.drawArrays(u.TRIANGLE_STRIP,this.arrowOffset,this.arrowVertexCount)},B.prototype.distortInverse=function(t){for(var e=0,n=1,r=t-this.distort(e);Math.abs(n-e)>1e-4;){var i=t-this.distort(n),a=n-i*((n-e)/(i-r));e=n,n=a,r=i}return n},B.prototype.distort=function(t){for(var e=t*t,n=0,r=0;r=1)return this.w=a,this.x=n,this.y=r,this.z=i,this;var s=Math.acos(o),c=Math.sqrt(1-o*o);if(Math.abs(c)<.001)return this.w=.5*(a+this.w),this.x=.5*(n+this.x),this.y=.5*(r+this.y),this.z=.5*(i+this.z),this;var l=Math.sin((1-e)*s)/c,u=Math.sin(e*s)/c;return this.w=a*l+this.w*u,this.x=n*l+this.x*u,this.y=r*l+this.y*u,this.z=i*l+this.z*u,this},setFromUnitVectors:function(t,e){return void 0===G&&(G=new U),(H=t.dot(e)+1)<1e-6?(H=0,Math.abs(t.x)>Math.abs(t.z)?G.set(-t.y,t.x,0):G.set(0,-t.z,t.y)):G.crossVectors(t,e),this.x=G.x,this.y=G.y,this.z=G.z,this.w=H,this.normalize(),this}};var j=new k({widthMeters:.11,heightMeters:.062,bevelMeters:.004}),W=new k({widthMeters:.1038,heightMeters:.0584,bevelMeters:.004}),q={CardboardV1:new Y({id:"CardboardV1",label:"Cardboard I/O 2014",fov:40,interLensDistance:.06,baselineLensDistance:.035,screenLensDistance:.042,distortionCoefficients:[.441,.156],inverseCoefficients:[-.4410035,.42756155,-.4804439,.5460139,-.58821183,.5733938,-.48303202,.33299083,-.17573841,.0651772,-.01488963,.001559834]}),CardboardV2:new Y({id:"CardboardV2",label:"Cardboard I/O 2015",fov:60,interLensDistance:.064,baselineLensDistance:.035,screenLensDistance:.039,distortionCoefficients:[.34,.55],inverseCoefficients:[-.33836704,-.18162185,.862655,-1.2462051,1.0560602,-.58208317,.21609078,-.05444823,.009177956,-.0009904169,6183535e-11,-16981803e-13]})};function X(t,e){this.viewer=q.CardboardV2,this.updateDeviceParams(t),this.distortion=new B(this.viewer.distortionCoefficients);for(var n=0;n=200&&n.status<=299?(r.dpdb=JSON.parse(n.response),r.recalculateDeviceParams_()):console.error("Error loading online DPDB!")})),n.send()}}function Q(t){this.xdpi=t.xdpi,this.ydpi=t.ydpi,this.bevelMm=t.bevelMm}function K(t,e){this.set(t,e)}function $(t,e){this.kFilter=t,this.isDebug=e,this.currentAccelMeasurement=new K,this.currentGyroMeasurement=new K,this.previousGyroMeasurement=new K,c()?this.filterQ=new V(-1,0,0,1):this.filterQ=new V(1,0,0,1),this.previousFilterQ=new V,this.previousFilterQ.copy(this.filterQ),this.accelQ=new V,this.isOrientationInitialized=!1,this.estimatedGravity=new U,this.measuredGravity=new U,this.gyroIntegralQ=new V}function tt(t,e){this.predictionTimeS=t,this.isDebug=e,this.previousQ=new V,this.previousTimestampS=null,this.deltaQ=new V,this.outQ=new V}function et(t,e,n,r){this.yawOnly=n,this.accelerometer=new U,this.gyroscope=new U,this.filter=new $(t,r),this.posePredictor=new tt(e,r),this.isFirefoxAndroid=u(),this.isIOS=c();var i=h();this.isDeviceMotionInRadians=!this.isIOS&&i&&i<66,this.isWithoutDeviceMotion=d(),this.filterToWorldQ=new V,c()?this.filterToWorldQ.setFromAxisAngle(new U(1,0,0),Math.PI/2):this.filterToWorldQ.setFromAxisAngle(new U(1,0,0),-Math.PI/2),this.inverseWorldToScreenQ=new V,this.worldToScreenQ=new V,this.originalPoseAdjustQ=new V,this.originalPoseAdjustQ.setFromAxisAngle(new U(0,0,1),-window.orientation*Math.PI/180),this.setScreenTransform_(),f()&&this.filterToWorldQ.multiply(this.inverseWorldToScreenQ),this.resetQ=new V,this.orientationOut_=new Float32Array(4),this.start()}J.prototype.getDeviceParams=function(){return this.deviceParams},J.prototype.recalculateDeviceParams_=function(){var t=this.calcDeviceParams_();t?(this.deviceParams=t,this.onDeviceParamsUpdated&&this.onDeviceParamsUpdated(this.deviceParams)):console.error("Failed to recalculate device parameters.")},J.prototype.calcDeviceParams_=function(){var t=this.dpdb;if(!t)return console.error("DPDB not available."),null;if(1!=t.format)return console.error("DPDB has unexpected format version."),null;if(!t.devices||!t.devices.length)return console.error("DPDB does not have a devices section."),null;var e=navigator.userAgent||navigator.vendor||window.opera,n=m(),r=v();if(!t.devices)return console.error("DPDB has no devices section."),null;for(var i=0;i1||this.run_(),this.previousGyroMeasurement.copy(this.currentGyroMeasurement)},$.prototype.run_=function(){if(!this.isOrientationInitialized)return this.accelQ=this.accelToQuaternion_(this.currentAccelMeasurement.sample),this.previousFilterQ.copy(this.accelQ),void(this.isOrientationInitialized=!0);var t=this.currentGyroMeasurement.timestampS-this.previousGyroMeasurement.timestampS,e=this.gyroToQuaternionDelta_(this.currentGyroMeasurement.sample,t);this.gyroIntegralQ.multiply(e),this.filterQ.copy(this.previousFilterQ),this.filterQ.multiply(e);var n=new V;n.copy(this.filterQ),n.inverse(),this.estimatedGravity.set(0,0,-1),this.estimatedGravity.applyQuaternion(n),this.estimatedGravity.normalize(),this.measuredGravity.copy(this.currentAccelMeasurement.sample),this.measuredGravity.normalize();var r,i=new V;i.setFromUnitVectors(this.estimatedGravity,this.measuredGravity),i.inverse(),this.isDebug&&console.log("Delta: %d deg, G_est: (%s, %s, %s), G_meas: (%s, %s, %s)",z*((r=i).w>1?(console.warn("getQuaternionAngle: w > 1"),0):2*Math.acos(r.w)),this.estimatedGravity.x.toFixed(1),this.estimatedGravity.y.toFixed(1),this.estimatedGravity.z.toFixed(1),this.measuredGravity.x.toFixed(1),this.measuredGravity.y.toFixed(1),this.measuredGravity.z.toFixed(1));var a=new V;a.copy(this.filterQ),a.multiply(i),this.filterQ.slerp(a,1-this.kFilter),this.previousFilterQ.copy(this.filterQ)},$.prototype.getOrientation=function(){return this.filterQ},$.prototype.accelToQuaternion_=function(t){var e=new U;e.copy(t),e.normalize();var n=new V;return n.setFromUnitVectors(new U(0,0,-1),e),n.inverse(),n},$.prototype.gyroToQuaternionDelta_=function(t,e){var n=new V,r=new U;return r.copy(t),r.normalize(),n.setFromAxisAngle(r,t.length()*e),n},tt.prototype.getPrediction=function(t,e,n){if(!this.previousTimestampS)return this.previousQ.copy(t),this.previousTimestampS=n,t;var r=new U;r.copy(e),r.normalize();var i=e.length();if(i<20*F)return this.isDebug&&console.log("Moving slowly, at %s deg/s: no prediction",(z*i).toFixed(1)),this.outQ.copy(t),this.previousQ.copy(t),this.outQ;var a=i*this.predictionTimeS;return this.deltaQ.setFromAxisAngle(r,a),this.outQ.copy(this.previousQ),this.outQ.multiply(this.deltaQ),this.previousQ.copy(t),this.previousTimestampS=n,this.outQ},et.prototype.getPosition=function(){return null},et.prototype.getOrientation=function(){var t=void 0;if(this.isWithoutDeviceMotion&&this._deviceOrientationQ)return this.deviceOrientationFixQ=this.deviceOrientationFixQ||(n=(new V).setFromAxisAngle(new U(0,0,-1),0),r=new V,-90===window.orientation?r.setFromAxisAngle(new U(0,1,0),Math.PI/-2):r.setFromAxisAngle(new U(0,1,0),Math.PI/2),n.multiply(r)),this.deviceOrientationFilterToWorldQ=this.deviceOrientationFilterToWorldQ||((e=new V).setFromAxisAngle(new U(1,0,0),-Math.PI/2),e),t=this._deviceOrientationQ,(i=new V).copy(t),i.multiply(this.deviceOrientationFilterToWorldQ),i.multiply(this.resetQ),i.multiply(this.worldToScreenQ),i.multiplyQuaternions(this.deviceOrientationFixQ,i),this.yawOnly&&(i.x=0,i.z=0,i.normalize()),this.orientationOut_[0]=i.x,this.orientationOut_[1]=i.y,this.orientationOut_[2]=i.z,this.orientationOut_[3]=i.w,this.orientationOut_;var e,n,r,i,a=this.filter.getOrientation();return t=this.posePredictor.getPrediction(a,this.gyroscope,this.previousTimestampS),(i=new V).copy(this.filterToWorldQ),i.multiply(this.resetQ),i.multiply(t),i.multiply(this.worldToScreenQ),this.yawOnly&&(i.x=0,i.z=0,i.normalize()),this.orientationOut_[0]=i.x,this.orientationOut_[1]=i.y,this.orientationOut_[2]=i.z,this.orientationOut_[3]=i.w,this.orientationOut_},et.prototype.resetPose=function(){this.resetQ.copy(this.filter.getOrientation()),this.resetQ.x=0,this.resetQ.y=0,this.resetQ.z*=-1,this.resetQ.normalize(),f()&&this.resetQ.multiply(this.inverseWorldToScreenQ),this.resetQ.multiply(this.originalPoseAdjustQ)},et.prototype.onDeviceOrientation_=function(t){this._deviceOrientationQ=this._deviceOrientationQ||new V;var e=t.alpha,n=t.beta,r=t.gamma;e=(e||0)*Math.PI/180,n=(n||0)*Math.PI/180,r=(r||0)*Math.PI/180,this._deviceOrientationQ.setFromEulerYXZ(n,e,-r)},et.prototype.onDeviceMotion_=function(t){this.updateDeviceMotion_(t)},et.prototype.updateDeviceMotion_=function(t){var e=t.accelerationIncludingGravity,n=t.rotationRate,r=t.timeStamp/1e3,i=r-this.previousTimestampS;return i<0?(E("fusion-pose-sensor:invalid:non-monotonic","Invalid timestamps detected: non-monotonic timestamp from devicemotion"),void(this.previousTimestampS=r)):i<=.001||i>1?(E("fusion-pose-sensor:invalid:outside-threshold","Invalid timestamps detected: Timestamp from devicemotion outside expected range."),void(this.previousTimestampS=r)):(this.accelerometer.set(-e.x,-e.y,-e.z),p()?this.gyroscope.set(-n.beta,n.alpha,n.gamma):this.gyroscope.set(n.alpha,n.beta,n.gamma),this.isDeviceMotionInRadians||this.gyroscope.multiplyScalar(Math.PI/180),this.filter.addAccelMeasurement(this.accelerometer,r),this.filter.addGyroMeasurement(this.gyroscope,r),void(this.previousTimestampS=r))},et.prototype.onOrientationChange_=function(t){this.setScreenTransform_()},et.prototype.onMessage_=function(t){var e=t.data;e&&e.type&&"devicemotion"===e.type.toLowerCase()&&this.updateDeviceMotion_(e.deviceMotionEvent)},et.prototype.setScreenTransform_=function(){switch(this.worldToScreenQ.set(0,0,0,1),window.orientation){case 0:break;case 90:this.worldToScreenQ.setFromAxisAngle(new U(0,0,1),-Math.PI/2);break;case-90:this.worldToScreenQ.setFromAxisAngle(new U(0,0,1),Math.PI/2)}this.inverseWorldToScreenQ.copy(this.worldToScreenQ),this.inverseWorldToScreenQ.inverse()},et.prototype.start=function(){var t,e,n;this.onDeviceMotionCallback_=this.onDeviceMotion_.bind(this),this.onOrientationChangeCallback_=this.onOrientationChange_.bind(this),this.onMessageCallback_=this.onMessage_.bind(this),this.onDeviceOrientationCallback_=this.onDeviceOrientation_.bind(this),c()&&(t=window.self!==window.top,e=S(document.referrer),n=S(window.location.href),t&&e!==n)&&window.addEventListener("message",this.onMessageCallback_),window.addEventListener("orientationchange",this.onOrientationChangeCallback_),this.isWithoutDeviceMotion?window.addEventListener("deviceorientation",this.onDeviceOrientationCallback_):window.addEventListener("devicemotion",this.onDeviceMotionCallback_)},et.prototype.stop=function(){window.removeEventListener("devicemotion",this.onDeviceMotionCallback_),window.removeEventListener("deviceorientation",this.onDeviceOrientationCallback_),window.removeEventListener("orientationchange",this.onOrientationChangeCallback_),window.removeEventListener("message",this.onMessageCallback_)};var nt=new U(1,0,0),rt=new U(0,0,1),it=new V;it.setFromAxisAngle(nt,-Math.PI/2),it.multiply((new V).setFromAxisAngle(rt,Math.PI/2));var at=function(){function t(e){i(this,t),this.config=e,this.sensor=null,this.fusionSensor=null,this._out=new Float32Array(4),this.api=null,this.errors=[],this._sensorQ=new V,this._outQ=new V,this._onSensorRead=this._onSensorRead.bind(this),this._onSensorError=this._onSensorError.bind(this),this.init()}return a(t,[{key:"init",value:function(){var t=null;try{(t=new RelativeOrientationSensor({frequency:60,referenceFrame:"screen"})).addEventListener("error",this._onSensorError)}catch(t){this.errors.push(t),"SecurityError"===t.name?(console.error("Cannot construct sensors due to the Feature Policy"),console.warn('Attempting to fall back using "devicemotion"; however this will fail in the future without correct permissions.'),this.useDeviceMotion()):"ReferenceError"===t.name?this.useDeviceMotion():console.error(t)}t&&(this.api="sensor",this.sensor=t,this.sensor.addEventListener("reading",this._onSensorRead),this.sensor.start())}},{key:"useDeviceMotion",value:function(){this.api="devicemotion",this.fusionSensor=new et(this.config.K_FILTER,this.config.PREDICTION_TIME_S,this.config.YAW_ONLY,this.config.DEBUG),this.sensor&&(this.sensor.removeEventListener("reading",this._onSensorRead),this.sensor.removeEventListener("error",this._onSensorError),this.sensor=null)}},{key:"getOrientation",value:function(){if(this.fusionSensor)return this.fusionSensor.getOrientation();if(!this.sensor||!this.sensor.quaternion)return this._out[0]=this._out[1]=this._out[2]=0,this._out[3]=1,this._out;var t=this.sensor.quaternion;this._sensorQ.set(t[0],t[1],t[2],t[3]);var e=this._outQ;return e.copy(it),e.multiply(this._sensorQ),this.config.YAW_ONLY&&(e.x=e.z=0,e.normalize()),this._out[0]=e.x,this._out[1]=e.y,this._out[2]=e.z,this._out[3]=e.w,this._out}},{key:"_onSensorError",value:function(t){this.errors.push(t.error),"NotAllowedError"===t.error.name?console.error("Permission to access sensor was denied"):"NotReadableError"===t.error.name?console.error("Sensor could not be read"):console.error(t.error),this.useDeviceMotion()}},{key:"_onSensorRead",value:function(){}}]),t}();function ot(){this.loadIcon_();var t=document.createElement("div");(a=t.style).position="fixed",a.top=0,a.right=0,a.bottom=0,a.left=0,a.backgroundColor="gray",a.fontFamily="sans-serif",a.zIndex=1e6;var e=document.createElement("img");e.src=this.icon,(a=e.style).marginLeft="25%",a.marginTop="25%",a.width="50%",t.appendChild(e);var n=document.createElement("div");(a=n.style).textAlign="center",a.fontSize="16px",a.lineHeight="24px",a.margin="24px 25%",a.width="50%",n.innerHTML="Place your phone into your Cardboard viewer.",t.appendChild(n);var r=document.createElement("div");(a=r.style).backgroundColor="#CFD8DC",a.position="fixed",a.bottom=0,a.width="100%",a.height="48px",a.padding="14px 24px",a.boxSizing="border-box",a.color="#656A6B",t.appendChild(r);var i=document.createElement("div");i.style.float="left",i.innerHTML="No Cardboard viewer?";var a,o=document.createElement("a");o.href="https://www.google.com/get/cardboard/get-cardboard/",o.innerHTML="get one",o.target="_blank",(a=o.style).float="right",a.fontWeight=600,a.textTransform="uppercase",a.borderLeft="1px solid gray",a.paddingLeft="24px",a.textDecoration="none",a.color="#656A6B",r.appendChild(i),r.appendChild(o),this.overlay=t,this.text=n,this.hide()}ot.prototype.show=function(t){t||this.overlay.parentElement?t&&(this.overlay.parentElement&&this.overlay.parentElement!=t&&this.overlay.parentElement.removeChild(this.overlay),t.appendChild(this.overlay)):document.body.appendChild(this.overlay),this.overlay.style.display="block";var e=this.overlay.querySelector("img").style;f()?(e.width="20%",e.marginLeft="40%",e.marginTop="3%"):(e.width="50%",e.marginLeft="25%",e.marginTop="25%")},ot.prototype.hide=function(){this.overlay.style.display="none"},ot.prototype.showTemporarily=function(t,e){this.show(e),this.timer=setTimeout(this.hide.bind(this),t)},ot.prototype.disableShowTemporarily=function(){clearTimeout(this.timer)},ot.prototype.update=function(){this.disableShowTemporarily(),!f()&&b()?this.show():this.hide()},ot.prototype.loadIcon_=function(){this.icon="data:image/svg+xml,"+encodeURIComponent("")};var st="CardboardV1",ct="WEBVR_CARDBOARD_VIEWER";function lt(t){try{this.selectedKey=localStorage.getItem(ct)}catch(t){console.error("Failed to load viewer profile: %s",t)}this.selectedKey||(this.selectedKey=t||st),this.dialog=this.createDialog_(X.Viewers),this.root=null,this.onChangeCallbacks_=[]}lt.prototype.show=function(t){this.root=t,t.appendChild(this.dialog),this.dialog.querySelector("#"+this.selectedKey).checked=!0,this.dialog.style.display="block"},lt.prototype.hide=function(){this.root&&this.root.contains(this.dialog)&&this.root.removeChild(this.dialog),this.dialog.style.display="none"},lt.prototype.getCurrentViewer=function(){return X.Viewers[this.selectedKey]},lt.prototype.getSelectedKey_=function(){var t=this.dialog.querySelector("input[name=field]:checked");return t?t.id:null},lt.prototype.onChange=function(t){this.onChangeCallbacks_.push(t)},lt.prototype.fireOnChange_=function(t){for(var e=0;e.5&&(this.noSleepVideo.currentTime=Math.random())}.bind(this)))}return r(t,[{key:"enable",value:function(){a?(this.disable(),this.noSleepTimer=window.setInterval((function(){window.location.href="/",window.setTimeout(window.stop,0)}),15e3)):this.noSleepVideo.play()}},{key:"disable",value:function(){a?this.noSleepTimer&&(window.clearInterval(this.noSleepTimer),this.noSleepTimer=null):this.noSleepVideo.pause()}}]),t}();t.exports=o},function(t,e,n){t.exports="data:video/mp4;base64,AAAAIGZ0eXBtcDQyAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAACKBtZGF0AAAC8wYF///v3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE0MiByMjQ3OSBkZDc5YTYxIC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAxNCAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTEgcmVmPTEgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MToweDExMSBtZT1oZXggc3VibWU9MiBwc3k9MSBwc3lfcmQ9MS4wMDowLjAwIG1peGVkX3JlZj0wIG1lX3JhbmdlPTE2IGNocm9tYV9tZT0xIHRyZWxsaXM9MCA4eDhkY3Q9MCBjcW09MCBkZWFkem9uZT0yMSwxMSBmYXN0X3Bza2lwPTEgY2hyb21hX3FwX29mZnNldD0wIHRocmVhZHM9NiBsb29rYWhlYWRfdGhyZWFkcz0xIHNsaWNlZF90aHJlYWRzPTAgbnI9MCBkZWNpbWF0ZT0xIGludGVybGFjZWQ9MCBibHVyYXlfY29tcGF0PTAgY29uc3RyYWluZWRfaW50cmE9MCBiZnJhbWVzPTMgYl9weXJhbWlkPTIgYl9hZGFwdD0xIGJfYmlhcz0wIGRpcmVjdD0xIHdlaWdodGI9MSBvcGVuX2dvcD0wIHdlaWdodHA9MSBrZXlpbnQ9MzAwIGtleWludF9taW49MzAgc2NlbmVjdXQ9NDAgaW50cmFfcmVmcmVzaD0wIHJjX2xvb2thaGVhZD0xMCByYz1jcmYgbWJ0cmVlPTEgY3JmPTIwLjAgcWNvbXA9MC42MCBxcG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IHZidl9tYXhyYXRlPTIwMDAwIHZidl9idWZzaXplPTI1MDAwIGNyZl9tYXg9MC4wIG5hbF9ocmQ9bm9uZSBmaWxsZXI9MCBpcF9yYXRpbz0xLjQwIGFxPTE6MS4wMACAAAAAOWWIhAA3//p+C7v8tDDSTjf97w55i3SbRPO4ZY+hkjD5hbkAkL3zpJ6h/LR1CAABzgB1kqqzUorlhQAAAAxBmiQYhn/+qZYADLgAAAAJQZ5CQhX/AAj5IQADQGgcIQADQGgcAAAACQGeYUQn/wALKCEAA0BoHAAAAAkBnmNEJ/8ACykhAANAaBwhAANAaBwAAAANQZpoNExDP/6plgAMuSEAA0BoHAAAAAtBnoZFESwr/wAI+SEAA0BoHCEAA0BoHAAAAAkBnqVEJ/8ACykhAANAaBwAAAAJAZ6nRCf/AAsoIQADQGgcIQADQGgcAAAADUGarDRMQz/+qZYADLghAANAaBwAAAALQZ7KRRUsK/8ACPkhAANAaBwAAAAJAZ7pRCf/AAsoIQADQGgcIQADQGgcAAAACQGe60Qn/wALKCEAA0BoHAAAAA1BmvA0TEM//qmWAAy5IQADQGgcIQADQGgcAAAAC0GfDkUVLCv/AAj5IQADQGgcAAAACQGfLUQn/wALKSEAA0BoHCEAA0BoHAAAAAkBny9EJ/8ACyghAANAaBwAAAANQZs0NExDP/6plgAMuCEAA0BoHAAAAAtBn1JFFSwr/wAI+SEAA0BoHCEAA0BoHAAAAAkBn3FEJ/8ACyghAANAaBwAAAAJAZ9zRCf/AAsoIQADQGgcIQADQGgcAAAADUGbeDRMQz/+qZYADLkhAANAaBwAAAALQZ+WRRUsK/8ACPghAANAaBwhAANAaBwAAAAJAZ+1RCf/AAspIQADQGgcAAAACQGft0Qn/wALKSEAA0BoHCEAA0BoHAAAAA1Bm7w0TEM//qmWAAy4IQADQGgcAAAAC0Gf2kUVLCv/AAj5IQADQGgcAAAACQGf+UQn/wALKCEAA0BoHCEAA0BoHAAAAAkBn/tEJ/8ACykhAANAaBwAAAANQZvgNExDP/6plgAMuSEAA0BoHCEAA0BoHAAAAAtBnh5FFSwr/wAI+CEAA0BoHAAAAAkBnj1EJ/8ACyghAANAaBwhAANAaBwAAAAJAZ4/RCf/AAspIQADQGgcAAAADUGaJDRMQz/+qZYADLghAANAaBwAAAALQZ5CRRUsK/8ACPkhAANAaBwhAANAaBwAAAAJAZ5hRCf/AAsoIQADQGgcAAAACQGeY0Qn/wALKSEAA0BoHCEAA0BoHAAAAA1Bmmg0TEM//qmWAAy5IQADQGgcAAAAC0GehkUVLCv/AAj5IQADQGgcIQADQGgcAAAACQGepUQn/wALKSEAA0BoHAAAAAkBnqdEJ/8ACyghAANAaBwAAAANQZqsNExDP/6plgAMuCEAA0BoHCEAA0BoHAAAAAtBnspFFSwr/wAI+SEAA0BoHAAAAAkBnulEJ/8ACyghAANAaBwhAANAaBwAAAAJAZ7rRCf/AAsoIQADQGgcAAAADUGa8DRMQz/+qZYADLkhAANAaBwhAANAaBwAAAALQZ8ORRUsK/8ACPkhAANAaBwAAAAJAZ8tRCf/AAspIQADQGgcIQADQGgcAAAACQGfL0Qn/wALKCEAA0BoHAAAAA1BmzQ0TEM//qmWAAy4IQADQGgcAAAAC0GfUkUVLCv/AAj5IQADQGgcIQADQGgcAAAACQGfcUQn/wALKCEAA0BoHAAAAAkBn3NEJ/8ACyghAANAaBwhAANAaBwAAAANQZt4NExC//6plgAMuSEAA0BoHAAAAAtBn5ZFFSwr/wAI+CEAA0BoHCEAA0BoHAAAAAkBn7VEJ/8ACykhAANAaBwAAAAJAZ+3RCf/AAspIQADQGgcAAAADUGbuzRMQn/+nhAAYsAhAANAaBwhAANAaBwAAAAJQZ/aQhP/AAspIQADQGgcAAAACQGf+UQn/wALKCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHCEAA0BoHAAACiFtb292AAAAbG12aGQAAAAA1YCCX9WAgl8AAAPoAAAH/AABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAGGlvZHMAAAAAEICAgAcAT////v7/AAAF+XRyYWsAAABcdGtoZAAAAAPVgIJf1YCCXwAAAAEAAAAAAAAH0AAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAygAAAMoAAAAAACRlZHRzAAAAHGVsc3QAAAAAAAAAAQAAB9AAABdwAAEAAAAABXFtZGlhAAAAIG1kaGQAAAAA1YCCX9WAgl8AAV+QAAK/IFXEAAAAAAAtaGRscgAAAAAAAAAAdmlkZQAAAAAAAAAAAAAAAFZpZGVvSGFuZGxlcgAAAAUcbWluZgAAABR2bWhkAAAAAQAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAAE3HN0YmwAAACYc3RzZAAAAAAAAAABAAAAiGF2YzEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAygDKAEgAAABIAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY//8AAAAyYXZjQwFNQCj/4QAbZ01AKOyho3ySTUBAQFAAAAMAEAAr8gDxgxlgAQAEaO+G8gAAABhzdHRzAAAAAAAAAAEAAAA8AAALuAAAABRzdHNzAAAAAAAAAAEAAAABAAAB8GN0dHMAAAAAAAAAPAAAAAEAABdwAAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAADqYAAAAAQAAF3AAAAABAAAAAAAAAAEAAAu4AAAAAQAAOpgAAAABAAAXcAAAAAEAAAAAAAAAAQAAC7gAAAABAAA6mAAAAAEAABdwAAAAAQAAAAAAAAABAAALuAAAAAEAAC7gAAAAAQAAF3AAAAABAAAAAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAEEc3RzegAAAAAAAAAAAAAAPAAAAzQAAAAQAAAADQAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAAPAAAADQAAAA0AAAARAAAADwAAAA0AAAANAAAAEQAAAA8AAAANAAAADQAAABEAAAANAAAADQAAAQBzdGNvAAAAAAAAADwAAAAwAAADZAAAA3QAAAONAAADoAAAA7kAAAPQAAAD6wAAA/4AAAQXAAAELgAABEMAAARcAAAEbwAABIwAAAShAAAEugAABM0AAATkAAAE/wAABRIAAAUrAAAFQgAABV0AAAVwAAAFiQAABaAAAAW1AAAFzgAABeEAAAX+AAAGEwAABiwAAAY/AAAGVgAABnEAAAaEAAAGnQAABrQAAAbPAAAG4gAABvUAAAcSAAAHJwAAB0AAAAdTAAAHcAAAB4UAAAeeAAAHsQAAB8gAAAfjAAAH9gAACA8AAAgmAAAIQQAACFQAAAhnAAAIhAAACJcAAAMsdHJhawAAAFx0a2hkAAAAA9WAgl/VgIJfAAAAAgAAAAAAAAf8AAAAAAAAAAAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAACsm1kaWEAAAAgbWRoZAAAAADVgIJf1YCCXwAArEQAAWAAVcQAAAAAACdoZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU3RlcmVvAAAAAmNtaW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAidzdGJsAAAAZ3N0c2QAAAAAAAAAAQAAAFdtcDRhAAAAAAAAAAEAAAAAAAAAAAACABAAAAAArEQAAAAAADNlc2RzAAAAAAOAgIAiAAIABICAgBRAFQAAAAADDUAAAAAABYCAgAISEAaAgIABAgAAABhzdHRzAAAAAAAAAAEAAABYAAAEAAAAABxzdHNjAAAAAAAAAAEAAAABAAAAAQAAAAEAAAAUc3RzegAAAAAAAAAGAAAAWAAAAXBzdGNvAAAAAAAAAFgAAAOBAAADhwAAA5oAAAOtAAADswAAA8oAAAPfAAAD5QAAA/gAAAQLAAAEEQAABCgAAAQ9AAAEUAAABFYAAARpAAAEgAAABIYAAASbAAAErgAABLQAAATHAAAE3gAABPMAAAT5AAAFDAAABR8AAAUlAAAFPAAABVEAAAVXAAAFagAABX0AAAWDAAAFmgAABa8AAAXCAAAFyAAABdsAAAXyAAAF+AAABg0AAAYgAAAGJgAABjkAAAZQAAAGZQAABmsAAAZ+AAAGkQAABpcAAAauAAAGwwAABskAAAbcAAAG7wAABwYAAAcMAAAHIQAABzQAAAc6AAAHTQAAB2QAAAdqAAAHfwAAB5IAAAeYAAAHqwAAB8IAAAfXAAAH3QAAB/AAAAgDAAAICQAACCAAAAg1AAAIOwAACE4AAAhhAAAIeAAACH4AAAiRAAAIpAAACKoAAAiwAAAItgAACLwAAAjCAAAAFnVkdGEAAAAObmFtZVN0ZXJlbwAAAHB1ZHRhAAAAaG1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAAO2lsc3QAAAAzqXRvbwAAACtkYXRhAAAAAQAAAABIYW5kQnJha2UgMC4xMC4yIDIwMTUwNjExMDA="}])}))})))&&ut.__esModule&&Object.prototype.hasOwnProperty.call(ut,"default")?ut.default:ut,dt=1e3,pt=[0,0,.5,1],ft=[.5,0,.5,1],mt=window.requestAnimationFrame,vt=window.cancelAnimationFrame;function gt(t){Object.defineProperties(this,{hasPosition:{writable:!1,enumerable:!0,value:t.hasPosition},hasExternalDisplay:{writable:!1,enumerable:!0,value:t.hasExternalDisplay},canPresent:{writable:!1,enumerable:!0,value:t.canPresent},maxLayers:{writable:!1,enumerable:!0,value:t.maxLayers},hasOrientation:{enumerable:!0,get:function(){return A("VRDisplayCapabilities.prototype.hasOrientation","VRDisplay.prototype.getFrameData"),t.hasOrientation}}})}function yt(t){var e=!("wakelock"in(t=t||{}))||t.wakelock;this.isPolyfilled=!0,this.displayId=dt++,this.displayName="",this.depthNear=.01,this.depthFar=1e4,this.isPresenting=!1,Object.defineProperty(this,"isConnected",{get:function(){return A("VRDisplay.prototype.isConnected","VRDisplayCapabilities.prototype.hasExternalDisplay"),!1}}),this.capabilities=new gt({hasPosition:!1,hasOrientation:!1,hasExternalDisplay:!1,canPresent:!1,maxLayers:1}),this.stageParameters=null,this.waitingForPresent_=!1,this.layer_=null,this.originalParent_=null,this.fullscreenElement_=null,this.fullscreenWrapper_=null,this.fullscreenElementCachedStyle_=null,this.fullscreenEventTarget_=null,this.fullscreenChangeHandler_=null,this.fullscreenErrorHandler_=null,e&&b()&&(this.wakelock_=new ht)}yt.prototype.getFrameData=function(t){return M(t,this._getPose(),this)},yt.prototype.getPose=function(){return A("VRDisplay.prototype.getPose","VRDisplay.prototype.getFrameData"),this._getPose()},yt.prototype.resetPose=function(){return A("VRDisplay.prototype.resetPose"),this._resetPose()},yt.prototype.getImmediatePose=function(){return A("VRDisplay.prototype.getImmediatePose","VRDisplay.prototype.getFrameData"),this._getPose()},yt.prototype.requestAnimationFrame=function(t){return mt(t)},yt.prototype.cancelAnimationFrame=function(t){return vt(t)},yt.prototype.wrapForFullscreen=function(t){if(c())return t;if(!this.fullscreenWrapper_){this.fullscreenWrapper_=document.createElement("div");var e=["height: "+Math.min(screen.height,screen.width)+"px !important","top: 0 !important","left: 0 !important","right: 0 !important","border: 0","margin: 0","padding: 0","z-index: 999999 !important","position: fixed"];this.fullscreenWrapper_.setAttribute("style",e.join("; ")+";"),this.fullscreenWrapper_.classList.add("webvr-polyfill-fullscreen-wrapper")}if(this.fullscreenElement_==t)return this.fullscreenWrapper_;if(this.fullscreenElement_&&(this.originalParent_?this.originalParent_.appendChild(this.fullscreenElement_):this.fullscreenElement_.parentElement.removeChild(this.fullscreenElement_)),this.fullscreenElement_=t,this.originalParent_=t.parentElement,this.originalParent_||document.body.appendChild(t),!this.fullscreenWrapper_.parentElement){var n=this.fullscreenElement_.parentElement;n.insertBefore(this.fullscreenWrapper_,this.fullscreenElement_),n.removeChild(this.fullscreenElement_)}this.fullscreenWrapper_.insertBefore(this.fullscreenElement_,this.fullscreenWrapper_.firstChild),this.fullscreenElementCachedStyle_=this.fullscreenElement_.getAttribute("style");var r=this;return function(){if(r.fullscreenElement_){var t=["position: absolute","top: 0","left: 0","width: "+Math.max(screen.width,screen.height)+"px","height: "+Math.min(screen.height,screen.width)+"px","border: 0","margin: 0","padding: 0"];r.fullscreenElement_.setAttribute("style",t.join("; ")+";")}}(),this.fullscreenWrapper_},yt.prototype.removeFullscreenWrapper=function(){if(this.fullscreenElement_){var t=this.fullscreenElement_;this.fullscreenElementCachedStyle_?t.setAttribute("style",this.fullscreenElementCachedStyle_):t.removeAttribute("style"),this.fullscreenElement_=null,this.fullscreenElementCachedStyle_=null;var e=this.fullscreenWrapper_.parentElement;return this.fullscreenWrapper_.removeChild(t),this.originalParent_===e?e.insertBefore(t,this.fullscreenWrapper_):this.originalParent_&&this.originalParent_.appendChild(t),e.removeChild(this.fullscreenWrapper_),t}},yt.prototype.requestPresent=function(t){var e=this.isPresenting,n=this;return t instanceof Array||(A("VRDisplay.prototype.requestPresent with non-array argument","an array of VRLayers as the first argument"),t=[t]),new Promise((function(r,i){if(n.capabilities.canPresent)if(0==t.length||t.length>n.capabilities.maxLayers)i(new Error("Invalid number of layers."));else{var a=t[0];if(a.source){var o=a.leftBounds||pt,s=a.rightBounds||ft;if(e){var u=n.layer_;u.source!==a.source&&(u.source=a.source);for(var h=0;h<4;h++)u.leftBounds[h]=o[h],u.rightBounds[h]=s[h];return n.wrapForFullscreen(n.layer_.source),n.updatePresent_(),void r()}if(n.layer_={predistorted:a.predistorted,source:a.source,leftBounds:o.slice(0),rightBounds:s.slice(0)},n.waitingForPresent_=!1,n.layer_&&n.layer_.source){var d=n.wrapForFullscreen(n.layer_.source);n.addFullscreenListeners_(d,(function(){var t=document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement;n.isPresenting=d===t,n.isPresenting?(screen.orientation&&screen.orientation.lock&&screen.orientation.lock("landscape-primary").catch((function(t){console.error("screen.orientation.lock() failed due to",t.message)})),n.waitingForPresent_=!1,n.beginPresent_(),r()):(screen.orientation&&screen.orientation.unlock&&screen.orientation.unlock(),n.removeFullscreenWrapper(),n.disableWakeLock(),n.endPresent_(),n.removeFullscreenListeners_()),n.fireVRDisplayPresentChange_()}),(function(){n.waitingForPresent_&&(n.removeFullscreenWrapper(),n.removeFullscreenListeners_(),n.disableWakeLock(),n.waitingForPresent_=!1,n.isPresenting=!1,i(new Error("Unable to present.")))})),function(t){if(l())return!1;if(t.requestFullscreen)t.requestFullscreen();else if(t.webkitRequestFullscreen)t.webkitRequestFullscreen();else if(t.mozRequestFullScreen)t.mozRequestFullScreen();else{if(!t.msRequestFullscreen)return!1;t.msRequestFullscreen()}return!0}(d)?(n.enableWakeLock(),n.waitingForPresent_=!0):(c()||l())&&(n.enableWakeLock(),n.isPresenting=!0,n.beginPresent_(),n.fireVRDisplayPresentChange_(),r())}n.waitingForPresent_||c()||(g(),i(new Error("Unable to present.")))}else r()}else i(new Error("VRDisplay is not capable of presenting."))}))},yt.prototype.exitPresent=function(){var t=this.isPresenting,e=this;return this.isPresenting=!1,this.layer_=null,this.disableWakeLock(),new Promise((function(n,r){t?(!g()&&c()&&(e.endPresent_(),e.fireVRDisplayPresentChange_()),l()&&(e.removeFullscreenWrapper(),e.removeFullscreenListeners_(),e.endPresent_(),e.fireVRDisplayPresentChange_()),n()):r(new Error("Was not presenting to VRDisplay."))}))},yt.prototype.getLayers=function(){return this.layer_?[this.layer_]:[]},yt.prototype.fireVRDisplayPresentChange_=function(){var t=new CustomEvent("vrdisplaypresentchange",{detail:{display:this}});window.dispatchEvent(t)},yt.prototype.fireVRDisplayConnect_=function(){var t=new CustomEvent("vrdisplayconnect",{detail:{display:this}});window.dispatchEvent(t)},yt.prototype.addFullscreenListeners_=function(t,e,n){this.removeFullscreenListeners_(),this.fullscreenEventTarget_=t,this.fullscreenChangeHandler_=e,this.fullscreenErrorHandler_=n,e&&(document.fullscreenEnabled?t.addEventListener("fullscreenchange",e,!1):document.webkitFullscreenEnabled?t.addEventListener("webkitfullscreenchange",e,!1):document.mozFullScreenEnabled?document.addEventListener("mozfullscreenchange",e,!1):document.msFullscreenEnabled&&t.addEventListener("msfullscreenchange",e,!1)),n&&(document.fullscreenEnabled?t.addEventListener("fullscreenerror",n,!1):document.webkitFullscreenEnabled?t.addEventListener("webkitfullscreenerror",n,!1):document.mozFullScreenEnabled?document.addEventListener("mozfullscreenerror",n,!1):document.msFullscreenEnabled&&t.addEventListener("msfullscreenerror",n,!1))},yt.prototype.removeFullscreenListeners_=function(){if(this.fullscreenEventTarget_){var t=this.fullscreenEventTarget_;if(this.fullscreenChangeHandler_){var e=this.fullscreenChangeHandler_;t.removeEventListener("fullscreenchange",e,!1),t.removeEventListener("webkitfullscreenchange",e,!1),document.removeEventListener("mozfullscreenchange",e,!1),t.removeEventListener("msfullscreenchange",e,!1)}if(this.fullscreenErrorHandler_){var n=this.fullscreenErrorHandler_;t.removeEventListener("fullscreenerror",n,!1),t.removeEventListener("webkitfullscreenerror",n,!1),document.removeEventListener("mozfullscreenerror",n,!1),t.removeEventListener("msfullscreenerror",n,!1)}this.fullscreenEventTarget_=null,this.fullscreenChangeHandler_=null,this.fullscreenErrorHandler_=null}},yt.prototype.enableWakeLock=function(){this.wakelock_&&this.wakelock_.enable()},yt.prototype.disableWakeLock=function(){this.wakelock_&&this.wakelock_.disable()},yt.prototype.beginPresent_=function(){},yt.prototype.endPresent_=function(){},yt.prototype.submitFrame=function(t){},yt.prototype.getEyeParameters=function(t){return null};var xt={ADDITIONAL_VIEWERS:[],DEFAULT_VIEWER:"",MOBILE_WAKE_LOCK:!0,DEBUG:!1,DPDB_URL:"https://dpdb.webvr.rocks/dpdb.json",K_FILTER:.98,PREDICTION_TIME_S:.04,CARDBOARD_UI_DISABLED:!1,ROTATE_INSTRUCTIONS_DISABLED:!1,YAW_ONLY:!1,BUFFER_SCALE:.5,DIRTY_SUBMIT_FRAME_BINDINGS:!1},bt="left",wt="right";function _t(t){var e=w({},xt);t=w(e,t||{}),yt.call(this,{wakelock:t.MOBILE_WAKE_LOCK}),this.config=t,this.displayName="Cardboard VRDisplay",this.capabilities=new gt({hasPosition:!1,hasOrientation:!0,hasExternalDisplay:!1,canPresent:!0,maxLayers:1}),this.stageParameters=null,this.bufferScale_=this.config.BUFFER_SCALE,this.poseSensor_=new at(this.config),this.distorter_=null,this.cardboardUI_=null,this.dpdb_=new J(this.config.DPDB_URL,this.onDeviceParamsUpdated_.bind(this)),this.deviceInfo_=new X(this.dpdb_.getDeviceParams(),t.ADDITIONAL_VIEWERS),this.viewerSelector_=new lt(t.DEFAULT_VIEWER),this.viewerSelector_.onChange(this.onViewerChanged_.bind(this)),this.deviceInfo_.setViewer(this.viewerSelector_.getCurrentViewer()),this.config.ROTATE_INSTRUCTIONS_DISABLED||(this.rotateInstructions_=new ot),c()&&window.addEventListener("resize",this.onResize_.bind(this))}return _t.prototype=Object.create(yt.prototype),_t.prototype._getPose=function(){return{position:null,orientation:this.poseSensor_.getOrientation(),linearVelocity:null,linearAcceleration:null,angularVelocity:null,angularAcceleration:null}},_t.prototype._resetPose=function(){this.poseSensor_.resetPose&&this.poseSensor_.resetPose()},_t.prototype._getFieldOfView=function(t){var e;if(t==bt)e=this.deviceInfo_.getFieldOfViewLeftEye();else{if(t!=wt)return console.error("Invalid eye provided: %s",t),null;e=this.deviceInfo_.getFieldOfViewRightEye()}return e},_t.prototype._getEyeOffset=function(t){var e;if(t==bt)e=[.5*-this.deviceInfo_.viewer.interLensDistance,0,0];else{if(t!=wt)return console.error("Invalid eye provided: %s",t),null;e=[.5*this.deviceInfo_.viewer.interLensDistance,0,0]}return e},_t.prototype.getEyeParameters=function(t){var e=this._getEyeOffset(t),n=this._getFieldOfView(t),r={offset:e,renderWidth:.5*this.deviceInfo_.device.width*this.bufferScale_,renderHeight:this.deviceInfo_.device.height*this.bufferScale_};return Object.defineProperty(r,"fieldOfView",{enumerable:!0,get:function(){return A("VRFieldOfView","VRFrameData's projection matrices"),n}}),r},_t.prototype.onDeviceParamsUpdated_=function(t){this.config.DEBUG&&console.log("DPDB reported that device params were updated."),this.deviceInfo_.updateDeviceParams(t),this.distorter_&&this.distorter_.updateDeviceInfo(this.deviceInfo_)},_t.prototype.updateBounds_=function(){this.layer_&&this.distorter_&&(this.layer_.leftBounds||this.layer_.rightBounds)&&this.distorter_.setTextureBounds(this.layer_.leftBounds,this.layer_.rightBounds)},_t.prototype.beginPresent_=function(){var t=this.layer_.source.getContext("webgl");t||(t=this.layer_.source.getContext("experimental-webgl")),t||(t=this.layer_.source.getContext("webgl2")),t&&(this.layer_.predistorted?this.config.CARDBOARD_UI_DISABLED||(t.canvas.width=m()*this.bufferScale_,t.canvas.height=v()*this.bufferScale_,this.cardboardUI_=new N(t)):(this.config.CARDBOARD_UI_DISABLED||(this.cardboardUI_=new N(t)),this.distorter_=new P(t,this.cardboardUI_,this.config.BUFFER_SCALE,this.config.DIRTY_SUBMIT_FRAME_BINDINGS),this.distorter_.updateDeviceInfo(this.deviceInfo_)),this.cardboardUI_&&this.cardboardUI_.listen(function(t){this.viewerSelector_.show(this.layer_.source.parentElement),t.stopPropagation(),t.preventDefault()}.bind(this),function(t){this.exitPresent(),t.stopPropagation(),t.preventDefault()}.bind(this)),this.rotateInstructions_&&(f()&&b()?this.rotateInstructions_.showTemporarily(3e3,this.layer_.source.parentElement):this.rotateInstructions_.update()),this.orientationHandler=this.onOrientationChange_.bind(this),window.addEventListener("orientationchange",this.orientationHandler),this.vrdisplaypresentchangeHandler=this.updateBounds_.bind(this),window.addEventListener("vrdisplaypresentchange",this.vrdisplaypresentchangeHandler),this.fireVRDisplayDeviceParamsChange_())},_t.prototype.endPresent_=function(){this.distorter_&&(this.distorter_.destroy(),this.distorter_=null),this.cardboardUI_&&(this.cardboardUI_.destroy(),this.cardboardUI_=null),this.rotateInstructions_&&this.rotateInstructions_.hide(),this.viewerSelector_.hide(),window.removeEventListener("orientationchange",this.orientationHandler),window.removeEventListener("vrdisplaypresentchange",this.vrdisplaypresentchangeHandler)},_t.prototype.updatePresent_=function(){this.endPresent_(),this.beginPresent_()},_t.prototype.submitFrame=function(t){if(this.distorter_)this.updateBounds_(),this.distorter_.submitFrame();else if(this.cardboardUI_&&this.layer_){var e=this.layer_.source.getContext("webgl");e||(e=this.layer_.source.getContext("experimental-webgl")),e||(e=this.layer_.source.getContext("webgl2"));var n=e.canvas;n.width==this.lastWidth&&n.height==this.lastHeight||this.cardboardUI_.onResize(),this.lastWidth=n.width,this.lastHeight=n.height,this.cardboardUI_.render()}},_t.prototype.onOrientationChange_=function(t){this.viewerSelector_.hide(),this.rotateInstructions_&&this.rotateInstructions_.update(),this.onResize_()},_t.prototype.onResize_=function(t){if(this.layer_){var e=this.layer_.source.getContext("webgl");e||(e=this.layer_.source.getContext("experimental-webgl")),e||(e=this.layer_.source.getContext("webgl2")),e.canvas.setAttribute("style",["position: absolute","top: 0","left: 0","width: 100vw","height: 100vh","border: 0","margin: 0","padding: 0px","box-sizing: content-box"].join("; ")+";"),_(e.canvas)}},_t.prototype.onViewerChanged_=function(t){this.deviceInfo_.setViewer(t),this.distorter_&&this.distorter_.updateDeviceInfo(this.deviceInfo_),this.fireVRDisplayDeviceParamsChange_()},_t.prototype.fireVRDisplayDeviceParamsChange_=function(){var t=new CustomEvent("vrdisplaydeviceparamschange",{detail:{vrdisplay:this,deviceInfo:this.deviceInfo_}});window.dispatchEvent(t)},_t.VRFrameData=function(){this.leftProjectionMatrix=new Float32Array(16),this.leftViewMatrix=new Float32Array(16),this.rightProjectionMatrix=new Float32Array(16),this.rightViewMatrix=new Float32Array(16),this.pose=null},_t.VRDisplay=yt,_t}()})),s=(t=o)&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t,c={ADDITIONAL_VIEWERS:[],DEFAULT_VIEWER:"",PROVIDE_MOBILE_VRDISPLAY:!0,MOBILE_WAKE_LOCK:!0,DEBUG:!1,DPDB_URL:"https://dpdb.webvr.rocks/dpdb.json",K_FILTER:.98,PREDICTION_TIME_S:.04,CARDBOARD_UI_DISABLED:!1,ROTATE_INSTRUCTIONS_DISABLED:!1,YAW_ONLY:!1,BUFFER_SCALE:.5,DIRTY_SUBMIT_FRAME_BINDINGS:!1};function l(t){this.config=a(a({},c),t),this.polyfillDisplays=[],this.enabled=!1,this.hasNative="getVRDisplays"in navigator,this.native={},this.native.getVRDisplays=navigator.getVRDisplays,this.native.VRFrameData=window.VRFrameData,this.native.VRDisplay=window.VRDisplay,(!this.hasNative||this.config.PROVIDE_MOBILE_VRDISPLAY&&r())&&(this.enable(),this.getVRDisplays().then((function(t){t&&t[0]&&t[0].fireVRDisplayConnect_&&t[0].fireVRDisplayConnect_()})))}l.prototype.getPolyfillDisplays=function(){if(this._polyfillDisplaysPopulated)return this.polyfillDisplays;if(r()){var t=new s({ADDITIONAL_VIEWERS:this.config.ADDITIONAL_VIEWERS,DEFAULT_VIEWER:this.config.DEFAULT_VIEWER,MOBILE_WAKE_LOCK:this.config.MOBILE_WAKE_LOCK,DEBUG:this.config.DEBUG,DPDB_URL:this.config.DPDB_URL,CARDBOARD_UI_DISABLED:this.config.CARDBOARD_UI_DISABLED,K_FILTER:this.config.K_FILTER,PREDICTION_TIME_S:this.config.PREDICTION_TIME_S,ROTATE_INSTRUCTIONS_DISABLED:this.config.ROTATE_INSTRUCTIONS_DISABLED,YAW_ONLY:this.config.YAW_ONLY,BUFFER_SCALE:this.config.BUFFER_SCALE,DIRTY_SUBMIT_FRAME_BINDINGS:this.config.DIRTY_SUBMIT_FRAME_BINDINGS});this.polyfillDisplays.push(t)}return this._polyfillDisplaysPopulated=!0,this.polyfillDisplays},l.prototype.enable=function(){if(this.enabled=!0,this.hasNative&&this.native.VRFrameData){var t=this.native.VRFrameData,e=new this.native.VRFrameData,n=this.native.VRDisplay.prototype.getFrameData;window.VRDisplay.prototype.getFrameData=function(r){r instanceof t?n.call(this,r):(n.call(this,e),r.pose=e.pose,i(e.leftProjectionMatrix,r.leftProjectionMatrix),i(e.rightProjectionMatrix,r.rightProjectionMatrix),i(e.leftViewMatrix,r.leftViewMatrix),i(e.rightViewMatrix,r.rightViewMatrix))}}navigator.getVRDisplays=this.getVRDisplays.bind(this),window.VRDisplay=s.VRDisplay,window.VRFrameData=s.VRFrameData},l.prototype.getVRDisplays=function(){var t=this;return this.config,this.hasNative?this.native.getVRDisplays.call(navigator).then((function(e){return e.length>0?e:t.getPolyfillDisplays()})):Promise.resolve(this.getPolyfillDisplays())},l.version="0.10.10",l.VRFrameData=s.VRFrameData,l.VRDisplay=s.VRDisplay;var u=Object.freeze({default:l}),h=u&&l||u;return void 0!==n&&n.window&&(n.document||(n.document=n.window.document),n.navigator||(n.navigator=n.window.navigator)),h},t.exports=n()}).call(this,n(12))},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var r=n(0);function i(t,e){for(var n=0;n0?i.vrDisplay=t[0]:n&&n("VR input not available.")})).catch((function(){console.warn("VRControls: Unable to get VR Displays")})),this.scale=1,this.standing=!1,this.userHeight=1.6}var e,n,a;return e=t,(n=[{key:"getVRDisplay",value:function(){return this.vrDisplay}},{key:"setVRDisplay",value:function(t){this.vrDisplay=t}},{key:"getVRDisplays",value:function(){return console.warn("VRControls: getVRDisplays() is being deprecated."),this.vrDisplays}},{key:"getStandingMatrix",value:function(){return this.standingMatrix}},{key:"update",value:function(){var t,e=this.camera;this.vrDisplay&&(this.vrDisplay.getFrameData?(this.vrDisplay.getFrameData(this.frameData),t=this.frameData.pose):this.vrDisplay.getPose&&(t=this.vrDisplay.getPose()),null!==t.orientation&&e.quaternion.fromArray(t.orientation),null!==t.position?e.position.fromArray(t.position):e.position.set(0,0,0),this.standing&&(this.vrDisplay.stageParameters?(e.updateMatrix(),this.standingMatrix.fromArray(this.vrDisplay.stageParameters.sittingToStandingTransform),e.applyMatrix(this.standingMatrix)):e.position.setY(e.position.y+this.userHeight)),e.position.multiplyScalar(this.scale))}},{key:"dispose",value:function(){this.vrDisplay=null}}])&&i(e.prototype,n),a&&i(e,a),t}();e.default=a}]); \ No newline at end of file diff --git a/example/package-lock.json b/example/package-lock.json index b60f27b..85ccffd 100644 --- a/example/package-lock.json +++ b/example/package-lock.json @@ -3753,10 +3753,34 @@ "scenemanager": { "version": "file:../scenemanager", "requires": { + "dragdrop": "file:../dragdrop", "three": "^0.110.0", "threeml": "file:../threeml" }, "dependencies": { + "dragdrop": { + "version": "file:../dragdrop", + "requires": { + "three": "^0.110.0" + }, + "dependencies": { + "@types/node": { + "version": "12.12.20", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.20.tgz", + "integrity": "sha512-VAe+DiwpnC/g448uN+/3gRl4th0BTdrR9gSLIOHA+SUQskaYZQDOHG7xmjiE7JUhjbXnbXytf6Ih+/pA6CtMFQ==" + }, + "three": { + "version": "0.110.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.110.0.tgz", + "integrity": "sha512-wlurH8XBO9Sd5VIw8nBa+taLR20kqaI4e9FiuMh6tqK8eOS2q2R+ZoUyufbyDTVTHhs8GiTbv0r2CMLkwerFJg==" + }, + "typescript": { + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.3.tgz", + "integrity": "sha512-Mcr/Qk7hXqFBXMN7p7Lusj1ktCBydylfQM/FZCk5glCNQJrCUKPkMHdo9R0MTFWsC/4kPFvDS0fDPvukfCkFsw==" + } + } + }, "three": { "version": "0.110.0", "resolved": "https://registry.npmjs.org/three/-/three-0.110.0.tgz", diff --git a/scenemanager/package-lock.json b/scenemanager/package-lock.json index 178d899..0a6316d 100644 --- a/scenemanager/package-lock.json +++ b/scenemanager/package-lock.json @@ -10,12 +10,27 @@ "integrity": "sha512-Is+l3mcHvs47sKy+afn2O1rV4ldZFU7W8101cNlOd+MRbjM4Onida8jSZnJdTe/0Pcf25g9BNIUsuugmE6puHA==", "dev": true }, - "@types/three": { - "version": "0.103.2", - "resolved": "https://registry.npmjs.org/@types/three/-/three-0.103.2.tgz", - "integrity": "sha512-zhtf0Qs5wLJpIn1+VWCpzSgpKayj/GSWZ6woiuz09FW59KEDeLpnBkYz6lbblVpRmGdlnG8nd0unaASshOvcXw==", + "dragdrop": { + "version": "file:../dragdrop", "requires": { - "three": "*" + "three": "^0.110.0" + }, + "dependencies": { + "@types/node": { + "version": "12.12.20", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.20.tgz", + "integrity": "sha512-VAe+DiwpnC/g448uN+/3gRl4th0BTdrR9gSLIOHA+SUQskaYZQDOHG7xmjiE7JUhjbXnbXytf6Ih+/pA6CtMFQ==" + }, + "three": { + "version": "0.110.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.110.0.tgz", + "integrity": "sha512-wlurH8XBO9Sd5VIw8nBa+taLR20kqaI4e9FiuMh6tqK8eOS2q2R+ZoUyufbyDTVTHhs8GiTbv0r2CMLkwerFJg==" + }, + "typescript": { + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.3.tgz", + "integrity": "sha512-Mcr/Qk7hXqFBXMN7p7Lusj1ktCBydylfQM/FZCk5glCNQJrCUKPkMHdo9R0MTFWsC/4kPFvDS0fDPvukfCkFsw==" + } } }, "three": { @@ -24,12 +39,34 @@ "integrity": "sha512-wlurH8XBO9Sd5VIw8nBa+taLR20kqaI4e9FiuMh6tqK8eOS2q2R+ZoUyufbyDTVTHhs8GiTbv0r2CMLkwerFJg==" }, "threeml": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/threeml/-/threeml-1.0.11.tgz", - "integrity": "sha512-tpm6gMsDlKtlVPnM2fHc/H7JEROU/Vj80rm3oUd4gxDAqKtO40/vkNvA4UsJ2zywl5DdpS6DF9857o5o3opFvg==", + "version": "file:../threeml", "requires": { - "@types/three": "^0.103.2", "three": "^0.110.0" + }, + "dependencies": { + "@types/node": { + "version": "12.12.17", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.17.tgz", + "integrity": "sha512-Is+l3mcHvs47sKy+afn2O1rV4ldZFU7W8101cNlOd+MRbjM4Onida8jSZnJdTe/0Pcf25g9BNIUsuugmE6puHA==" + }, + "@types/three": { + "version": "0.103.2", + "resolved": "https://registry.npmjs.org/@types/three/-/three-0.103.2.tgz", + "integrity": "sha512-zhtf0Qs5wLJpIn1+VWCpzSgpKayj/GSWZ6woiuz09FW59KEDeLpnBkYz6lbblVpRmGdlnG8nd0unaASshOvcXw==", + "requires": { + "three": "*" + } + }, + "three": { + "version": "0.110.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.110.0.tgz", + "integrity": "sha512-wlurH8XBO9Sd5VIw8nBa+taLR20kqaI4e9FiuMh6tqK8eOS2q2R+ZoUyufbyDTVTHhs8GiTbv0r2CMLkwerFJg==" + }, + "typescript": { + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.3.tgz", + "integrity": "sha512-Mcr/Qk7hXqFBXMN7p7Lusj1ktCBydylfQM/FZCk5glCNQJrCUKPkMHdo9R0MTFWsC/4kPFvDS0fDPvukfCkFsw==" + } } }, "typescript": { From ec0fb73c423b884c118dc9bda5a45425611e4f3c Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Sun, 5 Jan 2020 02:04:23 -0500 Subject: [PATCH 2/9] coordinate generation code made available --- coordinates/prototype2.py | 329 ++++++++++++++++++++++++++++++++++++ coordinates/prototype3.py | 347 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 676 insertions(+) create mode 100644 coordinates/prototype2.py create mode 100644 coordinates/prototype3.py diff --git a/coordinates/prototype2.py b/coordinates/prototype2.py new file mode 100644 index 0000000..89746e4 --- /dev/null +++ b/coordinates/prototype2.py @@ -0,0 +1,329 @@ +######################### +# Andrew Wang # +# # +######################### + +# Utility +import numpy as np +import math +from collections import deque + +# Graphing +from mpl_toolkits.mplot3d import axes3d +from matplotlib import pyplot as plt +from matplotlib import cm + + +def sample_spherical(npoints, radius, ndim=3): + ''' + source: https://stackoverflow.com/a/33977530 + ''' + vec = np.abs(np.random.randn(ndim, npoints)) + vec /= np.linalg.norm(vec, axis=0) + vec *= radius + return vec + +def draw_lines(coordinates, adj, ax): + # ax.plot([0, 1],[0, 1],[0, 1],color = 'g') + # print(adj) + for v in adj: + for n in adj[v]: + ax.plot([coordinates[v][0],coordinates[n][0]],\ + [coordinates[v][1],coordinates[n][1]],\ + [coordinates[v][2],coordinates[n][2]], color='g') + +def set_axes_equal(ax): + ''' + source: https://stackoverflow.com/a/31364297 + Make axes of 3D plot have equal scale so that spheres appear as spheres, + cubes as cubes, etc.. This is one possible solution to Matplotlib's + ax.set_aspect('equal') and ax.axis('equal') not working for 3D. + + Input + ax: a matplotlib axis, e.g., as output from plt.gca(). + ''' + + x_limits = ax.get_xlim3d() + y_limits = ax.get_ylim3d() + z_limits = ax.get_zlim3d() + + x_range = abs(x_limits[1] - x_limits[0]) + x_middle = np.mean(x_limits) + y_range = abs(y_limits[1] - y_limits[0]) + y_middle = np.mean(y_limits) + z_range = abs(z_limits[1] - z_limits[0]) + z_middle = np.mean(z_limits) + + # The plot bounding box is a sphere in the sense of the infinity + # norm, hence I call half the max range the plot radius. + plot_radius = 0.5*max([x_range, y_range, z_range]) + + ax.set_xlim3d([x_middle - plot_radius, x_middle + plot_radius]) + ax.set_ylim3d([y_middle - plot_radius, y_middle + plot_radius]) + ax.set_zlim3d([z_middle - plot_radius, z_middle + plot_radius]) + +def graph(X, Y, Z, coordinates, adj, rev): + ''' + Visualize coordinates + ''' + + phi = np.linspace(0, np.pi/2, 20) + theta = np.linspace(0, np.pi/2, 40) + x = np.outer(np.sin(theta), np.cos(phi)) + y = np.outer(np.sin(theta), np.sin(phi)) + z = np.outer(np.cos(theta), np.ones_like(phi)) + + + #X, Y, Z = sample_spherical(npoints, radius) + fig = plt.figure() + ax = fig.add_subplot(1,1,1,projection='3d') + #ax = fig.gca(projection='3d') + ax.set_aspect('equal') + ''' + for num in range(len(rev)): # display level + ax.plot_wireframe(x*(num+1), y*(num+1), z*(num+1), color='gray', rstride=1, cstride=1) + #ax.plot_surface(x*(num+1), y*(num+1), z*(num+1),cmap=cm.gray) + ''' + draw_lines(coordinates, adj, ax) + # ax.plot([0, 1],[0, 1],[0, 1],color = 'g') + ax.scatter(X, Y, Z, s=100, c='r', zorder=10) + set_axes_equal(ax) + + +def points(adj, length, nodes, radius): + ''' + takes in: + - adj, the adjacency list, where vertices are represented as ints + - length, number of vertices + - nodes, a list of vertices + generates the points at each level + returns three dictionaries, one for + ''' + + q = deque() + initial = nodes[0] + q.append(initial) + level = [None] * length + level[initial] = radius # initial level must be 1 s.t. radius begins at 1. + combined_X = {} + combined_Y = {} + combined_Z = {} + while len(q)>0: + v = q.popleft() + e = adj[v] + l = level[v] + X, Y, Z = sample_spherical(len(e), l) + + if l not in combined_X: + combined_X[l] = list(X) + else: + combined_X[l].extend(X) + + if l not in combined_Y: + combined_Y[l] = list(Y) + else: + combined_Y[l].extend(Y) + + if l not in combined_Z: + combined_Z[l] = list(Z) + else: + combined_Z[l].extend(Z) + + for neighbor in e: + q.append(neighbor) + level[neighbor] = level[v]+1 + + # print(level) + return combined_X, combined_Y, combined_Z, level + +def reverse_level(level): + index = 0 + level_dic = {} + for l in level: + if l not in level_dic: + level_dic[l] = [index] + else: + level_dic[l].append(index) + index+=1 + return level_dic + +def distance(a, b): + ''' + arguments: a, b are 3-D points + returns: distance between a and b + ''' + return math.sqrt((a[0]-b[0])**2+(a[1]-b[1])**2+(a[2]-b[2])**2) + +def gen_candidates(points, origin, n=-1): + ''' + compute all the minimum distance vertices first before checking if there are duplicates + ''' + + # print(n) + # print(points) + # print(origin) + if n < 0: + return points + x = {} + for point in points: + d = distance(origin, point) + if d not in x: + x[d] = [point] + else: + x[d].append(point) + # print(x) + keys = list(x.keys()) + keys.sort(reverse=True) + # print(keys) + num = 0 + index = 0 + coordinates = [] + while num < n: + #print(num) + num+=len(x[keys[index]]) + coordinates.extend(x[keys[index]]) + index+=1 + return coordinates + +def min_distance(points, origin): + ''' + given node coordinate and candidate neighbor coordinates, returns closest point + ''' + min_d_coord = [] + min_d = 1e32 + for point in points: + d = distance(origin, point) + if d < min_d: + min_d = d + min_d_coord = point + return d, min_d_coord + +def max_distance(points, origin): + ''' + given node coordinate and candidate neighbor coordinates, returns farthest point + ''' + max_d_coord = [] + max_d = 0 + for point in points: + d = distance(origin, point) + if d > max_d: + max_d = d + max_d_coord = point + return max_d, max_d_coord + +def connect(x, y, z, level, adj): + ''' + IDEA: + + - Greedy: + + PSEUDO: + + 1) For each level + 2) order the nodes of the level by max_distance(...) + 3) for each node in the ordered nodes + 4) assign closest point + + NOTES: + + - if two vertices on different levels share the same neighbor, override + the existing level + - level matches node (as index) to its corresponding level + + all along the watchtower, princes kept the view. + + ''' + #print(adj) + rev = reverse_level(level) + coordinates = {0: [0, 0, 0]} + for l in rev.keys(): + + ## PREPROCESSING + + points = [] # candidate coordinates for next level + # print(x[l]) + for num in range(len(x[l])): + point = [x[l][num], y[l][num], z[l][num]] + points.append(point) + # print(point) + + ## DETERMINING ORDER + + # print(points) + ordered = rev[l] # nodes in level l + ''' + for v in ordered: # debugging + print(v) + print(coordinates[v]) + print(max_distance(points, coordinates[v])[0]) + ''' + ordered = sorted(ordered, key=lambda v: max_distance(points,\ + coordinates[v])[0], reverse=True) # list for order + # print(ordered) + + ## ASSIGN POINT + + # print(nodes) + for v in ordered: # for each ordered node + # if v in coordinates: + for neighbor in adj[v]: # for each neighbor to ^node + # print(neighbor, level[neighbor]) + if l+1 == level[neighbor]: # if the level of the neighbor is correct + assignment = min_distance(points, coordinates[v])[1] # min distance assignment + points.remove(assignment) + if neighbor not in coordinates: # neighbor already assigned? (ie shared neighbors) + coordinates[neighbor] = assignment + # print(nodes) + # print(matches) + # print(candidates) + # print(matches) + + + + #print(l) + #print(x[l]) + + # print(coordinates) + return coordinates + +def gen_coordinates(adj, radius=1): + nodes = list(adj.keys()) + X, Y, Z, level = points(adj, len(nodes), nodes, radius) + # print(level) + rev = reverse_level(level) + coordinates = connect(X, Y, Z, level, adj) + return coordinates + +def main(): + adj = { + 0:[1, 2], + 1:[3, 4], + 2:[3, 4], + 3:[5], + 4:[6], + 5:[6], + 6:[] + } + nodes = list(adj.keys()) + X, Y, Z, level = points(adj, len(nodes), nodes, 1) + # print(level) + rev = reverse_level(level) + coordinates = connect(X, Y, Z, level, adj) + + # verification + x = [] + y = [] + z = [] + for level in X.keys(): + x.extend(X[level]) + y.extend(Y[level]) + z.extend(Z[level]) + #print(x) + #print(y) + #print(z) + graph(x, y, z, coordinates, adj, rev) + plt.show() + + +if __name__== "__main__": + main() \ No newline at end of file diff --git a/coordinates/prototype3.py b/coordinates/prototype3.py new file mode 100644 index 0000000..403e48d --- /dev/null +++ b/coordinates/prototype3.py @@ -0,0 +1,347 @@ +######################### +# Andrew Wang # +# # +######################### + +# Utility +import numpy as np +import math +from collections import deque +import json + +# Graphing +from mpl_toolkits.mplot3d import axes3d +from matplotlib import pyplot as plt + + +def sample_spherical(npoints, radius, ndim=3): + ''' + source: https://stackoverflow.com/a/33977530 + ''' + vec = np.abs(np.random.randn(ndim, npoints)) + vec /= np.linalg.norm(vec, axis=0) + vec *= radius + return vec + +def draw_lines(coordinates, adj, ax): + # ax.plot([0, 1],[0, 1],[0, 1],color = 'g') + # print(adj) + for v in adj: + for n in adj[v]: + ax.plot([coordinates[v][0],coordinates[n][0]],\ + [coordinates[v][1],coordinates[n][1]],\ + [coordinates[v][2],coordinates[n][2]], color='g') + +def set_axes_equal(ax): + ''' + source: https://stackoverflow.com/a/31364297 + Make axes of 3D plot have equal scale so that spheres appear as spheres, + cubes as cubes, etc.. This is one possible solution to Matplotlib's + ax.set_aspect('equal') and ax.axis('equal') not working for 3D. + + Input + ax: a matplotlib axis, e.g., as output from plt.gca(). + ''' + + x_limits = ax.get_xlim3d() + y_limits = ax.get_ylim3d() + z_limits = ax.get_zlim3d() + + x_range = abs(x_limits[1] - x_limits[0]) + x_middle = np.mean(x_limits) + y_range = abs(y_limits[1] - y_limits[0]) + y_middle = np.mean(y_limits) + z_range = abs(z_limits[1] - z_limits[0]) + z_middle = np.mean(z_limits) + + # The plot bounding box is a sphere in the sense of the infinity + # norm, hence I call half the max range the plot radius. + plot_radius = 0.5*max([x_range, y_range, z_range]) + + ax.set_xlim3d([x_middle - plot_radius, x_middle + plot_radius]) + ax.set_ylim3d([y_middle - plot_radius, y_middle + plot_radius]) + ax.set_zlim3d([z_middle - plot_radius, z_middle + plot_radius]) + +def graph(X, Y, Z, coordinates, adj, rev): + ''' + Visualize coordinates + ''' + + phi = np.linspace(0, np.pi, 20) + theta = np.linspace(0, np.pi, 40) + x = np.outer(np.sin(theta), np.cos(phi)) + y = np.outer(np.sin(theta), np.sin(phi)) + z = np.outer(np.cos(theta), np.ones_like(phi)) + + + #X, Y, Z = sample_spherical(npoints, radius) + fig = plt.figure() + ax = fig.add_subplot(1,1,1,projection='3d') + #ax = fig.gca(projection='3d') + ax.set_aspect('equal') + #for num in range(len(rev)): + # ax.plot_wireframe(x*(num+1), y*(num+1), z*(num+1), color='k', rstride=5, cstride=5) + draw_lines(coordinates, adj, ax) + # ax.plot([0, 1],[0, 1],[0, 1],color = 'g') + ax.scatter(X, Y, Z, s=100, c='r', zorder=10) + set_axes_equal(ax) + + +def points(adj, length, nodes, radius): + ''' + takes in: + - adj, the adjacency list, where vertices are represented as ints + - length, number of vertices + - nodes, a list of vertices + generates the points at each level + returns three dictionaries, one for + ''' + + q = deque() + # print(nodes) + initial = nodes[0] + q.append(initial) + level = [None] * length + #visited = [False] * length + level[initial] = radius # initial level must be 1 s.t. radius begins at 1. + #visited[initial] = True + combined_X = {} + combined_Y = {} + combined_Z = {} + while len(q)>0: + v = q.popleft() + e = adj[v] + l = level[v] + X, Y, Z = sample_spherical(len(e), l) + + if l not in combined_X: + combined_X[l] = list(X) + else: + combined_X[l].extend(X) + + if l not in combined_Y: + combined_Y[l] = list(Y) + else: + combined_Y[l].extend(Y) + + if l not in combined_Z: + combined_Z[l] = list(Z) + else: + combined_Z[l].extend(Z) + + for neighbor in e: + q.append(neighbor) + level[neighbor] = level[v]+radius + + # Uncomment for level check: + #print(level) + return combined_X, combined_Y, combined_Z, level + +def reverse_level(level): + index = 0 + level_dic = {} + for l in level: + if l not in level_dic: + level_dic[l] = [index] + else: + level_dic[l].append(index) + index+=1 + return level_dic + +def distance(a, b): + ''' + arguments: a, b are 3-D points + returns: distance between a and b + ''' + return math.sqrt((a[0]-b[0])**2+(a[1]-b[1])**2+(a[2]-b[2])**2) + +def gen_candidates(points, origin, n=-1): + ''' + compute all the minimum distance vertices first before checking if there are duplicates + ''' + + #print(n) + #print(points) + #print(origin) + if n < 0: + return points + x = {} + for point in points: + d = distance(origin, point) + if d not in x: + x[d] = [point] + else: + x[d].append(point) + #print(x) + keys = list(x.keys()) + keys.sort(reverse=True) + #print(keys) + num = 0 + index = 0 + coordinates = [] + while num < n: + #print(num) + num+=len(x[keys[index]]) + coordinates.extend(x[keys[index]]) + index+=1 + return coordinates + +def min_distance(points, origin): + ''' + given node coordinate and candidate neighbor coordinates, returns closest point + ''' + min_d_coord = [] + min_d = 1e32 + for point in points: + d = distance(origin, point) + if d < min_d: + min_d = d + min_d_coord = point + return d, min_d_coord + +def max_distance(points, origin): + ''' + given node coordinate and candidate neighbor coordinates, returns farthest point + ''' + max_d_coord = [] + max_d = 0 + for point in points: + d = distance(origin, point) + if d > max_d: + max_d = d + max_d_coord = point + return max_d, max_d_coord + +def connect(x, y, z, level, adj): + ''' + IDEA: + + - Greedy: + + PSEUDO: + + 1) For each level + 2) order the nodes of the level by max_distance(...) + 3) for each node in the ordered nodes + 4) assign closest point + + NOTES: + + - if two vertices on different levels share the same neighbor, override + the existing level + - level matches node (as index) to its corresponding level + + all along the watchtower, princes kept the view. + + ''' + #print(adj) + rev = reverse_level(level) + coordinates = {0: [0, 0, 0]} + for l in rev.keys(): + + ## PREPROCESSING + + points = [] # candidate coordinates for next level + # print(x[l]) + for num in range(len(x[l])): + point = [x[l][num], y[l][num], z[l][num]] + points.append(point) + # print(point) + + ## DETERMINING ORDER + + # print(points) + ordered = rev[l] # nodes in level l + ''' + for v in ordered: # debugging + print(v) + print(coordinates[v]) + print(max_distance(points, coordinates[v])[0]) + ''' + ordered = sorted(ordered, key=lambda v: max_distance(points,\ + coordinates[v])[0], reverse=True) # list for order + # print(ordered) + + ## ASSIGN POINT + + # print(nodes) + # to_be_assigned = [] + for v in ordered: # for each ordered node + # if v in coordinates: + for neighbor in adj[v]: # for each neighbor to ^node + # print(neighbor, level[neighbor]) + if l+1 == level[neighbor]: # if the level of the neighbor is correct + assignment = min_distance(points, coordinates[v])[1] # min distance assignment + points.remove(assignment) + if neighbor not in coordinates: # neighbor already assigned? (ie shared neighbors) + coordinates[neighbor] = assignment + # print(nodes) + # print(matches) + # candidates = gen_candidates(points, coordinates[v], n) + # print(candidates) + # print(matches) + + + + #print(l) + #print(x[l]) + + # print(coordinates) + return coordinates + +def gen_coordinates(adj, radius=1): + nodes = list(adj.keys()) + X, Y, Z, level = points(adj, len(nodes), nodes, radius) + # print(level) + rev = reverse_level(level) + coordinates = connect(X, Y, Z, level, adj) + return coordinates + +def adjacency_list(): + json_string = r'{"name":"%3","directed":true,"strict":false,"compound":"true","newrank":"true","_subgraph_cnt":1,"objects":[{"name":"root","compound":"true","newrank":"true","_gvid":0,"nodes":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88],"edges":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193]},{"_gvid":1,"name":"[root] aws_api_gateway_base_path_mapping.base_path","label":"aws_api_gateway_base_path_mapping.base_path","shape":"box"},{"_gvid":2,"name":"[root] aws_api_gateway_deployment.deployment","label":"aws_api_gateway_deployment.deployment","shape":"box"},{"_gvid":3,"name":"[root] aws_api_gateway_domain_name.urlapi","label":"aws_api_gateway_domain_name.urlapi","shape":"box"},{"_gvid":4,"name":"[root] aws_api_gateway_integration.fetch_integration","label":"aws_api_gateway_integration.fetch_integration","shape":"box"},{"_gvid":5,"name":"[root] aws_api_gateway_integration.generate_integration","label":"aws_api_gateway_integration.generate_integration","shape":"box"},{"_gvid":6,"name":"[root] aws_api_gateway_integration.generate_options_integration","label":"aws_api_gateway_integration.generate_options_integration","shape":"box"},{"_gvid":7,"name":"[root] aws_api_gateway_integration.upload_integration","label":"aws_api_gateway_integration.upload_integration","shape":"box"},{"_gvid":8,"name":"[root] aws_api_gateway_integration.upload_options_integration","label":"aws_api_gateway_integration.upload_options_integration","shape":"box"},{"_gvid":9,"name":"[root] aws_api_gateway_integration_response.fetch_ir_200","label":"aws_api_gateway_integration_response.fetch_ir_200","shape":"box"},{"_gvid":10,"name":"[root] aws_api_gateway_integration_response.generate_ir_400","label":"aws_api_gateway_integration_response.generate_ir_400","shape":"box"},{"_gvid":11,"name":"[root] aws_api_gateway_integration_response.generate_options_integration_response","label":"aws_api_gateway_integration_response.generate_options_integration_response","shape":"box"},{"_gvid":12,"name":"[root] aws_api_gateway_integration_response.upload_ir_400","label":"aws_api_gateway_integration_response.upload_ir_400","shape":"box"},{"_gvid":13,"name":"[root] aws_api_gateway_integration_response.upload_options_integration_response","label":"aws_api_gateway_integration_response.upload_options_integration_response","shape":"box"},{"_gvid":14,"name":"[root] aws_api_gateway_method.fetch","label":"aws_api_gateway_method.fetch","shape":"box"},{"_gvid":15,"name":"[root] aws_api_gateway_method.generate","label":"aws_api_gateway_method.generate","shape":"box"},{"_gvid":16,"name":"[root] aws_api_gateway_method.generate_options","label":"aws_api_gateway_method.generate_options","shape":"box"},{"_gvid":17,"name":"[root] aws_api_gateway_method.upload","label":"aws_api_gateway_method.upload","shape":"box"},{"_gvid":18,"name":"[root] aws_api_gateway_method.upload_options","label":"aws_api_gateway_method.upload_options","shape":"box"},{"_gvid":19,"name":"[root] aws_api_gateway_method_response.fetch_200","label":"aws_api_gateway_method_response.fetch_200","shape":"box"},{"_gvid":20,"name":"[root] aws_api_gateway_method_response.fetch_400","label":"aws_api_gateway_method_response.fetch_400","shape":"box"},{"_gvid":21,"name":"[root] aws_api_gateway_method_response.generate_200","label":"aws_api_gateway_method_response.generate_200","shape":"box"},{"_gvid":22,"name":"[root] aws_api_gateway_method_response.generate_400","label":"aws_api_gateway_method_response.generate_400","shape":"box"},{"_gvid":23,"name":"[root] aws_api_gateway_method_response.generate_401","label":"aws_api_gateway_method_response.generate_401","shape":"box"},{"_gvid":24,"name":"[root] aws_api_gateway_method_response.generate_404","label":"aws_api_gateway_method_response.generate_404","shape":"box"},{"_gvid":25,"name":"[root] aws_api_gateway_method_response.generate_500","label":"aws_api_gateway_method_response.generate_500","shape":"box"},{"_gvid":26,"name":"[root] aws_api_gateway_method_response.generate_options_200","label":"aws_api_gateway_method_response.generate_options_200","shape":"box"},{"_gvid":27,"name":"[root] aws_api_gateway_method_response.upload_200","label":"aws_api_gateway_method_response.upload_200","shape":"box"},{"_gvid":28,"name":"[root] aws_api_gateway_method_response.upload_400","label":"aws_api_gateway_method_response.upload_400","shape":"box"},{"_gvid":29,"name":"[root] aws_api_gateway_method_response.upload_401","label":"aws_api_gateway_method_response.upload_401","shape":"box"},{"_gvid":30,"name":"[root] aws_api_gateway_method_response.upload_500","label":"aws_api_gateway_method_response.upload_500","shape":"box"},{"_gvid":31,"name":"[root] aws_api_gateway_method_response.upload_options_200","label":"aws_api_gateway_method_response.upload_options_200","shape":"box"},{"_gvid":32,"name":"[root] aws_api_gateway_request_validator.fetch_validator","label":"aws_api_gateway_request_validator.fetch_validator","shape":"box"},{"_gvid":33,"name":"[root] aws_api_gateway_request_validator.generate_validator","label":"aws_api_gateway_request_validator.generate_validator","shape":"box"},{"_gvid":34,"name":"[root] aws_api_gateway_resource.fetch_resource","label":"aws_api_gateway_resource.fetch_resource","shape":"box"},{"_gvid":35,"name":"[root] aws_api_gateway_resource.generate_resource","label":"aws_api_gateway_resource.generate_resource","shape":"box"},{"_gvid":36,"name":"[root] aws_api_gateway_resource.upload_resource","label":"aws_api_gateway_resource.upload_resource","shape":"box"},{"_gvid":37,"name":"[root] aws_api_gateway_rest_api.api","label":"aws_api_gateway_rest_api.api","shape":"box"},{"_gvid":38,"name":"[root] aws_cloudwatch_event_rule.everyday","label":"aws_cloudwatch_event_rule.everyday","shape":"box"},{"_gvid":39,"name":"[root] aws_cloudwatch_event_target.clean_up_urls_everyday","label":"aws_cloudwatch_event_target.clean_up_urls_everyday","shape":"box"},{"_gvid":40,"name":"[root] aws_iam_policy.invoke","label":"aws_iam_policy.invoke","shape":"box"},{"_gvid":41,"name":"[root] aws_iam_policy.ip","label":"aws_iam_policy.ip","shape":"box"},{"_gvid":42,"name":"[root] aws_iam_policy.ip_put","label":"aws_iam_policy.ip_put","shape":"box"},{"_gvid":43,"name":"[root] aws_iam_policy.lambda_fetch_s3","label":"aws_iam_policy.lambda_fetch_s3","shape":"box"},{"_gvid":44,"name":"[root] aws_iam_role.lambda_fetch_object_role","label":"aws_iam_role.lambda_fetch_object_role","shape":"box"},{"_gvid":45,"name":"[root] aws_iam_role.lambda_generate_url_helper_role","label":"aws_iam_role.lambda_generate_url_helper_role","shape":"box"},{"_gvid":46,"name":"[root] aws_iam_role.lambda_generate_url_role","label":"aws_iam_role.lambda_generate_url_role","shape":"box"},{"_gvid":47,"name":"[root] aws_iam_role.lambda_remove_urls_role","label":"aws_iam_role.lambda_remove_urls_role","shape":"box"},{"_gvid":48,"name":"[root] aws_iam_role.lambda_upload_url_role","label":"aws_iam_role.lambda_upload_url_role","shape":"box"},{"_gvid":49,"name":"[root] aws_iam_role_policy_attachment.invokehelper_gen","label":"aws_iam_role_policy_attachment.invokehelper_gen","shape":"box"},{"_gvid":50,"name":"[root] aws_iam_role_policy_attachment.invokehelper_remove","label":"aws_iam_role_policy_attachment.invokehelper_remove","shape":"box"},{"_gvid":51,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_fetch","label":"aws_iam_role_policy_attachment.lambdabasic_fetch","shape":"box"},{"_gvid":52,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_gen","label":"aws_iam_role_policy_attachment.lambdabasic_gen","shape":"box"},{"_gvid":53,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_genhelp","label":"aws_iam_role_policy_attachment.lambdabasic_genhelp","shape":"box"},{"_gvid":54,"name":"[root] aws_iam_role_policy_attachment.s3full_gen","label":"aws_iam_role_policy_attachment.s3full_gen","shape":"box"},{"_gvid":55,"name":"[root] aws_iam_role_policy_attachment.s3full_remove","label":"aws_iam_role_policy_attachment.s3full_remove","shape":"box"},{"_gvid":56,"name":"[root] aws_iam_role_policy_attachment.s3ip_genhelp","label":"aws_iam_role_policy_attachment.s3ip_genhelp","shape":"box"},{"_gvid":57,"name":"[root] aws_iam_role_policy_attachment.s3ip_upload","label":"aws_iam_role_policy_attachment.s3ip_upload","shape":"box"},{"_gvid":58,"name":"[root] aws_iam_role_policy_attachment.s3read_fetch","label":"aws_iam_role_policy_attachment.s3read_fetch","shape":"box"},{"_gvid":59,"name":"[root] aws_lambda_function.fetch","label":"aws_lambda_function.fetch","shape":"box"},{"_gvid":60,"name":"[root] aws_lambda_function.gen","label":"aws_lambda_function.gen","shape":"box"},{"_gvid":61,"name":"[root] aws_lambda_function.genhelp","label":"aws_lambda_function.genhelp","shape":"box"},{"_gvid":62,"name":"[root] aws_lambda_function.remove","label":"aws_lambda_function.remove","shape":"box"},{"_gvid":63,"name":"[root] aws_lambda_function.upload","label":"aws_lambda_function.upload","shape":"box"},{"_gvid":64,"name":"[root] aws_lambda_permission.allow_cloudwatch_to_call_check_foo","label":"aws_lambda_permission.allow_cloudwatch_to_call_check_foo","shape":"box"},{"_gvid":65,"name":"[root] aws_lambda_permission.apigw_fetch_lambda","label":"aws_lambda_permission.apigw_fetch_lambda","shape":"box"},{"_gvid":66,"name":"[root] aws_lambda_permission.apigw_generate_lambda","label":"aws_lambda_permission.apigw_generate_lambda","shape":"box"},{"_gvid":67,"name":"[root] aws_lambda_permission.apigw_upload_lambda","label":"aws_lambda_permission.apigw_upload_lambda","shape":"box"},{"_gvid":68,"name":"[root] aws_route53_record.route","label":"aws_route53_record.route","shape":"box"},{"_gvid":69,"name":"[root] aws_route53_zone.primary","label":"aws_route53_zone.primary","shape":"box"},{"_gvid":70,"name":"[root] aws_s3_bucket.download_bucket","label":"aws_s3_bucket.download_bucket","shape":"box"},{"_gvid":71,"name":"[root] aws_s3_bucket.upload_bucket","label":"aws_s3_bucket.upload_bucket","shape":"box"},{"_gvid":72,"name":"[root] aws_s3_bucket_public_access_block.private_download_bucket","label":"aws_s3_bucket_public_access_block.private_download_bucket","shape":"box"},{"_gvid":73,"name":"[root] aws_s3_bucket_public_access_block.private_upload_bucket","label":"aws_s3_bucket_public_access_block.private_upload_bucket","shape":"box"},{"_gvid":74,"name":"[root] data.archive_file.fetch_object_code","label":"data.archive_file.fetch_object_code","shape":"box"},{"_gvid":75,"name":"[root] data.archive_file.generate_url_helper_code","label":"data.archive_file.generate_url_helper_code","shape":"box"},{"_gvid":76,"name":"[root] data.archive_file.generate_url_main_code","label":"data.archive_file.generate_url_main_code","shape":"box"},{"_gvid":77,"name":"[root] data.archive_file.remove_expired_urls_code","label":"data.archive_file.remove_expired_urls_code","shape":"box"},{"_gvid":78,"name":"[root] data.archive_file.upload_url_code","label":"data.archive_file.upload_url_code","shape":"box"},{"_gvid":79,"name":"[root] data.aws_acm_certificate.cert","label":"data.aws_acm_certificate.cert","shape":"box"},{"_gvid":80,"name":"[root] null_resource.build_image","label":"null_resource.build_image","shape":"box"},{"_gvid":81,"name":"[root] provider.archive","label":"provider.archive","shape":"diamond"},{"_gvid":82,"name":"[root] provider.aws","label":"provider.aws","shape":"diamond"},{"_gvid":83,"name":"[root] meta.count-boundary (EachMode fixup)","label":"\\N"},{"_gvid":84,"name":"[root] provider.archive (close)","label":"\\N"},{"_gvid":85,"name":"[root] provider.aws (close)","label":"\\N"},{"_gvid":86,"name":"[root] provider.null (close)","label":"\\N"},{"_gvid":87,"name":"[root] provisioner.local-exec (close)","label":"\\N"},{"_gvid":88,"name":"[root] root","label":"\\N"}],"edges":[{"_gvid":0,"tail":1,"head":2},{"_gvid":1,"tail":1,"head":3},{"_gvid":2,"tail":2,"head":4},{"_gvid":3,"tail":2,"head":5},{"_gvid":4,"tail":2,"head":7},{"_gvid":5,"tail":3,"head":79},{"_gvid":6,"tail":4,"head":14},{"_gvid":7,"tail":4,"head":59},{"_gvid":8,"tail":5,"head":15},{"_gvid":9,"tail":5,"head":60},{"_gvid":10,"tail":6,"head":16},{"_gvid":11,"tail":7,"head":17},{"_gvid":12,"tail":7,"head":63},{"_gvid":13,"tail":8,"head":18},{"_gvid":14,"tail":9,"head":4},{"_gvid":15,"tail":9,"head":19},{"_gvid":16,"tail":10,"head":22},{"_gvid":17,"tail":10,"head":70},{"_gvid":18,"tail":11,"head":26},{"_gvid":19,"tail":11,"head":70},{"_gvid":20,"tail":12,"head":28},{"_gvid":21,"tail":12,"head":71},{"_gvid":22,"tail":13,"head":31},{"_gvid":23,"tail":13,"head":71},{"_gvid":24,"tail":14,"head":32},{"_gvid":25,"tail":14,"head":34},{"_gvid":26,"tail":15,"head":33},{"_gvid":27,"tail":15,"head":35},{"_gvid":28,"tail":16,"head":35},{"_gvid":29,"tail":17,"head":36},{"_gvid":30,"tail":18,"head":36},{"_gvid":31,"tail":19,"head":14},{"_gvid":32,"tail":20,"head":14},{"_gvid":33,"tail":21,"head":15},{"_gvid":34,"tail":22,"head":15},{"_gvid":35,"tail":23,"head":15},{"_gvid":36,"tail":24,"head":15},{"_gvid":37,"tail":25,"head":15},{"_gvid":38,"tail":26,"head":16},{"_gvid":39,"tail":27,"head":17},{"_gvid":40,"tail":28,"head":17},{"_gvid":41,"tail":29,"head":17},{"_gvid":42,"tail":30,"head":17},{"_gvid":43,"tail":31,"head":18},{"_gvid":44,"tail":32,"head":37},{"_gvid":45,"tail":33,"head":37},{"_gvid":46,"tail":34,"head":37},{"_gvid":47,"tail":35,"head":37},{"_gvid":48,"tail":36,"head":37},{"_gvid":49,"tail":37,"head":82},{"_gvid":50,"tail":38,"head":82},{"_gvid":51,"tail":39,"head":38},{"_gvid":52,"tail":39,"head":62},{"_gvid":53,"tail":40,"head":61},{"_gvid":54,"tail":41,"head":82},{"_gvid":55,"tail":42,"head":82},{"_gvid":56,"tail":43,"head":82},{"_gvid":57,"tail":44,"head":82},{"_gvid":58,"tail":45,"head":82},{"_gvid":59,"tail":46,"head":82},{"_gvid":60,"tail":47,"head":82},{"_gvid":61,"tail":48,"head":82},{"_gvid":62,"tail":49,"head":40},{"_gvid":63,"tail":49,"head":46},{"_gvid":64,"tail":50,"head":40},{"_gvid":65,"tail":50,"head":47},{"_gvid":66,"tail":51,"head":44},{"_gvid":67,"tail":52,"head":46},{"_gvid":68,"tail":53,"head":45},{"_gvid":69,"tail":54,"head":46},{"_gvid":70,"tail":55,"head":47},{"_gvid":71,"tail":56,"head":41},{"_gvid":72,"tail":56,"head":45},{"_gvid":73,"tail":57,"head":42},{"_gvid":74,"tail":57,"head":48},{"_gvid":75,"tail":58,"head":43},{"_gvid":76,"tail":58,"head":44},{"_gvid":77,"tail":59,"head":44},{"_gvid":78,"tail":59,"head":70},{"_gvid":79,"tail":59,"head":74},{"_gvid":80,"tail":60,"head":46},{"_gvid":81,"tail":60,"head":70},{"_gvid":82,"tail":60,"head":76},{"_gvid":83,"tail":61,"head":45},{"_gvid":84,"tail":61,"head":75},{"_gvid":85,"tail":62,"head":47},{"_gvid":86,"tail":62,"head":70},{"_gvid":87,"tail":62,"head":77},{"_gvid":88,"tail":63,"head":48},{"_gvid":89,"tail":63,"head":71},{"_gvid":90,"tail":63,"head":78},{"_gvid":91,"tail":64,"head":38},{"_gvid":92,"tail":64,"head":62},{"_gvid":93,"tail":65,"head":14},{"_gvid":94,"tail":65,"head":59},{"_gvid":95,"tail":66,"head":15},{"_gvid":96,"tail":66,"head":60},{"_gvid":97,"tail":67,"head":17},{"_gvid":98,"tail":67,"head":63},{"_gvid":99,"tail":68,"head":3},{"_gvid":100,"tail":68,"head":69},{"_gvid":101,"tail":69,"head":82},{"_gvid":102,"tail":70,"head":82},{"_gvid":103,"tail":71,"head":70},{"_gvid":104,"tail":72,"head":70},{"_gvid":105,"tail":73,"head":71},{"_gvid":106,"tail":74,"head":81},{"_gvid":107,"tail":75,"head":81},{"_gvid":108,"tail":76,"head":81},{"_gvid":109,"tail":77,"head":81},{"_gvid":110,"tail":78,"head":81},{"_gvid":111,"tail":79,"head":82},{"_gvid":112,"tail":80,"head":71},{"_gvid":113,"tail":83,"head":1},{"_gvid":114,"tail":83,"head":6},{"_gvid":115,"tail":83,"head":8},{"_gvid":116,"tail":83,"head":9},{"_gvid":117,"tail":83,"head":10},{"_gvid":118,"tail":83,"head":11},{"_gvid":119,"tail":83,"head":12},{"_gvid":120,"tail":83,"head":13},{"_gvid":121,"tail":83,"head":20},{"_gvid":122,"tail":83,"head":21},{"_gvid":123,"tail":83,"head":23},{"_gvid":124,"tail":83,"head":24},{"_gvid":125,"tail":83,"head":25},{"_gvid":126,"tail":83,"head":27},{"_gvid":127,"tail":83,"head":29},{"_gvid":128,"tail":83,"head":30},{"_gvid":129,"tail":83,"head":39},{"_gvid":130,"tail":83,"head":49},{"_gvid":131,"tail":83,"head":50},{"_gvid":132,"tail":83,"head":51},{"_gvid":133,"tail":83,"head":52},{"_gvid":134,"tail":83,"head":53},{"_gvid":135,"tail":83,"head":54},{"_gvid":136,"tail":83,"head":55},{"_gvid":137,"tail":83,"head":56},{"_gvid":138,"tail":83,"head":57},{"_gvid":139,"tail":83,"head":58},{"_gvid":140,"tail":83,"head":64},{"_gvid":141,"tail":83,"head":65},{"_gvid":142,"tail":83,"head":66},{"_gvid":143,"tail":83,"head":67},{"_gvid":144,"tail":83,"head":68},{"_gvid":145,"tail":83,"head":72},{"_gvid":146,"tail":83,"head":73},{"_gvid":147,"tail":83,"head":80},{"_gvid":148,"tail":84,"head":74},{"_gvid":149,"tail":84,"head":75},{"_gvid":150,"tail":84,"head":76},{"_gvid":151,"tail":84,"head":77},{"_gvid":152,"tail":84,"head":78},{"_gvid":153,"tail":85,"head":1},{"_gvid":154,"tail":85,"head":6},{"_gvid":155,"tail":85,"head":8},{"_gvid":156,"tail":85,"head":9},{"_gvid":157,"tail":85,"head":10},{"_gvid":158,"tail":85,"head":11},{"_gvid":159,"tail":85,"head":12},{"_gvid":160,"tail":85,"head":13},{"_gvid":161,"tail":85,"head":20},{"_gvid":162,"tail":85,"head":21},{"_gvid":163,"tail":85,"head":23},{"_gvid":164,"tail":85,"head":24},{"_gvid":165,"tail":85,"head":25},{"_gvid":166,"tail":85,"head":27},{"_gvid":167,"tail":85,"head":29},{"_gvid":168,"tail":85,"head":30},{"_gvid":169,"tail":85,"head":39},{"_gvid":170,"tail":85,"head":49},{"_gvid":171,"tail":85,"head":50},{"_gvid":172,"tail":85,"head":51},{"_gvid":173,"tail":85,"head":52},{"_gvid":174,"tail":85,"head":53},{"_gvid":175,"tail":85,"head":54},{"_gvid":176,"tail":85,"head":55},{"_gvid":177,"tail":85,"head":56},{"_gvid":178,"tail":85,"head":57},{"_gvid":179,"tail":85,"head":58},{"_gvid":180,"tail":85,"head":64},{"_gvid":181,"tail":85,"head":65},{"_gvid":182,"tail":85,"head":66},{"_gvid":183,"tail":85,"head":67},{"_gvid":184,"tail":85,"head":68},{"_gvid":185,"tail":85,"head":72},{"_gvid":186,"tail":85,"head":73},{"_gvid":187,"tail":86,"head":80},{"_gvid":188,"tail":87,"head":80},{"_gvid":189,"tail":88,"head":83},{"_gvid":190,"tail":88,"head":84},{"_gvid":191,"tail":88,"head":85},{"_gvid":192,"tail":88,"head":86},{"_gvid":193,"tail":88,"head":87}]}' + obj = json.loads(json_string) + + adj = {i:[] for i in obj['objects'][0]['nodes']} + + for edge in obj['edges']: + adj[edge['tail']].append(edge['head']) + + return adj + +def main(): + ''' + adj = { + 0:[1, 2], + 1:[3, 4], + 2:[3, 4], + 3:[5], + 4:[6], + 5:[6], + 6:[] + } + ''' + adj = adjacency_list() + print(adj) + nodes = list(adj.keys()) + X, Y, Z, level = points(adj, len(nodes), nodes, 1) + print(level) + rev = reverse_level(level) + coordinates = connect(X, Y, Z, level, adj) + + # verification + x = [] + y = [] + z = [] + for level in X.keys(): + x.extend(X[level]) + y.extend(Y[level]) + z.extend(Z[level]) + #print(x) + #print(y) + #print(z) + graph(x, y, z, coordinates, adj, rev) + plt.show() + + +if __name__== "__main__": + main() \ No newline at end of file From 0cadb78aef359aee35cf4303639dc9a2def4b3e2 Mon Sep 17 00:00:00 2001 From: Joshua SA Date: Sun, 5 Jan 2020 17:22:08 -0500 Subject: [PATCH 3/9] reversed nodes --- coordinates/prototype3.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/coordinates/prototype3.py b/coordinates/prototype3.py index 403e48d..db05999 100644 --- a/coordinates/prototype3.py +++ b/coordinates/prototype3.py @@ -98,7 +98,6 @@ def points(adj, length, nodes, radius): ''' q = deque() - # print(nodes) initial = nodes[0] q.append(initial) level = [None] * length @@ -131,7 +130,7 @@ def points(adj, length, nodes, radius): for neighbor in e: q.append(neighbor) - level[neighbor] = level[v]+radius + level[neighbor] = level[v]+1 # Uncomment for level check: #print(level) @@ -298,13 +297,16 @@ def gen_coordinates(adj, radius=1): return coordinates def adjacency_list(): - json_string = r'{"name":"%3","directed":true,"strict":false,"compound":"true","newrank":"true","_subgraph_cnt":1,"objects":[{"name":"root","compound":"true","newrank":"true","_gvid":0,"nodes":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88],"edges":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193]},{"_gvid":1,"name":"[root] aws_api_gateway_base_path_mapping.base_path","label":"aws_api_gateway_base_path_mapping.base_path","shape":"box"},{"_gvid":2,"name":"[root] aws_api_gateway_deployment.deployment","label":"aws_api_gateway_deployment.deployment","shape":"box"},{"_gvid":3,"name":"[root] aws_api_gateway_domain_name.urlapi","label":"aws_api_gateway_domain_name.urlapi","shape":"box"},{"_gvid":4,"name":"[root] aws_api_gateway_integration.fetch_integration","label":"aws_api_gateway_integration.fetch_integration","shape":"box"},{"_gvid":5,"name":"[root] aws_api_gateway_integration.generate_integration","label":"aws_api_gateway_integration.generate_integration","shape":"box"},{"_gvid":6,"name":"[root] aws_api_gateway_integration.generate_options_integration","label":"aws_api_gateway_integration.generate_options_integration","shape":"box"},{"_gvid":7,"name":"[root] aws_api_gateway_integration.upload_integration","label":"aws_api_gateway_integration.upload_integration","shape":"box"},{"_gvid":8,"name":"[root] aws_api_gateway_integration.upload_options_integration","label":"aws_api_gateway_integration.upload_options_integration","shape":"box"},{"_gvid":9,"name":"[root] aws_api_gateway_integration_response.fetch_ir_200","label":"aws_api_gateway_integration_response.fetch_ir_200","shape":"box"},{"_gvid":10,"name":"[root] aws_api_gateway_integration_response.generate_ir_400","label":"aws_api_gateway_integration_response.generate_ir_400","shape":"box"},{"_gvid":11,"name":"[root] aws_api_gateway_integration_response.generate_options_integration_response","label":"aws_api_gateway_integration_response.generate_options_integration_response","shape":"box"},{"_gvid":12,"name":"[root] aws_api_gateway_integration_response.upload_ir_400","label":"aws_api_gateway_integration_response.upload_ir_400","shape":"box"},{"_gvid":13,"name":"[root] aws_api_gateway_integration_response.upload_options_integration_response","label":"aws_api_gateway_integration_response.upload_options_integration_response","shape":"box"},{"_gvid":14,"name":"[root] aws_api_gateway_method.fetch","label":"aws_api_gateway_method.fetch","shape":"box"},{"_gvid":15,"name":"[root] aws_api_gateway_method.generate","label":"aws_api_gateway_method.generate","shape":"box"},{"_gvid":16,"name":"[root] aws_api_gateway_method.generate_options","label":"aws_api_gateway_method.generate_options","shape":"box"},{"_gvid":17,"name":"[root] aws_api_gateway_method.upload","label":"aws_api_gateway_method.upload","shape":"box"},{"_gvid":18,"name":"[root] aws_api_gateway_method.upload_options","label":"aws_api_gateway_method.upload_options","shape":"box"},{"_gvid":19,"name":"[root] aws_api_gateway_method_response.fetch_200","label":"aws_api_gateway_method_response.fetch_200","shape":"box"},{"_gvid":20,"name":"[root] aws_api_gateway_method_response.fetch_400","label":"aws_api_gateway_method_response.fetch_400","shape":"box"},{"_gvid":21,"name":"[root] aws_api_gateway_method_response.generate_200","label":"aws_api_gateway_method_response.generate_200","shape":"box"},{"_gvid":22,"name":"[root] aws_api_gateway_method_response.generate_400","label":"aws_api_gateway_method_response.generate_400","shape":"box"},{"_gvid":23,"name":"[root] aws_api_gateway_method_response.generate_401","label":"aws_api_gateway_method_response.generate_401","shape":"box"},{"_gvid":24,"name":"[root] aws_api_gateway_method_response.generate_404","label":"aws_api_gateway_method_response.generate_404","shape":"box"},{"_gvid":25,"name":"[root] aws_api_gateway_method_response.generate_500","label":"aws_api_gateway_method_response.generate_500","shape":"box"},{"_gvid":26,"name":"[root] aws_api_gateway_method_response.generate_options_200","label":"aws_api_gateway_method_response.generate_options_200","shape":"box"},{"_gvid":27,"name":"[root] aws_api_gateway_method_response.upload_200","label":"aws_api_gateway_method_response.upload_200","shape":"box"},{"_gvid":28,"name":"[root] aws_api_gateway_method_response.upload_400","label":"aws_api_gateway_method_response.upload_400","shape":"box"},{"_gvid":29,"name":"[root] aws_api_gateway_method_response.upload_401","label":"aws_api_gateway_method_response.upload_401","shape":"box"},{"_gvid":30,"name":"[root] aws_api_gateway_method_response.upload_500","label":"aws_api_gateway_method_response.upload_500","shape":"box"},{"_gvid":31,"name":"[root] aws_api_gateway_method_response.upload_options_200","label":"aws_api_gateway_method_response.upload_options_200","shape":"box"},{"_gvid":32,"name":"[root] aws_api_gateway_request_validator.fetch_validator","label":"aws_api_gateway_request_validator.fetch_validator","shape":"box"},{"_gvid":33,"name":"[root] aws_api_gateway_request_validator.generate_validator","label":"aws_api_gateway_request_validator.generate_validator","shape":"box"},{"_gvid":34,"name":"[root] aws_api_gateway_resource.fetch_resource","label":"aws_api_gateway_resource.fetch_resource","shape":"box"},{"_gvid":35,"name":"[root] aws_api_gateway_resource.generate_resource","label":"aws_api_gateway_resource.generate_resource","shape":"box"},{"_gvid":36,"name":"[root] aws_api_gateway_resource.upload_resource","label":"aws_api_gateway_resource.upload_resource","shape":"box"},{"_gvid":37,"name":"[root] aws_api_gateway_rest_api.api","label":"aws_api_gateway_rest_api.api","shape":"box"},{"_gvid":38,"name":"[root] aws_cloudwatch_event_rule.everyday","label":"aws_cloudwatch_event_rule.everyday","shape":"box"},{"_gvid":39,"name":"[root] aws_cloudwatch_event_target.clean_up_urls_everyday","label":"aws_cloudwatch_event_target.clean_up_urls_everyday","shape":"box"},{"_gvid":40,"name":"[root] aws_iam_policy.invoke","label":"aws_iam_policy.invoke","shape":"box"},{"_gvid":41,"name":"[root] aws_iam_policy.ip","label":"aws_iam_policy.ip","shape":"box"},{"_gvid":42,"name":"[root] aws_iam_policy.ip_put","label":"aws_iam_policy.ip_put","shape":"box"},{"_gvid":43,"name":"[root] aws_iam_policy.lambda_fetch_s3","label":"aws_iam_policy.lambda_fetch_s3","shape":"box"},{"_gvid":44,"name":"[root] aws_iam_role.lambda_fetch_object_role","label":"aws_iam_role.lambda_fetch_object_role","shape":"box"},{"_gvid":45,"name":"[root] aws_iam_role.lambda_generate_url_helper_role","label":"aws_iam_role.lambda_generate_url_helper_role","shape":"box"},{"_gvid":46,"name":"[root] aws_iam_role.lambda_generate_url_role","label":"aws_iam_role.lambda_generate_url_role","shape":"box"},{"_gvid":47,"name":"[root] aws_iam_role.lambda_remove_urls_role","label":"aws_iam_role.lambda_remove_urls_role","shape":"box"},{"_gvid":48,"name":"[root] aws_iam_role.lambda_upload_url_role","label":"aws_iam_role.lambda_upload_url_role","shape":"box"},{"_gvid":49,"name":"[root] aws_iam_role_policy_attachment.invokehelper_gen","label":"aws_iam_role_policy_attachment.invokehelper_gen","shape":"box"},{"_gvid":50,"name":"[root] aws_iam_role_policy_attachment.invokehelper_remove","label":"aws_iam_role_policy_attachment.invokehelper_remove","shape":"box"},{"_gvid":51,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_fetch","label":"aws_iam_role_policy_attachment.lambdabasic_fetch","shape":"box"},{"_gvid":52,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_gen","label":"aws_iam_role_policy_attachment.lambdabasic_gen","shape":"box"},{"_gvid":53,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_genhelp","label":"aws_iam_role_policy_attachment.lambdabasic_genhelp","shape":"box"},{"_gvid":54,"name":"[root] aws_iam_role_policy_attachment.s3full_gen","label":"aws_iam_role_policy_attachment.s3full_gen","shape":"box"},{"_gvid":55,"name":"[root] aws_iam_role_policy_attachment.s3full_remove","label":"aws_iam_role_policy_attachment.s3full_remove","shape":"box"},{"_gvid":56,"name":"[root] aws_iam_role_policy_attachment.s3ip_genhelp","label":"aws_iam_role_policy_attachment.s3ip_genhelp","shape":"box"},{"_gvid":57,"name":"[root] aws_iam_role_policy_attachment.s3ip_upload","label":"aws_iam_role_policy_attachment.s3ip_upload","shape":"box"},{"_gvid":58,"name":"[root] aws_iam_role_policy_attachment.s3read_fetch","label":"aws_iam_role_policy_attachment.s3read_fetch","shape":"box"},{"_gvid":59,"name":"[root] aws_lambda_function.fetch","label":"aws_lambda_function.fetch","shape":"box"},{"_gvid":60,"name":"[root] aws_lambda_function.gen","label":"aws_lambda_function.gen","shape":"box"},{"_gvid":61,"name":"[root] aws_lambda_function.genhelp","label":"aws_lambda_function.genhelp","shape":"box"},{"_gvid":62,"name":"[root] aws_lambda_function.remove","label":"aws_lambda_function.remove","shape":"box"},{"_gvid":63,"name":"[root] aws_lambda_function.upload","label":"aws_lambda_function.upload","shape":"box"},{"_gvid":64,"name":"[root] aws_lambda_permission.allow_cloudwatch_to_call_check_foo","label":"aws_lambda_permission.allow_cloudwatch_to_call_check_foo","shape":"box"},{"_gvid":65,"name":"[root] aws_lambda_permission.apigw_fetch_lambda","label":"aws_lambda_permission.apigw_fetch_lambda","shape":"box"},{"_gvid":66,"name":"[root] aws_lambda_permission.apigw_generate_lambda","label":"aws_lambda_permission.apigw_generate_lambda","shape":"box"},{"_gvid":67,"name":"[root] aws_lambda_permission.apigw_upload_lambda","label":"aws_lambda_permission.apigw_upload_lambda","shape":"box"},{"_gvid":68,"name":"[root] aws_route53_record.route","label":"aws_route53_record.route","shape":"box"},{"_gvid":69,"name":"[root] aws_route53_zone.primary","label":"aws_route53_zone.primary","shape":"box"},{"_gvid":70,"name":"[root] aws_s3_bucket.download_bucket","label":"aws_s3_bucket.download_bucket","shape":"box"},{"_gvid":71,"name":"[root] aws_s3_bucket.upload_bucket","label":"aws_s3_bucket.upload_bucket","shape":"box"},{"_gvid":72,"name":"[root] aws_s3_bucket_public_access_block.private_download_bucket","label":"aws_s3_bucket_public_access_block.private_download_bucket","shape":"box"},{"_gvid":73,"name":"[root] aws_s3_bucket_public_access_block.private_upload_bucket","label":"aws_s3_bucket_public_access_block.private_upload_bucket","shape":"box"},{"_gvid":74,"name":"[root] data.archive_file.fetch_object_code","label":"data.archive_file.fetch_object_code","shape":"box"},{"_gvid":75,"name":"[root] data.archive_file.generate_url_helper_code","label":"data.archive_file.generate_url_helper_code","shape":"box"},{"_gvid":76,"name":"[root] data.archive_file.generate_url_main_code","label":"data.archive_file.generate_url_main_code","shape":"box"},{"_gvid":77,"name":"[root] data.archive_file.remove_expired_urls_code","label":"data.archive_file.remove_expired_urls_code","shape":"box"},{"_gvid":78,"name":"[root] data.archive_file.upload_url_code","label":"data.archive_file.upload_url_code","shape":"box"},{"_gvid":79,"name":"[root] data.aws_acm_certificate.cert","label":"data.aws_acm_certificate.cert","shape":"box"},{"_gvid":80,"name":"[root] null_resource.build_image","label":"null_resource.build_image","shape":"box"},{"_gvid":81,"name":"[root] provider.archive","label":"provider.archive","shape":"diamond"},{"_gvid":82,"name":"[root] provider.aws","label":"provider.aws","shape":"diamond"},{"_gvid":83,"name":"[root] meta.count-boundary (EachMode fixup)","label":"\\N"},{"_gvid":84,"name":"[root] provider.archive (close)","label":"\\N"},{"_gvid":85,"name":"[root] provider.aws (close)","label":"\\N"},{"_gvid":86,"name":"[root] provider.null (close)","label":"\\N"},{"_gvid":87,"name":"[root] provisioner.local-exec (close)","label":"\\N"},{"_gvid":88,"name":"[root] root","label":"\\N"}],"edges":[{"_gvid":0,"tail":1,"head":2},{"_gvid":1,"tail":1,"head":3},{"_gvid":2,"tail":2,"head":4},{"_gvid":3,"tail":2,"head":5},{"_gvid":4,"tail":2,"head":7},{"_gvid":5,"tail":3,"head":79},{"_gvid":6,"tail":4,"head":14},{"_gvid":7,"tail":4,"head":59},{"_gvid":8,"tail":5,"head":15},{"_gvid":9,"tail":5,"head":60},{"_gvid":10,"tail":6,"head":16},{"_gvid":11,"tail":7,"head":17},{"_gvid":12,"tail":7,"head":63},{"_gvid":13,"tail":8,"head":18},{"_gvid":14,"tail":9,"head":4},{"_gvid":15,"tail":9,"head":19},{"_gvid":16,"tail":10,"head":22},{"_gvid":17,"tail":10,"head":70},{"_gvid":18,"tail":11,"head":26},{"_gvid":19,"tail":11,"head":70},{"_gvid":20,"tail":12,"head":28},{"_gvid":21,"tail":12,"head":71},{"_gvid":22,"tail":13,"head":31},{"_gvid":23,"tail":13,"head":71},{"_gvid":24,"tail":14,"head":32},{"_gvid":25,"tail":14,"head":34},{"_gvid":26,"tail":15,"head":33},{"_gvid":27,"tail":15,"head":35},{"_gvid":28,"tail":16,"head":35},{"_gvid":29,"tail":17,"head":36},{"_gvid":30,"tail":18,"head":36},{"_gvid":31,"tail":19,"head":14},{"_gvid":32,"tail":20,"head":14},{"_gvid":33,"tail":21,"head":15},{"_gvid":34,"tail":22,"head":15},{"_gvid":35,"tail":23,"head":15},{"_gvid":36,"tail":24,"head":15},{"_gvid":37,"tail":25,"head":15},{"_gvid":38,"tail":26,"head":16},{"_gvid":39,"tail":27,"head":17},{"_gvid":40,"tail":28,"head":17},{"_gvid":41,"tail":29,"head":17},{"_gvid":42,"tail":30,"head":17},{"_gvid":43,"tail":31,"head":18},{"_gvid":44,"tail":32,"head":37},{"_gvid":45,"tail":33,"head":37},{"_gvid":46,"tail":34,"head":37},{"_gvid":47,"tail":35,"head":37},{"_gvid":48,"tail":36,"head":37},{"_gvid":49,"tail":37,"head":82},{"_gvid":50,"tail":38,"head":82},{"_gvid":51,"tail":39,"head":38},{"_gvid":52,"tail":39,"head":62},{"_gvid":53,"tail":40,"head":61},{"_gvid":54,"tail":41,"head":82},{"_gvid":55,"tail":42,"head":82},{"_gvid":56,"tail":43,"head":82},{"_gvid":57,"tail":44,"head":82},{"_gvid":58,"tail":45,"head":82},{"_gvid":59,"tail":46,"head":82},{"_gvid":60,"tail":47,"head":82},{"_gvid":61,"tail":48,"head":82},{"_gvid":62,"tail":49,"head":40},{"_gvid":63,"tail":49,"head":46},{"_gvid":64,"tail":50,"head":40},{"_gvid":65,"tail":50,"head":47},{"_gvid":66,"tail":51,"head":44},{"_gvid":67,"tail":52,"head":46},{"_gvid":68,"tail":53,"head":45},{"_gvid":69,"tail":54,"head":46},{"_gvid":70,"tail":55,"head":47},{"_gvid":71,"tail":56,"head":41},{"_gvid":72,"tail":56,"head":45},{"_gvid":73,"tail":57,"head":42},{"_gvid":74,"tail":57,"head":48},{"_gvid":75,"tail":58,"head":43},{"_gvid":76,"tail":58,"head":44},{"_gvid":77,"tail":59,"head":44},{"_gvid":78,"tail":59,"head":70},{"_gvid":79,"tail":59,"head":74},{"_gvid":80,"tail":60,"head":46},{"_gvid":81,"tail":60,"head":70},{"_gvid":82,"tail":60,"head":76},{"_gvid":83,"tail":61,"head":45},{"_gvid":84,"tail":61,"head":75},{"_gvid":85,"tail":62,"head":47},{"_gvid":86,"tail":62,"head":70},{"_gvid":87,"tail":62,"head":77},{"_gvid":88,"tail":63,"head":48},{"_gvid":89,"tail":63,"head":71},{"_gvid":90,"tail":63,"head":78},{"_gvid":91,"tail":64,"head":38},{"_gvid":92,"tail":64,"head":62},{"_gvid":93,"tail":65,"head":14},{"_gvid":94,"tail":65,"head":59},{"_gvid":95,"tail":66,"head":15},{"_gvid":96,"tail":66,"head":60},{"_gvid":97,"tail":67,"head":17},{"_gvid":98,"tail":67,"head":63},{"_gvid":99,"tail":68,"head":3},{"_gvid":100,"tail":68,"head":69},{"_gvid":101,"tail":69,"head":82},{"_gvid":102,"tail":70,"head":82},{"_gvid":103,"tail":71,"head":70},{"_gvid":104,"tail":72,"head":70},{"_gvid":105,"tail":73,"head":71},{"_gvid":106,"tail":74,"head":81},{"_gvid":107,"tail":75,"head":81},{"_gvid":108,"tail":76,"head":81},{"_gvid":109,"tail":77,"head":81},{"_gvid":110,"tail":78,"head":81},{"_gvid":111,"tail":79,"head":82},{"_gvid":112,"tail":80,"head":71},{"_gvid":113,"tail":83,"head":1},{"_gvid":114,"tail":83,"head":6},{"_gvid":115,"tail":83,"head":8},{"_gvid":116,"tail":83,"head":9},{"_gvid":117,"tail":83,"head":10},{"_gvid":118,"tail":83,"head":11},{"_gvid":119,"tail":83,"head":12},{"_gvid":120,"tail":83,"head":13},{"_gvid":121,"tail":83,"head":20},{"_gvid":122,"tail":83,"head":21},{"_gvid":123,"tail":83,"head":23},{"_gvid":124,"tail":83,"head":24},{"_gvid":125,"tail":83,"head":25},{"_gvid":126,"tail":83,"head":27},{"_gvid":127,"tail":83,"head":29},{"_gvid":128,"tail":83,"head":30},{"_gvid":129,"tail":83,"head":39},{"_gvid":130,"tail":83,"head":49},{"_gvid":131,"tail":83,"head":50},{"_gvid":132,"tail":83,"head":51},{"_gvid":133,"tail":83,"head":52},{"_gvid":134,"tail":83,"head":53},{"_gvid":135,"tail":83,"head":54},{"_gvid":136,"tail":83,"head":55},{"_gvid":137,"tail":83,"head":56},{"_gvid":138,"tail":83,"head":57},{"_gvid":139,"tail":83,"head":58},{"_gvid":140,"tail":83,"head":64},{"_gvid":141,"tail":83,"head":65},{"_gvid":142,"tail":83,"head":66},{"_gvid":143,"tail":83,"head":67},{"_gvid":144,"tail":83,"head":68},{"_gvid":145,"tail":83,"head":72},{"_gvid":146,"tail":83,"head":73},{"_gvid":147,"tail":83,"head":80},{"_gvid":148,"tail":84,"head":74},{"_gvid":149,"tail":84,"head":75},{"_gvid":150,"tail":84,"head":76},{"_gvid":151,"tail":84,"head":77},{"_gvid":152,"tail":84,"head":78},{"_gvid":153,"tail":85,"head":1},{"_gvid":154,"tail":85,"head":6},{"_gvid":155,"tail":85,"head":8},{"_gvid":156,"tail":85,"head":9},{"_gvid":157,"tail":85,"head":10},{"_gvid":158,"tail":85,"head":11},{"_gvid":159,"tail":85,"head":12},{"_gvid":160,"tail":85,"head":13},{"_gvid":161,"tail":85,"head":20},{"_gvid":162,"tail":85,"head":21},{"_gvid":163,"tail":85,"head":23},{"_gvid":164,"tail":85,"head":24},{"_gvid":165,"tail":85,"head":25},{"_gvid":166,"tail":85,"head":27},{"_gvid":167,"tail":85,"head":29},{"_gvid":168,"tail":85,"head":30},{"_gvid":169,"tail":85,"head":39},{"_gvid":170,"tail":85,"head":49},{"_gvid":171,"tail":85,"head":50},{"_gvid":172,"tail":85,"head":51},{"_gvid":173,"tail":85,"head":52},{"_gvid":174,"tail":85,"head":53},{"_gvid":175,"tail":85,"head":54},{"_gvid":176,"tail":85,"head":55},{"_gvid":177,"tail":85,"head":56},{"_gvid":178,"tail":85,"head":57},{"_gvid":179,"tail":85,"head":58},{"_gvid":180,"tail":85,"head":64},{"_gvid":181,"tail":85,"head":65},{"_gvid":182,"tail":85,"head":66},{"_gvid":183,"tail":85,"head":67},{"_gvid":184,"tail":85,"head":68},{"_gvid":185,"tail":85,"head":72},{"_gvid":186,"tail":85,"head":73},{"_gvid":187,"tail":86,"head":80},{"_gvid":188,"tail":87,"head":80},{"_gvid":189,"tail":88,"head":83},{"_gvid":190,"tail":88,"head":84},{"_gvid":191,"tail":88,"head":85},{"_gvid":192,"tail":88,"head":86},{"_gvid":193,"tail":88,"head":87}]}' + # json_string = r'{"name":"%3","directed":true,"strict":false,"compound":"true","newrank":"true","_subgraph_cnt":1,"objects":[{"name":"root","compound":"true","newrank":"true","_gvid":0,"nodes":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88],"edges":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193]},{"_gvid":1,"name":"[root] aws_api_gateway_base_path_mapping.base_path","label":"aws_api_gateway_base_path_mapping.base_path","shape":"box"},{"_gvid":2,"name":"[root] aws_api_gateway_deployment.deployment","label":"aws_api_gateway_deployment.deployment","shape":"box"},{"_gvid":3,"name":"[root] aws_api_gateway_domain_name.urlapi","label":"aws_api_gateway_domain_name.urlapi","shape":"box"},{"_gvid":4,"name":"[root] aws_api_gateway_integration.fetch_integration","label":"aws_api_gateway_integration.fetch_integration","shape":"box"},{"_gvid":5,"name":"[root] aws_api_gateway_integration.generate_integration","label":"aws_api_gateway_integration.generate_integration","shape":"box"},{"_gvid":6,"name":"[root] aws_api_gateway_integration.generate_options_integration","label":"aws_api_gateway_integration.generate_options_integration","shape":"box"},{"_gvid":7,"name":"[root] aws_api_gateway_integration.upload_integration","label":"aws_api_gateway_integration.upload_integration","shape":"box"},{"_gvid":8,"name":"[root] aws_api_gateway_integration.upload_options_integration","label":"aws_api_gateway_integration.upload_options_integration","shape":"box"},{"_gvid":9,"name":"[root] aws_api_gateway_integration_response.fetch_ir_200","label":"aws_api_gateway_integration_response.fetch_ir_200","shape":"box"},{"_gvid":10,"name":"[root] aws_api_gateway_integration_response.generate_ir_400","label":"aws_api_gateway_integration_response.generate_ir_400","shape":"box"},{"_gvid":11,"name":"[root] aws_api_gateway_integration_response.generate_options_integration_response","label":"aws_api_gateway_integration_response.generate_options_integration_response","shape":"box"},{"_gvid":12,"name":"[root] aws_api_gateway_integration_response.upload_ir_400","label":"aws_api_gateway_integration_response.upload_ir_400","shape":"box"},{"_gvid":13,"name":"[root] aws_api_gateway_integration_response.upload_options_integration_response","label":"aws_api_gateway_integration_response.upload_options_integration_response","shape":"box"},{"_gvid":14,"name":"[root] aws_api_gateway_method.fetch","label":"aws_api_gateway_method.fetch","shape":"box"},{"_gvid":15,"name":"[root] aws_api_gateway_method.generate","label":"aws_api_gateway_method.generate","shape":"box"},{"_gvid":16,"name":"[root] aws_api_gateway_method.generate_options","label":"aws_api_gateway_method.generate_options","shape":"box"},{"_gvid":17,"name":"[root] aws_api_gateway_method.upload","label":"aws_api_gateway_method.upload","shape":"box"},{"_gvid":18,"name":"[root] aws_api_gateway_method.upload_options","label":"aws_api_gateway_method.upload_options","shape":"box"},{"_gvid":19,"name":"[root] aws_api_gateway_method_response.fetch_200","label":"aws_api_gateway_method_response.fetch_200","shape":"box"},{"_gvid":20,"name":"[root] aws_api_gateway_method_response.fetch_400","label":"aws_api_gateway_method_response.fetch_400","shape":"box"},{"_gvid":21,"name":"[root] aws_api_gateway_method_response.generate_200","label":"aws_api_gateway_method_response.generate_200","shape":"box"},{"_gvid":22,"name":"[root] aws_api_gateway_method_response.generate_400","label":"aws_api_gateway_method_response.generate_400","shape":"box"},{"_gvid":23,"name":"[root] aws_api_gateway_method_response.generate_401","label":"aws_api_gateway_method_response.generate_401","shape":"box"},{"_gvid":24,"name":"[root] aws_api_gateway_method_response.generate_404","label":"aws_api_gateway_method_response.generate_404","shape":"box"},{"_gvid":25,"name":"[root] aws_api_gateway_method_response.generate_500","label":"aws_api_gateway_method_response.generate_500","shape":"box"},{"_gvid":26,"name":"[root] aws_api_gateway_method_response.generate_options_200","label":"aws_api_gateway_method_response.generate_options_200","shape":"box"},{"_gvid":27,"name":"[root] aws_api_gateway_method_response.upload_200","label":"aws_api_gateway_method_response.upload_200","shape":"box"},{"_gvid":28,"name":"[root] aws_api_gateway_method_response.upload_400","label":"aws_api_gateway_method_response.upload_400","shape":"box"},{"_gvid":29,"name":"[root] aws_api_gateway_method_response.upload_401","label":"aws_api_gateway_method_response.upload_401","shape":"box"},{"_gvid":30,"name":"[root] aws_api_gateway_method_response.upload_500","label":"aws_api_gateway_method_response.upload_500","shape":"box"},{"_gvid":31,"name":"[root] aws_api_gateway_method_response.upload_options_200","label":"aws_api_gateway_method_response.upload_options_200","shape":"box"},{"_gvid":32,"name":"[root] aws_api_gateway_request_validator.fetch_validator","label":"aws_api_gateway_request_validator.fetch_validator","shape":"box"},{"_gvid":33,"name":"[root] aws_api_gateway_request_validator.generate_validator","label":"aws_api_gateway_request_validator.generate_validator","shape":"box"},{"_gvid":34,"name":"[root] aws_api_gateway_resource.fetch_resource","label":"aws_api_gateway_resource.fetch_resource","shape":"box"},{"_gvid":35,"name":"[root] aws_api_gateway_resource.generate_resource","label":"aws_api_gateway_resource.generate_resource","shape":"box"},{"_gvid":36,"name":"[root] aws_api_gateway_resource.upload_resource","label":"aws_api_gateway_resource.upload_resource","shape":"box"},{"_gvid":37,"name":"[root] aws_api_gateway_rest_api.api","label":"aws_api_gateway_rest_api.api","shape":"box"},{"_gvid":38,"name":"[root] aws_cloudwatch_event_rule.everyday","label":"aws_cloudwatch_event_rule.everyday","shape":"box"},{"_gvid":39,"name":"[root] aws_cloudwatch_event_target.clean_up_urls_everyday","label":"aws_cloudwatch_event_target.clean_up_urls_everyday","shape":"box"},{"_gvid":40,"name":"[root] aws_iam_policy.invoke","label":"aws_iam_policy.invoke","shape":"box"},{"_gvid":41,"name":"[root] aws_iam_policy.ip","label":"aws_iam_policy.ip","shape":"box"},{"_gvid":42,"name":"[root] aws_iam_policy.ip_put","label":"aws_iam_policy.ip_put","shape":"box"},{"_gvid":43,"name":"[root] aws_iam_policy.lambda_fetch_s3","label":"aws_iam_policy.lambda_fetch_s3","shape":"box"},{"_gvid":44,"name":"[root] aws_iam_role.lambda_fetch_object_role","label":"aws_iam_role.lambda_fetch_object_role","shape":"box"},{"_gvid":45,"name":"[root] aws_iam_role.lambda_generate_url_helper_role","label":"aws_iam_role.lambda_generate_url_helper_role","shape":"box"},{"_gvid":46,"name":"[root] aws_iam_role.lambda_generate_url_role","label":"aws_iam_role.lambda_generate_url_role","shape":"box"},{"_gvid":47,"name":"[root] aws_iam_role.lambda_remove_urls_role","label":"aws_iam_role.lambda_remove_urls_role","shape":"box"},{"_gvid":48,"name":"[root] aws_iam_role.lambda_upload_url_role","label":"aws_iam_role.lambda_upload_url_role","shape":"box"},{"_gvid":49,"name":"[root] aws_iam_role_policy_attachment.invokehelper_gen","label":"aws_iam_role_policy_attachment.invokehelper_gen","shape":"box"},{"_gvid":50,"name":"[root] aws_iam_role_policy_attachment.invokehelper_remove","label":"aws_iam_role_policy_attachment.invokehelper_remove","shape":"box"},{"_gvid":51,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_fetch","label":"aws_iam_role_policy_attachment.lambdabasic_fetch","shape":"box"},{"_gvid":52,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_gen","label":"aws_iam_role_policy_attachment.lambdabasic_gen","shape":"box"},{"_gvid":53,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_genhelp","label":"aws_iam_role_policy_attachment.lambdabasic_genhelp","shape":"box"},{"_gvid":54,"name":"[root] aws_iam_role_policy_attachment.s3full_gen","label":"aws_iam_role_policy_attachment.s3full_gen","shape":"box"},{"_gvid":55,"name":"[root] aws_iam_role_policy_attachment.s3full_remove","label":"aws_iam_role_policy_attachment.s3full_remove","shape":"box"},{"_gvid":56,"name":"[root] aws_iam_role_policy_attachment.s3ip_genhelp","label":"aws_iam_role_policy_attachment.s3ip_genhelp","shape":"box"},{"_gvid":57,"name":"[root] aws_iam_role_policy_attachment.s3ip_upload","label":"aws_iam_role_policy_attachment.s3ip_upload","shape":"box"},{"_gvid":58,"name":"[root] aws_iam_role_policy_attachment.s3read_fetch","label":"aws_iam_role_policy_attachment.s3read_fetch","shape":"box"},{"_gvid":59,"name":"[root] aws_lambda_function.fetch","label":"aws_lambda_function.fetch","shape":"box"},{"_gvid":60,"name":"[root] aws_lambda_function.gen","label":"aws_lambda_function.gen","shape":"box"},{"_gvid":61,"name":"[root] aws_lambda_function.genhelp","label":"aws_lambda_function.genhelp","shape":"box"},{"_gvid":62,"name":"[root] aws_lambda_function.remove","label":"aws_lambda_function.remove","shape":"box"},{"_gvid":63,"name":"[root] aws_lambda_function.upload","label":"aws_lambda_function.upload","shape":"box"},{"_gvid":64,"name":"[root] aws_lambda_permission.allow_cloudwatch_to_call_check_foo","label":"aws_lambda_permission.allow_cloudwatch_to_call_check_foo","shape":"box"},{"_gvid":65,"name":"[root] aws_lambda_permission.apigw_fetch_lambda","label":"aws_lambda_permission.apigw_fetch_lambda","shape":"box"},{"_gvid":66,"name":"[root] aws_lambda_permission.apigw_generate_lambda","label":"aws_lambda_permission.apigw_generate_lambda","shape":"box"},{"_gvid":67,"name":"[root] aws_lambda_permission.apigw_upload_lambda","label":"aws_lambda_permission.apigw_upload_lambda","shape":"box"},{"_gvid":68,"name":"[root] aws_route53_record.route","label":"aws_route53_record.route","shape":"box"},{"_gvid":69,"name":"[root] aws_route53_zone.primary","label":"aws_route53_zone.primary","shape":"box"},{"_gvid":70,"name":"[root] aws_s3_bucket.download_bucket","label":"aws_s3_bucket.download_bucket","shape":"box"},{"_gvid":71,"name":"[root] aws_s3_bucket.upload_bucket","label":"aws_s3_bucket.upload_bucket","shape":"box"},{"_gvid":72,"name":"[root] aws_s3_bucket_public_access_block.private_download_bucket","label":"aws_s3_bucket_public_access_block.private_download_bucket","shape":"box"},{"_gvid":73,"name":"[root] aws_s3_bucket_public_access_block.private_upload_bucket","label":"aws_s3_bucket_public_access_block.private_upload_bucket","shape":"box"},{"_gvid":74,"name":"[root] data.archive_file.fetch_object_code","label":"data.archive_file.fetch_object_code","shape":"box"},{"_gvid":75,"name":"[root] data.archive_file.generate_url_helper_code","label":"data.archive_file.generate_url_helper_code","shape":"box"},{"_gvid":76,"name":"[root] data.archive_file.generate_url_main_code","label":"data.archive_file.generate_url_main_code","shape":"box"},{"_gvid":77,"name":"[root] data.archive_file.remove_expired_urls_code","label":"data.archive_file.remove_expired_urls_code","shape":"box"},{"_gvid":78,"name":"[root] data.archive_file.upload_url_code","label":"data.archive_file.upload_url_code","shape":"box"},{"_gvid":79,"name":"[root] data.aws_acm_certificate.cert","label":"data.aws_acm_certificate.cert","shape":"box"},{"_gvid":80,"name":"[root] null_resource.build_image","label":"null_resource.build_image","shape":"box"},{"_gvid":81,"name":"[root] provider.archive","label":"provider.archive","shape":"diamond"},{"_gvid":82,"name":"[root] provider.aws","label":"provider.aws","shape":"diamond"},{"_gvid":83,"name":"[root] meta.count-boundary (EachMode fixup)","label":"\\N"},{"_gvid":84,"name":"[root] provider.archive (close)","label":"\\N"},{"_gvid":85,"name":"[root] provider.aws (close)","label":"\\N"},{"_gvid":86,"name":"[root] provider.null (close)","label":"\\N"},{"_gvid":87,"name":"[root] provisioner.local-exec (close)","label":"\\N"},{"_gvid":88,"name":"[root] root","label":"\\N"}],"edges":[{"_gvid":0,"tail":1,"head":2},{"_gvid":1,"tail":1,"head":3},{"_gvid":2,"tail":2,"head":4},{"_gvid":3,"tail":2,"head":5},{"_gvid":4,"tail":2,"head":7},{"_gvid":5,"tail":3,"head":79},{"_gvid":6,"tail":4,"head":14},{"_gvid":7,"tail":4,"head":59},{"_gvid":8,"tail":5,"head":15},{"_gvid":9,"tail":5,"head":60},{"_gvid":10,"tail":6,"head":16},{"_gvid":11,"tail":7,"head":17},{"_gvid":12,"tail":7,"head":63},{"_gvid":13,"tail":8,"head":18},{"_gvid":14,"tail":9,"head":4},{"_gvid":15,"tail":9,"head":19},{"_gvid":16,"tail":10,"head":22},{"_gvid":17,"tail":10,"head":70},{"_gvid":18,"tail":11,"head":26},{"_gvid":19,"tail":11,"head":70},{"_gvid":20,"tail":12,"head":28},{"_gvid":21,"tail":12,"head":71},{"_gvid":22,"tail":13,"head":31},{"_gvid":23,"tail":13,"head":71},{"_gvid":24,"tail":14,"head":32},{"_gvid":25,"tail":14,"head":34},{"_gvid":26,"tail":15,"head":33},{"_gvid":27,"tail":15,"head":35},{"_gvid":28,"tail":16,"head":35},{"_gvid":29,"tail":17,"head":36},{"_gvid":30,"tail":18,"head":36},{"_gvid":31,"tail":19,"head":14},{"_gvid":32,"tail":20,"head":14},{"_gvid":33,"tail":21,"head":15},{"_gvid":34,"tail":22,"head":15},{"_gvid":35,"tail":23,"head":15},{"_gvid":36,"tail":24,"head":15},{"_gvid":37,"tail":25,"head":15},{"_gvid":38,"tail":26,"head":16},{"_gvid":39,"tail":27,"head":17},{"_gvid":40,"tail":28,"head":17},{"_gvid":41,"tail":29,"head":17},{"_gvid":42,"tail":30,"head":17},{"_gvid":43,"tail":31,"head":18},{"_gvid":44,"tail":32,"head":37},{"_gvid":45,"tail":33,"head":37},{"_gvid":46,"tail":34,"head":37},{"_gvid":47,"tail":35,"head":37},{"_gvid":48,"tail":36,"head":37},{"_gvid":49,"tail":37,"head":82},{"_gvid":50,"tail":38,"head":82},{"_gvid":51,"tail":39,"head":38},{"_gvid":52,"tail":39,"head":62},{"_gvid":53,"tail":40,"head":61},{"_gvid":54,"tail":41,"head":82},{"_gvid":55,"tail":42,"head":82},{"_gvid":56,"tail":43,"head":82},{"_gvid":57,"tail":44,"head":82},{"_gvid":58,"tail":45,"head":82},{"_gvid":59,"tail":46,"head":82},{"_gvid":60,"tail":47,"head":82},{"_gvid":61,"tail":48,"head":82},{"_gvid":62,"tail":49,"head":40},{"_gvid":63,"tail":49,"head":46},{"_gvid":64,"tail":50,"head":40},{"_gvid":65,"tail":50,"head":47},{"_gvid":66,"tail":51,"head":44},{"_gvid":67,"tail":52,"head":46},{"_gvid":68,"tail":53,"head":45},{"_gvid":69,"tail":54,"head":46},{"_gvid":70,"tail":55,"head":47},{"_gvid":71,"tail":56,"head":41},{"_gvid":72,"tail":56,"head":45},{"_gvid":73,"tail":57,"head":42},{"_gvid":74,"tail":57,"head":48},{"_gvid":75,"tail":58,"head":43},{"_gvid":76,"tail":58,"head":44},{"_gvid":77,"tail":59,"head":44},{"_gvid":78,"tail":59,"head":70},{"_gvid":79,"tail":59,"head":74},{"_gvid":80,"tail":60,"head":46},{"_gvid":81,"tail":60,"head":70},{"_gvid":82,"tail":60,"head":76},{"_gvid":83,"tail":61,"head":45},{"_gvid":84,"tail":61,"head":75},{"_gvid":85,"tail":62,"head":47},{"_gvid":86,"tail":62,"head":70},{"_gvid":87,"tail":62,"head":77},{"_gvid":88,"tail":63,"head":48},{"_gvid":89,"tail":63,"head":71},{"_gvid":90,"tail":63,"head":78},{"_gvid":91,"tail":64,"head":38},{"_gvid":92,"tail":64,"head":62},{"_gvid":93,"tail":65,"head":14},{"_gvid":94,"tail":65,"head":59},{"_gvid":95,"tail":66,"head":15},{"_gvid":96,"tail":66,"head":60},{"_gvid":97,"tail":67,"head":17},{"_gvid":98,"tail":67,"head":63},{"_gvid":99,"tail":68,"head":3},{"_gvid":100,"tail":68,"head":69},{"_gvid":101,"tail":69,"head":82},{"_gvid":102,"tail":70,"head":82},{"_gvid":103,"tail":71,"head":70},{"_gvid":104,"tail":72,"head":70},{"_gvid":105,"tail":73,"head":71},{"_gvid":106,"tail":74,"head":81},{"_gvid":107,"tail":75,"head":81},{"_gvid":108,"tail":76,"head":81},{"_gvid":109,"tail":77,"head":81},{"_gvid":110,"tail":78,"head":81},{"_gvid":111,"tail":79,"head":82},{"_gvid":112,"tail":80,"head":71},{"_gvid":113,"tail":83,"head":1},{"_gvid":114,"tail":83,"head":6},{"_gvid":115,"tail":83,"head":8},{"_gvid":116,"tail":83,"head":9},{"_gvid":117,"tail":83,"head":10},{"_gvid":118,"tail":83,"head":11},{"_gvid":119,"tail":83,"head":12},{"_gvid":120,"tail":83,"head":13},{"_gvid":121,"tail":83,"head":20},{"_gvid":122,"tail":83,"head":21},{"_gvid":123,"tail":83,"head":23},{"_gvid":124,"tail":83,"head":24},{"_gvid":125,"tail":83,"head":25},{"_gvid":126,"tail":83,"head":27},{"_gvid":127,"tail":83,"head":29},{"_gvid":128,"tail":83,"head":30},{"_gvid":129,"tail":83,"head":39},{"_gvid":130,"tail":83,"head":49},{"_gvid":131,"tail":83,"head":50},{"_gvid":132,"tail":83,"head":51},{"_gvid":133,"tail":83,"head":52},{"_gvid":134,"tail":83,"head":53},{"_gvid":135,"tail":83,"head":54},{"_gvid":136,"tail":83,"head":55},{"_gvid":137,"tail":83,"head":56},{"_gvid":138,"tail":83,"head":57},{"_gvid":139,"tail":83,"head":58},{"_gvid":140,"tail":83,"head":64},{"_gvid":141,"tail":83,"head":65},{"_gvid":142,"tail":83,"head":66},{"_gvid":143,"tail":83,"head":67},{"_gvid":144,"tail":83,"head":68},{"_gvid":145,"tail":83,"head":72},{"_gvid":146,"tail":83,"head":73},{"_gvid":147,"tail":83,"head":80},{"_gvid":148,"tail":84,"head":74},{"_gvid":149,"tail":84,"head":75},{"_gvid":150,"tail":84,"head":76},{"_gvid":151,"tail":84,"head":77},{"_gvid":152,"tail":84,"head":78},{"_gvid":153,"tail":85,"head":1},{"_gvid":154,"tail":85,"head":6},{"_gvid":155,"tail":85,"head":8},{"_gvid":156,"tail":85,"head":9},{"_gvid":157,"tail":85,"head":10},{"_gvid":158,"tail":85,"head":11},{"_gvid":159,"tail":85,"head":12},{"_gvid":160,"tail":85,"head":13},{"_gvid":161,"tail":85,"head":20},{"_gvid":162,"tail":85,"head":21},{"_gvid":163,"tail":85,"head":23},{"_gvid":164,"tail":85,"head":24},{"_gvid":165,"tail":85,"head":25},{"_gvid":166,"tail":85,"head":27},{"_gvid":167,"tail":85,"head":29},{"_gvid":168,"tail":85,"head":30},{"_gvid":169,"tail":85,"head":39},{"_gvid":170,"tail":85,"head":49},{"_gvid":171,"tail":85,"head":50},{"_gvid":172,"tail":85,"head":51},{"_gvid":173,"tail":85,"head":52},{"_gvid":174,"tail":85,"head":53},{"_gvid":175,"tail":85,"head":54},{"_gvid":176,"tail":85,"head":55},{"_gvid":177,"tail":85,"head":56},{"_gvid":178,"tail":85,"head":57},{"_gvid":179,"tail":85,"head":58},{"_gvid":180,"tail":85,"head":64},{"_gvid":181,"tail":85,"head":65},{"_gvid":182,"tail":85,"head":66},{"_gvid":183,"tail":85,"head":67},{"_gvid":184,"tail":85,"head":68},{"_gvid":185,"tail":85,"head":72},{"_gvid":186,"tail":85,"head":73},{"_gvid":187,"tail":86,"head":80},{"_gvid":188,"tail":87,"head":80},{"_gvid":189,"tail":88,"head":83},{"_gvid":190,"tail":88,"head":84},{"_gvid":191,"tail":88,"head":85},{"_gvid":192,"tail":88,"head":86},{"_gvid":193,"tail":88,"head":87}]}' + json_string = r'{"name":"%3","directed":true,"strict":false,"compound":"true","newrank":"true","_subgraph_cnt":1,"objects":[{"name":"root","compound":"true","newrank":"true","_gvid":0,"nodes":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33],"edges":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57]},{"_gvid":1,"name":"[root] aws_alb.main","label":"aws_alb.main","shape":"box"},{"_gvid":2,"name":"[root] aws_alb_listener.front_end","label":"aws_alb_listener.front_end","shape":"box"},{"_gvid":3,"name":"[root] aws_alb_target_group.test","label":"aws_alb_target_group.test","shape":"box"},{"_gvid":4,"name":"[root] aws_autoscaling_group.app","label":"aws_autoscaling_group.app","shape":"box"},{"_gvid":5,"name":"[root] aws_cloudwatch_log_group.app","label":"aws_cloudwatch_log_group.app","shape":"box"},{"_gvid":6,"name":"[root] aws_cloudwatch_log_group.ecs","label":"aws_cloudwatch_log_group.ecs","shape":"box"},{"_gvid":7,"name":"[root] aws_ecs_cluster.main","label":"aws_ecs_cluster.main","shape":"box"},{"_gvid":8,"name":"[root] aws_ecs_service.test","label":"aws_ecs_service.test","shape":"box"},{"_gvid":9,"name":"[root] aws_ecs_task_definition.ghost","label":"aws_ecs_task_definition.ghost","shape":"box"},{"_gvid":10,"name":"[root] aws_iam_instance_profile.app","label":"aws_iam_instance_profile.app","shape":"box"},{"_gvid":11,"name":"[root] aws_iam_role.app_instance","label":"aws_iam_role.app_instance","shape":"box"},{"_gvid":12,"name":"[root] aws_iam_role.ecs_service","label":"aws_iam_role.ecs_service","shape":"box"},{"_gvid":13,"name":"[root] aws_iam_role_policy.ecs_service","label":"aws_iam_role_policy.ecs_service","shape":"box"},{"_gvid":14,"name":"[root] aws_iam_role_policy.instance","label":"aws_iam_role_policy.instance","shape":"box"},{"_gvid":15,"name":"[root] aws_internet_gateway.gw","label":"aws_internet_gateway.gw","shape":"box"},{"_gvid":16,"name":"[root] aws_launch_configuration.app","label":"aws_launch_configuration.app","shape":"box"},{"_gvid":17,"name":"[root] aws_route_table.r","label":"aws_route_table.r","shape":"box"},{"_gvid":18,"name":"[root] aws_route_table_association.a","label":"aws_route_table_association.a","shape":"box"},{"_gvid":19,"name":"[root] aws_security_group.instance_sg","label":"aws_security_group.instance_sg","shape":"box"},{"_gvid":20,"name":"[root] aws_security_group.lb_sg","label":"aws_security_group.lb_sg","shape":"box"},{"_gvid":21,"name":"[root] aws_subnet.main","label":"aws_subnet.main","shape":"box"},{"_gvid":22,"name":"[root] aws_vpc.main","label":"aws_vpc.main","shape":"box"},{"_gvid":23,"name":"[root] data.aws_ami.stable_coreos","label":"data.aws_ami.stable_coreos","shape":"box"},{"_gvid":24,"name":"[root] data.aws_availability_zones.available","label":"data.aws_availability_zones.available","shape":"box"},{"_gvid":25,"name":"[root] data.template_file.cloud_config","label":"data.template_file.cloud_config","shape":"box"},{"_gvid":26,"name":"[root] data.template_file.instance_profile","label":"data.template_file.instance_profile","shape":"box"},{"_gvid":27,"name":"[root] data.template_file.task_definition","label":"data.template_file.task_definition","shape":"box"},{"_gvid":28,"name":"[root] provider.aws","label":"provider.aws","shape":"diamond"},{"_gvid":29,"name":"[root] provider.template","label":"provider.template","shape":"diamond"},{"_gvid":30,"name":"[root] meta.count-boundary (EachMode fixup)","label":"\\N"},{"_gvid":31,"name":"[root] provider.aws (close)","label":"\\N"},{"_gvid":32,"name":"[root] provider.template (close)","label":"\\N"},{"_gvid":33,"name":"[root] root","label":"\\N"}],"edges":[{"_gvid":0,"tail":1,"head":20},{"_gvid":1,"tail":1,"head":21},{"_gvid":2,"tail":2,"head":1},{"_gvid":3,"tail":2,"head":3},{"_gvid":4,"tail":3,"head":22},{"_gvid":5,"tail":4,"head":16},{"_gvid":6,"tail":4,"head":21},{"_gvid":7,"tail":5,"head":28},{"_gvid":8,"tail":6,"head":28},{"_gvid":9,"tail":7,"head":28},{"_gvid":10,"tail":8,"head":2},{"_gvid":11,"tail":8,"head":7},{"_gvid":12,"tail":8,"head":9},{"_gvid":13,"tail":8,"head":13},{"_gvid":14,"tail":9,"head":27},{"_gvid":15,"tail":9,"head":28},{"_gvid":16,"tail":10,"head":11},{"_gvid":17,"tail":11,"head":28},{"_gvid":18,"tail":12,"head":28},{"_gvid":19,"tail":13,"head":12},{"_gvid":20,"tail":14,"head":11},{"_gvid":21,"tail":14,"head":26},{"_gvid":22,"tail":15,"head":22},{"_gvid":23,"tail":16,"head":10},{"_gvid":24,"tail":16,"head":19},{"_gvid":25,"tail":16,"head":23},{"_gvid":26,"tail":16,"head":25},{"_gvid":27,"tail":17,"head":15},{"_gvid":28,"tail":18,"head":17},{"_gvid":29,"tail":18,"head":21},{"_gvid":30,"tail":19,"head":20},{"_gvid":31,"tail":20,"head":22},{"_gvid":32,"tail":21,"head":22},{"_gvid":33,"tail":21,"head":24},{"_gvid":34,"tail":22,"head":28},{"_gvid":35,"tail":23,"head":28},{"_gvid":36,"tail":24,"head":28},{"_gvid":37,"tail":25,"head":29},{"_gvid":38,"tail":26,"head":29},{"_gvid":39,"tail":27,"head":29},{"_gvid":40,"tail":30,"head":4},{"_gvid":41,"tail":30,"head":5},{"_gvid":42,"tail":30,"head":6},{"_gvid":43,"tail":30,"head":8},{"_gvid":44,"tail":30,"head":14},{"_gvid":45,"tail":30,"head":18},{"_gvid":46,"tail":31,"head":4},{"_gvid":47,"tail":31,"head":5},{"_gvid":48,"tail":31,"head":6},{"_gvid":49,"tail":31,"head":8},{"_gvid":50,"tail":31,"head":14},{"_gvid":51,"tail":31,"head":18},{"_gvid":52,"tail":32,"head":25},{"_gvid":53,"tail":32,"head":26},{"_gvid":54,"tail":32,"head":27},{"_gvid":55,"tail":33,"head":30},{"_gvid":56,"tail":33,"head":31},{"_gvid":57,"tail":33,"head":32}]}' + obj = json.loads(json_string) + root = obj['objects'][0]['nodes'][-1] - adj = {i:[] for i in obj['objects'][0]['nodes']} + adj = {(root-i):[] for i in obj['objects'][0]['nodes']} for edge in obj['edges']: - adj[edge['tail']].append(edge['head']) + adj[root-edge['tail']].insert(0, root-edge['head']) return adj @@ -321,10 +323,10 @@ def main(): } ''' adj = adjacency_list() - print(adj) nodes = list(adj.keys()) + print(adj) X, Y, Z, level = points(adj, len(nodes), nodes, 1) - print(level) + print(X, Y, Z, level) rev = reverse_level(level) coordinates = connect(X, Y, Z, level, adj) From aad477d07df0eed38464c012619f198ac2459866 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Sun, 5 Jan 2020 17:32:39 -0500 Subject: [PATCH 4/9] reversed nodes --- coordinates/prototype3.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/coordinates/prototype3.py b/coordinates/prototype3.py index db05999..369f3e8 100644 --- a/coordinates/prototype3.py +++ b/coordinates/prototype3.py @@ -324,9 +324,12 @@ def main(): ''' adj = adjacency_list() nodes = list(adj.keys()) + nodes.reverse() print(adj) + print(nodes) X, Y, Z, level = points(adj, len(nodes), nodes, 1) - print(X, Y, Z, level) + print(level) + # print(X, Y, Z, level) rev = reverse_level(level) coordinates = connect(X, Y, Z, level, adj) From 18c7bfc68bae2f22a9be31f107bffa15a8dca626 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Sun, 5 Jan 2020 19:14:08 -0500 Subject: [PATCH 5/9] fixed it --- coordinates/prototype3.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/coordinates/prototype3.py b/coordinates/prototype3.py index 369f3e8..8cced07 100644 --- a/coordinates/prototype3.py +++ b/coordinates/prototype3.py @@ -235,9 +235,10 @@ def connect(x, y, z, level, adj): ''' #print(adj) rev = reverse_level(level) - coordinates = {0: [0, 0, 0]} - for l in rev.keys(): + coordinates = {0: [0, 0, 0]} + for num in range(len(rev.keys())): + l = num+1 ## PREPROCESSING points = [] # candidate coordinates for next level @@ -251,12 +252,12 @@ def connect(x, y, z, level, adj): # print(points) ordered = rev[l] # nodes in level l - ''' + #''' for v in ordered: # debugging print(v) print(coordinates[v]) print(max_distance(points, coordinates[v])[0]) - ''' + #''' ordered = sorted(ordered, key=lambda v: max_distance(points,\ coordinates[v])[0], reverse=True) # list for order # print(ordered) @@ -331,6 +332,7 @@ def main(): print(level) # print(X, Y, Z, level) rev = reverse_level(level) + print(rev) coordinates = connect(X, Y, Z, level, adj) # verification From d62f75ab0fd5562439bd6eeb7434293b04c3b63f Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Sun, 5 Jan 2020 19:45:27 -0500 Subject: [PATCH 6/9] fixed radius issue --- coordinates/prototype3.py | 49 ++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/coordinates/prototype3.py b/coordinates/prototype3.py index 8cced07..fa705fb 100644 --- a/coordinates/prototype3.py +++ b/coordinates/prototype3.py @@ -62,13 +62,13 @@ def set_axes_equal(ax): ax.set_ylim3d([y_middle - plot_radius, y_middle + plot_radius]) ax.set_zlim3d([z_middle - plot_radius, z_middle + plot_radius]) -def graph(X, Y, Z, coordinates, adj, rev): +def graph(X, Y, Z, coordinates, adj, rev, show_level=False): ''' Visualize coordinates ''' - phi = np.linspace(0, np.pi, 20) - theta = np.linspace(0, np.pi, 40) + phi = np.linspace(0, np.pi/2, 20) + theta = np.linspace(0, np.pi/2, 40) x = np.outer(np.sin(theta), np.cos(phi)) y = np.outer(np.sin(theta), np.sin(phi)) z = np.outer(np.cos(theta), np.ones_like(phi)) @@ -79,8 +79,11 @@ def graph(X, Y, Z, coordinates, adj, rev): ax = fig.add_subplot(1,1,1,projection='3d') #ax = fig.gca(projection='3d') ax.set_aspect('equal') - #for num in range(len(rev)): - # ax.plot_wireframe(x*(num+1), y*(num+1), z*(num+1), color='k', rstride=5, cstride=5) + if show_level: + keys = rev.keys() + radius = min(keys) + for num in range(len(rev)): + ax.plot_wireframe(x*(num+1)*radius, y*(num+1)*radius, z*(num+1)*radius, color='gray', rstride=1, cstride=1) draw_lines(coordinates, adj, ax) # ax.plot([0, 1],[0, 1],[0, 1],color = 'g') ax.scatter(X, Y, Z, s=100, c='r', zorder=10) @@ -130,7 +133,7 @@ def points(adj, length, nodes, radius): for neighbor in e: q.append(neighbor) - level[neighbor] = level[v]+1 + level[neighbor] = level[v]+radius # Uncomment for level check: #print(level) @@ -211,7 +214,7 @@ def max_distance(points, origin): max_d_coord = point return max_d, max_d_coord -def connect(x, y, z, level, adj): +def connect(x, y, z, level, adj, radius=1): ''' IDEA: @@ -235,10 +238,12 @@ def connect(x, y, z, level, adj): ''' #print(adj) rev = reverse_level(level) - + levels_sorted = rev.keys() + levels_sorted = sorted(levels_sorted) + # print(levels_sorted) coordinates = {0: [0, 0, 0]} - for num in range(len(rev.keys())): - l = num+1 + for l in levels_sorted: + ## PREPROCESSING points = [] # candidate coordinates for next level @@ -252,12 +257,12 @@ def connect(x, y, z, level, adj): # print(points) ordered = rev[l] # nodes in level l - #''' + ''' for v in ordered: # debugging print(v) print(coordinates[v]) print(max_distance(points, coordinates[v])[0]) - #''' + ''' ordered = sorted(ordered, key=lambda v: max_distance(points,\ coordinates[v])[0], reverse=True) # list for order # print(ordered) @@ -270,7 +275,7 @@ def connect(x, y, z, level, adj): # if v in coordinates: for neighbor in adj[v]: # for each neighbor to ^node # print(neighbor, level[neighbor]) - if l+1 == level[neighbor]: # if the level of the neighbor is correct + if l+radius == level[neighbor]: # if the level of the neighbor is correct assignment = min_distance(points, coordinates[v])[1] # min distance assignment points.remove(assignment) if neighbor not in coordinates: # neighbor already assigned? (ie shared neighbors) @@ -291,10 +296,11 @@ def connect(x, y, z, level, adj): def gen_coordinates(adj, radius=1): nodes = list(adj.keys()) + nodes.reverse() X, Y, Z, level = points(adj, len(nodes), nodes, radius) # print(level) rev = reverse_level(level) - coordinates = connect(X, Y, Z, level, adj) + coordinates = connect(X, Y, Z, level, adj, radius) return coordinates def adjacency_list(): @@ -326,14 +332,15 @@ def main(): adj = adjacency_list() nodes = list(adj.keys()) nodes.reverse() - print(adj) - print(nodes) - X, Y, Z, level = points(adj, len(nodes), nodes, 1) - print(level) + radius = 5 + # print(adj) + # print(nodes) + X, Y, Z, level = points(adj, len(nodes), nodes, radius) + # print(level) # print(X, Y, Z, level) rev = reverse_level(level) - print(rev) - coordinates = connect(X, Y, Z, level, adj) + # print(rev) + coordinates = connect(X, Y, Z, level, adj, radius) # verification x = [] @@ -346,7 +353,7 @@ def main(): #print(x) #print(y) #print(z) - graph(x, y, z, coordinates, adj, rev) + graph(x, y, z, coordinates, adj, rev, show_level=False) plt.show() From a17519da55792ddc95a83a0017ea172b1eb1dade Mon Sep 17 00:00:00 2001 From: Joshua SA Date: Sun, 5 Jan 2020 22:13:54 -0500 Subject: [PATCH 7/9] inserted coordinates into json object --- coordinates/prototype3.py | 61 ++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/coordinates/prototype3.py b/coordinates/prototype3.py index fa705fb..4da376c 100644 --- a/coordinates/prototype3.py +++ b/coordinates/prototype3.py @@ -13,6 +13,7 @@ from mpl_toolkits.mplot3d import axes3d from matplotlib import pyplot as plt +json_string = None def sample_spherical(npoints, radius, ndim=3): ''' @@ -294,16 +295,23 @@ def connect(x, y, z, level, adj, radius=1): # print(coordinates) return coordinates -def gen_coordinates(adj, radius=1): +def gen_coordinates(adj, radius=5): nodes = list(adj.keys()) nodes.reverse() X, Y, Z, level = points(adj, len(nodes), nodes, radius) # print(level) rev = reverse_level(level) coordinates = connect(X, Y, Z, level, adj, radius) - return coordinates + + obj = json.loads(json_string) + root = obj['objects'][0]['nodes'][-1] + for each in obj['objects'][1:]: + each['coord-xyz'] = coordinates[root-each['_gvid']] + + return obj def adjacency_list(): + global json_string # json_string = r'{"name":"%3","directed":true,"strict":false,"compound":"true","newrank":"true","_subgraph_cnt":1,"objects":[{"name":"root","compound":"true","newrank":"true","_gvid":0,"nodes":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88],"edges":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193]},{"_gvid":1,"name":"[root] aws_api_gateway_base_path_mapping.base_path","label":"aws_api_gateway_base_path_mapping.base_path","shape":"box"},{"_gvid":2,"name":"[root] aws_api_gateway_deployment.deployment","label":"aws_api_gateway_deployment.deployment","shape":"box"},{"_gvid":3,"name":"[root] aws_api_gateway_domain_name.urlapi","label":"aws_api_gateway_domain_name.urlapi","shape":"box"},{"_gvid":4,"name":"[root] aws_api_gateway_integration.fetch_integration","label":"aws_api_gateway_integration.fetch_integration","shape":"box"},{"_gvid":5,"name":"[root] aws_api_gateway_integration.generate_integration","label":"aws_api_gateway_integration.generate_integration","shape":"box"},{"_gvid":6,"name":"[root] aws_api_gateway_integration.generate_options_integration","label":"aws_api_gateway_integration.generate_options_integration","shape":"box"},{"_gvid":7,"name":"[root] aws_api_gateway_integration.upload_integration","label":"aws_api_gateway_integration.upload_integration","shape":"box"},{"_gvid":8,"name":"[root] aws_api_gateway_integration.upload_options_integration","label":"aws_api_gateway_integration.upload_options_integration","shape":"box"},{"_gvid":9,"name":"[root] aws_api_gateway_integration_response.fetch_ir_200","label":"aws_api_gateway_integration_response.fetch_ir_200","shape":"box"},{"_gvid":10,"name":"[root] aws_api_gateway_integration_response.generate_ir_400","label":"aws_api_gateway_integration_response.generate_ir_400","shape":"box"},{"_gvid":11,"name":"[root] aws_api_gateway_integration_response.generate_options_integration_response","label":"aws_api_gateway_integration_response.generate_options_integration_response","shape":"box"},{"_gvid":12,"name":"[root] aws_api_gateway_integration_response.upload_ir_400","label":"aws_api_gateway_integration_response.upload_ir_400","shape":"box"},{"_gvid":13,"name":"[root] aws_api_gateway_integration_response.upload_options_integration_response","label":"aws_api_gateway_integration_response.upload_options_integration_response","shape":"box"},{"_gvid":14,"name":"[root] aws_api_gateway_method.fetch","label":"aws_api_gateway_method.fetch","shape":"box"},{"_gvid":15,"name":"[root] aws_api_gateway_method.generate","label":"aws_api_gateway_method.generate","shape":"box"},{"_gvid":16,"name":"[root] aws_api_gateway_method.generate_options","label":"aws_api_gateway_method.generate_options","shape":"box"},{"_gvid":17,"name":"[root] aws_api_gateway_method.upload","label":"aws_api_gateway_method.upload","shape":"box"},{"_gvid":18,"name":"[root] aws_api_gateway_method.upload_options","label":"aws_api_gateway_method.upload_options","shape":"box"},{"_gvid":19,"name":"[root] aws_api_gateway_method_response.fetch_200","label":"aws_api_gateway_method_response.fetch_200","shape":"box"},{"_gvid":20,"name":"[root] aws_api_gateway_method_response.fetch_400","label":"aws_api_gateway_method_response.fetch_400","shape":"box"},{"_gvid":21,"name":"[root] aws_api_gateway_method_response.generate_200","label":"aws_api_gateway_method_response.generate_200","shape":"box"},{"_gvid":22,"name":"[root] aws_api_gateway_method_response.generate_400","label":"aws_api_gateway_method_response.generate_400","shape":"box"},{"_gvid":23,"name":"[root] aws_api_gateway_method_response.generate_401","label":"aws_api_gateway_method_response.generate_401","shape":"box"},{"_gvid":24,"name":"[root] aws_api_gateway_method_response.generate_404","label":"aws_api_gateway_method_response.generate_404","shape":"box"},{"_gvid":25,"name":"[root] aws_api_gateway_method_response.generate_500","label":"aws_api_gateway_method_response.generate_500","shape":"box"},{"_gvid":26,"name":"[root] aws_api_gateway_method_response.generate_options_200","label":"aws_api_gateway_method_response.generate_options_200","shape":"box"},{"_gvid":27,"name":"[root] aws_api_gateway_method_response.upload_200","label":"aws_api_gateway_method_response.upload_200","shape":"box"},{"_gvid":28,"name":"[root] aws_api_gateway_method_response.upload_400","label":"aws_api_gateway_method_response.upload_400","shape":"box"},{"_gvid":29,"name":"[root] aws_api_gateway_method_response.upload_401","label":"aws_api_gateway_method_response.upload_401","shape":"box"},{"_gvid":30,"name":"[root] aws_api_gateway_method_response.upload_500","label":"aws_api_gateway_method_response.upload_500","shape":"box"},{"_gvid":31,"name":"[root] aws_api_gateway_method_response.upload_options_200","label":"aws_api_gateway_method_response.upload_options_200","shape":"box"},{"_gvid":32,"name":"[root] aws_api_gateway_request_validator.fetch_validator","label":"aws_api_gateway_request_validator.fetch_validator","shape":"box"},{"_gvid":33,"name":"[root] aws_api_gateway_request_validator.generate_validator","label":"aws_api_gateway_request_validator.generate_validator","shape":"box"},{"_gvid":34,"name":"[root] aws_api_gateway_resource.fetch_resource","label":"aws_api_gateway_resource.fetch_resource","shape":"box"},{"_gvid":35,"name":"[root] aws_api_gateway_resource.generate_resource","label":"aws_api_gateway_resource.generate_resource","shape":"box"},{"_gvid":36,"name":"[root] aws_api_gateway_resource.upload_resource","label":"aws_api_gateway_resource.upload_resource","shape":"box"},{"_gvid":37,"name":"[root] aws_api_gateway_rest_api.api","label":"aws_api_gateway_rest_api.api","shape":"box"},{"_gvid":38,"name":"[root] aws_cloudwatch_event_rule.everyday","label":"aws_cloudwatch_event_rule.everyday","shape":"box"},{"_gvid":39,"name":"[root] aws_cloudwatch_event_target.clean_up_urls_everyday","label":"aws_cloudwatch_event_target.clean_up_urls_everyday","shape":"box"},{"_gvid":40,"name":"[root] aws_iam_policy.invoke","label":"aws_iam_policy.invoke","shape":"box"},{"_gvid":41,"name":"[root] aws_iam_policy.ip","label":"aws_iam_policy.ip","shape":"box"},{"_gvid":42,"name":"[root] aws_iam_policy.ip_put","label":"aws_iam_policy.ip_put","shape":"box"},{"_gvid":43,"name":"[root] aws_iam_policy.lambda_fetch_s3","label":"aws_iam_policy.lambda_fetch_s3","shape":"box"},{"_gvid":44,"name":"[root] aws_iam_role.lambda_fetch_object_role","label":"aws_iam_role.lambda_fetch_object_role","shape":"box"},{"_gvid":45,"name":"[root] aws_iam_role.lambda_generate_url_helper_role","label":"aws_iam_role.lambda_generate_url_helper_role","shape":"box"},{"_gvid":46,"name":"[root] aws_iam_role.lambda_generate_url_role","label":"aws_iam_role.lambda_generate_url_role","shape":"box"},{"_gvid":47,"name":"[root] aws_iam_role.lambda_remove_urls_role","label":"aws_iam_role.lambda_remove_urls_role","shape":"box"},{"_gvid":48,"name":"[root] aws_iam_role.lambda_upload_url_role","label":"aws_iam_role.lambda_upload_url_role","shape":"box"},{"_gvid":49,"name":"[root] aws_iam_role_policy_attachment.invokehelper_gen","label":"aws_iam_role_policy_attachment.invokehelper_gen","shape":"box"},{"_gvid":50,"name":"[root] aws_iam_role_policy_attachment.invokehelper_remove","label":"aws_iam_role_policy_attachment.invokehelper_remove","shape":"box"},{"_gvid":51,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_fetch","label":"aws_iam_role_policy_attachment.lambdabasic_fetch","shape":"box"},{"_gvid":52,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_gen","label":"aws_iam_role_policy_attachment.lambdabasic_gen","shape":"box"},{"_gvid":53,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_genhelp","label":"aws_iam_role_policy_attachment.lambdabasic_genhelp","shape":"box"},{"_gvid":54,"name":"[root] aws_iam_role_policy_attachment.s3full_gen","label":"aws_iam_role_policy_attachment.s3full_gen","shape":"box"},{"_gvid":55,"name":"[root] aws_iam_role_policy_attachment.s3full_remove","label":"aws_iam_role_policy_attachment.s3full_remove","shape":"box"},{"_gvid":56,"name":"[root] aws_iam_role_policy_attachment.s3ip_genhelp","label":"aws_iam_role_policy_attachment.s3ip_genhelp","shape":"box"},{"_gvid":57,"name":"[root] aws_iam_role_policy_attachment.s3ip_upload","label":"aws_iam_role_policy_attachment.s3ip_upload","shape":"box"},{"_gvid":58,"name":"[root] aws_iam_role_policy_attachment.s3read_fetch","label":"aws_iam_role_policy_attachment.s3read_fetch","shape":"box"},{"_gvid":59,"name":"[root] aws_lambda_function.fetch","label":"aws_lambda_function.fetch","shape":"box"},{"_gvid":60,"name":"[root] aws_lambda_function.gen","label":"aws_lambda_function.gen","shape":"box"},{"_gvid":61,"name":"[root] aws_lambda_function.genhelp","label":"aws_lambda_function.genhelp","shape":"box"},{"_gvid":62,"name":"[root] aws_lambda_function.remove","label":"aws_lambda_function.remove","shape":"box"},{"_gvid":63,"name":"[root] aws_lambda_function.upload","label":"aws_lambda_function.upload","shape":"box"},{"_gvid":64,"name":"[root] aws_lambda_permission.allow_cloudwatch_to_call_check_foo","label":"aws_lambda_permission.allow_cloudwatch_to_call_check_foo","shape":"box"},{"_gvid":65,"name":"[root] aws_lambda_permission.apigw_fetch_lambda","label":"aws_lambda_permission.apigw_fetch_lambda","shape":"box"},{"_gvid":66,"name":"[root] aws_lambda_permission.apigw_generate_lambda","label":"aws_lambda_permission.apigw_generate_lambda","shape":"box"},{"_gvid":67,"name":"[root] aws_lambda_permission.apigw_upload_lambda","label":"aws_lambda_permission.apigw_upload_lambda","shape":"box"},{"_gvid":68,"name":"[root] aws_route53_record.route","label":"aws_route53_record.route","shape":"box"},{"_gvid":69,"name":"[root] aws_route53_zone.primary","label":"aws_route53_zone.primary","shape":"box"},{"_gvid":70,"name":"[root] aws_s3_bucket.download_bucket","label":"aws_s3_bucket.download_bucket","shape":"box"},{"_gvid":71,"name":"[root] aws_s3_bucket.upload_bucket","label":"aws_s3_bucket.upload_bucket","shape":"box"},{"_gvid":72,"name":"[root] aws_s3_bucket_public_access_block.private_download_bucket","label":"aws_s3_bucket_public_access_block.private_download_bucket","shape":"box"},{"_gvid":73,"name":"[root] aws_s3_bucket_public_access_block.private_upload_bucket","label":"aws_s3_bucket_public_access_block.private_upload_bucket","shape":"box"},{"_gvid":74,"name":"[root] data.archive_file.fetch_object_code","label":"data.archive_file.fetch_object_code","shape":"box"},{"_gvid":75,"name":"[root] data.archive_file.generate_url_helper_code","label":"data.archive_file.generate_url_helper_code","shape":"box"},{"_gvid":76,"name":"[root] data.archive_file.generate_url_main_code","label":"data.archive_file.generate_url_main_code","shape":"box"},{"_gvid":77,"name":"[root] data.archive_file.remove_expired_urls_code","label":"data.archive_file.remove_expired_urls_code","shape":"box"},{"_gvid":78,"name":"[root] data.archive_file.upload_url_code","label":"data.archive_file.upload_url_code","shape":"box"},{"_gvid":79,"name":"[root] data.aws_acm_certificate.cert","label":"data.aws_acm_certificate.cert","shape":"box"},{"_gvid":80,"name":"[root] null_resource.build_image","label":"null_resource.build_image","shape":"box"},{"_gvid":81,"name":"[root] provider.archive","label":"provider.archive","shape":"diamond"},{"_gvid":82,"name":"[root] provider.aws","label":"provider.aws","shape":"diamond"},{"_gvid":83,"name":"[root] meta.count-boundary (EachMode fixup)","label":"\\N"},{"_gvid":84,"name":"[root] provider.archive (close)","label":"\\N"},{"_gvid":85,"name":"[root] provider.aws (close)","label":"\\N"},{"_gvid":86,"name":"[root] provider.null (close)","label":"\\N"},{"_gvid":87,"name":"[root] provisioner.local-exec (close)","label":"\\N"},{"_gvid":88,"name":"[root] root","label":"\\N"}],"edges":[{"_gvid":0,"tail":1,"head":2},{"_gvid":1,"tail":1,"head":3},{"_gvid":2,"tail":2,"head":4},{"_gvid":3,"tail":2,"head":5},{"_gvid":4,"tail":2,"head":7},{"_gvid":5,"tail":3,"head":79},{"_gvid":6,"tail":4,"head":14},{"_gvid":7,"tail":4,"head":59},{"_gvid":8,"tail":5,"head":15},{"_gvid":9,"tail":5,"head":60},{"_gvid":10,"tail":6,"head":16},{"_gvid":11,"tail":7,"head":17},{"_gvid":12,"tail":7,"head":63},{"_gvid":13,"tail":8,"head":18},{"_gvid":14,"tail":9,"head":4},{"_gvid":15,"tail":9,"head":19},{"_gvid":16,"tail":10,"head":22},{"_gvid":17,"tail":10,"head":70},{"_gvid":18,"tail":11,"head":26},{"_gvid":19,"tail":11,"head":70},{"_gvid":20,"tail":12,"head":28},{"_gvid":21,"tail":12,"head":71},{"_gvid":22,"tail":13,"head":31},{"_gvid":23,"tail":13,"head":71},{"_gvid":24,"tail":14,"head":32},{"_gvid":25,"tail":14,"head":34},{"_gvid":26,"tail":15,"head":33},{"_gvid":27,"tail":15,"head":35},{"_gvid":28,"tail":16,"head":35},{"_gvid":29,"tail":17,"head":36},{"_gvid":30,"tail":18,"head":36},{"_gvid":31,"tail":19,"head":14},{"_gvid":32,"tail":20,"head":14},{"_gvid":33,"tail":21,"head":15},{"_gvid":34,"tail":22,"head":15},{"_gvid":35,"tail":23,"head":15},{"_gvid":36,"tail":24,"head":15},{"_gvid":37,"tail":25,"head":15},{"_gvid":38,"tail":26,"head":16},{"_gvid":39,"tail":27,"head":17},{"_gvid":40,"tail":28,"head":17},{"_gvid":41,"tail":29,"head":17},{"_gvid":42,"tail":30,"head":17},{"_gvid":43,"tail":31,"head":18},{"_gvid":44,"tail":32,"head":37},{"_gvid":45,"tail":33,"head":37},{"_gvid":46,"tail":34,"head":37},{"_gvid":47,"tail":35,"head":37},{"_gvid":48,"tail":36,"head":37},{"_gvid":49,"tail":37,"head":82},{"_gvid":50,"tail":38,"head":82},{"_gvid":51,"tail":39,"head":38},{"_gvid":52,"tail":39,"head":62},{"_gvid":53,"tail":40,"head":61},{"_gvid":54,"tail":41,"head":82},{"_gvid":55,"tail":42,"head":82},{"_gvid":56,"tail":43,"head":82},{"_gvid":57,"tail":44,"head":82},{"_gvid":58,"tail":45,"head":82},{"_gvid":59,"tail":46,"head":82},{"_gvid":60,"tail":47,"head":82},{"_gvid":61,"tail":48,"head":82},{"_gvid":62,"tail":49,"head":40},{"_gvid":63,"tail":49,"head":46},{"_gvid":64,"tail":50,"head":40},{"_gvid":65,"tail":50,"head":47},{"_gvid":66,"tail":51,"head":44},{"_gvid":67,"tail":52,"head":46},{"_gvid":68,"tail":53,"head":45},{"_gvid":69,"tail":54,"head":46},{"_gvid":70,"tail":55,"head":47},{"_gvid":71,"tail":56,"head":41},{"_gvid":72,"tail":56,"head":45},{"_gvid":73,"tail":57,"head":42},{"_gvid":74,"tail":57,"head":48},{"_gvid":75,"tail":58,"head":43},{"_gvid":76,"tail":58,"head":44},{"_gvid":77,"tail":59,"head":44},{"_gvid":78,"tail":59,"head":70},{"_gvid":79,"tail":59,"head":74},{"_gvid":80,"tail":60,"head":46},{"_gvid":81,"tail":60,"head":70},{"_gvid":82,"tail":60,"head":76},{"_gvid":83,"tail":61,"head":45},{"_gvid":84,"tail":61,"head":75},{"_gvid":85,"tail":62,"head":47},{"_gvid":86,"tail":62,"head":70},{"_gvid":87,"tail":62,"head":77},{"_gvid":88,"tail":63,"head":48},{"_gvid":89,"tail":63,"head":71},{"_gvid":90,"tail":63,"head":78},{"_gvid":91,"tail":64,"head":38},{"_gvid":92,"tail":64,"head":62},{"_gvid":93,"tail":65,"head":14},{"_gvid":94,"tail":65,"head":59},{"_gvid":95,"tail":66,"head":15},{"_gvid":96,"tail":66,"head":60},{"_gvid":97,"tail":67,"head":17},{"_gvid":98,"tail":67,"head":63},{"_gvid":99,"tail":68,"head":3},{"_gvid":100,"tail":68,"head":69},{"_gvid":101,"tail":69,"head":82},{"_gvid":102,"tail":70,"head":82},{"_gvid":103,"tail":71,"head":70},{"_gvid":104,"tail":72,"head":70},{"_gvid":105,"tail":73,"head":71},{"_gvid":106,"tail":74,"head":81},{"_gvid":107,"tail":75,"head":81},{"_gvid":108,"tail":76,"head":81},{"_gvid":109,"tail":77,"head":81},{"_gvid":110,"tail":78,"head":81},{"_gvid":111,"tail":79,"head":82},{"_gvid":112,"tail":80,"head":71},{"_gvid":113,"tail":83,"head":1},{"_gvid":114,"tail":83,"head":6},{"_gvid":115,"tail":83,"head":8},{"_gvid":116,"tail":83,"head":9},{"_gvid":117,"tail":83,"head":10},{"_gvid":118,"tail":83,"head":11},{"_gvid":119,"tail":83,"head":12},{"_gvid":120,"tail":83,"head":13},{"_gvid":121,"tail":83,"head":20},{"_gvid":122,"tail":83,"head":21},{"_gvid":123,"tail":83,"head":23},{"_gvid":124,"tail":83,"head":24},{"_gvid":125,"tail":83,"head":25},{"_gvid":126,"tail":83,"head":27},{"_gvid":127,"tail":83,"head":29},{"_gvid":128,"tail":83,"head":30},{"_gvid":129,"tail":83,"head":39},{"_gvid":130,"tail":83,"head":49},{"_gvid":131,"tail":83,"head":50},{"_gvid":132,"tail":83,"head":51},{"_gvid":133,"tail":83,"head":52},{"_gvid":134,"tail":83,"head":53},{"_gvid":135,"tail":83,"head":54},{"_gvid":136,"tail":83,"head":55},{"_gvid":137,"tail":83,"head":56},{"_gvid":138,"tail":83,"head":57},{"_gvid":139,"tail":83,"head":58},{"_gvid":140,"tail":83,"head":64},{"_gvid":141,"tail":83,"head":65},{"_gvid":142,"tail":83,"head":66},{"_gvid":143,"tail":83,"head":67},{"_gvid":144,"tail":83,"head":68},{"_gvid":145,"tail":83,"head":72},{"_gvid":146,"tail":83,"head":73},{"_gvid":147,"tail":83,"head":80},{"_gvid":148,"tail":84,"head":74},{"_gvid":149,"tail":84,"head":75},{"_gvid":150,"tail":84,"head":76},{"_gvid":151,"tail":84,"head":77},{"_gvid":152,"tail":84,"head":78},{"_gvid":153,"tail":85,"head":1},{"_gvid":154,"tail":85,"head":6},{"_gvid":155,"tail":85,"head":8},{"_gvid":156,"tail":85,"head":9},{"_gvid":157,"tail":85,"head":10},{"_gvid":158,"tail":85,"head":11},{"_gvid":159,"tail":85,"head":12},{"_gvid":160,"tail":85,"head":13},{"_gvid":161,"tail":85,"head":20},{"_gvid":162,"tail":85,"head":21},{"_gvid":163,"tail":85,"head":23},{"_gvid":164,"tail":85,"head":24},{"_gvid":165,"tail":85,"head":25},{"_gvid":166,"tail":85,"head":27},{"_gvid":167,"tail":85,"head":29},{"_gvid":168,"tail":85,"head":30},{"_gvid":169,"tail":85,"head":39},{"_gvid":170,"tail":85,"head":49},{"_gvid":171,"tail":85,"head":50},{"_gvid":172,"tail":85,"head":51},{"_gvid":173,"tail":85,"head":52},{"_gvid":174,"tail":85,"head":53},{"_gvid":175,"tail":85,"head":54},{"_gvid":176,"tail":85,"head":55},{"_gvid":177,"tail":85,"head":56},{"_gvid":178,"tail":85,"head":57},{"_gvid":179,"tail":85,"head":58},{"_gvid":180,"tail":85,"head":64},{"_gvid":181,"tail":85,"head":65},{"_gvid":182,"tail":85,"head":66},{"_gvid":183,"tail":85,"head":67},{"_gvid":184,"tail":85,"head":68},{"_gvid":185,"tail":85,"head":72},{"_gvid":186,"tail":85,"head":73},{"_gvid":187,"tail":86,"head":80},{"_gvid":188,"tail":87,"head":80},{"_gvid":189,"tail":88,"head":83},{"_gvid":190,"tail":88,"head":84},{"_gvid":191,"tail":88,"head":85},{"_gvid":192,"tail":88,"head":86},{"_gvid":193,"tail":88,"head":87}]}' json_string = r'{"name":"%3","directed":true,"strict":false,"compound":"true","newrank":"true","_subgraph_cnt":1,"objects":[{"name":"root","compound":"true","newrank":"true","_gvid":0,"nodes":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33],"edges":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57]},{"_gvid":1,"name":"[root] aws_alb.main","label":"aws_alb.main","shape":"box"},{"_gvid":2,"name":"[root] aws_alb_listener.front_end","label":"aws_alb_listener.front_end","shape":"box"},{"_gvid":3,"name":"[root] aws_alb_target_group.test","label":"aws_alb_target_group.test","shape":"box"},{"_gvid":4,"name":"[root] aws_autoscaling_group.app","label":"aws_autoscaling_group.app","shape":"box"},{"_gvid":5,"name":"[root] aws_cloudwatch_log_group.app","label":"aws_cloudwatch_log_group.app","shape":"box"},{"_gvid":6,"name":"[root] aws_cloudwatch_log_group.ecs","label":"aws_cloudwatch_log_group.ecs","shape":"box"},{"_gvid":7,"name":"[root] aws_ecs_cluster.main","label":"aws_ecs_cluster.main","shape":"box"},{"_gvid":8,"name":"[root] aws_ecs_service.test","label":"aws_ecs_service.test","shape":"box"},{"_gvid":9,"name":"[root] aws_ecs_task_definition.ghost","label":"aws_ecs_task_definition.ghost","shape":"box"},{"_gvid":10,"name":"[root] aws_iam_instance_profile.app","label":"aws_iam_instance_profile.app","shape":"box"},{"_gvid":11,"name":"[root] aws_iam_role.app_instance","label":"aws_iam_role.app_instance","shape":"box"},{"_gvid":12,"name":"[root] aws_iam_role.ecs_service","label":"aws_iam_role.ecs_service","shape":"box"},{"_gvid":13,"name":"[root] aws_iam_role_policy.ecs_service","label":"aws_iam_role_policy.ecs_service","shape":"box"},{"_gvid":14,"name":"[root] aws_iam_role_policy.instance","label":"aws_iam_role_policy.instance","shape":"box"},{"_gvid":15,"name":"[root] aws_internet_gateway.gw","label":"aws_internet_gateway.gw","shape":"box"},{"_gvid":16,"name":"[root] aws_launch_configuration.app","label":"aws_launch_configuration.app","shape":"box"},{"_gvid":17,"name":"[root] aws_route_table.r","label":"aws_route_table.r","shape":"box"},{"_gvid":18,"name":"[root] aws_route_table_association.a","label":"aws_route_table_association.a","shape":"box"},{"_gvid":19,"name":"[root] aws_security_group.instance_sg","label":"aws_security_group.instance_sg","shape":"box"},{"_gvid":20,"name":"[root] aws_security_group.lb_sg","label":"aws_security_group.lb_sg","shape":"box"},{"_gvid":21,"name":"[root] aws_subnet.main","label":"aws_subnet.main","shape":"box"},{"_gvid":22,"name":"[root] aws_vpc.main","label":"aws_vpc.main","shape":"box"},{"_gvid":23,"name":"[root] data.aws_ami.stable_coreos","label":"data.aws_ami.stable_coreos","shape":"box"},{"_gvid":24,"name":"[root] data.aws_availability_zones.available","label":"data.aws_availability_zones.available","shape":"box"},{"_gvid":25,"name":"[root] data.template_file.cloud_config","label":"data.template_file.cloud_config","shape":"box"},{"_gvid":26,"name":"[root] data.template_file.instance_profile","label":"data.template_file.instance_profile","shape":"box"},{"_gvid":27,"name":"[root] data.template_file.task_definition","label":"data.template_file.task_definition","shape":"box"},{"_gvid":28,"name":"[root] provider.aws","label":"provider.aws","shape":"diamond"},{"_gvid":29,"name":"[root] provider.template","label":"provider.template","shape":"diamond"},{"_gvid":30,"name":"[root] meta.count-boundary (EachMode fixup)","label":"\\N"},{"_gvid":31,"name":"[root] provider.aws (close)","label":"\\N"},{"_gvid":32,"name":"[root] provider.template (close)","label":"\\N"},{"_gvid":33,"name":"[root] root","label":"\\N"}],"edges":[{"_gvid":0,"tail":1,"head":20},{"_gvid":1,"tail":1,"head":21},{"_gvid":2,"tail":2,"head":1},{"_gvid":3,"tail":2,"head":3},{"_gvid":4,"tail":3,"head":22},{"_gvid":5,"tail":4,"head":16},{"_gvid":6,"tail":4,"head":21},{"_gvid":7,"tail":5,"head":28},{"_gvid":8,"tail":6,"head":28},{"_gvid":9,"tail":7,"head":28},{"_gvid":10,"tail":8,"head":2},{"_gvid":11,"tail":8,"head":7},{"_gvid":12,"tail":8,"head":9},{"_gvid":13,"tail":8,"head":13},{"_gvid":14,"tail":9,"head":27},{"_gvid":15,"tail":9,"head":28},{"_gvid":16,"tail":10,"head":11},{"_gvid":17,"tail":11,"head":28},{"_gvid":18,"tail":12,"head":28},{"_gvid":19,"tail":13,"head":12},{"_gvid":20,"tail":14,"head":11},{"_gvid":21,"tail":14,"head":26},{"_gvid":22,"tail":15,"head":22},{"_gvid":23,"tail":16,"head":10},{"_gvid":24,"tail":16,"head":19},{"_gvid":25,"tail":16,"head":23},{"_gvid":26,"tail":16,"head":25},{"_gvid":27,"tail":17,"head":15},{"_gvid":28,"tail":18,"head":17},{"_gvid":29,"tail":18,"head":21},{"_gvid":30,"tail":19,"head":20},{"_gvid":31,"tail":20,"head":22},{"_gvid":32,"tail":21,"head":22},{"_gvid":33,"tail":21,"head":24},{"_gvid":34,"tail":22,"head":28},{"_gvid":35,"tail":23,"head":28},{"_gvid":36,"tail":24,"head":28},{"_gvid":37,"tail":25,"head":29},{"_gvid":38,"tail":26,"head":29},{"_gvid":39,"tail":27,"head":29},{"_gvid":40,"tail":30,"head":4},{"_gvid":41,"tail":30,"head":5},{"_gvid":42,"tail":30,"head":6},{"_gvid":43,"tail":30,"head":8},{"_gvid":44,"tail":30,"head":14},{"_gvid":45,"tail":30,"head":18},{"_gvid":46,"tail":31,"head":4},{"_gvid":47,"tail":31,"head":5},{"_gvid":48,"tail":31,"head":6},{"_gvid":49,"tail":31,"head":8},{"_gvid":50,"tail":31,"head":14},{"_gvid":51,"tail":31,"head":18},{"_gvid":52,"tail":32,"head":25},{"_gvid":53,"tail":32,"head":26},{"_gvid":54,"tail":32,"head":27},{"_gvid":55,"tail":33,"head":30},{"_gvid":56,"tail":33,"head":31},{"_gvid":57,"tail":33,"head":32}]}' @@ -329,33 +337,32 @@ def main(): 6:[] } ''' + adj = adjacency_list() - nodes = list(adj.keys()) - nodes.reverse() - radius = 5 - # print(adj) - # print(nodes) - X, Y, Z, level = points(adj, len(nodes), nodes, radius) - # print(level) - # print(X, Y, Z, level) - rev = reverse_level(level) - # print(rev) - coordinates = connect(X, Y, Z, level, adj, radius) + coordinates = gen_coordinates(adj) + + # # verification + # x = [] + # y = [] + # z = [] + # for level in X.keys(): + # x.extend(X[level]) + # y.extend(Y[level]) + # z.extend(Z[level]) + # #print(x) + # #print(y) + # #print(z) + # graph(x, y, z, coordinates, adj, rev, show_level=False) + # plt.show() + + # # return + # obj = json.loads(json_string) + # root = obj['objects'][0]['nodes'][-1] + # for each in obj['objects'][1:]: + # each['coord-xyz'] = coordinates[root-each['_gvid']] + + print(coordinates) - # verification - x = [] - y = [] - z = [] - for level in X.keys(): - x.extend(X[level]) - y.extend(Y[level]) - z.extend(Z[level]) - #print(x) - #print(y) - #print(z) - graph(x, y, z, coordinates, adj, rev, show_level=False) - plt.show() - if __name__== "__main__": main() \ No newline at end of file From aeb99a34bed6f7bd46fd3174bf97e379121f48e3 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Sun, 5 Jan 2020 22:22:35 -0500 Subject: [PATCH 8/9] broken commit --- coordinates/prototype3.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/coordinates/prototype3.py b/coordinates/prototype3.py index 4da376c..3599c24 100644 --- a/coordinates/prototype3.py +++ b/coordinates/prototype3.py @@ -295,7 +295,12 @@ def connect(x, y, z, level, adj, radius=1): # print(coordinates) return coordinates -def gen_coordinates(adj, radius=5): +def gen_coordinates(adj_unparsed, radius=5): + ''' + arguments: json object + returns: dictionary where each node is mapped to a coordinate + ''' + adj = adjacency_list(adj_unparsed) nodes = list(adj.keys()) nodes.reverse() X, Y, Z, level = points(adj, len(nodes), nodes, radius) @@ -310,10 +315,10 @@ def gen_coordinates(adj, radius=5): return obj -def adjacency_list(): +def adjacency_list(adj_string): global json_string # json_string = r'{"name":"%3","directed":true,"strict":false,"compound":"true","newrank":"true","_subgraph_cnt":1,"objects":[{"name":"root","compound":"true","newrank":"true","_gvid":0,"nodes":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88],"edges":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193]},{"_gvid":1,"name":"[root] aws_api_gateway_base_path_mapping.base_path","label":"aws_api_gateway_base_path_mapping.base_path","shape":"box"},{"_gvid":2,"name":"[root] aws_api_gateway_deployment.deployment","label":"aws_api_gateway_deployment.deployment","shape":"box"},{"_gvid":3,"name":"[root] aws_api_gateway_domain_name.urlapi","label":"aws_api_gateway_domain_name.urlapi","shape":"box"},{"_gvid":4,"name":"[root] aws_api_gateway_integration.fetch_integration","label":"aws_api_gateway_integration.fetch_integration","shape":"box"},{"_gvid":5,"name":"[root] aws_api_gateway_integration.generate_integration","label":"aws_api_gateway_integration.generate_integration","shape":"box"},{"_gvid":6,"name":"[root] aws_api_gateway_integration.generate_options_integration","label":"aws_api_gateway_integration.generate_options_integration","shape":"box"},{"_gvid":7,"name":"[root] aws_api_gateway_integration.upload_integration","label":"aws_api_gateway_integration.upload_integration","shape":"box"},{"_gvid":8,"name":"[root] aws_api_gateway_integration.upload_options_integration","label":"aws_api_gateway_integration.upload_options_integration","shape":"box"},{"_gvid":9,"name":"[root] aws_api_gateway_integration_response.fetch_ir_200","label":"aws_api_gateway_integration_response.fetch_ir_200","shape":"box"},{"_gvid":10,"name":"[root] aws_api_gateway_integration_response.generate_ir_400","label":"aws_api_gateway_integration_response.generate_ir_400","shape":"box"},{"_gvid":11,"name":"[root] aws_api_gateway_integration_response.generate_options_integration_response","label":"aws_api_gateway_integration_response.generate_options_integration_response","shape":"box"},{"_gvid":12,"name":"[root] aws_api_gateway_integration_response.upload_ir_400","label":"aws_api_gateway_integration_response.upload_ir_400","shape":"box"},{"_gvid":13,"name":"[root] aws_api_gateway_integration_response.upload_options_integration_response","label":"aws_api_gateway_integration_response.upload_options_integration_response","shape":"box"},{"_gvid":14,"name":"[root] aws_api_gateway_method.fetch","label":"aws_api_gateway_method.fetch","shape":"box"},{"_gvid":15,"name":"[root] aws_api_gateway_method.generate","label":"aws_api_gateway_method.generate","shape":"box"},{"_gvid":16,"name":"[root] aws_api_gateway_method.generate_options","label":"aws_api_gateway_method.generate_options","shape":"box"},{"_gvid":17,"name":"[root] aws_api_gateway_method.upload","label":"aws_api_gateway_method.upload","shape":"box"},{"_gvid":18,"name":"[root] aws_api_gateway_method.upload_options","label":"aws_api_gateway_method.upload_options","shape":"box"},{"_gvid":19,"name":"[root] aws_api_gateway_method_response.fetch_200","label":"aws_api_gateway_method_response.fetch_200","shape":"box"},{"_gvid":20,"name":"[root] aws_api_gateway_method_response.fetch_400","label":"aws_api_gateway_method_response.fetch_400","shape":"box"},{"_gvid":21,"name":"[root] aws_api_gateway_method_response.generate_200","label":"aws_api_gateway_method_response.generate_200","shape":"box"},{"_gvid":22,"name":"[root] aws_api_gateway_method_response.generate_400","label":"aws_api_gateway_method_response.generate_400","shape":"box"},{"_gvid":23,"name":"[root] aws_api_gateway_method_response.generate_401","label":"aws_api_gateway_method_response.generate_401","shape":"box"},{"_gvid":24,"name":"[root] aws_api_gateway_method_response.generate_404","label":"aws_api_gateway_method_response.generate_404","shape":"box"},{"_gvid":25,"name":"[root] aws_api_gateway_method_response.generate_500","label":"aws_api_gateway_method_response.generate_500","shape":"box"},{"_gvid":26,"name":"[root] aws_api_gateway_method_response.generate_options_200","label":"aws_api_gateway_method_response.generate_options_200","shape":"box"},{"_gvid":27,"name":"[root] aws_api_gateway_method_response.upload_200","label":"aws_api_gateway_method_response.upload_200","shape":"box"},{"_gvid":28,"name":"[root] aws_api_gateway_method_response.upload_400","label":"aws_api_gateway_method_response.upload_400","shape":"box"},{"_gvid":29,"name":"[root] aws_api_gateway_method_response.upload_401","label":"aws_api_gateway_method_response.upload_401","shape":"box"},{"_gvid":30,"name":"[root] aws_api_gateway_method_response.upload_500","label":"aws_api_gateway_method_response.upload_500","shape":"box"},{"_gvid":31,"name":"[root] aws_api_gateway_method_response.upload_options_200","label":"aws_api_gateway_method_response.upload_options_200","shape":"box"},{"_gvid":32,"name":"[root] aws_api_gateway_request_validator.fetch_validator","label":"aws_api_gateway_request_validator.fetch_validator","shape":"box"},{"_gvid":33,"name":"[root] aws_api_gateway_request_validator.generate_validator","label":"aws_api_gateway_request_validator.generate_validator","shape":"box"},{"_gvid":34,"name":"[root] aws_api_gateway_resource.fetch_resource","label":"aws_api_gateway_resource.fetch_resource","shape":"box"},{"_gvid":35,"name":"[root] aws_api_gateway_resource.generate_resource","label":"aws_api_gateway_resource.generate_resource","shape":"box"},{"_gvid":36,"name":"[root] aws_api_gateway_resource.upload_resource","label":"aws_api_gateway_resource.upload_resource","shape":"box"},{"_gvid":37,"name":"[root] aws_api_gateway_rest_api.api","label":"aws_api_gateway_rest_api.api","shape":"box"},{"_gvid":38,"name":"[root] aws_cloudwatch_event_rule.everyday","label":"aws_cloudwatch_event_rule.everyday","shape":"box"},{"_gvid":39,"name":"[root] aws_cloudwatch_event_target.clean_up_urls_everyday","label":"aws_cloudwatch_event_target.clean_up_urls_everyday","shape":"box"},{"_gvid":40,"name":"[root] aws_iam_policy.invoke","label":"aws_iam_policy.invoke","shape":"box"},{"_gvid":41,"name":"[root] aws_iam_policy.ip","label":"aws_iam_policy.ip","shape":"box"},{"_gvid":42,"name":"[root] aws_iam_policy.ip_put","label":"aws_iam_policy.ip_put","shape":"box"},{"_gvid":43,"name":"[root] aws_iam_policy.lambda_fetch_s3","label":"aws_iam_policy.lambda_fetch_s3","shape":"box"},{"_gvid":44,"name":"[root] aws_iam_role.lambda_fetch_object_role","label":"aws_iam_role.lambda_fetch_object_role","shape":"box"},{"_gvid":45,"name":"[root] aws_iam_role.lambda_generate_url_helper_role","label":"aws_iam_role.lambda_generate_url_helper_role","shape":"box"},{"_gvid":46,"name":"[root] aws_iam_role.lambda_generate_url_role","label":"aws_iam_role.lambda_generate_url_role","shape":"box"},{"_gvid":47,"name":"[root] aws_iam_role.lambda_remove_urls_role","label":"aws_iam_role.lambda_remove_urls_role","shape":"box"},{"_gvid":48,"name":"[root] aws_iam_role.lambda_upload_url_role","label":"aws_iam_role.lambda_upload_url_role","shape":"box"},{"_gvid":49,"name":"[root] aws_iam_role_policy_attachment.invokehelper_gen","label":"aws_iam_role_policy_attachment.invokehelper_gen","shape":"box"},{"_gvid":50,"name":"[root] aws_iam_role_policy_attachment.invokehelper_remove","label":"aws_iam_role_policy_attachment.invokehelper_remove","shape":"box"},{"_gvid":51,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_fetch","label":"aws_iam_role_policy_attachment.lambdabasic_fetch","shape":"box"},{"_gvid":52,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_gen","label":"aws_iam_role_policy_attachment.lambdabasic_gen","shape":"box"},{"_gvid":53,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_genhelp","label":"aws_iam_role_policy_attachment.lambdabasic_genhelp","shape":"box"},{"_gvid":54,"name":"[root] aws_iam_role_policy_attachment.s3full_gen","label":"aws_iam_role_policy_attachment.s3full_gen","shape":"box"},{"_gvid":55,"name":"[root] aws_iam_role_policy_attachment.s3full_remove","label":"aws_iam_role_policy_attachment.s3full_remove","shape":"box"},{"_gvid":56,"name":"[root] aws_iam_role_policy_attachment.s3ip_genhelp","label":"aws_iam_role_policy_attachment.s3ip_genhelp","shape":"box"},{"_gvid":57,"name":"[root] aws_iam_role_policy_attachment.s3ip_upload","label":"aws_iam_role_policy_attachment.s3ip_upload","shape":"box"},{"_gvid":58,"name":"[root] aws_iam_role_policy_attachment.s3read_fetch","label":"aws_iam_role_policy_attachment.s3read_fetch","shape":"box"},{"_gvid":59,"name":"[root] aws_lambda_function.fetch","label":"aws_lambda_function.fetch","shape":"box"},{"_gvid":60,"name":"[root] aws_lambda_function.gen","label":"aws_lambda_function.gen","shape":"box"},{"_gvid":61,"name":"[root] aws_lambda_function.genhelp","label":"aws_lambda_function.genhelp","shape":"box"},{"_gvid":62,"name":"[root] aws_lambda_function.remove","label":"aws_lambda_function.remove","shape":"box"},{"_gvid":63,"name":"[root] aws_lambda_function.upload","label":"aws_lambda_function.upload","shape":"box"},{"_gvid":64,"name":"[root] aws_lambda_permission.allow_cloudwatch_to_call_check_foo","label":"aws_lambda_permission.allow_cloudwatch_to_call_check_foo","shape":"box"},{"_gvid":65,"name":"[root] aws_lambda_permission.apigw_fetch_lambda","label":"aws_lambda_permission.apigw_fetch_lambda","shape":"box"},{"_gvid":66,"name":"[root] aws_lambda_permission.apigw_generate_lambda","label":"aws_lambda_permission.apigw_generate_lambda","shape":"box"},{"_gvid":67,"name":"[root] aws_lambda_permission.apigw_upload_lambda","label":"aws_lambda_permission.apigw_upload_lambda","shape":"box"},{"_gvid":68,"name":"[root] aws_route53_record.route","label":"aws_route53_record.route","shape":"box"},{"_gvid":69,"name":"[root] aws_route53_zone.primary","label":"aws_route53_zone.primary","shape":"box"},{"_gvid":70,"name":"[root] aws_s3_bucket.download_bucket","label":"aws_s3_bucket.download_bucket","shape":"box"},{"_gvid":71,"name":"[root] aws_s3_bucket.upload_bucket","label":"aws_s3_bucket.upload_bucket","shape":"box"},{"_gvid":72,"name":"[root] aws_s3_bucket_public_access_block.private_download_bucket","label":"aws_s3_bucket_public_access_block.private_download_bucket","shape":"box"},{"_gvid":73,"name":"[root] aws_s3_bucket_public_access_block.private_upload_bucket","label":"aws_s3_bucket_public_access_block.private_upload_bucket","shape":"box"},{"_gvid":74,"name":"[root] data.archive_file.fetch_object_code","label":"data.archive_file.fetch_object_code","shape":"box"},{"_gvid":75,"name":"[root] data.archive_file.generate_url_helper_code","label":"data.archive_file.generate_url_helper_code","shape":"box"},{"_gvid":76,"name":"[root] data.archive_file.generate_url_main_code","label":"data.archive_file.generate_url_main_code","shape":"box"},{"_gvid":77,"name":"[root] data.archive_file.remove_expired_urls_code","label":"data.archive_file.remove_expired_urls_code","shape":"box"},{"_gvid":78,"name":"[root] data.archive_file.upload_url_code","label":"data.archive_file.upload_url_code","shape":"box"},{"_gvid":79,"name":"[root] data.aws_acm_certificate.cert","label":"data.aws_acm_certificate.cert","shape":"box"},{"_gvid":80,"name":"[root] null_resource.build_image","label":"null_resource.build_image","shape":"box"},{"_gvid":81,"name":"[root] provider.archive","label":"provider.archive","shape":"diamond"},{"_gvid":82,"name":"[root] provider.aws","label":"provider.aws","shape":"diamond"},{"_gvid":83,"name":"[root] meta.count-boundary (EachMode fixup)","label":"\\N"},{"_gvid":84,"name":"[root] provider.archive (close)","label":"\\N"},{"_gvid":85,"name":"[root] provider.aws (close)","label":"\\N"},{"_gvid":86,"name":"[root] provider.null (close)","label":"\\N"},{"_gvid":87,"name":"[root] provisioner.local-exec (close)","label":"\\N"},{"_gvid":88,"name":"[root] root","label":"\\N"}],"edges":[{"_gvid":0,"tail":1,"head":2},{"_gvid":1,"tail":1,"head":3},{"_gvid":2,"tail":2,"head":4},{"_gvid":3,"tail":2,"head":5},{"_gvid":4,"tail":2,"head":7},{"_gvid":5,"tail":3,"head":79},{"_gvid":6,"tail":4,"head":14},{"_gvid":7,"tail":4,"head":59},{"_gvid":8,"tail":5,"head":15},{"_gvid":9,"tail":5,"head":60},{"_gvid":10,"tail":6,"head":16},{"_gvid":11,"tail":7,"head":17},{"_gvid":12,"tail":7,"head":63},{"_gvid":13,"tail":8,"head":18},{"_gvid":14,"tail":9,"head":4},{"_gvid":15,"tail":9,"head":19},{"_gvid":16,"tail":10,"head":22},{"_gvid":17,"tail":10,"head":70},{"_gvid":18,"tail":11,"head":26},{"_gvid":19,"tail":11,"head":70},{"_gvid":20,"tail":12,"head":28},{"_gvid":21,"tail":12,"head":71},{"_gvid":22,"tail":13,"head":31},{"_gvid":23,"tail":13,"head":71},{"_gvid":24,"tail":14,"head":32},{"_gvid":25,"tail":14,"head":34},{"_gvid":26,"tail":15,"head":33},{"_gvid":27,"tail":15,"head":35},{"_gvid":28,"tail":16,"head":35},{"_gvid":29,"tail":17,"head":36},{"_gvid":30,"tail":18,"head":36},{"_gvid":31,"tail":19,"head":14},{"_gvid":32,"tail":20,"head":14},{"_gvid":33,"tail":21,"head":15},{"_gvid":34,"tail":22,"head":15},{"_gvid":35,"tail":23,"head":15},{"_gvid":36,"tail":24,"head":15},{"_gvid":37,"tail":25,"head":15},{"_gvid":38,"tail":26,"head":16},{"_gvid":39,"tail":27,"head":17},{"_gvid":40,"tail":28,"head":17},{"_gvid":41,"tail":29,"head":17},{"_gvid":42,"tail":30,"head":17},{"_gvid":43,"tail":31,"head":18},{"_gvid":44,"tail":32,"head":37},{"_gvid":45,"tail":33,"head":37},{"_gvid":46,"tail":34,"head":37},{"_gvid":47,"tail":35,"head":37},{"_gvid":48,"tail":36,"head":37},{"_gvid":49,"tail":37,"head":82},{"_gvid":50,"tail":38,"head":82},{"_gvid":51,"tail":39,"head":38},{"_gvid":52,"tail":39,"head":62},{"_gvid":53,"tail":40,"head":61},{"_gvid":54,"tail":41,"head":82},{"_gvid":55,"tail":42,"head":82},{"_gvid":56,"tail":43,"head":82},{"_gvid":57,"tail":44,"head":82},{"_gvid":58,"tail":45,"head":82},{"_gvid":59,"tail":46,"head":82},{"_gvid":60,"tail":47,"head":82},{"_gvid":61,"tail":48,"head":82},{"_gvid":62,"tail":49,"head":40},{"_gvid":63,"tail":49,"head":46},{"_gvid":64,"tail":50,"head":40},{"_gvid":65,"tail":50,"head":47},{"_gvid":66,"tail":51,"head":44},{"_gvid":67,"tail":52,"head":46},{"_gvid":68,"tail":53,"head":45},{"_gvid":69,"tail":54,"head":46},{"_gvid":70,"tail":55,"head":47},{"_gvid":71,"tail":56,"head":41},{"_gvid":72,"tail":56,"head":45},{"_gvid":73,"tail":57,"head":42},{"_gvid":74,"tail":57,"head":48},{"_gvid":75,"tail":58,"head":43},{"_gvid":76,"tail":58,"head":44},{"_gvid":77,"tail":59,"head":44},{"_gvid":78,"tail":59,"head":70},{"_gvid":79,"tail":59,"head":74},{"_gvid":80,"tail":60,"head":46},{"_gvid":81,"tail":60,"head":70},{"_gvid":82,"tail":60,"head":76},{"_gvid":83,"tail":61,"head":45},{"_gvid":84,"tail":61,"head":75},{"_gvid":85,"tail":62,"head":47},{"_gvid":86,"tail":62,"head":70},{"_gvid":87,"tail":62,"head":77},{"_gvid":88,"tail":63,"head":48},{"_gvid":89,"tail":63,"head":71},{"_gvid":90,"tail":63,"head":78},{"_gvid":91,"tail":64,"head":38},{"_gvid":92,"tail":64,"head":62},{"_gvid":93,"tail":65,"head":14},{"_gvid":94,"tail":65,"head":59},{"_gvid":95,"tail":66,"head":15},{"_gvid":96,"tail":66,"head":60},{"_gvid":97,"tail":67,"head":17},{"_gvid":98,"tail":67,"head":63},{"_gvid":99,"tail":68,"head":3},{"_gvid":100,"tail":68,"head":69},{"_gvid":101,"tail":69,"head":82},{"_gvid":102,"tail":70,"head":82},{"_gvid":103,"tail":71,"head":70},{"_gvid":104,"tail":72,"head":70},{"_gvid":105,"tail":73,"head":71},{"_gvid":106,"tail":74,"head":81},{"_gvid":107,"tail":75,"head":81},{"_gvid":108,"tail":76,"head":81},{"_gvid":109,"tail":77,"head":81},{"_gvid":110,"tail":78,"head":81},{"_gvid":111,"tail":79,"head":82},{"_gvid":112,"tail":80,"head":71},{"_gvid":113,"tail":83,"head":1},{"_gvid":114,"tail":83,"head":6},{"_gvid":115,"tail":83,"head":8},{"_gvid":116,"tail":83,"head":9},{"_gvid":117,"tail":83,"head":10},{"_gvid":118,"tail":83,"head":11},{"_gvid":119,"tail":83,"head":12},{"_gvid":120,"tail":83,"head":13},{"_gvid":121,"tail":83,"head":20},{"_gvid":122,"tail":83,"head":21},{"_gvid":123,"tail":83,"head":23},{"_gvid":124,"tail":83,"head":24},{"_gvid":125,"tail":83,"head":25},{"_gvid":126,"tail":83,"head":27},{"_gvid":127,"tail":83,"head":29},{"_gvid":128,"tail":83,"head":30},{"_gvid":129,"tail":83,"head":39},{"_gvid":130,"tail":83,"head":49},{"_gvid":131,"tail":83,"head":50},{"_gvid":132,"tail":83,"head":51},{"_gvid":133,"tail":83,"head":52},{"_gvid":134,"tail":83,"head":53},{"_gvid":135,"tail":83,"head":54},{"_gvid":136,"tail":83,"head":55},{"_gvid":137,"tail":83,"head":56},{"_gvid":138,"tail":83,"head":57},{"_gvid":139,"tail":83,"head":58},{"_gvid":140,"tail":83,"head":64},{"_gvid":141,"tail":83,"head":65},{"_gvid":142,"tail":83,"head":66},{"_gvid":143,"tail":83,"head":67},{"_gvid":144,"tail":83,"head":68},{"_gvid":145,"tail":83,"head":72},{"_gvid":146,"tail":83,"head":73},{"_gvid":147,"tail":83,"head":80},{"_gvid":148,"tail":84,"head":74},{"_gvid":149,"tail":84,"head":75},{"_gvid":150,"tail":84,"head":76},{"_gvid":151,"tail":84,"head":77},{"_gvid":152,"tail":84,"head":78},{"_gvid":153,"tail":85,"head":1},{"_gvid":154,"tail":85,"head":6},{"_gvid":155,"tail":85,"head":8},{"_gvid":156,"tail":85,"head":9},{"_gvid":157,"tail":85,"head":10},{"_gvid":158,"tail":85,"head":11},{"_gvid":159,"tail":85,"head":12},{"_gvid":160,"tail":85,"head":13},{"_gvid":161,"tail":85,"head":20},{"_gvid":162,"tail":85,"head":21},{"_gvid":163,"tail":85,"head":23},{"_gvid":164,"tail":85,"head":24},{"_gvid":165,"tail":85,"head":25},{"_gvid":166,"tail":85,"head":27},{"_gvid":167,"tail":85,"head":29},{"_gvid":168,"tail":85,"head":30},{"_gvid":169,"tail":85,"head":39},{"_gvid":170,"tail":85,"head":49},{"_gvid":171,"tail":85,"head":50},{"_gvid":172,"tail":85,"head":51},{"_gvid":173,"tail":85,"head":52},{"_gvid":174,"tail":85,"head":53},{"_gvid":175,"tail":85,"head":54},{"_gvid":176,"tail":85,"head":55},{"_gvid":177,"tail":85,"head":56},{"_gvid":178,"tail":85,"head":57},{"_gvid":179,"tail":85,"head":58},{"_gvid":180,"tail":85,"head":64},{"_gvid":181,"tail":85,"head":65},{"_gvid":182,"tail":85,"head":66},{"_gvid":183,"tail":85,"head":67},{"_gvid":184,"tail":85,"head":68},{"_gvid":185,"tail":85,"head":72},{"_gvid":186,"tail":85,"head":73},{"_gvid":187,"tail":86,"head":80},{"_gvid":188,"tail":87,"head":80},{"_gvid":189,"tail":88,"head":83},{"_gvid":190,"tail":88,"head":84},{"_gvid":191,"tail":88,"head":85},{"_gvid":192,"tail":88,"head":86},{"_gvid":193,"tail":88,"head":87}]}' - json_string = r'{"name":"%3","directed":true,"strict":false,"compound":"true","newrank":"true","_subgraph_cnt":1,"objects":[{"name":"root","compound":"true","newrank":"true","_gvid":0,"nodes":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33],"edges":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57]},{"_gvid":1,"name":"[root] aws_alb.main","label":"aws_alb.main","shape":"box"},{"_gvid":2,"name":"[root] aws_alb_listener.front_end","label":"aws_alb_listener.front_end","shape":"box"},{"_gvid":3,"name":"[root] aws_alb_target_group.test","label":"aws_alb_target_group.test","shape":"box"},{"_gvid":4,"name":"[root] aws_autoscaling_group.app","label":"aws_autoscaling_group.app","shape":"box"},{"_gvid":5,"name":"[root] aws_cloudwatch_log_group.app","label":"aws_cloudwatch_log_group.app","shape":"box"},{"_gvid":6,"name":"[root] aws_cloudwatch_log_group.ecs","label":"aws_cloudwatch_log_group.ecs","shape":"box"},{"_gvid":7,"name":"[root] aws_ecs_cluster.main","label":"aws_ecs_cluster.main","shape":"box"},{"_gvid":8,"name":"[root] aws_ecs_service.test","label":"aws_ecs_service.test","shape":"box"},{"_gvid":9,"name":"[root] aws_ecs_task_definition.ghost","label":"aws_ecs_task_definition.ghost","shape":"box"},{"_gvid":10,"name":"[root] aws_iam_instance_profile.app","label":"aws_iam_instance_profile.app","shape":"box"},{"_gvid":11,"name":"[root] aws_iam_role.app_instance","label":"aws_iam_role.app_instance","shape":"box"},{"_gvid":12,"name":"[root] aws_iam_role.ecs_service","label":"aws_iam_role.ecs_service","shape":"box"},{"_gvid":13,"name":"[root] aws_iam_role_policy.ecs_service","label":"aws_iam_role_policy.ecs_service","shape":"box"},{"_gvid":14,"name":"[root] aws_iam_role_policy.instance","label":"aws_iam_role_policy.instance","shape":"box"},{"_gvid":15,"name":"[root] aws_internet_gateway.gw","label":"aws_internet_gateway.gw","shape":"box"},{"_gvid":16,"name":"[root] aws_launch_configuration.app","label":"aws_launch_configuration.app","shape":"box"},{"_gvid":17,"name":"[root] aws_route_table.r","label":"aws_route_table.r","shape":"box"},{"_gvid":18,"name":"[root] aws_route_table_association.a","label":"aws_route_table_association.a","shape":"box"},{"_gvid":19,"name":"[root] aws_security_group.instance_sg","label":"aws_security_group.instance_sg","shape":"box"},{"_gvid":20,"name":"[root] aws_security_group.lb_sg","label":"aws_security_group.lb_sg","shape":"box"},{"_gvid":21,"name":"[root] aws_subnet.main","label":"aws_subnet.main","shape":"box"},{"_gvid":22,"name":"[root] aws_vpc.main","label":"aws_vpc.main","shape":"box"},{"_gvid":23,"name":"[root] data.aws_ami.stable_coreos","label":"data.aws_ami.stable_coreos","shape":"box"},{"_gvid":24,"name":"[root] data.aws_availability_zones.available","label":"data.aws_availability_zones.available","shape":"box"},{"_gvid":25,"name":"[root] data.template_file.cloud_config","label":"data.template_file.cloud_config","shape":"box"},{"_gvid":26,"name":"[root] data.template_file.instance_profile","label":"data.template_file.instance_profile","shape":"box"},{"_gvid":27,"name":"[root] data.template_file.task_definition","label":"data.template_file.task_definition","shape":"box"},{"_gvid":28,"name":"[root] provider.aws","label":"provider.aws","shape":"diamond"},{"_gvid":29,"name":"[root] provider.template","label":"provider.template","shape":"diamond"},{"_gvid":30,"name":"[root] meta.count-boundary (EachMode fixup)","label":"\\N"},{"_gvid":31,"name":"[root] provider.aws (close)","label":"\\N"},{"_gvid":32,"name":"[root] provider.template (close)","label":"\\N"},{"_gvid":33,"name":"[root] root","label":"\\N"}],"edges":[{"_gvid":0,"tail":1,"head":20},{"_gvid":1,"tail":1,"head":21},{"_gvid":2,"tail":2,"head":1},{"_gvid":3,"tail":2,"head":3},{"_gvid":4,"tail":3,"head":22},{"_gvid":5,"tail":4,"head":16},{"_gvid":6,"tail":4,"head":21},{"_gvid":7,"tail":5,"head":28},{"_gvid":8,"tail":6,"head":28},{"_gvid":9,"tail":7,"head":28},{"_gvid":10,"tail":8,"head":2},{"_gvid":11,"tail":8,"head":7},{"_gvid":12,"tail":8,"head":9},{"_gvid":13,"tail":8,"head":13},{"_gvid":14,"tail":9,"head":27},{"_gvid":15,"tail":9,"head":28},{"_gvid":16,"tail":10,"head":11},{"_gvid":17,"tail":11,"head":28},{"_gvid":18,"tail":12,"head":28},{"_gvid":19,"tail":13,"head":12},{"_gvid":20,"tail":14,"head":11},{"_gvid":21,"tail":14,"head":26},{"_gvid":22,"tail":15,"head":22},{"_gvid":23,"tail":16,"head":10},{"_gvid":24,"tail":16,"head":19},{"_gvid":25,"tail":16,"head":23},{"_gvid":26,"tail":16,"head":25},{"_gvid":27,"tail":17,"head":15},{"_gvid":28,"tail":18,"head":17},{"_gvid":29,"tail":18,"head":21},{"_gvid":30,"tail":19,"head":20},{"_gvid":31,"tail":20,"head":22},{"_gvid":32,"tail":21,"head":22},{"_gvid":33,"tail":21,"head":24},{"_gvid":34,"tail":22,"head":28},{"_gvid":35,"tail":23,"head":28},{"_gvid":36,"tail":24,"head":28},{"_gvid":37,"tail":25,"head":29},{"_gvid":38,"tail":26,"head":29},{"_gvid":39,"tail":27,"head":29},{"_gvid":40,"tail":30,"head":4},{"_gvid":41,"tail":30,"head":5},{"_gvid":42,"tail":30,"head":6},{"_gvid":43,"tail":30,"head":8},{"_gvid":44,"tail":30,"head":14},{"_gvid":45,"tail":30,"head":18},{"_gvid":46,"tail":31,"head":4},{"_gvid":47,"tail":31,"head":5},{"_gvid":48,"tail":31,"head":6},{"_gvid":49,"tail":31,"head":8},{"_gvid":50,"tail":31,"head":14},{"_gvid":51,"tail":31,"head":18},{"_gvid":52,"tail":32,"head":25},{"_gvid":53,"tail":32,"head":26},{"_gvid":54,"tail":32,"head":27},{"_gvid":55,"tail":33,"head":30},{"_gvid":56,"tail":33,"head":31},{"_gvid":57,"tail":33,"head":32}]}' + json_string = adj_string # r'{"name":"%3","directed":true,"strict":false,"compound":"true","newrank":"true","_subgraph_cnt":1,"objects":[{"name":"root","compound":"true","newrank":"true","_gvid":0,"nodes":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33],"edges":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57]},{"_gvid":1,"name":"[root] aws_alb.main","label":"aws_alb.main","shape":"box"},{"_gvid":2,"name":"[root] aws_alb_listener.front_end","label":"aws_alb_listener.front_end","shape":"box"},{"_gvid":3,"name":"[root] aws_alb_target_group.test","label":"aws_alb_target_group.test","shape":"box"},{"_gvid":4,"name":"[root] aws_autoscaling_group.app","label":"aws_autoscaling_group.app","shape":"box"},{"_gvid":5,"name":"[root] aws_cloudwatch_log_group.app","label":"aws_cloudwatch_log_group.app","shape":"box"},{"_gvid":6,"name":"[root] aws_cloudwatch_log_group.ecs","label":"aws_cloudwatch_log_group.ecs","shape":"box"},{"_gvid":7,"name":"[root] aws_ecs_cluster.main","label":"aws_ecs_cluster.main","shape":"box"},{"_gvid":8,"name":"[root] aws_ecs_service.test","label":"aws_ecs_service.test","shape":"box"},{"_gvid":9,"name":"[root] aws_ecs_task_definition.ghost","label":"aws_ecs_task_definition.ghost","shape":"box"},{"_gvid":10,"name":"[root] aws_iam_instance_profile.app","label":"aws_iam_instance_profile.app","shape":"box"},{"_gvid":11,"name":"[root] aws_iam_role.app_instance","label":"aws_iam_role.app_instance","shape":"box"},{"_gvid":12,"name":"[root] aws_iam_role.ecs_service","label":"aws_iam_role.ecs_service","shape":"box"},{"_gvid":13,"name":"[root] aws_iam_role_policy.ecs_service","label":"aws_iam_role_policy.ecs_service","shape":"box"},{"_gvid":14,"name":"[root] aws_iam_role_policy.instance","label":"aws_iam_role_policy.instance","shape":"box"},{"_gvid":15,"name":"[root] aws_internet_gateway.gw","label":"aws_internet_gateway.gw","shape":"box"},{"_gvid":16,"name":"[root] aws_launch_configuration.app","label":"aws_launch_configuration.app","shape":"box"},{"_gvid":17,"name":"[root] aws_route_table.r","label":"aws_route_table.r","shape":"box"},{"_gvid":18,"name":"[root] aws_route_table_association.a","label":"aws_route_table_association.a","shape":"box"},{"_gvid":19,"name":"[root] aws_security_group.instance_sg","label":"aws_security_group.instance_sg","shape":"box"},{"_gvid":20,"name":"[root] aws_security_group.lb_sg","label":"aws_security_group.lb_sg","shape":"box"},{"_gvid":21,"name":"[root] aws_subnet.main","label":"aws_subnet.main","shape":"box"},{"_gvid":22,"name":"[root] aws_vpc.main","label":"aws_vpc.main","shape":"box"},{"_gvid":23,"name":"[root] data.aws_ami.stable_coreos","label":"data.aws_ami.stable_coreos","shape":"box"},{"_gvid":24,"name":"[root] data.aws_availability_zones.available","label":"data.aws_availability_zones.available","shape":"box"},{"_gvid":25,"name":"[root] data.template_file.cloud_config","label":"data.template_file.cloud_config","shape":"box"},{"_gvid":26,"name":"[root] data.template_file.instance_profile","label":"data.template_file.instance_profile","shape":"box"},{"_gvid":27,"name":"[root] data.template_file.task_definition","label":"data.template_file.task_definition","shape":"box"},{"_gvid":28,"name":"[root] provider.aws","label":"provider.aws","shape":"diamond"},{"_gvid":29,"name":"[root] provider.template","label":"provider.template","shape":"diamond"},{"_gvid":30,"name":"[root] meta.count-boundary (EachMode fixup)","label":"\\N"},{"_gvid":31,"name":"[root] provider.aws (close)","label":"\\N"},{"_gvid":32,"name":"[root] provider.template (close)","label":"\\N"},{"_gvid":33,"name":"[root] root","label":"\\N"}],"edges":[{"_gvid":0,"tail":1,"head":20},{"_gvid":1,"tail":1,"head":21},{"_gvid":2,"tail":2,"head":1},{"_gvid":3,"tail":2,"head":3},{"_gvid":4,"tail":3,"head":22},{"_gvid":5,"tail":4,"head":16},{"_gvid":6,"tail":4,"head":21},{"_gvid":7,"tail":5,"head":28},{"_gvid":8,"tail":6,"head":28},{"_gvid":9,"tail":7,"head":28},{"_gvid":10,"tail":8,"head":2},{"_gvid":11,"tail":8,"head":7},{"_gvid":12,"tail":8,"head":9},{"_gvid":13,"tail":8,"head":13},{"_gvid":14,"tail":9,"head":27},{"_gvid":15,"tail":9,"head":28},{"_gvid":16,"tail":10,"head":11},{"_gvid":17,"tail":11,"head":28},{"_gvid":18,"tail":12,"head":28},{"_gvid":19,"tail":13,"head":12},{"_gvid":20,"tail":14,"head":11},{"_gvid":21,"tail":14,"head":26},{"_gvid":22,"tail":15,"head":22},{"_gvid":23,"tail":16,"head":10},{"_gvid":24,"tail":16,"head":19},{"_gvid":25,"tail":16,"head":23},{"_gvid":26,"tail":16,"head":25},{"_gvid":27,"tail":17,"head":15},{"_gvid":28,"tail":18,"head":17},{"_gvid":29,"tail":18,"head":21},{"_gvid":30,"tail":19,"head":20},{"_gvid":31,"tail":20,"head":22},{"_gvid":32,"tail":21,"head":22},{"_gvid":33,"tail":21,"head":24},{"_gvid":34,"tail":22,"head":28},{"_gvid":35,"tail":23,"head":28},{"_gvid":36,"tail":24,"head":28},{"_gvid":37,"tail":25,"head":29},{"_gvid":38,"tail":26,"head":29},{"_gvid":39,"tail":27,"head":29},{"_gvid":40,"tail":30,"head":4},{"_gvid":41,"tail":30,"head":5},{"_gvid":42,"tail":30,"head":6},{"_gvid":43,"tail":30,"head":8},{"_gvid":44,"tail":30,"head":14},{"_gvid":45,"tail":30,"head":18},{"_gvid":46,"tail":31,"head":4},{"_gvid":47,"tail":31,"head":5},{"_gvid":48,"tail":31,"head":6},{"_gvid":49,"tail":31,"head":8},{"_gvid":50,"tail":31,"head":14},{"_gvid":51,"tail":31,"head":18},{"_gvid":52,"tail":32,"head":25},{"_gvid":53,"tail":32,"head":26},{"_gvid":54,"tail":32,"head":27},{"_gvid":55,"tail":33,"head":30},{"_gvid":56,"tail":33,"head":31},{"_gvid":57,"tail":33,"head":32}]}' obj = json.loads(json_string) root = obj['objects'][0]['nodes'][-1] @@ -337,8 +342,10 @@ def main(): 6:[] } ''' - - adj = adjacency_list() + global json_string + json_string = r'{"name":"%3","directed":true,"strict":false,"compound":"true","newrank":"true","_subgraph_cnt":1,"objects":[{"name":"root","compound":"true","newrank":"true","_gvid":0,"nodes":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88],"edges":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193]},{"_gvid":1,"name":"[root] aws_api_gateway_base_path_mapping.base_path","label":"aws_api_gateway_base_path_mapping.base_path","shape":"box"},{"_gvid":2,"name":"[root] aws_api_gateway_deployment.deployment","label":"aws_api_gateway_deployment.deployment","shape":"box"},{"_gvid":3,"name":"[root] aws_api_gateway_domain_name.urlapi","label":"aws_api_gateway_domain_name.urlapi","shape":"box"},{"_gvid":4,"name":"[root] aws_api_gateway_integration.fetch_integration","label":"aws_api_gateway_integration.fetch_integration","shape":"box"},{"_gvid":5,"name":"[root] aws_api_gateway_integration.generate_integration","label":"aws_api_gateway_integration.generate_integration","shape":"box"},{"_gvid":6,"name":"[root] aws_api_gateway_integration.generate_options_integration","label":"aws_api_gateway_integration.generate_options_integration","shape":"box"},{"_gvid":7,"name":"[root] aws_api_gateway_integration.upload_integration","label":"aws_api_gateway_integration.upload_integration","shape":"box"},{"_gvid":8,"name":"[root] aws_api_gateway_integration.upload_options_integration","label":"aws_api_gateway_integration.upload_options_integration","shape":"box"},{"_gvid":9,"name":"[root] aws_api_gateway_integration_response.fetch_ir_200","label":"aws_api_gateway_integration_response.fetch_ir_200","shape":"box"},{"_gvid":10,"name":"[root] aws_api_gateway_integration_response.generate_ir_400","label":"aws_api_gateway_integration_response.generate_ir_400","shape":"box"},{"_gvid":11,"name":"[root] aws_api_gateway_integration_response.generate_options_integration_response","label":"aws_api_gateway_integration_response.generate_options_integration_response","shape":"box"},{"_gvid":12,"name":"[root] aws_api_gateway_integration_response.upload_ir_400","label":"aws_api_gateway_integration_response.upload_ir_400","shape":"box"},{"_gvid":13,"name":"[root] aws_api_gateway_integration_response.upload_options_integration_response","label":"aws_api_gateway_integration_response.upload_options_integration_response","shape":"box"},{"_gvid":14,"name":"[root] aws_api_gateway_method.fetch","label":"aws_api_gateway_method.fetch","shape":"box"},{"_gvid":15,"name":"[root] aws_api_gateway_method.generate","label":"aws_api_gateway_method.generate","shape":"box"},{"_gvid":16,"name":"[root] aws_api_gateway_method.generate_options","label":"aws_api_gateway_method.generate_options","shape":"box"},{"_gvid":17,"name":"[root] aws_api_gateway_method.upload","label":"aws_api_gateway_method.upload","shape":"box"},{"_gvid":18,"name":"[root] aws_api_gateway_method.upload_options","label":"aws_api_gateway_method.upload_options","shape":"box"},{"_gvid":19,"name":"[root] aws_api_gateway_method_response.fetch_200","label":"aws_api_gateway_method_response.fetch_200","shape":"box"},{"_gvid":20,"name":"[root] aws_api_gateway_method_response.fetch_400","label":"aws_api_gateway_method_response.fetch_400","shape":"box"},{"_gvid":21,"name":"[root] aws_api_gateway_method_response.generate_200","label":"aws_api_gateway_method_response.generate_200","shape":"box"},{"_gvid":22,"name":"[root] aws_api_gateway_method_response.generate_400","label":"aws_api_gateway_method_response.generate_400","shape":"box"},{"_gvid":23,"name":"[root] aws_api_gateway_method_response.generate_401","label":"aws_api_gateway_method_response.generate_401","shape":"box"},{"_gvid":24,"name":"[root] aws_api_gateway_method_response.generate_404","label":"aws_api_gateway_method_response.generate_404","shape":"box"},{"_gvid":25,"name":"[root] aws_api_gateway_method_response.generate_500","label":"aws_api_gateway_method_response.generate_500","shape":"box"},{"_gvid":26,"name":"[root] aws_api_gateway_method_response.generate_options_200","label":"aws_api_gateway_method_response.generate_options_200","shape":"box"},{"_gvid":27,"name":"[root] aws_api_gateway_method_response.upload_200","label":"aws_api_gateway_method_response.upload_200","shape":"box"},{"_gvid":28,"name":"[root] aws_api_gateway_method_response.upload_400","label":"aws_api_gateway_method_response.upload_400","shape":"box"},{"_gvid":29,"name":"[root] aws_api_gateway_method_response.upload_401","label":"aws_api_gateway_method_response.upload_401","shape":"box"},{"_gvid":30,"name":"[root] aws_api_gateway_method_response.upload_500","label":"aws_api_gateway_method_response.upload_500","shape":"box"},{"_gvid":31,"name":"[root] aws_api_gateway_method_response.upload_options_200","label":"aws_api_gateway_method_response.upload_options_200","shape":"box"},{"_gvid":32,"name":"[root] aws_api_gateway_request_validator.fetch_validator","label":"aws_api_gateway_request_validator.fetch_validator","shape":"box"},{"_gvid":33,"name":"[root] aws_api_gateway_request_validator.generate_validator","label":"aws_api_gateway_request_validator.generate_validator","shape":"box"},{"_gvid":34,"name":"[root] aws_api_gateway_resource.fetch_resource","label":"aws_api_gateway_resource.fetch_resource","shape":"box"},{"_gvid":35,"name":"[root] aws_api_gateway_resource.generate_resource","label":"aws_api_gateway_resource.generate_resource","shape":"box"},{"_gvid":36,"name":"[root] aws_api_gateway_resource.upload_resource","label":"aws_api_gateway_resource.upload_resource","shape":"box"},{"_gvid":37,"name":"[root] aws_api_gateway_rest_api.api","label":"aws_api_gateway_rest_api.api","shape":"box"},{"_gvid":38,"name":"[root] aws_cloudwatch_event_rule.everyday","label":"aws_cloudwatch_event_rule.everyday","shape":"box"},{"_gvid":39,"name":"[root] aws_cloudwatch_event_target.clean_up_urls_everyday","label":"aws_cloudwatch_event_target.clean_up_urls_everyday","shape":"box"},{"_gvid":40,"name":"[root] aws_iam_policy.invoke","label":"aws_iam_policy.invoke","shape":"box"},{"_gvid":41,"name":"[root] aws_iam_policy.ip","label":"aws_iam_policy.ip","shape":"box"},{"_gvid":42,"name":"[root] aws_iam_policy.ip_put","label":"aws_iam_policy.ip_put","shape":"box"},{"_gvid":43,"name":"[root] aws_iam_policy.lambda_fetch_s3","label":"aws_iam_policy.lambda_fetch_s3","shape":"box"},{"_gvid":44,"name":"[root] aws_iam_role.lambda_fetch_object_role","label":"aws_iam_role.lambda_fetch_object_role","shape":"box"},{"_gvid":45,"name":"[root] aws_iam_role.lambda_generate_url_helper_role","label":"aws_iam_role.lambda_generate_url_helper_role","shape":"box"},{"_gvid":46,"name":"[root] aws_iam_role.lambda_generate_url_role","label":"aws_iam_role.lambda_generate_url_role","shape":"box"},{"_gvid":47,"name":"[root] aws_iam_role.lambda_remove_urls_role","label":"aws_iam_role.lambda_remove_urls_role","shape":"box"},{"_gvid":48,"name":"[root] aws_iam_role.lambda_upload_url_role","label":"aws_iam_role.lambda_upload_url_role","shape":"box"},{"_gvid":49,"name":"[root] aws_iam_role_policy_attachment.invokehelper_gen","label":"aws_iam_role_policy_attachment.invokehelper_gen","shape":"box"},{"_gvid":50,"name":"[root] aws_iam_role_policy_attachment.invokehelper_remove","label":"aws_iam_role_policy_attachment.invokehelper_remove","shape":"box"},{"_gvid":51,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_fetch","label":"aws_iam_role_policy_attachment.lambdabasic_fetch","shape":"box"},{"_gvid":52,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_gen","label":"aws_iam_role_policy_attachment.lambdabasic_gen","shape":"box"},{"_gvid":53,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_genhelp","label":"aws_iam_role_policy_attachment.lambdabasic_genhelp","shape":"box"},{"_gvid":54,"name":"[root] aws_iam_role_policy_attachment.s3full_gen","label":"aws_iam_role_policy_attachment.s3full_gen","shape":"box"},{"_gvid":55,"name":"[root] aws_iam_role_policy_attachment.s3full_remove","label":"aws_iam_role_policy_attachment.s3full_remove","shape":"box"},{"_gvid":56,"name":"[root] aws_iam_role_policy_attachment.s3ip_genhelp","label":"aws_iam_role_policy_attachment.s3ip_genhelp","shape":"box"},{"_gvid":57,"name":"[root] aws_iam_role_policy_attachment.s3ip_upload","label":"aws_iam_role_policy_attachment.s3ip_upload","shape":"box"},{"_gvid":58,"name":"[root] aws_iam_role_policy_attachment.s3read_fetch","label":"aws_iam_role_policy_attachment.s3read_fetch","shape":"box"},{"_gvid":59,"name":"[root] aws_lambda_function.fetch","label":"aws_lambda_function.fetch","shape":"box"},{"_gvid":60,"name":"[root] aws_lambda_function.gen","label":"aws_lambda_function.gen","shape":"box"},{"_gvid":61,"name":"[root] aws_lambda_function.genhelp","label":"aws_lambda_function.genhelp","shape":"box"},{"_gvid":62,"name":"[root] aws_lambda_function.remove","label":"aws_lambda_function.remove","shape":"box"},{"_gvid":63,"name":"[root] aws_lambda_function.upload","label":"aws_lambda_function.upload","shape":"box"},{"_gvid":64,"name":"[root] aws_lambda_permission.allow_cloudwatch_to_call_check_foo","label":"aws_lambda_permission.allow_cloudwatch_to_call_check_foo","shape":"box"},{"_gvid":65,"name":"[root] aws_lambda_permission.apigw_fetch_lambda","label":"aws_lambda_permission.apigw_fetch_lambda","shape":"box"},{"_gvid":66,"name":"[root] aws_lambda_permission.apigw_generate_lambda","label":"aws_lambda_permission.apigw_generate_lambda","shape":"box"},{"_gvid":67,"name":"[root] aws_lambda_permission.apigw_upload_lambda","label":"aws_lambda_permission.apigw_upload_lambda","shape":"box"},{"_gvid":68,"name":"[root] aws_route53_record.route","label":"aws_route53_record.route","shape":"box"},{"_gvid":69,"name":"[root] aws_route53_zone.primary","label":"aws_route53_zone.primary","shape":"box"},{"_gvid":70,"name":"[root] aws_s3_bucket.download_bucket","label":"aws_s3_bucket.download_bucket","shape":"box"},{"_gvid":71,"name":"[root] aws_s3_bucket.upload_bucket","label":"aws_s3_bucket.upload_bucket","shape":"box"},{"_gvid":72,"name":"[root] aws_s3_bucket_public_access_block.private_download_bucket","label":"aws_s3_bucket_public_access_block.private_download_bucket","shape":"box"},{"_gvid":73,"name":"[root] aws_s3_bucket_public_access_block.private_upload_bucket","label":"aws_s3_bucket_public_access_block.private_upload_bucket","shape":"box"},{"_gvid":74,"name":"[root] data.archive_file.fetch_object_code","label":"data.archive_file.fetch_object_code","shape":"box"},{"_gvid":75,"name":"[root] data.archive_file.generate_url_helper_code","label":"data.archive_file.generate_url_helper_code","shape":"box"},{"_gvid":76,"name":"[root] data.archive_file.generate_url_main_code","label":"data.archive_file.generate_url_main_code","shape":"box"},{"_gvid":77,"name":"[root] data.archive_file.remove_expired_urls_code","label":"data.archive_file.remove_expired_urls_code","shape":"box"},{"_gvid":78,"name":"[root] data.archive_file.upload_url_code","label":"data.archive_file.upload_url_code","shape":"box"},{"_gvid":79,"name":"[root] data.aws_acm_certificate.cert","label":"data.aws_acm_certificate.cert","shape":"box"},{"_gvid":80,"name":"[root] null_resource.build_image","label":"null_resource.build_image","shape":"box"},{"_gvid":81,"name":"[root] provider.archive","label":"provider.archive","shape":"diamond"},{"_gvid":82,"name":"[root] provider.aws","label":"provider.aws","shape":"diamond"},{"_gvid":83,"name":"[root] meta.count-boundary (EachMode fixup)","label":"\\N"},{"_gvid":84,"name":"[root] provider.archive (close)","label":"\\N"},{"_gvid":85,"name":"[root] provider.aws (close)","label":"\\N"},{"_gvid":86,"name":"[root] provider.null (close)","label":"\\N"},{"_gvid":87,"name":"[root] provisioner.local-exec (close)","label":"\\N"},{"_gvid":88,"name":"[root] root","label":"\\N"}],"edges":[{"_gvid":0,"tail":1,"head":2},{"_gvid":1,"tail":1,"head":3},{"_gvid":2,"tail":2,"head":4},{"_gvid":3,"tail":2,"head":5},{"_gvid":4,"tail":2,"head":7},{"_gvid":5,"tail":3,"head":79},{"_gvid":6,"tail":4,"head":14},{"_gvid":7,"tail":4,"head":59},{"_gvid":8,"tail":5,"head":15},{"_gvid":9,"tail":5,"head":60},{"_gvid":10,"tail":6,"head":16},{"_gvid":11,"tail":7,"head":17},{"_gvid":12,"tail":7,"head":63},{"_gvid":13,"tail":8,"head":18},{"_gvid":14,"tail":9,"head":4},{"_gvid":15,"tail":9,"head":19},{"_gvid":16,"tail":10,"head":22},{"_gvid":17,"tail":10,"head":70},{"_gvid":18,"tail":11,"head":26},{"_gvid":19,"tail":11,"head":70},{"_gvid":20,"tail":12,"head":28},{"_gvid":21,"tail":12,"head":71},{"_gvid":22,"tail":13,"head":31},{"_gvid":23,"tail":13,"head":71},{"_gvid":24,"tail":14,"head":32},{"_gvid":25,"tail":14,"head":34},{"_gvid":26,"tail":15,"head":33},{"_gvid":27,"tail":15,"head":35},{"_gvid":28,"tail":16,"head":35},{"_gvid":29,"tail":17,"head":36},{"_gvid":30,"tail":18,"head":36},{"_gvid":31,"tail":19,"head":14},{"_gvid":32,"tail":20,"head":14},{"_gvid":33,"tail":21,"head":15},{"_gvid":34,"tail":22,"head":15},{"_gvid":35,"tail":23,"head":15},{"_gvid":36,"tail":24,"head":15},{"_gvid":37,"tail":25,"head":15},{"_gvid":38,"tail":26,"head":16},{"_gvid":39,"tail":27,"head":17},{"_gvid":40,"tail":28,"head":17},{"_gvid":41,"tail":29,"head":17},{"_gvid":42,"tail":30,"head":17},{"_gvid":43,"tail":31,"head":18},{"_gvid":44,"tail":32,"head":37},{"_gvid":45,"tail":33,"head":37},{"_gvid":46,"tail":34,"head":37},{"_gvid":47,"tail":35,"head":37},{"_gvid":48,"tail":36,"head":37},{"_gvid":49,"tail":37,"head":82},{"_gvid":50,"tail":38,"head":82},{"_gvid":51,"tail":39,"head":38},{"_gvid":52,"tail":39,"head":62},{"_gvid":53,"tail":40,"head":61},{"_gvid":54,"tail":41,"head":82},{"_gvid":55,"tail":42,"head":82},{"_gvid":56,"tail":43,"head":82},{"_gvid":57,"tail":44,"head":82},{"_gvid":58,"tail":45,"head":82},{"_gvid":59,"tail":46,"head":82},{"_gvid":60,"tail":47,"head":82},{"_gvid":61,"tail":48,"head":82},{"_gvid":62,"tail":49,"head":40},{"_gvid":63,"tail":49,"head":46},{"_gvid":64,"tail":50,"head":40},{"_gvid":65,"tail":50,"head":47},{"_gvid":66,"tail":51,"head":44},{"_gvid":67,"tail":52,"head":46},{"_gvid":68,"tail":53,"head":45},{"_gvid":69,"tail":54,"head":46},{"_gvid":70,"tail":55,"head":47},{"_gvid":71,"tail":56,"head":41},{"_gvid":72,"tail":56,"head":45},{"_gvid":73,"tail":57,"head":42},{"_gvid":74,"tail":57,"head":48},{"_gvid":75,"tail":58,"head":43},{"_gvid":76,"tail":58,"head":44},{"_gvid":77,"tail":59,"head":44},{"_gvid":78,"tail":59,"head":70},{"_gvid":79,"tail":59,"head":74},{"_gvid":80,"tail":60,"head":46},{"_gvid":81,"tail":60,"head":70},{"_gvid":82,"tail":60,"head":76},{"_gvid":83,"tail":61,"head":45},{"_gvid":84,"tail":61,"head":75},{"_gvid":85,"tail":62,"head":47},{"_gvid":86,"tail":62,"head":70},{"_gvid":87,"tail":62,"head":77},{"_gvid":88,"tail":63,"head":48},{"_gvid":89,"tail":63,"head":71},{"_gvid":90,"tail":63,"head":78},{"_gvid":91,"tail":64,"head":38},{"_gvid":92,"tail":64,"head":62},{"_gvid":93,"tail":65,"head":14},{"_gvid":94,"tail":65,"head":59},{"_gvid":95,"tail":66,"head":15},{"_gvid":96,"tail":66,"head":60},{"_gvid":97,"tail":67,"head":17},{"_gvid":98,"tail":67,"head":63},{"_gvid":99,"tail":68,"head":3},{"_gvid":100,"tail":68,"head":69},{"_gvid":101,"tail":69,"head":82},{"_gvid":102,"tail":70,"head":82},{"_gvid":103,"tail":71,"head":70},{"_gvid":104,"tail":72,"head":70},{"_gvid":105,"tail":73,"head":71},{"_gvid":106,"tail":74,"head":81},{"_gvid":107,"tail":75,"head":81},{"_gvid":108,"tail":76,"head":81},{"_gvid":109,"tail":77,"head":81},{"_gvid":110,"tail":78,"head":81},{"_gvid":111,"tail":79,"head":82},{"_gvid":112,"tail":80,"head":71},{"_gvid":113,"tail":83,"head":1},{"_gvid":114,"tail":83,"head":6},{"_gvid":115,"tail":83,"head":8},{"_gvid":116,"tail":83,"head":9},{"_gvid":117,"tail":83,"head":10},{"_gvid":118,"tail":83,"head":11},{"_gvid":119,"tail":83,"head":12},{"_gvid":120,"tail":83,"head":13},{"_gvid":121,"tail":83,"head":20},{"_gvid":122,"tail":83,"head":21},{"_gvid":123,"tail":83,"head":23},{"_gvid":124,"tail":83,"head":24},{"_gvid":125,"tail":83,"head":25},{"_gvid":126,"tail":83,"head":27},{"_gvid":127,"tail":83,"head":29},{"_gvid":128,"tail":83,"head":30},{"_gvid":129,"tail":83,"head":39},{"_gvid":130,"tail":83,"head":49},{"_gvid":131,"tail":83,"head":50},{"_gvid":132,"tail":83,"head":51},{"_gvid":133,"tail":83,"head":52},{"_gvid":134,"tail":83,"head":53},{"_gvid":135,"tail":83,"head":54},{"_gvid":136,"tail":83,"head":55},{"_gvid":137,"tail":83,"head":56},{"_gvid":138,"tail":83,"head":57},{"_gvid":139,"tail":83,"head":58},{"_gvid":140,"tail":83,"head":64},{"_gvid":141,"tail":83,"head":65},{"_gvid":142,"tail":83,"head":66},{"_gvid":143,"tail":83,"head":67},{"_gvid":144,"tail":83,"head":68},{"_gvid":145,"tail":83,"head":72},{"_gvid":146,"tail":83,"head":73},{"_gvid":147,"tail":83,"head":80},{"_gvid":148,"tail":84,"head":74},{"_gvid":149,"tail":84,"head":75},{"_gvid":150,"tail":84,"head":76},{"_gvid":151,"tail":84,"head":77},{"_gvid":152,"tail":84,"head":78},{"_gvid":153,"tail":85,"head":1},{"_gvid":154,"tail":85,"head":6},{"_gvid":155,"tail":85,"head":8},{"_gvid":156,"tail":85,"head":9},{"_gvid":157,"tail":85,"head":10},{"_gvid":158,"tail":85,"head":11},{"_gvid":159,"tail":85,"head":12},{"_gvid":160,"tail":85,"head":13},{"_gvid":161,"tail":85,"head":20},{"_gvid":162,"tail":85,"head":21},{"_gvid":163,"tail":85,"head":23},{"_gvid":164,"tail":85,"head":24},{"_gvid":165,"tail":85,"head":25},{"_gvid":166,"tail":85,"head":27},{"_gvid":167,"tail":85,"head":29},{"_gvid":168,"tail":85,"head":30},{"_gvid":169,"tail":85,"head":39},{"_gvid":170,"tail":85,"head":49},{"_gvid":171,"tail":85,"head":50},{"_gvid":172,"tail":85,"head":51},{"_gvid":173,"tail":85,"head":52},{"_gvid":174,"tail":85,"head":53},{"_gvid":175,"tail":85,"head":54},{"_gvid":176,"tail":85,"head":55},{"_gvid":177,"tail":85,"head":56},{"_gvid":178,"tail":85,"head":57},{"_gvid":179,"tail":85,"head":58},{"_gvid":180,"tail":85,"head":64},{"_gvid":181,"tail":85,"head":65},{"_gvid":182,"tail":85,"head":66},{"_gvid":183,"tail":85,"head":67},{"_gvid":184,"tail":85,"head":68},{"_gvid":185,"tail":85,"head":72},{"_gvid":186,"tail":85,"head":73},{"_gvid":187,"tail":86,"head":80},{"_gvid":188,"tail":87,"head":80},{"_gvid":189,"tail":88,"head":83},{"_gvid":190,"tail":88,"head":84},{"_gvid":191,"tail":88,"head":85},{"_gvid":192,"tail":88,"head":86},{"_gvid":193,"tail":88,"head":87}]}' + + adj = adjacency_list(json_string) coordinates = gen_coordinates(adj) # # verification From 48aa67e75eb1f811fed1b625213122b4414a9df0 Mon Sep 17 00:00:00 2001 From: Joshua SA Date: Mon, 6 Jan 2020 14:08:49 -0500 Subject: [PATCH 9/9] working --- coordinates/prototype3.py | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/coordinates/prototype3.py b/coordinates/prototype3.py index 3599c24..5a5168e 100644 --- a/coordinates/prototype3.py +++ b/coordinates/prototype3.py @@ -318,7 +318,7 @@ def gen_coordinates(adj_unparsed, radius=5): def adjacency_list(adj_string): global json_string # json_string = r'{"name":"%3","directed":true,"strict":false,"compound":"true","newrank":"true","_subgraph_cnt":1,"objects":[{"name":"root","compound":"true","newrank":"true","_gvid":0,"nodes":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88],"edges":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193]},{"_gvid":1,"name":"[root] aws_api_gateway_base_path_mapping.base_path","label":"aws_api_gateway_base_path_mapping.base_path","shape":"box"},{"_gvid":2,"name":"[root] aws_api_gateway_deployment.deployment","label":"aws_api_gateway_deployment.deployment","shape":"box"},{"_gvid":3,"name":"[root] aws_api_gateway_domain_name.urlapi","label":"aws_api_gateway_domain_name.urlapi","shape":"box"},{"_gvid":4,"name":"[root] aws_api_gateway_integration.fetch_integration","label":"aws_api_gateway_integration.fetch_integration","shape":"box"},{"_gvid":5,"name":"[root] aws_api_gateway_integration.generate_integration","label":"aws_api_gateway_integration.generate_integration","shape":"box"},{"_gvid":6,"name":"[root] aws_api_gateway_integration.generate_options_integration","label":"aws_api_gateway_integration.generate_options_integration","shape":"box"},{"_gvid":7,"name":"[root] aws_api_gateway_integration.upload_integration","label":"aws_api_gateway_integration.upload_integration","shape":"box"},{"_gvid":8,"name":"[root] aws_api_gateway_integration.upload_options_integration","label":"aws_api_gateway_integration.upload_options_integration","shape":"box"},{"_gvid":9,"name":"[root] aws_api_gateway_integration_response.fetch_ir_200","label":"aws_api_gateway_integration_response.fetch_ir_200","shape":"box"},{"_gvid":10,"name":"[root] aws_api_gateway_integration_response.generate_ir_400","label":"aws_api_gateway_integration_response.generate_ir_400","shape":"box"},{"_gvid":11,"name":"[root] aws_api_gateway_integration_response.generate_options_integration_response","label":"aws_api_gateway_integration_response.generate_options_integration_response","shape":"box"},{"_gvid":12,"name":"[root] aws_api_gateway_integration_response.upload_ir_400","label":"aws_api_gateway_integration_response.upload_ir_400","shape":"box"},{"_gvid":13,"name":"[root] aws_api_gateway_integration_response.upload_options_integration_response","label":"aws_api_gateway_integration_response.upload_options_integration_response","shape":"box"},{"_gvid":14,"name":"[root] aws_api_gateway_method.fetch","label":"aws_api_gateway_method.fetch","shape":"box"},{"_gvid":15,"name":"[root] aws_api_gateway_method.generate","label":"aws_api_gateway_method.generate","shape":"box"},{"_gvid":16,"name":"[root] aws_api_gateway_method.generate_options","label":"aws_api_gateway_method.generate_options","shape":"box"},{"_gvid":17,"name":"[root] aws_api_gateway_method.upload","label":"aws_api_gateway_method.upload","shape":"box"},{"_gvid":18,"name":"[root] aws_api_gateway_method.upload_options","label":"aws_api_gateway_method.upload_options","shape":"box"},{"_gvid":19,"name":"[root] aws_api_gateway_method_response.fetch_200","label":"aws_api_gateway_method_response.fetch_200","shape":"box"},{"_gvid":20,"name":"[root] aws_api_gateway_method_response.fetch_400","label":"aws_api_gateway_method_response.fetch_400","shape":"box"},{"_gvid":21,"name":"[root] aws_api_gateway_method_response.generate_200","label":"aws_api_gateway_method_response.generate_200","shape":"box"},{"_gvid":22,"name":"[root] aws_api_gateway_method_response.generate_400","label":"aws_api_gateway_method_response.generate_400","shape":"box"},{"_gvid":23,"name":"[root] aws_api_gateway_method_response.generate_401","label":"aws_api_gateway_method_response.generate_401","shape":"box"},{"_gvid":24,"name":"[root] aws_api_gateway_method_response.generate_404","label":"aws_api_gateway_method_response.generate_404","shape":"box"},{"_gvid":25,"name":"[root] aws_api_gateway_method_response.generate_500","label":"aws_api_gateway_method_response.generate_500","shape":"box"},{"_gvid":26,"name":"[root] aws_api_gateway_method_response.generate_options_200","label":"aws_api_gateway_method_response.generate_options_200","shape":"box"},{"_gvid":27,"name":"[root] aws_api_gateway_method_response.upload_200","label":"aws_api_gateway_method_response.upload_200","shape":"box"},{"_gvid":28,"name":"[root] aws_api_gateway_method_response.upload_400","label":"aws_api_gateway_method_response.upload_400","shape":"box"},{"_gvid":29,"name":"[root] aws_api_gateway_method_response.upload_401","label":"aws_api_gateway_method_response.upload_401","shape":"box"},{"_gvid":30,"name":"[root] aws_api_gateway_method_response.upload_500","label":"aws_api_gateway_method_response.upload_500","shape":"box"},{"_gvid":31,"name":"[root] aws_api_gateway_method_response.upload_options_200","label":"aws_api_gateway_method_response.upload_options_200","shape":"box"},{"_gvid":32,"name":"[root] aws_api_gateway_request_validator.fetch_validator","label":"aws_api_gateway_request_validator.fetch_validator","shape":"box"},{"_gvid":33,"name":"[root] aws_api_gateway_request_validator.generate_validator","label":"aws_api_gateway_request_validator.generate_validator","shape":"box"},{"_gvid":34,"name":"[root] aws_api_gateway_resource.fetch_resource","label":"aws_api_gateway_resource.fetch_resource","shape":"box"},{"_gvid":35,"name":"[root] aws_api_gateway_resource.generate_resource","label":"aws_api_gateway_resource.generate_resource","shape":"box"},{"_gvid":36,"name":"[root] aws_api_gateway_resource.upload_resource","label":"aws_api_gateway_resource.upload_resource","shape":"box"},{"_gvid":37,"name":"[root] aws_api_gateway_rest_api.api","label":"aws_api_gateway_rest_api.api","shape":"box"},{"_gvid":38,"name":"[root] aws_cloudwatch_event_rule.everyday","label":"aws_cloudwatch_event_rule.everyday","shape":"box"},{"_gvid":39,"name":"[root] aws_cloudwatch_event_target.clean_up_urls_everyday","label":"aws_cloudwatch_event_target.clean_up_urls_everyday","shape":"box"},{"_gvid":40,"name":"[root] aws_iam_policy.invoke","label":"aws_iam_policy.invoke","shape":"box"},{"_gvid":41,"name":"[root] aws_iam_policy.ip","label":"aws_iam_policy.ip","shape":"box"},{"_gvid":42,"name":"[root] aws_iam_policy.ip_put","label":"aws_iam_policy.ip_put","shape":"box"},{"_gvid":43,"name":"[root] aws_iam_policy.lambda_fetch_s3","label":"aws_iam_policy.lambda_fetch_s3","shape":"box"},{"_gvid":44,"name":"[root] aws_iam_role.lambda_fetch_object_role","label":"aws_iam_role.lambda_fetch_object_role","shape":"box"},{"_gvid":45,"name":"[root] aws_iam_role.lambda_generate_url_helper_role","label":"aws_iam_role.lambda_generate_url_helper_role","shape":"box"},{"_gvid":46,"name":"[root] aws_iam_role.lambda_generate_url_role","label":"aws_iam_role.lambda_generate_url_role","shape":"box"},{"_gvid":47,"name":"[root] aws_iam_role.lambda_remove_urls_role","label":"aws_iam_role.lambda_remove_urls_role","shape":"box"},{"_gvid":48,"name":"[root] aws_iam_role.lambda_upload_url_role","label":"aws_iam_role.lambda_upload_url_role","shape":"box"},{"_gvid":49,"name":"[root] aws_iam_role_policy_attachment.invokehelper_gen","label":"aws_iam_role_policy_attachment.invokehelper_gen","shape":"box"},{"_gvid":50,"name":"[root] aws_iam_role_policy_attachment.invokehelper_remove","label":"aws_iam_role_policy_attachment.invokehelper_remove","shape":"box"},{"_gvid":51,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_fetch","label":"aws_iam_role_policy_attachment.lambdabasic_fetch","shape":"box"},{"_gvid":52,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_gen","label":"aws_iam_role_policy_attachment.lambdabasic_gen","shape":"box"},{"_gvid":53,"name":"[root] aws_iam_role_policy_attachment.lambdabasic_genhelp","label":"aws_iam_role_policy_attachment.lambdabasic_genhelp","shape":"box"},{"_gvid":54,"name":"[root] aws_iam_role_policy_attachment.s3full_gen","label":"aws_iam_role_policy_attachment.s3full_gen","shape":"box"},{"_gvid":55,"name":"[root] aws_iam_role_policy_attachment.s3full_remove","label":"aws_iam_role_policy_attachment.s3full_remove","shape":"box"},{"_gvid":56,"name":"[root] aws_iam_role_policy_attachment.s3ip_genhelp","label":"aws_iam_role_policy_attachment.s3ip_genhelp","shape":"box"},{"_gvid":57,"name":"[root] aws_iam_role_policy_attachment.s3ip_upload","label":"aws_iam_role_policy_attachment.s3ip_upload","shape":"box"},{"_gvid":58,"name":"[root] aws_iam_role_policy_attachment.s3read_fetch","label":"aws_iam_role_policy_attachment.s3read_fetch","shape":"box"},{"_gvid":59,"name":"[root] aws_lambda_function.fetch","label":"aws_lambda_function.fetch","shape":"box"},{"_gvid":60,"name":"[root] aws_lambda_function.gen","label":"aws_lambda_function.gen","shape":"box"},{"_gvid":61,"name":"[root] aws_lambda_function.genhelp","label":"aws_lambda_function.genhelp","shape":"box"},{"_gvid":62,"name":"[root] aws_lambda_function.remove","label":"aws_lambda_function.remove","shape":"box"},{"_gvid":63,"name":"[root] aws_lambda_function.upload","label":"aws_lambda_function.upload","shape":"box"},{"_gvid":64,"name":"[root] aws_lambda_permission.allow_cloudwatch_to_call_check_foo","label":"aws_lambda_permission.allow_cloudwatch_to_call_check_foo","shape":"box"},{"_gvid":65,"name":"[root] aws_lambda_permission.apigw_fetch_lambda","label":"aws_lambda_permission.apigw_fetch_lambda","shape":"box"},{"_gvid":66,"name":"[root] aws_lambda_permission.apigw_generate_lambda","label":"aws_lambda_permission.apigw_generate_lambda","shape":"box"},{"_gvid":67,"name":"[root] aws_lambda_permission.apigw_upload_lambda","label":"aws_lambda_permission.apigw_upload_lambda","shape":"box"},{"_gvid":68,"name":"[root] aws_route53_record.route","label":"aws_route53_record.route","shape":"box"},{"_gvid":69,"name":"[root] aws_route53_zone.primary","label":"aws_route53_zone.primary","shape":"box"},{"_gvid":70,"name":"[root] aws_s3_bucket.download_bucket","label":"aws_s3_bucket.download_bucket","shape":"box"},{"_gvid":71,"name":"[root] aws_s3_bucket.upload_bucket","label":"aws_s3_bucket.upload_bucket","shape":"box"},{"_gvid":72,"name":"[root] aws_s3_bucket_public_access_block.private_download_bucket","label":"aws_s3_bucket_public_access_block.private_download_bucket","shape":"box"},{"_gvid":73,"name":"[root] aws_s3_bucket_public_access_block.private_upload_bucket","label":"aws_s3_bucket_public_access_block.private_upload_bucket","shape":"box"},{"_gvid":74,"name":"[root] data.archive_file.fetch_object_code","label":"data.archive_file.fetch_object_code","shape":"box"},{"_gvid":75,"name":"[root] data.archive_file.generate_url_helper_code","label":"data.archive_file.generate_url_helper_code","shape":"box"},{"_gvid":76,"name":"[root] data.archive_file.generate_url_main_code","label":"data.archive_file.generate_url_main_code","shape":"box"},{"_gvid":77,"name":"[root] data.archive_file.remove_expired_urls_code","label":"data.archive_file.remove_expired_urls_code","shape":"box"},{"_gvid":78,"name":"[root] data.archive_file.upload_url_code","label":"data.archive_file.upload_url_code","shape":"box"},{"_gvid":79,"name":"[root] data.aws_acm_certificate.cert","label":"data.aws_acm_certificate.cert","shape":"box"},{"_gvid":80,"name":"[root] null_resource.build_image","label":"null_resource.build_image","shape":"box"},{"_gvid":81,"name":"[root] provider.archive","label":"provider.archive","shape":"diamond"},{"_gvid":82,"name":"[root] provider.aws","label":"provider.aws","shape":"diamond"},{"_gvid":83,"name":"[root] meta.count-boundary (EachMode fixup)","label":"\\N"},{"_gvid":84,"name":"[root] provider.archive (close)","label":"\\N"},{"_gvid":85,"name":"[root] provider.aws (close)","label":"\\N"},{"_gvid":86,"name":"[root] provider.null (close)","label":"\\N"},{"_gvid":87,"name":"[root] provisioner.local-exec (close)","label":"\\N"},{"_gvid":88,"name":"[root] root","label":"\\N"}],"edges":[{"_gvid":0,"tail":1,"head":2},{"_gvid":1,"tail":1,"head":3},{"_gvid":2,"tail":2,"head":4},{"_gvid":3,"tail":2,"head":5},{"_gvid":4,"tail":2,"head":7},{"_gvid":5,"tail":3,"head":79},{"_gvid":6,"tail":4,"head":14},{"_gvid":7,"tail":4,"head":59},{"_gvid":8,"tail":5,"head":15},{"_gvid":9,"tail":5,"head":60},{"_gvid":10,"tail":6,"head":16},{"_gvid":11,"tail":7,"head":17},{"_gvid":12,"tail":7,"head":63},{"_gvid":13,"tail":8,"head":18},{"_gvid":14,"tail":9,"head":4},{"_gvid":15,"tail":9,"head":19},{"_gvid":16,"tail":10,"head":22},{"_gvid":17,"tail":10,"head":70},{"_gvid":18,"tail":11,"head":26},{"_gvid":19,"tail":11,"head":70},{"_gvid":20,"tail":12,"head":28},{"_gvid":21,"tail":12,"head":71},{"_gvid":22,"tail":13,"head":31},{"_gvid":23,"tail":13,"head":71},{"_gvid":24,"tail":14,"head":32},{"_gvid":25,"tail":14,"head":34},{"_gvid":26,"tail":15,"head":33},{"_gvid":27,"tail":15,"head":35},{"_gvid":28,"tail":16,"head":35},{"_gvid":29,"tail":17,"head":36},{"_gvid":30,"tail":18,"head":36},{"_gvid":31,"tail":19,"head":14},{"_gvid":32,"tail":20,"head":14},{"_gvid":33,"tail":21,"head":15},{"_gvid":34,"tail":22,"head":15},{"_gvid":35,"tail":23,"head":15},{"_gvid":36,"tail":24,"head":15},{"_gvid":37,"tail":25,"head":15},{"_gvid":38,"tail":26,"head":16},{"_gvid":39,"tail":27,"head":17},{"_gvid":40,"tail":28,"head":17},{"_gvid":41,"tail":29,"head":17},{"_gvid":42,"tail":30,"head":17},{"_gvid":43,"tail":31,"head":18},{"_gvid":44,"tail":32,"head":37},{"_gvid":45,"tail":33,"head":37},{"_gvid":46,"tail":34,"head":37},{"_gvid":47,"tail":35,"head":37},{"_gvid":48,"tail":36,"head":37},{"_gvid":49,"tail":37,"head":82},{"_gvid":50,"tail":38,"head":82},{"_gvid":51,"tail":39,"head":38},{"_gvid":52,"tail":39,"head":62},{"_gvid":53,"tail":40,"head":61},{"_gvid":54,"tail":41,"head":82},{"_gvid":55,"tail":42,"head":82},{"_gvid":56,"tail":43,"head":82},{"_gvid":57,"tail":44,"head":82},{"_gvid":58,"tail":45,"head":82},{"_gvid":59,"tail":46,"head":82},{"_gvid":60,"tail":47,"head":82},{"_gvid":61,"tail":48,"head":82},{"_gvid":62,"tail":49,"head":40},{"_gvid":63,"tail":49,"head":46},{"_gvid":64,"tail":50,"head":40},{"_gvid":65,"tail":50,"head":47},{"_gvid":66,"tail":51,"head":44},{"_gvid":67,"tail":52,"head":46},{"_gvid":68,"tail":53,"head":45},{"_gvid":69,"tail":54,"head":46},{"_gvid":70,"tail":55,"head":47},{"_gvid":71,"tail":56,"head":41},{"_gvid":72,"tail":56,"head":45},{"_gvid":73,"tail":57,"head":42},{"_gvid":74,"tail":57,"head":48},{"_gvid":75,"tail":58,"head":43},{"_gvid":76,"tail":58,"head":44},{"_gvid":77,"tail":59,"head":44},{"_gvid":78,"tail":59,"head":70},{"_gvid":79,"tail":59,"head":74},{"_gvid":80,"tail":60,"head":46},{"_gvid":81,"tail":60,"head":70},{"_gvid":82,"tail":60,"head":76},{"_gvid":83,"tail":61,"head":45},{"_gvid":84,"tail":61,"head":75},{"_gvid":85,"tail":62,"head":47},{"_gvid":86,"tail":62,"head":70},{"_gvid":87,"tail":62,"head":77},{"_gvid":88,"tail":63,"head":48},{"_gvid":89,"tail":63,"head":71},{"_gvid":90,"tail":63,"head":78},{"_gvid":91,"tail":64,"head":38},{"_gvid":92,"tail":64,"head":62},{"_gvid":93,"tail":65,"head":14},{"_gvid":94,"tail":65,"head":59},{"_gvid":95,"tail":66,"head":15},{"_gvid":96,"tail":66,"head":60},{"_gvid":97,"tail":67,"head":17},{"_gvid":98,"tail":67,"head":63},{"_gvid":99,"tail":68,"head":3},{"_gvid":100,"tail":68,"head":69},{"_gvid":101,"tail":69,"head":82},{"_gvid":102,"tail":70,"head":82},{"_gvid":103,"tail":71,"head":70},{"_gvid":104,"tail":72,"head":70},{"_gvid":105,"tail":73,"head":71},{"_gvid":106,"tail":74,"head":81},{"_gvid":107,"tail":75,"head":81},{"_gvid":108,"tail":76,"head":81},{"_gvid":109,"tail":77,"head":81},{"_gvid":110,"tail":78,"head":81},{"_gvid":111,"tail":79,"head":82},{"_gvid":112,"tail":80,"head":71},{"_gvid":113,"tail":83,"head":1},{"_gvid":114,"tail":83,"head":6},{"_gvid":115,"tail":83,"head":8},{"_gvid":116,"tail":83,"head":9},{"_gvid":117,"tail":83,"head":10},{"_gvid":118,"tail":83,"head":11},{"_gvid":119,"tail":83,"head":12},{"_gvid":120,"tail":83,"head":13},{"_gvid":121,"tail":83,"head":20},{"_gvid":122,"tail":83,"head":21},{"_gvid":123,"tail":83,"head":23},{"_gvid":124,"tail":83,"head":24},{"_gvid":125,"tail":83,"head":25},{"_gvid":126,"tail":83,"head":27},{"_gvid":127,"tail":83,"head":29},{"_gvid":128,"tail":83,"head":30},{"_gvid":129,"tail":83,"head":39},{"_gvid":130,"tail":83,"head":49},{"_gvid":131,"tail":83,"head":50},{"_gvid":132,"tail":83,"head":51},{"_gvid":133,"tail":83,"head":52},{"_gvid":134,"tail":83,"head":53},{"_gvid":135,"tail":83,"head":54},{"_gvid":136,"tail":83,"head":55},{"_gvid":137,"tail":83,"head":56},{"_gvid":138,"tail":83,"head":57},{"_gvid":139,"tail":83,"head":58},{"_gvid":140,"tail":83,"head":64},{"_gvid":141,"tail":83,"head":65},{"_gvid":142,"tail":83,"head":66},{"_gvid":143,"tail":83,"head":67},{"_gvid":144,"tail":83,"head":68},{"_gvid":145,"tail":83,"head":72},{"_gvid":146,"tail":83,"head":73},{"_gvid":147,"tail":83,"head":80},{"_gvid":148,"tail":84,"head":74},{"_gvid":149,"tail":84,"head":75},{"_gvid":150,"tail":84,"head":76},{"_gvid":151,"tail":84,"head":77},{"_gvid":152,"tail":84,"head":78},{"_gvid":153,"tail":85,"head":1},{"_gvid":154,"tail":85,"head":6},{"_gvid":155,"tail":85,"head":8},{"_gvid":156,"tail":85,"head":9},{"_gvid":157,"tail":85,"head":10},{"_gvid":158,"tail":85,"head":11},{"_gvid":159,"tail":85,"head":12},{"_gvid":160,"tail":85,"head":13},{"_gvid":161,"tail":85,"head":20},{"_gvid":162,"tail":85,"head":21},{"_gvid":163,"tail":85,"head":23},{"_gvid":164,"tail":85,"head":24},{"_gvid":165,"tail":85,"head":25},{"_gvid":166,"tail":85,"head":27},{"_gvid":167,"tail":85,"head":29},{"_gvid":168,"tail":85,"head":30},{"_gvid":169,"tail":85,"head":39},{"_gvid":170,"tail":85,"head":49},{"_gvid":171,"tail":85,"head":50},{"_gvid":172,"tail":85,"head":51},{"_gvid":173,"tail":85,"head":52},{"_gvid":174,"tail":85,"head":53},{"_gvid":175,"tail":85,"head":54},{"_gvid":176,"tail":85,"head":55},{"_gvid":177,"tail":85,"head":56},{"_gvid":178,"tail":85,"head":57},{"_gvid":179,"tail":85,"head":58},{"_gvid":180,"tail":85,"head":64},{"_gvid":181,"tail":85,"head":65},{"_gvid":182,"tail":85,"head":66},{"_gvid":183,"tail":85,"head":67},{"_gvid":184,"tail":85,"head":68},{"_gvid":185,"tail":85,"head":72},{"_gvid":186,"tail":85,"head":73},{"_gvid":187,"tail":86,"head":80},{"_gvid":188,"tail":87,"head":80},{"_gvid":189,"tail":88,"head":83},{"_gvid":190,"tail":88,"head":84},{"_gvid":191,"tail":88,"head":85},{"_gvid":192,"tail":88,"head":86},{"_gvid":193,"tail":88,"head":87}]}' - json_string = adj_string # r'{"name":"%3","directed":true,"strict":false,"compound":"true","newrank":"true","_subgraph_cnt":1,"objects":[{"name":"root","compound":"true","newrank":"true","_gvid":0,"nodes":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33],"edges":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57]},{"_gvid":1,"name":"[root] aws_alb.main","label":"aws_alb.main","shape":"box"},{"_gvid":2,"name":"[root] aws_alb_listener.front_end","label":"aws_alb_listener.front_end","shape":"box"},{"_gvid":3,"name":"[root] aws_alb_target_group.test","label":"aws_alb_target_group.test","shape":"box"},{"_gvid":4,"name":"[root] aws_autoscaling_group.app","label":"aws_autoscaling_group.app","shape":"box"},{"_gvid":5,"name":"[root] aws_cloudwatch_log_group.app","label":"aws_cloudwatch_log_group.app","shape":"box"},{"_gvid":6,"name":"[root] aws_cloudwatch_log_group.ecs","label":"aws_cloudwatch_log_group.ecs","shape":"box"},{"_gvid":7,"name":"[root] aws_ecs_cluster.main","label":"aws_ecs_cluster.main","shape":"box"},{"_gvid":8,"name":"[root] aws_ecs_service.test","label":"aws_ecs_service.test","shape":"box"},{"_gvid":9,"name":"[root] aws_ecs_task_definition.ghost","label":"aws_ecs_task_definition.ghost","shape":"box"},{"_gvid":10,"name":"[root] aws_iam_instance_profile.app","label":"aws_iam_instance_profile.app","shape":"box"},{"_gvid":11,"name":"[root] aws_iam_role.app_instance","label":"aws_iam_role.app_instance","shape":"box"},{"_gvid":12,"name":"[root] aws_iam_role.ecs_service","label":"aws_iam_role.ecs_service","shape":"box"},{"_gvid":13,"name":"[root] aws_iam_role_policy.ecs_service","label":"aws_iam_role_policy.ecs_service","shape":"box"},{"_gvid":14,"name":"[root] aws_iam_role_policy.instance","label":"aws_iam_role_policy.instance","shape":"box"},{"_gvid":15,"name":"[root] aws_internet_gateway.gw","label":"aws_internet_gateway.gw","shape":"box"},{"_gvid":16,"name":"[root] aws_launch_configuration.app","label":"aws_launch_configuration.app","shape":"box"},{"_gvid":17,"name":"[root] aws_route_table.r","label":"aws_route_table.r","shape":"box"},{"_gvid":18,"name":"[root] aws_route_table_association.a","label":"aws_route_table_association.a","shape":"box"},{"_gvid":19,"name":"[root] aws_security_group.instance_sg","label":"aws_security_group.instance_sg","shape":"box"},{"_gvid":20,"name":"[root] aws_security_group.lb_sg","label":"aws_security_group.lb_sg","shape":"box"},{"_gvid":21,"name":"[root] aws_subnet.main","label":"aws_subnet.main","shape":"box"},{"_gvid":22,"name":"[root] aws_vpc.main","label":"aws_vpc.main","shape":"box"},{"_gvid":23,"name":"[root] data.aws_ami.stable_coreos","label":"data.aws_ami.stable_coreos","shape":"box"},{"_gvid":24,"name":"[root] data.aws_availability_zones.available","label":"data.aws_availability_zones.available","shape":"box"},{"_gvid":25,"name":"[root] data.template_file.cloud_config","label":"data.template_file.cloud_config","shape":"box"},{"_gvid":26,"name":"[root] data.template_file.instance_profile","label":"data.template_file.instance_profile","shape":"box"},{"_gvid":27,"name":"[root] data.template_file.task_definition","label":"data.template_file.task_definition","shape":"box"},{"_gvid":28,"name":"[root] provider.aws","label":"provider.aws","shape":"diamond"},{"_gvid":29,"name":"[root] provider.template","label":"provider.template","shape":"diamond"},{"_gvid":30,"name":"[root] meta.count-boundary (EachMode fixup)","label":"\\N"},{"_gvid":31,"name":"[root] provider.aws (close)","label":"\\N"},{"_gvid":32,"name":"[root] provider.template (close)","label":"\\N"},{"_gvid":33,"name":"[root] root","label":"\\N"}],"edges":[{"_gvid":0,"tail":1,"head":20},{"_gvid":1,"tail":1,"head":21},{"_gvid":2,"tail":2,"head":1},{"_gvid":3,"tail":2,"head":3},{"_gvid":4,"tail":3,"head":22},{"_gvid":5,"tail":4,"head":16},{"_gvid":6,"tail":4,"head":21},{"_gvid":7,"tail":5,"head":28},{"_gvid":8,"tail":6,"head":28},{"_gvid":9,"tail":7,"head":28},{"_gvid":10,"tail":8,"head":2},{"_gvid":11,"tail":8,"head":7},{"_gvid":12,"tail":8,"head":9},{"_gvid":13,"tail":8,"head":13},{"_gvid":14,"tail":9,"head":27},{"_gvid":15,"tail":9,"head":28},{"_gvid":16,"tail":10,"head":11},{"_gvid":17,"tail":11,"head":28},{"_gvid":18,"tail":12,"head":28},{"_gvid":19,"tail":13,"head":12},{"_gvid":20,"tail":14,"head":11},{"_gvid":21,"tail":14,"head":26},{"_gvid":22,"tail":15,"head":22},{"_gvid":23,"tail":16,"head":10},{"_gvid":24,"tail":16,"head":19},{"_gvid":25,"tail":16,"head":23},{"_gvid":26,"tail":16,"head":25},{"_gvid":27,"tail":17,"head":15},{"_gvid":28,"tail":18,"head":17},{"_gvid":29,"tail":18,"head":21},{"_gvid":30,"tail":19,"head":20},{"_gvid":31,"tail":20,"head":22},{"_gvid":32,"tail":21,"head":22},{"_gvid":33,"tail":21,"head":24},{"_gvid":34,"tail":22,"head":28},{"_gvid":35,"tail":23,"head":28},{"_gvid":36,"tail":24,"head":28},{"_gvid":37,"tail":25,"head":29},{"_gvid":38,"tail":26,"head":29},{"_gvid":39,"tail":27,"head":29},{"_gvid":40,"tail":30,"head":4},{"_gvid":41,"tail":30,"head":5},{"_gvid":42,"tail":30,"head":6},{"_gvid":43,"tail":30,"head":8},{"_gvid":44,"tail":30,"head":14},{"_gvid":45,"tail":30,"head":18},{"_gvid":46,"tail":31,"head":4},{"_gvid":47,"tail":31,"head":5},{"_gvid":48,"tail":31,"head":6},{"_gvid":49,"tail":31,"head":8},{"_gvid":50,"tail":31,"head":14},{"_gvid":51,"tail":31,"head":18},{"_gvid":52,"tail":32,"head":25},{"_gvid":53,"tail":32,"head":26},{"_gvid":54,"tail":32,"head":27},{"_gvid":55,"tail":33,"head":30},{"_gvid":56,"tail":33,"head":31},{"_gvid":57,"tail":33,"head":32}]}' + #json_string = adj_string # r'{"name":"%3","directed":true,"strict":false,"compound":"true","newrank":"true","_subgraph_cnt":1,"objects":[{"name":"root","compound":"true","newrank":"true","_gvid":0,"nodes":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33],"edges":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57]},{"_gvid":1,"name":"[root] aws_alb.main","label":"aws_alb.main","shape":"box"},{"_gvid":2,"name":"[root] aws_alb_listener.front_end","label":"aws_alb_listener.front_end","shape":"box"},{"_gvid":3,"name":"[root] aws_alb_target_group.test","label":"aws_alb_target_group.test","shape":"box"},{"_gvid":4,"name":"[root] aws_autoscaling_group.app","label":"aws_autoscaling_group.app","shape":"box"},{"_gvid":5,"name":"[root] aws_cloudwatch_log_group.app","label":"aws_cloudwatch_log_group.app","shape":"box"},{"_gvid":6,"name":"[root] aws_cloudwatch_log_group.ecs","label":"aws_cloudwatch_log_group.ecs","shape":"box"},{"_gvid":7,"name":"[root] aws_ecs_cluster.main","label":"aws_ecs_cluster.main","shape":"box"},{"_gvid":8,"name":"[root] aws_ecs_service.test","label":"aws_ecs_service.test","shape":"box"},{"_gvid":9,"name":"[root] aws_ecs_task_definition.ghost","label":"aws_ecs_task_definition.ghost","shape":"box"},{"_gvid":10,"name":"[root] aws_iam_instance_profile.app","label":"aws_iam_instance_profile.app","shape":"box"},{"_gvid":11,"name":"[root] aws_iam_role.app_instance","label":"aws_iam_role.app_instance","shape":"box"},{"_gvid":12,"name":"[root] aws_iam_role.ecs_service","label":"aws_iam_role.ecs_service","shape":"box"},{"_gvid":13,"name":"[root] aws_iam_role_policy.ecs_service","label":"aws_iam_role_policy.ecs_service","shape":"box"},{"_gvid":14,"name":"[root] aws_iam_role_policy.instance","label":"aws_iam_role_policy.instance","shape":"box"},{"_gvid":15,"name":"[root] aws_internet_gateway.gw","label":"aws_internet_gateway.gw","shape":"box"},{"_gvid":16,"name":"[root] aws_launch_configuration.app","label":"aws_launch_configuration.app","shape":"box"},{"_gvid":17,"name":"[root] aws_route_table.r","label":"aws_route_table.r","shape":"box"},{"_gvid":18,"name":"[root] aws_route_table_association.a","label":"aws_route_table_association.a","shape":"box"},{"_gvid":19,"name":"[root] aws_security_group.instance_sg","label":"aws_security_group.instance_sg","shape":"box"},{"_gvid":20,"name":"[root] aws_security_group.lb_sg","label":"aws_security_group.lb_sg","shape":"box"},{"_gvid":21,"name":"[root] aws_subnet.main","label":"aws_subnet.main","shape":"box"},{"_gvid":22,"name":"[root] aws_vpc.main","label":"aws_vpc.main","shape":"box"},{"_gvid":23,"name":"[root] data.aws_ami.stable_coreos","label":"data.aws_ami.stable_coreos","shape":"box"},{"_gvid":24,"name":"[root] data.aws_availability_zones.available","label":"data.aws_availability_zones.available","shape":"box"},{"_gvid":25,"name":"[root] data.template_file.cloud_config","label":"data.template_file.cloud_config","shape":"box"},{"_gvid":26,"name":"[root] data.template_file.instance_profile","label":"data.template_file.instance_profile","shape":"box"},{"_gvid":27,"name":"[root] data.template_file.task_definition","label":"data.template_file.task_definition","shape":"box"},{"_gvid":28,"name":"[root] provider.aws","label":"provider.aws","shape":"diamond"},{"_gvid":29,"name":"[root] provider.template","label":"provider.template","shape":"diamond"},{"_gvid":30,"name":"[root] meta.count-boundary (EachMode fixup)","label":"\\N"},{"_gvid":31,"name":"[root] provider.aws (close)","label":"\\N"},{"_gvid":32,"name":"[root] provider.template (close)","label":"\\N"},{"_gvid":33,"name":"[root] root","label":"\\N"}],"edges":[{"_gvid":0,"tail":1,"head":20},{"_gvid":1,"tail":1,"head":21},{"_gvid":2,"tail":2,"head":1},{"_gvid":3,"tail":2,"head":3},{"_gvid":4,"tail":3,"head":22},{"_gvid":5,"tail":4,"head":16},{"_gvid":6,"tail":4,"head":21},{"_gvid":7,"tail":5,"head":28},{"_gvid":8,"tail":6,"head":28},{"_gvid":9,"tail":7,"head":28},{"_gvid":10,"tail":8,"head":2},{"_gvid":11,"tail":8,"head":7},{"_gvid":12,"tail":8,"head":9},{"_gvid":13,"tail":8,"head":13},{"_gvid":14,"tail":9,"head":27},{"_gvid":15,"tail":9,"head":28},{"_gvid":16,"tail":10,"head":11},{"_gvid":17,"tail":11,"head":28},{"_gvid":18,"tail":12,"head":28},{"_gvid":19,"tail":13,"head":12},{"_gvid":20,"tail":14,"head":11},{"_gvid":21,"tail":14,"head":26},{"_gvid":22,"tail":15,"head":22},{"_gvid":23,"tail":16,"head":10},{"_gvid":24,"tail":16,"head":19},{"_gvid":25,"tail":16,"head":23},{"_gvid":26,"tail":16,"head":25},{"_gvid":27,"tail":17,"head":15},{"_gvid":28,"tail":18,"head":17},{"_gvid":29,"tail":18,"head":21},{"_gvid":30,"tail":19,"head":20},{"_gvid":31,"tail":20,"head":22},{"_gvid":32,"tail":21,"head":22},{"_gvid":33,"tail":21,"head":24},{"_gvid":34,"tail":22,"head":28},{"_gvid":35,"tail":23,"head":28},{"_gvid":36,"tail":24,"head":28},{"_gvid":37,"tail":25,"head":29},{"_gvid":38,"tail":26,"head":29},{"_gvid":39,"tail":27,"head":29},{"_gvid":40,"tail":30,"head":4},{"_gvid":41,"tail":30,"head":5},{"_gvid":42,"tail":30,"head":6},{"_gvid":43,"tail":30,"head":8},{"_gvid":44,"tail":30,"head":14},{"_gvid":45,"tail":30,"head":18},{"_gvid":46,"tail":31,"head":4},{"_gvid":47,"tail":31,"head":5},{"_gvid":48,"tail":31,"head":6},{"_gvid":49,"tail":31,"head":8},{"_gvid":50,"tail":31,"head":14},{"_gvid":51,"tail":31,"head":18},{"_gvid":52,"tail":32,"head":25},{"_gvid":53,"tail":32,"head":26},{"_gvid":54,"tail":32,"head":27},{"_gvid":55,"tail":33,"head":30},{"_gvid":56,"tail":33,"head":31},{"_gvid":57,"tail":33,"head":32}]}' obj = json.loads(json_string) root = obj['objects'][0]['nodes'][-1] @@ -349,18 +349,26 @@ def main(): coordinates = gen_coordinates(adj) # # verification - # x = [] - # y = [] - # z = [] - # for level in X.keys(): - # x.extend(X[level]) - # y.extend(Y[level]) - # z.extend(Z[level]) - # #print(x) - # #print(y) - # #print(z) - # graph(x, y, z, coordinates, adj, rev, show_level=False) - # plt.show() + # adj = adjacency_list() + print(adj) + nodes = list(adj.keys()) + nodes.reverse() + X, Y, Z, level = points(adj, len(nodes), nodes, 1) + print(level) + rev = reverse_level(level) + coordinates = connect(X, Y, Z, level, adj) + x = [] + y = [] + z = [] + for level in X.keys(): + x.extend(X[level]) + y.extend(Y[level]) + z.extend(Z[level]) + #print(x) + #print(y) + #print(z) + graph(x, y, z, coordinates, adj, rev, show_level=False) + plt.show() # # return # obj = json.loads(json_string)